mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
improve trimmed curve handling in both kernels
This commit is contained in:
@@ -324,6 +324,11 @@ namespace {
|
|||||||
} else {
|
} else {
|
||||||
std::tie(a, b) = param;
|
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);
|
int num_segments = (int)std::ceil(std::fabs(a - b) / (2 * M_PI) * FULL_CIRCLE_NUM_SEGMENTS);
|
||||||
double du = (b - a) / num_segments;
|
double du = (b - a) / num_segments;
|
||||||
taxonomy::point3 P;
|
taxonomy::point3 P;
|
||||||
@@ -352,6 +357,10 @@ namespace {
|
|||||||
boost::apply_visitor(v1, e.start);
|
boost::apply_visitor(v1, e.start);
|
||||||
boost::apply_visitor(v2, e.end);
|
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 });
|
cgal_curve_creation_visitor v({ v1.u, v2.u });
|
||||||
|
|
||||||
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(e.basis, v);
|
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) {
|
for (auto& e : edges) {
|
||||||
if (e->basis) {
|
if (e->basis) {
|
||||||
std::vector<taxonomy::point3> edge;
|
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);
|
extend_wire(points, edge);
|
||||||
} else {
|
} else {
|
||||||
extend_wire(points, {
|
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;
|
std::wcout << o_str.c_str() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!segment->orientation) {
|
if (!segment->orientation_2.get_value_or(true)) {
|
||||||
segment_wire.Reverse();
|
segment_wire.Reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1325,7 +1325,7 @@ namespace {
|
|||||||
*c->matrix.components = Eigen::Affine3d(Eigen::Translation3d(O)).matrix();
|
*c->matrix.components = Eigen::Affine3d(Eigen::Translation3d(O)).matrix();
|
||||||
c->radius = *p.radius;
|
c->radius = *p.radius;
|
||||||
e->basis = c;
|
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);
|
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());
|
auto crv = map(segment->ParentCurve());
|
||||||
if (crv) {
|
if (crv) {
|
||||||
if (crv->kind() == taxonomy::EDGE) {
|
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);
|
loop->children.push_back(crv);
|
||||||
} else if (crv->kind() == taxonomy::LOOP) {
|
} else if (crv->kind() == taxonomy::LOOP) {
|
||||||
if (!segment->SameSense()) {
|
if (!segment->SameSense()) {
|
||||||
@@ -1816,7 +1816,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
|
|||||||
}
|
}
|
||||||
auto p = new taxonomy::plane;
|
auto p = new taxonomy::plane;
|
||||||
p->matrix = as<taxonomy::matrix4>(map(((IfcSchema::IfcPlane*)surface)->Position()));
|
p->matrix = as<taxonomy::matrix4>(map(((IfcSchema::IfcPlane*)surface)->Position()));
|
||||||
p->orientation = !inst->AgreementFlag();
|
p->orientation.reset(!inst->AgreementFlag());
|
||||||
auto f = new taxonomy::face;
|
auto f = new taxonomy::face;
|
||||||
f->basis = p;
|
f->basis = p;
|
||||||
return f;
|
return f;
|
||||||
|
|||||||
@@ -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.
|
// @todo somehow account for the fact that curve in IFC can be trimmed curve, polyline and composite curve as well.
|
||||||
item* basis;
|
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() {
|
virtual void reverse() {
|
||||||
// std::swap(start, end);
|
// std::swap(start, end);
|
||||||
|
|||||||
Reference in New Issue
Block a user