diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp b/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp index 9d86771058..ce6e606e2c 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp +++ b/src/ifcgeom/kernels/opencascade/IfcGeomShapes.cpp @@ -848,6 +848,19 @@ bool OpenCascadeKernel::convert(const taxonomy::loop* loop, TopoDS_Wire& wire) { for (auto& segment : segments) { auto segment_wire = boost::get(convert_curve(this, segment)); + +#ifdef IFOPSH_DEBUG + std::ostringstream o; + segment->print(o); + TopoDS_Vertex v0, v1; + TopExp::Vertices(segment_wire, v0, v1); + gp_Pnt p0 = BRep_Tool::Pnt(v0); + gp_Pnt p1 = BRep_Tool::Pnt(v1); + o << "p0 " << p0.X() << " " << p0.Y() << " " << p0.Z() << std::endl; + o << "p1 " << p1.X() << " " << p1.Y() << " " << p1.Z() << std::endl; + auto o_str = o.str(); + std::wcout << o_str.c_str() << std::endl; +#endif if (!segment->orientation) { segment_wire.Reverse(); diff --git a/src/ifcgeom/schema/mapping.cpp b/src/ifcgeom/schema/mapping.cpp index 74bc6ffbe5..77d57a6d02 100644 --- a/src/ifcgeom/schema/mapping.cpp +++ b/src/ifcgeom/schema/mapping.cpp @@ -1668,13 +1668,14 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) { IfcEntityList::ptr trims1 = inst->Trim1(); IfcEntityList::ptr trims2 = inst->Trim2(); - unsigned sense_agreement = inst->SenseAgreement() ? 0 : 1; + // reversed orientation handling happens in geometry kernel + unsigned sense_agreement = 0; // inst->SenseAgreement() ? 0 : 1; double flts[2]; taxonomy::point3 pnts[2]; bool has_flts[2] = { false,false }; bool has_pnts[2] = { false,false }; - tc->orientation = sense_agreement != 0; + tc->orientation = inst->SenseAgreement(); for (IfcEntityList::it it = trims1->begin(); it != trims1->end(); it++) { IfcUtil::IfcBaseClass* i = *it; diff --git a/src/ifcgeom/schema_agnostic/Converter.cpp b/src/ifcgeom/schema_agnostic/Converter.cpp index 148aa6cdfe..b037ad6c29 100644 --- a/src/ifcgeom/schema_agnostic/Converter.cpp +++ b/src/ifcgeom/schema_agnostic/Converter.cpp @@ -58,7 +58,15 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create auto place = taxonomy::matrix4(); std::swap(place, product_node->matrix); - kernel_->convert(product_node, shapes); + try { + kernel_->convert(product_node, shapes); + } catch (...) { + std::ostringstream oss; + product_node->print(oss); + std::string s = oss.str(); + std::wcout << s.c_str() << std::endl; + return nullptr; + } shape = new ifcopenshell::geometry::Representation::BRep(s, representation_id_builder.str(), shapes); diff --git a/src/ifcgeom/taxonomy.h b/src/ifcgeom/taxonomy.h index 22d4738cb2..98a8da2ca7 100644 --- a/src/ifcgeom/taxonomy.h +++ b/src/ifcgeom/taxonomy.h @@ -62,7 +62,8 @@ struct eigen_base { void print_impl(std::ostream& o, const std::string& class_name, int indent = 0) const { o << std::string(indent, ' ') << class_name; - for (size_t i = 0; i < 16; ++i) { + int n = T::RowsAtCompileTime * T::ColsAtCompileTime; + for (size_t i = 0; i < n; ++i) { o << " " << (*components)(i); } o << std::endl; @@ -188,14 +189,19 @@ struct direction3 : public cartesian_base<3> { direction3(double x = 0., double y = 0., double z = 0.) : cartesian_base(x, y, z) {} }; -struct curve : public geom_item {}; +struct curve : public geom_item { + void print_impl(std::ostream& o, const std::string& classname, int indent = 0) const { + o << std::string(indent, ' ') << classname << std::endl; + this->matrix.print(o, indent + 4); + } +}; struct line : public curve { virtual item* clone() const { return new line(*this); } virtual kinds kind() const { return LINE; } void print(std::ostream& o, int indent = 0) const { - o << "not implemented"; + print_impl(o, "line", indent); } }; @@ -206,7 +212,7 @@ struct circle : public curve { virtual kinds kind() const { return CIRCLE; } void print(std::ostream& o, int indent = 0) const { - o << "not implemented"; + print_impl(o, "circle", indent); } }; @@ -217,7 +223,7 @@ struct ellipse : public circle { virtual kinds kind() const { return ELLIPSE; } void print(std::ostream& o, int indent = 0) const { - o << "not implemented"; + print_impl(o, "ellipse", indent); } }; @@ -226,7 +232,7 @@ struct bspline_curve : public curve { virtual kinds kind() const { return BSPLINE_CURVE; } void print(std::ostream& o, int indent = 0) const { - o << "not implemented"; + o << std::string(indent, ' ') << "bspline curve" << std::endl; } }; @@ -251,6 +257,20 @@ struct trimmed_curve : public curve { if (basis) { basis->print(o, indent + 4); } + + const boost::variant const * start_end[2] = { &start, &end }; + for (int i = 0; i < 2; ++i) { + o << std::string(indent + 4, ' ') << (i == 0 ? "start" : "end") << std::endl; + if (start_end[i]->which() == 0) { + boost::get(*start_end[i]).print(o, indent + 4); + } else if (start_end[i]->which() == 1) { + o << std::string(indent + 4, ' ') << "parameter " << boost::get(*start_end[i]) << std::endl; + } + } + + if (this->instance) { + o << std::string(indent, ' ') << this->instance->data().toString() << std::endl; + } } };