2012-07-19 18:26:47 +00:00
|
|
|
/********************************************************************************
|
2011-07-25 14:56:40 +00:00
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* Lesser GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* Implementations of the various conversion functions defined in IfcRegister.h *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <gp_Pnt.hxx>
|
|
|
|
|
#include <gp_Vec.hxx>
|
|
|
|
|
#include <gp_Dir.hxx>
|
|
|
|
|
#include <gp_Pnt2d.hxx>
|
|
|
|
|
#include <gp_Vec2d.hxx>
|
|
|
|
|
#include <gp_Dir2d.hxx>
|
2011-10-23 17:11:06 +00:00
|
|
|
#include <gp_Mat.hxx>
|
|
|
|
|
#include <gp_Mat2d.hxx>
|
|
|
|
|
#include <gp_GTrsf.hxx>
|
|
|
|
|
#include <gp_GTrsf2d.hxx>
|
2011-07-25 14:56:40 +00:00
|
|
|
#include <gp_Trsf.hxx>
|
|
|
|
|
#include <gp_Trsf2d.hxx>
|
2014-03-15 11:51:23 +00:00
|
|
|
#include <gp_Ax1.hxx>
|
2011-07-25 14:56:40 +00:00
|
|
|
#include <gp_Ax3.hxx>
|
|
|
|
|
#include <gp_Ax2d.hxx>
|
|
|
|
|
#include <gp_Pln.hxx>
|
|
|
|
|
#include <gp_Circ.hxx>
|
|
|
|
|
|
|
|
|
|
#include <TColgp_Array1OfPnt.hxx>
|
|
|
|
|
#include <TColgp_Array1OfPnt2d.hxx>
|
|
|
|
|
#include <TColStd_Array1OfReal.hxx>
|
|
|
|
|
#include <TColStd_Array1OfInteger.hxx>
|
Add support for IfcBooleanResult, IfcBlock, IfcRectangularPyramid, IfcRightCircularCylinder, IfcRightCircularCone, IfcSphere, IfcCsgSolid, IfcCurveBoundedPlane, IfcRectangularTrimmedSurface, IfcSurfaceCurveSweptAreaSolid, IfcCylindricalSurface.
2014-03-22 10:31:51 +00:00
|
|
|
|
2011-07-25 14:56:40 +00:00
|
|
|
#include <Geom_Line.hxx>
|
|
|
|
|
#include <Geom_Circle.hxx>
|
|
|
|
|
#include <Geom_Ellipse.hxx>
|
|
|
|
|
#include <Geom_TrimmedCurve.hxx>
|
Add support for IfcBooleanResult, IfcBlock, IfcRectangularPyramid, IfcRightCircularCylinder, IfcRightCircularCone, IfcSphere, IfcCsgSolid, IfcCurveBoundedPlane, IfcRectangularTrimmedSurface, IfcSurfaceCurveSweptAreaSolid, IfcCylindricalSurface.
2014-03-22 10:31:51 +00:00
|
|
|
#include <Geom_CylindricalSurface.hxx>
|
2011-07-25 14:56:40 +00:00
|
|
|
|
|
|
|
|
#include <BRepOffsetAPI_Sewing.hxx>
|
Add support for IfcBooleanResult, IfcBlock, IfcRectangularPyramid, IfcRightCircularCylinder, IfcRightCircularCone, IfcSphere, IfcCsgSolid, IfcCurveBoundedPlane, IfcRectangularTrimmedSurface, IfcSurfaceCurveSweptAreaSolid, IfcCylindricalSurface.
2014-03-22 10:31:51 +00:00
|
|
|
#include <BRepOffsetAPI_MakePipe.hxx>
|
|
|
|
|
#include <BRepOffsetAPI_MakePipeShell.hxx>
|
|
|
|
|
|
2011-07-25 14:56:40 +00:00
|
|
|
#include <BRepBuilderAPI_MakeFace.hxx>
|
|
|
|
|
#include <BRepBuilderAPI_MakeEdge.hxx>
|
|
|
|
|
#include <BRepBuilderAPI_MakeWire.hxx>
|
|
|
|
|
#include <BRepBuilderAPI_MakePolygon.hxx>
|
|
|
|
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
|
|
|
|
|
|
|
|
|
#include <TopoDS.hxx>
|
|
|
|
|
#include <TopoDS_Wire.hxx>
|
|
|
|
|
#include <TopoDS_Face.hxx>
|
2016-02-18 13:17:15 +01:00
|
|
|
#include <TopoDS_CompSolid.hxx>
|
|
|
|
|
|
2016-06-21 11:18:16 +02:00
|
|
|
#include <TopExp.hxx>
|
2011-07-25 14:56:40 +00:00
|
|
|
#include <TopExp_Explorer.hxx>
|
|
|
|
|
|
|
|
|
|
#include <BRepPrimAPI_MakePrism.hxx>
|
2014-03-15 11:51:23 +00:00
|
|
|
#include <BRepPrimAPI_MakeRevol.hxx>
|
Add support for IfcBooleanResult, IfcBlock, IfcRectangularPyramid, IfcRightCircularCylinder, IfcRightCircularCone, IfcSphere, IfcCsgSolid, IfcCurveBoundedPlane, IfcRectangularTrimmedSurface, IfcSurfaceCurveSweptAreaSolid, IfcCylindricalSurface.
2014-03-22 10:31:51 +00:00
|
|
|
#include <BRepPrimAPI_MakeBox.hxx>
|
|
|
|
|
#include <BRepPrimAPI_MakeCone.hxx>
|
|
|
|
|
#include <BRepPrimAPI_MakeCylinder.hxx>
|
|
|
|
|
#include <BRepPrimAPI_MakeSphere.hxx>
|
|
|
|
|
#include <BRepPrimAPI_MakeWedge.hxx>
|
2015-06-16 12:58:51 +00:00
|
|
|
#include <BRepBuilderAPI_MakePolygon.hxx>
|
Add support for IfcBooleanResult, IfcBlock, IfcRectangularPyramid, IfcRightCircularCylinder, IfcRightCircularCone, IfcSphere, IfcCsgSolid, IfcCurveBoundedPlane, IfcRectangularTrimmedSurface, IfcSurfaceCurveSweptAreaSolid, IfcCylindricalSurface.
2014-03-22 10:31:51 +00:00
|
|
|
|
|
|
|
|
#include <BRepBuilderAPI_Transform.hxx>
|
2011-07-25 14:56:40 +00:00
|
|
|
#include <BRepBuilderAPI_MakeShell.hxx>
|
|
|
|
|
#include <BRepBuilderAPI_MakeSolid.hxx>
|
|
|
|
|
#include <BRepPrimAPI_MakeHalfSpace.hxx>
|
Add support for IfcBooleanResult, IfcBlock, IfcRectangularPyramid, IfcRightCircularCylinder, IfcRightCircularCone, IfcSphere, IfcCsgSolid, IfcCurveBoundedPlane, IfcRectangularTrimmedSurface, IfcSurfaceCurveSweptAreaSolid, IfcCylindricalSurface.
2014-03-22 10:31:51 +00:00
|
|
|
|
2011-07-25 14:56:40 +00:00
|
|
|
#include <BRepAlgoAPI_Cut.hxx>
|
Add support for IfcBooleanResult, IfcBlock, IfcRectangularPyramid, IfcRightCircularCylinder, IfcRightCircularCone, IfcSphere, IfcCsgSolid, IfcCurveBoundedPlane, IfcRectangularTrimmedSurface, IfcSurfaceCurveSweptAreaSolid, IfcCylindricalSurface.
2014-03-22 10:31:51 +00:00
|
|
|
#include <BRepAlgoAPI_Fuse.hxx>
|
|
|
|
|
#include <BRepAlgoAPI_Common.hxx>
|
2011-07-25 14:56:40 +00:00
|
|
|
|
|
|
|
|
#include <ShapeFix_Shape.hxx>
|
|
|
|
|
#include <ShapeFix_ShapeTolerance.hxx>
|
|
|
|
|
#include <ShapeFix_Solid.hxx>
|
|
|
|
|
|
|
|
|
|
#include <TopLoc_Location.hxx>
|
|
|
|
|
|
2012-03-13 11:56:52 +00:00
|
|
|
#include <BRepCheck_Analyzer.hxx>
|
2014-06-27 12:00:41 +00:00
|
|
|
#include <BRepClass3d_SolidClassifier.hxx>
|
2012-03-13 11:56:52 +00:00
|
|
|
|
2015-02-06 14:20:33 +00:00
|
|
|
#include <Standard_Version.hxx>
|
|
|
|
|
|
2016-04-16 14:47:34 +02:00
|
|
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
|
|
|
|
|
2019-08-16 17:40:13 +02:00
|
|
|
#include "OpenCascadeKernel.h"
|
2011-07-25 14:56:40 +00:00
|
|
|
|
2018-11-02 16:10:06 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2019-08-16 17:40:13 +02:00
|
|
|
#include "../../../ifcparse/IfcLogger.h"
|
2017-12-20 16:38:55 +01:00
|
|
|
|
2019-08-16 17:40:13 +02:00
|
|
|
using namespace ifcopenshell::geometry;
|
|
|
|
|
using namespace ifcopenshell::geometry::kernels;
|
|
|
|
|
|
|
|
|
|
bool OpenCascadeKernel::convert(const taxonomy::extrusion& extrusion, TopoDS_Shape& shape) {
|
|
|
|
|
const double& height = extrusion.depth;
|
|
|
|
|
|
|
|
|
|
if (height < precision_) {
|
|
|
|
|
Logger::Error("Non-positive extrusion height encountered for:", extrusion.instance);
|
2015-12-02 10:17:59 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 11:22:31 +00:00
|
|
|
TopoDS_Shape face;
|
2019-08-16 17:40:13 +02:00
|
|
|
if (!convert(extrusion.basis, face)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-07-24 11:22:31 +00:00
|
|
|
|
2011-07-25 14:56:40 +00:00
|
|
|
gp_Trsf trsf;
|
2019-08-16 17:40:13 +02:00
|
|
|
if (!convert(extrusion.matrix, trsf)) {
|
|
|
|
|
Logger::Error("Unable to move extrusion");
|
2016-06-21 11:18:16 +02:00
|
|
|
}
|
2019-08-16 17:40:13 +02:00
|
|
|
|
2011-07-25 14:56:40 +00:00
|
|
|
gp_Dir dir;
|
2019-08-16 17:40:13 +02:00
|
|
|
if (!convert(extrusion.direction, dir)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-03-13 11:56:52 +00:00
|
|
|
|
2014-07-24 11:22:31 +00:00
|
|
|
shape.Nullify();
|
|
|
|
|
|
|
|
|
|
if (face.ShapeType() == TopAbs_COMPOUND) {
|
|
|
|
|
|
|
|
|
|
// For compounds (most likely the result of a IfcCompositeProfileDef)
|
|
|
|
|
// create a compound solid shape.
|
|
|
|
|
|
|
|
|
|
TopExp_Explorer exp(face, TopAbs_FACE);
|
|
|
|
|
|
|
|
|
|
TopoDS_CompSolid compound;
|
|
|
|
|
BRep_Builder builder;
|
|
|
|
|
builder.MakeCompSolid(compound);
|
|
|
|
|
|
|
|
|
|
int num_faces_extruded = 0;
|
|
|
|
|
for (; exp.More(); exp.Next(), ++num_faces_extruded) {
|
|
|
|
|
builder.Add(compound, BRepPrimAPI_MakePrism(exp.Current(), height*dir));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_faces_extruded) {
|
|
|
|
|
shape = compound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (shape.IsNull()) {
|
|
|
|
|
shape = BRepPrimAPI_MakePrism(face, height*dir);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-16 17:40:13 +02:00
|
|
|
if (!shape.IsNull()) {
|
2016-06-21 11:25:10 +02:00
|
|
|
// IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D
|
|
|
|
|
// and therefore has a unit scale factor
|
|
|
|
|
shape.Move(trsf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !shape.IsNull();
|
|
|
|
|
}
|