From fa0a33f3c04b33190e2611e8ecf4b2aba53dd4df Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 19 Jan 2019 12:39:47 +0100 Subject: [PATCH] Option to select Kernel from IfcConvert --- cmake/CMakeLists.txt | 16 +++- src/ifcconvert/IfcConvert.cpp | 2 +- .../IfcGeomIteratorImplementation.cpp | 6 +- .../IfcGeomIteratorImplementation.h | 95 ++++++------------- .../kernels/cgal/CgalConversionFunctions.cpp | 2 +- .../kernels/cgal/CgalEntityMapping.cpp | 1 - src/ifcgeom/kernels/cgal/CgalKernel.cpp | 25 ++++- src/ifcgeom/kernels/cgal/CgalKernel.h | 14 +-- src/ifcgeom/kernels/opencascade/IfcGeom.h | 2 +- src/ifcgeom/schema_agnostic/IfcGeomIterator.h | 8 +- .../schema_agnostic/IfcGeomRepresentation.cpp | 2 +- .../IteratorImplementation.cpp | 4 +- .../schema_agnostic/IteratorImplementation.h | 8 +- .../cgal/CgalConversionResult.cpp | 1 - .../cgal/CgalConversionResult.h | 7 ++ .../OpenCascadeConversionResult.cpp} | 5 +- .../opencascade/OpenCascadeConversionResult.h | 0 src/serializers/OpenCascadeBasedSerializer.h | 2 +- 18 files changed, 99 insertions(+), 101 deletions(-) rename src/ifcgeom/{kernels/opencascade => kernel_agnostic}/IfcGeomIteratorImplementation.cpp (78%) rename src/ifcgeom/{kernels/opencascade => kernel_agnostic}/IfcGeomIteratorImplementation.h (88%) rename src/ifcgeom/{kernels => schema_agnostic}/cgal/CgalConversionResult.cpp (97%) rename src/ifcgeom/{kernels => schema_agnostic}/cgal/CgalConversionResult.h (95%) rename src/ifcgeom/{kernels/opencascade/OpenCascadeShape.cpp => schema_agnostic/opencascade/OpenCascadeConversionResult.cpp} (98%) rename src/ifcgeom/{kernels => schema_agnostic}/opencascade/OpenCascadeConversionResult.h (100%) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 8877c98919..a96c523bc1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -554,6 +554,18 @@ ENDIF() if (BUILD_IFCGEOM) +foreach(kernel opencascade cgal) +string(TOUPPER ${kernel} KERNEL_UPPER) +file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/schema_agnostic/${kernel}/*.h) +file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/schema_agnostic/${kernel}/*.cpp) +set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) + +add_library(IfcGeom_${kernel} ${IFCGEOM_FILES}) +set_target_properties(IfcGeom_${kernel} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS") +target_link_libraries(IfcGeom_${kernel} IfcParse ${${KERNEL_UPPER}_LIBRARIES}) +list(APPEND IfcGeom_libraries IfcGeom_${kernel}) +endforeach() + foreach(schema 2x3 4) file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernel_agnostic/*.h) @@ -566,15 +578,13 @@ target_link_libraries(IfcGeom_ifc${schema} IfcParse) list(APPEND IfcGeom_libraries IfcGeom_ifc${schema}) foreach(kernel opencascade cgal) -string(TOUPPER ${kernel} KERNEL_UPPER) - file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/kernels/${kernel}/*.h) file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/kernels/${kernel}/*.cpp) set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) add_library(IfcGeom_${kernel}_ifc${schema} ${IFCGEOM_FILES}) set_target_properties(IfcGeom_${kernel}_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema} -DUSE_IFC${schema}") -target_link_libraries(IfcGeom_${kernel}_ifc${schema} IfcGeom_ifc${schema} ${${KERNEL_UPPER}_LIBRARIES}) +target_link_libraries(IfcGeom_${kernel}_ifc${schema} IfcGeom_${kernel} IfcGeom_ifc${schema}) list(APPEND IfcGeom_libraries IfcGeom_${kernel}_ifc${schema}) endforeach() diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 5c1b7d5c58..1c174dae13 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -652,7 +652,7 @@ int main(int argc, char** argv) return EXIT_FAILURE; } - IfcGeom::Iterator context_iterator(settings, ifc_file, filter_funcs); + IfcGeom::Iterator context_iterator(settings, ifc_file, filter_funcs, "cgal"); 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. diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomIteratorImplementation.cpp b/src/ifcgeom/kernel_agnostic/IfcGeomIteratorImplementation.cpp similarity index 78% rename from src/ifcgeom/kernels/opencascade/IfcGeomIteratorImplementation.cpp rename to src/ifcgeom/kernel_agnostic/IfcGeomIteratorImplementation.cpp index 82fc1cc17b..6bc2225c0f 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomIteratorImplementation.cpp +++ b/src/ifcgeom/kernel_agnostic/IfcGeomIteratorImplementation.cpp @@ -1,5 +1,5 @@ #include "IfcGeomIteratorImplementation.h" -#include "../../../ifcgeom/schema_agnostic/IteratorImplementation.h" +#include "../../ifcgeom/schema_agnostic/IteratorImplementation.h" namespace IfcGeom { template class MAKE_TYPE_NAME(IteratorImplementation_); @@ -14,8 +14,8 @@ namespace IfcGeom { namespace { template struct MAKE_TYPE_NAME(factory_t) { - IfcGeom::IteratorImplementation* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters) const { - return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)(settings, file, filters); + IfcGeom::IteratorImplementation* operator()(const std::string& geometry_engine, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters) const { + return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)(geometry_engine, settings, file, filters); } }; } diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomIteratorImplementation.h b/src/ifcgeom/kernel_agnostic/IfcGeomIteratorImplementation.h similarity index 88% rename from src/ifcgeom/kernels/opencascade/IfcGeomIteratorImplementation.h rename to src/ifcgeom/kernel_agnostic/IfcGeomIteratorImplementation.h index 1741c84e2f..0f1577eab0 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/kernel_agnostic/IfcGeomIteratorImplementation.h @@ -73,16 +73,18 @@ #include #include -#include "../../../ifcparse/IfcFile.h" +#include "../../ifcparse/IfcFile.h" -#include "../../../ifcgeom/kernels/opencascade/IfcGeom.h" -#include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h" -#include "../../../ifcgeom/schema_agnostic/IfcGeomMaterial.h" -#include "../../../ifcgeom/schema_agnostic/IfcGeomIteratorSettings.h" -#include "../../../ifcgeom/schema_agnostic/ConversionResult.h" +#include "../../ifcgeom/kernels/opencascade/IfcGeom.h" +#include "../../ifcgeom/schema_agnostic/IfcGeomElement.h" +#include "../../ifcgeom/schema_agnostic/IfcGeomMaterial.h" +#include "../../ifcgeom/schema_agnostic/IfcGeomIteratorSettings.h" +#include "../../ifcgeom/schema_agnostic/ConversionResult.h" -#include "../../../ifcgeom/schema_agnostic/IfcGeomFilter.h" -#include "../../../ifcgeom/schema_agnostic/IteratorImplementation.h" +#include "../../ifcgeom/schema_agnostic/IfcGeomFilter.h" +#include "../../ifcgeom/schema_agnostic/IteratorImplementation.h" + +#include "../../ifcgeom/schema_agnostic/Kernel.h" // The infamous min & max Win32 #defines can leak here from OCE depending on the build configuration #ifdef min @@ -101,7 +103,7 @@ namespace IfcGeom { MAKE_TYPE_NAME(IteratorImplementation_)(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I MAKE_TYPE_NAME(IteratorImplementation_)& operator=(const MAKE_TYPE_NAME(IteratorImplementation_)&); // N/I - MAKE_TYPE_NAME(Kernel) kernel; + MAKE_TYPE_NAME(Kernel)* kernel; IteratorSettings settings; IfcParse::IfcFile* ifc_file; @@ -141,29 +143,12 @@ namespace IfcGeom { IfcSchema::IfcProduct* product; }; - void initUnits() { - IfcSchema::IfcProject::list::ptr projects = ifc_file->instances_by_type(); - if (projects->size() == 1) { - IfcSchema::IfcProject* project = *projects->begin(); - std::pair length_unit = kernel.initializeUnits(project->UnitsInContext()); - unit_name = length_unit.first; - unit_magnitude = length_unit.second; - } else { - Logger::Warning("A single IfcProject is expected (encountered " + boost::lexical_cast(projects->size()) + "); unable to read unit information."); - } - } - /// @todo public/private sections all over the place: move all public to the beginning of the class public: typedef P Precision; typedef PP PlacementPrecision; bool initialize() { - try { - initUnits(); - } catch (const std::exception& e) { - Logger::Error(e); - } std::set allowed_context_types; allowed_context_types.insert("model"); @@ -185,9 +170,6 @@ namespace IfcGeom { context_types.insert("plan"); } - double lowest_precision_encountered = std::numeric_limits::infinity(); - bool any_precision_encountered = false; - representations = IfcSchema::IfcRepresentation::list::ptr(new IfcSchema::IfcRepresentation::list); ok_mapped_representations = IfcSchema::IfcRepresentation::list::ptr(new IfcSchema::IfcRepresentation::list); @@ -237,15 +219,7 @@ namespace IfcGeom { IfcSchema::IfcGeometricRepresentationContext* context = *it; representations->push(context->RepresentationsInContext()); - try { - if (context->hasPrecision() && context->Precision() < lowest_precision_encountered) { - lowest_precision_encountered = context->Precision(); - any_precision_encountered = true; - } - } catch (const std::exception& e) { - Logger::Error(e); - } - + IfcSchema::IfcGeometricRepresentationSubContext::list::ptr sub_contexts = context->HasSubContexts(); for (jt = sub_contexts->begin(); jt != sub_contexts->end(); ++jt) { representations->push((*jt)->RepresentationsInContext()); @@ -254,21 +228,6 @@ namespace IfcGeom { // WR31: The parent context shall not be another geometric representation sub context. } - if (any_precision_encountered) { - // Some arbitrary factor that has proven to work better for the models in the set of test files. - lowest_precision_encountered *= 10.; - - lowest_precision_encountered *= unit_magnitude; - if (lowest_precision_encountered < 1.e-7) { - Logger::Message(Logger::LOG_WARNING, "Precision lower than 0.0000001 meter not enforced"); - kernel.setValue(IfcGeom::Kernel::GV_PRECISION, 1.e-7); - } else { - kernel.setValue(IfcGeom::Kernel::GV_PRECISION, lowest_precision_encountered); - } - } else { - kernel.setValue(IfcGeom::Kernel::GV_PRECISION, 1.e-5); - } - if (representations->size() == 0) { Logger::Warning("No representations encountered in relevant contexts, using all"); representations = ifc_file->instances_by_type(); @@ -310,7 +269,7 @@ namespace IfcGeom { bool success = false; try { - success = kernel.convert(product->ObjectPlacement(), trsf); + success = kernel->convert(product->ObjectPlacement(), trsf); } catch (const std::exception& e) { Logger::Error(e); } catch (...) { @@ -357,7 +316,7 @@ namespace IfcGeom { // benchmarked extensively: https://github.com/IfcOpenShell/IfcOpenShell/pull/47 static const int clear_interval = 64; if (done % clear_interval == clear_interval - 1) { - kernel.purge_cache(); + kernel->purge_cache(); } ifcproducts.reset(); ++ representation_iterator; @@ -378,7 +337,7 @@ namespace IfcGeom { for (IfcSchema::IfcProduct::list::it it = products->begin(); it != products->end(); ++it) { IfcSchema::IfcProduct* product = *it; - if (!settings.get(IteratorSettings::DISABLE_OPENING_SUBTRACTIONS) && kernel.find_openings(product)->size()) { + if (!settings.get(IteratorSettings::DISABLE_OPENING_SUBTRACTIONS) && kernel->find_openings(product)->size()) { return false; } @@ -396,7 +355,7 @@ namespace IfcGeom { } // Note that this can be a nullptr (!), but the fact that set size should be one still holds - associated_single_materials.insert(kernel.get_single_material_association(product)); + associated_single_materials.insert(kernel->get_single_material_association(product)); if (associated_single_materials.size() > 1) return false; } @@ -416,7 +375,7 @@ namespace IfcGeom { if (!ifcproducts) { // Init. the list of filtered IfcProducts for this representation ifcproducts = IfcSchema::IfcProduct::list::ptr(new IfcSchema::IfcProduct::list); - IfcSchema::IfcProduct::list::ptr unfiltered_products = kernel.products_represented_by(representation); + IfcSchema::IfcProduct::list::ptr unfiltered_products = kernel->products_represented_by(representation); // Include only the desired products for processing. for (IfcSchema::IfcProduct::list::it jt = unfiltered_products->begin(); jt != unfiltered_products->end(); ++jt) { IfcSchema::IfcProduct* prod = *jt; @@ -450,7 +409,7 @@ namespace IfcGeom { // Check if this represenation has (or will be) processed as part its mapped representation bool representation_processed_as_mapped_item = false; - IfcSchema::IfcRepresentation* representation_mapped_to = kernel.representation_mapped_to(representation); + IfcSchema::IfcRepresentation* representation_mapped_to = kernel->representation_mapped_to(representation); if (representation_mapped_to) { representation_processed_as_mapped_item = geometry_reuse_ok_for_current_representation_ || ok_mapped_representations->contains(representation_mapped_to); @@ -476,9 +435,9 @@ namespace IfcGeom { NativeElement* element; if (ifcproduct_iterator == ifcproducts->begin() || !geometry_reuse_ok_for_current_representation_) { - element = kernel.create_brep_for_representation_and_product(settings, representation, product); + element = kernel->create_brep_for_representation_and_product(settings, representation, product); } else { - element = kernel.create_brep_for_processed_representation(settings, representation, product, current_shape_model); + element = kernel->create_brep_for_processed_representation(settings, representation, product, current_shape_model); } Logger::SetProduct(boost::none); @@ -614,7 +573,7 @@ namespace IfcGeom { ifc_product = ifc_entity->as(); parent_id = -1; try { - IfcSchema::IfcObjectDefinition* parent_object = kernel.get_decomposing_entity(ifc_product)->template as(); + IfcSchema::IfcObjectDefinition* parent_object = kernel->get_decomposing_entity(ifc_product)->template as(); if (parent_object) { parent_id = parent_object->data().id(); } @@ -625,7 +584,7 @@ namespace IfcGeom { } try { - kernel.convert(ifc_product->ObjectPlacement(), trsf); + kernel->convert(ifc_product->ObjectPlacement(), trsf); } catch (const std::exception& e) { Logger::Error(e); } catch (...) { @@ -706,26 +665,28 @@ namespace IfcGeom { unit_name = "METER"; unit_magnitude = 1.f; - kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IteratorSettings::INCLUDE_CURVES) + kernel->setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IteratorSettings::INCLUDE_CURVES) ? (settings.get(IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES) ? -1. : 0.) : +1.)); if (settings.get(IteratorSettings::BUILDING_LOCAL_PLACEMENT)) { if (settings.get(IteratorSettings::SITE_LOCAL_PLACEMENT)) { Logger::Message(Logger::LOG_WARNING, "building-local-placement takes precedence over site-local-placement"); } - kernel.set_conversion_placement_rel_to(&IfcSchema::IfcBuilding::Class()); + kernel->set_conversion_placement_rel_to(&IfcSchema::IfcBuilding::Class()); } else if (settings.get(IteratorSettings::SITE_LOCAL_PLACEMENT)) { - kernel.set_conversion_placement_rel_to(&IfcSchema::IfcSite::Class()); + 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) + MAKE_TYPE_NAME(IteratorImplementation_)(const std::string& geometry_library, const IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters) : settings(settings) , ifc_file(file) , filters_(filters) , owns_ifc_file(false) { + kernel = (MAKE_TYPE_NAME(Kernel)*) impl::kernel_implementations().construct(file->schema()->name(), geometry_library, file); + // kernel = new Kernel(geometry_library, file); _initialize(); } diff --git a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp index fcb766ca11..9cb297835c 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp @@ -1,5 +1,5 @@ #include "CgalKernel.h" -#include "CgalConversionResult.h" +#include "../../../ifcgeom/schema_agnostic/cgal/CgalConversionResult.h" #define CgalKernel MAKE_TYPE_NAME(CgalKernel) diff --git a/src/ifcgeom/kernels/cgal/CgalEntityMapping.cpp b/src/ifcgeom/kernels/cgal/CgalEntityMapping.cpp index c92ac7c166..a5ecf67624 100644 --- a/src/ifcgeom/kernels/cgal/CgalEntityMapping.cpp +++ b/src/ifcgeom/kernels/cgal/CgalEntityMapping.cpp @@ -18,7 +18,6 @@ ********************************************************************************/ #include "CgalKernel.h" -#include "CgalConversionResult.h" #define CgalKernel MAKE_TYPE_NAME(CgalKernel) diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.cpp b/src/ifcgeom/kernels/cgal/CgalKernel.cpp index 4c67c670ba..5983748042 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.cpp +++ b/src/ifcgeom/kernels/cgal/CgalKernel.cpp @@ -18,7 +18,6 @@ ********************************************************************************/ #include "CgalKernel.h" -#include "CgalConversionResult.h" namespace { struct MAKE_TYPE_NAME(factory_t) { @@ -208,3 +207,27 @@ template IFC_GEOM_API IfcGeom::NativeElement* IfcGeom::CgalKernel const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::NativeElement* brep); template IFC_GEOM_API IfcGeom::NativeElement* IfcGeom::CgalKernel::create_brep_for_processed_representation( const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::NativeElement* brep); + + +void IfcGeom::CgalKernel::setValue(GeomValue var, double value) { + switch (var) { + case GV_DEFLECTION_TOLERANCE: + deflection_tolerance = value; + break; + case GV_DIMENSIONALITY: + dimensionality = value; + break; + default: + throw std::runtime_error("Not implemented for this kernel"); + } +} + +double IfcGeom::CgalKernel::getValue(GeomValue var) const { + switch (var) { + case GV_DEFLECTION_TOLERANCE: + return deflection_tolerance; + case GV_DIMENSIONALITY: + return dimensionality; + } + throw std::runtime_error("Not implemented for this kernel"); +} \ No newline at end of file diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.h b/src/ifcgeom/kernels/cgal/CgalKernel.h index 5d9cfd21fe..86f878fd4c 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.h +++ b/src/ifcgeom/kernels/cgal/CgalKernel.h @@ -38,6 +38,7 @@ if ( it != cache.T.end() ) { e = it->second; return true; } #include "../../../ifcparse/macros.h" #include "../../../ifcgeom/schema_agnostic/Kernel.h" #include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h" +#include "../../../ifcgeom/schema_agnostic/cgal/CgalConversionResult.h" // @todo create separate shapetype enum? #include "../../../ifcgeom/kernels/opencascade/IfcGeomShapeType.h" @@ -46,13 +47,6 @@ if ( it != cache.T.end() ) { e = it->second; return true; } #include INCLUDE_SCHEMA(IfcSchema) #undef INCLUDE_SCHEMA -typedef void* cgal_shape_t; -typedef void* cgal_face_t; -typedef void* cgal_wire_t; -typedef void* cgal_curve_t; -typedef void* cgal_placement_t; -typedef void* cgal_point_t; - namespace IfcGeom { class IFC_GEOM_API CgalCache { @@ -78,6 +72,9 @@ namespace IfcGeom { bool convert_curve(const IfcUtil::IfcBaseClass* L, cgal_curve_t& result); bool convert_face(const IfcUtil::IfcBaseClass* L, cgal_face_t& result); + virtual void setValue(GeomValue var, double value); + virtual double getValue(GeomValue var) const; + // bool convert_openings(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const ConversionResults& entity_shapes, const gp_Trsf& entity_trsf, ConversionResults& cut_shapes); void purge_cache() { @@ -102,6 +99,9 @@ namespace IfcGeom { #include "CgalEntityMappingDeclaration.h" + private: + double deflection_tolerance; + double dimensionality; }; } diff --git a/src/ifcgeom/kernels/opencascade/IfcGeom.h b/src/ifcgeom/kernels/opencascade/IfcGeom.h index 0663450788..c3f933ad27 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeom.h +++ b/src/ifcgeom/kernels/opencascade/IfcGeom.h @@ -58,7 +58,7 @@ inline static bool ALMOST_THE_SAME(const T& a, const T& b, double tolerance=ALMO #include "../../../ifcgeom/kernels/opencascade/IfcGeomShapeType.h" #include "../../../ifcgeom/schema_agnostic/Kernel.h" -#include "OpenCascadeConversionResult.h" +#include "../../../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../../../ifcgeom/schema_agnostic/ifc_geom_api.h" diff --git a/src/ifcgeom/schema_agnostic/IfcGeomIterator.h b/src/ifcgeom/schema_agnostic/IfcGeomIterator.h index d011ad6657..2af27e32ce 100644 --- a/src/ifcgeom/schema_agnostic/IfcGeomIterator.h +++ b/src/ifcgeom/schema_agnostic/IfcGeomIterator.h @@ -83,19 +83,19 @@ namespace IfcGeom { IteratorImplementation* implementation_; public: - Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) + Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::string& geometry_library="opencascade") : file_(file) , settings_(settings) { - implementation_ = iterator_implementations().construct(file_->schema()->name(), settings, file, filters_); + implementation_ = iterator_implementations().construct(file_->schema()->name(), geometry_library, settings, file, filters_); } - Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters) + Iterator(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters, const std::string& geometry_library = "opencascade") : file_(file) , settings_(settings) , filters_(filters) { - implementation_ = iterator_implementations().construct(file_->schema()->name(), settings, file, filters_); + implementation_ = iterator_implementations().construct(file_->schema()->name(), geometry_library, settings, file, filters_); } bool initialize() { diff --git a/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.cpp b/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.cpp index 5a273eb95e..e7230d8b17 100644 --- a/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.cpp +++ b/src/ifcgeom/schema_agnostic/IfcGeomRepresentation.cpp @@ -27,7 +27,7 @@ #include #include "IfcGeomRepresentation.h" -#include "../../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h" +#include "../../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../../ifcgeom/schema_agnostic/Kernel.h" IfcGeom::Representation::Serialization::Serialization(const BRep& brep) diff --git a/src/ifcgeom/schema_agnostic/IteratorImplementation.cpp b/src/ifcgeom/schema_agnostic/IteratorImplementation.cpp index 10608d8cb7..5b039fd615 100644 --- a/src/ifcgeom/schema_agnostic/IteratorImplementation.cpp +++ b/src/ifcgeom/schema_agnostic/IteratorImplementation.cpp @@ -31,14 +31,14 @@ void IteratorFactoryImplementation::bind(const std::string& schema_name, } template -IfcGeom::IteratorImplementation* IteratorFactoryImplementation::construct(const std::string& schema_name, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters) { +IfcGeom::IteratorImplementation* IteratorFactoryImplementation::construct(const std::string& schema_name, const std::string& geometry_library, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file, const std::vector& filters) { const std::string schema_name_lower = boost::to_lower_copy(schema_name); typename std::map::type>::const_iterator it; it = this->find(schema_name_lower); if (it == this->end()) { throw IfcParse::IfcException("No geometry iterator registered for " + schema_name); } - return it->second(settings, file, filters); + return it->second(geometry_library, settings, file, filters); } diff --git a/src/ifcgeom/schema_agnostic/IteratorImplementation.h b/src/ifcgeom/schema_agnostic/IteratorImplementation.h index 46dc8adccd..eb7399c697 100644 --- a/src/ifcgeom/schema_agnostic/IteratorImplementation.h +++ b/src/ifcgeom/schema_agnostic/IteratorImplementation.h @@ -23,9 +23,9 @@ namespace IfcGeom { class NativeElement; } -typedef boost::function3*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&> iterator_float_float_fn; -typedef boost::function3*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&> iterator_float_double_fn; -typedef boost::function3*, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&> iterator_double_double_fn; +typedef boost::function4*, const std::string&, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&> iterator_float_float_fn; +typedef boost::function4*, const std::string&, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&> iterator_float_double_fn; +typedef boost::function4*, const std::string&, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&> iterator_double_double_fn; template struct get_factory_type {}; @@ -50,7 +50,7 @@ class IteratorFactoryImplementation : public std::map::type fn); - IfcGeom::IteratorImplementation* construct(const std::string& schema_name, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&); + IfcGeom::IteratorImplementation* construct(const std::string& schema_name, const std::string& geometry_library, const IfcGeom::IteratorSettings&, IfcParse::IfcFile*, const std::vector&); }; template diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp b/src/ifcgeom/schema_agnostic/cgal/CgalConversionResult.cpp similarity index 97% rename from src/ifcgeom/kernels/cgal/CgalConversionResult.cpp rename to src/ifcgeom/schema_agnostic/cgal/CgalConversionResult.cpp index 3b9ee4d2d3..3f98bc00d9 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp +++ b/src/ifcgeom/schema_agnostic/cgal/CgalConversionResult.cpp @@ -1,4 +1,3 @@ -#include "CgalKernel.h" #include "CgalConversionResult.h" template diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.h b/src/ifcgeom/schema_agnostic/cgal/CgalConversionResult.h similarity index 95% rename from src/ifcgeom/kernels/cgal/CgalConversionResult.h rename to src/ifcgeom/schema_agnostic/cgal/CgalConversionResult.h index 4d78b23e2a..6f231d1efa 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.h +++ b/src/ifcgeom/schema_agnostic/cgal/CgalConversionResult.h @@ -20,6 +20,13 @@ #ifndef CGALCONVERSIONRESULT_H #define CGALCONVERSIONRESULT_H +typedef void* cgal_shape_t; +typedef void* cgal_face_t; +typedef void* cgal_wire_t; +typedef void* cgal_curve_t; +typedef void* cgal_placement_t; +typedef void* cgal_point_t; + #include "../../../ifcgeom/schema_agnostic/ConversionResult.h" namespace IfcGeom { diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeShape.cpp b/src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.cpp similarity index 98% rename from src/ifcgeom/kernels/opencascade/OpenCascadeShape.cpp rename to src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.cpp index a48515d07b..b113ba45ce 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeShape.cpp +++ b/src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.cpp @@ -3,8 +3,6 @@ #include "../../../ifcparse/IfcLogger.h" #include "../../../ifcgeom/schema_agnostic/IfcGeomRepresentation.h" -#include "IfcGeom.h" - #include #include @@ -198,5 +196,6 @@ void IfcGeom::OpenCascadeShape::Triangulate(const IfcGeom::IteratorSettings & se } int IfcGeom::OpenCascadeShape::surface_genus() const { - return IfcGeom::Kernel::surface_genus(shape_); + throw std::runtime_error("Not implemented"); + // return IfcGeom::Kernel::surface_genus(shape_); } \ No newline at end of file diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h b/src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h similarity index 100% rename from src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h rename to src/ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h diff --git a/src/serializers/OpenCascadeBasedSerializer.h b/src/serializers/OpenCascadeBasedSerializer.h index dd673024b9..bb92b4fd1c 100644 --- a/src/serializers/OpenCascadeBasedSerializer.h +++ b/src/serializers/OpenCascadeBasedSerializer.h @@ -21,7 +21,7 @@ #define OPENCASCADEBASEDSERIALIZER_H #include "../ifcgeom/schema_agnostic/IfcGeomIterator.h" -#include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h" +#include "../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../serializers/GeometrySerializer.h" class OpenCascadeBasedSerializer : public GeometrySerializer {