Refactoring

This commit is contained in:
Thomas Krijnen
2022-11-13 11:04:16 +01:00
committed by Dion Moult
parent 3a8df68710
commit 64021720ca
28 changed files with 849 additions and 1105 deletions
+2 -1
View File
@@ -24,6 +24,7 @@
#include <gp_Trsf2d.hxx>
#include <gp_Ax2d.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -44,7 +45,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement2D* l, gp_Trsf2d
gp_Ax2d axis(gp_Pnt2d(P.X(),P.Y()), gp_Dir2d(V.X(),V.Y()));
if (!axis_equal(axis, gp_Ax2d(), getValue(GV_PRECISION))) {
if (!util::axis_equal(axis, gp_Ax2d(), getValue(GV_PRECISION))) {
trsf.SetTransformation(axis, gp_Ax2d());
}
+2 -1
View File
@@ -23,6 +23,7 @@
#include <gp_Trsf.hxx>
#include <gp_Ax3.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -66,7 +67,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement3D* l, gp_Trsf&
gp_Ax3 ax3(o, axis, refDirection);
if (!axis_equal(ax3, (gp_Ax3) gp::XOY(), getValue(GV_PRECISION))) {
if (!util::axis_equal(ax3, (gp_Ax3) gp::XOY(), getValue(GV_PRECISION))) {
trsf.SetTransformation(ax3, gp::XOY());
}
+9 -2
View File
@@ -20,6 +20,8 @@
#include <TopoDS_Wire.hxx>
#include <Standard_Version.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#include "../ifcgeom_schema_agnostic/boolean_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -179,6 +181,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
bool valid_result;
util::boolean_settings bst;
bst.attempt_2d = getValue(GV_BOOLEAN_ATTEMPT_2D) > 0.;
bst.debug = getValue(GV_DEBUG_BOOLEAN) > 0.;
bst.precision = getValue(GV_PRECISION);
if (s1.ShapeType() == TopAbs_COMPOUND && TopoDS_Iterator(s1).More() && util::is_nested_compound_of_solid(s1)) {
TopoDS_Compound C;
BRep_Builder B;
@@ -187,7 +194,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
valid_result = true;
for (; it.More(); it.Next()) {
TopoDS_Shape part;
if (boolean_operation(it.Value(), second_operand_shapes, occ_op, part)) {
if (util::boolean_operation(bst, it.Value(), second_operand_shapes, occ_op, part)) {
B.Add(C, part);
} else {
valid_result = false;
@@ -195,7 +202,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
}
shape = C;
} else {
valid_result = boolean_operation(s1, second_operand_shapes, occ_op, shape);
valid_result = util::boolean_operation(bst, s1, second_operand_shapes, occ_op, shape);
}
#endif
@@ -24,6 +24,7 @@
#include <gp_Trsf2d.hxx>
#include <gp_Ax2d.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -60,7 +61,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
trsf.SetScaleFactor(*l->Scale());
}
if (is_identity(trsf, getValue(GV_PRECISION))) {
if (util::is_identity(trsf, getValue(GV_PRECISION))) {
trsf = gp_Trsf2d();
}
@@ -25,6 +25,7 @@
#include <gp_Trsf2d.hxx>
#include <gp_Ax2d.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -61,7 +62,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
gtrsf.SetValue(2,2,scale2);
gtrsf.Multiply(trsf);
if (is_identity(gtrsf, getValue(GV_PRECISION))) {
if (util::is_identity(gtrsf, getValue(GV_PRECISION))) {
gtrsf = gp_GTrsf2d();
}
@@ -22,6 +22,7 @@
#include <gp_Trsf.hxx>
#include <gp_Ax3.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -38,7 +39,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
gp_Ax3 ax3 (origin,axis3,axis1);
if ( axis2.Dot(ax3.YDirection()) < 0 ) ax3.YReverse();
if (!axis_equal(ax3, (gp_Ax3) gp::XOY(), getValue(GV_PRECISION))) {
if (!util::axis_equal(ax3, (gp_Ax3) gp::XOY(), getValue(GV_PRECISION))) {
trsf.SetTransformation(ax3);
trsf.Invert();
}
@@ -23,6 +23,7 @@
#include <gp_Trsf.hxx>
#include <gp_Ax3.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -50,7 +51,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
gtrsf.SetValue(3,3,scale3);
gtrsf.PreMultiply(trsf);
if (is_identity(gtrsf, getValue(GV_PRECISION))) {
if (util::is_identity(gtrsf, getValue(GV_PRECISION))) {
gtrsf = gp_GTrsf();
}
+4 -4
View File
@@ -125,14 +125,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& result)
}
}
for (auto& wire : wires) {
for (auto& w : wires) {
if (!same_sense) {
wire.Reverse();
w.Reverse();
}
wire_senses.Bind(wire.Oriented(TopAbs_FORWARD), same_sense ? TopAbs_FORWARD : TopAbs_REVERSED);
wire_senses.Bind(w.Oriented(TopAbs_FORWARD), same_sense ? TopAbs_FORWARD : TopAbs_REVERSED);
fd.wires().emplace_back(TopoDS::Wire(wire));
fd.wires().emplace_back(TopoDS::Wire(w));
}
}
}
+19 -894
View File
File diff suppressed because it is too large Load Diff
-11
View File
@@ -167,8 +167,6 @@ private:
double boolean_debug_setting;
double boolean_attempt_2d;
size_t operation_counter_ = 0;
// For stopping PlacementRelTo recursion in convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf)
const IfcParse::declaration* placement_rel_to_type_;
const IfcUtil::IfcBaseEntity* placement_rel_to_instance_;
@@ -273,7 +271,6 @@ public:
bool convert_curve(const IfcUtil::IfcBaseInterface* L, Handle(Geom_Curve)& result);
bool convert_face(const IfcUtil::IfcBaseInterface* L, TopoDS_Shape& result);
bool convert_openings(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
bool convert_openings_fast(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
void assert_closed_wire(TopoDS_Wire& wire);
bool convert_layerset(const IfcSchema::IfcProduct*, std::vector<Handle_Geom_Surface>&, std::vector<std::shared_ptr<const SurfaceStyle>>&, std::vector<double>&);
@@ -284,14 +281,6 @@ public:
bool split_solid_by_surface(const TopoDS_Shape&, const Handle_Geom_Surface&, TopoDS_Shape&, TopoDS_Shape&);
bool split_solid_by_shell(const TopoDS_Shape&, const TopoDS_Shape& s, TopoDS_Shape&, TopoDS_Shape&);
#if OCC_VERSION_HEX < 0x60900
bool boolean_operation(const TopoDS_Shape&, const TopTools_ListOfShape&, BOPAlgo_Operation, TopoDS_Shape&);
bool boolean_operation(const TopoDS_Shape&, const TopoDS_Shape&, BOPAlgo_Operation, TopoDS_Shape&);
#else
bool boolean_operation(const TopoDS_Shape&, const TopTools_ListOfShape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
bool boolean_operation(const TopoDS_Shape&, const TopoDS_Shape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
#endif
bool fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, TopoDS_Shape& box, double& height);
const Handle_Geom_Curve intersect(const Handle_Geom_Surface&, const Handle_Geom_Surface&);
+1 -1
View File
@@ -303,7 +303,7 @@ namespace IfcGeom {
task_result_ptr_initialized = true;
}
progress_ = ++processed_ * 100 / tasks_.size();
progress_ = (int) (++processed_ * 100 / tasks_.size());
}
void process_concurrently() {
+1 -1
View File
@@ -50,7 +50,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi
coords.size() < 3 ? 0. : coords[2] * getValue(GV_LENGTH_UNIT)));
}
int max_index = points.size();
int max_index = (int) points.size();
BRepBuilderAPI_MakeWire w;
+2 -2
View File
@@ -41,12 +41,12 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalFaceSet* pfs, TopoDS_
for (auto& f : *polygonal_faces) {
loop_grouping.emplace_back();
loop_grouping.back().push_back(indices.size());
loop_grouping.back().push_back((int) indices.size());
indices.push_back(f->CoordIndex());
if (f->as<IfcSchema::IfcIndexedPolygonalFaceWithVoids>()) {
auto inner_coordinates = f->as<IfcSchema::IfcIndexedPolygonalFaceWithVoids>()->InnerCoordIndices();
for (auto& x : inner_coordinates) {
loop_grouping.back().push_back(indices.size());
loop_grouping.back().push_back((int) indices.size());
indices.push_back(x);
}
}
+3 -3
View File
@@ -33,9 +33,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRepresentation* l, IfcRepresen
TopoDS_Shape s;
if (convert_shape(representation_item, s)) {
if (s.ShapeType() == TopAbs_COMPOUND && TopoDS_Iterator(s).More() && TopoDS_Iterator(s).Value().ShapeType() == TopAbs_SOLID) {
TopoDS_Iterator it(s);
for (; it.More(); it.Next()) {
shapes.push_back(IfcRepresentationShapeItem(representation_item->data().id(), it.Value(), get_style(representation_item)));
TopoDS_Iterator topo_it(s);
for (; topo_it.More(); topo_it.Next()) {
shapes.push_back(IfcRepresentationShapeItem(representation_item->data().id(), topo_it.Value(), get_style(representation_item)));
}
} else {
shapes.push_back(IfcRepresentationShapeItem(representation_item->data().id(), s, get_style(representation_item)));
@@ -34,6 +34,7 @@
#include <ShapeFix_Edge.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include "../ifcgeom/IfcGeom.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -51,7 +52,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l,
Logger::Error("Failed to convert reference surface", l);
return false;
}
if (count(surface_shell, TopAbs_FACE) != 1) {
if (util::count(surface_shell, TopAbs_FACE) != 1) {
Logger::Error("Non-continuous reference surface", l);
return false;
}
+9 -6
View File
@@ -37,6 +37,7 @@
#include "../ifcgeom_schema_agnostic/sweep_utils.h"
#include "../ifcgeom_schema_agnostic/wire_utils.h"
#include "../ifcgeom_schema_agnostic/face_definition.h"
#include "../ifcgeom_schema_agnostic/base_utils.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
@@ -81,7 +82,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap
ep = l->EndParam();
#endif
if (count(wire, TopAbs_EDGE) == 1 && sp && ep) {
if (util::count(wire, TopAbs_EDGE) == 1 && sp && ep) {
TopoDS_Vertex v0, v1;
TopExp::Vertices(wire, v0, v1);
if (v0.IsSame(v1)) {
@@ -153,11 +154,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap
gp_Pln plane(c1->Position().Location(), n);
auto face = BRepBuilderAPI_MakeFace(plane).Face();
TopoDS_Wire wire;
BB.MakeWire(wire);
BB.Add(wire, a);
BB.Add(wire, b);
BB.Add(face, wire);
{
TopoDS_Wire w;
BB.MakeWire(w);
BB.Add(w, a);
BB.Add(w, b);
BB.Add(face, w);
}
TopExp::CommonVertex(a, b, V);
BRepFilletAPI_MakeFillet2d mf2d(face);