Some meshing working.
This commit is contained in:
parent
392a2b7889
commit
d0ab51c99a
18 changed files with 164 additions and 4 deletions
|
@ -9,6 +9,8 @@ public:
|
|||
|
||||
Point(double x, double y);
|
||||
|
||||
//Point(const Point& reference, double offSetX, double offSetY);
|
||||
|
||||
~Point();
|
||||
|
||||
static std::shared_ptr<Point> Create(double x, double y);
|
||||
|
|
|
@ -34,6 +34,11 @@ public:
|
|||
return mBottomLeft.getDeltaX(mTopRight);
|
||||
}
|
||||
|
||||
Point getBottomLeft() const
|
||||
{
|
||||
return mBottomLeft;
|
||||
}
|
||||
|
||||
private:
|
||||
Point mBottomLeft;
|
||||
Point mTopRight;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
class AbstractGeometricItem;
|
||||
|
||||
class AbstractMesh
|
||||
{
|
||||
|
||||
};
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include "Edge.h"
|
||||
|
||||
#include "Node.h"
|
||||
|
||||
Edge::Edge(Node* node0, Node* node1)
|
||||
: mNode0(node0),
|
||||
mNode1(node1)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
class Node;
|
||||
|
||||
class Edge
|
||||
{
|
||||
public:
|
||||
Edge(Node* node0, Node* node1);
|
||||
|
||||
private:
|
||||
Node* mNode0{nullptr};
|
||||
Node* mNode1{nullptr};
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
class Edge;
|
||||
|
||||
class Face
|
||||
{
|
||||
|
||||
};
|
0
src/mesh/MeshBuilder.cpp
Normal file
0
src/mesh/MeshBuilder.cpp
Normal file
0
src/mesh/MeshBuilder.h
Normal file
0
src/mesh/MeshBuilder.h
Normal file
0
src/mesh/MeshPrimitives.cpp
Normal file
0
src/mesh/MeshPrimitives.cpp
Normal file
26
src/mesh/MeshPrimitives.h
Normal file
26
src/mesh/MeshPrimitives.h
Normal file
|
@ -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<TriMesh> build(const Rectangle& rectangle)
|
||||
{
|
||||
auto mesh = std::make_unique<TriMesh>();
|
||||
|
||||
|
||||
const auto bottom_left = rectangle.getBottomLeft();
|
||||
const auto width = rectangle.GetWidth();
|
||||
const auto height = rectangle.GetHeight();
|
||||
|
||||
//VecNodes nodes = {Node(bottom_left), }
|
||||
return mesh;
|
||||
}
|
||||
};
|
3
src/mesh/Node.cpp
Normal file
3
src/mesh/Node.cpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "Node.h"
|
||||
|
||||
|
27
src/mesh/Node.h
Normal file
27
src/mesh/Node.h
Normal file
|
@ -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;
|
||||
};
|
9
src/mesh/TriFace.cpp
Normal file
9
src/mesh/TriFace.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "TriFace.h"
|
||||
|
||||
TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2)
|
||||
: mEdge0(edge0),
|
||||
mEdge1(edge1),
|
||||
mEdge2(edge2)
|
||||
{
|
||||
|
||||
}
|
14
src/mesh/TriFace.h
Normal file
14
src/mesh/TriFace.h
Normal file
|
@ -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};
|
||||
};
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class Node;
|
||||
class Edge;
|
||||
class TriFace;
|
||||
|
||||
using NodePtr = std::unique_ptr<Node>;
|
||||
using EdgePtr = std::unique_ptr<Edge>;
|
||||
using TriFacePtr = std::unique_ptr<TriFace>;
|
||||
|
||||
using VecNodes = std::vector<NodePtr>;
|
||||
using VecEdges = std::vector<EdgePtr>;
|
||||
using VecFaces = std::vector<TriFacePtr>;
|
||||
|
||||
class TriMesh
|
||||
{
|
||||
TriMesh() = default;
|
||||
|
||||
void populate(const VecNodes& nodes, const VecEdges& edges, const VecFaces& faces);
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Node> > mNodes;
|
||||
std::vector<std::unique_ptr<Edge> > mEdges;
|
||||
std::vector<std::unique_ptr<TriFace> > mFaces;
|
||||
};
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue