From 5fcee9dfe5ff1eca8e8d63ba1c613fe2e1e4f5d3 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 1 Nov 2019 16:11:26 +0100 Subject: [PATCH] spherical toroidal surface --- src/ifcgeom/IfcGeomFunctions.cpp | 8 +++---- src/ifcgeom/IfcGeomShapes.cpp | 40 +++++++++++++++++++++++++------- src/ifcgeom/IfcRegister.h | 6 +++++ 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index c2639f94ea..88561dd8ec 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -4322,15 +4322,15 @@ IfcGeom::Kernel::faceset_helper::faceset_helper(Kernel* kernel, const IfcSchema: eps_ = Precision::Confusion(); } - for (int i = 0; i < (int)pnts.size(); ++i) { - if (pnts[i]) { + for (int pnt_i = 0; pnt_i < (int)pnts.size(); ++pnt_i) { + if (pnts[pnt_i]) { std::set vs; - find_neighbours(tree, pnts, vs, i, eps_); + find_neighbours(tree, pnts, vs, pnt_i, eps_); for (int v : vs) { auto pt = *(points->begin() + v); // NB: insert() ignores duplicate keys - vertex_mapping_.insert({ pt->data().id() , i }); + vertex_mapping_.insert({ pt->data().id() , pnt_i }); } } } diff --git a/src/ifcgeom/IfcGeomShapes.cpp b/src/ifcgeom/IfcGeomShapes.cpp index 182b235596..278c07a82b 100644 --- a/src/ifcgeom/IfcGeomShapes.cpp +++ b/src/ifcgeom/IfcGeomShapes.cpp @@ -108,6 +108,10 @@ #include +#ifdef SCHEMA_HAS_IfcToroidalSurface +#include +#endif + #define Kernel MAKE_TYPE_NAME(Kernel) bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_Shape& shape) { @@ -1187,12 +1191,10 @@ namespace { } } - void segment_adjacent_non_linear(const TopoDS_Wire& wire, std::vector& wires, double eps) { + void segment_adjacent_non_linear(const TopoDS_Wire& wire, std::vector& wires) { std::vector sorted_edges; sort_edges(wire, sorted_edges); - bool segment_next = true; - BRep_Builder B; double u, v; @@ -1222,7 +1224,7 @@ namespace { // @todo make this generic for other sweeps not just swept disk void process_sweep(const TopoDS_Wire& wire, double radius, TopoDS_Shape& result) { std::vector wires; - segment_adjacent_non_linear(wire, wires, 1.e-2); + segment_adjacent_non_linear(wire, wires); TopoDS_Compound C; BRep_Builder B; @@ -1287,7 +1289,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap if (hasInnerRadius) { // Subtraction of pipes with small radii is unstable. - const double r2 = l->InnerRadius() * getValue(GV_LENGTH_UNIT); + r2 = l->InnerRadius() * getValue(GV_LENGTH_UNIT); } if (r2 > getValue(GV_PRECISION) * 10.) { @@ -1334,11 +1336,33 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCylindricalSurface* l, TopoDS_ IfcGeom::Kernel::convert(l->Position(),trsf); // IfcElementarySurface.Position has unit scale factor -#if OCC_VERSION_HEX < 0x60502 - face = BRepBuilderAPI_MakeFace(new Geom_CylindricalSurface(gp::XOY(), l->Radius() * getValue(GV_LENGTH_UNIT))).Face().Moved(trsf); -#else face = BRepBuilderAPI_MakeFace(new Geom_CylindricalSurface(gp::XOY(), l->Radius() * getValue(GV_LENGTH_UNIT)), getValue(GV_PRECISION)).Face().Moved(trsf); + return true; +} + #endif + +#ifdef SCHEMA_HAS_IfcSphericalSurface + +bool IfcGeom::Kernel::convert(const IfcSchema::IfcSphericalSurface* l, TopoDS_Shape& face) { + gp_Trsf trsf; + IfcGeom::Kernel::convert(l->Position(), trsf); + + // IfcElementarySurface.Position has unit scale factor + face = BRepBuilderAPI_MakeFace(new Geom_SphericalSurface(gp::XOY(), l->Radius() * getValue(GV_LENGTH_UNIT)), getValue(GV_PRECISION)).Face().Moved(trsf); + return true; +} + +#endif + +#ifdef SCHEMA_HAS_IfcToroidalSurface + +bool IfcGeom::Kernel::convert(const IfcSchema::IfcToroidalSurface* l, TopoDS_Shape& face) { + gp_Trsf trsf; + IfcGeom::Kernel::convert(l->Position(), trsf); + + // IfcElementarySurface.Position has unit scale factor + face = BRepBuilderAPI_MakeFace(new Geom_ToroidalSurface(gp::XOY(), l->MajorRadius() * getValue(GV_LENGTH_UNIT), l->MinorRadius() * getValue(GV_LENGTH_UNIT)), getValue(GV_PRECISION)).Face().Moved(trsf); return true; } diff --git a/src/ifcgeom/IfcRegister.h b/src/ifcgeom/IfcRegister.h index c646e7827b..be885212c8 100644 --- a/src/ifcgeom/IfcRegister.h +++ b/src/ifcgeom/IfcRegister.h @@ -58,6 +58,12 @@ SHAPE(IfcCylindricalSurface); #ifdef SCHEMA_HAS_IfcAdvancedBrep SHAPE(IfcAdvancedBrep); #endif +#ifdef SCHEMA_HAS_IfcToroidalSurface +SHAPE(IfcToroidalSurface); +#endif +#ifdef SCHEMA_HAS_IfcSphericalSurface +SHAPE(IfcSphericalSurface); +#endif // FIXME: Surfaces should have a shape type of their own #ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots SHAPE(IfcBSplineSurfaceWithKnots);