Commit a683cd9a authored by JasonPries's avatar JasonPries
Browse files

Remove redundant Curves property in Mesh

parent bf047711
......@@ -14,7 +14,7 @@ public:
std::shared_ptr<BoundaryConstraint> boundary_constraint() const { return Constraint; };
std::shared_ptr<Curve const> constraint_curve() const { return Constraint->curve(); };
std::shared_ptr<Curve const> curve() const { return Constraint->curve(); };
size_t self() const { return Self; };
......
......@@ -6,7 +6,6 @@ Mesh::Mesh(Sketch &sketch) {
for (size_t i = 0; i != sketch.size_curves(); ++i) {
auto c = sketch.curve(i);
if (!(c->for_construction())) {
Curves.push_back(c);
BoundaryConstraints.push_back(std::make_shared<BoundaryConstraint>(c));
}
}
......@@ -130,28 +129,28 @@ bool Mesh::edges_are_valid() const {
double tol = length(e) * FLT_EPSILON;
if (orientation(e)) {
Point p0 = base(e);
Point p1 = dc.constraint_curve()->point(dc.S0);
Point p1 = dc.curve()->point(dc.S0);
if (dist(p0,p1) > tol) {
result = false;
break;
}
p0 = tip(e);
p1 = dc.constraint_curve()->point(dc.S1);
p1 = dc.curve()->point(dc.S1);
if (dist(p0,p1) > tol) {
result = false;
break;
}
} else {
Point p0 = base(e);
Point p1 = dc.constraint_curve()->point(dc.S1);
Point p1 = dc.curve()->point(dc.S1);
if (dist(p0,p1) > tol) {
result = false;
break;
}
p0 = tip(e);
p1 = dc.constraint_curve()->point(dc.S0);
p1 = dc.curve()->point(dc.S0);
if (dist(p0,p1) > tol) {
result = false;
break;
......@@ -676,25 +675,26 @@ void Mesh::insert_internal_boundaries() {
*/
// Find interior curves
std::vector<std::shared_ptr<Curve const>> interior;
for (auto c : Curves) {
std::vector<size_t> interior_index;
for (size_t i = 0; i!= BoundaryConstraints.size(); ++i) {
auto const & bc = BoundaryConstraints[i];
bool on_exterior = false;
for (size_t i = 0; i != Boundary->size(); ++i) {
if (c == Boundary->curve(i)) {
if (bc->curve() == Boundary->curve(i)) {
on_exterior = true;
break;
}
}
if (!on_exterior) {
interior.push_back(c);
interior_index.push_back(i);
}
}
// Insert interior curve end points
for (size_t i = 0; i != interior.size(); ++i) {
for (size_t i : interior_index) {
// Insert start point
Point p = interior[i]->start();
Point p = BoundaryConstraints[i]->curve()->start();
LocateTriangleResult result = locate_triangle(p);
if (result == LocateTriangleResult::Interior) {
while (add_point_to_queue(p) == AddToQueueResult::Midpoint) {
......@@ -704,7 +704,7 @@ void Mesh::insert_internal_boundaries() {
}
// Insert end point
p = interior[i]->end();
p = BoundaryConstraints[i]->curve()->end();
result = locate_triangle(p);
if (result == LocateTriangleResult::Interior) {
while (add_point_to_queue(p) == AddToQueueResult::Midpoint) {
......@@ -716,13 +716,13 @@ void Mesh::insert_internal_boundaries() {
// Attach edges to constraints by inserting interior curve midpoints until constraints are naturally satisfied
std::vector<size_t> queue;
for (size_t i = 0; i != interior.size(); ++i) {
for (size_t i : interior_index) {
queue.push_back(DartConstraints.size());
new_dart_constraint(0.0, 1.0, boundary_constraint(interior[i]));
new_dart_constraint(0.0, 1.0, BoundaryConstraints[i]);
while (queue.size() != 0) {
DartConstraint &dc = DartConstraints[queue.back()];
Point p0 = dc.constraint_curve()->point(dc.S0); // TODO: write Point Curve::point(double) and differentiate from Vertex Curve::vertex(double)
Point p1 = dc.constraint_curve()->point(dc.S1);
Point p0 = dc.curve()->point(dc.S0); // TODO: write Point Curve::point(double) and differentiate from Vertex Curve::vertex(double)
Point p1 = dc.curve()->point(dc.S1);
size_t ei = Edges.size() - 1;
LocateTriangleResult result = locate_triangle(p0, ei);
......@@ -737,7 +737,6 @@ void Mesh::insert_internal_boundaries() {
e.Orientation = true;
dc.forward_dart(e.self());
Edge &et = Edges[e.Twin];
et.Constraint = dc.Self;
et.Orientation = false;
......@@ -747,10 +746,9 @@ void Mesh::insert_internal_boundaries() {
} else {
double s0 = dc.S0;
double s1 = dc.S1;
std::shared_ptr<Curve const> cc = dc.constraint_curve();
double sn = (s0 + s1) / 2.0;
Point const p = cc->point(sn);
Point const p = dc.curve()->point(sn);
dc.S1 = sn;
......@@ -869,7 +867,7 @@ void Mesh::split_edge(size_t ei) {
DartConstraint &dci = DartConstraints[Edges[ei].Constraint];
double s0 = dci.S0;
double s1 = dci.S1;
std::shared_ptr<Curve const> cc = dci.constraint_curve();
std::shared_ptr<Curve const> cc = dci.curve();
double sn = (s0 + s1) / 2.0;
dci.S1 = sn;
......@@ -1169,7 +1167,7 @@ InsertPointResult Mesh::insert_midpoint(size_t ei) {
DartConstraint &dc = DartConstraints[Edges[ei].Constraint];
double s0 = dc.S0;
double s1 = dc.S1;
std::shared_ptr<Curve const> cc = dc.constraint_curve();
std::shared_ptr<Curve const> cc = dc.curve();
double sn = (s0 + s1) / 2.0;
dc.S1 = sn;
......
......@@ -97,7 +97,7 @@ public:
// TODO: rename these methods something like, dart_constraint_from_edge_index, curve_from_edge_index
DartConstraint const constraint(size_t ei) const { return DartConstraints[Edges[ei].Constraint]; };
std::shared_ptr<Curve const> constraint_curve(size_t ei) const { return DartConstraints[Edges[ei].Constraint].constraint_curve(); };
std::shared_ptr<Curve const> constraint_curve(size_t ei) const { return DartConstraints[Edges[ei].Constraint].curve(); };
std::shared_ptr<BoundaryConstraint> boundary_constraint(std::shared_ptr<Curve const> const &c) const;
......@@ -166,17 +166,13 @@ public:
AddToQueueResult add_point_to_queue(Point const p) { return add_point_to_queue(p, Edges.size() - 1); };
protected:
// TODO: There is some amount of redundancy here (e.g. There is one Curve for each BoundaryConstraint, Countours and Boundary also contain those curves
std::shared_ptr<Contour const> Boundary;
std::vector<std::shared_ptr<Curve const>> Curves;
std::vector<std::shared_ptr<Contour const>> Contours;
std::vector<std::shared_ptr<BoundaryConstraint>> BoundaryConstraints;
std::vector<Point> Points;
std::vector<Edge> Edges;
std::vector<DartConstraint> DartConstraints;
std::vector<std::shared_ptr<BoundaryConstraint>> BoundaryConstraints;
std::vector<DartTriangle> Triangles;
std::vector<std::unique_ptr<InsertionQueuer>> Queue;
......
......@@ -4,6 +4,8 @@
#include <vector>
#include <cstddef>
#include <Sketch.hpp>
template<size_t Dimension>
class Boundary {
};
......@@ -11,7 +13,9 @@ class Boundary {
template<>
class Boundary<2> {
public:
Boundary(std::vector<size_t> &&nodes) : Nodes{nodes} {};
Boundary(std::vector<size_t> &&nodes) : CurvePtr{nullptr}, Nodes{nodes} {};
Boundary(std::shared_ptr<Curve const> cptr, std::vector<size_t> &&nodes) : CurvePtr{cptr}, Nodes{nodes} {};
size_t size() const { return Nodes.size(); };
......@@ -25,6 +29,7 @@ public:
protected:
std::shared_ptr<Curve const> CurvePtr;
std::vector<size_t> Nodes;
};
......
......@@ -27,11 +27,13 @@ template<> FiniteElementMesh<2,1>::FiniteElementMesh(Mesh &m) {
Then selection can be implemented by passing the shared_ptr that the user has (similar to how the Mesh operations work)
*/
/*Boundaries.reserve(m.size_constraints());
for (size_t i = 0; i!= m.size_constraionts(); ++i) {
...
/*
Boundaries.reserve(m.size_constraints());
for (size_t i = 0; i!= m.size_constraints(); ++i) {
Boundaries.push_back(std::make_shared<Boundary<2>>());
}
*/
Regions.reserve(m.size_contours());
for (size_t i = 0; i != m.size_contours(); ++i) {
Regions.push_back(std::make_shared<Region<2>>()); // TODO: Assign material properties here
......
......@@ -7,8 +7,8 @@ public:
auto v0 = sk.new_element<Vertex>(0.0,0.0);
auto v1 = sk.new_element<Vertex>(1.0,0.0);
auto v2 = sk.new_element<Vertex>(1.0*std::cos(M_PI*2.0/3.0),1.0*std::sin(M_PI*2.0/3.0));
auto v3 = sk.new_element<Vertex>(1.0*std::cos(-M_PI*2.0/3.0),1.0*std::sin(-M_PI*2.0/3.0));
auto v2 = sk.new_element<Vertex>(1.0 * std::cos(M_PI * 2.0 / 3.0), 1.0 * std::sin(M_PI * 2.0 / 3.0));
auto v3 = sk.new_element<Vertex>(1.0 * std::cos(-M_PI * 2.0 / 3.0), 1.0 * std::sin(-M_PI * 2.0 / 3.0));
auto c0 = sk.new_element<CircularArc>(v1,v2,v0,1.0);
auto c1 = sk.new_element<CircularArc>(v2,v3,v0,1.0);
......
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