From 3f94d4af37da312cd1972459655dd31bd59663d6 Mon Sep 17 00:00:00 2001 From: Ken Arroyo Ohori Date: Tue, 7 Mar 2017 14:30:48 -0600 Subject: [PATCH] Skeleton for planes+halfspaces. Might be wrong. --- .../kernels/cgal/CgalConversionFunctions.cpp | 12 ++++++++++++ src/ifcgeom/kernels/cgal/CgalEntityMapping.h | 2 ++ src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp | 18 ++++++++++++++++++ src/ifcgeom/kernels/cgal/CgalKernel.h | 1 + 4 files changed, 33 insertions(+) diff --git a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp index 040b09bd59..50c0cb892d 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp @@ -49,6 +49,18 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcDirection* l, cgal_directi return true; } +bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcPlane* pln, cgal_plane_t& plane) { +// IN_CACHE(IfcPlane,pln,gp_Pln,plane) + IfcSchema::IfcAxis2Placement3D* l = pln->Position(); + 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); + plane = Kernel::Plane_3(o, axis); +// CACHE(IfcPlane,pln,plane) + return true; +} + bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement2D* l, cgal_placement_t& trsf) { // IN_CACHE(IfcAxis2Placement3D,l,gp_Trsf,trsf) cgal_point_t o; diff --git a/src/ifcgeom/kernels/cgal/CgalEntityMapping.h b/src/ifcgeom/kernels/cgal/CgalEntityMapping.h index b85f741966..77c654e604 100644 --- a/src/ifcgeom/kernels/cgal/CgalEntityMapping.h +++ b/src/ifcgeom/kernels/cgal/CgalEntityMapping.h @@ -47,6 +47,7 @@ SHAPE(IfcRectangularPyramid); SHAPE(IfcRightCircularCylinder); SHAPE(IfcRightCircularCone); SHAPE(IfcTriangulatedFaceSet); +SHAPE(IfcHalfSpaceSolid); FACE(IfcArbitraryClosedProfileDef); FACE(IfcCircleHollowProfileDef); @@ -65,6 +66,7 @@ WIRE(IfcPolyline); CLASS(IfcCartesianPoint,cgal_point_t); CLASS(IfcDirection,cgal_direction_t); +CLASS(IfcPlane,cgal_plane_t); CLASS(IfcAxis2Placement2D,cgal_placement_t); CLASS(IfcAxis2Placement3D,cgal_placement_t); CLASS(IfcObjectPlacement,cgal_placement_t); diff --git a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp index f028fec103..8882d9e961 100644 --- a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp +++ b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp @@ -925,3 +925,21 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, cg shape = CGAL::Nef_polyhedron_3(polyhedron); return true; } + +bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcHalfSpaceSolid* l, cgal_shape_t& shape) { + IfcSchema::IfcSurface* surface = l->BaseSurface(); + if ( ! surface->is(IfcSchema::Type::IfcPlane) ) { + Logger::Message(Logger::LOG_ERROR, "Unsupported BaseSurface:", surface->entity); + return false; + } + cgal_plane_t pln; + IfcGeom::CgalKernel::convert((IfcSchema::IfcPlane*)surface,pln); + + // TODO: This might be the other way around? + if (!l->AgreementFlag()) pln = pln.opposite(); +// const gp_Pnt pnt = pln.Location().Translated( l->AgreementFlag() ? -pln.Axis().Direction() : pln.Axis().Direction()); +// shape = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln),pnt).Solid(); + + shape = CGAL::Nef_polyhedron_3(pln); + return true; +} diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.h b/src/ifcgeom/kernels/cgal/CgalKernel.h index ada2fdd91c..7a27ae854e 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.h +++ b/src/ifcgeom/kernels/cgal/CgalKernel.h @@ -54,6 +54,7 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef Kernel::Aff_transformation_3 cgal_placement_t; typedef Kernel::Point_3 cgal_point_t; typedef Kernel::Vector_3 cgal_direction_t; +typedef Kernel::Plane_3 cgal_plane_t; typedef std::vector cgal_curve_t; typedef std::vector cgal_wire_t;