From 05e6f5691164f5c5d8f3c314f28f2eba94b36b1a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 29 Dec 2017 13:48:08 +0100 Subject: [PATCH] Linker errors, geom server, warnings --- cmake/CMakeLists.txt | 2 +- src/ifcgeomserver/IfcGeomServer.cpp | 87 +++++++++++++++-------------- src/ifcparse/IfcFile.h | 2 +- src/ifcwrap/IfcGeomWrapper.i | 2 +- 4 files changed, 47 insertions(+), 46 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5f88ba2f7d..2857e97f78 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -551,7 +551,7 @@ if(NOT MSVC) endif() endif() -set(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom) +set(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom IfcGeom_ifc2x3 IfcGeom_ifc4 IfcGeom) # IfcParse file(GLOB IFCPARSE_H_FILES ../src/ifcparse/*.h) diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index e15d888f2b..18b4a26163 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -38,7 +38,10 @@ #include #endif -#include "../ifcgeom/IfcGeomIterator.h" +#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h" +#include "../ifcgeom/IfcGeomElement.h" +#include "../ifcparse/IfcFile.h" +#include "../ifcparse/IfcLogger.h" #if USE_VLD #include @@ -378,53 +381,47 @@ public: double total_shape_volume = 0.; double walkable_surface_area = 0.; - for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = elem_->geometry().begin(); it != elem_->geometry().end(); ++it) { - gp_GTrsf gtrsf = it->Placement(); - const gp_Trsf& o_trsf = elem_->transformation().data(); - gtrsf.PreMultiply(o_trsf); - const TopoDS_Shape& shp = it->Shape(); - const TopoDS_Shape moved_shape = IfcGeom::Kernel::apply_transformation(shp, gtrsf); + TopoDS_Shape moved_shape = elem_->geometry().as_compound(); - { - GProp_GProps prop_area; - BRepGProp::SurfaceProperties(moved_shape, prop_area); - total_surface_area += prop_area.Mass(); - } + { + GProp_GProps prop_area; + BRepGProp::SurfaceProperties(moved_shape, prop_area); + total_surface_area += prop_area.Mass(); + } - { - GProp_GProps prop_volume; - BRepGProp::VolumeProperties(moved_shape, prop_volume); - total_shape_volume += prop_volume.Mass(); - } + { + GProp_GProps prop_volume; + BRepGProp::VolumeProperties(moved_shape, prop_volume); + total_shape_volume += prop_volume.Mass(); + } - if (elem_->type() == "IfcSpace") { - TopExp_Explorer exp(moved_shape, TopAbs_FACE); - for (; exp.More(); exp.Next()) { - const TopoDS_Face& face = TopoDS::Face(exp.Current()); - Handle(Geom_Surface) surf = BRep_Tool::Surface(face); + if (elem_->type() == "IfcSpace") { + TopExp_Explorer exp(moved_shape, TopAbs_FACE); + for (; exp.More(); exp.Next()) { + const TopoDS_Face& face = TopoDS::Face(exp.Current()); + Handle(Geom_Surface) surf = BRep_Tool::Surface(face); - // Assume we can only walk on planar surfaces - if (surf->DynamicType() != STANDARD_TYPE(Geom_Plane)) { - continue; - } + // Assume we can only walk on planar surfaces + if (surf->DynamicType() != STANDARD_TYPE(Geom_Plane)) { + continue; + } - BRepGProp_Face prop(face); - double u0, u1, v0, v1; - BRepTools::UVBounds(face, u0, u1, v0, v1); - gp_Pnt p; - gp_Vec normal_direction; - prop.Normal((u0 + u1) / 2., (v0 + v1) / 2., p, normal_direction); + BRepGProp_Face prop(face); + double u0, u1, v0, v1; + BRepTools::UVBounds(face, u0, u1, v0, v1); + gp_Pnt p; + gp_Vec normal_direction; + prop.Normal((u0 + u1) / 2., (v0 + v1) / 2., p, normal_direction); - gp_Vec normal(0., 0., 0.); - if (normal_direction.Magnitude() > ALMOST_ZERO) { - normal = gp_Dir(normal_direction.XYZ()); - } + gp_Vec normal(0., 0., 0.); + if (normal_direction.Magnitude() > 1.e-5) { + normal = gp_Dir(normal_direction.XYZ()); + } - if (normal.Angle(gp::DZ()) < (MAX_WALKABLE_SURFACE_ANGLE_DEGREES * M_PI / 180.0)) { - GProp_GProps prop_face; - BRepGProp::SurfaceProperties(face, prop_face); - walkable_surface_area += prop_face.Mass(); - } + if (normal.Angle(gp::DZ()) < (MAX_WALKABLE_SURFACE_ANGLE_DEGREES * M_PI / 180.0)) { + GProp_GProps prop_face; + BRepGProp::SurfaceProperties(face, prop_face); + walkable_surface_area += prop_face.Mass(); } } } @@ -475,6 +472,7 @@ int main () { bool has_more = false; IfcGeom::Iterator* iterator = 0; + IfcParse::IfcFile* file = 0; std::vector< std::pair > setting_pairs; Hello().write(std::cout); @@ -502,7 +500,8 @@ int main () { settings.set_deflection_tolerance(deflection); - iterator = new IfcGeom::Iterator(settings, data, (int)len); + file = new IfcParse::IfcFile(data, (int)len); + iterator = new IfcGeom::Iterator(settings, file); has_more = iterator->initialize(); More(has_more).write(std::cout); @@ -523,7 +522,9 @@ int main () { Next n; n.read(std::cin); has_more = iterator->next() != 0; if (!has_more) { + delete file; delete iterator; + file = 0; iterator = 0; } More(has_more).write(std::cout); @@ -531,7 +532,7 @@ int main () { } case GET_LOG: { GetLog gl; gl.read(std::cin); - WriteLog(iterator->getLog()).write(std::cout); + WriteLog(Logger::GetLog()).write(std::cout); continue; } case BYE: { diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index dc2e3cae3b..329c2d156a 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -99,7 +99,7 @@ public: IfcFile(IfcParse::IfcSpfStream* f); IfcFile(const IfcParse::schema_definition* schema = IfcParse::schema_by_name("IFC4")); - ~IfcFile(); + virtual ~IfcFile(); bool good() const { return good_; } diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index f8342a5ef6..0fc8def4b8 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -41,7 +41,7 @@ %include "../ifcgeom/ifc_geom_api.h" %include "../ifcgeom/IfcGeomIteratorSettings.h" %include "../ifcgeom/IfcGeomElement.h" -%include "../ifcgeom/IfcGeomMaterial.h" +%include "../ifcgeom_schema_agnostic/IfcGeomMaterial.h" %include "../ifcgeom/IfcGeomRepresentation.h" %include "../ifcgeom_schema_agnostic/IfcGeomIterator.h"