mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 19:07:57 +00:00
Last minute refactoring
This commit is contained in:
+43
-43
@@ -38,13 +38,13 @@ namespace {
|
||||
return values;
|
||||
}
|
||||
|
||||
const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& empty_style_vector() {
|
||||
static const std::vector<ifcopenshell::geometry::taxonomy::style::ptr> values;
|
||||
const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& empty_style_vector() {
|
||||
static const std::vector<ifcopenshell::geom::taxonomy::style::ptr> values;
|
||||
return values;
|
||||
}
|
||||
|
||||
std::vector<express::Entity> to_product_entities(const std::vector<express::Base>& instances) {
|
||||
std::vector<express::Entity> entities;
|
||||
std::vector<express::entity> to_product_entities(const std::vector<express::base>& instances) {
|
||||
std::vector<express::entity> entities;
|
||||
entities.reserve(instances.size());
|
||||
|
||||
for (const auto& instance : instances) {
|
||||
@@ -52,7 +52,7 @@ namespace {
|
||||
throw ifcopenshell::exception("All instances should be of type IfcProduct");
|
||||
}
|
||||
|
||||
auto entity = instance.as<express::Entity>();
|
||||
auto entity = instance.as<express::entity>();
|
||||
if (!entity || !instance.declaration().is("IfcProduct")) {
|
||||
throw ifcopenshell::exception("All instances should be of type IfcProduct");
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
class IfcGeom::tree::impl {
|
||||
class ifcopenshell::geom::tree::impl {
|
||||
public:
|
||||
impl() = default;
|
||||
|
||||
@@ -71,81 +71,81 @@ public:
|
||||
: backend_id_(backend_id)
|
||||
{}
|
||||
|
||||
ifcopenshell::geometry::trees::abstract_tree& backend() const {
|
||||
ifcopenshell::geom::trees::abstract_tree& backend() const {
|
||||
if (!backend_) {
|
||||
if (backend_id_.empty()) {
|
||||
throw ifcopenshell::exception("No geometry tree backend configured");
|
||||
}
|
||||
backend_ = ifcopenshell::geometry::trees::construct(backend_id_);
|
||||
backend_ = ifcopenshell::geom::trees::construct(backend_id_);
|
||||
}
|
||||
return *backend_;
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::trees::abstract_tree& backend(const std::string& default_backend_id) const {
|
||||
ifcopenshell::geom::trees::abstract_tree& backend(const std::string& default_backend_id) const {
|
||||
if (backend_id_.empty()) {
|
||||
backend_id_ = default_backend_id;
|
||||
}
|
||||
return backend();
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::trees::abstract_tree& backend_for_element(IfcGeom::Element* element) const {
|
||||
if (dynamic_cast<IfcGeom::BRepElement*>(element)) {
|
||||
ifcopenshell::geom::trees::abstract_tree& backend_for_element(ifcopenshell::geom::element* element) const {
|
||||
if (dynamic_cast<ifcopenshell::geom::brep_element*>(element)) {
|
||||
return backend(default_selection_backend_id);
|
||||
}
|
||||
|
||||
if (dynamic_cast<IfcGeom::TriangulationElement*>(element)) {
|
||||
if (dynamic_cast<ifcopenshell::geom::triangulation_element*>(element)) {
|
||||
return backend(default_clash_backend_id);
|
||||
}
|
||||
|
||||
throw ifcopenshell::exception("Unsupported tree element type");
|
||||
}
|
||||
|
||||
const ifcopenshell::geometry::trees::abstract_tree* backend_or_null() const {
|
||||
const ifcopenshell::geom::trees::abstract_tree* backend_or_null() const {
|
||||
return backend_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::string backend_id_;
|
||||
mutable std::unique_ptr<ifcopenshell::geometry::trees::abstract_tree> backend_;
|
||||
mutable std::unique_ptr<ifcopenshell::geom::trees::abstract_tree> backend_;
|
||||
};
|
||||
|
||||
IfcGeom::tree::tree()
|
||||
ifcopenshell::geom::tree::tree()
|
||||
: impl_(new impl())
|
||||
{}
|
||||
|
||||
IfcGeom::tree::tree(const std::string& backend_id)
|
||||
ifcopenshell::geom::tree::tree(const std::string& backend_id)
|
||||
: impl_(new impl(backend_id))
|
||||
{}
|
||||
|
||||
IfcGeom::tree::tree(ifcopenshell::file& file)
|
||||
ifcopenshell::geom::tree::tree(ifcopenshell::file& file)
|
||||
: tree()
|
||||
{
|
||||
add_file(file, ifcopenshell::geometry::Settings{});
|
||||
add_file(file, ifcopenshell::geom::settings{});
|
||||
}
|
||||
|
||||
IfcGeom::tree::tree(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings)
|
||||
ifcopenshell::geom::tree::tree(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings)
|
||||
: tree()
|
||||
{
|
||||
add_file(file, settings);
|
||||
}
|
||||
|
||||
IfcGeom::tree::tree(IfcGeom::Iterator& iterator)
|
||||
ifcopenshell::geom::tree::tree(ifcopenshell::geom::iterator& iterator)
|
||||
: tree()
|
||||
{
|
||||
add_file(iterator);
|
||||
}
|
||||
|
||||
IfcGeom::tree::~tree() = default;
|
||||
ifcopenshell::geom::tree::~tree() = default;
|
||||
|
||||
IfcGeom::tree::tree(tree&& other) noexcept = default;
|
||||
ifcopenshell::geom::tree::tree(tree&& other) noexcept = default;
|
||||
|
||||
IfcGeom::tree& IfcGeom::tree::operator=(tree&& other) noexcept = default;
|
||||
ifcopenshell::geom::tree& ifcopenshell::geom::tree::operator=(tree&& other) noexcept = default;
|
||||
|
||||
void IfcGeom::tree::add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings) {
|
||||
void ifcopenshell::geom::tree::add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings) {
|
||||
impl_->backend(default_selection_backend_id).add_file(file, settings);
|
||||
}
|
||||
|
||||
void IfcGeom::tree::add_file(IfcGeom::Iterator& iterator) {
|
||||
void ifcopenshell::geom::tree::add_file(ifcopenshell::geom::iterator& iterator) {
|
||||
if (!iterator.initialize()) {
|
||||
return;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ void IfcGeom::tree::add_file(IfcGeom::Iterator& iterator) {
|
||||
} while (iterator.next());
|
||||
}
|
||||
|
||||
void IfcGeom::tree::add_element(IfcGeom::Element* element) {
|
||||
void ifcopenshell::geom::tree::add_element(ifcopenshell::geom::element* element) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
@@ -163,71 +163,71 @@ void IfcGeom::tree::add_element(IfcGeom::Element* element) {
|
||||
impl_->backend_for_element(element).add_element(element);
|
||||
}
|
||||
|
||||
std::vector<express::Entity> IfcGeom::tree::select_box(const express::Entity& entity, bool completely_within, double extend) const {
|
||||
std::vector<express::entity> ifcopenshell::geom::tree::select_box(const express::entity& entity, bool completely_within, double extend) const {
|
||||
return impl_->backend(default_selection_backend_id).select_box(entity, completely_within, extend);
|
||||
}
|
||||
|
||||
std::vector<express::Entity> IfcGeom::tree::select_box(const tree_point& point) const {
|
||||
std::vector<express::entity> ifcopenshell::geom::tree::select_box(const tree_point& point) const {
|
||||
return impl_->backend(default_selection_backend_id).select_box(point);
|
||||
}
|
||||
|
||||
std::vector<express::Entity> IfcGeom::tree::select_box(const tree_box& bounds, bool completely_within) const {
|
||||
std::vector<express::entity> ifcopenshell::geom::tree::select_box(const tree_box& bounds, bool completely_within) const {
|
||||
return impl_->backend(default_selection_backend_id).select_box(bounds, completely_within);
|
||||
}
|
||||
|
||||
std::vector<express::Entity> IfcGeom::tree::select(const express::Entity& entity, bool completely_within, double extend) const {
|
||||
std::vector<express::entity> ifcopenshell::geom::tree::select(const express::entity& entity, bool completely_within, double extend) const {
|
||||
return impl_->backend(default_selection_backend_id).select(entity, completely_within, extend);
|
||||
}
|
||||
|
||||
std::vector<express::Entity> IfcGeom::tree::select(const IfcGeom::Element* element, bool completely_within, double extend) const {
|
||||
std::vector<express::entity> ifcopenshell::geom::tree::select(const ifcopenshell::geom::element* element, bool completely_within, double extend) const {
|
||||
return impl_->backend(default_selection_backend_id).select(element, completely_within, extend);
|
||||
}
|
||||
|
||||
std::vector<express::Entity> IfcGeom::tree::select(const tree_point& point, double extend) const {
|
||||
std::vector<express::entity> ifcopenshell::geom::tree::select(const tree_point& point, double extend) const {
|
||||
return impl_->backend(default_selection_backend_id).select(point, extend);
|
||||
}
|
||||
|
||||
std::vector<IfcGeom::ray_intersection_result> IfcGeom::tree::select_ray(const tree_point& origin, const tree_point& direction, double length) const {
|
||||
std::vector<ifcopenshell::geom::ray_intersection_result> ifcopenshell::geom::tree::select_ray(const tree_point& origin, const tree_point& direction, double length) const {
|
||||
return impl_->backend(default_selection_backend_id).select_ray(origin, direction, length);
|
||||
}
|
||||
|
||||
std::vector<IfcGeom::clash> IfcGeom::tree::clash_intersection_many(const std::vector<express::Base>& set_a, const std::vector<express::Base>& set_b, double tolerance, bool check_all) const {
|
||||
std::vector<ifcopenshell::geom::clash> ifcopenshell::geom::tree::clash_intersection_many(const std::vector<express::base>& set_a, const std::vector<express::base>& set_b, double tolerance, bool check_all) const {
|
||||
return impl_->backend(default_clash_backend_id).clash_intersection_many(to_product_entities(set_a), to_product_entities(set_b), tolerance, check_all);
|
||||
}
|
||||
|
||||
std::vector<IfcGeom::clash> IfcGeom::tree::clash_collision_many(const std::vector<express::Base>& set_a, const std::vector<express::Base>& set_b, bool allow_touching) const {
|
||||
std::vector<ifcopenshell::geom::clash> ifcopenshell::geom::tree::clash_collision_many(const std::vector<express::base>& set_a, const std::vector<express::base>& set_b, bool allow_touching) const {
|
||||
return impl_->backend(default_clash_backend_id).clash_collision_many(to_product_entities(set_a), to_product_entities(set_b), allow_touching);
|
||||
}
|
||||
|
||||
std::vector<IfcGeom::clash> IfcGeom::tree::clash_clearance_many(const std::vector<express::Base>& set_a, const std::vector<express::Base>& set_b, double clearance, bool check_all) const {
|
||||
std::vector<ifcopenshell::geom::clash> ifcopenshell::geom::tree::clash_clearance_many(const std::vector<express::base>& set_a, const std::vector<express::base>& set_b, double clearance, bool check_all) const {
|
||||
return impl_->backend(default_clash_backend_id).clash_clearance_many(to_product_entities(set_a), to_product_entities(set_b), clearance, check_all);
|
||||
}
|
||||
|
||||
const std::vector<double>& IfcGeom::tree::distances() const {
|
||||
const std::vector<double>& ifcopenshell::geom::tree::distances() const {
|
||||
const auto* backend = impl_->backend_or_null();
|
||||
return backend ? backend->distances() : empty_double_vector();
|
||||
}
|
||||
|
||||
const std::vector<double>& IfcGeom::tree::protrusion_distances() const {
|
||||
const std::vector<double>& ifcopenshell::geom::tree::protrusion_distances() const {
|
||||
const auto* backend = impl_->backend_or_null();
|
||||
return backend ? backend->protrusion_distances() : empty_double_vector();
|
||||
}
|
||||
|
||||
bool IfcGeom::tree::enable_face_styles() const {
|
||||
bool ifcopenshell::geom::tree::enable_face_styles() const {
|
||||
const auto* backend = impl_->backend_or_null();
|
||||
return backend ? backend->enable_face_styles() : false;
|
||||
}
|
||||
|
||||
void IfcGeom::tree::enable_face_styles(bool enable) {
|
||||
void ifcopenshell::geom::tree::enable_face_styles(bool enable) {
|
||||
impl_->backend(default_selection_backend_id).enable_face_styles(enable);
|
||||
}
|
||||
|
||||
const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& IfcGeom::tree::styles() const {
|
||||
const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& ifcopenshell::geom::tree::styles() const {
|
||||
const auto* backend = impl_->backend_or_null();
|
||||
return backend ? backend->styles() : empty_style_vector();
|
||||
}
|
||||
|
||||
std::string IfcGeom::tree::uint8_to_b64(const std::vector<uint8_t>& uuids_array) const {
|
||||
std::string ifcopenshell::geom::tree::uint8_to_b64(const std::vector<uint8_t>& uuids_array) const {
|
||||
std::string hex_str;
|
||||
hex_str.reserve(uuids_array.size() * 2);
|
||||
|
||||
@@ -240,7 +240,7 @@ std::string IfcGeom::tree::uint8_to_b64(const std::vector<uint8_t>& uuids_array)
|
||||
return hex_str;
|
||||
}
|
||||
|
||||
bool IfcGeom::tree::is_manifold(const std::vector<int>& faces) {
|
||||
bool ifcopenshell::geom::tree::is_manifold(const std::vector<int>& faces) {
|
||||
std::unordered_set<std::pair<size_t, size_t>, boost::hash<std::pair<size_t, size_t>>> directed_edges;
|
||||
|
||||
for (size_t i = 0; i < faces.size(); i += 3) {
|
||||
|
||||
Reference in New Issue
Block a user