diff --git a/.travis.yml b/.travis.yml index f01e99e5b4..635172791f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ script: - /usr/local/bin/IfcConvert -yv acad2010_walls.ifc acad2010_walls.glb - gltf_validator acad2010_walls.glb - - python -c "from __future__ import print_function; from io import open; import ifcopenshell; f = ifcopenshell.open('encoding.ifc'); print(f[1][0], file=open('encoding.txt', 'w', encoding='utf-8'))" && grep "'a' 1m³ ≤ 5m³ ≥ 10m³" encoding.txt + - /usr/bin/python2.7 -c "from __future__ import print_function; from io import open; import ifcopenshell; f = ifcopenshell.open('encoding.ifc'); print(f[1][0], file=open('encoding.txt', 'w', encoding='utf-8'))" && grep "'a' 1m³ ≤ 5m³ ≥ 10m³" encoding.txt - | (for i in *.ifc; do \ diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index 75add079a1..baf6307e30 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -216,12 +216,12 @@ private: }; double deflection_tolerance; + double max_faces_to_orient; double ifc_length_unit; double ifc_planeangle_unit; double modelling_precision; double dimensionality; - double max_faces_to_orient; - + #ifndef NO_CACHE MAKE_TYPE_NAME(Cache) cache; #endif diff --git a/src/ifcgeom/IfcGeomIteratorImplementation.h b/src/ifcgeom/IfcGeomIteratorImplementation.h index 673f5e8534..dec994b583 100644 --- a/src/ifcgeom/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/IfcGeomIteratorImplementation.h @@ -178,7 +178,6 @@ namespace IfcGeom { class MAKE_TYPE_NAME(IteratorImplementation_) : public IteratorImplementation { private: - int num_threads_; std::atomic progress_; std::vector> tasks_; std::vector*> all_processed_elements_; @@ -190,9 +189,12 @@ namespace IfcGeom { MAKE_TYPE_NAME(IteratorImplementation_)& operator=(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I MAKE_TYPE_NAME(Kernel) kernel; - IteratorSettings settings; + IteratorSettings settings; IfcParse::IfcFile* ifc_file; + std::vector filters_; + bool owns_ifc_file; + int num_threads_; // A container and iterator for IfcRepresentations IfcSchema::IfcRepresentation::list::ptr representations; @@ -219,8 +221,6 @@ namespace IfcGeom { gp_XYZ bounds_min_; gp_XYZ bounds_max_; - std::vector filters_; - struct filter_match { filter_match(IfcSchema::IfcProduct *prod) : product(prod) {} @@ -952,8 +952,7 @@ namespace IfcGeom { kernel.set_conversion_placement_rel_to(&IfcSchema::IfcSite::Class()); } } - - bool owns_ifc_file; + public: MAKE_TYPE_NAME(IteratorImplementation_)(const IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters, int num_threads) : settings(settings) diff --git a/src/ifcgeom/IfcGeomShapes.cpp b/src/ifcgeom/IfcGeomShapes.cpp index a8f0f9ea67..13e222a1c8 100644 --- a/src/ifcgeom/IfcGeomShapes.cpp +++ b/src/ifcgeom/IfcGeomShapes.cpp @@ -1165,7 +1165,7 @@ namespace { // @todo we could be extruding the wire only when we know this is an intermediate edge. const double depth = std::abs(u - v); TopoDS_Face face = BRepBuilderAPI_MakeFace(section).Face(); - result = BRepPrimAPI_MakeRevol(section, circ->Axis(), v - u).Shape(); + result = BRepPrimAPI_MakeRevol(section, circ->Axis(), depth).Shape(); } void process_sweep_as_pipe(const TopoDS_Wire& wire, const TopoDS_Wire& section, TopoDS_Shape& result) { @@ -1563,7 +1563,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalFaceSet* pfs, TopoDS_ BRep_Builder compound_builder; compound_builder.MakeCompound(all_faces); - for (int i = 0; i < polygonal_faces->size(); i++) { + for (unsigned i = 0; i < polygonal_faces->size(); i++) { IfcSchema::IfcIndexedPolygonalFace* la = (IfcSchema::IfcIndexedPolygonalFace*)*(polygonal_faces->begin() + i); TopoDS_Face face; // Gives the indexed points defining the face @@ -1573,8 +1573,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalFaceSet* pfs, TopoDS_ // points, sorted in order (cf BuildingSmart https://urlz.fr/aXN6) std::vector face_points; BRepBuilderAPI_MakePolygon wire_builder = BRepBuilderAPI_MakePolygon(); - for (std::vector::size_type i = 0; i != test.size(); i++) { - const gp_Pnt& point = points[test[i] - 1]; + for (std::vector::size_type j = 0; j != test.size(); j++) { + const gp_Pnt& point = points[test[j] - 1]; TopoDS_Vertex vertex = BRepBuilderAPI_MakeVertex(point); wire_builder.Add(vertex); } @@ -1591,8 +1591,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalFaceSet* pfs, TopoDS_ for (std::vector >::const_iterator it = innercoordinates.begin(); it != innercoordinates.end(); ++it) { std::vector mycoords = *it; BRepBuilderAPI_MakePolygon inner_wire_builder = BRepBuilderAPI_MakePolygon(); - for (std::vector::size_type i = 0; i != mycoords.size(); i++) { - gp_Pnt apoint = points[mycoords[i] - 1]; + for (std::vector::size_type j = 0; j != mycoords.size(); j++) { + gp_Pnt apoint = points[mycoords[j] - 1]; TopoDS_Vertex vertex = BRepBuilderAPI_MakeVertex(apoint); inner_wire_builder.Add(vertex); } @@ -1621,8 +1621,6 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalFaceSet* pfs, TopoDS_ if (faces.empty()) return false; - bool valid_shell = false; - TopTools_ListOfShape faces_list; for (std::vector::const_iterator it = faces.begin(); it != faces.end(); ++it) { faces_list.Append(*it); diff --git a/src/serializers/IgesSerializer.h b/src/serializers/IgesSerializer.h index 93fca9b514..e6a5bdf3b6 100644 --- a/src/serializers/IgesSerializer.h +++ b/src/serializers/IgesSerializer.h @@ -42,7 +42,7 @@ public: : OpenCascadeBasedSerializer(out_filename, settings) {} virtual ~IgesSerializer() {} - void writeShape(const TopoDS_Shape& shape) { + void writeShape(const std::string&, const TopoDS_Shape& shape) { writer.AddShape(shape); } void finalize() { diff --git a/src/serializers/OpenCascadeBasedSerializer.cpp b/src/serializers/OpenCascadeBasedSerializer.cpp index 1b35754795..8028fbb64c 100644 --- a/src/serializers/OpenCascadeBasedSerializer.cpp +++ b/src/serializers/OpenCascadeBasedSerializer.cpp @@ -43,7 +43,7 @@ void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement* o) { if (settings.get(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS) && settings.unit_magnitude() != 1.0) { trsf.SetTranslationPart(trsf.TranslationPart() / settings.unit_magnitude()); } - writeShape(compound.Moved(trsf)); + writeShape(object_id(o), compound.Moved(trsf)); } #define RATHER_SMALL (1e-3) diff --git a/src/serializers/OpenCascadeBasedSerializer.h b/src/serializers/OpenCascadeBasedSerializer.h index 048c1228a4..6410e3d05b 100644 --- a/src/serializers/OpenCascadeBasedSerializer.h +++ b/src/serializers/OpenCascadeBasedSerializer.h @@ -38,7 +38,7 @@ public: virtual ~OpenCascadeBasedSerializer() {} void writeHeader() {} bool ready(); - virtual void writeShape(const TopoDS_Shape& shape) = 0; + virtual void writeShape(const std::string& name, const TopoDS_Shape& shape) = 0; void write(const IfcGeom::TriangulationElement* /*o*/) {} void write(const IfcGeom::BRepElement* o); bool isTesselated() const { return false; } diff --git a/src/serializers/StepSerializer.h b/src/serializers/StepSerializer.h index db9ea54d77..3c53a10d6b 100644 --- a/src/serializers/StepSerializer.h +++ b/src/serializers/StepSerializer.h @@ -36,9 +36,10 @@ public: : OpenCascadeBasedSerializer(out_filename, settings) {} virtual ~StepSerializer() {} - void writeShape(const TopoDS_Shape& shape) { + void writeShape(const std::string& name, const TopoDS_Shape& shape) { std::stringstream ss; std::streambuf *sb = std::cout.rdbuf(ss.rdbuf()); + Interface_Static::SetCVal("write.step.product.name", name.c_str()); writer.Transfer(shape, STEPControl_AsIs); std::cout.rdbuf(sb); }