improve trimmed curve handling in both kernels

This commit is contained in:
Thomas Krijnen
2020-07-25 09:12:39 +02:00
parent badac24d6c
commit 63638a4d26
4 changed files with 21 additions and 7 deletions
+13 -1
View File
@@ -324,6 +324,11 @@ namespace {
} else {
std::tie(a, b) = param;
}
a = std::fmod(a, 2 * M_PI);
b = std::fmod(b, 2 * M_PI);
if (b < a) {
b += 2 * M_PI;
}
int num_segments = (int)std::ceil(std::fabs(a - b) / (2 * M_PI) * FULL_CIRCLE_NUM_SEGMENTS);
double du = (b - a) / num_segments;
taxonomy::point3 P;
@@ -352,6 +357,10 @@ namespace {
boost::apply_visitor(v1, e.start);
boost::apply_visitor(v2, e.end);
if (!e.orientation.get_value_or(true)) {
std::swap(v1.u, v2.u);
}
cgal_curve_creation_visitor v({ v1.u, v2.u });
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(e.basis, v);
@@ -392,7 +401,10 @@ bool CgalKernel::convert(const taxonomy::loop* loop, cgal_wire_t& result) {
for (auto& e : edges) {
if (e->basis) {
std::vector<taxonomy::point3> edge;
convert_curve(e->basis, points);
convert_curve(e, edge);
if (!e->orientation_2.get_value_or(true)) {
std::reverse(edge.begin(), edge.end());
}
extend_wire(points, edge);
} else {
extend_wire(points, {
@@ -862,7 +862,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loop* loop, TopoDS_Wire& wire) {
std::wcout << o_str.c_str() << std::endl;
#endif
if (!segment->orientation) {
if (!segment->orientation_2.get_value_or(true)) {
segment_wire.Reverse();
}
+3 -3
View File
@@ -1325,7 +1325,7 @@ namespace {
*c->matrix.components = Eigen::Affine3d(Eigen::Translation3d(O)).matrix();
c->radius = *p.radius;
e->basis = c;
c->orientation = sign == -1.;
c->orientation.reset(sign == -1.);
loop->children.insert(std::find(loop->children.begin(), loop->children.end(), p.next), e);
}
@@ -1612,7 +1612,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
auto crv = map(segment->ParentCurve());
if (crv) {
if (crv->kind() == taxonomy::EDGE) {
((taxonomy::geom_item*)crv)->orientation = segment->SameSense();
((taxonomy::edge*)crv)->orientation_2.reset(segment->SameSense());
loop->children.push_back(crv);
} else if (crv->kind() == taxonomy::LOOP) {
if (!segment->SameSense()) {
@@ -1816,7 +1816,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
}
auto p = new taxonomy::plane;
p->matrix = as<taxonomy::matrix4>(map(((IfcSchema::IfcPlane*)surface)->Position()));
p->orientation = !inst->AgreementFlag();
p->orientation.reset(!inst->AgreementFlag());
auto f = new taxonomy::face;
f->basis = p;
return f;
+4 -2
View File
@@ -251,9 +251,11 @@ struct trimmed_curve : public curve {
// @todo somehow account for the fact that curve in IFC can be trimmed curve, polyline and composite curve as well.
item* basis;
bool orientation;
trimmed_curve() : basis(nullptr), orientation(true) {}
// @todo does this make sense? this is to accomodate for the fact that orientation is defined on both TrimmedCurve as well CompCurveSegment
boost::optional<bool> orientation_2;
trimmed_curve() : basis(nullptr), orientation_2(true) {}
virtual void reverse() {
// std::swap(start, end);