From bc5e33489eac3037020a4cbc0df9803cb4d4b509 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 22 Sep 2021 20:57:54 +1000 Subject: [PATCH] Implement IfcBoundingBox. --- src/ifcgeom/IfcGeomShapes.cpp | 22 ++++++++++++++++++++++ src/ifcgeom/IfcRegister.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/ifcgeom/IfcGeomShapes.cpp b/src/ifcgeom/IfcGeomShapes.cpp index 8ea57cc6f9..446404aa77 100644 --- a/src/ifcgeom/IfcGeomShapes.cpp +++ b/src/ifcgeom/IfcGeomShapes.cpp @@ -947,6 +947,28 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBlock* l, TopoDS_Shape& shape) return true; } +bool IfcGeom::Kernel::convert(const IfcSchema::IfcBoundingBox* l, TopoDS_Shape& shape) { + const double dx = l->XDim() * getValue(GV_LENGTH_UNIT); + const double dy = l->YDim() * getValue(GV_LENGTH_UNIT); + const double dz = l->ZDim() * getValue(GV_LENGTH_UNIT); + + BRepPrimAPI_MakeBox builder(dx, dy, dz); + gp_Pnt corner; + IfcGeom::Kernel::convert(l->Corner(), corner); + + gp_Trsf trsf; + gp_Dir axis1 (1.,0.,0.); + gp_Dir axis3 (0.,0.,1.); + gp_Ax3 ax3 (corner, axis3, axis1); + trsf.SetTransformation(ax3); + trsf.Invert(); + + // IfcBoundingBox.Corner has unit scale factor + shape = builder.Solid().Moved(trsf); + + return true; +} + bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangularPyramid* l, TopoDS_Shape& shape) { const double dx = l->XLength() * getValue(GV_LENGTH_UNIT); const double dy = l->YLength() * getValue(GV_LENGTH_UNIT); diff --git a/src/ifcgeom/IfcRegister.h b/src/ifcgeom/IfcRegister.h index ab48b7b875..51c49e99d1 100644 --- a/src/ifcgeom/IfcRegister.h +++ b/src/ifcgeom/IfcRegister.h @@ -88,6 +88,7 @@ SHAPE(IfcHalfSpaceSolid); SHAPE(IfcSurfaceOfLinearExtrusion); SHAPE(IfcSurfaceOfRevolution); SHAPE(IfcBlock); +SHAPE(IfcBoundingBox); SHAPE(IfcRectangularPyramid); SHAPE(IfcRightCircularCylinder); SHAPE(IfcRightCircularCone);