Further work on trying to get orientation properly mapped

This commit is contained in:
Thomas Krijnen
2024-06-28 13:41:01 +02:00
parent c240f0582a
commit 42b96d6290
3 changed files with 22 additions and 16 deletions
+18 -11
View File
@@ -140,19 +140,22 @@ namespace {
const bool reversed = !e->orientation.get_value_or(true);
const bool is_conic = e_basis->kind() == taxonomy::ELLIPSE || e_basis->kind() == taxonomy::CIRCLE;
if (!e->curve_sense) {
curve->Reverse();
auto e_start = e->start;
auto e_end = e->end;
if (!e->curve_sense.get_value_or(true)) {
std::swap(e_start, e_end);
}
// @todo, copy over logic from previous IfcTrimmedCurve handling
if (e->start.which() == 0) {
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->start));
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->end));
if (e_start.which() == 0) {
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e_start));
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e_end));
E = BRepBuilderAPI_MakeEdge(curve, p1, p2).Edge();
} else {
auto v1 = boost::get<double>(e->start);
auto v2 = boost::get<double>(e->end);
auto v1 = boost::get<double>(e_start);
auto v2 = boost::get<double>(e_end);
if (is_conic && ALMOST_THE_SAME(fmod(v2 - v1, M_PI*2.), 0.)) {
E = BRepBuilderAPI_MakeEdge(curve).Edge();
@@ -161,6 +164,14 @@ namespace {
}
}
// When SenseAgreement == .F. the vertices above have been reversed to
// comply with the direction of conical curves. The ordering of the
// vertices then still needs to be reversed in order to have begin and
// end vertex consistent with IFC.
if (!e->curve_sense.get_value_or(true)) {
E.Reverse();
}
if (reversed) {
E.Reverse();
}
@@ -235,10 +246,6 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
std::wcout << o_str.c_str() << std::endl;
#endif
if (!segment->curve_sense.get_value_or(true)) {
segment_wire.Reverse();
}
ShapeFix_ShapeTolerance FTol;
FTol.SetTolerance(segment_wire, precision_, TopAbs_WIRE);
+3 -4
View File
@@ -52,15 +52,14 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
else if (segment->as<IfcSchema::IfcCompositeCurveSegment>()) {
auto crv = map(segment->as<IfcSchema::IfcCompositeCurveSegment>()->ParentCurve());
if (crv) {
if (!segment->as<IfcSchema::IfcCompositeCurveSegment>()->SameSense()) {
crv->reverse();
}
if (crv->kind() == taxonomy::EDGE) {
auto ecrv = taxonomy::cast<taxonomy::edge>(crv);
ecrv->curve_sense.reset(segment->as<IfcSchema::IfcCompositeCurveSegment>()->SameSense());
loop->children.push_back(ecrv);
}
else if (crv->kind() == taxonomy::LOOP) {
if (!segment->as<IfcSchema::IfcCompositeCurveSegment>()->SameSense()) {
crv->reverse();
}
for (auto& s : taxonomy::cast<taxonomy::loop>(crv)->children) {
loop->children.push_back(s);
}
+1 -1
View File
@@ -44,7 +44,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
bool has_flts[2] = {false,false};
bool has_pnts[2] = {false,false};
tc->orientation = inst->SenseAgreement();
tc->curve_sense = inst->SenseAgreement();
for (auto it = trims1->begin(); it != trims1->end(); it ++) {
auto i = *it;