diff --git a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp index 6a7b805150..8b465db32a 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp @@ -26,7 +26,7 @@ void IfcGeom::CgalKernel::remove_duplicate_points_from_loop(cgal_wire_t& polygon CGAL::Polyhedron_3 IfcGeom::CgalKernel::create_polyhedron(std::list &face_list) { // Naive creation - CGAL::Polyhedron_3 polyhedron = CGAL::Polyhedron_3(); + CGAL::Polyhedron_3 polyhedron; PolyhedronBuilder builder(&face_list); polyhedron.delegate(builder); diff --git a/src/ifcgeom/kernels/cgal/CgalEntityMapping.h b/src/ifcgeom/kernels/cgal/CgalEntityMapping.h index e438b3ace1..37967d966b 100644 --- a/src/ifcgeom/kernels/cgal/CgalEntityMapping.h +++ b/src/ifcgeom/kernels/cgal/CgalEntityMapping.h @@ -39,55 +39,84 @@ SHAPES(IfcMappedItem); SHAPES(IfcManifoldSolidBrep); SHAPES(IfcGeometricSet); +#ifdef USE_IFC4 +//SHAPE(IfcCylindricalSurface); +//SHAPE(IfcAdvancedBrep); +//SHAPE(IfcBSplineSurfaceWithKnots); +SHAPE(IfcTriangulatedFaceSet); +//SHAPE(IfcExtrudedAreaSolidTapered); +#endif +//SHAPE(IfcPlane); SHAPE(IfcExtrudedAreaSolid); +//SHAPE(IfcRevolvedAreaSolid); SHAPE(IfcConnectedFaceSet); -SHAPE(IfcCsgSolid); -SHAPE(IfcBlock); SHAPE(IfcBooleanResult); -SHAPE(IfcSphere); +//SHAPE(IfcPolygonalBoundedHalfSpace); +SHAPE(IfcHalfSpaceSolid); +//SHAPE(IfcSurfaceOfLinearExtrusion); +//SHAPE(IfcSurfaceOfRevolution); +SHAPE(IfcBlock); SHAPE(IfcRectangularPyramid); SHAPE(IfcRightCircularCylinder); SHAPE(IfcRightCircularCone); -#ifdef USE_IFC4 -SHAPE(IfcTriangulatedFaceSet); -#endif -SHAPE(IfcHalfSpaceSolid); +SHAPE(IfcSphere); +SHAPE(IfcCsgSolid); +//SHAPE(IfcCurveBoundedPlane); +//SHAPE(IfcRectangularTrimmedSurface); +//SHAPE(IfcSurfaceCurveSweptAreaSolid); +//SHAPE(IfcSweptDiskSolid); +FACE(IfcArbitraryProfileDefWithVoids); FACE(IfcArbitraryClosedProfileDef); -FACE(IfcCircleHollowProfileDef); -FACE(IfcCircleProfileDef); -FACE(IfcFace); FACE(IfcRoundedRectangleProfileDef); FACE(IfcRectangleHollowProfileDef); FACE(IfcRectangleProfileDef); -FACE(IfcTrapeziumProfileDef); -FACE(IfcEllipseProfileDef); +FACE(IfcTrapeziumProfileDef) FACE(IfcCShapeProfileDef); +// IfcAsymmetricIShapeProfileDef included FACE(IfcIShapeProfileDef); FACE(IfcLShapeProfileDef); FACE(IfcTShapeProfileDef); FACE(IfcUShapeProfileDef); FACE(IfcZShapeProfileDef); +FACE(IfcCircleHollowProfileDef); +FACE(IfcCircleProfileDef); +FACE(IfcEllipseProfileDef); +//FACE(IfcCenterLineProfileDef); +//FACE(IfcCompositeProfileDef); +//FACE(IfcDerivedProfileDef); +// IfcFaceSurface included +// IfcAdvancedFace included in case of IFC4 +FACE(IfcFace); -WIRE(IfcEdgeLoop); +//WIRE(IfcEdgeCurve); +//WIRE(IfcSubedge); WIRE(IfcOrientedEdge); -WIRE(IfcPolyLoop); +WIRE(IfcEdge); +WIRE(IfcEdgeLoop); WIRE(IfcPolyline); +WIRE(IfcPolyLoop); WIRE(IfcCompositeCurve); WIRE(IfcTrimmedCurve); +//WIRE(IfcArbitraryOpenProfileDef); CURVE(IfcCircle); CURVE(IfcEllipse); CURVE(IfcLine); +#ifdef USE_IFC4 +// IfcRationalBSplineCurveWithKnots included +//CURVE(IfcBSplineCurveWithKnots); +#endif CLASS(IfcCartesianPoint,cgal_point_t); CLASS(IfcDirection,cgal_direction_t); -CLASS(IfcVector,cgal_vector_t); -CLASS(IfcPlane,cgal_plane_t); CLASS(IfcAxis2Placement2D,cgal_placement_t); CLASS(IfcAxis2Placement3D,cgal_placement_t); -CLASS(IfcObjectPlacement,cgal_placement_t); +CLASS(IfcAxis1Placement,cgal_placement_t); CLASS(IfcCartesianTransformationOperator2DnonUniform,cgal_placement_t); CLASS(IfcCartesianTransformationOperator3DnonUniform,cgal_placement_t); CLASS(IfcCartesianTransformationOperator2D,cgal_placement_t); CLASS(IfcCartesianTransformationOperator3D,cgal_placement_t); +CLASS(IfcObjectPlacement,cgal_placement_t); +CLASS(IfcVector,cgal_vector_t); +CLASS(IfcPlane,cgal_plane_t); diff --git a/src/ifcgeom/kernels/cgal/CgalIfcGeomFaces.cpp b/src/ifcgeom/kernels/cgal/CgalIfcGeomFaces.cpp index 0040b65cc3..09729e2467 100644 --- a/src/ifcgeom/kernels/cgal/CgalIfcGeomFaces.cpp +++ b/src/ifcgeom/kernels/cgal/CgalIfcGeomFaces.cpp @@ -10,6 +10,21 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcArbitraryClosedProfileDef* return success; } +bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcArbitraryProfileDefWithVoids* l, cgal_face_t& face) { + cgal_wire_t profile; + if ( ! convert_wire(l->OuterCurve(),profile) ) return false; + cgal_face_t mf; + mf.outer = profile; + IfcSchema::IfcCurve::list::ptr voids = l->InnerCurves(); + for( IfcSchema::IfcCurve::list::it it = voids->begin(); it != voids->end(); ++ it ) { + cgal_wire_t hole; + if ( convert_wire(*it,hole) ) { + mf.inner.push_back(hole); + } + } face = mf; + return true; +} + bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcRectangleProfileDef* l, cgal_face_t& face) { const double x = l->XDim() / 2.0f * getValue(GV_LENGTH_UNIT); const double y = l->YDim() / 2.0f * getValue(GV_LENGTH_UNIT); diff --git a/src/ifcgeom/kernels/cgal/CgalIfcGeomPrimitives.cpp b/src/ifcgeom/kernels/cgal/CgalIfcGeomPrimitives.cpp index 446f877394..d4cda51f6c 100644 --- a/src/ifcgeom/kernels/cgal/CgalIfcGeomPrimitives.cpp +++ b/src/ifcgeom/kernels/cgal/CgalIfcGeomPrimitives.cpp @@ -126,6 +126,22 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement3D* l, cgal_ return true; } +bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis1Placement* l, cgal_placement_t& ax) { +// IN_CACHE(IfcAxis1Placement,l,gp_Ax1,ax) + cgal_point_t o; + cgal_direction_t axis = Kernel::Vector_3(0,0,1); + IfcGeom::CgalKernel::convert(l->Location(),o); + if ( l->hasAxis() ) IfcGeom::CgalKernel::convert(l->Axis(), axis); + + // TODO: Should be checked. + ax = Kernel::Aff_transformation_3(1.0, 0.0, axis.cartesian(0), o.cartesian(0), + 0.0, 1.0, axis.cartesian(1), o.cartesian(1), + 0.0, 0.0, axis.cartesian(2), o.cartesian(2)); + +// CACHE(IfcAxis1Placement,l,ax) + return true; +} + bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcObjectPlacement* l, cgal_placement_t& trsf) { // IN_CACHE(IfcObjectPlacement,l,cgal_placement_t,trsf) if ( ! l->is(IfcSchema::Type::IfcLocalPlacement) ) { diff --git a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp index a275b071bf..c29b9ad36f 100644 --- a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp +++ b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp @@ -50,6 +50,12 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal top_face.outer.push_back(*vertex+height*dir); } face_list.push_back(top_face); + if (bottom_face.inner.empty()) { + shape = create_polyhedron(face_list); + for (auto &vertex: vertices(shape)) vertex->point() = vertex->point().transform(trsf); + return true; + } + CGAL::Nef_polyhedron_3 nef_shape = create_nef_polyhedron(face_list); // Inner @@ -701,8 +707,8 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcHalfSpaceSolid* l, cgal_sh // const gp_Pnt pnt = pln.Location().Translated( l->AgreementFlag() ? -pln.Axis().Direction() : pln.Axis().Direction()); // shape = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln),pnt).Solid(); + // TODO: For now we do nothing and process halfspaces in IfcBooleanResult, which likely doesn't capture all cases. + // Find a better solution later (with an abstract shape class?) shape = CGAL::Polyhedron_3(); - // TODO: We need to do something for now. Find a better solution later (abstract shape class?) -// shape = CGAL::Nef_polyhedron_3(pln); return true; } diff --git a/src/ifcgeom/kernels/cgal/CgalIfcGeomWires.cpp b/src/ifcgeom/kernels/cgal/CgalIfcGeomWires.cpp index 674ba921d6..ee874bc140 100644 --- a/src/ifcgeom/kernels/cgal/CgalIfcGeomWires.cpp +++ b/src/ifcgeom/kernels/cgal/CgalIfcGeomWires.cpp @@ -86,6 +86,34 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcOrientedEdge* l, cgal_wire } } +bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcEdge* l, cgal_wire_t& result) { + if (!l->EdgeStart()->is(IfcSchema::Type::IfcVertexPoint) || !l->EdgeEnd()->is(IfcSchema::Type::IfcVertexPoint)) { + Logger::Message(Logger::LOG_ERROR, "Only IfcVertexPoints are supported for EdgeStart and -End", l->entity); + return false; + } + + IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) l->EdgeStart())->VertexGeometry(); + IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) l->EdgeEnd())->VertexGeometry(); + if (!pnt1->is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->is(IfcSchema::Type::IfcCartesianPoint)) { + Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l->entity); + return false; + } + + cgal_point_t p1, p2; + if (!convert(((IfcSchema::IfcCartesianPoint*)pnt1), p1) || + !convert(((IfcSchema::IfcCartesianPoint*)pnt2), p2)) + { + return false; + } + + cgal_wire_t mw; + mw.push_back(p1); + mw.push_back(p2); + + result = mw; + return true; +} + bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcCompositeCurve* l, cgal_wire_t& wire) { if ( getValue(GV_PLANEANGLE_UNIT)<0 ) { Logger::Message(Logger::LOG_WARNING,"Creating a composite curve without unit information:",l->entity);