Merge branch 'v0.8.0' into v0.8.0

This commit is contained in:
csritter
2024-08-26 10:26:10 -03:00
committed by GitHub
502 changed files with 124330 additions and 145664 deletions
+17 -4
View File
@@ -102,14 +102,27 @@ namespace {
}
};
template <class T, class Tuple>
struct TupleTypeIndex;
template <class T, class... Types>
struct TupleTypeIndex<T, std::tuple<T, Types...>> {
static const std::size_t value = 0;
};
template <class T, class U, class... Types>
struct TupleTypeIndex<T, std::tuple<U, Types...>> {
static const std::size_t value = 1 + TupleTypeIndex<T, std::tuple<Types...>>::value;
};
/* 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::ptr item, T& visitor) {
// @todo it should be possible to eliminate this dynamic_cast when there is a static equivalent to kind()
auto v = ifcopenshell::geometry::taxonomy::template dcast<ifcopenshell::geometry::taxonomy::curves::type<N>>(item);
if (v && item->kind() == v->kind()) {
visitor(v);
constexpr auto KindIndex = TupleTypeIndex<std::tuple_element_t<N, ifcopenshell::geometry::taxonomy::impl::CurvesTuple>, ifcopenshell::geometry::taxonomy::impl::KindsTuple>::value;
if (item->kind() == KindIndex) {
auto concrete_item = ifcopenshell::geometry::taxonomy::template cast<ifcopenshell::geometry::taxonomy::curves::type<N>>(item);
visitor(concrete_item);
return true;
} else {
return dispatch_curve_creation<T, N + 1>::dispatch(item, visitor);
+7 -1
View File
@@ -312,6 +312,12 @@ namespace ifcopenshell {
static constexpr bool defaultvalue = false;
};
struct NoParallelMapping : public SettingBase<NoParallelMapping, bool> {
static constexpr const char* const name = "no-parallel-mapping";
static constexpr const char* const description = "Perform mapping upfront (single-threaded) as opposed to in parallel. May decrease performance, but also decrease output size (in the future)";
static constexpr bool defaultvalue = false;
};
struct ForceSpaceTransparency : public SettingBase<ForceSpaceTransparency, double> {
static constexpr const char* const name = "force-space-transparency";
static constexpr const char* const description = "Overrides transparency of spaces in geometry output.";
@@ -447,7 +453,7 @@ namespace ifcopenshell {
};
class IFC_GEOM_API Settings : public SettingsContainer<
std::tuple<MesherLinearDeflection, MesherAngularDeflection, ReorientShells, LengthUnit, PlaneUnit, Precision, OutputDimensionality, LayersetFirst, DisableBooleanResult, NoWireIntersectionCheck, NoWireIntersectionTolerance, PrecisionFactor, DebugBooleanOperations, BooleanAttempt2d, SurfaceColour, WeldVertices, UseWorldCoords, UseMaterialNames, ConvertBackUnits, ContextIds, ContextTypes, ContextIdentifiers, IteratorOutput, DisableOpeningSubtractions, ApplyDefaultMaterials, DontEmitNormals, GenerateUvs, ApplyLayerSets, UseElementHierarchy, ValidateQuantities, EdgeArrows, BuildingLocalPlacement, SiteLocalPlacement, ForceSpaceTransparency, CircleSegments, KeepBoundingBoxes, PiecewiseStepType, PiecewiseStepParam>
std::tuple<MesherLinearDeflection, MesherAngularDeflection, ReorientShells, LengthUnit, PlaneUnit, Precision, OutputDimensionality, LayersetFirst, DisableBooleanResult, NoWireIntersectionCheck, NoWireIntersectionTolerance, PrecisionFactor, DebugBooleanOperations, BooleanAttempt2d, SurfaceColour, WeldVertices, UseWorldCoords, UseMaterialNames, ConvertBackUnits, ContextIds, ContextTypes, ContextIdentifiers, IteratorOutput, DisableOpeningSubtractions, ApplyDefaultMaterials, DontEmitNormals, GenerateUvs, ApplyLayerSets, UseElementHierarchy, ValidateQuantities, EdgeArrows, BuildingLocalPlacement, SiteLocalPlacement, ForceSpaceTransparency, CircleSegments, KeepBoundingBoxes, PiecewiseStepType, PiecewiseStepParam, NoParallelMapping>
>
{};
}
+12 -12
View File
@@ -35,7 +35,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
auto place = place_;
representation_id_builder << representation_node->instance->data().id();
representation_id_builder << representation_node->instance->as<IfcUtil::IfcBaseEntity>()->id();
IfcGeom::Representation::BRep* shape;
IfcGeom::ConversionResults shapes;
@@ -137,7 +137,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
}
if (material_style_applied) {
representation_id_builder << "-material-" << single_material->data().id();
representation_id_builder << "-material-" << single_material->id();
}
if (settings_.get<ifcopenshell::geometry::settings::ForceSpaceTransparency>().has() && product->declaration().is("IfcSpace")) {
@@ -153,7 +153,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
try {
IfcUtil::IfcBaseEntity* parent_object = mapping_->get_decomposing_entity(product);
if (parent_object) {
parent_id = parent_object->data().id();
parent_id = parent_object->id();
}
} catch (const std::exception& e) {
Logger::Error(e);
@@ -171,7 +171,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
if (!settings_.get<ifcopenshell::geometry::settings::DisableOpeningSubtractions>().get() && openings && openings->size()) {
representation_id_builder << "-openings";
for (auto it = openings->begin(); it != openings->end(); ++it) {
representation_id_builder << "-" << (*it)->data().id();
representation_id_builder << "-" << (*it)->id();
}
IfcGeom::ConversionResults opened_shapes;
@@ -236,19 +236,19 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe
// IfcShapeRepresentation.
const IfcUtil::IfcBaseEntity *representation = representation_node->instance->as<IfcUtil::IfcBaseEntity>();
auto representation_identifier = representation->get("RepresentationIdentifier");
if (!representation_identifier->isNull()) {
context_string = (std::string) *representation_identifier;
if (!representation_identifier.isNull()) {
context_string = (std::string) representation_identifier;
}
else {
IfcUtil::IfcBaseClass *context = (IfcUtil::IfcBaseClass *) *representation->get("ContextOfItems");
IfcUtil::IfcBaseClass *context = (IfcUtil::IfcBaseClass*)representation->get("ContextOfItems");
auto context_type = context->as<IfcUtil::IfcBaseEntity>()->get("ContextType");
if (!context_type->isNull()) {
context_string = (std::string) *context_type;
if (!context_type.isNull()) {
context_string = (std::string)context_type;
}
}
auto elem = new IfcGeom::BRepElement(
product->data().id(),
product->id(),
parent_id,
name,
product_type,
@@ -340,7 +340,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process
try {
IfcUtil::IfcBaseEntity* parent_object = mapping_->get_decomposing_entity(product);
if (parent_object) {
parent_id = parent_object->data().id();
parent_id = parent_object->id();
}
} catch (const std::exception& e) {
Logger::Error(e);
@@ -352,7 +352,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process
const std::string context_string = brep->context();
return new IfcGeom::BRepElement(
product->data().id(),
product->id(),
parent_id,
name,
product_type,
+1 -1
View File
@@ -80,7 +80,7 @@ inline namespace settings {
class SerializerSettings : public SettingsContainer <
// @todo should we use tuple_cat here to unify the settings into a single class?
std::tuple<UseElementNames, UseElementGuids, UseElementStepIds, UseMaterialNames, UseElementTypes, UseYUp, WriteGltfEcef, FloatingPointDigits>
std::tuple<UseElementNames, UseElementGuids, UseElementStepIds, UseElementTypes, UseYUp, WriteGltfEcef, FloatingPointDigits>
>
{};
+5 -5
View File
@@ -73,12 +73,12 @@ namespace IfcGeom {
friend bool operator < (const Element& element1, const Element& element2) {
if (element1.type() == "IfcBuildingStorey" && element2.type() == "IfcBuildingStorey") {
size_t attr_index = element1.product()->declaration().attribute_index("Elevation");
Argument* elev_attr1 = element1.product()->data().getArgument(attr_index);
Argument* elev_attr2 = element2.product()->data().getArgument(attr_index);
auto elev_attr1 = element1.product()->data().get_attribute_value(attr_index);
auto elev_attr2 = element2.product()->data().get_attribute_value(attr_index);
if (!elev_attr1->isNull() && !elev_attr2->isNull()) {
double elev1 = *elev_attr1;
double elev2 = *elev_attr2;
if (!elev_attr1.isNull() && !elev_attr2.isNull()) {
double elev1 = elev_attr1;
double elev2 = elev_attr2;
return elev1 < elev2;
}
+4 -4
View File
@@ -76,7 +76,7 @@ namespace IfcGeom {
// schema.
// @todo pass settings
ifcopenshell::geometry::Settings s;
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->data().file, s);
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->file_, s);
while ((parent = mapping->get_decomposing_entity(current, traverse_openings)) != nullptr) {
if (pred(parent)) {
return true;
@@ -138,7 +138,7 @@ namespace IfcGeom {
std::string value(IfcUtil::IfcBaseEntity* prod) const {
try {
return (std::string) *prod->get(attribute_name);
return (std::string) prod->get(attribute_name);
} catch (...) {
// Either
// (a) not an attribute name for this entity instance
@@ -184,7 +184,7 @@ namespace IfcGeom {
bool match(IfcUtil::IfcBaseEntity* prod) const {
// @todo
ifcopenshell::geometry::Settings s;
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->data().file, s);
static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod->file_, s);
layer_map_t layers = mapping->get_layers(prod);
return std::find_if(layers.begin(), layers.end(), wildcards_match(values)) != layers.end();
}
@@ -255,7 +255,7 @@ namespace IfcGeom {
, instance_ids_(instance_ids) {}
bool match(IfcUtil::IfcBaseEntity* prod) const {
return instance_ids_.find(prod->data().id()) != instance_ids_.end();
return instance_ids_.find(prod->id()) != instance_ids_.end();
}
bool operator()(IfcUtil::IfcBaseEntity* prod) const {
+1 -1
View File
@@ -154,7 +154,7 @@ IfcGeom::Representation::Serialization::Serialization(const BRep& brep)
surface_styles_.push_back(clr(1));
surface_styles_.push_back(clr(2));
sid = it->Style().instance ? it->Style().instance->data().id() : -1;
sid = it->Style().instance ? it->Style().instance->as<IfcUtil::IfcBaseEntity>()->id() : -1;
} else {
surface_styles_.push_back(-1.);
surface_styles_.push_back(-1.);
+37 -14
View File
@@ -88,8 +88,15 @@
namespace {
struct geometry_conversion_result {
int index;
// For NoParallelMapping==true
ifcopenshell::geometry::taxonomy::ptr item;
std::vector<std::pair<const IfcUtil::IfcBaseEntity*, ifcopenshell::geometry::taxonomy::matrix4::ptr>> products;
// For NoParallelMapping==false
IfcUtil::IfcBaseEntity* representation;
aggregate_of_instance::ptr products_2;
std::vector<IfcGeom::BRepElement*> breps;
std::vector<IfcGeom::Element*> elements;
};
@@ -199,20 +206,26 @@ namespace IfcGeom {
for (auto& task : reps) {
geometry_conversion_result res;
res.item = converter_->mapping()->map(task.representation);
if (!res.item) {
continue;
res.index = task.index;
if (!settings_.get<ifcopenshell::geometry::settings::NoParallelMapping>().get()) {
res.representation = task.representation;
res.products_2 = task.products;
} else {
res.item = converter_->mapping()->map(task.representation);
if (!res.item) {
continue;
}
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>(), ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::geom_item>(prod_item)->matrix);
});
}
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>(), ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::geom_item>(prod_item)->matrix);
});
tasks_.push_back(res);
}
size_t num_products = 0;
for (auto& r : tasks_) {
num_products += r.products.size();
num_products += !settings_.get<ifcopenshell::geometry::settings::NoParallelMapping>().get() ? r.products_2->size() : r.products.size();
}
time_points[2] = high_resolution_clock::now();
@@ -510,7 +523,17 @@ namespace IfcGeom {
ifcopenshell::geometry::Settings settings,
geometry_conversion_result* rep)
{
auto representation = rep->item;
if (!settings_.get<ifcopenshell::geometry::settings::NoParallelMapping>().get()) {
rep->item = kernel->mapping()->map(rep->representation);
if (!rep->item) {
return;
}
std::transform(rep->products_2->begin(), rep->products_2->end(), std::back_inserter(rep->products), [this, &rep, kernel](IfcUtil::IfcBaseClass* prod) {
auto prod_item = kernel->mapping()->map(prod);
return std::make_pair(prod->as<IfcUtil::IfcBaseEntity>(), ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::geom_item>(prod_item)->matrix);
});
} else {
}
auto product_node = rep->products.front();
const IfcUtil::IfcBaseEntity* product = product_node.first;
@@ -518,8 +541,8 @@ namespace IfcGeom {
Logger::SetProduct(product);
IfcGeom::BRepElement* brep = static_cast<IfcGeom::BRepElement*>(decorate_with_cache_(GeometrySerializer::READ_BREP, (std::string)*product->get("GlobalId"), std::to_string(representation->instance->data().id()), [kernel, settings, product, place, representation]() {
return kernel->create_brep_for_representation_and_product(representation, product, place);
IfcGeom::BRepElement* brep = static_cast<IfcGeom::BRepElement*>(decorate_with_cache_(GeometrySerializer::READ_BREP, (std::string)product->get("GlobalId"), std::to_string(rep->item->instance->as<IfcUtil::IfcBaseEntity>()->id()), [kernel, settings, product, place, rep]() {
return kernel->create_brep_for_representation_and_product(rep->item, product, place);
}));
if (!brep) {
@@ -539,7 +562,7 @@ namespace IfcGeom {
const IfcUtil::IfcBaseEntity* product2 = p.first;
const auto& place2 = p.second;
IfcGeom::BRepElement* brep2 = static_cast<IfcGeom::BRepElement*>(decorate_with_cache_(GeometrySerializer::READ_BREP, (std::string)*product2->get("GlobalId"), std::to_string(representation->instance->data().id()), [kernel, settings, product2, place2, representation, brep]() {
IfcGeom::BRepElement* brep2 = static_cast<IfcGeom::BRepElement*>(decorate_with_cache_(GeometrySerializer::READ_BREP, (std::string)product2->get("GlobalId"), std::to_string(rep->item->instance->as<IfcUtil::IfcBaseEntity>()->id()), [kernel, settings, product2, place2, brep]() {
return kernel->create_brep_for_processed_representation(product2, place2, brep);
}));
if (brep2) {
@@ -746,13 +769,13 @@ namespace IfcGeom {
instance_type = ifc_product->declaration().name();
if (ifc_product->declaration().is("IfcRoot")) {
product_guid = (std::string) *ifc_product->get("GlobalId");
product_guid = (std::string) ifc_product->get("GlobalId");
product_name = ifc_product->get_value<std::string>("Name", "");
}
auto parent_object = converter_->mapping()->get_decomposing_entity(ifc_product);
if (parent_object) {
parent_id = parent_object->data().id();
parent_id = parent_object->id();
}
// fails in case of IfcProject
+2
View File
@@ -30,8 +30,10 @@ namespace geometry {
Settings settings_;
bool use_caching_ = true;
public:
abstract_mapping(Settings& s) : settings_(s) {}
virtual ~abstract_mapping() {}
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;
@@ -39,7 +39,7 @@
#ifdef IFOPSH_SIMPLE_KERNEL
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#define Kernel_ SimpleKernel_
#define CgalShape SimpleCgalShape
@@ -55,7 +55,7 @@
#define cgal_vertex_descriptor_t cgal_simple_vertex_descriptor_t
#define cgal_face_descriptor_t cgal_simple_face_descriptor_t
typedef CGAL::Simple_cartesian<double> Kernel_;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_;
#else
+25 -17
View File
@@ -215,7 +215,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
if (bound->external.get_value_or(false)) num_outer_bounds++;
}
if (num_outer_bounds != 1 && num_outer_bounds != face->children.size()) {
if (face->children.size() > 1 && num_outer_bounds > 1 && face->children.size() != num_outer_bounds) {
Logger::Message(Logger::LOG_ERROR, "Invalid configuration of boundaries for:", face->instance);
return false;
}
@@ -224,7 +224,8 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
for (auto& bound : face->children) {
const bool is_interior = !bound->external.get_value_or(false);
const bool is_interior = !(bound->external.get_value_or(false) || face->children.size() == 1);
// single face bound is always external... even if not marked as such
cgal_wire_t wire;
if (!convert(bound, wire)) {
@@ -244,7 +245,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
}
}
if (num_outer_bounds == 1) {
if (num_outer_bounds == 1 || face->children.size() == 1) {
result.push_back(mf);
}
@@ -297,7 +298,7 @@ namespace {
};
void evaluate_curve(const taxonomy::line::ptr& c, double u, taxonomy::point3& p) {
Eigen::Vector4d xy{ u, 0, 0, 1. };
Eigen::Vector4d xy{ 0, 0, u, 1. };
p.components() = (c->matrix->ccomponents() * xy).head<3>();
}
@@ -314,7 +315,7 @@ namespace {
// ----
void project_onto_curve(const taxonomy::line::ptr& c, const taxonomy::point3& p, double& u) {
u = (c->matrix->ccomponents().inverse() * p.ccomponents().homogeneous())(0);
u = (c->matrix->ccomponents().inverse() * p.ccomponents().homogeneous())(2);
}
void project_onto_curve(const taxonomy::circle::ptr& c, const taxonomy::point3& p, double& u) {
@@ -427,11 +428,19 @@ namespace {
}
void operator()(const taxonomy::trimmed_curve::ptr& e) {
auto e_basis = e->basis;
while (e_basis->kind() == taxonomy::EDGE && e_basis->instance && e_basis->instance->declaration().name() == "IfcTrimmedCurve") {
// @todo we still might have something to wrt orientation on periodic curves
// to make sure we select the correct arc later on.
e_basis = taxonomy::cast<taxonomy::edge>(e_basis)->basis;
}
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->curve_sense.get_value_or(true)) {
std::swap(v1.u, v2.u);
}
@@ -440,7 +449,7 @@ namespace {
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(e->basis, v);
this->points = v.points;
if (!e->orientation.get_value_or(true)) {
if (!e->curve_sense.get_value_or(true)) {
std::reverse(this->points.begin(), this->points.end());
}
}
@@ -652,20 +661,19 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
for (auto& e : loop->children) {
std::vector<taxonomy::point3> edge;
if (e->basis) {
if (e->basis && e->basis->kind() != taxonomy::LINE) {
convert_curve(settings_, e, edge);
if (!e->curve_sense.get_value_or(true)) {
std::reverse(edge.begin(), edge.end());
}
} else {
edge = {
*boost::get<taxonomy::point3::ptr>(e->start),
*boost::get<taxonomy::point3::ptr>(e->end)
};
}
if (!e->orientation.get_value_or(true)) {
std::reverse(edge.begin(), edge.end());
}
extend_wire(points, edge);
}
@@ -767,7 +775,7 @@ bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResult
return false;
}
results.emplace_back(ConversionResult(
shell->instance->data().id(),
shell->instance->as<IfcUtil::IfcBaseEntity>()->id(),
shell->matrix,
new CgalShape(shape),
shell->surface_style
@@ -788,7 +796,7 @@ bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResult
return false;
}
results.emplace_back(ConversionResult(
solid->instance->data().id(),
solid->instance->as<IfcUtil::IfcBaseEntity>()->id(),
solid->matrix,
new CgalShape(shape),
solid->surface_style
@@ -840,7 +848,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
CGAL::Nef_polyhedron_3<Kernel_> a;
if (!preprocess_boolean_operand(entity, {}, {}, {}, entity_shape, a, PP_NONE /*PP_UNIFY_PLANES_INTERNALLY*/)) {
continue;
return false;
}
first_operands_nef.push_back(a);
@@ -938,7 +946,7 @@ bool CgalKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, Conversi
return false;
}
results.emplace_back(ConversionResult(
extrusion->instance->data().id(),
extrusion->instance->as<IfcUtil::IfcBaseEntity>()->id(),
extrusion->matrix,
new CgalShape(shape),
extrusion->surface_style
@@ -1814,7 +1822,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
}
return ConversionResult(
br->instance->data().id(),
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
br->matrix,
new CgalShape(shp),
br->surface_style ? br->surface_style : first_item_style
@@ -2047,7 +2055,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
}
results.emplace_back(ConversionResult(
br->instance->data().id(),
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
br->matrix,
new CgalShape(a_poly),
br->surface_style ? br->surface_style : first_item_style
@@ -408,7 +408,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
TopoDS_Shape shape = BRepPrimAPI_MakeRevol(face, ax);
results.emplace_back(ConversionResult(
r->instance->data().id(),
r->instance->as<IfcUtil::IfcBaseEntity>()->id(),
r->matrix,
new OpenCascadeShape(shape),
r->surface_style
@@ -107,7 +107,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
if (settings_.get<settings::DisableBooleanResult>().get()) {
results.emplace_back(IfcGeom::ConversionResult(
(int)br->instance->data().id(),
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
br->matrix,
new OpenCascadeShape(a),
br->surface_style ? br->surface_style : first_item_style
@@ -189,7 +189,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
}
results.emplace_back(IfcGeom::ConversionResult(
(int) br->instance->data().id(),
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
br->matrix,
new OpenCascadeShape(a),
br->surface_style ? br->surface_style : first_item_style
@@ -78,7 +78,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, I
}
results.emplace_back(ConversionResult(
extrusion->instance->data().id(),
extrusion->instance->as<IfcUtil::IfcBaseEntity>()->id(),
extrusion->matrix,
new OpenCascadeShape(shape),
extrusion->surface_style
+1 -1
View File
@@ -528,7 +528,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::face::ptr face, IfcGeom::Co
return false;
}
results.emplace_back(ConversionResult(
face->instance->data().id(),
face->instance->as<IfcUtil::IfcBaseEntity>()->id(),
new OpenCascadeShape(shape),
face->surface_style
));
+1 -1
View File
@@ -113,7 +113,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::loft::ptr loft, IfcGeom::Co
return false;
}
results.emplace_back(ConversionResult(
loft->instance->data().id(),
loft->instance->as<IfcUtil::IfcBaseEntity>()->id(),
loft->matrix,
new OpenCascadeShape(shape),
loft->surface_style
+2 -2
View File
@@ -363,7 +363,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::loop::ptr loop, IfcGeom::Co
}
results.emplace_back(ConversionResult(
loop->instance->data().id(),
loop->instance->as<IfcUtil::IfcBaseEntity>()->id(),
new OpenCascadeShape(shape),
loop->surface_style
));
@@ -374,7 +374,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::edge::ptr edge, IfcGeom::Co
TopoDS_Wire shape = boost::get<TopoDS_Wire>(convert_curve(edge));
results.emplace_back(ConversionResult(
edge->instance->data().id(),
edge->instance->as<IfcUtil::IfcBaseEntity>()->id(),
new OpenCascadeShape(shape),
edge->surface_style
));
+1 -1
View File
@@ -112,7 +112,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::
return false;
}
results.emplace_back(ConversionResult(
shell->instance->data().id(),
shell->instance->as<IfcUtil::IfcBaseEntity>()->id(),
shell->matrix,
new OpenCascadeShape(shape),
shell->surface_style
+1 -1
View File
@@ -107,7 +107,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::
return false;
}
results.emplace_back(ConversionResult(
solid->instance->data().id(),
solid->instance->as<IfcUtil::IfcBaseEntity>()->id(),
solid->matrix,
new OpenCascadeShape(shape),
solid->surface_style
@@ -148,7 +148,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs,
return false;
}
results.emplace_back(ConversionResult(
scs->instance->data().id(),
scs->instance->as<IfcUtil::IfcBaseEntity>()->id(),
scs->matrix,
new OpenCascadeShape(shape),
scs->surface_style
+1 -1
View File
@@ -85,7 +85,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) {
}
if (pwfs.empty()) {
aggregate_of_instance::ptr profile = inst->data().getInverse(&IfcSchema::IfcProfileDef::Class(), -1);
aggregate_of_instance::ptr profile = inst->file_->getInverse(inst->id(), &IfcSchema::IfcProfileDef::Class(), -1);
const bool force_close = profile && profile->size() > 0;
loop->closed = force_close;
loop->instance = inst;
+1 -1
View File
@@ -67,7 +67,7 @@ double translate_if_param_value(const IfcSchema::IfcCurve* crv, IfcSchema::IfcCu
// We don't care whether length- or positive length measure.
return translate_to_length_measure(crv, *param);
} else {
return *val->data().getArgument(0);
return val->data().get_attribute_value(0);
}
}
+2 -2
View File
@@ -117,9 +117,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) {
// or trimmed segment would be whether there are other curve segments or this
// is the only one.
boost::optional<size_t> num_segments;
auto segment = inst->data().getInverse(&IfcSchema::IfcCompositeCurveSegment::Class(), -1);
auto segment = inst->file_->getInverse(inst->id(), & IfcSchema::IfcCompositeCurveSegment::Class(), -1);
if (segment->size() == 1) {
auto comp = (*segment->begin())->data().getInverse(&IfcSchema::IfcCompositeCurve::Class(), -1);
auto comp = (*segment->begin())->file_->getInverse((*segment->begin())->id(), &IfcSchema::IfcCompositeCurve::Class(), -1);
if (comp->size() == 1) {
num_segments = (*comp->begin())->as<IfcSchema::IfcCompositeCurve>()->Segments()->size();
}
+12 -12
View File
@@ -59,7 +59,7 @@ IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchem
// IfcProductRepresentation also lacks the INVERSE relation to IfcProduct
// Let's find the IfcProducts that reference the IfcProductRepresentation anyway
products->push((*it)->data().getInverse((&IfcSchema::IfcProduct::Class()), -1)->as<IfcSchema::IfcProduct>());
products->push((*it)->file_->getInverse((*it)->id(), &IfcSchema::IfcProduct::Class(), -1)->as<IfcSchema::IfcProduct>());
}
if (only_direct) {
@@ -81,13 +81,13 @@ IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchem
continue;
}
IfcSchema::IfcRepresentation::list::ptr reps = item->data().getInverse((&IfcSchema::IfcRepresentation::Class()), -1)->as<IfcSchema::IfcRepresentation>();
IfcSchema::IfcRepresentation::list::ptr reps = item->file_->getInverse(item->id(), (&IfcSchema::IfcRepresentation::Class()), -1)->as<IfcSchema::IfcRepresentation>();
for (IfcSchema::IfcRepresentation::list::it jt = reps->begin(); jt != reps->end(); ++jt) {
IfcSchema::IfcRepresentation* rep = *jt;
if (rep->Items()->size() != 1) continue;
IfcSchema::IfcProductRepresentation::list::ptr prodreps_mapped = rep->OfProductRepresentation();
for (IfcSchema::IfcProductRepresentation::list::it kt = prodreps_mapped->begin(); kt != prodreps_mapped->end(); ++kt) {
IfcSchema::IfcProduct::list::ptr ps = (*kt)->data().getInverse((&IfcSchema::IfcProduct::Class()), -1)->as<IfcSchema::IfcProduct>();
IfcSchema::IfcProduct::list::ptr ps = (*kt)->file_->getInverse((*kt)->id(), (&IfcSchema::IfcProduct::Class()), -1)->as<IfcSchema::IfcProduct>();
products->push(ps);
}
}
@@ -273,7 +273,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_product_type(const IfcUtil::IfcBaseEn
}
#endif
// Avoid segfault if RelatingType is unset.
if (rel->get("RelatingType")->isNull()){
if (rel->get("RelatingType").isNull()){
break;
return nullptr;
}
@@ -303,7 +303,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
if (associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>() || associated_material->as<IfcSchema::IfcMaterialLayerSet>()) {
IfcSchema::IfcMaterialLayerSet* layerset;
if (auto *m = associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>()) {
if (m->get("ForLayerSet")->isNull()) {
if (m->get("ForLayerSet").isNull()) {
Logger::Warning("Missing ForLayerSet for:", m);
return nullptr;
}
@@ -322,7 +322,7 @@ const IfcUtil::IfcBaseEntity* mapping::get_single_material_association(const Ifc
if (associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>() || associated_material->as<IfcSchema::IfcMaterialProfileSet>()) {
IfcSchema::IfcMaterialProfileSet* profileset;
if (auto* m = associated_material->as<IfcSchema::IfcMaterialProfileSetUsage>()) {
if (m->get("ForProfileSet")->isNull()) {
if (m->get("ForProfileSet").isNull()) {
Logger::Warning("Missing ForProfileSet for:", m);
return nullptr;
}
@@ -523,7 +523,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial* material) {
material_style->name = material->Name();
} else {
std::ostringstream oss;
oss << material->declaration().name() << "-" << material->data().id();
oss << material->declaration().name() << "-" << material->id();
material_style->name = oss.str();
}
return material_style;
@@ -553,7 +553,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
} else {
std::ostringstream oss;
if (shading) {
oss << shading->declaration().name() << "-" << shading->data().id();
oss << shading->declaration().name() << "-" << shading->id();
} else {
oss << "-";
}
@@ -698,8 +698,8 @@ IfcUtil::IfcBaseEntity* mapping::get_decomposing_entity(const IfcUtil::IfcBaseEn
/* Parent decompositions to the RelatingObject */
if (!parent) {
aggregate_of_instance::ptr parents = product->data().getInverse((&IfcSchema::IfcRelAggregates::Class()), -1);
parents->push(product->data().getInverse((&IfcSchema::IfcRelNests::Class()), -1));
aggregate_of_instance::ptr parents = product->file_->getInverse(product->id(), (&IfcSchema::IfcRelAggregates::Class()), -1);
parents->push(product->file_->getInverse(product->id(), (&IfcSchema::IfcRelNests::Class()), -1));
for (aggregate_of_instance::it it = parents->begin(); it != parents->end(); ++it) {
IfcSchema::IfcRelDecomposes* decompose = (*it)->as<IfcSchema::IfcRelDecomposes>();
IfcUtil::IfcBaseEntity* ifc_objectdef;
@@ -832,11 +832,11 @@ void mapping::initialize_settings() {
// See if there is a context_id filter and whether the context is selected
if (settings_.get<settings::ContextIds>().has()) {
auto cids = settings_.get<settings::ContextIds>().get();
if (cids.find(context->data().id()) == cids.end()) {
if (cids.find(context->id()) == cids.end()) {
bool selected_sub_context = false;
auto subs = context->HasSubContexts();
for (auto& sub : *subs) {
if (cids.find(context->data().id()) != cids.end()) {
if (cids.find(context->id()) != cids.end()) {
selected_sub_context = true;
break;
}
+3 -1
View File
@@ -588,7 +588,9 @@ void ifcopenshell::geometry::taxonomy::trimmed_curve::print(std::ostream& o, int
}
if (this->instance) {
o << std::string(indent + 4, ' ') << this->instance->data().toString() << std::endl;
std::ostringstream oss;
this->instance->as<IfcUtil::IfcBaseClass>()->toString(oss);
o << std::string(indent + 4, ' ') << oss.str() << std::endl;
}
}