Update implementation of IfcBSplineSurfaceWithKnots for IfcAdvancedFace in IFC4

This commit is contained in:
Thomas Krijnen
2015-05-21 13:02:10 +00:00
parent 9b64c6f4b9
commit 7abe2df066
2 changed files with 13 additions and 45 deletions
+8 -42
View File
@@ -885,7 +885,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcDerivedProfileDef* l, TopoDS_S
#ifdef USE_IFC4 #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<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList(); SHARED_PTR< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
std::vector<double> uknots = l->UKnots(); std::vector<double> uknots = l->UKnots();
std::vector<double> vknots = l->VKnots(); std::vector<double> vknots = l->VKnots();
@@ -926,52 +926,18 @@ bool convert_surf(IfcSchema::IfcBSplineSurfaceWithKnots* l, Handle_Geom_Surface&
for (std::vector<int>::const_iterator it = vmults.begin(); it != vmults.end(); ++it, ++i) { for (std::vector<int>::const_iterator it = vmults.begin(); it != vmults.end(); ++it, ++i) {
VMults(i) = *it; 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; 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; gp_Pln pln;
convert(l, pln); convert(l, pln);
surf = new Geom_Plane(pln); Handle_Geom_Surface surf = new Geom_Plane(pln);
return true; face = BRepBuilderAPI_MakeFace(surf, getValue(GV_PRECISION));
}
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();
return true; return true;
} }
+5 -3
View File
@@ -51,6 +51,9 @@ SHAPES(IfcGeometricSet);
#ifdef USE_IFC4 #ifdef USE_IFC4
SHAPE(IfcCylindricalSurface); SHAPE(IfcCylindricalSurface);
SHAPE(IfcAdvancedBrep); SHAPE(IfcAdvancedBrep);
// FIXME: Surfaces should have a shape type of their own
SHAPE(IfcBSplineSurfaceWithKnots);
SHAPE(IfcPlane);
#endif #endif
SHAPE(IfcExtrudedAreaSolid); SHAPE(IfcExtrudedAreaSolid);
SHAPE(IfcRevolvedAreaSolid); SHAPE(IfcRevolvedAreaSolid);
@@ -58,6 +61,7 @@ SHAPE(IfcConnectedFaceSet);
SHAPE(IfcBooleanResult); SHAPE(IfcBooleanResult);
SHAPE(IfcPolygonalBoundedHalfSpace); SHAPE(IfcPolygonalBoundedHalfSpace);
SHAPE(IfcHalfSpaceSolid); SHAPE(IfcHalfSpaceSolid);
// FIXME: Surfaces should have a shape type of their own
SHAPE(IfcSurfaceOfLinearExtrusion); SHAPE(IfcSurfaceOfLinearExtrusion);
SHAPE(IfcSurfaceOfRevolution); SHAPE(IfcSurfaceOfRevolution);
SHAPE(IfcBlock); SHAPE(IfcBlock);
@@ -71,9 +75,6 @@ SHAPE(IfcRectangularTrimmedSurface);
SHAPE(IfcSurfaceCurveSweptAreaSolid); SHAPE(IfcSurfaceCurveSweptAreaSolid);
SHAPE(IfcSweptDiskSolid); SHAPE(IfcSweptDiskSolid);
#ifdef USE_IFC4
FACE(IfcAdvancedFace);
#endif
FACE(IfcArbitraryProfileDefWithVoids); FACE(IfcArbitraryProfileDefWithVoids);
FACE(IfcArbitraryClosedProfileDef); FACE(IfcArbitraryClosedProfileDef);
FACE(IfcRoundedRectangleProfileDef); FACE(IfcRoundedRectangleProfileDef);
@@ -94,6 +95,7 @@ FACE(IfcCenterLineProfileDef);
FACE(IfcCompositeProfileDef); FACE(IfcCompositeProfileDef);
FACE(IfcDerivedProfileDef); FACE(IfcDerivedProfileDef);
// IfcFaceSurface included // IfcFaceSurface included
// IfcAdvancedFace included in case of IFC4
FACE(IfcFace); FACE(IfcFace);
WIRE(IfcEdgeCurve); WIRE(IfcEdgeCurve);