diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 3b045f04f3..271f5c0794 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -633,24 +633,24 @@ int main(int argc, char** argv) { SerializerSettings settings; /// @todo Make APPLY_DEFAULT_MATERIALS configurable? Quickly tested setting this to false and using obj exporter caused the program to crash and burn. - settings.set(IfcGeom::IteratorSettings::APPLY_DEFAULT_MATERIALS, true); - settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, use_world_coords || output_extension == SVG || output_extension == OBJ); - settings.set(IfcGeom::IteratorSettings::WELD_VERTICES, weld_vertices); - settings.set(IfcGeom::IteratorSettings::SEW_SHELLS, orient_shells); - settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, convert_back_units); + settings.set(ifcopenshell::geometry::settings::APPLY_DEFAULT_MATERIALS, true); + settings.set(ifcopenshell::geometry::settings::USE_WORLD_COORDS, use_world_coords || output_extension == SVG || output_extension == OBJ); + settings.set(ifcopenshell::geometry::settings::WELD_VERTICES, weld_vertices); + settings.set(ifcopenshell::geometry::settings::SEW_SHELLS, orient_shells); + settings.set(ifcopenshell::geometry::settings::CONVERT_BACK_UNITS, convert_back_units); #if OCC_VERSION_HEX < 0x60900 - settings.set(IfcGeom::IteratorSettings::FASTER_BOOLEANS, merge_boolean_operands); + settings.set(ifcopenshell::geometry::settings::FASTER_BOOLEANS, merge_boolean_operands); #endif - settings.set(IfcGeom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS, disable_opening_subtractions); - settings.set(IfcGeom::IteratorSettings::INCLUDE_CURVES, include_plan); - settings.set(IfcGeom::IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES, !include_model); - settings.set(IfcGeom::IteratorSettings::APPLY_LAYERSETS, enable_layerset_slicing); - settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals); - settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs); - settings.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, use_element_hierarchy || output_extension == SVG); - settings.set(IfcGeom::IteratorSettings::SITE_LOCAL_PLACEMENT, site_local_placement); - settings.set(IfcGeom::IteratorSettings::BUILDING_LOCAL_PLACEMENT, building_local_placement); - settings.set(IfcGeom::IteratorSettings::VALIDATE_QUANTITIES, validate); + settings.set(ifcopenshell::geometry::settings::DISABLE_OPENING_SUBTRACTIONS, disable_opening_subtractions); + settings.set(ifcopenshell::geometry::settings::INCLUDE_CURVES, include_plan); + settings.set(ifcopenshell::geometry::settings::EXCLUDE_SOLIDS_AND_SURFACES, !include_model); + settings.set(ifcopenshell::geometry::settings::APPLY_LAYERSETS, enable_layerset_slicing); + settings.set(ifcopenshell::geometry::settings::NO_NORMALS, no_normals); + settings.set(ifcopenshell::geometry::settings::GENERATE_UVS, generate_uvs); + settings.set(ifcopenshell::geometry::settings::SEARCH_FLOOR, use_element_hierarchy || output_extension == SVG); + settings.set(ifcopenshell::geometry::settings::SITE_LOCAL_PLACEMENT, site_local_placement); + settings.set(ifcopenshell::geometry::settings::BUILDING_LOCAL_PLACEMENT, building_local_placement); + settings.set(ifcopenshell::geometry::settings::VALIDATE_QUANTITIES, validate); settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names); settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids); @@ -682,7 +682,7 @@ int main(int argc, char** argv) { #endif serializer = boost::make_shared(IfcUtil::path::to_utf8(output_temp_filename), settings); } else if (output_extension == SVG) { - settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); + settings.set(ifcopenshell::geometry::settings::DISABLE_TRIANGULATION, true); serializer = boost::make_shared(IfcUtil::path::to_utf8(output_temp_filename), settings); if (vmap.count("section-height") != 0) { Logger::Notice("Overriding section height"); @@ -719,7 +719,7 @@ int main(int argc, char** argv) { Logger::Notice("Centering/offsetting model setting ignored when writing non-tesselated output"); } - settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); + settings.set(ifcopenshell::geometry::settings::DISABLE_TRIANGULATION, true); } if (!serializer->ready()) { @@ -749,7 +749,7 @@ int main(int argc, char** argv) { Logger::SetOutput(quiet ? nullptr : &cout_, &log_stream); - IfcGeom::Iterator context_iterator(settings, ifc_file, filter_funcs, geometry_kernel, num_threads); + ifcopenshell::geometry::Iterator context_iterator(geometry_kernel, settings, ifc_file, filter_funcs, num_threads); if (!context_iterator.initialize()) { /// @todo It would be nice to know and print separate error prints for a case where we found no entities /// and for a case we found no entities that satisfy our filtering criteria. @@ -823,15 +823,15 @@ int main(int argc, char** argv) { size_t num_created = 0; do { - IfcGeom::Element *geom_object = context_iterator.get(); + ifcopenshell::geometry::Element* geom_object = context_iterator.get(); if (is_tesselated) { - serializer->write(static_cast*>(geom_object)); + serializer->write(static_cast(geom_object)); } else { - serializer->write(static_cast*>(geom_object)); + serializer->write(static_cast(geom_object)); } if (!no_progress) { @@ -1219,14 +1219,14 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std } } - IfcGeom::IteratorSettings settings; - settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, false); - settings.set(IfcGeom::IteratorSettings::WELD_VERTICES, false); - settings.set(IfcGeom::IteratorSettings::SEW_SHELLS, true); - settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, true); - settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); + ifcopenshell::geometry::settings settings; + settings.set(ifcopenshell::geometry::settings::USE_WORLD_COORDS, false); + settings.set(ifcopenshell::geometry::settings::WELD_VERTICES, false); + settings.set(ifcopenshell::geometry::settings::SEW_SHELLS, true); + settings.set(ifcopenshell::geometry::settings::CONVERT_BACK_UNITS, true); + settings.set(ifcopenshell::geometry::settings::DISABLE_TRIANGULATION, true); - IfcGeom::Iterator context_iterator(settings, &f); + ifcopenshell::geometry::Iterator context_iterator(settings, &f); if (!context_iterator.initialize()) { return; @@ -1260,14 +1260,14 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std IfcUtil::IfcBaseClass* quantity = nullptr; IfcEntityList::ptr objects; - boost::shared_ptr previous_geometry_pointer; + boost::shared_ptr previous_geometry_pointer; for (;; ++num_created) { bool has_more = true; if (num_created) { has_more = context_iterator.next(); } - IfcGeom::NativeElement* geom_object = nullptr; + ifcopenshell::geometry::NativeElement* geom_object = nullptr; if (has_more) { geom_object = context_iterator.get_native(); } diff --git a/src/ifcgeom/schema_agnostic/ConversionResult.h b/src/ifcgeom/schema_agnostic/ConversionResult.h index ec88055893..cd967a6eee 100644 --- a/src/ifcgeom/schema_agnostic/ConversionResult.h +++ b/src/ifcgeom/schema_agnostic/ConversionResult.h @@ -30,6 +30,9 @@ namespace ifcopenshell { namespace geometry { class IFC_GEOM_API Triangulation; } + // @todo, this class is no longer necessary, we can directly use + // taxonomy::matrix4, which does not need to be implemented specifically + // in the respective kernels class IFC_GEOM_API ConversionResultPlacement { public: virtual void Multiply(const ConversionResultPlacement*) = 0; diff --git a/src/ifcgeom/schema_agnostic/IfcGeomIteratorImplementation.h b/src/ifcgeom/schema_agnostic/IfcGeomIterator.h similarity index 96% rename from src/ifcgeom/schema_agnostic/IfcGeomIteratorImplementation.h rename to src/ifcgeom/schema_agnostic/IfcGeomIterator.h index 85d436644b..c6febd30e1 100644 --- a/src/ifcgeom/schema_agnostic/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/schema_agnostic/IfcGeomIterator.h @@ -194,8 +194,8 @@ namespace ifcopenshell { namespace geometry { int done; int total; - std::string unit_name; - double unit_magnitude; + std::string unit_name_; + double unit_magnitude_; gp_XYZ bounds_min_; gp_XYZ bounds_max_; @@ -205,6 +205,9 @@ namespace ifcopenshell { namespace geometry { /// @todo public/private sections all over the place: move all public to the beginning of the class public: + const std::string& unit_name() const { return unit_name_; } + const double unit_magnitude() const { return unit_magnitude_; } + bool initialize() { converter_->mapping()->get_representations(tasks_, filters_, settings_); @@ -357,10 +360,10 @@ namespace ifcopenshell { namespace geometry { } } - const std::string& getUnitName() const { return unit_name; } + const std::string& getUnitName() const { return unit_name_; } /// @note Double always as per IFC specification. - double getUnitMagnitude() const { return unit_magnitude; } + double getUnitMagnitude() const { return unit_magnitude_; } std::string getLog() const { return Logger::GetLog(); } @@ -418,6 +421,10 @@ namespace ifcopenshell { namespace geometry { if (task_result_index_ == all_processed_elements_.size()) { return create(); } + if (task_result_index_ == all_processed_elements_.size()) { + return nullptr; + } + return all_processed_elements_[task_result_index_]->product(); } } @@ -563,8 +570,8 @@ namespace ifcopenshell { namespace geometry { } private: void _initialize() { - unit_name = "METER"; - unit_magnitude = 1.f; + unit_name_ = "METER"; + unit_magnitude_ = 1.f; // @todo @@ -585,7 +592,7 @@ namespace ifcopenshell { namespace geometry { bool owns_ifc_file; public: - Iterator(const std::string& geometry_library, const settings& settings, IfcParse::IfcFile* file, const std::vector& filters, int num_threads) + Iterator(const std::string& geometry_library, const settings& settings, IfcParse::IfcFile* file, const std::vector& filters, int num_threads = 1) : settings_(settings) , ifc_file(file) , filters_(filters) @@ -596,6 +603,16 @@ namespace ifcopenshell { namespace geometry { _initialize(); } + Iterator(const settings& settings, IfcParse::IfcFile* file, int num_threads = 1) + : settings_(settings) + , ifc_file(file) + , owns_ifc_file(false) + , num_threads_(num_threads) + , geometry_library_("opencascade") + { + _initialize(); + } + ~Iterator() { if (owns_ifc_file) { delete ifc_file; diff --git a/src/ifcgeom/schema_agnostic/IfcGeomIteratorImplementation.cpp b/src/ifcgeom/schema_agnostic/IfcGeomIteratorImplementation.cpp deleted file mode 100644 index 6340b79d04..0000000000 --- a/src/ifcgeom/schema_agnostic/IfcGeomIteratorImplementation.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "IfcGeomIteratorImplementation.h" diff --git a/src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h b/src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h index 51680f645d..25d26150f9 100644 --- a/src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h +++ b/src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h @@ -88,9 +88,7 @@ namespace ifcopenshell { const TopoDS_Shape& shape() const { return shape_; } operator const TopoDS_Shape& () { return shape_; } - virtual void Triangulate(const settings & settings, const ConversionResultPlacement * place, Representation::Triangulation* t, int surface_style_id) const; - - virtual void Triangulate(const settings & settings, const ConversionResultPlacement * place, Representation::Triangulation* t, int surface_style_id) const; + virtual void Triangulate(const settings & settings, const ConversionResultPlacement * place, Representation::Triangulation* t, int surface_style_id) const; virtual void Serialize(std::string&) const { throw std::runtime_error("Not implemented"); diff --git a/src/serializers/IgesSerializer.h b/src/serializers/IgesSerializer.h index 77845d0116..9455f34e7f 100644 --- a/src/serializers/IgesSerializer.h +++ b/src/serializers/IgesSerializer.h @@ -42,8 +42,8 @@ public: : OpenCascadeBasedSerializer(out_filename, settings) {} virtual ~IgesSerializer() {} - void writeShape(const IfcGeom::ConversionResultShape* shape) { - writer.AddShape(*(IfcGeom::OpenCascadeShape*)shape); + void writeShape(const ifcopenshell::geometry::ConversionResultShape* shape) { + writer.AddShape(*(ifcopenshell::geometry::OpenCascadeShape*)shape); } void finalize() { writer.Write(out_filename.c_str()); diff --git a/src/serializers/OpenCascadeBasedSerializer.cpp b/src/serializers/OpenCascadeBasedSerializer.cpp index d5790a1134..89ad2dc1c6 100644 --- a/src/serializers/OpenCascadeBasedSerializer.cpp +++ b/src/serializers/OpenCascadeBasedSerializer.cpp @@ -36,19 +36,19 @@ bool OpenCascadeBasedSerializer::ready() { return succeeded; } -void OpenCascadeBasedSerializer::write(const IfcGeom::NativeElement* o) { - IfcGeom::OpenCascadeShape* occt_shape = ((IfcGeom::OpenCascadeShape*) o->geometry().as_compound()); +void OpenCascadeBasedSerializer::write(const ifcopenshell::geometry::NativeElement* o) { + ifcopenshell::geometry::OpenCascadeShape* occt_shape = ((ifcopenshell::geometry::OpenCascadeShape*) o->geometry().as_compound()); TopoDS_Shape compound = occt_shape->shape(); delete occt_shape; - if (o->geometry().settings().get(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS)) { + if (o->geometry().settings().get(ifcopenshell::geometry::settings::CONVERT_BACK_UNITS)) { gp_Trsf scale; scale.SetScaleFactor(1.0 / o->geometry().settings().unit_magnitude()); compound = BRepBuilderAPI_Transform(compound, scale, true).Shape(); } - IfcGeom::OpenCascadeShape s(compound); + ifcopenshell::geometry::OpenCascadeShape s(compound); writeShape(&s); } diff --git a/src/serializers/OpenCascadeBasedSerializer.h b/src/serializers/OpenCascadeBasedSerializer.h index 81b8bbd126..a8e72feddd 100644 --- a/src/serializers/OpenCascadeBasedSerializer.h +++ b/src/serializers/OpenCascadeBasedSerializer.h @@ -37,9 +37,9 @@ public: virtual ~OpenCascadeBasedSerializer() {} void writeHeader() {} bool ready(); - virtual void writeShape(const IfcGeom::ConversionResultShape* shape) = 0; - void write(const IfcGeom::TriangulationElement* /*o*/) {} - void write(const IfcGeom::NativeElement* o); + virtual void writeShape(const ifcopenshell::geometry::ConversionResultShape* shape) = 0; + void write(const ifcopenshell::geometry::TriangulationElement* /*o*/) {} + void write(const ifcopenshell::geometry::NativeElement* o); bool isTesselated() const { return false; } void setFile(IfcParse::IfcFile*) {} }; diff --git a/src/serializers/StepSerializer.h b/src/serializers/StepSerializer.h index 5152c5d362..b742397717 100644 --- a/src/serializers/StepSerializer.h +++ b/src/serializers/StepSerializer.h @@ -23,8 +23,6 @@ #include #include -#include "../ifcgeom/schema_agnostic/IfcGeomIterator.h" - #include "../serializers/OpenCascadeBasedSerializer.h" class StepSerializer : public OpenCascadeBasedSerializer @@ -36,10 +34,10 @@ public: : OpenCascadeBasedSerializer(out_filename, settings) {} virtual ~StepSerializer() {} - void writeShape(const IfcGeom::ConversionResultShape* shape) { + void writeShape(const ifcopenshell::geometry::ConversionResultShape* shape) { std::stringstream ss; std::streambuf *sb = std::cout.rdbuf(ss.rdbuf()); - writer.Transfer(((IfcGeom::OpenCascadeShape*)shape)->shape(), STEPControl_AsIs); + writer.Transfer(((ifcopenshell::geometry::OpenCascadeShape*)shape)->shape(), STEPControl_AsIs); std::cout.rdbuf(sb); } void finalize() { diff --git a/src/serializers/SvgSerializer.cpp b/src/serializers/SvgSerializer.cpp index 7c821dfbda..846a9bac14 100644 --- a/src/serializers/SvgSerializer.cpp +++ b/src/serializers/SvgSerializer.cpp @@ -285,7 +285,7 @@ SvgSerializer::path_object& SvgSerializer::start_path(IfcUtil::IfcBaseEntity* st return p; } -void SvgSerializer::write(const IfcGeom::NativeElement* o) +void SvgSerializer::write(const ifcopenshell::geometry::NativeElement* o) { IfcUtil::IfcBaseEntity* storey = storey_; boost::optional storey_elevation = boost::none; @@ -293,7 +293,7 @@ void SvgSerializer::write(const IfcGeom::NativeElement* o) for (const auto& p : o->parents()) { if (p->type() == "IfcBuildingStorey") { try { - const IfcGeom::ElementSettings& settings = o->geometry().settings(); + const ifcopenshell::geometry::element_settings& settings = o->geometry().settings(); double e = *p->product()->get("Elevation"); storey_elevation = e * settings.unit_magnitude(); } catch (...) { @@ -312,7 +312,8 @@ void SvgSerializer::write(const IfcGeom::NativeElement* o) path_object& p = start_path(storey, nameElement(o)); - IfcGeom::OpenCascadeShape* occt_shape = ((IfcGeom::OpenCascadeShape*) o->geometry().as_compound()); + // @todo check whether correct kernel is used + ifcopenshell::geometry::OpenCascadeShape* occt_shape = ((ifcopenshell::geometry::OpenCascadeShape*) o->geometry().as_compound()); TopoDS_Shape compound = occt_shape->shape(); delete occt_shape; @@ -443,7 +444,7 @@ void SvgSerializer::writeHeader() { svg_file << "\n"; } -std::string SvgSerializer::nameElement(const IfcGeom::Element* elem) +std::string SvgSerializer::nameElement(const ifcopenshell::geometry::Element* elem) { std::ostringstream oss; const std::string type = "product"; @@ -471,11 +472,10 @@ std::string SvgSerializer::nameElement(const IfcUtil::IfcBaseEntity* elem) { void SvgSerializer::setFile(IfcParse::IfcFile* f) { file = f; + mapping_ = ifcopenshell::geometry::impl::mapping_implementations().construct(f); + auto storeys = f->instances_by_type("IfcBuildingStorey"); if (!storeys || storeys->size() == 0) { - - IfcGeom::Kernel kernel("opencascade", f); - std::vector to_derive_from; to_derive_from.push_back(f->schema()->declaration_by_name("IfcBuilding")); to_derive_from.push_back(f->schema()->declaration_by_name("IfcSite")); @@ -485,10 +485,10 @@ void SvgSerializer::setFile(IfcParse::IfcFile* f) { for (auto jt = insts->begin(); jt != insts->end(); ++jt) { IfcUtil::IfcBaseEntity* product = (IfcUtil::IfcBaseEntity*) *jt; if (!product->get("ObjectPlacement")->isNull()) { - IfcGeom::ConversionResultPlacement* trsf; - if (kernel.convert_placement(*product->get("ObjectPlacement"), trsf)) { - double X, Y, Z; - trsf->TranslationPart(X, Y, Z); + auto item = mapping_->map(*product->get("ObjectPlacement")); + if (item) { + auto matrix = (ifcopenshell::geometry::taxonomy::matrix4*) item; + const double& Z = matrix->components(3, 2); setSectionHeight(Z + 1.); Logger::Warning("No building storeys encountered, used for reference:", product); return; diff --git a/src/serializers/SvgSerializer.h b/src/serializers/SvgSerializer.h index 2f739996a6..0bacb0437a 100644 --- a/src/serializers/SvgSerializer.h +++ b/src/serializers/SvgSerializer.h @@ -26,6 +26,7 @@ #include "../serializers/util.h" #include "../ifcparse/utils.h" +#include "../ifcgeom/abstract_mapping.h" #include #include @@ -45,6 +46,7 @@ protected: std::vector< boost::shared_ptr > radii; IfcParse::IfcFile* file; IfcUtil::IfcBaseEntity* storey_; + ifcopenshell::geometry::abstract_mapping* mapping_; public: SvgSerializer(const std::string& out_filename, const SerializerSettings& settings) : GeometrySerializer(settings) @@ -63,8 +65,8 @@ public: void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; } void writeHeader(); bool ready(); - void write(const IfcGeom::TriangulationElement* /*o*/) {} - void write(const IfcGeom::NativeElement* o); + void write(const ifcopenshell::geometry::TriangulationElement* /*o*/) {} + void write(const ifcopenshell::geometry::NativeElement* o); void write(path_object& p, const TopoDS_Wire& wire); path_object& start_path(IfcUtil::IfcBaseEntity* storey, const std::string& id); bool isTesselated() const { return false; } @@ -73,7 +75,7 @@ public: void setFile(IfcParse::IfcFile* f); void setBoundingRectangle(double width, double height); void setSectionHeight(double h, IfcUtil::IfcBaseEntity* storey = 0) { section_height = h; storey_ = storey; } - std::string nameElement(const IfcGeom::Element* elem); + std::string nameElement(const ifcopenshell::geometry::Element* elem); std::string nameElement(const IfcUtil::IfcBaseEntity* elem); }; diff --git a/src/serializers/WavefrontObjSerializer.cpp b/src/serializers/WavefrontObjSerializer.cpp index 102acab022..1297e37353 100644 --- a/src/serializers/WavefrontObjSerializer.cpp +++ b/src/serializers/WavefrontObjSerializer.cpp @@ -58,38 +58,39 @@ void WaveFrontOBJSerializer::writeHeader() { mtl_stream << "# File generated by IfcOpenShell " << IFCOPENSHELL_VERSION << "\n"; } -void WaveFrontOBJSerializer::writeMaterial(const IfcGeom::Material& style) +void WaveFrontOBJSerializer::writeMaterial(const ifcopenshell::geometry::taxonomy::style& style) { - std::string material_name = (settings().get(SerializerSettings::USE_MATERIAL_NAMES) - ? style.original_name() : style.name()); + // @todo original_name + std::string material_name = *(settings().get(SerializerSettings::USE_MATERIAL_NAMES) + ? style.name : style.name); IfcUtil::sanitate_material_name(material_name); mtl_stream << "newmtl " << material_name << "\n"; - if (style.hasDiffuse()) { - const double* diffuse = style.diffuse(); + if (style.diffuse) { + auto diffuse = style.diffuse->components; mtl_stream << "Kd " << diffuse[0] << " " << diffuse[1] << " " << diffuse[2] << "\n"; } - if (style.hasSpecular()) { - const double* specular = style.specular(); + if (style.specular) { + auto specular = style.specular->components; mtl_stream << "Ks " << specular[0] << " " << specular[1] << " " << specular[2] << "\n"; } - if (style.hasSpecularity()) { - mtl_stream << "Ns " << style.specularity() << "\n"; + if (style.specularity) { + mtl_stream << "Ns " << *style.specularity << "\n"; } - if (style.hasTransparency()) { - const double transparency = 1.0 - style.transparency(); + if (style.transparency) { + const double transparency = 1.0 - *style.transparency; if (transparency < 1) { mtl_stream << "d " << transparency << "\n"; } } } -void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o) +void WaveFrontOBJSerializer::write(const ifcopenshell::geometry::TriangulationElement* o) { obj_stream << "g " << object_id(o) << "\n"; obj_stream << "s 1" << "\n"; - const IfcGeom::Representation::Triangulation& mesh = o->geometry(); + const ifcopenshell::geometry::Representation::Triangulation& mesh = o->geometry(); const int vcount = (int)mesh.verts().size() / 3; for ( std::vector::const_iterator it = mesh.verts().begin(); it != mesh.verts().end(); ) { @@ -121,9 +122,10 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* const int material_id = *(material_it++); if (material_id != previous_material_id) { - const IfcGeom::Material& material = mesh.materials()[material_id]; - std::string material_name = (settings().get(SerializerSettings::USE_MATERIAL_NAMES) - ? material.original_name() : material.name()); + const ifcopenshell::geometry::taxonomy::style& material = mesh.materials()[material_id]; + // @todo original_name + std::string material_name = *(settings().get(SerializerSettings::USE_MATERIAL_NAMES) + ? material.name : material.name); IfcUtil::sanitate_material_name(material_name); obj_stream << "usemtl " << material_name << "\n"; if (materials.find(material_name) == materials.end()) { @@ -165,9 +167,10 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* const int material_id = *(material_it++); if (material_id != previous_material_id) { - const IfcGeom::Material& material = mesh.materials()[material_id]; - std::string material_name = (settings().get(SerializerSettings::USE_MATERIAL_NAMES) - ? material.original_name() : material.name()); + const ifcopenshell::geometry::taxonomy::style& material = mesh.materials()[material_id]; + // @todo original_name + std::string material_name = *(settings().get(SerializerSettings::USE_MATERIAL_NAMES) + ? material.name : material.name); IfcUtil::sanitate_material_name(material_name); obj_stream << "usemtl " << material_name << "\n"; if (materials.find(material_name) == materials.end()) { diff --git a/src/serializers/WavefrontObjSerializer.h b/src/serializers/WavefrontObjSerializer.h index 8bce643d74..48ee1588da 100644 --- a/src/serializers/WavefrontObjSerializer.h +++ b/src/serializers/WavefrontObjSerializer.h @@ -39,9 +39,9 @@ public: virtual ~WaveFrontOBJSerializer() {} bool ready(); void writeHeader(); - void writeMaterial(const IfcGeom::Material& style); - void write(const IfcGeom::TriangulationElement* o); - void write(const IfcGeom::NativeElement* /*o*/) {} + void writeMaterial(const ifcopenshell::geometry::taxonomy::style& style); + void write(const ifcopenshell::geometry::TriangulationElement* o); + void write(const ifcopenshell::geometry::NativeElement* /*o*/) {} void finalize() {} bool isTesselated() const { return true; } void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {} diff --git a/src/serializers/schema_dependent/XmlSerializer.cpp b/src/serializers/schema_dependent/XmlSerializer.cpp index dbe310d538..ddc174b027 100644 --- a/src/serializers/schema_dependent/XmlSerializer.cpp +++ b/src/serializers/schema_dependent/XmlSerializer.cpp @@ -129,11 +129,13 @@ boost::optional format_attribute(ifcopenshell::geometry::abstract_m auto matrix = (ifcopenshell::geometry::taxonomy::matrix4*) placement; std::stringstream stream; - for (int i = 0; i < 16; ++i) { - const double trsf_value = matrix->components[i]; - stream << trsf_value; - if (i != 15) { - stream << " "; + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 4; ++j) { + const double trsf_value = matrix->components(j, i); + stream << trsf_value; + if (i < 3 && j < 3) { + stream << " "; + } } } value = stream.str(); @@ -475,7 +477,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() { for (IfcEntityList::it it = unit_assignments->begin(); it != unit_assignments->end(); ++it) { if ((*it)->declaration().is(IfcSchema::IfcNamedUnit::Class())) { IfcSchema::IfcNamedUnit* named_unit = (*it)->as(); - ptree& node = format_entity_instance(mapping, named_unit, units); + ptree& node = format_entity_instance(mapping_, named_unit, units); node.put(".SI_equivalent", IfcParse::get_SI_equivalent(named_unit)); } else if ((*it)->declaration().is(IfcSchema::IfcMonetaryUnit::Class())) { format_entity_instance(mapping_, (*it)->as(), units);