Use snake case conversion result APIs

Generated with the assistance of an AI coding tool.
This commit is contained in:
Thomas Krijnen
2026-08-08 16:09:30 +02:00
parent 2ba55ba984
commit 99a09a2a3c
26 changed files with 101 additions and 101 deletions
+1 -1
View File
@@ -889,7 +889,7 @@ class context:
def write_obj(ofn, *, elem=None, item=None):
s = ifcopenshell.geom.settings(USE_WORLD_COORDS=True, WELD_VERTICES=False)
if item:
geom = item.Triangulate(s)
geom = item.triangulate(s)
else:
geom = elem.geometry
+1 -1
View File
@@ -1466,7 +1466,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st
auto quantity_count = latebound_access::create(f, "IfcQuantityCount");
latebound_access::set(quantity_count, "Name", std::string("Surface Genus"));
latebound_access::set(quantity_count, "Description", '#' + boost::lexical_cast<std::string>(part.ItemId()));
latebound_access::set(quantity_count, "CountValue", (int64_t) part.Shape()->surface_genus());
latebound_access::set(quantity_count, "CountValue", (int64_t) part.shape()->surface_genus());
quantities_2.push_back(quantity_count);
}
@@ -134,8 +134,8 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet,
std::vector<double> intersection_volumes(nefs.size());
for (auto& g : geom_object->geometry()) {
auto s = std::static_pointer_cast<ifcopenshell::geom::cgal_shape>(g.Shape())->poly();
const auto& m = g.Placement()->ccomponents();
auto s = std::static_pointer_cast<ifcopenshell::geom::cgal_shape>(g.shape())->poly();
const auto& m = g.placement()->ccomponents();
const auto& n = geom_object->transformation().data()->ccomponents();
const cgal_placement trsf(
+2 -2
View File
@@ -491,8 +491,8 @@ struct intersection_validator {
std::wcout << sss.c_str() << std::endl;
for (auto& g : geom_object->geometry()) {
cgal_polyhedron s = *std::static_pointer_cast<ifcopenshell::geom::cgal_shape>(g.Shape());
const auto& m = g.Placement()->ccomponents();
cgal_polyhedron s = *std::static_pointer_cast<ifcopenshell::geom::cgal_shape>(g.shape());
const auto& m = g.placement()->ccomponents();
const auto& n = geom_object->transformation().data()->ccomponents();
const cgal_placement trsf(
+2 -2
View File
@@ -1,11 +1,11 @@
#include "conversion_result.h"
#include "representation.h"
ifcopenshell::geom::triangulation* ifcopenshell::geom::conversion_result_shape::Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger) const
ifcopenshell::geom::triangulation* ifcopenshell::geom::conversion_result_shape::triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger) const
{
auto t = ifcopenshell::geom::triangulation::empty(settings);
static ifcopenshell::geom::taxonomy::matrix4 iden;
Triangulate(settings, iden, t, -1, -1, logger);
triangulate(settings, iden, t, -1, -1, logger);
return t;
}
+7 -7
View File
@@ -507,9 +507,9 @@ namespace ifcopenshell::geom {
#else
virtual std::string_view backend_id() const = 0;
#endif
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const = 0;
ifcopenshell::geom::triangulation* Triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const = 0;
virtual void triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const = 0;
ifcopenshell::geom::triangulation* triangulate(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const = 0;
virtual int surface_genus() const = 0;
virtual bool is_manifold() const = 0;
@@ -578,11 +578,11 @@ namespace ifcopenshell::geom {
{}
void append(ifcopenshell::geom::taxonomy::matrix4::ptr trsf);
void prepend(ifcopenshell::geom::taxonomy::matrix4::ptr trsf);
std::shared_ptr<conversion_result_shape> Shape() const { return shape_; }
ifcopenshell::geom::taxonomy::matrix4::ptr Placement() const { return placement_; }
std::shared_ptr<conversion_result_shape> shape() const { return shape_; }
ifcopenshell::geom::taxonomy::matrix4::ptr placement() const { return placement_; }
bool hasStyle() const { return !!style_; }
const ifcopenshell::geom::taxonomy::style& Style() const { return *style_; }
ifcopenshell::geom::taxonomy::style::ptr StylePtr() const { return style_; }
const ifcopenshell::geom::taxonomy::style& style() const { return *style_; }
ifcopenshell::geom::taxonomy::style::ptr style_ptr() const { return style_; }
void setStyle(ifcopenshell::geom::taxonomy::style::ptr newStyle) { style_ = newStyle; }
int ItemId() const { return id; }
conversion_result_shape* apply_transform(double unit_scale = 1.) const {
+6 -6
View File
@@ -23,12 +23,12 @@ namespace {
void* box = nullptr;
double volume = 0.;
for (auto& i : items) {
nv += i.Shape()->num_vertices();
volume = i.Shape()->bounding_box(box);
nv += i.shape()->num_vertices();
volume = i.shape()->bounding_box(box);
}
density = nv / volume;
if (density > 1e5) {
items[0].Shape()->set_box(box);
items[0].shape()->set_box(box);
items.erase(items.begin() + 1, items.end());
logger.notice("GEO", 30, "Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
}
@@ -135,7 +135,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
bool some_items_without_style = false;
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
// @todo implement num_faces()
if (!it->hasStyle() /* && it->Shape()->num_faces() */) {
if (!it->hasStyle() /* && it->shape()->num_faces() */) {
some_items_without_style = true;
break;
}
@@ -153,7 +153,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
for (auto& s : shapes) {
if (s.hasStyle()) {
// @todo the uglyness
const_cast<taxonomy::style*>(&*s.StylePtr())->transparency = settings_.get<ifcopenshell::geom::settings::ForceSpaceTransparency>().get();
const_cast<taxonomy::style*>(&*s.style_ptr())->transparency = settings_.get<ifcopenshell::geom::settings::ForceSpaceTransparency>().get();
}
}
}
@@ -335,7 +335,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
int genus = (int)q2->as<IfcSchema::IfcQuantityCount>()->CountValue();
for (auto& part : elem->geometry()) {
if (part.ItemId() == item_id) {
if (util::surface_genus(part.Shape()) != genus) {
if (util::surface_genus(part.shape()) != genus) {
all_succeeded = false;
}
}
+1 -1
View File
@@ -109,7 +109,7 @@ namespace ifcopenshell {
for (auto& k : kernels_) {
bool is_valid = true;
for (auto& s : entity_shapes) {
if (!k->accepts(*s.Shape())) {
if (!k->accepts(*s.shape())) {
is_valid = false;
break;
}
@@ -364,7 +364,7 @@ void ifcopenshell::geom::cgal_shape::to_nef() const {
}
#endif
void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
void ifcopenshell::geom::cgal_shape::triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
if (is_point() || is_wire()) {
return;
}
@@ -458,7 +458,7 @@ void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings se
// std::map<cgal_vertex_descriptor, kernel_::Vector_3> vertex_normals;
// boost::associative_property_map<std::map<cgal_vertex_descriptor, kernel_::Vector_3>> vertex_normals_map(vertex_normals);
// Triangulate the shape and compute the normals
// triangulate the shape and compute the normals
std::map<facet_const_handle, kernel_::Vector_3> face_normals;
boost::associative_property_map<std::map<facet_const_handle, kernel_::Vector_3>> face_normals_map(face_normals);
@@ -586,7 +586,7 @@ void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings se
}
void ifcopenshell::geom::cgal_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
void ifcopenshell::geom::cgal_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
std::stringstream sstream;
if (is_point()) {
auto p = point();
@@ -1035,11 +1035,11 @@ bool ifcopenshell::geom::cgal_shape::surface_area_along_direction(double tol, co
#ifndef IFOPSH_SIMPLE_KERNEL
void ifcopenshell::geom::cgal_shape_half_space_decomposition::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
void ifcopenshell::geom::cgal_shape_half_space_decomposition::triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
throw std::runtime_error("Not implemented");
}
void ifcopenshell::geom::cgal_shape_half_space_decomposition::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
void ifcopenshell::geom::cgal_shape_half_space_decomposition::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
throw std::runtime_error("Not implemented");
}
@@ -226,8 +226,8 @@ namespace ifcopenshell { namespace geom {
const cgal_point& point() const { return std::get<cgal_point>(*shape_); }
const cgal_wire& wire() const { return std::get<cgal_wire>(*shape_); }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual void triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual ifcopenshell::geom::conversion_result_shape* clone() const {
if (shape_) {
@@ -319,8 +319,8 @@ namespace ifcopenshell { namespace geom {
#endif
}
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual void triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const;
virtual bool is_manifold() const;
+8 -8
View File
@@ -912,8 +912,8 @@ bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::b
std::list<CGAL::Nef_polyhedron_3<kernel_>> first_operands_nef, second_operands_nef;
for (auto& shp : entity_shapes) {
cgal_polyhedron entity_shape = *std::static_pointer_cast<cgal_shape>(shp.Shape());
const auto& m = shp.Placement()->ccomponents();
cgal_polyhedron entity_shape = *std::static_pointer_cast<cgal_shape>(shp.shape());
const auto& m = shp.placement()->ccomponents();
if (!m.isIdentity()) {
cgal_placement trsf;
convert_placement(m, trsf);
@@ -943,9 +943,9 @@ bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::b
abstract_kernel::convert(op.first, opening_shapes);
for (unsigned int i = 0; i < opening_shapes.size(); ++i) {
cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast<cgal_shape>(opening_shapes[i].Shape());
cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast<cgal_shape>(opening_shapes[i].shape());
cgal_polyhedron entity_shape(entity_shape_unlocated);
auto gtrsf = opening_shapes[i].Placement();
auto gtrsf = opening_shapes[i].placement();
// @todo check
Eigen::Matrix4d m = opening_trsf.ccomponents() * gtrsf->ccomponents();
if (!m.isIdentity()) {
@@ -1008,7 +1008,7 @@ bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::b
return false;
}
cut_shapes.push_back(ifcopenshell::geom::conversion_result(it->ItemId(), new cgal_shape(a_poly), it->StylePtr()));
cut_shapes.push_back(ifcopenshell::geom::conversion_result(it->ItemId(), new cgal_shape(a_poly), it->style_ptr()));
it++;
nit++;
}
@@ -2068,11 +2068,11 @@ bool cgal_kernel::convert_impl(const taxonomy::boolean_result::ptr br, std::vect
}
for (auto it = cr.begin(); it != cr.end(); ++it) {
cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast<cgal_shape>(it->Shape());
cgal_polyhedron entity_shape_unlocated = *std::static_pointer_cast<cgal_shape>(it->shape());
cgal_polyhedron entity_shape(entity_shape_unlocated);
if (!it->Placement()->is_identity()) {
if (!it->placement()->is_identity()) {
cgal_placement trsf;
convert_placement(it->Placement(), trsf);
convert_placement(it->placement(), trsf);
for (auto &vertex : vertices(entity_shape)) {
vertex->point() = vertex->point().transform(trsf);
}
@@ -215,7 +215,7 @@ std::optional<manifold::Manifold> ifcopenshell::geom::manifold_shape::as_manifol
return manifold::Manifold::BatchBoolean(solids, manifold::OpType::Add);
}
void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
void ifcopenshell::geom::manifold_shape::triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
for (const auto& part : parts_) {
auto mesh = transform_mesh(part.mesh, place);
std::vector<int> indices(mesh.NumVert());
@@ -250,7 +250,7 @@ void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::setting
}
}
void ifcopenshell::geom::manifold_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const {
void ifcopenshell::geom::manifold_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const {
std::stringstream stream;
stream << std::setprecision(17);
size_t offset = 0;
@@ -40,8 +40,8 @@ public:
std::optional<manifold::Manifold> as_manifold() const;
virtual std::string_view backend_id() const { return "manifold"; }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual void triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const;
virtual bool is_manifold() const;
@@ -1412,7 +1412,7 @@ namespace {
}
for (const auto& result : results) {
if (result.hasStyle()) {
return result.StylePtr();
return result.style_ptr();
}
}
return nullptr;
@@ -1650,7 +1650,7 @@ bool manifold_kernel::convert_openings(const express::base&, const std::vector<s
return false;
}
for (const auto& result : converted) {
auto moved = std::unique_ptr<ifcopenshell::geom::conversion_result_shape>(result.Shape()->moved(taxonomy::make<taxonomy::matrix4>(relative->ccomponents() * result.Placement()->ccomponents())));
auto moved = std::unique_ptr<ifcopenshell::geom::conversion_result_shape>(result.shape()->moved(taxonomy::make<taxonomy::matrix4>(relative->ccomponents() * result.placement()->ccomponents())));
auto* shape = dynamic_cast<ifcopenshell::geom::manifold_shape*>(moved.get());
if (!shape) {
ifcopenshell::logger::root().warning("Manifold kernel: opening result is not a manifold shape");
@@ -1679,7 +1679,7 @@ bool manifold_kernel::convert_openings(const express::base&, const std::vector<s
cut_shapes.emplace_back(ifcopenshell::geom::conversion_result(
entity_shape.ItemId(),
new ifcopenshell::geom::manifold_shape(result),
entity_shape.StylePtr()));
entity_shape.style_ptr()));
}
return !cut_shapes.empty();
}
@@ -812,7 +812,7 @@ bool ifcopenshell::geom::util::flatten_shape_list(const std::vector<ifcopenshell
for (std::vector<ifcopenshell::geom::conversion_result>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
TopoDS_Shape merged;
const TopoDS_Shape& s = std::static_pointer_cast<ifcopenshell::geom::open_cascade_shape>(it->Shape())->shape();
const TopoDS_Shape& s = std::static_pointer_cast<ifcopenshell::geom::open_cascade_shape>(it->shape())->shape();
if (fuse || create_shell) {
merged = util::ensure_fit_for_subtraction(s, tol);
} else {
@@ -820,7 +820,7 @@ bool ifcopenshell::geom::util::flatten_shape_list(const std::vector<ifcopenshell
}
// @todo refactor, also should be GTrsf
const auto& m = it->Placement()->ccomponents();
const auto& m = it->placement()->ccomponents();
gp_Trsf trsf;
trsf.SetValues(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
@@ -122,13 +122,13 @@ bool open_cascade_kernel::convert_impl(const taxonomy::boolean_result::ptr br, s
} else {
for (auto& r : cr) {
auto S = std::static_pointer_cast<open_cascade_shape>(r.Shape())->shape();
auto S = std::static_pointer_cast<open_cascade_shape>(r.shape())->shape();
if (S.IsNull()) {
logger_.error("GEO", 120, "Null operand");
continue;
}
gp_GTrsf trsf;
convert(r.Placement(), trsf);
convert(r.placement(), trsf);
// @todo it really confuses me why I cannot use Moved() here instead
S.Location(S.Location() * trsf.Trsf());
+12 -12
View File
@@ -251,9 +251,9 @@ bool ifcopenshell::geom::util::apply_folded_layerset(const std::vector<conversio
for (std::vector<conversion_result>::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
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())));
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->style_ptr())));
result.push_back(conversion_result(it->ItemId(), it->placement(), new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->style_ptr())));
} else {
continue;
}
@@ -265,13 +265,13 @@ bool ifcopenshell::geom::util::apply_folded_layerset(const std::vector<conversio
for (std::vector<conversion_result>::const_iterator it = items.begin(); it != items.end(); ++it) {
const TopoDS_Shape& s = std::static_pointer_cast<open_cascade_shape>(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(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(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->style_ptr())));
}
} else {
return false;
@@ -293,9 +293,9 @@ bool ifcopenshell::geom::util::apply_layerset(const std::vector<conversion_resul
for (std::vector<conversion_result>::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
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())));
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->style_ptr())));
result.push_back(conversion_result(it->ItemId(), it->placement(),new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->style_ptr())));
} else {
continue;
}
@@ -310,7 +310,7 @@ bool ifcopenshell::geom::util::apply_layerset(const std::vector<conversion_resul
// layer operations are applied in the correct order. This seems to be always the case.
Bnd_Box bb;
for (std::vector<conversion_result>::const_iterator it = items.begin(); it != items.end(); ++it) {
BRepBndLib::Add(it->Shape(), bb);
BRepBndLib::Add(it->shape(), bb);
}
double x1, y1, z1, x2, y2, z2;
@@ -336,7 +336,7 @@ bool ifcopenshell::geom::util::apply_layerset(const std::vector<conversion_resul
for (std::vector<conversion_result>::const_iterator it = items.begin(); it != items.end(); ++it) {
const TopoDS_Shape& s = std::static_pointer_cast<open_cascade_shape>(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 ifcopenshell::geom::util::apply_layerset(const std::vector<conversion_resul
/*
// enable this is you want to see how IfcOpenShell has placed the layer surfaces
for (auto& x : operands) {
result.push_back(conversion_result(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(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(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->style_ptr())));
}
} else {
return false;
@@ -68,7 +68,7 @@ ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::open_cascade_sh
return new open_cascade_shape(shape_);
}
void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
void ifcopenshell::geom::open_cascade_shape::triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger) const {
// @todo remove duplication with open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// above can be static?
@@ -104,7 +104,7 @@ void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::set
}
}
if (!has_triangulation) {
// Triangulate the shape
// triangulate the shape
try {
BRepMesh_IncrementalMesh(shape_, settings.get<settings::MesherLinearDeflection>().get(), false, settings.get<settings::MesherAngularDeflection>().get());
} catch (...) {
@@ -372,7 +372,7 @@ void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::set
}
}
void ifcopenshell::geom::open_cascade_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
void ifcopenshell::geom::open_cascade_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
auto s = ifcopenshell::geom::util::apply_transformation(shape_, place);
std::stringstream sstream;
#if OCC_VERSION_HEX >= 0x70600
@@ -49,8 +49,8 @@ namespace ifcopenshell {
operator const TopoDS_Shape& ();
virtual std::string_view backend_id() const;
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual void triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual ifcopenshell::geom::conversion_result_shape* clone() const;
@@ -89,10 +89,10 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba
abstract_kernel::convert(op.first, opening_shapes);
for (unsigned int i = 0; i < opening_shapes.size(); ++i) {
auto opening_shape_i = std::static_pointer_cast<open_cascade_shape>(opening_shapes[i].Shape())->shape();
auto opening_shape_i = std::static_pointer_cast<open_cascade_shape>(opening_shapes[i].shape())->shape();
const TopoDS_Shape& opening_shape_unlocated = util::ensure_fit_for_subtraction(opening_shape_i, settings_.get<settings::Precision>().get());
auto gtrsf = opening_shapes[i].Placement();
auto gtrsf = opening_shapes[i].placement();
// @todo check
Eigen::Matrix4d m = relative * gtrsf->ccomponents();
gp_Trsf trsf;
@@ -119,7 +119,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba
std::list<TopoDS_Shape> parts;
auto it3_shape = std::static_pointer_cast<open_cascade_shape>(it3->Shape())->shape();
auto it3_shape = std::static_pointer_cast<open_cascade_shape>(it3->shape())->shape();
if (it3_shape.IsNull()) {
logger_.error("GEO", 187, "Null operand");
continue;
@@ -187,7 +187,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba
} else {
entity_shape_unlocated = util::ensure_fit_for_subtraction(entity_part, settings_.get<settings::Precision>().get());
}
const auto& m = it3->Placement()->ccomponents();
const auto& m = it3->placement()->ccomponents();
// @todo
// if (entity_shape_gtrsf.Form() == gp_Other) {
// ifcopenshell::logger::root().message(ifcopenshell::logger::LOG_WARNING, "Applying non uniform transformation to:", entity);
@@ -262,19 +262,19 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::ba
combined_result = C;
}
cut_shapes.push_back(ifcopenshell::geom::conversion_result(it3->ItemId(), new open_cascade_shape(combined_result), it3->StylePtr()));
cut_shapes.push_back(ifcopenshell::geom::conversion_result(it3->ItemId(), new open_cascade_shape(combined_result), it3->style_ptr()));
}
return true;
}
bool ifcopenshell::geom::open_cascade_kernel::unify_shapes(const std::vector<ifcopenshell::geom::conversion_result>& input, std::vector<ifcopenshell::geom::conversion_result>& output) {
std::transform(input.begin(), input.end(), std::back_inserter(output), [this](auto v) {
auto& s = std::static_pointer_cast<open_cascade_shape>(v.Shape())->shape();
auto& s = std::static_pointer_cast<open_cascade_shape>(v.shape())->shape();
return ifcopenshell::geom::conversion_result(
v.ItemId(),
v.Placement(),
v.placement(),
new open_cascade_shape(util::unify(s, settings_.get<ifcopenshell::geom::settings::Precision>().get())),
v.StylePtr());
v.style_ptr());
});
return true;
}
@@ -439,7 +439,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// } else {
// bool some_items_without_style = false;
// for (std::vector<ifcopenshell::geom::conversion_result>::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// if (!it->hasStyle() && util::count(it->Shape(), TopAbs_FACE)) {
// if (!it->hasStyle() && util::count(it->shape(), TopAbs_FACE)) {
// some_items_without_style = true;
// break;
// }
@@ -457,7 +457,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// for (auto& s : shapes) {
// if (s.hasStyle()) {
// for (auto& p : style_cache) {
// if (p.second == s.StylePtr()) {
// if (p.second == s.style_ptr()) {
// std::const_pointer_cast<ifcopenshell::geom::SurfaceStyle>(p.second)->Transparency() = settings.force_space_transparency();
// }
// }
@@ -604,7 +604,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// int genus = (int)q2->as<IfcSchema::IfcQuantityCount>()->CountValue();
// for (auto& part : elem->geometry()) {
// if (part.ItemId() == item_id) {
// if (util::surface_genus(part.Shape()) != genus) {
// if (util::surface_genus(part.shape()) != genus) {
// all_succeeded = false;
// }
// }
@@ -779,7 +779,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
//
// TopoDS_Vertex a, b;
// for (std::vector<conversion_result>::const_iterator it = items.begin(); it != items.end(); ++it) {
// TopExp_Explorer exp(it->Shape(), TopAbs_VERTEX);
// TopExp_Explorer exp(it->shape(), TopAbs_VERTEX);
// for (; exp.More(); exp.Next()) {
// b = TopoDS::Vertex(exp.Current());
// if (a.IsNull()) {
+2 -2
View File
@@ -1771,11 +1771,11 @@ namespace ifcopenshell::geom {
TopoDS_Iterator it(compound);
for (; it.More(); it.Next(), ++git) {
// Assumption is that the number of styles is small, so the linear lookup time is not significant.
auto sit = std::find(styles_.begin(), styles_.end(), git->StylePtr());
auto sit = std::find(styles_.begin(), styles_.end(), git->style_ptr());
size_t index;
if (sit == styles_.end()) {
index = styles_.size();
styles_.push_back(git->StylePtr());
styles_.push_back(git->style_ptr());
} else {
index = std::distance(styles_.begin(), sit);
}
@@ -286,7 +286,7 @@ ifcopenshell::geom::passthrough_shape::passthrough_shape(const std::vector<passt
ifcopenshell::geom::passthrough_shape::passthrough_shape(std::vector<passthrough_part>&& parts)
: parts_(normalize_parts(parts)) {}
void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
void ifcopenshell::geom::passthrough_shape::triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger&) const {
auto mesh = build_mesh(parts_, &place);
std::vector<int> indices(mesh.vertices.size());
for (size_t i = 0; i < mesh.vertices.size(); ++i) {
@@ -302,7 +302,7 @@ void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::sett
}
}
void ifcopenshell::geom::passthrough_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const {
void ifcopenshell::geom::passthrough_shape::serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const {
auto mesh = build_mesh(parts_, &place);
std::stringstream stream;
for (const auto& vertex : mesh.vertices) {
@@ -24,8 +24,8 @@ public:
const std::vector<passthrough_part>& parts() const { return parts_; }
virtual std::string_view backend_id() const { return "passthrough"; }
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual void triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::triangulation* t, int item_id, int surface_style_id, ifcopenshell::logger& logger = ifcopenshell::logger::root()) const;
virtual void serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual int surface_genus() const;
virtual bool is_manifold() const;
+11 -11
View File
@@ -26,20 +26,20 @@ ifcopenshell::geom::serialization::serialization(const brep& brep)
int sid = -1;
if (it->hasStyle()) {
const auto& clr = it->Style().get_color().ccomponents();
const auto& clr = it->style().get_color().ccomponents();
surface_styles_.push_back(clr(0));
surface_styles_.push_back(clr(1));
surface_styles_.push_back(clr(2));
sid = it->Style().instance ? it->Style().instance.id() : -1;
sid = it->style().instance ? it->style().instance.id() : -1;
} else {
surface_styles_.push_back(-1.);
surface_styles_.push_back(-1.);
surface_styles_.push_back(-1.);
}
if (it->hasStyle() && it->Style().has_transparency()) {
surface_styles_.push_back(1. - it->Style().transparency);
if (it->hasStyle() && it->style().has_transparency()) {
surface_styles_.push_back(1. - it->style().transparency);
} else {
surface_styles_.push_back(1.);
}
@@ -49,7 +49,7 @@ ifcopenshell::geom::serialization::serialization(const brep& brep)
ifcopenshell::geom::taxonomy::matrix4 identity;
auto* comp = brep.as_compound();
comp->Serialize(identity, brep_data_);
comp->serialize(identity, brep_data_);
delete comp;
}
@@ -100,9 +100,9 @@ bool ifcopenshell::geom::brep::calculate_projected_surface_area(const ifcopenshe
for (std::vector<ifcopenshell::geom::conversion_result>::const_iterator it = begin(); it != end(); ++it) {
double x, y, z;
it->Shape()->surface_area_along_direction(settings().get<ifcopenshell::geom::settings::MesherLinearDeflection>().get(), place, x, y, z);
it->shape()->surface_area_along_direction(settings().get<ifcopenshell::geom::settings::MesherLinearDeflection>().get(), place, x, y, z);
if (it->Shape()->is_manifold()) {
if (it->shape()->is_manifold()) {
x /= 2.;
y /= 2.;
z /= 2.;
@@ -127,10 +127,10 @@ ifcopenshell::geom::triangulation::triangulation(const brep& shape_model)
int surface_style_id = -1;
if (iit->hasStyle()) {
auto jt = std::find(materials_.begin(), materials_.end(), iit->StylePtr());
auto jt = std::find(materials_.begin(), materials_.end(), iit->style_ptr());
if (jt == materials_.end()) {
surface_style_id = (int)materials_.size();
materials_.push_back(iit->StylePtr());
materials_.push_back(iit->style_ptr());
} else {
surface_style_id = (int)(jt - materials_.begin());
}
@@ -147,7 +147,7 @@ ifcopenshell::geom::triangulation::triangulation(const brep& shape_model)
}
}
iit->Shape()->Triangulate(settings(), *iit->Placement(), this, iit->ItemId(), surface_style_id);
iit->shape()->triangulate(settings(), *iit->placement(), this, iit->ItemId(), surface_style_id);
}
}
@@ -212,7 +212,7 @@ void ifcopenshell::geom::triangulation::registerEdgeCount(int n1, int n2, std::m
const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::item(int i) const {
if (i >= 0 && i < shapes_.size()) {
return shapes_[i].Shape()->moved(shapes_[i].Placement());
return shapes_[i].shape()->moved(shapes_[i].placement());
} else {
return nullptr;
}
@@ -142,8 +142,8 @@ class ConversionResult:
def setStyle(self, newStyle): ...
class ConversionResultShape:
def Serialize(self, place, arg3): ...
def Triangulate(self, *args): ...
def serialize(self, place, arg3): ...
def triangulate(self, *args): ...
def __init__(self, *args, **kwargs): ...
def add(self, arg2): ...
def area(self): ...
+3 -3
View File
@@ -1168,7 +1168,7 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf
%extend ifcopenshell::geom::conversion_result_shape {
std::string serialize_obj() {
ifcopenshell::geom::settings settings;
std::unique_ptr<ifcopenshell::geom::triangulation> triangulation($self->Triangulate(settings));
std::unique_ptr<ifcopenshell::geom::triangulation> triangulation($self->triangulate(settings));
std::ostringstream result;
for (auto it = triangulation->verts().begin(); it != triangulation->verts().end();) {
@@ -1204,7 +1204,7 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf
std::string serialize() {
std::string result;
ifcopenshell::geom::taxonomy::matrix4 iden;
$self->Serialize(iden, result);
$self->serialize(iden, result);
return result;
}
@@ -1317,7 +1317,7 @@ ifcopenshell::geom::taxonomy::item::ptr try_upcast(PyObject* obj0, swig_type_inf
std::string serialize() {
std::string result;
ifcopenshell::geom::taxonomy::matrix4 iden;
$self->Serialize(iden, result);
$self->serialize(iden, result);
return result;
}