First opengl/x11/window integration.
This commit is contained in:
parent
7c6a92f4ec
commit
cea3d2c39f
30 changed files with 254 additions and 72 deletions
|
@ -1,8 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
class AbstractGeometricItem;
|
||||
|
||||
class AbstractMesh
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~AbstractMesh() = default;
|
||||
};
|
||||
|
|
|
@ -18,3 +18,13 @@ Edge::~Edge()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned Edge::getNode0Id() const
|
||||
{
|
||||
return mNode0->getIndex();
|
||||
}
|
||||
|
||||
unsigned Edge::getNode1Id() const
|
||||
{
|
||||
return mNode1->getIndex();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ public:
|
|||
|
||||
static std::unique_ptr<Edge> Create(Node* node0, Node* node1, unsigned id = 0);
|
||||
|
||||
unsigned getNode0Id() const;
|
||||
|
||||
unsigned getNode1Id() const;
|
||||
|
||||
private:
|
||||
unsigned mId{0};
|
||||
Node* mNode0{nullptr};
|
||||
|
|
|
@ -16,16 +16,11 @@ class MeshPrimitives
|
|||
{
|
||||
public:
|
||||
|
||||
static std::unique_ptr<TriMesh> build(AbstractGeometricItem* item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static std::unique_ptr<TriMesh> build(const Rectangle& rectangle)
|
||||
{
|
||||
const auto bottom_left = rectangle.getBottomLeft();
|
||||
const auto width = rectangle.GetWidth();
|
||||
const auto height = rectangle.GetHeight();
|
||||
const auto bottom_left = rectangle.getLocation();
|
||||
const auto width = rectangle.getWidth();
|
||||
const auto height = rectangle.getHeight();
|
||||
|
||||
VecPoints locations = {
|
||||
bottom_left,
|
||||
|
|
|
@ -15,6 +15,11 @@ public:
|
|||
|
||||
void updateIndex(unsigned index);
|
||||
|
||||
const Point& getPoint() const
|
||||
{
|
||||
return mPoint;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned mIndex{0};
|
||||
Point mPoint;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "TriFace.h"
|
||||
|
||||
#include "Edge.h"
|
||||
|
||||
TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id)
|
||||
: mEdge0(edge0),
|
||||
mEdge1(edge1),
|
||||
|
@ -18,3 +20,8 @@ TriFace::~TriFace()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<unsigned> TriFace::getNodeIds() const
|
||||
{
|
||||
return {mEdge0->getNode0Id(), mEdge0->getNode1Id(), mEdge1->getNode1Id()};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class Edge;
|
||||
|
||||
|
@ -11,6 +12,8 @@ public:
|
|||
~TriFace();
|
||||
|
||||
static std::unique_ptr<TriFace> Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0);
|
||||
|
||||
std::vector<unsigned> getNodeIds() const;
|
||||
private:
|
||||
unsigned mId{0};
|
||||
Edge* mEdge0{nullptr};
|
||||
|
|
|
@ -15,3 +15,15 @@ void TriMesh::populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces)
|
|||
mEdges = std::move(edges);
|
||||
mFaces = std::move(faces);
|
||||
}
|
||||
|
||||
std::vector<std::vector<Point> > TriMesh::getFaceVertices() const
|
||||
{
|
||||
std::vector<std::vector<Point> > verts(mFaces.size());
|
||||
|
||||
for(std::size_t idx=0; idx<mFaces.size(); idx++)
|
||||
{
|
||||
const auto nodeIds = mFaces[idx]->getNodeIds();
|
||||
verts[idx] = {mNodes[nodeIds[0]]->getPoint(), mNodes[nodeIds[1]]->getPoint(), mNodes[nodeIds[2]]->getPoint()};
|
||||
}
|
||||
return verts;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractMesh.h"
|
||||
#include "Point.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
|
@ -15,7 +18,7 @@ using VecNodes = std::vector<NodePtr>;
|
|||
using VecEdges = std::vector<EdgePtr>;
|
||||
using VecFaces = std::vector<TriFacePtr>;
|
||||
|
||||
class TriMesh
|
||||
class TriMesh : public AbstractMesh
|
||||
{
|
||||
public:
|
||||
TriMesh() = default;
|
||||
|
@ -24,6 +27,8 @@ public:
|
|||
|
||||
void populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces);
|
||||
|
||||
std::vector<std::vector<Point> > getFaceVertices() const;
|
||||
|
||||
private:
|
||||
VecNodes mNodes;
|
||||
VecEdges mEdges;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue