From 6318610bdba5bc5734bdeba132e00fa8fcb78f2a Mon Sep 17 00:00:00 2001 From: Frozen Forest Reality Technologies Date: Wed, 24 Jun 2026 00:40:32 +0300 Subject: [PATCH] OCCT Update to 8.0 Part 1 --- .../Serialization/schema/Serialization.cpp | 66 +++++++++---------- src/ifcgeom/kernels/opencascade/IfcGeomTree.h | 4 +- .../OpenCascadeConversionResult.cpp | 8 +-- .../kernels/opencascade/base_utils.cpp | 41 ++++++------ src/ifcgeom/kernels/opencascade/base_utils.h | 18 ++--- .../kernels/opencascade/boolean_utils.cpp | 29 ++++---- .../kernels/opencascade/boolean_utils.h | 10 +-- .../kernels/opencascade/bspline_surface.cpp | 16 ++--- src/ifcgeom/kernels/opencascade/face.cpp | 28 ++++---- src/ifcgeom/kernels/opencascade/layerset.cpp | 12 ++-- src/ifcgeom/kernels/opencascade/layerset.h | 6 +- src/ifcgeom/kernels/opencascade/loft.cpp | 2 +- src/ifcgeom/kernels/opencascade/loop.cpp | 16 ++--- .../kernels/opencascade/sweep_along_curve.cpp | 4 +- .../kernels/opencascade/sweep_utils.cpp | 16 ++--- .../kernels/opencascade/wire_builder.cpp | 17 ++--- .../kernels/opencascade/wire_builder.h | 4 +- .../kernels/opencascade/wire_utils.cpp | 28 ++++---- src/ifcgeom/kernels/opencascade/wire_utils.h | 8 +-- src/serializers/SvgSerializer.cpp | 8 +-- 20 files changed, 171 insertions(+), 170 deletions(-) diff --git a/src/ifcgeom/Serialization/schema/Serialization.cpp b/src/ifcgeom/Serialization/schema/Serialization.cpp index 96ff0c86b5..7dc8dd2d13 100644 --- a/src/ifcgeom/Serialization/schema/Serialization.cpp +++ b/src/ifcgeom/Serialization/schema/Serialization.cpp @@ -110,16 +110,16 @@ namespace { #endif template <> -int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool advanced) { +int convert_to_ifc(const opencascade::handle& c, IfcSchema::IfcCurve*& curve, bool advanced) { if (c->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { - Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast(c); - const Handle_Geom_Curve basis = trim->BasisCurve(); + opencascade::handle trim = opencascade::handle::DownCast(c); + const opencascade::handle basis = trim->BasisCurve(); return convert_to_ifc(basis, curve, advanced); } else if (c->DynamicType() == STANDARD_TYPE(Geom_Line)) { IfcSchema::IfcDirection* d; IfcSchema::IfcCartesianPoint* p; - Handle_Geom_Line line = Handle_Geom_Line::DownCast(c); + opencascade::handle line = opencascade::handle::DownCast(c); if (!convert_to_ifc(line->Position().Location(), p, advanced)) { return 0; @@ -135,7 +135,7 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool } else if (c->DynamicType() == STANDARD_TYPE(Geom_Circle)) { IfcSchema::IfcAxis2Placement3D* ax; - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(c); + opencascade::handle circle = opencascade::handle::DownCast(c); convert_to_ifc(circle->Position(), ax, advanced); curve = new IfcSchema::IfcCircle(ax, circle->Radius()); @@ -144,16 +144,16 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool } else if (c->DynamicType() == STANDARD_TYPE(Geom_Ellipse)) { IfcSchema::IfcAxis2Placement3D* ax; - Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(c); + opencascade::handle ellipse = opencascade::handle::DownCast(c); convert_to_ifc(ellipse->Position(), ax, advanced); curve = new IfcSchema::IfcEllipse(ax, ellipse->MajorRadius(), ellipse->MinorRadius()); - + return 1; } #ifdef SCHEMA_HAS_IfcRationalBSplineSurfaceWithKnots else if (c->DynamicType() == STANDARD_TYPE(Geom_BezierCurve)) { - Handle_Geom_BezierCurve bezier = Handle_Geom_BezierCurve::DownCast(c); + opencascade::handle bezier = opencascade::handle::DownCast(c); std::vector mults; std::vector knots; @@ -162,7 +162,7 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool IfcSchema::IfcKnotType::Value knot_spec = IfcSchema::IfcKnotType::IfcKnotType_QUASI_UNIFORM_KNOTS; IfcSchema::IfcCartesianPoint::list::ptr points(new IfcSchema::IfcCartesianPoint::list); - TColgp_Array1OfPnt poles(1, bezier->NbPoles()); + NCollection_Array1 poles(1, bezier->NbPoles()); bezier->Poles(poles); for (int i = 1; i <= bezier->NbPoles(); ++i) { IfcSchema::IfcCartesianPoint* p; @@ -180,7 +180,7 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool knots.push_back((double) i - 1); } - TColStd_Array1OfReal bspline_weights(1, bezier->NbPoles()); + NCollection_Array1 bspline_weights(1, bezier->NbPoles()); bezier->Weights(bspline_weights); opencascade_array_to_vector(bspline_weights, weights); @@ -199,10 +199,10 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool return 1; } else if (c->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) { - Handle_Geom_BSplineCurve bspline = Handle_Geom_BSplineCurve::DownCast(c); + opencascade::handle bspline = opencascade::handle::DownCast(c); IfcSchema::IfcCartesianPoint::list::ptr points(new IfcSchema::IfcCartesianPoint::list); - TColgp_Array1OfPnt poles(1, bspline->NbPoles()); + NCollection_Array1 poles(1, bspline->NbPoles()); bspline->Poles(poles); for (int i = 1; i <= bspline->NbPoles(); ++i) { IfcSchema::IfcCartesianPoint* p; @@ -217,9 +217,9 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool std::vector knots; std::vector weights; - TColStd_Array1OfInteger bspline_mults(1, bspline->NbKnots()); - TColStd_Array1OfReal bspline_knots(1, bspline->NbKnots()); - TColStd_Array1OfReal bspline_weights(1, bspline->NbPoles()); + NCollection_Array1 bspline_mults(1, bspline->NbKnots()); + NCollection_Array1 bspline_knots(1, bspline->NbKnots()); + NCollection_Array1 bspline_weights(1, bspline->NbPoles()); bspline->Multiplicities(bspline_mults); bspline->Knots(bspline_knots); @@ -278,9 +278,9 @@ int convert_to_ifc(const Handle_Geom_Curve& c, IfcSchema::IfcCurve*& curve, bool } template <> -int convert_to_ifc(const Handle_Geom_Surface& s, IfcSchema::IfcSurface*& surface, bool advanced) { +int convert_to_ifc(const opencascade::handle& s, IfcSchema::IfcSurface*& surface, bool advanced) { if (s->DynamicType() == STANDARD_TYPE(Geom_Plane)) { - Handle_Geom_Plane plane = Handle_Geom_Plane::DownCast(s); + opencascade::handle plane = opencascade::handle::DownCast(s); IfcSchema::IfcAxis2Placement3D* place; /// @todo: Note that the Ax3 is converted to an Ax2 here if (!convert_to_ifc(plane->Position().Ax2(), place, advanced)) { @@ -291,7 +291,7 @@ int convert_to_ifc(const Handle_Geom_Surface& s, IfcSchema::IfcSurface*& surface } #ifdef SCHEMA_HAS_IfcRationalBSplineSurfaceWithKnots else if (s->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) { - Handle_Geom_CylindricalSurface cyl = Handle_Geom_CylindricalSurface::DownCast(s); + opencascade::handle cyl = opencascade::handle::DownCast(s); IfcSchema::IfcAxis2Placement3D* place; /// @todo: Note that the Ax3 is converted to an Ax2 here if (!convert_to_ifc(cyl->Position().Ax2(), place, advanced)) { @@ -302,10 +302,10 @@ int convert_to_ifc(const Handle_Geom_Surface& s, IfcSchema::IfcSurface*& surface } else if (s->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface)) { typedef aggregate_of_aggregate_of points_t; - Handle_Geom_BSplineSurface bspline = Handle_Geom_BSplineSurface::DownCast(s); + opencascade::handle bspline = opencascade::handle::DownCast(s); points_t::ptr points(new points_t); - TColgp_Array2OfPnt poles(1, bspline->NbUPoles(), 1, bspline->NbVPoles()); + NCollection_Array2 poles(1, bspline->NbUPoles(), 1, bspline->NbVPoles()); bspline->Poles(poles); for (int i = 1; i <= bspline->NbUPoles(); ++i) { std::vector ps; @@ -333,11 +333,11 @@ int convert_to_ifc(const Handle_Geom_Surface& s, IfcSchema::IfcSurface*& surface std::vector vknots; std::vector< std::vector > weights; - TColStd_Array1OfInteger bspline_umults(1, bspline->NbUKnots()); - TColStd_Array1OfInteger bspline_vmults(1, bspline->NbVKnots()); - TColStd_Array1OfReal bspline_uknots(1, bspline->NbUKnots()); - TColStd_Array1OfReal bspline_vknots(1, bspline->NbVKnots()); - TColStd_Array2OfReal bspline_weights(1, bspline->NbUPoles(), 1, bspline->NbVPoles()); + NCollection_Array1 bspline_umults(1, bspline->NbUKnots()); + NCollection_Array1 bspline_vmults(1, bspline->NbVKnots()); + NCollection_Array1 bspline_uknots(1, bspline->NbUKnots()); + NCollection_Array1 bspline_vknots(1, bspline->NbVKnots()); + NCollection_Array2 bspline_weights(1, bspline->NbUPoles(), 1, bspline->NbVPoles()); bspline->UMultiplicities(bspline_umults); bspline->VMultiplicities(bspline_vmults); @@ -405,7 +405,7 @@ int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcCurve*& c, bool advanced) double a, b; IfcSchema::IfcCurve* base; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, a, b); + opencascade::handle crv = BRep_Tool::Curve(e, a, b); if (!convert_to_ifc(crv, base, advanced)) { return 0; } @@ -436,7 +436,7 @@ int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcEdge*& edge, bool advance return 0; } - Handle_Geom_Curve crv = BRep_Tool::Curve(e, a, b); + opencascade::handle crv = BRep_Tool::Curve(e, a, b); if (crv.IsNull()) { return 0; @@ -460,13 +460,13 @@ int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcEdge*& edge, bool advance } namespace { - bool is_polygonal(const Handle_Geom_Curve& crv) { + bool is_polygonal(const opencascade::handle& crv) { if (crv->DynamicType() == STANDARD_TYPE(Geom_Line)) { return true; } else if (crv->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { - return is_polygonal(Handle_Geom_TrimmedCurve::DownCast(crv)->BasisCurve()); + return is_polygonal(opencascade::handle::DownCast(crv)->BasisCurve()); } else if (crv->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) { - auto bspl = Handle_Geom_BSplineCurve::DownCast(crv); + auto bspl = opencascade::handle::DownCast(crv); return bspl->NbPoles() == 2 && bspl->Degree() == 1; } else { return false; @@ -479,7 +479,7 @@ int convert_to_ifc(const TopoDS_Wire& wire, IfcSchema::IfcLoop*& loop, bool adva bool polygonal = true; for (TopExp_Explorer exp(wire, TopAbs_EDGE); exp.More(); exp.Next()) { double a, b; - Handle_Geom_Curve crv = BRep_Tool::Curve(TopoDS::Edge(exp.Current()), a, b); + opencascade::handle crv = BRep_Tool::Curve(TopoDS::Edge(exp.Current()), a, b); if (crv.IsNull()) { continue; } @@ -526,7 +526,7 @@ int convert_to_ifc(const TopoDS_Wire& wire, IfcSchema::IfcLoop*& loop, bool adva template <> int convert_to_ifc(const TopoDS_Face& f, IfcSchema::IfcFace*& face, bool advanced) { - Handle_Geom_Surface surf = BRep_Tool::Surface(f); + opencascade::handle surf = BRep_Tool::Surface(f); TopExp_Explorer exp(f, TopAbs_WIRE); IfcSchema::IfcFaceBound::list::ptr bounds(new IfcSchema::IfcFaceBound::list); int index = 0; @@ -723,7 +723,7 @@ IfcUtil::IfcBaseClass* POSTFIX_SCHEMA(tesselate)(const TopoDS_Shape& shape, doub IfcSchema::IfcCartesianPoint* cpnt = new IfcSchema::IfcCartesianPoint(xyz); vertices.push_back(cpnt); } - const Poly_Array1OfTriangle& triangles = tri->Triangles(); + const NCollection_Array1& triangles = tri->Triangles(); for (int i = 1; i <= triangles.Length(); ++i) { int n1, n2, n3; triangles(i).Get(n1, n2, n3); diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h index aa5ae456a4..d3337c4b13 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h +++ b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h @@ -1926,7 +1926,7 @@ namespace IfcGeom { BVH_Triangulation triangulation(builder); for (int i = 0; i < elem_verts.size(); i += 3) { - triangulation.Vertices.push_back(BVH_Vec3d(elem_verts[i], elem_verts[i + 1], elem_verts[i + 2])); + triangulation.Vertices.Append(BVH_Vec3d(elem_verts[i], elem_verts[i + 1], elem_verts[i + 2])); verts.push_back(gp_Pnt(elem_verts[i], elem_verts[i + 1], elem_verts[i + 2])); } @@ -1938,7 +1938,7 @@ namespace IfcGeom { gp_Vec dir2(v1_pnt, v3_pnt); gp_Vec cross_product = dir1.Crossed(dir2); if (cross_product.Magnitude() > Precision::Confusion()) { - triangulation.Elements.push_back(BVH_Vec4i( + triangulation.Elements.Append(BVH_Vec4i( elem_faces[i], elem_faces[i + 1], elem_faces[i + 2], original_tris_index )); original_tris_index++; diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp index 00de7fbbee..7540dafa48 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp @@ -109,7 +109,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr std::vector> triangle_indices; TopLoc_Location loc; - Handle_Poly_Triangulation tri = BRep_Tool::Triangulation(face, loc); + occ::handle tri = BRep_Tool::Triangulation(face, loc); if (tri.IsNull()) { Logger::Root().Message(Logger::LOG_ERROR, "GEO", 184, "Triangulation missing for face"); @@ -145,7 +145,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr normal = normal_direction; } } else { - Handle_Geom_Surface surf = BRep_Tool::Surface(face); + occ::handle surf = BRep_Tool::Surface(face); // Special case the normal at the poles of a spherical surface if (surf->DynamicType() == STANDARD_TYPE(Geom_SphericalSurface)) { if (fabs(fabs(uv.Y()) - M_PI / 2.) < 1.e-9) { @@ -165,7 +165,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr } } - const Poly_Array1OfTriangle& triangles = tri->Triangles(); + const NCollection_Array1& triangles = tri->Triangles(); for (int i = 1; i <= triangles.Length(); ++i) { int n1, n2, n3; if (face.Orientation() == TopAbs_REVERSED) @@ -634,7 +634,7 @@ namespace { coords.push_back(tri->Node(i).Transformed(loc).XYZ()); } - const Poly_Array1OfTriangle& triangles = tri->Triangles(); + const NCollection_Array1& triangles = tri->Triangles(); for (int i = 1; i <= triangles.Length(); ++i) { int n1, n2, n3; diff --git a/src/ifcgeom/kernels/opencascade/base_utils.cpp b/src/ifcgeom/kernels/opencascade/base_utils.cpp index eeeac6c7c6..3b0425c727 100644 --- a/src/ifcgeom/kernels/opencascade/base_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/base_utils.cpp @@ -108,7 +108,7 @@ bool IfcGeom::util::is_manifold(const TopoDS_Shape& a) { } return true; } else { - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap map; TopExp::MapShapesAndAncestors(a, TopAbs_EDGE, TopAbs_FACE, map); for (int i = 1; i <= map.Extent(); ++i) { @@ -199,17 +199,17 @@ gp_Trsf IfcGeom::util::combine_offset_and_rotation(const gp_Vec & offset, const } -bool IfcGeom::util::project(const Handle_Geom_Surface& srf, const TopoDS_Shape& shp, double& u1, double& v1, double& u2, double& v2, double widen) { +bool IfcGeom::util::project(const opencascade::handle& srf, const TopoDS_Shape& shp, double& u1, double& v1, double& u2, double& v2, double widen) { // @todo std::unique_ptr for C++11 ShapeAnalysis_Surface* sas = 0; - Handle(Geom_Plane) pln; + opencascade::handle pln; if (srf->DynamicType() == STANDARD_TYPE(Geom_Plane)) { // Optimize projection for specific cases - pln = Handle(Geom_Plane)::DownCast(srf); - } else if (srf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface) && Handle(Geom_OffsetSurface)::DownCast(srf)->BasisSurface()->DynamicType() == STANDARD_TYPE(Geom_Plane)) { + pln = opencascade::handle::DownCast(srf); + } else if (srf->DynamicType() == STANDARD_TYPE(Geom_OffsetSurface) && opencascade::handle::DownCast(srf)->BasisSurface()->DynamicType() == STANDARD_TYPE(Geom_Plane)) { // For an offset planar surface the projected UV coords are the same as the basis surface - pln = Handle(Geom_Plane)::DownCast(Handle(Geom_OffsetSurface)::DownCast(srf)->BasisSurface()); + pln = opencascade::handle::DownCast(opencascade::handle::DownCast(srf)->BasisSurface()); } else { sas = new ShapeAnalysis_Surface(srf); } @@ -246,7 +246,7 @@ bool IfcGeom::util::project(const Handle_Geom_Surface& srf, const TopoDS_Shape& const TopoDS_Edge& e = TopoDS::Edge(exp.Current()); double a, b; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, a, b); + opencascade::handle crv = BRep_Tool::Curve(e, a, b); gp_Pnt p; crv->D0((a + b) / 2., p); @@ -449,24 +449,25 @@ bool IfcGeom::util::fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, } -const Handle_Geom_Curve IfcGeom::util::intersect(const Handle_Geom_Surface& a, const Handle_Geom_Surface& b) { +const opencascade::handle IfcGeom::util::intersect(const opencascade::handle& a, const opencascade::handle& b) { GeomAPI_IntSS x(a, b, 1.e-7); if (x.IsDone() && x.NbLines() == 1) { return x.Line(1); } else { - return Handle_Geom_Curve(); + return opencascade::handle(); + } } -const Handle_Geom_Curve IfcGeom::util::intersect(const Handle_Geom_Surface& a, const TopoDS_Face& b) { +const opencascade::handle IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Face& b) { return intersect(a, BRep_Tool::Surface(b)); } -const Handle_Geom_Curve IfcGeom::util::intersect(const TopoDS_Face& a, const Handle_Geom_Surface& b) { +const opencascade::handle IfcGeom::util::intersect(const TopoDS_Face& a, const opencascade::handle& b) { return intersect(BRep_Tool::Surface(a), b); } -bool IfcGeom::util::intersect(const Handle_Geom_Curve& a, const Handle_Geom_Surface& b, gp_Pnt& p) { +bool IfcGeom::util::intersect(const opencascade::handle& a, const opencascade::handle& b, gp_Pnt& p) { GeomAPI_IntCS x(a, b); if (x.IsDone() && x.NbPoints() == 1) { p = x.Point(1); @@ -476,11 +477,11 @@ bool IfcGeom::util::intersect(const Handle_Geom_Curve& a, const Handle_Geom_Surf } } -bool IfcGeom::util::intersect(const Handle_Geom_Curve& a, const TopoDS_Face& b, gp_Pnt &c) { +bool IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Face& b, gp_Pnt &c) { return intersect(a, BRep_Tool::Surface(b), c); } -bool IfcGeom::util::intersect(const Handle_Geom_Curve& a, const TopoDS_Shape& b, std::vector& out) { +bool IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Shape& b, std::vector& out) { TopExp_Explorer exp(b, TopAbs_FACE); gp_Pnt p; for (; exp.More(); exp.Next()) { @@ -491,12 +492,12 @@ bool IfcGeom::util::intersect(const Handle_Geom_Curve& a, const TopoDS_Shape& b, return !out.empty(); } -bool IfcGeom::util::intersect(const Handle_Geom_Surface& a, const TopoDS_Shape& b, std::vector< std::pair >& out) { +bool IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Shape& b, std::vector< std::pair, opencascade::handle > >& out) { TopExp_Explorer exp(b, TopAbs_FACE); for (; exp.More(); exp.Next()) { const TopoDS_Face& f = TopoDS::Face(exp.Current()); - const Handle_Geom_Surface& s = BRep_Tool::Surface(f); - Handle_Geom_Curve crv = intersect(a, s); + const opencascade::handle& s = BRep_Tool::Surface(f); + opencascade::handle crv = intersect(a, s); if (!crv.IsNull()) { out.push_back(std::make_pair(s, crv)); } @@ -516,7 +517,7 @@ bool IfcGeom::util::closest(const gp_Pnt& a, const std::vector& b, gp_Pn return minimal_distance != std::numeric_limits::infinity(); } -bool IfcGeom::util::project(const Handle_Geom_Curve& crv, const gp_Pnt& pt, gp_Pnt& p, double& u, double& d) { +bool IfcGeom::util::project(const opencascade::handle& crv, const gp_Pnt& pt, gp_Pnt& p, double& u, double& d) { ShapeAnalysis_Curve sac; sac.Project(crv, pt, 1e-3, p, u, false); d = pt.Distance(p); @@ -647,7 +648,7 @@ bool IfcGeom::util::create_solid_from_faces(const TopTools_ListOfShape& face_lis TopTools_ListIteratorOfListOfShape face_iterator; bool has_shared_edges = false; - TopTools_MapOfShape edge_set; + NCollection_Map edge_set; // In case there are wire intersections or failures in non-planar wire triangulations // the idea is to let occt do an exhaustive search of edge partners. But we have not @@ -875,7 +876,7 @@ bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) { std::function dump; dump = [&ana, &str, &dump, &any_emitted](const TopoDS_Shape& s) { if (!ana.Result(s).IsNull()) { - BRepCheck_ListIteratorOfListOfStatus itl; + NCollection_List::Iterator itl; itl.Initialize(ana.Result(s)->Status()); for (; itl.More(); itl.Next()) { if (itl.Value() != BRepCheck_NoError) { diff --git a/src/ifcgeom/kernels/opencascade/base_utils.h b/src/ifcgeom/kernels/opencascade/base_utils.h index f8f86fafaa..fc6212d5b0 100644 --- a/src/ifcgeom/kernels/opencascade/base_utils.h +++ b/src/ifcgeom/kernels/opencascade/base_utils.h @@ -58,16 +58,16 @@ namespace IfcGeom { IFC_GEOMLIBRARY_API gp_Pnt point_above_plane(const gp_Pln& pln, bool agree = true); IFC_GEOMLIBRARY_API bool fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, TopoDS_Shape& box, double& height, double tol); - IFC_GEOMLIBRARY_API const Handle_Geom_Curve intersect(const Handle_Geom_Surface&, const Handle_Geom_Surface&); - IFC_GEOMLIBRARY_API const Handle_Geom_Curve intersect(const Handle_Geom_Surface&, const TopoDS_Face&); - IFC_GEOMLIBRARY_API const Handle_Geom_Curve intersect(const TopoDS_Face&, const Handle_Geom_Surface&); - IFC_GEOMLIBRARY_API bool intersect(const Handle_Geom_Curve&, const Handle_Geom_Surface&, gp_Pnt&); - IFC_GEOMLIBRARY_API bool intersect(const Handle_Geom_Curve&, const TopoDS_Face&, gp_Pnt&); - IFC_GEOMLIBRARY_API bool intersect(const Handle_Geom_Curve&, const TopoDS_Shape&, std::vector&); - IFC_GEOMLIBRARY_API bool intersect(const Handle_Geom_Surface&, const TopoDS_Shape&, std::vector< std::pair >&); + IFC_GEOMLIBRARY_API const opencascade::handle intersect(const opencascade::handle&, const opencascade::handle&); + IFC_GEOMLIBRARY_API const opencascade::handle intersect(const opencascade::handle&, const TopoDS_Face&); + IFC_GEOMLIBRARY_API const opencascade::handle intersect(const TopoDS_Face&, const opencascade::handle&); + IFC_GEOMLIBRARY_API bool intersect(const opencascade::handle&, const opencascade::handle&, gp_Pnt&); + IFC_GEOMLIBRARY_API bool intersect(const opencascade::handle&, const TopoDS_Face&, gp_Pnt&); + IFC_GEOMLIBRARY_API bool intersect(const opencascade::handle&, const TopoDS_Shape&, std::vector&); + IFC_GEOMLIBRARY_API bool intersect(const opencascade::handle&, const TopoDS_Shape&, std::vector< std::pair, opencascade::handle > >&); IFC_GEOMLIBRARY_API bool closest(const gp_Pnt&, const std::vector&, gp_Pnt&); - IFC_GEOMLIBRARY_API bool project(const Handle_Geom_Curve&, const gp_Pnt&, gp_Pnt& p, double& u, double& d); - IFC_GEOMLIBRARY_API bool project(const Handle_Geom_Surface&, const TopoDS_Shape&, double& u1, double& v1, double& u2, double& v2, double widen = 0.1); + IFC_GEOMLIBRARY_API bool project(const opencascade::handle&, const gp_Pnt&, gp_Pnt& p, double& u, double& d); + IFC_GEOMLIBRARY_API bool project(const opencascade::handle&, const TopoDS_Shape&, double& u1, double& v1, double& u2, double& v2, double widen = 0.1); IFC_GEOMLIBRARY_API double shape_volume(const TopoDS_Shape& s); IFC_GEOMLIBRARY_API double face_area(const TopoDS_Face& f); diff --git a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp index f7eeb61d41..88d67e3795 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -230,7 +229,7 @@ double IfcGeom::util::min_face_face_distance(const TopoDS_Shape & a, double max_ return M; } -int IfcGeom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const TopTools_ListOfShape & b, TopTools_ListOfShape & c) { +int IfcGeom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const NCollection_List & b, NCollection_List & c) { int N = 0; Bnd_Box A; @@ -240,7 +239,7 @@ int IfcGeom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const return 0; } - TopTools_ListIteratorOfListOfShape it(b); + NCollection_List::Iterator it(b); for (; it.More(); it.Next()) { Bnd_Box B; BRepBndLib::Add(it.Value(), B); @@ -263,8 +262,8 @@ bool IfcGeom::util::get_edge_axis(const TopoDS_Edge & e, gp_Ax1 & ax) { double _, __; auto crv = BRep_Tool::Curve(e, _, __); - auto line = Handle_Geom_Line::DownCast(crv); - auto bsple = Handle_Geom_BSplineCurve::DownCast(crv); + auto line = opencascade::handle::DownCast(crv); + auto bsple = opencascade::handle::DownCast(crv); if (line) { ax = line->Position(); @@ -297,7 +296,7 @@ bool IfcGeom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape & s, TopoD // This assumes UnifySameDomain has been processed on s, so that // the extrusion top and bottom are a single face. - TopTools_IndexedDataMapOfShapeListOfShape mapping; + NCollection_IndexedDataMap mapping; TopExp::MapShapesAndAncestors(s, TopAbs_EDGE, TopAbs_FACE, mapping); TopExp::MapShapesAndAncestors(s, TopAbs_VERTEX, TopAbs_FACE, mapping); @@ -406,9 +405,9 @@ bool IfcGeom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape & s, TopoD return true; } -int IfcGeom::util::eliminate_narrow_operands(double prec, const TopTools_ListOfShape& bs, TopTools_ListOfShape & c) { +int IfcGeom::util::eliminate_narrow_operands(double prec, const NCollection_List& bs, NCollection_List & c) { int N = 0; - TopTools_ListIteratorOfListOfShape it(bs); + NCollection_List::Iterator it(bs); for (; it.More(); it.Next()) { Bnd_OBB box; @@ -430,7 +429,7 @@ int IfcGeom::util::eliminate_narrow_operands(double prec, const TopTools_ListOfS return N; } -int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & a, const TopTools_ListOfShape & bs, TopTools_ListOfShape & c) { +int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & a, const NCollection_List & bs, NCollection_List & c) { TopTools_IndexedMapOfShape a_faces; TopExp::MapShapes(a, TopAbs_FACE, a_faces); @@ -574,13 +573,13 @@ int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & return N; } -bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const TopTools_ListOfShape & b_input, TopoDS_Shape & result, double eps) { +bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const NCollection_List & b_input, TopoDS_Shape & result, double eps) { IfcGeom::impl::tree edge_tree; - TopTools_ListOfShape ab_input = b_input; + NCollection_List ab_input = b_input; ab_input.Prepend(a_input); - TopTools_ListIteratorOfListOfShape it(ab_input); + NCollection_List::Iterator it(ab_input); int shape_index = 0; int edge_index = 0; std::map edge_index_to_shape_index; @@ -833,7 +832,7 @@ bool IfcGeom::util::points_on_planar_face_generator::operator()(gp_Pnt& p) { } -bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a_input, const TopTools_ListOfShape& b_input, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { +bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a_input, const NCollection_List& b_input, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { using namespace std::string_literals; const bool do_unify = true; @@ -1193,7 +1192,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To std::function dump; dump = [&ana, &str, &dump, &any_emitted](const TopoDS_Shape& s) { if (!ana.Result(s).IsNull()) { - BRepCheck_ListIteratorOfListOfStatus itl; + NCollection_List::Iterator itl; itl.Initialize(ana.Result(s)->Status()); for (; itl.More(); itl.Next()) { if (itl.Value() != BRepCheck_NoError) { @@ -1234,7 +1233,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To bool operands_nonmanifold = false; if (op == BOPAlgo_CUT) { TopTools_IndexedMapOfShape edges; - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap map; for (TopTools_ListIteratorOfListOfShape it2(b); it2.More(); it2.Next()) { auto& bb = it2.Value(); TopExp::MapShapes(bb, TopAbs_EDGE, edges); diff --git a/src/ifcgeom/kernels/opencascade/boolean_utils.h b/src/ifcgeom/kernels/opencascade/boolean_utils.h index 80a9b49998..001d6595ed 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_utils.h +++ b/src/ifcgeom/kernels/opencascade/boolean_utils.h @@ -73,7 +73,7 @@ namespace IfcGeom { double min_face_face_distance(const TopoDS_Shape& a, double max_search); - int bounding_box_overlap(double p, const TopoDS_Shape& a, const TopTools_ListOfShape& b, TopTools_ListOfShape& c); + int bounding_box_overlap(double p, const TopoDS_Shape& a, const NCollection_List& b, NCollection_List& c); bool get_edge_axis(const TopoDS_Edge& e, gp_Ax1& ax); @@ -81,18 +81,18 @@ namespace IfcGeom { bool is_extrusion(const gp_Vec& v, const TopoDS_Shape& s, TopoDS_Face& base, std::pair& interval); - int eliminate_touching_operands(double prec, const TopoDS_Shape& a, const TopTools_ListOfShape& bs, TopTools_ListOfShape& c); + int eliminate_touching_operands(double prec, const TopoDS_Shape& a, const NCollection_List& bs, NCollection_List& c); - int eliminate_narrow_operands(double prec, const TopTools_ListOfShape& bs, TopTools_ListOfShape & c); + int eliminate_narrow_operands(double prec, const NCollection_List& bs, NCollection_List & c); - bool boolean_subtraction_2d_using_builder(const TopoDS_Shape& a_input, const TopTools_ListOfShape& b_input, TopoDS_Shape& result, double eps); + bool boolean_subtraction_2d_using_builder(const TopoDS_Shape& a_input, const NCollection_List& b_input, TopoDS_Shape& result, double eps); struct boolean_settings { bool debug, attempt_2d; double precision; }; - bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const TopTools_ListOfShape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.); + bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const NCollection_List&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.); bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const TopoDS_Shape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.); diff --git a/src/ifcgeom/kernels/opencascade/bspline_surface.cpp b/src/ifcgeom/kernels/opencascade/bspline_surface.cpp index 2f854268e7..b7da350f9d 100644 --- a/src/ifcgeom/kernels/opencascade/bspline_surface.cpp +++ b/src/ifcgeom/kernels/opencascade/bspline_surface.cpp @@ -9,14 +9,14 @@ using namespace IfcGeom; bool OpenCascadeKernel::convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf) { const bool is_rational = !!bs->weights; - TColgp_Array2OfPnt Poles(0, (int)bs->control_points.size() - 1, 0, (int)(*bs->control_points.begin()).size() - 1); - TColStd_Array2OfReal Weights(0, (int)bs->control_points.size() - 1, 0, (int)(*bs->control_points.begin()).size() - 1); - TColStd_Array1OfReal UKnots(0, (int)bs->knots[0].size() - 1); - TColStd_Array1OfReal VKnots(0, (int)bs->knots[1].size() - 1); - TColStd_Array1OfInteger UMults(0, (int)bs->multiplicities[0].size() - 1); - TColStd_Array1OfInteger VMults(0, (int)bs->multiplicities[1].size() - 1); - Standard_Integer UDegree = bs->degree[0]; - Standard_Integer VDegree = bs->degree[1]; + NCollection_Array2 Poles(0, (int)bs->control_points.size() - 1, 0, (int)(*bs->control_points.begin()).size() - 1); + NCollection_Array2 Weights(0, (int)bs->control_points.size() - 1, 0, (int)(*bs->control_points.begin()).size() - 1); + NCollection_Array1 UKnots(0, (int)bs->knots[0].size() - 1); + NCollection_Array1 VKnots(0, (int)bs->knots[1].size() - 1); + NCollection_Array1 UMults(0, (int)bs->multiplicities[0].size() - 1); + NCollection_Array1 VMults(0, (int)bs->multiplicities[1].size() - 1); + int UDegree = bs->degree[0]; + int VDegree = bs->degree[1]; int i = 0, j; for (auto it = bs->control_points.begin(); it != bs->control_points.end(); ++it, ++i) { diff --git a/src/ifcgeom/kernels/opencascade/face.cpp b/src/ifcgeom/kernels/opencascade/face.cpp index 6f52c03561..d4b41b5851 100644 --- a/src/ifcgeom/kernels/opencascade/face.cpp +++ b/src/ifcgeom/kernels/opencascade/face.cpp @@ -79,13 +79,13 @@ namespace { auto& umults = bs->multiplicities[0]; auto& vmults = bs->multiplicities[1]; - TColgp_Array2OfPnt Poles(0, (int)cps.size() - 1, 0, (int)cps[0].size() - 1); - TColStd_Array1OfReal UKnots(0, (int)uknots.size() - 1); - TColStd_Array1OfReal VKnots(0, (int)vknots.size() - 1); - TColStd_Array1OfInteger UMults(0, (int)umults.size() - 1); - TColStd_Array1OfInteger VMults(0, (int)vmults.size() - 1); - Standard_Integer UDegree = bs->degree[0]; - Standard_Integer VDegree = bs->degree[1]; + NCollection_Array2 Poles(0, (int)cps.size() - 1, 0, (int)cps[0].size() - 1); + NCollection_Array1 UKnots(0, (int)uknots.size() - 1); + NCollection_Array1 VKnots(0, (int)vknots.size() - 1); + NCollection_Array1 UMults(0, (int)umults.size() - 1); + NCollection_Array1 VMults(0, (int)vmults.size() - 1); + int UDegree = bs->degree[0]; + int VDegree = bs->degree[1]; int i = 0, j; for (auto it = cps.begin(); it != cps.end(); ++it, ++i) { @@ -449,9 +449,9 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re sfs.SetMsgRegistrator(msg); sfs.Perform(); - ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg jt(msg->MapShape()); + NCollection_DataMap, TopTools_ShapeMapHasher>::Iterator jt(msg->MapShape()); for (; jt.More(); jt.Next()) { - Message_ListIteratorOfListOfMsg kt(jt.Value()); + NCollection_List::Iterator kt(jt.Value()); for (; kt.More(); kt.Next()) { char* c = new char[kt.Value().Original().LengthOfCString() + 1]; kt.Value().Original().ToUTF8CString(c); @@ -510,9 +510,9 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re sfs.Perform(); it.Value() = sfs.Shape(); - ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg jt(msg->MapShape()); + NCollection_DataMap, TopTools_ShapeMapHasher>::Iterator jt(msg->MapShape()); for (; jt.More(); jt.Next()) { - Message_ListIteratorOfListOfMsg kt(jt.Value()); + NCollection_List::Iterator kt(jt.Value()); for (; kt.More(); kt.Next()) { char* c = new char[kt.Value().Original().LengthOfCString() + 1]; kt.Value().Original().ToUTF8CString(c); @@ -537,7 +537,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re const TopoDS_Face& occ_face = TopoDS::Face(it.Value()); ShapeFix_Face sfs(TopoDS::Face(occ_face)); - TopTools_DataMapOfShapeListOfShape wire_map; + NCollection_DataMap, TopTools_ShapeMapHasher> wire_map; sfs.FixOrientation(wire_map); TopoDS_Iterator jt(occ_face, false); @@ -546,8 +546,8 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re // tfk: @todo if wire_map contains w, I would assume wire_senses also contains w, // this is not the case in github issue #405. if (wire_map.IsBound(w) && wire_senses.IsBound(w)) { - const TopTools_ListOfShape& shapes = wire_map.Find(w); - TopTools_ListIteratorOfListOfShape kt(shapes); + const NCollection_List& shapes = wire_map.Find(w); + NCollection_List::Iterator kt(shapes); for (; kt.More(); kt.Next()) { // Apparently the wire got reversed, so register it with opposite orientation in the map wire_senses.Bind(kt.Value(), wire_senses.Find(w) == TopAbs_FORWARD ? TopAbs_REVERSED : TopAbs_FORWARD); diff --git a/src/ifcgeom/kernels/opencascade/layerset.cpp b/src/ifcgeom/kernels/opencascade/layerset.cpp index c1abe45817..4e9fa1918d 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.cpp +++ b/src/ifcgeom/kernels/opencascade/layerset.cpp @@ -164,12 +164,12 @@ namespace { } -bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const std::vector< std::vector >& surfaces, const std::vector& styles, ConversionResults& result, double tol) { +bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const std::vector< std::vector>>& surfaces, const std::vector& styles, ConversionResults& result, double tol) { Bnd_Box bb; TopoDS_Shape input; flatten_shape_list(items, input, false, false, tol); - typedef std::vector< std::vector > folded_surfaces_t; + typedef std::vector< std::vector> > folded_surfaces_t; typedef std::vector< std::pair< TopoDS_Face, std::pair > > faces_with_mass_t; TopTools_ListOfShape shells; @@ -178,7 +178,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const if (it->empty()) { continue; } else if (it->size() == 1) { - const Handle_Geom_Surface& surface = (*it)[0]; + const occ::handle& surface = (*it)[0]; double u1, v1, u2, v2; if (!project(surface, input, u1, v1, u2, v2)) { continue; @@ -187,7 +187,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const } else { faces_with_mass_t solids; for (folded_surfaces_t::value_type::const_iterator jt = it->begin(); jt != it->end(); ++jt) { - const Handle_Geom_Surface& surface = *jt; + const occ::handle& surface = *jt; double u1, v1, u2, v2; if (!project(surface, input, u1, v1, u2, v2)) { continue; @@ -281,7 +281,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const } -bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector& surfaces, const std::vector& styles, ConversionResults& result, double tol) { +bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector>& surfaces, const std::vector& styles, ConversionResults& result, double tol) { if (surfaces.size() < 3) { return false; @@ -370,7 +370,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve } -bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const Handle_Geom_Surface& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) { +bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const occ::handle& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) { // Use an unbounded surface, that isolate part of the input shape, // to split this shape into two parts. Make sure that the addition // of the two result volumes matches that of the input. diff --git a/src/ifcgeom/kernels/opencascade/layerset.h b/src/ifcgeom/kernels/opencascade/layerset.h index 4d51cb8ffe..bbf72eba3b 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.h +++ b/src/ifcgeom/kernels/opencascade/layerset.h @@ -11,11 +11,11 @@ namespace IfcGeom { namespace util { - bool apply_layerset(const ConversionResults&, const std::vector&, const std::vector&, ConversionResults&, double tol); + bool apply_layerset(const ConversionResults&, const std::vector>&, const std::vector&, ConversionResults&, double tol); - bool apply_folded_layerset(const ConversionResults&, const std::vector< std::vector >&, const std::vector&, ConversionResults&, double tol); + bool apply_folded_layerset(const ConversionResults&, const std::vector>>&, const std::vector&, ConversionResults&, double tol); - bool split_solid_by_surface(const TopoDS_Shape&, const Handle_Geom_Surface&, TopoDS_Shape&, TopoDS_Shape&, double tol); + bool split_solid_by_surface(const TopoDS_Shape&, const occ::handle&, TopoDS_Shape&, TopoDS_Shape&, double tol); bool split_solid_by_shell(const TopoDS_Shape&, const TopoDS_Shape& s, TopoDS_Shape&, TopoDS_Shape&, double tol); } diff --git a/src/ifcgeom/kernels/opencascade/loft.cpp b/src/ifcgeom/kernels/opencascade/loft.cpp index 19d62e1aa2..e7226c59ec 100644 --- a/src/ifcgeom/kernels/opencascade/loft.cpp +++ b/src/ifcgeom/kernels/opencascade/loft.cpp @@ -307,7 +307,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re all_tags.begin() + std::distance(shps.begin(), jt)}; for (size_t i = 0; i < 2; ++i) { - TopTools_IndexedDataMapOfShapeListOfShape ancestors; + NCollection_IndexedDataMap ancestors; const auto& wire = wp[i]; auto& result = profile_points[i]; diff --git a/src/ifcgeom/kernels/opencascade/loop.cpp b/src/ifcgeom/kernels/opencascade/loop.cpp index 4329dec3d9..8cda46b644 100644 --- a/src/ifcgeom/kernels/opencascade/loop.cpp +++ b/src/ifcgeom/kernels/opencascade/loop.cpp @@ -39,12 +39,12 @@ namespace { const bool is_rational = !!bc->weights; - TColgp_Array1OfPnt Poles(0, bc->control_points.size() - 1); - TColStd_Array1OfReal Weights(0, bc->control_points.size() - 1); - TColStd_Array1OfReal Knots(0, (int)bc->knots.size() - 1); - TColStd_Array1OfInteger Mults(0, (int)bc->knots.size() - 1); - Standard_Integer Degree = bc->degree; - Standard_Boolean Periodic = false; + NCollection_Array1 Poles(0, bc->control_points.size() - 1); + NCollection_Array1 Weights(0, bc->control_points.size() - 1); + NCollection_Array1 Knots(0, (int)bc->knots.size() - 1); + NCollection_Array1 Mults(0, (int)bc->knots.size() - 1); + int Degree = bc->degree; + bool Periodic = false; // @tfk: it appears to be wrong to expect a period curve when the curve is closed, see #586 // Standard_Boolean Periodic = l->ClosedCurve(); @@ -287,10 +287,10 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir shape_pair_enumerate(it, bld, force_close); wire = bld.wire(); - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap, TopTools_ShapeMapHasher> map; TopExp::MapShapesAndAncestors(wire, TopAbs_VERTEX, TopAbs_EDGE, map); - TopTools_IndexedMapOfShape edges_to_tesselate; + NCollection_IndexedMap edges_to_tesselate; for (int i = 1; i <= map.Extent(); ++i) { auto& edges = map.FindFromIndex(i); diff --git a/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp b/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp index 4e10ffc14b..208d18755e 100644 --- a/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp +++ b/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp @@ -40,7 +40,7 @@ namespace { bool wire_is_c1_continuous(const TopoDS_Wire& w, double tol) { // NB Note that c0 continuity is NOT checked! - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap map; TopExp::MapShapesAndAncestors(w, TopAbs_VERTEX, TopAbs_EDGE, map); for (int i = 1; i <= map.Extent(); ++i) { const auto& li = map.FindFromIndex(i); @@ -188,7 +188,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo { TopoDS_Vertex v0, v1; TopExp::Vertices(wire, v0, v1); - TopTools_IndexedDataMapOfShapeListOfShape m; + NCollection_IndexedDataMap m; TopExp::MapShapesAndAncestors(wire, TopAbs_VERTEX, TopAbs_EDGE, m); const TopoDS_Edge& edge = TopoDS::Edge(m.FindFromKey(v0).First()); double u0, u1; diff --git a/src/ifcgeom/kernels/opencascade/sweep_utils.cpp b/src/ifcgeom/kernels/opencascade/sweep_utils.cpp index 4c96516479..5280895b5d 100644 --- a/src/ifcgeom/kernels/opencascade/sweep_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/sweep_utils.cpp @@ -27,7 +27,7 @@ bool IfcGeom::util::wire_is_c1_continuous(const TopoDS_Wire & w, double tol) { // NB Note that c0 continuity is NOT checked! - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap map; TopExp::MapShapesAndAncestors(w, TopAbs_VERTEX, TopAbs_EDGE, map); for (int i = 1; i <= map.Extent(); ++i) { const auto& li = map.FindFromIndex(i); @@ -66,7 +66,7 @@ bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) { // Find first edge TopoDS_Vertex v0, v1; TopExp::Vertices(wire, v0, v1); - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap map; TopExp::MapShapesAndAncestors(wire, TopAbs_VERTEX, TopAbs_EDGE, map); if (v0.IsSame(v1) && map.Contains(v0) && map.FindFromKey(v0).Extent() == 2) { // Closed wire, with more than 1 edges @@ -117,7 +117,7 @@ bool IfcGeom::util::is_single_linear_edge(const TopoDS_Wire & wire) { return false; } double u, v; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, u, v); + occ::handle crv = BRep_Tool::Curve(e, u, v); return crv->DynamicType() == STANDARD_TYPE(Geom_Line); } @@ -132,7 +132,7 @@ bool IfcGeom::util::is_single_circular_edge(const TopoDS_Wire & wire) { return false; } double u, v; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, u, v); + occ::handle crv = BRep_Tool::Curve(e, u, v); return crv->DynamicType() == STANDARD_TYPE(Geom_Circle); } @@ -140,7 +140,7 @@ void IfcGeom::util::process_sweep_as_extrusion(const TopoDS_Wire & wire, const T TopExp_Explorer exp(wire, TopAbs_EDGE); TopoDS_Edge e = TopoDS::Edge(exp.Current()); double u, v; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, u, v); + occ::handle crv = BRep_Tool::Curve(e, u, v); const auto& dir = Handle(Geom_Line)::DownCast(crv)->Position().Direction(); // OCCT line is normalized so diff in parametric coords equals length const double depth = std::abs(u - v); @@ -153,7 +153,7 @@ void IfcGeom::util::process_sweep_as_revolution(const TopoDS_Wire & wire, const TopExp_Explorer exp(wire, TopAbs_EDGE); TopoDS_Edge e = TopoDS::Edge(exp.Current()); double u, v; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, u, v); + occ::handle crv = BRep_Tool::Curve(e, u, v); auto circ = Handle(Geom_Circle)::DownCast(crv); // @todo we could be extruding the wire only when we know this is an intermediate edge. const double depth = std::abs(u - v); @@ -182,7 +182,7 @@ void IfcGeom::util::process_sweep_as_pipe(const TopoDS_Wire & wire, const TopoDS } void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector& sorted_edges) { - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap map; TopExp::MapShapesAndAncestors(wire, TopAbs_VERTEX, TopAbs_EDGE, map); for (int i = 1; i <= map.Extent(); ++i) { @@ -269,7 +269,7 @@ void IfcGeom::util::segment_adjacent_non_linear(const TopoDS_Wire & wire, std::v for (int i = 0; i < (int)sorted_edges.size() - 1; ++i) { const auto& e = sorted_edges[i]; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, u, v); + occ::handle crv = BRep_Tool::Curve(e, u, v); const bool is_linear = crv->DynamicType() == STANDARD_TYPE(Geom_Line); const auto& f = sorted_edges[i + 1]; diff --git a/src/ifcgeom/kernels/opencascade/wire_builder.cpp b/src/ifcgeom/kernels/opencascade/wire_builder.cpp index 29d6e5b3ef..ebb023530d 100644 --- a/src/ifcgeom/kernels/opencascade/wire_builder.cpp +++ b/src/ifcgeom/kernels/opencascade/wire_builder.cpp @@ -18,20 +18,21 @@ TopoDS_Edge IfcGeom::util::first_edge(const TopoDS_Wire & w) { TopoDS_Vertex v1, v2; TopExp::Vertices(w, v1, v2); - TopTools_IndexedDataMapOfShapeListOfShape wm; + NCollection_IndexedDataMap, TopTools_ShapeMapHasher> wm; TopExp::MapShapesAndAncestors(w, TopAbs_VERTEX, TopAbs_EDGE, wm); return TopoDS::Edge(wm.FindFromKey(v1).First()); } // Returns new wire with the edge replaced by a linear edge with the vertex v moved to p TopoDS_Wire IfcGeom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v, const gp_Pnt & p) { - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap, TopTools_ShapeMapHasher> map; TopExp::MapShapesAndAncestors(w, TopAbs_VERTEX, TopAbs_EDGE, map); bool all_linear = true, single_circle = false, first = true; - const TopTools_ListOfShape& edges = map.FindFromKey(v); - TopTools_ListIteratorOfListOfShape it(edges); + const NCollection_List& edges = map.FindFromKey(v); + + NCollection_List::Iterator it(edges); for (; it.More(); it.Next()) { const TopoDS_Edge& e = TopoDS::Edge(it.Value()); double _, __; @@ -81,7 +82,7 @@ double IfcGeom::util::deflection_for_approximating_circle(double radius, double return -radius * std::cos(1. / 2. * param) * std::cos(param) - radius * std::sin(1. / 2. * param) * std::sin(param) + radius; } -bool IfcGeom::util::create_edge_over_curve_with_log_messages(const Handle_Geom_Curve & crv, const double eps, const gp_Pnt & p1, const gp_Pnt & p2, TopoDS_Edge & result) { +bool IfcGeom::util::create_edge_over_curve_with_log_messages(const opencascade::handle& crv, const double eps, const gp_Pnt& p1, const gp_Pnt& p2, TopoDS_Edge& result) { if (crv->IsClosed() && p1.Distance(p2) <= eps) { BRepBuilderAPI_MakeEdge me(crv); if (me.IsDone()) { @@ -176,14 +177,14 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS } { - TopTools_IndexedDataMapOfShapeListOfShape wmap1, wmap2; + NCollection_IndexedDataMap, TopTools_ShapeMapHasher> wmap1, wmap2; // Find edges connected to end- and begin vertex TopExp::MapShapesAndAncestors(w1, TopAbs_VERTEX, TopAbs_EDGE, wmap1); TopExp::MapShapesAndAncestors(w2, TopAbs_VERTEX, TopAbs_EDGE, wmap2); - const TopTools_ListOfShape& last_edges = wmap1.FindFromKey(w12); - const TopTools_ListOfShape& first_edges = wmap2.FindFromKey(w21); + const NCollection_List& last_edges = wmap1.FindFromKey(w12); + const NCollection_List& first_edges = wmap2.FindFromKey(w21); double _, __; if (last_edges.Extent() == 1 && first_edges.Extent() == 1) { diff --git a/src/ifcgeom/kernels/opencascade/wire_builder.h b/src/ifcgeom/kernels/opencascade/wire_builder.h index 34178b815d..a518834bf5 100644 --- a/src/ifcgeom/kernels/opencascade/wire_builder.h +++ b/src/ifcgeom/kernels/opencascade/wire_builder.h @@ -59,7 +59,7 @@ namespace IfcGeom { }; template - void shape_pair_enumerate(TopTools_ListIteratorOfListOfShape& it, Fn& fn, bool closed) { + void shape_pair_enumerate(NCollection_List::Iterator& it, Fn& fn, bool closed) { bool is_first = true; TopoDS_Shape first, previous, current; for (; it.More(); it.Next(), is_first = false) { @@ -98,7 +98,7 @@ namespace IfcGeom { double deflection_for_approximating_circle(double radius, double param); - bool create_edge_over_curve_with_log_messages(const Handle_Geom_Curve& crv, const double eps, const gp_Pnt& p1, const gp_Pnt& p2, TopoDS_Edge& result); + bool create_edge_over_curve_with_log_messages(const opencascade::handle& crv, const double eps, const gp_Pnt& p1, const gp_Pnt& p2, TopoDS_Edge& result); } } diff --git a/src/ifcgeom/kernels/opencascade/wire_utils.cpp b/src/ifcgeom/kernels/opencascade/wire_utils.cpp index 5fb0c3d085..7bb67e7681 100644 --- a/src/ifcgeom/kernels/opencascade/wire_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/wire_utils.cpp @@ -125,7 +125,7 @@ bool IfcGeom::util::flatten_wire(TopoDS_Wire& wire, double eps) { return true; } -IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std::vector& wires, TopTools_ListOfShape& faces) { +IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std::vector& wires, NCollection_List& faces) { // This is a bit of a precarious approach, but seems to work for the // versions of OCCT tested for. OCCT has a Delaunay triangulation function // BRepMesh_Delaun, but it is notoriously hard to interpret the results @@ -210,11 +210,11 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std int n123[3]; TopLoc_Location loc; - Handle_Poly_Triangulation tri = BRep_Tool::Triangulation(face, loc); + opencascade::handle tri = BRep_Tool::Triangulation(face, loc); if (!tri.IsNull()) { - const Poly_Array1OfTriangle& triangles = tri->Triangles(); + const NCollection_Array1& triangles = tri->Triangles(); for (int i = 1; i <= triangles.Length(); ++i) { if (face.Orientation() == TopAbs_REVERSED) triangles(i).Get(n123[2], n123[1], n123[0]); @@ -283,7 +283,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std } } - TopTools_IndexedDataMapOfShapeListOfShape mape, mapn; + NCollection_IndexedDataMap mape, mapn; for (auto& wire : wires) { TopExp::MapShapesAndAncestors(wire, TopAbs_EDGE, TopAbs_WIRE, mape); } @@ -374,7 +374,7 @@ namespace { } } -bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, TopTools_ListOfShape& wires, const wire_tolerance_settings& settings) { +bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List& wires, const wire_tolerance_settings& settings) { double eps = get_wire_intersection_tolerance(settings, wire); double eps_real = settings.precision; @@ -508,7 +508,7 @@ bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, TopTools_ListOfS // Substitute with a new edge from/to the intersection point if (p1.Distance(p2) > eps_real * 2) { double _, __; - Handle_Geom_Curve crv = BRep_Tool::Curve(e, _, __); + opencascade::handle crv = BRep_Tool::Curve(e, _, __); BRepBuilderAPI_MakeEdge me(crv, p1, p2); TopoDS_Edge ed = me.Edge(); mw.Add(ed); @@ -557,9 +557,9 @@ bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, TopTools_ListOfS return intersected; } -void IfcGeom::util::select_largest(const TopTools_ListOfShape& shapes, TopoDS_Shape& largest) { +void IfcGeom::util::select_largest(const NCollection_List& shapes, TopoDS_Shape& largest) { double mass = 0.; - TopTools_ListIteratorOfListOfShape it(shapes); + NCollection_List::Iterator it(shapes); for (; it.More(); it.Next()) { /* // tfk: bounding box is more efficient probably @@ -601,7 +601,7 @@ bool IfcGeom::util::wire_to_sequence_of_point(const TopoDS_Wire& w, TColgp_Seque TopExp_Explorer exp(w, TopAbs_EDGE); for (; exp.More(); exp.Next()) { double a, b; - Handle_Geom_Curve crv = BRep_Tool::Curve(TopoDS::Edge(exp.Current()), a, b); + opencascade::handle crv = BRep_Tool::Curve(TopoDS::Edge(exp.Current()), a, b); if (crv->DynamicType() != STANDARD_TYPE(Geom_Line)) { return false; } @@ -697,7 +697,7 @@ namespace { return TopoDS_Vertex(); } - TopoDS_Edge find_next(const TopTools_IndexedMapOfShape& edge_set, const TopTools_IndexedDataMapOfShapeListOfShape& vertex_to_edges, const TopoDS_Vertex& current, const TopoDS_Edge& previous_edge) { + TopoDS_Edge find_next(const TopTools_IndexedMapOfShape& edge_set, const NCollection_IndexedDataMap& vertex_to_edges, const TopoDS_Vertex& current, const TopoDS_Edge& previous_edge) { const TopTools_ListOfShape& edges = vertex_to_edges.FindFromKey(current); TopTools_ListIteratorOfListOfShape eit; for (eit.Initialize(edges); eit.More(); eit.Next()) { @@ -716,10 +716,10 @@ bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape BRepOffsetAPI_Sewing sew; sew.Add(shape); - TopTools_IndexedDataMapOfShapeListOfShape edge_to_faces; - TopTools_IndexedDataMapOfShapeListOfShape vertex_to_edges; + NCollection_IndexedDataMap edge_to_faces; + NCollection_IndexedDataMap vertex_to_edges; std::set visited; - TopTools_IndexedMapOfShape edge_set; + NCollection_IndexedMap edge_set; TopExp::MapShapesAndAncestors(shape, TopAbs_EDGE, TopAbs_FACE, edge_to_faces); @@ -802,7 +802,7 @@ bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape } -bool IfcGeom::util::convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire) { +bool IfcGeom::util::convert_curve_to_wire(const opencascade::handle& curve, TopoDS_Wire& wire) { try { wire = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(curve)); return true; diff --git a/src/ifcgeom/kernels/opencascade/wire_utils.h b/src/ifcgeom/kernels/opencascade/wire_utils.h index 146734662b..fcf8f0a5dd 100644 --- a/src/ifcgeom/kernels/opencascade/wire_utils.h +++ b/src/ifcgeom/kernels/opencascade/wire_utils.h @@ -37,11 +37,11 @@ namespace IfcGeom { }; /// Triangulate the set of wires. The firstmost wire is assumed to be the outer wire. - IFC_GEOMLIBRARY_API triangulate_wire_result triangulate_wire(const std::vector& wires, TopTools_ListOfShape& faces); + IFC_GEOMLIBRARY_API triangulate_wire_result triangulate_wire(const std::vector& wires, NCollection_List& faces); - IFC_GEOMLIBRARY_API bool wire_intersections(const TopoDS_Wire& wire, TopTools_ListOfShape& wires, const wire_tolerance_settings& settings); + IFC_GEOMLIBRARY_API bool wire_intersections(const TopoDS_Wire& wire, NCollection_List& wires, const wire_tolerance_settings& settings); - IFC_GEOMLIBRARY_API void select_largest(const TopTools_ListOfShape& shapes, TopoDS_Shape& largest); + IFC_GEOMLIBRARY_API void select_largest(const NCollection_List& shapes, TopoDS_Shape& largest); IFC_GEOMLIBRARY_API bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face, const IfcGeom::util::wire_tolerance_settings& settings); @@ -55,7 +55,7 @@ namespace IfcGeom { IFC_GEOMLIBRARY_API bool wire_to_sequence_of_point(const TopoDS_Wire&, TColgp_SequenceOfPnt&); IFC_GEOMLIBRARY_API void sequence_of_point_to_wire(const TColgp_SequenceOfPnt&, TopoDS_Wire&, bool closed); - IFC_GEOMLIBRARY_API bool convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire); + IFC_GEOMLIBRARY_API bool convert_curve_to_wire(const opencascade::handle& curve, TopoDS_Wire& wire); } } diff --git a/src/serializers/SvgSerializer.cpp b/src/serializers/SvgSerializer.cpp index b870a3f825..56aba97859 100644 --- a/src/serializers/SvgSerializer.cpp +++ b/src/serializers/SvgSerializer.cpp @@ -134,7 +134,7 @@ void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, boos Handle(Geom2d_Curve) curve2d; if (curve.IsNull()) { TopLoc_Location loc; - Handle_Geom_Surface surf; + opencascade::handle surf; BRep_Tool::CurveOnSurface(edge, curve2d, surf, loc, u1, u2); @@ -1119,7 +1119,7 @@ void SvgSerializer::write(const geometry_data& data) { TopoDS_Compound profile_edges; if (profile_threshold_ != -1 && !(data.product->declaration().is("IfcWall") || data.product->declaration().is("IfcSlab"))) { - TopTools_IndexedDataMapOfShapeListOfShape map; + NCollection_IndexedDataMap map; TopExp::MapShapesAndAncestors(*compound_to_hlr, TopAbs_EDGE, TopAbs_FACE, map); if (map.Extent() > profile_threshold_) { BRep_Builder BB; @@ -1434,8 +1434,8 @@ void SvgSerializer::write(const geometry_data& data) { result = make_transform_mirror_.Shape(); } - Handle(TopTools_HSequenceOfShape) edges = new TopTools_HSequenceOfShape(); - Handle(TopTools_HSequenceOfShape) wires = new TopTools_HSequenceOfShape(); + opencascade::handle edges = new TopTools_HSequenceOfShape(); + opencascade::handle wires = new TopTools_HSequenceOfShape(); { TopExp_Explorer exp(result, TopAbs_EDGE); for (; exp.More(); exp.Next()) {