Major update: taxonomy shared pointers, collection type safety, work towards hashing

This commit is contained in:
Thomas Krijnen
2023-07-27 16:42:06 +08:00
parent 98a73f1646
commit 65a5646bf0
122 changed files with 1669 additions and 1203 deletions
+7 -10
View File
@@ -63,18 +63,15 @@ void fix_spaceboundaries(IfcParse::IfcFile& f, bool no_progress, bool quiet, boo
auto g1 = n.substr(0, 22);
auto g2 = n.substr(23);
auto item = c.mapping()->map(i);
if (((ifcopenshell::geometry::taxonomy::collection*) item)->children[0] == nullptr) {
if (taxonomy::cast<taxonomy::collection>(item)->children[0] == nullptr) {
continue;
}
auto shell = (taxonomy::shell*) ((taxonomy::collection*)((taxonomy::collection*) item)->children[0])->children[0];
for (auto& f : shell->children) {
auto face = (taxonomy::face*) f;
for (auto& w : face->children) {
auto wire = (taxonomy::loop*) w;
for (auto& e : wire->children) {
auto edge = (taxonomy::edge*) e;
auto p3 = boost::get<taxonomy::point3>(edge->start);
auto p4 = ((taxonomy::geom_item*)item)->matrix.ccomponents() * p3.ccomponents().homogeneous();
auto shell = taxonomy::cast<taxonomy::shell>(taxonomy::cast<taxonomy::collection>(taxonomy::cast<taxonomy::collection>(item)->children[0])->children[0]);
for (auto& face : shell->children) {
for (auto& wire : face->children) {
for (auto& edge : wire->children) {
auto p3 = boost::get<taxonomy::point3::ptr>(edge->start);
auto p4 = taxonomy::cast<taxonomy::geom_item>(item)->matrix->ccomponents() * p3->ccomponents().homogeneous();
Kernel_::Point_3 P(p4(0), p4(1), p4(2));
elem_to_space_boundary_coords[{g1, g2}].emplace_back(P);
}
@@ -134,8 +134,8 @@ void fix_storeycontainment(IfcParse::IfcFile& f, bool no_progress, bool quiet, b
for (auto& g : geom_object->geometry()) {
auto s = ((ifcopenshell::geometry::CgalShape*) g.Shape())->shape();
const auto& m = g.Placement().ccomponents();
const auto& n = geom_object->transformation().data().ccomponents();
const auto& m = g.Placement()->ccomponents();
const auto& n = geom_object->transformation().data()->ccomponents();
const cgal_placement_t trsf(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
@@ -110,23 +110,23 @@ void fix_wallconnectivity(IfcParse::IfcFile& f, bool no_progress, bool quiet, bo
auto get_axis_parameter_min_max = [&c, &x_poly](const IfcUtil::IfcBaseEntity* inst) {
auto item = c.mapping()->map(inst);
auto shaperep = ((taxonomy::collection*) item)->children[0];
auto loop = ((taxonomy::collection*) shaperep)->children[0];
auto shaperep = taxonomy::cast<taxonomy::collection>(item)->children[0];
auto loop = taxonomy::dcast<taxonomy::loop>(taxonomy::cast<taxonomy::collection>(shaperep)->children[0]);
if (loop->kind() != taxonomy::LOOP) {
if (!loop) {
// std::wcout << "no suitable axis" << std::endl;
} else {
auto first_vertex = ((taxonomy::edge*) ((taxonomy::loop*) loop)->children.front())->start;
auto last_vertex = ((taxonomy::edge*) ((taxonomy::loop*) loop)->children.back())->end;
auto first_vertex = loop->children.front()->start;
auto last_vertex = loop->children.back()->end;
if (first_vertex.which() != 0 || last_vertex.which() != 0) {
// std::wcout << "trims not supported" << std::endl;
} else {
auto p0 = boost::get<taxonomy::point3>(first_vertex);
auto p1 = boost::get<taxonomy::point3>(last_vertex);
auto p0 = boost::get<taxonomy::point3::ptr>(first_vertex);
auto p1 = boost::get<taxonomy::point3::ptr>(last_vertex);
auto v0 = ((taxonomy::geom_item*)item)->matrix.ccomponents() * p0.ccomponents().homogeneous();
auto v1 = ((taxonomy::geom_item*)item)->matrix.ccomponents() * p1.ccomponents().homogeneous();
auto v0 = taxonomy::cast<taxonomy::geom_item>(item)->matrix->ccomponents() * p0->ccomponents().homogeneous();
auto v1 = taxonomy::cast<taxonomy::geom_item>(item)->matrix->ccomponents() * p1->ccomponents().homogeneous();
auto P0 = Kernel_::Point_3(v0(0), v0(1), v0(2));
auto P1 = Kernel_::Point_3(v1(0), v1(1), v1(2));
+2 -2
View File
@@ -477,8 +477,8 @@ struct intersection_validator {
for (auto& g : geom_object->geometry()) {
auto s = ((ifcopenshell::geometry::CgalShape*) g.Shape())->shape();
const auto& m = g.Placement().ccomponents();
const auto& n = geom_object->transformation().data().ccomponents();
const auto& m = g.Placement()->ccomponents();
const auto& n = geom_object->transformation().data()->ccomponents();
const cgal_placement_t trsf(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
+6 -4
View File
@@ -18,7 +18,7 @@
using namespace ifcopenshell::geometry;
bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::item* item, IfcGeom::ConversionResults& results) {
bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::ptr item, IfcGeom::ConversionResults& results) {
// std::stringstream ss;
// item->print(ss);
// auto sss = ss.str();
@@ -59,15 +59,17 @@ ifcopenshell::geometry::kernels::AbstractKernel* ifcopenshell::geometry::kernels
throw IfcParse::IfcException("No geometry kernel registered for " + geometry_library);
}
bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::collection* collection, IfcGeom::ConversionResults& r) {
bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::collection::ptr collection, IfcGeom::ConversionResults& r) {
auto s = r.size();
for (auto& c : collection->children) {
convert(c, r);
}
for (auto i = s; i < r.size(); ++i) {
r[i].prepend(collection->matrix);
if (collection->matrix) {
r[i].prepend(collection->matrix);
}
if (!r[i].hasStyle() && collection->surface_style) {
r[i].setStyle(*collection->surface_style);
r[i].setStyle(collection->surface_style);
}
}
return r.size() > s;
+33 -32
View File
@@ -27,32 +27,33 @@ namespace ifcopenshell { namespace geometry { namespace kernels {
: geometry_library(geometry_library)
, conv_settings_(settings) {}
bool convert(const taxonomy::item*, IfcGeom::ConversionResults&);
bool convert(const taxonomy::ptr, IfcGeom::ConversionResults&);
const ConversionSettings& settings() const;
virtual bool convert_impl(const taxonomy::matrix4*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::point3*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::direction3*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::line*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::circle*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::ellipse*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::bspline_curve*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::edge*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::loop*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::shell*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::face*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::extrusion*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::node*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::colour*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::boolean_result*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::plane*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::offset_curve*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::revolve*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::bspline_surface*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::cylinder*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::solid*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::surface_curve_sweep*, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::collection*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::matrix4::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::point3::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::direction3::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::line::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::circle::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::ellipse::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::bspline_curve::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::edge::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::loop::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::face::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::extrusion::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::node::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::colour::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::plane::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::offset_curve::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::revolve::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::bspline_surface::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::cylinder::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::surface_curve_sweep::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::loft::ptr, IfcGeom::ConversionResults&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_impl(const taxonomy::collection::ptr, IfcGeom::ConversionResults&);
/*
virtual void set_offset(const std::array<double, 3> &p_offset);
@@ -61,7 +62,7 @@ namespace ifcopenshell { namespace geometry { namespace kernels {
virtual bool apply_layerset(IfcGeom::ConversionResults&, const ifcopenshell::geometry::layerset_information&) { throw std::runtime_error("Not implemented"); }
virtual bool apply_folded_layerset(IfcGeom::ConversionResults&, const ifcopenshell::geometry::layerset_information&, const std::map<IfcUtil::IfcBaseEntity*, ifcopenshell::geometry::layerset_information>&) { throw std::runtime_error("Not implemented"); }
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::item*, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) = 0;
};
@@ -77,9 +78,9 @@ namespace {
/* A compile-time for loop over the taxonomy kinds */
template <size_t N>
struct dispatch_conversion {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::item* item, IfcGeom::ConversionResults& results) {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults& results) {
if (N == item->kind()) {
auto concrete_item = static_cast<const ifcopenshell::geometry::taxonomy::type_by_kind::type<N>*>(item);
auto concrete_item = taxonomy::template cast<ifcopenshell::geometry::taxonomy::type_by_kind::type<N>>(item);
return kernel->convert_impl(concrete_item, results);
} else {
return dispatch_conversion<N + 1>::dispatch(kernel, item, results);
@@ -89,7 +90,7 @@ namespace {
template <>
struct dispatch_conversion<ifcopenshell::geometry::taxonomy::type_by_kind::max> {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::item* item, IfcGeom::ConversionResults&) {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults&) {
Logger::Error("No conversion for " + std::to_string(item->kind()));
return false;
}
@@ -98,11 +99,11 @@ namespace {
/* A compile-time for loop over the curve kinds */
template <typename T, size_t N = 0>
struct dispatch_curve_creation {
static bool dispatch(const ifcopenshell::geometry::taxonomy::item* item, T& visitor) {
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr item, T& visitor) {
// @todo it should be possible to eliminate this dynamic_cast when there is a static equivalent to kind()
const ifcopenshell::geometry::taxonomy::curves::type<N>* v = dynamic_cast<const ifcopenshell::geometry::taxonomy::curves::type<N>*>(item);
auto v = taxonomy::template dcast<ifcopenshell::geometry::taxonomy::curves::type<N>>(item);
if (v) {
visitor(*v);
visitor(v);
return true;
} else {
return dispatch_curve_creation<T, N + 1>::dispatch(item, visitor);
@@ -112,7 +113,7 @@ namespace {
template <typename T>
struct dispatch_curve_creation<T, ifcopenshell::geometry::taxonomy::curves::max> {
static bool dispatch(const ifcopenshell::geometry::taxonomy::item* item, T&) {
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr item, T&) {
Logger::Error("No conversion for " + std::to_string(item->kind()));
return false;
}
+25 -31
View File
@@ -50,42 +50,36 @@ namespace IfcGeom {
class IFC_GEOM_API ConversionResult {
private:
int id;
ifcopenshell::geometry::taxonomy::matrix4 placement;
ConversionResultShape* shape;
ifcopenshell::geometry::taxonomy::style style_;
ifcopenshell::geometry::taxonomy::matrix4::ptr placement_;
ConversionResultShape* shape_;
ifcopenshell::geometry::taxonomy::style::ptr style_;
public:
ConversionResult(int id, const ifcopenshell::geometry::taxonomy::matrix4& placement, const ConversionResultShape* shape, const ifcopenshell::geometry::taxonomy::style* style)
: id(id), placement(placement), shape(shape->clone())
{
if (style) {
style_ = *style;
}
}
ConversionResult(int id, const ifcopenshell::geometry::taxonomy::matrix4& placement, const ConversionResultShape* shape)
: id(id), placement(placement), shape(shape->clone()) {}
ConversionResult(int id, const ConversionResultShape* shape, const ifcopenshell::geometry::taxonomy::style* style)
: id(id), shape(shape->clone())
{
if (style) {
style_ = *style;
}
}
ConversionResult(int id, const ConversionResultShape* shape)
: id(id), shape(shape->clone()) {}
void append(const ifcopenshell::geometry::taxonomy::matrix4& trsf) {
ConversionResult(int id, ifcopenshell::geometry::taxonomy::matrix4::ptr placement, ConversionResultShape* shape, ifcopenshell::geometry::taxonomy::style::ptr style)
: id(id), placement_(placement ? placement : ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>()), shape_(shape), style_(style)
{}
ConversionResult(int id, ifcopenshell::geometry::taxonomy::matrix4::ptr placement, ConversionResultShape* shape)
: id(id), placement_(placement ? placement : ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>()), shape_(shape)
{}
ConversionResult(int id, ConversionResultShape* shape, ifcopenshell::geometry::taxonomy::style::ptr style)
: id(id), placement_(ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>()), shape_(shape), style_(style)
{}
ConversionResult(int id, ConversionResultShape* shape)
: id(id), placement_(ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>()), shape_(shape)
{}
void append(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) {
// @todo verify order
placement.components() = placement.ccomponents() * trsf.ccomponents();
placement_->components() = placement_->ccomponents() * trsf->ccomponents();
}
void prepend(const ifcopenshell::geometry::taxonomy::matrix4& trsf) {
void prepend(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) {
// @todo verify order
placement.components() = trsf.ccomponents() * placement.ccomponents();
placement_->components() = trsf->ccomponents() * placement_->ccomponents();
}
const ConversionResultShape* Shape() const { return shape; }
ConversionResultShape* Shape() { return shape; }
const ifcopenshell::geometry::taxonomy::matrix4& Placement() const { return placement; }
bool hasStyle() const { return !!style_.diffuse; }
const ifcopenshell::geometry::taxonomy::style& Style() const { return style_; }
void setStyle(const ifcopenshell::geometry::taxonomy::style& newStyle) { style_ = newStyle; }
ConversionResultShape* Shape() const { return shape_; }
ifcopenshell::geometry::taxonomy::matrix4::ptr Placement() const { return placement_; }
bool hasStyle() const { return !!style_; }
const ifcopenshell::geometry::taxonomy::style& Style() const { return *style_; }
ifcopenshell::geometry::taxonomy::style::ptr StylePtr() const { return style_; }
void setStyle(ifcopenshell::geometry::taxonomy::style::ptr newStyle) { style_ = newStyle; }
int ItemId() const { return id; }
};
+11 -11
View File
@@ -30,7 +30,7 @@ namespace {
}
}
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(taxonomy::item* representation_node, const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4& place_) {
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4::ptr& place_) {
std::stringstream representation_id_builder;
auto place = place_;
@@ -108,10 +108,10 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
auto single_material = mapping_->get_single_material_association(product);
if (single_material) {
auto s = (taxonomy::style*) mapping_->map(single_material);
auto s = taxonomy::cast<taxonomy::style>(mapping_->map(single_material));
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
if (!it->hasStyle() && s) {
it->setStyle(*s);
it->setStyle(s);
material_style_applied = true;
}
}
@@ -137,7 +137,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
for (auto& s : shapes) {
if (s.hasStyle()) {
// @todo the uglyness
const_cast<taxonomy::style*>(&s.Style())->transparency = settings_.force_space_transparency();
const_cast<taxonomy::style*>(&*s.StylePtr())->transparency = settings_.force_space_transparency();
}
}
}
@@ -172,14 +172,14 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
IfcGeom::ConversionResults opened_shapes;
bool caught_error = false;
try {
std::vector<std::pair<taxonomy::item*, taxonomy::matrix4>> opening_items;
std::vector<std::pair<taxonomy::ptr, taxonomy::matrix4>> opening_items;
std::transform(openings->begin(), openings->end(), std::back_inserter(opening_items), [this](IfcUtil::IfcBaseClass* opening) {
auto prod_item = mapping()->map(opening);
return std::make_pair(mapping()->map(mapping()->representation_of(opening->as<IfcUtil::IfcBaseEntity>())), ((taxonomy::geom_item*)prod_item)->matrix);
return std::make_pair(mapping()->map(mapping()->representation_of(opening->as<IfcUtil::IfcBaseEntity>())), *taxonomy::cast<taxonomy::geom_item>(prod_item)->matrix);
});
kernel_->convert_openings(product, opening_items, shapes, place, opened_shapes);
kernel_->convert_openings(product, opening_items, shapes, *place, opened_shapes);
} catch (const std::exception& e) {
Logger::Message(Logger::LOG_ERROR, std::string("Error processing openings for: ") + e.what() + ":", product);
caught_error = true;
@@ -195,7 +195,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
for (auto it = opened_shapes.begin(); it != opened_shapes.end(); ++it) {
it->prepend(place);
}
place = ifcopenshell::geometry::taxonomy::matrix4();
place = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>();
representation_id_builder << "-world-coords";
}
shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), opened_shapes);
@@ -203,7 +203,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
it->prepend(place);
}
place = ifcopenshell::geometry::taxonomy::matrix4();
place = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>();
representation_id_builder << "-world-coords";
shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), shapes);
} else {
@@ -308,7 +308,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
return elem;
}
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4& place, IfcGeom::BRepElement* brep) {
IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4::ptr& place, IfcGeom::BRepElement* brep) {
int parent_id = -1;
try {
@@ -352,7 +352,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
return create_brep_for_representation_and_product(
mapping_->map(representation),
product,
((taxonomy::geom_item*)mapping_->map(product))->matrix
taxonomy::cast<taxonomy::geom_item>(mapping_->map(product))->matrix
);
}
+3 -3
View File
@@ -21,7 +21,7 @@ namespace ifcopenshell { namespace geometry {
abstract_mapping* mapping_;
kernels::AbstractKernel* kernel_;
IfcGeom::IteratorSettings settings_;
std::map<ifcopenshell::geometry::taxonomy::item*, brep_ptr, ifcopenshell::geometry::taxonomy::less_functor> cache_;
std::map<ifcopenshell::geometry::taxonomy::ptr, brep_ptr, ifcopenshell::geometry::taxonomy::less_functor> cache_;
public:
kernels::AbstractKernel* kernel() { return kernel_; }
@@ -59,8 +59,8 @@ namespace ifcopenshell { namespace geometry {
IfcGeom::BRepElement* create_brep_for_representation_and_product(const IfcUtil::IfcBaseEntity* representation, const IfcUtil::IfcBaseEntity* product);
// IfcGeom::BRepElement* create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* representation, const IfcUtil::IfcBaseEntity* product, IfcGeom::BRepElement* brep);
IfcGeom::BRepElement* create_brep_for_representation_and_product(taxonomy::item*, const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4& place);
IfcGeom::BRepElement* create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4& place, IfcGeom::BRepElement*);
IfcGeom::BRepElement* create_brep_for_representation_and_product(taxonomy::ptr, const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4::ptr& place);
IfcGeom::BRepElement* create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* product, const taxonomy::matrix4::ptr& place, IfcGeom::BRepElement*);
};
}}
+6 -6
View File
@@ -36,13 +36,13 @@ namespace IfcGeom {
class Transformation {
private:
ElementSettings settings_;
ifcopenshell::geometry::taxonomy::matrix4 matrix_;
ifcopenshell::geometry::taxonomy::matrix4::ptr matrix_;
public:
Transformation(const ElementSettings& settings, const ifcopenshell::geometry::taxonomy::matrix4& matrix)
Transformation(const ElementSettings& settings, const ifcopenshell::geometry::taxonomy::matrix4::ptr& matrix)
: settings_(settings)
, matrix_(matrix)
{}
const ifcopenshell::geometry::taxonomy::matrix4& data() const { return matrix_; }
const ifcopenshell::geometry::taxonomy::matrix4::ptr& data() const { return matrix_; }
};
class Element {
@@ -94,7 +94,7 @@ namespace IfcGeom {
void SetParents(std::vector<const IfcGeom::Element*> newparents) { _parents = newparents; }
Element(const ElementSettings& settings, int id, int parent_id, const std::string& name, const std::string& type,
const std::string& guid, const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4& trsf, const IfcUtil::IfcBaseEntity* product)
const std::string& guid, const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4::ptr& trsf, const IfcUtil::IfcBaseEntity* product)
: _id(id), _parent_id(parent_id), _name(name), _type(type), _guid(guid), _context(context), _transformation(settings, trsf)
, product_(product)
{
@@ -130,14 +130,14 @@ namespace IfcGeom {
const boost::shared_ptr<IfcGeom::Representation::BRep>& geometry_pointer() const { return _geometry; }
const IfcGeom::Representation::BRep& geometry() const { return *_geometry; }
BRepElement(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid,
const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4& trsf, const boost::shared_ptr<IfcGeom::Representation::BRep>& geometry,
const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4::ptr& trsf, const boost::shared_ptr<IfcGeom::Representation::BRep>& geometry,
const IfcUtil::IfcBaseEntity* product)
: Element(geometry->settings() ,id, parent_id, name, type, guid, context, trsf, product)
, _geometry(geometry)
{}
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);
return geometry().calculate_projected_surface_area(*this->transformation().data(), along_x, along_y, along_z);
}
private:
BRepElement(const BRepElement& other);
+3 -3
View File
@@ -194,9 +194,9 @@ IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool
// @todo, check
gp_GTrsf trsf;
if (it->Placement().components_) {
if (it->Placement()->components_) {
gp_Trsf tr;
const auto& m = it->Placement().ccomponents();
const auto& m = it->Placement()->ccomponents();
tr.SetValues(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
m(1, 0), m(1, 1), m(1, 2), m(1, 3),
@@ -346,7 +346,7 @@ IfcGeom::Representation::Triangulation::Triangulation(const BRep& shape_model)
}
}
iit->Shape()->Triangulate(settings(), iit->Placement(), this, surface_style_id);
iit->Shape()->Triangulate(settings(), *iit->Placement(), this, surface_style_id);
}
}
+11 -11
View File
@@ -91,8 +91,8 @@ using namespace ifcopenshell::geometry;
namespace {
struct geometry_conversion_result {
int index;
ifcopenshell::geometry::taxonomy::item* item;
std::vector<std::pair<const IfcUtil::IfcBaseEntity*, taxonomy::matrix4>> products;
ifcopenshell::geometry::taxonomy::ptr item;
std::vector<std::pair<const IfcUtil::IfcBaseEntity*, taxonomy::matrix4::ptr>> products;
std::vector<IfcGeom::BRepElement*> breps;
std::vector<IfcGeom::Element*> elements;
};
@@ -180,7 +180,7 @@ namespace IfcGeom {
res.item = converter_->mapping()->map(task.representation);
std::transform(task.products->begin(), task.products->end(), std::back_inserter(res.products), [this, &res](IfcUtil::IfcBaseClass* prod) {
auto prod_item = converter_->mapping()->map(prod);
return std::make_pair(prod->as<IfcUtil::IfcBaseEntity>(), ((taxonomy::geom_item*)prod_item)->matrix);
return std::make_pair(prod->as<IfcUtil::IfcBaseEntity>(), taxonomy::cast<taxonomy::geom_item>(prod_item)->matrix);
});
tasks_.push_back(res);
}
@@ -195,13 +195,13 @@ namespace IfcGeom {
// There needs to be two options, mapped item respecting (does that still work?), and optimized based on topology sorting.
// Or is the sorting not necessary if we just cache?
std::vector<taxonomy::item*> items;
std::map<taxonomy::item*, taxonomy::matrix4> placements;
std::vector<taxonomy::ptr> items;
std::map<taxonomy::ptr, taxonomy::matrix4> placements;
std::transform(products.begin(), products.end(), std::back_inserter(items), [this, &placements](IfcUtil::IfcBaseClass* p) {
auto item = converter_->mapping()->map(p);
// Product placements do not affect item reuse and should temporarily be swapped to identity
if (item) {
std::swap(placements[item], ((taxonomy::geom_item*)item)->matrix);
std::swap(placements[item], ((taxonomy::geom_ptr)item)->matrix);
}
return item;
});
@@ -212,7 +212,7 @@ namespace IfcGeom {
auto jt = std::upper_bound(it, items.end(), *it, taxonomy::less);
geometry_conversion_result r;
r.item = *it;
std::transform(it, jt, std::back_inserter(r.products), [&r, &placements](taxonomy::item* product_node) {
std::transform(it, jt, std::back_inserter(r.products), [&r, &placements](taxonomy::ptr product_node) {
return std::make_pair((IfcUtil::IfcBaseEntity*) product_node->instance, placements[product_node]);
});
tasks_.push_back(r);
@@ -344,7 +344,7 @@ namespace IfcGeom {
IfcGeom::Element* geom_object = get();
const IfcGeom::TriangulationElement* o = static_cast<const IfcGeom::TriangulationElement*>(geom_object);
const IfcGeom::Representation::Triangulation& mesh = o->geometry();
auto mat = o->transformation().data().ccomponents();
auto mat = o->transformation().data()->ccomponents();
Eigen::Vector4d vec, transformed;
for (typename std::vector<double>::const_iterator it = mesh.verts().begin(); it != mesh.verts().end();) {
@@ -371,7 +371,7 @@ namespace IfcGeom {
for (auto& product : products) {
auto prod_item = converter_->mapping()->map(product);
auto vec = ((taxonomy::geom_item*)prod_item)->matrix.translation_part();
auto vec = taxonomy::cast<taxonomy::geom_item>(prod_item)->matrix->translation_part();
for (int i = 0; i < 3; ++i) {
bounds_min_.components()(i) = std::min(bounds_min_.components()(i), vec(i));
@@ -660,7 +660,7 @@ namespace IfcGeom {
}
const Element* get_object(int id) {
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
int parent_id = -1;
std::string instance_type, product_name, product_guid;
IfcUtil::IfcBaseEntity* ifc_product = 0;
@@ -679,7 +679,7 @@ namespace IfcGeom {
parent_id = parent_object->data().id();
}
m4 = ((taxonomy::geom_item*) converter_->mapping()->map(ifc_product))->matrix;
m4 = taxonomy::cast<taxonomy::geom_item>(converter_->mapping()->map(ifc_product))->matrix;
} catch (const std::exception& e) {
Logger::Error(e);
}
+1 -1
View File
@@ -32,7 +32,7 @@ namespace geometry {
public:
abstract_mapping(IfcGeom::IteratorSettings& s) : settings_(s) {}
virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseInterface*) = 0;
virtual ifcopenshell::geometry::taxonomy::ptr map(const IfcUtil::IfcBaseInterface*) = 0;
virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters) = 0;
virtual IfcUtil::IfcBaseEntity* get_decomposing_entity(const IfcUtil::IfcBaseEntity* product, bool include_openings = true) = 0;
virtual std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*) = 0;
+113 -116
View File
@@ -151,17 +151,15 @@ CGAL::Nef_polyhedron_3<Kernel_> ifcopenshell::geometry::utils::create_nef_polyhe
}
#endif
bool CgalKernel::convert(const taxonomy::shell* l, cgal_shape_t& shape) {
auto faces = l->children_as<taxonomy::face>();
if (faces.size() > 100) {
bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
if (l->children.size() > 100) {
static double inf = 1.e9; // std::numeric_limits<double>::infinity();
std::pair<Eigen::Vector3d, Eigen::Vector3d> minmax(
Eigen::Vector3d(+inf, +inf, +inf),
Eigen::Vector3d(-inf, -inf, -inf)
);
size_t num_points = 0;
visit_2<taxonomy::point3>(l, [&minmax, &num_points](const taxonomy::point3* p) {
visit_2<taxonomy::point3, taxonomy::shell>(l, [&minmax, &num_points](const taxonomy::point3::ptr p) {
auto& c = p->ccomponents();
++num_points;
for (int i = 0; i < 3; ++i) {
@@ -187,7 +185,7 @@ bool CgalKernel::convert(const taxonomy::shell* l, cgal_shape_t& shape) {
}
std::list<cgal_face_t> face_list;
for (auto& f : faces) {
for (auto& f : l->children) {
bool success = false;
cgal_face_t face;
@@ -212,12 +210,10 @@ bool CgalKernel::convert(const taxonomy::shell* l, cgal_shape_t& shape) {
return shape.size_of_facets();
}
bool CgalKernel::convert(const taxonomy::face* face, cgal_face_t& result) {
auto bounds = face->children_as<taxonomy::loop>();
bool CgalKernel::convert(const taxonomy::face::ptr face, cgal_face_t& result) {
int num_outer_bounds = 0;
for (auto& bound : bounds) {
for (auto& bound : face->children) {
if (bound->external.get_value_or(false)) num_outer_bounds++;
}
@@ -228,7 +224,7 @@ bool CgalKernel::convert(const taxonomy::face* face, cgal_face_t& result) {
cgal_face_t mf;
for (auto& bound : bounds) {
for (auto& bound : face->children) {
const bool is_interior = !bound->external.get_value_or(false);
@@ -257,28 +253,26 @@ bool CgalKernel::convert(const taxonomy::face* face, cgal_face_t& result) {
namespace {
// @todo obsolete?
bool convert_curve(CgalKernel* kernel, const taxonomy::item* curve, cgal_wire_t& builder) {
if (curve->kind() == taxonomy::EDGE) {
auto e = (taxonomy::edge*) curve;
bool convert_curve(CgalKernel* kernel, const taxonomy::ptr curve, cgal_wire_t& builder) {
if (auto e = taxonomy::dcast<taxonomy::edge>(curve)) {
if (true || e->basis == nullptr) {
if (builder.empty()) {
const auto& p = boost::get<taxonomy::point3>(e->start);
cgal_point_t pnt(p.ccomponents()(0), p.ccomponents()(1), p.ccomponents()(2));
const auto& p = boost::get<taxonomy::point3::ptr>(e->start);
cgal_point_t pnt(p->ccomponents()(0), p->ccomponents()(1), p->ccomponents()(2));
builder.push_back(pnt);
}
const auto& p = boost::get<taxonomy::point3>(e->end);
cgal_point_t pnt(p.ccomponents()(0), p.ccomponents()(1), p.ccomponents()(2));
const auto& p = boost::get<taxonomy::point3::ptr>(e->end);
cgal_point_t pnt(p->ccomponents()(0), p->ccomponents()(1), p->ccomponents()(2));
builder.push_back(pnt);
} else if (e->basis->kind() == taxonomy::CIRCLE) {
// @todo
} else if (e->basis->kind() == taxonomy::ELLIPSE) {
// @todo
} else {
throw std::runtime_error("Not implemented basis kind");
}
} else if (curve->kind() == taxonomy::LOOP) {
const auto& edges = ((taxonomy::loop*) curve)->children;
for (auto& c : edges) {
} else if (auto lp = taxonomy::dcast<taxonomy::loop>(curve)) {
for (auto& c : lp->children) {
convert_curve(kernel, c, builder);
}
} else {
@@ -295,34 +289,34 @@ namespace {
+std::numeric_limits<double>::infinity()
};
void evaluate_curve(const taxonomy::line& c, double u, taxonomy::point3& p) {
void evaluate_curve(const taxonomy::line::ptr& c, double u, taxonomy::point3& p) {
Eigen::Vector4d xy{ u, 0, 0, 1. };
p.components() = (c.matrix.ccomponents() * xy).head<3>();
p.components() = (c->matrix->ccomponents() * xy).head<3>();
}
void evaluate_curve(const taxonomy::circle& c, double u, taxonomy::point3& p) {
Eigen::Vector4d xy{ c.radius * std::cos(u), c.radius * std::sin(u), 0, 1. };
p.components() = (c.matrix.ccomponents() * xy).head<3>();
void evaluate_curve(const taxonomy::circle::ptr& c, double u, taxonomy::point3& p) {
Eigen::Vector4d xy{ c->radius * std::cos(u), c->radius * std::sin(u), 0, 1. };
p.components() = (c->matrix->ccomponents() * xy).head<3>();
}
void evaluate_curve(const taxonomy::ellipse& c, double u, taxonomy::point3& p) {
Eigen::Vector4d xy{ c.radius * std::cos(u), c.radius2 * std::sin(u), 0, 1. };
p.components() = (c.matrix.ccomponents() * xy).head<3>();
void evaluate_curve(const taxonomy::ellipse::ptr& c, double u, taxonomy::point3& p) {
Eigen::Vector4d xy{ c->radius * std::cos(u), c->radius2 * std::sin(u), 0, 1. };
p.components() = (c->matrix->ccomponents() * xy).head<3>();
}
// ----
void project_onto_curve(const taxonomy::line& c, const taxonomy::point3& p, double& u) {
u = (c.matrix.ccomponents().inverse() * p.ccomponents().homogeneous())(0);
void project_onto_curve(const taxonomy::line::ptr& c, const taxonomy::point3& p, double& u) {
u = (c->matrix->ccomponents().inverse() * p.ccomponents().homogeneous())(0);
}
void project_onto_curve(const taxonomy::circle& c, const taxonomy::point3& p, double& u) {
Eigen::Vector2d xy = (c.matrix.ccomponents().inverse() * p.ccomponents().homogeneous()).head<2>();
void project_onto_curve(const taxonomy::circle::ptr& c, const taxonomy::point3& p, double& u) {
Eigen::Vector2d xy = (c->matrix->ccomponents().inverse() * p.ccomponents().homogeneous()).head<2>();
u = std::atan2(xy(1), xy(0));
}
void project_onto_curve(const taxonomy::ellipse& c, const taxonomy::point3& p, double& u) {
Eigen::Vector2d xy = (c.matrix.ccomponents().inverse() * p.ccomponents().homogeneous()).head<2>();
void project_onto_curve(const taxonomy::ellipse::ptr& c, const taxonomy::point3& p, double& u) {
Eigen::Vector2d xy = (c->matrix->ccomponents().inverse() * p.ccomponents().homogeneous()).head<2>();
u = std::atan2(xy(1), xy(0));
}
@@ -331,30 +325,30 @@ namespace {
double u;
typedef void result_type;
void operator()(const taxonomy::line& c) {
void operator()(const taxonomy::line::ptr& c) {
project_onto_curve(c, p, u);
}
void operator()(const taxonomy::circle& c) {
void operator()(const taxonomy::circle::ptr& c) {
project_onto_curve(c, p, u);
}
void operator()(const taxonomy::ellipse& c) {
void operator()(const taxonomy::ellipse::ptr& c) {
project_onto_curve(c, p, u);
}
void operator()(const taxonomy::item& c) {
void operator()(const taxonomy::item::ptr&) {
throw std::runtime_error("Point projection not implemented on this geometry type");
}
};
struct point_projection_visitor {
taxonomy::item* curve;
taxonomy::ptr curve;
double u;
typedef void result_type;
void operator()(const taxonomy::point3& p) {
point_projection_visitor_ v{ p };
void operator()(const taxonomy::point3::ptr& p) {
point_projection_visitor_ v{ *p };
dispatch_curve_creation<point_projection_visitor_>::dispatch(curve, v);
u = v.u;
}
@@ -373,7 +367,7 @@ namespace {
cgal_curve_creation_visitor() : param(unbounded) {}
cgal_curve_creation_visitor(const parameter_range& p) : param(p) {}
void operator()(const taxonomy::line& l) {
void operator()(const taxonomy::line::ptr& l) {
if (param == unbounded) {
throw std::runtime_error("Cannot represent infinite line segment");
}
@@ -413,39 +407,43 @@ namespace {
points.push_back(P);
}
void operator()(const taxonomy::circle& c) {
void operator()(const taxonomy::circle::ptr& c) {
evaluate_conic(c);
}
void operator()(const taxonomy::ellipse& e) {
void operator()(const taxonomy::ellipse::ptr& e) {
evaluate_conic(e);
}
void operator()(const taxonomy::trimmed_curve& e) {
point_projection_visitor v1{ e.basis }, v2{ e.basis };
boost::apply_visitor(v1, e.start);
boost::apply_visitor(v2, e.end);
void operator()(const taxonomy::trimmed_curve::ptr& e) {
point_projection_visitor v1{ e->basis }, v2{ e->basis };
boost::apply_visitor(v1, e->start);
boost::apply_visitor(v2, e->end);
if (!e.orientation.get_value_or(true)) {
if (!e->orientation.get_value_or(true)) {
std::swap(v1.u, v2.u);
}
cgal_curve_creation_visitor v({ v1.u, v2.u });
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(e.basis, v);
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(e->basis, v);
this->points = v.points;
if (!e.orientation.get_value_or(true)) {
if (!e->orientation.get_value_or(true)) {
std::reverse(this->points.begin(), this->points.end());
}
}
void operator()(const taxonomy::item& e) {
void operator()(const taxonomy::edge::ptr& e) {
return (*this)(taxonomy::dcast<taxonomy::trimmed_curve>(e));
}
void operator()(const taxonomy::item::ptr&) {
throw std::runtime_error("Not supported");
}
};
void convert_curve(taxonomy::item* i, std::vector<taxonomy::point3>& points) {
void convert_curve(taxonomy::ptr i, std::vector<taxonomy::point3>& points) {
cgal_curve_creation_visitor v;
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(i, v);
points = v.points;
@@ -540,11 +538,10 @@ namespace {
}
namespace {
CGAL::Polygon_2<Kernel_> loop_to_polygon_2(taxonomy::loop* loop) {
CGAL::Polygon_2<Kernel_> loop_to_polygon_2(taxonomy::loop::ptr loop) {
CGAL::Polygon_2<Kernel_> polygon;
auto edges = loop->children_as<taxonomy::edge>();
for (auto& e : edges) {
auto& p = boost::get<taxonomy::point3>(e->start);
for (auto& e : loop->children) {
auto& p = *boost::get<taxonomy::point3::ptr>(e->start);
CGAL::Point_2<Kernel_> pnt(p.ccomponents()(0), p.ccomponents()(1));
polygon.push_back(pnt);
}
@@ -637,13 +634,12 @@ namespace {
}
bool CgalKernel::convert(const taxonomy::loop* loop, cgal_wire_t& result) {
bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
// @todo only implement polygonal loops
auto edges = loop->children_as<taxonomy::edge>();
std::vector<taxonomy::point3> points;
for (auto& e : edges) {
for (auto& e : loop->children) {
std::vector<taxonomy::point3> edge;
if (e->basis) {
convert_curve(e, edge);
@@ -652,8 +648,8 @@ bool CgalKernel::convert(const taxonomy::loop* loop, cgal_wire_t& result) {
}
} else {
edge = {
boost::get<taxonomy::point3>(e->start),
boost::get<taxonomy::point3>(e->end)
*boost::get<taxonomy::point3::ptr>(e->start),
*boost::get<taxonomy::point3::ptr>(e->end)
};
}
extend_wire(points, edge);
@@ -748,7 +744,7 @@ bool CgalKernel::convert(const taxonomy::loop* loop, cgal_wire_t& result) {
}
bool CgalKernel::convert_impl(const taxonomy::shell *shell, ConversionResults& results) {
bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResults& results) {
cgal_shape_t shape;
if (!convert(shell, shape)) {
return false;
@@ -765,13 +761,13 @@ bool CgalKernel::convert_impl(const taxonomy::shell *shell, ConversionResults& r
return true;
}
bool CgalKernel::convert_impl(const taxonomy::solid *solid, ConversionResults& results) {
bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResults& results) {
cgal_shape_t shape;
if (solid->children.empty()) {
return false;
}
// @todo
if (!convert((taxonomy::shell*)solid->children[0], shape)) {
if (!convert((taxonomy::shell::ptr)solid->children[0], shape)) {
return false;
}
if (shape.size_of_facets() == 0) {
@@ -787,9 +783,7 @@ bool CgalKernel::convert_impl(const taxonomy::solid *solid, ConversionResults& r
}
namespace {
bool convert_placement(const ifcopenshell::geometry::taxonomy::matrix4& place, cgal_placement_t& trsf) {
const auto& m = place.ccomponents();
bool convert_placement(const Eigen::Matrix4d& m, cgal_placement_t& trsf) {
// @todo check
trsf = cgal_placement_t(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
@@ -798,9 +792,12 @@ namespace {
return true;
}
bool convert_placement(ifcopenshell::geometry::taxonomy::matrix4::ptr place, cgal_placement_t& trsf) {
return convert_placement(place->ccomponents(), trsf);
}
}
bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil::IfcBaseEntity * entity, const std::vector<std::pair<taxonomy::item*, ifcopenshell::geometry::taxonomy::matrix4>>& openings, const IfcGeom::ConversionResults & entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4 & entity_trsf, IfcGeom::ConversionResults & cut_shapes)
bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil::IfcBaseEntity * entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings, const IfcGeom::ConversionResults & entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4 & entity_trsf, IfcGeom::ConversionResults & cut_shapes)
{
#ifdef IFOPSH_SIMPLE_KERNEL
return false;
@@ -823,7 +820,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
cgal_shape_t entity_shape(entity_shape_unlocated);
auto gtrsf = opening_shapes[i].Placement();
// @todo check
Eigen::Matrix4d m = opening_trsf.ccomponents() * gtrsf.ccomponents();
Eigen::Matrix4d m = opening_trsf.ccomponents() * gtrsf->ccomponents();
if (!m.isIdentity()) {
cgal_placement_t trsf;
convert_placement(m, trsf);
@@ -848,7 +845,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
for (auto& shp : entity_shapes) {
auto entity_shape = ((CgalShape*)shp.Shape())->shape();
const auto& m = shp.Placement().ccomponents();
const auto& m = shp.Placement()->ccomponents();
if (!m.isIdentity()) {
cgal_placement_t trsf;
convert_placement(m, trsf);
@@ -872,7 +869,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
return false;
}
cut_shapes.push_back(IfcGeom::ConversionResult(shp.ItemId(), new CgalShape(a_poly), &shp.Style()));
cut_shapes.push_back(IfcGeom::ConversionResult(shp.ItemId(), new CgalShape(a_poly), shp.StylePtr()));
}
return true;
@@ -880,7 +877,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
}
bool CgalKernel::convert_impl(const taxonomy::extrusion* extrusion, ConversionResults& results) {
bool CgalKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ConversionResults& results) {
cgal_shape_t shape;
if (!convert(extrusion, shape)) {
return false;
@@ -894,14 +891,14 @@ bool CgalKernel::convert_impl(const taxonomy::extrusion* extrusion, ConversionRe
return true;
}
bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, const taxonomy::direction3& direction, double height, cgal_shape_t& shape) {
bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::direction3::ptr direction, double height, cgal_shape_t& shape) {
bool has_inner_bounds = !bottom_face.inner.empty();
std::list<cgal_wire_t> faces_to_extrude;
std::set<std::pair<size_t, size_t>> internal_edges;
CGAL::Cartesian_converter<CGAL::Epeck, CGAL::Simple_cartesian<double>> C;
// CGAL::Cartesian_converter<CGAL::Epeck, CGAL::Simple_cartesian<double>> C;
if (has_inner_bounds) {
CGAL::Polygon_with_holes_2<Kernel_> pwh;
@@ -966,7 +963,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, const taxonom
face_list.push_back(cgal_face_t{ w });
auto& fs = direction.ccomponents();
auto& fs = direction->ccomponents();
cgal_direction_t dir(fs(0), fs(1), fs(2));
int si = 0;
@@ -1065,7 +1062,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, const taxonom
*/
}
bool CgalKernel::convert(const taxonomy::extrusion* extrusion, cgal_shape_t &shape) {
bool CgalKernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) {
const double& height = extrusion->depth;
if (height < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", extrusion->instance);
@@ -1073,7 +1070,7 @@ bool CgalKernel::convert(const taxonomy::extrusion* extrusion, cgal_shape_t &sha
}
cgal_face_t bottom_face;
if (!convert(&extrusion->basis, bottom_face)) {
if (!convert(extrusion->basis, bottom_face)) {
return false;
}
@@ -1270,41 +1267,41 @@ bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_ref
#endif
bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result* br, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1) {
bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1) {
// @todo can also be for other boolean operations, just depth/matrix operands are different
if (br->operation != taxonomy::boolean_result::SUBTRACTION) {
return false;
}
typedef std::pair<Eigen::Matrix4d*, taxonomy::extrusion*> extrusion_pair;
typedef std::pair<Eigen::Matrix4d*, taxonomy::extrusion::ptr> extrusion_pair;
// @todo delete extrusion_pair.first
auto& ops = br->children;
std::vector<extrusion_pair> extrusions;
std::transform(ops.begin(), ops.end(), std::back_inserter(extrusions), [](taxonomy::item* op) {
static std::pair<Eigen::Matrix4d*, taxonomy::extrusion*> nptr = { nullptr, nullptr };
std::transform(ops.begin(), ops.end(), std::back_inserter(extrusions), [](taxonomy::ptr op) {
static std::pair<Eigen::Matrix4d*, taxonomy::extrusion::ptr> nptr = { nullptr, nullptr };
Eigen::Matrix4d* m4 = nullptr;
if (op->kind() == taxonomy::EXTRUSION) {
return std::make_pair(m4, (taxonomy::extrusion*) op);
if (auto ex = taxonomy::dcast<taxonomy::extrusion>(op)) {
return std::make_pair(m4, ex);
}
if (op->kind() != taxonomy::COLLECTION) return nptr;
auto cl = (taxonomy::collection*) op;
auto cl = taxonomy::dcast<taxonomy::collection>(op);
if (!cl) return nptr;
if ((cl)->children.size() != 1) return nptr;
m4 = new Eigen::Matrix4d(cl->matrix.ccomponents());
m4 = new Eigen::Matrix4d(cl->matrix->ccomponents());
if (cl->children[0]->kind() == taxonomy::COLLECTION) {
cl = (taxonomy::collection*) cl->children[0];
cl = taxonomy::cast<taxonomy::collection>(cl->children[0]);
if ((cl)->children.size() != 1) {
delete m4;
return nptr;
}
(*m4) = (*m4) * cl->matrix.ccomponents();
(*m4) = (*m4) * cl->matrix->ccomponents();
}
if (cl->children[0]->kind() != taxonomy::EXTRUSION) {
delete m4;
return nptr;
}
auto ex = (taxonomy::extrusion*) cl->children[0];
auto ex = taxonomy::cast<taxonomy::extrusion>(cl->children[0]);
return std::make_pair(m4, ex);
});
@@ -1319,7 +1316,7 @@ bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result* br, std::
if (std::find_if(extrusions.begin(), extrusions.end(), [&Z](extrusion_pair& p) {
// @todo factor in p.first;
auto ex = p.second;
auto& m = ex->matrix.ccomponents();
auto& m = ex->matrix->ccomponents();
return std::abs(1. - std::abs(m.col(2).head<3>().dot(Z))) > 1.e-5;
}) != extrusions.end()) {
return false;
@@ -1328,8 +1325,8 @@ bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result* br, std::
// | op[i].matrix[2,0:3] . op[i].direction | = 1
if (std::find_if(extrusions.begin(), extrusions.end(), [](extrusion_pair& p) {
auto ex = p.second;
auto& d = ex->direction.ccomponents();
auto& m = ex->matrix.ccomponents();
auto& d = ex->direction->ccomponents();
auto& m = ex->matrix->ccomponents();
return std::abs(1. - std::abs(m.col(2).head<3>().dot(d))) > 1.e-5;
}) != extrusions.end()) {
return false;
@@ -1344,10 +1341,10 @@ bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result* br, std::
return false;
}
const auto& op_0_matrix_2_3 = extrusions[0].second->matrix.ccomponents()(2, 3);
const auto& op_0_matrix_2_3 = extrusions[0].second->matrix->ccomponents()(2, 3);
if (std::find_if(extrusions.begin() + 1, extrusions.end(), [&op_0_matrix_2_3](extrusion_pair& p) {
auto ex = p.second;
return op_0_matrix_2_3 < ex->matrix.components()(2, 3);
return op_0_matrix_2_3 < ex->matrix->components()(2, 3);
}) != extrusions.end()) {
return false;
}
@@ -1356,8 +1353,8 @@ bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result* br, std::
try {
std::transform(extrusions.begin(), extrusions.end(), std::back_inserter(wires), [this](extrusion_pair& p) {
auto ex = p.second;
if (ex->basis.children.size() == 1 && ex->basis.children[0]->kind() == taxonomy::LOOP) {
auto l = (taxonomy::loop*) ex->basis.children[0];
if (ex->basis->children.size() == 1 && ex->basis->children[0]->kind() == taxonomy::LOOP) {
auto l = (taxonomy::loop::ptr) ex->basis->children[0];
cgal_wire_t w;
cgal_placement_t trsf;
convert_placement(ex->matrix, trsf);
@@ -1396,9 +1393,9 @@ bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result* br, std::
loops.clear();
std::transform(wires.begin(), wires.end(), std::back_inserter(loops), wire_to_polygon_2);
auto& op_0_matrix = extrusions[0].second->matrix.ccomponents();
auto& op_0_matrix = extrusions[0].second->matrix->ccomponents();
Eigen::Vector4d op_0_dir;
op_0_dir << extrusions[0].second->direction.ccomponents(), 0;
op_0_dir << extrusions[0].second->direction->ccomponents(), 0;
op_0_dir = op_0_matrix * op_0_dir;
z0 = op_0_matrix_2_3;
z1 = z0 + extrusions[0].second->depth * op_0_dir(2);
@@ -1501,7 +1498,7 @@ bool CgalKernel::process_as_2d_polygon(const std::list<std::list<std::pair<const
for (auto jt = it->begin(); jt != it->end(); ++jt) {
auto& nth_op = jt->second;
std::pair<Kernel_::FT, Kernel_::FT> operand_n_distance_along_normal;
if (!orthogonal_edge_length(first_op, fnorm, operand_n_distance_along_normal)) {
if (!orthogonal_edge_length(nth_op, fnorm, operand_n_distance_along_normal)) {
return false;
}
@@ -1525,7 +1522,7 @@ bool CgalKernel::process_as_2d_polygon(const std::list<std::list<std::pair<const
namespace {
template <typename It, typename Fn>
void project_onto_plane(const taxonomy::plane& p, It i, It j, Fn fn) {
auto mi = p.matrix.ccomponents().inverse();
auto mi = p.matrix->ccomponents().inverse();
Eigen::Vector4d v;
std::for_each(i, j, [&mi, &v, &fn](const cgal_shape_t& shp) {
for (auto& vv : vertices(shp)) {
@@ -1541,22 +1538,22 @@ namespace {
}
}
bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResults& results) {
bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, ConversionResults& results) {
double z0, z1;
std::list<CGAL::Polygon_2<Kernel_>> loops;
if (process_as_2d_polygon(br, loops, z0, z1)) {
taxonomy::style* first_item_style = nullptr;
taxonomy::style::ptr first_item_style = nullptr;
{
auto gi = dynamic_cast<const taxonomy::geom_item*>(br->children[0]);
auto gi = br->children[0];
while (gi) {
if (gi->surface_style) {
first_item_style = gi->surface_style;
break;
}
auto ci = dynamic_cast<const taxonomy::collection*>(gi);
auto ci = taxonomy::dcast<taxonomy::collection>(gi);
if (ci && ci->children.size() == 1) {
gi = dynamic_cast<const taxonomy::geom_item*>(ci->children[0]);
gi = ci->children[0];
} else {
break;
}
@@ -1614,7 +1611,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResu
);
cgal_shape_t shp;
taxonomy::direction3 d(0, 0, 1);
auto d = taxonomy::make<taxonomy::direction3>(0, 0, 1);
process_extrusion(f, d, z1 - z0, shp);
for (auto it = shp.vertices_begin(); it != shp.vertices_end(); ++it) {
@@ -1646,7 +1643,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResu
CGAL::Nef_nary_union_3<CGAL::Nef_polyhedron_3<Kernel_>> second_operand_collector;
size_t second_operand_collector_size = 0;
taxonomy::style* first_item_style = nullptr;
taxonomy::style::ptr first_item_style = nullptr;
std::list<std::pair<const IfcUtil::IfcBaseClass*, std::list<cgal_shape_t>>> operands;
@@ -1660,7 +1657,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResu
operands.back().first = c->instance->as<IfcUtil::IfcBaseClass>();
if (c->kind() == taxonomy::SOLID && c->instance->declaration().is("IfcHalfSpaceSolid") && !first) {
auto face = (taxonomy::face*) ((taxonomy::solid*) c)->children[0];
auto face = taxonomy::cast<taxonomy::solid>(c)->children[0]->children[0];
if (face->basis == nullptr || face->basis->kind() != taxonomy::PLANE) {
return false;
@@ -1671,7 +1668,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResu
double uvw_min[3] = { +inf, +inf, +inf };
double uvw_max[3] = { -inf, -inf, -inf };
auto& p = *((taxonomy::plane*)face->basis);
auto& p = *taxonomy::cast<taxonomy::plane>(face->basis);
project_onto_plane(p,
operands.front().second.begin(),
operands.front().second.end(),
@@ -1710,7 +1707,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResu
return false;
}
// static
taxonomy::direction3 z(0, 0, 1);
auto z = taxonomy::make<taxonomy::direction3>(0, 0, 1);
cgal_shape_t poly;
process_extrusion(f, z, 200, poly);
for (auto& v : vertices(poly)) {
@@ -1741,17 +1738,17 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResu
AbstractKernel::convert(c, cr);
if (first && br->operation == taxonomy::boolean_result::SUBTRACTION) {
first_item_style = ((taxonomy::geom_item*)c)->surface_style;
first_item_style = c->surface_style;
if (!first_item_style && c->kind() == taxonomy::COLLECTION) {
// @todo recursively right?
first_item_style = ((taxonomy::geom_item*) ((taxonomy::collection*)c)->children[0])->surface_style;
first_item_style = taxonomy::cast<taxonomy::collection>(c)->children[0]->surface_style;
}
}
for (auto it = cr.begin(); it != cr.end(); ++it) {
const cgal_shape_t& entity_shape_unlocated(((CgalShape*)it->Shape())->shape());
cgal_shape_t entity_shape(entity_shape_unlocated);
if (!it->Placement().is_identity()) {
if (!it->Placement()->is_identity()) {
cgal_placement_t trsf;
convert_placement(it->Placement(), trsf);
for (auto &vertex : vertices(entity_shape)) {
+12 -12
View File
@@ -91,22 +91,22 @@ namespace ifcopenshell {
void remove_duplicate_points_from_loop(cgal_wire_t& polygon);
bool convert(const taxonomy::extrusion*, cgal_shape_t&);
bool convert(const taxonomy::face*, cgal_face_t&);
bool convert(const taxonomy::loop*, cgal_wire_t&);
// bool convert(const taxonomy::matrix4*, cgal_placement_t&);
bool convert(const taxonomy::shell*, cgal_shape_t&);
bool convert(const taxonomy::extrusion::ptr, cgal_shape_t&);
bool convert(const taxonomy::face::ptr, cgal_face_t&);
bool convert(const taxonomy::loop::ptr, cgal_wire_t&);
// bool convert(const taxonomy::matrix4::ptr, cgal_placement_t&);
bool convert(const taxonomy::shell::ptr, cgal_shape_t&);
bool process_extrusion(const cgal_face_t& bottom_face, const taxonomy::direction3& direction, double height, cgal_shape_t& shape);
bool process_as_2d_polygon(const taxonomy::boolean_result* br, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
bool process_extrusion(const cgal_face_t& bottom_face, taxonomy::direction3::ptr direction, double height, cgal_shape_t& shape);
bool process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
bool process_as_2d_polygon(const std::list<std::list<std::pair<const IfcUtil::IfcBaseClass*, cgal_shape_t>>>& operands, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
virtual bool convert_impl(const taxonomy::shell*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::extrusion*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::boolean_result*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::solid*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::extrusion::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&);
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::item*, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes);
#ifndef IFOPSH_SIMPLE_KERNEL
@@ -406,7 +406,7 @@ namespace IfcGeom {
auto compound_generic = elem->geometry().as_compound();
auto compound = ((ifcopenshell::geometry::OpenCascadeShape*)compound_generic)->shape();
const auto& m = elem->transformation().data().ccomponents();
const auto& m = elem->transformation().data()->ccomponents();
gp_Trsf tr;
tr.SetValues(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
@@ -23,7 +23,7 @@ namespace {
void ifcopenshell::geometry::OpenCascadeShape::Triangulate(const IfcGeom::IteratorSettings& settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int surface_style_id) const {
// @todo remove duplication with OpenCascadeKernel::convert(const taxonomy::matrix4* matrix, gp_GTrsf& trsf);
// @todo remove duplication with OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// above can be static?
// A 3x3 matrix to rotate the vertex normals
@@ -201,7 +201,7 @@ namespace {
};
}
bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::item*, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) {
util::boolean_settings bst;
@@ -252,7 +252,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
auto gtrsf = opening_shapes[i].Placement();
// @todo check
Eigen::Matrix4d m = relative * gtrsf.ccomponents();
Eigen::Matrix4d m = relative * gtrsf->ccomponents();
gp_Trsf trsf;
trsf.SetValues(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
@@ -308,7 +308,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
} else {
entity_shape_unlocated = util::ensure_fit_for_subtraction(entity_part, entity_shape_solid, conv_settings_.getValue(ConversionSettings::GV_PRECISION));
}
const auto& m = it3->Placement().ccomponents();
const auto& m = it3->Placement()->ccomponents();
// @todo
// if (entity_shape_gtrsf.Form() == gp_Other) {
// Logger::Message(Logger::LOG_WARNING, "Applying non uniform transformation to:", entity);
@@ -383,7 +383,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
combined_result = C;
}
cut_shapes.push_back(IfcGeom::ConversionResult(it3->ItemId(), new OpenCascadeShape(combined_result), &it3->Style()));
cut_shapes.push_back(IfcGeom::ConversionResult(it3->ItemId(), new OpenCascadeShape(combined_result), it3->StylePtr()));
}
return true;
}
@@ -713,10 +713,10 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
// try {
// IfcSchema::IfcRepresentationItem::list::ptr items = representation->Items();
// if (items->size() == 1) {
// IfcSchema::IfcRepresentationItem* item = *items->begin();
// IfcSchema::IfcRepresentationptr item = *items->begin();
// if (item->declaration().is(IfcSchema::IfcMappedItem::Class())) {
// if (item->StyledByItem()->size() == 0) {
// IfcSchema::IfcMappedItem* mapped_item = item->as<IfcSchema::IfcMappedItem>();
// IfcSchema::IfcMappedptr mapped_item = item->as<IfcSchema::IfcMappedItem>();
// if (is_identity_transform(mapped_item->MappingTarget())) {
// IfcSchema::IfcRepresentationMap* map = mapped_item->MappingSource();
// if (is_identity_transform(map->MappingOrigin())) {
@@ -767,7 +767,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
// if (is_identity_transform(map->MappingOrigin())) {
// IfcSchema::IfcMappedItem::list::ptr items = map->MapUsage();
// for (IfcSchema::IfcMappedItem::list::it it = items->begin(); it != items->end(); ++it) {
// IfcSchema::IfcMappedItem* item = *it;
// IfcSchema::IfcMappedptr item = *it;
// if (item->StyledByItem()->size() != 0) continue;
//
// if (!is_identity_transform(item->MappingTarget())) {
@@ -1265,7 +1265,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
// return 0;
// }
//
// const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationItem* item) {
// const IfcSchema::IfcRepresentationptr IfcGeom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationptr item) {
// if (item->StyledByItem()->size()) {
// return item;
// }
@@ -1435,7 +1435,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
// return style_cache[surface_style_id] = surface_style_ptr_const;
// }
//
// std::shared_ptr<const IfcGeom::SurfaceStyle> IfcGeom::Kernel::get_style(const IfcSchema::IfcRepresentationItem* item) {
// std::shared_ptr<const IfcGeom::SurfaceStyle> IfcGeom::Kernel::get_style(const IfcSchema::IfcRepresentationptr item) {
// return internalize_surface_style(get_surface_style<IfcSchema::IfcSurfaceStyleShading>(item));
// }
//
@@ -81,7 +81,7 @@ private:
double eps_;
bool non_manifold_;
void loop_(const taxonomy::loop* ps, const std::function<void(int, int, bool)>& callback);
void loop_(const taxonomy::loop::ptr ps, const std::function<void(int, int, bool)>& callback);
/*
bool construct(const IfcSchema::IfcCartesianPoint* cp, gp_Pnt* l);
@@ -99,7 +99,7 @@ private:
std::vector<const void*> get_idxs(const std::vector<int>& it);
*/
public:
faceset_helper(OpenCascadeKernel* kernel, const taxonomy::shell* l);
faceset_helper(OpenCascadeKernel* kernel, const taxonomy::shell::ptr l);
~faceset_helper();
bool non_manifold() const { return non_manifold_; }
@@ -108,8 +108,8 @@ private:
bool edge(int A, int B, TopoDS_Edge& e);
bool wire(const taxonomy::loop* loop, TopoDS_Wire& wire);
bool wires(const taxonomy::loop* loop, TopTools_ListOfShape& wires);
bool wire(const taxonomy::loop::ptr loop, TopoDS_Wire& wire);
bool wires(const taxonomy::loop::ptr loop, TopTools_ListOfShape& wires);
};
faceset_helper* faceset_helper_;
@@ -130,25 +130,25 @@ public:
, precision_(settings.getValue(ConversionSettings::GV_PRECISION))
{}
bool convert(const taxonomy::extrusion*, TopoDS_Shape&);
bool convert(const taxonomy::face*, TopoDS_Shape&);
bool convert(const taxonomy::loop*, TopoDS_Wire&);
bool convert(const taxonomy::matrix4*, gp_GTrsf&);
bool convert(const taxonomy::shell*, TopoDS_Shape&);
bool convert(const taxonomy::solid*, TopoDS_Shape&);
bool convert(const taxonomy::bspline_surface* bs, Handle(Geom_Surface) surf);
bool convert(const taxonomy::extrusion::ptr, TopoDS_Shape&);
bool convert(const taxonomy::face::ptr, TopoDS_Shape&);
bool convert(const taxonomy::loop::ptr, TopoDS_Wire&);
bool convert(const taxonomy::matrix4::ptr, gp_GTrsf&);
bool convert(const taxonomy::shell::ptr, TopoDS_Shape&);
bool convert(const taxonomy::solid::ptr, TopoDS_Shape&);
bool convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf);
TopoDS_Shape apply_transformation(const TopoDS_Shape& s, const taxonomy::matrix4& t);
TopoDS_Shape apply_transformation(const TopoDS_Shape& s, const gp_GTrsf& t);
TopoDS_Shape apply_transformation(const TopoDS_Shape& s, const gp_Trsf& t);
virtual bool convert_impl(const taxonomy::face*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::solid*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::shell*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::extrusion*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::boolean_result*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::face::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::extrusion::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&);
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::item*, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes);
template <typename T, typename U>
@@ -761,7 +761,7 @@ bool IfcGeom::util::flatten_shape_list(const IfcGeom::ConversionResults& shapes,
}
// @todo refactor, also should be GTrsf
const auto& m = it->Placement().ccomponents();
const auto& m = it->Placement()->ccomponents();
gp_Trsf trsf;
trsf.SetValues(
m(0, 0), m(0, 1), m(0, 2), m(0, 3),
@@ -43,7 +43,7 @@ namespace {
}
}
bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result* br, ConversionResults& results) {
bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, ConversionResults& results) {
bool valid_result = false;
bool first = true;
const double tol = conv_settings_.getValue(ConversionSettings::GV_PRECISION);
@@ -51,7 +51,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result* br, Convers
TopoDS_Shape a;
TopTools_ListOfShape b;
taxonomy::style* first_item_style = nullptr;
taxonomy::style::ptr first_item_style;
for (auto& c : br->children) {
IfcGeom::ConversionResults cr;
@@ -59,10 +59,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result* br, Convers
if (first && br->operation == taxonomy::boolean_result::SUBTRACTION) {
// @todo A will be null on union/intersection, intended?
IfcGeom::util::flatten_shape_list(cr, a, false, conv_settings_.getValue(ifcopenshell::geometry::ConversionSettings::GV_PRECISION));
first_item_style = ((taxonomy::geom_item*)c)->surface_style;
first_item_style = c->surface_style;
if (!first_item_style && c->kind() == taxonomy::COLLECTION) {
// @todo recursively right?
first_item_style = ((taxonomy::geom_item*) ((taxonomy::collection*)c)->children[0])->surface_style;
first_item_style = taxonomy::cast<taxonomy::geom_item>(taxonomy::cast<taxonomy::collection>(c)->children[0])->surface_style;
}
if (conv_settings_.getValue(ConversionSettings::GV_DISABLE_BOOLEAN_RESULT) > 0.0) {
@@ -84,7 +84,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result* br, Convers
for (auto& r : cr) {
auto S = ((OpenCascadeShape*)r.Shape())->shape();
gp_GTrsf trsf;
convert(&r.Placement(), trsf);
convert(r.Placement(), trsf);
// @todo it really confuses me why I cannot use Moved() here instead
S.Location(S.Location() * trsf.Trsf());
@@ -6,7 +6,7 @@ using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
bool OpenCascadeKernel::convert(const taxonomy::bspline_surface* bs, Handle(Geom_Surface) surf) {
bool OpenCascadeKernel::convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf) {
const bool is_rational = !!bs->weights;
TColgp_Array2OfPnt Poles(0, (int)bs->control_points.size() - 1, 0, (int)(*bs->control_points.begin()).size() - 1);
@@ -22,7 +22,7 @@ bool OpenCascadeKernel::convert(const taxonomy::bspline_surface* bs, Handle(Geom
for (auto it = bs->control_points.begin(); it != bs->control_points.end(); ++it, ++i) {
j = 0;
for (auto jt = (*it).begin(); jt != (*it).end(); ++jt, ++j) {
Poles(i, j) = convert_xyz<gp_Pnt>(*jt);
Poles(i, j) = convert_xyz<gp_Pnt>(**jt);
}
}
@@ -6,7 +6,7 @@ using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
bool OpenCascadeKernel::convert(const taxonomy::extrusion* extrusion, TopoDS_Shape& shape) {
bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS_Shape& shape) {
const double& height = extrusion->depth;
if (height < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
@@ -15,7 +15,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion* extrusion, TopoDS_Sha
}
TopoDS_Shape face;
if (!convert(&extrusion->basis, face)) {
if (!convert(extrusion->basis, face)) {
return false;
}
@@ -29,7 +29,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion* extrusion, TopoDS_Sha
auto trsf = gtrsf.Trsf();
*/
const auto& fs = extrusion->direction.ccomponents();
const auto& fs = extrusion->direction->ccomponents();
gp_Dir dir(fs(0), fs(1), fs(2));
shape.Nullify();
@@ -71,7 +71,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion* extrusion, TopoDS_Sha
return !shape.IsNull();
}
bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion* extrusion, IfcGeom::ConversionResults& results) {
bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, IfcGeom::ConversionResults& results) {
TopoDS_Shape shape;
if (!convert(extrusion, shape)) {
return false;
+6 -8
View File
@@ -47,9 +47,7 @@ using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
bool OpenCascadeKernel::convert(const taxonomy::face* face, TopoDS_Shape& result) {
auto bounds = face->children_as<taxonomy::loop>();
bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& result) {
face_definition fd;
const bool is_face_surface = false; /* todo */
@@ -71,10 +69,10 @@ bool OpenCascadeKernel::convert(const taxonomy::face* face, TopoDS_Shape& result
}
*/
const int num_bounds = bounds.size();
const int num_bounds = face->children.size();
int num_outer_bounds = 0;
for (auto& bound : bounds) {
for (auto& bound : face->children) {
if (bound->external.get_value_or(false)) {
num_outer_bounds++;
}
@@ -97,7 +95,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face* face, TopoDS_Shape& result
TopTools_DataMapOfShapeInteger wire_senses;
for (int process_interior = 0; process_interior <= 1; ++process_interior) {
for (auto& bound : bounds) {
for (auto& bound : face->children) {
bool same_sense = true; /* todo bound->Orientation(); */
const bool is_interior =
@@ -302,7 +300,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face* face, TopoDS_Shape& result
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::face* face, IfcGeom::ConversionResults& results) {
bool OpenCascadeKernel::convert_impl(const taxonomy::face::ptr face, IfcGeom::ConversionResults& results) {
throw std::runtime_error("Root-level face not expected");
/*
@@ -320,7 +318,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::face* face, IfcGeom::Conver
}
// @todo boundary
const auto& m = ((taxonomy::geom_item*)face->basis)->matrix.ccomponents();
const auto& m = ((taxonomy::geom_ptr)face->basis)->matrix.ccomponents();
gp_Pln pln(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(2)));
const gp_Pnt pnt = pln.Location().Translated(face->orientation.get_value_or(false) ? -pln.Axis().Direction() : pln.Axis().Direction());
TopoDS_Shape shape = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln), pnt).Solid();
@@ -27,21 +27,21 @@ namespace {
IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
OpenCascadeKernel* kernel,
const taxonomy::shell* shell
const taxonomy::shell::ptr shell
)
: kernel_(kernel)
, non_manifold_(false)
{
// @todo use pointers?
std::vector<taxonomy::point3> points;
std::vector<taxonomy::loop*> loops;
std::vector<taxonomy::point3::ptr> points;
std::vector<taxonomy::loop::ptr> loops;
for (auto& f : shell->children_as<taxonomy::face>()) {
for (auto& l : f->children_as<taxonomy::loop>()) {
for (auto& f : shell->children) {
for (auto& l : f->children) {
loops.push_back(l);
for (auto& e : l->children_as<taxonomy::edge>()) {
for (auto& e : l->children) {
// @todo make sure only cartesian points are provided here
points.push_back(boost::get<taxonomy::point3>(e->start));
points.push_back(boost::get<taxonomy::point3::ptr>(e->start));
}
}
}
@@ -55,7 +55,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
Bnd_Box box;
for (size_t i = 0; i < points.size(); ++i) {
gp_Pnt* p = new gp_Pnt(convert_xyz<gp_Pnt>(points[i]));
gp_Pnt* p = new gp_Pnt(convert_xyz<gp_Pnt>(*points[i]));
pnts[i].reset(p);
B.MakeVertex(vertices[i], *p, Precision::Confusion());
tree.add(i, vertices[i]);
@@ -116,7 +116,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
find_neighbours(tree, pnts, vs, pnt_i, eps_);
for (int v : vs) {
auto& pt = points[v];
auto& pt = *points[v];
// NB: insert() ignores duplicate keys
// v-1?
// @todo this reliable also in case of tesselations?
@@ -192,15 +192,15 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
}
}
void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const taxonomy::loop* ps, const std::function<void(int, int, bool)>& callback) {
void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const taxonomy::loop::ptr ps, const std::function<void(int, int, bool)>& callback) {
if (ps->children.size() < 3) {
return;
}
auto a = boost::get<taxonomy::point3>(((taxonomy::edge*) ps->children.back())->start);
auto A = a.identity();
auto a = boost::get<taxonomy::point3::ptr>(ps->children.back()->start);
auto A = a->identity();
for (auto& b : ps->children) {
auto B = boost::get<taxonomy::point3>(((taxonomy::edge*) b)->start).identity();
auto B = boost::get<taxonomy::point3::ptr>(b->start)->identity();
auto C = vertex_mapping_[A], D = vertex_mapping_[B];
bool fwd = C < D;
if (!fwd) {
@@ -222,7 +222,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::edge(int A, int B, TopoDS_Edge&
return true;
}
bool IfcGeom::OpenCascadeKernel::faceset_helper::wire(const taxonomy::loop* loop, TopoDS_Wire& w) {
bool IfcGeom::OpenCascadeKernel::faceset_helper::wire(const taxonomy::loop::ptr loop, TopoDS_Wire& w) {
TopTools_ListOfShape ws;
if (!wires(loop, ws)) {
return false;
@@ -231,7 +231,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wire(const taxonomy::loop* loop
return true;
}
bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const taxonomy::loop* loop, TopTools_ListOfShape& wires) {
bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const taxonomy::loop::ptr loop, TopTools_ListOfShape& wires) {
if (duplicates_.find(loop->identity()) != duplicates_.end()) {
return false;
}
+8 -8
View File
@@ -164,7 +164,7 @@ namespace {
}
bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const std::vector< std::vector<Handle_Geom_Surface> >& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style>& styles, ConversionResults& result, double tol) {
bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const std::vector< std::vector<Handle_Geom_Surface> >& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles, ConversionResults& result, double tol) {
Bnd_Box bb;
TopoDS_Shape input;
flatten_shape_list(items, input, false, tol);
@@ -249,8 +249,8 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
if (split_solid_by_shell(((OpenCascadeShape*)it->Shape())->shape(), shells.First(), a, b, tol)) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(b), &(!!styles[0].diffuse ? styles[0] : it->Style())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(a), &(!!styles[1].diffuse ? styles[1] : it->Style())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
} else {
continue;
}
@@ -269,7 +269,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
std::vector<TopoDS_Shape> slices;
if (split(s, shells, tol, slices) && slices.size() == styles.size()) {
for (size_t i = 0; i < slices.size(); ++i) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), &(!!styles[i].diffuse ? styles[i] : it->Style())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
}
} else {
return false;
@@ -282,7 +282,7 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
}
bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector<Handle_Geom_Surface>& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style>& styles, ConversionResults& result, double tol) {
bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector<Handle_Geom_Surface>& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles, ConversionResults& result, double tol) {
if (surfaces.size() < 3) {
return false;
@@ -292,8 +292,8 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
if (split_solid_by_surface(((OpenCascadeShape*)it->Shape())->shape(), surfaces[1], a, b, tol)) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(b), &(!!styles[0].diffuse ? styles[0] : it->Style())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(a), &(!!styles[1].diffuse ? styles[1] : it->Style())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
} else {
continue;
}
@@ -360,7 +360,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
std::vector<TopoDS_Shape> slices;
if (split(s, operands, tol, slices) && slices.size() == styles.size()) {
for (size_t i = 0; i < slices.size(); ++i) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), &(!!styles[i].diffuse ? styles[i] : it->Style())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
}
} else {
return false;
+2 -2
View File
@@ -11,9 +11,9 @@
namespace IfcGeom {
namespace util {
bool apply_layerset(const ConversionResults&, const std::vector<Handle_Geom_Surface>&, const std::vector<ifcopenshell::geometry::taxonomy::style>&, ConversionResults&, double tol);
bool apply_layerset(const ConversionResults&, const std::vector<Handle_Geom_Surface>&, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>&, ConversionResults&, double tol);
bool apply_folded_layerset(const ConversionResults&, const std::vector< std::vector<Handle_Geom_Surface> >&, const std::vector<ifcopenshell::geometry::taxonomy::style>&, ConversionResults&, double tol);
bool apply_folded_layerset(const ConversionResults&, const std::vector< std::vector<Handle_Geom_Surface> >&, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>&, ConversionResults&, double tol);
bool split_solid_by_surface(const TopoDS_Shape&, const Handle_Geom_Surface&, TopoDS_Shape&, TopoDS_Shape&, double tol);
+42 -44
View File
@@ -26,21 +26,21 @@ using namespace IfcGeom::util;
namespace {
typedef boost::variant<Handle(Geom_Curve), TopoDS_Wire> curve_creation_visitor_result_type;
curve_creation_visitor_result_type convert_curve(OpenCascadeKernel* kernel, const taxonomy::item* curve);
curve_creation_visitor_result_type convert_curve(OpenCascadeKernel* kernel, const taxonomy::ptr curve);
struct curve_creation_visitor {
OpenCascadeKernel* kernel;
curve_creation_visitor_result_type result;
curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve& bc) {
curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve::ptr& bc) {
const bool is_rational = !!bc.weights;
const bool is_rational = !!bc->weights;
TColgp_Array1OfPnt Poles(0, bc.control_points.size() - 1);
TColStd_Array1OfReal Weights(0, bc.control_points.size() - 1);
TColStd_Array1OfReal Knots(0, (int)bc.knots.size() - 1);
TColStd_Array1OfInteger Mults(0, (int)bc.knots.size() - 1);
Standard_Integer Degree = bc.degree;
TColgp_Array1OfPnt Poles(0, bc->control_points.size() - 1);
TColStd_Array1OfReal Weights(0, bc->control_points.size() - 1);
TColStd_Array1OfReal Knots(0, (int)bc->knots.size() - 1);
TColStd_Array1OfInteger Mults(0, (int)bc->knots.size() - 1);
Standard_Integer Degree = bc->degree;
Standard_Boolean Periodic = false;
// @tfk: it appears to be wrong to expect a period curve when the curve is closed, see #586
// Standard_Boolean Periodic = l->ClosedCurve();
@@ -49,23 +49,23 @@ namespace {
if (is_rational) {
i = 0;
for (auto it = bc.weights->begin(); it != bc.weights->end(); ++it, ++i) {
for (auto it = bc->weights->begin(); it != bc->weights->end(); ++it, ++i) {
Weights(i) = *it;
}
}
i = 0;
for (auto it = bc.control_points.begin(); it != bc.control_points.end(); ++it, ++i) {
Poles(i) = OpenCascadeKernel::convert_xyz<gp_Pnt>(*it);
for (auto it = bc->control_points.begin(); it != bc->control_points.end(); ++it, ++i) {
Poles(i) = OpenCascadeKernel::convert_xyz<gp_Pnt>(**it);
}
i = 0;
for (auto it = bc.multiplicities.begin(); it != bc.multiplicities.end(); ++it, ++i) {
for (auto it = bc->multiplicities.begin(); it != bc->multiplicities.end(); ++it, ++i) {
Mults(i) = *it;
}
i = 0;
for (auto it = bc.knots.begin(); it != bc.knots.end(); ++it, ++i) {
for (auto it = bc->knots.begin(); it != bc->knots.end(); ++it, ++i) {
Knots(i) = *it;
}
@@ -76,44 +76,44 @@ namespace {
}
}
curve_creation_visitor_result_type operator()(const taxonomy::line& l) {
const auto& m = l.matrix.ccomponents();
curve_creation_visitor_result_type operator()(const taxonomy::line::ptr& l) {
const auto& m = l->matrix->ccomponents();
return result = Handle(Geom_Curve)(new Geom_Line(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))));
}
curve_creation_visitor_result_type operator()(const taxonomy::circle& c) {
const auto& m = c.matrix.ccomponents();
return result = Handle(Geom_Curve)(new Geom_Circle(gp_Ax2(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))), c.radius));
curve_creation_visitor_result_type operator()(const taxonomy::circle::ptr& c) {
const auto& m = c->matrix->ccomponents();
return result = Handle(Geom_Curve)(new Geom_Circle(gp_Ax2(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))), c->radius));
}
curve_creation_visitor_result_type operator()(const taxonomy::ellipse& e) {
const auto& m = e.matrix.ccomponents();
return result = Handle(Geom_Curve)(new Geom_Ellipse(gp_Ax2(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))), e.radius, e.radius2));
curve_creation_visitor_result_type operator()(const taxonomy::ellipse::ptr& e) {
const auto& m = e->matrix->ccomponents();
return result = Handle(Geom_Curve)(new Geom_Ellipse(gp_Ax2(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))), e->radius, e->radius2));
}
curve_creation_visitor_result_type operator()(const taxonomy::loop& l) {
curve_creation_visitor_result_type operator()(const taxonomy::loop::ptr& l) {
TopoDS_Wire wire;
kernel->convert(&l, wire);
kernel->convert(l, wire);
return result = wire;
}
curve_creation_visitor_result_type operator()(const taxonomy::edge& e) {
curve_creation_visitor_result_type operator()(const taxonomy::edge::ptr& e) {
// @todo for polyloops/-lines we should probably construct edges based on correct oriented TopoDS_Vertex instead.
if (e.start.which() != e.end.which()) {
if (e->start.which() != e->end.which()) {
throw std::runtime_error("Different trim types not supported");
}
TopoDS_Edge E;
if (e.basis) {
auto crv_or_wire = convert_curve(kernel, e.basis);
if (e->basis) {
auto crv_or_wire = convert_curve(kernel, e->basis);
Handle(Geom_Curve) curve;
if (crv_or_wire.which() == 0) {
curve = boost::get<Handle(Geom_Curve)>(crv_or_wire);
} else {
// @todo
const double precision_ = 1.e-5;
Logger::Warning("Approximating BasisCurve due to possible discontinuities", e.instance);
Logger::Warning("Approximating BasisCurve due to possible discontinuities", e->instance);
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
#if OCC_VERSION_HEX < 0x70600
BRepAdaptor_CompCurve cc(w, true);
@@ -126,13 +126,13 @@ namespace {
curve = approx.Curve();
}
const bool reversed = !((taxonomy::geom_item*)e.basis)->orientation.get_value_or(true);
const bool is_conic = e.basis->kind() == taxonomy::ELLIPSE || e.basis->kind() == taxonomy::CIRCLE;
const bool reversed = !taxonomy::cast<taxonomy::geom_item>(e->basis)->orientation.get_value_or(true);
const bool is_conic = e->basis->kind() == taxonomy::ELLIPSE || e->basis->kind() == taxonomy::CIRCLE;
// @todo, copy over logic from previous IfcTrimmedCurve handling
if (e.start.which() == 0) {
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(boost::get<taxonomy::point3>(e.start));
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(boost::get<taxonomy::point3>(e.end));
if (e->start.which() == 0) {
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->start));
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->end));
if (reversed) {
std::swap(p1, p2);
@@ -140,8 +140,8 @@ namespace {
E = BRepBuilderAPI_MakeEdge(curve, p1, p2).Edge();
} else {
auto v1 = boost::get<double>(e.start);
auto v2 = boost::get<double>(e.end);
auto v1 = boost::get<double>(e->start);
auto v2 = boost::get<double>(e->end);
if (reversed) {
std::swap(v1, v2);
@@ -158,11 +158,11 @@ namespace {
E.Reverse();
}
} else {
if (e.start.which() != 0) {
if (e->start.which() != 0) {
throw std::runtime_error("Non-cartesian trim on edge without curve");
}
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(boost::get<taxonomy::point3>(e.start));
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(boost::get<taxonomy::point3>(e.end));
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->start));
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->end));
E = BRepBuilderAPI_MakeEdge(p1, p2).Edge();
}
@@ -173,13 +173,13 @@ namespace {
return result = W;
}
curve_creation_visitor_result_type operator()(const taxonomy::offset_curve& l) {
curve_creation_visitor_result_type operator()(const taxonomy::offset_curve::ptr&) {
// @todo
throw std::runtime_error("Offset curves not supported as part of loop");
}
};
curve_creation_visitor_result_type convert_curve(OpenCascadeKernel* kernel, const taxonomy::item* curve) {
curve_creation_visitor_result_type convert_curve(OpenCascadeKernel* kernel, const taxonomy::ptr curve) {
curve_creation_visitor v{ kernel };
if (dispatch_curve_creation<curve_creation_visitor, 0>::dispatch(curve, v)) {
return v.result;
@@ -189,12 +189,10 @@ namespace {
}
}
bool OpenCascadeKernel::convert(const taxonomy::loop* loop, TopoDS_Wire& wire) {
auto segments = loop->children_as<taxonomy::edge>();
bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wire) {
TopTools_ListOfShape converted_segments;
for (auto& segment : segments) {
for (auto& segment : loop->children) {
auto segment_wire = boost::get<TopoDS_Wire>(convert_curve(this, segment));
#ifdef IFOPSH_DEBUG
+1 -1
View File
@@ -5,7 +5,7 @@ using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
bool OpenCascadeKernel::convert(const taxonomy::matrix4* matrix, gp_GTrsf& trsf) {
bool OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf) {
// @todo check
const auto& m = matrix->ccomponents();
gp_Mat mat(
+3 -4
View File
@@ -7,13 +7,12 @@ using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
bool OpenCascadeKernel::convert(const taxonomy::shell* l, TopoDS_Shape& shape) {
bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shape) {
std::unique_ptr<faceset_helper> helper_scope;
helper_scope.reset(new faceset_helper(this, l));
faceset_helper_ = helper_scope.get();
auto faces = l->children_as<taxonomy::face>();
double minimal_face_area = precision_ * precision_ * 0.5;
double min_face_area = faceset_helper_
@@ -21,7 +20,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell* l, TopoDS_Shape& shape) {
: minimal_face_area;
TopTools_ListOfShape face_list;
for (auto& face : faces) {
for (auto& face : l->children) {
bool success = false;
TopoDS_Face occ_face;
@@ -88,7 +87,7 @@ bool OpenCascadeKernel::convert(const taxonomy::shell* l, TopoDS_Shape& shape) {
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::shell *shell, IfcGeom::ConversionResults& results) {
bool OpenCascadeKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::ConversionResults& results) {
TopoDS_Shape shape;
if (!convert(shell, shape)) {
return false;
+41 -43
View File
@@ -29,59 +29,57 @@ using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
bool OpenCascadeKernel::convert(const taxonomy::solid* solid, TopoDS_Shape& result) {
bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) {
BRep_Builder BB;
TopoDS_Solid S;
for (auto& s : solid->children) {
if (s->kind() == taxonomy::FACE) {
// halfspace
if (solid->children.size() != 1) {
throw std::runtime_error("Unexpected number of children on solid");
}
auto face = (taxonomy::face*) s;
const auto& m = ((taxonomy::geom_item*)face->basis)->matrix.ccomponents();
gp_Pln pln(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(2)));
const gp_Pnt pnt = pln.Location().Translated(face->orientation.get_value_or(false) ? pln.Axis().Direction() : -pln.Axis().Direction());
TopoDS_Shape halfspace = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln), pnt).Solid();
if (!face->children.empty()) {
TopoDS_Wire wire;
gp_GTrsf gtrsf;
if (convert((taxonomy::loop*)face->children[0], wire) && wire.Closed() && convert(&face->matrix, gtrsf)) {
gp_Trsf trsf = gtrsf.Trsf();
TopoDS_Shape prism = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(wire), gp_Vec(0, 0, 200));
gp_Trsf down; down.SetTranslation(gp_Vec(0, 0, -100.0));
// `trsf` and `down` both have a unit scale factor
prism.Move(trsf*down);
halfspace = BRepAlgoAPI_Common(halfspace, prism);
}
}
result = halfspace;
return true;
} else {
if (s->kind() != taxonomy::SHELL) {
throw std::runtime_error("Unexpected child in solid");
}
if (S.IsNull()) {
BB.MakeSolid(S);
}
TopoDS_Shell shl;
convert(((taxonomy::shell*)s), shl);
BB.Add(S, shl);
if (solid->instance->declaration().is("IfcHalfSpaceSolid")) {
// halfspace
if (solid->children.size() != 1) {
throw std::runtime_error("Unexpected number of children on solid");
}
auto face = solid->children[0]->children[0];
const auto& m = taxonomy::cast<taxonomy::plane>(face->basis)->matrix->ccomponents();
gp_Pln pln(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(2)));
const gp_Pnt pnt = pln.Location().Translated(face->orientation.get_value_or(false) ? pln.Axis().Direction() : -pln.Axis().Direction());
TopoDS_Shape halfspace = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln), pnt).Solid();
if (!face->children.empty()) {
TopoDS_Wire wire;
gp_GTrsf gtrsf;
if (convert((taxonomy::loop::ptr)face->children[0], wire) && wire.Closed() && convert(face->matrix, gtrsf)) {
gp_Trsf trsf = gtrsf.Trsf();
TopoDS_Shape prism = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(wire), gp_Vec(0, 0, 200));
gp_Trsf down; down.SetTranslation(gp_Vec(0, 0, -100.0));
// `trsf` and `down` both have a unit scale factor
prism.Move(trsf*down);
halfspace = BRepAlgoAPI_Common(halfspace, prism);
}
}
result = halfspace;
return true;
}
for (auto& s : solid->children) {
if (S.IsNull()) {
BB.MakeSolid(S);
}
TopoDS_Shell shl;
convert(((taxonomy::shell::ptr)s), shl);
BB.Add(S, shl);
}
if (!S.IsNull()) {
result = S;
}
}
bool OpenCascadeKernel::convert_impl(const taxonomy::solid* solid , IfcGeom::ConversionResults& results) {
bool OpenCascadeKernel::convert_impl(const taxonomy::solid::ptr solid , IfcGeom::ConversionResults& results) {
TopoDS_Shape shape;
if (!convert(solid, shape)) {
return false;
@@ -23,19 +23,19 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAnnotationFillArea* inst) {
auto loop = map(inst->OuterBoundary());
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAnnotationFillArea* inst) {
auto loop = taxonomy::cast<taxonomy::loop>(map(inst->OuterBoundary()));
if (loop) {
auto face = new taxonomy::face;
((taxonomy::loop*)loop)->external = true;
auto face = taxonomy::make<taxonomy::face>();
loop->external = true;
face->children = { loop };
if (inst->InnerBoundaries()) {
IfcSchema::IfcCurve::list::ptr inner_boundaries = *inst->InnerBoundaries();
for (auto& v : *inner_boundaries) {
auto inner_loop = map(v);
auto inner_loop = taxonomy::cast<taxonomy::loop>(map(v));
if (inner_loop) {
((taxonomy::loop*)inner_loop)->external = false;
inner_loop->external = false;
face->children.push_back(inner_loop);
}
}
@@ -23,20 +23,20 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcArbitraryClosedProfileDef* inst) {
auto loop = map(inst->OuterCurve());
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcArbitraryClosedProfileDef* inst) {
auto loop = taxonomy::cast<taxonomy::loop>(map(inst->OuterCurve()));
if (loop) {
auto face = new taxonomy::face;
((taxonomy::loop*)loop)->external = true;
auto face = taxonomy::make<taxonomy::face>();
loop->external = true;
face->children = { loop };
if (inst->as<IfcSchema::IfcArbitraryProfileDefWithVoids>()) {
auto with_voids = inst->as<IfcSchema::IfcArbitraryProfileDefWithVoids>();
auto voids = with_voids->InnerCurves();
for (auto& v : *voids) {
auto inner_loop = map(v);
auto inner_loop = taxonomy::cast<taxonomy::loop>(map(v));
if (inner_loop) {
((taxonomy::loop*)inner_loop)->external = false;
inner_loop->external = false;
face->children.push_back(inner_loop);
}
}
@@ -23,6 +23,6 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcArbitraryOpenProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcArbitraryOpenProfileDef* inst) {
return map(inst->Curve());
}
+6 -6
View File
@@ -22,16 +22,16 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
Eigen::Vector3d P, axis(0, 0, 1), ref;
{
taxonomy::point3 v = as<taxonomy::point3>(map(inst->Location()));
P = *v.components_;
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
P = *v->components_;
}
const bool hasAxis = inst->Axis();
if (hasAxis) {
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->Axis()));
axis = *v.components_;
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->Axis()));
axis = *v->components_;
}
// @todo not sure what to do with ref, we're probably never reading it,
@@ -43,5 +43,5 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis1Placement* inst) {
ref = Eigen::Vector3d(1, 0, 0).cross(axis).normalized();
}
return new taxonomy::matrix4(P, axis, ref);
return taxonomy::make<taxonomy::matrix4>(P, axis, ref);
}
+6 -6
View File
@@ -23,16 +23,16 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement2D* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement2D* inst) {
Eigen::Vector3d P, axis(0, 0, 1), V(1, 0, 0);
{
taxonomy::point3 v = as<taxonomy::point3>(map(inst->Location()));
P = *v.components_;
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
P = *v->components_;
}
const bool hasRef = !!inst->RefDirection();
if (hasRef) {
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->RefDirection()));
V = *v.components_;
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->RefDirection()));
V = *v->components_;
}
return new taxonomy::matrix4(P, axis, V);
return taxonomy::make<taxonomy::matrix4>(P, axis, V);
}
+8 -8
View File
@@ -23,11 +23,11 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
Eigen::Vector3d o, axis(0, 0, 1), refDirection, X(1, 0, 0);
{
taxonomy::point3 v = as<taxonomy::point3>(map(inst->Location()));
o = *v.components_;
taxonomy::point3::ptr v = taxonomy::cast<taxonomy::point3>(map(inst->Location()));
o = *v->components_;
}
const bool hasAxis = !!inst->Axis();
const bool hasRef = !!inst->RefDirection();
@@ -37,13 +37,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
}
if (hasAxis) {
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->Axis()));
axis = *v.components_;
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->Axis()));
axis = *v->components_;
}
if (hasRef) {
taxonomy::direction3 v = as<taxonomy::direction3>(map(inst->RefDirection()));
refDirection = *v.components_;
taxonomy::direction3::ptr v = taxonomy::cast<taxonomy::direction3>(map(inst->RefDirection()));
refDirection = *v->components_;
} else {
if (acos(axis.dot(X)) > 1.e-5) {
refDirection = { 1., 0., 0. };
@@ -54,5 +54,5 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcAxis2Placement3D* inst) {
auto Xaxis = refDirection - Xvec;
refDirection = Xaxis;
}
return new taxonomy::matrix4(o, axis, refDirection);
return taxonomy::make<taxonomy::matrix4>(o, axis, refDirection);
}
@@ -25,12 +25,12 @@
using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBSplineCurveWithKnots* inst) {
auto bc = new taxonomy::bspline_curve;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineCurveWithKnots* inst) {
auto bc = taxonomy::make<taxonomy::bspline_curve>();
const IfcSchema::IfcCartesianPoint::list::ptr cps = inst->ControlPointsList();
std::vector<taxonomy::point3> points;
std::transform(cps->begin(), cps->end(), std::back_inserter(points), [this](IfcSchema::IfcCartesianPoint* cp) { return as<taxonomy::point3>(map(cp)); });
std::vector<taxonomy::point3::ptr> points;
std::transform(cps->begin(), cps->end(), std::back_inserter(points), [this](IfcSchema::IfcCartesianPoint* cp) { return taxonomy::cast<taxonomy::point3>(map(cp)); });
bc->control_points = points;
bc->multiplicities = inst->KnotMultiplicities();
@@ -25,13 +25,13 @@ using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBSplineSurfaceWithKnots* inst) {
auto bs = new taxonomy::bspline_surface;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineSurfaceWithKnots* inst) {
auto bs = taxonomy::make<taxonomy::bspline_surface>();
auto cps = inst->ControlPointsList();
std::transform(cps->begin(), cps->end(), std::back_inserter(bs->control_points), [this](const std::vector<IfcSchema::IfcCartesianPoint*>& inner) {
std::vector<taxonomy::point3> ps;
std::transform(inner.begin(), inner.end(), std::back_inserter(ps), [this](IfcSchema::IfcCartesianPoint* cp) { return as<taxonomy::point3>(map(cp)); });
std::vector<taxonomy::point3::ptr> ps;
std::transform(inner.begin(), inner.end(), std::back_inserter(ps), [this](IfcSchema::IfcCartesianPoint* cp) { return taxonomy::cast<taxonomy::point3>(map(cp)); });
return ps;
});
+2 -2
View File
@@ -22,13 +22,13 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBlock* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBlock* inst) {
const double dx = inst->XLength() * length_unit_;
const double dy = inst->YLength() * length_unit_;
const double dz = inst->ZLength() * length_unit_;
auto solid = create_box(dx, dy, dz);
solid->matrix = as<taxonomy::matrix4>(map(inst->Position()));
solid->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
return solid;
}
+1 -1
View File
@@ -37,7 +37,7 @@ namespace {
}
}
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBooleanResult* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBooleanResult* inst) {
IfcSchema::IfcBooleanOperand* operand1 = inst->FirstOperand();
IfcSchema::IfcBooleanOperand* operand2 = inst->SecondOperand();
bool has_halfspace_operand = false;
+3 -3
View File
@@ -22,13 +22,13 @@
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcBoundingBox* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBoundingBox* inst) {
const double dx = inst->XDim() * length_unit_;
const double dy = inst->YDim() * length_unit_;
const double dz = inst->ZDim() * length_unit_;
taxonomy::point3 corner = as<taxonomy::point3>(map(inst->Corner()));
auto solid = create_box(corner.ccomponents().x(), corner.ccomponents().y(), corner.ccomponents().z(), dx, dy, dz);
taxonomy::point3::ptr corner = taxonomy::cast<taxonomy::point3>(map(inst->Corner()));
auto solid = create_box(corner->ccomponents().x(), corner->ccomponents().y(), corner->ccomponents().z(), dx, dy, dz);
return solid;
}
+3 -3
View File
@@ -27,7 +27,7 @@ using namespace ifcopenshell::geometry;
#include <vector>
#include <boost/optional/optional.hpp>
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
const double y = inst->Depth() / 2.0f * length_unit_;
const double x = inst->Width() / 2.0f * length_unit_;
const double d1 = inst->WallThickness() * length_unit_;
@@ -47,13 +47,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) {
return nullptr;
}
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+2 -2
View File
@@ -21,9 +21,9 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCartesianPoint* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianPoint* inst) {
std::vector<double> xyz = inst->Coordinates();
return new taxonomy::point3(
return taxonomy::make<taxonomy::point3>(
xyz.size() >= 1 ? xyz[0] * length_unit_ : 0.,
xyz.size() >= 2 ? xyz[1] * length_unit_ : 0.,
xyz.size() >= 3 ? xyz[2] * length_unit_ : 0.
@@ -21,21 +21,21 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator2D* inst) {
auto m = new taxonomy::matrix4;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator2D* inst) {
auto m = taxonomy::make<taxonomy::matrix4>();
Eigen::Vector4d origin, axis1(1.0, 0.0, 0.0, 0.0), axis2(0.0, 1.0, 0.0, 0.0), axis3(0.0, 0.0, 1.0, 0.0);
taxonomy::point3 O = as<taxonomy::point3>(map(inst->LocalOrigin()));
origin << *O.components_, 1.0;
taxonomy::point3::ptr O = taxonomy::cast<taxonomy::point3>(map(inst->LocalOrigin()));
origin << *O->components_, 1.0;
if (inst->Axis1()) {
taxonomy::direction3 ax1 = as<taxonomy::direction3>(map(inst->Axis1()));
axis1 << *ax1.components_, 0.0;
taxonomy::direction3::ptr ax1 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis1()));
axis1 << *ax1->components_, 0.0;
}
if (inst->Axis2()) {
taxonomy::direction3 ax2 = as<taxonomy::direction3>(map(inst->Axis1()));
axis2 << *ax2.components_, 0.0;
taxonomy::direction3::ptr ax2 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis1()));
axis2 << *ax2->components_, 0.0;
}
double scale1, scale2;
@@ -21,30 +21,30 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator3D* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator3D* inst) {
Eigen::Vector4d origin;
Eigen::Vector4d axis1(1., 0., 0., 0.);
Eigen::Vector4d axis2(0., 1., 0., 0.);
Eigen::Vector4d axis3(0., 0., 1., 0.);
taxonomy::point3 O = as<taxonomy::point3>(map(inst->LocalOrigin()));
origin << *O.components_, 1.0;
taxonomy::point3::ptr O = taxonomy::cast<taxonomy::point3>(map(inst->LocalOrigin()));
origin << *O->components_, 1.0;
if (inst->Axis1()) {
taxonomy::direction3 ax1 = as<taxonomy::direction3>(map(inst->Axis1()));
axis1 << *ax1.components_, 0.0;
taxonomy::direction3::ptr ax1 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis1()));
axis1 << *ax1->components_, 0.0;
}
if (inst->Axis2()) {
taxonomy::direction3 ax2 = as<taxonomy::direction3>(map(inst->Axis2()));
axis2 << *ax2.components_, 0.0;
taxonomy::direction3::ptr ax2 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis2()));
axis2 << *ax2->components_, 0.0;
}
if (inst->Axis3()) {
taxonomy::direction3 ax3 = as<taxonomy::direction3>(map(inst->Axis3()));
axis3 << *ax3.components_, 0.0;
taxonomy::direction3::ptr ax3 = taxonomy::cast<taxonomy::direction3>(map(inst->Axis3()));
axis3 << *ax3->components_, 0.0;
}
auto m4 = new taxonomy::matrix4(origin.head<3>(), axis3.head<3>(), axis1.head<3>());
auto m4 = taxonomy::make<taxonomy::matrix4>(origin.head<3>(), axis3.head<3>(), axis1.head<3>());
if (m4->ccomponents().col(1).dot(axis2) < 0.) {
m4->components().col(1) *= -1.;
}
@@ -21,16 +21,21 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCenterLineProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCenterLineProfileDef* inst) {
return nullptr;
/*
const double d = inst->Thickness() * length_unit_ / 2.;
auto f = new taxonomy::face;
auto ofc = new taxonomy::offset_curve;
auto f = taxonomy::make<taxonomy::face>();
auto ofc = taxonomy::make<taxonomy::offset_curve>();
ofc->basis = map(inst->Curve());
ofc->offset = d;
f->children.push_back(ofc);
// @todo
// f->children.push_back(ofc);
return f;
*/
// @todo we still need to handle this in the l
// @todo we still need to handle this in the geometry libraries
/*
TopoDS_Wire wire;
+3 -3
View File
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#define ALMOST_ZERO 1.e-7;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircle* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle* inst) {
const double r = inst->Radius() * length_unit_;
if (r < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", inst);
@@ -31,8 +31,8 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircle* inst) {
}
IfcSchema::IfcAxis2Placement* placement = inst->Position();
auto c = new taxonomy::circle;
auto c = taxonomy::make<taxonomy::circle>();
c->radius = r;
c->matrix = as<taxonomy::matrix4>(map(placement));
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(placement));
return c;
}
+6 -9
View File
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#include <boost/math/constants/constants.hpp>
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
std::vector<double> radii = { inst->Radius() * length_unit_ };
if (inst->as<IfcSchema::IfcCircleHollowProfileDef>()) {
@@ -31,13 +31,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
radii.push_back(radii.front() - t);
}
auto f = new taxonomy::face;
auto f = taxonomy::make<taxonomy::face>();
for (auto it = radii.begin(); it != radii.end(); ++it) {
const double r = *it;
const bool exterior = it == radii.begin();
auto c = new taxonomy::circle;
auto c = taxonomy::make<taxonomy::circle>();
c->radius = r;
bool has_position = true;
@@ -45,18 +45,15 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
has_position = !!inst->Position();
#endif
if (has_position) {
taxonomy::matrix4 m = as<taxonomy::matrix4>(map(inst->Position()));
if (m.components_) {
c->matrix = *m.components_;
}
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
auto e = new taxonomy::edge;
auto e = taxonomy::make<taxonomy::edge>();
e->basis = c;
e->start = 0.;
e->end = 2 * boost::math::constants::pi<double>();
auto l = new taxonomy::loop;
auto l = taxonomy::make<taxonomy::loop>();
l->children = { e };
l->external = exterior;
+8 -8
View File
@@ -21,8 +21,8 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
auto loop = new taxonomy::loop;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
auto loop = taxonomy::make<taxonomy::loop>();
#ifdef SCHEMA_HAS_IfcSegment
// 4x3
@@ -49,7 +49,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
Logger::Warning("Segment length below tolerance", segment);
}
auto e = new taxonomy::edge;
auto e = taxonomy::make<taxonomy::edge>();
e->basis = map(curve);
e->start = u0;
e->end = u1;
@@ -60,14 +60,14 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
auto crv = map(segment->ParentCurve());
if (crv) {
if (crv->kind() == taxonomy::EDGE) {
((taxonomy::edge*)crv)->orientation_2.reset(segment->SameSense());
loop->children.push_back(crv);
auto ecrv = taxonomy::cast<taxonomy::edge>(crv);
ecrv->orientation_2.reset(segment->SameSense());
loop->children.push_back(ecrv);
} else if (crv->kind() == taxonomy::LOOP) {
if (!segment->SameSense()) {
crv->reverse();
}
auto curve_segments = ((taxonomy::loop*)crv)->children_as<taxonomy::edge>();
for (auto& s : curve_segments) {
for (auto& s : taxonomy::cast<taxonomy::loop>(crv)->children) {
loop->children.push_back(s);
}
// @todo delete crv without children
@@ -95,7 +95,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
#define _USE_MATH_DEFINES
#define mapping POSTFIX_SCHEMA(mapping)
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire& wire) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire& wire) {
TopTools_ListOfShape converted_segments;
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCompositeProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeProfileDef* inst) {
// @todo double check that this is actually supported
IfcSchema::IfcProfileDef::list::ptr profiles = inst->Profiles();
return map_to_collection<>(this, profiles);
+2 -2
View File
@@ -21,9 +21,9 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcConnectedFaceSet* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcConnectedFaceSet* inst) {
auto shell = map_to_collection<taxonomy::shell>(this, inst->CfsFaces());
if (shell == nullptr) {
if (!shell) {
return nullptr;
}
shell->closed = inst->declaration().is(IfcSchema::IfcClosedShell::Class());
@@ -25,7 +25,7 @@ using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcCraneRailAShapeProfileDef
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCraneRailAShapeProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCraneRailAShapeProfileDef* inst) {
double oh = inst->OverallHeight() * length_unit_;
double bw2 = inst->BaseWidth2() * length_unit_;
double hw = inst->HeadWidth() * length_unit_;
@@ -37,13 +37,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCraneRailAShapeProfileDef*
double bd2 = inst->BaseDepth2() * length_unit_;
double bd3 = inst->BaseDepth3() * length_unit_;
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+1 -1
View File
@@ -21,6 +21,6 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCsgSolid* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCsgSolid* inst) {
return map(inst->TreeRootExpression());
}
+6 -6
View File
@@ -21,17 +21,17 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCurveBoundedPlane* inst) {
taxonomy::plane pl = as<taxonomy::plane>(map(inst->BasisSurface()));
auto f = new taxonomy::face;
f->children.push_back(map(inst->OuterBoundary()));
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCurveBoundedPlane* inst) {
taxonomy::plane::ptr pl = taxonomy::cast<taxonomy::plane>(map(inst->BasisSurface()));
auto f = taxonomy::make<taxonomy::face>();
f->children.push_back(taxonomy::cast<taxonomy::loop>(map(inst->OuterBoundary())));
IfcSchema::IfcCurve::list::ptr boundaries = inst->InnerBoundaries();
for (IfcSchema::IfcCurve::list::it it = boundaries->begin(); it != boundaries->end(); ++it) {
f->children.push_back(map(*it));
f->children.push_back(taxonomy::cast<taxonomy::loop>(map(*it)));
}
f->matrix = pl.matrix;
f->matrix = pl->matrix;
return f;
}
@@ -23,10 +23,10 @@ using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcCylindricalSurface
taxonomy::item* mapping::map_impl(const IfcSchema::IfcCylindricalSurface* inst) {
auto c = new taxonomy::cylinder;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCylindricalSurface* inst) {
auto c = taxonomy::make<taxonomy::cylinder>();
c->radius = inst->Radius() * length_unit_;
c->matrix = as<taxonomy::matrix4>(map(inst->Position()));
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
return c;
}
+3 -3
View File
@@ -21,9 +21,9 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcDerivedProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDerivedProfileDef* inst) {
auto it = map(inst->ParentProfile());
taxonomy::matrix4 m = as<taxonomy::matrix4>(map(inst->Operator()));
((taxonomy::geom_item*)it)->matrix.components() *= m.ccomponents();
taxonomy::matrix4::ptr m = taxonomy::cast<taxonomy::matrix4>(map(inst->Operator()));
taxonomy::cast<taxonomy::geom_item>(it)->matrix->components() *= m->ccomponents();
return it;
}
+2 -2
View File
@@ -21,9 +21,9 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcDirection* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDirection* inst) {
auto coords = inst->DirectionRatios();
return new taxonomy::direction3(
return taxonomy::make<taxonomy::direction3>(
coords.size() >= 1 ? coords[0] : 0.,
coords.size() >= 2 ? coords[1] : 0.,
coords.size() >= 3 ? coords[2] : 0.
+4 -4
View File
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEdge* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge* inst) {
if (!inst->EdgeStart()->declaration().is(IfcSchema::IfcVertexPoint::Class()) || !inst->EdgeEnd()->declaration().is(IfcSchema::IfcVertexPoint::Class())) {
Logger::Message(Logger::LOG_ERROR, "Only IfcVertexPoints are supported for EdgeStart and -End", inst);
return nullptr;
@@ -34,10 +34,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEdge* inst) {
return nullptr;
}
auto e = new taxonomy::edge;
auto e = taxonomy::make<taxonomy::edge>();
e->start = as<taxonomy::point3>(map(pnt1));
e->end = as<taxonomy::point3>(map(pnt2));
e->start = taxonomy::cast<taxonomy::point3>(map(pnt1));
e->end = taxonomy::cast<taxonomy::point3>(map(pnt2));
if (inst->as<IfcSchema::IfcEdgeCurve>()) {
e->basis = map(inst->as<IfcSchema::IfcEdgeCurve>()->EdgeGeometry());
+1 -1
View File
@@ -21,6 +21,6 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEdgeLoop* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdgeLoop* inst) {
return map_to_collection<taxonomy::loop>(this, inst->EdgeList());
}
+10 -8
View File
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
double x = inst->SemiAxis1() * length_unit_;
double y = inst->SemiAxis2() * length_unit_;
const double tol = conv_settings_.getValue(ConversionSettings::GV_PRECISION);
@@ -30,19 +30,21 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
return nullptr;
}
auto el = new taxonomy::ellipse;
el->matrix = as<taxonomy::matrix4>(map(inst->Position()));
auto el = taxonomy::make<taxonomy::ellipse>();
el->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
// Open Cascade does not allow ellipses of which the minor radius
// is greater than the major radius. Hence, in this case, the
// ellipse is rotated. Note that special care is taken
// when creating a trimmed curve off of an ellipse like this.
if (y > x) {
el->matrix.components() <<
-el->matrix.ccomponents().col(1),
el->matrix.ccomponents().col(0),
el->matrix.ccomponents().col(2),
el->matrix.ccomponents().col(3);
// @todo is a copy necesary here or can this be done in place?
auto m4_copy = *el->matrix;
el->matrix->components() <<
-m4_copy.components().col(1),
m4_copy.components().col(0),
m4_copy.components().col(2),
m4_copy.components().col(3);
std::swap(x, y);
}
+9 -9
View File
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
double rx = inst->SemiAxis1() * length_unit_;
double ry = inst->SemiAxis2() * length_unit_;
const double tol = conv_settings_.getValue(ConversionSettings::GV_PRECISION);
@@ -32,19 +32,19 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
const bool rotated = ry > rx;
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
if (ry > rx) {
// @todo is a copy necesary here or can this be done in place?
auto m4_copy = m4;
m4.components() <<
auto m4_copy = *m4;
m4->components() <<
-m4_copy.components().col(1),
m4_copy.components().col(0),
m4_copy.components().col(2),
@@ -52,10 +52,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) {
std::swap(rx, ry);
}
auto fc = new taxonomy::face;
auto lp = new taxonomy::loop;
auto ed = new taxonomy::edge;
auto el = new taxonomy::ellipse;
auto fc = taxonomy::make<taxonomy::face>();
auto lp = taxonomy::make<taxonomy::loop>();
auto ed = taxonomy::make<taxonomy::edge>();
auto el = taxonomy::make<taxonomy::ellipse>();
el->radius = rx;
el->radius2 = ry;
ed->basis = el;
+6 -6
View File
@@ -24,7 +24,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
const double height = inst->Depth() * length_unit_;
if (height < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", inst);
@@ -33,13 +33,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
#endif
}
taxonomy::matrix4 matrix;
taxonomy::matrix4::ptr matrix;
bool has_position = true;
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = inst->Position() != nullptr;
#endif
if (has_position) {
matrix = as<taxonomy::matrix4>(map(inst->Position()));
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
#ifdef PERMISSIVE_EXTRUSION
@@ -49,10 +49,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid* inst) {
}
#endif
return new taxonomy::extrusion(
return taxonomy::make<taxonomy::extrusion>(
matrix,
as<taxonomy::face>(map(inst->SweptArea())),
as<taxonomy::direction3>(map(inst->ExtrudedDirection())),
taxonomy::cast<taxonomy::face>(map(inst->SweptArea())),
taxonomy::cast<taxonomy::direction3>(map(inst->ExtrudedDirection())),
height
);
}
@@ -24,25 +24,25 @@ using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
#define mapping POSTFIX_SCHEMA(mapping)
taxonomy::item* mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolidTapered* inst) {
const double height = inst->Depth() * length_unit_;
if (height < conv_settings_.getValue(ConversionSettings::GV_PRECISION)) {
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", inst);
return nullptr;
}
taxonomy::direction3 dir = as<taxonomy::direction3>(map(inst->ExtrudedDirection()));
Eigen::Affine3d af3d(Eigen::Translation3d(height * dir.ccomponents()));
taxonomy::direction3::ptr dir = taxonomy::cast<taxonomy::direction3>(map(inst->ExtrudedDirection()));
Eigen::Affine3d af3d(Eigen::Translation3d(height * dir->ccomponents()));
Eigen::Matrix4d end_profile = af3d.matrix();
auto loft = new taxonomy::loft;
auto loft = taxonomy::make<taxonomy::loft>();
loft->children = {
map(inst->SweptArea()),
map(inst->EndSweptArea())
taxonomy::cast<taxonomy::face>(map(inst->SweptArea())),
taxonomy::cast<taxonomy::face>(map(inst->EndSweptArea()))
};
auto old = ((taxonomy::geom_item*)loft->children.back())->matrix.ccomponents();
((taxonomy::geom_item*)loft->children.back())->matrix.components() = old * end_profile;
auto old = loft->children.back()->matrix->ccomponents();
loft->children.back()->matrix->components() = old * end_profile;
return loft;
+7 -5
View File
@@ -21,16 +21,16 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* inst) {
taxonomy::face* face = new taxonomy::face;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFace* inst) {
auto face = taxonomy::make<taxonomy::face>();
auto bounds = inst->Bounds();
for (auto& bound : *bounds) {
if (auto r = map(bound->Bound())) {
if (auto r = taxonomy::cast<taxonomy::loop>(map(bound->Bound()))) {
if (!bound->Orientation()) {
r->reverse();
}
if (bound->declaration().is(IfcSchema::IfcFaceOuterBound::Class())) {
((taxonomy::loop*)r)->external = true;
r->external = true;
/*
// Make a copy in case we need immutability later for e.g. caching
auto s = r->clone();
@@ -43,7 +43,9 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* inst) {
}
}
if (face->children.empty()) {
#ifdef TAXONOMY_USE_NAKED_PTR
delete face;
#endif
return nullptr;
}
return face;
@@ -76,7 +78,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* inst) {
#define mapping POSTFIX_SCHEMA(mapping)
taxonomy::item* mapping::map_impl(const IfcSchema::IfcFace* l, TopoDS_Shape& result) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFace* l, TopoDS_Shape& result) {
IfcSchema::IfcFaceBound::list::ptr bounds = inst->Bounds();
util::face_definition fd;
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcFaceBasedSurfaceModel* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFaceBasedSurfaceModel* inst) {
// @todo check styles?
return map_to_collection(this, inst->FbsmFaces());
}
+1 -1
View File
@@ -21,6 +21,6 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcGeometricSet* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGeometricSet* inst) {
return map_to_collection(this, inst->Elements());
}
+9 -7
View File
@@ -21,18 +21,20 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid* inst) {
IfcSchema::IfcSurface* surface = inst->BaseSurface();
if (!surface->declaration().is(IfcSchema::IfcPlane::Class())) {
Logger::Message(Logger::LOG_ERROR, "Unsupported BaseSurface:", surface);
return nullptr;
}
auto p = new taxonomy::plane;
p->matrix = as<taxonomy::matrix4>(map(((IfcSchema::IfcPlane*)surface)->Position()));
auto f = new taxonomy::face;
auto p = taxonomy::make<taxonomy::plane>();
p->matrix = taxonomy::cast<taxonomy::matrix4>(map(((IfcSchema::IfcPlane*)surface)->Position()));
auto f = taxonomy::make<taxonomy::face>();
f->orientation.reset(!inst->AgreementFlag());
f->basis = p;
auto s = new taxonomy::solid;
s->children.push_back(f);
return s;
auto sh = taxonomy::make<taxonomy::shell>();
sh->children.push_back(f);
auto so = taxonomy::make<taxonomy::solid>();
so->children.push_back(sh);
return so;
}
+3 -3
View File
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#include "../profile_helper.h"
taxonomy::item* mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
const bool doFillet1 = !!inst->FilletRadius();
#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius
const bool doFlangeEdgeRadius = !!inst->FlangeEdgeRadius();
@@ -85,13 +85,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
return nullptr;
}
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+10 -10
View File
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve
taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
IfcSchema::IfcCartesianPointList* point_list = inst->Points();
std::vector< std::vector<double> > coordinates;
@@ -33,10 +33,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
coordinates = point_list->as<IfcSchema::IfcCartesianPointList3D>()->CoordList();
}
std::vector<taxonomy::point3> points;
std::vector<taxonomy::point3::ptr> points;
points.reserve(coordinates.size());
for (auto& coords : coordinates) {
points.push_back(taxonomy::point3(
points.push_back(taxonomy::make<taxonomy::point3>(
coords.size() < 1 ? 0. : coords[0] * length_unit_,
coords.size() < 2 ? 0. : coords[1] * length_unit_,
coords.size() < 3 ? 0. : coords[2] * length_unit_));
@@ -44,7 +44,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
int max_index = (int) points.size();
auto loop = new taxonomy::loop;
auto loop = taxonomy::make<taxonomy::loop>();
if(inst->Segments()) {
aggregate_of_instance::ptr segments = *inst->Segments();
@@ -53,14 +53,14 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
if (segment->declaration().is(IfcSchema::IfcLineIndex::Class())) {
IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment;
std::vector<int> indices = *line;
taxonomy::point3 previous;
taxonomy::point3::ptr previous;
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
if (*jt < 1 || *jt > max_index) {
throw IfcParse::IfcException("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
}
const taxonomy::point3& current = points[*jt - 1];
auto current = points[*jt - 1];
if (jt != indices.begin()) {
loop->children.push_back(new taxonomy::edge(previous, current));
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
}
previous = current;
}
@@ -80,9 +80,9 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
const auto& b = points[indices[1] - 1];
const auto& c = points[indices[2] - 1];
auto circ = taxonomy::circle::from_3_points(a.ccomponents(), b.ccomponents(), c.ccomponents());
auto circ = taxonomy::circle::from_3_points(a->ccomponents(), b->ccomponents(), c->ccomponents());
if (circ) {
auto e = new taxonomy::edge(a, c);
auto e = taxonomy::make<taxonomy::edge>(a, c);
e->basis = circ;
loop->children.push_back(e);
} else {
@@ -95,7 +95,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) {
} else if (points.begin() < points.end()) {
auto previous = points.begin();
for (auto current = previous+1; current < points.end(); ++current){
loop->children.push_back(new taxonomy::edge(*previous, *current));
loop->children.push_back(taxonomy::make<taxonomy::edge>(*previous, *current));
previous = current;
}
}
+3 -3
View File
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#include "../profile_helper.h"
taxonomy::item* mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
const bool hasSlope = !!inst->LegSlope();
const bool doEdgeFillet = !!inst->EdgeRadius();
const bool doFillet = !!inst->FilletRadius();
@@ -85,13 +85,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) {
xy = (a1*c2 - a2*c1) / det;
}
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+5 -5
View File
@@ -21,11 +21,11 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcLine* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLine* inst) {
// @todo test with trimmed curve on non-normalized direction
auto l = new taxonomy::line;
taxonomy::point3 pnt = as<taxonomy::point3>(map(inst->Pnt()));
taxonomy::direction3 dir = as<taxonomy::direction3>(map(inst->Dir()));
l->matrix = taxonomy::matrix4(pnt.ccomponents(), dir.ccomponents());
auto l = taxonomy::make<taxonomy::line>();
auto pnt = taxonomy::cast<taxonomy::point3>(map(inst->Pnt()));
auto dir = taxonomy::cast<taxonomy::direction3>(map(inst->Dir()));
l->matrix = taxonomy::make<taxonomy::matrix4>(pnt->ccomponents(), dir->ccomponents());
return l;
}
+3 -4
View File
@@ -21,16 +21,15 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcLocalPlacement* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLocalPlacement* inst) {
IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)inst;
auto m4 = new taxonomy::matrix4;
auto m4 = taxonomy::make<taxonomy::matrix4>();
for (;;) {
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
// @todo this type check is wrong and unnecessary?
if (relplacement->as<IfcSchema::IfcAxis2Placement3D>()) {
taxonomy::matrix4 trsf2 = as<taxonomy::matrix4>(map(relplacement));
// @todo check
m4->components() = trsf2.ccomponents() * m4->ccomponents();
m4->components() = taxonomy::cast<taxonomy::matrix4>(map(relplacement))->ccomponents() * m4->ccomponents();
}
if (current->PlacementRelTo()) {
IfcSchema::IfcObjectPlacement* parent = current->PlacementRelTo();
+4 -4
View File
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcManifoldSolidBrep* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcManifoldSolidBrep* inst) {
IfcSchema::IfcClosedShell::list::ptr voids(new IfcSchema::IfcClosedShell::list);
if (inst->declaration().is(IfcSchema::IfcFacetedBrepWithVoids::Class())) {
voids = inst->as<IfcSchema::IfcFacetedBrepWithVoids>()->Voids();
@@ -32,13 +32,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcManifoldSolidBrep* inst) {
}
#endif
taxonomy::solid* solid;
taxonomy::solid::ptr solid;
if (voids->size()) {
solid = map_to_collection<taxonomy::solid>(this, voids);
} else {
solid = new taxonomy::solid;
solid = taxonomy::make<taxonomy::solid>();
}
solid->children.insert(solid->children.begin(), map(inst->Outer()));
solid->children.insert(solid->children.begin(), taxonomy::cast<taxonomy::shell>(map(inst->Outer())));
return solid;
}
+8 -9
View File
@@ -21,28 +21,27 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcMappedItem* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMappedItem* inst) {
IfcSchema::IfcCartesianTransformationOperator* transform = inst->MappingTarget();
auto qqq = (taxonomy::matrix4*)map(transform);
taxonomy::matrix4 gtrsf = *qqq;
taxonomy::matrix4::ptr gtrsf = taxonomy::cast<taxonomy::matrix4>(map(transform));
IfcSchema::IfcRepresentationMap* rmap = inst->MappingSource();
IfcSchema::IfcAxis2Placement* placement = rmap->MappingOrigin();
taxonomy::matrix4 trsf2 = *(taxonomy::matrix4*)(map(placement));
Eigen::Matrix4d res = gtrsf.ccomponents() * trsf2.ccomponents();
taxonomy::matrix4::ptr trsf2 = taxonomy::cast<taxonomy::matrix4>(map(placement));
Eigen::Matrix4d res = gtrsf->ccomponents() * trsf2->ccomponents();
// @todo immutable for caching?
// @todo allow for multiple levels of matrix?
auto shapes = map(rmap->MappedRepresentation());
auto shapes = taxonomy::cast<taxonomy::geom_item>(map(rmap->MappedRepresentation()));
if (shapes == nullptr) {
return shapes;
}
auto collection = new taxonomy::collection;
auto collection = taxonomy::make<taxonomy::collection>();
collection->children.push_back(shapes);
collection->matrix = res;
collection->matrix = taxonomy::make<taxonomy::matrix4>(res);
if (shapes != nullptr) {
for (auto& c : ((taxonomy::collection*)shapes)->children) {
for (auto& c : taxonomy::cast<taxonomy::collection>(shapes)->children) {
// @todo previously style was also copied.
}
}
+2 -2
View File
@@ -21,8 +21,8 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcOrientedEdge* inst) {
auto e = map(inst->EdgeElement());
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOrientedEdge* inst) {
auto e = taxonomy::cast<taxonomy::edge>(map(inst->EdgeElement()));
if (!inst->Orientation()) {
e->reverse();
}
+3 -3
View File
@@ -21,8 +21,8 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPlane* inst) {
auto p = new taxonomy::plane;
p->matrix = as<taxonomy::matrix4>(map(inst->Position()));
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPlane* inst) {
auto p = taxonomy::make<taxonomy::plane>();
p->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
return p;
}
+3 -3
View File
@@ -23,14 +23,14 @@ using namespace ifcopenshell::geometry;
#include "../profile_helper.h"
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyLoop* inst) {
IfcSchema::IfcCartesianPoint::list::ptr points = inst->Polygon();
// Parse and store the points in a sequence
std::vector<taxonomy::point3> polygon;
std::vector<taxonomy::point3::ptr> polygon;
polygon.reserve(points->size());
std::transform(points->begin(), points->end(), std::back_inserter(polygon), [this](const IfcSchema::IfcCartesianPoint* p) {
return as<taxonomy::point3>(map(p));
return taxonomy::cast<taxonomy::point3>(map(p));
});
// A loop should consist of at least three vertices
@@ -21,10 +21,10 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolygonalBoundedHalfSpace* inst) {
auto s = (taxonomy::solid*)map_impl((IfcSchema::IfcHalfSpaceSolid*) inst);
auto f = (taxonomy::face*)s->children[0];
f->children = { map(inst->PolygonalBoundary()) };
f->matrix = as<taxonomy::matrix4>(map(inst->Position()));
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolygonalBoundedHalfSpace* inst) {
auto s = taxonomy::cast<taxonomy::solid>(map_impl((IfcSchema::IfcHalfSpaceSolid*) inst));
auto f = s->children[0]->children[0];
f->children = { taxonomy::cast<taxonomy::loop>(map(inst->PolygonalBoundary())) };
f->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
return s;
}
+30 -28
View File
@@ -23,15 +23,15 @@ using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcPolygonalFaceSet
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet* inst) {
IfcSchema::IfcCartesianPointList3D* point_list = inst->Coordinates();
auto coordinates = point_list->CoordList();
auto polygonal_faces = inst->Faces();
std::vector<taxonomy::point3> points;
std::vector<taxonomy::point3::ptr> points;
points.reserve(coordinates.size());
for (auto& coords : coordinates) {
points.push_back(taxonomy::point3(
points.push_back(taxonomy::make<taxonomy::point3>(
coords.size() < 1 ? 0. : coords[0] * length_unit_,
coords.size() < 2 ? 0. : coords[1] * length_unit_,
coords.size() < 3 ? 0. : coords[2] * length_unit_));
@@ -39,57 +39,59 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet* inst) {
int max_index = (int)points.size();
auto shell = new taxonomy::shell;
auto shell = taxonomy::make<taxonomy::shell>();
for (auto& f : *polygonal_faces) {
auto fa = new taxonomy::face;
auto fa = taxonomy::make<taxonomy::face>();
shell->children.push_back(fa);
{
auto loop = new taxonomy::loop;
auto loop = taxonomy::make<taxonomy::loop>();
fa->children = { loop };
loop->external = true;
auto indices = f->CoordIndex();
taxonomy::point3 previous;
taxonomy::point3::ptr previous;
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
if (*jt < 1 || *jt > max_index) {
throw IfcParse::IfcException("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
}
const taxonomy::point3& current = points[(*jt) - 1];
auto current = points[(*jt) - 1];
if (jt != indices.begin()) {
loop->children.push_back(new taxonomy::edge(previous, current));
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
}
previous = current;
}
if (!indices.empty()) {
const taxonomy::point3& current = points[indices.front() - 1];
loop->children.push_back(new taxonomy::edge(previous, current));
auto current = points[indices.front() - 1];
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
}
}
if (f->as<IfcSchema::IfcIndexedPolygonalFaceWithVoids>()) {
auto indices = f->as<IfcSchema::IfcIndexedPolygonalFaceWithVoids>()->InnerCoordIndices();
{
auto loop = new taxonomy::loop;
fa->children.push_back(loop);
loop->external = false;
auto indices = f->CoordIndex();
taxonomy::point3 previous;
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
if (*jt < 1 || *jt > max_index) {
throw IfcParse::IfcException("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
taxonomy::point3::ptr previous;
for (auto& li : indices) {
auto loop = taxonomy::make<taxonomy::loop>();
fa->children.push_back(loop);
loop->external = false;
for (std::vector<int>::const_iterator jt = li.begin(); jt != li.end(); ++jt) {
if (*jt < 1 || *jt > max_index) {
throw IfcParse::IfcException("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
}
auto current = points[(*jt) - 1];
if (jt != li.begin()) {
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
}
previous = current;
}
const taxonomy::point3& current = points[(*jt) - 1];
if (jt != indices.begin()) {
loop->children.push_back(new taxonomy::edge(previous, current));
if (!li.empty()) {
auto current = points[li.front() - 1];
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
}
previous = current;
}
if (!indices.empty()) {
const taxonomy::point3& current = points[indices.front() - 1];
loop->children.push_back(new taxonomy::edge(previous, current));
}
}
}
}
+4 -4
View File
@@ -23,17 +23,17 @@ using namespace ifcopenshell::geometry;
#include "../profile_helper.h"
taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolyline* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolyline* inst) {
IfcSchema::IfcCartesianPoint::list::ptr points = inst->Points();
// Parse and store the points in a sequence
std::vector<taxonomy::point3> polygon;
std::vector<taxonomy::point3::ptr> polygon;
polygon.reserve(points->size());
std::transform(points->begin(), points->end(), std::back_inserter(polygon), [this](const IfcSchema::IfcCartesianPoint* p) {
return as<taxonomy::point3>(map(p));
return taxonomy::cast<taxonomy::point3>(map(p));
});
const bool closed_by_proximity = polygon.size() >= 3 && (*polygon.front().components_ - *polygon.back().components_).norm() < conv_settings_.getValue(ConversionSettings::GV_PRECISION);
const bool closed_by_proximity = polygon.size() >= 3 && (*polygon.front()->components_ - *polygon.back()->components_).norm() < conv_settings_.getValue(ConversionSettings::GV_PRECISION);
if (closed_by_proximity) {
polygon.resize(polygon.size() - 1);
polygon.push_back(polygon.front());
+6 -6
View File
@@ -4,11 +4,11 @@ using namespace ifcopenshell::geometry;
using namespace IfcGeom;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcProduct* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcProduct* inst) {
// @todo decide on this, what happens in the product mapping?
// currently things like openings, layers and materials are processed in the converter
auto c = new taxonomy::collection;
c->matrix = as<taxonomy::matrix4>(map(inst->ObjectPlacement()));
auto c = taxonomy::make<taxonomy::collection>();
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->ObjectPlacement()));
return c;
/*
@@ -30,7 +30,7 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcProduct* inst) {
}
auto c = new taxonomy::collection;
c->matrix = as<taxonomy::matrix4>(map(inst->ObjectPlacement()));
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->ObjectPlacement()));
const auto single_material = get_single_material_association(inst);
if (single_material) {
@@ -53,8 +53,8 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcProduct* inst) {
operands->push(body);
operands->push(openings);
auto n = map_to_collection<taxonomy::boolean_result>(this, operands);
std::for_each(n->children.begin() + 1, n->children.end(), [&ci](taxonomy::item* i) {
((taxonomy::geom_item*)i)->matrix.components() = ci * ((taxonomy::geom_item*)i)->matrix.ccomponents();
std::for_each(n->children.begin() + 1, n->children.end(), [&ci](taxonomy::ptr i) {
((taxonomy::geom_ptr)i)->matrix.components() = ci * ((taxonomy::geom_ptr)i)->matrix.ccomponents();
});
n->operation = taxonomy::boolean_result::SUBTRACTION;
// @todo one indirection too many
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#include "../profile_helper.h"
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef* inst) {
const double x = inst->XDim() / 2.0f * length_unit_;
const double y = inst->YDim() / 2.0f * length_unit_;
const double d = inst->WallThickness() * length_unit_;
@@ -41,13 +41,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef*
return nullptr;
}
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
auto s1 = profile_helper(m4, {
@@ -69,7 +69,10 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef*
}
s1->children.push_back(s2->children[0]);
#ifdef TAXONOMY_USE_NAKED_PTR
delete s2;
#endif
return s1;
}
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#include "../profile_helper.h"
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst) {
const double x = inst->XDim() / 2.0f * length_unit_;
const double y = inst->YDim() / 2.0f * length_unit_;
@@ -34,13 +34,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst)
return nullptr;
}
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+50 -50
View File
@@ -21,107 +21,107 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangularPyramid* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularPyramid* inst) {
const double dx = inst->XLength() * length_unit_;
const double dy = inst->YLength() * length_unit_;
const double dz = inst->Height() * length_unit_;
auto solid = new taxonomy::solid;
auto shell = new taxonomy::shell;
auto solid = taxonomy::make<taxonomy::solid>();
auto shell = taxonomy::make<taxonomy::shell>();
solid->children.push_back(shell);
// Base
{
auto face = new taxonomy::face;
auto loop = new taxonomy::loop;
auto face = taxonomy::make<taxonomy::face>();
auto loop = taxonomy::make<taxonomy::loop>();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array<taxonomy::point3, 4> points{
taxonomy::point3(0, 0, 0),
taxonomy::point3(dx, 0, 0),
taxonomy::point3(dx, dy, 0),
taxonomy::point3(0, dy, 0)
std::array<taxonomy::point3::ptr, 4> points{
taxonomy::make<taxonomy::point3>(0, 0, 0),
taxonomy::make<taxonomy::point3>(dx, 0, 0),
taxonomy::make<taxonomy::point3>(dx, dy, 0),
taxonomy::make<taxonomy::point3>(0, dy, 0)
};
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
loop->children.push_back(new taxonomy::edge(points[2], points[3]));
loop->children.push_back(new taxonomy::edge(points[3], points[0]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[3]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[3], points[0]));
}
// Lateral faces
{
auto face = new taxonomy::face;
auto loop = new taxonomy::loop;
auto face = taxonomy::make<taxonomy::face>();
auto loop = taxonomy::make<taxonomy::loop>();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array<taxonomy::point3, 3> points{
taxonomy::point3(0, 0, 0),
taxonomy::point3(0, dy, 0),
taxonomy::point3(0.5*dx, 0.5*dy, dz)
std::array<taxonomy::point3::ptr, 3> points{
taxonomy::make<taxonomy::point3>(0, 0, 0),
taxonomy::make<taxonomy::point3>(0, dy, 0),
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
}
{
auto face = new taxonomy::face;
auto loop = new taxonomy::loop;
auto face = taxonomy::make<taxonomy::face>();
auto loop = taxonomy::make<taxonomy::loop>();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array<taxonomy::point3, 3> points{
taxonomy::point3(0, dy, 0),
taxonomy::point3(dx, dy, 0),
taxonomy::point3(0.5*dx, 0.5*dy, dz)
std::array<taxonomy::point3::ptr, 3> points{
taxonomy::make<taxonomy::point3>(0, dy, 0),
taxonomy::make<taxonomy::point3>(dx, dy, 0),
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
}
{
auto face = new taxonomy::face;
auto loop = new taxonomy::loop;
auto face = taxonomy::make<taxonomy::face>();
auto loop = taxonomy::make<taxonomy::loop>();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array<taxonomy::point3, 3> points{
taxonomy::point3(dx, dy, 0),
taxonomy::point3(dx, 0, 0),
taxonomy::point3(0.5*dx, 0.5*dy, dz)
std::array<taxonomy::point3::ptr, 3> points{
taxonomy::make<taxonomy::point3>(dx, dy, 0),
taxonomy::make<taxonomy::point3>(dx, 0, 0),
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
}
{
auto face = new taxonomy::face;
auto loop = new taxonomy::loop;
auto face = taxonomy::make<taxonomy::face>();
auto loop = taxonomy::make<taxonomy::loop>();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array<taxonomy::point3, 3> points{
taxonomy::point3(dx, 0, 0),
taxonomy::point3(0, 0, 0),
taxonomy::point3(0.5*dx, 0.5*dy, dz)
std::array<taxonomy::point3::ptr, 3> points{
taxonomy::make<taxonomy::point3>(dx, 0, 0),
taxonomy::make<taxonomy::point3>(0, 0, 0),
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(new taxonomy::edge(points[0], points[1]));
loop->children.push_back(new taxonomy::edge(points[1], points[2]));
loop->children.push_back(new taxonomy::edge(points[2], points[0]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[0], points[1]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[1], points[2]));
loop->children.push_back(taxonomy::make<taxonomy::edge>(points[2], points[0]));
}
return solid;
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface* inst) {
// @todo we'll need to add support for p-curves at some point, but not now.
return nullptr;
+4 -4
View File
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
const bool use_body = !this->settings_.get(IfcGeom::IteratorSettings::INCLUDE_CURVES);
auto items = map_to_collection(this, inst->Items());
@@ -41,19 +41,19 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
// @todo
// if (s.ShapeType() == TopAbs_COMPOUND && TopoDS_Iterator(s).More() && TopoDS_Iterator(s).Value().ShapeType() == TopAbs_SOLID) {
return filter_in_place(items, [&use_body](taxonomy::item* i) {
return filter_in_place(items, [&use_body](taxonomy::ptr i) {
// @todo just filter loops for now.
return (i->kind() != taxonomy::LOOP) == use_body;
});
}
/*
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
IfcSchema::IfcRepresentationItem::list::ptr items = inst->Items();
bool part_succes = false;
if ( items->size() ) {
for ( IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++ it ) {
IfcSchema::IfcRepresentationItem* representation_item = *it;
IfcSchema::IfcRepresentationptr representation_item = *it;
if ( shape_type(representation_item) == ST_SHAPELIST ) {
part_succes |= convert_shapes(*it, shapes);
} else {
+8 -8
View File
@@ -23,31 +23,31 @@ using namespace ifcopenshell::geometry;
#include <boost/math/constants/constants.hpp>
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid* inst) {
const double ang = inst->Angle() * angle_unit_;
as<taxonomy::face>(map(inst->SweptArea()));
taxonomy::cast<taxonomy::face>(map(inst->SweptArea()));
boost::optional<double> angle;
taxonomy::matrix4 matrix;
taxonomy::matrix4::ptr matrix;
bool has_position = true;
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = inst->Position() != nullptr;
#endif
if (has_position) {
matrix = as<taxonomy::matrix4>(map(inst->Position()));
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
if (ang < boost::math::constants::pi<double>() * 2. - 1.e-5) {
angle = ang;
}
return new taxonomy::revolve(
return taxonomy::make<taxonomy::revolve>(
matrix,
as<taxonomy::face>(map(inst->SweptArea())),
as<taxonomy::point3>(map(inst->Axis()->Location())),
as<taxonomy::direction3>(map(inst->Axis()->Axis())),
taxonomy::cast<taxonomy::face>(map(inst->SweptArea())),
taxonomy::cast<taxonomy::point3>(map(inst->Axis()->Location())),
taxonomy::cast<taxonomy::direction3>(map(inst->Axis()->Axis())),
angle
);
+1 -1
View File
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRightCircularCone* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCone* inst) {
// @todo
return nullptr;
/*
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRightCircularCylinder* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCylinder* inst) {
// @todo
return nullptr;
/*
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#include "../profile_helper.h"
taxonomy::item* mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef* inst) {
const double x = inst->XDim() / 2.0f * length_unit_;
const double y = inst->YDim() / 2.0f * length_unit_;
const double r = inst->RoundingRadius() * length_unit_;
@@ -35,13 +35,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef
return nullptr;
}
taxonomy::matrix4 m4;
taxonomy::matrix4::ptr m4;
bool has_position = true;
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = !!inst->Position();
#endif
if (has_position) {
m4 = as<taxonomy::matrix4>(map(inst->Position()));
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
@@ -21,6 +21,6 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcShellBasedSurfaceModel* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcShellBasedSurfaceModel* inst) {
return map_to_collection(this, inst->SbsmBoundary());
}
+1 -1
View File
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSphere* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphere* inst) {
// @todo
return nullptr;
/*
+1 -1
View File
@@ -23,7 +23,7 @@ using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcSphericalSurface
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSphericalSurface* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphericalSurface* inst) {
return nullptr;
/*
+1 -1
View File
@@ -22,7 +22,7 @@
using namespace ifcopenshell::geometry;
/*
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSubedge* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSubedge* inst) {
// @todo
return nullptr;
}
+1 -1
View File
@@ -22,7 +22,7 @@
using namespace ifcopenshell::geometry;
#ifdef SCHEMA_HAS_IfcSurfaceCurve
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceCurve* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurve* inst) {
// @todo take into account PCurves.
return map(inst->Curve3D());
}
@@ -21,19 +21,19 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* inst) {
taxonomy::face f = as<taxonomy::face>(map(inst->SweptArea()));
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* inst) {
taxonomy::face::ptr f = taxonomy::cast<taxonomy::face>(map(inst->SweptArea()));
taxonomy::matrix4 matrix;
taxonomy::matrix4::ptr matrix;
bool has_position = true;
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = inst->Position() != nullptr;
#endif
if (has_position) {
matrix = as<taxonomy::matrix4>(map(inst->Position()));
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
auto scs = new taxonomy::surface_curve_sweep(matrix, f, map(inst->ReferenceSurface()), map(inst->Directrix()));
auto scs = taxonomy::make<taxonomy::surface_curve_sweep>(matrix, f, map(inst->ReferenceSurface()), map(inst->Directrix()));
scs->matrix = matrix;
return scs;
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceOfLinearExtrusion* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfLinearExtrusion* inst) {
return nullptr;
/*
@@ -21,7 +21,7 @@
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::item* mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution* inst) {
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution* inst) {
return nullptr;
/*

Some files were not shown because too many files have changed in this diff Show More