Last minute refactoring

This commit is contained in:
Thomas Krijnen
2026-08-08 07:42:45 +02:00
parent 8870ffb018
commit af58eaf79f
300 changed files with 5230 additions and 5150 deletions
+23 -23
View File
@@ -34,7 +34,7 @@
#include <ShapeFix_Shape.hxx>
#include <NCollection_IncAllocator.hxx>
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geom;
namespace {
@@ -152,8 +152,8 @@ namespace {
surf = BRep_Tool::Surface(TopoDS::Face(s));
}
if ((s.ShapeType() == TopAbs_FACE && IfcGeom::util::split_solid_by_surface(i, surf, a, b)) ||
(s.ShapeType() == TopAbs_SHELL && IfcGeom::util::split_solid_by_shell(i, s, a, b))) {
if ((s.ShapeType() == TopAbs_FACE && ifcopenshell::geom::util::split_solid_by_surface(i, surf, a, b)) ||
(s.ShapeType() == TopAbs_SHELL && ifcopenshell::geom::util::split_solid_by_shell(i, s, a, b))) {
slices.push_back(b);
i = a;
} else {
@@ -167,7 +167,7 @@ namespace {
}
bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const std::vector< std::vector<opencascade::handle<Geom_Surface>>>& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles, ConversionResults& result, double tol) {
bool ifcopenshell::geom::util::apply_folded_layerset(const conversion_results& items, const std::vector< std::vector<opencascade::handle<Geom_Surface>>>& surfaces, const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& styles, conversion_results& result, double tol) {
Bnd_Box bb;
TopoDS_Shape input;
flatten_shape_list(items, input, false, false, tol);
@@ -249,11 +249,11 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
} else if (shells.Extent() == 1) {
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
if (split_solid_by_shell(std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape(), shells.First(), a, b, tol)) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
if (split_solid_by_shell(std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape(), shells.First(), a, b, tol)) {
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
} else {
continue;
}
@@ -263,15 +263,15 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
} else {
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
const TopoDS_Shape& s = std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape();
const TopoDS_Shape& s = std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape();
TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol);
std::vector<TopoDS_Shape> slices;
if (split(s, shells, tol, slices) && slices.size() == styles.size()) {
for (size_t i = 0; i < slices.size(); ++i) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
}
} else {
return false;
@@ -284,18 +284,18 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
}
bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector<opencascade::handle<Geom_Surface>>& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles, ConversionResults& result, double tol) {
bool ifcopenshell::geom::util::apply_layerset(const conversion_results& items, const std::vector<opencascade::handle<Geom_Surface>>& surfaces, const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& styles, conversion_results& result, double tol) {
if (surfaces.size() < 3) {
return false;
} else if (surfaces.size() == 3) {
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
if (split_solid_by_surface(std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape(), surfaces[1], a, b, tol)) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
if (split_solid_by_surface(std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape(), surfaces[1], a, b, tol)) {
result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
} else {
continue;
}
@@ -309,7 +309,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
// Determine whether sequence of surfaces is consistent with surface normal, so that
// layer operations are applied in the correct order. This seems to be always the case.
Bnd_Box bb;
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
BRepBndLib::Add(it->Shape(), bb);
}
@@ -334,9 +334,9 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
mass.ChangeCoord() += n1.XYZ();
*/
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
const TopoDS_Shape& s = std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape();
const TopoDS_Shape& s = std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape();
TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol);
NCollection_List<TopoDS_Shape> operands;
@@ -354,14 +354,14 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
/*
// enable this is you want to see how IfcOpenShell has placed the layer surfaces
for (auto& x : operands) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), x, nullptr));
result.push_back(conversion_result(it->ItemId(), it->Placement(), x, nullptr));
}
*/
std::vector<TopoDS_Shape> slices;
if (split(s, operands, tol, slices) && slices.size() == styles.size()) {
for (size_t i = 0; i < slices.size(); ++i) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
}
} else {
return false;
@@ -373,7 +373,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
}
bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const opencascade::handle<Geom_Surface>& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
bool ifcopenshell::geom::util::split_solid_by_surface(const TopoDS_Shape& input, const opencascade::handle<Geom_Surface>& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
// Use an unbounded surface, that isolate part of the input shape,
// to split this shape into two parts. Make sure that the addition
// of the two result volumes matches that of the input.
@@ -394,7 +394,7 @@ bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const open
return b;
}
bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS_Shape& shell, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
bool ifcopenshell::geom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS_Shape& shell, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
// Use a shell, typically one or more connected faces, that isolate part
// of the input shape, to split this shape into two parts. Make sure that
// the addition of the two result volumes matches that of the input.