From 7abe2df0667da35ca35bfc18369dc48b2a105936 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 21 May 2015 13:02:10 +0000 Subject: [PATCH] Update implementation of IfcBSplineSurfaceWithKnots for IfcAdvancedFace in IFC4 --- src/ifcgeom/IfcGeomFaces.cpp | 50 ++++++------------------------------ src/ifcgeom/IfcRegister.h | 8 +++--- 2 files changed, 13 insertions(+), 45 deletions(-) diff --git a/src/ifcgeom/IfcGeomFaces.cpp b/src/ifcgeom/IfcGeomFaces.cpp index fdafbbfec8..31e4a80e44 100644 --- a/src/ifcgeom/IfcGeomFaces.cpp +++ b/src/ifcgeom/IfcGeomFaces.cpp @@ -885,7 +885,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcDerivedProfileDef* l, TopoDS_S #ifdef USE_IFC4 -bool convert_surf(IfcSchema::IfcBSplineSurfaceWithKnots* l, Handle_Geom_Surface& surf) { +bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, TopoDS_Shape& face) { SHARED_PTR< IfcTemplatedEntityListList > cps = l->ControlPointsList(); std::vector uknots = l->UKnots(); std::vector vknots = l->VKnots(); @@ -926,52 +926,18 @@ bool convert_surf(IfcSchema::IfcBSplineSurfaceWithKnots* l, Handle_Geom_Surface& for (std::vector::const_iterator it = vmults.begin(); it != vmults.end(); ++it, ++i) { VMults(i) = *it; } - surf = new Geom_BSplineSurface(Poles, UKnots, VKnots, UMults, VMults, UDegree, VDegree); + Handle_Geom_Surface surf = new Geom_BSplineSurface(Poles, UKnots, VKnots, UMults, VMults, UDegree, VDegree); + + face = BRepBuilderAPI_MakeFace(surf, getValue(GV_PRECISION)); + return true; } -bool convert_surf(IfcSchema::IfcPlane* l, Handle_Geom_Surface& surf) { +bool IfcGeom::Kernel::convert(const IfcSchema::IfcPlane* l, TopoDS_Shape& face) { gp_Pln pln; convert(l, pln); - surf = new Geom_Plane(pln); - return true; -} - -bool IfcGeom::Kernel::convert(const IfcSchema::IfcAdvancedFace* l, TopoDS_Shape& face) { - IfcSchema::IfcSurface* s = l->FaceSurface(); - Handle_Geom_Surface surf(0); - if (s->is(IfcSchema::Type::IfcBSplineSurfaceWithKnots)) { - convert_surf((IfcSchema::IfcBSplineSurfaceWithKnots*)s, surf); - } else if (s->is(IfcSchema::Type::IfcPlane)) { - convert_surf((IfcSchema::IfcPlane*)s, surf); - } else { - return false; - } - - BRepBuilderAPI_MakeFace mf(surf, Precision::Confusion()); - IfcSchema::IfcFaceBound::list::ptr bounds = l->Bounds(); - for (IfcSchema::IfcFaceBound::list::it it = bounds->begin(); it != bounds->end(); ++it) { - IfcSchema::IfcLoop* loop = (*it)->Bound(); - TopoDS_Wire outer_wire; - if (!convert_wire(loop, outer_wire)) return false; - - TopoDS_Face temp = BRepBuilderAPI_MakeFace(surf, outer_wire); - - if (BRepCheck_Face(temp).OrientationOfWires() == BRepCheck_BadOrientationOfSubshape) { - outer_wire.Reverse(); - ShapeFix_Face fix(BRepBuilderAPI_MakeFace(surf, outer_wire).Face()); - fix.FixOrientation(); - fix.Perform(); - TopoDS_Face temp = fix.Face(); - TopExp_Explorer exp(temp, TopAbs_WIRE); - outer_wire = TopoDS::Wire(exp.Current()); - } - - mf.Add(outer_wire); - } - - face = mf.Face(); - + Handle_Geom_Surface surf = new Geom_Plane(pln); + face = BRepBuilderAPI_MakeFace(surf, getValue(GV_PRECISION)); return true; } diff --git a/src/ifcgeom/IfcRegister.h b/src/ifcgeom/IfcRegister.h index 648bb70699..71fe1a7f1d 100644 --- a/src/ifcgeom/IfcRegister.h +++ b/src/ifcgeom/IfcRegister.h @@ -51,6 +51,9 @@ SHAPES(IfcGeometricSet); #ifdef USE_IFC4 SHAPE(IfcCylindricalSurface); SHAPE(IfcAdvancedBrep); +// FIXME: Surfaces should have a shape type of their own +SHAPE(IfcBSplineSurfaceWithKnots); +SHAPE(IfcPlane); #endif SHAPE(IfcExtrudedAreaSolid); SHAPE(IfcRevolvedAreaSolid); @@ -58,6 +61,7 @@ SHAPE(IfcConnectedFaceSet); SHAPE(IfcBooleanResult); SHAPE(IfcPolygonalBoundedHalfSpace); SHAPE(IfcHalfSpaceSolid); +// FIXME: Surfaces should have a shape type of their own SHAPE(IfcSurfaceOfLinearExtrusion); SHAPE(IfcSurfaceOfRevolution); SHAPE(IfcBlock); @@ -71,9 +75,6 @@ SHAPE(IfcRectangularTrimmedSurface); SHAPE(IfcSurfaceCurveSweptAreaSolid); SHAPE(IfcSweptDiskSolid); -#ifdef USE_IFC4 -FACE(IfcAdvancedFace); -#endif FACE(IfcArbitraryProfileDefWithVoids); FACE(IfcArbitraryClosedProfileDef); FACE(IfcRoundedRectangleProfileDef); @@ -94,6 +95,7 @@ FACE(IfcCenterLineProfileDef); FACE(IfcCompositeProfileDef); FACE(IfcDerivedProfileDef); // IfcFaceSurface included +// IfcAdvancedFace included in case of IFC4 FACE(IfcFace); WIRE(IfcEdgeCurve);