Cleaning for mesh addition.
This commit is contained in:
parent
8e0ce22b57
commit
402f381d10
67 changed files with 655 additions and 456 deletions
|
@ -2,6 +2,7 @@ list(APPEND mesh_LIB_INCLUDES
|
|||
AbstractMesh.cpp
|
||||
Edge.cpp
|
||||
Face.cpp
|
||||
TriFace.cpp
|
||||
Node.cpp
|
||||
QuadMesh.cpp
|
||||
TriMesh.cpp
|
||||
|
@ -13,5 +14,7 @@ list(APPEND mesh_LIB_INCLUDES
|
|||
add_library(mesh SHARED ${mesh_LIB_INCLUDES})
|
||||
target_link_libraries(mesh core geometry)
|
||||
|
||||
target_include_directories(mesh PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/")
|
||||
|
||||
set_target_properties( mesh PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_property(TARGET mesh PROPERTY FOLDER src)
|
||||
|
|
|
@ -2,8 +2,19 @@
|
|||
|
||||
#include "Node.h"
|
||||
|
||||
Edge::Edge(Node* node0, Node* node1)
|
||||
Edge::Edge(Node* node0, Node* node1, unsigned id)
|
||||
: mNode0(node0),
|
||||
mNode1(node1)
|
||||
mNode1(node1),
|
||||
mId(id)
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<Edge> Edge::Create(Node* node0, Node* node1, unsigned id)
|
||||
{
|
||||
return std::make_unique<Edge>(node0, node1, id);
|
||||
}
|
||||
|
||||
Edge::~Edge()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,18 @@
|
|||
|
||||
class Node;
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Edge
|
||||
{
|
||||
public:
|
||||
Edge(Node* node0, Node* node1);
|
||||
Edge(Node* node0, Node* node1, unsigned id = 0);
|
||||
~Edge();
|
||||
|
||||
static std::unique_ptr<Edge> Create(Node* node0, Node* node1, unsigned id = 0);
|
||||
|
||||
private:
|
||||
unsigned mId{0};
|
||||
Node* mNode0{nullptr};
|
||||
Node* mNode1{nullptr};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#include "MeshBuilder.h"
|
||||
|
||||
#include "Node.h"
|
||||
#include "Edge.h"
|
||||
#include "TriFace.h"
|
||||
|
||||
std::unique_ptr<TriMesh> MeshBuilder::buildTriMesh(const VecPoints& locations, const EdgeIds& edgeIds, const FaceIds& faceIds)
|
||||
{
|
||||
auto mesh = std::make_unique<TriMesh>();
|
||||
|
||||
VecNodes nodes(locations.size());
|
||||
for (std::size_t idx=0; idx<locations.size(); idx++)
|
||||
{
|
||||
nodes[idx] = Node::Create(locations[idx], idx);
|
||||
}
|
||||
|
||||
VecEdges edges(edgeIds.size());
|
||||
for (std::size_t idx=0; idx<edgeIds.size(); idx++)
|
||||
{
|
||||
edges[idx] = Edge::Create(nodes[edgeIds[idx].first].get(), nodes[edgeIds[idx].second].get(), idx);
|
||||
}
|
||||
|
||||
VecFaces faces(faceIds.size());
|
||||
for (std::size_t idx=0; idx<faceIds.size(); idx++)
|
||||
{
|
||||
faces[idx] = TriFace::Create(
|
||||
edges[faceIds[idx][0]].get(),
|
||||
edges[faceIds[idx][1]].get(),
|
||||
edges[faceIds[idx][2]].get(),
|
||||
idx);
|
||||
}
|
||||
|
||||
mesh->populate(nodes, edges, faces);
|
||||
return mesh;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "TriMesh.h"
|
||||
#include "Point.h"
|
||||
|
||||
using EdgeIds = std::vector<std::pair<unsigned, unsigned> >;
|
||||
using FaceIds = std::vector<std::vector<unsigned> >;
|
||||
using VecPoints = std::vector<Point>;
|
||||
|
||||
class MeshBuilder
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<TriMesh> buildTriMesh(const VecPoints& locations, const EdgeIds& edgeIds, const FaceIds& faceIds);
|
||||
};
|
|
@ -7,20 +7,46 @@
|
|||
#include "Edge.h"
|
||||
#include "Face.h"
|
||||
|
||||
#include "MeshBuilder.h"
|
||||
#include "AbstractGeometricItem.h"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
class MeshPrimitives
|
||||
{
|
||||
public:
|
||||
|
||||
std::unique_ptr<TriMesh> build(const Rectangle& rectangle)
|
||||
static std::unique_ptr<TriMesh> build(AbstractGeometricItem* item)
|
||||
{
|
||||
auto mesh = std::make_unique<TriMesh>();
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
//VecNodes nodes = {Node(bottom_left), }
|
||||
return mesh;
|
||||
VecPoints locations = {
|
||||
bottom_left,
|
||||
Point(bottom_left, width, 0),
|
||||
Point(bottom_left, width, height),
|
||||
Point(bottom_left, 0, height)
|
||||
};
|
||||
|
||||
EdgeIds edge_ids = {
|
||||
{0, 1},
|
||||
{1, 2},
|
||||
{2, 0},
|
||||
{2, 3},
|
||||
{3, 0}
|
||||
};
|
||||
|
||||
FaceIds face_ids = {
|
||||
{0, 1, 2},
|
||||
{2, 3, 4}
|
||||
};
|
||||
|
||||
return MeshBuilder::buildTriMesh(locations, edge_ids, face_ids);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
#include "Node.h"
|
||||
|
||||
std::unique_ptr<Node> Node::Create(const Point& p, unsigned index)
|
||||
{
|
||||
return std::make_unique<Node>(p, index);
|
||||
}
|
||||
|
||||
Node::~Node()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Node::Node(const Point& p, unsigned index)
|
||||
: mPoint(p),
|
||||
mIndex(index)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned Node::getIndex() const
|
||||
{
|
||||
return mIndex;
|
||||
}
|
||||
|
||||
void Node::updateIndex(unsigned index)
|
||||
{
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,22 +4,16 @@
|
|||
|
||||
class Node
|
||||
{
|
||||
Node(const Point& p, unsigned index = 0)
|
||||
: mPoint(p),
|
||||
mIndex(index)
|
||||
{
|
||||
public:
|
||||
Node(const Point& p, unsigned index = 0);
|
||||
|
||||
}
|
||||
static std::unique_ptr<Node> Create(const Point& p, unsigned index = 0);
|
||||
|
||||
unsigned getIndex() const
|
||||
{
|
||||
return mIndex;
|
||||
}
|
||||
~Node();
|
||||
|
||||
void updateIndex(unsigned index)
|
||||
{
|
||||
mIndex = index;
|
||||
}
|
||||
unsigned getIndex() const;
|
||||
|
||||
void updateIndex(unsigned index);
|
||||
|
||||
private:
|
||||
unsigned mIndex{0};
|
||||
|
|
|
@ -1,9 +1,20 @@
|
|||
#include "TriFace.h"
|
||||
|
||||
TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2)
|
||||
TriFace::TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id)
|
||||
: mEdge0(edge0),
|
||||
mEdge1(edge1),
|
||||
mEdge2(edge2)
|
||||
mEdge2(edge2),
|
||||
mId(id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<TriFace> TriFace::Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id)
|
||||
{
|
||||
return std::make_unique<TriFace>(edge0, edge1, edge2, id);
|
||||
}
|
||||
|
||||
TriFace::~TriFace()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Edge;
|
||||
|
||||
class TriFace
|
||||
{
|
||||
public:
|
||||
TriFace(Edge* edge0, Edge* edge1, Edge* edge2);
|
||||
TriFace(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0);
|
||||
~TriFace();
|
||||
|
||||
static std::unique_ptr<TriFace> Create(Edge* edge0, Edge* edge1, Edge* edge2, unsigned id=0);
|
||||
private:
|
||||
unsigned mId{0};
|
||||
Edge* mEdge0{nullptr};
|
||||
Edge* mEdge1{nullptr};
|
||||
Edge* mEdge2{nullptr};
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
#include "TriMesh.h"
|
||||
|
||||
void TriMesh::populate(const VecNodes& nodes, const VecEdges& edges, const VecFaces& faces)
|
||||
#include "Node.h"
|
||||
#include "Edge.h"
|
||||
#include "TriFace.h"
|
||||
|
||||
TriMesh::~TriMesh()
|
||||
{
|
||||
//mNodes = std::move(nodes);
|
||||
//mEdges = std::move(edges);
|
||||
//mFaces = std::move(faces);
|
||||
|
||||
}
|
||||
|
||||
void TriMesh::populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces)
|
||||
{
|
||||
mNodes = std::move(nodes);
|
||||
mEdges = std::move(edges);
|
||||
mFaces = std::move(faces);
|
||||
}
|
||||
|
|
|
@ -17,9 +17,12 @@ using VecFaces = std::vector<TriFacePtr>;
|
|||
|
||||
class TriMesh
|
||||
{
|
||||
public:
|
||||
TriMesh() = default;
|
||||
|
||||
void populate(const VecNodes& nodes, const VecEdges& edges, const VecFaces& faces);
|
||||
~TriMesh();
|
||||
|
||||
void populate(VecNodes& nodes, VecEdges& edges, VecFaces& faces);
|
||||
|
||||
private:
|
||||
VecNodes mNodes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue