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
+3 -3
View File
@@ -194,7 +194,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
// The matrix attribute of an entity is basically a 4x3 representation of its ObjectPlacement.
// Note that this placement is absolute, ie it is multiplied with all parent placements.
auto transformation_towrite = transformation.data().ccomponents();
auto transformation_towrite = transformation.data()->ccomponents();
// If this is not the first parent, get the relative placement
if (parentNodes.size() > 0)
@@ -238,7 +238,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::
const IfcGeom::Transformation& parent_trsf = parent.transformation();
auto transformation_towrite = parent_trsf.data().ccomponents();
auto transformation_towrite = parent_trsf.data()->ccomponents();
// If this is not the first parent, get the relative placement
if (parentNodes.size() > 0) {
@@ -268,7 +268,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::
current_node->addMatrix(matrix_array);
// Add the node to the parent stack
matrixStack.push(ifcopenshell::geometry::taxonomy::matrix4(parent_trsf.data().ccomponents().inverse()));
matrixStack.push(ifcopenshell::geometry::taxonomy::matrix4(parent_trsf.data()->ccomponents().inverse()));
parentNodes.push(current_node);
serializer->parentStackId.push(parent.id());
}
+1 -1
View File
@@ -164,7 +164,7 @@ void GltfSerializer::write(const IfcGeom::TriangulationElement* o) {
node_array_.push_back(json_["nodes"].size());
const auto& m = o->transformation().data().ccomponents();
const auto& m = o->transformation().data()->ccomponents();
// nb: note that this contains the Y-UP transform as well.
// @todo check
const std::array<double, 16> matrix_flat = {
+8 -8
View File
@@ -274,12 +274,12 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g
std::string context = read_scalar_attribute<std::string>(element_group, "context");
std::string unique_id = read_scalar_attribute<std::string>(element_group, "unique_id");
ifcopenshell::geometry::taxonomy::matrix4 trsf;
auto trsf = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>();
auto placeds = element_group.openDataSet(DATASET_NAME_PLACEMENT);
double m44[4][4];
placeds.read(m44, H5::PredType::NATIVE_DOUBLE);
// @todo check
trsf.components() << Eigen::Map<Eigen::Matrix4d>(&m44[0][0]);
trsf->components() << Eigen::Map<Eigen::Matrix4d>(&m44[0][0]);
auto representation_group = element_group.openGroup(representation_id_str);
std::string geom_id = read_scalar_attribute<std::string>(representation_group, "geom_id");
@@ -348,10 +348,10 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g
TopoDS_Shape shp = read_shape(part.shape_serialization);
// @todo check
ifcopenshell::geometry::taxonomy::matrix4 matrix;
matrix.components() << Eigen::Map<Eigen::Matrix4d>(&part.matrix[0][0]);
auto matrix = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>();
matrix->components() << Eigen::Map<Eigen::Matrix4d>(&part.matrix[0][0]);
auto style_ptr = new ifcopenshell::geometry::taxonomy::style;
auto style_ptr = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::style>();
read_surface_style(part.surface_style, *style_ptr);
shapes.push_back(IfcGeom::ConversionResult(part.id, matrix, new ifcopenshell::geometry::OpenCascadeShape(shp), style_ptr));
@@ -362,7 +362,7 @@ IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& g
for (IfcGeom::ConversionResults::iterator it = shapes.begin(); it != shapes.end(); ++it) {
it->prepend(trsf);
}
trsf = ifcopenshell::geometry::taxonomy::matrix4();
trsf = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>();
}
brep_geometry = boost::shared_ptr<IfcGeom::Representation::BRep>(new IfcGeom::Representation::BRep(element_settings, geom_id, shapes));
@@ -487,7 +487,7 @@ H5::Group HdfSerializer::write(const IfcGeom::Element* o) {
H5::DataSpace dataspace_4x4(2, dims_4x4);
auto placement_dataset = element_group.createDataSet(DATASET_NAME_PLACEMENT, H5::PredType::NATIVE_DOUBLE, dataspace_4x4);
const auto& m = o->transformation().data().ccomponents();
const auto& m = o->transformation().data()->ccomponents();
// @todo check, is this needed, can we use the storage of Eigen?
double m44[4][4] = {
{ m(0,0), m(1,0), m(2,0), m(3,0) },
@@ -580,7 +580,7 @@ void HdfSerializer::write(const IfcGeom::BRepElement* o) {
size_t i = 0;
for (auto it = o->geometry().begin(); it != o->geometry().end(); ++it, ++i) {
parts[i].id = it->ItemId();
const auto& m = o->transformation().data().ccomponents();
const auto& m = o->transformation().data()->ccomponents();
// @todo check, is this needed, can we use the storage of Eigen?
std::array<std::array<double, 4>, 4> arr = { {
{ { m(0,0), m(1,0), m(2,0), m(3,0) } },
+7 -3
View File
@@ -584,7 +584,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement* brep_obj) {
gp_Trsf trsf;
// @todo
const auto& m = brep_obj->transformation().data().ccomponents();
const auto& m = brep_obj->transformation().data()->ccomponents();
trsf.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),
@@ -1885,7 +1885,7 @@ void SvgSerializer::addTextAnnotations(const drawing_key& k) {
if (object_type == "Text") {
auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings_);
auto item = mapping->map(*pl);
auto matrix = (ifcopenshell::geometry::taxonomy::matrix4*) item;
auto matrix = ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::matrix4>(item);
delete mapping;
if (item) {
gp_Trsf trsf;
@@ -1895,7 +1895,9 @@ void SvgSerializer::addTextAnnotations(const drawing_key& k) {
m(1, 0), m(1, 1), m(1, 2), m(1, 3),
m(2, 0), m(2, 1), m(2, 2), m(2, 3)
);
#ifdef TAXONOMY_USE_NAKED_PTR
delete matrix;
#endif
auto v = gp_Pnt(trsf.TranslationPart());
@@ -2350,12 +2352,14 @@ void SvgSerializer::setFile(IfcParse::IfcFile* f) {
IfcUtil::IfcBaseEntity* product = (IfcUtil::IfcBaseEntity*) *jt;
if (!product->get("ObjectPlacement")->isNull()) {
auto item = mapping->map(*product->get("ObjectPlacement"));
auto matrix = (ifcopenshell::geometry::taxonomy::matrix4*) item;
auto matrix = ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::matrix4>(item);
gp_Trsf trsf;
if (matrix) {
// @todo shouldn't this take into account configurable section height?
setSectionHeight(matrix->translation_part()(3) + 1.);
#ifdef TAXONOMY_USE_NAKED_PTR
delete matrix;
#endif
Logger::Warning("No building storeys encountered, used for reference:", product);
return;
}
@@ -126,7 +126,7 @@ boost::optional<std::string> format_attribute(ifcopenshell::geometry::abstract_m
} else if (e->declaration().is(IfcSchema::IfcLocalPlacement::Class())) {
IfcSchema::IfcLocalPlacement* placement = e->as<IfcSchema::IfcLocalPlacement>();
auto item = mapping->map(e);
auto matrix = (ifcopenshell::geometry::taxonomy::matrix4*) item;
auto matrix = ifcopenshell::geometry::taxonomy::cast< ifcopenshell::geometry::taxonomy::matrix4>(item);
std::stringstream stream;
for (int i = 1; i < 5; ++i) {
@@ -138,7 +138,9 @@ boost::optional<std::string> format_attribute(ifcopenshell::geometry::abstract_m
}
value = stream.str();
#ifdef TAXONOMY_USE_NAKED_PTR
delete item;
#endif
}
break; }
default: