Expose geometry types in snake case

Generated with the assistance of an AI coding tool.
This commit is contained in:
Thomas Krijnen
2026-08-09 04:44:18 +02:00
parent fbfa51c451
commit be3c2ee770
49 changed files with 300 additions and 287 deletions
+5 -5
View File
@@ -740,7 +740,7 @@ class IfcImporter:
self.update_progress((percent_average / 100 * progress_range) + start_progress)
shape = iterator.get()
if shape:
assert isinstance(shape, W.TriangulationElement)
assert isinstance(shape, W.triangulation_element)
product = self.file.by_id(shape.id)
self.create_product(product, shape)
results.add(product)
@@ -1079,9 +1079,9 @@ class IfcImporter:
def create_curve(
self,
element: ifcopenshell.entity_instance,
shape: Union[W.Triangulation, W.TriangulationElement],
shape: Union[W.triangulation, W.triangulation_element],
) -> bpy.types.Curve:
if isinstance(shape, W.TriangulationElement):
if isinstance(shape, W.triangulation_element):
geometry = shape.geometry
else:
geometry = shape
@@ -1112,11 +1112,11 @@ class IfcImporter:
def create_mesh(
self,
element: ifcopenshell.entity_instance,
shape: Union[W.Triangulation, W.TriangulationElement],
shape: Union[W.triangulation, W.triangulation_element],
cartesian_point_offset: Union[npt.NDArray[np.float64], Literal[False]] = None,
) -> Union[bpy.types.Mesh, None]:
try:
if isinstance(shape, W.TriangulationElement):
if isinstance(shape, W.triangulation_element):
# shape is ShapeElementType
geometry = shape.geometry
else:
@@ -708,7 +708,7 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator):
while True:
tree.add_element(iterator.get_native())
shape = iterator.get()
assert isinstance(shape, W.TriangulationElement)
assert isinstance(shape, W.triangulation_element)
shapes[shape.id] = {
"verts": ifcopenshell.util.shape.get_vertices(shape.geometry),
"faces": ifcopenshell.util.shape.get_faces(shape.geometry),
@@ -313,7 +313,7 @@ class CreateAllShapes(bpy.types.Operator):
failures.append(element)
print("***** FAILURE *****")
if shape:
assert isinstance(shape, W.TriangulationElement)
assert isinstance(shape, W.triangulation_element)
geom = shape.geometry
print(
f"Success {time.time() - start:.3f}s "
@@ -106,7 +106,7 @@ class ExportOBJ(bpy.types.Operator):
if iterator.initialize():
while True:
shape = iterator.get()
assert isinstance(shape, W.TriangulationElement)
assert isinstance(shape, W.triangulation_element)
materials = shape.geometry.materials
for material in materials:
@@ -2442,7 +2442,7 @@ class LoadLinkedProject(bpy.types.Operator, ImportHelper):
if iterator.initialize():
while True: # Main loop.
shape = iterator.get()
assert isinstance(shape, W.TriangulationElement)
assert isinstance(shape, W.triangulation_element)
results.add(self.file.by_id(shape.id))
geometry = shape.geometry
@@ -2518,7 +2518,7 @@ class LoadLinkedProject(bpy.types.Operator, ImportHelper):
print("Finished", time.time() - start)
return {"FINISHED"}
def process_occurrence(self, shape: W.TriangulationElement) -> None:
def process_occurrence(self, shape: W.triangulation_element) -> None:
element = self.file.by_id(shape.id)
mat = ifcopenshell.util.shape.get_shape_matrix(shape)
+1 -1
View File
@@ -1187,7 +1187,7 @@ class Geometry(bonsai.core.tool.Geometry):
if iterator and iterator.initialize():
while True:
shape = iterator.get()
assert isinstance(shape, W.TriangulationElement)
assert isinstance(shape, W.triangulation_element)
element = tool.Ifc.get().by_id(shape.id)
if obj := tool.Ifc.get_object(element):
# It's possible that there will be multiple shapes for the same context,
+2 -2
View File
@@ -872,7 +872,7 @@ class Loader(bonsai.core.tool.Loader):
cls,
element: ifcopenshell.entity_instance,
representation: ifcopenshell.entity_instance,
shape: W.TriangulationElement,
shape: W.triangulation_element,
) -> bpy.types.Camera:
"""Create camera data.
@@ -1026,7 +1026,7 @@ class Loader(bonsai.core.tool.Loader):
@classmethod
def convert_geometry_to_mesh(
cls,
geometry: W.Triangulation,
geometry: W.triangulation,
mesh: bpy.types.Mesh,
verts: Optional[npt.NDArray[np.float64]] = None,
*,
+1 -1
View File
@@ -2459,7 +2459,7 @@ class Model(bonsai.core.tool.Model):
polygons = {}
for curve in curves:
geometry = ifcopenshell.geom.create_shape(settings, curve)
assert isinstance(geometry, W.Triangulation)
assert isinstance(geometry, W.triangulation)
v = ifcopenshell.util.shape.get_vertices(geometry, is_2d=True)
v = np.round(v, 4) # Round to nearest 0.1mm, otherwise things like circles don't polygonise reliably
edges = ifcopenshell.util.shape.get_edges(geometry)
+1 -1
View File
@@ -53,7 +53,7 @@ class Profile(bonsai.core.tool.Profile):
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(settings, profile)
assert isinstance(shape, W.Triangulation)
assert isinstance(shape, W.triangulation)
verts = ifcopenshell.util.shape.get_vertices(shape)
if verts.size == 0:
raise RuntimeError(f"Profile shape has no vertices, it probably is invalid: '{profile}'.")
+1 -1
View File
@@ -206,7 +206,7 @@ class context:
Args:
file (ifcopenshell.file): file containing elem
elem (TriangulationElement): triangulated geometry
elem (triangulation_element): triangulated geometry
min_thickness (float, optional): minimal thickness of the oriented bounding box to create around elem
Returns:
+1 -1
View File
@@ -518,7 +518,7 @@ class IfcOpenShell(QtoCalculator):
area_shape = ifcopenshell.geom.create_shape(settings, item.SweptArea)
except RuntimeError:
return
assert isinstance(area_shape, W.Triangulation)
assert isinstance(area_shape, W.triangulation)
x = ifcopenshell.util.shape.get_x(area_shape) / cls.unit_scale
y = ifcopenshell.util.shape.get_y(area_shape) / cls.unit_scale
z = item.Depth
+4 -4
View File
@@ -923,7 +923,7 @@ int main(int argc, char** argv) {
// The functions ifcopenshell::geom::iterator::get() and ifcopenshell::geom::iterator::next()
// wrap an iterator of all geometrical products in the Ifc file.
// ifcopenshell::geom::iterator::get() returns an ifcopenshell::geom::triangulation_element or
// -brep_element pointer, based on current settings. (see iterator.h
// -native_element pointer, based on current settings. (see iterator.h
// for definition) ifcopenshell::geom::iterator::next() is used to poll whether more
// geometrical entities are available. None of these functions throw
// exceptions, neither for parsing errors or geometrical errors. Upon
@@ -942,7 +942,7 @@ int main(int argc, char** argv) {
}
else
{
serializer->write(static_cast<const ifcopenshell::geom::brep_element*>(geom_object.get()));
serializer->write(static_cast<const ifcopenshell::geom::native_element*>(geom_object.get()));
}
if (!no_progress) {
@@ -1406,14 +1406,14 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st
express::base quantity;
std::vector<express::base> objects;
std::shared_ptr<ifcopenshell::geom::brep> previous_geometry_pointer;
std::shared_ptr<ifcopenshell::geom::native> previous_geometry_pointer;
for (;; ++num_created) {
bool has_more = true;
if (num_created) {
has_more = context_iterator.next();
}
std::unique_ptr<ifcopenshell::geom::brep_element> geom_object;
std::unique_ptr<ifcopenshell::geom::native_element> geom_object;
if (has_more) {
geom_object = context_iterator.get_native();
}
@@ -111,7 +111,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet,
if (num_created) {
has_more = context_iterator.next();
}
std::unique_ptr<ifcopenshell::geom::brep_element> geom_object;
std::unique_ptr<ifcopenshell::geom::native_element> geom_object;
if (has_more) {
geom_object = context_iterator.get_native();
}
+1 -1
View File
@@ -477,7 +477,7 @@ struct intersection_validator {
if (num_created) {
has_more = context_iterator.next();
}
std::unique_ptr<ifcopenshell::geom::brep_element> geom_object;
std::unique_ptr<ifcopenshell::geom::native_element> geom_object;
if (has_more) {
geom_object = context_iterator.get_native();
}
+8 -8
View File
@@ -17,7 +17,7 @@ ifcopenshell::geom::converter::~converter() {
delete mapping_;
}
ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const express::base product_, const taxonomy::matrix4::ptr& place_) {
ifcopenshell::geom::native_element* ifcopenshell::geom::converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const express::base product_, const taxonomy::matrix4::ptr& place_) {
auto product = product_.as<express::entity>();
std::stringstream representation_id_builder;
@@ -26,7 +26,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
representation_id_builder << representation_node->instance.id();
ifcopenshell::geom::brep* shape;
ifcopenshell::geom::native* shape;
std::vector<ifcopenshell::geom::conversion_result> shapes;
if (!kernel_->convert(representation_node, shapes)) {
@@ -237,7 +237,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
}
}
shape = new ifcopenshell::geom::brep(settings_, product_type, representation_id_builder.str(), shapes);
shape = new ifcopenshell::geom::native(settings_, product_type, representation_id_builder.str(), shapes);
std::string context_string = "";
@@ -255,7 +255,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
}
}
auto elem = new ifcopenshell::geom::brep_element(
auto elem = new ifcopenshell::geom::native_element(
product.id(),
parent_id,
name,
@@ -263,7 +263,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
guid,
context_string,
place,
std::shared_ptr<ifcopenshell::geom::brep>(shape),
std::shared_ptr<ifcopenshell::geom::native>(shape),
product
);
@@ -342,7 +342,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
return elem;
}
ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for_processed_representation(const express::base product_, const taxonomy::matrix4::ptr& place, ifcopenshell::geom::brep_element* brep) {
ifcopenshell::geom::native_element* ifcopenshell::geom::converter::create_brep_for_processed_representation(const express::base product_, const taxonomy::matrix4::ptr& place, ifcopenshell::geom::native_element* brep) {
auto product = product_.as<express::entity>();
int parent_id = -1;
@@ -360,7 +360,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
const std::string product_type = product.declaration().name();
const std::string context_string = brep->context();
return new ifcopenshell::geom::brep_element(
return new ifcopenshell::geom::native_element(
product.id(),
parent_id,
name,
@@ -373,7 +373,7 @@ ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for
);
}
ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for_representation_and_product(const express::base representation, const express::base product) {
ifcopenshell::geom::native_element* ifcopenshell::geom::converter::create_brep_for_representation_and_product(const express::base representation, const express::base product) {
auto interpreted_representation = mapping_->map(representation);
if (!interpreted_representation) {
interpreted_representation = taxonomy::make<taxonomy::collection>();
+5 -5
View File
@@ -15,7 +15,7 @@ namespace ifcopenshell { namespace geom {
class IFC_GEOM_API converter {
public:
typedef std::shared_ptr<ifcopenshell::geom::brep> brep_ptr;
typedef std::shared_ptr<ifcopenshell::geom::native> brep_ptr;
private:
ifcopenshell::geom::abstract_mapping* mapping_;
std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel> kernel_;
@@ -47,11 +47,11 @@ namespace ifcopenshell { namespace geom {
std::vector<ifcopenshell::geom::conversion_result> convert(express::base item);
ifcopenshell::geom::brep_element* create_brep_for_representation_and_product(const express::base representation, const express::base product);
// ifcopenshell::geom::brep_element* create_brep_for_processed_representation(const express::base representation, const express::base product, ifcopenshell::geom::brep_element* brep);
ifcopenshell::geom::native_element* create_brep_for_representation_and_product(const express::base representation, const express::base product);
// ifcopenshell::geom::native_element* create_brep_for_processed_representation(const express::base representation, const express::base product, ifcopenshell::geom::native_element* brep);
ifcopenshell::geom::brep_element* create_brep_for_representation_and_product(ifcopenshell::geom::taxonomy::ptr, const express::base product, const ifcopenshell::geom::taxonomy::matrix4::ptr& place);
ifcopenshell::geom::brep_element* create_brep_for_processed_representation(const express::base product, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, ifcopenshell::geom::brep_element*);
ifcopenshell::geom::native_element* create_brep_for_representation_and_product(ifcopenshell::geom::taxonomy::ptr, const express::base product, const ifcopenshell::geom::taxonomy::matrix4::ptr& place);
ifcopenshell::geom::native_element* create_brep_for_processed_representation(const express::base product, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, ifcopenshell::geom::native_element*);
const ifcopenshell::geom::settings& settings() { return settings_; }
};
+11 -11
View File
@@ -158,14 +158,14 @@ namespace ifcopenshell::geom {
virtual ~element() {}
};
class brep_element : public element {
class native_element : public element {
private:
std::shared_ptr<ifcopenshell::geom::brep> _geometry;
std::shared_ptr<ifcopenshell::geom::native> _geometry;
public:
const std::shared_ptr<ifcopenshell::geom::brep>& geometry_pointer() const { return _geometry; }
const ifcopenshell::geom::brep& geometry() const { return *_geometry; }
brep_element(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid,
const std::string& context, const ifcopenshell::geom::taxonomy::matrix4::ptr& trsf, const std::shared_ptr<ifcopenshell::geom::brep>& geometry,
const std::shared_ptr<ifcopenshell::geom::native>& geometry_pointer() const { return _geometry; }
const ifcopenshell::geom::native& geometry() const { return *_geometry; }
native_element(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid,
const std::string& context, const ifcopenshell::geom::taxonomy::matrix4::ptr& trsf, const std::shared_ptr<ifcopenshell::geom::native>& geometry,
const express::entity& product)
: element(geometry->settings(), id, parent_id, name, type, guid, context, trsf, product)
, _geometry(geometry)
@@ -174,10 +174,10 @@ namespace ifcopenshell::geom {
bool calculate_projected_surface_area(double& along_x, double& along_y, double& along_z) const {
return geometry().calculate_projected_surface_area(this->transformation().data(), along_x, along_y, along_z);
}
brep_element(const brep_element& other) = default;
native_element(const native_element& other) = default;
private:
brep_element& operator=(const brep_element& other);
std::unique_ptr<element> clone() const override { return std::make_unique<brep_element>(*this); }
native_element& operator=(const native_element& other);
std::unique_ptr<element> clone() const override { return std::make_unique<native_element>(*this); }
};
class triangulation_element : public element {
@@ -186,7 +186,7 @@ namespace ifcopenshell::geom {
public:
const ifcopenshell::geom::triangulation& geometry() const { return *_geometry; }
const std::shared_ptr< ifcopenshell::geom::triangulation>& geometry_pointer() const { return _geometry; }
triangulation_element(const ifcopenshell::geom::brep_element& shape_model)
triangulation_element(const ifcopenshell::geom::native_element& shape_model)
: element(shape_model)
, _geometry(std::make_shared<ifcopenshell::geom::triangulation>(shape_model.geometry()))
{}
@@ -205,7 +205,7 @@ namespace ifcopenshell::geom {
std::shared_ptr<ifcopenshell::geom::serialization> _geometry;
public:
const ifcopenshell::geom::serialization& geometry() const { return *_geometry; }
serialized_element(const brep_element& shape_model)
serialized_element(const native_element& shape_model)
: element(shape_model)
, _geometry(std::make_shared<ifcopenshell::geom::serialization>(shape_model.geometry()))
{}
+4 -4
View File
@@ -21,7 +21,7 @@ inline taxonomy::function_item::ptr convert_loop_to_function_item(taxonomy::loop
/// @brief Abstract class for evaluating a function_item. This class is specialized for each of the function_item types.
struct IFC_GEOM_API fn_evaluator {
fn_evaluator(const ifcopenshell::geom::settings& settings, logger& logger = ifcopenshell::logger::root()) : settings_(settings), logger_(logger) {
fn_evaluator(const ifcopenshell::geom::settings& settings, ifcopenshell::logger& logger = ifcopenshell::logger::root()) : settings_(settings), logger_(logger) {
}
fn_evaluator(const fn_evaluator& other) = default;
virtual ~fn_evaluator() = default;
@@ -36,13 +36,13 @@ struct IFC_GEOM_API fn_evaluator {
ifcopenshell::geom::settings settings_;
protected:
logger& logger_;
ifcopenshell::logger& logger_;
};
/// @brief utility class to evaluate function_item objects.
class IFC_GEOM_API function_item_evaluator {
public:
function_item_evaluator(const ifcopenshell::geom::settings& settings, taxonomy::function_item::const_ptr fn, logger& logger = ifcopenshell::logger::root());
function_item_evaluator(const ifcopenshell::geom::settings& settings, taxonomy::function_item::const_ptr fn, ifcopenshell::logger& logger = ifcopenshell::logger::root());
function_item_evaluator(const function_item_evaluator& other);
~function_item_evaluator();
@@ -78,7 +78,7 @@ class IFC_GEOM_API function_item_evaluator {
fn_evaluator* fn_evaluator_ = nullptr;
mutable std::optional<std::vector<double>> eval_points_; // cache evaluation points
logger& logger_;
ifcopenshell::logger& logger_;
};
}}
+1 -1
View File
@@ -76,7 +76,7 @@ public:
virtual bool isTesselated() const = 0;
virtual void write(const ifcopenshell::geom::triangulation_element* o) = 0;
virtual void write(const ifcopenshell::geom::brep_element* o) = 0;
virtual void write(const ifcopenshell::geom::native_element* o) = 0;
virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) = 0;
virtual ifcopenshell::geom::element* read(ifcopenshell::file& f, const std::string& guid, const std::string& representation_id, read_type rt = READ_BREP) = 0;
+3 -3
View File
@@ -382,7 +382,7 @@ void ifcopenshell::geom::iterator::create_element_(ifcopenshell::geom::converter
kernel_logger.set_product(product);
ifcopenshell::geom::brep_element* brep = static_cast<ifcopenshell::geom::brep_element*>(create_processed_element_([kernel, settings, product, place, rep]() {
ifcopenshell::geom::native_element* brep = static_cast<ifcopenshell::geom::native_element*>(create_processed_element_([kernel, settings, product, place, rep]() {
return kernel->create_brep_for_representation_and_product(rep->item, product, place);
}));
@@ -407,7 +407,7 @@ void ifcopenshell::geom::iterator::create_element_(ifcopenshell::geom::converter
kernel_logger.set_product(product2);
ifcopenshell::geom::brep_element* brep2 = static_cast<ifcopenshell::geom::brep_element*>(create_processed_element_([kernel, settings, product2, place2, brep]() {
ifcopenshell::geom::native_element* brep2 = static_cast<ifcopenshell::geom::native_element*>(create_processed_element_([kernel, settings, product2, place2, brep]() {
return kernel->create_brep_for_processed_representation(product2, place2, brep);
}));
if (brep2) {
@@ -422,7 +422,7 @@ void ifcopenshell::geom::iterator::create_element_(ifcopenshell::geom::converter
kernel_logger.set_product(std::optional<express::base>{});
}
ifcopenshell::geom::element* ifcopenshell::geom::iterator::process_based_on_settings(ifcopenshell::geom::settings settings, ifcopenshell::geom::brep_element* elem, ifcopenshell::logger& logger, ifcopenshell::geom::triangulation_element* previous)
ifcopenshell::geom::element* ifcopenshell::geom::iterator::process_based_on_settings(ifcopenshell::geom::settings settings, ifcopenshell::geom::native_element* elem, ifcopenshell::logger& logger, ifcopenshell::geom::triangulation_element* previous)
{
if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::SERIALIZED) {
try {
+7 -7
View File
@@ -93,7 +93,7 @@ namespace ifcopenshell::geom {
express::base representation;
std::vector<express::base> products_2;
std::vector<ifcopenshell::geom::brep_element*> breps;
std::vector<ifcopenshell::geom::native_element*> breps;
std::vector<ifcopenshell::geom::element*> elements;
bool is_parallel() const {
@@ -113,10 +113,10 @@ namespace ifcopenshell::geom {
std::vector<geometry_conversion_result>::iterator task_iterator_;
std::list<ifcopenshell::geom::element*> all_processed_elements_;
std::list<ifcopenshell::geom::brep_element*> all_processed_native_elements_;
std::list<ifcopenshell::geom::native_element*> all_processed_native_elements_;
std::list<ifcopenshell::geom::element*>::const_iterator task_result_iterator_;
std::list<ifcopenshell::geom::brep_element*>::const_iterator native_task_result_iterator_;
std::list<ifcopenshell::geom::native_element*>::const_iterator native_task_result_iterator_;
std::mutex element_ready_mutex_;
bool task_result_ptr_initialized = false;
@@ -139,7 +139,7 @@ namespace ifcopenshell::geom {
// The object is fetched beforehand to be sure that get() returns a valid element
triangulation_element* current_triangulation;
brep_element* current_shape_model;
native_element* current_shape_model;
serialized_element* current_serialization;
double lowest_precision_encountered;
@@ -169,7 +169,7 @@ namespace ifcopenshell::geom {
ifcopenshell::geom::element* process_based_on_settings(
ifcopenshell::geom::settings settings,
ifcopenshell::geom::brep_element* elem,
ifcopenshell::geom::native_element* elem,
ifcopenshell::logger& logger,
ifcopenshell::geom::triangulation_element* previous = nullptr);
@@ -294,10 +294,10 @@ namespace ifcopenshell::geom {
std::unique_ptr<element> get();
/// Gets the native (Open Cascade or CGAL) representation of the current geometrical entity.
std::unique_ptr<brep_element> get_native()
std::unique_ptr<native_element> get_native()
{
validate_iterator_state();
return std::make_unique<brep_element>(**native_task_result_iterator_);
return std::make_unique<native_element>(**native_task_result_iterator_);
}
std::unique_ptr<element> get_object(int id);
@@ -367,14 +367,14 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// return single_material;
// }
//
// ifcopenshell::geom::brep_element* ifcopenshell::geom::Kernel::create_brep_for_representation_and_product(
// ifcopenshell::geom::native_element* ifcopenshell::geom::Kernel::create_brep_for_representation_and_product(
// const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product)
// {
// std::stringstream representation_id_builder;
//
// representation_id_builder << representation->data().id();
//
// ifcopenshell::geom::brep* shape;
// ifcopenshell::geom::native* shape;
// std::vector<ifcopenshell::geom::conversion_result> shapes, shapes2;
//
// if (!convert_shapes(representation, shapes)) {
@@ -524,16 +524,16 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// trsf = gp_Trsf();
// representation_id_builder << "-world-coords";
// }
// shape = new ifcopenshell::geom::brep(element_settings, representation_id_builder.str(), opened_shapes);
// shape = new ifcopenshell::geom::native(element_settings, representation_id_builder.str(), opened_shapes);
// } else if (settings.get(IteratorSettings::USE_WORLD_COORDS)) {
// for (std::vector<ifcopenshell::geom::conversion_result>::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// it->prepend(trsf);
// }
// trsf = gp_Trsf();
// representation_id_builder << "-world-coords";
// shape = new ifcopenshell::geom::brep(element_settings, representation_id_builder.str(), shapes);
// shape = new ifcopenshell::geom::native(element_settings, representation_id_builder.str(), shapes);
// } else {
// shape = new ifcopenshell::geom::brep(element_settings, representation_id_builder.str(), shapes);
// shape = new ifcopenshell::geom::native(element_settings, representation_id_builder.str(), shapes);
// }
//
// std::string context_string = "";
@@ -543,7 +543,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// context_string = *representation->ContextOfItems()->ContextType();
// }
//
// auto elem = new brep_element(
// auto elem = new native_element(
// product->data().id(),
// parent_id,
// name,
@@ -551,7 +551,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// guid,
// context_string,
// trsf,
// std::shared_ptr<ifcopenshell::geom::brep>(shape),
// std::shared_ptr<ifcopenshell::geom::native>(shape),
// product
// );
//
@@ -710,9 +710,9 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
// return products;
// }
//
// ifcopenshell::geom::brep_element* ifcopenshell::geom::Kernel::create_brep_for_processed_representation(
// ifcopenshell::geom::native_element* ifcopenshell::geom::Kernel::create_brep_for_processed_representation(
// const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
// ifcopenshell::geom::brep_element* brep)
// ifcopenshell::geom::native_element* brep)
// {
// int parent_id = -1;
// try {
@@ -747,7 +747,7 @@ bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revol
//
// const std::string product_type = product->declaration().name();
//
// return new brep_element(
// return new native_element(
// product->data().id(),
// parent_id,
// name,
+3 -3
View File
@@ -1349,7 +1349,7 @@ namespace ifcopenshell::geom {
return ts_filtered;
}
std::vector<T> select(const ifcopenshell::geom::brep_element* elem, bool completely_within = false, double extend = -1.e-5) const {
std::vector<T> select(const ifcopenshell::geom::native_element* elem, bool completely_within = false, double extend = -1.e-5) const {
auto shp = (ifcopenshell::geom::open_cascade_shape*)elem->geometry().as_compound();
TopoDS_Shape compound(std::move(((ifcopenshell::geom::open_cascade_shape*)shp)->shape()));
delete shp;
@@ -1497,7 +1497,7 @@ namespace ifcopenshell::geom {
if (it.initialize()) {
do {
auto element = it.get();
add_element(dynamic_cast<ifcopenshell::geom::brep_element*>(element.get()));
add_element(dynamic_cast<ifcopenshell::geom::native_element*>(element.get()));
} while (it.next());
}
}
@@ -1745,7 +1745,7 @@ namespace ifcopenshell::geom {
max_protrusions_[t] = std::min(std::min(obb.XHSize(), obb.YHSize()), obb.ZHSize()) * 2;
}
void add_element(ifcopenshell::geom::brep_element* elem) {
void add_element(ifcopenshell::geom::native_element* elem) {
if (!elem) {
return;
}
@@ -63,7 +63,7 @@ namespace ifcopenshell {
}
void add_element(ifcopenshell::geom::element* element) override {
auto* brep = dynamic_cast<ifcopenshell::geom::brep_element*>(element);
auto* brep = dynamic_cast<ifcopenshell::geom::native_element*>(element);
if (!brep) {
throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires native brep elements");
}
@@ -87,7 +87,7 @@ namespace ifcopenshell {
}
std::vector<express::entity> select(const ifcopenshell::geom::element* element, bool completely_within, double extend) const override {
auto* brep = dynamic_cast<const ifcopenshell::geom::brep_element*>(element);
auto* brep = dynamic_cast<const ifcopenshell::geom::native_element*>(element);
if (!brep) {
throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires brep elements for select()");
}
+11 -11
View File
@@ -19,10 +19,10 @@
#include "representation.h"
ifcopenshell::geom::serialization::serialization(const brep& brep)
: representation(brep.settings(), brep.entity(), brep.id())
ifcopenshell::geom::serialization::serialization(const native& native_geometry)
: representation(native_geometry.settings(), native_geometry.entity(), native_geometry.id())
{
for (auto it = brep.begin(); it != brep.end(); ++it) {
for (auto it = native_geometry.begin(); it != native_geometry.end(); ++it) {
int sid = -1;
if (it->hasStyle()) {
@@ -48,12 +48,12 @@ ifcopenshell::geom::serialization::serialization(const brep& brep)
}
ifcopenshell::geom::taxonomy::matrix4 identity;
auto* comp = brep.as_compound();
auto* comp = native_geometry.as_compound();
comp->serialize(identity, brep_data_);
delete comp;
}
ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::as_compound(bool force_meters) const {
ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::native::as_compound(bool force_meters) const {
conversion_result_shape* accum = nullptr;
for (auto it = begin(); it != end(); ++it) {
@@ -75,7 +75,7 @@ ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::as_compou
return accum;
}
bool ifcopenshell::geom::brep::calculate_surface_area(double& area) const {
bool ifcopenshell::geom::native::calculate_surface_area(double& area) const {
std::unique_ptr<conversion_result_shape> s(as_compound());
if (!s) {
area = 0.;
@@ -85,7 +85,7 @@ bool ifcopenshell::geom::brep::calculate_surface_area(double& area) const {
return true;
}
bool ifcopenshell::geom::brep::calculate_volume(double& volume) const {
bool ifcopenshell::geom::native::calculate_volume(double& volume) const {
std::unique_ptr<conversion_result_shape> s(as_compound());
if (!s) {
volume = 0.;
@@ -95,7 +95,7 @@ bool ifcopenshell::geom::brep::calculate_volume(double& volume) const {
return true;
}
bool ifcopenshell::geom::brep::calculate_projected_surface_area(const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const {
bool ifcopenshell::geom::native::calculate_projected_surface_area(const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const {
along_x = along_y = along_z = 0.;
for (std::vector<ifcopenshell::geom::conversion_result>::const_iterator it = begin(); it != end(); ++it) {
@@ -116,7 +116,7 @@ bool ifcopenshell::geom::brep::calculate_projected_surface_area(const ifcopenshe
return true;
}
ifcopenshell::geom::triangulation::triangulation(const brep& shape_model)
ifcopenshell::geom::triangulation::triangulation(const native& shape_model)
: representation(shape_model.settings(), shape_model.entity(), shape_model.id())
, weld_offset_(0)
{
@@ -210,7 +210,7 @@ void ifcopenshell::geom::triangulation::registerEdgeCount(int n1, int n2, std::m
edgecount[e] ++;
}
const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::item(int i) const {
const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::native::item(int i) const {
if (i >= 0 && static_cast<std::size_t>(i) < shapes_.size()) {
return shapes_[i].shape()->moved(shapes_[i].placement());
} else {
@@ -218,7 +218,7 @@ const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::brep::ite
}
}
int ifcopenshell::geom::brep::item_id(int i) const {
int ifcopenshell::geom::native::item_id(int i) const {
if (i >= 0 && static_cast<std::size_t>(i) < shapes_.size()) {
return shapes_[i].ItemId();
} else {
+7 -7
View File
@@ -52,17 +52,17 @@ namespace ifcopenshell::geom {
virtual ~representation() {}
};
class IFC_GEOM_API brep : public representation {
class IFC_GEOM_API native : public representation {
private:
const std::vector<ifcopenshell::geom::conversion_result> shapes_;
brep(const brep& other);
brep& operator=(const brep& other);
native(const native& other);
native& operator=(const native& other);
public:
brep(const ifcopenshell::geom::settings& settings, const std::string& entity, const std::string& id, const std::vector<ifcopenshell::geom::conversion_result>& shapes)
native(const ifcopenshell::geom::settings& settings, const std::string& entity, const std::string& id, const std::vector<ifcopenshell::geom::conversion_result>& shapes)
: representation(settings, entity, id)
, shapes_(shapes)
{}
virtual ~brep() {}
virtual ~native() {}
std::vector<ifcopenshell::geom::conversion_result>::const_iterator begin() const { return shapes_.begin(); }
std::vector<ifcopenshell::geom::conversion_result>::const_iterator end() const { return shapes_.end(); }
const std::vector<ifcopenshell::geom::conversion_result>& shapes() const { return shapes_; }
@@ -86,7 +86,7 @@ namespace ifcopenshell::geom {
const std::string& brep_data() const { return brep_data_; }
const std::vector<double>& surface_styles() const { return surface_styles_; }
const std::vector<int>& surface_style_ids() const { return surface_style_ids_; }
serialization(const brep& brep);
serialization(const native& native_geometry);
virtual ~serialization() {}
private:
serialization();
@@ -138,7 +138,7 @@ namespace ifcopenshell::geom {
const std::vector<int>& item_ids() const { return item_ids_; }
const std::vector<int>& edges_item_ids() const { return edges_item_ids_; }
triangulation(const brep& shape_model);
triangulation(const native& shape_model);
triangulation(
const ifcopenshell::geom::settings& settings,
+1 -1
View File
@@ -89,7 +89,7 @@ public:
}
ifcopenshell::geom::trees::abstract_tree& backend_for_element(ifcopenshell::geom::element* element) const {
if (dynamic_cast<ifcopenshell::geom::brep_element*>(element)) {
if (dynamic_cast<ifcopenshell::geom::native_element*>(element)) {
return backend(default_selection_backend_id);
}
+5 -5
View File
@@ -467,9 +467,9 @@ static const std::array<std::string, 3> XYZ = { "X", "Y", "Z" };
class QuantityWriter_v0 : public EntityExtension {
private:
const ifcopenshell::geom::brep_element* elem_;
const ifcopenshell::geom::native_element* elem_;
public:
QuantityWriter_v0(const ifcopenshell::geom::brep_element* elem) :
QuantityWriter_v0(const ifcopenshell::geom::native_element* elem) :
elem_(elem)
{
put_json(TOTAL_SURFACE_AREA, 0.);
@@ -482,9 +482,9 @@ public:
class QuantityWriter_v1 : public EntityExtension {
private:
const ifcopenshell::geom::brep_element* elem_;
const ifcopenshell::geom::native_element* elem_;
public:
QuantityWriter_v1(const ifcopenshell::geom::brep_element* elem) :
QuantityWriter_v1(const ifcopenshell::geom::native_element* elem) :
elem_(elem) {
double a, b, c, largest_face_area = 0.;
@@ -643,7 +643,7 @@ int main () {
}
case GET_LOG: {
get_log gl; gl.read(std::cin);
WriteLog(logger::root().get_log()).write(std::cout);
WriteLog(ifcopenshell::logger::root().get_log()).write(std::cout);
continue;
}
case BYE: {
@@ -37,9 +37,9 @@ if TYPE_CHECKING:
T = TypeVar("T")
ShapeElementType = Union[
ifcopenshell_wrapper.BRepElement, ifcopenshell_wrapper.TriangulationElement, ifcopenshell_wrapper.SerializedElement
ifcopenshell_wrapper.native_element, ifcopenshell_wrapper.triangulation_element, ifcopenshell_wrapper.serialized_element
]
ShapeType = Union[ifcopenshell_wrapper.BRep, ifcopenshell_wrapper.Triangulation, ifcopenshell_wrapper.Serialization]
ShapeType = Union[ifcopenshell_wrapper.native, ifcopenshell_wrapper.triangulation, ifcopenshell_wrapper.serialization]
def wrap_shape_creation(settings, shape):
@@ -54,7 +54,7 @@ if has_occ:
except ImportError:
from OCC import TopoDS # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
def wrap_shape_creation(settings: settings, shape: ifcopenshell_wrapper.Element):
def wrap_shape_creation(settings: settings, shape: ifcopenshell_wrapper.element):
if getattr(settings, "use_python_opencascade", False):
return utils.create_shape_from_serialization(shape)
else:
@@ -252,7 +252,7 @@ class settings_mixin:
if k in map(self.rname, self.setting_names()):
return k
else:
raise AttributeError("'Settings' object has no attribute '%s'" % k)
raise AttributeError("'settings' object has no attribute '%s'" % k)
def build_parser(self, parser) -> None:
"""
@@ -304,11 +304,11 @@ class settings_mixin:
self.set(k.replace("_", "-"), v)
class settings(settings_mixin, ifcopenshell_wrapper.Settings):
class settings(settings_mixin, ifcopenshell_wrapper.settings):
use_python_opencascade = False
class iterator(ifcopenshell_wrapper.Iterator):
class iterator(ifcopenshell_wrapper.iterator):
def __init__(
self,
settings: settings,
@@ -370,7 +370,7 @@ class iterator(ifcopenshell_wrapper.Iterator):
if has_occ:
def get(self):
return wrap_shape_creation(self.settings, ifcopenshell_wrapper.Iterator.get(self))
return wrap_shape_creation(self.settings, ifcopenshell_wrapper.iterator.get(self))
def __iter__(self) -> Generator[IteratorOutput, None, None]:
if self.initialize():
@@ -380,7 +380,7 @@ class iterator(ifcopenshell_wrapper.Iterator):
break
def get_task_products(self):
return entity_instance.wrap_value(ifcopenshell_wrapper.Iterator.get_task_products(self), self.file)
return entity_instance.wrap_value(ifcopenshell_wrapper.iterator.get_task_products(self), self.file)
ClashType = Literal["protrusion", "pierce", "collision", "clearance"]
@@ -404,7 +404,7 @@ class tree(ifcopenshell_wrapper.tree):
def select(
self,
value: Union[entity_instance, ifcopenshell_wrapper.BRepElement, tuple[float, float, float]],
value: Union[entity_instance, ifcopenshell_wrapper.native_element, tuple[float, float, float]],
**kwargs,
) -> list[entity_instance]:
def unwrap(value):
@@ -415,7 +415,7 @@ class tree(ifcopenshell_wrapper.tree):
return value
args = [self, unwrap(value)]
if isinstance(value, (entity_instance, ifcopenshell_wrapper.BRepElement)):
if isinstance(value, (entity_instance, ifcopenshell_wrapper.native_element)):
args.append(kwargs.get("completely_within", False))
if "extend" in kwargs:
args.append(kwargs["extend"])
@@ -480,7 +480,7 @@ def create_shape(
repr: Optional[entity_instance] = None,
geometry_library: GEOMETRY_LIBRARY = "opencascade",
logger: Optional[ifcopenshell.logger] = None,
) -> Union[ShapeType, ShapeElementType, ifcopenshell_wrapper.Transformation, utils.shape_tuple, TopoDS.TopoDS_Shape]:
) -> Union[ShapeType, ShapeElementType, ifcopenshell_wrapper.transformation, utils.shape_tuple, TopoDS.TopoDS_Shape]:
"""
Returns a geometric interpretation of the IFC entity instance
@@ -494,7 +494,7 @@ def create_shape(
- `inst` is IfcRepresentation and `repr` is None -> ShapeType\n
- `inst` is IfcRepresentationItem and `repr` is None -> ShapeType\n
- `inst` is IfcProfileDef and `repr` is None -> ShapeType\n
- `inst` is IfcPlacement / IfcObjectPlacement -> Transformation\n
- `inst` is IfcPlacement / IfcObjectPlacement -> transformation\n
- `inst` is IfcTypeProduct and `repr` is None -> None\n
- `inst` is IfcTypeProduct and `repr` is provided -> RuntimeError
(for IfcTypeProducts provide just IfcRepresentation as `inst`).\n
@@ -664,7 +664,7 @@ class _serializer_factory:
self.extension = extension
self.__name__ = name
def __call__(self, out_filename: Union[str, PathLike[str]], *args: Any) -> ifcopenshell_wrapper.GeometrySerializer:
def __call__(self, out_filename: Union[str, PathLike[str]], *args: Any) -> ifcopenshell_wrapper.geometry_serializer:
if self.name == "obj" and len(args) == 2:
output_filename = args[0]
output_temp_filename = out_filename
@@ -60,7 +60,7 @@ except ImportError:
class shape_tuple(NamedTuple):
"""A tuple containing IfcOpenShell serialized element/shape and pythonOCC shape."""
data: Union[ifcopenshell_wrapper.SerializedElement, ifcopenshell_wrapper.Serialization]
data: Union[ifcopenshell_wrapper.serialized_element, ifcopenshell_wrapper.serialization]
geometry: TopoDS.TopoDS_Shape
styles: tuple[tuple[float, float, float, float], ...]
style_ids: tuple[int, ...]
@@ -268,16 +268,16 @@ def serialize_shape(shape):
def create_shape_from_serialization(
brep_object: Union[ifcopenshell_wrapper.SerializedElement, ifcopenshell_wrapper.Serialization],
brep_object: Union[ifcopenshell_wrapper.serialized_element, ifcopenshell_wrapper.serialization],
) -> Union[shape_tuple, TopoDS.TopoDS_Shape]:
brep_data, occ_shape, styles, style_ids = None, None, (), ()
is_product_shape = True
if isinstance(brep_object, ifcopenshell_wrapper.SerializedElement):
if isinstance(brep_object, ifcopenshell_wrapper.serialized_element):
brep_data = brep_object.geometry.brep_data
styles = brep_object.geometry.surface_styles
style_ids = brep_object.geometry.surface_style_ids
elif isinstance(brep_object, ifcopenshell_wrapper.Serialization):
elif isinstance(brep_object, ifcopenshell_wrapper.serialization):
try:
brep_data = brep_object.brep_data
styles = brep_object.surface_styles
@@ -105,7 +105,7 @@ class spf_header:
@property
def file_schema(self) -> entity_instance: ...
class BRep(Representation):
class native(representation):
def __init__(self, settings, entity, id, shapes): ...
def as_compound(self, force_meters=False): ...
def begin(self): ...
@@ -118,30 +118,30 @@ class BRep(Representation):
def shapes(self): ...
def size(self): ...
class BRepElement(Element):
class native_element(element):
def __init__(self, id, parent_id, name, type, guid, context, trsf, geometry, product): ...
def calculate_projected_surface_area(self, along_x, along_y, along_z): ...
@property
def geometry(self) -> BRep: ...
def geometry(self) -> native: ...
@property
def surface_area(self): ...
@property
def volume(self): ...
class ConversionResult:
class conversion_result:
def ItemId(self): ...
def Placement(self): ...
def Shape(self): ...
def Style(self): ...
def StylePtr(self): ...
def __init__(self, *args): ...
def append(self, trsf): ...
def apply_transform(self, unit_scale=1.0): ...
def hasStyle(self): ...
def placement(self): ...
def prepend(self, trsf): ...
def setStyle(self, newStyle): ...
def shape(self) -> conversion_result_shape: ...
def style(self): ...
def style_ptr(self): ...
class ConversionResultShape:
class conversion_result_shape:
def serialize(self, place, arg3): ...
def triangulate(self, *args): ...
def __init__(self, *args, **kwargs): ...
@@ -193,7 +193,7 @@ class DoubleArray3:
def size(self): ...
def swap(self, v): ...
class Element:
class element:
def __init__(self, settings, id, parent_id, name, type, guid, context, trsf, product): ...
# TODO: Remove from the wrapper?
def SetParents(self, newparents): ...
@@ -233,7 +233,7 @@ class Element:
@property
def product(self) -> entity_instance: ...
@property
def transformation(self) -> Transformation: ...
def transformation(self) -> transformation: ...
@property
def transformation_buffer(self) -> bytes: ...
@property
@@ -252,7 +252,7 @@ class Element:
"""
...
class GeometrySerializer:
class geometry_serializer:
READ_BREP: Any
READ_TRIANGULATION: Any
def __init__(self, *args, **kwargs): ...
@@ -264,7 +264,7 @@ class GeometrySerializer:
def ready(self): ...
def setFile(self, file: file) -> None: ...
def setUnitNameAndMagnitude(self, name, magnitude): ...
def settings(self, *args) -> "Settings": ...
def settings(self, *args) -> "settings": ...
def write(self, *args): ...
def writeHeader(self): ...
@@ -284,7 +284,7 @@ class instance_streamer:
def status(self): ...
def yield_header_instances(self, enabled): ...
class Iterator:
class iterator:
def __init__(self, *args): ...
initialization_outcome_: Any
processed_: Any
@@ -294,7 +294,7 @@ class Iterator:
def create(self): ...
def file(self): ...
def filters(self, *args): ...
def get(self) -> Element:
def get(self) -> element:
"""Get last processed element."""
...
@@ -344,7 +344,7 @@ class OpaqueCoordinate_4:
def size(self): ...
def to_double(self): ...
class OpaqueNumber:
class opaque_number:
def abs(self): ...
def add(self, other): ...
def divide(self, other): ...
@@ -358,7 +358,7 @@ class OpaqueNumber:
def to_double(self): ...
def to_string(self): ...
class Representation:
class representation:
def __init__(self, settings, entity, id): ...
def entity(self): ...
@property
@@ -369,7 +369,7 @@ class Representation:
- 2468 - IfcRelVoidsElement
"""
def settings(self) -> "Settings": ...
def settings(self) -> "settings": ...
class RocksDBPrefixIterator:
def __init__(self, storage, prefix): ...
@@ -386,7 +386,7 @@ class RocksDbSerializer:
def setFile(self, arg2) -> None: ...
def writeHeader(self) -> None: ...
class Serialization(Representation):
class serialization(representation):
def __init__(self, brep): ...
@property
def brep_data(self): ...
@@ -395,12 +395,12 @@ class Serialization(Representation):
@property
def surface_styles(self): ...
class SerializedElement(Element):
class serialized_element(element):
def __init__(self, shape_model): ...
@property
def geometry(self) -> Serialization: ...
def geometry(self) -> serialization: ...
class Settings:
class settings:
def get_(self, name): ...
def get_type(self, name): ...
def set_(self, *args): ...
@@ -418,13 +418,13 @@ class SwigPyIterator:
def previous(self): ...
def value(self): ...
class Transformation:
class transformation:
def __init__(self, settings, matrix): ...
def data(self): ...
@property
def matrix(self): ...
class Triangulation(Representation):
class triangulation(representation):
def __init__(self, *args): ...
def addEdge(self, item_id, style, i0, i1): ...
def addFace(self, *args): ...
@@ -479,12 +479,12 @@ class Triangulation(Representation):
@property
def verts_buffer(self) -> bytes: ...
class TriangulationElement(Element):
class triangulation_element(element):
def __init__(self, *args): ...
@property
def geometry(self) -> Triangulation: ...
def geometry(self) -> triangulation: ...
class WriteOnlyGeometrySerializer(GeometrySerializer):
class write_only_geometry_serializer(geometry_serializer):
def __init__(self, *args, **kwargs): ...
def read(self, *args): ...
@@ -1568,7 +1568,7 @@ class torus(surface):
class tree:
def __init__(self, *args): ...
def add_element(self, element: Element | None) -> None: ...
def add_element(self, element: element | None) -> None: ...
def add_file(self, *args) -> None: ...
def clash_clearance_many(
self,
@@ -1651,7 +1651,7 @@ def set_feature(x: Literal["use_attribute_value_derived"], v: bool) -> None:
def create_box(*args): ...
def create_epeck(*args): ...
def create_geometry_serializer(*args) -> GeometrySerializer: ...
def create_geometry_serializer(*args) -> geometry_serializer: ...
def create_shape(*args): ...
def flatten(deep): ...
def get_info_cpp(v: entity_instance, recursive: bool, include_identifier: bool) -> dict[str, Any]: ...
@@ -46,7 +46,7 @@ MatrixType = npt.NDArray[np.float64]
tol = 1e-6
# NOTE: See representation.h for W.Triangulation buffer types.
# NOTE: See representation.h for W.triangulation buffer types.
# NOTE: For functions that return a single scalar ensure to use .item() to
# return the Python float instead of numpy float
@@ -68,7 +68,7 @@ def is_x(value: float, x: float, tolerance: Optional[float] = None) -> bool:
return abs(x - value) < tolerance
def get_volume(geometry: W.Triangulation) -> float:
def get_volume(geometry: W.triangulation) -> float:
"""Calculates the total internal volume of a geometry
Volumes of non-manifold geometry will be unpredictable.
@@ -98,7 +98,7 @@ def get_volume(geometry: W.Triangulation) -> float:
return abs(sum(volumes))
def get_x(geometry: W.Triangulation) -> float:
def get_x(geometry: W.triangulation) -> float:
"""Calculates the X length of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -108,7 +108,7 @@ def get_x(geometry: W.Triangulation) -> float:
return (np.max(verts_flat[0::3]) - np.min(verts_flat[0::3])).item()
def get_y(geometry: W.Triangulation) -> float:
def get_y(geometry: W.triangulation) -> float:
"""Calculates the Y length of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -118,7 +118,7 @@ def get_y(geometry: W.Triangulation) -> float:
return (np.max(verts_flat[1::3]) - np.min(verts_flat[1::3])).item()
def get_z(geometry: W.Triangulation) -> float:
def get_z(geometry: W.triangulation) -> float:
"""Calculates the Z length of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -128,7 +128,7 @@ def get_z(geometry: W.Triangulation) -> float:
return (np.max(verts_flat[2::3]) - np.min(verts_flat[2::3])).item()
def get_max_xy(geometry: W.Triangulation) -> float:
def get_max_xy(geometry: W.triangulation) -> float:
"""Gets the maximum X or Y length of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -137,7 +137,7 @@ def get_max_xy(geometry: W.Triangulation) -> float:
return max(get_x(geometry), get_y(geometry))
def get_max_xyz(geometry: W.Triangulation) -> float:
def get_max_xyz(geometry: W.triangulation) -> float:
"""Gets the maximum X, Y, or Z length of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -146,7 +146,7 @@ def get_max_xyz(geometry: W.Triangulation) -> float:
return max(get_x(geometry), get_y(geometry), get_z(geometry))
def get_min_xyz(geometry: W.Triangulation) -> float:
def get_min_xyz(geometry: W.triangulation) -> float:
"""Gets the minimum X, Y, or Z length of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -164,7 +164,7 @@ def get_shape_matrix(shape: ShapeElementType) -> MatrixType:
return np.frombuffer(shape.transformation_buffer, "d").reshape((4, 4), order="F")
def get_bbox_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
def get_bbox_centroid(geometry: W.triangulation) -> tuple[float, float, float]:
"""Calculates the bounding box centroid of the geometry
The centroid is in local coordinates relative to the object's placement.
@@ -176,7 +176,7 @@ def get_bbox_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
return (np.min(vertices_array, axis=0) + np.max(vertices_array, axis=0)) / 2
def get_vert_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
def get_vert_centroid(geometry: W.triangulation) -> tuple[float, float, float]:
"""Calculates the average vertex centroid of the geometry
The centroid is in local coordinates relative to the object's placement.
@@ -188,7 +188,7 @@ def get_vert_centroid(geometry: W.Triangulation) -> tuple[float, float, float]:
def get_element_bbox_centroid(
element: ifcopenshell.entity_instance, geometry: W.Triangulation
element: ifcopenshell.entity_instance, geometry: W.triangulation
) -> npt.NDArray[np.float64]:
"""Calculates the element's bounding box centroid
@@ -206,7 +206,7 @@ def get_element_bbox_centroid(
return (mat @ np.array([*centroid, 1.0]))[0:3]
def get_shape_bbox_centroid(shape: ShapeElementType, geometry: W.Triangulation) -> npt.NDArray[np.float64]:
def get_shape_bbox_centroid(shape: ShapeElementType, geometry: W.triangulation) -> npt.NDArray[np.float64]:
"""Calculates the shape's bounding box centroid
The centroid is in global coordinates. Note that if you do not have the
@@ -220,7 +220,7 @@ def get_shape_bbox_centroid(shape: ShapeElementType, geometry: W.Triangulation)
return (get_shape_matrix(shape) @ np.array([*centroid, 1.0]))[0:3]
def get_vertices(geometry: W.Triangulation, is_2d: bool = False) -> npt.NDArray[np.float64]:
def get_vertices(geometry: W.triangulation, is_2d: bool = False) -> npt.NDArray[np.float64]:
"""Get all the vertices as a numpy array
Vertices are in local coordinates.
@@ -235,7 +235,7 @@ def get_vertices(geometry: W.Triangulation, is_2d: bool = False) -> npt.NDArray[
return np.frombuffer(geometry.verts_buffer, "d").reshape(-1, 3)
def get_edges(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
def get_edges(geometry: W.triangulation) -> npt.NDArray[np.int32]:
"""Get all the edges as a numpy array
Results are a nested numpy array e.g. [[e1v1, e1v2], [e2v1, e2v2], ...]
@@ -251,7 +251,7 @@ def get_edges(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
return np.frombuffer(geometry.edges_buffer, dtype="i").reshape(-1, 2)
def get_faces(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
def get_faces(geometry: W.triangulation) -> npt.NDArray[np.int32]:
"""Get all the faces as a numpy array
Faces are always triangulated. If the shape is a BRep and you want to get
@@ -266,7 +266,7 @@ def get_faces(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
return np.frombuffer(geometry.faces_buffer, dtype="i").reshape(-1, 3)
def get_material_colors(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
def get_material_colors(geometry: W.triangulation) -> npt.NDArray[np.float64]:
"""Get material colors as a numpy array.
:return: A numpy array listing RGBA color for each shape's material.
@@ -277,7 +277,7 @@ def get_material_colors(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
return np.frombuffer(geometry.colors_buffer, dtype="d").reshape(-1, 4)
def get_normals(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
def get_normals(geometry: W.triangulation) -> npt.NDArray[np.float64]:
"""Get vertex normals as a numpy array.
See geometry settings documentation for settings that affect normals.
@@ -288,12 +288,12 @@ def get_normals(geometry: W.Triangulation) -> npt.NDArray[np.float64]:
return np.frombuffer(geometry.normals_buffer, dtype="d").reshape(-1, 3)
def get_shape_material_styles(geometry: W.Triangulation) -> tuple[W.style, ...]:
def get_shape_material_styles(geometry: W.triangulation) -> tuple[W.style, ...]:
"""Get list of material styles."""
return geometry.materials
def get_faces_material_style_ids(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
def get_faces_material_style_ids(geometry: W.triangulation) -> npt.NDArray[np.int32]:
"""Get material styles ids for the geometry faces.
Return a list of corresponding indices of styles from get_shape_material_styles for each face.
@@ -302,12 +302,12 @@ def get_faces_material_style_ids(geometry: W.Triangulation) -> npt.NDArray[np.in
return np.frombuffer(geometry.material_ids_buffer, dtype="i")
def get_faces_representation_item_ids(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
def get_faces_representation_item_ids(geometry: W.triangulation) -> npt.NDArray[np.int32]:
"""Get representation item ids for the geometry faces."""
return np.frombuffer(geometry.item_ids_buffer, dtype="i")
def get_edges_representation_item_ids(geometry: W.Triangulation) -> npt.NDArray[np.int32]:
def get_edges_representation_item_ids(geometry: W.triangulation) -> npt.NDArray[np.int32]:
"""Get representation item ids for the geometry edges.
Can be useful for geometry without faces and in general is more universal
@@ -316,7 +316,7 @@ def get_edges_representation_item_ids(geometry: W.Triangulation) -> npt.NDArray[
return np.frombuffer(geometry.edges_item_ids_buffer, dtype="i")
def get_shape_vertices(shape: ShapeElementType, geometry: W.Triangulation) -> npt.NDArray[np.float64]:
def get_shape_vertices(shape: ShapeElementType, geometry: W.triangulation) -> npt.NDArray[np.float64]:
"""Get the shape's vertices as a numpy array
Vertices are in global coordinates. If you do not have the shape, you can
@@ -334,7 +334,7 @@ def get_shape_vertices(shape: ShapeElementType, geometry: W.Triangulation) -> np
return np.delete((mat @ np.hstack((verts, np.ones((len(verts), 1)))).T).T, -1, axis=1)
def get_element_vertices(element: ifcopenshell.entity_instance, geometry: W.Triangulation) -> npt.NDArray[np.float64]:
def get_element_vertices(element: ifcopenshell.entity_instance, geometry: W.triangulation) -> npt.NDArray[np.float64]:
"""Get the element's vertices as a numpy array
Vertices are in global coordinates. Note that if you have the shape, it is
@@ -353,7 +353,7 @@ def get_element_vertices(element: ifcopenshell.entity_instance, geometry: W.Tria
return np.delete((mat @ np.hstack((verts, np.ones((len(verts), 1)))).T).T, -1, axis=1)
def get_bottom_elevation(geometry: W.Triangulation) -> float:
def get_bottom_elevation(geometry: W.triangulation) -> float:
"""Gets the lowest local Z ordinate of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -363,7 +363,7 @@ def get_bottom_elevation(geometry: W.Triangulation) -> float:
return np.min(verts_flat[2::3]).item()
def get_top_elevation(geometry: W.Triangulation) -> float:
def get_top_elevation(geometry: W.triangulation) -> float:
"""Gets the highest local Z ordinate of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -373,7 +373,7 @@ def get_top_elevation(geometry: W.Triangulation) -> float:
return np.max(verts_flat[2::3]).item()
def get_shape_bottom_elevation(shape: ShapeElementType, geometry: W.Triangulation) -> float:
def get_shape_bottom_elevation(shape: ShapeElementType, geometry: W.triangulation) -> float:
"""Gets the lowest global Z ordinate of the shape
If you do not have the shape, you can use :func:`get_element_bottom_elevation`
@@ -386,7 +386,7 @@ def get_shape_bottom_elevation(shape: ShapeElementType, geometry: W.Triangulatio
return min([v[2] for v in get_shape_vertices(shape, geometry)])
def get_shape_top_elevation(shape: ShapeElementType, geometry: W.Triangulation) -> float:
def get_shape_top_elevation(shape: ShapeElementType, geometry: W.triangulation) -> float:
"""Gets the highest global Z ordinate of the shape
If you do not have the shape, you can use :func:`get_element_top_elevation`
@@ -399,7 +399,7 @@ def get_shape_top_elevation(shape: ShapeElementType, geometry: W.Triangulation)
return max([v[2] for v in get_shape_vertices(shape, geometry)])
def get_element_bottom_elevation(element: ifcopenshell.entity_instance, geometry: W.Triangulation) -> float:
def get_element_bottom_elevation(element: ifcopenshell.entity_instance, geometry: W.triangulation) -> float:
"""Gets the lowest global Z ordinate of the element
Note that if you have the shape, it is more efficient to use
@@ -412,7 +412,7 @@ def get_element_bottom_elevation(element: ifcopenshell.entity_instance, geometry
return min([v[2] for v in get_element_vertices(element, geometry)])
def get_element_top_elevation(element: ifcopenshell.entity_instance, geometry: W.Triangulation) -> float:
def get_element_top_elevation(element: ifcopenshell.entity_instance, geometry: W.triangulation) -> float:
"""Gets the highest global Z ordinate of the element
Note that if you have the shape, it is more efficient to use
@@ -458,7 +458,7 @@ def get_area_vf(vertices: npt.NDArray[np.float64], faces: npt.NDArray[np.int32])
return mesh_area.item()
def get_area(geometry: W.Triangulation) -> float:
def get_area(geometry: W.triangulation) -> float:
"""Calculates the surface area of the geometry
:param geometry: Geometry output calculated by IfcOpenShell
@@ -470,7 +470,7 @@ def get_area(geometry: W.Triangulation) -> float:
def get_side_area(
geometry: W.Triangulation,
geometry: W.triangulation,
axis: AXIS_LITERAL = "Y",
direction: Optional[VectorType] = None,
angle: float = 90.0,
@@ -520,7 +520,7 @@ def get_side_area(
return get_area_vf(vertices, filtered_faces)
def get_max_side_area(geometry: W.Triangulation) -> float:
def get_max_side_area(geometry: W.triangulation) -> float:
"""Returns the maximum X, Y, or Z side area
See :func:`get_side_area` for how side area is calculated.
@@ -531,12 +531,12 @@ def get_max_side_area(geometry: W.Triangulation) -> float:
return max(get_side_area(geometry, axis="X"), get_side_area(geometry, axis="Y"), get_side_area(geometry, axis="Z"))
def get_top_area(geometry: W.Triangulation) -> float:
def get_top_area(geometry: W.triangulation) -> float:
return get_side_area(geometry, axis="Z", angle=45)
def get_footprint_area(
geometry: W.Triangulation,
geometry: W.triangulation,
axis: AXIS_LITERAL = "Z",
direction: Optional[VECTOR_3D] = None,
) -> float:
@@ -614,7 +614,7 @@ def get_footprint_area(
return unioned_polygon.area
def get_outer_surface_area(geometry: W.Triangulation) -> float:
def get_outer_surface_area(geometry: W.triangulation) -> float:
"""Calculates the outer surface area (i.e. all sides except for top and bottom)
This is typically useful for calculating painted areas of beams which
@@ -640,7 +640,7 @@ def get_outer_surface_area(geometry: W.Triangulation) -> float:
return get_area_vf(vertices, filtered_faces)
def get_footprint_perimeter(geometry: W.Triangulation) -> float:
def get_footprint_perimeter(geometry: W.triangulation) -> float:
"""Calculates the footprint perimeter of the geometry
All faces with a negative Z normal are considered and the distance of all
@@ -743,7 +743,7 @@ def get_base_extrusions(element: ifcopenshell.entity_instance) -> Union[list[ifc
return extrusions
def get_total_edge_length(geometry: W.Triangulation) -> float:
def get_total_edge_length(geometry: W.triangulation) -> float:
"""Calculates the total length of edges in a given geometry.
:param geometry: Geometry output calculated by IfcOpenShell
+3 -3
View File
@@ -297,7 +297,7 @@ class Patcher(ifcpatch.BasePatcher):
checkpoint = time.time()
shape = iterator.get()
if shape:
assert isinstance(shape, W.TriangulationElement)
assert isinstance(shape, W.triangulation_element)
shape_id = shape.id
geometry = shape.geometry
geometry_id = geometry.id
@@ -328,13 +328,13 @@ class Patcher(ifcpatch.BasePatcher):
geometry_id = geometry_id_
elif geometry := ifcopenshell.geom.create_shape(self.settings, representation):
geometry_id = geometry_id_
assert isinstance(geometry, W.Triangulation)
assert isinstance(geometry, W.triangulation)
self.add_geometry_row(geometry_id, geometry)
shape_id = element_type.id()
self.shape_rows[shape_id] = (shape_id, *(0.0, 0.0, 0.0), m_bytes, geometry_id)
def add_geometry_row(self, geometry_id: str, geometry: W.Triangulation) -> None:
def add_geometry_row(self, geometry_id: str, geometry: W.triangulation) -> None:
v = geometry.verts_buffer
e = geometry.edges_buffer
f = geometry.faces_buffer
@@ -53,7 +53,7 @@ class SvSbShapeOutput(bpy.types.Node, SverchCustomTreeNode, helper.SvIfcCore):
settings = ifcopenshell.geom.settings()
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
shape = ifcopenshell.geom.create_shape(settings, entity)
assert isinstance(shape, W.Triangulation)
assert isinstance(shape, W.triangulation)
self.verts = ifcopenshell.util.shape.get_vertices(shape).tolist()
self.edges = ifcopenshell.util.shape.get_edges(shape).tolist()
self.polys = ifcopenshell.util.shape.get_faces(shape).tolist()
+77 -72
View File
@@ -19,28 +19,10 @@
%rename("buffer") stream_or_filename;
// Keep the established Python API names while the underlying C++ types use
// snake_case.
%rename("BRep") ifcopenshell::geom::brep;
%rename("BRepElement") ifcopenshell::geom::brep_element;
%rename("ConversionResult") ifcopenshell::geom::conversion_result;
%rename("ConversionResultShape") ifcopenshell::geom::conversion_result_shape;
%rename("Element") ifcopenshell::geom::element;
%rename("GeometrySerializer") ifcopenshell::geom::geometry_serializer;
%rename("Iterator") ifcopenshell::geom::iterator;
%rename("OpaqueNumber") ifcopenshell::geom::opaque_number;
%rename("Representation") ifcopenshell::geom::representation;
%rename("Serialization") ifcopenshell::geom::serialization;
%rename("SerializedElement") ifcopenshell::geom::serialized_element;
%rename("Settings") ifcopenshell::geom::settings;
%rename("Transformation") ifcopenshell::geom::transformation;
%rename("Triangulation") ifcopenshell::geom::triangulation;
%rename("TriangulationElement") ifcopenshell::geom::triangulation_element;
%rename("WriteOnlyGeometrySerializer") ifcopenshell::geom::write_only_geometry_serializer;
%ignore stream_or_filename::stream;
%ignore ifcopenshell::geom::conversion_result::shape;
%ignore boost::hash_value;
%ignore ifcopenshell::geom::brep_element::geometry_pointer;
%ignore ifcopenshell::geom::native_element::geometry_pointer;
%ignore ifcopenshell::geom::triangulation_element::geometry_pointer;
// This is only used for RGB colours, hence the size of 3
@@ -85,48 +67,26 @@
$1 = &temp;
}
// Using RTTI return a more specialized type of Element
// Note that these elements are not to be owned by SWIG/Python as they will be freed automatically upon the next iteration
// except for the ifcopenshell::geom::element instances which are returned by Iterator::getObject() calls
// Use RTTI to return the most specialized element proxy. The ownership flag is
// supplied by the wrapped function, so iterator copies can transfer ownership
// while borrowed serializer results remain non-owning.
%typemap(out) ifcopenshell::geom::element* {
ifcopenshell::geom::serialized_element* serialized_elem = dynamic_cast<ifcopenshell::geom::serialized_element*>($1);
ifcopenshell::geom::triangulation_element* triangulation_elem = dynamic_cast<ifcopenshell::geom::triangulation_element*>($1);
ifcopenshell::geom::brep_element* brep_elem = dynamic_cast<ifcopenshell::geom::brep_element*>($1);
ifcopenshell::geom::native_element* brep_elem = dynamic_cast<ifcopenshell::geom::native_element*>($1);
if (triangulation_elem) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_ifcopenshell__geom__triangulation_element, 0);
$result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_ifcopenshell__geom__triangulation_element, $owner);
} else if (serialized_elem) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_ifcopenshell__geom__serialized_element, 0);
$result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_ifcopenshell__geom__serialized_element, $owner);
} else if (brep_elem) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_ifcopenshell__geom__brep_element, 0);
$result = SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_ifcopenshell__geom__native_element, $owner);
} else {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_ifcopenshell__geom__element, SWIG_POINTER_OWN);
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_ifcopenshell__geom__element, $owner);
}
}
// Iterator results are copies owned by the caller. Release the unique pointer
// into the most specific Python proxy and transfer deletion to Python.
%typemap(out) std::unique_ptr<ifcopenshell::geom::element> {
ifcopenshell::geom::element* elem = $1.release();
ifcopenshell::geom::serialized_element* serialized_elem = dynamic_cast<ifcopenshell::geom::serialized_element*>(elem);
ifcopenshell::geom::triangulation_element* triangulation_elem = dynamic_cast<ifcopenshell::geom::triangulation_element*>(elem);
ifcopenshell::geom::brep_element* brep_elem = dynamic_cast<ifcopenshell::geom::brep_element*>(elem);
if (triangulation_elem) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_ifcopenshell__geom__triangulation_element, SWIG_POINTER_OWN);
} else if (serialized_elem) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_ifcopenshell__geom__serialized_element, SWIG_POINTER_OWN);
} else if (brep_elem) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_ifcopenshell__geom__brep_element, SWIG_POINTER_OWN);
} else {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(elem), SWIGTYPE_p_ifcopenshell__geom__element, SWIG_POINTER_OWN);
}
}
%typemap(out) std::unique_ptr<ifcopenshell::geom::brep_element> {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1.release()), SWIGTYPE_p_ifcopenshell__geom__brep_element, SWIG_POINTER_OWN);
}
%newobject ifcopenshell::geom::brep::item;
%newobject ifcopenshell::geom::brep::as_compound;
%newobject ifcopenshell::geom::native::item;
%newobject ifcopenshell::geom::native::as_compound;
%newobject ifcopenshell::geom::conversion_result_shape::halfspaces;
%newobject ifcopenshell::geom::conversion_result_shape::box;
@@ -307,6 +267,19 @@ namespace {
%include "../ifcgeom/ifc_geom_api.h"
%include "../ifcgeom/conversion_result.h"
%extend ifcopenshell::geom::conversion_result {
ifcopenshell::geom::conversion_result_shape* _shape() const {
return $self->shape().get();
}
%pythoncode %{
def shape(self):
result = self._shape()
result._parent = self
return result
%}
}
// The implementation tuple is intentionally opaque to Python. Letting SWIG
// emit a type token for all setting descriptors exceeds MSVC's token limit.
%ignore ifcopenshell::geom::settings_container;
@@ -327,11 +300,43 @@ namespace {
GEOMETRY_WITH_BACKREF(ifcopenshell::geom::triangulation_element)
GEOMETRY_WITH_BACKREF(ifcopenshell::geom::serialized_element)
GEOMETRY_WITH_BACKREF(ifcopenshell::geom::brep_element)
GEOMETRY_WITH_BACKREF(ifcopenshell::geom::native_element)
%include "../ifcgeom/element.h"
%include "../ifcgeom/representation.h"
%ignore ifcopenshell::geom::iterator::get;
%ignore ifcopenshell::geom::iterator::get_native;
%ignore ifcopenshell::geom::iterator::get_object;
%newobject ifcopenshell::geom::iterator::_get;
%newobject ifcopenshell::geom::iterator::_get_native;
%newobject ifcopenshell::geom::iterator::_get_object;
%include "../ifcgeom/iterator.h"
%extend ifcopenshell::geom::iterator {
ifcopenshell::geom::element* _get() {
return $self->get().release();
}
ifcopenshell::geom::native_element* _get_native() {
return $self->get_native().release();
}
ifcopenshell::geom::element* _get_object(int id) {
return $self->get_object(id).release();
}
%pythoncode %{
def get(self):
return self._get()
def get_native(self):
return self._get_native()
def get_object(self, id):
return self._get_object(id)
%}
}
%include "../ifcgeom/geometry_serializer.h"
%include "../ifcgeom/taxonomy.h"
%include "../ifcgeom/function_item_evaluator.h"
@@ -339,7 +344,7 @@ GEOMETRY_WITH_BACKREF(ifcopenshell::geom::brep_element)
%{
#include "../serializers/geometry_serializer_plugin.h"
class python_plugin_geometry_serializer : public geometry_serializer {
class python_plugin_geometry_serializer : public ifcopenshell::geom::geometry_serializer {
public:
python_plugin_geometry_serializer(
const std::string& extension,
@@ -347,7 +352,7 @@ public:
const std::string& output_temp_filename,
ifcopenshell::geom::settings& settings
)
: geometry_serializer(settings)
: ifcopenshell::geom::geometry_serializer(settings)
{
ifcopenshell::serializers::geometry_serializer_context context{
output_filename,
@@ -364,7 +369,7 @@ public:
const stream_or_filename& output_temp_filename,
ifcopenshell::geom::settings& settings
)
: geometry_serializer(settings)
: ifcopenshell::geom::geometry_serializer(settings)
{
const auto output_filename_string = output_filename.filename().value_or("");
const auto output_temp_filename_string = output_temp_filename.filename().value_or(output_filename_string);
@@ -420,7 +425,7 @@ public:
serializer_->write(element);
}
void write(const ifcopenshell::geom::brep_element* element) override {
void write(const ifcopenshell::geom::native_element* element) override {
serializer_->write(element);
}
@@ -432,7 +437,7 @@ public:
ifcopenshell::file& file,
const std::string& guid,
const std::string& representation_id,
read_type rt = READ_BREP
ifcopenshell::geom::geometry_serializer::read_type rt = ifcopenshell::geom::geometry_serializer::READ_BREP
) override {
return serializer_->read(file, guid, representation_id, rt);
}
@@ -442,11 +447,11 @@ public:
}
private:
std::shared_ptr<geometry_serializer> serializer_;
std::shared_ptr<ifcopenshell::geom::geometry_serializer> serializer_;
};
%}
%extend geometry_serializer {
%extend ifcopenshell::geom::geometry_serializer {
bool ready() {
return $self->ready();
}
@@ -676,13 +681,13 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
PyObject* operator()(ifcopenshell::geom::element* elem) const {
ifcopenshell::geom::serialized_element* serialized_elem = dynamic_cast<ifcopenshell::geom::serialized_element*>(elem);
ifcopenshell::geom::triangulation_element* triangulation_elem = dynamic_cast<ifcopenshell::geom::triangulation_element*>(elem);
ifcopenshell::geom::brep_element* brep_elem = dynamic_cast<ifcopenshell::geom::brep_element*>(elem);
ifcopenshell::geom::native_element* brep_elem = dynamic_cast<ifcopenshell::geom::native_element*>(elem);
if (triangulation_elem) {
return SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_ifcopenshell__geom__triangulation_element, SWIG_POINTER_OWN);
} else if (serialized_elem) {
return SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_ifcopenshell__geom__serialized_element, SWIG_POINTER_OWN);
} else if (brep_elem) {
return SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_ifcopenshell__geom__brep_element, SWIG_POINTER_OWN);
return SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_ifcopenshell__geom__native_element, SWIG_POINTER_OWN);
} else {
return SWIG_Py_Void();
}
@@ -690,13 +695,13 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
PyObject* operator()(ifcopenshell::geom::representation* representation) const {
ifcopenshell::geom::serialization* serialized_representation = dynamic_cast<ifcopenshell::geom::serialization*>(representation);
ifcopenshell::geom::triangulation* triangulated_representation = dynamic_cast<ifcopenshell::geom::triangulation*>(representation);
ifcopenshell::geom::brep* brep_representation = dynamic_cast<ifcopenshell::geom::brep*>(representation);
ifcopenshell::geom::native* brep_representation = dynamic_cast<ifcopenshell::geom::native*>(representation);
if (serialized_representation) {
return SWIG_NewPointerObj(SWIG_as_voidptr(serialized_representation), SWIGTYPE_p_ifcopenshell__geom__Representation__serialization, SWIG_POINTER_OWN);
return SWIG_NewPointerObj(SWIG_as_voidptr(serialized_representation), SWIGTYPE_p_ifcopenshell__geom__serialization, SWIG_POINTER_OWN);
} else if (triangulated_representation) {
return SWIG_NewPointerObj(SWIG_as_voidptr(triangulated_representation), SWIGTYPE_p_ifcopenshell__geom__Representation__triangulation, SWIG_POINTER_OWN);
return SWIG_NewPointerObj(SWIG_as_voidptr(triangulated_representation), SWIGTYPE_p_ifcopenshell__geom__triangulation, SWIG_POINTER_OWN);
} else if (brep_representation) {
return SWIG_NewPointerObj(SWIG_as_voidptr(brep_representation), SWIGTYPE_p_ifcopenshell__geom__Representation__brep, SWIG_POINTER_OWN);
return SWIG_NewPointerObj(SWIG_as_voidptr(brep_representation), SWIGTYPE_p_ifcopenshell__geom__native, SWIG_POINTER_OWN);
} else {
return SWIG_Py_Void();
}
@@ -722,7 +727,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
// I couldn't get the vector<string> typemap to be applied when %extending Iterator constructor.
// anyway it does not matter as SWIG generates C code without actual constructors
%inline %{
geometry_serializer* create_geometry_serializer(
ifcopenshell::geom::geometry_serializer* create_geometry_serializer(
const std::string& extension,
const std::string& output_filename,
const std::string& output_temp_filename,
@@ -736,7 +741,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
);
}
geometry_serializer* create_geometry_serializer(
ifcopenshell::geom::geometry_serializer* create_geometry_serializer(
const std::string& extension,
const stream_or_filename& output_filename,
const stream_or_filename& output_temp_filename,
@@ -918,7 +923,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
%extend ifcopenshell::geom::serialized_element {
};
%extend ifcopenshell::geom::brep_element {
%extend ifcopenshell::geom::native_element {
double calc_volume_() const {
double v;
if ($self->geometry().calculate_volume(v)) {
@@ -983,7 +988,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
return oss.str();
}
static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*> helper_fn_create_shape(logger& logger, const std::string& geometry_library, ifcopenshell::geom::settings& settings, const express::base& instance, const express::base& representation = express::base()) {
static std::variant<ifcopenshell::geom::element*, ifcopenshell::geom::representation*, ifcopenshell::geom::transformation*> helper_fn_create_shape(ifcopenshell::logger& logger, const std::string& geometry_library, ifcopenshell::geom::settings& settings, const express::base& instance, const express::base& representation = express::base()) {
ifcopenshell::file* file = instance.file();
ifcopenshell::geom::converter kernel(ifcopenshell::geom::kernels::construct(file, geometry_library, settings), file, settings, logger);
@@ -997,7 +1002,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
throw ifcopenshell::exception("No suitable IfcRepresentation found");
}
ifcopenshell::geom::brep_element* brep = kernel.create_brep_for_representation_and_product(selected_representation, instance);
ifcopenshell::geom::native_element* brep = kernel.create_brep_for_representation_and_product(selected_representation, instance);
if (!brep) {
std::ostringstream oss_repr, oss_product;
selected_representation.to_string(oss_repr);
@@ -1045,7 +1050,7 @@ struct shape_rtti : public boost::static_visitor<PyObject*>
throw ifcopenshell::exception("Failed to process shape. Instance: " + oss.str());
}
ifcopenshell::geom::brep brep(kernel.settings(), instance.declaration().name(), to_locale_invariant_string(instance.id()), shapes);
ifcopenshell::geom::native brep(kernel.settings(), instance.declaration().name(), to_locale_invariant_string(instance.id()), shapes);
try {
if (settings.get<ifcopenshell::geom::settings::IteratorOutput>().get() == ifcopenshell::geom::settings::SERIALIZED) {
return new ifcopenshell::geom::serialization(brep);
+11 -11
View File
@@ -1186,9 +1186,9 @@ from .entity_instance import entity_instance_mixin
PyObject* convert_cpp_attribute_to_python(const express::base& instance, size_t attribute_index, bool recursive, bool include_identifier) {
return instance.get_attribute_value(attribute_index).apply_visitor([recursive, include_identifier](const auto& v){
using u = std::decay_t<decltype(v)>;
if constexpr (std::is_same_v<u, enumeration_reference>) {
if constexpr (std::is_same_v<u, ifcopenshell::enumeration_reference>) {
return pythonize(std::string(v.value()));
} else if constexpr (std::is_same_v<u, derived>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::derived>) {
if (feature_use_attribute_value_derived) {
return SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN);
} else {
@@ -1228,7 +1228,7 @@ from .entity_instance import entity_instance_mixin
} else {
return pythonize_vector(v);
}
} else if constexpr (std::is_same_v<u, empty_aggregate> || std::is_same_v<u, empty_aggregate_of_aggregate> || std::is_same_v<u, blank>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::empty_aggregate> || std::is_same_v<u, ifcopenshell::empty_aggregate_of_aggregate> || std::is_same_v<u, ifcopenshell::blank>) {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
} else if constexpr (is_std_vector_v<u>) {
@@ -1289,16 +1289,16 @@ from .entity_instance import entity_instance_mixin
if constexpr (is_std_vector_v<u>) {
return pythonize_vector(t);
} else if constexpr (std::is_same_v<u, enumeration_reference>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::enumeration_reference>) {
return pythonize(std::string(t.value()));
} else if constexpr (std::is_same_v<u, derived>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::derived>) {
if (feature_use_attribute_value_derived) {
return SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN);
} else {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
}
} else if constexpr (std::is_same_v<u, empty_aggregate> || std::is_same_v<u, empty_aggregate_of_aggregate> || std::is_same_v<u, blank>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::empty_aggregate> || std::is_same_v<u, ifcopenshell::empty_aggregate_of_aggregate> || std::is_same_v<u, ifcopenshell::blank>) {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
} else {
@@ -1385,16 +1385,16 @@ from .entity_instance import entity_instance_mixin
} else {
if constexpr (is_std_vector_v<value_type>) {
attribute_val_py = pythonize_vector(t);
} else if constexpr (std::is_same_v<value_type, enumeration_reference>) {
} else if constexpr (std::is_same_v<value_type, ifcopenshell::enumeration_reference>) {
attribute_val_py = pythonize(std::string(t.value()));
} else if constexpr (std::is_same_v<value_type, derived>) {
} else if constexpr (std::is_same_v<value_type, ifcopenshell::derived>) {
if (feature_use_attribute_value_derived) {
attribute_val_py = SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN);
} else {
Py_INCREF(Py_None);
attribute_val_py = static_cast<PyObject*>(Py_None);
}
} else if constexpr (std::is_same_v<value_type, empty_aggregate> || std::is_same_v<value_type, empty_aggregate_of_aggregate> || std::is_same_v<value_type, blank>) {
} else if constexpr (std::is_same_v<value_type, ifcopenshell::empty_aggregate> || std::is_same_v<value_type, ifcopenshell::empty_aggregate_of_aggregate> || std::is_same_v<value_type, ifcopenshell::blank>) {
Py_INCREF(Py_None);
attribute_val_py = static_cast<PyObject*>(Py_None);
} else {
@@ -1483,14 +1483,14 @@ from .entity_instance import entity_instance_mixin
}
}
%extend logger {
%extend ifcopenshell::logger {
%pythoncode %{
def __iter__(self):
return iter(self.log_messages())
%}
}
%extend log_message {
%extend ifcopenshell::log_message {
std::string severity_string() const {
static const char* const severity_strings[] = {"PERF", "DEBUG", "NOTICE", "WARNING", "ERROR"};
return severity_strings[(int)$self->severity];
+8
View File
@@ -53,6 +53,7 @@
%include "std_string.i"
%include "exception.i"
%include "std_shared_ptr.i"
%include "std_unique_ptr.i"
%{
#include <array>
@@ -257,6 +258,13 @@
// @todo abstract into plug-in interface
#include "../serializers/rocks_db_serializer.h"
using ifcopenshell::attribute_value;
using ifcopenshell::blank;
using ifcopenshell::derived;
using ifcopenshell::empty_aggregate;
using ifcopenshell::empty_aggregate_of_aggregate;
using ifcopenshell::enumeration_reference;
%}
// Create docstrings for generated python code.
+1 -1
View File
@@ -267,7 +267,7 @@
PyObject* pythonize(const ifcopenshell::inverse_attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__inverse_attribute, 0); }
PyObject* pythonize(const ifcopenshell::entity* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__entity, 0); }
PyObject* pythonize(const ifcopenshell::declaration* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), declaration_type_to_swig(t), 0); }
PyObject* pythonize(const log_message& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_log_message, 0); }
PyObject* pythonize(const ifcopenshell::log_message& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_ifcopenshell__log_message, 0); }
// @nb ownership
PyObject* pythonize(const ifcopenshell::geom::conversion_result_shape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__geom__conversion_result_shape, SWIG_POINTER_OWN); }
// PyObject* pythonize(const ifcopenshell::geom::conversion_result_shape* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_ifcopenshell__geom__conversion_result_shape, 0); }
+4 -4
View File
@@ -36,16 +36,16 @@
using u = std::decay_t<decltype(v)>;
if constexpr (is_std_vector_v<u>) {
return pythonize_vector(v);
} else if constexpr (std::is_same_v<u, enumeration_reference>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::enumeration_reference>) {
return pythonize(std::string(v.value()));
} else if constexpr (std::is_same_v<u, derived>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::derived>) {
if (feature_use_attribute_value_derived) {
return SWIG_NewPointerObj(new attribute_value_derived, SWIGTYPE_p_attribute_value_derived, SWIG_POINTER_OWN);
} else {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
}
} else if constexpr (std::is_same_v<u, empty_aggregate> || std::is_same_v<u, empty_aggregate_of_aggregate> || std::is_same_v<u, blank>) {
} else if constexpr (std::is_same_v<u, ifcopenshell::empty_aggregate> || std::is_same_v<u, ifcopenshell::empty_aggregate_of_aggregate> || std::is_same_v<u, ifcopenshell::blank>) {
Py_INCREF(Py_None);
return static_cast<PyObject*>(Py_None);
} else {
@@ -92,7 +92,7 @@ CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::inverse_attribute const *)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::entity const *)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::declaration const *)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::geom::conversion_result_shape *)
CREATE_VECTOR_TYPEMAP_OUT(log_message)
CREATE_VECTOR_TYPEMAP_OUT(ifcopenshell::log_message)
%typemap(out) ifcopenshell::geom::settings::value_variant_t {
pythonizing_visitor vis;
+1 -1
View File
@@ -177,7 +177,7 @@ public:
bool ready();
void writeHeader();
void write(const ifcopenshell::geom::triangulation_element* o);
void write(const ifcopenshell::geom::brep_element* /*o*/) {}
void write(const ifcopenshell::geom::native_element* /*o*/) {}
void finalize();
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {
+1 -1
View File
@@ -48,7 +48,7 @@ public:
bool ready();
void writeHeader();
void write(const ifcopenshell::geom::triangulation_element* o);
void write(const ifcopenshell::geom::brep_element* /*o*/) {}
void write(const ifcopenshell::geom::native_element* /*o*/) {}
void finalize();
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
@@ -39,7 +39,7 @@ bool open_cascade_based_serializer::ready() {
return succeeded;
}
void open_cascade_based_serializer::write(const ifcopenshell::geom::brep_element* o) {
void open_cascade_based_serializer::write(const ifcopenshell::geom::native_element* o) {
auto itm = o->geometry().as_compound();
TopoDS_Shape compound = ((ifcopenshell::geom::open_cascade_shape*)itm)->shape();
writeShape(object_id(o), compound);
@@ -45,7 +45,7 @@ public:
bool ready();
virtual void writeShape(const std::string& name, const TopoDS_Shape& shape) = 0;
void write(const ifcopenshell::geom::triangulation_element* /*o*/) {}
void write(const ifcopenshell::geom::brep_element* o);
void write(const ifcopenshell::geom::native_element* o);
bool isTesselated() const { return false; }
void setFile(ifcopenshell::file&) {}
};
+2 -2
View File
@@ -540,7 +540,7 @@ svg_serializer::path_object& svg_serializer::start_path(const gp_Pln& pln, const
}
namespace {
std::optional<std::pair<express::base, double>> storey_elevation_from_element(const ifcopenshell::geom::brep_element* o) {
std::optional<std::pair<express::base, double>> storey_elevation_from_element(const ifcopenshell::geom::native_element* o) {
for (const auto& p : o->parents()) {
if (p->type() == "IfcBuildingStorey") {
try {
@@ -716,7 +716,7 @@ namespace {
}
}
void svg_serializer::write(const ifcopenshell::geom::brep_element* brep_obj) {
void svg_serializer::write(const ifcopenshell::geom::native_element* brep_obj) {
std::optional<std::string> object_type;
if (!brep_obj->product().get("ObjectType").isNull()) {
+1 -1
View File
@@ -676,7 +676,7 @@ public:
void doWriteHeader();
bool ready();
void write(const ifcopenshell::geom::triangulation_element* /*o*/) {}
void write(const ifcopenshell::geom::brep_element* o);
void write(const ifcopenshell::geom::native_element* o);
void write(path_object& p, const TopoDS_Shape& wire, std::optional<std::vector<double>> dash_array=std::nullopt, std::optional<std::string> css_class=std::nullopt);
void write(const geometry_data& data);
path_object& start_path(const gp_Pln& p, const express::base& storey, const std::string& id);
+1 -1
View File
@@ -362,7 +362,7 @@ void ttl_wkt_serializer::write(const ifcopenshell::geom::triangulation_element*
}
}
void ttl_wkt_serializer::write(const ifcopenshell::geom::brep_element* brep_obj) {
void ttl_wkt_serializer::write(const ifcopenshell::geom::native_element* brep_obj) {
#ifdef IFOPSH_WITH_OPENCASCADE
filename_.stream << ttl_object_id(brep_obj) << " a geo:Feature ;\n";
filename_.stream << " dcterms:identifier " << escape_for_turtle(
+1 -1
View File
@@ -36,7 +36,7 @@ public:
bool ready();
void writeHeader();
void write(const ifcopenshell::geom::triangulation_element* o);
void write(const ifcopenshell::geom::brep_element* /*o*/);
void write(const ifcopenshell::geom::native_element* /*o*/);
void finalize() {}
bool isTesselated() const;
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
+1 -1
View File
@@ -91,7 +91,7 @@ public:
bool ready() { return ready_; }
void writeHeader();
void write(const ifcopenshell::geom::triangulation_element*);
void write(const ifcopenshell::geom::brep_element*) {}
void write(const ifcopenshell::geom::native_element*) {}
void finalize();
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string&, float) {}
+1 -1
View File
@@ -41,7 +41,7 @@ public:
void writeHeader();
void writeMaterial(const ifcopenshell::geom::taxonomy::style::ptr style);
void write(const ifcopenshell::geom::triangulation_element* o);
void write(const ifcopenshell::geom::brep_element* /*o*/) {}
void write(const ifcopenshell::geom::native_element* /*o*/) {}
void finalize() {}
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}