diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
index cfc5a50..899e3c1 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
@@ -103,20 +103,21 @@
-
+
-
-
+
+
-
+
-
+
+
-
-
+
+
@@ -148,6 +149,7 @@
+
@@ -155,19 +157,19 @@
-
+
-
-
+
+
-
+
-
+
-
-
+
+
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index 87d0e67..1deb188 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -35,6 +35,12 @@
{60515177-3da7-420f-8f5b-27c16bb2b77b}
+
+ {653d1291-0de8-4e0a-855d-7cfc755f7632}
+
+
+ {22909273-2b23-49fa-84ab-444cefb09656}
+
@@ -51,45 +57,24 @@
Source Files\Editor
-
- Source Files\Renderer
-
Source Files\Renderer
-
- Source Files\Renderer
-
-
- Source Files\Renderer
-
Source Files\Renderer
-
- Source Files\Renderer
-
Source Files\Renderer
Source Files\Renderer
-
- Source Files\Renderer
-
Source Files\Renderer
Source Files\Renderer
-
- Source Files\Renderer
-
-
- Source Files\Renderer
-
Source Files
@@ -114,6 +99,30 @@
Source Files
+
+ Source Files\Renderer\Painting
+
+
+ Source Files\Renderer\Painting
+
+
+ Source Files\Renderer\Painting
+
+
+ Source Files\Renderer\Painting
+
+
+ Source Files\Renderer\Painting
+
+
+ Source Files\Renderer\Painting
+
+
+ Source Files\Renderer\Painting
+
+
+ Source Files\Renderer\Painting
+
@@ -206,48 +215,51 @@
-
- Header Files\Renderer
-
Header Files\Renderer
-
- Header Files\Renderer
-
-
- Header Files\Renderer
-
Header Files\Renderer
Header Files\Renderer
-
- Header Files\Renderer
-
Header Files\Renderer
Header Files\Renderer
-
- Header Files\Renderer
-
Header Files\Renderer
-
- Header Files\Renderer
-
-
- Header Files\Renderer
-
Header Files
+
+ Header Files\Renderer\Painting
+
+
+ Header Files\Renderer\Painting
+
+
+ Header Files\Renderer\Painting
+
+
+ Header Files\Renderer\Painting
+
+
+ Header Files\Renderer\Painting
+
+
+ Header Files\Renderer\Painting
+
+
+ Header Files\Renderer\Painting
+
+
+ Header Files\Renderer\Painting
+
diff --git a/ArchitectureColoredPainting/MainWindow.ui b/ArchitectureColoredPainting/MainWindow.ui
index 2922f49..418a6af 100644
--- a/ArchitectureColoredPainting/MainWindow.ui
+++ b/ArchitectureColoredPainting/MainWindow.ui
@@ -94,7 +94,7 @@ QTabWidget::pane {
纹理编辑
-
+
场景渲染
@@ -109,7 +109,7 @@ QTabWidget::pane {
- RendererWidget
+ Renderer::RendererWidget
QWidget
Renderer/RendererWidget.h
diff --git a/ArchitectureColoredPainting/RendererWidget.ui b/ArchitectureColoredPainting/RendererWidget.ui
index 190a6ca..fdebb92 100644
--- a/ArchitectureColoredPainting/RendererWidget.ui
+++ b/ArchitectureColoredPainting/RendererWidget.ui
@@ -48,7 +48,7 @@
QLayout::SetDefaultConstraint
-
-
+
0
@@ -94,7 +94,7 @@
- RendererGLWidget
+ Renderer::RendererGLWidget
QOpenGLWidget
diff --git a/ArchitectureColoredPainting/src/MainWindow.cpp b/ArchitectureColoredPainting/src/MainWindow.cpp
index d5c1af8..589b6c6 100644
--- a/ArchitectureColoredPainting/src/MainWindow.cpp
+++ b/ArchitectureColoredPainting/src/MainWindow.cpp
@@ -110,7 +110,7 @@ CentralWidget::CentralWidget(QWidget* parent) : QMainWindow(parent)
QObject::connect(navigationBarWidget->buttonGroup, &QButtonGroup::idClicked,
ui.tabWidget, &QTabWidget::setCurrentIndex);
QObject::connect(ui.tabWidget, &QTabWidget::currentChanged,
- ui.rendererWidget, &RendererWidget::currentTabChanged);
+ ui.rendererWidget, &Renderer::RendererWidget::currentTabChanged);
}
CentralWidget::~CentralWidget()
diff --git a/ArchitectureColoredPainting/src/Renderer/BvhTree.h b/ArchitectureColoredPainting/src/Renderer/BvhTree.h
deleted file mode 100644
index 6faafbc..0000000
--- a/ArchitectureColoredPainting/src/Renderer/BvhTree.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using std::shared_ptr;
-
-struct BvhTreeData {
- QVector4D bound;
- GLuint leftSon, rightSon;
- void show() {
- printf("Bvh: (%lf, %lf) (%lf, %lf): %d %d\n",
- bound.x(), bound.y(), bound.z(), bound.w(),
- leftSon, rightSon);
- }
- BvhTreeData(QVector4D bound, GLuint leftSon, GLuint rightSon)
- : bound(bound), leftSon(leftSon), rightSon(rightSon) {}
- BvhTreeData()
- : leftSon(0), rightSon(0) {}
- ~BvhTreeData() {}
-};
-// BvhTree ڵ
-struct BvhNode {
- GLuint lab;
- bool isLeaf;
- QVector4D bound;
- shared_ptr child[2];
- static bool x_compare(BvhTreeData a, BvhTreeData b) {
- return a.bound.x() < b.bound.x();
- }
- static bool y_compare(BvhTreeData a, BvhTreeData b) {
- return a.bound.y() < b.bound.y();
- }
- GLuint getLeftSon(int k) {
- if (isLeaf) {
- return 0x80000000+child[0]->lab;
- }
- return child[0]->lab;
- }
- GLuint getRightSon(int k) {
- if (isLeaf) {
- return child[1]->lab;
- }
- return child[1]->lab;
- }
- BvhNode() {
- child[0] = child[1] = NULL;
- isLeaf = false;
- lab = 0;
- }
- int maximumBound() {
- return (std::fabs(bound.x() - bound.w()) < std::fabs(bound.y() - bound.z()));
- }
- ~BvhNode() {}
-};
-
-typedef std::shared_ptr BvhPtr;
-
-class BvhTree
-{
-
-private:
- GLuint tot;
- BvhPtr root;
- static QVector4D calcBound(BvhTreeData initBound[], int l, int r);
- static QVector4D Union(QVector4D a, QVector4D b);
- BvhPtr subBvhTree(BvhTreeData initBound[], int l, int r);
- void traverseBvhTree(BvhPtr now, std::vector& children, std::vector& bounds);
-public:
- BvhTree() {
- tot = 0;
- root = NULL;
- }
- // ݵײΧbvh
- void buildBvhTree(BvhTreeData initBound[], int len);
- // Bvh rootBvh֣ children 飬Χ vector
- void getBvhArray(std::vector& children, std::vector& bounds);
- // BvhTree нڵ
- GLuint getBvhNodeNum();
-};
-
diff --git a/ArchitectureColoredPainting/src/Renderer/Camera.cpp b/ArchitectureColoredPainting/src/Renderer/Camera.cpp
index 23703e6..4875435 100644
--- a/ArchitectureColoredPainting/src/Renderer/Camera.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Camera.cpp
@@ -1,5 +1,5 @@
#include "Camera.h"
-
+using namespace Renderer;
// constructor with vectors
diff --git a/ArchitectureColoredPainting/src/Renderer/Camera.h b/ArchitectureColoredPainting/src/Renderer/Camera.h
index a464c8f..cb29577 100644
--- a/ArchitectureColoredPainting/src/Renderer/Camera.h
+++ b/ArchitectureColoredPainting/src/Renderer/Camera.h
@@ -5,66 +5,69 @@
#include
#include
-// Default camera values
-const float YAW = -90.0f;
-const float PITCH = 0.0f;
-const float SPEED = 200.f;
-const float SENSITIVITY = 0.1f;
-const float ZOOM = 45.0f;
-
-// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods
-enum Camera_Movement {
- FORWARD,
- BACKWARD,
- LEFT,
- RIGHT,
- UP,
- DOWN
-};
-
-class Camera
+namespace Renderer
{
-public:
- // camera Attributes
- QVector3D Position;
- QVector3D Front;
- QVector3D Up;
- QVector3D Right;
- QVector3D WorldUp;
- QVector3D PositionFront;
- QVector3D PositionRight;
- // euler Angles, Ƕ
- float Yaw;
- float Pitch;
- // camera options
- float MovementSpeed;
- float MouseSensitivity;
- float Zoom;
- float Ratio;
- float NearPlane = 10.f;
- float FarPlane = 5000.f;
+ // Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods
+ enum Camera_Movement {
+ FORWARD,
+ BACKWARD,
+ LEFT,
+ RIGHT,
+ UP,
+ DOWN
+ };
- // constructor with vectors
- Camera(QVector3D position = QVector3D(0.0f, 0.0f, 0.0f), QVector3D up = QVector3D(0.0f, 1.0f, 0.0f), float yaw = YAW, float pitch = PITCH);
+ class Camera
+ {
- // constructor with scalar values
- Camera(float posX, float posY, float posZ, float upX, float upY, float upZ, float yaw, float pitch);
+ public:
+ // Default camera values
+ static constexpr float YAW = -90.0f;
+ static constexpr float PITCH = 0.0f;
+ static constexpr float SPEED = 200.f;
+ static constexpr float SENSITIVITY = 0.1f;
+ static constexpr float ZOOM = 45.0f;
+ // camera Attributes
+ QVector3D Position;
+ QVector3D Front;
+ QVector3D Up;
+ QVector3D Right;
+ QVector3D WorldUp;
+ QVector3D PositionFront;
+ QVector3D PositionRight;
+ // euler Angles, Ƕ
+ float Yaw;
+ float Pitch;
+ // camera options
+ float MovementSpeed;
+ float MouseSensitivity;
+ float Zoom;
+ float Ratio;
+ float NearPlane = 10.f;
+ float FarPlane = 5000.f;
- // returns the view matrix calculated using Euler Angles and the LookAt Matrix
- QMatrix4x4 GetViewMatrix();
-
- // processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems)
- void ProcessKeyboard(Camera_Movement direction, float deltaTime);
+ // constructor with vectors
+ Camera(QVector3D position = QVector3D(0.0f, 0.0f, 0.0f), QVector3D up = QVector3D(0.0f, 1.0f, 0.0f), float yaw = YAW, float pitch = PITCH);
- // processes input received from a mouse input system. Expects the offset value in both the x and y direction.
- void ProcessMouseMovement(float xoffset, float yoffset, GLboolean constrainPitch = true);
+ // constructor with scalar values
+ Camera(float posX, float posY, float posZ, float upX, float upY, float upZ, float yaw, float pitch);
- // processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis
- void ProcessMouseScroll(float yoffset);
+ // returns the view matrix calculated using Euler Angles and the LookAt Matrix
+ QMatrix4x4 GetViewMatrix();
-private:
- // calculates the front vector from the Camera's (updated) Euler Angles
- void updateCameraVectors();
-};
+ // processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems)
+ void ProcessKeyboard(Camera_Movement direction, float deltaTime);
+ // processes input received from a mouse input system. Expects the offset value in both the x and y direction.
+ void ProcessMouseMovement(float xoffset, float yoffset, GLboolean constrainPitch = true);
+
+ // processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis
+ void ProcessMouseScroll(float yoffset);
+
+ private:
+ // calculates the front vector from the Camera's (updated) Euler Angles
+ void updateCameraVectors();
+ };
+
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/CubicBezier.h b/ArchitectureColoredPainting/src/Renderer/CubicBezier.h
deleted file mode 100644
index d2691f7..0000000
--- a/ArchitectureColoredPainting/src/Renderer/CubicBezier.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-#include "Line.h"
-#include
-
-class CubicBezier : public Line
-{
- using Line::Line;
-private:
- static Point getPointByT(Point a, Point b, double t);
- static Point calculateControlPoint(Point a, Point b);
- static void findPointsOfDivison(vector &p, vector& res);
- void splitBezierCubic(double t, vector& res);
-public:
- virtual double findTByValue(double value, bool isY);
- virtual void monotonization(vector & res);
- virtual double getLineValueByT(double t, bool isY);
- virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
- void transformToCubic();
-};
-
diff --git a/ArchitectureColoredPainting/src/Renderer/CubicMonotonization.h b/ArchitectureColoredPainting/src/Renderer/CubicMonotonization.h
deleted file mode 100644
index 6531b27..0000000
--- a/ArchitectureColoredPainting/src/Renderer/CubicMonotonization.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#include
-#include
-#include
-#pragma once
-using std::pair;
-using std::vector;
-using std::min;
-using std::max;
-using std::sort;
-class CubicMonotonization
-{
-typedef pair point;
-typedef vector Line;
-private:
- static const double eps;
- point getPointByT(point a, point b, double t) const;
- void findPointsOfDivison(vector p, vector &res);
- double getBezierPoint(vector &p, double t) const;
- void splitBezierCubic(Line& p, point mid, double t, vector &res);
-public:
- // p Ϊ˵㡢Ƶ㡢Ƶ㡢˵㣬 res ΪеΪ0ĵ
- void getPointsOfDivision(Line p, vector &res);
-};
-
diff --git a/ArchitectureColoredPainting/src/Renderer/Drawable.h b/ArchitectureColoredPainting/src/Renderer/Drawable.h
index 583cf17..0e1f8ff 100644
--- a/ArchitectureColoredPainting/src/Renderer/Drawable.h
+++ b/ArchitectureColoredPainting/src/Renderer/Drawable.h
@@ -1,8 +1,10 @@
#pragma once
-class Drawable
+namespace Renderer
{
-public:
- virtual void draw() = 0;
- virtual void drawShadow() = 0;
-};
-
+ class Drawable
+ {
+ public:
+ virtual void draw() = 0;
+ virtual void drawShadow() = 0;
+ };
+}
diff --git a/ArchitectureColoredPainting/src/Renderer/Light.cpp b/ArchitectureColoredPainting/src/Renderer/Light.cpp
index a0a75ba..3bdd35f 100644
--- a/ArchitectureColoredPainting/src/Renderer/Light.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Light.cpp
@@ -1,6 +1,6 @@
#include "Light.h"
#include
-
+using namespace Renderer;
Light::Light(Camera* camera)
: camera(camera)
//, shadowCascadeLevels{ camera->FarPlane / 25.0f, camera->FarPlane / 12.0f, camera->FarPlane / 6.0f, camera->FarPlane / 3.0f }
diff --git a/ArchitectureColoredPainting/src/Renderer/Light.h b/ArchitectureColoredPainting/src/Renderer/Light.h
index 12ffbc2..2af104b 100644
--- a/ArchitectureColoredPainting/src/Renderer/Light.h
+++ b/ArchitectureColoredPainting/src/Renderer/Light.h
@@ -9,21 +9,24 @@
#include "Camera.h"
#include "Model.h"
-class Light
+namespace Renderer
{
-public:
- QVector3D lightDirection = QVector3D(0.2, 4, 1).normalized();
- std::vector shadowCascadeLevels;
- float blendRatio = 0.3;
- std::vector frustumSizes;
- Model* model;
- Light(Camera* camera);
- std::vector getFrustumCornersWorldSpace(const QMatrix4x4& projview);
- std::vector getFrustumCornersWorldSpace(const QMatrix4x4& proj, const QMatrix4x4& view);
- QMatrix4x4 getLightSpaceMatrix(const float nearPlane, const float farPlane);
- std::vector getLightSpaceMatrices();
-private:
- Camera* camera;
-
-};
+ class Light
+ {
+ public:
+ QVector3D lightDirection = QVector3D(0.2, 4, 1).normalized();
+ std::vector shadowCascadeLevels;
+ float blendRatio = 0.3;
+ std::vector frustumSizes;
+ Model* model;
+ Light(Camera* camera);
+ std::vector getFrustumCornersWorldSpace(const QMatrix4x4& projview);
+ std::vector getFrustumCornersWorldSpace(const QMatrix4x4& proj, const QMatrix4x4& view);
+ QMatrix4x4 getLightSpaceMatrix(const float nearPlane, const float farPlane);
+ std::vector getLightSpaceMatrices();
+ private:
+ Camera* camera;
+
+ };
+}
diff --git a/ArchitectureColoredPainting/src/Renderer/Line.h b/ArchitectureColoredPainting/src/Renderer/Line.h
deleted file mode 100644
index 6b2ee17..0000000
--- a/ArchitectureColoredPainting/src/Renderer/Line.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#pragma once
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using std::vector;
-using std::pair;
-using std::min;
-using std::max;
-using std::sort;
-using std::shared_ptr;
-using std::make_shared;
-using std::swap;
-
-const double eps = 1e-5;
-
-struct Point {
- double x, y;
- Point operator + (const Point a) { return { x + a.x, y + a.y }; }
- Point operator - (const Point a) { return { x - a.x, y - a.y }; }
- Point operator * (const double a) { return { x * a, y * a }; }
- double operator * (const Point a) { return x * a.y - y * a.x; }
- bool operator== (const Point& a) const {
- return fabs(x - a.x) <= eps && fabs(y - a.y) <= eps;
- }
- bool operator< (const Point& a) const {
- return fabs(x - a.x) <= eps ? y < a.y : x < a.x;
- }
- void show() {
- std::cout << '(' << x << ',' << y << ')' << ' ';
- }
-};
-
-class Line
-{
-protected:
- vector vX, vY;
- int siz;
-public:
- typedef shared_ptr LinePtr;
- Line() :siz(0) {}
- Line(vector Vp);
- int size();
- void clear();
- Point getBegin();
- Point getEnd();
- int direction(bool isY);
- virtual double getLineValueByT(double t, bool isY) = 0;
- virtual void monotonization(vector & res) = 0;
- virtual int judgeBoundIntersection(double xy, double l, double r, bool isY) = 0;
- virtual bool judgeIntersection(QVector4D bound);
- bool isLineContained(QVector4D bound);
- Point operator[](int index) const;
- Point getPointByIndex(int index) const;
- vector toPointVector() const;
- void setPointByIndex(int index, Point now);
- void push_back(Point now);
- virtual ~Line() {}
-};
-
-typedef shared_ptr LinePtr;
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/Mesh.cpp b/ArchitectureColoredPainting/src/Renderer/Mesh.cpp
index fb8531d..32652db 100644
--- a/ArchitectureColoredPainting/src/Renderer/Mesh.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Mesh.cpp
@@ -1,5 +1,5 @@
#include "Mesh.h"
-
+using namespace Renderer;
Mesh::Mesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model)
: glFunc(glFunc)
, shaderProgram(shaderProgram)
diff --git a/ArchitectureColoredPainting/src/Renderer/Mesh.h b/ArchitectureColoredPainting/src/Renderer/Mesh.h
index a67214d..50b473e 100644
--- a/ArchitectureColoredPainting/src/Renderer/Mesh.h
+++ b/ArchitectureColoredPainting/src/Renderer/Mesh.h
@@ -13,49 +13,51 @@
#include
#include
#include "Drawable.h"
-
-struct Vertex
+namespace Renderer
{
- QVector3D Position;
- QVector3D Normal;
- QVector2D TexCoords;
- QVector3D Tangent;
- QVector3D Bitangent;
-};
+ struct Vertex
+ {
+ QVector3D Position;
+ QVector3D Normal;
+ QVector2D TexCoords;
+ QVector3D Tangent;
+ QVector3D Bitangent;
+ };
-struct Texture
-{
- QOpenGLTexture texture;
- QString type;
- QString path;
- Texture() :texture(QOpenGLTexture::Target2D) {
- texture.create();
- texture.setWrapMode(QOpenGLTexture::DirectionS, QOpenGLTexture::Repeat);
- texture.setWrapMode(QOpenGLTexture::DirectionT, QOpenGLTexture::Repeat);
- texture.setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
- }
-};
+ struct Texture
+ {
+ QOpenGLTexture texture;
+ QString type;
+ QString path;
+ Texture() :texture(QOpenGLTexture::Target2D) {
+ texture.create();
+ texture.setWrapMode(QOpenGLTexture::DirectionS, QOpenGLTexture::Repeat);
+ texture.setWrapMode(QOpenGLTexture::DirectionT, QOpenGLTexture::Repeat);
+ texture.setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
+ }
+ };
-class Mesh : public Drawable
-{
-public:
- /* */
- QVector vertices; //
- QVector indices; //
- QVector textures; //
- QMatrix4x4 model; //ģ;
- QOpenGLFunctions_4_5_Compatibility* glFunc; //opengl
- QOpenGLShaderProgram* shaderProgram, * shadowProgram; //ɫ
+ class Mesh : public Drawable
+ {
+ public:
+ /* */
+ QVector vertices; //
+ QVector indices; //
+ QVector textures; //
+ QMatrix4x4 model; //ģ;
+ QOpenGLFunctions_4_5_Compatibility* glFunc; //opengl
+ QOpenGLShaderProgram* shaderProgram, * shadowProgram; //ɫ
- /* */
- Mesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model);
- void draw() override;
- void drawShadow() override;
- void setupMesh();
+ /* */
+ Mesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model);
+ void draw() override;
+ void drawShadow() override;
+ void setupMesh();
-private:
- /* Ⱦ */
- QOpenGLVertexArrayObject VAO;
- QOpenGLBuffer VBO, EBO;
+ private:
+ /* Ⱦ */
+ QOpenGLVertexArrayObject VAO;
+ QOpenGLBuffer VBO, EBO;
-};
+ };
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/Model.cpp b/ArchitectureColoredPainting/src/Renderer/Model.cpp
index 38106b3..382354b 100644
--- a/ArchitectureColoredPainting/src/Renderer/Model.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Model.cpp
@@ -6,10 +6,11 @@
#include
#include "PaintingMesh.h"
#include
-#include "BvhTree.h"
-#include "ShortCutTree.h"
+#include "Painting/BvhTree.h"
+#include "Painting/ShortCutTree.h"
#include "../SvgParser.h"
-
+using namespace Renderer;
+using std::vector;
Model::Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram)
: context(context)
, glFunc(context->versionFunctions())
@@ -175,7 +176,7 @@ Drawable* Model::processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 mod
m_mesh->indices.push_back(face.mIndices[j]);
}
}
-
+
BvhTree rootBvhTree;
vector rootBvhTreeData;
for (int i = 0; i < 1000; i++)
diff --git a/ArchitectureColoredPainting/src/Renderer/Model.h b/ArchitectureColoredPainting/src/Renderer/Model.h
index 900dbf7..325ef9c 100644
--- a/ArchitectureColoredPainting/src/Renderer/Model.h
+++ b/ArchitectureColoredPainting/src/Renderer/Model.h
@@ -2,49 +2,52 @@
#include "Mesh.h"
#include "Drawable.h"
-#include "PaintingHelper.h"
+#include "Painting/PaintingHelper.h"
#include
-class Model
+namespace Renderer
{
-public:
- std::vector AABB;
+ class Model
+ {
+ public:
+ std::vector AABB;
- void draw();
- void drawShadow();
- void destroy();
- static Model* createModel(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
- Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, PaintingHelper* paintingHelper);
-private:
- Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
+ void draw();
+ void drawShadow();
+ void destroy();
+ static Model* createModel(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
+ Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* paintingProgram, QOpenGLShaderProgram* shadowProgram, PaintingHelper* paintingHelper);
+ private:
+ Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram);
- ~Model();
- QOpenGLContext* context; //opengl
- QOpenGLFunctions_4_5_Compatibility* glFunc;
- QOpenGLShaderProgram* shaderProgram = nullptr;
- QOpenGLShaderProgram* paintingProgram = nullptr; //ʻɫ
- QOpenGLShaderProgram* shadowProgram = nullptr;
- PaintingHelper* paintingHelper = nullptr;
+ ~Model();
+ QOpenGLContext* context; //opengl
+ QOpenGLFunctions_4_5_Compatibility* glFunc;
+ QOpenGLShaderProgram* shaderProgram = nullptr;
+ QOpenGLShaderProgram* paintingProgram = nullptr; //ʻɫ
+ QOpenGLShaderProgram* shadowProgram = nullptr;
+ PaintingHelper* paintingHelper = nullptr;
- /* ģ */
- QVector textures_loaded; //
- QVector meshes; //
- QDir directory; //ģ·
+ /* ģ */
+ QVector textures_loaded; //
+ QVector meshes; //
+ QDir directory; //ģ·
- float minX = std::numeric_limits::max();
- float maxX = std::numeric_limits::min();
- float minY = std::numeric_limits::max();
- float maxY = std::numeric_limits::min();
- float minZ = std::numeric_limits::max();
- float maxZ = std::numeric_limits::min();
+ float minX = std::numeric_limits::max();
+ float maxX = std::numeric_limits::min();
+ float minY = std::numeric_limits::max();
+ float maxY = std::numeric_limits::min();
+ float minZ = std::numeric_limits::max();
+ float maxZ = std::numeric_limits::min();
- //ݹ
- void processNode(aiNode* node, const aiScene* scene, aiMatrix4x4 mat4 = aiMatrix4x4());
+ //ݹ
+ void processNode(aiNode* node, const aiScene* scene, aiMatrix4x4 mat4 = aiMatrix4x4());
- //
- Drawable* processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 model);
+ //
+ Drawable* processMesh(aiMesh* mesh, const aiScene* scene, aiMatrix4x4 model);
- //ز
- QVector loadMaterialTextures(aiMaterial* mat, aiTextureType type, QString typeName);
+ //ز
+ QVector loadMaterialTextures(aiMaterial* mat, aiTextureType type, QString typeName);
-};
\ No newline at end of file
+ };
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/BvhTree.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.cpp
similarity index 98%
rename from ArchitectureColoredPainting/src/Renderer/BvhTree.cpp
rename to ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.cpp
index ca3c01d..f69c3f0 100644
--- a/ArchitectureColoredPainting/src/Renderer/BvhTree.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.cpp
@@ -1,5 +1,5 @@
#include "BvhTree.h"
-
+using namespace Renderer;
GLuint BvhTree::getBvhNodeNum() {
return tot;
}
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.h b/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.h
new file mode 100644
index 0000000..0dfc795
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/BvhTree.h
@@ -0,0 +1,89 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace Renderer
+{
+ struct BvhTreeData {
+ QVector4D bound;
+ GLuint leftSon, rightSon;
+ void show() {
+ printf("Bvh: (%lf, %lf) (%lf, %lf): %d %d\n",
+ bound.x(), bound.y(), bound.z(), bound.w(),
+ leftSon, rightSon);
+ }
+ BvhTreeData(QVector4D bound, GLuint leftSon, GLuint rightSon)
+ : bound(bound), leftSon(leftSon), rightSon(rightSon) {}
+ BvhTreeData()
+ : leftSon(0), rightSon(0) {}
+ ~BvhTreeData() {}
+ };
+ // BvhTree ڵ
+ struct BvhNode {
+ GLuint lab;
+ bool isLeaf;
+ QVector4D bound;
+ std::shared_ptr child[2];
+ static bool x_compare(BvhTreeData a, BvhTreeData b) {
+ return a.bound.x() < b.bound.x();
+ }
+ static bool y_compare(BvhTreeData a, BvhTreeData b) {
+ return a.bound.y() < b.bound.y();
+ }
+ GLuint getLeftSon(int k) {
+ if (isLeaf) {
+ return 0x80000000 + child[0]->lab;
+ }
+ return child[0]->lab;
+ }
+ GLuint getRightSon(int k) {
+ if (isLeaf) {
+ return child[1]->lab;
+ }
+ return child[1]->lab;
+ }
+ BvhNode() {
+ child[0] = child[1] = NULL;
+ isLeaf = false;
+ lab = 0;
+ }
+ int maximumBound() {
+ return (std::fabs(bound.x() - bound.w()) < std::fabs(bound.y() - bound.z()));
+ }
+ ~BvhNode() {}
+ };
+
+ typedef std::shared_ptr BvhPtr;
+
+ class BvhTree
+ {
+
+ private:
+ GLuint tot;
+ BvhPtr root;
+ static QVector4D calcBound(BvhTreeData initBound[], int l, int r);
+ static QVector4D Union(QVector4D a, QVector4D b);
+ BvhPtr subBvhTree(BvhTreeData initBound[], int l, int r);
+ void traverseBvhTree(BvhPtr now, std::vector& children, std::vector& bounds);
+ public:
+ BvhTree() {
+ tot = 0;
+ root = NULL;
+ }
+ // ݵײΧbvh
+ void buildBvhTree(BvhTreeData initBound[], int len);
+ // Bvh rootBvh֣ children 飬Χ vector
+ void getBvhArray(std::vector& children, std::vector& bounds);
+ // BvhTree нڵ
+ GLuint getBvhNodeNum();
+ };
+
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/CubicBezier.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/CubicBezier.cpp
similarity index 98%
rename from ArchitectureColoredPainting/src/Renderer/CubicBezier.cpp
rename to ArchitectureColoredPainting/src/Renderer/Painting/CubicBezier.cpp
index 2ca4425..fcd8352 100644
--- a/ArchitectureColoredPainting/src/Renderer/CubicBezier.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/CubicBezier.cpp
@@ -1,5 +1,6 @@
#include "CubicBezier.h"
-
+using namespace Renderer;
+using std::vector;
double CubicBezier::getLineValueByT(double t, bool isY) {
vector p;
if (isY) p = vY;
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/CubicBezier.h b/ArchitectureColoredPainting/src/Renderer/Painting/CubicBezier.h
new file mode 100644
index 0000000..702936f
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/CubicBezier.h
@@ -0,0 +1,21 @@
+#pragma once
+#include "Line.h"
+#include
+namespace Renderer
+{
+ class CubicBezier : public Line
+ {
+ using Line::Line;
+ private:
+ static Point getPointByT(Point a, Point b, double t);
+ static Point calculateControlPoint(Point a, Point b);
+ static void findPointsOfDivison(std::vector& p, std::vector& res);
+ void splitBezierCubic(double t, std::vector& res);
+ public:
+ virtual double findTByValue(double value, bool isY);
+ virtual void monotonization(std::vector & res);
+ virtual double getLineValueByT(double t, bool isY);
+ virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
+ void transformToCubic();
+ };
+}
diff --git a/ArchitectureColoredPainting/src/Renderer/CubicMonotonization.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/CubicMonotonization.cpp
similarity index 95%
rename from ArchitectureColoredPainting/src/Renderer/CubicMonotonization.cpp
rename to ArchitectureColoredPainting/src/Renderer/Painting/CubicMonotonization.cpp
index 8e96f1b..b2c6953 100644
--- a/ArchitectureColoredPainting/src/Renderer/CubicMonotonization.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/CubicMonotonization.cpp
@@ -1,5 +1,9 @@
#include "CubicMonotonization.h"
-
+using namespace Renderer;
+using std::vector;
+using std::min;
+using std::max;
+using std::sort;
const double CubicMonotonization::eps = 1e-6;
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/CubicMonotonization.h b/ArchitectureColoredPainting/src/Renderer/Painting/CubicMonotonization.h
new file mode 100644
index 0000000..5207eb4
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/CubicMonotonization.h
@@ -0,0 +1,23 @@
+#pragma once
+#include
+#include
+#include
+
+namespace Renderer
+{
+ class CubicMonotonization
+ {
+ typedef std::pair point;
+ typedef std::vector Line;
+ private:
+ static const double eps;
+ point getPointByT(point a, point b, double t) const;
+ void findPointsOfDivison(std::vector p, std::vector& res);
+ double getBezierPoint(std::vector& p, double t) const;
+ void splitBezierCubic(Line& p, point mid, double t, std::vector & res);
+ public:
+ // p Ϊ˵㡢Ƶ㡢Ƶ㡢˵㣬 res ΪеΪ0ĵ
+ void getPointsOfDivision(Line p, std::vector & res);
+ };
+
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/Line.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/Line.cpp
similarity index 91%
rename from ArchitectureColoredPainting/src/Renderer/Line.cpp
rename to ArchitectureColoredPainting/src/Renderer/Painting/Line.cpp
index 53a4e02..b5ed91a 100644
--- a/ArchitectureColoredPainting/src/Renderer/Line.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/Line.cpp
@@ -1,5 +1,13 @@
#include "Line.h"
-
+using namespace Renderer;
+using std::vector;
+using std::pair;
+using std::min;
+using std::max;
+using std::sort;
+using std::shared_ptr;
+using std::make_shared;
+using std::swap;
Line::Line(vector Vp) {
siz = Vp.size();
for (Point now : Vp) {
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Line.h b/ArchitectureColoredPainting/src/Renderer/Painting/Line.h
new file mode 100644
index 0000000..6b0e57e
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/Line.h
@@ -0,0 +1,57 @@
+#pragma once
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+namespace Renderer
+{
+
+ const double eps = 1e-5;
+
+ struct Point {
+ double x, y;
+ Point operator + (const Point a) { return { x + a.x, y + a.y }; }
+ Point operator - (const Point a) { return { x - a.x, y - a.y }; }
+ Point operator * (const double a) { return { x * a, y * a }; }
+ double operator * (const Point a) { return x * a.y - y * a.x; }
+ bool operator== (const Point& a) const {
+ return fabs(x - a.x) <= eps && fabs(y - a.y) <= eps;
+ }
+ bool operator< (const Point& a) const {
+ return fabs(x - a.x) <= eps ? y < a.y : x < a.x;
+ }
+ void show() {
+ std::cout << '(' << x << ',' << y << ')' << ' ';
+ }
+ };
+
+ class Line
+ {
+ protected:
+ std::vector vX, vY;
+ int siz;
+ public:
+ typedef std::shared_ptr LinePtr;
+ Line() :siz(0) {}
+ Line(std::vector Vp);
+ int size();
+ void clear();
+ Point getBegin();
+ Point getEnd();
+ int direction(bool isY);
+ virtual double getLineValueByT(double t, bool isY) = 0;
+ virtual void monotonization(std::vector & res) = 0;
+ virtual int judgeBoundIntersection(double xy, double l, double r, bool isY) = 0;
+ virtual bool judgeIntersection(QVector4D bound);
+ bool isLineContained(QVector4D bound);
+ Point operator[](int index) const;
+ Point getPointByIndex(int index) const;
+ std::vector toPointVector() const;
+ void setPointByIndex(int index, Point now);
+ void push_back(Point now);
+ virtual ~Line() {}
+ };
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp
new file mode 100644
index 0000000..01caf4a
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp
@@ -0,0 +1,8 @@
+#include "Painting.h"
+
+using namespace Renderer;
+Painting::Painting()
+{
+}
+
+
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.h b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.h
new file mode 100644
index 0000000..a8127cf
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.h
@@ -0,0 +1,23 @@
+#pragma once
+#include
+#include
+#include "Line.h"
+
+namespace Renderer
+{
+ class Painting
+ {
+ std::vector paintingOffsets;
+ std::vector bvhChildren;
+ std::vector bvhBound;
+ std::vector elementOffset;
+ std::vector elementIndex;
+ std::vector elementData;
+ int paintingId = 0;
+ public:
+ Painting();
+
+ };
+}
+
+
diff --git a/ArchitectureColoredPainting/src/Renderer/PaintingHelper.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/PaintingHelper.cpp
similarity index 99%
rename from ArchitectureColoredPainting/src/Renderer/PaintingHelper.cpp
rename to ArchitectureColoredPainting/src/Renderer/Painting/PaintingHelper.cpp
index 7ec9261..adb7951 100644
--- a/ArchitectureColoredPainting/src/Renderer/PaintingHelper.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/PaintingHelper.cpp
@@ -1,5 +1,5 @@
#include "PaintingHelper.h"
-
+using namespace Renderer;
PaintingHelper::PaintingHelper(QOpenGLFunctions_4_5_Compatibility* glFunc) :glFunc(glFunc)
{
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/PaintingHelper.h b/ArchitectureColoredPainting/src/Renderer/Painting/PaintingHelper.h
new file mode 100644
index 0000000..8b2b81b
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/PaintingHelper.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include "BvhTree.h"
+namespace Renderer
+{
+ class PaintingHelper
+ {
+ private:
+ QOpenGLFunctions_4_5_Compatibility* glFunc;
+ GLuint paintingOffsetsSSBO, bvhSSBO, bvhBoundSSBO, elementOffsetSSBO, elementIndexSSBO, elementDataSSBO;
+ std::vector paintingOffsets;
+ std::vector bvhChildren;
+ std::vector bvhBound;
+ std::vector elementOffset;
+ std::vector elementIndex;
+ std::vector elementData;
+ int paintingCount = 0;
+
+ public:
+ PaintingHelper(QOpenGLFunctions_4_5_Compatibility* glFunc);
+ int addPainting(GLuint paintingBvhLength, std::vector bvhChildren, std::vector bvhBound,
+ std::vector elementOffset, std::vector elementIndex, std::vector elementData);
+ void allocateBuffers();
+ void bindPaintingBuffers();
+ };
+
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/ShortCutTree.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/ShortCutTree.cpp
similarity index 97%
rename from ArchitectureColoredPainting/src/Renderer/ShortCutTree.cpp
rename to ArchitectureColoredPainting/src/Renderer/Painting/ShortCutTree.cpp
index 25fda07..19651e2 100644
--- a/ArchitectureColoredPainting/src/Renderer/ShortCutTree.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/ShortCutTree.cpp
@@ -1,6 +1,12 @@
#include "ShortCutTree.h"
#include
-
+using namespace Renderer;
+using std::queue;
+using std::map;
+using std::for_each;
+using std::set;
+using std::pair;
+using std::vector;
void ShortCutTree::init() {
restOfTreeNodes.clear();
allLine.clear();
@@ -57,9 +63,9 @@ bool ShortCutTree::isLineEqual(PointIndexVector& a, PointIndexVector& b) const {
return true;
}
-void ShortCutTree::monotonization(vector& inLines, vector& outLines) {
+void ShortCutTree::monotonization(vector& inLines, vector>& outLines) {
for (PointVector&l: inLines) {
- LinePtr nowLine;
+ std::shared_ptr nowLine;
switch(l.size()) {
case 2: nowLine.reset(new StraightLine(l)); break;
case 3: case 4: nowLine.reset(new CubicBezier(l)); break;
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/ShortCutTree.h b/ArchitectureColoredPainting/src/Renderer/Painting/ShortCutTree.h
new file mode 100644
index 0000000..cf58e99
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/ShortCutTree.h
@@ -0,0 +1,62 @@
+#pragma once
+#include "CubicBezier.h"
+#include "StraightLine.h"
+#include "BvhTree.h"
+#include
+#include
+namespace Renderer
+{
+
+
+ struct ShortCutNode {
+ typedef std::vector vectorPoint;
+ int windingIncrement, eastGroup;
+ bool divided;
+ /* type еĽڵࣺ
+ 0ҪĽڵ
+ 1Ҫ*/
+ QVector4D bound;
+ std::vector lineSet;
+ ShortCutNode() {
+ divided = true;
+ windingIncrement = 0;
+ eastGroup = 0;
+ lineSet.clear();
+ bound = { 0, 0, 0, 0 };
+ }
+ ~ShortCutNode() {}
+ };
+ class ShortCutTree
+ {
+ typedef std::vector PointVector;
+ typedef std::vector PointIndexVector;
+ private:
+ std::vector restOfTreeNodes;
+ std::vector> allLine;
+ int RequiredLineMin, numPoint, numLine;
+ std::map pointMap;
+ std::vector lineIndexs;
+
+ int getPointIndex(Point nowPoint);
+ void generateShortCutsegmentement(ShortCutNode& nowTreeNode);
+ bool handleShortCutNode(ShortCutNode& fa, ShortCutNode& nowTreeNode, double yValue, std::vector& v, int& sumIncrement);
+ void spliteToShortCutTree();
+ static void monotonization(std::vector& inL, std::vector>& outL);
+ bool isLineEqual(PointIndexVector& a, PointIndexVector& b) const;
+ void simplifyLineVector();
+ // Ҫԣúı߽
+ static bool IsBorderValueResonable(double value, std::set & valueSet);
+ static double findBorderValueNotOnLine(double value, std::set & valueSet);
+ public:
+ void init();
+ //lineMinСĿֹ
+ ShortCutTree(int lineMin = 3)
+ :RequiredLineMin(lineMin), numPoint(0), numLine(0) {}
+ // һvector > Ϊ
+ void buildShortCutTree(std::vector& lineSet);
+ // õ㼯Ϻ BvhTreeݼ
+ std::vector getPointLineAndBvhTree(std::vector& pointSet, std::vector& lineSet);
+ ~ShortCutTree() {}
+ };
+
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/StraightLine.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/StraightLine.cpp
similarity index 96%
rename from ArchitectureColoredPainting/src/Renderer/StraightLine.cpp
rename to ArchitectureColoredPainting/src/Renderer/Painting/StraightLine.cpp
index 606e4af..ceb1797 100644
--- a/ArchitectureColoredPainting/src/Renderer/StraightLine.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/StraightLine.cpp
@@ -1,5 +1,6 @@
#include "StraightLine.h"
-
+using namespace Renderer;
+using std::swap;
double StraightLine::getLineValueByT(double t, bool isY) {
double valueBegin, valueEnd;
if (isY) {
diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/StraightLine.h b/ArchitectureColoredPainting/src/Renderer/Painting/StraightLine.h
new file mode 100644
index 0000000..38f6b2c
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Renderer/Painting/StraightLine.h
@@ -0,0 +1,12 @@
+#include "Line.h"
+namespace Renderer
+{
+ class StraightLine : public Line
+ {
+ using Line::Line;
+ virtual double getLineValueByT(double t, bool isY);
+ virtual void monotonization(std::vector & res) {};
+ virtual double findTByValue(double value, bool isY);
+ virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
+ };
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/PaintingHelper.h b/ArchitectureColoredPainting/src/Renderer/PaintingHelper.h
deleted file mode 100644
index b8dc972..0000000
--- a/ArchitectureColoredPainting/src/Renderer/PaintingHelper.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-#include "BvhTree.h"
-
-class PaintingHelper
-{
-private:
- QOpenGLFunctions_4_5_Compatibility* glFunc;
- GLuint paintingOffsetsSSBO, bvhSSBO, bvhBoundSSBO, elementOffsetSSBO, elementIndexSSBO, elementDataSSBO;
- std::vector paintingOffsets;
- std::vector bvhChildren;
- std::vector bvhBound;
- std::vector elementOffset;
- std::vector elementIndex;
- std::vector elementData;
- int paintingCount = 0;
-
-public:
- PaintingHelper(QOpenGLFunctions_4_5_Compatibility* glFunc);
- int addPainting(GLuint paintingBvhLength, std::vector bvhChildren, std::vector bvhBound,
- std::vector elementOffset, std::vector elementIndex, std::vector elementData);
- void allocateBuffers();
- void bindPaintingBuffers();
-};
-
diff --git a/ArchitectureColoredPainting/src/Renderer/PaintingMesh.cpp b/ArchitectureColoredPainting/src/Renderer/PaintingMesh.cpp
index 5bc960c..89ea5e6 100644
--- a/ArchitectureColoredPainting/src/Renderer/PaintingMesh.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/PaintingMesh.cpp
@@ -1,5 +1,5 @@
#include "PaintingMesh.h"
-
+using namespace Renderer;
PaintingMesh::PaintingMesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model)
: glFunc(glFunc)
, shaderProgram(shaderProgram)
diff --git a/ArchitectureColoredPainting/src/Renderer/PaintingMesh.h b/ArchitectureColoredPainting/src/Renderer/PaintingMesh.h
index 348d97d..8e3531a 100644
--- a/ArchitectureColoredPainting/src/Renderer/PaintingMesh.h
+++ b/ArchitectureColoredPainting/src/Renderer/PaintingMesh.h
@@ -15,34 +15,37 @@
#include
#include "Drawable.h"
-struct PaintingVertex
+namespace Renderer
{
- QVector3D Position;
- QVector3D Normal;
- QVector2D TexCoords;
- QVector3D Tangent;
- QVector3D Bitangent;
-};
+ struct PaintingVertex
+ {
+ QVector3D Position;
+ QVector3D Normal;
+ QVector2D TexCoords;
+ QVector3D Tangent;
+ QVector3D Bitangent;
+ };
-class PaintingMesh : public Drawable
-{
-public:
- /* */
- QVector vertices; //
- QVector indices; //
- QMatrix4x4 model; //ģ;
- QOpenGLFunctions_4_5_Compatibility* glFunc; //opengl
- QOpenGLShaderProgram* shaderProgram, * shadowProgram; //ɫ
- GLuint paintingIndex;
- /* */
- PaintingMesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model);
- void draw() override;
- void drawShadow() override;
- void setupMesh();
+ class PaintingMesh : public Drawable
+ {
+ public:
+ /* */
+ QVector vertices; //
+ QVector indices; //
+ QMatrix4x4 model; //ģ;
+ QOpenGLFunctions_4_5_Compatibility* glFunc; //opengl
+ QOpenGLShaderProgram* shaderProgram, * shadowProgram; //ɫ
+ GLuint paintingIndex;
+ /* */
+ PaintingMesh(QOpenGLFunctions_4_5_Compatibility* glFunc, QOpenGLShaderProgram* shaderProgram, QOpenGLShaderProgram* shadowProgram, aiMatrix4x4 model);
+ void draw() override;
+ void drawShadow() override;
+ void setupMesh();
-private:
- /* Ⱦ */
- QOpenGLVertexArrayObject VAO;
- QOpenGLBuffer VBO, EBO;
+ private:
+ /* Ⱦ */
+ QOpenGLVertexArrayObject VAO;
+ QOpenGLBuffer VBO, EBO;
-};
+ };
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.cpp b/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.cpp
index 0a821b6..efa688a 100644
--- a/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.cpp
@@ -6,7 +6,7 @@
#include
#include
#include
-
+using namespace Renderer;
//QVector3D lightPositions[] = { 2000 * QVector3D(0.2, 4, 1).normalized(), QVector3D(100,100,100) ,QVector3D(-100,100,100) ,QVector3D(100,100,-100) };
QVector3D lightColors[] = { 20 * QVector3D(0.7529,0.7450,0.6784).normalized(), QVector3D(0,0,0) ,QVector3D(0,0,0) ,QVector3D(0,0,0) };
static float sunPitch = 105, sunYaw = 80;
diff --git a/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.h b/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.h
index 5d4635f..c602d33 100644
--- a/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.h
+++ b/ArchitectureColoredPainting/src/Renderer/RendererGLWidget.h
@@ -10,59 +10,60 @@
#include "Camera.h"
#include "Light.h"
#include "Model.h"
-#include "PaintingHelper.h"
-
-class RendererGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_5_Compatibility
+#include "Painting/PaintingHelper.h"
+namespace Renderer
{
- Q_OBJECT
-public:
- RendererGLWidget(QWidget* parent = nullptr);
- ~RendererGLWidget();
+ class RendererGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_5_Compatibility
+ {
+ Q_OBJECT
+ public:
+ RendererGLWidget(QWidget* parent = nullptr);
+ ~RendererGLWidget();
- void startTimer();
- void stopTimer();
-public slots:
- void setMainLightPitch(float pitch);
- void setMainLightYaw(float yaw);
-protected:
- void initializeGL() override;
- void paintGL() override;
- void resizeGL(int width, int height) override;
- void timerEvent(QTimerEvent* event) override;
- void keyPressEvent(QKeyEvent* event) override;
- void keyReleaseEvent(QKeyEvent* event) override;
- void wheelEvent(QWheelEvent* event) override;
- void focusInEvent(QFocusEvent* event) override;
- void focusOutEvent(QFocusEvent* event) override;
+ void startTimer();
+ void stopTimer();
+ public slots:
+ void setMainLightPitch(float pitch);
+ void setMainLightYaw(float yaw);
+ protected:
+ void initializeGL() override;
+ void paintGL() override;
+ void resizeGL(int width, int height) override;
+ void timerEvent(QTimerEvent* event) override;
+ void keyPressEvent(QKeyEvent* event) override;
+ void keyReleaseEvent(QKeyEvent* event) override;
+ void wheelEvent(QWheelEvent* event) override;
+ void focusInEvent(QFocusEvent* event) override;
+ void focusOutEvent(QFocusEvent* event) override;
-private:
- int timerId = -1;
- int frameWidth, frameHeight;
- int depthWidth, depthHeight;
- QSet pressedKeys;
- Camera camera;
- Light light;
- clock_t lastFrame;
- float deltaTime;
- int shadowMapResolution;
-
- QOpenGLShaderProgram* shadowProgramPtr = nullptr;
- QOpenGLShaderProgram* modelProgramPtr = nullptr;
- QOpenGLShaderProgram* paintingProgramPtr = nullptr;
- QOpenGLShaderProgram* paintingCompProgramPtr = nullptr;
- QOpenGLShaderProgram* depthInitProgramPtr = nullptr;
- QOpenGLShaderProgram* depthMipmapProgramPtr = nullptr;
- QOpenGLShaderProgram* shadowMappingProgramPtr = nullptr;
- QOpenGLShaderProgram* ssgiProgramPtr = nullptr;
- QOpenGLShaderProgram* finalProgramPtr = nullptr;
- QOpenGLFramebufferObject* fboPtr = nullptr;
- GLuint gbuffers[10];
- GLuint shadowFboHandle = 0;
- GLuint shadowGbuffer;
- GLuint lightSpaceMatricesUBO;
- QOpenGLBuffer quadVBO;
- QOpenGLVertexArrayObject quadVAO;
- Model* model;
- PaintingHelper* paintingHelper;
-};
+ private:
+ int timerId = -1;
+ int frameWidth, frameHeight;
+ int depthWidth, depthHeight;
+ QSet pressedKeys;
+ Camera camera;
+ Light light;
+ clock_t lastFrame;
+ float deltaTime;
+ int shadowMapResolution;
+ QOpenGLShaderProgram* shadowProgramPtr = nullptr;
+ QOpenGLShaderProgram* modelProgramPtr = nullptr;
+ QOpenGLShaderProgram* paintingProgramPtr = nullptr;
+ QOpenGLShaderProgram* paintingCompProgramPtr = nullptr;
+ QOpenGLShaderProgram* depthInitProgramPtr = nullptr;
+ QOpenGLShaderProgram* depthMipmapProgramPtr = nullptr;
+ QOpenGLShaderProgram* shadowMappingProgramPtr = nullptr;
+ QOpenGLShaderProgram* ssgiProgramPtr = nullptr;
+ QOpenGLShaderProgram* finalProgramPtr = nullptr;
+ QOpenGLFramebufferObject* fboPtr = nullptr;
+ GLuint gbuffers[10];
+ GLuint shadowFboHandle = 0;
+ GLuint shadowGbuffer;
+ GLuint lightSpaceMatricesUBO;
+ QOpenGLBuffer quadVBO;
+ QOpenGLVertexArrayObject quadVAO;
+ Model* model;
+ PaintingHelper* paintingHelper;
+ };
+}
diff --git a/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp b/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp
index 8eeb965..d8a6bb8 100644
--- a/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp
+++ b/ArchitectureColoredPainting/src/Renderer/RendererWidget.cpp
@@ -1,6 +1,6 @@
#include "RendererWidget.h"
#include "RendererGLWidget.h"
-
+using namespace Renderer;
RendererWidget::RendererWidget(QWidget *parent)
: QWidget(parent)
{
diff --git a/ArchitectureColoredPainting/src/Renderer/RendererWidget.h b/ArchitectureColoredPainting/src/Renderer/RendererWidget.h
index d1c518c..8d3f1e2 100644
--- a/ArchitectureColoredPainting/src/Renderer/RendererWidget.h
+++ b/ArchitectureColoredPainting/src/Renderer/RendererWidget.h
@@ -2,17 +2,19 @@
#include
#include "ui_RendererWidget.h"
-
-class RendererWidget : public QWidget
+namespace Renderer
{
- Q_OBJECT
+ class RendererWidget : public QWidget
+ {
+ Q_OBJECT
-public:
+ public:
- RendererWidget(QWidget *parent = nullptr);
- ~RendererWidget();
-public slots:
- void currentTabChanged(int index);
-private:
- Ui::RendererWidgetClass ui;
-};
+ RendererWidget(QWidget* parent = nullptr);
+ ~RendererWidget();
+ public slots:
+ void currentTabChanged(int index);
+ private:
+ Ui::RendererWidgetClass ui;
+ };
+}
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/Renderer/ShortCutTree.h b/ArchitectureColoredPainting/src/Renderer/ShortCutTree.h
deleted file mode 100644
index 31f0f7a..0000000
--- a/ArchitectureColoredPainting/src/Renderer/ShortCutTree.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#pragma once
-#include "CubicBezier.h"
-#include "StraightLine.h"
-#include "BvhTree.h"
-#include
-#include
-
-using std::queue;
-using std::map;
-using std::for_each;
-using std::set;
-
-struct ShortCutNode {
- typedef vector vectorPoint;
- int windingIncrement, eastGroup;
- bool divided;
- /* type еĽڵࣺ
- 0ҪĽڵ
- 1Ҫ*/
- QVector4D bound;
- vector lineSet;
- ShortCutNode() {
- divided = true;
- windingIncrement = 0;
- eastGroup = 0;
- lineSet.clear();
- bound = { 0, 0, 0, 0 };
- }
- ~ShortCutNode() {}
-};
-class ShortCutTree
-{
- typedef vector PointVector;
- typedef vector PointIndexVector;
-private:
- vector restOfTreeNodes;
- vector allLine;
- int RequiredLineMin, numPoint, numLine;
- map pointMap;
- vector lineIndexs;
-
- int getPointIndex(Point nowPoint);
- void generateShortCutsegmentement(ShortCutNode& nowTreeNode);
- bool handleShortCutNode(ShortCutNode& fa, ShortCutNode& nowTreeNode, double yValue, vector& v, int& sumIncrement);
- void spliteToShortCutTree();
- static void monotonization(vector& inL, vector &outL);
- bool isLineEqual(PointIndexVector& a, PointIndexVector& b) const;
- void simplifyLineVector();
- // Ҫԣúı߽
- static bool IsBorderValueResonable(double value, set & valueSet);
- static double findBorderValueNotOnLine(double value, set & valueSet);
-public:
- void init();
- //lineMinСĿֹ
- ShortCutTree(int lineMin = 3)
- :RequiredLineMin(lineMin), numPoint(0), numLine(0) {}
- // һvector > Ϊ
- void buildShortCutTree(vector& lineSet);
- // õ㼯Ϻ BvhTreeݼ
- vector getPointLineAndBvhTree(vector &pointSet, vector &lineSet);
- ~ShortCutTree() {}
-};
-
diff --git a/ArchitectureColoredPainting/src/Renderer/StraightLine.h b/ArchitectureColoredPainting/src/Renderer/StraightLine.h
deleted file mode 100644
index 88fb09b..0000000
--- a/ArchitectureColoredPainting/src/Renderer/StraightLine.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "Line.h"
-
-class StraightLine : public Line
-{
- using Line::Line;
- virtual double getLineValueByT(double t, bool isY);
- virtual void monotonization(vector & res) {};
- virtual double findTByValue(double value, bool isY);
- virtual int judgeBoundIntersection(double xy, double l, double r, bool isY);
-};
\ No newline at end of file
diff --git a/ArchitectureColoredPainting/src/SvgParser.cpp b/ArchitectureColoredPainting/src/SvgParser.cpp
index d8bcfa6..6890f3d 100644
--- a/ArchitectureColoredPainting/src/SvgParser.cpp
+++ b/ArchitectureColoredPainting/src/SvgParser.cpp
@@ -484,7 +484,7 @@ namespace SVGParser
}
}; // namespace SVGParser
-
+using Renderer::Point;
SvgParser::SvgParser(const std::string path, double width, double height) : path(path), width(width), height(height)
{
}
diff --git a/ArchitectureColoredPainting/src/SvgParser.h b/ArchitectureColoredPainting/src/SvgParser.h
index ebb0f8b..79a489a 100644
--- a/ArchitectureColoredPainting/src/SvgParser.h
+++ b/ArchitectureColoredPainting/src/SvgParser.h
@@ -1,173 +1,173 @@
#pragma once
-#include "Renderer/Line.h"
+#include "Renderer/Painting/Line.h"
#include
#include
-using namespace std;
+
namespace SVGParser
{
-enum SVGCommandType
-{
- SVG_INVALID = -1,
- // SVG_MOVE_TO_REL, SVG_LINE_TO_REL, SVG_QUADRATIC_CURVE_TO_REL, SVG_CUBIC_CURVE_TO_REL,
- // SVG_MOVE_TO_ABS, SVG_LINE_TO_ABS, SVG_QUADRATIC_CURVE_TO_ABS, SVG_CUBIC_CURVE_TO_ABS,
- SVG_MOVE_TO_REL,
- SVG_MOVE_TO_ABS,
- SVG_LINE_TO_REL,
- SVG_LINE_TO_ABS,
- SVG_HORIZONTAL_LINE_TO_REL,
- SVG_HORIZONTAL_LINE_TO_ABS,
- SVG_VERTICAL_LINE_TO_REL,
- SVG_VERTICAL_LINE_TO_ABS,
- SVG_QUADRATIC_CURVE_TO_REL,
- SVG_QUADRATIC_CURVE_TO_ABS,
- SVG_CUBIC_CURVE_TO_REL,
- SVG_CUBIC_CURVE_TO_ABS,
- SVG_SMOOTH_CUBIC_CURVE_TO_REL,
- SVG_SMOOTH_CUBIC_CURVE_TO_ABS,
- SVG_SMOOTH_QUADRATIC_CURVE_TO_REL,
- SVG_SMOOTH_QUADRATIC_CURVE_TO_ABS,
- SVG_ARC_TO_REL,
- SVG_ARC_TO_ABS,
+ enum SVGCommandType
+ {
+ SVG_INVALID = -1,
+ // SVG_MOVE_TO_REL, SVG_LINE_TO_REL, SVG_QUADRATIC_CURVE_TO_REL, SVG_CUBIC_CURVE_TO_REL,
+ // SVG_MOVE_TO_ABS, SVG_LINE_TO_ABS, SVG_QUADRATIC_CURVE_TO_ABS, SVG_CUBIC_CURVE_TO_ABS,
+ SVG_MOVE_TO_REL,
+ SVG_MOVE_TO_ABS,
+ SVG_LINE_TO_REL,
+ SVG_LINE_TO_ABS,
+ SVG_HORIZONTAL_LINE_TO_REL,
+ SVG_HORIZONTAL_LINE_TO_ABS,
+ SVG_VERTICAL_LINE_TO_REL,
+ SVG_VERTICAL_LINE_TO_ABS,
+ SVG_QUADRATIC_CURVE_TO_REL,
+ SVG_QUADRATIC_CURVE_TO_ABS,
+ SVG_CUBIC_CURVE_TO_REL,
+ SVG_CUBIC_CURVE_TO_ABS,
+ SVG_SMOOTH_CUBIC_CURVE_TO_REL,
+ SVG_SMOOTH_CUBIC_CURVE_TO_ABS,
+ SVG_SMOOTH_QUADRATIC_CURVE_TO_REL,
+ SVG_SMOOTH_QUADRATIC_CURVE_TO_ABS,
+ SVG_ARC_TO_REL,
+ SVG_ARC_TO_ABS,
- SVG_CLOSE_PATH
-};
+ SVG_CLOSE_PATH
+ };
-bool isAbsolute(SVGCommandType);
-class SVGCommand
-{
- public:
- SVGCommand(double, double, bool = false);
- static const int length;
- double x, y;
- bool absolute;
- virtual const std::string toString() const = 0;
- virtual SVGCommandType getType() = 0;
- virtual std::string toString2() = 0;
-};
-class SVGMoveTo : public SVGCommand
-{
- public:
- static const int length = 2;
- SVGMoveTo(double, double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
+ bool isAbsolute(SVGCommandType);
+ class SVGCommand
+ {
+ public:
+ SVGCommand(double, double, bool = false);
+ static const int length;
+ double x, y;
+ bool absolute;
+ virtual const std::string toString() const = 0;
+ virtual SVGCommandType getType() = 0;
+ virtual std::string toString2() = 0;
+ };
+ class SVGMoveTo : public SVGCommand
+ {
+ public:
+ static const int length = 2;
+ SVGMoveTo(double, double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
-class SVGLineTo : public SVGCommand
-{
- public:
- static const int length = 2;
- SVGLineTo(double, double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
-class SVGHLineTo : public SVGCommand
-{
- public:
- static const int length = 1;
- SVGHLineTo(double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
-class SVGVLineTo : public SVGCommand
-{
- public:
- static const int length = 1;
- SVGVLineTo(double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
+ class SVGLineTo : public SVGCommand
+ {
+ public:
+ static const int length = 2;
+ SVGLineTo(double, double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
+ class SVGHLineTo : public SVGCommand
+ {
+ public:
+ static const int length = 1;
+ SVGHLineTo(double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
+ class SVGVLineTo : public SVGCommand
+ {
+ public:
+ static const int length = 1;
+ SVGVLineTo(double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
-class SVGQuadraticCurveTo : public SVGCommand
-{
- public:
- SVGQuadraticCurveTo(double, double, double, double, bool = false);
- double x0, y0;
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
+ class SVGQuadraticCurveTo : public SVGCommand
+ {
+ public:
+ SVGQuadraticCurveTo(double, double, double, double, bool = false);
+ double x0, y0;
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
-class SVGCubicCurveTo : public SVGCommand
-{
- public:
- double x0, y0, x1, y1;
- SVGCubicCurveTo(double, double, double, double, double, double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
-class SVGSmoothQuadraticCurveTo : public SVGCommand
-{
- public:
- SVGSmoothQuadraticCurveTo(double, double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
+ class SVGCubicCurveTo : public SVGCommand
+ {
+ public:
+ double x0, y0, x1, y1;
+ SVGCubicCurveTo(double, double, double, double, double, double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
+ class SVGSmoothQuadraticCurveTo : public SVGCommand
+ {
+ public:
+ SVGSmoothQuadraticCurveTo(double, double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
-class SVGSmoothCubicCurveTo : public SVGCommand
-{
- public:
- double x1, y1;
- SVGSmoothCubicCurveTo(double, double, double, double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
+ class SVGSmoothCubicCurveTo : public SVGCommand
+ {
+ public:
+ double x1, y1;
+ SVGSmoothCubicCurveTo(double, double, double, double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
-class SVGArcTo : public SVGCommand
-{
- public:
- double rx, ry, rot;
- bool large, sweep;
- SVGArcTo(double, double, double, bool, bool, double, double, bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
+ class SVGArcTo : public SVGCommand
+ {
+ public:
+ double rx, ry, rot;
+ bool large, sweep;
+ SVGArcTo(double, double, double, bool, bool, double, double, bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
-class SVGClosePath : public SVGCommand
-{
- public:
- SVGClosePath(bool = false);
- virtual const std::string toString() const;
- virtual SVGCommandType getType();
- virtual std::string toString2();
-};
-typedef vector> SVGPath;
-SVGPath parsePath(std::istream &);
+ class SVGClosePath : public SVGCommand
+ {
+ public:
+ SVGClosePath(bool = false);
+ virtual const std::string toString() const;
+ virtual SVGCommandType getType();
+ virtual std::string toString2();
+ };
+ typedef std::vector> SVGPath;
+ SVGPath parsePath(std::istream&);
-std::ostream &operator<<(std::ostream &, const SVGParser::SVGPath &);
-std::ostream &operator<<(std::ostream &, const SVGParser::SVGCommand *);
+ std::ostream& operator<<(std::ostream&, const SVGParser::SVGPath&);
+ std::ostream& operator<<(std::ostream&, const SVGParser::SVGCommand*);
}; // namespace SVGParser
class SvgParser
{
- public:
- SvgParser(const std::string path, const double width, const double height);
- vector> parse();
+public:
+ SvgParser(const std::string path, const double width, const double height);
+ std::vector> parse();
- private:
- static constexpr const double eps = 1e-6;
- static constexpr const double PI = 3.14159265358979323846;
- const std::string path;
- const double width;
- const double height;
+private:
+ static constexpr const double eps = 1e-6;
+ static constexpr const double PI = 3.14159265358979323846;
+ const std::string path;
+ const double width;
+ const double height;
- Point convertPoint(double x, double y);
- Point clampPoint(Point p);
- Point convertAbsPoint(double x, double y);
- Point convertRelPoint(Point pointBegin, double x, double y);
- void ellipticalArcConverter(Point beginPoint, double radiusX, double radiusY, double phi, bool flagA,
- bool flagS, Point endPoint,vector>& lines);
- vector centerConverter(Point beginPoint, double radiusX, double radiusY, double phi, bool flagA, bool flagS,
- Point endPoint);
- double angleConverter(Point u, Point v);
- Point eConverter(Point c, Point r, double cosPhi, double sinPhi, double t);
- Point e2Converter(Point c, Point r, double cosPhi, double sinPhi, double t);
+ Renderer::Point convertPoint(double x, double y);
+ Renderer::Point clampPoint(Renderer::Point p);
+ Renderer::Point convertAbsPoint(double x, double y);
+ Renderer::Point convertRelPoint(Renderer::Point pointBegin, double x, double y);
+ void ellipticalArcConverter(Renderer::Point beginPoint, double radiusX, double radiusY, double phi, bool flagA,
+ bool flagS, Renderer::Point endPoint, std::vector>& lines);
+ std::vector centerConverter(Renderer::Point beginPoint, double radiusX, double radiusY, double phi, bool flagA, bool flagS,
+ Renderer::Point endPoint);
+ double angleConverter(Renderer::Point u, Renderer::Point v);
+ Renderer::Point eConverter(Renderer::Point c, Renderer::Point r, double cosPhi, double sinPhi, double t);
+ Renderer::Point e2Converter(Renderer::Point c, Renderer::Point r, double cosPhi, double sinPhi, double t);
};