| 7 | using namespace IfcGeom; |
| 8 | |
| 9 | bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS_Shape& shape) { |
| 10 | const double& height = extrusion->depth; |
| 11 | |
| 12 | if (height < settings_.get<settings::Precision>().get()) { |
| 13 | Logger::Error("Non-positive extrusion height encountered for:", extrusion->instance); |
| 14 | return false; |
| 15 | } |
| 16 | |
| 17 | TopoDS_Shape face; |
| 18 | if (!convert(taxonomy::cast<taxonomy::face>(extrusion->basis), face)) { |
| 19 | return false; |
| 20 | } |
| 21 | |
| 22 | /* |
| 23 | // @todo we need to decide whether the matrix is kept on the taxonomy node or |
| 24 | // move the TopoDS_Shape, but obviously not both. |
| 25 | gp_GTrsf gtrsf; |
| 26 | if (!convert(&extrusion->matrix, gtrsf)) { |
| 27 | Logger::Error("Unable to move extrusion"); |
| 28 | } |
| 29 | auto trsf = gtrsf.Trsf(); |
| 30 | */ |
| 31 | |
| 32 | const auto& fs = extrusion->direction->ccomponents(); |
| 33 | gp_Dir dir(fs(0), fs(1), fs(2)); |
| 34 | |
| 35 | shape.Nullify(); |
| 36 | |
| 37 | if (face.ShapeType() == TopAbs_COMPOUND) { |
| 38 | |
| 39 | // For compounds (most likely the result of a IfcCompositeProfileDef) |
| 40 | // create a compound solid shape. |
| 41 | |
| 42 | TopExp_Explorer exp(face, TopAbs_FACE); |
| 43 | |
| 44 | TopoDS_CompSolid compound; |
| 45 | BRep_Builder builder; |
| 46 | builder.MakeCompSolid(compound); |
| 47 | |
| 48 | int num_faces_extruded = 0; |
| 49 | for (; exp.More(); exp.Next(), ++num_faces_extruded) { |
| 50 | builder.Add(compound, BRepPrimAPI_MakePrism(exp.Current(), height*dir)); |
| 51 | } |
| 52 | |
| 53 | if (num_faces_extruded) { |
| 54 | shape = compound; |
| 55 | } |
| 56 | |
| 57 | } |
| 58 | |
| 59 | if (shape.IsNull()) { |
| 60 | shape = BRepPrimAPI_MakePrism(face, height*dir); |
| 61 | } |
| 62 | |
| 63 | /* |
| 64 | if (!shape.IsNull()) { |
| 65 | // IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D |
| 66 | // and therefore has a unit scale factor |