diff --git a/src/geometry/Point.h b/src/geometry/Point.h index 335cfcc..a75a0e2 100644 --- a/src/geometry/Point.h +++ b/src/geometry/Point.h @@ -9,6 +9,8 @@ public: Point(double x, double y); + //Point(const Point& reference, double offSetX, double offSetY); + ~Point(); static std::shared_ptr Create(double x, double y); diff --git a/src/geometry/Rectangle.h b/src/geometry/Rectangle.h index ea7c469..ccbdd50 100644 --- a/src/geometry/Rectangle.h +++ b/src/geometry/Rectangle.h @@ -34,6 +34,11 @@ public: return mBottomLeft.getDeltaX(mTopRight); } + Point getBottomLeft() const + { + return mBottomLeft; + } + private: Point mBottomLeft; Point mTopRight; diff --git a/src/mesh/AbstractMesh.h b/src/mesh/AbstractMesh.h index e69de29..cb4ba9f 100644 --- a/src/mesh/AbstractMesh.h +++ b/src/mesh/AbstractMesh.h @@ -0,0 +1,8 @@ +#pragma once + +class AbstractGeometricItem; + +class AbstractMesh +{ + +}; diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index e6c73f7..22f30eb 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -2,8 +2,11 @@ list(APPEND mesh_LIB_INCLUDES AbstractMesh.cpp Edge.cpp Face.cpp + Node.cpp QuadMesh.cpp - TriMesh.cpp) + TriMesh.cpp + MeshPrimitives.cpp + MeshBuilder.cpp) # add the library diff --git a/src/mesh/Edge.cpp b/src/mesh/Edge.cpp index e69de29..a4290b5 100644 --- a/src/mesh/Edge.cpp +++ b/src/mesh/Edge.cpp @@ -0,0 +1,9 @@ +#include "Edge.h" + +#include "Node.h" + +Edge::Edge(Node* node0, Node* node1) + : mNode0(node0), + mNode1(node1) +{ +} diff --git a/src/mesh/Edge.h b/src/mesh/Edge.h index e69de29..8bfaba2 100644 --- a/src/mesh/Edge.h +++ b/src/mesh/Edge.h @@ -0,0 +1,13 @@ +#pragma once + +class Node; + +class Edge +{ +public: + Edge(Node* node0, Node* node1); + +private: + Node* mNode0{nullptr}; + Node* mNode1{nullptr}; +}; diff --git a/src/mesh/Face.h b/src/mesh/Face.h index e69de29..a4081d4 100644 --- a/src/mesh/Face.h +++ b/src/mesh/Face.h @@ -0,0 +1,8 @@ +#pragma once + +class Edge; + +class Face +{ + +}; diff --git a/src/mesh/MeshBuilder.cpp b/src/mesh/MeshBuilder.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/mesh/MeshBuilder.h b/src/mesh/MeshBuilder.h new file mode 100644 index 0000000..e69de29 diff --git a/src/mesh/MeshPrimitives.cpp b/src/mesh/MeshPrimitives.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/mesh/MeshPrimitives.h b/src/mesh/MeshPrimitives.h new file mode 100644 index 0000000..4a73c3e --- /dev/null +++ b/src/mesh/MeshPrimitives.h @@ -0,0 +1,26 @@ +#pragma once + +#include "Rectangle.h" +#include "TriMesh.h" + +#include "Node.h" +#include "Edge.h" +#include "Face.h" + +class MeshPrimitives +{ +public: + + std::unique_ptr build(const Rectangle& rectangle) + { + auto mesh = std::make_unique(); + + + const auto bottom_left = rectangle.getBottomLeft(); + const auto width = rectangle.GetWidth(); + const auto height = rectangle.GetHeight(); + + //VecNodes nodes = {Node(bottom_left), } + return mesh; + } +}; diff --git a/src/mesh/Node.cpp b/src/mesh/Node.cpp new file mode 100644 index 0000000..1e5b784 --- /dev/null +++ b/src/mesh/Node.cpp @@ -0,0 +1,3 @@ +#include "Node.h" + + diff --git a/src/mesh/Node.h b/src/mesh/Node.h new file mode 100644 index 0000000..1f606a1 --- /dev/null +++ b/src/mesh/Node.h @@ -0,0 +1,27 @@ +#pragma once + +#include "Point.h" + +class Node +{ + Node(const Point& p, unsigned index = 0) + : mPoint(p), + mIndex(index) + { + + } + + unsigned getIndex() const + { + return mIndex; + } + + void updateIndex(unsigned index) + { + mIndex = index; + } + +private: + unsigned mIndex{0}; + Point mPoint; +}; diff --git a/src/mesh/TriFace.cpp b/src/mesh/TriFace.cpp new file mode 100644 index 0000000..524ed05 --- /dev/null +++ b/src/mesh/TriFace.cpp @@ -0,0 +1,9 @@ +#include "TriFace.h" + +TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2) + : mEdge0(edge0), + mEdge1(edge1), + mEdge2(edge2) +{ + +} diff --git a/src/mesh/TriFace.h b/src/mesh/TriFace.h new file mode 100644 index 0000000..b5fa184 --- /dev/null +++ b/src/mesh/TriFace.h @@ -0,0 +1,14 @@ +#pragma once + +class Edge; + +class TriFace +{ +public: + TriFace(Edge* edge0, Edge* edge1, Edge* edge2); + +private: + Edge* mEdge0{nullptr}; + Edge* mEdge1{nullptr}; + Edge* mEdge2{nullptr}; +}; diff --git a/src/mesh/TriMesh.cpp b/src/mesh/TriMesh.cpp index e69de29..2ef3c0f 100644 --- a/src/mesh/TriMesh.cpp +++ b/src/mesh/TriMesh.cpp @@ -0,0 +1,8 @@ +#include "TriMesh.h" + +void TriMesh::populate(const VecNodes& nodes, const VecEdges& edges, const VecFaces& faces) +{ + mNodes = std::move(nodes); + mEdges = std::move(edges); + mFaces = std::move(faces); +} diff --git a/src/mesh/TriMesh.h b/src/mesh/TriMesh.h index e69de29..40ed821 100644 --- a/src/mesh/TriMesh.h +++ b/src/mesh/TriMesh.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +class Node; +class Edge; +class TriFace; + +using NodePtr = std::unique_ptr; +using EdgePtr = std::unique_ptr; +using TriFacePtr = std::unique_ptr; + +using VecNodes = std::vector; +using VecEdges = std::vector; +using VecFaces = std::vector; + +class TriMesh +{ + TriMesh() = default; + + void populate(const VecNodes& nodes, const VecEdges& edges, const VecFaces& faces); + +private: + std::vector > mNodes; + std::vector > mEdges; + std::vector > mFaces; +}; diff --git a/src/windows/ui_interfaces/x11/XcbGlWindowInterface.cpp b/src/windows/ui_interfaces/x11/XcbGlWindowInterface.cpp index 9c8a61b..340c316 100644 --- a/src/windows/ui_interfaces/x11/XcbGlWindowInterface.cpp +++ b/src/windows/ui_interfaces/x11/XcbGlWindowInterface.cpp @@ -44,17 +44,14 @@ bool XcbGlWindowInterface::initialize(xcb_window_t window) mWindow = glXCreateWindow(mGlInterface->getDisplay(), mGlInterface->getConfig(), window, 0); if (!mWindow) { - glXDestroyContext(mGlInterface->getDisplay(), mGlInterface->getContext()); MLOG_ERROR("glXCreateWindow failed"); return false; } - mDrawable = mWindow; /* make OpenGL context current */ if (!glXMakeContextCurrent(mGlInterface->getDisplay(), mDrawable, mDrawable, mGlInterface->getContext())) { - glXDestroyContext(mGlInterface->getDisplay(), mGlInterface->getContext()); MLOG_ERROR("glXMakeContextCurrent failed"); return false; }