Commit 548b3918 authored by JasonPries's avatar JasonPries
Browse files

Cleanup of Edge and Node access interface in Mesh

parent 40b24c84
#include "Mesh.hpp"
Edge::Edge(Curve *c, bool d, size_t n, size_t s) {
ConstraintCurve = c;
Node = n;
Self = s;
Twin = SIZE_MAX;
Next = SIZE_MAX;
Prev = SIZE_MAX;
Orientation = d;
}
size_t Edge::tip(Mesh const &mesh) const {
return (Next == Self ? mesh.Edges[Twin]->Node : mesh.Edges[Next]->Node);
};
\ No newline at end of file
#include "Mesh.hpp"
\ No newline at end of file
......@@ -9,22 +9,14 @@ class Edge {
public:
friend class Mesh;
friend bool are_intersecting(Edge const *e0, Edge const *e1, Mesh const &m);
Edge() : Node(SIZE_MAX), Self(SIZE_MAX), Next(SIZE_MAX), Twin(SIZE_MAX), Prev(SIZE_MAX), ConstraintCurve(nullptr), Orientation(true), Mark(false) {};
// Constructors
Edge() : Node(SIZE_MAX), Self(SIZE_MAX), Next(SIZE_MAX), Prev(SIZE_MAX), Twin(SIZE_MAX), ConstraintCurve(nullptr), Orientation(true), Mark(false) {};
Edge(size_t n, size_t s, Edge &nx, Edge &pr, Edge &tw) : Node(n), Self(s), Next(nx.Self), Twin(tw.Self), Prev(pr.Self), ConstraintCurve(nullptr), Orientation(true), Mark(false) {};
Edge(size_t v, size_t s, Edge &n, Edge &p, Edge &tw) : Node(v), Self(s), Next(n.Self), Prev(p.Self), Twin(tw.Self), ConstraintCurve(nullptr), Orientation(true), Mark(false) {};
Edge(size_t n, size_t s, Curve *c, bool d) : Node(n), Self(s), Next(SIZE_MAX), Twin(SIZE_MAX), Prev(SIZE_MAX), ConstraintCurve(c), Orientation(d), Mark(false) {};
Edge(Curve *c, bool Orientation, size_t v, size_t s);
// Accessors
size_t node() const { return Node; };
size_t base() const { return Node; };
size_t tip(Mesh const &mesh) const;
size_t self() const { return Self; };
size_t next() const { return Next; };
......@@ -52,16 +44,16 @@ public:
bool is_constrained() const { return (ConstraintCurve != nullptr); };
protected:
size_t Node; //Start of edge
size_t Self; //This triangle
size_t Next; //In triangle
size_t Twin; //Adjacent triangle
size_t Prev; //In triangle
size_t Node; //Point at start of this edge
size_t Self; //This edge in this triangle
size_t Next; //Next edge in this triangle
size_t Twin; //Twin edge in adjacent triangle
size_t Prev; //Previous edge in this triangle
Curve *ConstraintCurve; //==nullptr if unconstrained
bool Orientation; //undefined if unconstrained
bool Orientation; //don't care if unconstrained
bool Mark; // Auxillary variable for mesh refinement
bool Mark; //Auxiliary variable for mesh refinement
};
#endif //OERSTED_EDGE_H
This diff is collapsed.
......@@ -18,8 +18,6 @@ enum class InsertPointResult {
};
class Mesh {
friend class Edge;
public:
double MinimumElementQuality = 0.0;
double MinimumElementSize = 0.0;
......@@ -57,6 +55,8 @@ public:
size_t size_triangles() const { return Triangles.size(); };
size_t node(Edge const *e) const { return e->Node; };
size_t num_points() const { return Points.size(); };
size_t num_edges() const;
......@@ -71,10 +71,28 @@ public:
Point circumcenter(Edge const *e) const;
Point const base(Edge const *e) const { return Points[e->Node]; };
Point const point(size_t i) const { return Points[i]; };
Point const point(Edge const *e) const { return Points[e->Node]; };
Point const tip(Edge const *e) const { return Points[next(e)->Node]; };
Edge const *edge(size_t i) const { return Edges[i]; };
Edge const *next(Edge const *e) const { return Edges[e->Next]; };
Edge *&next(Edge *e) { return Edges[e->Next]; };
Edge const *prev(Edge const *e) const { return Edges[e->Prev]; };
Edge *&prev(Edge *e) { return Edges[e->Prev]; };
Edge const *twin(Edge const *e) const { return Edges[e->Twin]; };
Edge *&twin(Edge *e) { return Edges[e->Twin]; };
Edge const *triangle(size_t i) const { return Triangles[i]; };
LocateTriangleResult locate_triangle(Point const p, Edge const *&e) const;
......@@ -95,11 +113,11 @@ protected:
std::vector<Edge *> Triangles;
private:
bool find_attached(Edge *&e_out, Point const p) const;
bool find_attached(Edge *&e_out, Point const p);
bool recursive_swap(Edge *e) const;
bool recursive_swap(Edge *e);
bool swap(Edge *&e0) const;
bool swap(Edge *&e0);
void add_edge(Edge *&e) {
e->Self = Edges.size();
......@@ -116,8 +134,6 @@ private:
void mark_triangles();
void recursive_mark(Edge *e) const;
void refine_once(std::vector<size_t> index, std::vector<double> circumradius, std::vector<double> quality);
void sort_permutation_ascending(std::vector<double> &value, std::vector<size_t> &index) const;
......
......@@ -138,12 +138,12 @@ TEST(Mesh, create__square_domain) {
// Test edge and node connections
{
EXPECT_TRUE(m.point(0) == m.point(m.edge(0)->node()));
EXPECT_TRUE(m.point(1) == m.point(m.edge(1)->node()));
EXPECT_TRUE(m.point(2) == m.point(m.edge(2)->node()));
EXPECT_TRUE(m.point(3) == m.point(m.edge(3)->node()));
EXPECT_TRUE(m.point(1) == m.point(m.edge(4)->node()));
EXPECT_TRUE(m.point(3) == m.point(m.edge(5)->node()));
EXPECT_TRUE(m.point((size_t)0) == m.point(m.edge(0)));
EXPECT_TRUE(m.point((size_t)1) == m.point(m.edge(1)));
EXPECT_TRUE(m.point((size_t)2) == m.point(m.edge(2)));
EXPECT_TRUE(m.point((size_t)3) == m.point(m.edge(3)));
EXPECT_TRUE(m.point((size_t)1) == m.point(m.edge(4)));
EXPECT_TRUE(m.point((size_t)3) == m.point(m.edge(5)));
for (size_t i = 0; i < 5; i++) {
const Edge *e = m.edge(i);
......
......@@ -16,7 +16,6 @@ bool edges_are_valid(Mesh &m) {
EXPECT_TRUE(e->self() == m.edge(e->prev())->next());
EXPECT_TRUE(e->self() == m.edge(e->twin())->twin());
//e->ConstraintCurve == e->Twin->ConstraintCurve and e->Orientation != e->Orientation
if ((e->twin() != e->self())) {
EXPECT_TRUE(e->node() == m.edge(m.edge(e->twin())->next())->node());
EXPECT_TRUE(e->constraint_curve() == m.edge(e->twin())->constraint_curve());
......@@ -29,12 +28,12 @@ bool edges_are_valid(Mesh &m) {
if (e->constraint_curve() != nullptr) {
if (e->orientation()) {
EXPECT_TRUE(m.point(e->base()) == *e->constraint_curve()->start());
EXPECT_TRUE(m.point(e->tip(m)) == *e->constraint_curve()->end());
EXPECT_TRUE(m.base(e) == *e->constraint_curve()->start());
EXPECT_TRUE(m.tip(e) == *e->constraint_curve()->end());
}
else {
EXPECT_TRUE(m.point(e->base()) == *e->constraint_curve()->end());
EXPECT_TRUE(m.point(e->tip(m)) == *e->constraint_curve()->start());
EXPECT_TRUE(m.base(e) == *e->constraint_curve()->end());
EXPECT_TRUE(m.tip(e) == *e->constraint_curve()->start());
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment