From af58eaf79fe4ac4cd47bc3fe8986bdf6c55a4391 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 8 Aug 2026 07:42:45 +0200 Subject: [PATCH] Last minute refactoring --- docs/cpp-api/Doxyfile | 15 +- nix/build-all.py | 2 +- src/bonsai/bonsai/bim/ifc.py | 11 +- .../bonsai/bim/module/drawing/operator.py | 43 +- .../bonsai/bim/module/light/operator.py | 5 +- src/bonsai/scripts/standalone_drawer.py | 45 +- src/bonsaiviewer/ElementRegistry.cpp | 2 +- src/bonsaiviewer/ElementRegistry.h | 2 +- .../docs/viewport_architecture.rst | 2 +- src/bonsaiviewer/modules/models/Commands.cpp | 4 +- .../modules/models/SettingsView.cpp | 4 +- src/bonsaiviewer/modules/properties/View.cpp | 8 +- .../modules/spatial_hierarchy/View.cpp | 6 +- src/examples/IfcAdvancedHouse.cpp | 10 +- src/examples/IfcOpenHouse.cpp | 2 +- src/examples/IfcParseExamples.cpp | 2 +- src/helpers/element.cpp | 30 +- src/helpers/element.h | 14 +- src/helpers/geolocation.cpp | 8 +- src/helpers/geolocation.h | 2 +- src/helpers/placement.cpp | 12 +- src/helpers/placement.h | 6 +- src/helpers/pset.cpp | 42 +- src/helpers/pset.h | 18 +- src/helpers/unit.cpp | 20 +- src/helpers/unit.h | 8 +- src/ifcconvert/IfcConvert.cpp | 133 ++-- src/ifcconvert/validate_space_boundaries.cpp | 18 +- .../validate_storey_containment.cpp | 34 +- src/ifcconvert/validate_wall_connectivity.cpp | 25 +- src/ifcconvert/validation_utils.h | 30 +- src/ifcgeom/AbstractKernel.cpp | 20 +- src/ifcgeom/AbstractKernel.h | 140 ++-- src/ifcgeom/ConversionResult.cpp | 16 +- src/ifcgeom/ConversionResult.h | 312 ++++---- src/ifcgeom/ConversionSettings.cpp | 12 +- src/ifcgeom/ConversionSettings.h | 474 +++++++++++- src/ifcgeom/Converter.cpp | 78 +- src/ifcgeom/Converter.h | 38 +- src/ifcgeom/GeometrySerializer.h | 313 +------- src/ifcgeom/IfcGeomElement.h | 106 +-- src/ifcgeom/IfcGeomFilter.h | 40 +- src/ifcgeom/IfcGeomRenderStyles.h | 6 +- src/ifcgeom/IfcGeomRepresentation.cpp | 60 +- src/ifcgeom/IfcGeomRepresentation.h | 92 +-- src/ifcgeom/Iterator.cpp | 179 +++-- src/ifcgeom/Iterator.h | 122 ++-- src/ifcgeom/Serialization/CMakeLists.txt | 2 +- src/ifcgeom/Serialization/Serialization.cpp | 20 +- src/ifcgeom/Serialization/Serialization.h | 20 +- ...opencascade_geometry_ifc_writer_plugin.cpp | 12 +- .../opencascade_geometry_ifc_writer_plugin.h | 2 +- .../Serialization/schema/Serialization.cpp | 18 +- src/ifcgeom/Serialization/schema/plugin.cpp | 20 +- src/ifcgeom/Serializer.h | 6 +- src/ifcgeom/SurfaceStyle.cpp | 66 +- src/ifcgeom/abstract_mapping.cpp | 20 +- src/ifcgeom/abstract_mapping.h | 46 +- src/ifcgeom/function_item_evaluator.cpp | 26 +- src/ifcgeom/function_item_evaluator.h | 12 +- src/ifcgeom/hybrid_kernel.h | 30 +- src/ifcgeom/infra_sweep_helper.cpp | 12 +- src/ifcgeom/infra_sweep_helper.h | 6 +- src/ifcgeom/kernel_plugin.cpp | 12 +- src/ifcgeom/kernel_plugin.h | 2 +- src/ifcgeom/kernel_registry.cpp | 32 +- src/ifcgeom/kernel_registry.h | 8 +- .../kernels/cgal/CgalConversionResult.cpp | 370 +++++----- .../kernels/cgal/CgalConversionResult.h | 218 +++--- src/ifcgeom/kernels/cgal/CgalKernel.cpp | 379 +++++----- src/ifcgeom/kernels/cgal/CgalKernel.h | 52 +- .../kernels/cgal/nef_to_halfspace_tree.h | 178 ++--- src/ifcgeom/kernels/cgal/plugin.cpp | 12 +- .../manifold/ManifoldConversionResult.cpp | 160 ++-- .../manifold/ManifoldConversionResult.h | 78 +- .../kernels/manifold/ManifoldKernel.cpp | 208 +++--- src/ifcgeom/kernels/manifold/ManifoldKernel.h | 24 +- src/ifcgeom/kernels/manifold/plugin.cpp | 12 +- src/ifcgeom/kernels/opencascade/IfcGeomTree.h | 60 +- .../OpenCascadeConversionResult.cpp | 166 ++--- .../opencascade/OpenCascadeConversionResult.h | 64 +- .../kernels/opencascade/OpenCascadeKernel.cpp | 124 ++-- .../kernels/opencascade/OpenCascadeKernel.h | 76 +- .../kernels/opencascade/base_utils.cpp | 80 +- src/ifcgeom/kernels/opencascade/base_utils.h | 6 +- .../kernels/opencascade/boolean_result.cpp | 27 +- .../kernels/opencascade/boolean_utils.cpp | 50 +- .../kernels/opencascade/boolean_utils.h | 4 +- .../kernels/opencascade/bspline_surface.cpp | 7 +- .../kernels/opencascade/clash_utils.cpp | 38 +- src/ifcgeom/kernels/opencascade/extrusion.cpp | 13 +- src/ifcgeom/kernels/opencascade/face.cpp | 47 +- .../kernels/opencascade/face_definition.cpp | 2 +- .../kernels/opencascade/face_definition.h | 2 +- .../kernels/opencascade/faceset_helper.cpp | 48 +- src/ifcgeom/kernels/opencascade/layerset.cpp | 46 +- src/ifcgeom/kernels/opencascade/layerset.h | 8 +- src/ifcgeom/kernels/opencascade/loft.cpp | 15 +- src/ifcgeom/kernels/opencascade/loop.cpp | 65 +- src/ifcgeom/kernels/opencascade/matrix4.cpp | 11 +- src/ifcgeom/kernels/opencascade/plugin.cpp | 12 +- src/ifcgeom/kernels/opencascade/shell.cpp | 15 +- src/ifcgeom/kernels/opencascade/solid.cpp | 15 +- .../kernels/opencascade/sweep_along_curve.cpp | 19 +- .../kernels/opencascade/sweep_utils.cpp | 22 +- src/ifcgeom/kernels/opencascade/sweep_utils.h | 2 +- .../kernels/opencascade/tree_backends.h | 64 +- .../kernels/opencascade/tree_brep_plugin.cpp | 8 +- .../opencascade/tree_trianglebvh_plugin.cpp | 8 +- .../kernels/opencascade/wire_builder.cpp | 16 +- .../kernels/opencascade/wire_builder.h | 6 +- .../kernels/opencascade/wire_utils.cpp | 40 +- src/ifcgeom/kernels/opencascade/wire_utils.h | 6 +- .../PassthroughConversionResult.cpp | 176 ++--- .../passthrough/PassthroughConversionResult.h | 70 +- .../kernels/passthrough/PassthroughKernel.cpp | 26 +- .../kernels/passthrough/PassthroughKernel.h | 22 +- src/ifcgeom/kernels/passthrough/plugin.cpp | 12 +- src/ifcgeom/mapping/IfcAnnotationFillArea.cpp | 2 +- .../mapping/IfcArbitraryClosedProfileDef.cpp | 2 +- .../mapping/IfcArbitraryOpenProfileDef.cpp | 2 +- .../mapping/IfcAsymmetricIShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcAxis1Placement.cpp | 2 +- src/ifcgeom/mapping/IfcAxis2Placement2D.cpp | 2 +- src/ifcgeom/mapping/IfcAxis2Placement3D.cpp | 2 +- .../mapping/IfcAxis2PlacementLinear.cpp | 2 +- .../mapping/IfcBSplineCurveWithKnots.cpp | 4 +- .../mapping/IfcBSplineSurfaceWithKnots.cpp | 2 +- src/ifcgeom/mapping/IfcBlock.cpp | 2 +- src/ifcgeom/mapping/IfcBooleanResult.cpp | 2 +- src/ifcgeom/mapping/IfcBoundingBox.cpp | 2 +- src/ifcgeom/mapping/IfcCShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcCartesianPoint.cpp | 2 +- .../IfcCartesianTransformationOperator2D.cpp | 2 +- .../IfcCartesianTransformationOperator3D.cpp | 2 +- .../mapping/IfcCenterLineProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcCircle.cpp | 2 +- src/ifcgeom/mapping/IfcCircleProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcCompositeCurve.cpp | 8 +- .../mapping/IfcCompositeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcConnectedFaceSet.cpp | 2 +- .../mapping/IfcCraneRailAShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcCsgSolid.cpp | 2 +- src/ifcgeom/mapping/IfcCurveBoundedPlane.cpp | 2 +- src/ifcgeom/mapping/IfcCurveSegment.cpp | 2 +- src/ifcgeom/mapping/IfcCylindricalSurface.cpp | 2 +- src/ifcgeom/mapping/IfcDerivedProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcDirection.cpp | 4 +- src/ifcgeom/mapping/IfcEdge.cpp | 2 +- src/ifcgeom/mapping/IfcEdgeLoop.cpp | 2 +- src/ifcgeom/mapping/IfcEllipse.cpp | 2 +- src/ifcgeom/mapping/IfcEllipseProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp | 2 +- .../mapping/IfcExtrudedAreaSolidTapered.cpp | 2 +- src/ifcgeom/mapping/IfcFace.cpp | 2 +- .../mapping/IfcFaceBasedSurfaceModel.cpp | 2 +- .../IfcFixedReferenceSweptAreaSolid.cpp | 2 +- src/ifcgeom/mapping/IfcGeometricSet.cpp | 2 +- src/ifcgeom/mapping/IfcGradientCurve.cpp | 4 +- src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp | 2 +- src/ifcgeom/mapping/IfcIShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp | 2 +- src/ifcgeom/mapping/IfcLShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcLine.cpp | 2 +- src/ifcgeom/mapping/IfcManifoldSolidBrep.cpp | 2 +- src/ifcgeom/mapping/IfcMappedItem.cpp | 2 +- src/ifcgeom/mapping/IfcObjectPlacement.cpp | 8 +- .../mapping/IfcOffsetCurveByDistance.cpp | 4 +- .../mapping/IfcOpenCrossProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcOrientedEdge.cpp | 2 +- src/ifcgeom/mapping/IfcPlane.cpp | 2 +- .../mapping/IfcPointByDistanceExpression.cpp | 2 +- src/ifcgeom/mapping/IfcPolyLoop.cpp | 2 +- .../mapping/IfcPolygonalBoundedHalfSpace.cpp | 2 +- src/ifcgeom/mapping/IfcPolygonalFaceSet.cpp | 2 +- src/ifcgeom/mapping/IfcPolyline.cpp | 2 +- src/ifcgeom/mapping/IfcProduct.cpp | 6 +- .../mapping/IfcRectangleHollowProfileDef.cpp | 2 +- .../mapping/IfcRectangleProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcRectangularPyramid.cpp | 2 +- .../mapping/IfcRectangularTrimmedSurface.cpp | 4 +- src/ifcgeom/mapping/IfcRepresentation.cpp | 2 +- src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp | 2 +- src/ifcgeom/mapping/IfcRightCircularCone.cpp | 4 +- .../mapping/IfcRightCircularCylinder.cpp | 4 +- .../mapping/IfcRoundedRectangleProfileDef.cpp | 2 +- .../mapping/IfcSectionedSolidHorizontal.cpp | 2 +- src/ifcgeom/mapping/IfcSectionedSurface.cpp | 2 +- .../mapping/IfcSegmentedReferenceCurve.cpp | 4 +- .../mapping/IfcShellBasedSurfaceModel.cpp | 2 +- src/ifcgeom/mapping/IfcSphere.cpp | 2 +- src/ifcgeom/mapping/IfcSphericalSurface.cpp | 4 +- src/ifcgeom/mapping/IfcSubedge.cpp | 2 +- src/ifcgeom/mapping/IfcSurfaceCurve.cpp | 2 +- .../mapping/IfcSurfaceCurveSweptAreaSolid.cpp | 6 +- .../mapping/IfcSurfaceOfLinearExtrusion.cpp | 2 +- .../mapping/IfcSurfaceOfRevolution.cpp | 2 +- src/ifcgeom/mapping/IfcSweptDiskSolid.cpp | 2 +- src/ifcgeom/mapping/IfcTShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcToroidalSurface.cpp | 2 +- .../mapping/IfcTrapeziumProfileDef.cpp | 2 +- .../mapping/IfcTriangulatedFaceSet.cpp | 4 +- src/ifcgeom/mapping/IfcTrimmedCurve.cpp | 2 +- src/ifcgeom/mapping/IfcUShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/IfcVector.cpp | 2 +- src/ifcgeom/mapping/IfcZShapeProfileDef.cpp | 2 +- src/ifcgeom/mapping/bind_convert_decl.i | 2 +- src/ifcgeom/mapping/mapping.cpp | 69 +- src/ifcgeom/mapping/mapping.h | 30 +- src/ifcgeom/mapping/plugin.cpp | 10 +- src/ifcgeom/mapping_plugin.cpp | 12 +- src/ifcgeom/mapping_plugin.h | 2 +- src/ifcgeom/profile_helper.cpp | 10 +- src/ifcgeom/profile_helper.h | 2 +- src/ifcgeom/taxonomy.cpp | 64 +- src/ifcgeom/taxonomy.h | 70 +- .../tests/test_ifcopenshell_geometry.cpp | 32 +- src/ifcgeom/tree.cpp | 86 +-- src/ifcgeom/tree.h | 44 +- src/ifcgeom/tree_plugin.cpp | 12 +- src/ifcgeom/tree_plugin.h | 2 +- src/ifcgeom/tree_registry.cpp | 46 +- src/ifcgeom/tree_registry.h | 30 +- src/ifcgeomserver/IfcGeomServer.cpp | 34 +- .../geometry_processing.rst | 11 +- .../docs/ifcopenshell/geometry_settings.rst | 22 +- .../docs/ifcopenshell/serialiser_settings.rst | 8 +- src/ifcopenshell-python/ifcopenshell/draw.py | 49 +- .../ifcopenshell/express/header.py | 6 +- .../ifcopenshell/express/implementation.py | 8 +- .../ifcopenshell/express/templates.py | 30 +- .../ifcopenshell/geom/main.py | 112 ++- .../ifcopenshell/ifcopenshell_wrapper.pyi | 11 +- .../test/test_create_shape.py | 17 +- src/ifcparse/entity_instance_data.cpp | 80 +- src/ifcparse/express.cpp | 10 +- src/ifcparse/express.h | 93 +-- src/ifcparse/file.cpp | 32 +- src/ifcparse/file.h | 46 +- src/ifcparse/file_reader.cpp | 4 +- src/ifcparse/file_reader.h | 8 +- src/ifcparse/hierarchy_helper.h | 12 +- src/ifcparse/instance_data.h | 76 +- src/ifcparse/logger.cpp | 38 +- src/ifcparse/logger.h | 68 +- src/ifcparse/parse.cpp | 416 +++++------ src/ifcparse/parse.h | 4 +- src/ifcparse/spf_header.cpp | 18 +- src/ifcparse/storage.h | 40 +- src/ifcparse/utils.cpp | 4 +- src/ifcparse/variant_array.h | 98 +-- src/ifcviewer/GeometryStreamer.cpp | 26 +- src/ifcwrap/IfcGeomWrapper.i | 691 +++++++++--------- src/ifcwrap/IfcParseWrapper.i | 146 ++-- src/ifcwrap/IfcPython.i | 14 +- src/ifcwrap/utils/type_conversion.i | 123 ++-- src/ifcwrap/utils/typemaps_in.i | 22 +- src/ifcwrap/utils/typemaps_out.i | 86 +-- src/pyodide/demo-app/context.py | 2 +- src/serializers/ColladaSerializer.cpp | 76 +- src/serializers/ColladaSerializer.h | 118 +-- src/serializers/GltfSerializer.cpp | 58 +- src/serializers/GltfSerializer.h | 14 +- src/serializers/IgesSerializer.h | 10 +- src/serializers/JsonSerializer.h | 8 +- .../OpenCascadeBasedSerializer.cpp | 8 +- src/serializers/OpenCascadeBasedSerializer.h | 16 +- src/serializers/RocksDbSerializer.cpp | 24 +- src/serializers/RocksDbSerializer.h | 2 +- src/serializers/StepSerializer.h | 8 +- src/serializers/SvgSerializer.cpp | 276 ++++--- src/serializers/SvgSerializer.h | 76 +- src/serializers/TtlWktSerializer.cpp | 43 +- src/serializers/TtlWktSerializer.h | 12 +- src/serializers/USDSerializer.cpp | 30 +- src/serializers/USDSerializer.h | 20 +- src/serializers/WavefrontObjSerializer.cpp | 24 +- src/serializers/WavefrontObjSerializer.h | 12 +- src/serializers/XmlSerializer.h | 8 +- src/serializers/document_rdb_plugin.cpp | 2 +- .../document_serializer_plugin.cpp | 2 +- src/serializers/document_serializer_plugin.h | 4 +- src/serializers/geometry_dae_plugin.cpp | 4 +- src/serializers/geometry_glb_plugin.cpp | 4 +- src/serializers/geometry_igs_plugin.cpp | 8 +- src/serializers/geometry_obj_plugin.cpp | 10 +- .../geometry_serializer_plugin.cpp | 2 +- src/serializers/geometry_serializer_plugin.h | 7 +- src/serializers/geometry_stp_plugin.cpp | 8 +- src/serializers/geometry_svg_plugin.cpp | 12 +- src/serializers/geometry_ttl_plugin.cpp | 14 +- src/serializers/geometry_usd_plugin.cpp | 4 +- .../schema_dependent/JsonSerializer.cpp | 24 +- .../schema_dependent/JsonSerializer.h | 10 +- .../schema_dependent/XmlSerializer.cpp | 36 +- .../schema_dependent/XmlSerializer.h | 12 +- .../schema_dependent/json_plugin.cpp | 6 +- .../schema_dependent/xml_plugin.cpp | 4 +- src/wrappergen/generate.py | 8 +- .../ifcopenshell_experimental_c_api.cpp | 20 +- 300 files changed, 5230 insertions(+), 5150 deletions(-) diff --git a/docs/cpp-api/Doxyfile b/docs/cpp-api/Doxyfile index 9cda87ede0..fa2a850162 100644 --- a/docs/cpp-api/Doxyfile +++ b/docs/cpp-api/Doxyfile @@ -1024,14 +1024,13 @@ EXCLUDE_PATTERNS = # wildcard * is used, a substring. Examples: ANamespace, AClass, # ANamespace::AClass, ANamespace::*Test -EXCLUDE_SYMBOLS = "IfcGeom::OpaqueNumber::*" \ - "ifcopenshell::geometry::OpaqueNumber::*" \ +EXCLUDE_SYMBOLS = "ifcopenshell::geom::opaque_number::*" \ ifcopenshell::entity::attribute_by_name_cmp \ ifcopenshell::impl::rocks_db_file_storage::rocksdb_types_iterator \ ifcopenshell::impl::in_memory_file_storage::type_iterator \ "util::string_buffer::*_item" \ util::string_buffer::item \ - IfcGeom::layer_filter::wildcards_match \ + ifcopenshell::geom::layer_filter::wildcards_match \ ifcopenshell::paged_file_impl::Entry \ attribute_value::pointer_type \ INCLUDE_PARENT_PARENT_DIR \ @@ -1048,9 +1047,9 @@ EXCLUDE_SYMBOLS = "IfcGeom::OpaqueNumber::*" \ equals_ \ less_than_ \ negate_ \ - ifcopenshell::geometry::utils::create_cube \ - ifcopenshell::geometry::utils::create_polyhedron \ - ifcopenshell::geometry::utils::create_nef_polyhedron + ifcopenshell::geom::utils::create_cube \ + ifcopenshell::geom::utils::create_polyhedron \ + ifcopenshell::geom::utils::create_nef_polyhedron # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include @@ -2389,8 +2388,8 @@ PREDEFINED = IFC_PARSE_API= \ # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. EXPAND_AS_DEFINED = Kernel_ \ - CgalShape \ - CgalKernel \ + cgal_shape \ + cgal_kernel \ cgal_placement_t \ cgal_point_t \ cgal_direction_t \ diff --git a/nix/build-all.py b/nix/build-all.py index ce34ee6300..c0e9d238f9 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -1020,7 +1020,7 @@ if USE_OCCT and "occ" in targets: # Skip ExpToCasExe as we don't need it and it requires additional dependencies. # Before 7.7.2 ExpToCasExe is part of DataExchange, DETools doesn't exist yet. - # Since we do need DataExchange (used for IgesSerializer), we use a patch to skip only ExpToCasExe. + # Since we do need DataExchange (used for iges_serializer), we use a patch to skip only ExpToCasExe. if "7.7.2" > OCCT_VERSION >= "7.7": patches.append("./patches/occt/no_ExpToCasExe.patch") elif OCCT_VERSION >= "7.7.2": diff --git a/src/bonsai/bonsai/bim/ifc.py b/src/bonsai/bonsai/bim/ifc.py index e532c4d5ac..c5dfabf046 100644 --- a/src/bonsai/bonsai/bim/ifc.py +++ b/src/bonsai/bonsai/bim/ifc.py @@ -185,13 +185,10 @@ class IfcStore: os.makedirs(os.path.dirname(cache_path), exist_ok=True) IfcStore.cache_path = cache_path cache_path = Path(IfcStore.cache_path) - cache_settings = ifcopenshell.geom.settings() - serializer_settings = ifcopenshell.geom.serializer_settings() + settings = ifcopenshell.geom.settings() cache_preexists = cache_path.exists() try: - IfcStore.cache = ifcopenshell.geom.serializers.hdf5( - IfcStore.cache_path, cache_settings, serializer_settings - ) + IfcStore.cache = ifcopenshell.geom.serializers.hdf5(IfcStore.cache_path, settings) if cache_preexists: print(f"Successfully loaded existing cache: {cache_path.name}.") else: @@ -206,9 +203,7 @@ class IfcStore: os.remove(IfcStore.cache_path) try: - IfcStore.cache = ifcopenshell.geom.serializers.hdf5( - IfcStore.cache_path, cache_settings, serializer_settings - ) + IfcStore.cache = ifcopenshell.geom.serializers.hdf5(IfcStore.cache_path, settings) print("New cache was created.") except Exception as e: print(f"Failed to create a cache: {str(e)}.") diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 67883363c5..2efa980659 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -1406,31 +1406,28 @@ class CreateDrawing(bpy.types.Operator): # Backwards compatibility with older ifcopenshell builds that don't expose these keys. pass self.svg_buffer = ifcopenshell.geom.serializers.buffer() - self.serialiser_settings = ifcopenshell.geom.serializer_settings() - self.serialiser_settings.set("svg-without-storeys", True) - self.serialiser_settings.set("svg-write-poly", True) - self.serialiser_settings.set("svg-poly", True) + self.svg_settings.set("svg-without-storeys", True) + self.svg_settings.set("svg-write-poly", True) + self.svg_settings.set("svg-poly", True) # Objects with more than these edges are rendered as wireframe instead of HLR for optimisation - self.serialiser_settings.set("profile-threshold", 10000) - self.serialiser_settings.set("svg-xmlns", True) - self.serialiser_settings.set("svg-project", True) - self.serialiser_settings.set("auto-elevation", False) - self.serialiser_settings.set("auto-section", False) - self.serialiser_settings.set("print-space-names", False) - self.serialiser_settings.set("print-space-areas", False) - self.serialiser_settings.set("door-arcs", False) - self.serialiser_settings.set("svg-no-css", True) - self.serialiser_settings.set("elevation-ref-guid", self.camera_element.GlobalId) - self.serialiser_settings.set("scale", str(self.scale)) - self.serialiser_settings.set("svg-subtract-before", "always") - self.serialiser_settings.set("svg-prefilter", True) # See #3359 - self.serialiser_settings.set("svg-unify-inputs", True) - self.serialiser_settings.set("svg-segment-projection", True) + self.svg_settings.set("profile-threshold", 10000) + self.svg_settings.set("svg-xmlns", True) + self.svg_settings.set("svg-project", True) + self.svg_settings.set("auto-elevation", False) + self.svg_settings.set("auto-section", False) + self.svg_settings.set("print-space-names", False) + self.svg_settings.set("print-space-areas", False) + self.svg_settings.set("door-arcs", False) + self.svg_settings.set("svg-no-css", True) + self.svg_settings.set("elevation-ref-guid", self.camera_element.GlobalId) + self.svg_settings.set("scale", str(self.scale)) + self.svg_settings.set("svg-subtract-before", "always") + self.svg_settings.set("svg-prefilter", True) # See #3359 + self.svg_settings.set("svg-unify-inputs", True) + self.svg_settings.set("svg-segment-projection", True) if target_view == "REFLECTED_PLAN_VIEW": - self.serialiser_settings.set("svg-mirror-y", True) - self.serialiser = ifcopenshell.geom.serializers.svg( - self.svg_buffer, self.svg_settings, self.serialiser_settings - ) + self.svg_settings.set("svg-mirror-y", True) + self.serialiser = ifcopenshell.geom.serializers.svg(self.svg_buffer, self.svg_settings) # tree = ifcopenshell.geom.tree() # This instructs the tree to explode BReps into faces and return # the style of the face when running tree.select_ray() diff --git a/src/bonsai/bonsai/bim/module/light/operator.py b/src/bonsai/bonsai/bim/module/light/operator.py index bfdb0644cd..2206a0c519 100644 --- a/src/bonsai/bonsai/bim/module/light/operator.py +++ b/src/bonsai/bonsai/bim/module/light/operator.py @@ -72,11 +72,10 @@ class ExportOBJ(bpy.types.Operator): # Conversion from IFC to OBJ # Settings for obj settings = ifcopenshell.geom.settings() - serializer_settings = ifcopenshell.geom.serializer_settings() settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.SURFACES_AND_SOLIDS) settings.set("apply-default-materials", True) - serializer_settings.set("use-element-guids", True) + settings.set("use-element-guids", True) settings.set("use-world-coords", True) ifc_file: ifcopenshell.file @@ -90,7 +89,7 @@ class ExportOBJ(bpy.types.Operator): obj_file_path = os.path.join(output_dir, "model.obj") mtl_file_path = os.path.join(output_dir, "model.mtl") - serialiser = ifcopenshell.geom.serializers.obj(obj_file_path, mtl_file_path, settings, serializer_settings) + serialiser = ifcopenshell.geom.serializers.obj(obj_file_path, mtl_file_path, settings) serialiser.setFile(ifc_file) serialiser.setUnitNameAndMagnitude("METER", 1.0) serialiser.writeHeader() diff --git a/src/bonsai/scripts/standalone_drawer.py b/src/bonsai/scripts/standalone_drawer.py index acffb8994a..a02162a0e9 100644 --- a/src/bonsai/scripts/standalone_drawer.py +++ b/src/bonsai/scripts/standalone_drawer.py @@ -163,32 +163,29 @@ class Drawer: # self.svg_settings.set_deflection_tolerance(0.0001) self.svg_buffer = ifcopenshell.geom.serializers.buffer() - self.serialiser_settings = ifcopenshell.geom.serializer_settings() - self.serialiser_settings.set("svg-without-storeys", True) - self.serialiser_settings.set("svg-write-poly", True) - self.serialiser_settings.set("svg-poly", True) + self.svg_settings.set("svg-without-storeys", True) + self.svg_settings.set("svg-write-poly", True) + self.svg_settings.set("svg-poly", True) # Objects with more than these edges are rendered as wireframe instead of HLR for optimisation - self.serialiser_settings.set("profile-threshold", 10000) - self.serialiser_settings.set("svg-xmlns", True) - self.serialiser_settings.set("svg-project", True) - self.serialiser_settings.set("auto-elevation", False) - self.serialiser_settings.set("auto-section", False) - self.serialiser_settings.set("print-space-names", False) - self.serialiser_settings.set("print-space-areas", False) - self.serialiser_settings.set("door-arcs", False) - self.serialiser_settings.set("svg-no-css", True) - self.serialiser_settings.set("elevation-ref-guid", self.camera_element.GlobalId) - self.serialiser_settings.set("scale", "1/50") - self.serialiser_settings.set("svg-subtract-before", "always") - self.serialiser_settings.set("svg-prefilter", True) # See #3359 - # self.serialiser_settings.set("svg-prefilter", False) # See #3359 - self.serialiser_settings.set("svg-unify-inputs", True) - self.serialiser_settings.set("svg-segment-projection", True) + self.svg_settings.set("profile-threshold", 10000) + self.svg_settings.set("svg-xmlns", True) + self.svg_settings.set("svg-project", True) + self.svg_settings.set("auto-elevation", False) + self.svg_settings.set("auto-section", False) + self.svg_settings.set("print-space-names", False) + self.svg_settings.set("print-space-areas", False) + self.svg_settings.set("door-arcs", False) + self.svg_settings.set("svg-no-css", True) + self.svg_settings.set("elevation-ref-guid", self.camera_element.GlobalId) + self.svg_settings.set("scale", "1/50") + self.svg_settings.set("svg-subtract-before", "always") + self.svg_settings.set("svg-prefilter", True) # See #3359 + # self.svg_settings.set("svg-prefilter", False) # See #3359 + self.svg_settings.set("svg-unify-inputs", True) + self.svg_settings.set("svg-segment-projection", True) if target_view == "REFLECTED_PLAN_VIEW": - self.serialiser_settings.set("svg-mirror-y", True) - self.serialiser = ifcopenshell.geom.serializers.svg( - self.svg_buffer, self.svg_settings, self.serialiser_settings - ) + self.svg_settings.set("svg-mirror-y", True) + self.serialiser = ifcopenshell.geom.serializers.svg(self.svg_buffer, self.svg_settings) self.serialiser.setFile(ifc) diff --git a/src/bonsaiviewer/ElementRegistry.cpp b/src/bonsaiviewer/ElementRegistry.cpp index 84221f4be9..76664f4b96 100644 --- a/src/bonsaiviewer/ElementRegistry.cpp +++ b/src/bonsaiviewer/ElementRegistry.cpp @@ -70,7 +70,7 @@ std::optional ElementRegistry::findBasicElementInfo(uint32_t o return it->second; } -std::optional ElementRegistry::findEntity(uint32_t object_id) const { +std::optional ElementRegistry::findEntity(uint32_t object_id) const { if (!loader_) return std::nullopt; auto info = findBasicElementInfo(object_id); diff --git a/src/bonsaiviewer/ElementRegistry.h b/src/bonsaiviewer/ElementRegistry.h index 409554d643..947df285d1 100644 --- a/src/bonsaiviewer/ElementRegistry.h +++ b/src/bonsaiviewer/ElementRegistry.h @@ -54,7 +54,7 @@ public: void removeModel(uint32_t session_model_id); std::vector basicElementInfoForModel(uint32_t session_model_id) const; std::optional findBasicElementInfo(uint32_t object_id) const; - std::optional findEntity(uint32_t object_id) const; + std::optional findEntity(uint32_t object_id) const; private: void onSidecarElementsReady(uint32_t session_model_id, diff --git a/src/bonsaiviewer/docs/viewport_architecture.rst b/src/bonsaiviewer/docs/viewport_architecture.rst index a23ee7dd2f..47c0c52c7f 100644 --- a/src/bonsaiviewer/docs/viewport_architecture.rst +++ b/src/bonsaiviewer/docs/viewport_architecture.rst @@ -44,7 +44,7 @@ Main components code. ``GeometryStreamer`` - Runs ``IfcGeom::Iterator`` on a worker thread for raw IFC loads. It emits a + Runs ``ifcopenshell::geom::iterator`` on a worker thread for raw IFC loads. It emits a ``StreamedMesh`` once for each unique representation mesh and a ``StreamedInstance`` for each placed occurrence. diff --git a/src/bonsaiviewer/modules/models/Commands.cpp b/src/bonsaiviewer/modules/models/Commands.cpp index 954f0dffb6..fcd7a02fea 100644 --- a/src/bonsaiviewer/modules/models/Commands.cpp +++ b/src/bonsaiviewer/modules/models/Commands.cpp @@ -685,7 +685,7 @@ void convertIfcToDatabase(SessionState& session, QWidget& host) { throw ifcopenshell::exception("RDB serializer does not support streaming from an input filename"); } - boost::shared_ptr serializer = registry.create("rdb", context); + boost::shared_ptr serializer = registry.create("rdb", context); serializer->finalize(); } catch (const std::exception& e) { *error_message = QString::fromUtf8(e.what()); @@ -791,7 +791,7 @@ void exportGeometryDatabase(SessionState& session, QWidget& host) { throw ifcopenshell::exception("RDB serializer does not support streaming from an input filename"); } - boost::shared_ptr serializer = registry.create("rdb", context); + boost::shared_ptr serializer = registry.create("rdb", context); serializer->finalize(); serializer.reset(); diff --git a/src/bonsaiviewer/modules/models/SettingsView.cpp b/src/bonsaiviewer/modules/models/SettingsView.cpp index b8c0f74cf8..a181e767c3 100644 --- a/src/bonsaiviewer/modules/models/SettingsView.cpp +++ b/src/bonsaiviewer/modules/models/SettingsView.cpp @@ -82,9 +82,9 @@ std::string enumString(const attribute_value& av) { return std::string(enumeration.value() ? enumeration.value() : ""); } -QString formatNamedUnit(const express::Base& unit) { +QString formatNamedUnit(const express::base& unit) { if (!unit) return "—"; - auto entity = unit.as(); + auto entity = unit.as(); if (unit.declaration().is("IfcSIUnit")) { const std::string prefix = enumString(entity.get("Prefix")); const std::string name = enumString(entity.get("Name")); diff --git a/src/bonsaiviewer/modules/properties/View.cpp b/src/bonsaiviewer/modules/properties/View.cpp index de9d820b61..2f8abfea0d 100644 --- a/src/bonsaiviewer/modules/properties/View.cpp +++ b/src/bonsaiviewer/modules/properties/View.cpp @@ -109,7 +109,7 @@ void PropertiesPanelView::refresh(uint32_t object_id) { state.entity = {"No item selected", ""}; auto entity = registry ? registry->findEntity(object_id) - : std::optional{}; + : std::optional{}; if (entity) { state.entity.entity_class = QString::fromStdString(entity->declaration().name()); if (auto predefined_type = get_predefined_type(*entity)) { @@ -121,16 +121,16 @@ void PropertiesPanelView::refresh(uint32_t object_id) { } // Relationships: the construction type and the spatial container, shown // by name (falling back to the entity class when unnamed). - auto display_name = [](const express::Base& related) -> QString { + auto display_name = [](const express::base& related) -> QString { if (auto name = get_string_attribute(related, "Name"); name && !name->empty()) { return QString::fromStdString(*name); } return QString::fromStdString(related.declaration().name()); }; - if (express::Base type = get_type(*entity)) { + if (express::base type = get_type(*entity)) { state.relationships.append({"Type", display_name(type)}); } - if (express::Base container = get_container(*entity)) { + if (express::base container = get_container(*entity)) { state.relationships.append({"Container", display_name(container)}); } // Property sets (Pset_*) and quantity sets (Qto_* / BaseQuantities), diff --git a/src/bonsaiviewer/modules/spatial_hierarchy/View.cpp b/src/bonsaiviewer/modules/spatial_hierarchy/View.cpp index 765fe7273c..aee94525ed 100644 --- a/src/bonsaiviewer/modules/spatial_hierarchy/View.cpp +++ b/src/bonsaiviewer/modules/spatial_hierarchy/View.cpp @@ -60,7 +60,7 @@ TreeNode* findNodeRecursive(QList& nodes, const NodePath& path, int de return nullptr; } -ItemKind kindOf(const express::Base& element) { +ItemKind kindOf(const express::base& element) { const auto& declaration = element.declaration(); if (declaration.is("IfcSite")) return ItemKind::Site; if (declaration.is("IfcBuilding")) return ItemKind::Building; @@ -68,14 +68,14 @@ ItemKind kindOf(const express::Base& element) { return ItemKind::Space; // IfcSpace, IfcSpatialZone, … } -QString displayName(const express::Base& element) { +QString displayName(const express::base& element) { if (auto name = get_string_attribute(element, "Name"); name && !name->empty()) { return QString::fromStdString(*name); } return QString::fromStdString(element.declaration().name()); } -TreeNode buildNode(const express::Base& element) { +TreeNode buildNode(const express::base& element) { TreeNode node; node.name = displayName(element); node.kind = kindOf(element); diff --git a/src/examples/IfcAdvancedHouse.cpp b/src/examples/IfcAdvancedHouse.cpp index 5d13a516f5..a9cfa8add7 100644 --- a/src/examples/IfcAdvancedHouse.cpp +++ b/src/examples/IfcAdvancedHouse.cpp @@ -101,7 +101,7 @@ int main() { // IfcFacetedBRep. If it would not be a polyhedron, serialise() can only be successful when linked // to the IFC4 model and with `advanced` set to `true` which introduces IfcAdvancedFace. It would // return `0` otherwise. - auto building_shape = IfcGeom::serialise(file, building_shell, false).as(); + auto building_shape = ifcopenshell::geom::serialise(file, building_shell, false).as(); file.add_entity(building_shape); auto building_representations = building_shape.Representations(); @@ -117,9 +117,9 @@ int main() { TopoDS_Shape shape; createGroundShape(shape); - auto ground_representation = IfcGeom::serialise(file, shape, true); + auto ground_representation = ifcopenshell::geom::serialise(file, shape, true); if (!ground_representation) { - ground_representation = IfcGeom::tesselate(file, shape, 100.); + ground_representation = ifcopenshell::geom::tesselate(file, shape, 100.); } file.getSingle().setRepresentation(ground_representation.as()); @@ -134,10 +134,10 @@ int main() { // Note that IFC lacks elementary surfaces that STEP does have, such as spherical_surface. // BRepBuilderAPI_NurbsConvert can be used to serialize such surfaces as nurbs surfaces. TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(gp_Pnt(), 1000.).Shape(); - IfcSchema::IfcProductDefinitionShape* sphere_representation = IfcGeom::serialise(sphere, true); + IfcSchema::IfcProductDefinitionShape* sphere_representation = ifcopenshell::geom::serialise(sphere, true); if (S(IfcSchema::Identifier) == "IFC4") { sphere = BRepBuilderAPI_NurbsConvert(sphere, true).Shape(); - sphere_representation = IfcGeom::serialise(sphere, true); + sphere_representation = ifcopenshell::geom::serialise(sphere, true); } */ diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index 99e8d56e1c..ac208c5d6f 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -301,7 +301,7 @@ int main() { // will be tessellated using the deflection specified. TopoDS_Shape shape; createGroundShape(shape); - auto ground_representation = IfcGeom::tesselate(file, shape, 100.).as(); + auto ground_representation = ifcopenshell::geom::tesselate(file, shape, 100.).as(); file.getSingle().setRepresentation(ground_representation); GProp_GProps prop; diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index 6b9f07102d..4e86a8fe99 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -194,7 +194,7 @@ void get_psets_s(element_properties& props, const typename Schema::IfcObjectDefi } } -element_properties get_psets(const express::Base& inst) { +element_properties get_psets(const express::base& inst) { element_properties props; if (auto object_definition = inst.as()) { get_psets_s(props, object_definition); diff --git a/src/helpers/element.cpp b/src/helpers/element.cpp index 820ce7a823..9485fcbf45 100644 --- a/src/helpers/element.cpp +++ b/src/helpers/element.cpp @@ -41,7 +41,7 @@ struct is_ifc4_or_higher : std::false_type {}; template struct is_ifc4_or_higher> : std::true_type {}; -std::string schema_name(const express::Base& instance) { +std::string schema_name(const express::base& instance) { return instance.declaration().schema()->name(); } @@ -87,7 +87,7 @@ std::optional format_scalar(const attribute_value& value) { // ifcopenshell.util.element.get_type: the construction type of an occurrence // (get_type(type_element) == type_element). template -express::Base get_type_s(const express::Base& element) { +express::base get_type_s(const express::base& element) { if (element.template as()) { return element; } @@ -111,9 +111,9 @@ express::Base get_type_s(const express::Base& element) { } template -std::optional get_predefined_type_s(const express::Base& element) { +std::optional get_predefined_type_s(const express::base& element) { // Prefer the associated type element's predefined type. - if (const express::Base type = get_type_s(element)) { + if (const express::base type = get_type_s(element)) { std::optional predefined_type = get_string_attribute(type, "PredefinedType"); if (!predefined_type || *predefined_type == "USERDEFINED") { // ElementType (IfcElementType) or ProcessType (IfcTypeProcess) — the @@ -140,7 +140,7 @@ std::optional get_predefined_type_s(const express::Base& element) { // ifcopenshell.util.element.get_aggregate: the aggregate parent, via the // Decomposes inverse (IfcRelAggregates.RelatingObject). template -express::Base get_aggregate_s(const express::Base& element) { +express::base get_aggregate_s(const express::base& element) { const auto object = element.template as(); if (!object) { return {}; @@ -162,8 +162,8 @@ express::Base get_aggregate_s(const express::Base& element) { // The spatial-structure children aggregated under this element (IsDecomposedBy → // RelatedObjects, filtered to spatial elements). template -std::vector get_spatial_children_s(const express::Base& element) { - std::vector children; +std::vector get_spatial_children_s(const express::base& element) { + std::vector children; const auto object = element.template as(); if (!object) { return children; @@ -182,14 +182,14 @@ std::vector get_spatial_children_s(const express::Base& element) // ifc_class): the directly containing spatial element, or the container of the // aggregate parent for an aggregated part. template -express::Base get_container_s(const express::Base& element) { +express::base get_container_s(const express::base& element) { if (const auto product = element.template as()) { const auto relationships = product.ContainedInStructure(); if (!relationships.empty()) { return relationships.front().RelatingStructure(); } } - if (const express::Base aggregate = get_aggregate_s(element)) { + if (const express::base aggregate = get_aggregate_s(element)) { return get_container_s(aggregate); } return {}; @@ -197,7 +197,7 @@ express::Base get_container_s(const express::Base& element) { } // namespace -std::optional get_predefined_type(const express::Base& element) { +std::optional get_predefined_type(const express::base& element) { if (!element) { return std::nullopt; } @@ -211,7 +211,7 @@ std::optional get_predefined_type(const express::Base& element) { unsupported_schema(name); } -std::vector> get_scalar_attributes(const express::Base& element) { +std::vector> get_scalar_attributes(const express::base& element) { std::vector> result; if (!element) { return result; @@ -230,7 +230,7 @@ std::vector> get_scalar_attributes(const exp return result; } -express::Base get_type(const express::Base& element) { +express::base get_type(const express::base& element) { if (!element) { return {}; } @@ -244,7 +244,7 @@ express::Base get_type(const express::Base& element) { unsupported_schema(name); } -express::Base get_container(const express::Base& element) { +express::base get_container(const express::base& element) { if (!element) { return {}; } @@ -258,7 +258,7 @@ express::Base get_container(const express::Base& element) { unsupported_schema(name); } -std::vector get_spatial_children(const express::Base& element) { +std::vector get_spatial_children(const express::base& element) { if (!element) { return {}; } @@ -275,7 +275,7 @@ std::vector get_spatial_children(const express::Base& element) { // getattr(element, name) for a string- or enum-valued attribute. Reads by name, // so it works uniformly across the various subtypes that carry a given // attribute (PredefinedType, Name, ...). -std::optional get_string_attribute(const express::Base& element, +std::optional get_string_attribute(const express::base& element, const std::string& name) { if (!element) { return std::nullopt; diff --git a/src/helpers/element.h b/src/helpers/element.h index 3b477846c4..017e2b84f0 100644 --- a/src/helpers/element.h +++ b/src/helpers/element.h @@ -35,35 +35,35 @@ // type of the associated type element (via IsTypedBy / IsDefinedBy) first. // std::nullopt when there is no such attribute (e.g. the element is not an // IfcObject, or a geometry-only proxy with no live IFC data). -std::optional get_predefined_type(const express::Base& element); +std::optional get_predefined_type(const express::base& element); // Mirrors ifcopenshell.util.element.get_type: the construction type element of // an occurrence (via IsTypedBy on IFC4+, IsDefinedBy on IFC2X3). A type element -// returns itself. Empty express::Base when the element is untyped. -express::Base get_type(const express::Base& element); +// returns itself. Empty express::base when the element is untyped. +express::base get_type(const express::base& element); // Mirrors ifcopenshell.util.element.get_container (indirect, no ifc_class // filter): the spatial element that contains this element — the directly // containing spatial structure, or, for an aggregated part, the container of its // aggregate parent. Empty when uncontained. (The nest / filled-void / // voided-element branches of the Python original are not ported.) -express::Base get_container(const express::Base& element); +express::base get_container(const express::base& element); // Safely read a string- or enum-valued attribute by name (Python's getattr). // std::nullopt when the attribute is absent for this entity's type or IFC null. -std::optional get_string_attribute(const express::Base& element, +std::optional get_string_attribute(const express::base& element, const std::string& name); // The spatial-structure elements aggregated directly under `element` (its // IsDecomposedBy → RelatedObjects, filtered to spatial elements). Used to walk // the IfcProject → IfcSite → IfcBuilding → IfcBuildingStorey → IfcSpace tree. -std::vector get_spatial_children(const express::Base& element); +std::vector get_spatial_children(const express::base& element); // The element's direct EXPRESS attributes that have a primitive scalar value // (string / enum / integer / real / boolean / logical), as (name, formatted // value) pairs in declaration order. Attributes that are entity references, // aggregates / lists, or unset (IFC null) are omitted — so the caller gets a // flat, display-ready view with no nested objects. -std::vector> get_scalar_attributes(const express::Base& element); +std::vector> get_scalar_attributes(const express::base& element); #endif // ELEMENT_H diff --git a/src/helpers/geolocation.cpp b/src/helpers/geolocation.cpp index d65ca09892..8e2670f0fe 100644 --- a/src/helpers/geolocation.cpp +++ b/src/helpers/geolocation.cpp @@ -83,7 +83,7 @@ double numeric_property(const property_map& properties, return fallback; } -double selected_number(const express::Base& selected, double fallback) { +double selected_number(const express::base& selected, double fallback) { if (!selected) { return fallback; } @@ -184,7 +184,7 @@ template std::optional get_wcs_s(ifcopenshell::file* ifc_file) { const auto contexts = ifc_file->template instances_by_type_excl_subtypes(); - express::Base wcs; + express::base wcs; for (const auto& context : contexts) { const auto placement = context.WorldCoordinateSystem(); if (!placement) { @@ -202,7 +202,7 @@ std::optional get_wcs_s(ifcopenshell::file* ifc_file) { } template -std::optional get_map_unit_s(ifcopenshell::file* ifc_file) { +std::optional get_map_unit_s(ifcopenshell::file* ifc_file) { if constexpr (!is_ifc4_or_higher::value) { return std::nullopt; } else { @@ -328,7 +328,7 @@ Eigen::Matrix4d helmert_meters_from_parameters(const HelmertTransformation& p, return M; } -std::optional get_map_unit(ifcopenshell::file* ifc_file) { +std::optional get_map_unit(ifcopenshell::file* ifc_file) { const auto name = ifc_file->schema()->name(); #define IFCOPENSHELL_DISPATCH(Schema, Identifier) \ if (name == Identifier) \ diff --git a/src/helpers/geolocation.h b/src/helpers/geolocation.h index 10a9c08ab0..94194d2acc 100644 --- a/src/helpers/geolocation.h +++ b/src/helpers/geolocation.h @@ -98,7 +98,7 @@ Eigen::Matrix4d helmert_meters_from_parameters(const HelmertTransformation& para // when MapUnit is absent on the IfcProjectedCRS. This is retained for UI / // metadata inspection; transform composition derives map unit scale from // IfcMapConversion.Scale instead. -std::optional get_map_unit(ifcopenshell::file* ifc_file); +std::optional get_map_unit(ifcopenshell::file* ifc_file); // "How do I rotate project east to get to grid east?" — i.e. -atan2(xao, xaa) // converted to degrees, anticlockwise positive. Mirrors diff --git a/src/helpers/placement.cpp b/src/helpers/placement.cpp index 37c0c5d29a..be35216435 100644 --- a/src/helpers/placement.cpp +++ b/src/helpers/placement.cpp @@ -84,7 +84,7 @@ Eigen::Matrix4d axis2_placement_3d_s(const Placement& placement) { } template -Eigen::Matrix4d get_axis2_placement_s(const express::Base& placement) { +Eigen::Matrix4d get_axis2_placement_s(const express::base& placement) { if (auto axis3 = placement.template as()) { return axis2_placement_3d_s(axis3); } @@ -113,7 +113,7 @@ Eigen::Matrix4d get_axis2_placement_s(const express::Base& placement) { } template -Eigen::Matrix4d get_local_placement_s(const express::Base& placement) { +Eigen::Matrix4d get_local_placement_s(const express::base& placement) { if (auto local = placement.template as()) { Eigen::Matrix4d parent = Eigen::Matrix4d::Identity(); if (const auto relative_to = local.PlacementRelTo()) { @@ -131,7 +131,7 @@ Eigen::Matrix4d get_local_placement_s(const express::Base& placement) { // ifcopenshell.util.placement.get_storey_elevation: the Z of the storey's // placement in project units, falling back to the Elevation attribute. template -double get_storey_elevation_s(const express::Base& storey) { +double get_storey_elevation_s(const express::base& storey) { const auto typed = storey.template as(); if (!typed) { return 0.0; @@ -170,7 +170,7 @@ Eigen::Matrix4d axes_to_placement(const Eigen::Vector3d& origin, return m; } -Eigen::Matrix4d get_axis2_placement(const express::Base& placement) { +Eigen::Matrix4d get_axis2_placement(const express::base& placement) { if (!placement) { return Eigen::Matrix4d::Identity(); } @@ -183,7 +183,7 @@ Eigen::Matrix4d get_axis2_placement(const express::Base& placement) { unsupported_schema(name); } -Eigen::Matrix4d get_local_placement(const express::Base& placement) { +Eigen::Matrix4d get_local_placement(const express::base& placement) { if (!placement) { return Eigen::Matrix4d::Identity(); } @@ -196,7 +196,7 @@ Eigen::Matrix4d get_local_placement(const express::Base& placement) { unsupported_schema(name); } -double get_storey_elevation(const express::Base& storey) { +double get_storey_elevation(const express::base& storey) { if (!storey) { return 0.0; } diff --git a/src/helpers/placement.h b/src/helpers/placement.h index 1cf2d711f9..a5c9dc95fc 100644 --- a/src/helpers/placement.h +++ b/src/helpers/placement.h @@ -39,17 +39,17 @@ Eigen::Matrix4d axes_to_placement(const Eigen::Vector3d& origin, // IfcAxis2Placement{2D,3D,Linear} / IfcAxis1Placement -> 4x4 matrix. Mirrors // ifcopenshell.util.placement.get_axis2placement. Returns identity for null // or unparseable inputs. Translation is in the IFC's project length unit. -Eigen::Matrix4d get_axis2_placement(const express::Base& placement); +Eigen::Matrix4d get_axis2_placement(const express::base& placement); // Resolve an IfcLocalPlacement (or an IfcAxis2Placement* directly) into a // 4x4 matrix in the IFC project's length unit, walking the PlacementRelTo // chain. Mirrors ifcopenshell.util.placement.get_local_placement. Returns // identity for a null input. -Eigen::Matrix4d get_local_placement(const express::Base& placement); +Eigen::Matrix4d get_local_placement(const express::base& placement); // ifcopenshell.util.placement.get_storey_elevation: the Z elevation of an // IfcBuildingStorey in the project's length unit — the Z of its placement, or // the Elevation attribute as a fallback. 0 for a non-storey or null input. -double get_storey_elevation(const express::Base& storey); +double get_storey_elevation(const express::base& storey); #endif // PLACEMENT_H diff --git a/src/helpers/pset.cpp b/src/helpers/pset.cpp index 4ddeb3fd59..68be58550c 100644 --- a/src/helpers/pset.cpp +++ b/src/helpers/pset.cpp @@ -61,7 +61,7 @@ struct has_curve_interpolation : std::false_type {}; template struct has_curve_interpolation().CurveInterpolation())>> : std::true_type {}; -std::string schema_name(const express::Base& instance) { +std::string schema_name(const express::base& instance) { return instance.declaration().schema()->name(); } @@ -113,7 +113,7 @@ property_value from_attribute(const attribute_value& value) { return result; } case ifcopenshell::Argument_ENTITY_INSTANCE: { - const express::Base instance = value; + const express::base instance = value; if (instance && !instance.declaration().as_entity()) { return from_attribute(instance.get_attribute_value(0)); } @@ -127,7 +127,7 @@ property_value from_attribute(const attribute_value& value) { return scalar_list(static_cast>(value)); case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE: { property_list result; - for (const auto& instance : static_cast>(value)) { + for (const auto& instance : static_cast>(value)) { if (instance && !instance.declaration().as_entity()) { result.push_back(from_attribute(instance.get_attribute_value(0))); } else { @@ -171,7 +171,7 @@ property_value from_select_values(const Values& maybe_values) { } } -property_value verbose_value(const express::Base& instance, +property_value verbose_value(const express::base& instance, property_value value, const std::optional& value_type = std::nullopt) { property_map result = { @@ -355,7 +355,7 @@ std::optional predefined_properties_s( template std::optional get_property_definition_s( - const express::Base& definition, + const express::base& definition, const std::optional& property_name, bool verbose) { if (!definition) { @@ -405,8 +405,8 @@ std::optional get_property_definition_s( } template -express::Base concrete_definition(const Definition& definition) { - if constexpr (std::is_base_of_v) { +express::base concrete_definition(const Definition& definition) { + if constexpr (std::is_base_of_v) { return definition.concrete(); } else { return definition; @@ -414,7 +414,7 @@ express::Base concrete_definition(const Definition& definition) { } template -bool definition_is_pset_s(const express::Base& definition) { +bool definition_is_pset_s(const express::base& definition) { if (definition.template as()) { return true; } @@ -432,7 +432,7 @@ bool definition_is_pset_s(const express::Base& definition) { } template -std::optional definition_name_s(const express::Base& definition) { +std::optional definition_name_s(const express::base& definition) { if (auto pset = definition.template as()) { return pset.Name(); } @@ -458,7 +458,7 @@ std::optional definition_name_s(const express::Base& definition) { template void merge_definition_s(element_properties& result, - const express::Base& definition, + const express::base& definition, bool psets_only, bool qtos_only, bool verbose) { @@ -505,7 +505,7 @@ typename Schema::IfcTypeObject get_type_s(const typename Schema::IfcObject& obje } template -element_properties get_psets_s(const express::Base& element, +element_properties get_psets_s(const express::base& element, bool psets_only, bool qtos_only, bool should_inherit, @@ -578,7 +578,7 @@ element_properties get_psets_s(const express::Base& element, } template -std::optional get_inherited_property_s(const express::Base& element, +std::optional get_inherited_property_s(const express::base& element, const std::string& pset_name, const std::string& property_name, bool psets_only, @@ -605,7 +605,7 @@ std::optional get_inherited_property_s(const express::Base& elem } template -std::vector cast_entities(const std::vector& values) { +std::vector cast_entities(const std::vector& values) { std::vector result; result.reserve(values.size()); for (const auto& value : values) { @@ -624,7 +624,7 @@ void print_value(std::ostream& stream, const property_value& value) { stream << "null"; } else if constexpr (std::is_same_v) { stream << (item ? "true" : "false"); - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { if (item) { item.to_string(stream); } else { @@ -667,7 +667,7 @@ std::ostream& operator<<(std::ostream& stream, const property_value& value) { return stream; } -element_properties get_psets(const express::Base& element, +element_properties get_psets(const express::base& element, bool psets_only, bool qtos_only, bool should_inherit, @@ -685,7 +685,7 @@ element_properties get_psets(const express::Base& element, unsupported_schema(name); } -std::optional get_pset(const express::Base& element, +std::optional get_pset(const express::base& element, const std::string& name, const std::optional& property_name, bool psets_only, @@ -719,7 +719,7 @@ std::optional get_pset(const express::Base& element, } std::optional get_property_definition( - const express::Base& definition, + const express::base& definition, const std::optional& property_name, bool verbose) { if (!definition) { @@ -734,7 +734,7 @@ std::optional get_property_definition( unsupported_schema(name); } -std::optional get_quantity(const std::vector& quantities, +std::optional get_quantity(const std::vector& quantities, const std::string& name, bool verbose) { if (quantities.empty()) { @@ -752,7 +752,7 @@ std::optional get_quantity(const std::vector& qua unsupported_schema(schema); } -property_map get_quantities(const std::vector& quantities, bool verbose) { +property_map get_quantities(const std::vector& quantities, bool verbose) { if (quantities.empty()) { return {}; } @@ -767,7 +767,7 @@ property_map get_quantities(const std::vector& quantities, bool v unsupported_schema(schema); } -std::optional get_property(const std::vector& properties, +std::optional get_property(const std::vector& properties, const std::string& name, bool verbose) { if (properties.empty()) { @@ -785,7 +785,7 @@ std::optional get_property(const std::vector& pro unsupported_schema(schema); } -property_map get_properties(const std::vector& properties, bool verbose) { +property_map get_properties(const std::vector& properties, bool verbose) { if (properties.empty()) { return {}; } diff --git a/src/helpers/pset.h b/src/helpers/pset.h index b84e3c8517..ad07965aa9 100644 --- a/src/helpers/pset.h +++ b/src/helpers/pset.h @@ -43,7 +43,7 @@ using element_properties = std::map; // IFC null. Entity values are retained for compound property metadata that // cannot be flattened to a scalar. struct property_value { - using storage_type = std::variant; + using storage_type = std::variant; storage_type value; @@ -55,7 +55,7 @@ struct property_value { property_value(double value) : value(value) {} property_value(const char* value) : value(std::string(value)) {} property_value(std::string value) : value(std::move(value)) {} - property_value(express::Base value) : value(std::move(value)) {} + property_value(express::base value) : value(std::move(value)) {} property_value(property_list value) : value(std::move(value)) {} property_value(property_map value) : value(std::move(value)) {} @@ -73,7 +73,7 @@ std::ostream& operator<<(std::ostream& stream, const property_value& value); // the returned value contains a property_map. A selected IFC null property is // represented by an engaged optional containing a null property_value. std::optional get_pset( - const express::Base& element, + const express::base& element, const std::string& name, const std::optional& property_name = std::nullopt, bool psets_only = false, @@ -83,27 +83,27 @@ std::optional get_pset( // Mirrors ifcopenshell.util.element.get_psets, including occurrence-over-type // precedence and the definition instance id in each returned property map. -element_properties get_psets(const express::Base& element, +element_properties get_psets(const express::base& element, bool psets_only = false, bool qtos_only = false, bool should_inherit = true, bool verbose = false); std::optional get_property_definition( - const express::Base& definition, + const express::base& definition, const std::optional& property_name = std::nullopt, bool verbose = false); -std::optional get_quantity(const std::vector& quantities, +std::optional get_quantity(const std::vector& quantities, const std::string& name, bool verbose = false); -property_map get_quantities(const std::vector& quantities, +property_map get_quantities(const std::vector& quantities, bool verbose = false); -std::optional get_property(const std::vector& properties, +std::optional get_property(const std::vector& properties, const std::string& name, bool verbose = false); -property_map get_properties(const std::vector& properties, +property_map get_properties(const std::vector& properties, bool verbose = false); #endif // PSET_H diff --git a/src/helpers/unit.cpp b/src/helpers/unit.cpp index 0dfd92df1f..3066923215 100644 --- a/src/helpers/unit.cpp +++ b/src/helpers/unit.cpp @@ -212,7 +212,7 @@ std::string to_lower(const std::string& s) { throw ifcopenshell::exception("No helper implementation was built for schema " + name); } -std::optional numeric_value(const express::Base& value) { +std::optional numeric_value(const express::base& value) { if (!value) { return std::nullopt; } @@ -230,7 +230,7 @@ std::optional numeric_value(const express::Base& value) { } template -std::optional si_scale_from_named_unit_s(express::Base unit) { +std::optional si_scale_from_named_unit_s(express::base unit) { double scale = 1.0; while (auto conversion = unit.template as()) { if (const auto it = SI_CONVERSIONS.find(to_lower(conversion.Name())); @@ -271,7 +271,7 @@ std::optional si_scale_from_named_unit_s(express::Base unit) { } template -std::optional get_unit_assignment_s(ifcopenshell::file* ifc_file) { +std::optional get_unit_assignment_s(ifcopenshell::file* ifc_file) { const auto projects = ifc_file->template instances_by_type(); if (projects.empty()) { return std::nullopt; @@ -284,7 +284,7 @@ std::optional get_unit_assignment_s(ifcopenshell::file* ifc_file) } template -std::optional get_project_unit_s(ifcopenshell::file* ifc_file, +std::optional get_project_unit_s(ifcopenshell::file* ifc_file, const std::string& unit_type) { const auto assignment = get_unit_assignment_s(ifc_file); if (!assignment) { @@ -316,7 +316,7 @@ double calculate_unit_scale_s(ifcopenshell::file* ifc_file, const std::string& u } template -void unit_name_s(const express::Base& unit, std::string& prefix, std::string& name) { +void unit_name_s(const express::base& unit, std::string& prefix, std::string& name) { prefix.clear(); name.clear(); if (auto si = unit.template as()) { @@ -332,7 +332,7 @@ void unit_name_s(const express::Base& unit, std::string& prefix, std::string& na } template -double convert_unit_s(double value, const express::Base& from_unit, const express::Base& to_unit) { +double convert_unit_s(double value, const express::base& from_unit, const express::base& to_unit) { std::string from_prefix; std::string from_name; std::string to_prefix; @@ -352,7 +352,7 @@ double get_prefix_multiplier(const std::string& prefix) { return (it == SI_PREFIXES.end()) ? 1.0 : it->second; } -std::optional si_scale_from_named_unit(express::Base unit) { +std::optional si_scale_from_named_unit(express::base unit) { if (!unit) { return std::nullopt; } @@ -365,7 +365,7 @@ std::optional si_scale_from_named_unit(express::Base unit) { unsupported_schema(name); } -std::optional get_unit_assignment(ifcopenshell::file* ifc_file) { +std::optional get_unit_assignment(ifcopenshell::file* ifc_file) { const auto name = ifc_file->schema()->name(); #define IFCOPENSHELL_DISPATCH(Schema, Identifier) \ if (name == Identifier) \ @@ -375,7 +375,7 @@ std::optional get_unit_assignment(ifcopenshell::file* ifc_file) { unsupported_schema(name); } -std::optional get_project_unit(ifcopenshell::file* ifc_file, +std::optional get_project_unit(ifcopenshell::file* ifc_file, const std::string& unit_type) { const auto name = ifc_file->schema()->name(); #define IFCOPENSHELL_DISPATCH(Schema, Identifier) \ @@ -434,7 +434,7 @@ double convert(double value, return value; } -double convert_unit(double value, express::Base from_unit, express::Base to_unit) { +double convert_unit(double value, express::base from_unit, express::base to_unit) { if (!from_unit || !to_unit) { return value; } diff --git a/src/helpers/unit.h b/src/helpers/unit.h index f93cc691dd..c8ca040088 100644 --- a/src/helpers/unit.h +++ b/src/helpers/unit.h @@ -58,15 +58,15 @@ double get_prefix_multiplier(const std::string& prefix); // value_in_unit * scale == value_in_si_base // Walks IfcConversionBasedUnit chains down to IfcSIUnit. Returns nullopt // when the chain bottoms out in IfcContextDependentUnit (cannot convert). -std::optional si_scale_from_named_unit(express::Base named_unit); +std::optional si_scale_from_named_unit(express::base named_unit); // IfcProject.UnitsInContext (the IfcUnitAssignment). Returns nullopt if // the file has no project or no assignment. -std::optional get_unit_assignment(ifcopenshell::file* ifc_file); +std::optional get_unit_assignment(ifcopenshell::file* ifc_file); // First unit in the project's IfcUnitAssignment matching `unit_type` // (e.g. "LENGTHUNIT"). Returns nullopt if not found. -std::optional get_project_unit(ifcopenshell::file* ifc_file, +std::optional get_project_unit(ifcopenshell::file* ifc_file, const std::string& unit_type); // Project unit -> SI base scale (e.g. project in mm => 0.001). Defaults @@ -86,6 +86,6 @@ double convert(double value, // Convert between two IfcNamedUnit entities. Pulls Name and Prefix off each // and delegates to convert(). IfcConversionBasedUnit names that don't appear // in SI_CONVERSIONS return the value unchanged. -double convert_unit(double value, express::Base from_unit, express::Base to_unit); +double convert_unit(double value, express::base from_unit, express::base to_unit); #endif // UNIT_H diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 77bff67843..13329af81f 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -223,9 +223,9 @@ void fix_quantities(ifcopenshell::file&, bool, bool, bool, logger& logger = ::lo std::string format_duration(time_t start, time_t end); /// @todo make the filters non-global -IfcGeom::entity_filter entity_filter; // Entity filter is used always by default. -IfcGeom::layer_filter layer_filter; -IfcGeom::attribute_filter attribute_filter; +ifcopenshell::geom::entity_filter entity_filter; // Entity filter is used always by default. +ifcopenshell::geom::layer_filter layer_filter; +ifcopenshell::geom::attribute_filter attribute_filter; struct geom_filter { @@ -247,7 +247,7 @@ struct exclusion_traverse_filter : public geom_filter { exclusion_traverse_filte size_t read_filters_from_file(const std::string&, inclusion_filter&, inclusion_traverse_filter&, exclusion_filter&, exclusion_traverse_filter&); void parse_filter(geom_filter &, const std::vector&); -std::vector setup_filters(const std::vector&, const std::string&); +std::vector setup_filters(const std::vector&, const std::string&); bool init_input_file(const std::string& filename, ifcopenshell::file*& ifc_file, bool no_progress, bool mmap, bool bypass_properties=false, logger& logger = ::logger::root()); @@ -334,7 +334,7 @@ int main(int argc, char** argv) { // none, convex-decomposition, minkowski-triangles or halfspace-snapping std::string exterior_only_algo; - ifcopenshell::geometry::Settings geometry_settings; + ifcopenshell::geom::settings settings; po::options_description geom_options("Geometry options"); geom_options.add_options() @@ -389,7 +389,7 @@ int main(int argc, char** argv) { "Typically these are representations of type Body or Facetation. ") ; - geometry_settings.define_options(geom_options); + settings.define_options(geom_options); std::string bounds; #ifdef HAVE_ICU @@ -397,8 +397,6 @@ int main(int argc, char** argv) { #endif short precision; - ifcopenshell::geometry::SerializerSettings serializer_settings; - po::options_description serializer_options("Serialization options"); serializer_options.add_options() #ifdef HAVE_ICU @@ -408,8 +406,6 @@ int main(int argc, char** argv) { #endif ; - serializer_settings.define_options(serializer_options); - po::options_description cmdline_options; cmdline_options.add(generic_options).add(fileio_options).add(geom_options).add(ifc_options).add(serializer_options); @@ -511,7 +507,7 @@ int main(int argc, char** argv) { if (!default_material_filename.empty()) { try { - IfcGeom::set_default_style_file(ifcopenshell::path::to_utf8(default_material_filename)); + ifcopenshell::geom::set_default_style_file(ifcopenshell::path::to_utf8(default_material_filename)); } catch (const std::exception& e) { cerr_ << "[error] Could not read default material file:" << std::endl; cerr_ << e.what() << std::endl; @@ -591,7 +587,7 @@ int main(int argc, char** argv) { ifcopenshell::file* ifc_file = 0; - boost::optional> elems_from_adaptor; + boost::optional> elems_from_adaptor; const path_t IFC = ifcopenshell::path::from_utf8(".ifc"); @@ -622,7 +618,7 @@ int main(int argc, char** argv) { context.schema_name = ifc_file ? ifc_file->schema()->name() : document_serializer_info->schema_name; context.stream = use_input_filename; - boost::shared_ptr serializer = document_serializer_registry.create(output_extension_utf8, context); + boost::shared_ptr serializer = document_serializer_registry.create(output_extension_utf8, context); if (serializer->is_streaming() != use_input_filename) { throw ifcopenshell::exception("Selected document serializer streaming mode does not match its registry metadata"); } @@ -698,7 +694,7 @@ int main(int argc, char** argv) { if (exclude_filter.type != geom_filter::UNUSED) { used_filters.push_back(exclude_filter); } if (exclude_traverse_filter.type != geom_filter::UNUSED) { used_filters.push_back(exclude_traverse_filter); } - std::vector filter_funcs = setup_filters(used_filters, ifcopenshell::path::to_utf8(output_extension)); + std::vector filter_funcs = setup_filters(used_filters, ifcopenshell::path::to_utf8(output_extension)); if (filter_funcs.empty()) { cerr_ << "[error] Failed to set up geometry filters\n"; return EXIT_FAILURE; @@ -727,21 +723,21 @@ int main(int argc, char** argv) { } // The OS will clean up for us if there is a leak - geometry_settings.get().value = true; + settings.get().value = true; - if (geometry_settings.get().get()) { - geometry_settings.get().value = true; + if (settings.get().get()) { + settings.get().value = true; } - if (vmap[ifcopenshell::geometry::settings::WeldVertices::name].defaulted()) { - geometry_settings.get().value = false; + if (vmap[ifcopenshell::geom::settings::WeldVertices::name].defaulted()) { + settings.get().value = false; } - if (geometry_settings.get().has()) { - IfcGeom::update_default_style("IfcSpace")->transparency = geometry_settings.get().get(); + if (settings.get().has()) { + ifcopenshell::geom::update_default_style("IfcSpace")->transparency = settings.get().get(); } - if (geometry_settings.get().get() && + if (settings.get().get() && !geometry_serializer_info->supports_user_element_hierarchy) { cerr_ << "[error] --use-element-hierarchy is not supported by the selected geometry serializer.\n"; write_log(!quiet); @@ -753,11 +749,10 @@ int main(int argc, char** argv) { ifcopenshell::serializers::geometry_serializer_context serializer_context{ ifcopenshell::path::to_utf8(output_filename), ifcopenshell::path::to_utf8(output_temp_filename), - geometry_settings, - serializer_settings + settings }; - boost::shared_ptr serializer; /**< @todo use std::unique_ptr when possible */ + boost::shared_ptr serializer; /**< @todo use std::unique_ptr when possible */ try { geometry_serializer_registry.configure(output_extension_utf8, serializer_context); serializer = geometry_serializer_registry.create(output_extension_utf8, serializer_context); @@ -771,17 +766,17 @@ int main(int argc, char** argv) { const bool is_tesselated = serializer->isTesselated(); // isTesselated() doesn't change at run-time if (!is_tesselated) { - if (geometry_settings.get().get()) { + if (settings.get().get()) { logger.notice("SYS", 16, "Weld vertices setting ignored when writing non-tesselated output"); } - if (geometry_settings.get().get()) { + if (settings.get().get()) { logger.notice("SYS", 17, "Generate UVs setting ignored when writing non-tesselated output"); } if (center_model || center_model_geometry) { logger.notice("SYS", 18, "Centering/offsetting model setting ignored when writing non-tesselated output"); } - geometry_settings.get().value = ifcopenshell::geometry::settings::NATIVE; + settings.get().value = ifcopenshell::geom::settings::NATIVE; } if (!serializer->ready()) { @@ -824,7 +819,7 @@ int main(int argc, char** argv) { msg << "Using model rotation (" << rotation[0] << "," << rotation[1] << "," << rotation[2] << "," << rotation[3] << ")"; logger.notice("SYS", 19, msg.str()); - geometry_settings.get().value = rotation; + settings.get().value = rotation; } if (model_offset && (center_model || center_model_geometry)) { @@ -845,13 +840,13 @@ int main(int argc, char** argv) { msg << std::setprecision(std::numeric_limits::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")"; logger.notice("SYS", 20, msg.str()); - geometry_settings.get().value = offset; + settings.get().value = offset; } if (is_tesselated && (center_model || center_model_geometry)) { std::vector offset(3); - IfcGeom::Iterator tmp_context_iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings), geometry_settings, ifc_file, filter_funcs, num_threads, logger); + ifcopenshell::geom::iterator tmp_context_iterator(ifcopenshell::geom::kernels::construct(ifc_file, geometry_kernel, settings), settings, ifc_file, filter_funcs, num_threads, logger); time_t start, end; time(&start); @@ -883,21 +878,21 @@ int main(int argc, char** argv) { msg << std::setprecision (std::numeric_limits::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")"; logger.notice("SYS", 21, msg.str()); - geometry_settings.get().value = offset; + settings.get().value = offset; } // backwards compatibility if (vmap.count("plan") && vmap.count("model")) { - geometry_settings.get().value = ifcopenshell::geometry::settings::CURVES_SURFACES_AND_SOLIDS; + settings.get().value = ifcopenshell::geom::settings::CURVES_SURFACES_AND_SOLIDS; } else if (vmap.count("model")) { - geometry_settings.get().value = ifcopenshell::geometry::settings::SURFACES_AND_SOLIDS; + settings.get().value = ifcopenshell::geom::settings::SURFACES_AND_SOLIDS; } else if (vmap.count("plan")) { - geometry_settings.get().value = ifcopenshell::geometry::settings::CURVES; + settings.get().value = ifcopenshell::geom::settings::CURVES; } - std::unique_ptr context_iterator; + std::unique_ptr context_iterator; if (!elems_from_adaptor) { - context_iterator.reset(new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(ifc_file, geometry_kernel, geometry_settings), geometry_settings, ifc_file, filter_funcs, num_threads, logger)); + context_iterator.reset(new ifcopenshell::geom::iterator(ifcopenshell::geom::kernels::construct(ifc_file, geometry_kernel, settings), settings, ifc_file, filter_funcs, num_threads, logger)); } logger.message(::logger::LOG_PERF, "file geometry conversion"); @@ -914,7 +909,7 @@ int main(int argc, char** argv) { serializer->setFile(*ifc_file); - if (context_iterator && geometry_settings.get().get()) { + if (context_iterator && settings.get().get()) { serializer->setUnitNameAndMagnitude(context_iterator->unit_name(), static_cast(context_iterator->unit_magnitude())); } else { serializer->setUnitNameAndMagnitude("METER", 1.0f); @@ -928,11 +923,11 @@ int main(int argc, char** argv) { logger.status("Creating geometry..."); } - // The functions IfcGeom::Iterator::get() and IfcGeom::Iterator::next() + // The functions ifcopenshell::geom::iterator::get() and ifcopenshell::geom::iterator::next() // wrap an iterator of all geometrical products in the Ifc file. - // IfcGeom::Iterator::get() returns an IfcGeom::TriangulationElement or - // -BRepElement pointer, based on current settings. (see Iterator.h - // for definition) IfcGeom::Iterator::next() is used to poll whether more + // ifcopenshell::geom::iterator::get() returns an ifcopenshell::geom::triangulation_element or + // -brep_element pointer, based on current settings. (see Iterator.h + // for definition) ifcopenshell::geom::iterator::next() is used to poll whether more // geometrical entities are available. None of these functions throw // exceptions, neither for parsing errors or geometrical errors. Upon // calling next() the entity to be returned has already been processed, a @@ -940,22 +935,22 @@ int main(int argc, char** argv) { // available. size_t num_created = 0; - std::list::const_iterator elems_from_adaptor_it; + std::list::const_iterator elems_from_adaptor_it; if (elems_from_adaptor) { elems_from_adaptor_it = elems_from_adaptor->begin(); } while (true) { - IfcGeom::Element* geom_object = elems_from_adaptor ? *elems_from_adaptor_it : context_iterator->get(); + ifcopenshell::geom::element* geom_object = elems_from_adaptor ? *elems_from_adaptor_it : 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) { @@ -1028,7 +1023,7 @@ int main(int argc, char** argv) { output_temp_filename << "' for the conversion result."; } - if (geometry_settings.get().get() && logger.max_severity() >= ::logger::LOG_ERROR) { + if (settings.get().get() && logger.max_severity() >= ::logger::LOG_ERROR) { logger.error("SYS", 24, "Errors encountered during processing."); successful = false; } @@ -1265,9 +1260,9 @@ void validate(boost::any& v, const std::vector& values, exclusion_t /// @todo Clean up this filter initialization code further. /// @return References to the used filter functors, if none an error occurred. -std::vector setup_filters(const std::vector& filters, const std::string& output_extension) +std::vector setup_filters(const std::vector& filters, const std::string& output_extension) { - std::vector filter_funcs; + std::vector filter_funcs; for(auto& f: filters) { if (f.type == geom_filter::ENTITY_TYPE) { entity_filter.include = f.include; @@ -1307,13 +1302,13 @@ std::vector setup_filters(const std::vector - void set(express::Base inst, const std::string& attr, T t); + void set(express::base inst, const std::string& attr, T t); template - void set_enumeration(express::Base, const std::string&, const ifcopenshell::enumeration_type*, T) {} + void set_enumeration(express::base, const std::string&, const ifcopenshell::enumeration_type*, T) {} template <> - void set_enumeration(express::Base inst, const std::string& attr, const ifcopenshell::enumeration_type* enum_type, std::string t) { + void set_enumeration(express::base inst, const std::string& attr, const ifcopenshell::enumeration_type* enum_type, std::string t) { std::vector::const_iterator it = std::find( enum_type->enumeration_items().begin(), enum_type->enumeration_items().end(), @@ -1323,7 +1318,7 @@ namespace latebound_access { } template - void set(express::Base inst, const std::string& attr, T t) { + void set(express::base inst, const std::string& attr, T t) { auto decl = inst.declaration().as_entity(); auto i = decl->attribute_index(attr); @@ -1335,7 +1330,7 @@ namespace latebound_access { } } - express::Base create(ifcopenshell::file& f, const std::string& entity) { + express::base create(ifcopenshell::file& f, const std::string& entity) { auto decl = f.schema()->declaration_by_name(entity); return f.create(decl); } @@ -1343,7 +1338,7 @@ namespace latebound_access { void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger) { { - auto delete_reversed = [&f](const std::vector& insts) { + auto delete_reversed = [&f](const std::vector& insts) { // Lists are traversed back to front as the list may be mutated when // instances are removed from the grouping by type. for (auto it = insts.end() - 1; it >= insts.begin(); --it) { @@ -1365,7 +1360,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st auto element_quantities = f.instances_by_type("IfcElementQuantity"); // Capture relationship nodes - std::vector relationships; + std::vector relationships; auto IfcRelDefinesByProperties = f.schema()->declaration_by_name("IfcRelDefinesByProperties"); for (auto& eq : element_quantities) { @@ -1385,14 +1380,14 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st } } - ifcopenshell::geometry::Settings settings; - settings.get().value = false; - settings.get().value = false; - settings.get().value = true; - settings.get().value = true; - settings.get().value = ifcopenshell::geometry::settings::NATIVE; + ifcopenshell::geom::settings settings; + settings.get().value = false; + settings.get().value = false; + settings.get().value = true; + settings.get().value = true; + settings.get().value = ifcopenshell::geom::settings::NATIVE; - IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "opencascade", settings), settings, &f, {}, 1, logger); + ifcopenshell::geom::iterator context_iterator(ifcopenshell::geom::kernels::construct(&f, "opencascade", settings), settings, &f, {}, 1, logger); if (!context_iterator.initialize()) { return; @@ -1424,16 +1419,16 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st latebound_access::set(ownerhist, "ChangeAction", std::string("MODIFIED")); latebound_access::set(ownerhist, "CreationDate", (int64_t)time(0)); - express::Base quantity; - std::vector objects; - boost::shared_ptr previous_geometry_pointer; + express::base quantity; + std::vector objects; + boost::shared_ptr previous_geometry_pointer; for (;; ++num_created) { bool has_more = true; if (num_created) { has_more = context_iterator.next(); } - IfcGeom::BRepElement* geom_object = nullptr; + ifcopenshell::geom::brep_element* geom_object = nullptr; if (has_more) { geom_object = context_iterator.get_native(); } @@ -1453,7 +1448,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st break; } - std::vector quantities; + std::vector quantities; double a, b, c; if (geom_object->geometry().calculate_surface_area(a)) { @@ -1481,7 +1476,7 @@ void fix_quantities(ifcopenshell::file& f, bool no_progress, bool quiet, bool st latebound_access::set(quantity_complex, "Name", std::string("Shape Validation Properties")); quantities.push_back(quantity_complex); - std::vector quantities_2; + std::vector quantities_2; for (auto& part : geom_object->geometry()) { auto quantity_count = latebound_access::create(f, "IfcQuantityCount"); diff --git a/src/ifcconvert/validate_space_boundaries.cpp b/src/ifcconvert/validate_space_boundaries.cpp index 0a20555481..bcc018aa12 100644 --- a/src/ifcconvert/validate_space_boundaries.cpp +++ b/src/ifcconvert/validate_space_boundaries.cpp @@ -2,7 +2,7 @@ #include "validation_utils.h" -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include #include @@ -45,16 +45,16 @@ void fix_spaceboundaries(ifcopenshell::file& f, bool no_progress, bool quiet, bo return; } - ifcopenshell::geometry::Settings settings; + ifcopenshell::geom::settings settings; - settings.get().value = false; - settings.get().value = false; - settings.get().value = true; - settings.get().value = true; - settings.get().value = ifcopenshell::geometry::settings::NATIVE; - settings.get().value = true; + settings.get().value = false; + settings.get().value = false; + settings.get().value = true; + settings.get().value = true; + settings.get().value = ifcopenshell::geom::settings::NATIVE; + settings.get().value = true; - ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f2, "cgal", settings), &f2, settings, logger); + ifcopenshell::geom::converter c(ifcopenshell::geom::kernels::construct(&f2, "cgal", settings), &f2, settings, logger); std::map, std::vector> elem_to_space_boundary_coords; diff --git a/src/ifcconvert/validate_storey_containment.cpp b/src/ifcconvert/validate_storey_containment.cpp index a4f49ac1a8..9d706b54d0 100644 --- a/src/ifcconvert/validate_storey_containment.cpp +++ b/src/ifcconvert/validate_storey_containment.cpp @@ -10,20 +10,20 @@ #include void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { - ifcopenshell::geometry::Settings settings; + ifcopenshell::geom::settings settings; - settings.get().value = false; - settings.get().value = false; - settings.get().value = true; - settings.get().value = true; - settings.get().value = ifcopenshell::geometry::settings::NATIVE; - settings.get().value = true; + settings.get().value = false; + settings.get().value = false; + settings.get().value = true; + settings.get().value = true; + settings.get().value = ifcopenshell::geom::settings::NATIVE; + settings.get().value = true; - std::vector no_openings_and_spaces = { - IfcGeom::entity_filter(false, false, {"IfcOpeningElement", "IfcSpace"}) + std::vector no_openings_and_spaces = { + ifcopenshell::geom::entity_filter(false, false, {"IfcOpeningElement", "IfcSpace"}) }; - IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings), settings, &f, no_openings_and_spaces, 1, logger); + ifcopenshell::geom::iterator context_iterator(ifcopenshell::geom::kernels::construct(&f, "cgal", settings), settings, &f, no_openings_and_spaces, 1, logger); auto get_elevation = [](const ifcopenshell::IfcBaseClass* a) { return ((const ifcopenshell::IfcBaseEntity*)a)->get_value("Elevation", 0.); @@ -81,13 +81,13 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, // std::wcout << p.first << " - " << p.second << std::endl; Kernel_::Point_3 p1(-LARGE, -LARGE, p.first); Kernel_::Point_3 p2(+LARGE, +LARGE, p.second); - auto poly = ifcopenshell::geometry::utils::create_cube(p1, p2); - return ifcopenshell::geometry::utils::create_nef_polyhedron(poly); + auto poly = ifcopenshell::geom::utils::create_cube(p1, p2); + return ifcopenshell::geom::utils::create_nef_polyhedron(poly); }); /* for (auto& n : nefs) { - auto poly = ifcopenshell::geometry::utils::create_polyhedron(n); + auto poly = ifcopenshell::geom::utils::create_polyhedron(n); auto bounds = CGAL::Polygon_mesh_processing::bbox_3(poly); for (int i = 0; i < 3; ++i) { std::wcout << bounds.min(i) << std::endl; @@ -111,7 +111,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, if (num_created) { has_more = context_iterator.next(); } - IfcGeom::BRepElement* geom_object = nullptr; + ifcopenshell::geom::brep_element* geom_object = nullptr; if (has_more) { geom_object = context_iterator.get_native(); } @@ -134,7 +134,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, std::vector intersection_volumes(nefs.size()); for (auto& g : geom_object->geometry()) { - auto s = std::static_pointer_cast(g.Shape())->poly(); + auto s = std::static_pointer_cast(g.Shape())->poly(); const auto& m = g.Placement()->ccomponents(); const auto& n = geom_object->transformation().data()->ccomponents(); @@ -166,7 +166,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, } */ - CGAL::Nef_polyhedron_3 part_nef = ifcopenshell::geometry::utils::create_nef_polyhedron(s); + CGAL::Nef_polyhedron_3 part_nef = ifcopenshell::geom::utils::create_nef_polyhedron(s); if (!part_nef.is_simple()) { // std::wcout << "not simple" << std::endl; @@ -175,7 +175,7 @@ void fix_storeycontainment(ifcopenshell::file& f, bool no_progress, bool quiet, std::vector::iterator accumulator = intersection_volumes.begin(); std::for_each(nefs.begin(), nefs.end(), [&accumulator, &part_nef](const CGAL::Nef_polyhedron_3& storey_nef) { - auto poly = ifcopenshell::geometry::utils::create_polyhedron(part_nef * storey_nef); + auto poly = ifcopenshell::geom::utils::create_polyhedron(part_nef * storey_nef); CGAL::Polygon_mesh_processing::triangulate_faces(poly); *accumulator += CGAL::to_double(CGAL::Polygon_mesh_processing::volume(poly)); accumulator++; diff --git a/src/ifcconvert/validate_wall_connectivity.cpp b/src/ifcconvert/validate_wall_connectivity.cpp index ebfedeafa7..e4e6674d25 100644 --- a/src/ifcconvert/validate_wall_connectivity.cpp +++ b/src/ifcconvert/validate_wall_connectivity.cpp @@ -7,24 +7,23 @@ #include -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { intersection_validator v(f, { "IfcWall" }, 1.e-3, no_progress, quiet, stderr_progress, logger); - ifcopenshell::geometry::Settings settings; + ifcopenshell::geom::settings settings; - settings.get().value = false; - settings.get().value = false; - settings.get().value = true; - settings.get().value = true; - settings.get().value = ifcopenshell::geometry::settings::NATIVE; - settings.get().value = true; + settings.get().value = false; + settings.get().value = false; + settings.get().value = true; + settings.get().value = true; + settings.get().value = ifcopenshell::geom::settings::NATIVE; + settings.get().value = true; - settings.get().value = true; - settings.get().value = false; + settings.get().value = ifcopenshell::geom::settings::CURVES; - ifcopenshell::geometry::Converter c(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings), &f, settings, logger); + ifcopenshell::geom::converter c(ifcopenshell::geom::kernels::construct(&f, "cgal", settings), &f, settings, logger); auto rels = f.instances_by_type("IfcRelConnectsPathElements"); std::map, const ifcopenshell::IfcBaseClass*> rel_by_elem; @@ -58,8 +57,8 @@ void fix_wallconnectivity(ifcopenshell::file& f, bool no_progress, bool quiet, b } #if 0 - auto a_poly = ifcopenshell::geometry::utils::create_polyhedron(a.handle()->second); - auto b_poly = ifcopenshell::geometry::utils::create_polyhedron(b.handle()->second); + auto a_poly = ifcopenshell::geom::utils::create_polyhedron(a.handle()->second); + auto b_poly = ifcopenshell::geom::utils::create_polyhedron(b.handle()->second); std::wcout << "a" << std::endl; for (auto& v : vertices(a_poly)) { diff --git a/src/ifcconvert/validation_utils.h b/src/ifcconvert/validation_utils.h index 1068c7f3b6..0452079497 100644 --- a/src/ifcconvert/validation_utils.h +++ b/src/ifcconvert/validation_utils.h @@ -448,26 +448,26 @@ struct intersection_validator { intersection_validator(ifcopenshell::file& f, std::initializer_list entities, double eps, bool no_progress, bool quiet, bool stderr_progress, logger& logger = ::logger::root()) { - ifcopenshell::geometry::Settings settings; - settings.get().value = false; - settings.get().value = false; - settings.get().value = true; - settings.get().value = true; - settings.get().value = ifcopenshell::geometry::settings::NATIVE; - settings.get().value = true; + ifcopenshell::geom::settings settings; + settings.get().value = false; + settings.get().value = false; + settings.get().value = true; + settings.get().value = true; + settings.get().value = ifcopenshell::geom::settings::NATIVE; + settings.get().value = true; - std::vector spaces_and_walls = { - IfcGeom::entity_filter(true, false, entities) + std::vector spaces_and_walls = { + ifcopenshell::geom::entity_filter(true, false, entities) }; - IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "cgal", settings), settings, &f, spaces_and_walls, 1, logger); + ifcopenshell::geom::iterator context_iterator(ifcopenshell::geom::kernels::construct(&f, "cgal", settings), settings, &f, spaces_and_walls, 1, logger); if (!context_iterator.initialize()) { return; } - auto polycube = ifcopenshell::geometry::utils::create_cube(eps); - auto cube = ifcopenshell::geometry::utils::create_nef_polyhedron(polycube); + auto polycube = ifcopenshell::geom::utils::create_cube(eps); + auto cube = ifcopenshell::geom::utils::create_nef_polyhedron(polycube); size_t num_created = 0; int old_progress = quiet ? 0 : -1; @@ -477,7 +477,7 @@ struct intersection_validator { if (num_created) { has_more = context_iterator.next(); } - IfcGeom::BRepElement* geom_object = nullptr; + ifcopenshell::geom::brep_element* geom_object = nullptr; if (has_more) { geom_object = context_iterator.get_native(); } @@ -491,7 +491,7 @@ struct intersection_validator { std::wcout << sss.c_str() << std::endl; for (auto& g : geom_object->geometry()) { - cgal_shape_t s = *std::static_pointer_cast(g.Shape()); + cgal_shape_t s = *std::static_pointer_cast(g.Shape()); const auto& m = g.Placement()->ccomponents(); const auto& n = geom_object->transformation().data()->ccomponents(); @@ -511,7 +511,7 @@ struct intersection_validator { } std::clock_t nef_begin = std::clock(); - CGAL::Nef_polyhedron_3 nef = ifcopenshell::geometry::utils::create_nef_polyhedron(s); + CGAL::Nef_polyhedron_3 nef = ifcopenshell::geom::utils::create_nef_polyhedron(s); std::clock_t nef_end = std::clock(); total_nef_time += (nef_end - nef_begin) / (double) CLOCKS_PER_SEC; if (nef.is_empty()) { diff --git a/src/ifcgeom/AbstractKernel.cpp b/src/ifcgeom/AbstractKernel.cpp index 634151880b..5af6d975c1 100644 --- a/src/ifcgeom/AbstractKernel.cpp +++ b/src/ifcgeom/AbstractKernel.cpp @@ -5,7 +5,7 @@ #include "AbstractKernel.h" -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; const char* ifcopenshell::not_implemented_error::what() const noexcept { return "Not implemented."; @@ -15,7 +15,7 @@ const char* ifcopenshell::not_supported_error::what() const noexcept { return "Not supported."; } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::ptr item, IfcGeom::ConversionResults& results) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert(const taxonomy::ptr item, ifcopenshell::geom::conversion_results& results) { if (settings_.get().get()) { auto it = cache_.find(item); if (it != cache_.end()) { @@ -62,12 +62,12 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt return res; } -const Settings& ifcopenshell::geometry::kernels::AbstractKernel::settings() const +const ifcopenshell::geom::settings& ifcopenshell::geom::kernels::abstract_kernel::settings() const { return settings_; } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::collection::ptr collection, IfcGeom::ConversionResults& r) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert_impl(const taxonomy::collection::ptr collection, ifcopenshell::geom::conversion_results& r) { auto s = r.size(); for (auto& c : collection->children) { if (!convert(c, r) && !partial_success_is_success) { @@ -85,42 +85,42 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonom return r.size() > s; } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::function_item::ptr item, IfcGeom::ConversionResults& cs) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert_impl(const taxonomy::function_item::ptr item, ifcopenshell::geom::conversion_results& cs) { function_item_evaluator evaluator(settings(),item); auto expl = evaluator.evaluate(); expl->instance = item->instance; return convert(expl, cs); } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::functor_item::ptr item, IfcGeom::ConversionResults& cs) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert_impl(const taxonomy::functor_item::ptr item, ifcopenshell::geom::conversion_results& cs) { function_item_evaluator evaluator(settings(), item); auto expl = evaluator.evaluate(); expl->instance = item->instance; return convert(expl, cs); } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::piecewise_function::ptr item, IfcGeom::ConversionResults& cs) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert_impl(const taxonomy::piecewise_function::ptr item, ifcopenshell::geom::conversion_results& cs) { function_item_evaluator evaluator(settings(), item); auto expl = evaluator.evaluate(); expl->instance = item->instance; return convert(expl, cs); } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::gradient_function::ptr item, IfcGeom::ConversionResults& cs) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert_impl(const taxonomy::gradient_function::ptr item, ifcopenshell::geom::conversion_results& cs) { function_item_evaluator evaluator(settings(), item); auto expl = evaluator.evaluate(); expl->instance = item->instance; return convert(expl, cs); } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::cant_function::ptr item, IfcGeom::ConversionResults& cs) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert_impl(const taxonomy::cant_function::ptr item, ifcopenshell::geom::conversion_results& cs) { function_item_evaluator evaluator(settings(), item); auto expl = evaluator.evaluate(); expl->instance = item->instance; return convert(expl, cs); } -bool ifcopenshell::geometry::kernels::AbstractKernel::convert_impl(const taxonomy::offset_function::ptr item, IfcGeom::ConversionResults& cs) { +bool ifcopenshell::geom::kernels::abstract_kernel::convert_impl(const taxonomy::offset_function::ptr item, ifcopenshell::geom::conversion_results& cs) { function_item_evaluator evaluator(settings(), item); auto expl = evaluator.evaluate(); expl->instance = item->instance; diff --git a/src/ifcgeom/AbstractKernel.h b/src/ifcgeom/AbstractKernel.h index e6f7ad4afb..f387afb595 100644 --- a/src/ifcgeom/AbstractKernel.h +++ b/src/ifcgeom/AbstractKernel.h @@ -58,86 +58,86 @@ namespace ifcopenshell { #pragma warning(pop) #endif - namespace geometry { namespace kernels { + namespace geom { namespace kernels { - class IFC_GEOM_API AbstractKernel { + class IFC_GEOM_API abstract_kernel { private: - std::unordered_map cache_; + std::unordered_map cache_; protected: std::string geometry_library_; - Settings settings_; + ifcopenshell::geom::settings settings_; ::logger& logger_; public: bool propagate_exceptions = false; bool partial_success_is_success = true; - AbstractKernel(const std::string& geometry_library, const Settings& settings, ::logger& logger = ::logger::root()) + abstract_kernel(const std::string& geometry_library, const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) : geometry_library_(geometry_library) , settings_(settings) , logger_(logger) {} - virtual ~AbstractKernel() = default; + virtual ~abstract_kernel() = default; - virtual bool convert(const taxonomy::ptr, IfcGeom::ConversionResults&); - const Settings& settings() const; + virtual bool convert(const taxonomy::ptr, ifcopenshell::geom::conversion_results&); + const ifcopenshell::geom::settings& settings() const; const std::string& geometry_library() const { return geometry_library_; } virtual std::string_view backend_id() const { return geometry_library_; } - virtual bool accepts(const IfcGeom::ConversionResultShape& shape) const { + virtual bool accepts(const ifcopenshell::geom::conversion_result_shape& shape) const { return shape.backend_id() == backend_id(); } ::logger& logger() const { return logger_; } virtual bool supports_boolean_operations() const = 0; - virtual bool convert_impl(const taxonomy::matrix4::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::point3::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::direction3::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::line::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::circle::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::ellipse::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::bspline_curve::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::edge::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::loop::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::face::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::extrusion::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::node::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::colour::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::plane::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::offset_curve::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::revolve::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::bspline_surface::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::cylinder::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::sphere::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::torus::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::sweep_along_curve::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::loft::ptr, IfcGeom::ConversionResults&) { throw not_implemented_error(); } - virtual bool convert_impl(const taxonomy::collection::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const taxonomy::function_item::ptr item, IfcGeom::ConversionResults& cs); - virtual bool convert_impl(const taxonomy::functor_item::ptr item, IfcGeom::ConversionResults& cs); - virtual bool convert_impl(const taxonomy::piecewise_function::ptr item, IfcGeom::ConversionResults& cs); - virtual bool convert_impl(const taxonomy::gradient_function::ptr item, IfcGeom::ConversionResults& cs); - virtual bool convert_impl(const taxonomy::cant_function::ptr item, IfcGeom::ConversionResults& cs); - virtual bool convert_impl(const taxonomy::offset_function::ptr item, IfcGeom::ConversionResults& cs); + virtual bool convert_impl(const taxonomy::matrix4::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::point3::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::direction3::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::line::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::circle::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::ellipse::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::bspline_curve::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::edge::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::loop::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::shell::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::face::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::extrusion::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::node::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::colour::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::boolean_result::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::plane::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::offset_curve::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::revolve::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::bspline_surface::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::cylinder::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::sphere::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::torus::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::solid::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::sweep_along_curve::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::loft::ptr, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } + virtual bool convert_impl(const taxonomy::collection::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const taxonomy::function_item::ptr item, ifcopenshell::geom::conversion_results& cs); + virtual bool convert_impl(const taxonomy::functor_item::ptr item, ifcopenshell::geom::conversion_results& cs); + virtual bool convert_impl(const taxonomy::piecewise_function::ptr item, ifcopenshell::geom::conversion_results& cs); + virtual bool convert_impl(const taxonomy::gradient_function::ptr item, ifcopenshell::geom::conversion_results& cs); + virtual bool convert_impl(const taxonomy::cant_function::ptr item, ifcopenshell::geom::conversion_results& cs); + virtual bool convert_impl(const taxonomy::offset_function::ptr item, ifcopenshell::geom::conversion_results& cs); /* virtual void set_offset(const std::array &p_offset); virtual void set_rotation(const std::array &p_rotation); */ - virtual bool apply_layerset(IfcGeom::ConversionResults&, const ifcopenshell::geometry::layerset_information&) { throw not_implemented_error(); } - virtual bool apply_folded_layerset(IfcGeom::ConversionResults&, const ifcopenshell::geometry::layerset_information&, const std::map&) { throw not_implemented_error(); } - virtual bool convert_openings(const express::Base& entity, const std::vector>& openings, - const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) = 0; - virtual bool unify_shapes(const IfcGeom::ConversionResults&, IfcGeom::ConversionResults&) { throw not_implemented_error(); } + virtual bool apply_layerset(ifcopenshell::geom::conversion_results&, const ifcopenshell::geom::layerset_information&) { throw not_implemented_error(); } + virtual bool apply_folded_layerset(ifcopenshell::geom::conversion_results&, const ifcopenshell::geom::layerset_information&, const std::map&) { throw not_implemented_error(); } + virtual bool convert_openings(const express::base& entity, const std::vector>& openings, + const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes) = 0; + virtual bool unify_shapes(const ifcopenshell::geom::conversion_results&, ifcopenshell::geom::conversion_results&) { throw not_implemented_error(); } - virtual AbstractKernel* clone(::logger& logger) const = 0; + virtual abstract_kernel* clone(::logger& logger) const = 0; }; } } @@ -148,9 +148,9 @@ namespace { /* A compile-time for loop over the taxonomy kinds */ template struct dispatch_conversion { - static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, ifcopenshell::geometry::taxonomy::kinds item_kind, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults& results) { + static bool dispatch(ifcopenshell::geom::kernels::abstract_kernel* kernel, ifcopenshell::geom::taxonomy::kinds item_kind, const ifcopenshell::geom::taxonomy::ptr& item, ifcopenshell::geom::conversion_results& results) { if (N == item_kind) { - auto concrete_item = std::static_pointer_cast>(item); + auto concrete_item = std::static_pointer_cast>(item); return kernel->convert_impl(concrete_item, results); } else { return dispatch_conversion::dispatch(kernel, item_kind, item, results); @@ -159,14 +159,14 @@ namespace { }; template <> - struct dispatch_conversion { - static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, ifcopenshell::geometry::taxonomy::kinds, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) { + struct dispatch_conversion { + static bool dispatch(ifcopenshell::geom::kernels::abstract_kernel* kernel, ifcopenshell::geom::taxonomy::kinds, const ifcopenshell::geom::taxonomy::ptr& item, ifcopenshell::geom::conversion_results&) { if (kernel->partial_success_is_success) { std::string created_from; if (item->instance) { created_from = " (created from " + item->instance.declaration().name() + ")"; } - kernel->logger().error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); + kernel->logger().error("UNS", 1, "No support for " + ifcopenshell::geom::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); } return false; } @@ -174,8 +174,8 @@ namespace { template struct dispatch_with_upgrade { - static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults& results) { - auto concrete_item = ifcopenshell::geometry::taxonomy::template dcast>(item); + static bool dispatch(ifcopenshell::geom::kernels::abstract_kernel* kernel, const ifcopenshell::geom::taxonomy::ptr& item, ifcopenshell::geom::conversion_results& results) { + auto concrete_item = ifcopenshell::geom::taxonomy::template dcast>(item); if (concrete_item) { return kernel->convert_impl(concrete_item, results); } else { @@ -185,39 +185,39 @@ namespace { }; template <> - struct dispatch_with_upgrade { - static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) { + struct dispatch_with_upgrade { + static bool dispatch(ifcopenshell::geom::kernels::abstract_kernel* kernel, const ifcopenshell::geom::taxonomy::ptr& item, ifcopenshell::geom::conversion_results&) { if (kernel->partial_success_is_success) { std::string created_from; if (item->instance) { created_from = " (created from " + item->instance.declaration().name() + ")"; } - kernel->logger().error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); + kernel->logger().error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geom::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library()); } return false; } }; template - struct TupleTypeIndex; + struct tuple_type_index; template - struct TupleTypeIndex> { + struct tuple_type_index> { static const std::size_t value = 0; }; template - struct TupleTypeIndex> { - static const std::size_t value = 1 + TupleTypeIndex>::value; + struct tuple_type_index> { + static const std::size_t value = 1 + tuple_type_index>::value; }; /* A compile-time for loop over the curve kinds */ template struct dispatch_curve_creation { - static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T& visitor) { - constexpr auto KindIndex = TupleTypeIndex, ifcopenshell::geometry::taxonomy::impl::KindsTuple>::value; + static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T& visitor) { + constexpr auto KindIndex = tuple_type_index, ifcopenshell::geom::taxonomy::impl::kinds_tuple>::value; if (item->kind() == KindIndex) { - auto concrete_item = std::static_pointer_cast>(item); + auto concrete_item = std::static_pointer_cast>(item); visitor(concrete_item); return true; } else { @@ -227,8 +227,8 @@ namespace { }; template - struct dispatch_curve_creation { - static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) { + struct dispatch_curve_creation { + static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T&) { ::logger::root().error("GEO", 28, "No conversion for " + std::to_string(item->kind())); return false; } @@ -237,8 +237,8 @@ namespace { /* A compile-time for loop over the curve kinds */ template struct dispatch_surface_creation { - static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T& visitor) { - auto v = ifcopenshell::geometry::taxonomy::template dcast>(item); + static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T& visitor) { + auto v = ifcopenshell::geom::taxonomy::template dcast>(item); if (v && item->kind() == v->kind()) { visitor(v); return true; @@ -249,8 +249,8 @@ namespace { }; template - struct dispatch_surface_creation { - static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) { + struct dispatch_surface_creation { + static bool dispatch(const ifcopenshell::geom::taxonomy::ptr& item, T&) { ::logger::root().error("GEO", 29, "No conversion for " + std::to_string(item->kind())); return false; } diff --git a/src/ifcgeom/ConversionResult.cpp b/src/ifcgeom/ConversionResult.cpp index d860bba6d8..fa7dc38d32 100644 --- a/src/ifcgeom/ConversionResult.cpp +++ b/src/ifcgeom/ConversionResult.cpp @@ -1,23 +1,23 @@ #include "ConversionResult.h" #include "IfcGeomRepresentation.h" -IfcGeom::Representation::Triangulation* IfcGeom::ConversionResultShape::Triangulate(const ifcopenshell::geometry::Settings& settings, ::logger& logger) const +ifcopenshell::geom::Representation::triangulation* ifcopenshell::geom::conversion_result_shape::Triangulate(const ifcopenshell::geom::settings& settings, ::logger& logger) const { - auto t = IfcGeom::Representation::Triangulation::empty(settings); - static ifcopenshell::geometry::taxonomy::matrix4 iden; + auto t = ifcopenshell::geom::Representation::triangulation::empty(settings); + static ifcopenshell::geom::taxonomy::matrix4 iden; Triangulate(settings, iden, t, -1, -1, logger); return t; } -using namespace ifcopenshell::geometry::taxonomy; +using namespace ifcopenshell::geom::taxonomy; -void IfcGeom::ConversionResult::append(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) { +void ifcopenshell::geom::conversion_result::append(ifcopenshell::geom::taxonomy::matrix4::ptr trsf) { placement_ = make(placement_->ccomponents() * trsf->ccomponents()); } -void IfcGeom::ConversionResult::prepend(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) { +void ifcopenshell::geom::conversion_result::prepend(ifcopenshell::geom::taxonomy::matrix4::ptr trsf) { placement_ = make(trsf->ccomponents() * placement_->ccomponents()); } -template struct IFC_GEOM_API IfcGeom::OpaqueCoordinate<3>; -template struct IFC_GEOM_API IfcGeom::OpaqueCoordinate<4>; +template struct IFC_GEOM_API ifcopenshell::geom::opaque_coordinate<3>; +template struct IFC_GEOM_API ifcopenshell::geom::opaque_coordinate<4>; diff --git a/src/ifcgeom/ConversionResult.h b/src/ifcgeom/ConversionResult.h index 3bf8a51456..01421e52cd 100644 --- a/src/ifcgeom/ConversionResult.h +++ b/src/ifcgeom/ConversionResult.h @@ -40,7 +40,7 @@ #include #include -struct EdgeKey { +struct edge_key { int v1, v2; // These are not part of the hash or equality, @@ -51,7 +51,7 @@ struct EdgeKey { // conflicting original vertex indices. int ov1, ov2; - EdgeKey(int a, int b) + edge_key(int a, int b) : ov1(a) , ov2(b) { @@ -64,7 +64,7 @@ struct EdgeKey { } } - bool operator==(const EdgeKey& other) const { + bool operator==(const edge_key& other) const { return v1 == other.v1 && v2 == other.v2; } }; @@ -72,18 +72,18 @@ struct EdgeKey { #ifndef SWIG namespace std { template <> - struct hash { - std::size_t operator()(const EdgeKey& ek) const { + struct hash { + std::size_t operator()(const edge_key& ek) const { return std::hash()(ek.v1) ^ std::hash()(ek.v2); } }; } #endif -namespace IfcGeom { +namespace ifcopenshell::geom { namespace Representation { - class IFC_GEOM_API Triangulation; + class IFC_GEOM_API triangulation; } #ifndef SWIG @@ -123,21 +123,21 @@ namespace IfcGeom { } #endif - class IFC_GEOM_API OpaqueNumber { + class IFC_GEOM_API opaque_number { protected: - struct NumberConcept { - virtual ~NumberConcept() {} + struct number_concept { + virtual ~number_concept() {} virtual double to_double() const = 0; virtual std::string to_string() const = 0; - virtual std::shared_ptr add(const NumberConcept& other) const = 0; - virtual std::shared_ptr subtract(const NumberConcept& other) const = 0; - virtual std::shared_ptr multiply(const NumberConcept& other) const = 0; - virtual std::shared_ptr divide(const NumberConcept& other) const = 0; - virtual std::shared_ptr negate() const = 0; - virtual std::shared_ptr from_double(double value) const = 0; - virtual std::shared_ptr from_int(int value) const = 0; - virtual bool equals(const NumberConcept& other) const = 0; - virtual bool less_than(const NumberConcept& other) const = 0; + virtual std::shared_ptr add(const number_concept& other) const = 0; + virtual std::shared_ptr subtract(const number_concept& other) const = 0; + virtual std::shared_ptr multiply(const number_concept& other) const = 0; + virtual std::shared_ptr divide(const number_concept& other) const = 0; + virtual std::shared_ptr negate() const = 0; + virtual std::shared_ptr from_double(double value) const = 0; + virtual std::shared_ptr from_int(int value) const = 0; + virtual bool equals(const number_concept& other) const = 0; + virtual bool less_than(const number_concept& other) const = 0; virtual const std::type_info& type() const = 0; virtual const void* value_ptr() const = 0; }; @@ -151,14 +151,14 @@ namespace IfcGeom { #endif template - struct NumberModel : NumberConcept { + struct number_model : number_concept { T value; - NumberModel(const T& v) + number_model(const T& v) : value(v) {} - static const NumberModel& as_same(const NumberConcept& other) { - auto same = dynamic_cast(&other); + static const number_model& as_same(const number_concept& other) { + auto same = dynamic_cast(&other); if (same == nullptr) { throw std::runtime_error("Incompatible opaque number types"); } @@ -182,39 +182,39 @@ namespace IfcGeom { return ss.str(); } - virtual std::shared_ptr add(const NumberConcept& other) const { - return std::make_shared(value + as_same(other).value); + virtual std::shared_ptr add(const number_concept& other) const { + return std::make_shared(value + as_same(other).value); } - virtual std::shared_ptr subtract(const NumberConcept& other) const { - return std::make_shared(value - as_same(other).value); + virtual std::shared_ptr subtract(const number_concept& other) const { + return std::make_shared(value - as_same(other).value); } - virtual std::shared_ptr multiply(const NumberConcept& other) const { - return std::make_shared(value * as_same(other).value); + virtual std::shared_ptr multiply(const number_concept& other) const { + return std::make_shared(value * as_same(other).value); } - virtual std::shared_ptr divide(const NumberConcept& other) const { - return std::make_shared(value / as_same(other).value); + virtual std::shared_ptr divide(const number_concept& other) const { + return std::make_shared(value / as_same(other).value); } - virtual std::shared_ptr negate() const { - return std::make_shared(-value); + virtual std::shared_ptr negate() const { + return std::make_shared(-value); } - virtual std::shared_ptr from_double(double v) const { - return std::make_shared(T(v)); + virtual std::shared_ptr from_double(double v) const { + return std::make_shared(T(v)); } - virtual std::shared_ptr from_int(int v) const { - return std::make_shared(T(v)); + virtual std::shared_ptr from_int(int v) const { + return std::make_shared(T(v)); } - virtual bool equals(const NumberConcept& other) const { + virtual bool equals(const number_concept& other) const { return value == as_same(other).value; } - virtual bool less_than(const NumberConcept& other) const { + virtual bool less_than(const number_concept& other) const { return value < as_same(other).value; } @@ -234,9 +234,9 @@ namespace IfcGeom { struct is_shared_ptr> : std::true_type {}; private: - std::shared_ptr data_; + std::shared_ptr data_; - const NumberConcept& data() const { + const number_concept& data() const { if (!data_) { throw std::runtime_error("Empty opaque number"); } @@ -244,20 +244,20 @@ namespace IfcGeom { } protected: - OpaqueNumber(std::shared_ptr data) + opaque_number(std::shared_ptr data) : data_(std::move(data)) {} public: - OpaqueNumber() = default; - virtual ~OpaqueNumber() = default; + opaque_number() = default; + virtual ~opaque_number() = default; #ifndef SWIG template < typename T, typename Decayed = std::decay_t, - typename = std::enable_if_t::value && !is_shared_ptr::value>> - explicit OpaqueNumber(T&& value) - : data_(std::make_shared>(std::forward(value))) {} + typename = std::enable_if_t::value && !is_shared_ptr::value>> + explicit opaque_number(T&& value) + : data_(std::make_shared>(std::forward(value))) {} #endif double to_double() const { @@ -280,102 +280,102 @@ namespace IfcGeom { return *static_cast(data().value_ptr()); } - OpaqueNumber add(const OpaqueNumber& other) const { - return OpaqueNumber(data().add(other.data())); + opaque_number add(const opaque_number& other) const { + return opaque_number(data().add(other.data())); } - OpaqueNumber subtract(const OpaqueNumber& other) const { - return OpaqueNumber(data().subtract(other.data())); + opaque_number subtract(const opaque_number& other) const { + return opaque_number(data().subtract(other.data())); } - OpaqueNumber multiply(const OpaqueNumber& other) const { - return OpaqueNumber(data().multiply(other.data())); + opaque_number multiply(const opaque_number& other) const { + return opaque_number(data().multiply(other.data())); } - OpaqueNumber divide(const OpaqueNumber& other) const { - return OpaqueNumber(data().divide(other.data())); + opaque_number divide(const opaque_number& other) const { + return opaque_number(data().divide(other.data())); } - OpaqueNumber negated() const { - return OpaqueNumber(data().negate()); + opaque_number negated() const { + return opaque_number(data().negate()); } - OpaqueNumber abs() const { + opaque_number abs() const { auto zero = data().from_int(0); - return OpaqueNumber(data().less_than(*zero) ? data().negate() : *this); + return opaque_number(data().less_than(*zero) ? data().negate() : *this); } - OpaqueNumber same_type(double value) const { - return OpaqueNumber(data().from_double(value)); + opaque_number same_type(double value) const { + return opaque_number(data().from_double(value)); } - OpaqueNumber same_type(int value) const { - return OpaqueNumber(data().from_int(value)); + opaque_number same_type(int value) const { + return opaque_number(data().from_int(value)); } - bool equals(const OpaqueNumber& other) const { + bool equals(const opaque_number& other) const { return data().equals(other.data()); } - bool less_than(const OpaqueNumber& other) const { + bool less_than(const opaque_number& other) const { return data().less_than(other.data()); } - OpaqueNumber operator+(const OpaqueNumber& other) const { + opaque_number operator+(const opaque_number& other) const { return add(other); } - OpaqueNumber operator-(const OpaqueNumber& other) const { + opaque_number operator-(const opaque_number& other) const { return subtract(other); } - OpaqueNumber operator*(const OpaqueNumber& other) const { + opaque_number operator*(const opaque_number& other) const { return multiply(other); } - OpaqueNumber operator/(const OpaqueNumber& other) const { + opaque_number operator/(const opaque_number& other) const { return divide(other); } - bool operator==(const OpaqueNumber& other) const { + bool operator==(const opaque_number& other) const { return equals(other); } - bool operator<(const OpaqueNumber& other) const { + bool operator<(const opaque_number& other) const { return less_than(other); } - OpaqueNumber operator-() const { + opaque_number operator-() const { return negated(); } }; #ifndef SWIG template - struct IFC_GEOM_API OpaqueCoordinate { + struct IFC_GEOM_API opaque_coordinate { private: - std::array values_; + std::array values_; - static OpaqueNumber as_number(OpaqueNumber value) { + static opaque_number as_number(opaque_number value) { return value; } public: #ifndef SWIG template > - OpaqueCoordinate(Args&&... args) { + opaque_coordinate(Args&&... args) { init_<0>(std::forward(args)...); } #endif - OpaqueCoordinate() = default; + opaque_coordinate() = default; std::size_t size() const { return N; } - OpaqueNumber get(size_t i) const { + opaque_number get(size_t i) const { if (i >= N) { - return OpaqueNumber(); + return opaque_number(); } return values_[i]; } @@ -384,7 +384,7 @@ namespace IfcGeom { return get(i).to_double(); } - void set(size_t i, const OpaqueNumber& n) { + void set(size_t i, const opaque_number& n) { if (i < N) { values_[i] = n; } @@ -399,55 +399,55 @@ namespace IfcGeom { return result; } - OpaqueCoordinate operator-() const { - OpaqueCoordinate result; + opaque_coordinate operator-() const { + opaque_coordinate result; for (size_t i = 0; i < N; ++i) { result.values_[i] = values_[i].negated(); } return result; } - OpaqueCoordinate operator+(const OpaqueCoordinate& other) const { - OpaqueCoordinate result; + opaque_coordinate operator+(const opaque_coordinate& other) const { + opaque_coordinate result; for (size_t i = 0; i < N; ++i) { result.values_[i] = values_[i].add(other.values_[i]); } return result; } - OpaqueCoordinate operator-(const OpaqueCoordinate& other) const { - OpaqueCoordinate result; + opaque_coordinate operator-(const opaque_coordinate& other) const { + opaque_coordinate result; for (size_t i = 0; i < N; ++i) { result.values_[i] = values_[i].subtract(other.values_[i]); } return result; } - OpaqueCoordinate operator*(const OpaqueNumber& scalar) const { - OpaqueCoordinate result; + opaque_coordinate operator*(const opaque_number& scalar) const { + opaque_coordinate result; for (size_t i = 0; i < N; ++i) { result.values_[i] = values_[i].multiply(scalar); } return result; } - OpaqueCoordinate operator/(const OpaqueNumber& scalar) const { - OpaqueCoordinate result; + opaque_coordinate operator/(const opaque_number& scalar) const { + opaque_coordinate result; for (size_t i = 0; i < N; ++i) { result.values_[i] = values_[i].divide(scalar); } return result; } - OpaqueCoordinate scale(double scalar) const { + opaque_coordinate scale(double scalar) const { return *this * values_[0].same_type(scalar); } - OpaqueNumber dot(const OpaqueCoordinate& other) const { + opaque_number dot(const opaque_coordinate& other) const { if constexpr (N == 0) { - return OpaqueNumber(0.0); + return opaque_number(0.0); } else { - OpaqueNumber result = values_[0].multiply(other.values_[0]); + opaque_number result = values_[0].multiply(other.values_[0]); for (size_t i = 1; i < N; ++i) { result = result.add(values_[i].multiply(other.values_[i])); } @@ -459,7 +459,7 @@ namespace IfcGeom { return std::sqrt(dot(*this).to_double()); } - OpaqueCoordinate normalized() const { + opaque_coordinate normalized() const { const double length = norm(); if (length == 0.0) { return *this; @@ -467,7 +467,7 @@ namespace IfcGeom { return *this / values_[0].same_type(length); } - OpaqueCoordinate normalized_by_max_abs() const { + opaque_coordinate normalized_by_max_abs() const { double max_abs = 0.0; for (const auto& value : values_) { max_abs = (std::max)(max_abs, std::fabs(value.to_double())); @@ -489,29 +489,29 @@ namespace IfcGeom { }; #else template - struct IFC_GEOM_API OpaqueCoordinate { - OpaqueCoordinate(); - OpaqueCoordinate(const OpaqueCoordinate& other); - OpaqueCoordinate& operator=(const OpaqueCoordinate& other); - ~OpaqueCoordinate(); + struct IFC_GEOM_API opaque_coordinate { + opaque_coordinate(); + opaque_coordinate(const opaque_coordinate& other); + opaque_coordinate& operator=(const opaque_coordinate& other); + ~opaque_coordinate(); std::size_t size() const; - OpaqueNumber get(size_t i) const; + opaque_number get(size_t i) const; double get_double(size_t i) const; - void set(size_t i, const OpaqueNumber& n); + void set(size_t i, const opaque_number& n); std::vector to_double() const; }; #endif - class IFC_GEOM_API ConversionResultShape { + class IFC_GEOM_API conversion_result_shape { public: #ifdef SWIG virtual std::string backend_id() const = 0; #else virtual std::string_view backend_id() const = 0; #endif - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const = 0; - IfcGeom::Representation::Triangulation* Triangulate(const ifcopenshell::geometry::Settings& settings, ::logger& logger = ::logger::root()) const; - virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const = 0; + virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const = 0; + ifcopenshell::geom::Representation::triangulation* Triangulate(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) const; + virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const = 0; virtual int surface_genus() const = 0; virtual bool is_manifold() const = 0; @@ -523,73 +523,73 @@ namespace IfcGeom { // @todo choose one prototype virtual double bounding_box(void*&) const = 0; // @todo this must be something with a virtual dtor so that we can delete it. - virtual std::pair, OpaqueCoordinate<3>> bounding_box() const = 0; + virtual std::pair, opaque_coordinate<3>> bounding_box() const = 0; virtual void set_box(void* b) = 0; - virtual OpaqueNumber length() = 0; - virtual OpaqueNumber area() = 0; - virtual OpaqueNumber volume() = 0; + virtual opaque_number length() = 0; + virtual opaque_number area() = 0; + virtual opaque_number volume() = 0; - virtual OpaqueCoordinate<3> position() = 0; - virtual OpaqueCoordinate<3> axis() = 0; - virtual OpaqueCoordinate<4> plane_equation() = 0; + virtual opaque_coordinate<3> position() = 0; + virtual opaque_coordinate<3> axis() = 0; + virtual opaque_coordinate<4> plane_equation() = 0; - virtual std::vector convex_decomposition() = 0; - virtual ConversionResultShape* halfspaces() = 0; - virtual ConversionResultShape* box() = 0; - virtual ConversionResultShape* solid() = 0; - virtual ConversionResultShape* wrap_in_compound() = 0; + virtual std::vector convex_decomposition() = 0; + virtual conversion_result_shape* halfspaces() = 0; + virtual conversion_result_shape* box() = 0; + virtual conversion_result_shape* solid() = 0; + virtual conversion_result_shape* wrap_in_compound() = 0; - virtual std::vector vertices() = 0; - virtual std::vector edges() = 0; - virtual std::vector facets() = 0; + virtual std::vector vertices() = 0; + virtual std::vector edges() = 0; + virtual std::vector facets() = 0; - virtual ConversionResultShape* add(ConversionResultShape*) = 0; - virtual ConversionResultShape* subtract(ConversionResultShape*) = 0; - virtual ConversionResultShape* intersect(ConversionResultShape*) = 0; - virtual ConversionResultShape* concat(ConversionResultShape*) = 0; + virtual conversion_result_shape* add(conversion_result_shape*) = 0; + virtual conversion_result_shape* subtract(conversion_result_shape*) = 0; + virtual conversion_result_shape* intersect(conversion_result_shape*) = 0; + virtual conversion_result_shape* concat(conversion_result_shape*) = 0; - virtual std::size_t map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to) = 0; - virtual std::size_t map(const std::vector>& from, const std::vector>& to) = 0; - virtual ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const = 0; + virtual std::size_t map(opaque_coordinate<4>& from, opaque_coordinate<4>& to) = 0; + virtual std::size_t map(const std::vector>& from, const std::vector>& to) = 0; + virtual conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const = 0; - virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const = 0; + virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const = 0; - virtual ~ConversionResultShape() {} + virtual ~conversion_result_shape() {} }; - class IFC_GEOM_API ConversionResult { + class IFC_GEOM_API conversion_result { private: int id; - ifcopenshell::geometry::taxonomy::matrix4::ptr placement_; - std::shared_ptr shape_; - ifcopenshell::geometry::taxonomy::style::ptr style_; + ifcopenshell::geom::taxonomy::matrix4::ptr placement_; + std::shared_ptr shape_; + ifcopenshell::geom::taxonomy::style::ptr style_; public: - ConversionResult(int id, ifcopenshell::geometry::taxonomy::matrix4::ptr placement, ConversionResultShape* shape, ifcopenshell::geometry::taxonomy::style::ptr style) - : id(id), placement_(placement ? placement : ifcopenshell::geometry::taxonomy::make()), shape_(shape), style_(style) + conversion_result(int id, ifcopenshell::geom::taxonomy::matrix4::ptr placement, conversion_result_shape* shape, ifcopenshell::geom::taxonomy::style::ptr style) + : id(id), placement_(placement ? placement : ifcopenshell::geom::taxonomy::make()), shape_(shape), style_(style) {} - ConversionResult(int id, ifcopenshell::geometry::taxonomy::matrix4::ptr placement, ConversionResultShape* shape) - : id(id), placement_(placement ? placement : ifcopenshell::geometry::taxonomy::make()), shape_(shape) + conversion_result(int id, ifcopenshell::geom::taxonomy::matrix4::ptr placement, conversion_result_shape* shape) + : id(id), placement_(placement ? placement : ifcopenshell::geom::taxonomy::make()), shape_(shape) {} - ConversionResult(int id, ConversionResultShape* shape, ifcopenshell::geometry::taxonomy::style::ptr style) - : id(id), placement_(ifcopenshell::geometry::taxonomy::make()), shape_(shape), style_(style) + conversion_result(int id, conversion_result_shape* shape, ifcopenshell::geom::taxonomy::style::ptr style) + : id(id), placement_(ifcopenshell::geom::taxonomy::make()), shape_(shape), style_(style) {} - ConversionResult(int id, ConversionResultShape* shape) - : id(id), placement_(ifcopenshell::geometry::taxonomy::make()), shape_(shape) + conversion_result(int id, conversion_result_shape* shape) + : id(id), placement_(ifcopenshell::geom::taxonomy::make()), shape_(shape) {} - void append(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf); - void prepend(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf); - std::shared_ptr Shape() const { return shape_; } - ifcopenshell::geometry::taxonomy::matrix4::ptr Placement() const { return placement_; } + void append(ifcopenshell::geom::taxonomy::matrix4::ptr trsf); + void prepend(ifcopenshell::geom::taxonomy::matrix4::ptr trsf); + std::shared_ptr Shape() const { return shape_; } + ifcopenshell::geom::taxonomy::matrix4::ptr Placement() const { return placement_; } bool hasStyle() const { return !!style_; } - const ifcopenshell::geometry::taxonomy::style& Style() const { return *style_; } - ifcopenshell::geometry::taxonomy::style::ptr StylePtr() const { return style_; } - void setStyle(ifcopenshell::geometry::taxonomy::style::ptr newStyle) { style_ = newStyle; } + const ifcopenshell::geom::taxonomy::style& Style() const { return *style_; } + ifcopenshell::geom::taxonomy::style::ptr StylePtr() const { return style_; } + void setStyle(ifcopenshell::geom::taxonomy::style::ptr newStyle) { style_ = newStyle; } int ItemId() const { return id; } - ConversionResultShape* apply_transform(double unit_scale = 1.) const { + conversion_result_shape* apply_transform(double unit_scale = 1.) const { if (unit_scale != 1.) { - auto m = ifcopenshell::geometry::taxonomy::matrix4::ptr(placement_->clone_()); + auto m = ifcopenshell::geom::taxonomy::matrix4::ptr(placement_->clone_()); m->pre_multiply_scale(unit_scale); return shape_->moved(m); } else { @@ -598,17 +598,17 @@ namespace IfcGeom { } }; - typedef std::vector ConversionResults; + typedef std::vector conversion_results; #ifndef SWIG namespace util { // @todo this is now moved to occt kernel, do we need something similar in cgal? - // bool flatten_shape_list(const IfcGeom::ConversionResults& shapes, TopoDS_Shape& result, bool fuse, double tol); + // bool flatten_shape_list(const ifcopenshell::geom::conversion_results& shapes, TopoDS_Shape& result, bool fuse, double tol); // Function to find boundary loops from triangles template std::vector> find_boundary_loops(const std::vector& positions, const std::vector>& triangles) { - std::unordered_map edge_count; + std::unordered_map edge_count; // Count how many triangles each edge belongs to for (const auto& triangle : triangles) { @@ -621,7 +621,7 @@ namespace IfcGeom { } // Boundary edges have count 1 - std::vector boundary_edges; + std::vector boundary_edges; for (auto& p : edge_count) { if (p.second == 1) { boundary_edges.push_back(p.first); diff --git a/src/ifcgeom/ConversionSettings.cpp b/src/ifcgeom/ConversionSettings.cpp index b8032fe288..055183ffce 100644 --- a/src/ifcgeom/ConversionSettings.cpp +++ b/src/ifcgeom/ConversionSettings.cpp @@ -32,7 +32,7 @@ std::istream& std::operator>>(istream& in, vector& ds) { return in; } -std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, IteratorOutputOptions& ioo) +std::istream& ifcopenshell::geom::settings_detail::operator>>(std::istream& in, IteratorOutputOptions& ioo) { std::string token; in >> token; @@ -49,7 +49,7 @@ std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, Ite return in; } -std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, FunctionStepMethod& ioo) { +std::istream& ifcopenshell::geom::settings_detail::operator>>(std::istream& in, FunctionStepMethod& ioo) { std::string token; in >> token; boost::to_upper(token); @@ -63,7 +63,7 @@ std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, Fun return in; } -std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, OutputDimensionalityTypes& v) { +std::istream& ifcopenshell::geom::settings_detail::operator>>(std::istream& in, OutputDimensionalityTypes& v) { std::string token; in >> token; boost::to_upper(token); @@ -79,7 +79,7 @@ std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, Out return in; } -std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, TriangulationMethod& v) { +std::istream& ifcopenshell::geom::settings_detail::operator>>(std::istream& in, TriangulationMethod& v) { std::string token; in >> token; boost::to_upper(token); @@ -95,6 +95,6 @@ std::istream& ifcopenshell::geometry::settings::operator>>(std::istream& in, Tri return in; } -IfcGeom::geometry_exception::~geometry_exception() = default; +ifcopenshell::geom::geometry_exception::~geometry_exception() = default; -IfcGeom::too_many_faces_exception::~too_many_faces_exception() = default; +ifcopenshell::geom::too_many_faces_exception::~too_many_faces_exception() = default; diff --git a/src/ifcgeom/ConversionSettings.h b/src/ifcgeom/ConversionSettings.h index 6a6daf058a..834e796f81 100644 --- a/src/ifcgeom/ConversionSettings.h +++ b/src/ifcgeom/ConversionSettings.h @@ -29,8 +29,8 @@ namespace std { #endif namespace ifcopenshell { - namespace geometry { - inline namespace settings { + namespace geom { + namespace settings_detail { #ifndef SWIG template @@ -546,32 +546,32 @@ namespace ifcopenshell { }; template <> - struct readable_name { + struct readable_name { static constexpr const char* name = "IteratorOutputOptions"; }; template <> - struct readable_name { + struct readable_name { static constexpr const char* name = "FunctionStepMethod"; }; template <> - struct readable_name { + struct readable_name { static constexpr const char* name = "OutputDimensionalityTypes"; }; template <> - struct readable_name { + struct readable_name { static constexpr const char* name = "TriangulationMethod"; }; } template - class SettingsContainer { + class settings_container { public: typedef std::variant, std::set, - std::vector, std::vector, IteratorOutputOptions, FunctionStepMethod, - OutputDimensionalityTypes, TriangulationMethod> value_variant_t; + std::vector, std::vector, settings_detail::IteratorOutputOptions, settings_detail::FunctionStepMethod, + settings_detail::OutputDimensionalityTypes, settings_detail::TriangulationMethod> value_variant_t; private: settings_t settings; @@ -678,15 +678,461 @@ namespace ifcopenshell { } }; - class Settings : public SettingsContainer< - std::tuple - > - {}; + namespace settings_detail { + + struct UseElementNames : public settings_detail::SettingBase { + static constexpr const char* const name = "use-element-names"; + static constexpr const char* const description = "Use entity instance IfcRoot.Name instead of unique IDs for naming elements upon serialization. Applicable for OBJ, DAE, STP, and SVG output."; + static constexpr bool defaultvalue = false; + }; + + struct UseElementGuids : public settings_detail::SettingBase { + static constexpr const char* const name = "use-element-guids"; + static constexpr const char* const description = "Use entity instance IfcRoot.GlobalId instead of unique IDs for naming elements upon serialization. Applicable for OBJ, DAE, STP, and SVG output."; + static constexpr bool defaultvalue = false; + }; + + struct UseElementStepIds : public settings_detail::SettingBase { + static constexpr const char* const name = "use-element-step-ids"; + static constexpr const char* const description = "Use the numeric step identifier (entity instance name) for naming elements upon serialization. Applicable for OBJ, DAE, STP, and SVG output."; + static constexpr bool defaultvalue = false; + }; + + struct UseElementTypes : public settings_detail::SettingBase { + static constexpr const char* const name = "use-element-types"; + static constexpr const char* const description = "Use element types instead of unique IDs for naming elements upon serialization. Applicable to DAE output."; + static constexpr bool defaultvalue = false; + }; + + struct UseYUp : public settings_detail::SettingBase { + static constexpr const char* const name = "y-up"; + static constexpr const char* const description = "Change the 'up' axis to positive Y, default is Z UP. Applicable to OBJ output."; + static constexpr bool defaultvalue = false; + }; + + struct WriteGltfEcef : public settings_detail::SettingBase { + static constexpr const char* const name = "ecef"; + static constexpr const char* const description = "Write glTF in Earth-Centered Earth-Fixed coordinates. Requires PROJ."; + static constexpr bool defaultvalue = false; + }; + + struct FloatingPointDigits : public settings_detail::SettingBase { + static constexpr const char* const name = "digits"; + static constexpr const char* const description = "Sets the precision to be used to format floating-point values, 15 by default. Use a negative value to use the system's default precision (should be 6 typically). Applicable for OBJ and DAE output. For DAE output, value >= 15 means that up to 16 decimals are used, and any other value means that 6 or 7 decimals are used."; + static constexpr int defaultvalue = 15; + }; + + struct BaseUri : public settings_detail::SettingBase { + static constexpr const char* const name = "base-uri"; + static constexpr const char* const description = "Base URI for products to be used in RDF-based serializations."; + }; + + struct WktUseSection : public settings_detail::SettingBase { + static constexpr const char* const name = "wkt-use-section"; + static constexpr const char* const description = "Use a geometrical section rather than full polyhedral output and footprint in TTL WKT"; + static constexpr bool defaultvalue = false; + }; + + struct SeparateZUpNode : public settings_detail::SettingBase { + static constexpr const char* const name = "separate-z-up-node"; + static constexpr const char* const description = "Introduce a separate Z-Up node into the GlTF hierarchy instead of multiplying the transform into the root node matrices"; + static constexpr bool defaultvalue = false; + }; + + struct SvgBounds : public settings_detail::SettingBase { + static constexpr const char* const name = "bounds"; + static constexpr const char* const description = "Specifies the bounding rectangle, for example 512x512, to which the output will be scaled. Only used when converting to SVG."; + }; + + struct SvgScale : public settings_detail::SettingBase { + static constexpr const char* const name = "scale"; + static constexpr const char* const description = "Interprets SVG bounds in mm, centers layout and draw elements to scale. Only used when converting to SVG. Example 1:100."; + }; + + struct SvgCenter : public settings_detail::SettingBase { + static constexpr const char* const name = "center"; + static constexpr const char* const description = "When using --scale, specifies the location in the range [0 1]x[0 1] around which to center the drawings. Example 0.5x0.5."; + }; + + struct SvgSectionRef : public settings_detail::SettingBase { + static constexpr const char* const name = "section-ref"; + static constexpr const char* const description = "Element at which cross sections should be created."; + }; + + struct SvgElevationRef : public settings_detail::SettingBase { + static constexpr const char* const name = "elevation-ref"; + static constexpr const char* const description = "Element at which drawings should be created."; + }; + + struct SvgElevationRefGuid : public settings_detail::SettingBase { + static constexpr const char* const name = "elevation-ref-guid"; + static constexpr const char* const description = "Element guids at which drawings should be created."; + }; + + struct SvgAutoSection : public settings_detail::SettingBase { + static constexpr const char* const name = "auto-section"; + static constexpr const char* const description = "Creates SVG cross section drawings automatically based on model extents."; + static constexpr bool defaultvalue = false; + }; + + struct SvgAutoElevation : public settings_detail::SettingBase { + static constexpr const char* const name = "auto-elevation"; + static constexpr const char* const description = "Creates SVG elevation drawings automatically based on model extents."; + static constexpr bool defaultvalue = false; + }; + + struct SvgDrawStoreyHeights : public settings_detail::SettingBase { + static constexpr const char* const name = "draw-storey-heights"; + static constexpr const char* const description = "Draws a horizontal line at the height of building storeys in vertical drawings. Accepted values are none, full, and left."; + }; + + struct SvgProfileThreshold : public settings_detail::SettingBase { + static constexpr const char* const name = "profile-threshold"; + static constexpr const char* const description = "Limits the number of projected wire profiles for non-wall and non-slab elements in SVG output. A negative value disables the limit."; + static constexpr int defaultvalue = -1; + }; + + struct SvgStoreyHeightLineLength : public settings_detail::SettingBase { + static constexpr const char* const name = "storey-height-line-length"; + static constexpr const char* const description = "Length of the line when --draw-storey-heights=left."; + }; + + struct SvgUseNamespace : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-xmlns"; + static constexpr const char* const description = "Stores name and guid in a separate namespace as opposed to data-name, data-guid."; + static constexpr bool defaultvalue = false; + }; + + struct SvgUseHlrPoly : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-poly"; + static constexpr const char* const description = "Uses the polygonal algorithm for hidden line rendering."; + static constexpr bool defaultvalue = false; + }; + + struct SvgUsePrefiltering : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-prefilter"; + static constexpr const char* const description = "Prefilter faces and shapes before feeding to the hidden-line algorithm."; + static constexpr bool defaultvalue = false; + }; + + struct SvgUnifyInputs : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-unify-inputs"; + static constexpr const char* const description = "Unify input shapes before SVG projection."; + static constexpr bool defaultvalue = false; + }; + + struct SvgSegmentProjection : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-segment-projection"; + static constexpr const char* const description = "Segment result of projection with respect to original products."; + static constexpr bool defaultvalue = false; + }; + + struct SvgSubtractBefore : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-subtract-before"; + static constexpr const char* const description = "Controls which shapes are cut before SVG hidden-line projection. Accepted values are auto, slabs-and-walls, and always."; + }; + + struct SvgPolygonal : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-write-poly"; + static constexpr const char* const description = "Approximate every curve as polygonal in SVG output."; + static constexpr bool defaultvalue = false; + }; + + struct SvgAlwaysProject : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-project"; + static constexpr const char* const description = "Always enable hidden line rendering instead of only on elevations."; + static constexpr bool defaultvalue = false; + }; + + struct SvgWithoutStoreys : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-without-storeys"; + static constexpr const char* const description = "Do not emit drawings for building storeys."; + static constexpr bool defaultvalue = false; + }; + + struct SvgNoCss : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-no-css"; + static constexpr const char* const description = "Do not emit CSS style declarations."; + static constexpr bool defaultvalue = false; + }; + + struct SvgMirrorY : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-mirror-y"; + static constexpr const char* const description = "Mirror SVG output along the Y axis."; + static constexpr bool defaultvalue = false; + }; + + struct SvgMirrorX : public settings_detail::SettingBase { + static constexpr const char* const name = "svg-mirror-x"; + static constexpr const char* const description = "Mirror SVG output along the X axis."; + static constexpr bool defaultvalue = false; + }; + + struct SvgDoorArcs : public settings_detail::SettingBase { + static constexpr const char* const name = "door-arcs"; + static constexpr const char* const description = "Draw door opening arcs for IfcDoor elements."; + static constexpr bool defaultvalue = false; + }; + + struct SvgSectionHeight : public settings_detail::SettingBase { + static constexpr const char* const name = "section-height"; + static constexpr const char* const description = "Specifies the cut section height for SVG 2D geometry."; + }; + + struct SvgSectionHeightFromStoreys : public settings_detail::SettingBase { + static constexpr const char* const name = "section-height-from-storeys"; + static constexpr const char* const description = "Derives section height from storey elevation. Use --section-height to override the default offset of 1.2."; + static constexpr bool defaultvalue = false; + }; + + struct SvgPrintSpaceNames : public settings_detail::SettingBase { + static constexpr const char* const name = "print-space-names"; + static constexpr const char* const description = "Prints IfcSpace LongName and Name in the geometry output. Applicable for SVG output."; + static constexpr bool defaultvalue = false; + }; + + struct SvgPrintSpaceAreas : public settings_detail::SettingBase { + static constexpr const char* const name = "print-space-areas"; + static constexpr const char* const description = "Prints calculated IfcSpace areas in square meters. Applicable for SVG output."; + static constexpr bool defaultvalue = false; + }; + + struct SvgSpaceNameTransform : public settings_detail::SettingBase { + static constexpr const char* const name = "space-name-transform"; + static constexpr const char* const description = "Additional transform to the space labels in SVG."; + }; +} + +using geometry_setting_types = std::tuple< + settings_detail::MesherLinearDeflection, + settings_detail::MesherAngularDeflection, + settings_detail::ReorientShells, + settings_detail::LengthUnit, + settings_detail::PlaneUnit, + settings_detail::Precision, + settings_detail::OutputDimensionality, + settings_detail::LayersetFirst, + settings_detail::DisableBooleanResult, + settings_detail::NoWireIntersectionCheck, + settings_detail::NoWireIntersectionTolerance, + settings_detail::PrecisionFactor, + settings_detail::DebugBooleanOperations, + settings_detail::BooleanAttempt2d, + settings_detail::SurfaceColour, + settings_detail::WeldVertices, + settings_detail::UseWorldCoords, + settings_detail::UnifyShapes, + settings_detail::UseMaterialNames, + settings_detail::ConvertBackUnits, + settings_detail::ContextIds, + settings_detail::ContextTypes, + settings_detail::ContextIdentifiers, + settings_detail::ContextPriorities, + settings_detail::IteratorOutput, + settings_detail::DisableOpeningSubtractions, + settings_detail::MaxVoidsPerElement, + settings_detail::ApplyDefaultMaterials, + settings_detail::DontEmitNormals, + settings_detail::GenerateUvs, + settings_detail::ApplyLayerSets, + settings_detail::UseElementHierarchy, + settings_detail::ValidateQuantities, + settings_detail::EdgeArrows, + settings_detail::BuildingLocalPlacement, + settings_detail::SiteLocalPlacement, + settings_detail::ForceSpaceTransparency, + settings_detail::CircleSegments, + settings_detail::CgalSmoothAngleDegrees, + settings_detail::SvgRidgeAngleMinDegrees, + settings_detail::SvgValleyAngleMinDegrees, + settings_detail::SvgEmitFlushEdges, + settings_detail::SvgUseEdgeClassification, + settings_detail::SvgRenderCreaseEdges, + settings_detail::SvgRenderSharpEdges, + settings_detail::KeepBoundingBoxes, + settings_detail::ComputeCurvature, + settings_detail::FunctionStepType, + settings_detail::FunctionStepParam, + settings_detail::NoParallelMapping, + settings_detail::PermissiveShapeReuse, + settings_detail::ModelOffset, + settings_detail::ModelRotation, + settings_detail::TriangulationType, + settings_detail::CgalEmitOriginalEdges, + settings_detail::OcctNoCleanTriangulation, + settings_detail::CacheShapes, + settings_detail::DeferProcessingFirstElement, + settings_detail::MaxOffset, + settings_detail::MaxOffsetDeviation, + settings_detail::ApplyOffset, + settings_detail::MakeVolume, + settings_detail::UseElementNames, + settings_detail::UseElementGuids, + settings_detail::UseElementStepIds, + settings_detail::UseElementTypes, + settings_detail::UseYUp, + settings_detail::WriteGltfEcef, + settings_detail::FloatingPointDigits, + settings_detail::BaseUri, + settings_detail::WktUseSection, + settings_detail::SeparateZUpNode, + settings_detail::SvgBounds, + settings_detail::SvgScale, + settings_detail::SvgCenter, + settings_detail::SvgSectionRef, + settings_detail::SvgElevationRef, + settings_detail::SvgElevationRefGuid, + settings_detail::SvgAutoSection, + settings_detail::SvgAutoElevation, + settings_detail::SvgDrawStoreyHeights, + settings_detail::SvgProfileThreshold, + settings_detail::SvgStoreyHeightLineLength, + settings_detail::SvgUseNamespace, + settings_detail::SvgUseHlrPoly, + settings_detail::SvgUsePrefiltering, + settings_detail::SvgUnifyInputs, + settings_detail::SvgSegmentProjection, + settings_detail::SvgSubtractBefore, + settings_detail::SvgPolygonal, + settings_detail::SvgAlwaysProject, + settings_detail::SvgWithoutStoreys, + settings_detail::SvgNoCss, + settings_detail::SvgMirrorY, + settings_detail::SvgMirrorX, + settings_detail::SvgDoorArcs, + settings_detail::SvgSectionHeight, + settings_detail::SvgSectionHeightFromStoreys, + settings_detail::SvgPrintSpaceNames, + settings_detail::SvgPrintSpaceAreas, + settings_detail::SvgSpaceNameTransform>; + + class settings : public settings_container { + public: + using MesherLinearDeflection = settings_detail::MesherLinearDeflection; + using MesherAngularDeflection = settings_detail::MesherAngularDeflection; + using ReorientShells = settings_detail::ReorientShells; + using LengthUnit = settings_detail::LengthUnit; + using PlaneUnit = settings_detail::PlaneUnit; + using Precision = settings_detail::Precision; + using OutputDimensionality = settings_detail::OutputDimensionality; + using LayersetFirst = settings_detail::LayersetFirst; + using DisableBooleanResult = settings_detail::DisableBooleanResult; + using NoWireIntersectionCheck = settings_detail::NoWireIntersectionCheck; + using NoWireIntersectionTolerance = settings_detail::NoWireIntersectionTolerance; + using PrecisionFactor = settings_detail::PrecisionFactor; + using DebugBooleanOperations = settings_detail::DebugBooleanOperations; + using BooleanAttempt2d = settings_detail::BooleanAttempt2d; + using SurfaceColour = settings_detail::SurfaceColour; + using WeldVertices = settings_detail::WeldVertices; + using UseWorldCoords = settings_detail::UseWorldCoords; + using UnifyShapes = settings_detail::UnifyShapes; + using UseMaterialNames = settings_detail::UseMaterialNames; + using ConvertBackUnits = settings_detail::ConvertBackUnits; + using ContextIds = settings_detail::ContextIds; + using ContextTypes = settings_detail::ContextTypes; + using ContextIdentifiers = settings_detail::ContextIdentifiers; + using ContextPriorities = settings_detail::ContextPriorities; + using IteratorOutput = settings_detail::IteratorOutput; + using DisableOpeningSubtractions = settings_detail::DisableOpeningSubtractions; + using MaxVoidsPerElement = settings_detail::MaxVoidsPerElement; + using ApplyDefaultMaterials = settings_detail::ApplyDefaultMaterials; + using DontEmitNormals = settings_detail::DontEmitNormals; + using GenerateUvs = settings_detail::GenerateUvs; + using ApplyLayerSets = settings_detail::ApplyLayerSets; + using UseElementHierarchy = settings_detail::UseElementHierarchy; + using ValidateQuantities = settings_detail::ValidateQuantities; + using EdgeArrows = settings_detail::EdgeArrows; + using BuildingLocalPlacement = settings_detail::BuildingLocalPlacement; + using SiteLocalPlacement = settings_detail::SiteLocalPlacement; + using ForceSpaceTransparency = settings_detail::ForceSpaceTransparency; + using CircleSegments = settings_detail::CircleSegments; + using CgalSmoothAngleDegrees = settings_detail::CgalSmoothAngleDegrees; + using SvgRidgeAngleMinDegrees = settings_detail::SvgRidgeAngleMinDegrees; + using SvgValleyAngleMinDegrees = settings_detail::SvgValleyAngleMinDegrees; + using SvgEmitFlushEdges = settings_detail::SvgEmitFlushEdges; + using SvgUseEdgeClassification = settings_detail::SvgUseEdgeClassification; + using SvgRenderCreaseEdges = settings_detail::SvgRenderCreaseEdges; + using SvgRenderSharpEdges = settings_detail::SvgRenderSharpEdges; + using KeepBoundingBoxes = settings_detail::KeepBoundingBoxes; + using ComputeCurvature = settings_detail::ComputeCurvature; + using FunctionStepType = settings_detail::FunctionStepType; + using FunctionStepParam = settings_detail::FunctionStepParam; + using NoParallelMapping = settings_detail::NoParallelMapping; + using PermissiveShapeReuse = settings_detail::PermissiveShapeReuse; + using ModelOffset = settings_detail::ModelOffset; + using ModelRotation = settings_detail::ModelRotation; + using TriangulationType = settings_detail::TriangulationType; + using CgalEmitOriginalEdges = settings_detail::CgalEmitOriginalEdges; + using OcctNoCleanTriangulation = settings_detail::OcctNoCleanTriangulation; + using CacheShapes = settings_detail::CacheShapes; + using DeferProcessingFirstElement = settings_detail::DeferProcessingFirstElement; + using MaxOffset = settings_detail::MaxOffset; + using MaxOffsetDeviation = settings_detail::MaxOffsetDeviation; + using ApplyOffset = settings_detail::ApplyOffset; + using MakeVolume = settings_detail::MakeVolume; + + using UseElementNames = settings_detail::UseElementNames; + using UseElementGuids = settings_detail::UseElementGuids; + using UseElementStepIds = settings_detail::UseElementStepIds; + using UseElementTypes = settings_detail::UseElementTypes; + using UseYUp = settings_detail::UseYUp; + using WriteGltfEcef = settings_detail::WriteGltfEcef; + using FloatingPointDigits = settings_detail::FloatingPointDigits; + using BaseUri = settings_detail::BaseUri; + using WktUseSection = settings_detail::WktUseSection; + using SeparateZUpNode = settings_detail::SeparateZUpNode; + using SvgBounds = settings_detail::SvgBounds; + using SvgScale = settings_detail::SvgScale; + using SvgCenter = settings_detail::SvgCenter; + using SvgSectionRef = settings_detail::SvgSectionRef; + using SvgElevationRef = settings_detail::SvgElevationRef; + using SvgElevationRefGuid = settings_detail::SvgElevationRefGuid; + using SvgAutoSection = settings_detail::SvgAutoSection; + using SvgAutoElevation = settings_detail::SvgAutoElevation; + using SvgDrawStoreyHeights = settings_detail::SvgDrawStoreyHeights; + using SvgProfileThreshold = settings_detail::SvgProfileThreshold; + using SvgStoreyHeightLineLength = settings_detail::SvgStoreyHeightLineLength; + using SvgUseNamespace = settings_detail::SvgUseNamespace; + using SvgUseHlrPoly = settings_detail::SvgUseHlrPoly; + using SvgUsePrefiltering = settings_detail::SvgUsePrefiltering; + using SvgUnifyInputs = settings_detail::SvgUnifyInputs; + using SvgSegmentProjection = settings_detail::SvgSegmentProjection; + using SvgSubtractBefore = settings_detail::SvgSubtractBefore; + using SvgPolygonal = settings_detail::SvgPolygonal; + using SvgAlwaysProject = settings_detail::SvgAlwaysProject; + using SvgWithoutStoreys = settings_detail::SvgWithoutStoreys; + using SvgNoCss = settings_detail::SvgNoCss; + using SvgMirrorY = settings_detail::SvgMirrorY; + using SvgMirrorX = settings_detail::SvgMirrorX; + using SvgDoorArcs = settings_detail::SvgDoorArcs; + using SvgSectionHeight = settings_detail::SvgSectionHeight; + using SvgSectionHeightFromStoreys = settings_detail::SvgSectionHeightFromStoreys; + using SvgPrintSpaceNames = settings_detail::SvgPrintSpaceNames; + using SvgPrintSpaceAreas = settings_detail::SvgPrintSpaceAreas; + using SvgSpaceNameTransform = settings_detail::SvgSpaceNameTransform; + + using OutputDimensionalityTypes = settings_detail::OutputDimensionalityTypes; + using IteratorOutputOptions = settings_detail::IteratorOutputOptions; + using FunctionStepMethod = settings_detail::FunctionStepMethod; + using TriangulationMethod = settings_detail::TriangulationMethod; + + static constexpr auto CURVES = settings_detail::CURVES; + static constexpr auto SURFACES_AND_SOLIDS = settings_detail::SURFACES_AND_SOLIDS; + static constexpr auto CURVES_SURFACES_AND_SOLIDS = settings_detail::CURVES_SURFACES_AND_SOLIDS; + static constexpr auto TRIANGULATED = settings_detail::TRIANGULATED; + static constexpr auto NATIVE = settings_detail::NATIVE; + static constexpr auto SERIALIZED = settings_detail::SERIALIZED; + static constexpr auto MAXSTEPSIZE = settings_detail::MAXSTEPSIZE; + static constexpr auto MINSTEPS = settings_detail::MINSTEPS; + static constexpr auto TRIANGLE_MESH = settings_detail::TRIANGLE_MESH; + static constexpr auto POLYHEDRON_WITHOUT_HOLES = settings_detail::POLYHEDRON_WITHOUT_HOLES; + static constexpr auto POLYHEDRON_WITH_HOLES = settings_detail::POLYHEDRON_WITH_HOLES; + }; } } // @todo find a place -namespace IfcGeom { +namespace ifcopenshell::geom { #if defined(_MSC_VER) #pragma warning(push) diff --git a/src/ifcgeom/Converter.cpp b/src/ifcgeom/Converter.cpp index 793778e508..ff35ce334f 100644 --- a/src/ifcgeom/Converter.cpp +++ b/src/ifcgeom/Converter.cpp @@ -2,23 +2,23 @@ #include "../ifcgeom/IfcGeomElement.h" -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; -ifcopenshell::geometry::Converter::Converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geometry::Settings& s, ::logger& logger) +ifcopenshell::geom::converter::converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger) : kernel_(std::move(geometry_library)) , logger_(logger) { - mapping_ = impl::mapping_implementations().construct(file, s, logger_); + mapping_ = impl::mapping_implementations().construct(file, settings, logger_); // Mapping reads unit information and applies to settings settings_ = mapping_->settings(); } -ifcopenshell::geometry::Converter::~Converter() { +ifcopenshell::geom::converter::~converter() { delete mapping_; } namespace { - void substitute_with_box_based_on_density(::logger& logger, IfcGeom::ConversionResults& items, double& density) { + void substitute_with_box_based_on_density(::logger& logger, ifcopenshell::geom::conversion_results& items, double& density) { int nv = 0; void* box = nullptr; double volume = 0.; @@ -35,8 +35,8 @@ namespace { } } -IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const express::Base product_, const taxonomy::matrix4::ptr& place_) { - auto product = product_.as(); +ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for_representation_and_product(taxonomy::ptr representation_node, const express::base product_, const taxonomy::matrix4::ptr& place_) { + auto product = product_.as(); std::stringstream representation_id_builder; @@ -44,17 +44,17 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe representation_id_builder << representation_node->instance.id(); - IfcGeom::Representation::BRep* shape; - IfcGeom::ConversionResults shapes; + ifcopenshell::geom::Representation::brep* shape; + ifcopenshell::geom::conversion_results shapes; if (!kernel_->convert(representation_node, shapes)) { return 0; } - if (settings_.get().get()) { - ifcopenshell::geometry::layerset_information layerinfo; - std::vector neighbours; - std::map neigbour_layers; + if (settings_.get().get()) { + ifcopenshell::geom::layerset_information layerinfo; + std::vector neighbours; + std::map neigbour_layers; int layerset_id, lid; if (mapping_->get_layerset_information(product, layerinfo, layerset_id)) { @@ -149,18 +149,18 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe representation_id_builder << "-material-" << single_material.id(); } - if (settings_.get().has() && product.declaration().is("IfcSpace")) { + if (settings_.get().has() && product.declaration().is("IfcSpace")) { for (auto& s : shapes) { if (s.hasStyle()) { // @todo the uglyness - const_cast(&*s.StylePtr())->transparency = settings_.get().get(); + const_cast(&*s.StylePtr())->transparency = settings_.get().get(); } } } int parent_id = -1; try { - express::Base parent_object = mapping_->get_decomposing_entity(product); + express::base parent_object = mapping_->get_decomposing_entity(product); if (parent_object) { parent_id = parent_object.id(); } @@ -178,8 +178,8 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe auto openings = mapping_->find_openings(product); const bool no_openings = openings.empty(); - const bool disable_opening_subtractions = settings_.get().get(); - const bool above_limit = settings_.get().has() && settings_.get().get() != 0 && openings.size() > settings_.get().get(); + const bool disable_opening_subtractions = settings_.get().get(); + const bool above_limit = settings_.get().has() && settings_.get().get() != 0 && openings.size() > settings_.get().get(); if (above_limit) { logger_.warning("GEO", 403, "Element has more openings than the maximum allowed. Openings will not be processed for this element:", product); @@ -191,12 +191,12 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe representation_id_builder << "-" << op.id(); } - IfcGeom::ConversionResults opened_shapes; + ifcopenshell::geom::conversion_results opened_shapes; bool caught_error = false; try { std::vector> opening_items; - std::transform(openings.begin(), openings.end(), std::back_inserter(opening_items), [this](express::Base opening) { + std::transform(openings.begin(), openings.end(), std::back_inserter(opening_items), [this](express::base opening) { auto prod_item = mapping()->map(opening); auto repr = mapping()->representation_of(opening); if (repr) { @@ -226,25 +226,25 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe } if (!(caught_error && opened_shapes.size() < shapes.size())) { - if (settings_.get().get()) { + if (settings_.get().get()) { for (auto it = opened_shapes.begin(); it != opened_shapes.end(); ++it) { it->prepend(place); } - place = ifcopenshell::geometry::taxonomy::make(); + place = ifcopenshell::geom::taxonomy::make(); representation_id_builder << "-world-coords"; } shapes = opened_shapes; } - } else if (settings_.get().get()) { + } else if (settings_.get().get()) { for (auto it = shapes.begin(); it != shapes.end(); ++it) { it->prepend(place); } - place = ifcopenshell::geometry::taxonomy::make(); + place = ifcopenshell::geom::taxonomy::make(); representation_id_builder << "-world-coords"; } - if (settings_.get().get()) { - IfcGeom::ConversionResults unified_shapes; + if (settings_.get().get()) { + ifcopenshell::geom::conversion_results unified_shapes; try { if (kernel_->unify_shapes(shapes, unified_shapes)) { std::swap(shapes, unified_shapes); @@ -254,25 +254,25 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe } } - shape = new IfcGeom::Representation::BRep(settings_, product_type, representation_id_builder.str(), shapes); + shape = new ifcopenshell::geom::Representation::brep(settings_, product_type, representation_id_builder.str(), shapes); std::string context_string = ""; // IfcShapeRepresentation. - auto representation = representation_node->instance.as(); + auto representation = representation_node->instance.as(); auto representation_identifier = representation.get("RepresentationIdentifier"); if (!representation_identifier.isNull()) { context_string = (std::string) representation_identifier; } else { - auto context = (express::Base)representation.get("ContextOfItems"); - auto context_type = context.as().get("ContextType"); + auto context = (express::base)representation.get("ContextOfItems"); + auto context_type = context.as().get("ContextType"); if (!context_type.isNull()) { context_string = (std::string)context_type; } } - auto elem = new IfcGeom::BRepElement( + auto elem = new ifcopenshell::geom::brep_element( product.id(), parent_id, name, @@ -280,7 +280,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe guid, context_string, place, - boost::shared_ptr(shape), + boost::shared_ptr(shape), product ); @@ -359,12 +359,12 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe return elem; } -IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(const express::Base product_, const taxonomy::matrix4::ptr& place, IfcGeom::BRepElement* brep) { - auto product = product_.as(); +ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for_processed_representation(const express::base product_, const taxonomy::matrix4::ptr& place, ifcopenshell::geom::brep_element* brep) { + auto product = product_.as(); int parent_id = -1; try { - express::Base parent_object = mapping_->get_decomposing_entity(product); + express::base parent_object = mapping_->get_decomposing_entity(product); if (parent_object) { parent_id = parent_object.id(); } @@ -377,7 +377,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process const std::string product_type = product.declaration().name(); const std::string context_string = brep->context(); - return new IfcGeom::BRepElement( + return new ifcopenshell::geom::brep_element( product.id(), parent_id, name, @@ -390,7 +390,7 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_process ); } -IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_representation_and_product(const express::Base representation, const express::Base product) { +ifcopenshell::geom::brep_element* ifcopenshell::geom::converter::create_brep_for_representation_and_product(const express::base representation, const express::base product) { auto interpreted_representation = mapping_->map(representation); if (!interpreted_representation) { interpreted_representation = taxonomy::make(); @@ -403,11 +403,11 @@ IfcGeom::BRepElement* ifcopenshell::geometry::Converter::create_brep_for_represe ); } -IfcGeom::ConversionResults ifcopenshell::geometry::Converter::convert(express::Base item) +ifcopenshell::geom::conversion_results ifcopenshell::geom::converter::convert(express::base item) { std::clock_t map_start = std::clock(); auto geom_item = mapping_->map(item); - IfcGeom::ConversionResults results; + ifcopenshell::geom::conversion_results results; if (geom_item) { std::clock_t geom_start = std::clock(); if (!kernel_->convert(geom_item, results)) { diff --git a/src/ifcgeom/Converter.h b/src/ifcgeom/Converter.h index 1c059c66ae..32f26e23ac 100644 --- a/src/ifcgeom/Converter.h +++ b/src/ifcgeom/Converter.h @@ -11,32 +11,32 @@ #include -namespace ifcopenshell { namespace geometry { +namespace ifcopenshell { namespace geom { - class IFC_GEOM_API Converter { + class IFC_GEOM_API converter { public: - typedef boost::shared_ptr brep_ptr; + typedef boost::shared_ptr brep_ptr; private: - ifcopenshell::geometry::abstract_mapping* mapping_; - std::unique_ptr kernel_; - ifcopenshell::geometry::Settings settings_; - std::map cache_; + ifcopenshell::geom::abstract_mapping* mapping_; + std::unique_ptr kernel_; + ifcopenshell::geom::settings settings_; + std::map cache_; ::logger& logger_; public: - ifcopenshell::geometry::kernels::AbstractKernel* kernel() { return &*kernel_; } + ifcopenshell::geom::kernels::abstract_kernel* kernel() { return &*kernel_; } - Converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geometry::Settings& settings, ::logger& logger = ::logger::root()); + converter(std::unique_ptr&& geometry_library, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()); - ~Converter(); + ~converter(); - ifcopenshell::geometry::abstract_mapping* mapping() const { return mapping_; } + ifcopenshell::geom::abstract_mapping* mapping() const { return mapping_; } ::logger& logger() const { return logger_; } /* virtual NativeElement* convert( - const IteratorSettings& settings, express::Base representation, - express::Base product) + const IteratorSettings& settings, express::base representation, + express::base product) { return implementation_->convert(settings, representation, product); } @@ -45,15 +45,15 @@ namespace ifcopenshell { namespace geometry { double total_map_time = 0.; double total_geom_time = 0.; - IfcGeom::ConversionResults convert(express::Base item); + ifcopenshell::geom::conversion_results convert(express::base item); - IfcGeom::BRepElement* create_brep_for_representation_and_product(const express::Base representation, const express::Base product); - // IfcGeom::BRepElement* create_brep_for_processed_representation(const express::Base representation, const express::Base product, IfcGeom::BRepElement* brep); + ifcopenshell::geom::brep_element* create_brep_for_representation_and_product(const express::base representation, const express::base product); + // ifcopenshell::geom::brep_element* create_brep_for_processed_representation(const express::base representation, const express::base product, ifcopenshell::geom::brep_element* brep); - IfcGeom::BRepElement* create_brep_for_representation_and_product(ifcopenshell::geometry::taxonomy::ptr, const express::Base product, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place); - IfcGeom::BRepElement* create_brep_for_processed_representation(const express::Base product, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, IfcGeom::BRepElement*); + ifcopenshell::geom::brep_element* create_brep_for_representation_and_product(ifcopenshell::geom::taxonomy::ptr, const express::base product, const ifcopenshell::geom::taxonomy::matrix4::ptr& place); + ifcopenshell::geom::brep_element* create_brep_for_processed_representation(const express::base product, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, ifcopenshell::geom::brep_element*); - const ifcopenshell::geometry::Settings& settings() { return settings_; } + const ifcopenshell::geom::settings& settings() { return settings_; } }; }} diff --git a/src/ifcgeom/GeometrySerializer.h b/src/ifcgeom/GeometrySerializer.h index 25de78f3af..7505fe0fcc 100644 --- a/src/ifcgeom/GeometrySerializer.h +++ b/src/ifcgeom/GeometrySerializer.h @@ -25,280 +25,6 @@ #include "../ifcparse/logger.h" #include -namespace ifcopenshell { -namespace geometry { -inline namespace settings { - - struct UseElementNames : public SettingBase { - static constexpr const char* const name = "use-element-names"; - static constexpr const char* const description = "Use entity instance IfcRoot.Name instead of unique IDs for naming elements upon serialization. Applicable for OBJ, DAE, STP, and SVG output."; - static constexpr bool defaultvalue = false; - }; - - struct UseElementGuids : public SettingBase { - static constexpr const char* const name = "use-element-guids"; - static constexpr const char* const description = "Use entity instance IfcRoot.GlobalId instead of unique IDs for naming elements upon serialization. Applicable for OBJ, DAE, STP, and SVG output."; - static constexpr bool defaultvalue = false; - }; - - struct UseElementStepIds : public SettingBase { - static constexpr const char* const name = "use-element-step-ids"; - static constexpr const char* const description = "Use the numeric step identifier (entity instance name) for naming elements upon serialization. Applicable for OBJ, DAE, STP, and SVG output."; - static constexpr bool defaultvalue = false; - }; - - struct UseElementTypes : public SettingBase { - static constexpr const char* const name = "use-element-types"; - static constexpr const char* const description = "Use element types instead of unique IDs for naming elements upon serialization. Applicable to DAE output."; - static constexpr bool defaultvalue = false; - }; - - struct UseYUp : public SettingBase { - static constexpr const char* const name = "y-up"; - static constexpr const char* const description = "Change the 'up' axis to positive Y, default is Z UP. Applicable to OBJ output."; - static constexpr bool defaultvalue = false; - }; - - struct WriteGltfEcef : public SettingBase { - static constexpr const char* const name = "ecef"; - static constexpr const char* const description = "Write glTF in Earth-Centered Earth-Fixed coordinates. Requires PROJ."; - static constexpr bool defaultvalue = false; - }; - - struct FloatingPointDigits : public SettingBase { - static constexpr const char* const name = "digits"; - static constexpr const char* const description = "Sets the precision to be used to format floating-point values, 15 by default. Use a negative value to use the system's default precision (should be 6 typically). Applicable for OBJ and DAE output. For DAE output, value >= 15 means that up to 16 decimals are used, and any other value means that 6 or 7 decimals are used."; - static constexpr int defaultvalue = 15; - }; - - struct BaseUri : public SettingBase { - static constexpr const char* const name = "base-uri"; - static constexpr const char* const description = "Base URI for products to be used in RDF-based serializations."; - }; - - struct WktUseSection : public SettingBase { - static constexpr const char* const name = "wkt-use-section"; - static constexpr const char* const description = "Use a geometrical section rather than full polyhedral output and footprint in TTL WKT"; - static constexpr bool defaultvalue = false; - }; - - struct SeparateZUpNode : public SettingBase { - static constexpr const char* const name = "separate-z-up-node"; - static constexpr const char* const description = "Introduce a separate Z-Up node into the GlTF hierarchy instead of multiplying the transform into the root node matrices"; - static constexpr bool defaultvalue = false; - }; - - struct SvgBounds : public SettingBase { - static constexpr const char* const name = "bounds"; - static constexpr const char* const description = "Specifies the bounding rectangle, for example 512x512, to which the output will be scaled. Only used when converting to SVG."; - }; - - struct SvgScale : public SettingBase { - static constexpr const char* const name = "scale"; - static constexpr const char* const description = "Interprets SVG bounds in mm, centers layout and draw elements to scale. Only used when converting to SVG. Example 1:100."; - }; - - struct SvgCenter : public SettingBase { - static constexpr const char* const name = "center"; - static constexpr const char* const description = "When using --scale, specifies the location in the range [0 1]x[0 1] around which to center the drawings. Example 0.5x0.5."; - }; - - struct SvgSectionRef : public SettingBase { - static constexpr const char* const name = "section-ref"; - static constexpr const char* const description = "Element at which cross sections should be created."; - }; - - struct SvgElevationRef : public SettingBase { - static constexpr const char* const name = "elevation-ref"; - static constexpr const char* const description = "Element at which drawings should be created."; - }; - - struct SvgElevationRefGuid : public SettingBase { - static constexpr const char* const name = "elevation-ref-guid"; - static constexpr const char* const description = "Element guids at which drawings should be created."; - }; - - struct SvgAutoSection : public SettingBase { - static constexpr const char* const name = "auto-section"; - static constexpr const char* const description = "Creates SVG cross section drawings automatically based on model extents."; - static constexpr bool defaultvalue = false; - }; - - struct SvgAutoElevation : public SettingBase { - static constexpr const char* const name = "auto-elevation"; - static constexpr const char* const description = "Creates SVG elevation drawings automatically based on model extents."; - static constexpr bool defaultvalue = false; - }; - - struct SvgDrawStoreyHeights : public SettingBase { - static constexpr const char* const name = "draw-storey-heights"; - static constexpr const char* const description = "Draws a horizontal line at the height of building storeys in vertical drawings. Accepted values are none, full, and left."; - }; - - struct SvgProfileThreshold : public SettingBase { - static constexpr const char* const name = "profile-threshold"; - static constexpr const char* const description = "Limits the number of projected wire profiles for non-wall and non-slab elements in SVG output. A negative value disables the limit."; - static constexpr int defaultvalue = -1; - }; - - struct SvgStoreyHeightLineLength : public SettingBase { - static constexpr const char* const name = "storey-height-line-length"; - static constexpr const char* const description = "Length of the line when --draw-storey-heights=left."; - }; - - struct SvgUseNamespace : public SettingBase { - static constexpr const char* const name = "svg-xmlns"; - static constexpr const char* const description = "Stores name and guid in a separate namespace as opposed to data-name, data-guid."; - static constexpr bool defaultvalue = false; - }; - - struct SvgUseHlrPoly : public SettingBase { - static constexpr const char* const name = "svg-poly"; - static constexpr const char* const description = "Uses the polygonal algorithm for hidden line rendering."; - static constexpr bool defaultvalue = false; - }; - - struct SvgUsePrefiltering : public SettingBase { - static constexpr const char* const name = "svg-prefilter"; - static constexpr const char* const description = "Prefilter faces and shapes before feeding to the hidden-line algorithm."; - static constexpr bool defaultvalue = false; - }; - - struct SvgUnifyInputs : public SettingBase { - static constexpr const char* const name = "svg-unify-inputs"; - static constexpr const char* const description = "Unify input shapes before SVG projection."; - static constexpr bool defaultvalue = false; - }; - - struct SvgSegmentProjection : public SettingBase { - static constexpr const char* const name = "svg-segment-projection"; - static constexpr const char* const description = "Segment result of projection with respect to original products."; - static constexpr bool defaultvalue = false; - }; - - struct SvgSubtractBefore : public SettingBase { - static constexpr const char* const name = "svg-subtract-before"; - static constexpr const char* const description = "Controls which shapes are cut before SVG hidden-line projection. Accepted values are auto, slabs-and-walls, and always."; - }; - - struct SvgPolygonal : public SettingBase { - static constexpr const char* const name = "svg-write-poly"; - static constexpr const char* const description = "Approximate every curve as polygonal in SVG output."; - static constexpr bool defaultvalue = false; - }; - - struct SvgAlwaysProject : public SettingBase { - static constexpr const char* const name = "svg-project"; - static constexpr const char* const description = "Always enable hidden line rendering instead of only on elevations."; - static constexpr bool defaultvalue = false; - }; - - struct SvgWithoutStoreys : public SettingBase { - static constexpr const char* const name = "svg-without-storeys"; - static constexpr const char* const description = "Do not emit drawings for building storeys."; - static constexpr bool defaultvalue = false; - }; - - struct SvgNoCss : public SettingBase { - static constexpr const char* const name = "svg-no-css"; - static constexpr const char* const description = "Do not emit CSS style declarations."; - static constexpr bool defaultvalue = false; - }; - - struct SvgMirrorY : public SettingBase { - static constexpr const char* const name = "svg-mirror-y"; - static constexpr const char* const description = "Mirror SVG output along the Y axis."; - static constexpr bool defaultvalue = false; - }; - - struct SvgMirrorX : public SettingBase { - static constexpr const char* const name = "svg-mirror-x"; - static constexpr const char* const description = "Mirror SVG output along the X axis."; - static constexpr bool defaultvalue = false; - }; - - struct SvgDoorArcs : public SettingBase { - static constexpr const char* const name = "door-arcs"; - static constexpr const char* const description = "Draw door opening arcs for IfcDoor elements."; - static constexpr bool defaultvalue = false; - }; - - struct SvgSectionHeight : public SettingBase { - static constexpr const char* const name = "section-height"; - static constexpr const char* const description = "Specifies the cut section height for SVG 2D geometry."; - }; - - struct SvgSectionHeightFromStoreys : public SettingBase { - static constexpr const char* const name = "section-height-from-storeys"; - static constexpr const char* const description = "Derives section height from storey elevation. Use --section-height to override the default offset of 1.2."; - static constexpr bool defaultvalue = false; - }; - - struct SvgPrintSpaceNames : public SettingBase { - static constexpr const char* const name = "print-space-names"; - static constexpr const char* const description = "Prints IfcSpace LongName and Name in the geometry output. Applicable for SVG output."; - static constexpr bool defaultvalue = false; - }; - - struct SvgPrintSpaceAreas : public SettingBase { - static constexpr const char* const name = "print-space-areas"; - static constexpr const char* const description = "Prints calculated IfcSpace areas in square meters. Applicable for SVG output."; - static constexpr bool defaultvalue = false; - }; - - struct SvgSpaceNameTransform : public SettingBase { - static constexpr const char* const name = "space-name-transform"; - static constexpr const char* const description = "Additional transform to the space labels in SVG."; - }; -} - -class SerializerSettings : public SettingsContainer < - // @todo should we use tuple_cat here to unify the settings into a single class? - std::tuple< - UseElementNames, - UseElementGuids, - UseElementStepIds, - UseElementTypes, - UseYUp, - WriteGltfEcef, - FloatingPointDigits, - BaseUri, - WktUseSection, - SeparateZUpNode, - SvgBounds, - SvgScale, - SvgCenter, - SvgSectionRef, - SvgElevationRef, - SvgElevationRefGuid, - SvgAutoSection, - SvgAutoElevation, - SvgDrawStoreyHeights, - SvgProfileThreshold, - SvgStoreyHeightLineLength, - SvgUseNamespace, - SvgUseHlrPoly, - SvgUsePrefiltering, - SvgUnifyInputs, - SvgSegmentProjection, - SvgSubtractBefore, - SvgPolygonal, - SvgAlwaysProject, - SvgWithoutStoreys, - SvgNoCss, - SvgMirrorY, - SvgMirrorX, - SvgDoorArcs, - SvgSectionHeight, - SvgSectionHeightFromStoreys, - SvgPrintSpaceNames, - SvgPrintSpaceAreas, - SvgSpaceNameTransform>> -{}; - -} -} - class IFC_GEOM_API stream_or_filename { private: std::shared_ptr ofs_; @@ -336,48 +62,43 @@ public: } }; -class IFC_GEOM_API GeometrySerializer : public Serializer { +class IFC_GEOM_API geometry_serializer : public serializer { public: enum read_type { READ_BREP, READ_TRIANGULATION }; - GeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger* logger = nullptr) - : Serializer(logger_or_root(logger)) - , geometry_settings_(geometry_settings) + geometry_serializer(const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr) + : serializer(logger_or_root(logger)) , settings_(settings) {} - virtual ~GeometrySerializer() {} + virtual ~geometry_serializer() {} virtual bool isTesselated() const = 0; - virtual void write(const IfcGeom::TriangulationElement* o) = 0; - virtual void write(const IfcGeom::BRepElement* o) = 0; + virtual void write(const ifcopenshell::geom::triangulation_element* o) = 0; + virtual void write(const ifcopenshell::geom::brep_element* o) = 0; virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) = 0; - virtual IfcGeom::Element* read(ifcopenshell::file& f, const std::string& guid, const std::string& representation_id, read_type rt = READ_BREP) = 0; + virtual ifcopenshell::geom::element* read(ifcopenshell::file& f, const std::string& guid, const std::string& representation_id, read_type rt = READ_BREP) = 0; - const ifcopenshell::geometry::SerializerSettings& settings() const { return settings_; } - ifcopenshell::geometry::SerializerSettings& settings() { return settings_; } - - const ifcopenshell::geometry::Settings& geometry_settings() const { return geometry_settings_; } - ifcopenshell::geometry::Settings& geometry_settings() { return geometry_settings_; } + const ifcopenshell::geom::settings& settings() const { return settings_; } + ifcopenshell::geom::settings& settings() { return settings_; } /// Returns ID for the object depending on the used setting. - virtual std::string object_id(const IfcGeom::Element* o) + virtual std::string object_id(const ifcopenshell::geom::element* o) { - if (settings_.get().get()) return o->guid(); - if (settings_.get().get()) return o->name(); - if (settings_.get().get()) return "id-" + boost::lexical_cast(o->id()); + if (settings_.get().get()) return o->guid(); + if (settings_.get().get()) return o->name(); + if (settings_.get().get()) return "id-" + boost::lexical_cast(o->id()); return o->unique_id(); } protected: - ifcopenshell::geometry::Settings geometry_settings_; - ifcopenshell::geometry::SerializerSettings settings_; + ifcopenshell::geom::settings settings_; }; -class IFC_GEOM_API WriteOnlyGeometrySerializer : public GeometrySerializer { +class IFC_GEOM_API write_only_geometry_serializer : public geometry_serializer { public: - WriteOnlyGeometrySerializer(const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger* logger = nullptr) : GeometrySerializer(geometry_settings, settings, logger) {} + write_only_geometry_serializer(const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr) : geometry_serializer(settings, logger) {} - virtual IfcGeom::Element* read(ifcopenshell::file&, const std::string&, const std::string&, read_type = READ_BREP) { + virtual ifcopenshell::geom::element* read(ifcopenshell::file&, const std::string&, const std::string&, read_type = READ_BREP) { throw std::runtime_error("Not supported"); }; }; diff --git a/src/ifcgeom/IfcGeomElement.h b/src/ifcgeom/IfcGeomElement.h index a115bb72a0..5e6c1e0012 100644 --- a/src/ifcgeom/IfcGeomElement.h +++ b/src/ifcgeom/IfcGeomElement.h @@ -31,39 +31,39 @@ #include "../ifcgeom/IfcGeomRepresentation.h" #include "../ifcgeom/ifc_geom_api.h" -namespace IfcGeom { +namespace ifcopenshell::geom { - class Transformation { + class transformation { private: - ifcopenshell::geometry::Settings settings_; - ifcopenshell::geometry::taxonomy::matrix4::ptr matrix_, matrix_orig_units_; + ifcopenshell::geom::settings settings_; + ifcopenshell::geom::taxonomy::matrix4::ptr matrix_, matrix_orig_units_; public: - Transformation(const ifcopenshell::geometry::Settings& settings, const ifcopenshell::geometry::taxonomy::matrix4::ptr& matrix) + transformation(const ifcopenshell::geom::settings& settings, const ifcopenshell::geom::taxonomy::matrix4::ptr& matrix) : settings_(settings), matrix_(matrix) { - const bool convert = settings.get().get(); - auto unit_magnitude = settings.get().get(); + const bool convert = settings.get().get(); + auto unit_magnitude = settings.get().get(); if (matrix_ && convert && unit_magnitude != 1.0) { - matrix_orig_units_ = ifcopenshell::geometry::taxonomy::make(*matrix); + matrix_orig_units_ = ifcopenshell::geom::taxonomy::make(*matrix); // only multiple the translation components of the matrix with the unit magnitude, not the rotation/scaling components matrix_orig_units_->components().col(3).head<3>() /= unit_magnitude; } else { matrix_orig_units_ = nullptr; } } - const ifcopenshell::geometry::taxonomy::matrix4::ptr& data() const { + const ifcopenshell::geom::taxonomy::matrix4::ptr& data() const { if (matrix_orig_units_) { return matrix_orig_units_; } if (matrix_) { return matrix_; } - static ifcopenshell::geometry::taxonomy::matrix4::ptr iden = ifcopenshell::geometry::taxonomy::make(); + static ifcopenshell::geom::taxonomy::matrix4::ptr iden = ifcopenshell::geom::taxonomy::make(); return iden; } }; - class Element { + class element { private: int _id; int _parent_id; @@ -72,17 +72,17 @@ namespace IfcGeom { std::string _guid; std::string _context; std::string _unique_id; - Transformation _transformation; - const express::Entity product_; - std::vector _parents; + transformation _transformation; + const express::entity product_; + std::vector _parents; public: - friend bool operator == (const Element& element1, const Element& element2) { + friend bool operator == (const element& element1, const element& element2) { return element1.id() == element2.id(); } // Use the id to compare, or the elevation is the elements are IfcBuildingStoreys and the elevation is set - friend bool operator < (const Element& element1, const Element& element2) { + friend bool operator < (const element& element1, const element& element2) { if (element1.type() == "IfcBuildingStorey" && element2.type() == "IfcBuildingStorey") { size_t attr_index = element1.product().declaration().as_entity()->attribute_index("Elevation"); auto elev_attr1 = element1.product().get_attribute_value(attr_index); @@ -107,13 +107,13 @@ namespace IfcGeom { // Return the representation's identifier (e.g. "Body") if present, or it's context type (e.g. "Model"). const std::string& context() const { return _context; } const std::string& unique_id() const { return _unique_id; } - const Transformation& transformation() const { return _transformation; } - const express::Entity& product() const { return product_; } - const std::vector& parents() const { return _parents; } - void SetParents(std::vector& newparents) { _parents = newparents; } + const transformation& transformation() const { return _transformation; } + const express::entity& product() const { return product_; } + const std::vector& parents() const { return _parents; } + void SetParents(std::vector& newparents) { _parents = newparents; } - Element(const ifcopenshell::geometry::Settings& settings, int id, int parent_id, const std::string& name, const std::string& type, - const std::string& guid, const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4::ptr& trsf, const express::Entity& product) + element(const ifcopenshell::geom::settings& settings, int id, int parent_id, const std::string& name, const std::string& type, + const std::string& guid, const std::string& context, const ifcopenshell::geom::taxonomy::matrix4::ptr& trsf, const express::entity& product) : _id(id), _parent_id(parent_id), _name(name), _type(type), _guid(guid), _context(context), _transformation(settings, trsf) , product_(product) { @@ -139,19 +139,19 @@ namespace IfcGeom { _unique_id = oss.str(); } - virtual ~Element() {} + virtual ~element() {} }; - class BRepElement : public Element { + class brep_element : public element { private: - boost::shared_ptr _geometry; + boost::shared_ptr _geometry; public: - const boost::shared_ptr& geometry_pointer() const { return _geometry; } - const IfcGeom::Representation::BRep& geometry() const { return *_geometry; } - BRepElement(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid, - const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4::ptr& trsf, const boost::shared_ptr& geometry, - const express::Entity& product) - : Element(geometry->settings(), id, parent_id, name, type, guid, context, trsf, product) + const boost::shared_ptr& geometry_pointer() const { return _geometry; } + const ifcopenshell::geom::Representation::brep& geometry() const { return *_geometry; } + brep_element(int id, int parent_id, const std::string& name, const std::string& type, const std::string& guid, + const std::string& context, const ifcopenshell::geom::taxonomy::matrix4::ptr& trsf, const boost::shared_ptr& geometry, + const express::entity& product) + : element(geometry->settings(), id, parent_id, name, type, guid, context, trsf, product) , _geometry(geometry) {} @@ -159,44 +159,44 @@ namespace IfcGeom { return geometry().calculate_projected_surface_area(this->transformation().data(), along_x, along_y, along_z); } private: - BRepElement(const BRepElement& other); - BRepElement& operator=(const BRepElement& other); + brep_element(const brep_element& other); + brep_element& operator=(const brep_element& other); }; - class TriangulationElement : public Element { + class triangulation_element : public element { private: - boost::shared_ptr< IfcGeom::Representation::Triangulation > _geometry; + boost::shared_ptr< ifcopenshell::geom::Representation::triangulation > _geometry; public: - const IfcGeom::Representation::Triangulation& geometry() const { return *_geometry; } - const boost::shared_ptr< IfcGeom::Representation::Triangulation>& geometry_pointer() const { return _geometry; } - TriangulationElement(const IfcGeom::BRepElement& shape_model) - : Element(shape_model) - , _geometry(boost::shared_ptr(new IfcGeom::Representation::Triangulation(shape_model.geometry()))) + const ifcopenshell::geom::Representation::triangulation& geometry() const { return *_geometry; } + const boost::shared_ptr< ifcopenshell::geom::Representation::triangulation>& geometry_pointer() const { return _geometry; } + triangulation_element(const ifcopenshell::geom::brep_element& shape_model) + : element(shape_model) + , _geometry(boost::shared_ptr(new ifcopenshell::geom::Representation::triangulation(shape_model.geometry()))) {} - TriangulationElement(const IfcGeom::Element& element, const boost::shared_ptr& geometry) - : Element(element) + triangulation_element(const ifcopenshell::geom::element& element, const boost::shared_ptr& geometry) + : element(element) , _geometry(geometry) {} private: - TriangulationElement(const TriangulationElement& other); - TriangulationElement& operator=(const TriangulationElement& other); + triangulation_element(const triangulation_element& other); + triangulation_element& operator=(const triangulation_element& other); }; - class SerializedElement : public Element { + class serialized_element : public element { private: - IfcGeom::Representation::Serialization* _geometry; + ifcopenshell::geom::Representation::serialization* _geometry; public: - const IfcGeom::Representation::Serialization& geometry() const { return *_geometry; } - SerializedElement(const BRepElement& shape_model) - : Element(shape_model) - , _geometry(new IfcGeom::Representation::Serialization(shape_model.geometry())) + const ifcopenshell::geom::Representation::serialization& geometry() const { return *_geometry; } + serialized_element(const brep_element& shape_model) + : element(shape_model) + , _geometry(new ifcopenshell::geom::Representation::serialization(shape_model.geometry())) {} - virtual ~SerializedElement() { + virtual ~serialized_element() { delete _geometry; } private: - SerializedElement(const SerializedElement& other); - SerializedElement& operator=(const SerializedElement& other); + serialized_element(const serialized_element& other); + serialized_element& operator=(const serialized_element& other); }; } diff --git a/src/ifcgeom/IfcGeomFilter.h b/src/ifcgeom/IfcGeomFilter.h index a29958f923..881f341e6f 100644 --- a/src/ifcgeom/IfcGeomFilter.h +++ b/src/ifcgeom/IfcGeomFilter.h @@ -18,7 +18,7 @@ ********************************************************************************/ /** @file IfcGeomFilter.h - @brief A set of predefined product filters for IfcGeom::Iterator */ + @brief A set of predefined product filters for ifcopenshell::geom::iterator */ #ifndef IFCGEOMFILTER_H #define IFCGEOMFILTER_H @@ -40,7 +40,7 @@ #include -namespace IfcGeom { +namespace ifcopenshell::geom { struct filter { @@ -56,7 +56,7 @@ namespace IfcGeom { /// Optional description for the filtering criteria of this filter. std::string description; - bool match(const express::Base& prod, const ifcopenshell::geometry::filter_t& pred) const { + bool match(const express::base& prod, const ifcopenshell::geom::filter_t& pred) const { bool is_match = pred(prod); if (!is_match && traverse) { is_match = traverse_match(prod, pred); @@ -64,15 +64,15 @@ namespace IfcGeom { return is_match == include; } - bool traverse_match(const express::Base& prod, const ifcopenshell::geometry::filter_t& pred) const + bool traverse_match(const express::base& prod, const ifcopenshell::geom::filter_t& pred) const { - express::Base parent, current = prod; + express::base parent, current = prod; // @todo examine if this can indeed be static. For now usage is only // in IfcConvert so invocation is bound to a single file with a single // schema. // @todo pass settings - ifcopenshell::geometry::Settings s; - static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod.file(), s); + ifcopenshell::geom::settings s; + static auto mapping = ifcopenshell::geom::impl::mapping_implementations().construct(prod.file(), s); while ((parent = mapping->get_decomposing_entity(current, traverse_openings))) { if (pred(parent)) { return true; @@ -132,9 +132,9 @@ namespace IfcGeom { attribute_filter(const std::string& attribute_name) : attribute_name(attribute_name) {} - std::string value(const express::Base& prod) const { + std::string value(const express::base& prod) const { try { - return (std::string) prod.as().get(attribute_name); + return (std::string) prod.as().get(attribute_name); } catch (...) { // Either // (a) not an attribute name for this entity instance @@ -146,11 +146,11 @@ namespace IfcGeom { } } - bool match(express::Base prod) const { + bool match(express::base prod) const { return wildcard_filter::match(value(prod)); } - bool operator()(express::Base prod) const { + bool operator()(express::base prod) const { return filter::match(prod, std::bind(&attribute_filter::match, this, std::placeholders::_1)); } @@ -171,21 +171,21 @@ namespace IfcGeom { }; struct layer_filter : public wildcard_filter { - typedef std::map layer_map_t; + typedef std::map layer_map_t; layer_filter() {} layer_filter(bool include, bool traverse, const std::set& patterns) : wildcard_filter(include, traverse, patterns) {} - bool match(express::Base prod) const { + bool match(express::base prod) const { // @todo - ifcopenshell::geometry::Settings s; - static auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(prod.file(), s); + ifcopenshell::geom::settings s; + static auto mapping = ifcopenshell::geom::impl::mapping_implementations().construct(prod.file(), s); layer_map_t layers = mapping->get_layers(prod); return std::find_if(layers.begin(), layers.end(), wildcards_match(values)) != layers.end(); } - bool operator()(express::Base prod) const { + bool operator()(express::base prod) const { return filter::match(prod, std::bind(&layer_filter::match, this, std::placeholders::_1)); } @@ -218,7 +218,7 @@ namespace IfcGeom { : filter(include, traverse) , entity_names(entity_names) {} - bool match(express::Base prod) const { + bool match(express::base prod) const { // The set is iterated over to able to filter on subtypes. for (auto& name : entity_names) { if (prod.declaration().is(name)) { @@ -228,7 +228,7 @@ namespace IfcGeom { return false; } - bool operator()(express::Base prod) const { + bool operator()(express::base prod) const { return filter::match(prod, std::bind(&entity_filter::match, this, std::placeholders::_1)); } @@ -250,11 +250,11 @@ namespace IfcGeom { : filter(include, traverse) , instance_ids_(instance_ids) {} - bool match(express::Base prod) const { + bool match(express::base prod) const { return instance_ids_.find(prod.id()) != instance_ids_.end(); } - bool operator()(express::Base prod) const { + bool operator()(express::base prod) const { return filter::match(prod, std::bind(&instance_id_filter::match, this, std::placeholders::_1)); } diff --git a/src/ifcgeom/IfcGeomRenderStyles.h b/src/ifcgeom/IfcGeomRenderStyles.h index 2486f2c9dc..35dcbea0dc 100644 --- a/src/ifcgeom/IfcGeomRenderStyles.h +++ b/src/ifcgeom/IfcGeomRenderStyles.h @@ -30,10 +30,10 @@ #include #include -namespace IfcGeom { - IFC_GEOM_API const ifcopenshell::geometry::taxonomy::style::ptr& get_default_style(const std::string& ifc_type); +namespace ifcopenshell::geom { + IFC_GEOM_API const ifcopenshell::geom::taxonomy::style::ptr& get_default_style(const std::string& ifc_type); - IFC_GEOM_API ifcopenshell::geometry::taxonomy::style::ptr& update_default_style(const std::string& ifc_type); + IFC_GEOM_API ifcopenshell::geom::taxonomy::style::ptr& update_default_style(const std::string& ifc_type); IFC_GEOM_API void set_default_style_file(const std::string& json_file); } diff --git a/src/ifcgeom/IfcGeomRepresentation.cpp b/src/ifcgeom/IfcGeomRepresentation.cpp index 22e9204765..a2dfa5d572 100644 --- a/src/ifcgeom/IfcGeomRepresentation.cpp +++ b/src/ifcgeom/IfcGeomRepresentation.cpp @@ -19,8 +19,8 @@ #include "IfcGeomRepresentation.h" -IfcGeom::Representation::Serialization::Serialization(const BRep& brep) - : Representation(brep.settings(), brep.entity(), brep.id()) +ifcopenshell::geom::Representation::serialization::serialization(const brep& brep) + : representation(brep.settings(), brep.entity(), brep.id()) { for (auto it = brep.begin(); it != brep.end(); ++it) { int sid = -1; @@ -47,19 +47,19 @@ IfcGeom::Representation::Serialization::Serialization(const BRep& brep) surface_style_ids_.push_back(sid); } - ifcopenshell::geometry::taxonomy::matrix4 identity; + ifcopenshell::geom::taxonomy::matrix4 identity; auto* comp = brep.as_compound(); comp->Serialize(identity, brep_data_); delete comp; } -IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool force_meters) const { - ConversionResultShape* accum = nullptr; +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::Representation::brep::as_compound(bool force_meters) const { + conversion_result_shape* accum = nullptr; for (auto it = begin(); it != end(); ++it) { double unit_scale = 1.0; - if (!force_meters && settings().get().get()) { - unit_scale = 1.0 / settings().get().get(); + if (!force_meters && settings().get().get()) { + unit_scale = 1.0 / settings().get().get(); } auto s = it->apply_transform(unit_scale); if (accum) { @@ -75,8 +75,8 @@ IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool return accum; } -bool IfcGeom::Representation::BRep::calculate_surface_area(double& area) const { - std::unique_ptr s(as_compound()); +bool ifcopenshell::geom::Representation::brep::calculate_surface_area(double& area) const { + std::unique_ptr s(as_compound()); if (!s) { area = 0.; return false; @@ -85,8 +85,8 @@ bool IfcGeom::Representation::BRep::calculate_surface_area(double& area) const { return true; } -bool IfcGeom::Representation::BRep::calculate_volume(double& volume) const { - std::unique_ptr s(as_compound()); +bool ifcopenshell::geom::Representation::brep::calculate_volume(double& volume) const { + std::unique_ptr s(as_compound()); if (!s) { volume = 0.; return false; @@ -95,12 +95,12 @@ bool IfcGeom::Representation::BRep::calculate_volume(double& volume) const { return true; } -bool IfcGeom::Representation::BRep::calculate_projected_surface_area(const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { +bool ifcopenshell::geom::Representation::brep::calculate_projected_surface_area(const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { along_x = along_y = along_z = 0.; - for (IfcGeom::ConversionResults::const_iterator it = begin(); it != end(); ++it) { + for (ifcopenshell::geom::conversion_results::const_iterator it = begin(); it != end(); ++it) { double x, y, z; - it->Shape()->surface_area_along_direction(settings().get().get(), place, x, y, z); + it->Shape()->surface_area_along_direction(settings().get().get(), place, x, y, z); if (it->Shape()->is_manifold()) { x /= 2.; @@ -116,11 +116,11 @@ bool IfcGeom::Representation::BRep::calculate_projected_surface_area(const ifcop return true; } -IfcGeom::Representation::Triangulation::Triangulation(const BRep& shape_model) - : Representation(shape_model.settings(), shape_model.entity(), shape_model.id()) +ifcopenshell::geom::Representation::triangulation::triangulation(const brep& shape_model) + : representation(shape_model.settings(), shape_model.entity(), shape_model.id()) , weld_offset_(0) { - for (IfcGeom::ConversionResults::const_iterator iit = shape_model.begin(); iit != shape_model.end(); ++iit) { + for (ifcopenshell::geom::conversion_results::const_iterator iit = shape_model.begin(); iit != shape_model.end(); ++iit) { // Don't weld vertices that belong to different items to prevent non-manifold situations. resetWelds(); @@ -136,8 +136,8 @@ IfcGeom::Representation::Triangulation::Triangulation(const BRep& shape_model) } } - if (settings().get().get() && surface_style_id == -1) { - const auto& material = IfcGeom::get_default_style(shape_model.entity()); + if (settings().get().get() && surface_style_id == -1) { + const auto& material = ifcopenshell::geom::get_default_style(shape_model.entity()); auto mit = std::find(materials_.begin(), materials_.end(), material); if (mit == materials_.end()) { surface_style_id = (int)materials_.size(); @@ -154,7 +154,7 @@ IfcGeom::Representation::Triangulation::Triangulation(const BRep& shape_model) /// Generates UVs for a single mesh using box projection. /// @todo Very simple impl. Assumes that input vertices and normals match 1:1. -std::vector IfcGeom::Representation::Triangulation::box_project_uvs(const std::vector& vertices, const std::vector& normals) +std::vector ifcopenshell::geom::Representation::triangulation::box_project_uvs(const std::vector& vertices, const std::vector& normals) { std::vector uvs; uvs.resize(vertices.size() / 3 * 2); @@ -182,16 +182,16 @@ std::vector IfcGeom::Representation::Triangulation::box_project_uvs(cons return uvs; } -int IfcGeom::Representation::Triangulation::addVertex(int item_id, int material_index, double pX, double pY, double pZ) { - const bool convert = settings().get().get(); - auto unit_magnitude = settings().get().get(); +int ifcopenshell::geom::Representation::triangulation::addVertex(int item_id, int material_index, double pX, double pY, double pZ) { + const bool convert = settings().get().get(); + auto unit_magnitude = settings().get().get(); const double X = convert ? (pX /unit_magnitude) : pX; const double Y = convert ? (pY /unit_magnitude) : pY; const double Z = convert ? (pZ /unit_magnitude) : pZ; int i = (int)verts_.size() / 3; - if (settings().get().get()) { - const VertexKey key = std::make_tuple(item_id, material_index, X, Y, Z); - typename VertexKeyMap::const_iterator it = welds.find(key); + if (settings().get().get()) { + const vertex_key key = std::make_tuple(item_id, material_index, X, Y, Z); + typename vertex_key_map::const_iterator it = welds.find(key); if (it != welds.end()) { // Return index for previously encountered point return it->second; @@ -205,12 +205,12 @@ int IfcGeom::Representation::Triangulation::addVertex(int item_id, int material_ return i; } -void IfcGeom::Representation::Triangulation::registerEdgeCount(int n1, int n2, std::map, int>& edgecount) { - const Edge e = Edge((std::min)(n1, n2), (std::max)(n1, n2)); +void ifcopenshell::geom::Representation::triangulation::registerEdgeCount(int n1, int n2, std::map, int>& edgecount) { + const edge e = edge((std::min)(n1, n2), (std::max)(n1, n2)); edgecount[e] ++; } -const IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::item(int i) const { +const ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::Representation::brep::item(int i) const { if (i >= 0 && i < shapes_.size()) { return shapes_[i].Shape()->moved(shapes_[i].Placement()); } else { @@ -218,7 +218,7 @@ const IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::item(int i) } } -int IfcGeom::Representation::BRep::item_id(int i) const { +int ifcopenshell::geom::Representation::brep::item_id(int i) const { if (i >= 0 && i < shapes_.size()) { return shapes_[i].ItemId(); } else { diff --git a/src/ifcgeom/IfcGeomRepresentation.h b/src/ifcgeom/IfcGeomRepresentation.h index 2bafa9ab88..706ae1fd39 100644 --- a/src/ifcgeom/IfcGeomRepresentation.h +++ b/src/ifcgeom/IfcGeomRepresentation.h @@ -25,24 +25,24 @@ #include -namespace IfcGeom { +namespace ifcopenshell::geom { namespace Representation { - class IFC_GEOM_API Representation { - Representation(const Representation&); //N/A - Representation& operator =(const Representation&); //N/A + class IFC_GEOM_API representation { + representation(const representation&); //N/A + representation& operator =(const representation&); //N/A protected: - const ifcopenshell::geometry::Settings settings_; + const ifcopenshell::geom::settings settings_; const std::string entity_; std::string id_; public: - explicit Representation(const ifcopenshell::geometry::Settings& settings, const std::string& entity, const std::string& id) + explicit representation(const ifcopenshell::geom::settings& settings, const std::string& entity, const std::string& id) : settings_(settings) , entity_(entity) , id_(id) {} - const ifcopenshell::geometry::Settings& settings() const { return settings_; } + const ifcopenshell::geom::settings& settings() const { return settings_; } const std::string& entity() const { return entity_; } @@ -51,35 +51,35 @@ namespace IfcGeom { // - material-material_id // - openings-opening0_id-...-openingN_id const std::string& id() const { return id_; } - virtual ~Representation() {} + virtual ~representation() {} }; - class IFC_GEOM_API BRep : public Representation { + class IFC_GEOM_API brep : public representation { private: - const IfcGeom::ConversionResults shapes_; - BRep(const BRep& other); - BRep& operator=(const BRep& other); + const ifcopenshell::geom::conversion_results shapes_; + brep(const brep& other); + brep& operator=(const brep& other); public: - BRep(const ifcopenshell::geometry::Settings& settings, const std::string& entity, const std::string& id, const IfcGeom::ConversionResults& shapes) - : Representation(settings, entity, id) + brep(const ifcopenshell::geom::settings& settings, const std::string& entity, const std::string& id, const ifcopenshell::geom::conversion_results& shapes) + : representation(settings, entity, id) , shapes_(shapes) {} - virtual ~BRep() {} - IfcGeom::ConversionResults::const_iterator begin() const { return shapes_.begin(); } - IfcGeom::ConversionResults::const_iterator end() const { return shapes_.end(); } - const IfcGeom::ConversionResults& shapes() const { return shapes_; } - IfcGeom::ConversionResultShape* as_compound(bool force_meters = false) const; + virtual ~brep() {} + ifcopenshell::geom::conversion_results::const_iterator begin() const { return shapes_.begin(); } + ifcopenshell::geom::conversion_results::const_iterator end() const { return shapes_.end(); } + const ifcopenshell::geom::conversion_results& shapes() const { return shapes_; } + ifcopenshell::geom::conversion_result_shape* as_compound(bool force_meters = false) const; bool calculate_volume(double&) const; bool calculate_surface_area(double&) const; - bool calculate_projected_surface_area(const ifcopenshell::geometry::taxonomy::matrix4::ptr& ax, double& along_x, double& along_y, double& along_z) const; + bool calculate_projected_surface_area(const ifcopenshell::geom::taxonomy::matrix4::ptr& ax, double& along_x, double& along_y, double& along_z) const; int size() const { return (int) shapes_.size(); } - const IfcGeom::ConversionResultShape* item(int i) const; + const ifcopenshell::geom::conversion_result_shape* item(int i) const; int item_id(int i) const; }; - class IFC_GEOM_API Serialization : public Representation { + class IFC_GEOM_API serialization : public representation { private: std::string brep_data_; std::vector surface_styles_; @@ -88,20 +88,20 @@ namespace IfcGeom { const std::string& brep_data() const { return brep_data_; } const std::vector& surface_styles() const { return surface_styles_; } const std::vector& surface_style_ids() const { return surface_style_ids_; } - Serialization(const BRep& brep); - virtual ~Serialization() {} + serialization(const brep& brep); + virtual ~serialization() {} private: - Serialization(); - Serialization(const Serialization&); - Serialization& operator=(const Serialization&); + serialization(); + serialization(const serialization&); + serialization& operator=(const serialization&); }; - class Triangulation : public Representation { + class triangulation : public representation { private: // A tuple of to store as a key in a map. - typedef typename std::tuple VertexKey; - typedef std::map VertexKeyMap; - typedef std::pair Edge; + typedef typename std::tuple vertex_key; + typedef std::map vertex_key_map; + typedef std::pair edge; std::vector verts_; @@ -115,14 +115,14 @@ namespace IfcGeom { std::vector normals_; std::vector uvs_; std::vector material_ids_; - std::vector materials_; + std::vector materials_; std::vector item_ids_; std::vector edges_item_ids_; size_t weld_offset_; - VertexKeyMap welds; + vertex_key_map welds; - Triangulation(const ifcopenshell::geometry::Settings& settings, const std::string& entity, const std::string& id) - : Representation(settings, entity, id) + triangulation(const ifcopenshell::geom::settings& settings, const std::string& entity, const std::string& id) + : representation(settings, entity, id) , weld_offset_(0) {} @@ -136,14 +136,14 @@ namespace IfcGeom { const std::vector& uvs() const { return uvs_; } std::vector& uvs_ref() { return uvs_; } const std::vector& material_ids() const { return material_ids_; } - const std::vector& materials() const { return materials_; } + const std::vector& materials() const { return materials_; } const std::vector& item_ids() const { return item_ids_; } const std::vector& edges_item_ids() const { return edges_item_ids_; } - Triangulation(const BRep& shape_model); + triangulation(const brep& shape_model); - Triangulation( - const ifcopenshell::geometry::Settings& settings, + triangulation( + const ifcopenshell::geom::settings& settings, const std::string& entity, const std::string& id, const std::vector& verts, @@ -152,11 +152,11 @@ namespace IfcGeom { const std::vector& normals, const std::vector& uvs, const std::vector& material_ids, - const std::vector& materials, + const std::vector& materials, const std::vector& item_ids , const std::vector& edges_item_ids ) - : Representation(settings, entity, id) + : representation(settings, entity, id) , verts_(verts) , faces_(faces) , edges_(edges) @@ -168,13 +168,13 @@ namespace IfcGeom { , edges_item_ids_(edges_item_ids) {} - virtual ~Triangulation() {} + virtual ~triangulation() {} /// Generates UVs for a single mesh using box projection. /// @todo Very simple impl. Assumes that input vertices and normals match 1:1. static std::vector box_project_uvs(const std::vector &vertices, const std::vector &normals); - static Triangulation* empty(const ifcopenshell::geometry::Settings& settings) { return new Triangulation(settings, "", ""); } + static triangulation* empty(const ifcopenshell::geom::settings& settings) { return new triangulation(settings, "", ""); } /// Welds vertices that belong to different faces int addVertex(int item_index, int material_index, double X, double Y, double Z); @@ -230,9 +230,9 @@ namespace IfcGeom { } private: - Triangulation(); - Triangulation(const Triangulation&); - Triangulation& operator=(const Triangulation&); + triangulation(); + triangulation(const triangulation&); + triangulation& operator=(const triangulation&); }; } diff --git a/src/ifcgeom/Iterator.cpp b/src/ifcgeom/Iterator.cpp index 39d86d2008..82a69a1601 100644 --- a/src/ifcgeom/Iterator.cpp +++ b/src/ifcgeom/Iterator.cpp @@ -15,7 +15,7 @@ * - For non-concurrent iterators, a false return may occur if initialization of the first * element fails, even if subsequent elements could be initialized successfully. */ -bool IfcGeom::Iterator::initialize() { +bool ifcopenshell::geom::iterator::initialize() { using std::chrono::high_resolution_clock; if (initialization_outcome_) { @@ -23,7 +23,7 @@ bool IfcGeom::Iterator::initialize() { } time_points[0] = high_resolution_clock::now(); - std::vector reps; + std::vector reps; if (num_threads_ != 1) { // @todo this shouldn't be necessary with properly immutable taxonomy items converter_->mapping()->use_caching() = false; @@ -38,7 +38,7 @@ bool IfcGeom::Iterator::initialize() { for (auto& task : reps) { geometry_conversion_result res; res.index = task.index; - if (!settings_.get().get()) { + if (!settings_.get().get()) { res.representation = task.representation; res.products_2 = task.products; } else { @@ -46,25 +46,25 @@ bool IfcGeom::Iterator::initialize() { if (!res.item) { continue; } - std::transform(task.products.begin(), task.products.end(), std::back_inserter(res.products), [this, &res](const express::Base& prod) { + std::transform(task.products.begin(), task.products.end(), std::back_inserter(res.products), [this, &res](const express::base& prod) { auto prod_item = converter_->mapping()->map(prod); - return std::make_pair(prod, ifcopenshell::geometry::taxonomy::cast(prod_item)->matrix); + return std::make_pair(prod, ifcopenshell::geom::taxonomy::cast(prod_item)->matrix); }); } tasks_.push_back(res); } - if (settings_.get().get() && settings_.get().get()) { + if (settings_.get().get() && settings_.get().get()) { std::unordered_map< - ifcopenshell::geometry::taxonomy::item::ptr, - std::vector>> folded; + ifcopenshell::geom::taxonomy::item::ptr, + std::vector>> folded; for (auto& r : tasks_) { auto i = r.item; Eigen::Matrix4d m4 = Eigen::Matrix4d::Identity(); - while (auto col = std::dynamic_pointer_cast(i)) { + while (auto col = std::dynamic_pointer_cast(i)) { if (col->children.size() == 1) { if (col->matrix) { m4 *= col->matrix->ccomponents(); @@ -76,7 +76,7 @@ bool IfcGeom::Iterator::initialize() { } for (auto& p : r.products) { - auto pl = ifcopenshell::geometry::taxonomy::matrix4::ptr(p.second->clone_()); + auto pl = ifcopenshell::geom::taxonomy::matrix4::ptr(p.second->clone_()); pl->components() *= m4; folded[i].push_back( { p.first, pl } @@ -98,13 +98,13 @@ bool IfcGeom::Iterator::initialize() { } } - if (settings_.get().get()) { + if (settings_.get().get()) { remove_offset_(); } size_t num_products = 0; for (auto& r : tasks_) { - num_products += !settings_.get().get() ? r.products_2.size() : r.products.size(); + num_products += !settings_.get().get() ? r.products_2.size() : r.products.size(); } time_points[2] = high_resolution_clock::now(); @@ -116,7 +116,7 @@ bool IfcGeom::Iterator::initialize() { std::vector items; std::map placements; - std::transform(products.begin(), products.end(), std::back_inserter(items), [this, &placements](express::Base p) { + std::transform(products.begin(), products.end(), std::back_inserter(items), [this, &placements](express::base p) { auto item = converter_->mapping()->map(p); // Product placements do not affect item reuse and should temporarily be swapped to identity if (item) { @@ -132,7 +132,7 @@ bool IfcGeom::Iterator::initialize() { geometry_conversion_result r; r.item = *it; std::transform(it, jt, std::back_inserter(r.products), [&r, &placements](taxonomy::ptr product_node) { - return std::make_pair((express::Base) product_node->instance, placements[product_node]); + return std::make_pair((express::base) product_node->instance, placements[product_node]); }); tasks_.push_back(r); it = jt; @@ -144,7 +144,7 @@ bool IfcGeom::Iterator::initialize() { if (tasks_.size() == 0) { logger_.warning("GEO", 51, "No representations encountered, aborting"); initialization_outcome_ = false; - } else if (!settings_.get().get()) { + } else if (!settings_.get().get()) { task_iterator_ = tasks_.begin(); @@ -167,13 +167,13 @@ bool IfcGeom::Iterator::initialize() { return *initialization_outcome_; } -void IfcGeom::Iterator::flush_worker_log(ifcopenshell::geometry::Converter* kernel) { +void ifcopenshell::geom::iterator::flush_worker_log(ifcopenshell::geom::converter* kernel) { if (kernel && &kernel->logger() != &logger_) { logger_.append(kernel->logger()); } } -void IfcGeom::Iterator::process_finished_rep(geometry_conversion_result* rep, ifcopenshell::geometry::Converter* kernel) { +void ifcopenshell::geom::iterator::process_finished_rep(geometry_conversion_result* rep, ifcopenshell::geom::converter* kernel) { flush_worker_log(kernel); if (rep->elements.empty()) { @@ -194,7 +194,7 @@ void IfcGeom::Iterator::process_finished_rep(geometry_conversion_result* rep, if progress_ = (int)(++processed_ * 100 / tasks_.size()); } -void IfcGeom::Iterator::process_concurrently() { +void ifcopenshell::geom::iterator::process_concurrently() { size_t conc_threads = num_threads_; if (conc_threads > tasks_.size()) { conc_threads = tasks_.size(); @@ -211,13 +211,13 @@ void IfcGeom::Iterator::process_concurrently() { if (worker_logger.output_format() != ::logger::FMT_INMEMORY) { worker_logger.set_output(static_cast(nullptr), static_cast(nullptr)); } - kernel_pool.push_back(new ifcopenshell::geometry::Converter(std::unique_ptr(converter_->kernel()->clone(worker_logger)), ifc_file, settings_, worker_logger)); + kernel_pool.push_back(new ifcopenshell::geom::converter(std::unique_ptr(converter_->kernel()->clone(worker_logger)), ifc_file, settings_, worker_logger)); } std::vector> threadpool; for (auto& rep : tasks_) { - ifcopenshell::geometry::Converter* K = nullptr; + ifcopenshell::geom::converter* K = nullptr; if (threadpool.size() < kernel_pool.size()) { K = kernel_pool[threadpool.size()]; } @@ -242,8 +242,8 @@ void IfcGeom::Iterator::process_concurrently() { std::future fu = std::async( std::launch::async, [this]( - ifcopenshell::geometry::Converter* kernel, - ifcopenshell::geometry::Settings settings, + ifcopenshell::geom::converter* kernel, + ifcopenshell::geom::settings settings, geometry_conversion_result* rep) { // Catch exceptions to be safe from freezing the iterator. try { @@ -281,7 +281,7 @@ void IfcGeom::Iterator::process_concurrently() { finished_ = true; - logger_.set_product(std::optional{}); + logger_.set_product(std::optional{}); if (!terminating_) { logger_.status("\rDone creating geometry (" + boost::lexical_cast(all_processed_elements_.size()) + @@ -291,7 +291,7 @@ void IfcGeom::Iterator::process_concurrently() { /// Computes model's bounding box (bounds_min and bounds_max). /// @note Can take several minutes for large files. -void IfcGeom::Iterator::compute_bounds(bool with_geometry) +void ifcopenshell::geom::iterator::compute_bounds(bool with_geometry) { for (int i = 0; i < 3; ++i) { bounds_min_.components()(i) = std::numeric_limits::infinity(); @@ -301,9 +301,9 @@ void IfcGeom::Iterator::compute_bounds(bool with_geometry) if (with_geometry) { size_t num_created = 0; do { - IfcGeom::Element* geom_object = get(); - const IfcGeom::TriangulationElement* o = static_cast(geom_object); - const IfcGeom::Representation::Triangulation& mesh = o->geometry(); + ifcopenshell::geom::element* geom_object = get(); + const ifcopenshell::geom::triangulation_element* o = static_cast(geom_object); + const ifcopenshell::geom::Representation::triangulation& mesh = o->geometry(); auto mat = o->transformation().data()->ccomponents(); Eigen::Vector4d vec, transformed; @@ -321,17 +321,17 @@ void IfcGeom::Iterator::compute_bounds(bool with_geometry) } } while (++num_created, next()); } else { - std::vector reps; + std::vector reps; converter_->mapping()->get_representations(reps, filters_); - std::vector products; + std::vector products; for (auto& r : reps) { std::copy(r.products.begin(), r.products.end(), std::back_inserter(products)); } for (auto& product : products) { auto prod_item = converter_->mapping()->map(product); - auto vec = ifcopenshell::geometry::taxonomy::cast(prod_item)->matrix->translation_part(); + auto vec = ifcopenshell::geom::taxonomy::cast(prod_item)->matrix->translation_part(); for (int i = 0; i < 3; ++i) { bounds_min_.components()(i) = std::min(bounds_min_.components()(i), vec(i)); @@ -341,7 +341,7 @@ void IfcGeom::Iterator::compute_bounds(bool with_geometry) } } -express::Base IfcGeom::Iterator::create_shape_model_for_next_entity() { +express::base ifcopenshell::geom::iterator::create_shape_model_for_next_entity() { geometry_conversion_result* task = nullptr; for (; task_iterator_ < tasks_.end();) { task = &*task_iterator_++; @@ -356,44 +356,44 @@ express::Base IfcGeom::Iterator::create_shape_model_for_next_entity() { process_finished_rep(task); return task->item->instance; } else { - return express::Base{}; + return express::base{}; } } -void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kernel, ifcopenshell::geometry::Settings settings, geometry_conversion_result* rep) +void ifcopenshell::geom::iterator::create_element_(ifcopenshell::geom::converter* kernel, ifcopenshell::geom::settings settings, geometry_conversion_result* rep) { ::logger& kernel_logger = kernel->logger(); - if (!settings_.get().get()) { + if (!settings_.get().get()) { rep->item = kernel->mapping()->map(rep->representation); if (!rep->item) { return; } - std::transform(rep->products_2.begin(), rep->products_2.end(), std::back_inserter(rep->products), [this, &rep, kernel](const express::Base& prod) { + std::transform(rep->products_2.begin(), rep->products_2.end(), std::back_inserter(rep->products), [this, &rep, kernel](const express::base& prod) { auto prod_item = kernel->mapping()->map(prod); - return std::make_pair(prod, ifcopenshell::geometry::taxonomy::cast(prod_item)->matrix); + return std::make_pair(prod, ifcopenshell::geom::taxonomy::cast(prod_item)->matrix); }); } else { } auto product_node = rep->products.front(); - const express::Base product = product_node.first; + const express::base product = product_node.first; const auto& place = product_node.second; kernel_logger.set_product(product); - IfcGeom::BRepElement* brep = static_cast(create_processed_element_([kernel, settings, product, place, rep]() { + ifcopenshell::geom::brep_element* brep = static_cast(create_processed_element_([kernel, settings, product, place, rep]() { return kernel->create_brep_for_representation_and_product(rep->item, product, place); })); if (!brep) { - kernel_logger.set_product(std::optional{}); + kernel_logger.set_product(std::optional{}); return; } auto elem = process_based_on_settings(settings, brep, kernel_logger); if (!elem) { - kernel_logger.set_product(std::optional{}); + kernel_logger.set_product(std::optional{}); return; } @@ -402,16 +402,16 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne for (auto it = rep->products.begin() + 1; it != rep->products.end(); ++it) { const auto& p = *it; - const express::Base product2 = p.first; + const express::base product2 = p.first; const auto& place2 = p.second; kernel_logger.set_product(product2); - IfcGeom::BRepElement* brep2 = static_cast(create_processed_element_([kernel, settings, product2, place2, brep]() { + ifcopenshell::geom::brep_element* brep2 = static_cast(create_processed_element_([kernel, settings, product2, place2, brep]() { return kernel->create_brep_for_processed_representation(product2, place2, brep); })); if (brep2) { - auto elem2 = process_based_on_settings(settings, brep2, kernel_logger, dynamic_cast(elem)); + auto elem2 = process_based_on_settings(settings, brep2, kernel_logger, dynamic_cast(elem)); if (elem2) { rep->breps.push_back(brep2); rep->elements.push_back(elem2); @@ -419,37 +419,37 @@ void IfcGeom::Iterator::create_element_(ifcopenshell::geometry::Converter* kerne } } - kernel_logger.set_product(std::optional{}); + kernel_logger.set_product(std::optional{}); } -IfcGeom::Element* IfcGeom::Iterator::process_based_on_settings(ifcopenshell::geometry::Settings settings, IfcGeom::BRepElement* elem, ::logger& logger, IfcGeom::TriangulationElement* previous) +ifcopenshell::geom::element* ifcopenshell::geom::iterator::process_based_on_settings(ifcopenshell::geom::settings settings, ifcopenshell::geom::brep_element* elem, ::logger& logger, ifcopenshell::geom::triangulation_element* previous) { - if (settings.get().get() == ifcopenshell::geometry::settings::SERIALIZED) { + if (settings.get().get() == ifcopenshell::geom::settings::SERIALIZED) { try { - return new IfcGeom::SerializedElement(*elem); + return new ifcopenshell::geom::serialized_element(*elem); } catch (...) { logger.message(::logger::LOG_ERROR, "GEO", 54, "Getting a serialized element from model failed."); return nullptr; } - } else if (settings.get().get() == ifcopenshell::geometry::settings::TRIANGULATED) { + } else if (settings.get().get() == ifcopenshell::geom::settings::TRIANGULATED) { return create_processed_element_([elem, previous, &logger]() { try { if (!previous) { - return new TriangulationElement(*elem); + return new triangulation_element(*elem); } else { - return new TriangulationElement(*elem, previous->geometry_pointer()); + return new triangulation_element(*elem, previous->geometry_pointer()); } } catch (...) { logger.message(::logger::LOG_ERROR, "GEO", 55, "Getting a triangulation element from model failed."); } - return (TriangulationElement*)nullptr; + return (triangulation_element*)nullptr; }); } else { return elem; } } -bool IfcGeom::Iterator::wait_for_element() { +bool ifcopenshell::geom::iterator::wait_for_element() { while (true) { size_t s; { @@ -467,7 +467,7 @@ bool IfcGeom::Iterator::wait_for_element() { } } -void IfcGeom::Iterator::log_timepoints() const { +void ifcopenshell::geom::iterator::log_timepoints() const { using std::chrono::high_resolution_clock; using std::chrono::duration; using namespace std::string_literals; @@ -485,9 +485,9 @@ void IfcGeom::Iterator::log_timepoints() const { } } -void IfcGeom::Iterator::validate_iterator_state() const { +void ifcopenshell::geom::iterator::validate_iterator_state() const { if (!initialization_outcome_) { - throw std::runtime_error("Iterator not initialized"); + throw std::runtime_error("iterator not initialized"); } // Causes: @@ -499,13 +499,13 @@ void IfcGeom::Iterator::validate_iterator_state() const { } if (task_result_ptr_exhausted) { - throw std::runtime_error("Iterator is exhausted"); + throw std::runtime_error("iterator is exhausted"); } } /// Moves to the next shape representation, create its geometry, and returns the associated product. /// Use get() to retrieve the created geometry. -express::Base IfcGeom::Iterator::next() { +express::base ifcopenshell::geom::iterator::next() { using std::chrono::high_resolution_clock; validate_iterator_state(); @@ -516,11 +516,11 @@ express::Base IfcGeom::Iterator::next() { if (num_threads_ != 1) { if (!wait_for_element()) { - logger_.set_product(std::optional{}); + logger_.set_product(std::optional{}); time_points[3] = high_resolution_clock::now(); log_timepoints(); task_result_ptr_exhausted = true; - return express::Base{}; + return express::base{}; } task_result_iterator_++; @@ -532,11 +532,11 @@ express::Base IfcGeom::Iterator::next() { // shape representation if (task_result_iterator_ == --all_processed_elements_.end()) { if (!create()) { - logger_.set_product(std::optional{}); + logger_.set_product(std::optional{}); time_points[3] = high_resolution_clock::now(); log_timepoints(); task_result_ptr_exhausted = true; - return express::Base{}; + return express::base{}; } } @@ -548,21 +548,21 @@ express::Base IfcGeom::Iterator::next() { } /// Gets the representation of the current geometrical entity. -IfcGeom::Element* IfcGeom::Iterator::get() +ifcopenshell::geom::element* ifcopenshell::geom::iterator::get() { validate_iterator_state(); auto ret = *task_result_iterator_; // If we want to organize the element considering their hierarchy - if (settings_.get().get()) { + if (settings_.get().get()) { // We are going to build a vector with the element parents. // First, create the parent vector - std::vector parents; + std::vector parents; // if the element has a parent if (ret->parent_id() != -1) { - const IfcGeom::Element* parent_object = NULL; + const ifcopenshell::geom::element* parent_object = NULL; bool hasParent = true; // get the parent @@ -598,7 +598,7 @@ IfcGeom::Element* IfcGeom::Iterator::get() hasParent = hasParent && parent_object->parent_id() != -1; } - // when done push the parent list in the Element object + // when done push the parent list in the element object ret->SetParents(parents); } } @@ -606,19 +606,19 @@ IfcGeom::Element* IfcGeom::Iterator::get() return ret; } -const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) { - ifcopenshell::geometry::taxonomy::matrix4::ptr m4; +const ifcopenshell::geom::element* ifcopenshell::geom::iterator::get_object(int id) { + ifcopenshell::geom::taxonomy::matrix4::ptr m4; int parent_id = -1; std::string instance_type, product_name, product_guid; - express::Base ifc_product; + express::base ifc_product; try { ifc_product = ifc_file->instance_by_id(id); instance_type = ifc_product.declaration().name(); if (ifc_product.declaration().is("IfcRoot")) { - product_guid = ifc_product.as().get_value("GlobalId"); - product_name = ifc_product.as().get_value("Name", ""); + product_guid = ifc_product.as().get_value("GlobalId"); + product_name = ifc_product.as().get_value("Name", ""); } auto parent_object = converter_->mapping()->get_decomposing_entity(ifc_product); @@ -628,7 +628,7 @@ const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) { // fails in case of IfcProject auto mapped = converter_->mapping()->map(ifc_product); - auto casted = mapped ? ifcopenshell::geometry::taxonomy::dcast(mapped) : nullptr; + auto casted = mapped ? ifcopenshell::geom::taxonomy::dcast(mapped) : nullptr; if (casted) { m4 = casted->matrix; @@ -639,12 +639,12 @@ const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) { logger_.error("GEO", 59, "Unknown error returning product"); } - Element* ifc_object = new Element(settings_, id, parent_id, product_name, instance_type, product_guid, "", m4, ifc_product.as()); + element* ifc_object = new element(settings_, id, parent_id, product_name, instance_type, product_guid, "", m4, ifc_product.as()); return ifc_object; } -express::Base IfcGeom::Iterator::create() { - express::Base product; +express::base ifcopenshell::geom::iterator::create() { + express::base product; try { product = create_shape_model_for_next_entity(); } catch (const std::exception& e) { @@ -657,20 +657,19 @@ express::Base IfcGeom::Iterator::create() { return product; } -ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offset_() { +ifcopenshell::geom::taxonomy::direction3::ptr ifcopenshell::geom::iterator::remove_offset_() { - using namespace ifcopenshell::geometry::taxonomy; - using namespace ifcopenshell::geometry::settings; + using namespace ifcopenshell::geom::taxonomy; - if (!settings_.get().has()) { + if (!settings_.get().has()) { return nullptr; } - if (!settings_.get().get()) { + if (!settings_.get().get()) { throw std::runtime_error("remove_offset() can only be called with defer-processing-first-element and no-parallel-mapping settings"); } - auto collect_offset = [&](const item::ptr& itm, const std::vector>& pr) -> std::pair { + auto collect_offset = [&](const item::ptr& itm, const std::vector>& pr) -> std::pair { std::function(const item::ptr&, Eigen::Matrix4d)> traverse; traverse = [&](const item::ptr& node, Eigen::Matrix4d m4) -> std::pair { if (auto shl = std::dynamic_pointer_cast(node)) { @@ -679,7 +678,7 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs v << p->components()(0), p->components()(1), p->components()(2), 1.0; Eigen::Vector3d translation_part = (m4 * v).head<3>(); double translation_amnt = translation_part.norm(); - if (translation_amnt > settings_.get().get()) { + if (translation_amnt > settings_.get().get()) { return { translation_amnt, translation_part }; } else { return { 0.0, Eigen::Vector3d::Zero() }; @@ -692,7 +691,7 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs } Eigen::Vector3d translation_part = m4.block<3, 1>(0, 3); double translation_amnt = translation_part.norm(); - if (translation_amnt > settings_.get().get()) { + if (translation_amnt > settings_.get().get()) { return { translation_amnt, translation_part }; } else if (auto col = std::dynamic_pointer_cast(node)) { std::vector> child_transforms; @@ -717,8 +716,8 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs Eigen::Vector3d vec; - if (settings_.get().has()) { - auto vs = settings_.get().get(); + if (settings_.get().has()) { + auto vs = settings_.get().get(); if (vs.size() != 3) { throw std::runtime_error("ApplyOffset setting must be a vector of size 3"); } @@ -750,7 +749,7 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs Eigen::Matrix4d translation_matrix = Eigen::Matrix4d::Identity(); translation_matrix.block<3, 1>(0, 3) = vec; - auto remove_offset = [&](const item::ptr& itm, const std::vector>& pr) -> bool { + auto remove_offset = [&](const item::ptr& itm, const std::vector>& pr) -> bool { std::function traverse; traverse = [&](const item::ptr& node, Eigen::Matrix4d m4) -> bool { if (auto shl = std::dynamic_pointer_cast(node)) { @@ -759,7 +758,7 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs v << p->components()(0), p->components()(1), p->components()(2), 1.0; Eigen::Vector3d translation_part = (m4 * v).head<3>(); double translation_amnt = translation_part.norm(); - if (translation_amnt > settings_.get().get()) { + if (translation_amnt > settings_.get().get()) { shl->matrix = make(translation_matrix); } return true; @@ -771,7 +770,7 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs } Eigen::Vector3d translation_part = m4b.block<3, 1>(0, 3); double translation_amnt = translation_part.norm(); - if (translation_amnt > settings_.get().get()) { + if (translation_amnt > settings_.get().get()) { auto inverted_rot_scale3 = m4.block<3, 3>(0, 0).inverse(); Eigen::Matrix4d inverted_rot_scale = Eigen::Matrix4d::Identity(); inverted_rot_scale.block<3, 3>(0, 0) = inverted_rot_scale3; @@ -807,7 +806,7 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs for (auto& p : task.products) { auto bb = p.second->components().block<3, 1>(0, 3); double translation_amnt = bb.norm(); - if (translation_amnt > settings_.get().get()) { + if (translation_amnt > settings_.get().get()) { // block has an underlying mutable ref to the matrix bb += vec; } else { @@ -829,7 +828,7 @@ ifcopenshell::geometry::taxonomy::direction3::ptr IfcGeom::Iterator::remove_offs return make(vec); } -IfcGeom::Iterator::~Iterator() { +ifcopenshell::geom::iterator::~iterator() { if (num_threads_ != 1) { terminating_ = true; diff --git a/src/ifcgeom/Iterator.h b/src/ifcgeom/Iterator.h index cf6ba58461..ef1179155a 100644 --- a/src/ifcgeom/Iterator.h +++ b/src/ifcgeom/Iterator.h @@ -22,7 +22,7 @@ * Geometrical data in an IFC file consists of shapes (IfcShapeRepresentation) * * and instances (SUBTYPE OF IfcBuildingElement e.g. IfcWindow). * * * - * IfcGeom::Representation::Triangulation is a class that represents a * + * ifcopenshell::geom::Representation::triangulation is a class that represents a * * triangulated IfcShapeRepresentation. * * Triangulation.verts is a 1 dimensional vector of float defining the * * cartesian coordinates of the vertices of the triangulated shape in the * @@ -32,25 +32,25 @@ * Triangulation.edges is a 1 dimensional vector of int in {0,1} that dictates* * the visibility of the edges that span the faces in Triangulation.faces * * * - * IfcGeom::Element represents the actual IfcBuildingElements. * + * ifcopenshell::geom::element represents the actual IfcBuildingElements. * * IfcGeomObject.name is the GUID of the element * * IfcGeomObject.type is the datatype of the element e.g. IfcWindow * * IfcGeomObject.mesh is a pointer to an IfcMesh * * IfcGeomObject.transformation.matrix is a 4x3 matrix that defines the * * orientation and translation of the mesh in relation to the world origin * * * - * IfcGeom::Iterator::initialize() * + * ifcopenshell::geom::iterator::initialize() * * finds the most suitable representation contexts. Returns true iff * * at least a single representation will process successfully * * * - * IfcGeom::Iterator::get() * - * returns a pointer to the current IfcGeom::Element * + * ifcopenshell::geom::iterator::get() * + * returns a pointer to the current ifcopenshell::geom::element * * * - * IfcGeom::Iterator::next() * + * ifcopenshell::geom::iterator::next() * * returns true iff a following entity is available for a successive call to * - * IfcGeom::Iterator::get() * + * ifcopenshell::geom::iterator::get() * * * - * IfcGeom::Iterator::progress() * + * ifcopenshell::geom::iterator::progress() * * returns an int in [0..100] that indicates the overall progress * * * ********************************************************************************/ @@ -80,21 +80,21 @@ #include #include -namespace IfcGeom { +namespace ifcopenshell::geom { struct IFC_GEOM_API geometry_conversion_result { int index; // For NoParallelMapping==true - ifcopenshell::geometry::taxonomy::ptr item; - std::vector> products; + ifcopenshell::geom::taxonomy::ptr item; + std::vector> products; // For NoParallelMapping==false - express::Base representation; - std::vector products_2; + express::base representation; + std::vector products_2; - std::vector breps; - std::vector elements; + std::vector breps; + std::vector elements; bool is_parallel() const { return !!representation; @@ -102,7 +102,7 @@ namespace IfcGeom { }; - class IFC_GEOM_API Iterator { + class IFC_GEOM_API iterator { private: std::atomic finished_{ false }; std::atomic terminating_{ false }; @@ -112,35 +112,35 @@ namespace IfcGeom { std::vector tasks_; std::vector::iterator task_iterator_; - std::list all_processed_elements_; - std::list all_processed_native_elements_; + std::list all_processed_elements_; + std::list all_processed_native_elements_; - std::list::const_iterator task_result_iterator_; - std::list::const_iterator native_task_result_iterator_; + std::list::const_iterator task_result_iterator_; + std::list::const_iterator native_task_result_iterator_; std::mutex element_ready_mutex_; bool task_result_ptr_initialized = false; bool task_result_ptr_exhausted = false; size_t async_elements_returned_ = 0; - ifcopenshell::geometry::Settings settings_; + ifcopenshell::geom::settings settings_; ifcopenshell::file* ifc_file; - std::vector filters_; + std::vector filters_; int num_threads_; std::string geometry_library_; ::logger& logger_; // When single-threaded - ifcopenshell::geometry::Converter* converter_; + ifcopenshell::geom::converter* converter_; // When multi-threaded - std::vector kernel_pool; + std::vector kernel_pool; std::vector> worker_loggers_; // The object is fetched beforehand to be sure that get() returns a valid element - TriangulationElement* current_triangulation; - BRepElement* current_shape_model; - SerializedElement* current_serialization; + triangulation_element* current_triangulation; + brep_element* current_shape_model; + serialized_element* current_serialization; double lowest_precision_encountered; bool any_precision_encountered; @@ -148,42 +148,42 @@ namespace IfcGeom { int done; int total; - ifcopenshell::geometry::taxonomy::point3 bounds_min_; - ifcopenshell::geometry::taxonomy::point3 bounds_max_; + ifcopenshell::geom::taxonomy::point3 bounds_min_; + ifcopenshell::geom::taxonomy::point3 bounds_max_; // Should not be destructed because, destructor is blocking std::future init_future_; std::array time_points; template - Element* create_processed_element_(Fn f) { + element* create_processed_element_(Fn f) { return f(); } - express::Base create_shape_model_for_next_entity(); + express::base create_shape_model_for_next_entity(); void create_element_( - ifcopenshell::geometry::Converter* kernel, - ifcopenshell::geometry::Settings settings, + ifcopenshell::geom::converter* kernel, + ifcopenshell::geom::settings settings, geometry_conversion_result* rep); - IfcGeom::Element* process_based_on_settings( - ifcopenshell::geometry::Settings settings, - IfcGeom::BRepElement* elem, + ifcopenshell::geom::element* process_based_on_settings( + ifcopenshell::geom::settings settings, + ifcopenshell::geom::brep_element* elem, ::logger& logger, - IfcGeom::TriangulationElement* previous = nullptr); + ifcopenshell::geom::triangulation_element* previous = nullptr); - void flush_worker_log(ifcopenshell::geometry::Converter* kernel); + void flush_worker_log(ifcopenshell::geom::converter* kernel); bool wait_for_element(); void log_timepoints() const; void validate_iterator_state() const; - ifcopenshell::geometry::taxonomy::direction3::ptr remove_offset_(); + ifcopenshell::geom::taxonomy::direction3::ptr remove_offset_(); public: - Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, const std::vector& filters, int num_threads, ::logger& logger = ::logger::root()) + iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, const std::vector& filters, int num_threads, ::logger& logger = ::logger::root()) : settings_(settings) , ifc_file(file) , filters_(filters) @@ -191,34 +191,34 @@ namespace IfcGeom { , geometry_library_(geometry_library->geometry_library()) , logger_(logger) // @todo verify whether settings are correctly passed on - , converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_)) + , converter_(new ifcopenshell::geom::converter(std::move(geometry_library), ifc_file, settings_, logger_)) { } - Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, ::logger& logger = ::logger::root()) + iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, ::logger& logger = ::logger::root()) : settings_(settings) , ifc_file(file) , num_threads_(1) , geometry_library_(geometry_library->geometry_library()) , logger_(logger) - , converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_)) + , converter_(new ifcopenshell::geom::converter(std::move(geometry_library), ifc_file, settings_, logger_)) { } - Iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geometry::Settings& settings, ifcopenshell::file* file, int num_threads, ::logger& logger = ::logger::root()) + iterator(std::unique_ptr&& geometry_library, const ifcopenshell::geom::settings& settings, ifcopenshell::file* file, int num_threads, ::logger& logger = ::logger::root()) : settings_(settings) , ifc_file(file) , num_threads_(num_threads) , geometry_library_(geometry_library->geometry_library()) , logger_(logger) - , converter_(new ifcopenshell::geometry::Converter(std::move(geometry_library), ifc_file, settings_, logger_)) + , converter_(new ifcopenshell::geom::converter(std::move(geometry_library), ifc_file, settings_, logger_)) { } - ~Iterator(); + ~iterator(); - std::vector get_task_items() const { - std::vector items; + std::vector get_task_items() const { + std::vector items; items.reserve(tasks_.size()); for (const auto& task : tasks_) { items.push_back(task.item); @@ -226,14 +226,14 @@ namespace IfcGeom { return items; } - std::vector> get_task_products() const { - std::vector> products; + std::vector> get_task_products() const { + std::vector> products; for (const auto& task : tasks_) { if (task.is_parallel()) { products.push_back(task.products_2); } else { for (auto& product : task.products) { - std::vector p; + std::vector p; p.push_back(product.first); products.push_back(p); } @@ -264,7 +264,7 @@ namespace IfcGeom { size_t processed_ = 0; - void process_finished_rep(geometry_conversion_result* rep, ifcopenshell::geometry::Converter* kernel = nullptr); + void process_finished_rep(geometry_conversion_result* rep, ifcopenshell::geom::converter* kernel = nullptr); void process_concurrently(); @@ -280,28 +280,28 @@ namespace IfcGeom { ifcopenshell::file* file() const { return ifc_file; } - const std::vector& filters() const { return filters_; } - std::vector& filters() { return filters_; } + const std::vector& filters() const { return filters_; } + std::vector& filters() { return filters_; } - const ifcopenshell::geometry::taxonomy::point3& bounds_min() const { return bounds_min_; } - const ifcopenshell::geometry::taxonomy::point3& bounds_max() const { return bounds_max_; } + const ifcopenshell::geom::taxonomy::point3& bounds_min() const { return bounds_min_; } + const ifcopenshell::geom::taxonomy::point3& bounds_max() const { return bounds_max_; } /// Moves to the next shape representation, create its geometry, and returns the associated product. /// Use get() to retrieve the created geometry. - express::Base next(); + express::base next(); /// Gets the representation of the current geometrical entity. - Element* get(); + element* get(); /// Gets the native (Open Cascade or CGAL) representation of the current geometrical entity. - BRepElement* get_native() + brep_element* get_native() { return *native_task_result_iterator_; } - const Element* get_object(int id); + const element* get_object(int id); - express::Base create(); + express::base create(); }; } diff --git a/src/ifcgeom/Serialization/CMakeLists.txt b/src/ifcgeom/Serialization/CMakeLists.txt index 6aab9fa9d5..6e233a4077 100644 --- a/src/ifcgeom/Serialization/CMakeLists.txt +++ b/src/ifcgeom/Serialization/CMakeLists.txt @@ -16,7 +16,7 @@ set_target_properties(geometry_serializer PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${geometry_serialization_plugin_runtime_dir}" LIBRARY_OUTPUT_DIRECTORY "${geometry_serialization_plugin_runtime_dir}" ) -target_link_libraries(geometry_serializer plugin IfcGeom IfcParse ${OpenCASCADE_LIBRARIES}) +target_link_libraries(geometry_serializer plugin IfcGeom IfcParse geometry_kernel_opencascade ${OpenCASCADE_LIBRARIES}) set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} "geometry_serializer") set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} PARENT_SCOPE) diff --git a/src/ifcgeom/Serialization/Serialization.cpp b/src/ifcgeom/Serialization/Serialization.cpp index 79a803990d..7ffeb9a615 100644 --- a/src/ifcgeom/Serialization/Serialization.cpp +++ b/src/ifcgeom/Serialization/Serialization.cpp @@ -12,12 +12,12 @@ namespace { } } -IfcGeom::opencascade_geometry_ifc_writer_registry& IfcGeom::opencascade_geometry_ifc_writer_registry_instance() { +ifcopenshell::geom::opencascade_geometry_ifc_writer_registry& ifcopenshell::geom::opencascade_geometry_ifc_writer_registry_instance() { static opencascade_geometry_ifc_writer_registry registry; return registry; } -void IfcGeom::opencascade_geometry_ifc_writer_registry::bind(const std::string& schema_name, serialise_fn serialise, tesselate_fn tesselate, const ifcopenshell::plugin::module& module) { +void ifcopenshell::geom::opencascade_geometry_ifc_writer_registry::bind(const std::string& schema_name, serialise_fn serialise, tesselate_fn tesselate, const ifcopenshell::plugin::module& module) { entry entry; entry.serialise_ = serialise; entry.tesselate_ = tesselate; @@ -25,7 +25,7 @@ void IfcGeom::opencascade_geometry_ifc_writer_registry::bind(const std::string& entries_[writer_schema_key(schema_name)] = entry; } -express::Base IfcGeom::opencascade_geometry_ifc_writer_registry::tesselate(ifcopenshell::file& f, const ConversionResultShape& shape, double deflection) const { +express::base ifcopenshell::geom::opencascade_geometry_ifc_writer_registry::tesselate(ifcopenshell::file& f, const conversion_result_shape& shape, double deflection) const { auto iter = entries_.find(writer_schema_key(f.schema()->name())); if (iter == entries_.end()) { load_opencascade_geometry_ifc_writer_plugin(const_cast(*this), f.schema()->name()); @@ -37,7 +37,7 @@ express::Base IfcGeom::opencascade_geometry_ifc_writer_registry::tesselate(ifcop return iter->second.tesselate_(f, shape, deflection); } -express::Base IfcGeom::opencascade_geometry_ifc_writer_registry::serialise(ifcopenshell::file& f, const ConversionResultShape& shape, bool advanced) const { +express::base ifcopenshell::geom::opencascade_geometry_ifc_writer_registry::serialise(ifcopenshell::file& f, const conversion_result_shape& shape, bool advanced) const { auto iter = entries_.find(writer_schema_key(f.schema()->name())); if (iter == entries_.end()) { load_opencascade_geometry_ifc_writer_plugin(const_cast(*this), f.schema()->name()); @@ -49,20 +49,20 @@ express::Base IfcGeom::opencascade_geometry_ifc_writer_registry::serialise(ifcop return iter->second.serialise_(f, shape, advanced); } -express::Base IfcGeom::tesselate(ifcopenshell::file& f, const ConversionResultShape& shape, double deflection) { +express::base ifcopenshell::geom::tesselate(ifcopenshell::file& f, const conversion_result_shape& shape, double deflection) { return opencascade_geometry_ifc_writer_registry_instance().tesselate(f, shape, deflection); } -express::Base IfcGeom::serialise(ifcopenshell::file& f, const ConversionResultShape& shape, bool advanced) { +express::base ifcopenshell::geom::serialise(ifcopenshell::file& f, const conversion_result_shape& shape, bool advanced) { return opencascade_geometry_ifc_writer_registry_instance().serialise(f, shape, advanced); } -express::Base IfcGeom::tesselate(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection) { - ifcopenshell::geometry::OpenCascadeShape converted(shape); +express::base ifcopenshell::geom::tesselate(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection) { + ifcopenshell::geom::open_cascade_shape converted(shape); return tesselate(f, converted, deflection); } -express::Base IfcGeom::serialise(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced) { - ifcopenshell::geometry::OpenCascadeShape converted(shape); +express::base ifcopenshell::geom::serialise(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced) { + ifcopenshell::geom::open_cascade_shape converted(shape); return serialise(f, converted, advanced); } diff --git a/src/ifcgeom/Serialization/Serialization.h b/src/ifcgeom/Serialization/Serialization.h index 72a2232405..d87fa71280 100644 --- a/src/ifcgeom/Serialization/Serialization.h +++ b/src/ifcgeom/Serialization/Serialization.h @@ -18,15 +18,15 @@ namespace ifcopenshell { class file; } -namespace IfcGeom { +namespace ifcopenshell::geom { class IFC_GEOMSERIALIZATION_API opencascade_geometry_ifc_writer_registry { public: - typedef boost::function3 tesselate_fn; - typedef boost::function3 serialise_fn; + typedef boost::function3 tesselate_fn; + typedef boost::function3 serialise_fn; void bind(const std::string& schema_name, serialise_fn serialise, tesselate_fn tesselate, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module()); - express::Base tesselate(ifcopenshell::file& f, const ConversionResultShape& shape, double deflection) const; - express::Base serialise(ifcopenshell::file& f, const ConversionResultShape& shape, bool advanced) const; + express::base tesselate(ifcopenshell::file& f, const conversion_result_shape& shape, double deflection) const; + express::base serialise(ifcopenshell::file& f, const conversion_result_shape& shape, bool advanced) const; private: struct entry { @@ -40,10 +40,10 @@ private: IFC_GEOMSERIALIZATION_API opencascade_geometry_ifc_writer_registry& opencascade_geometry_ifc_writer_registry_instance(); -IFC_GEOMSERIALIZATION_API express::Base tesselate(ifcopenshell::file& f, const ConversionResultShape& shape, double deflection); -IFC_GEOMSERIALIZATION_API express::Base serialise(ifcopenshell::file& f, const ConversionResultShape& shape, bool advanced); -IFC_GEOMSERIALIZATION_API express::Base tesselate(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection); -IFC_GEOMSERIALIZATION_API express::Base serialise(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced); -} // namespace IfcGeom +IFC_GEOMSERIALIZATION_API express::base tesselate(ifcopenshell::file& f, const conversion_result_shape& shape, double deflection); +IFC_GEOMSERIALIZATION_API express::base serialise(ifcopenshell::file& f, const conversion_result_shape& shape, bool advanced); +IFC_GEOMSERIALIZATION_API express::base tesselate(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection); +IFC_GEOMSERIALIZATION_API express::base serialise(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced); +} // namespace ifcopenshell::geom #endif diff --git a/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp b/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp index 81f6bfa82c..89588b0ee0 100644 --- a/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp +++ b/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.cpp @@ -31,11 +31,11 @@ namespace { constexpr const char* opencascade_geometry_ifc_writer_plugin_prefix = "geometry.writer."; } -const char* IfcGeom::opencascade_geometry_ifc_writer_plugin_registration_symbol() { +const char* ifcopenshell::geom::opencascade_geometry_ifc_writer_plugin_registration_symbol() { return "ifcopenshell_register_opencascade_geometry_ifc_writer_plugin_v1"; } -ifcopenshell::plugin::metadata IfcGeom::opencascade_geometry_ifc_writer_plugin_metadata(const std::string& schema_name) { +ifcopenshell::plugin::metadata ifcopenshell::geom::opencascade_geometry_ifc_writer_plugin_metadata(const std::string& schema_name) { ifcopenshell::plugin::metadata metadata; metadata.kind_ = ifcopenshell::plugin::kind::opencascade_geometry_ifc_writer; metadata.id = opencascade_geometry_ifc_writer_plugin_prefix + boost::to_lower_copy(schema_name); @@ -43,11 +43,11 @@ ifcopenshell::plugin::metadata IfcGeom::opencascade_geometry_ifc_writer_plugin_m return metadata; } -std::filesystem::path IfcGeom::opencascade_geometry_ifc_writer_plugin_directory() { - return ifcopenshell::plugin::module_directory(reinterpret_cast(&IfcGeom::load_opencascade_geometry_ifc_writer_plugins)); +std::filesystem::path ifcopenshell::geom::opencascade_geometry_ifc_writer_plugin_directory() { + return ifcopenshell::plugin::module_directory(reinterpret_cast(&ifcopenshell::geom::load_opencascade_geometry_ifc_writer_plugins)); } -void IfcGeom::load_opencascade_geometry_ifc_writer_plugins(opencascade_geometry_ifc_writer_registry& registry) { +void ifcopenshell::geom::load_opencascade_geometry_ifc_writer_plugins(opencascade_geometry_ifc_writer_registry& registry) { ifcopenshell::plugin::manager manager; ifcopenshell::plugin::add_search_paths_or_default(manager, &opencascade_geometry_ifc_writer_plugin_directory); @@ -62,7 +62,7 @@ void IfcGeom::load_opencascade_geometry_ifc_writer_plugins(opencascade_geometry_ } } -bool IfcGeom::load_opencascade_geometry_ifc_writer_plugin(opencascade_geometry_ifc_writer_registry& registry, const std::string& schema_name) { +bool ifcopenshell::geom::load_opencascade_geometry_ifc_writer_plugin(opencascade_geometry_ifc_writer_registry& registry, const std::string& schema_name) { ifcopenshell::plugin::manager manager; ifcopenshell::plugin::add_search_paths_or_default(manager, &opencascade_geometry_ifc_writer_plugin_directory); diff --git a/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.h b/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.h index 6aed2545cb..76f81f4dbe 100644 --- a/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.h +++ b/src/ifcgeom/Serialization/opencascade_geometry_ifc_writer_plugin.h @@ -24,7 +24,7 @@ #include -namespace IfcGeom { +namespace ifcopenshell::geom { typedef void register_opencascade_geometry_ifc_writer_plugin_fn(opencascade_geometry_ifc_writer_registry&, const ifcopenshell::plugin::module&); diff --git a/src/ifcgeom/Serialization/schema/Serialization.cpp b/src/ifcgeom/Serialization/schema/Serialization.cpp index d6115c675b..b4b657c869 100644 --- a/src/ifcgeom/Serialization/schema/Serialization.cpp +++ b/src/ifcgeom/Serialization/schema/Serialization.cpp @@ -622,7 +622,7 @@ int convert_to_ifc(ifcopenshell::file& f, const TopoDS_Shape& s, U& item, bool a if (convert_to_ifc(f, TopoDS::Face(exp.Current()), fa, advanced)) { faces.push_back(fa); } else { - std::set created; + std::set created; for (auto& face : faces) { auto resources = f.traverse(face); created.insert(resources.begin(), resources.end()); @@ -640,7 +640,7 @@ int convert_to_ifc(ifcopenshell::file& f, const TopoDS_Shape& s, U& item, bool a return faces.size(); } -express::Base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced) { +express::base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced) { #ifndef SCHEMA_HAS_IfcAdvancedBrep advanced = false; @@ -648,7 +648,7 @@ express::Base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shap for (TopExp_Explorer exp(shape, TopAbs_COMPSOLID); exp.More();) { /// @todo CompSolids are not supported - return express::Base{}; + return express::base{}; } IfcSchema::IfcRepresentation rep; @@ -661,7 +661,7 @@ express::Base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shap for (TopExp_Explorer exp2(exp.Current(), TopAbs_SHELL); exp2.More(); exp2.Next()) { IfcSchema::IfcClosedShell shell; if (!convert_to_ifc(f, exp2.Current(), shell, advanced)) { - return express::Base{}; + return express::base{}; } /// @todo Are shells always in this order or does Orientation() needs to be checked? /// > #4216, no, consider using BRepClass3d::OuterShell() @@ -714,7 +714,7 @@ express::Base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shap for (TopExp_Explorer exp(shape, TopAbs_SHELL); exp.More(); exp.Next()) { IfcSchema::IfcOpenShell shell; if (!convert_to_ifc(f, exp.Current(), shell, advanced)) { - return express::Base{}; + return express::base{}; } shells.push_back(shell); } @@ -750,18 +750,18 @@ express::Base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shap // they are not commonly top-level geometrical descriptions in IFC. // Also note that edges are written as trimmed curves rather than edges. - std::vector edges; + std::vector edges; for (TopExp_Explorer exp(shape, TopAbs_EDGE); exp.More(); exp.Next()) { IfcSchema::IfcCurve c; if (!convert_to_ifc(f, TopoDS::Edge(exp.Current()), c, advanced)) { - return express::Base{}; + return express::base{}; } edges.push_back(c); } if (edges.size() == 0) { - return express::Base{}; + return express::base{}; } else if (edges.size() == 1) { auto srep = f.create(); srep.setRepresentationIdentifier("Axis"); @@ -791,7 +791,7 @@ express::Base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shap return pds; } -express::Base POSTFIX_SCHEMA(tesselate)(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection) { +express::base POSTFIX_SCHEMA(tesselate)(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection) { // @todo use triangulated face set in ifc4+ schema BRepMesh_IncrementalMesh(shape, deflection); diff --git a/src/ifcgeom/Serialization/schema/plugin.cpp b/src/ifcgeom/Serialization/schema/plugin.cpp index 3c62991f00..1769d29514 100644 --- a/src/ifcgeom/Serialization/schema/plugin.cpp +++ b/src/ifcgeom/Serialization/schema/plugin.cpp @@ -25,28 +25,28 @@ #include -express::Base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced); -express::Base POSTFIX_SCHEMA(tesselate)(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection); +express::base POSTFIX_SCHEMA(serialise)(ifcopenshell::file& f, const TopoDS_Shape& shape, bool advanced); +express::base POSTFIX_SCHEMA(tesselate)(ifcopenshell::file& f, const TopoDS_Shape& shape, double deflection); namespace { - const ifcopenshell::geometry::OpenCascadeShape& require_opencascade_shape(const IfcGeom::ConversionResultShape& shape) { - const auto* oc_shape = dynamic_cast(&shape); + const ifcopenshell::geom::open_cascade_shape& require_opencascade_shape(const ifcopenshell::geom::conversion_result_shape& shape) { + const auto* oc_shape = dynamic_cast(&shape); if (!oc_shape) { throw ifcopenshell::exception("OpenCascade geometry IFC writer requires an opencascade conversion result shape"); } return *oc_shape; } - express::Base serialise_adapter(ifcopenshell::file& f, const IfcGeom::ConversionResultShape& shape, bool advanced) { + express::base serialise_adapter(ifcopenshell::file& f, const ifcopenshell::geom::conversion_result_shape& shape, bool advanced) { return POSTFIX_SCHEMA(serialise)(f, require_opencascade_shape(shape).shape(), advanced); } - express::Base tesselate_adapter(ifcopenshell::file& f, const IfcGeom::ConversionResultShape& shape, double deflection) { + express::base tesselate_adapter(ifcopenshell::file& f, const ifcopenshell::geom::conversion_result_shape& shape, double deflection) { return POSTFIX_SCHEMA(tesselate)(f, require_opencascade_shape(shape).shape(), deflection); } } -namespace IfcGeom { +namespace ifcopenshell::geom { namespace opencascade_geometry_ifc_writer_plugin { ifcopenshell::plugin::abi_info plugin_abi() { @@ -64,6 +64,6 @@ namespace IfcGeom { } } -BOOST_DLL_ALIAS(IfcGeom::opencascade_geometry_ifc_writer_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(IfcGeom::opencascade_geometry_ifc_writer_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(IfcGeom::opencascade_geometry_ifc_writer_plugin::register_plugin, ifcopenshell_register_opencascade_geometry_ifc_writer_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::opencascade_geometry_ifc_writer_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::opencascade_geometry_ifc_writer_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::opencascade_geometry_ifc_writer_plugin::register_plugin, ifcopenshell_register_opencascade_geometry_ifc_writer_plugin_v1) diff --git a/src/ifcgeom/Serializer.h b/src/ifcgeom/Serializer.h index 03c2b6c362..44631c851d 100644 --- a/src/ifcgeom/Serializer.h +++ b/src/ifcgeom/Serializer.h @@ -23,11 +23,11 @@ #include "ifc_geom_api.h" #include "../ifcparse/file.h" -class IFC_GEOM_API Serializer { +class IFC_GEOM_API serializer { ::logger& logger_; public: - explicit Serializer(::logger& logger = ::logger::root()) : logger_(logger) {} - virtual ~Serializer() {} + explicit serializer(::logger& logger = ::logger::root()) : logger_(logger) {} + virtual ~serializer() {} ::logger& logger() const { return logger_; } diff --git a/src/ifcgeom/SurfaceStyle.cpp b/src/ifcgeom/SurfaceStyle.cpp index bb7496d191..d15a15b9c5 100644 --- a/src/ifcgeom/SurfaceStyle.cpp +++ b/src/ifcgeom/SurfaceStyle.cpp @@ -8,55 +8,55 @@ namespace pt = boost::property_tree; -static std::map default_materials; -static ifcopenshell::geometry::taxonomy::style::ptr default_material; +static std::map default_materials; +static ifcopenshell::geom::taxonomy::style::ptr default_material; static bool default_materials_initialized = false; void InitDefaultMaterials() { - default_materials.insert(std::make_pair("IfcSite", std::make_shared("IfcSite"))); - default_materials["IfcSite"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.8, 0.65); + default_materials.insert(std::make_pair("IfcSite", std::make_shared("IfcSite"))); + default_materials["IfcSite"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.75, 0.8, 0.65); - default_materials.insert(std::make_pair("IfcSlab", std::make_shared("IfcSlab"))); - default_materials["IfcSlab"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.4, 0.4, 0.4); + default_materials.insert(std::make_pair("IfcSlab", std::make_shared("IfcSlab"))); + default_materials["IfcSlab"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.4, 0.4, 0.4); - default_materials.insert(std::make_pair("IfcWallStandardCase", std::make_shared("IfcWallStandardCase"))); - default_materials["IfcWallStandardCase"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.9, 0.9, 0.9); + default_materials.insert(std::make_pair("IfcWallStandardCase", std::make_shared("IfcWallStandardCase"))); + default_materials["IfcWallStandardCase"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.9, 0.9, 0.9); - default_materials.insert(std::make_pair("IfcWall", std::make_shared("IfcWall"))); - default_materials["IfcWall"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.9, 0.9, 0.9); + default_materials.insert(std::make_pair("IfcWall", std::make_shared("IfcWall"))); + default_materials["IfcWall"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.9, 0.9, 0.9); - default_materials.insert(std::make_pair("IfcWindow", std::make_shared("IfcWindow"))); - default_materials["IfcWindow"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.8, 0.75); + default_materials.insert(std::make_pair("IfcWindow", std::make_shared("IfcWindow"))); + default_materials["IfcWindow"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.75, 0.8, 0.75); default_materials["IfcWindow"]->transparency = 0.3; - default_materials.insert(std::make_pair("IfcDoor", std::make_shared("IfcDoor"))); - default_materials["IfcDoor"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.55, 0.3, 0.15); + default_materials.insert(std::make_pair("IfcDoor", std::make_shared("IfcDoor"))); + default_materials["IfcDoor"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.55, 0.3, 0.15); - default_materials.insert(std::make_pair("IfcBeam", std::make_shared("IfcBeam"))); - default_materials["IfcBeam"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.75, 0.7, 0.7); + default_materials.insert(std::make_pair("IfcBeam", std::make_shared("IfcBeam"))); + default_materials["IfcBeam"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.75, 0.7, 0.7); - default_materials.insert(std::make_pair("IfcRailing", std::make_shared("IfcRailing"))); - default_materials["IfcRailing"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.6, 0.6); + default_materials.insert(std::make_pair("IfcRailing", std::make_shared("IfcRailing"))); + default_materials["IfcRailing"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.65, 0.6, 0.6); - default_materials.insert(std::make_pair("IfcMember", std::make_shared("IfcMember"))); - default_materials["IfcMember"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.6, 0.6); + default_materials.insert(std::make_pair("IfcMember", std::make_shared("IfcMember"))); + default_materials["IfcMember"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.65, 0.6, 0.6); - default_materials.insert(std::make_pair("IfcPlate", std::make_shared("IfcPlate"))); - default_materials["IfcPlate"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.8, 0.8, 0.8); + default_materials.insert(std::make_pair("IfcPlate", std::make_shared("IfcPlate"))); + default_materials["IfcPlate"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.8, 0.8, 0.8); - default_materials.insert(std::make_pair("IfcSpace", std::make_shared("IfcSpace"))); - default_materials["IfcSpace"]->diffuse = ifcopenshell::geometry::taxonomy::colour(0.65, 0.75, 0.8); + default_materials.insert(std::make_pair("IfcSpace", std::make_shared("IfcSpace"))); + default_materials["IfcSpace"]->diffuse = ifcopenshell::geom::taxonomy::colour(0.65, 0.75, 0.8); default_materials["IfcSpace"]->transparency = 0.8; - default_material = std::make_shared("DefaultMaterial"); - default_material->diffuse = ifcopenshell::geometry::taxonomy::colour(0.7, 0.7, 0.7); + default_material = std::make_shared("DefaultMaterial"); + default_material->diffuse = ifcopenshell::geom::taxonomy::colour(0.7, 0.7, 0.7); default_materials_initialized = true; } -ifcopenshell::geometry::taxonomy::colour read_colour_component(const boost::optional list) { +ifcopenshell::geom::taxonomy::colour read_colour_component(const boost::optional list) { if (!list) { - return ifcopenshell::geometry::taxonomy::colour(); + return ifcopenshell::geom::taxonomy::colour(); } double rgb[3]; int i = 0; @@ -70,10 +70,10 @@ ifcopenshell::geometry::taxonomy::colour read_colour_component(const boost::opti if (i != 3) { throw std::runtime_error("rgb array less than 3 elements large (was " + std::to_string(i) + ")"); } - return ifcopenshell::geometry::taxonomy::colour(rgb[0], rgb[1], rgb[2]); + return ifcopenshell::geom::taxonomy::colour(rgb[0], rgb[1], rgb[2]); } -void IfcGeom::set_default_style_file(const std::string& json_file) { +void ifcopenshell::geom::set_default_style_file(const std::string& json_file) { if (!default_materials_initialized) InitDefaultMaterials(); default_materials.clear(); @@ -83,7 +83,7 @@ void IfcGeom::set_default_style_file(const std::string& json_file) { for (pt::ptree::value_type &material_pair : root) { std::string name = material_pair.first; - default_materials.insert(std::make_pair(name, std::make_shared(name))); + default_materials.insert(std::make_pair(name, std::make_shared(name))); pt::ptree material = material_pair.second; auto diffuse = material.get_child_optional("diffuse"); @@ -112,7 +112,7 @@ void IfcGeom::set_default_style_file(const std::string& json_file) { } } -const ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::get_default_style(const std::string& s) { +const ifcopenshell::geom::taxonomy::style::ptr& ifcopenshell::geom::get_default_style(const std::string& s) { static std::mutex m; std::lock_guard lk(m); @@ -125,7 +125,7 @@ const ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::get_default_style(c return it->second; } -ifcopenshell::geometry::taxonomy::style::ptr& IfcGeom::update_default_style(const std::string& s) { +ifcopenshell::geom::taxonomy::style::ptr& ifcopenshell::geom::update_default_style(const std::string& s) { if (!default_materials_initialized) InitDefaultMaterials(); auto it = default_materials.find(s); if (it == default_materials.end()) { diff --git a/src/ifcgeom/abstract_mapping.cpp b/src/ifcgeom/abstract_mapping.cpp index 19dfd17ad4..5139c02bd8 100644 --- a/src/ifcgeom/abstract_mapping.cpp +++ b/src/ifcgeom/abstract_mapping.cpp @@ -12,18 +12,18 @@ namespace { } -ifcopenshell::geometry::impl::mapping_registry& ifcopenshell::geometry::impl::mapping_registry_instance() { +ifcopenshell::geom::impl::mapping_registry& ifcopenshell::geom::impl::mapping_registry_instance() { static mapping_registry registry; return registry; } -void ifcopenshell::geometry::impl::mapping_registry::bind(const std::string& schema_name, ifcopenshell::geometry::impl::mapping_fn fn, const plugin::module& module) { +void ifcopenshell::geom::impl::mapping_registry::bind(const std::string& schema_name, ifcopenshell::geom::impl::mapping_fn fn, const plugin::module& module) { auto& entry = entries_[mapping_key(schema_name)]; entry.fn_ = fn; entry.module_ = module.meta().id.empty() ? plugin::module(mapping_plugin_metadata(schema_name)) : module; } -ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::mapping_registry::construct(ifcopenshell::file* file, Settings& s, ::logger& log) { +ifcopenshell::geom::abstract_mapping* ifcopenshell::geom::impl::mapping_registry::construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& log) { const std::string schema_name_lower = boost::to_lower_copy(file->schema()->name()); auto it = entries_.find(schema_name_lower); if (it == entries_.end()) { @@ -33,7 +33,7 @@ ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::mapping_ if (it == entries_.end()) { throw ifcopenshell::exception("No geometry mapping registered for " + schema_name_lower); } - auto new_mapping = it->second.fn_(file, s, log); + auto new_mapping = it->second.fn_(file, settings, log); try { new_mapping->initialize_settings(); } catch (const std::exception& e) { @@ -43,19 +43,19 @@ ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::mapping_ return new_mapping; } -ifcopenshell::geometry::impl::MappingFactoryImplementation& ifcopenshell::geometry::impl::mapping_implementations() { - static MappingFactoryImplementation impl; +ifcopenshell::geom::impl::mapping_factory_implementation& ifcopenshell::geom::impl::mapping_implementations() { + static mapping_factory_implementation impl; return impl; } -ifcopenshell::geometry::impl::MappingFactoryImplementation::MappingFactoryImplementation() { +ifcopenshell::geom::impl::mapping_factory_implementation::mapping_factory_implementation() { mapping_registry_instance(); } -void ifcopenshell::geometry::impl::MappingFactoryImplementation::bind(const std::string& schema_name, ifcopenshell::geometry::impl::mapping_fn fn) { +void ifcopenshell::geom::impl::mapping_factory_implementation::bind(const std::string& schema_name, ifcopenshell::geom::impl::mapping_fn fn) { mapping_registry_instance().bind(schema_name, fn, plugin::module(mapping_plugin_metadata(schema_name))); } -ifcopenshell::geometry::abstract_mapping* ifcopenshell::geometry::impl::MappingFactoryImplementation::construct(ifcopenshell::file* file, Settings& s, ::logger& log) { - return mapping_registry_instance().construct(file, s, log); +ifcopenshell::geom::abstract_mapping* ifcopenshell::geom::impl::mapping_factory_implementation::construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& log) { + return mapping_registry_instance().construct(file, settings, log); } diff --git a/src/ifcgeom/abstract_mapping.h b/src/ifcgeom/abstract_mapping.h index 5ad8b2c6cc..5912d52769 100644 --- a/src/ifcgeom/abstract_mapping.h +++ b/src/ifcgeom/abstract_mapping.h @@ -33,46 +33,46 @@ namespace ifcopenshell { -namespace geometry { +namespace geom { struct IFC_GEOM_API geometry_conversion_task { int index; - express::Base representation; - std::vector products; + express::base representation; + std::vector products; }; /// The filter function (free or member function) or function object (use boost::ref() to reference to it) /// should return true if the geometry for the product is wanted to be included in the output. /// http://www.boost.org/doc/libs/1_62_0/doc/html/function/tutorial.html - typedef boost::function filter_t; + typedef boost::function filter_t; class IFC_GEOM_API abstract_mapping { protected: - Settings settings_; + ifcopenshell::geom::settings settings_; ::logger& logger_; bool use_caching_ = true; public: - abstract_mapping(Settings& s, ::logger& logger = ::logger::root()) : settings_(s), logger_(logger) {} + abstract_mapping(ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) : settings_(settings), logger_(logger) {} virtual ~abstract_mapping() {} - virtual ifcopenshell::geometry::taxonomy::ptr map(const express::Base&) = 0; + virtual ifcopenshell::geom::taxonomy::ptr map(const express::base&) = 0; virtual void get_representations(std::vector& tasks, std::vector& filters) = 0; - virtual express::Base get_decomposing_entity(const express::Base& product, bool include_openings = true) = 0; - virtual std::map get_layers(const express::Base&) = 0; - virtual std::vector find_openings(const express::Base&) = 0; + virtual express::base get_decomposing_entity(const express::base& product, bool include_openings = true) = 0; + virtual std::map get_layers(const express::base&) = 0; + virtual std::vector find_openings(const express::base&) = 0; virtual void initialize_settings() = 0; - virtual bool get_layerset_information(const express::Base&, layerset_information&, int&) = 0; - virtual bool get_wall_neighbours(const express::Base&, std::vector&) = 0; - virtual const express::Base get_product_type(const express::Base&) = 0; - virtual const express::Base get_single_material_association(const express::Base&) = 0; + virtual bool get_layerset_information(const express::base&, layerset_information&, int&) = 0; + virtual bool get_wall_neighbours(const express::base&, std::vector&) = 0; + virtual const express::base get_product_type(const express::base&) = 0; + virtual const express::base get_single_material_association(const express::base&) = 0; virtual double get_length_unit() const = 0; virtual const std::string& get_length_unit_name() const = 0; - virtual express::Base representation_of(const express::Base& product) = 0; + virtual express::base representation_of(const express::base& product) = 0; - const Settings& settings() const { return settings_; } - Settings& settings() { return settings_; } + const ifcopenshell::geom::settings& settings() const { return settings_; } + ifcopenshell::geom::settings& settings() { return settings_; } ::logger& logger() const { return logger_; } bool use_caching() const { return use_caching_; } @@ -80,12 +80,12 @@ namespace geometry { }; namespace impl { - typedef boost::function3 mapping_fn; + typedef boost::function3 mapping_fn; class IFC_GEOM_API mapping_registry { public: void bind(const std::string& schema_name, mapping_fn fn, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module()); - abstract_mapping* construct(ifcopenshell::file* file, Settings& settings, ::logger& logger = ::logger::root()); + abstract_mapping* construct(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()); private: struct entry { @@ -98,14 +98,14 @@ namespace geometry { IFC_GEOM_API mapping_registry& mapping_registry_instance(); - class IFC_GEOM_API MappingFactoryImplementation { + class IFC_GEOM_API mapping_factory_implementation { public: - MappingFactoryImplementation(); + mapping_factory_implementation(); void bind(const std::string& schema_name, mapping_fn); - abstract_mapping* construct(ifcopenshell::file*, Settings&, ::logger& logger = ::logger::root()); + abstract_mapping* construct(ifcopenshell::file*, ifcopenshell::geom::settings&, ::logger& logger = ::logger::root()); }; - IFC_GEOM_API MappingFactoryImplementation& mapping_implementations(); + IFC_GEOM_API mapping_factory_implementation& mapping_implementations(); } } diff --git a/src/ifcgeom/function_item_evaluator.cpp b/src/ifcgeom/function_item_evaluator.cpp index 4e8b890be8..0c55dab7f2 100644 --- a/src/ifcgeom/function_item_evaluator.cpp +++ b/src/ifcgeom/function_item_evaluator.cpp @@ -3,9 +3,9 @@ #include -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; -std::vector ifcopenshell::geometry::helmert_curve_point(double A0, double A1, double A2, double s) { +std::vector ifcopenshell::geom::helmert_curve_point(double A0, double A1, double A2, double s) { auto theta = [A0, A1, A2](double t) -> double { auto a0 = A0 ? t / A0 : 0.0; auto a1 = A1 ? A1 * std::pow(t, 2) / (2 * fabs(std::pow(A1, 3))) : 0.0; @@ -22,7 +22,7 @@ std::vector ifcopenshell::geometry::helmert_curve_point(double A0, doubl } struct functor_fn_evaluator : public fn_evaluator { - functor_fn_evaluator(taxonomy::functor_item::const_ptr fn, const ifcopenshell::geometry::Settings& settings) : fn_evaluator(settings), + functor_fn_evaluator(taxonomy::functor_item::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), fn_(fn) { } @@ -38,7 +38,7 @@ struct functor_fn_evaluator : public fn_evaluator { }; struct piecewise_fn_evaluator : public fn_evaluator { - piecewise_fn_evaluator(taxonomy::piecewise_function::const_ptr fn, const ifcopenshell::geometry::Settings& settings) : fn_evaluator(settings), + piecewise_fn_evaluator(taxonomy::piecewise_function::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), fn_(fn) { } @@ -69,7 +69,7 @@ struct piecewise_fn_evaluator : public fn_evaluator { double span_start = s; for (auto& fn : fn_->spans()) { double span_end = span_start + fn->length(); - auto tolerance = settings_.get().get(); + auto tolerance = settings_.get().get(); if (span_start <= u && u < span_end + tolerance) { return {span_start, span_end, fn}; } @@ -87,7 +87,7 @@ struct piecewise_fn_evaluator : public fn_evaluator { }; struct gradient_fn_evaluator : public fn_evaluator { - gradient_fn_evaluator(taxonomy::gradient_function::const_ptr fn, const ifcopenshell::geometry::Settings& settings) : + gradient_fn_evaluator(taxonomy::gradient_function::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), fn_(fn), horizontal_evaluator_(settings, fn->get_horizontal()), @@ -120,7 +120,7 @@ struct gradient_fn_evaluator : public fn_evaluator { }; struct cant_fn_evaluator : public fn_evaluator { - cant_fn_evaluator(taxonomy::cant_function::const_ptr fn, const ifcopenshell::geometry::Settings& settings) : fn_evaluator(settings), + cant_fn_evaluator(taxonomy::cant_function::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), fn_(fn), gradient_evaluator_(settings, fn->get_gradient()), cant_evaluator_(settings, fn->get_cant()) { @@ -184,7 +184,7 @@ struct cant_fn_evaluator : public fn_evaluator { }; struct offset_fn_evaluator : public fn_evaluator { - offset_fn_evaluator(taxonomy::offset_function::const_ptr fn, const ifcopenshell::geometry::Settings& settings) : fn_evaluator(settings), + offset_fn_evaluator(taxonomy::offset_function::const_ptr fn, const ifcopenshell::geom::settings& settings) : fn_evaluator(settings), fn_(fn), basis_evaluator_(settings, fn->get_basis()), offset_evaluator_(settings, fn->get_offset()) { @@ -208,7 +208,7 @@ struct offset_fn_evaluator : public fn_evaluator { -function_item_evaluator::function_item_evaluator(const ifcopenshell::geometry::Settings& settings,taxonomy::function_item::const_ptr fn, logger& logger) : logger_(logger) { +function_item_evaluator::function_item_evaluator(const ifcopenshell::geom::settings& settings,taxonomy::function_item::const_ptr fn, logger& logger) : logger_(logger) { auto kind = fn ? fn->kind() : taxonomy::kinds::NODE; if (kind == taxonomy::FUNCTOR_ITEM) { fn_evaluator_ = new functor_fn_evaluator(std::dynamic_pointer_cast(fn),settings); @@ -238,10 +238,10 @@ std::vector function_item_evaluator::evaluation_points() const { if (!eval_points_.has_value()) { double curve_length = fn_evaluator_->length(); - auto param_type = fn_evaluator_->settings_.get().get(); - auto param = fn_evaluator_->settings_.get().get(); + auto param_type = fn_evaluator_->settings_.get().get(); + auto param = fn_evaluator_->settings_.get().get(); unsigned num_steps = 0; - if (param_type == ifcopenshell::geometry::settings::FunctionStepMethod::MAXSTEPSIZE) { + if (param_type == ifcopenshell::geom::settings::FunctionStepMethod::MAXSTEPSIZE) { // parameter is max step size num_steps = (unsigned)std::ceil(curve_length / param); } else { @@ -298,7 +298,7 @@ Eigen::Matrix4d function_item_evaluator::evaluate(double u) const { throw std::runtime_error("Function item not initialized"); } Eigen::Matrix4d m = fn_evaluator_->evaluate(u); - if (!fn_evaluator_->settings_.get().get()) { + if (!fn_evaluator_->settings_.get().get()) { m.row(3) = Eigen::Vector4d(0, 0, 0, 1); } return m; diff --git a/src/ifcgeom/function_item_evaluator.h b/src/ifcgeom/function_item_evaluator.h index e700da14a0..3aebdbb423 100644 --- a/src/ifcgeom/function_item_evaluator.h +++ b/src/ifcgeom/function_item_evaluator.h @@ -5,7 +5,7 @@ #include -namespace ifcopenshell { namespace geometry { +namespace ifcopenshell { namespace geom { /// @brief Computes a point on a helmert curve at s. /// Returns (x,y,theta) at L/2. The results are in a vector so they can be returned to python @@ -18,12 +18,12 @@ IFC_GEOM_API std::vector helmert_curve_point(double A0, double A1, doubl /// @param loop /// @return static taxonomy::function_item::ptr convert_loop_to_function_item(taxonomy::loop::ptr loop) { - return ifcopenshell::geometry::taxonomy::dcast(loop); + return ifcopenshell::geom::taxonomy::dcast(loop); } /// @brief Abstract class for evaluating a function_item. This class is specialized for each of the function_item types. struct IFC_GEOM_API fn_evaluator { - fn_evaluator(const ifcopenshell::geometry::Settings& settings, logger& logger = ::logger::root()) : settings_(settings), logger_(logger) { + fn_evaluator(const ifcopenshell::geom::settings& settings, logger& logger = ::logger::root()) : settings_(settings), logger_(logger) { } fn_evaluator(const fn_evaluator& other) = default; virtual ~fn_evaluator() = default; @@ -35,7 +35,7 @@ struct IFC_GEOM_API fn_evaluator { virtual double end() const = 0; double length() const { return end() - start(); } - ifcopenshell::geometry::Settings settings_; + ifcopenshell::geom::settings settings_; protected: logger& logger_; @@ -44,7 +44,7 @@ struct IFC_GEOM_API fn_evaluator { /// @brief utility class to evaluate function_item objects. class IFC_GEOM_API function_item_evaluator { public: - function_item_evaluator(const ifcopenshell::geometry::Settings& settings, taxonomy::function_item::const_ptr fn, logger& logger = ::logger::root()); + function_item_evaluator(const ifcopenshell::geom::settings& settings, taxonomy::function_item::const_ptr fn, logger& logger = ::logger::root()); function_item_evaluator(const function_item_evaluator& other); ~function_item_evaluator(); @@ -85,4 +85,4 @@ class IFC_GEOM_API function_item_evaluator { }} -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/hybrid_kernel.h b/src/ifcgeom/hybrid_kernel.h index 14582e95ff..3df76be305 100644 --- a/src/ifcgeom/hybrid_kernel.h +++ b/src/ifcgeom/hybrid_kernel.h @@ -24,18 +24,18 @@ #include "kernel_registry.h" namespace ifcopenshell { - namespace geometry { + namespace geom { namespace kernels { - class HybridKernel : public ifcopenshell::geometry::kernels::AbstractKernel { - std::vector> kernels_; - ifcopenshell::geometry::abstract_mapping* mapping_; + class hybrid_kernel : public ifcopenshell::geom::kernels::abstract_kernel { + std::vector> kernels_; + ifcopenshell::geom::abstract_mapping* mapping_; ifcopenshell::file* file_; public: - HybridKernel(const std::string& name, ifcopenshell::file* file, Settings& settings, std::vector>&& kernels, ::logger& logger = ::logger::root()) - : AbstractKernel(name, settings, logger) + hybrid_kernel(const std::string& name, ifcopenshell::file* file, ifcopenshell::geom::settings& settings, std::vector>&& kernels, ::logger& logger = ::logger::root()) + : abstract_kernel(name, settings, logger) , kernels_(std::move(kernels)) - , mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings, logger)) + , mapping_(ifcopenshell::geom::impl::mapping_implementations().construct(file, settings, logger)) , file_(file) { } @@ -48,7 +48,7 @@ namespace ifcopenshell { } return false; } - virtual bool convert(const taxonomy::ptr item, IfcGeom::ConversionResults& rs) + virtual bool convert(const taxonomy::ptr item, ifcopenshell::geom::conversion_results& rs) { auto ops = mapping_->find_openings(item->instance); bool has_openings = ops.size(); @@ -77,7 +77,7 @@ namespace ifcopenshell { } return false; } - virtual bool apply_layerset(IfcGeom::ConversionResults& items, const ifcopenshell::geometry::layerset_information& layers) + virtual bool apply_layerset(ifcopenshell::geom::conversion_results& items, const ifcopenshell::geom::layerset_information& layers) { for (auto& k : kernels_) { bool success = false; @@ -90,7 +90,7 @@ namespace ifcopenshell { } return false; } - virtual bool apply_folded_layerset(IfcGeom::ConversionResults& items, const ifcopenshell::geometry::layerset_information& layers, const std::map& folds) + virtual bool apply_folded_layerset(ifcopenshell::geom::conversion_results& items, const ifcopenshell::geom::layerset_information& layers, const std::map& folds) { for (auto& k : kernels_) { bool success = false; @@ -103,8 +103,8 @@ namespace ifcopenshell { } return false; } - virtual bool convert_openings(const express::Base& entity, const std::vector>& openings, - const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) + virtual bool convert_openings(const express::base& entity, const std::vector>& openings, + const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes) { for (auto& k : kernels_) { bool is_valid = true; @@ -127,14 +127,14 @@ namespace ifcopenshell { } return false; } - virtual AbstractKernel* clone(::logger& logger) const + virtual abstract_kernel* clone(::logger& logger) const { - std::vector> ks; + std::vector> ks; for (auto& k : kernels_) { ks.emplace_back(k->clone(logger)); } // @todo ugly - return new HybridKernel(geometry_library(), file_, const_cast(settings()), std::move(ks), logger); + return new hybrid_kernel(geometry_library(), file_, const_cast(settings()), std::move(ks), logger); } }; } diff --git a/src/ifcgeom/infra_sweep_helper.cpp b/src/ifcgeom/infra_sweep_helper.cpp index ca30092df8..6b12c6177f 100644 --- a/src/ifcgeom/infra_sweep_helper.cpp +++ b/src/ifcgeom/infra_sweep_helper.cpp @@ -4,7 +4,7 @@ #include -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; namespace { // std::lerp when upgrading to C++ 20 @@ -35,7 +35,7 @@ bool has_intersection(const std::set& A, } -taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, const express::Base inst, const taxonomy::function_item::ptr& fn, std::vector& cross_sections, logger& logger) +taxonomy::loft::ptr ifcopenshell::geom::make_loft(const ifcopenshell::geom::settings& settings, const express::base inst, const taxonomy::function_item::ptr& fn, std::vector& cross_sections, logger& logger) { std::sort(cross_sections.begin(), cross_sections.end()); @@ -46,7 +46,7 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, // @todo currently only the case is handled where directrix returns a function_item // @todo this "if" statement is not really required because the function returns at the start if the Directrix is not a function_item function if (fn) { - function_item_evaluator evaluator(settings_, fn); + function_item_evaluator evaluator(settings, fn); double start = std::max(0., cross_sections.front().dist_along); double end = std::min(fn->length(), cross_sections.back().dist_along); @@ -56,10 +56,10 @@ taxonomy::loft::ptr ifcopenshell::geometry::make_loft(const Settings& settings_, } auto curve_length = end - start; - auto param_type = settings_.get().get(); - auto param = settings_.get().get(); + auto param_type = settings.get().get(); + auto param = settings.get().get(); size_t num_steps = 0; - if (param_type == ifcopenshell::geometry::settings::FunctionStepMethod::MAXSTEPSIZE) { + if (param_type == ifcopenshell::geom::settings::FunctionStepMethod::MAXSTEPSIZE) { // parameter is max step size num_steps = (size_t)std::ceil(curve_length / param); } else { diff --git a/src/ifcgeom/infra_sweep_helper.h b/src/ifcgeom/infra_sweep_helper.h index 296206d18d..ff4aed4584 100644 --- a/src/ifcgeom/infra_sweep_helper.h +++ b/src/ifcgeom/infra_sweep_helper.h @@ -8,7 +8,7 @@ namespace ifcopenshell { - namespace geometry { + namespace geom { struct IFC_GEOM_API cross_section { double dist_along; @@ -21,9 +21,9 @@ namespace ifcopenshell { } }; - IFC_GEOM_API taxonomy::loft::ptr make_loft(const Settings& settings_, const express::Base inst, const taxonomy::function_item::ptr& directrix, std::vector& cross_sections, logger& logger = ::logger::root()); + IFC_GEOM_API taxonomy::loft::ptr make_loft(const ifcopenshell::geom::settings& settings, const express::base inst, const taxonomy::function_item::ptr& directrix, std::vector& cross_sections, logger& logger = ::logger::root()); } } -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/kernel_plugin.cpp b/src/ifcgeom/kernel_plugin.cpp index 53128a9bc1..00f9d03122 100644 --- a/src/ifcgeom/kernel_plugin.cpp +++ b/src/ifcgeom/kernel_plugin.cpp @@ -40,22 +40,22 @@ namespace { } } -const char* ifcopenshell::geometry::kernels::kernel_plugin_registration_symbol() { +const char* ifcopenshell::geom::kernels::kernel_plugin_registration_symbol() { return "ifcopenshell_register_kernel_plugin_v1"; } -ifcopenshell::plugin::metadata ifcopenshell::geometry::kernels::kernel_plugin_metadata(const std::string& plugin_name) { +ifcopenshell::plugin::metadata ifcopenshell::geom::kernels::kernel_plugin_metadata(const std::string& plugin_name) { plugin::metadata metadata; metadata.kind_ = plugin::kind::kernel; metadata.id = kernel_plugin_prefix + plugin_name; return metadata; } -std::filesystem::path ifcopenshell::geometry::kernels::kernel_plugin_directory() { - return plugin::module_directory(reinterpret_cast(&ifcopenshell::geometry::kernels::load_kernel_plugins)); +std::filesystem::path ifcopenshell::geom::kernels::kernel_plugin_directory() { + return plugin::module_directory(reinterpret_cast(&ifcopenshell::geom::kernels::load_kernel_plugins)); } -void ifcopenshell::geometry::kernels::load_kernel_plugins(kernel_registry& registry) { +void ifcopenshell::geom::kernels::load_kernel_plugins(kernel_registry& registry) { plugin::manager manager; plugin::add_search_paths_or_default(manager, &kernel_plugin_directory); @@ -70,7 +70,7 @@ void ifcopenshell::geometry::kernels::load_kernel_plugins(kernel_registry& regis } } -bool ifcopenshell::geometry::kernels::load_kernel_plugin(kernel_registry& registry, const std::string& backend_id) { +bool ifcopenshell::geom::kernels::load_kernel_plugin(kernel_registry& registry, const std::string& backend_id) { plugin::manager manager; plugin::add_search_paths_or_default(manager, &kernel_plugin_directory); diff --git a/src/ifcgeom/kernel_plugin.h b/src/ifcgeom/kernel_plugin.h index ca133d310c..33b16ed015 100644 --- a/src/ifcgeom/kernel_plugin.h +++ b/src/ifcgeom/kernel_plugin.h @@ -25,7 +25,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace kernels { typedef void register_kernel_plugin_fn(kernel_registry&, const ifcopenshell::plugin::module&); diff --git a/src/ifcgeom/kernel_registry.cpp b/src/ifcgeom/kernel_registry.cpp index 79f8e9acef..e19b4b36e1 100644 --- a/src/ifcgeom/kernel_registry.cpp +++ b/src/ifcgeom/kernel_registry.cpp @@ -47,9 +47,9 @@ namespace { return !prefix.empty() && text.rfind(prefix, 0) == 0; } - void register_kernel_module(ifcopenshell::geometry::kernels::kernel_registry& registry, const ifcopenshell::plugin::module& module) { - auto register_plugin = module.get_alias( - ifcopenshell::geometry::kernels::kernel_plugin_registration_symbol()); + void register_kernel_module(ifcopenshell::geom::kernels::kernel_registry& registry, const ifcopenshell::plugin::module& module) { + auto register_plugin = module.get_alias( + ifcopenshell::geom::kernels::kernel_plugin_registration_symbol()); register_plugin(registry, module); } @@ -59,7 +59,7 @@ namespace { bool has_module = false; }; - void consider_kernel_info(kernel_match& match, const std::string& geometry_library_lower, const ifcopenshell::geometry::kernels::kernel_info& info) { + void consider_kernel_info(kernel_match& match, const std::string& geometry_library_lower, const ifcopenshell::geom::kernels::kernel_info& info) { const auto backend_id = kernel_key(info.backend_id); if (is_prefix(geometry_library_lower, backend_id) && backend_id.size() > match.backend_id.size()) { match.backend_id = backend_id; @@ -67,7 +67,7 @@ namespace { } } - kernel_match find_kernel_match(ifcopenshell::geometry::kernels::kernel_registry& registry, const std::string& geometry_library_lower) { + kernel_match find_kernel_match(ifcopenshell::geom::kernels::kernel_registry& registry, const std::string& geometry_library_lower) { kernel_match match; for (const auto& info : registry.kernels()) { @@ -75,7 +75,7 @@ namespace { } ifcopenshell::plugin::manager manager; - ifcopenshell::plugin::add_search_paths_or_default(manager, &ifcopenshell::geometry::kernels::kernel_plugin_directory); + ifcopenshell::plugin::add_search_paths_or_default(manager, &ifcopenshell::geom::kernels::kernel_plugin_directory); for (const auto& path : manager.discover(kernel_plugin_prefix)) { ifcopenshell::plugin::module module; try { @@ -92,7 +92,7 @@ namespace { continue; } - ifcopenshell::geometry::kernels::kernel_registry plugin_registry; + ifcopenshell::geom::kernels::kernel_registry plugin_registry; register_kernel_module(plugin_registry, module); for (const auto& info : plugin_registry.kernels()) { const auto backend_id = kernel_key(info.backend_id); @@ -112,7 +112,7 @@ namespace { } } -void ifcopenshell::geometry::kernels::kernel_registry::bind(const kernel_info& info, create_fn create, const plugin::module& module) { +void ifcopenshell::geom::kernels::kernel_registry::bind(const kernel_info& info, create_fn create, const plugin::module& module) { entry entry; entry.info_ = info; entry.create_ = create; @@ -120,19 +120,19 @@ void ifcopenshell::geometry::kernels::kernel_registry::bind(const kernel_info& i entries_[kernel_key(info.backend_id)] = entry; } -bool ifcopenshell::geometry::kernels::kernel_registry::has(const std::string& backend_id) const { +bool ifcopenshell::geom::kernels::kernel_registry::has(const std::string& backend_id) const { return entries_.find(kernel_key(backend_id)) != entries_.end(); } -std::unique_ptr ifcopenshell::geometry::kernels::kernel_registry::create(const std::string& backend_id, ifcopenshell::file* file, Settings& settings) const { +std::unique_ptr ifcopenshell::geom::kernels::kernel_registry::create(const std::string& backend_id, ifcopenshell::file* file, ifcopenshell::geom::settings& settings) const { const auto iter = entries_.find(kernel_key(backend_id)); if (iter == entries_.end()) { throw ifcopenshell::exception("No geometry kernel registered for " + backend_id); } - return std::unique_ptr(iter->second.create_(file, settings)); + return std::unique_ptr(iter->second.create_(file, settings)); } -std::vector ifcopenshell::geometry::kernels::kernel_registry::kernels() const { +std::vector ifcopenshell::geom::kernels::kernel_registry::kernels() const { std::vector result; for (const auto& pair : entries_) { result.push_back(pair.second.info_); @@ -140,12 +140,12 @@ std::vector ifcopenshell::geometry return result; } -ifcopenshell::geometry::kernels::kernel_registry& ifcopenshell::geometry::kernels::kernel_registry_instance() { +ifcopenshell::geom::kernels::kernel_registry& ifcopenshell::geom::kernels::kernel_registry_instance() { static kernel_registry registry; return registry; } -std::unique_ptr ifcopenshell::geometry::kernels::construct(ifcopenshell::file* file, const std::string& geometry_library, Settings& settings) { +std::unique_ptr ifcopenshell::geom::kernels::construct(ifcopenshell::file* file, const std::string& geometry_library, ifcopenshell::geom::settings& settings) { auto geometry_library_lower = boost::to_lower_copy(geometry_library); auto& registry = kernel_registry_instance(); @@ -158,7 +158,7 @@ std::unique_ptr ifcopenshell::g if (geometry_library_lower.rfind("hybrid-", 0) == 0) { geometry_library_lower = geometry_library_lower.substr(strlen("hybrid")); - std::vector> kernels; + std::vector> kernels; while (!geometry_library_lower.empty()) { if (geometry_library_lower.find("-", 0) == 0) { geometry_library_lower = geometry_library_lower.substr(strlen("-")); @@ -183,7 +183,7 @@ std::unique_ptr ifcopenshell::g } if (!kernels.empty()) { - return std::make_unique(geometry_library, file, settings, std::move(kernels)); + return std::make_unique(geometry_library, file, settings, std::move(kernels)); } } diff --git a/src/ifcgeom/kernel_registry.h b/src/ifcgeom/kernel_registry.h index ec36969019..bdc5265e98 100644 --- a/src/ifcgeom/kernel_registry.h +++ b/src/ifcgeom/kernel_registry.h @@ -33,7 +33,7 @@ namespace ifcopenshell { class file; - namespace geometry { + namespace geom { namespace kernels { struct IFC_GEOM_API kernel_info { @@ -43,11 +43,11 @@ namespace ifcopenshell { class IFC_GEOM_API kernel_registry { public: - typedef boost::function2 create_fn; + typedef boost::function2 create_fn; void bind(const kernel_info& info, create_fn create, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module()); bool has(const std::string& backend_id) const; - std::unique_ptr create(const std::string& backend_id, ifcopenshell::file* file, Settings& settings) const; + std::unique_ptr create(const std::string& backend_id, ifcopenshell::file* file, ifcopenshell::geom::settings& settings) const; std::vector kernels() const; private: @@ -61,7 +61,7 @@ namespace ifcopenshell { }; IFC_GEOM_API kernel_registry& kernel_registry_instance(); - IFC_GEOM_API std::unique_ptr construct(ifcopenshell::file* file, const std::string& geometry_library, Settings& settings); + IFC_GEOM_API std::unique_ptr construct(ifcopenshell::file* file, const std::string& geometry_library, ifcopenshell::geom::settings& settings); } } diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp index a193b13596..858966d4bc 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp @@ -9,27 +9,27 @@ #include "../../../ifcparse/logger.h" #include "../../../ifcgeom/IfcGeomRepresentation.h" -using IfcGeom::OpaqueNumber; -using IfcGeom::OpaqueCoordinate; -using IfcGeom::ConversionResultShape; +using ifcopenshell::geom::opaque_number; +using ifcopenshell::geom::opaque_coordinate; +using ifcopenshell::geom::conversion_result_shape; #ifdef IFOPSH_SIMPLE_KERNEL -#define NumberType OpaqueNumber +#define NumberType opaque_number #else -using ifcopenshell::geometry::NumberEpeck; -#define NumberType NumberEpeck +using ifcopenshell::geom::number_epeck; +#define NumberType number_epeck #endif #ifdef IFOPSH_SIMPLE_KERNEL -#define CgalShape SimpleCgalShape +#define cgal_shape SimpleCgalShape #endif -typedef CGAL::Polyhedron_3 Polyhedron; -typedef Polyhedron::Facet_const_handle Facet_const_handle; -typedef Polyhedron::Halfedge_around_facet_const_circulator Halfedge_around_facet_circulator; +typedef CGAL::Polyhedron_3 polyhedron; +typedef polyhedron::Facet_const_handle facet_const_handle; +typedef polyhedron::Halfedge_around_facet_const_circulator halfedge_around_facet_circulator; namespace { - cgal_placement_t make_transform(const ifcopenshell::geometry::taxonomy::matrix4& place) { + cgal_placement_t make_transform(const ifcopenshell::geom::taxonomy::matrix4& place) { const auto& m = place.ccomponents(); return cgal_placement_t( m(0, 0), m(0, 1), m(0, 2), m(0, 3), @@ -37,39 +37,39 @@ namespace { m(2, 0), m(2, 1), m(2, 2), m(2, 3)); } - OpaqueCoordinate<3> opaque_point(const cgal_point_t& p) { - return OpaqueCoordinate<3>( + opaque_coordinate<3> opaque_point(const cgal_point_t& p) { + return opaque_coordinate<3>( NumberType(p.cartesian(0)), NumberType(p.cartesian(1)), NumberType(p.cartesian(2)) ); } - typename Kernel_::FT max_abs3(const typename Kernel_::FT& a, const typename Kernel_::FT& b, const typename Kernel_::FT& c) { - std::array abc{ a, b, c }; + typename kernel_::FT max_abs3(const typename kernel_::FT& a, const typename kernel_::FT& b, const typename kernel_::FT& c) { + std::array abc{ a, b, c }; auto minel = std::min_element(abc.begin(), abc.end()); auto maxel = std::max_element(abc.begin(), abc.end()); return ((-*minel) > *maxel) ? (-*minel) : *maxel; } - OpaqueCoordinate<3> opaque_axis(const cgal_vector_t& v) { + opaque_coordinate<3> opaque_axis(const cgal_vector_t& v) { auto maxval = max_abs3(v.x(), v.y(), v.z()); if (maxval == 0) { throw std::runtime_error("Invalid shape type"); } - return OpaqueCoordinate<3>( + return opaque_coordinate<3>( NumberType(v.x() / maxval), NumberType(v.y() / maxval), NumberType(v.z() / maxval) ); } - OpaqueCoordinate<4> opaque_plane(const cgal_plane_t& p) { + opaque_coordinate<4> opaque_plane(const cgal_plane_t& p) { auto maxval = max_abs3(p.a(), p.b(), p.c()); if (maxval == 0) { throw std::runtime_error("Invalid shape type"); } - return OpaqueCoordinate<4>( + return opaque_coordinate<4>( NumberType(p.a() / maxval), NumberType(p.b() / maxval), NumberType(p.c() / maxval), @@ -77,7 +77,7 @@ namespace { ); } - cgal_plane_t plane_from_opaque(const OpaqueCoordinate<4>& p) { + cgal_plane_t plane_from_opaque(const opaque_coordinate<4>& p) { #ifdef IFOPSH_SIMPLE_KERNEL return cgal_plane_t( p.get(0).to_double(), @@ -95,16 +95,16 @@ namespace { #endif } - void insert_normalized_plane_map(plane_map& mp, const OpaqueCoordinate<4>& from, const OpaqueCoordinate<4>& to) { + void insert_normalized_plane_map(plane_map& mp, const opaque_coordinate<4>& from, const opaque_coordinate<4>& to) { mp.insert({ - normalized_plane_for_map(plane_from_opaque(from)), - normalized_plane_for_map(plane_from_opaque(to)) + normalized_plane_for_map(plane_from_opaque(from)), + normalized_plane_for_map(plane_from_opaque(to)) }); } - void apply_normalized_plane_map(const plane_map& mp, std::list& planes) { + void apply_normalized_plane_map(const plane_map& mp, std::list& planes) { for (auto& plane : planes) { - auto it = mp.find(normalized_plane_for_map(plane)); + auto it = mp.find(normalized_plane_for_map(plane)); if (it != mp.end()) { plane = it->second; } @@ -112,7 +112,7 @@ namespace { } cgal_vector_t wire_normal(const cgal_wire_t& wire) { - typename Kernel_::FT a(0), b(0), c(0); + typename kernel_::FT a(0), b(0), c(0); if (wire.size() < 3) { return cgal_vector_t(a, b, c); } @@ -130,32 +130,32 @@ namespace { if (wire.empty()) { throw std::runtime_error("Invalid shape type"); } - std::array p{ Kernel_::FT(0), Kernel_::FT(0), Kernel_::FT(0) }; + std::array p{ kernel_::FT(0), kernel_::FT(0), kernel_::FT(0) }; for (const auto& point : wire) { for (int i = 0; i < 3; ++i) { p[i] += point.cartesian(i); } } - Kernel_::FT n(wire.size()); + kernel_::FT n(wire.size()); return cgal_point_t(p[0] / n, p[1] / n, p[2] / n); } - Kernel_::FT wire_length(const cgal_wire_t& wire) { - Kernel_::FT len(0); + kernel_::FT wire_length(const cgal_wire_t& wire) { + kernel_::FT len(0); if (wire.size() < 2) { return len; } for (std::size_t i = 1; i < wire.size(); ++i) { - len += CGAL::approximate_sqrt(CGAL::Segment_3(wire[i - 1], wire[i]).squared_length()); + len += CGAL::approximate_sqrt(CGAL::Segment_3(wire[i - 1], wire[i]).squared_length()); } if (wire.size() > 2) { - len += CGAL::approximate_sqrt(CGAL::Segment_3(wire.back(), wire.front()).squared_length()); + len += CGAL::approximate_sqrt(CGAL::Segment_3(wire.back(), wire.front()).squared_length()); } return len; } - Kernel_::FT wire_area(const cgal_wire_t& wire) { - Kernel_::FT area(0); + kernel_::FT wire_area(const cgal_wire_t& wire) { + kernel_::FT area(0); if (wire.size() < 3) { return area; } @@ -163,7 +163,7 @@ namespace { for (std::size_t i = 1; i + 1 < wire.size(); ++i) { auto v1 = wire[i] - origin; auto v2 = wire[i + 1] - origin; - area += CGAL::approximate_sqrt(CGAL::cross_product(v1, v2).squared_length()) / Kernel_::FT(2); + area += CGAL::approximate_sqrt(CGAL::cross_product(v1, v2).squared_length()) / kernel_::FT(2); } return area; } @@ -198,9 +198,9 @@ namespace { } template - CGAL::Direction_3 newell(Facet& face) { - typename Kernel_::FT a(0), b(0), c(0); - CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = face.facet_begin(); + CGAL::Direction_3 newell(Facet& face) { + typename kernel_::FT a(0), b(0), c(0); + CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = face.facet_begin(); do { auto& curr = current_halfedge->vertex()->point(); auto& next = current_halfedge->next()->vertex()->point(); @@ -208,10 +208,10 @@ namespace { b += (curr.z() - next.z()) * (curr.x() + next.x()); c += (curr.x() - next.x()) * (curr.y() + next.y()); } while (++current_halfedge != face.facet_begin()); - return CGAL::Direction_3(a, b, c); + return CGAL::Direction_3(a, b, c); } - struct Plane_equation { + struct facet_plane_equation { template typename Facet::Plane_3 operator()(Facet& face) { typename Facet::Halfedge_handle h = face.halfedge(); @@ -219,7 +219,7 @@ namespace { } }; - bool are_facets_coplanar(const Facet_const_handle& f1, const Facet_const_handle& f2) { + bool are_facets_coplanar(const facet_const_handle& f1, const facet_const_handle& f2) { auto normal_1 = CGAL::normal(f1->halfedge()->vertex()->point(), f1->halfedge()->next()->vertex()->point(), f1->halfedge()->next()->next()->vertex()->point()); @@ -231,9 +231,9 @@ namespace { return CGAL::collinear(CGAL::ORIGIN + decltype(normal_1)(0., 0., 0.), CGAL::ORIGIN + normal_1, CGAL::ORIGIN + normal_2); } - void partition_coplanar_components(const Polyhedron& shape, - std::vector>& components) { - std::set visited; + void partition_coplanar_components(const polyhedron& shape, + std::vector>& components) { + std::set visited; for (auto& face : shape.facet_handles()) { if (visited.find(face) != visited.end()) { @@ -242,20 +242,20 @@ namespace { components.emplace_back(); auto& component = components.back(); - std::queue queue; + std::queue queue; queue.push(face); visited.insert(face); while (!queue.empty()) { - Facet_const_handle current = queue.front(); + facet_const_handle current = queue.front(); queue.pop(); component.insert(current); - Halfedge_around_facet_circulator he = current->facet_begin(); + halfedge_around_facet_circulator he = current->facet_begin(); do { - Facet_const_handle neighbour = he->opposite()->face(); + facet_const_handle neighbour = he->opposite()->face(); if (visited.find(neighbour) == visited.end() && neighbour != nullptr && visited.find(neighbour) == visited.end() && are_facets_coplanar(current, neighbour)) { queue.push(neighbour); visited.insert(neighbour); @@ -266,7 +266,7 @@ namespace { } } -ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool convex, ::logger& logger) { +ifcopenshell::geom::cgal_shape::cgal_shape(const cgal_shape_t& shape, bool convex, ::logger& logger) { shape_ = shape; convex_tag_ = convex; auto& poly = std::get(*shape_); @@ -275,7 +275,7 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con for (const auto& face : CGAL::faces(poly)) { auto V = newell(*face).to_vector(); - CGAL::Plane_3 plane(CGAL::Point_3(), V); + CGAL::Plane_3 plane(CGAL::Point_3(), V); auto b1 = plane.base1(); auto b2 = plane.base2(); @@ -287,20 +287,20 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con auto C = face->halfedge()->vertex()->point(); auto transform_point = [&V, &C, &b1, &b2](const auto& p) { auto dv = p - C; - return CGAL::Point_2( + return CGAL::Point_2( dv * b1, dv * b2 ); }; - std::vector> ps; + std::vector> ps; for (auto& he1 : CGAL::halfedges_around_face(face->halfedge(), poly)) { const auto& source = he1->vertex()->point(); ps.push_back(transform_point(source)); } - if (!CGAL::Polygon_2(ps.begin(), ps.end()).is_simple()) { + if (!CGAL::Polygon_2(ps.begin(), ps.end()).is_simple()) { logger.warning("GEO", 63, "Removed face due to self-intersections"); faces_to_remove.insert(face); } @@ -313,17 +313,17 @@ ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t& shape, bool con } } -ifcopenshell::geometry::CgalShape::CgalShape(const cgal_point_t& point, bool convex) { +ifcopenshell::geom::cgal_shape::cgal_shape(const cgal_point_t& point, bool convex) { shape_ = point; convex_tag_ = convex; } -ifcopenshell::geometry::CgalShape::CgalShape(const cgal_wire_t& wire, bool convex) { +ifcopenshell::geom::cgal_shape::cgal_shape(const cgal_wire_t& wire, bool convex) { shape_ = wire; convex_tag_ = convex; } -const cgal_shape_t& ifcopenshell::geometry::CgalShape::poly() const { +const cgal_shape_t& ifcopenshell::geom::cgal_shape::poly() const { #ifndef IFOPSH_SIMPLE_KERNEL to_poly(); #endif @@ -334,7 +334,7 @@ const cgal_shape_t& ifcopenshell::geometry::CgalShape::poly() const { } #ifndef IFOPSH_SIMPLE_KERNEL -void ifcopenshell::geometry::CgalShape::to_poly() const { +void ifcopenshell::geom::cgal_shape::to_poly() const { if (!shape_) { cgal_shape_t poly; convert_to_polyhedron(*nef_, poly, std::numeric_limits::max()); @@ -348,7 +348,7 @@ void ifcopenshell::geometry::CgalShape::to_poly() const { } } -void ifcopenshell::geometry::CgalShape::to_nef() const { +void ifcopenshell::geom::cgal_shape::to_nef() const { if (!nef_) { auto shp = poly(); if (!convex_tag_) { @@ -362,7 +362,7 @@ void ifcopenshell::geometry::CgalShape::to_nef() const { } #endif -void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { +void ifcopenshell::geom::cgal_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { if (is_point() || is_wire()) { return; } @@ -381,9 +381,9 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett shape_to_use = const_cast(&base_shape); } - const bool setting_use_original_edges = settings.get().get(); + const bool setting_use_original_edges = settings.get().get(); - std::set> original_edges; + std::set> original_edges; if (setting_use_original_edges) { for (auto it = shape_to_use->edges_begin(); it != shape_to_use->edges_end(); ++it) { original_edges.insert({ it->vertex()->point(), it->prev()->vertex()->point() }); @@ -407,7 +407,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett std::optional smooth_treshold; { - auto setting_value = settings.get().get(); + auto setting_value = settings.get().get(); if (setting_value > 0.) { smooth_treshold = std::cos(setting_value * boost::math::constants::pi() / 180.0); } @@ -442,8 +442,8 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett // Facet -> planar component map for determining which // edges are to be registered. - std::vector> components; - std::map facet_to_component; + std::vector> components; + std::map facet_to_component; if (!setting_use_original_edges) { partition_coplanar_components(*shape_to_use, components); for (auto it = components.begin(); it != components.end(); ++it) { @@ -453,12 +453,12 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett } } - // std::map vertex_normals; - // boost::associative_property_map> vertex_normals_map(vertex_normals); + // std::map vertex_normals; + // boost::associative_property_map> vertex_normals_map(vertex_normals); // Triangulate the shape and compute the normals - std::map face_normals; - boost::associative_property_map> face_normals_map(face_normals); + std::map face_normals; + boost::associative_property_map> face_normals_map(face_normals); // CGAL::Polygon_mesh_processing::compute_normals(s, vertex_normals_map, face_normals_map); try { @@ -470,7 +470,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett // We do welding here in addition to in the triangulation item, because // CGAL does not have a concept of vertices with identity like OCCT has. - typedef std::tuple postion_normal; + typedef std::tuple postion_normal; std::map welds; std::set> registered_edges; @@ -481,9 +481,9 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett std::cout << "warning: non-triangular face!" << std::endl; continue; } - CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = face->facet_begin(); + CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = face->facet_begin(); - const Kernel_::Vector_3 facet_normal = face_normals_map[face]; + const kernel_::Vector_3 facet_normal = face_normals_map[face]; int vertexidx[3]; bool is_face_boundary[3]; @@ -494,7 +494,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett auto vertex_norm = facet_normal; if (smooth_treshold) { - Kernel_::Vector_3 normal_accum(0, 0, 0); + kernel_::Vector_3 normal_accum(0, 0, 0); { // circulator around the vertex auto vh_begin = v->vertex_begin(); @@ -502,7 +502,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett auto vh = vh_begin; do { if (!vh->is_border()) { - Facet_const_handle adj_f = vh->facet(); + facet_const_handle adj_f = vh->facet(); const auto fn2 = face_normals_map[adj_f]; if ((fn2 * facet_normal) >= *smooth_treshold) { normal_accum = normal_accum + fn2; @@ -584,7 +584,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett } -void ifcopenshell::geometry::CgalShape::Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string& r) const { +void ifcopenshell::geom::cgal_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { std::stringstream sstream; if (is_point()) { auto p = point(); @@ -617,7 +617,7 @@ void ifcopenshell::geometry::CgalShape::Serialize(const ifcopenshell::geometry:: #include -double ifcopenshell::geometry::CgalShape::bounding_box(void *& b) const { +double ifcopenshell::geom::cgal_shape::bounding_box(void *& b) const { if (b == nullptr) { b = new CGAL::Bbox_3; } @@ -634,7 +634,7 @@ double ifcopenshell::geometry::CgalShape::bounding_box(void *& b) const { return (bb.xmax() - bb.xmin()) * (bb.ymax() - bb.ymin()) * (bb.zmax() - bb.zmin()); } -int ifcopenshell::geometry::CgalShape::num_vertices() const { +int ifcopenshell::geom::cgal_shape::num_vertices() const { if (is_point()) { return 1; } @@ -644,14 +644,14 @@ int ifcopenshell::geometry::CgalShape::num_vertices() const { return (int) poly().size_of_vertices(); } -void ifcopenshell::geometry::CgalShape::set_box(void * b) { +void ifcopenshell::geom::cgal_shape::set_box(void * b) { auto& bb = (*((CGAL::Bbox_3*)b)); - Kernel_::Point_3 lower(bb.xmin(), bb.ymin(), bb.zmin()); - Kernel_::Point_3 upper(bb.xmax(), bb.ymax(), bb.zmax()); - shape_ = ifcopenshell::geometry::utils::create_cube(lower, upper); + kernel_::Point_3 lower(bb.xmin(), bb.ymin(), bb.zmin()); + kernel_::Point_3 upper(bb.xmax(), bb.ymax(), bb.zmax()); + shape_ = ifcopenshell::geom::utils::create_cube(lower, upper); } -int ifcopenshell::geometry::CgalShape::surface_genus() const { +int ifcopenshell::geom::cgal_shape::surface_genus() const { if (is_point() || is_wire()) { return 0; } @@ -666,12 +666,12 @@ int ifcopenshell::geometry::CgalShape::surface_genus() const { return (int) genus; } -bool ifcopenshell::geometry::CgalShape::is_manifold() const { +bool ifcopenshell::geom::cgal_shape::is_manifold() const { // @todo ? return (is_point() || is_wire()) ? true : poly().is_valid(); } -int ifcopenshell::geometry::CgalShape::num_edges() const +int ifcopenshell::geom::cgal_shape::num_edges() const { if (is_point()) { return 0; @@ -686,7 +686,7 @@ int ifcopenshell::geometry::CgalShape::num_edges() const return (int) poly().size_of_halfedges() / 2; } -int ifcopenshell::geometry::CgalShape::num_faces() const +int ifcopenshell::geom::cgal_shape::num_faces() const { #ifndef IFOPSH_SIMPLE_KERNEL if (nef_) { @@ -706,15 +706,15 @@ int ifcopenshell::geometry::CgalShape::num_faces() const } } -OpaqueNumber ifcopenshell::geometry::CgalShape::CgalShape::length() +opaque_number ifcopenshell::geom::cgal_shape::cgal_shape::length() { - Kernel_::FT len = 0; + kernel_::FT len = 0; if (is_wire()) { len = wire_length(wire()); } else if (!is_point()) { const auto& shp = poly(); for (auto it = shp.edges_begin(); it != shp.edges_end(); ++it) { - len += CGAL::approximate_sqrt(CGAL::Segment_3( + len += CGAL::approximate_sqrt(CGAL::Segment_3( it->vertex()->point(), it->opposite()->vertex()->point() ).squared_length()); @@ -723,30 +723,30 @@ OpaqueNumber ifcopenshell::geometry::CgalShape::CgalShape::length() return NumberType(len); } -OpaqueNumber ifcopenshell::geometry::CgalShape::area() +opaque_number ifcopenshell::geom::cgal_shape::area() { if (is_wire()) { return NumberType(wire_area(wire())); } if (is_point()) { - return NumberType(Kernel_::FT(0)); + return NumberType(kernel_::FT(0)); } auto s = poly(); CGAL::Polygon_mesh_processing::triangulate_faces(s); return NumberType(CGAL::Polygon_mesh_processing::area(s)); } -OpaqueNumber ifcopenshell::geometry::CgalShape::volume() +opaque_number ifcopenshell::geom::cgal_shape::volume() { if (is_point() || is_wire()) { - return NumberType(Kernel_::FT(0)); + return NumberType(kernel_::FT(0)); } auto s = poly(); CGAL::Polygon_mesh_processing::triangulate_faces(s); return NumberType(CGAL::Polygon_mesh_processing::volume(s)); } -OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position() +opaque_coordinate<3> ifcopenshell::geom::cgal_shape::position() { if (is_point()) { return opaque_point(point()); @@ -757,18 +757,18 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position() const auto& shp = poly(); if (shp.size_of_facets() == 1) { // return centroid; - // CGAL::Vector_3 p; - std::array p{ Kernel_::FT(0), Kernel_::FT(0), Kernel_::FT(0) }; + // CGAL::Vector_3 p; + std::array p{ kernel_::FT(0), kernel_::FT(0), kernel_::FT(0) }; for (auto it = shp.points_begin(); it != shp.points_end(); ++it) { for (int i = 0; i < 3; ++i) { p[i] += it->cartesian(i); } } - Kernel_::FT N(std::distance(shp.points_begin(), shp.points_end())); + kernel_::FT N(std::distance(shp.points_begin(), shp.points_end())); for (int i = 0; i < 3; ++i) { p[i] /= N; } - return OpaqueCoordinate<3>( + return opaque_coordinate<3>( NumberType(p[0]), NumberType(p[1]), NumberType(p[2]) @@ -778,7 +778,7 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position() } } -OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::axis() +opaque_coordinate<3> ifcopenshell::geom::cgal_shape::axis() { if (is_wire()) { if (wire().size() == 2) { @@ -791,32 +791,32 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::axis() } auto shp = poly(); if (shp.size_of_facets() == 1) { - auto pl = Plane_equation()(*shp.facets_begin()); + auto pl = facet_plane_equation()(*shp.facets_begin()); return opaque_axis(cgal_vector_t(pl.a(), pl.b(), pl.c())); } else { throw std::runtime_error("Invalid shape type"); } } -OpaqueCoordinate<4> ifcopenshell::geometry::CgalShape::plane_equation() +opaque_coordinate<4> ifcopenshell::geom::cgal_shape::plane_equation() { if (is_wire() && wire().size() >= 3) { auto normal = wire_normal(wire()); - return opaque_plane(cgal_plane_t(wire().front(), CGAL::Direction_3(normal))); + return opaque_plane(cgal_plane_t(wire().front(), CGAL::Direction_3(normal))); } auto shp = poly(); if (shp.size_of_facets() == 1) { - return opaque_plane(Plane_equation()(*shp.facets_begin())); + return opaque_plane(facet_plane_equation()(*shp.facets_begin())); } throw std::runtime_error("Invalid shape type"); } -std::vector ifcopenshell::geometry::CgalShape::convex_decomposition() +std::vector ifcopenshell::geom::cgal_shape::convex_decomposition() { #ifdef IFOPSH_SIMPLE_KERNEL throw std::runtime_error("Not implemented"); #else - std::vector result; + std::vector result; auto copy = nef(); CGAL::convex_decomposition_3(copy); // the first volume is the outer volume, which is @@ -828,89 +828,89 @@ std::vector ifcopenshell::geometry::CgalShape::convex_de if (ci->mark()) { // @todo couldn't get it to work with the multiple volumes of a complex decomposition // directly, so for now we need to isolate the individual volumes. - CGAL::Polyhedron_3 P; + CGAL::Polyhedron_3 P; copy.convert_inner_shell_to_polyhedron(ci->shells_begin(), P); - result.push_back(new CgalShape(P, /*convex=*/ true)); + result.push_back(new cgal_shape(P, /*convex=*/ true)); } } return result; #endif } -ConversionResultShape* ifcopenshell::geometry::CgalShape::halfspaces() +conversion_result_shape* ifcopenshell::geom::cgal_shape::halfspaces() { #ifdef IFOPSH_SIMPLE_KERNEL throw std::runtime_error("Not implemented"); #else - return new CgalShapeHalfSpaceDecomposition(nef(), convex_tag_); + return new cgal_shape_half_space_decomposition(nef(), convex_tag_); #endif } -ConversionResultShape* ifcopenshell::geometry::CgalShape::solid() +conversion_result_shape* ifcopenshell::geom::cgal_shape::solid() { throw std::runtime_error("Not implemented"); } -ConversionResultShape * ifcopenshell::geometry::CgalShape::box() +conversion_result_shape * ifcopenshell::geom::cgal_shape::box() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::CgalShape::wrap_in_compound() +conversion_result_shape* ifcopenshell::geom::cgal_shape::wrap_in_compound() { return clone(); } -std::vector ifcopenshell::geometry::CgalShape::vertices() +std::vector ifcopenshell::geom::cgal_shape::vertices() { - std::vector result; + std::vector result; if (is_point()) { - result.push_back(new CgalShape(point())); + result.push_back(new cgal_shape(point())); return result; } if (is_wire()) { for (const auto& p : wire()) { - result.push_back(new CgalShape(p)); + result.push_back(new cgal_shape(p)); } return result; } for (const auto& p : poly().points()) { - result.push_back(new CgalShape(p)); + result.push_back(new cgal_shape(p)); } return result; } -std::vector ifcopenshell::geometry::CgalShape::edges() +std::vector ifcopenshell::geom::cgal_shape::edges() { - std::vector result; + std::vector result; if (is_point()) { return result; } if (is_wire()) { const auto& w = wire(); for (std::size_t i = 1; i < w.size(); ++i) { - result.push_back(new CgalShape(cgal_wire_t{ w[i - 1], w[i] })); + result.push_back(new cgal_shape(cgal_wire_t{ w[i - 1], w[i] })); } if (w.size() > 2) { - result.push_back(new CgalShape(cgal_wire_t{ w.back(), w.front() })); + result.push_back(new cgal_shape(cgal_wire_t{ w.back(), w.front() })); } return result; } for (auto ed : poly().edges()) { - result.push_back(new CgalShape(cgal_wire_t{ ed.vertex()->point(), ed.opposite()->vertex()->point() })); + result.push_back(new cgal_shape(cgal_wire_t{ ed.vertex()->point(), ed.opposite()->vertex()->point() })); } return result; } -std::vector ifcopenshell::geometry::CgalShape::facets() +std::vector ifcopenshell::geom::cgal_shape::facets() { - std::vector result; + std::vector result; if (is_point()) { return result; } if (is_wire()) { if (wire().size() >= 3) { - result.push_back(new CgalShape(wire())); + result.push_back(new cgal_shape(wire())); } return result; } @@ -922,41 +922,41 @@ std::vector ifcopenshell::geometry::CgalShape::facets() ps.push_back(it->vertex()->point()); } while (++it != face->facet_begin()); - result.push_back(new CgalShape(ps)); + result.push_back(new cgal_shape(ps)); } return result; } -ConversionResultShape* ifcopenshell::geometry::CgalShape::add(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape::add(conversion_result_shape* other) { #ifdef IFOPSH_SIMPLE_KERNEL throw std::runtime_error("Not implemented"); #else - return new CgalShape(this->nef() + ((CgalShape*)other)->nef()); + return new cgal_shape(this->nef() + ((cgal_shape*)other)->nef()); #endif } -ConversionResultShape* ifcopenshell::geometry::CgalShape::subtract(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape::subtract(conversion_result_shape* other) { #ifdef IFOPSH_SIMPLE_KERNEL throw std::runtime_error("Not implemented"); #else - return new CgalShape(this->nef() - ((CgalShape*)other)->nef()); + return new cgal_shape(this->nef() - ((cgal_shape*)other)->nef()); #endif } -ConversionResultShape* ifcopenshell::geometry::CgalShape::intersect(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape::intersect(conversion_result_shape* other) { #ifdef IFOPSH_SIMPLE_KERNEL throw std::runtime_error("Not implemented"); #else - return new CgalShape(this->nef() * ((CgalShape*)other)->nef()); + return new cgal_shape(this->nef() * ((cgal_shape*)other)->nef()); #endif } namespace { - template - void concatenate_polyhedra(Polyhedron& p1, const Polyhedron& p2) { + template + void concatenate_polyhedra(polyhedron_type& p1, const polyhedron_type& p2) { std::vector points1, points2; std::vector> faces1, faces2; @@ -977,26 +977,26 @@ namespace { faces1.insert(faces1.end(), faces2.begin(), faces2.end()); // Build merged polyhedron - Polyhedron merged; + polyhedron_type merged; CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points1, faces1, merged); p1 = std::move(merged); } } -ConversionResultShape* ifcopenshell::geometry::CgalShape::concat(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape::concat(conversion_result_shape* other) { auto shp = poly(); - concatenate_polyhedra(shp, ((CgalShape*)other)->poly()); - return new CgalShape(shp); + concatenate_polyhedra(shp, ((cgal_shape*)other)->poly()); + return new cgal_shape(shp); } -std::pair, OpaqueCoordinate<3>> ifcopenshell::geometry::CgalShape::bounding_box() const +std::pair, opaque_coordinate<3>> ifcopenshell::geom::cgal_shape::bounding_box() const { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::CgalShape::moved(ifcopenshell::geometry::taxonomy::matrix4::ptr place) const +conversion_result_shape* ifcopenshell::geom::cgal_shape::moved(ifcopenshell::geom::taxonomy::matrix4::ptr place) const { if (place->is_identity()) { return clone(); @@ -1004,10 +1004,10 @@ ConversionResultShape* ifcopenshell::geometry::CgalShape::moved(ifcopenshell::ge const auto trsf = make_transform(*place); if (is_point()) { - return new CgalShape(point().transform(trsf), convex_tag_); + return new cgal_shape(point().transform(trsf), convex_tag_); } if (is_wire()) { - return new CgalShape(moved_wire(wire(), trsf), convex_tag_); + return new cgal_shape(moved_wire(wire(), trsf), convex_tag_); } cgal_shape_t s = poly(); @@ -1015,78 +1015,78 @@ ConversionResultShape* ifcopenshell::geometry::CgalShape::moved(ifcopenshell::ge vertex->point() = vertex->point().transform(trsf); } - return new CgalShape(s, convex_tag_); + return new cgal_shape(s, convex_tag_); } -std::size_t ifcopenshell::geometry::CgalShape::map(OpaqueCoordinate<4>&, OpaqueCoordinate<4>&) { +std::size_t ifcopenshell::geom::cgal_shape::map(opaque_coordinate<4>&, opaque_coordinate<4>&) { throw std::runtime_error("Not implemented"); } -std::size_t ifcopenshell::geometry::CgalShape::map(const std::vector>&, const std::vector>&) { +std::size_t ifcopenshell::geom::cgal_shape::map(const std::vector>&, const std::vector>&) { throw std::runtime_error("Not implemented"); } -bool ifcopenshell::geometry::CgalShape::surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { +bool ifcopenshell::geom::cgal_shape::surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { // @todo return false; } #ifndef IFOPSH_SIMPLE_KERNEL -void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { +void ifcopenshell::geom::cgal_shape_half_space_decomposition::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { throw std::runtime_error("Not implemented"); } -void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string& r) const { +void ifcopenshell::geom::cgal_shape_half_space_decomposition::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { throw std::runtime_error("Not implemented"); } -int ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::num_vertices() const { +int ifcopenshell::geom::cgal_shape_half_space_decomposition::num_vertices() const { throw std::runtime_error("Not implemented"); } -void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::set_box(void * b) { +void ifcopenshell::geom::cgal_shape_half_space_decomposition::set_box(void * b) { throw std::runtime_error("Not implemented"); } -int ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::surface_genus() const { +int ifcopenshell::geom::cgal_shape_half_space_decomposition::surface_genus() const { throw std::runtime_error("Not implemented"); } -bool ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::is_manifold() const { +bool ifcopenshell::geom::cgal_shape_half_space_decomposition::is_manifold() const { throw std::runtime_error("Not implemented"); } -int ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::num_edges() const +int ifcopenshell::geom::cgal_shape_half_space_decomposition::num_edges() const { throw std::runtime_error("Not implemented"); } -int ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::num_faces() const +int ifcopenshell::geom::cgal_shape_half_space_decomposition::num_faces() const { throw std::runtime_error("Not implemented"); } -OpaqueNumber ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::CgalShapeHalfSpaceDecomposition::length() +opaque_number ifcopenshell::geom::cgal_shape_half_space_decomposition::cgal_shape_half_space_decomposition::length() { throw std::runtime_error("Not implemented"); } -OpaqueNumber ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::area() +opaque_number ifcopenshell::geom::cgal_shape_half_space_decomposition::area() { throw std::runtime_error("Not implemented"); } -OpaqueNumber ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::volume() +opaque_number ifcopenshell::geom::cgal_shape_half_space_decomposition::volume() { throw std::runtime_error("Not implemented"); } -OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::position() +opaque_coordinate<3> ifcopenshell::geom::cgal_shape_half_space_decomposition::position() { if (planes_.size() == 1) { - auto xyz = CGAL::ORIGIN + planes_.front().d() * CGAL::Vector_3(planes_.front().a(), planes_.front().b(), planes_.front().c()); - return OpaqueCoordinate<3>( + auto xyz = CGAL::ORIGIN + planes_.front().d() * CGAL::Vector_3(planes_.front().a(), planes_.front().b(), planes_.front().c()); + return opaque_coordinate<3>( NumberType(xyz.cartesian(0)), NumberType(xyz.cartesian(1)), NumberType(xyz.cartesian(2)) @@ -1096,14 +1096,14 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::pos } } -OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::axis() +opaque_coordinate<3> ifcopenshell::geom::cgal_shape_half_space_decomposition::axis() { if (planes_.size() == 1) { - std::array abc{ planes_.front().a(), planes_.front().b(), planes_.front().c() }; + std::array abc{ planes_.front().a(), planes_.front().b(), planes_.front().c() }; auto minel = std::min_element(abc.begin(), abc.end()); auto maxel = std::max_element(abc.begin(), abc.end()); auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel; - return OpaqueCoordinate<3>( + return opaque_coordinate<3>( NumberType(planes_.front().a() / maxval), NumberType(planes_.front().b() / maxval), NumberType(planes_.front().c() / maxval) @@ -1113,14 +1113,14 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::axi } } -OpaqueCoordinate<4> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::plane_equation() +opaque_coordinate<4> ifcopenshell::geom::cgal_shape_half_space_decomposition::plane_equation() { if (planes_.size() == 1) { - std::array abc{ planes_.front().a(), planes_.front().b(), planes_.front().c() }; + std::array abc{ planes_.front().a(), planes_.front().b(), planes_.front().c() }; auto minel = std::min_element(abc.begin(), abc.end()); auto maxel = std::max_element(abc.begin(), abc.end()); auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel; - return OpaqueCoordinate<4>( + return opaque_coordinate<4>( NumberType(planes_.front().a() / maxval), NumberType(planes_.front().b() / maxval), NumberType(planes_.front().c() / maxval), @@ -1131,76 +1131,76 @@ OpaqueCoordinate<4> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::pla } } -std::vector ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::convex_decomposition() +std::vector ifcopenshell::geom::cgal_shape_half_space_decomposition::convex_decomposition() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::halfspaces() +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::halfspaces() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::solid() +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::solid() { - return new CgalShape(shape_->evaluate()); + return new cgal_shape(shape_->evaluate()); } -ConversionResultShape * ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::box() +conversion_result_shape * ifcopenshell::geom::cgal_shape_half_space_decomposition::box() { throw std::runtime_error("Not implemented"); } -std::vector ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::vertices() +std::vector ifcopenshell::geom::cgal_shape_half_space_decomposition::vertices() { throw std::runtime_error("Not implemented"); } -std::vector ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::edges() +std::vector ifcopenshell::geom::cgal_shape_half_space_decomposition::edges() { throw std::runtime_error("Not implemented"); } -std::vector ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::facets() +std::vector ifcopenshell::geom::cgal_shape_half_space_decomposition::facets() { - std::vector res; + std::vector res; for (auto& p : planes_) { - res.push_back(new CgalShapeHalfSpaceDecomposition(p)); + res.push_back(new cgal_shape_half_space_decomposition(p)); } return res; } -ConversionResultShape* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::add(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::add(conversion_result_shape* other) { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::subtract(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::subtract(conversion_result_shape* other) { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::intersect(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::intersect(conversion_result_shape* other) { throw std::runtime_error("Not implemented"); } -std::pair, OpaqueCoordinate<3>> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::bounding_box() const +std::pair, opaque_coordinate<3>> ifcopenshell::geom::cgal_shape_half_space_decomposition::bounding_box() const { throw std::runtime_error("Not implemented"); } -double ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::bounding_box(void *& b) const { +double ifcopenshell::geom::cgal_shape_half_space_decomposition::bounding_box(void *& b) const { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const { throw std::runtime_error("Not implemented"); } -std::size_t ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to) { - plane_map mp; +std::size_t ifcopenshell::geom::cgal_shape_half_space_decomposition::map(opaque_coordinate<4>& from, opaque_coordinate<4>& to) { + plane_map mp; insert_normalized_plane_map(mp, from, to); std::size_t mutated = 0; auto nw = shape_->map(mp, mutated); @@ -1209,8 +1209,8 @@ std::size_t ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::map(OpaqueC return mutated; } -std::size_t ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::map(const std::vector>& froms, const std::vector>& tos) { - plane_map mp; +std::size_t ifcopenshell::geom::cgal_shape_half_space_decomposition::map(const std::vector>& froms, const std::vector>& tos) { + plane_map mp; if (froms.size() != tos.size()) { throw std::runtime_error("Expected equal size"); } @@ -1229,7 +1229,7 @@ std::size_t ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::map(const s } -ConversionResultShape* ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::wrap_in_compound() +conversion_result_shape* ifcopenshell::geom::cgal_shape_half_space_decomposition::wrap_in_compound() { throw std::runtime_error("Not implemented"); } diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.h b/src/ifcgeom/kernels/cgal/CgalConversionResult.h index 9edfd4b5e5..ec85c29d7b 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.h +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.h @@ -45,8 +45,8 @@ #include -#define Kernel_ SimpleKernel_ -#define CgalShape SimpleCgalShape +#define kernel_ Simplekernel_ +#define cgal_shape SimpleCgalShape #define cgal_placement_t cgal_simple_placement_t #define cgal_point_t cgal_simple_point_t #define cgal_direction_t cgal_simple_direction_t @@ -59,23 +59,23 @@ #define cgal_vertex_descriptor_t cgal_simple_vertex_descriptor_t #define cgal_face_descriptor_t cgal_simple_face_descriptor_t -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_; +typedef CGAL::Exact_predicates_inexact_constructions_kernel kernel_; #else #include #include -typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel_; +typedef CGAL::Exact_predicates_exact_constructions_kernel kernel_; #endif -typedef Kernel_::Aff_transformation_3 cgal_placement_t; -typedef Kernel_::Point_3 cgal_point_t; -typedef Kernel_::Vector_3 cgal_direction_t; -typedef Kernel_::Vector_3 cgal_vector_t; -typedef Kernel_::Plane_3 cgal_plane_t; -typedef std::vector cgal_curve_t; -typedef std::vector cgal_wire_t; +typedef kernel_::Aff_transformation_3 cgal_placement_t; +typedef kernel_::Point_3 cgal_point_t; +typedef kernel_::Vector_3 cgal_direction_t; +typedef kernel_::Vector_3 cgal_vector_t; +typedef kernel_::Plane_3 cgal_plane_t; +typedef std::vector cgal_curve_t; +typedef std::vector cgal_wire_t; namespace { struct cgal_face_t { @@ -84,28 +84,28 @@ namespace { }; } -typedef CGAL::Polyhedron_3 cgal_shape_t; -typedef boost::graph_traits>::vertex_descriptor cgal_vertex_descriptor_t; -typedef boost::graph_traits>::face_descriptor cgal_face_descriptor_t; +typedef CGAL::Polyhedron_3 cgal_shape_t; +typedef boost::graph_traits>::vertex_descriptor cgal_vertex_descriptor_t; +typedef boost::graph_traits>::face_descriptor cgal_face_descriptor_t; #include "../../../ifcgeom/ConversionResult.h" -namespace ifcopenshell { namespace geometry { +namespace ifcopenshell { namespace geom { - using IfcGeom::OpaqueCoordinate; - using IfcGeom::OpaqueNumber; + using ifcopenshell::geom::opaque_coordinate; + using ifcopenshell::geom::opaque_number; #ifndef IFOPSH_SIMPLE_KERNEL - class IFC_GEOMLIBRARY_API NumberEpeck : public OpaqueNumber { + class IFC_GEOMLIBRARY_API number_epeck : public opaque_number { private: - struct Model : OpaqueNumber::NumberConcept { + struct model : opaque_number::number_concept { CGAL::Epeck::FT value; - Model(const CGAL::Epeck::FT& v) + model(const CGAL::Epeck::FT& v) : value(v) {} - static const Model& as_same(const NumberConcept& other) { - auto same = dynamic_cast(&other); + static const model& as_same(const number_concept& other) { + auto same = dynamic_cast(&other); if (same == nullptr) { throw std::runtime_error("Incompatible opaque number types"); } @@ -122,39 +122,39 @@ namespace ifcopenshell { namespace geometry { return ss.str(); } - virtual std::shared_ptr add(const NumberConcept& other) const { - return std::make_shared(value + as_same(other).value); + virtual std::shared_ptr add(const number_concept& other) const { + return std::make_shared(value + as_same(other).value); } - virtual std::shared_ptr subtract(const NumberConcept& other) const { - return std::make_shared(value - as_same(other).value); + virtual std::shared_ptr subtract(const number_concept& other) const { + return std::make_shared(value - as_same(other).value); } - virtual std::shared_ptr multiply(const NumberConcept& other) const { - return std::make_shared(value * as_same(other).value); + virtual std::shared_ptr multiply(const number_concept& other) const { + return std::make_shared(value * as_same(other).value); } - virtual std::shared_ptr divide(const NumberConcept& other) const { - return std::make_shared(value / as_same(other).value); + virtual std::shared_ptr divide(const number_concept& other) const { + return std::make_shared(value / as_same(other).value); } - virtual std::shared_ptr negate() const { - return std::make_shared(-value); + virtual std::shared_ptr negate() const { + return std::make_shared(-value); } - virtual std::shared_ptr from_double(double v) const { - return std::make_shared(CGAL::Epeck::FT(v)); + virtual std::shared_ptr from_double(double v) const { + return std::make_shared(CGAL::Epeck::FT(v)); } - virtual std::shared_ptr from_int(int v) const { - return std::make_shared(CGAL::Epeck::FT(v)); + virtual std::shared_ptr from_int(int v) const { + return std::make_shared(CGAL::Epeck::FT(v)); } - virtual bool equals(const NumberConcept& other) const { + virtual bool equals(const number_concept& other) const { return value == as_same(other).value; } - virtual bool less_than(const NumberConcept& other) const { + virtual bool less_than(const number_concept& other) const { return value < as_same(other).value; } @@ -168,8 +168,8 @@ namespace ifcopenshell { namespace geometry { }; public: - NumberEpeck(const CGAL::Epeck::FT& v) - : OpaqueNumber(std::make_shared(v)) {} + number_epeck(const CGAL::Epeck::FT& v) + : opaque_number(std::make_shared(v)) {} const CGAL::Epeck::FT& value() const { return value_as(); @@ -177,23 +177,23 @@ namespace ifcopenshell { namespace geometry { }; #endif - class IFC_GEOMLIBRARY_API CgalShape : public IfcGeom::ConversionResultShape { + class IFC_GEOMLIBRARY_API cgal_shape : public ifcopenshell::geom::conversion_result_shape { private: typedef std::variant cgal_shape_storage_t; bool convex_tag_ = false; mutable std::optional shape_; #ifndef IFOPSH_SIMPLE_KERNEL - mutable std::optional> nef_; + mutable std::optional> nef_; #endif public: - CgalShape(const cgal_shape_t& shape, bool convex = false, ::logger& logger = ::logger::root()); - CgalShape(const cgal_point_t& point, bool convex = false); - CgalShape(const cgal_wire_t& wire, bool convex = false); + cgal_shape(const cgal_shape_t& shape, bool convex = false, ::logger& logger = ::logger::root()); + cgal_shape(const cgal_point_t& point, bool convex = false); + cgal_shape(const cgal_wire_t& wire, bool convex = false); #ifndef IFOPSH_SIMPLE_KERNEL - CgalShape(const CGAL::Nef_polyhedron_3& shape, bool convex = false) { + cgal_shape(const CGAL::Nef_polyhedron_3& shape, bool convex = false) { nef_ = shape; convex_tag_ = convex; } @@ -204,8 +204,8 @@ namespace ifcopenshell { namespace geometry { void to_nef() const; - operator const CGAL::Nef_polyhedron_3& () const { to_nef(); return *nef_; } - const CGAL::Nef_polyhedron_3& nef() const { to_nef(); return *nef_; } + operator const CGAL::Nef_polyhedron_3& () const { to_nef(); return *nef_; } + const CGAL::Nef_polyhedron_3& nef() const { to_nef(); return *nef_; } #else // noop on simple kernel void to_poly() const {} @@ -226,18 +226,18 @@ namespace ifcopenshell { namespace geometry { const cgal_point_t& point() const { return std::get(*shape_); } const cgal_wire_t& wire() const { return std::get(*shape_); } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; - virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; + virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; + virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; - virtual IfcGeom::ConversionResultShape* clone() const { + virtual ifcopenshell::geom::conversion_result_shape* clone() const { if (shape_) { - return std::visit([this](const auto& value) -> IfcGeom::ConversionResultShape* { - return new CgalShape(value, convex_tag_); + return std::visit([this](const auto& value) -> ifcopenshell::geom::conversion_result_shape* { + return new cgal_shape(value, convex_tag_); }, *shape_); } #ifndef IFOPSH_SIMPLE_KERNEL if (nef_) { - return new CgalShape(*nef_, convex_tag_); + return new cgal_shape(*nef_, convex_tag_); } #endif return nullptr; @@ -257,49 +257,49 @@ namespace ifcopenshell { namespace geometry { virtual int num_faces() const; // @todo this must be something with a virtual dtor so that we can delete it. - virtual std::pair, OpaqueCoordinate<3>> bounding_box() const; + virtual std::pair, opaque_coordinate<3>> bounding_box() const; - virtual OpaqueNumber length(); - virtual OpaqueNumber area(); - virtual OpaqueNumber volume(); + virtual opaque_number length(); + virtual opaque_number area(); + virtual opaque_number volume(); - virtual OpaqueCoordinate<3> position(); - virtual OpaqueCoordinate<3> axis(); - virtual OpaqueCoordinate<4> plane_equation(); + virtual opaque_coordinate<3> position(); + virtual opaque_coordinate<3> axis(); + virtual opaque_coordinate<4> plane_equation(); - virtual std::vector convex_decomposition(); - virtual ConversionResultShape* halfspaces(); - virtual ConversionResultShape* solid(); - virtual ConversionResultShape* box(); - virtual ConversionResultShape* wrap_in_compound(); + virtual std::vector convex_decomposition(); + virtual conversion_result_shape* halfspaces(); + virtual conversion_result_shape* solid(); + virtual conversion_result_shape* box(); + virtual conversion_result_shape* wrap_in_compound(); - virtual std::vector vertices(); - virtual std::vector edges(); - virtual std::vector facets(); + virtual std::vector vertices(); + virtual std::vector edges(); + virtual std::vector facets(); - virtual ConversionResultShape* add(ConversionResultShape*); - virtual ConversionResultShape* subtract(ConversionResultShape*); - virtual ConversionResultShape* intersect(ConversionResultShape*); - virtual ConversionResultShape* concat(ConversionResultShape*); + virtual conversion_result_shape* add(conversion_result_shape*); + virtual conversion_result_shape* subtract(conversion_result_shape*); + virtual conversion_result_shape* intersect(conversion_result_shape*); + virtual conversion_result_shape* concat(conversion_result_shape*); - virtual std::size_t map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to); - virtual std::size_t map(const std::vector>& from, const std::vector>& to); - virtual ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const; + virtual std::size_t map(opaque_coordinate<4>& from, opaque_coordinate<4>& to); + virtual std::size_t map(const std::vector>& from, const std::vector>& to); + virtual conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const; - virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; + virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; bool convex_tag() const { return convex_tag_; } bool& convex_tag() { return convex_tag_; } }; #ifndef IFOPSH_SIMPLE_KERNEL - class IFC_GEOMLIBRARY_API CgalShapeHalfSpaceDecomposition : public IfcGeom::ConversionResultShape { + class IFC_GEOMLIBRARY_API cgal_shape_half_space_decomposition : public ifcopenshell::geom::conversion_result_shape { private: - std::unique_ptr> shape_; - std::list> planes_; + std::unique_ptr> shape_; + std::list> planes_; public: - CgalShapeHalfSpaceDecomposition(const CGAL::Nef_polyhedron_3& shape, bool is_convex) { + cgal_shape_half_space_decomposition(const CGAL::Nef_polyhedron_3& shape, bool is_convex) { if (is_convex) { shape_ = std::move(build_halfspace_tree_is_decomposed(shape, planes_)); } else { @@ -307,8 +307,8 @@ namespace ifcopenshell { namespace geometry { } } - CgalShapeHalfSpaceDecomposition(const CGAL::Plane_3& shape) { - shape_.reset(new halfspace_tree_plane(shape)); + cgal_shape_half_space_decomposition(const CGAL::Plane_3& shape) { + shape_.reset(new halfspace_tree_plane(shape)); planes_.push_back(shape); } virtual std::string_view backend_id() const { @@ -319,8 +319,8 @@ namespace ifcopenshell { namespace geometry { #endif } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; - virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; + virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; + virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual int surface_genus() const; virtual bool is_manifold() const; @@ -332,39 +332,39 @@ namespace ifcopenshell { namespace geometry { virtual double bounding_box(void*&) const; // @todo this must be something with a virtual dtor so that we can delete it. - virtual std::pair, OpaqueCoordinate<3>> bounding_box() const; + virtual std::pair, opaque_coordinate<3>> bounding_box() const; virtual void set_box(void* b); - virtual OpaqueNumber length(); - virtual OpaqueNumber area(); - virtual OpaqueNumber volume(); + virtual opaque_number length(); + virtual opaque_number area(); + virtual opaque_number volume(); - virtual OpaqueCoordinate<3> position(); - virtual OpaqueCoordinate<3> axis(); - virtual OpaqueCoordinate<4> plane_equation(); + virtual opaque_coordinate<3> position(); + virtual opaque_coordinate<3> axis(); + virtual opaque_coordinate<4> plane_equation(); - virtual std::vector convex_decomposition(); - virtual ConversionResultShape* halfspaces(); - virtual ConversionResultShape* solid(); - virtual ConversionResultShape* box(); - virtual ConversionResultShape* wrap_in_compound(); + virtual std::vector convex_decomposition(); + virtual conversion_result_shape* halfspaces(); + virtual conversion_result_shape* solid(); + virtual conversion_result_shape* box(); + virtual conversion_result_shape* wrap_in_compound(); - virtual std::vector vertices(); - virtual std::vector edges(); - virtual std::vector facets(); + virtual std::vector vertices(); + virtual std::vector edges(); + virtual std::vector facets(); - virtual ConversionResultShape* add(ConversionResultShape*); - virtual ConversionResultShape* subtract(ConversionResultShape*); - virtual ConversionResultShape* intersect(ConversionResultShape*); - virtual ConversionResultShape* concat(ConversionResultShape*) { + virtual conversion_result_shape* add(conversion_result_shape*); + virtual conversion_result_shape* subtract(conversion_result_shape*); + virtual conversion_result_shape* intersect(conversion_result_shape*); + virtual conversion_result_shape* concat(conversion_result_shape*) { return nullptr; } - virtual std::size_t map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to); - virtual std::size_t map(const std::vector>& from, const std::vector>& to); - virtual ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const; + virtual std::size_t map(opaque_coordinate<4>& from, opaque_coordinate<4>& to); + virtual std::size_t map(const std::vector>& from, const std::vector>& to); + virtual conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const; - virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const { + virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const { return false; } }; @@ -372,7 +372,7 @@ namespace ifcopenshell { namespace geometry { }} #ifdef IFOPSH_SIMPLE_KERNEL -#undef CgalShape +#undef cgal_shape #endif #endif diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.cpp b/src/ifcgeom/kernels/cgal/CgalKernel.cpp index 8dde17f10e..ade0217886 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.cpp +++ b/src/ifcgeom/kernels/cgal/CgalKernel.cpp @@ -25,7 +25,7 @@ #include "../../../ifcgeom/kernels/cgal/CgalConversionResult.h" #ifdef IFOPSH_SIMPLE_KERNEL -#define CgalShape SimpleCgalShape +#define cgal_shape SimpleCgalShape #endif #include @@ -38,27 +38,26 @@ #include #include -using namespace IfcGeom; -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; namespace { - struct PolyhedronBuilder : public CGAL::Modifier_base::HalfedgeDS> { + struct polyhedron_builder : public CGAL::Modifier_base::HalfedgeDS> { private: std::list *face_list; logger& logger_; public: std::optional from_soup; - PolyhedronBuilder(std::list *face_list, logger& logger = ::logger::root()); - void operator()(CGAL::Polyhedron_3::HalfedgeDS &hds); + polyhedron_builder(std::list *face_list, logger& logger = ::logger::root()); + void operator()(CGAL::Polyhedron_3::HalfedgeDS &hds); }; } -CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(std::list &face_list, bool stitch_borders, logger& logger) { +CGAL::Polyhedron_3 ifcopenshell::geom::utils::create_polyhedron(std::list &face_list, bool stitch_borders, logger& logger) { // Naive creation - CGAL::Polyhedron_3 polyhedron; - PolyhedronBuilder builder(&face_list, logger); + CGAL::Polyhedron_3 polyhedron; + polyhedron_builder builder(&face_list, logger); polyhedron.delegate(builder); if (builder.from_soup) { polyhedron = *builder.from_soup; @@ -82,7 +81,7 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(std // fresult.open("/Users/ken/Desktop/invalid.off"); // fresult << polyhedron << std::endl; // fresult.close(); - return CGAL::Polyhedron_3(); + return CGAL::Polyhedron_3(); } // std::cout << "After: " << polyhedron.size_of_vertices() << " vertices and " << polyhedron.size_of_facets() << " facets" << std::endl; @@ -91,24 +90,24 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(std } #ifndef IFOPSH_SIMPLE_KERNEL -CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_polyhedron(const CGAL::Nef_polyhedron_3& nef_polyhedron, logger& logger) { +CGAL::Polyhedron_3 ifcopenshell::geom::utils::create_polyhedron(const CGAL::Nef_polyhedron_3& nef_polyhedron, logger& logger) { if (nef_polyhedron.is_simple()) { try { - CGAL::Polyhedron_3 polyhedron; + CGAL::Polyhedron_3 polyhedron; nef_polyhedron.convert_to_polyhedron(polyhedron); return polyhedron; } catch (...) { logger.message(::logger::LOG_ERROR, "GEO", 70, "Conversion from Nef to polyhedron failed!"); - return CGAL::Polyhedron_3(); + return CGAL::Polyhedron_3(); } } else { logger.message(::logger::LOG_ERROR, "GEO", 71, "Nef polyhedron not simple: cannot create polyhedron!"); - return CGAL::Polyhedron_3(); + return CGAL::Polyhedron_3(); } } -CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhedron(std::list &face_list, logger& logger) { - CGAL::Polyhedron_3 polyhedron = create_polyhedron(face_list, true, logger); +CGAL::Nef_polyhedron_3 ifcopenshell::geom::utils::create_nef_polyhedron(std::list &face_list, logger& logger) { + CGAL::Polyhedron_3 polyhedron = create_polyhedron(face_list, true, logger); if (polyhedron.is_closed()) { try { if (!CGAL::Polygon_mesh_processing::is_outward_oriented(polyhedron)) { @@ -119,16 +118,16 @@ CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhe } } CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron); - CGAL::Nef_polyhedron_3 nef_polyhedron; + CGAL::Nef_polyhedron_3 nef_polyhedron; try { - nef_polyhedron = CGAL::Nef_polyhedron_3(polyhedron); + nef_polyhedron = CGAL::Nef_polyhedron_3(polyhedron); } catch (...) { logger.message(::logger::LOG_ERROR, "GEO", 73, "Conversion to Nef polyhedron failed!"); } return nef_polyhedron; } -CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, logger& logger) { +CGAL::Nef_polyhedron_3 ifcopenshell::geom::utils::create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, logger& logger) { // @todo needed? polyhedron.normalize_border(); @@ -145,21 +144,21 @@ CGAL::Nef_polyhedron_3 ifcopenshell::geometry::utils::create_nef_polyhe if (polyhedron.is_valid(false, 3) && polyhedron.is_closed()) { // @todo is it necessary to triangulat? CGAL::Polygon_mesh_processing::triangulate_faces(polyhedron); - CGAL::Nef_polyhedron_3 nef_polyhedron; + CGAL::Nef_polyhedron_3 nef_polyhedron; try { - nef_polyhedron = CGAL::Nef_polyhedron_3(polyhedron); + nef_polyhedron = CGAL::Nef_polyhedron_3(polyhedron); } catch (...) { logger.message(::logger::LOG_ERROR, "GEO", 75, "Conversion to Nef polyhedron failed!"); } return nef_polyhedron; } else { logger.message(::logger::LOG_ERROR, "GEO", 76, "Polyhedron not valid: cannot create Nef polyhedron!"); - return CGAL::Nef_polyhedron_3(); + return CGAL::Nef_polyhedron_3(); } } #endif -bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) { +bool cgal_kernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) { for (auto& f : l->children) { if (f->basis && f->basis->kind() != taxonomy::PLANE) { logger().error("UNS", 3, "CGAL Kernel: Non-planar faces not supported at the moment"); @@ -200,8 +199,8 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) { logger().notice("GEO", 77, "Density " + boost::lexical_cast(density), l->instance); if (density > 5000) { logger().notice("GEO", 78, "Substituted element with " + boost::lexical_cast(density) + " vertices / m3 with a bounding box"); - CGAL::Point_3 lower(minmax.first(0), minmax.first(1), minmax.first(2)); - CGAL::Point_3 upper(minmax.second(0), minmax.second(1), minmax.second(2)); + CGAL::Point_3 lower(minmax.first(0), minmax.first(1), minmax.first(2)); + CGAL::Point_3 upper(minmax.second(0), minmax.second(1), minmax.second(2)); shape = utils::create_cube(lower, upper); return true; } @@ -234,7 +233,7 @@ bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) { return shape.size_of_facets(); } -bool CgalKernel::convert(const taxonomy::face::ptr face, std::list& result) { +bool cgal_kernel::convert(const taxonomy::face::ptr face, std::list& result) { int num_outer_bounds = 0; for (auto& bound : face->children) { @@ -286,7 +285,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list& namespace { // @todo obsolete? /* - bool convert_curve(CgalKernel* kernel, const taxonomy::ptr curve, cgal_wire_t& builder) { + bool convert_curve(cgal_kernel* kernel, const taxonomy::ptr curve, cgal_wire_t& builder) { if (auto e = taxonomy::dcast(curve)) { if (true || e->basis == nullptr) { if (builder.empty()) { @@ -354,7 +353,7 @@ namespace { u = std::atan2(xy(1), xy(0)); } - struct point_projection_visitor_ { + struct curve_point_projection_visitor { taxonomy::point3 p; double u; typedef void result_type; @@ -376,7 +375,7 @@ namespace { } }; - struct point_projection_visitor { + struct trim_point_projection_visitor { taxonomy::ptr curve; double u; typedef void result_type; @@ -386,8 +385,8 @@ namespace { } void operator()(const taxonomy::point3::ptr& p) { - point_projection_visitor_ v{ *p }; - dispatch_curve_creation::dispatch(curve, v); + curve_point_projection_visitor v{ *p }; + dispatch_curve_creation::dispatch(curve, v); u = v.u; } @@ -402,13 +401,13 @@ namespace { inline double conic_radius(const taxonomy::ellipse::ptr& e) { return e->radius > e->radius2 ? e->radius : e->radius2; } struct cgal_curve_creation_visitor { - Settings& settings_; + ifcopenshell::geom::settings& settings_; parameter_range param; std::vector points; - cgal_curve_creation_visitor(Settings& s) : settings_(s), param(unbounded) {} - cgal_curve_creation_visitor(Settings& s, const parameter_range& p) : settings_(s), param(p) {} + cgal_curve_creation_visitor(ifcopenshell::geom::settings& settings) : settings_(settings), param(unbounded) {} + cgal_curve_creation_visitor(ifcopenshell::geom::settings& settings, const parameter_range& p) : settings_(settings), param(p) {} void operator()(const taxonomy::line::ptr& l) { if (param == unbounded) { @@ -496,7 +495,7 @@ namespace { e_basis = taxonomy::cast(e_basis)->basis; } - point_projection_visitor v1{ e->basis }, v2{ e->basis }; + trim_point_projection_visitor v1{ e->basis }, v2{ e->basis }; std::visit(v1, e->start); std::visit(v2, e->end); @@ -523,8 +522,8 @@ namespace { } }; - void convert_curve(Settings& s, taxonomy::ptr i, std::vector& points) { - cgal_curve_creation_visitor v(s); + void convert_curve(ifcopenshell::geom::settings& settings, taxonomy::ptr i, std::vector& points) { + cgal_curve_creation_visitor v(settings); dispatch_curve_creation::dispatch(i, v); points = v.points; } @@ -549,10 +548,10 @@ namespace { #include #include -typedef CGAL::Box_intersection_d::Box_with_handle_d Box; +typedef CGAL::Box_intersection_d::Box_with_handle_d box; namespace { - void loop_to_segments(const cgal_wire_t& wire, std::vector& segments) { + void loop_to_segments(const cgal_wire_t& wire, std::vector& segments) { for (int i = 0; i < wire.size(); ++i) { int j = (i + 1) % wire.size(); segments.emplace_back(wire[i], wire[j]); @@ -561,14 +560,14 @@ namespace { struct intersection_collector { - const std::vector& segments; + const std::vector& segments; int num_self_intersections = 0; - explicit intersection_collector(const std::vector& s) + explicit intersection_collector(const std::vector& s) : segments(s) {} - void operator()(const Box& a, const Box& b) { + void operator()(const box& a, const box& b) { int aid = *a.handle(); int bid = *b.handle(); @@ -590,12 +589,12 @@ namespace { } }; - bool do_segments_intersect(const std::vector& segments) { - std::vector boxes; + bool do_segments_intersect(const std::vector& segments) { + std::vector boxes; std::vector handles(segments.size()); std::iota(handles.begin(), handles.end(), 0); for (auto it = segments.begin(); it != segments.end(); ++it) { - boxes.push_back(Box(it->bbox(), &*(handles.begin() + std::distance(segments.begin(), it)))); + boxes.push_back(box(it->bbox(), &*(handles.begin() + std::distance(segments.begin(), it)))); } intersection_collector x(segments); CGAL::box_self_intersection_d(boxes.begin(), boxes.end(), x); @@ -605,7 +604,7 @@ namespace { namespace { cgal_direction_t newell(const std::vector & loop) { - Kernel_::FT a(0.0), b(0.0), c(0.0); + kernel_::FT a(0.0), b(0.0), c(0.0); for (size_t i = 0; i < loop.size(); ++i) { auto & curr = loop[i]; auto & next = loop[(i + 1) % loop.size()]; @@ -618,20 +617,20 @@ namespace { } namespace { - CGAL::Polygon_2 loop_to_polygon_2(taxonomy::loop::ptr loop) { - CGAL::Polygon_2 polygon; + CGAL::Polygon_2 loop_to_polygon_2(taxonomy::loop::ptr loop) { + CGAL::Polygon_2 polygon; for (auto& e : loop->children) { auto& p = *std::get(e->start); - CGAL::Point_2 pnt(p.ccomponents()(0), p.ccomponents()(1)); + CGAL::Point_2 pnt(p.ccomponents()(0), p.ccomponents()(1)); polygon.push_back(pnt); } return polygon; } - CGAL::Polygon_2 wire_to_polygon_2(const cgal_wire_t& w) { - CGAL::Polygon_2 polygon; + CGAL::Polygon_2 wire_to_polygon_2(const cgal_wire_t& w) { + CGAL::Polygon_2 polygon; for (auto& p : w) { - CGAL::Point_2 pnt(p.cartesian(0), p.cartesian(1)); + CGAL::Point_2 pnt(p.cartesian(0), p.cartesian(1)); polygon.push_back(pnt); } return polygon; @@ -645,13 +644,13 @@ namespace { class polygon_2_to_wire { private: - const CGAL::Aff_transformation_3& t_; + const CGAL::Aff_transformation_3& t_; public: - polygon_2_to_wire(const CGAL::Aff_transformation_3& t) + polygon_2_to_wire(const CGAL::Aff_transformation_3& t) : t_(t) {} - cgal_wire_t operator()(const CGAL::Polygon_2& p) { + cgal_wire_t operator()(const CGAL::Polygon_2& p) { cgal_wire_t w; for (auto it = p.vertices_begin(); it != p.vertices_end(); ++it) { cgal_point_t P(it->cartesian(0), it->cartesian(1), 0); @@ -662,7 +661,7 @@ namespace { } }; - void transform_in_place(cgal_wire_t& w, const CGAL::Aff_transformation_3& t) { + void transform_in_place(cgal_wire_t& w, const CGAL::Aff_transformation_3& t) { for (auto& p : w) { p = p.transform(t); } @@ -670,11 +669,11 @@ namespace { } namespace { - void face_to_poly_with_holes(const cgal_face_t& face, CGAL::Polygon_with_holes_2& pwh, CGAL::Aff_transformation_3& place) { + void face_to_poly_with_holes(const cgal_face_t& face, CGAL::Polygon_with_holes_2& pwh, CGAL::Aff_transformation_3& place) { // static - Kernel_::Vector_3 Z(0, 0, 1); + kernel_::Vector_3 Z(0, 0, 1); // static - Kernel_::Vector_3 X(1, 0, 0); + kernel_::Vector_3 X(1, 0, 0); auto refz = newell(face.outer); refz /= std::sqrt(CGAL::to_double(refz.squared_length())); @@ -682,14 +681,14 @@ namespace { auto refy = CGAL::cross_product(refz, refx); auto refl = face.outer.front(); - place = CGAL::Aff_transformation_3( + place = CGAL::Aff_transformation_3( refx.cartesian(0), refy.cartesian(0), refz.cartesian(0), refl.cartesian(0), refx.cartesian(1), refy.cartesian(1), refz.cartesian(1), refl.cartesian(1), refx.cartesian(2), refy.cartesian(2), refz.cartesian(2), refl.cartesian(2) ); /* - CGAL::NT_converter c; + CGAL::NT_converter c; std::array, 4> matrix; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { @@ -706,15 +705,15 @@ namespace { transform_in_place(w, ref); } - std::vector> holes; + std::vector> holes; holes.reserve(face_copy.inner.size()); std::transform(face_copy.inner.begin(), face_copy.inner.end(), std::back_inserter(holes), wire_to_polygon_2); - pwh = CGAL::Polygon_with_holes_2(wire_to_polygon_2(face_copy.outer), holes.begin(), holes.end()); + pwh = CGAL::Polygon_with_holes_2(wire_to_polygon_2(face_copy.outer), holes.begin(), holes.end()); } } -bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { +bool cgal_kernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { // @todo only implement polygonal loops std::vector points; @@ -748,7 +747,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { } // Parse and store the points in a sequence - cgal_wire_t polygon = std::vector(); + cgal_wire_t polygon = std::vector(); for (auto& p : points) { cgal_point_t pnt(p.ccomponents()(0), p.ccomponents()(1), p.ccomponents()(2)); polygon.push_back(pnt); @@ -784,7 +783,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { } } - std::vector segments; + std::vector segments; loop_to_segments(polygon, segments); auto inf = 1.e9; // std::numeric_limits::infinity(); @@ -802,7 +801,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { } auto dir = newell(polygon); - Kernel_::FT min_dot(+inf), max_dot(-inf); + kernel_::FT min_dot(+inf), max_dot(-inf); for (auto& p : polygon) { auto dot = dir * (p - CGAL::ORIGIN); if (dot < min_dot) { @@ -840,7 +839,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) { } -bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResults& results) { +bool cgal_kernel::convert_impl(const taxonomy::shell::ptr shell, conversion_results& results) { cgal_shape_t shape; if (!convert(shell, shape)) { return false; @@ -848,16 +847,16 @@ bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResult if (shape.size_of_facets() == 0) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( shell->instance.id(), shell->matrix, - new CgalShape(shape), + new cgal_shape(shape), shell->surface_style )); return true; } -bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResults& results) { +bool cgal_kernel::convert_impl(const taxonomy::solid::ptr solid, conversion_results& results) { if (solid->children.size() > 1) { logger().error("UNS", 5, "Multiple shells in solid not supported at the moment"); return false; @@ -873,10 +872,10 @@ bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResult if (shape.size_of_facets() == 0) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( solid->instance.id(), solid->matrix, - new CgalShape(shape), + new cgal_shape(shape), solid->surface_style )); return true; @@ -892,27 +891,27 @@ namespace { return true; } - bool convert_placement(ifcopenshell::geometry::taxonomy::matrix4::ptr place, cgal_placement_t& trsf) { + bool convert_placement(ifcopenshell::geom::taxonomy::matrix4::ptr place, cgal_placement_t& trsf) { return convert_placement(place->ccomponents(), trsf); } } -bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express::Base& entity, const std::vector>& openings, const IfcGeom::ConversionResults & entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4 & entity_trsf, IfcGeom::ConversionResults & cut_shapes) +bool ifcopenshell::geom::kernels::cgal_kernel::convert_openings(const express::base& entity, const std::vector>& openings, const ifcopenshell::geom::conversion_results & entity_shapes, const ifcopenshell::geom::taxonomy::matrix4 & entity_trsf, ifcopenshell::geom::conversion_results & cut_shapes) { #ifdef IFOPSH_SIMPLE_KERNEL return false; #else - CGAL::Nef_nary_union_3> second_operand_collector; + CGAL::Nef_nary_union_3> second_operand_collector; size_t second_operand_collector_size = 0; - std::list>> operands; + std::list>> operands; - std::list second_operand_instances; + std::list second_operand_instances; std::list first_operands, second_operands; - std::list> first_operands_nef, second_operands_nef; + std::list> first_operands_nef, second_operands_nef; for (auto& shp : entity_shapes) { - cgal_shape_t entity_shape = *std::static_pointer_cast(shp.Shape()); + cgal_shape_t entity_shape = *std::static_pointer_cast(shp.Shape()); const auto& m = shp.Placement()->ccomponents(); if (!m.isIdentity()) { cgal_placement_t trsf; @@ -924,7 +923,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express first_operands.push_back(entity_shape); - CGAL::Nef_polyhedron_3 a; + CGAL::Nef_polyhedron_3 a; if (!preprocess_boolean_operand(entity, {}, {}, {}, entity_shape, a, PP_NONE /*PP_UNIFY_PLANES_INTERNALLY*/)) { return false; } @@ -932,18 +931,18 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express first_operands_nef.push_back(a); } - std::list all_operand_planes; + std::list all_operand_planes; for (auto& op : openings) { auto opening_trsf = op.second; Eigen::Matrix4d relative = entity_trsf.ccomponents().inverse() * opening_trsf.ccomponents(); opening_trsf = relative; - ConversionResults opening_shapes; - AbstractKernel::convert(op.first, opening_shapes); + conversion_results opening_shapes; + abstract_kernel::convert(op.first, opening_shapes); for (unsigned int i = 0; i < opening_shapes.size(); ++i) { - cgal_shape_t entity_shape_unlocated = *std::static_pointer_cast(opening_shapes[i].Shape()); + cgal_shape_t entity_shape_unlocated = *std::static_pointer_cast(opening_shapes[i].Shape()); cgal_shape_t entity_shape(entity_shape_unlocated); auto gtrsf = opening_shapes[i].Placement(); // @todo check @@ -955,7 +954,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express vertex->point() = vertex->point().transform(trsf); } } - CGAL::Nef_polyhedron_3 nef; + CGAL::Nef_polyhedron_3 nef; if (!preprocess_boolean_operand(op.first->instance, {}, {}, {}, entity_shape, nef, PP_NONE)) { continue; } @@ -1008,7 +1007,7 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express return false; } - cut_shapes.push_back(IfcGeom::ConversionResult(it->ItemId(), new CgalShape(a_poly), it->StylePtr())); + cut_shapes.push_back(ifcopenshell::geom::conversion_result(it->ItemId(), new cgal_shape(a_poly), it->StylePtr())); it++; nit++; } @@ -1018,21 +1017,21 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express } -bool CgalKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ConversionResults& results) { +bool cgal_kernel::convert_impl(const taxonomy::extrusion::ptr extrusion, conversion_results& results) { cgal_shape_t shape; if (!convert(extrusion, shape)) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( extrusion->instance.id(), extrusion->matrix, - new CgalShape(shape), + new cgal_shape(shape), extrusion->surface_style )); return true; } -bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::direction3::ptr direction, double height, cgal_shape_t& shape) { +bool cgal_kernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::direction3::ptr direction, double height, cgal_shape_t& shape) { bool has_inner_bounds = !bottom_face.inner.empty(); @@ -1042,17 +1041,17 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir // CGAL::Cartesian_converter> C; if (has_inner_bounds) { - CGAL::Polygon_with_holes_2 pwh; - CGAL::Aff_transformation_3 place; + CGAL::Polygon_with_holes_2 pwh; + CGAL::Aff_transformation_3 place; // @todo check for segment intersections, analogous to other places. // they are caught now below after triangulation. face_to_poly_with_holes(bottom_face, pwh, place); - CGAL::Polygon_triangulation_decomposition_2 decompositor; - std::list> decom_polies; + CGAL::Polygon_triangulation_decomposition_2 decompositor; + std::list> decom_polies; decompositor(pwh, std::back_inserter(decom_polies)); int n_vertices = 0; - std::map point_map; + std::map point_map; for (auto& p : decom_polies) { for (auto it = p.vertices_begin(); it != p.vertices_end(); ++it) { point_map.insert({ *it, point_map.size() }); @@ -1119,7 +1118,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir } int si = 0; - for (std::vector::const_iterator current_vertex = w.begin(); + for (std::vector::const_iterator current_vertex = w.begin(); current_vertex != w.end(); ++current_vertex, ++si) { if (internal_edges.find({ wi, si }) != internal_edges.end()) { @@ -1166,7 +1165,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir return true; /* - CGAL::Nef_polyhedron_3 nef_shape = utils::create_nef_polyhedron(face_list); + CGAL::Nef_polyhedron_3 nef_shape = utils::create_nef_polyhedron(face_list); // Inner // TODO: Would be faster to triangulate top/bottom face template rather than use Nef polyhedra for subtraction for (auto &inner : bottom_face.inner) { @@ -1178,10 +1177,10 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir remove_duplicate_points_from_loop(hole_bottom_face.outer); face_list.push_back(hole_bottom_face); - for (std::vector::const_iterator current_vertex = inner.begin(); + for (std::vector::const_iterator current_vertex = inner.begin(); current_vertex != inner.end(); ++current_vertex) { - std::vector::const_iterator next_vertex = current_vertex; + std::vector::const_iterator next_vertex = current_vertex; ++next_vertex; if (next_vertex == inner.end()) { next_vertex = inner.begin(); @@ -1194,7 +1193,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir } cgal_face_t hole_top_face; - for (std::vector::const_reverse_iterator vertex = inner.rbegin(); + for (std::vector::const_reverse_iterator vertex = inner.rbegin(); vertex != inner.rend(); ++vertex) { hole_top_face.outer.push_back(*vertex + height * dir); @@ -1226,7 +1225,7 @@ bool CgalKernel::process_extrusion(const cgal_face_t& bottom_face, taxonomy::dir */ } -bool CgalKernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) { +bool cgal_kernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t &shape) { const double& height = extrusion->depth; if (height < settings_.get().get()) { logger().message(::logger::LOG_ERROR, "GEO", 89, "Non-positive extrusion height encountered for:", extrusion->instance); @@ -1241,21 +1240,21 @@ bool CgalKernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t return process_extrusion(bottom_face.front(), extrusion->direction, extrusion->depth, shape); } -CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_cube(double d) { +CGAL::Polyhedron_3 ifcopenshell::geom::utils::create_cube(double d) { cgal_face_t bottom_face; - bottom_face.outer.push_back(Kernel_::Point_3(-d, -d, -d)); - bottom_face.outer.push_back(Kernel_::Point_3(+d, -d, -d)); - bottom_face.outer.push_back(Kernel_::Point_3(+d, +d, -d)); - bottom_face.outer.push_back(Kernel_::Point_3(-d, +d, -d)); + bottom_face.outer.push_back(kernel_::Point_3(-d, -d, -d)); + bottom_face.outer.push_back(kernel_::Point_3(+d, -d, -d)); + bottom_face.outer.push_back(kernel_::Point_3(+d, +d, -d)); + bottom_face.outer.push_back(kernel_::Point_3(-d, +d, -d)); cgal_direction_t dir(0, 0, 2 * d); std::list face_list = { bottom_face }; - for (std::vector::const_iterator current_vertex = bottom_face.outer.begin(); + for (std::vector::const_iterator current_vertex = bottom_face.outer.begin(); current_vertex != bottom_face.outer.end(); ++current_vertex) { - std::vector::const_iterator next_vertex = current_vertex; + std::vector::const_iterator next_vertex = current_vertex; ++next_vertex; if (next_vertex == bottom_face.outer.end()) { @@ -1274,7 +1273,7 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_cube(double d) cgal_face_t top_face; - for (std::vector::const_reverse_iterator vertex = bottom_face.outer.rbegin(); + for (std::vector::const_reverse_iterator vertex = bottom_face.outer.rbegin(); vertex != bottom_face.outer.rend(); ++vertex) { top_face.outer.push_back(*vertex + dir); @@ -1286,7 +1285,7 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_cube(double d) } -CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_cube(const Kernel_::Point_3& lower, const Kernel_::Point_3& upper) { +CGAL::Polyhedron_3 ifcopenshell::geom::utils::create_cube(const kernel_::Point_3& lower, const kernel_::Point_3& upper) { cgal_face_t bottom_face; auto a0 = lower.cartesian(0); @@ -1297,19 +1296,19 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_cube(const Ker auto b1 = upper.cartesian(1); auto b2 = upper.cartesian(2); - bottom_face.outer.push_back(Kernel_::Point_3(a0, a1, a2)); - bottom_face.outer.push_back(Kernel_::Point_3(b0, a1, a2)); - bottom_face.outer.push_back(Kernel_::Point_3(b0, b1, a2)); - bottom_face.outer.push_back(Kernel_::Point_3(a0, b1, a2)); + bottom_face.outer.push_back(kernel_::Point_3(a0, a1, a2)); + bottom_face.outer.push_back(kernel_::Point_3(b0, a1, a2)); + bottom_face.outer.push_back(kernel_::Point_3(b0, b1, a2)); + bottom_face.outer.push_back(kernel_::Point_3(a0, b1, a2)); cgal_direction_t dir(0, 0, b2 - a2); std::list face_list = { bottom_face }; - for (std::vector::const_iterator current_vertex = bottom_face.outer.begin(); + for (std::vector::const_iterator current_vertex = bottom_face.outer.begin(); current_vertex != bottom_face.outer.end(); ++current_vertex) { - std::vector::const_iterator next_vertex = current_vertex; + std::vector::const_iterator next_vertex = current_vertex; ++next_vertex; if (next_vertex == bottom_face.outer.end()) { @@ -1328,7 +1327,7 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_cube(const Ker cgal_face_t top_face; - for (std::vector::const_reverse_iterator vertex = bottom_face.outer.rbegin(); + for (std::vector::const_reverse_iterator vertex = bottom_face.outer.rbegin(); vertex != bottom_face.outer.rend(); ++vertex) { top_face.outer.push_back(*vertex + dir); @@ -1341,7 +1340,7 @@ CGAL::Polyhedron_3 ifcopenshell::geometry::utils::create_cube(const Ker #ifndef IFOPSH_SIMPLE_KERNEL -bool CgalKernel::thin_solid(const CGAL::Nef_polyhedron_3& a, CGAL::Nef_polyhedron_3& result) { +bool cgal_kernel::thin_solid(const CGAL::Nef_polyhedron_3& a, CGAL::Nef_polyhedron_3& result) { // @todo this should be possible as a minkowski sum of facet & cube. rather than a set of boolean ops. auto precision_cube_ = precision_cube(); @@ -1361,7 +1360,7 @@ bool CgalKernel::thin_solid(const CGAL::Nef_polyhedron_3& a, CGAL::Nef_ return true; } -bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, const std::list& first_operands, const std::list>& first_operands_nef, const std::list& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3& result, boolean_operand_preprocess proc) { +bool cgal_kernel::preprocess_boolean_operand(const express::base& log_reference, const std::list& first_operands, const std::list>& first_operands_nef, const std::list& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3& result, boolean_operand_preprocess proc) { cgal_shape_t shape = shape_const; if (!shape.is_valid()) { @@ -1397,14 +1396,14 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, if (proc == PP_SNAP_POINTS_TO_FIRST_OPERAND) { static int NN = 0; - typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; + typedef CGAL::AABB_face_graph_triangle_primitive aabb_face_graph_primitive; #if CGAL_VERSION_NR >= 1060000000 - typedef CGAL::AABB_traits_3 AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 aabb_face_graph_traits; #else - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits aabb_face_graph_traits; #endif - CGAL::AABB_tree tree; + CGAL::AABB_tree tree; for (auto& op : first_operands) { auto tm = op; @@ -1414,7 +1413,7 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, std::transform(tm.facets_begin(), tm.facets_end(), tm.planes_begin(), [](auto& f) { auto h = f.halfedge(); - return CGAL::Plane_3(h->vertex()->point(), + return CGAL::Plane_3(h->vertex()->point(), h->next()->vertex()->point(), h->next()->next()->vertex()->point()); }); @@ -1461,7 +1460,7 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, } try { - result = CGAL::Nef_polyhedron_3(shape); + result = CGAL::Nef_polyhedron_3(shape); } catch (CGAL::Failure_exception& e) { logger().notice("GEO", 95, e); logger().message(::logger::LOG_ERROR, "GEO", 96, "Could not convert geometry to Nef:", log_reference); @@ -1469,8 +1468,8 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, } if (proc == PP_SNAP_PLANES_TO_FIRST_OPERAND) { - std::list planes_fixed; - std::list temp; + std::list planes_fixed; + std::list temp; for (auto& nef : first_operands_nef) { // @todo eliminate this copy (= to remove const) auto nef_copy = nef; @@ -1486,14 +1485,14 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, result = tree->map(pmap)->evaluate(); } { - std::list planes; + std::list planes; auto tree = build_halfspace_tree_decomposed(result, planes); auto pmap = snap_halfspaces_2(planes_fixed, planes, 1.e-5); result = tree->map(pmap)->evaluate(); } } } else if (proc == PP_UNIFY_PLANES_INTERNALLY) { - std::list planes; + std::list planes; auto tree = build_halfspace_tree_decomposed(result, planes); auto pmap = snap_halfspaces(planes, 1.e-6); std::wcout << tree->dump().c_str() << std::endl; @@ -1502,7 +1501,7 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, { static int i = 1; - auto x = (halfspace_tree_nary_branch*)&*tree; + auto x = (halfspace_tree_nary_branch*)&*tree; int j = 0; for (auto& a : x->operands_) { auto A = a->evaluate(); @@ -1515,7 +1514,7 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, } { static int i = 1; - auto x = (halfspace_tree_nary_branch*)&*mapped; + auto x = (halfspace_tree_nary_branch*)&*mapped; int j = 0; for (auto& a : x->operands_) { auto A = a->evaluate(); @@ -1573,7 +1572,7 @@ bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, #endif -bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list>& loops, double& z0, double& z1) { +bool cgal_kernel::process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list>& loops, double& z0, double& z1) { // @todo can also be for other boolean operations, just depth/matrix operands are different if (br->operation != taxonomy::boolean_result::SUBTRACTION) { return false; @@ -1717,7 +1716,7 @@ bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result::ptr br, s #include namespace { - bool orthogonal_edge_length(const cgal_shape_t& shape, const cgal_direction_t& face_normal, std::pair& distances) { + bool orthogonal_edge_length(const cgal_shape_t& shape, const cgal_direction_t& face_normal, std::pair& distances) { static double inf = 1.e9; // std::numeric_limits::infinity(); std::vector lengths; @@ -1767,14 +1766,14 @@ namespace { } } -bool CgalKernel::process_as_2d_polygon(const std::list>>& operands, std::list>& loops, double& z0, double& z1) { +bool cgal_kernel::process_as_2d_polygon(const std::list>>& operands, std::list>& loops, double& z0, double& z1) { if (operands.front().size() != 1) { return false; } auto& first_op = operands.front().front().second; cgal_shape_t::Facet_handle largest_face; - Kernel_::FT largest_area = 0; + kernel_::FT largest_area = 0; for (auto& f : faces(first_op)) { auto area = CGAL::Polygon_mesh_processing::face_area(f, first_op); @@ -1786,7 +1785,7 @@ bool CgalKernel::process_as_2d_polygon(const std::list f_points; - CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = largest_face->facet_begin(); + CGAL::Polyhedron_3::Halfedge_around_facet_const_circulator current_halfedge = largest_face->facet_begin(); do { f_points.push_back(current_halfedge->vertex()->point()); ++current_halfedge; @@ -1795,7 +1794,7 @@ bool CgalKernel::process_as_2d_polygon(const std::list operand_1_distance_along_normal; + std::pair operand_1_distance_along_normal; if (!orthogonal_edge_length(first_op, fnorm, operand_1_distance_along_normal)) { return false; @@ -1804,7 +1803,7 @@ bool CgalKernel::process_as_2d_polygon(const std::listbegin(); jt != it->end(); ++jt) { auto& nth_op = jt->second; - std::pair operand_n_distance_along_normal; + std::pair operand_n_distance_along_normal; if (!orthogonal_edge_length(nth_op, fnorm, operand_n_distance_along_normal)) { return false; } @@ -1845,9 +1844,9 @@ namespace { } } -bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, ConversionResults& results) { +bool cgal_kernel::convert_impl(const taxonomy::boolean_result::ptr br, conversion_results& results) { double z0, z1; - std::list> loops; + std::list> loops; if (process_as_2d_polygon(br, loops, z0, z1)) { taxonomy::style::ptr first_item_style = nullptr; @@ -1867,13 +1866,13 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion } } - std::list> pwhs; + std::list> pwhs; auto it = loops.begin(); const auto& p = *it; - CGAL::Polygon_with_holes_2 pwh(p, ++it, loops.end()); - CGAL::Gps_segment_traits_2 traits; + CGAL::Polygon_with_holes_2 pwh(p, ++it, loops.end()); + CGAL::Gps_segment_traits_2 traits; if (!CGAL::are_holes_and_boundary_pairwise_disjoint(pwh, traits)) { #ifdef IFOPSH_SIMPLE_KERNEL throw std::runtime_error("Holes are not disjoint - use a different geometry kernel"); @@ -1887,7 +1886,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion logger().notice("GEO", 101, "Holes are not disjoint"); - CGAL::Polygon_set_2 result; + CGAL::Polygon_set_2 result; auto it = loops.begin(); result.insert(*it++); for (; it != loops.end(); ++it) { @@ -1900,24 +1899,24 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion } #if 0 - CGAL::Polygon_vertical_decomposition_2 decompositor; + CGAL::Polygon_vertical_decomposition_2 decompositor; #else - CGAL::Polygon_triangulation_decomposition_2 decompositor; + CGAL::Polygon_triangulation_decomposition_2 decompositor; #endif - std::list> decom_polies; + std::list> decom_polies; for (auto& pwh : pwhs) { decompositor(pwh, std::back_inserter(decom_polies)); } - std::transform(decom_polies.begin(), decom_polies.end(), std::back_inserter(results), [this, &br, &z0, &z1, &first_item_style](const CGAL::Polygon_2& p2) { + std::transform(decom_polies.begin(), decom_polies.end(), std::back_inserter(results), [this, &br, &z0, &z1, &first_item_style](const CGAL::Polygon_2& p2) { cgal_face_t f; std::transform( p2.vertices_begin(), p2.vertices_end(), std::back_inserter(f.outer), - [](const CGAL::Point_2& p) { - return CGAL::Point_3(p.cartesian(0), p.cartesian(1), 0); + [](const CGAL::Point_2& p) { + return CGAL::Point_3(p.cartesian(0), p.cartesian(1), 0); } ); @@ -1930,10 +1929,10 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion it->point() = cgal_point_t(p.cartesian(0), p.cartesian(1), p.cartesian(2) + z0); } - return ConversionResult( + return conversion_result( br->instance.id(), br->matrix, - new CgalShape(shp), + new cgal_shape(shp), br->surface_style ? br->surface_style : first_item_style ); }); @@ -1950,19 +1949,19 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion #else bool first = true; - CGAL::Nef_polyhedron_3 a; - CGAL::Nef_nary_union_3> second_operand_collector; + CGAL::Nef_polyhedron_3 a; + CGAL::Nef_nary_union_3> second_operand_collector; size_t second_operand_collector_size = 0; taxonomy::style::ptr first_item_style = nullptr; - std::list>> operands; + std::list>> operands; for (auto& c : br->children) { - // AbstractKernel::convert(c, results); + // abstract_kernel::convert(c, results); // continue; - ConversionResults cr; + conversion_results cr; operands.emplace_back(); operands.back().first = c->instance; @@ -2003,8 +2002,8 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion wmax = 0.; } - Kernel_::Point_3 lower(uvw_min[0] - eps, uvw_min[1] - eps, wmin); - Kernel_::Point_3 upper(uvw_max[0] + eps, uvw_max[1] + eps, wmax); + kernel_::Point_3 lower(uvw_min[0] - eps, uvw_min[1] - eps, wmin); + kernel_::Point_3 upper(uvw_max[0] + eps, uvw_max[1] + eps, wmax); cgal_shape_t box = utils::create_cube(lower, upper); cgal_placement_t pl; convert_placement(p.matrix, pl); @@ -2019,7 +2018,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion } auto& w = fs.front().outer; - CGAL::Polygon_2 ps; + CGAL::Polygon_2 ps; for (auto& p : w) { ps.push_back({ p.x(), p.y() }); } @@ -2033,7 +2032,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion cgal_shape_t poly; process_extrusion(fs.front(), z, 200, poly); for (auto& v : vertices(poly)) { - v->point() = Kernel_::Point_3( + v->point() = kernel_::Point_3( v->point().cartesian(0), v->point().cartesian(1), v->point().cartesian(2) - 100 @@ -2044,8 +2043,8 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion for (auto& v : vertices(poly)) { v->point() = v->point().transform(trsf); } - CGAL::Nef_polyhedron_3 poly_nef(poly); - CGAL::Nef_polyhedron_3 box_nef(box); + CGAL::Nef_polyhedron_3 poly_nef(poly); + CGAL::Nef_polyhedron_3 box_nef(box); auto intersection = poly_nef * box_nef; cgal_shape_t intersection_poly; intersection.convert_to_polyhedron(intersection_poly); @@ -2057,7 +2056,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion continue; } - AbstractKernel::convert(c, cr); + abstract_kernel::convert(c, cr); if (first && br->operation == taxonomy::boolean_result::SUBTRACTION) { first_item_style = c->surface_style; @@ -2068,7 +2067,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion } for (auto it = cr.begin(); it != cr.end(); ++it) { - cgal_shape_t entity_shape_unlocated = *std::static_pointer_cast(it->Shape()); + cgal_shape_t entity_shape_unlocated = *std::static_pointer_cast(it->Shape()); cgal_shape_t entity_shape(entity_shape_unlocated); if (!it->Placement()->is_identity()) { cgal_placement_t trsf; @@ -2086,10 +2085,10 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion /* for (auto& li : operands) { for (auto& s : li.second) { - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( br->instance.data().id(), br->matrix, - new CgalShape(s), + new cgal_shape(s), br->surface_style ? br->surface_style : first_item_style )); } @@ -2108,10 +2107,10 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion // debugging trick for (auto& p : operands) { for (auto& s : p.second) { - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( br->instance.data().id(), br->matrix, - new CgalShape(s), + new cgal_shape(s), br->surface_style ? br->surface_style : first_item_style )); } @@ -2122,15 +2121,15 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion first = true; std::list ops; - std::list> nefops; - std::list all_operand_planes; + std::list> nefops; + std::list all_operand_planes; for (auto& li : operands) { auto entity_instance = li.first; for (auto& entity_shape : li.second) { - CGAL::Nef_polyhedron_3 nef; + CGAL::Nef_polyhedron_3 nef; if (!preprocess_boolean_operand(entity_instance, ops, nefops, all_operand_planes, entity_shape, nef, // Snap boolean subtraction operands first ? PP_NONE : PP_MINKOWSKY_DILATE/*PP_SNAP_PLANES_TO_FIRST_OPERAND*/)) { @@ -2164,7 +2163,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion cgal_shape_t a_poly; - // CGAL::Nef_polyhedron_3 b; + // CGAL::Nef_polyhedron_3 b; // thin_solid(a, b); try { @@ -2174,10 +2173,10 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( br->instance.id(), br->matrix, - new CgalShape(a_poly), + new cgal_shape(a_poly), br->surface_style ? br->surface_style : first_item_style )); return true; @@ -2185,20 +2184,20 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion #endif } -PolyhedronBuilder::PolyhedronBuilder(std::list* face_list, logger& logger) : face_list(face_list), logger_(logger) { +polyhedron_builder::polyhedron_builder(std::list* face_list, logger& logger) : face_list(face_list), logger_(logger) { } #include // @todo shouldn't we just always use polygon_soup_to_polygon_mesh instead of the incremental builder? #include -void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) { - // std::list points; - std::map points; +void polyhedron_builder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) { + // std::list points; + std::map points; std::vector> facet_vertices; facet_vertices.reserve(face_list->size()); - CGAL::Polyhedron_incremental_builder_3::HalfedgeDS> builder(hds, true); - std::list unique_points; + CGAL::Polyhedron_incremental_builder_3::HalfedgeDS> builder(hds, true); + std::list unique_points; for (auto &face : *face_list) { @@ -2216,9 +2215,9 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) } else { - std::map points_2d; - CGAL::Polygon_with_holes_2 pwh; - CGAL::Aff_transformation_3 place; + std::map points_2d; + CGAL::Polygon_with_holes_2 pwh; + CGAL::Aff_transformation_3 place; face_to_poly_with_holes(face, pwh, place); // we assume the pwh constructor leaves points in order @@ -2248,8 +2247,8 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) } } - CGAL::Polygon_triangulation_decomposition_2 decompositor; - std::list> decom_polies; + CGAL::Polygon_triangulation_decomposition_2 decompositor; + std::list> decom_polies; decompositor(pwh, std::back_inserter(decom_polies)); for (auto& p : decom_polies) { @@ -2298,7 +2297,7 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) // @todo ugh - std::vector unique_points_as_vector(unique_points.begin(), unique_points.end()); + std::vector unique_points_as_vector(unique_points.begin(), unique_points.end()); if (!CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(facet_vertices)) { // @todo seems to return false now, almost always? @@ -2351,7 +2350,7 @@ void PolyhedronBuilder::operator()(CGAL::Polyhedron_3::HalfedgeDS &hds) // We just always use polygon_soup_to_polygon_mesh() to now. // @todo figure out the downsides of this approach. -builder.begin_surface(points.size(), facet_vertices.size()); // , 0, CGAL::Polyhedron_incremental_builder_3::HalfedgeDS>::ABSOLUTE_INDEXING); +builder.begin_surface(points.size(), facet_vertices.size()); // , 0, CGAL::Polyhedron_incremental_builder_3::HalfedgeDS>::ABSOLUTE_INDEXING); for (auto& point : unique_points) { builder.add_vertex(point); diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.h b/src/ifcgeom/kernels/cgal/CgalKernel.h index 4001409ebb..e1a7b0dedf 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.h +++ b/src/ifcgeom/kernels/cgal/CgalKernel.h @@ -38,7 +38,7 @@ if ( it != cache.T.end() ) { e = it->second; return true; } */ #ifdef IFOPSH_SIMPLE_KERNEL -#define CgalKernel SimpleCgalKernel +#define cgal_kernel SimpleCgalKernel #define create_cube create_cube_simple #define create_polyhedron create_polyhedron_simple #endif @@ -56,22 +56,22 @@ if ( it != cache.T.end() ) { e = it->second; return true; } #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace utils { - IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_cube(double d); - IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_cube(const Kernel_::Point_3& lower, const Kernel_::Point_3& upper); - IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(std::list &face_list, bool stitch_borders = false, logger& logger = ::logger::root()); + IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_cube(double d); + IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_cube(const kernel_::Point_3& lower, const kernel_::Point_3& upper); + IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(std::list &face_list, bool stitch_borders = false, logger& logger = ::logger::root()); #ifndef IFOPSH_SIMPLE_KERNEL - IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(const CGAL::Nef_polyhedron_3 &nef_polyhedron, logger& logger = ::logger::root()); - IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(std::list &face_list, logger& logger = ::logger::root()); - IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, logger& logger = ::logger::root()); + IFC_GEOMLIBRARY_API CGAL::Polyhedron_3 create_polyhedron(const CGAL::Nef_polyhedron_3 &nef_polyhedron, logger& logger = ::logger::root()); + IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(std::list &face_list, logger& logger = ::logger::root()); + IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3 create_nef_polyhedron(CGAL::Polyhedron_3 &polyhedron, logger& logger = ::logger::root()); #endif } namespace kernels { - class IFC_GEOMLIBRARY_API CgalKernel : public AbstractKernel { + class IFC_GEOMLIBRARY_API cgal_kernel : public abstract_kernel { private: #ifndef IFOPSH_SIMPLE_KERNEL enum boolean_operand_preprocess { @@ -82,23 +82,23 @@ namespace ifcopenshell { PP_NONE }; - bool preprocess_boolean_operand(const express::Base& log_reference, const std::list& first_operands, const std::list>& first_operands_nef, const std::list& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3& result, boolean_operand_preprocess proc); + bool preprocess_boolean_operand(const express::base& log_reference, const std::list& first_operands, const std::list>& first_operands_nef, const std::list& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3& result, boolean_operand_preprocess proc); - bool thin_solid(const CGAL::Nef_polyhedron_3& a, CGAL::Nef_polyhedron_3& result); + bool thin_solid(const CGAL::Nef_polyhedron_3& a, CGAL::Nef_polyhedron_3& result); - CGAL::Nef_polyhedron_3 create_precision_cube_() const { + CGAL::Nef_polyhedron_3 create_precision_cube_() const { auto cc = utils::create_cube(settings_.get().get()); - return CGAL::Nef_polyhedron_3(cc); + return CGAL::Nef_polyhedron_3(cc); } #endif public: - CgalKernel(const Settings& settings, ::logger& logger = ::logger::root()) - : AbstractKernel("cgal", settings, logger) + cgal_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) + : abstract_kernel("cgal", settings, logger) {} - virtual AbstractKernel* clone(::logger& logger) const { - return new CgalKernel(settings(), logger); + virtual abstract_kernel* clone(::logger& logger) const { + return new cgal_kernel(settings(), logger); } virtual bool supports_boolean_operations() const { @@ -116,19 +116,19 @@ namespace ifcopenshell { bool convert(const taxonomy::shell::ptr, cgal_shape_t&); bool process_extrusion(const cgal_face_t& bottom_face, taxonomy::direction3::ptr direction, double height, cgal_shape_t& shape); - bool process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list>& loops, double& z0, double& z1); - bool process_as_2d_polygon(const std::list>>& operands, std::list>& loops, double& z0, double& z1); + bool process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list>& loops, double& z0, double& z1); + bool process_as_2d_polygon(const std::list>>& operands, std::list>& loops, double& z0, double& z1); - virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const taxonomy::extrusion::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&); + virtual bool convert_impl(const taxonomy::shell::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const taxonomy::extrusion::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const taxonomy::boolean_result::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const taxonomy::solid::ptr, ifcopenshell::geom::conversion_results&); - virtual bool convert_openings(const express::Base& entity, const std::vector>& openings, - const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes); + virtual bool convert_openings(const express::base& entity, const std::vector>& openings, + const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes); #ifndef IFOPSH_SIMPLE_KERNEL - CGAL::Nef_polyhedron_3 precision_cube() const { return create_precision_cube_(); } + CGAL::Nef_polyhedron_3 precision_cube() const { return create_precision_cube_(); } #endif }; diff --git a/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h b/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h index e575de5349..92e49adc79 100644 --- a/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h +++ b/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h @@ -54,7 +54,7 @@ // Functor to lexicographically sort Plane_3 template -struct PlaneLess { +struct plane_less { bool operator()(const typename Kernel::Plane_3& lhs, const typename Kernel::Plane_3& rhs) const { auto lhs_a = lhs.a(); auto lhs_b = lhs.b(); @@ -70,7 +70,7 @@ struct PlaneLess { // Functor to hash Plane_3 template -struct PlaneHash { +struct plane_hash { size_t operator()(const CGAL::Plane_3& plane) const noexcept { // @todo why can I only get this to work on double? @@ -86,8 +86,8 @@ struct PlaneHash { // Utility function to return Nef facet information as string template std::string dump_facet(typename CGAL::Nef_polyhedron_3::Halffacet_const_handle h) { - typedef typename CGAL::Nef_polyhedron_3::SHalfedge_const_handle SHalfedge_const_handle; - typedef typename CGAL::Nef_polyhedron_3::SHalfedge_around_facet_const_circulator SHalfedge_around_facet_const_circulator; + typedef typename CGAL::Nef_polyhedron_3::SHalfedge_const_handle shalfedge_const_handle; + typedef typename CGAL::Nef_polyhedron_3::SHalfedge_around_facet_const_circulator shalfedge_around_facet_const_circulator; std::ostringstream oss; @@ -95,10 +95,10 @@ std::string dump_facet(typename CGAL::Nef_polyhedron_3::Halffacet_const_ oss << "Facet plane=" << p << std::endl; auto fc = h->facet_cycles_begin(); - auto se = SHalfedge_const_handle(fc); + auto se = shalfedge_const_handle(fc); CGAL_assertion(se != 0); - SHalfedge_around_facet_const_circulator hc_start(se); - SHalfedge_around_facet_const_circulator hc_end(hc_start); + shalfedge_around_facet_const_circulator hc_start(se); + shalfedge_around_facet_const_circulator hc_end(hc_start); CGAL_For_all(hc_start, hc_end) { oss << " co=" << hc_start->source()->center_vertex()->point() << std::endl; } @@ -114,8 +114,8 @@ enum halfspace_operation { // Map of Plane_3 -> Plane_3 used when applied snapping template -using plane_map = std::map>; -// using plane_map = std::unordered_map>; +using plane_map = std::map>; +// using plane_map = std::unordered_map>; template typename Kernel::Plane_3 normalized_plane_for_map(const typename Kernel::Plane_3& plane) { @@ -134,10 +134,10 @@ typename Kernel::Plane_3 normalized_plane_for_map(const typename Kernel::Plane_3 ); } -// Lexicographic comparator for CGAL Point_d (operator< is deleted in CGAL 6.x) -struct Point_d_4d_Less { - using Point_d = CGAL::Epick_d>::Point_d; - bool operator()(const Point_d& a, const Point_d& b) const { +// Lexicographic comparator for CGAL point_d (operator< is deleted in CGAL 6.x) +struct point_d_4d_less { + using point_d = CGAL::Epick_d>::Point_d; + bool operator()(const point_d& a, const point_d& b) const { return std::lexicographical_compare( a.cartesian_begin(), a.cartesian_end(), b.cartesian_begin(), b.cartesian_end()); @@ -151,29 +151,29 @@ plane_map snap_halfspaces(const std::list>& planes // @todo this should incorporate some recursive or actual clustering approach so that // in cases of many approximate neighbours it still produces good results. - typedef CGAL::Epick_d> KdKernel; - typedef KdKernel::Point_d Point_d; - typedef CGAL::Search_traits_d TreeTraits; - typedef CGAL::Kd_tree Tree; - typedef CGAL::Fuzzy_sphere Fuzzy_sphere; + typedef CGAL::Epick_d> kd_kernel; + typedef kd_kernel::Point_d point_d; + typedef CGAL::Search_traits_d tree_traits; + typedef CGAL::Kd_tree tree; + typedef CGAL::Fuzzy_sphere fuzzy_sphere; plane_map result; - std::map, Point_d_4d_Less> neighbours; - std::map>, Point_d_4d_Less> originals; - std::vector planes_as_point; + std::map, point_d_4d_less> neighbours; + std::map>, point_d_4d_less> originals; + std::vector planes_as_point; for (auto& p : planes) { // @todo can we skip normalization (simply divide by largest component perhaps) double l = std::sqrt(CGAL::to_double(p.orthogonal_vector().squared_length())); // @todo how to properly initialize using p._().exact() without converting to double? - Point_d pp(CGAL::to_double(p.a()) / l, CGAL::to_double(p.b()) / l, CGAL::to_double(p.c()) / l, CGAL::to_double(p.d()) / l); + point_d pp(CGAL::to_double(p.a()) / l, CGAL::to_double(p.b()) / l, CGAL::to_double(p.c()) / l, CGAL::to_double(p.d()) / l); planes_as_point.push_back(pp); originals[pp].push_back(p); } // @todo should we have a proper distance metric for plane equations - Tree kdtree(planes_as_point.begin(), planes_as_point.end()); + tree kdtree(planes_as_point.begin(), planes_as_point.end()); auto plit = planes.begin(); for (size_t i = 0; i < planes.size(); ++i) { @@ -183,19 +183,19 @@ plane_map snap_halfspaces(const std::list>& planes auto& query = planes_as_point[i]; - Fuzzy_sphere fs(query, search_radius, 0.); + fuzzy_sphere fs(query, search_radius, 0.); // std::cout << "q " << query << std::endl; - std::list results_pos, results_neg; + std::list results_pos, results_neg; kdtree.search(std::back_inserter(results_pos), fs); - Point_d n(-query[0], -query[1], -query[2], -query[3]); - Fuzzy_sphere fsn(n, search_radius, 0.); + point_d n(-query[0], -query[1], -query[2], -query[3]); + fuzzy_sphere fsn(n, search_radius, 0.); kdtree.search(std::back_inserter(results_neg), fsn); - auto sum = std::accumulate(++results_pos.begin(), results_pos.end(), results_pos.front(), [](Point_d a, Point_d b) {return Point_d(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]); }); + auto sum = std::accumulate(++results_pos.begin(), results_pos.end(), results_pos.front(), [](point_d a, point_d b) {return point_d(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]); }); int N = results_pos.size(); - auto sum2 = std::accumulate(results_neg.begin(), results_neg.end(), sum, [](Point_d a, Point_d b) {return Point_d(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]); }); + auto sum2 = std::accumulate(results_neg.begin(), results_neg.end(), sum, [](point_d a, point_d b) {return point_d(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]); }); N += results_neg.size(); auto avg = CGAL::Plane_3(sum2[0] / N, sum2[1] / N, sum2[2] / N, sum2[3] / N); @@ -224,45 +224,45 @@ plane_map snap_halfspaces_2(const std::list>& plan // @todo this should incorporate some recursive or actual clustering approach so that // in cases of many approximate neighbours it still produces good results. - typedef CGAL::Epick_d> KdKernel; - typedef KdKernel::Point_d Point_d; - typedef CGAL::Search_traits_d TreeTraits; - typedef CGAL::Kd_tree Tree; - typedef CGAL::Fuzzy_sphere Fuzzy_sphere; + typedef CGAL::Epick_d> kd_kernel; + typedef kd_kernel::Point_d point_d; + typedef CGAL::Search_traits_d tree_traits; + typedef CGAL::Kd_tree tree; + typedef CGAL::Fuzzy_sphere fuzzy_sphere; plane_map result; - std::vector planes_as_point; - std::map, Point_d_4d_Less> normalized_to_original; + std::vector planes_as_point; + std::map, point_d_4d_less> normalized_to_original; for (auto& p : planes_fixed) { // @todo can we skip normalization (simply divide by largest component perhaps) double l = std::sqrt(CGAL::to_double(p.orthogonal_vector().squared_length())); // @todo how to properly initialize using p._().exact() without converting to double? - Point_d pp(CGAL::to_double(p.a()) / l, CGAL::to_double(p.b()) / l, CGAL::to_double(p.c()) / l, CGAL::to_double(p.d()) / l); + point_d pp(CGAL::to_double(p.a()) / l, CGAL::to_double(p.b()) / l, CGAL::to_double(p.c()) / l, CGAL::to_double(p.d()) / l); planes_as_point.push_back(pp); normalized_to_original.insert({ pp, p }); } // @todo should we have a proper distance metric for plane equations - Tree kdtree(planes_as_point.begin(), planes_as_point.end()); + tree kdtree(planes_as_point.begin(), planes_as_point.end()); auto plit = planes.begin(); for (; plit != planes.end(); ++plit) { // @todo rewrite to use 1 nearest neighbour double l = std::sqrt(CGAL::to_double(plit->orthogonal_vector().squared_length())); - Point_d query(CGAL::to_double(plit->a()) / l, CGAL::to_double(plit->b()) / l, CGAL::to_double(plit->c()) / l, CGAL::to_double(plit->d()) / l); - Fuzzy_sphere fs(query, search_radius, 0.); + point_d query(CGAL::to_double(plit->a()) / l, CGAL::to_double(plit->b()) / l, CGAL::to_double(plit->c()) / l, CGAL::to_double(plit->d()) / l); + fuzzy_sphere fs(query, search_radius, 0.); // std::cout << "q " << *plit << std::endl; - std::list results; + std::list results; kdtree.search(std::back_inserter(results), fs); if (!results.empty()) { result.insert({ *plit, normalized_to_original.find(results.front())->second }); // std::cout << " " << normalized_to_original.find(results.front())->second << std::endl; } else { - Point_d n(-query[0], -query[1], -query[2], -query[3]); - Fuzzy_sphere fsn(n, search_radius, 0.); + point_d n(-query[0], -query[1], -query[2], -query[3]); + fuzzy_sphere fsn(n, search_radius, 0.); kdtree.search(std::back_inserter(results), fsn); if (!results.empty()) { result.insert({ *plit, normalized_to_original.find(results.front())->second.opposite() }); @@ -450,14 +450,14 @@ void extrude(LoopType bottom, const CGAL::Vector_3& V, CGAL::Polyhedron_ // Create cube of half-distance d template void createCube(CGAL::Polyhedron_3& P, double d) { - typedef CGAL::Point_3 Point; - typedef std::array, 4> Quad; + typedef CGAL::Point_3 point; + typedef std::array, 4> quad; - Quad bottom = { { - Point(-d, -d, -d), - Point(+d, -d, -d), - Point(+d, +d, -d), - Point(-d, +d, -d) + quad bottom = { { + point(-d, -d, -d), + point(+d, -d, -d), + point(+d, +d, -d), + point(-d, +d, -d) } }; CGAL::Vector_3 V(0, 0, d * 2); @@ -523,11 +523,11 @@ public: // Triangulate a nef facet. Used for intersection check to find convex subcomponent template std::vector> triangulate_nef_facet(typename CGAL::Nef_polyhedron_3::Halffacet_const_handle f) { - typedef typename CGAL::Nef_polyhedron_3::SHalfedge_around_facet_const_circulator SHalfedge_around_facet_const_circulator; + typedef typename CGAL::Nef_polyhedron_3::SHalfedge_around_facet_const_circulator shalfedge_around_facet_const_circulator; std::vector ps; - SHalfedge_around_facet_const_circulator it(f->facet_cycles_begin()); - SHalfedge_around_facet_const_circulator first(it); + shalfedge_around_facet_const_circulator it(f->facet_cycles_begin()); + shalfedge_around_facet_const_circulator first(it); CGAL_For_all(it, first) { ps.push_back(it->source()->center_vertex()->point()); } @@ -548,25 +548,25 @@ std::vector> triangulate_nef_facet(typename CGAL::Nef_p enum EdgeType { CONCAVE, CONVEX }; template -struct VertexProperties { +struct vertex_properties { typename CGAL::Nef_polyhedron_3::Halffacet_const_handle facet; size_t original_index; }; template -using Graph = boost::adjacency_list, +using graph = boost::adjacency_list, boost::property>; // Build a boost graph with vertex corresponding to Nef facet, edge corresponding to Nef edge // marked as reflex or not. template -Graph build_facet_edge_graph(const CGAL::Nef_polyhedron_3& poly) { - typedef typename CGAL::Nef_polyhedron_3::Halffacet_const_handle Halffacet_const_handle; +graph build_facet_edge_graph(const CGAL::Nef_polyhedron_3& poly) { + typedef typename CGAL::Nef_polyhedron_3::Halffacet_const_handle halffacet_const_handle; - Graph G; + graph G; - std::map facet_to_idx; + std::map facet_to_idx; for (auto it = poly.vertices_begin(); it != poly.vertices_end(); ++it) { for (auto a = it->shalfedges_begin(); a != it->shalfedges_end(); ++a) { @@ -617,14 +617,14 @@ Graph build_facet_edge_graph(const CGAL::Nef_polyhedron_3& poly) } template -void dump_facets(Graph& G) { +void dump_facets(graph& G) { for (size_t ii = 0; ii < boost::num_vertices(G); ++ii) { // std::cout << ii << " " << dump_facet(G[ii].facet) << std::endl; } } /* -struct Intersection_visitor { +struct intersection_visitor { typedef void result_type; void operator()(const Kernel::Point_3& p) const { @@ -642,7 +642,7 @@ struct Intersection_visitor { */ template -struct Segment_collector { +struct segment_collector { typedef void result_type; std::optional> segment; @@ -669,8 +669,8 @@ public: convex_subcomponent_visitor(EdgeType edgetype, ComponentMap& component) : edgetype_(edgetype), components_(component) {} - template - bool tree_edge(Edge e, const Graph& g) { + template + bool tree_edge(Edge e, const graph& g) { if (std::get(boost::edge_weight, g, e) == edgetype_) { auto srcid = boost::source(e, g); auto tgtid = boost::target(e, g); @@ -688,7 +688,7 @@ public: if (*tgt == -1) { bool tgt_has_any_reflex_edge = false; - typename boost::graph_traits::out_edge_iterator ei, ei_end; + typename boost::graph_traits::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = boost::out_edges(tgtid, g); ei != ei_end; ++ei) { if (std::get(boost::edge_weight, g, *ei) != edgetype_) { tgt_has_any_reflex_edge = true; @@ -734,9 +734,9 @@ public: auto x = CGAL::intersection(plane_tgt, t); if (x) { // std::cout << " triangle: " << t << std::endl; - // Intersection_visitor v; + // intersection_visitor v; // std::visit([](auto x) {std::cout << " intersects: " << x << std::endl; })(*x); - Segment_collector sc; + segment_collector sc; std::visit(sc)(*x); if (sc.segment) { if (!std::any_of(edges_i.begin(), edges_i.end(), [&sc](CGAL::Segment_3& s) { @@ -745,7 +745,7 @@ public: if (!xy) { return false; } - Segment_collector scy; + segment_collector scy; std::visit(scy)(*xy); return (bool)scy.segment; })) { @@ -784,7 +784,7 @@ public: // bfs implementation to that respects a predicate on determining whether an edge is applicable template -void bfs(Graph& g, size_t start_vertex, Fn& fn) { +void bfs(graph& g, size_t start_vertex, Fn& fn) { std::queue queue; queue.push(start_vertex); @@ -795,7 +795,7 @@ void bfs(Graph& g, size_t start_vertex, Fn& fn) { auto cur = queue.front(); queue.pop(); - typename boost::graph_traits>::out_edge_iterator ei, ei_end; + typename boost::graph_traits>::out_edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = boost::out_edges(cur, g); ei != ei_end; ++ei) { auto s = boost::source(*ei, g); auto t = boost::target(*ei, g); @@ -821,14 +821,14 @@ void bfs(Graph& g, size_t start_vertex, Fn& fn) { // builds a tree of halfspaces from an input nef polyhedron // checks whether output is equivalent and if not uses a convex decomposition first template -std::unique_ptr> build_halfspace_tree(Graph& G, CGAL::Nef_polyhedron_3& poly, bool negate = false, int level=0) { - typedef boost::filtered_graph, boost::keep_all, std::function::vertex_descriptor)>> FilteredGraph; +std::unique_ptr> build_halfspace_tree(graph& G, CGAL::Nef_polyhedron_3& poly, bool negate = false, int level=0) { + typedef boost::filtered_graph, boost::keep_all, std::function::vertex_descriptor)>> filtered_graph; auto edge_trait = negate ? CONCAVE : CONVEX; /* bool all_convex = true; - typename boost::graph_traits>::edge_iterator ei, ei_end; + typename boost::graph_traits>::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = boost::edges(G); ei != ei_end; ++ei) { if (std::get(boost::edge_weight, G, *ei) != edge_trait) { // all_convex = false; @@ -850,11 +850,11 @@ std::unique_ptr> build_halfspace_tree(Graph& std::unique_ptr> tree; std::list>> root_expression; - auto included_in_vertex_subset_0 = [&components_0, &i](typename Graph::vertex_descriptor vd) { + auto included_in_vertex_subset_0 = [&components_0, &i](typename graph::vertex_descriptor vd) { return components_0[vd] == i; }; - FilteredGraph sub_graph_filtered_0(G, boost::keep_all{}, included_in_vertex_subset_0); - Graph sub_graph_0; + filtered_graph sub_graph_filtered_0(G, boost::keep_all{}, included_in_vertex_subset_0); + graph sub_graph_0; boost::copy_graph(sub_graph_filtered_0, sub_graph_0); std::vector components(boost::num_vertices(sub_graph_0), -1); @@ -915,7 +915,7 @@ std::unique_ptr> build_halfspace_tree(Graph& size_t vidx = 0; // Convex decomposition is not always optimal, sometimes contains coplanar facets - std::unordered_set> plane_set; + std::unordered_set> plane_set; for (auto it = components.begin(); it != components.end(); ++it, ++vidx) { auto fct = sub_graph_0[vidx].facet; if (negate) { @@ -929,11 +929,11 @@ std::unique_ptr> build_halfspace_tree(Graph& tree.reset(new halfspace_tree_nary_branch(OP_INTERSECTION, std::move(root_expression))); - auto included_in_vertex_subset = [&components, &largest_component_idx](typename Graph::vertex_descriptor vd) { + auto included_in_vertex_subset = [&components, &largest_component_idx](typename graph::vertex_descriptor vd) { return components[vd] != largest_component_idx; }; - FilteredGraph sub_graph_filtered(sub_graph_0, boost::keep_all{}, included_in_vertex_subset); - Graph sub_graph; + filtered_graph sub_graph_filtered(sub_graph_0, boost::keep_all{}, included_in_vertex_subset); + graph sub_graph; // @todo can we go without this copy? boost::copy_graph(sub_graph_filtered, sub_graph); @@ -1011,7 +1011,7 @@ std::unique_ptr> build_halfspace_tree(Graph& // using the Polygon_mesh_processing package and Polygon_triangulation_decomposition_2 // in case of facets with inner bounds. template -struct Halffacet_collector { +struct halffacet_collector { std::set::Halffacet_const_handle> facets; void visit(typename CGAL::Nef_polyhedron_3::Vertex_const_handle) {} void visit(typename CGAL::Nef_polyhedron_3::Halfedge_const_handle) {} @@ -1029,7 +1029,7 @@ struct Halffacet_collector { // using the Polygon_mesh_processing package and Polygon_triangulation_decomposition_2 // in case of facets with inner bounds. template -class Polysoup_builder { +class polysoup_builder { private: std::map, size_t> verts; std::vector> facets; @@ -1219,7 +1219,7 @@ std::unique_ptr> build_halfspace_tree_decomposed(cons std::list>> sub_expression; if (ci->mark()) { - Halffacet_collector vis; + halffacet_collector vis; poly.visit_shell_objects(typename CGAL::Nef_polyhedron_3::SFace_const_handle(ci->shells_begin()), vis); for (auto& f : vis.facets) { sub_expression.emplace_back(new halfspace_tree_plane(f->plane())); @@ -1240,7 +1240,7 @@ std::unique_ptr> build_halfspace_tree_decomposed(cons if (sub_expression.size() != vis.facets.size()) { - Polysoup_builder vis2; + polysoup_builder vis2; poly.visit_shell_objects(CGAL::Nef_polyhedron_3::SFace_const_handle(ci->shells_begin()), vis2); { @@ -1294,9 +1294,9 @@ std::unique_ptr> build_halfspace_tree_is_decomposed(c } template -size_t edge_contract(Graph& G) { +size_t edge_contract(graph& G) { size_t n = 0; - typename boost::graph_traits>::edge_iterator ei, ei_end; + typename boost::graph_traits>::edge_iterator ei, ei_end; bool has_contracted = true; while (has_contracted) { has_contracted = false; @@ -1334,7 +1334,7 @@ template bool convert_to_polyhedron(const CGAL::Nef_polyhedron_3& a, CGAL::Polyhedron_3& b, size_t volume_index=0) { const bool all_volumes = volume_index == std::numeric_limits::max(); size_t v = 0; - Polysoup_builder vis; + polysoup_builder vis; for (auto it = a.volumes_begin(); it != a.volumes_end(); ++it) { if (!it->mark()) { continue; @@ -1359,7 +1359,7 @@ bool convert_to_polyhedron(const CGAL::Nef_polyhedron_3& a, CGAL::Polyhe template bool write_to_obj(const CGAL::Nef_polyhedron_3& a, std::ostream& ofs, size_t volume_index = 0) { size_t v = 0; - Polysoup_builder vis; + polysoup_builder vis; for (auto it = a.volumes_begin(); it != a.volumes_end(); ++it) { if (!it->mark()) { continue; diff --git a/src/ifcgeom/kernels/cgal/plugin.cpp b/src/ifcgeom/kernels/cgal/plugin.cpp index 1e440100b1..2c69052ce7 100644 --- a/src/ifcgeom/kernels/cgal/plugin.cpp +++ b/src/ifcgeom/kernels/cgal/plugin.cpp @@ -27,7 +27,7 @@ #endif namespace ifcopenshell { - namespace geometry { + namespace geom { namespace kernels { namespace cgal_plugin { @@ -40,7 +40,7 @@ namespace ifcopenshell { constexpr const char* plugin_name = "cgal"; constexpr const char* backend_id = "cgal"; constexpr bool supports_boolean_operations = true; - using kernel_type = CgalKernel; + using kernel_type = cgal_kernel; #endif plugin::abi_info plugin_abi() { @@ -51,7 +51,7 @@ namespace ifcopenshell { return kernel_plugin_metadata(plugin_name); } - AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) { + abstract_kernel* create_kernel(ifcopenshell::file*, ifcopenshell::geom::settings& settings) { return new kernel_type(settings); } @@ -67,6 +67,6 @@ namespace ifcopenshell { } } -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::cgal_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::cgal_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::cgal_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::cgal_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::cgal_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::cgal_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) diff --git a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp index 2ee85e0ca2..0eb4ae042b 100644 --- a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp +++ b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.cpp @@ -10,15 +10,15 @@ #include #include -using IfcGeom::ConversionResultShape; -using IfcGeom::OpaqueCoordinate; -using IfcGeom::OpaqueNumber; +using ifcopenshell::geom::conversion_result_shape; +using ifcopenshell::geom::opaque_coordinate; +using ifcopenshell::geom::opaque_number; namespace { - using Mesh = manifold::MeshGL64; + using mesh_type = manifold::MeshGL64; - Mesh transform_mesh(const Mesh& mesh, const ifcopenshell::geometry::taxonomy::matrix4& place) { - Mesh result = mesh; + mesh_type transform_mesh(const mesh_type& mesh, const ifcopenshell::geom::taxonomy::matrix4& place) { + mesh_type result = mesh; const auto& m = place.ccomponents(); const bool flip = m.block<3, 3>(0, 0).determinant() < 0.; for (size_t i = 0; i < mesh.NumVert(); ++i) { @@ -41,7 +41,7 @@ namespace { return result; } - std::optional make_manifold(const Mesh& mesh) { + std::optional make_manifold(const mesh_type& mesh) { manifold::Manifold solid(mesh); if (solid.Status() == manifold::Manifold::Error::NoError) { return solid; @@ -49,7 +49,7 @@ namespace { return std::nullopt; } - manifold::Box mesh_bbox(const Mesh& mesh) { + manifold::Box mesh_bbox(const mesh_type& mesh) { if (!mesh.NumVert()) { return {}; } @@ -79,7 +79,7 @@ namespace { return size[0] * size[1] * size[2]; } - double triangle_area(const Mesh& mesh, size_t tri) { + double triangle_area(const mesh_type& mesh, size_t tri) { auto idx = [&](int corner) { return mesh.triVerts[tri * 3 + corner]; }; auto point = [&](uint32_t i) { return Eigen::Vector3d( @@ -93,7 +93,7 @@ namespace { return 0.5 * ((b - a).cross(c - a)).norm(); } - double mesh_area(const Mesh& mesh) { + double mesh_area(const mesh_type& mesh) { double area = 0.; for (size_t i = 0; i < mesh.NumTri(); ++i) { area += triangle_area(mesh, i); @@ -101,7 +101,7 @@ namespace { return area; } - double mesh_volume(const Mesh& mesh) { + double mesh_volume(const mesh_type& mesh) { double volume = 0.; for (size_t i = 0; i < mesh.NumTri(); ++i) { auto idx = [&](int corner) { return mesh.triVerts[i * 3 + corner]; }; @@ -119,14 +119,14 @@ namespace { return std::abs(volume); } - struct EdgeHash { + struct edge_hash { size_t operator()(const std::pair& edge) const { return std::hash()((uint64_t(edge.first) << 32) ^ uint64_t(edge.second)); } }; - std::unordered_map, int, EdgeHash> count_edges(const Mesh& mesh) { - std::unordered_map, int, EdgeHash> edges; + std::unordered_map, int, edge_hash> count_edges(const mesh_type& mesh) { + std::unordered_map, int, edge_hash> edges; for (size_t i = 0; i < mesh.NumTri(); ++i) { uint32_t tri[3] = { (uint32_t) mesh.triVerts[i * 3 + 0], @@ -145,7 +145,7 @@ namespace { return edges; } - double mesh_length(const Mesh& mesh) { + double mesh_length(const mesh_type& mesh) { double length = 0.; auto edges = count_edges(mesh); for (const auto& pair : edges) { @@ -164,40 +164,40 @@ namespace { return length; } - int mesh_edges(const Mesh& mesh) { + int mesh_edges(const mesh_type& mesh) { return (int)count_edges(mesh).size(); } - ifcopenshell::geometry::ManifoldPart make_part(const manifold::Manifold& solid) { + ifcopenshell::geom::manifold_part make_part(const manifold::Manifold& solid) { return { solid.GetMeshGL64(), solid }; } - ifcopenshell::geometry::ManifoldPart make_box_part(const manifold::Box& box) { + ifcopenshell::geom::manifold_part make_box_part(const manifold::Box& box) { const auto size = box.Size(); auto solid = manifold::Manifold::Cube(manifold::vec3(size[0], size[1], size[2]), false).Translate(box.min); return make_part(solid); } } -ifcopenshell::geometry::ManifoldShape::ManifoldShape(const manifold::Manifold& solid) { +ifcopenshell::geom::manifold_shape::manifold_shape(const manifold::Manifold& solid) { auto copy = solid; auto with_normals = copy.CalculateNormals(3); parts_.push_back({with_normals.GetMeshGL64(), solid}); } -ifcopenshell::geometry::ManifoldShape::ManifoldShape(const ManifoldPart& part) +ifcopenshell::geom::manifold_shape::manifold_shape(const manifold_part& part) : parts_{ part } {} -ifcopenshell::geometry::ManifoldShape::ManifoldShape(ManifoldPart&& part) +ifcopenshell::geom::manifold_shape::manifold_shape(manifold_part&& part) : parts_{ std::move(part) } {} -ifcopenshell::geometry::ManifoldShape::ManifoldShape(const std::vector& parts) +ifcopenshell::geom::manifold_shape::manifold_shape(const std::vector& parts) : parts_(parts) {} -ifcopenshell::geometry::ManifoldShape::ManifoldShape(std::vector&& parts) +ifcopenshell::geom::manifold_shape::manifold_shape(std::vector&& parts) : parts_(std::move(parts)) {} -std::optional ifcopenshell::geometry::ManifoldShape::as_manifold() const { +std::optional ifcopenshell::geom::manifold_shape::as_manifold() const { if (parts_.empty()) { return std::nullopt; } @@ -215,7 +215,7 @@ std::optional ifcopenshell::geometry::ManifoldShape::as_mani return manifold::Manifold::BatchBoolean(solids, manifold::OpType::Add); } -void ifcopenshell::geometry::ManifoldShape::Triangulate(ifcopenshell::geometry::Settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger&) const { +void ifcopenshell::geom::manifold_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger&) const { for (const auto& part : parts_) { auto mesh = transform_mesh(part.mesh, place); std::vector indices(mesh.NumVert()); @@ -250,7 +250,7 @@ void ifcopenshell::geometry::ManifoldShape::Triangulate(ifcopenshell::geometry:: } } -void ifcopenshell::geometry::ManifoldShape::Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string& result) const { +void ifcopenshell::geom::manifold_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const { std::stringstream stream; stream << std::setprecision(17); size_t offset = 0; @@ -273,7 +273,7 @@ void ifcopenshell::geometry::ManifoldShape::Serialize(const ifcopenshell::geomet result = stream.str(); } -int ifcopenshell::geometry::ManifoldShape::surface_genus() const { +int ifcopenshell::geom::manifold_shape::surface_genus() const { int genus = 0; for (const auto& part : parts_) { if (!part.solid) { @@ -284,11 +284,11 @@ int ifcopenshell::geometry::ManifoldShape::surface_genus() const { return genus; } -bool ifcopenshell::geometry::ManifoldShape::is_manifold() const { +bool ifcopenshell::geom::manifold_shape::is_manifold() const { return std::all_of(parts_.begin(), parts_.end(), [](const auto& part) { return part.solid.has_value(); }); } -int ifcopenshell::geometry::ManifoldShape::num_vertices() const { +int ifcopenshell::geom::manifold_shape::num_vertices() const { size_t total = 0; for (const auto& part : parts_) { total += part.mesh.NumVert(); @@ -296,7 +296,7 @@ int ifcopenshell::geometry::ManifoldShape::num_vertices() const { return (int)total; } -int ifcopenshell::geometry::ManifoldShape::num_edges() const { +int ifcopenshell::geom::manifold_shape::num_edges() const { int total = 0; for (const auto& part : parts_) { total += part.solid ? (int)part.solid->NumEdge() : mesh_edges(part.mesh); @@ -304,7 +304,7 @@ int ifcopenshell::geometry::ManifoldShape::num_edges() const { return total; } -int ifcopenshell::geometry::ManifoldShape::num_faces() const { +int ifcopenshell::geom::manifold_shape::num_faces() const { size_t total = 0; for (const auto& part : parts_) { total += part.solid ? part.solid->NumTri() : part.mesh.NumTri(); @@ -312,7 +312,7 @@ int ifcopenshell::geometry::ManifoldShape::num_faces() const { return (int)total; } -double ifcopenshell::geometry::ManifoldShape::bounding_box(void*& box_ptr) const { +double ifcopenshell::geom::manifold_shape::bounding_box(void*& box_ptr) const { bool initialized = false; auto* box = static_cast(box_ptr); if (!box) { @@ -335,7 +335,7 @@ double ifcopenshell::geometry::ManifoldShape::bounding_box(void*& box_ptr) const return initialized ? bbox_volume(*box) : 0.; } -std::pair, OpaqueCoordinate<3>> ifcopenshell::geometry::ManifoldShape::bounding_box() const { +std::pair, opaque_coordinate<3>> ifcopenshell::geom::manifold_shape::bounding_box() const { void* box_ptr = nullptr; bounding_box(box_ptr); auto* box = static_cast(box_ptr); @@ -344,19 +344,19 @@ std::pair, OpaqueCoordinate<3>> ifcopenshell::geometry::Mani throw std::runtime_error("Invalid shape"); } auto result = std::make_pair( - OpaqueCoordinate<3>( - OpaqueNumber(box->min[0]), - OpaqueNumber(box->min[1]), - OpaqueNumber(box->min[2])), - OpaqueCoordinate<3>( - OpaqueNumber(box->max[0]), - OpaqueNumber(box->max[1]), - OpaqueNumber(box->max[2]))); + opaque_coordinate<3>( + opaque_number(box->min[0]), + opaque_number(box->min[1]), + opaque_number(box->min[2])), + opaque_coordinate<3>( + opaque_number(box->max[0]), + opaque_number(box->max[1]), + opaque_number(box->max[2]))); delete box; return result; } -void ifcopenshell::geometry::ManifoldShape::set_box(void* box_ptr) { +void ifcopenshell::geom::manifold_shape::set_box(void* box_ptr) { auto* box = static_cast(box_ptr); if (!box || !box->IsFinite()) { throw std::runtime_error("Invalid shape"); @@ -364,51 +364,51 @@ void ifcopenshell::geometry::ManifoldShape::set_box(void* box_ptr) { parts_ = { make_box_part(*box) }; } -OpaqueNumber ifcopenshell::geometry::ManifoldShape::length() { +opaque_number ifcopenshell::geom::manifold_shape::length() { double total = 0.; for (const auto& part : parts_) { total += mesh_length(part.mesh); } - return OpaqueNumber(total); + return opaque_number(total); } -OpaqueNumber ifcopenshell::geometry::ManifoldShape::area() { +opaque_number ifcopenshell::geom::manifold_shape::area() { double total = 0.; for (const auto& part : parts_) { total += part.solid ? part.solid->SurfaceArea() : mesh_area(part.mesh); } - return OpaqueNumber(total); + return opaque_number(total); } -OpaqueNumber ifcopenshell::geometry::ManifoldShape::volume() { +opaque_number ifcopenshell::geom::manifold_shape::volume() { double total = 0.; for (const auto& part : parts_) { total += part.solid ? part.solid->Volume() : mesh_volume(part.mesh); } - return OpaqueNumber(total); + return opaque_number(total); } -OpaqueCoordinate<3> ifcopenshell::geometry::ManifoldShape::position() { +opaque_coordinate<3> ifcopenshell::geom::manifold_shape::position() { throw std::runtime_error("Invalid shape"); } -OpaqueCoordinate<3> ifcopenshell::geometry::ManifoldShape::axis() { +opaque_coordinate<3> ifcopenshell::geom::manifold_shape::axis() { throw std::runtime_error("Invalid shape"); } -OpaqueCoordinate<4> ifcopenshell::geometry::ManifoldShape::plane_equation() { +opaque_coordinate<4> ifcopenshell::geom::manifold_shape::plane_equation() { throw std::runtime_error("Invalid shape"); } -std::vector ifcopenshell::geometry::ManifoldShape::convex_decomposition() { +std::vector ifcopenshell::geom::manifold_shape::convex_decomposition() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::halfspaces() { +conversion_result_shape* ifcopenshell::geom::manifold_shape::halfspaces() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::box() { +conversion_result_shape* ifcopenshell::geom::manifold_shape::box() { void* box_ptr = nullptr; bounding_box(box_ptr); auto* box = static_cast(box_ptr); @@ -416,36 +416,36 @@ ConversionResultShape* ifcopenshell::geometry::ManifoldShape::box() { delete box; throw std::runtime_error("Invalid shape"); } - auto* result = new ManifoldShape(make_box_part(*box)); + auto* result = new manifold_shape(make_box_part(*box)); delete box; return result; } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::solid() { +conversion_result_shape* ifcopenshell::geom::manifold_shape::solid() { if (!is_manifold()) { throw std::runtime_error("Invalid shape"); } - return new ManifoldShape(parts_); + return new manifold_shape(parts_); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::wrap_in_compound() { - return new ManifoldShape(parts_); +conversion_result_shape* ifcopenshell::geom::manifold_shape::wrap_in_compound() { + return new manifold_shape(parts_); } -std::vector ifcopenshell::geometry::ManifoldShape::vertices() { +std::vector ifcopenshell::geom::manifold_shape::vertices() { throw std::runtime_error("Not implemented"); } -std::vector ifcopenshell::geometry::ManifoldShape::edges() { +std::vector ifcopenshell::geom::manifold_shape::edges() { throw std::runtime_error("Not implemented"); } -std::vector ifcopenshell::geometry::ManifoldShape::facets() { +std::vector ifcopenshell::geom::manifold_shape::facets() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::add(ConversionResultShape* other) { - auto* rhs = dynamic_cast(other); +conversion_result_shape* ifcopenshell::geom::manifold_shape::add(conversion_result_shape* other) { + auto* rhs = dynamic_cast(other); if (!rhs) { throw std::runtime_error("Invalid shape"); } @@ -454,11 +454,11 @@ ConversionResultShape* ifcopenshell::geometry::ManifoldShape::add(ConversionResu if (!a || !b) { throw std::runtime_error("Invalid shape"); } - return new ManifoldShape(make_part(*a + *b)); + return new manifold_shape(make_part(*a + *b)); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::subtract(ConversionResultShape* other) { - auto* rhs = dynamic_cast(other); +conversion_result_shape* ifcopenshell::geom::manifold_shape::subtract(conversion_result_shape* other) { + auto* rhs = dynamic_cast(other); if (!rhs) { throw std::runtime_error("Invalid shape"); } @@ -467,11 +467,11 @@ ConversionResultShape* ifcopenshell::geometry::ManifoldShape::subtract(Conversio if (!a || !b) { throw std::runtime_error("Invalid shape"); } - return new ManifoldShape(make_part(*a - *b)); + return new manifold_shape(make_part(*a - *b)); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::intersect(ConversionResultShape* other) { - auto* rhs = dynamic_cast(other); +conversion_result_shape* ifcopenshell::geom::manifold_shape::intersect(conversion_result_shape* other) { + auto* rhs = dynamic_cast(other); if (!rhs) { throw std::runtime_error("Invalid shape"); } @@ -480,29 +480,29 @@ ConversionResultShape* ifcopenshell::geometry::ManifoldShape::intersect(Conversi if (!a || !b) { throw std::runtime_error("Invalid shape"); } - return new ManifoldShape(make_part(*a ^ *b)); + return new manifold_shape(make_part(*a ^ *b)); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::concat(ConversionResultShape* other) { - auto* rhs = dynamic_cast(other); +conversion_result_shape* ifcopenshell::geom::manifold_shape::concat(conversion_result_shape* other) { + auto* rhs = dynamic_cast(other); if (!rhs) { throw std::runtime_error("Invalid shape"); } auto parts = parts_; parts.insert(parts.end(), rhs->parts_.begin(), rhs->parts_.end()); - return new ManifoldShape(std::move(parts)); + return new manifold_shape(std::move(parts)); } -std::size_t ifcopenshell::geometry::ManifoldShape::map(OpaqueCoordinate<4>&, OpaqueCoordinate<4>&) { +std::size_t ifcopenshell::geom::manifold_shape::map(opaque_coordinate<4>&, opaque_coordinate<4>&) { throw std::runtime_error("Not implemented"); } -std::size_t ifcopenshell::geometry::ManifoldShape::map(const std::vector>&, const std::vector>&) { +std::size_t ifcopenshell::geom::manifold_shape::map(const std::vector>&, const std::vector>&) { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::ManifoldShape::moved(ifcopenshell::geometry::taxonomy::matrix4::ptr place) const { - std::vector moved_parts; +conversion_result_shape* ifcopenshell::geom::manifold_shape::moved(ifcopenshell::geom::taxonomy::matrix4::ptr place) const { + std::vector moved_parts; moved_parts.reserve(parts_.size()); for (const auto& part : parts_) { auto mesh = transform_mesh(part.mesh, *place); @@ -512,10 +512,10 @@ ConversionResultShape* ifcopenshell::geometry::ManifoldShape::moved(ifcopenshell } moved_parts.emplace_back(mesh, *solid); } - return new ManifoldShape(std::move(moved_parts)); + return new manifold_shape(std::move(moved_parts)); } -bool ifcopenshell::geometry::ManifoldShape::surface_area_along_direction(double, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { +bool ifcopenshell::geom::manifold_shape::surface_area_along_direction(double, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { along_x = along_y = along_z = 0.; for (const auto& part : parts_) { auto mesh = transform_mesh(part.mesh, *place); diff --git a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h index a8d9154772..a8c7ab68a1 100644 --- a/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h +++ b/src/ifcgeom/kernels/manifold/ManifoldConversionResult.h @@ -9,39 +9,39 @@ #include namespace ifcopenshell { -namespace geometry { +namespace geom { -struct IFC_GEOMLIBRARY_API ManifoldPart { +struct IFC_GEOMLIBRARY_API manifold_part { manifold::MeshGL64 mesh; std::optional solid; - ManifoldPart(const manifold::Manifold& s) { + manifold_part(const manifold::Manifold& s) { auto copy = s; copy.CalculateNormals(3); mesh = copy.GetMeshGL64(); solid = s; } - ManifoldPart(const manifold::MeshGL64& s) : mesh(s) {} + manifold_part(const manifold::MeshGL64& s) : mesh(s) {} - ManifoldPart(const manifold::MeshGL64& s, const manifold::Manifold& m) : mesh(s), solid(m) {} + manifold_part(const manifold::MeshGL64& s, const manifold::Manifold& m) : mesh(s), solid(m) {} }; -class IFC_GEOMLIBRARY_API ManifoldShape : public IfcGeom::ConversionResultShape { +class IFC_GEOMLIBRARY_API manifold_shape : public ifcopenshell::geom::conversion_result_shape { public: - ManifoldShape() = default; - explicit ManifoldShape(const manifold::Manifold& part); - explicit ManifoldShape(const ManifoldPart& part); - explicit ManifoldShape(ManifoldPart&& part); - explicit ManifoldShape(const std::vector& parts); - explicit ManifoldShape(std::vector&& parts); + manifold_shape() = default; + explicit manifold_shape(const manifold::Manifold& part); + explicit manifold_shape(const manifold_part& part); + explicit manifold_shape(manifold_part&& part); + explicit manifold_shape(const std::vector& parts); + explicit manifold_shape(std::vector&& parts); - const std::vector& parts() const { return parts_; } + const std::vector& parts() const { return parts_; } std::optional as_manifold() const; virtual std::string_view backend_id() const { return "manifold"; } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; - virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; + virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; + virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual int surface_genus() const; virtual bool is_manifold() const; @@ -51,40 +51,40 @@ public: virtual int num_faces() const; virtual double bounding_box(void*&) const; - virtual std::pair, IfcGeom::OpaqueCoordinate<3>> bounding_box() const; + virtual std::pair, ifcopenshell::geom::opaque_coordinate<3>> bounding_box() const; virtual void set_box(void* b); - virtual IfcGeom::OpaqueNumber length(); - virtual IfcGeom::OpaqueNumber area(); - virtual IfcGeom::OpaqueNumber volume(); + virtual ifcopenshell::geom::opaque_number length(); + virtual ifcopenshell::geom::opaque_number area(); + virtual ifcopenshell::geom::opaque_number volume(); - virtual IfcGeom::OpaqueCoordinate<3> position(); - virtual IfcGeom::OpaqueCoordinate<3> axis(); - virtual IfcGeom::OpaqueCoordinate<4> plane_equation(); + virtual ifcopenshell::geom::opaque_coordinate<3> position(); + virtual ifcopenshell::geom::opaque_coordinate<3> axis(); + virtual ifcopenshell::geom::opaque_coordinate<4> plane_equation(); - virtual std::vector convex_decomposition(); - virtual IfcGeom::ConversionResultShape* halfspaces(); - virtual IfcGeom::ConversionResultShape* box(); - virtual IfcGeom::ConversionResultShape* solid(); - virtual IfcGeom::ConversionResultShape* wrap_in_compound(); + virtual std::vector convex_decomposition(); + virtual ifcopenshell::geom::conversion_result_shape* halfspaces(); + virtual ifcopenshell::geom::conversion_result_shape* box(); + virtual ifcopenshell::geom::conversion_result_shape* solid(); + virtual ifcopenshell::geom::conversion_result_shape* wrap_in_compound(); - virtual std::vector vertices(); - virtual std::vector edges(); - virtual std::vector facets(); + virtual std::vector vertices(); + virtual std::vector edges(); + virtual std::vector facets(); - virtual IfcGeom::ConversionResultShape* add(IfcGeom::ConversionResultShape*); - virtual IfcGeom::ConversionResultShape* subtract(IfcGeom::ConversionResultShape*); - virtual IfcGeom::ConversionResultShape* intersect(IfcGeom::ConversionResultShape*); - virtual IfcGeom::ConversionResultShape* concat(IfcGeom::ConversionResultShape*); + virtual ifcopenshell::geom::conversion_result_shape* add(ifcopenshell::geom::conversion_result_shape*); + virtual ifcopenshell::geom::conversion_result_shape* subtract(ifcopenshell::geom::conversion_result_shape*); + virtual ifcopenshell::geom::conversion_result_shape* intersect(ifcopenshell::geom::conversion_result_shape*); + virtual ifcopenshell::geom::conversion_result_shape* concat(ifcopenshell::geom::conversion_result_shape*); - virtual std::size_t map(IfcGeom::OpaqueCoordinate<4>& from, IfcGeom::OpaqueCoordinate<4>& to); - virtual std::size_t map(const std::vector>& from, const std::vector>& to); - virtual IfcGeom::ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const; + virtual std::size_t map(ifcopenshell::geom::opaque_coordinate<4>& from, ifcopenshell::geom::opaque_coordinate<4>& to); + virtual std::size_t map(const std::vector>& from, const std::vector>& to); + virtual ifcopenshell::geom::conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const; - virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; + virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; private: - std::vector parts_; + std::vector parts_; }; } diff --git a/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp b/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp index ad18d8f584..0b1a4765a6 100644 --- a/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp +++ b/src/ifcgeom/kernels/manifold/ManifoldKernel.cpp @@ -14,12 +14,12 @@ #include #include -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; namespace { - using Mesh = manifold::MeshGL64; - using Part = ifcopenshell::geometry::ManifoldPart; + using mesh_type = manifold::MeshGL64; + using part = ifcopenshell::geom::manifold_part; std::string manifold_error_string(manifold::Manifold::Error error) { switch (error) { @@ -53,18 +53,18 @@ namespace { return "unknown error"; } - struct VertexKey { + struct vertex_key { long long x; long long y; long long z; - bool operator==(const VertexKey& other) const { + bool operator==(const vertex_key& other) const { return x == other.x && y == other.y && z == other.z; } }; - struct VertexKeyHash { - size_t operator()(const VertexKey& key) const { + struct vertex_key_hash { + size_t operator()(const vertex_key& key) const { auto h = std::hash()(key.x); h ^= std::hash()(key.y) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); h ^= std::hash()(key.z) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); @@ -72,17 +72,17 @@ namespace { } }; - struct MeshBuilder { + struct mesh_builder { double precision; double dilation = 0.; std::vector vertices; - std::unordered_map vertex_map; + std::unordered_map vertex_map; std::vector tri_verts; std::vector face_ids; - explicit MeshBuilder(double p) : precision(p > 0. ? p : 1.e-9) {} + explicit mesh_builder(double p) : precision(p > 0. ? p : 1.e-9) {} - VertexKey key(const Eigen::Vector3d& p) const { + vertex_key key(const Eigen::Vector3d& p) const { return { (long long)std::llround(p(0) / precision), (long long)std::llround(p(1) / precision), @@ -111,8 +111,8 @@ namespace { face_ids.push_back(face_id); } - Mesh build() const { - Mesh mesh; + mesh_type build() const { + mesh_type mesh; mesh.numProp = 3; std::vector vertex_use_count(vertices.size(), 0); @@ -149,42 +149,42 @@ namespace { } }; - struct LoopPoint { + struct loop_point { Eigen::Vector3d xyz; manifold::vec2 uv; }; - using LoopPolygon = std::vector; + using loop_polygon = std::vector; - struct EdgeKey { + struct edge_key { uint64_t a; uint64_t b; - bool operator==(const EdgeKey& other) const { + bool operator==(const edge_key& other) const { return a == other.a && b == other.b; } }; - struct EdgeKeyHash { - size_t operator()(const EdgeKey& key) const { + struct edge_key_hash { + size_t operator()(const edge_key& key) const { auto h = std::hash()(key.a); h ^= std::hash()(key.b) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); return h; } }; - struct FaceKey { + struct face_key { uint64_t a; uint64_t b; uint64_t c; - bool operator==(const FaceKey& other) const { + bool operator==(const face_key& other) const { return a == other.a && b == other.b && c == other.c; } }; - struct FaceKeyHash { - size_t operator()(const FaceKey& key) const { + struct face_key_hash { + size_t operator()(const face_key& key) const { auto h = std::hash()(key.a); h ^= std::hash()(key.b) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); h ^= std::hash()(key.c) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); @@ -192,12 +192,12 @@ namespace { } }; - struct EdgeUseCount { + struct edge_use_count { size_t forward = 0; size_t reverse = 0; }; - struct MeshDiagnostics { + struct mesh_diagnostics { size_t vertices = 0; size_t triangles = 0; size_t unique_edges = 0; @@ -219,7 +219,7 @@ namespace { double max_area = 0.; }; - struct ShellDiagnostics { + struct shell_diagnostics { size_t faces = 0; size_t loops = 0; size_t edges = 0; @@ -399,10 +399,10 @@ namespace { } bool append_extrusion_loop_points(const taxonomy::loop::ptr& loop, int circle_segments, double precision, std::vector& points); - bool loop_polygon_from_points(const std::vector& points, const Eigen::Vector3d& origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, LoopPolygon& polygon); - double signed_area(const LoopPolygon& polygon); + bool loop_polygon_from_points(const std::vector& points, const Eigen::Vector3d& origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, loop_polygon& polygon); + double signed_area(const loop_polygon& polygon); - bool extrusion_face_polygons(const taxonomy::face::ptr& face, int circle_segments, double precision, Eigen::Vector3d& origin, Eigen::Vector3d& x, Eigen::Vector3d& y, std::vector& polygons, size_t& outer_index) { + bool extrusion_face_polygons(const taxonomy::face::ptr& face, int circle_segments, double precision, Eigen::Vector3d& origin, Eigen::Vector3d& x, Eigen::Vector3d& y, std::vector& polygons, size_t& outer_index) { polygons.clear(); outer_index = 0; if (!extrusion_face_supported(face)) { @@ -423,7 +423,7 @@ namespace { if (!basis_from_points(points, loop_origin, loop_x, loop_y)) { return false; } - LoopPolygon polygon; + loop_polygon polygon; if (!loop_polygon_from_points(points, loop_origin, loop_x, loop_y, precision, polygon)) { return false; } @@ -440,7 +440,7 @@ namespace { double outer_area = 0.; polygons.reserve(loops.size()); for (const auto& points : loops) { - LoopPolygon polygon; + loop_polygon polygon; if (!loop_polygon_from_points(points, origin, x, y, precision, polygon)) { return false; } @@ -525,7 +525,7 @@ namespace { return 0.5 * area; } - Eigen::Vector3d mesh_vertex(const Mesh& mesh, size_t index) { + Eigen::Vector3d mesh_vertex(const mesh_type& mesh, size_t index) { return Eigen::Vector3d( mesh.vertProperties[index * mesh.numProp + 0], mesh.vertProperties[index * mesh.numProp + 1], @@ -542,12 +542,12 @@ namespace { return "(" + format_number(value(0)) + ", " + format_number(value(1)) + ", " + format_number(value(2)) + ")"; } - MeshDiagnostics diagnose_mesh(const Mesh& mesh, double precision) { - MeshDiagnostics diagnostics; + mesh_diagnostics diagnose_mesh(const mesh_type& mesh, double precision) { + mesh_diagnostics diagnostics; diagnostics.vertices = mesh.NumVert(); diagnostics.triangles = mesh.NumTri(); - std::unordered_map edge_use_count; - std::unordered_map face_use_count; + std::unordered_map edge_use_count; + std::unordered_map face_use_count; for (size_t i = 0; i < diagnostics.vertices; ++i) { auto p = mesh_vertex(mesh, i); if (!std::isfinite(p(0)) || !std::isfinite(p(1)) || !std::isfinite(p(2))) { @@ -603,7 +603,7 @@ namespace { } std::array face = { a, b, c }; std::sort(face.begin(), face.end()); - const FaceKey face_key{ face[0], face[1], face[2] }; + const face_key face_key{ face[0], face[1], face[2] }; auto face_it = face_use_count.find(face_key); if (face_it == face_use_count.end()) { face_use_count.insert({ face_key, 1 }); @@ -611,10 +611,10 @@ namespace { face_it->second++; diagnostics.duplicate_faces++; } - std::array edges = { - EdgeKey{ std::min(a, b), std::max(a, b) }, - EdgeKey{ std::min(b, c), std::max(b, c) }, - EdgeKey{ std::min(c, a), std::max(c, a) } + std::array edges = { + edge_key{ std::min(a, b), std::max(a, b) }, + edge_key{ std::min(b, c), std::max(b, c) }, + edge_key{ std::min(c, a), std::max(c, a) } }; std::array forward = { a < b, @@ -651,8 +651,8 @@ namespace { return diagnostics; } - ShellDiagnostics diagnose_shell(const taxonomy::shell::ptr& shell) { - ShellDiagnostics diagnostics; + shell_diagnostics diagnose_shell(const taxonomy::shell::ptr& shell) { + shell_diagnostics diagnostics; diagnostics.faces = shell->children.size(); for (const auto& face : shell->children) { diagnostics.max_loops_per_face = std::max(diagnostics.max_loops_per_face, face->children.size()); @@ -678,7 +678,7 @@ namespace { return diagnostics; } - std::string mesh_diagnostics_string(const MeshDiagnostics& diagnostics) { + std::string mesh_diagnostics_string(const mesh_diagnostics& diagnostics) { std::ostringstream ss; ss << "verts=" << diagnostics.vertices << " tris=" << diagnostics.triangles @@ -711,7 +711,7 @@ namespace { return ss.str(); } - std::string shell_diagnostics_string(const ShellDiagnostics& diagnostics) { + std::string shell_diagnostics_string(const shell_diagnostics& diagnostics) { std::ostringstream ss; ss << "faces=" << diagnostics.faces << " loops=" << diagnostics.loops @@ -738,7 +738,7 @@ namespace { return ss.str(); } - std::string solid_shell_failure_diagnosis(const Part& part, const MeshDiagnostics& before, const MeshDiagnostics& after, manifold::Manifold::Error before_status, manifold::Manifold::Error after_status) { + std::string solid_shell_failure_diagnosis(const part& part, const mesh_diagnostics& before, const mesh_diagnostics& after, manifold::Manifold::Error before_status, manifold::Manifold::Error after_status) { const bool before_problematic = !part.solid || before_status != manifold::Manifold::Error::NoError || @@ -765,7 +765,7 @@ namespace { return "shell looks clean before and after mesh inspection, issue may be in manifold validation details"; } - void log_solid_shell_transform_failure(const taxonomy::shell::ptr& shell, const Part& before_part, const Mesh& after_mesh, const taxonomy::matrix4::ptr& place, double precision, manifold::Manifold::Error before_status, manifold::Manifold::Error after_status) { + void log_solid_shell_transform_failure(const taxonomy::shell::ptr& shell, const part& before_part, const mesh_type& after_mesh, const taxonomy::matrix4::ptr& place, double precision, manifold::Manifold::Error before_status, manifold::Manifold::Error after_status) { const auto shell_info = diagnose_shell(shell); const auto before = diagnose_mesh(before_part.mesh, precision); const auto after = diagnose_mesh(after_mesh, precision); @@ -791,7 +791,7 @@ namespace { return 0.5 * area; } - double signed_area(const LoopPolygon& polygon) { + double signed_area(const loop_polygon& polygon) { double area = 0.; for (size_t i = 0; i < polygon.size(); ++i) { const auto& a = polygon[i].uv; @@ -920,7 +920,7 @@ namespace { return points.size() >= 3; } - bool loop_polygon_from_points(const std::vector& points, const Eigen::Vector3d& origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, LoopPolygon& polygon) { + bool loop_polygon_from_points(const std::vector& points, const Eigen::Vector3d& origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, loop_polygon& polygon) { polygon.clear(); polygon.reserve(points.size()); for (const auto& point : points) { @@ -942,7 +942,7 @@ namespace { return polygon.size() >= 3; } - bool append_simple_loop(const taxonomy::loop::ptr& loop, const Eigen::Vector3d& origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, LoopPolygon& polygon) { + bool append_simple_loop(const taxonomy::loop::ptr& loop, const Eigen::Vector3d& origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, loop_polygon& polygon) { polygon.clear(); polygon.reserve(loop->children.size()); for (const auto& edge : loop->children) { @@ -974,11 +974,11 @@ namespace { return true; } - void reverse_loop(LoopPolygon& polygon) { + void reverse_loop(loop_polygon& polygon) { std::reverse(polygon.begin(), polygon.end()); } - void append_loop(const LoopPolygon& loop_polygon, MeshBuilder& builder, manifold::PolygonsIdx& polygons) { + void append_loop(const loop_polygon& loop_polygon, mesh_builder& builder, manifold::PolygonsIdx& polygons) { manifold::SimplePolygonIdx polygon; polygon.reserve(loop_polygon.size()); for (const auto& point : loop_polygon) { @@ -990,7 +990,7 @@ namespace { polygons.push_back(std::move(polygon)); } - bool append_face(const taxonomy::face::ptr& face, MeshBuilder& builder, uint64_t face_id) { + bool append_face(const taxonomy::face::ptr& face, mesh_builder& builder, uint64_t face_id) { if (!face_supported(face)) { return false; } @@ -1000,14 +1000,14 @@ namespace { if (!face_basis(face, origin, x, y)) { return false; } - std::vector loops; + std::vector loops; loops.reserve(face->children.size()); size_t outer_index = 0; double outer_area = 0.; manifold::PolygonsIdx polygons; polygons.reserve(face->children.size()); for (const auto& loop : face->children) { - LoopPolygon loop_polygon; + loop_polygon loop_polygon; if (!append_simple_loop(loop, origin, x, y, builder.precision, loop_polygon)) { return false; } @@ -1034,8 +1034,8 @@ namespace { return !triangles.empty(); } - bool shell_to_mesh(const taxonomy::shell::ptr& shell, double precision, Mesh& mesh, double dilation) { - MeshBuilder builder(precision); + bool shell_to_mesh(const taxonomy::shell::ptr& shell, double precision, mesh_type& mesh, double dilation) { + mesh_builder builder(precision); builder.dilation = dilation; uint64_t face_id = 0; bool any = false; @@ -1052,7 +1052,7 @@ namespace { return mesh.NumTri() > 0; } - std::optional part_from_mesh(const Mesh& mesh, bool require_manifold, manifold::Manifold::Error* status_ptr = nullptr) { + std::optional part_from_mesh(const mesh_type& mesh, bool require_manifold, manifold::Manifold::Error* status_ptr = nullptr) { auto solid = std::optional{}; manifold::Manifold candidate(mesh); auto status = candidate.Status(); @@ -1071,16 +1071,16 @@ namespace { return mesh; } - std::optional part_from_shell(const taxonomy::shell::ptr& shell, double precision, double dilation, manifold::Manifold::Error* status_ptr = nullptr) { - Mesh mesh; + std::optional part_from_shell(const taxonomy::shell::ptr& shell, double precision, double dilation, manifold::Manifold::Error* status_ptr = nullptr) { + mesh_type mesh; if (!shell_to_mesh(shell, precision, mesh, dilation)) { return std::nullopt; } return part_from_mesh(mesh, false, status_ptr); } - Mesh transform_mesh(const Mesh& mesh, const taxonomy::matrix4::ptr& place); - std::optional part_from_extrusion(const taxonomy::extrusion::ptr& extrusion, double precision, double dilation, int circle_segments); + mesh_type transform_mesh(const mesh_type& mesh, const taxonomy::matrix4::ptr& place); + std::optional part_from_extrusion(const taxonomy::extrusion::ptr& extrusion, double precision, double dilation, int circle_segments); Eigen::Matrix4d matrix_or_identity(const taxonomy::matrix4::ptr& matrix) { return matrix ? matrix->ccomponents() : Eigen::Matrix4d::Identity(); @@ -1109,7 +1109,7 @@ namespace { return face; } - bool explicit_loop_polygon(const taxonomy::loop::ptr& loop, const Eigen::Matrix4d& transform, const Eigen::Vector3d& plane_origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, LoopPolygon& polygon) { + bool explicit_loop_polygon(const taxonomy::loop::ptr& loop, const Eigen::Matrix4d& transform, const Eigen::Vector3d& plane_origin, const Eigen::Vector3d& x, const Eigen::Vector3d& y, double precision, loop_polygon& polygon) { polygon.clear(); if (!loop || loop->children.size() < 3) { return false; @@ -1145,12 +1145,12 @@ namespace { }; } - struct HalfspaceBuildState { + struct halfspace_build_state { bool unchanged = false; double depth = 0.; }; - std::optional part_from_polygon_extrusion(std::vector polygons, size_t outer_index, const Eigen::Vector3d& plane_normal, const Eigen::Vector3d& direction, double depth, double precision, double dilation) { + std::optional part_from_polygon_extrusion(std::vector polygons, size_t outer_index, const Eigen::Vector3d& plane_normal, const Eigen::Vector3d& direction, double depth, double precision, double dilation) { if (depth < precision || polygons.empty() || outer_index >= polygons.size()) { return std::nullopt; } @@ -1182,7 +1182,7 @@ namespace { return std::nullopt; } auto offset = dir * depth; - MeshBuilder builder(precision); + mesh_builder builder(precision); builder.dilation = dilation; std::vector> bottoms; std::vector> tops; @@ -1241,7 +1241,7 @@ namespace { return part_from_mesh(builder.build(), true); } - std::optional part_from_halfspace_solid(HalfspaceBuildState& state, const taxonomy::solid::ptr& solid, const taxonomy::face::ptr& face,const manifold::Box& reference_box, double precision, double dilation) { + std::optional part_from_halfspace_solid(halfspace_build_state& state, const taxonomy::solid::ptr& solid, const taxonomy::face::ptr& face,const manifold::Box& reference_box, double precision, double dilation) { auto plane = taxonomy::cast(face->basis); @@ -1255,7 +1255,7 @@ namespace { Eigen::Vector3d origin = transform.col(3).head<3>(); auto project_along_global_z = [&](const Eigen::Vector3d& p) - -> std::optional { + -> std::optional { Eigen::Vector3d hit; if (std::abs(normal.z()) > precision) { @@ -1266,7 +1266,7 @@ namespace { } const auto delta = hit - origin; - return std::make_optional(LoopPoint{ + return std::make_optional(loop_point{ hit, manifold::vec2(delta.dot(x), delta.dot(y))}); }; @@ -1300,7 +1300,7 @@ namespace { } const auto diagonal = Eigen::Vector3d(reference_box.max[0] - reference_box.min[0], reference_box.max[1] - reference_box.min[1], reference_box.max[2] - reference_box.min[2]).norm(); const auto margin = std::max(precision * 100., diagonal * 1.e-6); - LoopPolygon polygon; + loop_polygon polygon; if (face->children.empty()) { polygon = { { origin + x * (u_min - margin) + y * (v_min - margin), manifold::vec2(u_min - margin, v_min - margin) }, @@ -1327,7 +1327,7 @@ namespace { return part_from_polygon_extrusion({std::move(polygon)}, 0, normal, extrusion_dir * -inside_sign, max_depth + margin, precision, dilation); } - std::optional part_from_extrusion(const taxonomy::extrusion::ptr& extrusion, double precision, double dilation, int circle_segments) { + std::optional part_from_extrusion(const taxonomy::extrusion::ptr& extrusion, double precision, double dilation, int circle_segments) { if (extrusion->depth < precision) { return std::nullopt; } @@ -1338,7 +1338,7 @@ namespace { Eigen::Vector3d origin; Eigen::Vector3d x; Eigen::Vector3d y; - std::vector polygons; + std::vector polygons; size_t outer_index = 0; if (!extrusion_face_polygons(face, circle_segments, precision, origin, x, y, polygons, outer_index)) { return std::nullopt; @@ -1361,7 +1361,7 @@ namespace { Eigen::Vector3d origin; Eigen::Vector3d x; Eigen::Vector3d y; - std::vector polygons; + std::vector polygons; size_t outer_index = 0; if (!extrusion_face_polygons(face, settings::CircleSegments::defaultvalue, precision, origin, x, y, polygons, outer_index)) { return false; @@ -1382,9 +1382,9 @@ namespace { return !polygons.empty(); } - Mesh transform_mesh(const Mesh& mesh, const taxonomy::matrix4::ptr& place) { + mesh_type transform_mesh(const mesh_type& mesh, const taxonomy::matrix4::ptr& place) { const auto& m = place->ccomponents(); - Mesh result = mesh; + mesh_type result = mesh; const bool flip = m.block<3, 3>(0, 0).determinant() < 0.; for (size_t i = 0; i < mesh.NumVert(); ++i) { Eigen::Vector4d v( @@ -1406,7 +1406,7 @@ namespace { return result; } - taxonomy::style::ptr fallback_style(const taxonomy::geom_item::ptr& item, const IfcGeom::ConversionResults& results) { + taxonomy::style::ptr fallback_style(const taxonomy::geom_item::ptr& item, const ifcopenshell::geom::conversion_results& results) { if (item->surface_style) { return item->surface_style; } @@ -1418,16 +1418,16 @@ namespace { return nullptr; } - std::optional result_to_manifold(const IfcGeom::ConversionResult& result) { - auto moved = std::unique_ptr(result.apply_transform()); - auto* shape = dynamic_cast(moved.get()); + std::optional result_to_manifold(const ifcopenshell::geom::conversion_result& result) { + auto moved = std::unique_ptr(result.apply_transform()); + auto* shape = dynamic_cast(moved.get()); if (!shape) { return std::nullopt; } return shape->as_manifold(); } - std::optional results_to_operand(const IfcGeom::ConversionResults& results) { + std::optional results_to_operand(const ifcopenshell::geom::conversion_results& results) { std::vector operands; for (const auto& result : results) { auto operand = result_to_manifold(result); @@ -1444,7 +1444,7 @@ namespace { return manifold::Manifold::BatchBoolean(operands, manifold::OpType::Add); } - std::optional results_bbox(const IfcGeom::ConversionResults& results) { + std::optional results_bbox(const ifcopenshell::geom::conversion_results& results) { bool any = false; manifold::Box bbox; for (const auto& result : results) { @@ -1489,21 +1489,21 @@ namespace { } } -bool ManifoldKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, IfcGeom::ConversionResults& results) { +bool manifold_kernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ifcopenshell::geom::conversion_results& results) { auto part = part_from_extrusion(extrusion, settings_.get().get(), dilation_hack, settings_.get().get()); if (!part) { ::logger::root().warning("Manifold kernel: failed to convert extrusion, requires planar bounds with line, circle or ellipse edges", extrusion->instance); return false; } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( extrusion->instance.id(), extrusion->matrix, - new ifcopenshell::geometry::ManifoldShape(std::move(*part)), + new ifcopenshell::geom::manifold_shape(std::move(*part)), extrusion->surface_style)); return true; } -bool ManifoldKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::ConversionResults& results) { +bool manifold_kernel::convert_impl(const taxonomy::shell::ptr shell, ifcopenshell::geom::conversion_results& results) { manifold::Manifold::Error status = manifold::Manifold::Error::NoError; auto part = part_from_shell(shell, settings_.get().get(), dilation_hack, &status); if (!part) { @@ -1513,15 +1513,15 @@ bool ManifoldKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::Con if (!part->solid) { ::logger::root().notice("Manifold kernel: shell converted as mesh only (" + manifold_error_string(status) + ")", shell->instance); } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( shell->instance.id(), shell->matrix, - new ifcopenshell::geometry::ManifoldShape(std::move(*part)), + new ifcopenshell::geom::manifold_shape(std::move(*part)), shell->surface_style)); return true; } -bool ManifoldKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::ConversionResults& results) { +bool manifold_kernel::convert_impl(const taxonomy::solid::ptr solid, ifcopenshell::geom::conversion_results& results) { std::vector shells; for (const auto& shell : solid->children) { const auto precision = settings_.get().get(); @@ -1548,15 +1548,15 @@ bool ManifoldKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::Con for (size_t i = 1; i < shells.size(); ++i) { result -= shells[i]; } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( solid->instance.id(), solid->matrix, - new ifcopenshell::geometry::ManifoldShape(result), + new ifcopenshell::geom::manifold_shape(result), solid->surface_style)); return true; } -bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeom::ConversionResults& results) { +bool manifold_kernel::convert_impl(const taxonomy::boolean_result::ptr br, ifcopenshell::geom::conversion_results& results) { std::vector operands; taxonomy::style::ptr style; std::optional first_bbox; @@ -1573,7 +1573,7 @@ bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeo ::logger::root().warning("Manifold kernel: cannot fit halfspace operand without a valid first operand bounds", child->instance); return false; } - HalfspaceBuildState state; + halfspace_build_state state; auto part = part_from_halfspace_solid(state, solid, face, *first_bbox, precision, dilation_hack); if (!part) { if (state.unchanged && br->operation == taxonomy::boolean_result::SUBTRACTION) { @@ -1592,8 +1592,8 @@ bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeo style = child->surface_style; } } else { - IfcGeom::ConversionResults converted; - if (!AbstractKernel::convert(child, converted)) { + ifcopenshell::geom::conversion_results converted; + if (!abstract_kernel::convert(child, converted)) { ::logger::root().warning("Manifold kernel: failed to convert boolean operand", child->instance); return false; } @@ -1626,15 +1626,15 @@ bool ManifoldKernel::convert_impl(const taxonomy::boolean_result::ptr br, IfcGeo ::logger::root().warning("Manifold kernel: boolean operation produced no result", br->instance); return false; } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( br->instance.id(), br->matrix, - new ifcopenshell::geometry::ManifoldShape(*result), + new ifcopenshell::geom::manifold_shape(*result), br->surface_style ? br->surface_style : style)); return true; } -bool ManifoldKernel::convert_openings(const express::Base&, const std::vector>& openings, const IfcGeom::ConversionResults& entity_shapes, const taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) { +bool manifold_kernel::convert_openings(const express::base&, const std::vector>& openings, const ifcopenshell::geom::conversion_results& entity_shapes, const taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes) { std::vector opening_operands; auto entity_bbox = results_bbox(entity_shapes); if (!entity_bbox) { @@ -1644,14 +1644,14 @@ bool ManifoldKernel::convert_openings(const express::Base&, const std::vector().get() * 10.; for (const auto& opening : openings) { const auto relative = taxonomy::make(entity_trsf.ccomponents().inverse() * opening.second.ccomponents()); - IfcGeom::ConversionResults converted; - if (!AbstractKernel::convert(opening.first, converted)) { + ifcopenshell::geom::conversion_results converted; + if (!abstract_kernel::convert(opening.first, converted)) { ::logger::root().warning("Manifold kernel: failed to convert opening operand", opening.first->instance); return false; } for (const auto& result : converted) { - auto moved = std::unique_ptr(result.Shape()->moved(taxonomy::make(relative->ccomponents() * result.Placement()->ccomponents()))); - auto* shape = dynamic_cast(moved.get()); + auto moved = std::unique_ptr(result.Shape()->moved(taxonomy::make(relative->ccomponents() * result.Placement()->ccomponents()))); + auto* shape = dynamic_cast(moved.get()); if (!shape) { ::logger::root().warning("Manifold kernel: opening result is not a manifold shape"); return false; @@ -1676,9 +1676,9 @@ bool ManifoldKernel::convert_openings(const express::Base&, const std::vector>& openings, - const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes); + virtual bool convert_openings(const express::base& entity, const std::vector>& openings, + const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes); }; } diff --git a/src/ifcgeom/kernels/manifold/plugin.cpp b/src/ifcgeom/kernels/manifold/plugin.cpp index 6f7dd2d744..7bb73ee2da 100644 --- a/src/ifcgeom/kernels/manifold/plugin.cpp +++ b/src/ifcgeom/kernels/manifold/plugin.cpp @@ -23,7 +23,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace kernels { namespace manifold_plugin { @@ -35,8 +35,8 @@ namespace ifcopenshell { return kernel_plugin_metadata("manifold"); } - AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) { - return new ManifoldKernel(settings); + abstract_kernel* create_kernel(ifcopenshell::file*, ifcopenshell::geom::settings& settings) { + return new manifold_kernel(settings); } void register_plugin(kernel_registry& registry, const plugin::module& module) { @@ -51,6 +51,6 @@ namespace ifcopenshell { } } -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::manifold_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::manifold_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::manifold_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::manifold_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::manifold_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::manifold_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) diff --git a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h index 61478cf24b..d2594f2077 100644 --- a/src/ifcgeom/kernels/opencascade/IfcGeomTree.h +++ b/src/ifcgeom/kernels/opencascade/IfcGeomTree.h @@ -72,7 +72,7 @@ #include #include "clash_utils.h" -namespace IfcGeom { +namespace ifcopenshell::geom { namespace { // Approximates the distance `other` protrudes into `volume` by finding the @@ -1349,9 +1349,9 @@ namespace IfcGeom { return ts_filtered; } - std::vector select(const IfcGeom::BRepElement* elem, bool completely_within = false, double extend = -1.e-5) const { - auto shp = (ifcopenshell::geometry::OpenCascadeShape*)elem->geometry().as_compound(); - TopoDS_Shape compound(std::move(((ifcopenshell::geometry::OpenCascadeShape*)shp)->shape())); + std::vector select(const ifcopenshell::geom::brep_element* elem, bool completely_within = false, double extend = -1.e-5) const { + auto shp = (ifcopenshell::geom::open_cascade_shape*)elem->geometry().as_compound(); + TopoDS_Shape compound(std::move(((ifcopenshell::geom::open_cascade_shape*)shp)->shape())); delete shp; const auto& m = elem->transformation().data()->ccomponents(); @@ -1380,7 +1380,7 @@ namespace IfcGeom { TopoDS_Vertex v; if (extend > 0.) { BRep_Builder B; - B.MakeVertex(v, p, Precision::Confusion()); + B.MakeVertex(v, p, ::Precision::Confusion()); } typename std::vector::const_iterator it = ts.begin(); @@ -1425,13 +1425,13 @@ namespace IfcGeom { std::unordered_map> normals_; // Temporary structures for H5 - std::vector triangulation_elements_; - std::map global_ids_; - std::map names_; - std::map placements_; + std::vector triangulation_elements_; + std::map global_ids_; + std::map names_; + std::map placements_; std::map> local_verts_; std::map> local_faces_; - std::map> local_materials_; + std::map> local_materials_; std::map> local_material_ids_; bool enable_face_styles_ = false; @@ -1465,44 +1465,44 @@ namespace IfcGeom { }; } - class opencascade_tree : public impl::tree { + class opencascade_tree : public impl::tree { public: opencascade_tree() {}; opencascade_tree(ifcopenshell::file& f) { - add_file(f, ifcopenshell::geometry::Settings{}); + add_file(f, ifcopenshell::geom::settings{}); } - opencascade_tree(ifcopenshell::file& f, ifcopenshell::geometry::Settings settings) { + opencascade_tree(ifcopenshell::file& f, ifcopenshell::geom::settings settings) { add_file(f, settings); } - opencascade_tree(IfcGeom::Iterator& it) { + opencascade_tree(ifcopenshell::geom::iterator& it) { add_file(it); } - void add_file(ifcopenshell::file& f, ifcopenshell::geometry::Settings settings) { - ifcopenshell::geometry::Settings settings_ = settings; - settings_.get().value = ifcopenshell::geometry::settings::NATIVE; - settings_.get().value = true; - settings_.get().value = true; + void add_file(ifcopenshell::file& f, ifcopenshell::geom::settings settings) { + ifcopenshell::geom::settings settings_ = settings; + settings_.get().value = ifcopenshell::geom::settings::NATIVE; + settings_.get().value = true; + settings_.get().value = true; - IfcGeom::Iterator it(std::unique_ptr(new OpenCascadeKernel(settings_)), settings_, &f, {}, 1); + ifcopenshell::geom::iterator it(std::unique_ptr(new open_cascade_kernel(settings_)), settings_, &f, {}, 1); add_file(it); } - void add_file(IfcGeom::Iterator& it) { + void add_file(ifcopenshell::geom::iterator& it) { if (it.initialize()) { do { - add_element(dynamic_cast(it.get())); + add_element(dynamic_cast(it.get())); } while (it.next()); } } template - void apply_matrix_to_flat_verts(const std::vector& flat_list, const ifcopenshell::geometry::taxonomy::matrix4::ptr& matrix, std::vector& result) { + void apply_matrix_to_flat_verts(const std::vector& flat_list, const ifcopenshell::geom::taxonomy::matrix4::ptr& matrix, std::vector& result) { Eigen::Vector3d vin; result.clear(); result.reserve(flat_list.size()); @@ -1547,7 +1547,7 @@ namespace IfcGeom { return dict.empty(); } - void add_element(IfcGeom::TriangulationElement* elem) { + void add_element(ifcopenshell::geom::triangulation_element* elem) { Bnd_Box aabb; Bnd_OBB obb; @@ -1705,7 +1705,7 @@ namespace IfcGeom { gp_Vec dir1(v1_pnt, v2_pnt); gp_Vec dir2(v1_pnt, v3_pnt); gp_Vec cross_product = dir1.Crossed(dir2); - if (cross_product.Magnitude() > Precision::Confusion()) { + if (cross_product.Magnitude() > ::Precision::Confusion()) { #if OCC_VERSION_HEX >= 0x80000 triangulation.Elements.Append(BVH_Vec4i( #else @@ -1744,12 +1744,12 @@ namespace IfcGeom { max_protrusions_[t] = std::min(std::min(obb.XHSize(), obb.YHSize()), obb.ZHSize()) * 2; } - void add_element(IfcGeom::BRepElement* elem) { + void add_element(ifcopenshell::geom::brep_element* elem) { if (!elem) { return; } - auto compound_generic = (ifcopenshell::geometry::OpenCascadeShape*)elem->geometry().as_compound(); + auto compound_generic = (ifcopenshell::geom::open_cascade_shape*)elem->geometry().as_compound(); TopoDS_Shape compound(std::move(compound_generic->shape())); delete compound_generic; @@ -1795,7 +1795,7 @@ namespace IfcGeom { return protrusion_distances_; } - std::vector select_ray(const gp_Pnt& p0, const gp_Dir& d, double length = 1000.) const { + std::vector select_ray(const gp_Pnt& p0, const gp_Dir& d, double length = 1000.) const { gp_Pnt p1 = p0.XYZ() + d.XYZ() * length; auto E = BRepBuilderAPI_MakeEdge(p0, p1).Edge(); Bnd_Box bb; @@ -1852,7 +1852,7 @@ namespace IfcGeom { enable_face_styles_ = b; } - const std::vector& styles() const { + const std::vector& styles() const { return styles_; } @@ -1860,7 +1860,7 @@ namespace IfcGeom { typedef NCollection_DataMap face_style_map_t; face_style_map_t face_styles_; - std::vector styles_; + std::vector styles_; }; } diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp index 327b41c884..2a94998cb7 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.cpp @@ -29,9 +29,9 @@ #include #endif -using IfcGeom::OpaqueNumber; -using IfcGeom::OpaqueCoordinate; -using IfcGeom::ConversionResultShape; +using ifcopenshell::geom::opaque_number; +using ifcopenshell::geom::opaque_coordinate; +using ifcopenshell::geom::conversion_result_shape; namespace { // We bypass the conversion to gp_GTrsf, because it does not work @@ -46,31 +46,31 @@ namespace { } } -ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape(const TopoDS_Shape& shape) +ifcopenshell::geom::open_cascade_shape::open_cascade_shape(const TopoDS_Shape& shape) : shape_(shape) {} -ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape(TopoDS_Shape&& shape) +ifcopenshell::geom::open_cascade_shape::open_cascade_shape(TopoDS_Shape&& shape) : shape_(std::move(shape)) {} -const TopoDS_Shape& ifcopenshell::geometry::OpenCascadeShape::shape() const { +const TopoDS_Shape& ifcopenshell::geom::open_cascade_shape::shape() const { return shape_; } -ifcopenshell::geometry::OpenCascadeShape::operator const TopoDS_Shape& () { +ifcopenshell::geom::open_cascade_shape::operator const TopoDS_Shape& () { return shape_; } -std::string_view ifcopenshell::geometry::OpenCascadeShape::backend_id() const { +std::string_view ifcopenshell::geom::open_cascade_shape::backend_id() const { return "opencascade"; } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::clone() const { - return new OpenCascadeShape(shape_); +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::open_cascade_shape::clone() const { + return new open_cascade_shape(shape_); } -void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { +void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger) const { - // @todo remove duplication with OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf); + // @todo remove duplication with open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf); // above can be static? // A 3x3 matrix to rotate the vertex normals @@ -243,7 +243,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr } if (polyhedral_output_without_holes || polyhedral_output_with_holes) { - auto loops = IfcGeom::util::find_boundary_loops(t->verts(), triangle_indices); + auto loops = ifcopenshell::geom::util::find_boundary_loops(t->verts(), triangle_indices); if (polyhedral_output_without_holes) { if (!loops.empty() && !loops[0].empty()) { t->addFace(item_id, surface_style_id, loops[0]); @@ -257,7 +257,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr } if (!t->normals().empty() && settings.get().get()) { - t->uvs_ref() = IfcGeom::Representation::Triangulation::box_project_uvs(t->verts(), t->normals()); + t->uvs_ref() = ifcopenshell::geom::Representation::triangulation::box_project_uvs(t->verts(), t->normals()); } if (num_faces == 0) { @@ -372,8 +372,8 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr } } -void ifcopenshell::geometry::OpenCascadeShape::Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string& r) const { - auto s = IfcGeom::util::apply_transformation(shape_, place); +void ifcopenshell::geom::open_cascade_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const { + auto s = ifcopenshell::geom::util::apply_transformation(shape_, place); std::stringstream sstream; #if OCC_VERSION_HEX >= 0x70600 BRepTools::Write(s, sstream, false, false, TopTools_FormatVersion_VERSION_2); @@ -383,90 +383,90 @@ void ifcopenshell::geometry::OpenCascadeShape::Serialize(const ifcopenshell::geo r = sstream.str(); } -int ifcopenshell::geometry::OpenCascadeShape::surface_genus() const { - return IfcGeom::util::surface_genus(shape_); +int ifcopenshell::geom::open_cascade_shape::surface_genus() const { + return ifcopenshell::geom::util::surface_genus(shape_); } -bool ifcopenshell::geometry::OpenCascadeShape::is_manifold() const { - return IfcGeom::util::is_manifold(shape_); +bool ifcopenshell::geom::open_cascade_shape::is_manifold() const { + return ifcopenshell::geom::util::is_manifold(shape_); } -int ifcopenshell::geometry::OpenCascadeShape::num_vertices() const +int ifcopenshell::geom::open_cascade_shape::num_vertices() const { - return IfcGeom::util::count(shape_, TopAbs_VERTEX); + return ifcopenshell::geom::util::count(shape_, TopAbs_VERTEX); } -int ifcopenshell::geometry::OpenCascadeShape::num_edges() const +int ifcopenshell::geom::open_cascade_shape::num_edges() const { - return IfcGeom::util::count(shape_, TopAbs_EDGE); + return ifcopenshell::geom::util::count(shape_, TopAbs_EDGE); } -int ifcopenshell::geometry::OpenCascadeShape::num_faces() const +int ifcopenshell::geom::open_cascade_shape::num_faces() const { - return IfcGeom::util::count(shape_, TopAbs_FACE); + return ifcopenshell::geom::util::count(shape_, TopAbs_FACE); } -OpaqueNumber ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape::length() +opaque_number ifcopenshell::geom::open_cascade_shape::open_cascade_shape::length() { GProp_GProps prop; BRepGProp::LinearProperties(shape_, prop); double l = prop.Mass(); - return OpaqueNumber(l); + return opaque_number(l); } -OpaqueNumber ifcopenshell::geometry::OpenCascadeShape::area() +opaque_number ifcopenshell::geom::open_cascade_shape::area() { GProp_GProps prop; BRepGProp::SurfaceProperties(shape_, prop); double l = prop.Mass(); - return OpaqueNumber(l); + return opaque_number(l); } -OpaqueNumber ifcopenshell::geometry::OpenCascadeShape::volume() +opaque_number ifcopenshell::geom::open_cascade_shape::volume() { GProp_GProps prop; BRepGProp::VolumeProperties(shape_, prop); double l = prop.Mass(); - return OpaqueNumber(l); + return opaque_number(l); } #include -OpaqueCoordinate<3> ifcopenshell::geometry::OpenCascadeShape::position() +opaque_coordinate<3> ifcopenshell::geom::open_cascade_shape::position() { if (shape_.ShapeType() == TopAbs_FACE) { auto surf = BRep_Tool::Surface(TopoDS::Face(shape_)); auto plane = Handle(Geom_Plane)::DownCast(surf); if (plane) { auto loc = plane->Location(); - return OpaqueCoordinate<3>( - OpaqueNumber(loc.X()), - OpaqueNumber(loc.Y()), - OpaqueNumber(loc.Z()) + return opaque_coordinate<3>( + opaque_number(loc.X()), + opaque_number(loc.Y()), + opaque_number(loc.Z()) ); } } throw std::runtime_error("Invalid shape type"); } -OpaqueCoordinate<3> ifcopenshell::geometry::OpenCascadeShape::axis() +opaque_coordinate<3> ifcopenshell::geom::open_cascade_shape::axis() { if (shape_.ShapeType() == TopAbs_FACE) { auto surf = BRep_Tool::Surface(TopoDS::Face(shape_)); auto plane = Handle(Geom_Plane)::DownCast(surf); if (plane) { auto dir = plane->Axis().Direction(); - return OpaqueCoordinate<3>( - OpaqueNumber(dir.X()), - OpaqueNumber(dir.Y()), - OpaqueNumber(dir.Z()) + return opaque_coordinate<3>( + opaque_number(dir.X()), + opaque_number(dir.Y()), + opaque_number(dir.Z()) ); } } throw std::runtime_error("Invalid shape type"); } -OpaqueCoordinate<4> ifcopenshell::geometry::OpenCascadeShape::plane_equation() +opaque_coordinate<4> ifcopenshell::geom::open_cascade_shape::plane_equation() { if (shape_.ShapeType() == TopAbs_FACE) { auto surf = BRep_Tool::Surface(TopoDS::Face(shape_)); @@ -474,121 +474,121 @@ OpaqueCoordinate<4> ifcopenshell::geometry::OpenCascadeShape::plane_equation() if (plane) { double a, b, c, d; plane->Pln().Coefficients(a, b, c, d); - return OpaqueCoordinate<4>( - OpaqueNumber(a), - OpaqueNumber(b), - OpaqueNumber(c), - OpaqueNumber(d) + return opaque_coordinate<4>( + opaque_number(a), + opaque_number(b), + opaque_number(c), + opaque_number(d) ); } } throw std::runtime_error("Invalid shape type"); } -std::vector ifcopenshell::geometry::OpenCascadeShape::convex_decomposition() +std::vector ifcopenshell::geom::open_cascade_shape::convex_decomposition() { throw std::runtime_error("Not implemented"); } -ConversionResultShape * ifcopenshell::geometry::OpenCascadeShape::halfspaces() +conversion_result_shape * ifcopenshell::geom::open_cascade_shape::halfspaces() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::solid() +conversion_result_shape* ifcopenshell::geom::open_cascade_shape::solid() { throw std::runtime_error("Not implemented"); } -ConversionResultShape * ifcopenshell::geometry::OpenCascadeShape::box() +conversion_result_shape * ifcopenshell::geom::open_cascade_shape::box() { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::wrap_in_compound() +conversion_result_shape* ifcopenshell::geom::open_cascade_shape::wrap_in_compound() { TopoDS_Compound compound; BRep_Builder builder; builder.MakeCompound(compound); builder.Add(compound, shape_); - return new OpenCascadeShape(std::move(compound)); + return new open_cascade_shape(std::move(compound)); } -std::vector ifcopenshell::geometry::OpenCascadeShape::vertices() +std::vector ifcopenshell::geom::open_cascade_shape::vertices() { NCollection_IndexedMap map; TopExp::MapShapes(shape_, TopAbs_VERTEX, map); - std::vector vec; + std::vector vec; for (int i = 1; i <= map.Extent(); ++i) { - vec.push_back(new OpenCascadeShape(map.FindKey(i))); + vec.push_back(new open_cascade_shape(map.FindKey(i))); } return vec; } -std::vector ifcopenshell::geometry::OpenCascadeShape::edges() +std::vector ifcopenshell::geom::open_cascade_shape::edges() { NCollection_IndexedMap map; TopExp::MapShapes(shape_, TopAbs_EDGE, map); - std::vector vec; + std::vector vec; for (int i = 1; i <= map.Extent(); ++i) { - vec.push_back(new OpenCascadeShape(map.FindKey(i))); + vec.push_back(new open_cascade_shape(map.FindKey(i))); } return vec; } -std::vector ifcopenshell::geometry::OpenCascadeShape::facets() +std::vector ifcopenshell::geom::open_cascade_shape::facets() { NCollection_IndexedMap map; TopExp::MapShapes(shape_, TopAbs_FACE, map); - std::vector vec; + std::vector vec; for (int i = 1; i <= map.Extent(); ++i) { - vec.push_back(new OpenCascadeShape(map.FindKey(i))); + vec.push_back(new open_cascade_shape(map.FindKey(i))); } return vec; } namespace { - ConversionResultShape* boolean_op(BOPAlgo_Operation op, const TopoDS_Shape& shape_, const TopoDS_Shape& other_shape) { - IfcGeom::util::boolean_settings st; + conversion_result_shape* boolean_op(BOPAlgo_Operation op, const TopoDS_Shape& shape_, const TopoDS_Shape& other_shape) { + ifcopenshell::geom::util::boolean_settings st; st.attempt_2d = true; st.debug = false; st.precision = 1.e-5; TopoDS_Shape result; - if (IfcGeom::util::boolean_operation(st, shape_, other_shape, op, result)) { - return new ifcopenshell::geometry::OpenCascadeShape(result); + if (ifcopenshell::geom::util::boolean_operation(st, shape_, other_shape, op, result)) { + return new ifcopenshell::geom::open_cascade_shape(result); } else { throw std::runtime_error("Failed to process boolean operation"); } } } -ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::add(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::open_cascade_shape::add(conversion_result_shape* other) { - return boolean_op(BOPAlgo_FUSE, shape_, ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_); + return boolean_op(BOPAlgo_FUSE, shape_, ((ifcopenshell::geom::open_cascade_shape*)other)->shape_); } -ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::subtract(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::open_cascade_shape::subtract(conversion_result_shape* other) { - return boolean_op(BOPAlgo_CUT, shape_, ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_); + return boolean_op(BOPAlgo_CUT, shape_, ((ifcopenshell::geom::open_cascade_shape*)other)->shape_); } -ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::intersect(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::open_cascade_shape::intersect(conversion_result_shape* other) { - return boolean_op(BOPAlgo_COMMON, shape_, ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_); + return boolean_op(BOPAlgo_COMMON, shape_, ((ifcopenshell::geom::open_cascade_shape*)other)->shape_); } -ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::concat(ConversionResultShape* other) +conversion_result_shape* ifcopenshell::geom::open_cascade_shape::concat(conversion_result_shape* other) { TopoDS_Compound compound; BRep_Builder builder; auto& left = shape_; - auto& right = ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_; + auto& right = ((ifcopenshell::geom::open_cascade_shape*)other)->shape_; // This reads a bit strange, but we want to specifically avoid compounds of faces that are // the result of shell instances that are not sewn into a shell (yet). - if (left.ShapeType() == TopAbs_COMPOUND && !IfcGeom::util::is_compound_of_faces(left)) { + if (left.ShapeType() == TopAbs_COMPOUND && !ifcopenshell::geom::util::is_compound_of_faces(left)) { compound = TopoDS::Compound(left); } else { builder.MakeCompound(compound); @@ -597,17 +597,17 @@ ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::concat(Conversi builder.Add(compound, right); - return new OpenCascadeShape(std::move(compound)); + return new open_cascade_shape(std::move(compound)); } -std::pair, OpaqueCoordinate<3>> ifcopenshell::geometry::OpenCascadeShape::bounding_box() const +std::pair, opaque_coordinate<3>> ifcopenshell::geom::open_cascade_shape::bounding_box() const { throw std::runtime_error("Not implemented"); } -ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::moved(ifcopenshell::geometry::taxonomy::matrix4::ptr t) const +conversion_result_shape* ifcopenshell::geom::open_cascade_shape::moved(ifcopenshell::geom::taxonomy::matrix4::ptr t) const { - return new OpenCascadeShape(IfcGeom::util::apply_transformation(shape_, *t)); + return new open_cascade_shape(ifcopenshell::geom::util::apply_transformation(shape_, *t)); } namespace { @@ -694,7 +694,7 @@ namespace { } -bool ifcopenshell::geometry::OpenCascadeShape::surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const +bool ifcopenshell::geom::open_cascade_shape::surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { gp_GTrsf trsf; @@ -717,10 +717,10 @@ bool ifcopenshell::geometry::OpenCascadeShape::surface_area_along_direction(doub return true; } -std::size_t ifcopenshell::geometry::OpenCascadeShape::map(OpaqueCoordinate<4>&, OpaqueCoordinate<4>&) { +std::size_t ifcopenshell::geom::open_cascade_shape::map(opaque_coordinate<4>&, opaque_coordinate<4>&) { throw std::runtime_error("Not implemented"); } -std::size_t ifcopenshell::geometry::OpenCascadeShape::map(const std::vector>&, const std::vector>&) { +std::size_t ifcopenshell::geom::open_cascade_shape::map(const std::vector>&, const std::vector>&) { throw std::runtime_error("Not implemented"); } diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h index 5868cee64a..8cffa17dab 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h @@ -35,24 +35,24 @@ #include "../../../ifcgeom/kernels/ifc_geomlibrary_api.h" namespace ifcopenshell { - namespace geometry { + namespace geom { - using IfcGeom::OpaqueCoordinate; - using IfcGeom::OpaqueNumber; + using ifcopenshell::geom::opaque_coordinate; + using ifcopenshell::geom::opaque_number; - class IFC_GEOMLIBRARY_API OpenCascadeShape : public IfcGeom::ConversionResultShape { + class IFC_GEOMLIBRARY_API open_cascade_shape : public ifcopenshell::geom::conversion_result_shape { public: - OpenCascadeShape(const TopoDS_Shape& shape); - OpenCascadeShape(TopoDS_Shape&& shape); + open_cascade_shape(const TopoDS_Shape& shape); + open_cascade_shape(TopoDS_Shape&& shape); const TopoDS_Shape& shape() const; operator const TopoDS_Shape& (); virtual std::string_view backend_id() const; - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; - virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; + virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; + virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; - virtual IfcGeom::ConversionResultShape* clone() const; + virtual ifcopenshell::geom::conversion_result_shape* clone() const; virtual double bounding_box(void*&) const { throw std::runtime_error("Not implemented"); @@ -70,36 +70,36 @@ namespace ifcopenshell { virtual int num_faces() const; // @todo this must be something with a virtual dtor so that we can delete it. - virtual std::pair, OpaqueCoordinate<3>> bounding_box() const; + virtual std::pair, opaque_coordinate<3>> bounding_box() const; - virtual OpaqueNumber length(); - virtual OpaqueNumber area(); - virtual OpaqueNumber volume(); + virtual opaque_number length(); + virtual opaque_number area(); + virtual opaque_number volume(); - virtual OpaqueCoordinate<3> position(); - virtual OpaqueCoordinate<3> axis(); - virtual OpaqueCoordinate<4> plane_equation(); + virtual opaque_coordinate<3> position(); + virtual opaque_coordinate<3> axis(); + virtual opaque_coordinate<4> plane_equation(); - virtual std::vector convex_decomposition(); - virtual ConversionResultShape* halfspaces(); - virtual ConversionResultShape* solid(); - virtual ConversionResultShape* box(); - virtual ConversionResultShape* wrap_in_compound(); + virtual std::vector convex_decomposition(); + virtual conversion_result_shape* halfspaces(); + virtual conversion_result_shape* solid(); + virtual conversion_result_shape* box(); + virtual conversion_result_shape* wrap_in_compound(); - virtual std::vector vertices(); - virtual std::vector edges(); - virtual std::vector facets(); + virtual std::vector vertices(); + virtual std::vector edges(); + virtual std::vector facets(); - virtual ConversionResultShape* add(ConversionResultShape*); - virtual ConversionResultShape* subtract(ConversionResultShape*); - virtual ConversionResultShape* intersect(ConversionResultShape*); - virtual ConversionResultShape* concat(ConversionResultShape*); + virtual conversion_result_shape* add(conversion_result_shape*); + virtual conversion_result_shape* subtract(conversion_result_shape*); + virtual conversion_result_shape* intersect(conversion_result_shape*); + virtual conversion_result_shape* concat(conversion_result_shape*); - virtual std::size_t map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to); - virtual std::size_t map(const std::vector>& from, const std::vector>& to); - virtual ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const; + virtual std::size_t map(opaque_coordinate<4>& from, opaque_coordinate<4>& to); + virtual std::size_t map(const std::vector>& from, const std::vector>& to); + virtual conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const; - virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; + virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; private: TopoDS_Shape shape_; }; diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp index 75651b5c99..831c035cb6 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp @@ -41,10 +41,10 @@ namespace { }; } -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; -bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, const std::vector>& openings, - const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) { +bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::base& entity, const std::vector>& openings, + const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes) { util::boolean_settings bst; bst.attempt_2d = settings_.get().get(); @@ -83,13 +83,13 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c Eigen::Matrix4d relative = entity_trsf.ccomponents().inverse() * opening_trsf.ccomponents(); // opening_trsf = relative; - IfcGeom::ConversionResults opening_shapes; + ifcopenshell::geom::conversion_results opening_shapes; // @todo - AbstractKernel::convert(op.first, opening_shapes); + abstract_kernel::convert(op.first, opening_shapes); for (unsigned int i = 0; i < opening_shapes.size(); ++i) { - auto opening_shape_i = std::static_pointer_cast(opening_shapes[i].Shape())->shape(); + auto opening_shape_i = std::static_pointer_cast(opening_shapes[i].Shape())->shape(); const TopoDS_Shape& opening_shape_unlocated = util::ensure_fit_for_subtraction(opening_shape_i, settings_.get().get()); auto gtrsf = opening_shapes[i].Placement(); @@ -110,7 +110,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c std::sort(opening_vector.begin(), opening_vector.end(), opening_sorter()); // Iterate over the shapes of the IfcProduct - for (IfcGeom::ConversionResults::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++it3) { + for (ifcopenshell::geom::conversion_results::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++it3) { TopoDS_Compound C; BRep_Builder B; @@ -119,7 +119,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c std::list parts; - auto it3_shape = std::static_pointer_cast(it3->Shape())->shape(); + auto it3_shape = std::static_pointer_cast(it3->Shape())->shape(); if (it3_shape.IsNull()) { logger_.error("GEO", 187, "Null operand"); continue; @@ -142,8 +142,8 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c if (!is_manifold) { // force sewing, edge identity might have been mudied by FixAdvFace.FixOrientation.MSG5 to fix interior loop winding order NCollection_List list; - IfcGeom::util::shape_to_face_list(entity_part, list); - IfcGeom::util::create_solid_from_faces(list, entity_part, settings_.get().get(), true); + ifcopenshell::geom::util::shape_to_face_list(entity_part, list); + ifcopenshell::geom::util::create_solid_from_faces(list, entity_part, settings_.get().get(), true); is_manifold = util::is_manifold(entity_part); if (is_manifold) { logger_.warning("GEO", 188, "Successfully sewed non-manifold first operand"); @@ -160,8 +160,8 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c try { mv.Perform(); auto entity_part_2 = mv.Shape(); - if (IfcGeom::util::count(entity_part_2, TopAbs_FACE) == 0) { - failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(IfcGeom::util::count(entity_part, TopAbs_FACE)); + if (ifcopenshell::geom::util::count(entity_part_2, TopAbs_FACE) == 0) { + failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(ifcopenshell::geom::util::count(entity_part, TopAbs_FACE)); } else { is_manifold = util::is_manifold(entity_part_2); logger_.warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold"))); @@ -262,24 +262,24 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c combined_result = C; } - cut_shapes.push_back(IfcGeom::ConversionResult(it3->ItemId(), new OpenCascadeShape(combined_result), it3->StylePtr())); + cut_shapes.push_back(ifcopenshell::geom::conversion_result(it3->ItemId(), new open_cascade_shape(combined_result), it3->StylePtr())); } return true; } -bool IfcGeom::OpenCascadeKernel::unify_shapes(const IfcGeom::ConversionResults& input, IfcGeom::ConversionResults& output) { +bool ifcopenshell::geom::open_cascade_kernel::unify_shapes(const ifcopenshell::geom::conversion_results& input, ifcopenshell::geom::conversion_results& output) { std::transform(input.begin(), input.end(), std::back_inserter(output), [this](auto v) { - auto& s = std::static_pointer_cast(v.Shape())->shape(); - return IfcGeom::ConversionResult( + auto& s = std::static_pointer_cast(v.Shape())->shape(); + return ifcopenshell::geom::conversion_result( v.ItemId(), v.Placement(), - new OpenCascadeShape(util::unify(s, settings_.get().get())), + new open_cascade_shape(util::unify(s, settings_.get().get())), v.StylePtr()); }); return true; } -bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, IfcGeom::ConversionResults& results) { +bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revolve::ptr r, ifcopenshell::geom::conversion_results& results) { gp_Ax1 ax( @@ -298,16 +298,16 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If shape = BRepPrimAPI_MakeRevol(face, ax); } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( r->instance.id(), r->matrix, - new OpenCascadeShape(shape), + new open_cascade_shape(shape), r->surface_style )); return true; } -// IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchema::IfcProduct* product) { +// IfcSchema::IfcRelVoidsElement::list::ptr ifcopenshell::geom::Kernel::find_openings(IfcSchema::IfcProduct* product) { // std::vector rs; // // if (product->declaration().is(IfcSchema::IfcElement::Class()) && !product->declaration().is(IfcSchema::IfcOpeningElement::Class())) { @@ -345,7 +345,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return openings; // } // -// const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(const IfcSchema::IfcProduct* product) { +// const IfcSchema::IfcMaterial* ifcopenshell::geom::Kernel::get_single_material_association(const IfcSchema::IfcProduct* product) { // IfcSchema::IfcMaterial* single_material = 0; // IfcSchema::IfcRelAssociatesMaterial::list::ptr associated_materials = product->HasAssociations()->as(); // if (associated_materials->size() == 1) { @@ -367,15 +367,15 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return single_material; // } // -// IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_representation_and_product( +// ifcopenshell::geom::brep_element* ifcopenshell::geom::Kernel::create_brep_for_representation_and_product( // const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product) // { // std::stringstream representation_id_builder; // // representation_id_builder << representation->data().id(); // -// IfcGeom::Representation::BRep* shape; -// IfcGeom::ConversionResults shapes, shapes2; +// ifcopenshell::geom::Representation::brep* shape; +// ifcopenshell::geom::conversion_results shapes, shapes2; // // if (!convert_shapes(representation, shapes)) { // return 0; @@ -430,7 +430,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // const IfcSchema::IfcMaterial* single_material = get_single_material_association(product); // if (single_material) { // auto s = get_style(single_material); -// for (IfcGeom::ConversionResults::iterator it = shapes.begin(); it != shapes.end(); ++it) { +// for (ifcopenshell::geom::conversion_results::iterator it = shapes.begin(); it != shapes.end(); ++it) { // if (!it->hasStyle() && s) { // it->setStyle(s); // material_style_applied = true; @@ -438,7 +438,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // } else { // bool some_items_without_style = false; -// for (IfcGeom::ConversionResults::iterator it = shapes.begin(); it != shapes.end(); ++it) { +// for (ifcopenshell::geom::conversion_results::iterator it = shapes.begin(); it != shapes.end(); ++it) { // if (!it->hasStyle() && util::count(it->Shape(), TopAbs_FACE)) { // some_items_without_style = true; // break; @@ -458,7 +458,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // if (s.hasStyle()) { // for (auto& p : style_cache) { // if (p.second == s.StylePtr()) { -// std::const_pointer_cast(p.second)->Transparency() = settings.force_space_transparency(); +// std::const_pointer_cast(p.second)->Transparency() = settings.force_space_transparency(); // } // } // } @@ -467,7 +467,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // // int parent_id = -1; // try { -// express::Entity* parent_object = get_decomposing_entity(product); +// express::entity* parent_object = get_decomposing_entity(product); // if (parent_object && parent_object->as()) { // parent_id = parent_object->data().id(); // } @@ -496,13 +496,13 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // const std::string product_type = product->declaration().name(); // ElementSettings element_settings(settings, getValue(GV_LENGTH_UNIT), product_type); // -// if (!settings.get(IfcGeom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS) && openings && openings->size()) { +// if (!settings.get(ifcopenshell::geom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS) && openings && openings->size()) { // representation_id_builder << "-openings"; // for (IfcSchema::IfcRelVoidsElement::list::it it = openings->begin(); it != openings->end(); ++it) { // representation_id_builder << "-" << (*it)->data().id(); // } // -// IfcGeom::ConversionResults opened_shapes; +// ifcopenshell::geom::conversion_results opened_shapes; // bool caught_error = false; // try { // convert_openings(product, openings, shapes, trsf, opened_shapes); @@ -518,22 +518,22 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // // if (settings.get(IteratorSettings::USE_WORLD_COORDS)) { -// for (IfcGeom::ConversionResults::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++it) { +// for (ifcopenshell::geom::conversion_results::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++it) { // it->prepend(trsf); // } // trsf = gp_Trsf(); // representation_id_builder << "-world-coords"; // } -// shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), opened_shapes); +// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), opened_shapes); // } else if (settings.get(IteratorSettings::USE_WORLD_COORDS)) { -// for (IfcGeom::ConversionResults::iterator it = shapes.begin(); it != shapes.end(); ++it) { +// for (ifcopenshell::geom::conversion_results::iterator it = shapes.begin(); it != shapes.end(); ++it) { // it->prepend(trsf); // } // trsf = gp_Trsf(); // representation_id_builder << "-world-coords"; -// shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), shapes); +// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), shapes); // } else { -// shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), shapes); +// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), shapes); // } // // std::string context_string = ""; @@ -543,7 +543,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // context_string = *representation->ContextOfItems()->ContextType(); // } // -// auto elem = new BRepElement( +// auto elem = new brep_element( // product->data().id(), // parent_id, // name, @@ -551,7 +551,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // guid, // context_string, // trsf, -// boost::shared_ptr(shape), +// boost::shared_ptr(shape), // product // ); // @@ -627,7 +627,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return elem; // } // -// IfcSchema::IfcRepresentation* IfcGeom::Kernel::representation_mapped_to(const IfcSchema::IfcRepresentation* representation) { +// IfcSchema::IfcRepresentation* ifcopenshell::geom::Kernel::representation_mapped_to(const IfcSchema::IfcRepresentation* representation) { // IfcSchema::IfcRepresentation* representation_mapped_to = 0; // try { // IfcSchema::IfcRepresentationItem::list::ptr items = representation->Items(); @@ -652,7 +652,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return representation_mapped_to; // } // -// IfcSchema::IfcProduct::list::ptr IfcGeom::Kernel::products_represented_by(const IfcSchema::IfcRepresentation* representation) { +// IfcSchema::IfcProduct::list::ptr ifcopenshell::geom::Kernel::products_represented_by(const IfcSchema::IfcRepresentation* representation) { // IfcSchema::IfcProduct::list::ptr products(new IfcSchema::IfcProduct::list); // // IfcSchema::IfcProductRepresentation::list::ptr prodreps = representation->OfProductRepresentation(); @@ -710,13 +710,13 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return products; // } // -// IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_processed_representation( +// ifcopenshell::geom::brep_element* ifcopenshell::geom::Kernel::create_brep_for_processed_representation( // const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, -// IfcGeom::BRepElement* brep) +// ifcopenshell::geom::brep_element* brep) // { // int parent_id = -1; // try { -// express::Entity* parent_object = get_decomposing_entity(product); +// express::entity* parent_object = get_decomposing_entity(product); // if (parent_object && parent_object->as()) { // parent_id = parent_object->data().id(); // } @@ -747,7 +747,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // // const std::string product_type = product->declaration().name(); // -// return new BRepElement( +// return new brep_element( // product->data().id(), // parent_id, // name, @@ -760,17 +760,17 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // ); // } // -// bool IfcGeom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std::vector& surfaces, std::vector>& styles, std::vector& thicknesses) { +// bool ifcopenshell::geom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std::vector& surfaces, std::vector>& styles, std::vector& thicknesses) { // // } // -// bool IfcGeom::Kernel::find_wall_end_points(const IfcSchema::IfcWall* wall, gp_Pnt& start, gp_Pnt& end) { +// bool ifcopenshell::geom::Kernel::find_wall_end_points(const IfcSchema::IfcWall* wall, gp_Pnt& start, gp_Pnt& end) { // IfcSchema::IfcRepresentation* axis_representation = find_representation(wall, "Axis"); // if (!axis_representation) { // return false; // } // -// ConversionResults items; +// conversion_results items; // { // Kernel temp = *this; // temp.setValue(GV_DIMENSIONALITY, -1.); @@ -778,7 +778,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // // TopoDS_Vertex a, b; -// for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) { +// for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) { // TopExp_Explorer exp(it->Shape(), TopAbs_VERTEX); // for (; exp.More(); exp.Next()) { // b = TopoDS::Vertex(exp.Current()); @@ -798,7 +798,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return true; // } // -// bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const ConversionResults& items, const std::vector& surfaces, const std::vector& thicknesses, std::vector< std::vector >& result) { +// bool ifcopenshell::geom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const conversion_results& items, const std::vector& surfaces, const std::vector& thicknesses, std::vector< std::vector >& result) { // /* // * @todo isn't it easier to do this based on the non-folded surfaces of // * the connected walls and fold both pairs of layersets simultaneously? @@ -969,7 +969,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // continue; // } // -// ConversionResults axis_items; +// conversion_results axis_items; // { // Kernel temp = *this; // temp.setValue(GV_DIMENSIONALITY, -1.); @@ -1172,7 +1172,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return folds_made; // } // -// IfcSchema::IfcRepresentation* IfcGeom::Kernel::find_representation(const IfcSchema::IfcProduct* product, const std::string& identifier) { +// IfcSchema::IfcRepresentation* ifcopenshell::geom::Kernel::find_representation(const IfcSchema::IfcProduct* product, const std::string& identifier) { // if (!product->Representation()) return 0; // IfcSchema::IfcProductRepresentation* prod_rep = product->Representation(); // IfcSchema::IfcRepresentation::list::ptr reps = prod_rep->Representations(); @@ -1184,7 +1184,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return 0; // } // -// const IfcSchema::IfcRepresentationptr IfcGeom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationptr item) { +// const IfcSchema::IfcRepresentationptr ifcopenshell::geom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationptr item) { // if (item->StyledByItem()->size()) { // return item; // } @@ -1206,7 +1206,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return item; // } // -// bool IfcGeom::Kernel::is_identity_transform(ifcopenshell::IfcBaseInterface* l) { +// bool ifcopenshell::geom::Kernel::is_identity_transform(ifcopenshell::IfcBaseInterface* l) { // IfcSchema::IfcAxis2Placement2D* ax2d; // IfcSchema::IfcAxis2Placement3D* ax3d; // @@ -1244,11 +1244,11 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // } // -// void IfcGeom::Kernel::set_conversion_placement_rel_to_type(const ifcopenshell::declaration* type) { +// void ifcopenshell::geom::Kernel::set_conversion_placement_rel_to_type(const ifcopenshell::declaration* type) { // placement_rel_to_type_ = type; // } // -// void IfcGeom::Kernel::set_conversion_placement_rel_to_instance(const express::Entity* instance) { +// void ifcopenshell::geom::Kernel::set_conversion_placement_rel_to_instance(const express::entity* instance) { // placement_rel_to_instance_ = instance; // } // @@ -1288,7 +1288,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // // #define Kernel POSTFIX_SCHEMA(Kernel) // -// std::shared_ptr IfcGeom::Kernel::internalize_surface_style(const std::pair& shading_styles) { +// std::shared_ptr ifcopenshell::geom::Kernel::internalize_surface_style(const std::pair& shading_styles) { // if (shading_styles.second == 0) { // return 0; // } @@ -1354,11 +1354,11 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return style_cache[surface_style_id] = surface_style_ptr_const; // } // -// std::shared_ptr IfcGeom::Kernel::get_style(const IfcSchema::IfcRepresentationptr item) { +// std::shared_ptr ifcopenshell::geom::Kernel::get_style(const IfcSchema::IfcRepresentationptr item) { // return internalize_surface_style(get_surface_style(item)); // } // -// std::shared_ptr IfcGeom::Kernel::get_style(const IfcSchema::IfcMaterial* material) { +// std::shared_ptr ifcopenshell::geom::Kernel::get_style(const IfcSchema::IfcMaterial* material) { // IfcSchema::IfcMaterialDefinitionRepresentation::list::ptr defs = material->HasRepresentation(); // for (IfcSchema::IfcMaterialDefinitionRepresentation::list::it jt = defs->begin(); jt != defs->end(); ++jt) { // IfcSchema::IfcRepresentation::list::ptr reps = (*jt)->Representations(); @@ -1373,11 +1373,11 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // } // } // } -// auto material_style = std::make_shared(material->data().id(), material->Name()); +// auto material_style = std::make_shared(material->data().id(), material->Name()); // return style_cache[material->data().id()] = material_style; // } // -// void IfcGeom::Kernel::apply_layerset(IfcGeom::ConversionResults& r, const ifcopenshell::geometry::layerset_information& info) { +// void ifcopenshell::geom::Kernel::apply_layerset(ifcopenshell::geom::conversion_results& r, const ifcopenshell::geom::layerset_information& info) { // convert(info.layers); // // if (info.layers.empty()) { @@ -1398,8 +1398,8 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If // return false; // } // -// IfcGeom::ConversionResults r2; -// if (IfcGeom::util::apply_layerset(r, const std::vector&, ConversionResults& r2, double tol)) { +// ifcopenshell::geom::conversion_results r2; +// if (ifcopenshell::geom::util::apply_layerset(r, const std::vector&, conversion_results& r2, double tol)) { // std::swap(r, r2) // } // } diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h index 5a5f182760..07628e74d5 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.h @@ -69,9 +69,9 @@ bool handle_occt_exception(Fn&& fn) { } } -namespace IfcGeom { +namespace ifcopenshell::geom { -class IFC_GEOMLIBRARY_API OpenCascadeKernel : public ifcopenshell::geometry::kernels::AbstractKernel { +class IFC_GEOMLIBRARY_API open_cascade_kernel : public ifcopenshell::geom::kernels::abstract_kernel { private: /* @@ -84,16 +84,16 @@ private: class faceset_helper { private: - OpenCascadeKernel* kernel_; + open_cascade_kernel* kernel_; std::set duplicates_; std::map vertex_mapping_; std::map, TopoDS_Edge> edges_; double eps_; bool non_manifold_; - void loop_(const ifcopenshell::geometry::taxonomy::loop::ptr ps, const std::function& callback); + void loop_(const ifcopenshell::geom::taxonomy::loop::ptr ps, const std::function& callback); public: - faceset_helper(OpenCascadeKernel* kernel, const ifcopenshell::geometry::taxonomy::shell::ptr l); + faceset_helper(open_cascade_kernel* kernel, const ifcopenshell::geom::taxonomy::shell::ptr l); ~faceset_helper(); bool non_manifold() const { return non_manifold_; } @@ -102,54 +102,54 @@ private: bool edge(int A, int B, TopoDS_Edge& e); - bool wire(const ifcopenshell::geometry::taxonomy::loop::ptr loop, TopoDS_Wire& wire); - bool wires(const ifcopenshell::geometry::taxonomy::loop::ptr loop, NCollection_List& wires); + bool wire(const ifcopenshell::geom::taxonomy::loop::ptr loop, TopoDS_Wire& wire); + bool wires(const ifcopenshell::geom::taxonomy::loop::ptr loop, NCollection_List& wires); }; faceset_helper* faceset_helper_; double precision_; public: - OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings, ::logger& logger = ::logger::root()) - : AbstractKernel("opencascade", settings, logger) + open_cascade_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) + : abstract_kernel("opencascade", settings, logger) , faceset_helper_(nullptr) - , precision_(settings.get().get()) + , precision_(settings.get().get()) {} - virtual AbstractKernel* clone(::logger& logger) const { - return new OpenCascadeKernel(settings(), logger); + virtual abstract_kernel* clone(::logger& logger) const { + return new open_cascade_kernel(settings(), logger); } virtual bool supports_boolean_operations() const { return true; } - bool convert(const ifcopenshell::geometry::taxonomy::extrusion::ptr, TopoDS_Shape&); - bool convert(const ifcopenshell::geometry::taxonomy::face::ptr, TopoDS_Shape&, bool reversed_surface = false); - bool convert(const ifcopenshell::geometry::taxonomy::loop::ptr, TopoDS_Wire&); - bool convert(const ifcopenshell::geometry::taxonomy::matrix4::ptr, gp_GTrsf&); - bool convert(const ifcopenshell::geometry::taxonomy::shell::ptr, TopoDS_Shape&); - bool convert(const ifcopenshell::geometry::taxonomy::solid::ptr, TopoDS_Shape&); - bool convert(const ifcopenshell::geometry::taxonomy::loft::ptr, TopoDS_Shape&); - bool convert(const ifcopenshell::geometry::taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf); - bool convert(const ifcopenshell::geometry::taxonomy::sweep_along_curve::ptr, TopoDS_Shape&); + bool convert(const ifcopenshell::geom::taxonomy::extrusion::ptr, TopoDS_Shape&); + bool convert(const ifcopenshell::geom::taxonomy::face::ptr, TopoDS_Shape&, bool reversed_surface = false); + bool convert(const ifcopenshell::geom::taxonomy::loop::ptr, TopoDS_Wire&); + bool convert(const ifcopenshell::geom::taxonomy::matrix4::ptr, gp_GTrsf&); + bool convert(const ifcopenshell::geom::taxonomy::shell::ptr, TopoDS_Shape&); + bool convert(const ifcopenshell::geom::taxonomy::solid::ptr, TopoDS_Shape&); + bool convert(const ifcopenshell::geom::taxonomy::loft::ptr, TopoDS_Shape&); + bool convert(const ifcopenshell::geom::taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf); + bool convert(const ifcopenshell::geom::taxonomy::sweep_along_curve::ptr, TopoDS_Shape&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::edge::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::loop::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::face::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::solid::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::shell::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::extrusion::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::revolve::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::loft::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::sweep_along_curve::ptr, IfcGeom::ConversionResults&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::edge::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::loop::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::face::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::solid::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::shell::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::extrusion::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::revolve::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::boolean_result::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::loft::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const ifcopenshell::geom::taxonomy::sweep_along_curve::ptr, ifcopenshell::geom::conversion_results&); - virtual bool convert_openings(const express::Base& entity, const std::vector>& openings, - const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes); - virtual bool unify_shapes(const IfcGeom::ConversionResults& input, IfcGeom::ConversionResults& output); + virtual bool convert_openings(const express::base& entity, const std::vector>& openings, + const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes); + virtual bool unify_shapes(const ifcopenshell::geom::conversion_results& input, ifcopenshell::geom::conversion_results& output); typedef std::variant curve_creation_visitor_result_type; - curve_creation_visitor_result_type convert_curve(const ifcopenshell::geometry::taxonomy::ptr); - Handle(Geom_Surface) convert_surface(const ifcopenshell::geometry::taxonomy::ptr); + curve_creation_visitor_result_type convert_curve(const ifcopenshell::geom::taxonomy::ptr); + Handle(Geom_Surface) convert_surface(const ifcopenshell::geom::taxonomy::ptr); template static T convert_xyz(const U& u) { @@ -164,8 +164,8 @@ public: } }; -express::Base POSTFIX_SCHEMA(tesselate_)(const TopoDS_Shape& shape, double deflection); -express::Base POSTFIX_SCHEMA(serialise_)(const TopoDS_Shape& shape, bool advanced); +express::base POSTFIX_SCHEMA(tesselate_)(const TopoDS_Shape& shape, double deflection); +express::base POSTFIX_SCHEMA(serialise_)(const TopoDS_Shape& shape, bool advanced); } #endif diff --git a/src/ifcgeom/kernels/opencascade/base_utils.cpp b/src/ifcgeom/kernels/opencascade/base_utils.cpp index c0d2ac0d7d..6b22b56f13 100644 --- a/src/ifcgeom/kernels/opencascade/base_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/base_utils.cpp @@ -56,7 +56,7 @@ // For axis placements detect equality early in order for the // relatively computionaly expensive gp_Trsf calculation to be skipped -bool IfcGeom::util::axis_equal(const gp_Ax3 & a, const gp_Ax3 & b, double tolerance) { +bool ifcopenshell::geom::util::axis_equal(const gp_Ax3 & a, const gp_Ax3 & b, double tolerance) { if (!a.Location().IsEqual(b.Location(), tolerance)) return false; // Note that the tolerance below is angular, above is linear. Since architectural // objects are about 1m'ish in scale, it should be somewhat equivalent. Besides, @@ -67,13 +67,13 @@ bool IfcGeom::util::axis_equal(const gp_Ax3 & a, const gp_Ax3 & b, double tolera return true; } -bool IfcGeom::util::axis_equal(const gp_Ax2d & a, const gp_Ax2d & b, double tolerance) { +bool ifcopenshell::geom::util::axis_equal(const gp_Ax2d & a, const gp_Ax2d & b, double tolerance) { if (!a.Location().IsEqual(b.Location(), tolerance)) return false; if (!a.Direction().IsEqual(b.Direction(), tolerance)) return false; return true; } -int IfcGeom::util::count(const TopoDS_Shape& s, TopAbs_ShapeEnum t, bool unique) { +int ifcopenshell::geom::util::count(const TopoDS_Shape& s, TopAbs_ShapeEnum t, bool unique) { if (unique) { NCollection_IndexedMap map; TopExp::MapShapes(s, t, map); @@ -89,7 +89,7 @@ int IfcGeom::util::count(const TopoDS_Shape& s, TopAbs_ShapeEnum t, bool unique) } -int IfcGeom::util::surface_genus(const TopoDS_Shape& s) { +int ifcopenshell::geom::util::surface_genus(const TopoDS_Shape& s) { int nv = count(s, TopAbs_VERTEX, true); int ne = count(s, TopAbs_EDGE, true); int nf = count(s, TopAbs_FACE, true); @@ -100,7 +100,7 @@ int IfcGeom::util::surface_genus(const TopoDS_Shape& s) { return genus; } -bool IfcGeom::util::is_manifold(const TopoDS_Shape& a) { +bool ifcopenshell::geom::util::is_manifold(const TopoDS_Shape& a) { if (a.ShapeType() == TopAbs_COMPOUND || a.ShapeType() == TopAbs_SOLID) { TopoDS_Iterator it(a); for (; it.More(); it.Next()) { @@ -134,7 +134,7 @@ bool IfcGeom::util::is_manifold(const TopoDS_Shape& a) { } -bool IfcGeom::util::is_nested_compound_of_solid(const TopoDS_Shape& s, int depth) { +bool ifcopenshell::geom::util::is_nested_compound_of_solid(const TopoDS_Shape& s, int depth) { if (s.ShapeType() == TopAbs_COMPOUND) { TopoDS_Iterator it(s); for (; it.More(); it.Next()) { @@ -174,23 +174,23 @@ namespace { } } -bool IfcGeom::util::is_identity(const gp_Trsf2d& t, double tolerance) { +bool ifcopenshell::geom::util::is_identity(const gp_Trsf2d& t, double tolerance) { return is_identity_helper(t, tolerance); } -bool IfcGeom::util::is_identity(const gp_GTrsf2d& t, double tolerance) { +bool ifcopenshell::geom::util::is_identity(const gp_GTrsf2d& t, double tolerance) { return is_identity_helper(t, tolerance); } -bool IfcGeom::util::is_identity(const gp_Trsf& t, double tolerance) { +bool ifcopenshell::geom::util::is_identity(const gp_Trsf& t, double tolerance) { return is_identity_helper(t, tolerance); } -bool IfcGeom::util::is_identity(const gp_GTrsf& t, double tolerance) { +bool ifcopenshell::geom::util::is_identity(const gp_GTrsf& t, double tolerance) { return is_identity_helper(t, tolerance); } -gp_Trsf IfcGeom::util::combine_offset_and_rotation(const gp_Vec & offset, const gp_Quaternion & rotation) { +gp_Trsf ifcopenshell::geom::util::combine_offset_and_rotation(const gp_Vec & offset, const gp_Quaternion & rotation) { auto offset_transform = gp_Trsf{}; offset_transform.SetTranslation(offset); @@ -201,7 +201,7 @@ gp_Trsf IfcGeom::util::combine_offset_and_rotation(const gp_Vec & offset, const } -bool IfcGeom::util::project(const opencascade::handle& srf, const TopoDS_Shape& shp, double& u1, double& v1, double& u2, double& v2, double widen) { +bool ifcopenshell::geom::util::project(const opencascade::handle& srf, const TopoDS_Shape& shp, double& u1, double& v1, double& u2, double& v2, double widen) { // @todo std::unique_ptr for C++11 ShapeAnalysis_Surface* sas = 0; opencascade::handle pln; @@ -281,7 +281,7 @@ bool IfcGeom::util::project(const opencascade::handle& srf, const } -TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const gp_Trsf& t) { +TopoDS_Shape ifcopenshell::geom::util::apply_transformation(const TopoDS_Shape& s, const gp_Trsf& t) { if (t.Form() == gp_Identity) { return s; } else { @@ -295,7 +295,7 @@ TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const gp } -TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const gp_GTrsf& t) { +TopoDS_Shape ifcopenshell::geom::util::apply_transformation(const TopoDS_Shape& s, const gp_GTrsf& t) { if (t.Form() == gp_Other) { return BRepBuilderAPI_GTransform(s, t, true); } else { @@ -318,7 +318,7 @@ namespace { } } -TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const ifcopenshell::geometry::taxonomy::matrix4& t) { +TopoDS_Shape ifcopenshell::geom::util::apply_transformation(const TopoDS_Shape& s, const ifcopenshell::geom::taxonomy::matrix4& t) { gp_GTrsf trsf; if (t.components_) { @@ -353,7 +353,7 @@ TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const if return apply_transformation(s, trsf); } -bool IfcGeom::util::fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, TopoDS_Shape& box, double& height, double tol) { +bool ifcopenshell::geom::util::fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, TopoDS_Shape& box, double& height, double tol) { TopExp_Explorer exp(b, TopAbs_FACE); if (!exp.More()) { return false; @@ -451,7 +451,7 @@ bool IfcGeom::util::fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, } -const opencascade::handle IfcGeom::util::intersect(const opencascade::handle& a, const opencascade::handle& b) { +const opencascade::handle ifcopenshell::geom::util::intersect(const opencascade::handle& a, const opencascade::handle& b) { GeomAPI_IntSS x(a, b, 1.e-7); if (x.IsDone() && x.NbLines() == 1) { return x.Line(1); @@ -461,15 +461,15 @@ const opencascade::handle IfcGeom::util::intersect(const opencascade } } -const opencascade::handle IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Face& b) { +const opencascade::handle ifcopenshell::geom::util::intersect(const opencascade::handle& a, const TopoDS_Face& b) { return intersect(a, BRep_Tool::Surface(b)); } -const opencascade::handle IfcGeom::util::intersect(const TopoDS_Face& a, const opencascade::handle& b) { +const opencascade::handle ifcopenshell::geom::util::intersect(const TopoDS_Face& a, const opencascade::handle& b) { return intersect(BRep_Tool::Surface(a), b); } -bool IfcGeom::util::intersect(const opencascade::handle& a, const opencascade::handle& b, gp_Pnt& p) { +bool ifcopenshell::geom::util::intersect(const opencascade::handle& a, const opencascade::handle& b, gp_Pnt& p) { GeomAPI_IntCS x(a, b); if (x.IsDone() && x.NbPoints() == 1) { p = x.Point(1); @@ -479,11 +479,11 @@ bool IfcGeom::util::intersect(const opencascade::handle& a, const op } } -bool IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Face& b, gp_Pnt &c) { +bool ifcopenshell::geom::util::intersect(const opencascade::handle& a, const TopoDS_Face& b, gp_Pnt &c) { return intersect(a, BRep_Tool::Surface(b), c); } -bool IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Shape& b, std::vector& out) { +bool ifcopenshell::geom::util::intersect(const opencascade::handle& a, const TopoDS_Shape& b, std::vector& out) { TopExp_Explorer exp(b, TopAbs_FACE); gp_Pnt p; for (; exp.More(); exp.Next()) { @@ -494,7 +494,7 @@ bool IfcGeom::util::intersect(const opencascade::handle& a, const To return !out.empty(); } -bool IfcGeom::util::intersect(const opencascade::handle& a, const TopoDS_Shape& b, std::vector< std::pair, opencascade::handle > >& out) { +bool ifcopenshell::geom::util::intersect(const opencascade::handle& a, const TopoDS_Shape& b, std::vector< std::pair, opencascade::handle > >& out) { TopExp_Explorer exp(b, TopAbs_FACE); for (; exp.More(); exp.Next()) { const TopoDS_Face& f = TopoDS::Face(exp.Current()); @@ -507,7 +507,7 @@ bool IfcGeom::util::intersect(const opencascade::handle& a, const return !out.empty(); } -bool IfcGeom::util::closest(const gp_Pnt& a, const std::vector& b, gp_Pnt& c) { +bool ifcopenshell::geom::util::closest(const gp_Pnt& a, const std::vector& b, gp_Pnt& c) { double minimal_distance = std::numeric_limits::infinity(); for (std::vector::const_iterator it = b.begin(); it != b.end(); ++it) { const double d = a.Distance(*it); @@ -519,26 +519,26 @@ bool IfcGeom::util::closest(const gp_Pnt& a, const std::vector& b, gp_Pn return minimal_distance != std::numeric_limits::infinity(); } -bool IfcGeom::util::project(const opencascade::handle& crv, const gp_Pnt& pt, gp_Pnt& p, double& u, double& d) { +bool ifcopenshell::geom::util::project(const opencascade::handle& crv, const gp_Pnt& pt, gp_Pnt& p, double& u, double& d) { ShapeAnalysis_Curve sac; sac.Project(crv, pt, 1e-3, p, u, false); d = pt.Distance(p); return true; } -double IfcGeom::util::shape_volume(const TopoDS_Shape& s) { +double ifcopenshell::geom::util::shape_volume(const TopoDS_Shape& s) { GProp_GProps prop; BRepGProp::VolumeProperties(s, prop); return prop.Mass(); } -double IfcGeom::util::face_area(const TopoDS_Face& f) { +double ifcopenshell::geom::util::face_area(const TopoDS_Face& f) { GProp_GProps prop; BRepGProp::SurfaceProperties(f, prop); return prop.Mass(); } -bool IfcGeom::util::is_convex(const TopoDS_Wire& wire, double tol) { +bool ifcopenshell::geom::util::is_convex(const TopoDS_Wire& wire, double tol) { for (TopExp_Explorer exp1(wire, TopAbs_VERTEX); exp1.More(); exp1.Next()) { TopoDS_Vertex V1 = TopoDS::Vertex(exp1.Current()); gp_Pnt P1 = BRep_Tool::Pnt(V1); @@ -585,12 +585,12 @@ bool IfcGeom::util::is_convex(const TopoDS_Wire& wire, double tol) { return true; } -TopoDS_Shape IfcGeom::util::halfspace_from_plane(const gp_Pln& pln, const gp_Pnt& cent) { +TopoDS_Shape ifcopenshell::geom::util::halfspace_from_plane(const gp_Pln& pln, const gp_Pnt& cent) { TopoDS_Face face = BRepBuilderAPI_MakeFace(pln).Face(); return BRepPrimAPI_MakeHalfSpace(face, cent).Solid(); } -gp_Pln IfcGeom::util::plane_from_face(const TopoDS_Face& face) { +gp_Pln ifcopenshell::geom::util::plane_from_face(const TopoDS_Face& face) { BRepGProp_Face prop(face); double u1, u2, v1, v2; prop.Bounds(u1, u2, v1, v2); @@ -602,7 +602,7 @@ gp_Pln IfcGeom::util::plane_from_face(const TopoDS_Face& face) { return gp_Pln(p, n); } -gp_Pnt IfcGeom::util::point_above_plane(const gp_Pln& pln, bool agree) { +gp_Pnt ifcopenshell::geom::util::point_above_plane(const gp_Pln& pln, bool agree) { if (agree) { return pln.Location().Translated(pln.Axis().Direction()); } else { @@ -610,7 +610,7 @@ gp_Pnt IfcGeom::util::point_above_plane(const gp_Pln& pln, bool agree) { } } -bool IfcGeom::util::is_compound_of_faces(const TopoDS_Shape& shape) { +bool ifcopenshell::geom::util::is_compound_of_faces(const TopoDS_Shape& shape) { bool has_solids = TopExp_Explorer(shape, TopAbs_SOLID).More() != 0; bool has_shells = TopExp_Explorer(shape, TopAbs_SHELL).More() != 0; bool has_compounds = TopExp_Explorer(shape, TopAbs_COMPOUND).More() != 0; @@ -618,7 +618,7 @@ bool IfcGeom::util::is_compound_of_faces(const TopoDS_Shape& shape) { return has_compounds && has_faces && !has_solids && !has_shells; } -bool IfcGeom::util::shape_to_face_list(const TopoDS_Shape& s, NCollection_List& li) { +bool ifcopenshell::geom::util::shape_to_face_list(const TopoDS_Shape& s, NCollection_List& li) { TopExp_Explorer exp(s, TopAbs_FACE); for (; exp.More(); exp.Next()) { TopoDS_Face face = TopoDS::Face(exp.Current()); @@ -627,7 +627,7 @@ bool IfcGeom::util::shape_to_face_list(const TopoDS_Shape& s, NCollection_List face_list; shape_to_face_list(compound, face_list); if (face_list.Extent() == 0) { @@ -636,7 +636,7 @@ bool IfcGeom::util::create_solid_from_compound(const TopoDS_Shape& compound, Top return create_solid_from_faces(face_list, shape, tol); } -bool IfcGeom::util::create_solid_from_faces(const NCollection_List& face_list, TopoDS_Shape& shape, double tol, bool force_sewing) { +bool ifcopenshell::geom::util::create_solid_from_faces(const NCollection_List& face_list, TopoDS_Shape& shape, double tol, bool force_sewing) { bool valid_shell = false; if (face_list.Extent() == 1) { @@ -803,16 +803,16 @@ bool IfcGeom::util::create_solid_from_faces(const NCollection_List return valid_shell; } -bool IfcGeom::util::flatten_shape_list(const IfcGeom::ConversionResults& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol) { +bool ifcopenshell::geom::util::flatten_shape_list(const ifcopenshell::geom::conversion_results& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol) { TopoDS_Compound compound; BRep_Builder builder; builder.MakeCompound(compound); result = TopoDS_Shape(); - for (IfcGeom::ConversionResults::const_iterator it = shapes.begin(); it != shapes.end(); ++it) { + for (ifcopenshell::geom::conversion_results::const_iterator it = shapes.begin(); it != shapes.end(); ++it) { TopoDS_Shape merged; - const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); + const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); if (fuse || create_shell) { merged = util::ensure_fit_for_subtraction(s, tol); } else { @@ -866,7 +866,7 @@ bool IfcGeom::util::flatten_shape_list(const IfcGeom::ConversionResults& shapes, return success; } -bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) { +bool ifcopenshell::geom::util::validate_shape(const TopoDS_Shape& s) { BRepCheck_Analyzer ana(s); if (ana.IsValid()) { return true; @@ -906,7 +906,7 @@ bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) { return false; } -TopoDS_Shape IfcGeom::util::unify(const TopoDS_Shape& s, double tolerance) { +TopoDS_Shape ifcopenshell::geom::util::unify(const TopoDS_Shape& s, double tolerance) { tolerance = (std::min)(min_edge_length(s) / 2., tolerance); ShapeUpgrade_UnifySameDomain usd(s); #if OCC_VERSION_HEX >= 0x70200 diff --git a/src/ifcgeom/kernels/opencascade/base_utils.h b/src/ifcgeom/kernels/opencascade/base_utils.h index 672f1c4f9e..0b24b10fc0 100644 --- a/src/ifcgeom/kernels/opencascade/base_utils.h +++ b/src/ifcgeom/kernels/opencascade/base_utils.h @@ -25,7 +25,7 @@ #include -namespace IfcGeom { +namespace ifcopenshell::geom { namespace util { IFC_GEOMLIBRARY_API int count(const TopoDS_Shape&, TopAbs_ShapeEnum, bool unique = false); @@ -74,11 +74,11 @@ namespace IfcGeom { IFC_GEOMLIBRARY_API double shape_volume(const TopoDS_Shape& s); IFC_GEOMLIBRARY_API double face_area(const TopoDS_Face& f); - IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const ifcopenshell::geometry::taxonomy::matrix4& t); + IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const ifcopenshell::geom::taxonomy::matrix4& t); IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_Trsf&); IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_GTrsf&); - IFC_GEOMLIBRARY_API bool flatten_shape_list(const IfcGeom::ConversionResults& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol); + IFC_GEOMLIBRARY_API bool flatten_shape_list(const ifcopenshell::geom::conversion_results& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol); IFC_GEOMLIBRARY_API bool validate_shape(const TopoDS_Shape&); IFC_GEOMLIBRARY_API TopoDS_Shape unify(const TopoDS_Shape& s, double tolerance); diff --git a/src/ifcgeom/kernels/opencascade/boolean_result.cpp b/src/ifcgeom/kernels/opencascade/boolean_result.cpp index d4305181e6..8f5eda2b87 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_result.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_result.cpp @@ -3,9 +3,8 @@ #include "boolean_utils.h" #include "base_utils.h" -using namespace IfcGeom; -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; // @todo should we reapply the technique to apply openings in batches? namespace { @@ -15,7 +14,7 @@ namespace { } }; - bool apply_in_batches(IfcGeom::util::boolean_settings bst, const TopoDS_Shape& first_operand, std::vector< std::pair >& opening_vector, BOPAlgo_Operation occ_op, TopoDS_Shape& result) { + bool apply_in_batches(ifcopenshell::geom::util::boolean_settings bst, const TopoDS_Shape& first_operand, std::vector< std::pair >& opening_vector, BOPAlgo_Operation occ_op, TopoDS_Shape& result) { auto it = opening_vector.begin(); auto jt = it; @@ -29,7 +28,7 @@ namespace { } TopoDS_Shape intermediate_result; - if (IfcGeom::util::boolean_operation(bst, result, opening_list, occ_op, intermediate_result)) { + if (ifcopenshell::geom::util::boolean_operation(bst, result, opening_list, occ_op, intermediate_result)) { result = intermediate_result; } else { return false; @@ -83,7 +82,7 @@ namespace { } } -bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::boolean_result::ptr br, conversion_results& results) { return handle_occt_exception([&]() -> bool { bool valid_result = false; bool first = true; @@ -95,11 +94,11 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con taxonomy::style::ptr first_item_style; for (auto& c : br->children) { - IfcGeom::ConversionResults cr; - AbstractKernel::convert(c, cr); + ifcopenshell::geom::conversion_results cr; + abstract_kernel::convert(c, cr); if (first && br->operation == taxonomy::boolean_result::SUBTRACTION) { // @todo A will be null on union/intersection, intended? - IfcGeom::util::flatten_shape_list(cr, a, false, true, settings_.get().get()); + ifcopenshell::geom::util::flatten_shape_list(cr, a, false, true, settings_.get().get()); first_item_style = c->surface_style; if (!first_item_style && c->kind() == taxonomy::COLLECTION) { // @todo recursively right? @@ -107,10 +106,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con } if (settings_.get().get()) { - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( br->instance.id(), br->matrix, - new OpenCascadeShape(a), + new open_cascade_shape(a), br->surface_style ? br->surface_style : first_item_style )); return true; @@ -123,7 +122,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con } else { for (auto& r : cr) { - auto S = std::static_pointer_cast(r.Shape())->shape(); + auto S = std::static_pointer_cast(r.Shape())->shape(); if (S.IsNull()) { logger_.error("GEO", 120, "Null operand"); continue; @@ -190,10 +189,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con std::swap(r, a); } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( br->instance.id(), br->matrix, - new OpenCascadeShape(a), + new open_cascade_shape(a), br->surface_style ? br->surface_style : first_item_style )); diff --git a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp index 67eb7a9fc8..6dce79bd1d 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/boolean_utils.cpp @@ -30,7 +30,7 @@ #include #include -void IfcGeom::util::copy_operand(const NCollection_List& l, NCollection_List& r) { +void ifcopenshell::geom::util::copy_operand(const NCollection_List& l, NCollection_List& r) { #if OCC_VERSION_HEX < 0x70000 r.Clear(); TopTools_ListIteratorOfListOfShape it(l); @@ -45,7 +45,7 @@ void IfcGeom::util::copy_operand(const NCollection_List& l, NColle #endif } -TopoDS_Shape IfcGeom::util::copy_operand(const TopoDS_Shape & s) { +TopoDS_Shape ifcopenshell::geom::util::copy_operand(const TopoDS_Shape & s) { #if OCC_VERSION_HEX < 0x70000 return BRepBuilderAPI_Copy(s); #else @@ -53,7 +53,7 @@ TopoDS_Shape IfcGeom::util::copy_operand(const TopoDS_Shape & s) { #endif } -double IfcGeom::util::min_edge_length(const TopoDS_Shape & a) { +double ifcopenshell::geom::util::min_edge_length(const TopoDS_Shape & a) { double min_edge_len = std::numeric_limits::infinity(); TopExp_Explorer exp(a, TopAbs_EDGE); for (; exp.More(); exp.Next()) { @@ -77,7 +77,7 @@ double IfcGeom::util::min_edge_length(const TopoDS_Shape & a) { return min_edge_len; } -double IfcGeom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double min_search, double max_search) { +double ifcopenshell::geom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double min_search, double max_search) { double M = std::numeric_limits::infinity(); NCollection_IndexedMap vertices, edges; @@ -85,7 +85,7 @@ double IfcGeom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double mi TopExp::MapShapes(a, TopAbs_VERTEX, vertices); TopExp::MapShapes(a, TopAbs_EDGE, edges); - IfcGeom::impl::tree tree; + ifcopenshell::geom::impl::tree tree; // Add edges to tree for (int i = 1; i <= edges.Extent(); ++i) { @@ -129,7 +129,7 @@ double IfcGeom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double mi return M; } -bool IfcGeom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g) { +bool ifcopenshell::geom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g) { points_on_planar_face_generator pgen(f); BRep_Builder B; @@ -141,7 +141,7 @@ bool IfcGeom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g) while (pgen(test)) { TopoDS_Vertex V; - B.MakeVertex(V, test, Precision::Confusion()); + B.MakeVertex(V, test, ::Precision::Confusion()); x.LoadS2(V); x.Perform(); if (x.IsDone() && x.NbSolution() == 1) { @@ -154,7 +154,7 @@ bool IfcGeom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g) return true; } -double IfcGeom::util::min_face_face_distance(const TopoDS_Shape & a, double max_search) { +double ifcopenshell::geom::util::min_face_face_distance(const TopoDS_Shape & a, double max_search) { /* NB: This is currently only implemented for planar surfaces. */ @@ -164,7 +164,7 @@ double IfcGeom::util::min_face_face_distance(const TopoDS_Shape & a, double max_ TopExp::MapShapes(a, TopAbs_FACE, faces); - IfcGeom::impl::tree tree; + ifcopenshell::geom::impl::tree tree; // Add faces to tree for (int i = 1; i <= faces.Extent(); ++i) { @@ -229,7 +229,7 @@ double IfcGeom::util::min_face_face_distance(const TopoDS_Shape & a, double max_ return M; } -int IfcGeom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const NCollection_List & b, NCollection_List & c) { +int ifcopenshell::geom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const NCollection_List & b, NCollection_List & c) { int N = 0; Bnd_Box A; @@ -258,7 +258,7 @@ int IfcGeom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const return N; } -bool IfcGeom::util::get_edge_axis(const TopoDS_Edge & e, gp_Ax1 & ax) { +bool ifcopenshell::geom::util::get_edge_axis(const TopoDS_Edge & e, gp_Ax1 & ax) { double _, __; auto crv = BRep_Tool::Curve(e, _, __); @@ -279,7 +279,7 @@ bool IfcGeom::util::get_edge_axis(const TopoDS_Edge & e, gp_Ax1 & ax) { return false; } -bool IfcGeom::util::is_subset(const NCollection_IndexedMap& lhs, const NCollection_IndexedMap& rhs) { +bool ifcopenshell::geom::util::is_subset(const NCollection_IndexedMap& lhs, const NCollection_IndexedMap& rhs) { if (rhs.Extent() < lhs.Extent()) { return false; } @@ -292,7 +292,7 @@ bool IfcGeom::util::is_subset(const NCollection_IndexedMap& interval) { +bool ifcopenshell::geom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape & s, TopoDS_Face & base, std::pair& interval) { // This assumes UnifySameDomain has been processed on s, so that // the extrusion top and bottom are a single face. @@ -405,7 +405,7 @@ bool IfcGeom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape & s, TopoD return true; } -int IfcGeom::util::eliminate_narrow_operands(double prec, const NCollection_List& bs, NCollection_List & c, ::logger& logger) { +int ifcopenshell::geom::util::eliminate_narrow_operands(double prec, const NCollection_List& bs, NCollection_List & c, ::logger& logger) { int N = 0; NCollection_List::Iterator it(bs); for (; it.More(); it.Next()) { @@ -429,7 +429,7 @@ int IfcGeom::util::eliminate_narrow_operands(double prec, const NCollection_List return N; } -int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & a, const NCollection_List & bs, NCollection_List & c) { +int ifcopenshell::geom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & a, const NCollection_List & bs, NCollection_List & c) { NCollection_IndexedMap a_faces; TopExp::MapShapes(a, TopAbs_FACE, a_faces); @@ -445,7 +445,7 @@ int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & NCollection_IndexedMap a_vertices; TopExp::MapShapes(a, TopAbs_VERTEX, a_vertices); - IfcGeom::impl::tree tree; + ifcopenshell::geom::impl::tree tree; // Add faces to tree for (int i = 1; i <= a_faces.Extent(); ++i) { @@ -573,8 +573,8 @@ int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & return N; } -bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const NCollection_List & b_input, TopoDS_Shape & result, double eps, ::logger& logger) { - IfcGeom::impl::tree edge_tree; +bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const NCollection_List & b_input, TopoDS_Shape & result, double eps, ::logger& logger) { + ifcopenshell::geom::impl::tree edge_tree; NCollection_List ab_input = b_input; ab_input.Prepend(a_input); @@ -756,7 +756,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_ // Now build a tree to find inner wires contained in other inner wires // NB first wire is *not* in this tree - IfcGeom::impl::tree wire_tree; + ifcopenshell::geom::impl::tree wire_tree; for (size_t wire_index = 1; wire_index < wires.size(); ++wire_index) { wire_tree.add(wire_index, wires[wire_index]); } @@ -806,11 +806,11 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_ return true; } -void IfcGeom::util::points_on_planar_face_generator::reset() { +void ifcopenshell::geom::util::points_on_planar_face_generator::reset() { i = j = (int)inset_; } -bool IfcGeom::util::points_on_planar_face_generator::operator()(gp_Pnt& p) { +bool ifcopenshell::geom::util::points_on_planar_face_generator::operator()(gp_Pnt& p) { while (j < N) { double u = u0 + (u1 - u0) * i / N; double v = v0 + (v1 - v0) * j / N; @@ -832,7 +832,7 @@ bool IfcGeom::util::points_on_planar_face_generator::operator()(gp_Pnt& p) { } -bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a_input, const NCollection_List& b_input, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { +bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a_input, const NCollection_List& b_input, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { using namespace std::string_literals; const bool do_unify = true; @@ -1239,7 +1239,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To TopExp::MapShapes(bb, TopAbs_EDGE, edges); TopExp::MapShapesAndAncestors(bb, TopAbs_EDGE, TopAbs_FACE, map); } - IfcGeom::impl::tree tree; + ifcopenshell::geom::impl::tree tree; for (int i = 1; i <= edges.Extent(); ++i) { tree.add(i, edges.FindKey(i)); } @@ -1425,13 +1425,13 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To return success && !result.IsNull(); } -bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a, const TopoDS_Shape& b, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { +bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a, const TopoDS_Shape& b, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) { NCollection_List bs; bs.Append(b); return boolean_operation(settings, a, bs, op, result, fuzziness); } -TopoDS_Shape IfcGeom::util::ensure_fit_for_subtraction(const TopoDS_Shape& shape, double tol) { +TopoDS_Shape ifcopenshell::geom::util::ensure_fit_for_subtraction(const TopoDS_Shape& shape, double tol) { const bool is_comp = is_compound_of_faces(shape); if (!is_comp) { return shape; diff --git a/src/ifcgeom/kernels/opencascade/boolean_utils.h b/src/ifcgeom/kernels/opencascade/boolean_utils.h index ca217d8a7f..90451d790b 100644 --- a/src/ifcgeom/kernels/opencascade/boolean_utils.h +++ b/src/ifcgeom/kernels/opencascade/boolean_utils.h @@ -38,7 +38,7 @@ #include "../../../ifcparse/logger.h" #include "../ifc_geomlibrary_api.h" -namespace IfcGeom { +namespace ifcopenshell::geom { namespace util { IFC_GEOMLIBRARY_API void copy_operand(const NCollection_List& l, NCollection_List& r); @@ -97,7 +97,7 @@ namespace IfcGeom { bool debug, attempt_2d; double precision; // Set by callers that carry a per-conversion logger (e.g. kernels deriving - // from AbstractKernel). Falls back to the global ::logger::root() singleton. + // from abstract_kernel). Falls back to the global ::logger::root() singleton. ::logger* logger = nullptr; ::logger& log() const { return logger ? *logger : ::logger::root(); } }; diff --git a/src/ifcgeom/kernels/opencascade/bspline_surface.cpp b/src/ifcgeom/kernels/opencascade/bspline_surface.cpp index fbb428a66f..01e34eae80 100644 --- a/src/ifcgeom/kernels/opencascade/bspline_surface.cpp +++ b/src/ifcgeom/kernels/opencascade/bspline_surface.cpp @@ -2,11 +2,10 @@ #include -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; -bool OpenCascadeKernel::convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf) { +bool open_cascade_kernel::convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf) { const bool is_rational = !!bs->weights; NCollection_Array2 Poles(0, (int)bs->control_points.size() - 1, 0, (int)(*bs->control_points.begin()).size() - 1); diff --git a/src/ifcgeom/kernels/opencascade/clash_utils.cpp b/src/ifcgeom/kernels/opencascade/clash_utils.cpp index 97c0aa9862..ff05ecf42b 100644 --- a/src/ifcgeom/kernels/opencascade/clash_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/clash_utils.cpp @@ -6,7 +6,7 @@ #define GU_CULLING_EPSILON_RAY_TRIANGLE FLT_EPSILON*FLT_EPSILON #define PX_MAX_F32 3.4028234663852885981170418348452e+38F -typedef uint32_t PxU32; +typedef uint32_t px_u32; // Why can't I use std::clamp? template @@ -357,23 +357,23 @@ double distanceTriangleTriangleSquared(gp_Vec& cp, gp_Vec& cq, const std::array< //Based on the paper A Fast Triangle-Triangle Intersection Test by T. Moeller //http://web.stanford.edu/class/cs277/resources/papers/Moller1997b.pdf namespace { - struct Interval + struct interval { double min; double max; gp_Vec minPoint; gp_Vec maxPoint; - Interval() : min(FLT_MAX), max(-FLT_MAX), minPoint(gp_Vec(NAN, NAN, NAN)), maxPoint(gp_Vec(NAN, NAN, NAN)) { } + interval() : min(FLT_MAX), max(-FLT_MAX), minPoint(gp_Vec(NAN, NAN, NAN)), maxPoint(gp_Vec(NAN, NAN, NAN)) { } - static bool overlapOrTouch(const Interval& a, const Interval& b) + static bool overlapOrTouch(const interval& a, const interval& b) { return !(a.min > b.max || b.min > a.max); } - static Interval intersection(const Interval& a, const Interval& b) + static interval intersection(const interval& a, const interval& b) { - Interval result; + interval result; if (!overlapOrTouch(a, b)) return result; @@ -407,9 +407,9 @@ namespace { // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp // With minor modifications to use gp_Vec type. -static Interval computeInterval(double distanceA, double distanceB, double distanceC, const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& dir) +static interval computeInterval(double distanceA, double distanceB, double distanceC, const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& dir) { - Interval i; + interval i; const bool bA = distanceA > 0; const bool bB = distanceB > 0; @@ -441,7 +441,7 @@ static Interval computeInterval(double distanceA, double distanceB, double dista // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp // With minor modifications to use gp_Vec type. -double orient2d(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, PxU32 x, PxU32 y) +double orient2d(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, px_u32 x, px_u32 y) { return (a.Coord(y) - c.Coord(y)) * (b.Coord(x) - c.Coord(x)) - (a.Coord(x) - c.Coord(x)) * (b.Coord(y) - c.Coord(y)); } @@ -450,7 +450,7 @@ double orient2d(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, PxU32 x, PxU3 // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp // With minor modifications to use gp_Vec type. -double pointInTriangle(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& point, PxU32 x, PxU32 y) +double pointInTriangle(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& point, px_u32 x, px_u32 y) { const double ab = orient2d(a, b, point, x, y); const double bc = orient2d(b, c, point, x, y); @@ -466,7 +466,7 @@ double pointInTriangle(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp // With minor modifications to use gp_Vec type. -double linesIntersect(const gp_Vec& startA, const gp_Vec& endA, const gp_Vec& startB, const gp_Vec& endB, PxU32 x, PxU32 y) +double linesIntersect(const gp_Vec& startA, const gp_Vec& endA, const gp_Vec& startB, const gp_Vec& endB, px_u32 x, px_u32 y) { const double aaS = orient2d(startA, endA, startB, x, y); const double aaE = orient2d(startA, endA, endB, x, y); @@ -487,7 +487,7 @@ double linesIntersect(const gp_Vec& startA, const gp_Vec& endA, const gp_Vec& st // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md // https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp // With minor modifications to use gp_Vec type. -void getProjectionIndices(gp_Vec normal, PxU32& x, PxU32& y) +void getProjectionIndices(gp_Vec normal, px_u32& x, px_u32& y) { normal.SetCoord(std::abs(normal.X()), std::abs(normal.Y()), std::abs(normal.Z())); @@ -517,8 +517,8 @@ void getProjectionIndices(gp_Vec normal, PxU32& x, PxU32& y) // With minor modifications to use gp_Vec type. bool trianglesIntersectCoplanar(const gp_Vec& p1_n, const gp_Vec& a1, const gp_Vec& b1, const gp_Vec& c1, const gp_Vec& a2, const gp_Vec& b2, const gp_Vec& c2) { - PxU32 x = 0; - PxU32 y = 0; + px_u32 x = 0; + px_u32 y = 0; getProjectionIndices(p1_n, x, y); const double third = (1.0 / 3.0); @@ -570,18 +570,18 @@ bool trianglesIntersect(const gp_Vec& a1, const gp_Vec& b1, const gp_Vec& c1, co const double l2 = intersectionDirection.SquareMagnitude(); intersectionDirection *= 1.0f / std::sqrt(l2); - const Interval i1 = computeInterval(p2ToA, p2ToB, p2ToC, a1, b1, c1, intersectionDirection); - const Interval i2 = computeInterval(p1ToA, p1ToB, p1ToC, a2, b2, c2, intersectionDirection); + const interval i1 = computeInterval(p2ToA, p2ToB, p2ToC, a1, b1, c1, intersectionDirection); + const interval i2 = computeInterval(p1ToA, p1ToB, p1ToC, a2, b2, c2, intersectionDirection); - if (Interval::overlapOrTouch(i1, i2)) + if (interval::overlapOrTouch(i1, i2)) { /*if (intersection) { - const Interval i = Interval::intersection(i1, i2); + const interval i = interval::intersection(i1, i2); intersection->p0 = i.minPoint; intersection->p1 = i.maxPoint; }*/ - const Interval i = Interval::intersection(i1, i2); + const interval i = interval::intersection(i1, i2); int1 = i.minPoint; int2 = i.maxPoint; return true; diff --git a/src/ifcgeom/kernels/opencascade/extrusion.cpp b/src/ifcgeom/kernels/opencascade/extrusion.cpp index c306b11ada..e8697388a8 100644 --- a/src/ifcgeom/kernels/opencascade/extrusion.cpp +++ b/src/ifcgeom/kernels/opencascade/extrusion.cpp @@ -2,11 +2,10 @@ #include -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; -bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS_Shape& shape) { +bool open_cascade_kernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS_Shape& shape) { const double& height = extrusion->depth; if (height < settings_.get().get()) { @@ -71,7 +70,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS return !shape.IsNull(); } -bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ifcopenshell::geom::conversion_results& results) { return handle_occt_exception([&]() -> bool { TopoDS_Shape shape; @@ -79,10 +78,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, I return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( extrusion->instance.id(), extrusion->matrix, - new OpenCascadeShape(shape), + new open_cascade_shape(shape), extrusion->surface_style )); return true; diff --git a/src/ifcgeom/kernels/opencascade/face.cpp b/src/ifcgeom/kernels/opencascade/face.cpp index 4e7caae223..b702f61b8e 100644 --- a/src/ifcgeom/kernels/opencascade/face.cpp +++ b/src/ifcgeom/kernels/opencascade/face.cpp @@ -63,15 +63,14 @@ #include "wire_utils.h" #include "base_utils.h" -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; -using namespace IfcGeom::util; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; +using namespace ifcopenshell::geom::util; namespace { struct surface_creation_visitor { - OpenCascadeKernel* kernel; + open_cascade_kernel* kernel; Handle(Geom_Surface) result; Handle(Geom_Surface) operator()(const taxonomy::bspline_surface::ptr& bs) { @@ -122,34 +121,34 @@ namespace { Handle(Geom_Surface) operator()(const taxonomy::plane::ptr& p) { const auto& m = p->matrix->ccomponents(); return result = Handle(Geom_Surface)(new Geom_Plane( - OpenCascadeKernel::convert_xyz2(m.col(3)), - OpenCascadeKernel::convert_xyz2(m.col(2)))); + open_cascade_kernel::convert_xyz2(m.col(3)), + open_cascade_kernel::convert_xyz2(m.col(2)))); } Handle(Geom_Surface) operator()(const taxonomy::cylinder::ptr& c) { const auto& m = c->matrix->ccomponents(); return result = Handle(Geom_Surface)(new Geom_CylindricalSurface(gp_Ax3( - OpenCascadeKernel::convert_xyz2(m.col(3)), - OpenCascadeKernel::convert_xyz2(m.col(2)), - OpenCascadeKernel::convert_xyz2(m.col(0)) + open_cascade_kernel::convert_xyz2(m.col(3)), + open_cascade_kernel::convert_xyz2(m.col(2)), + open_cascade_kernel::convert_xyz2(m.col(0)) ), c->radius)); } Handle(Geom_Surface) operator()(const taxonomy::sphere::ptr& s) { const auto& m = s->matrix->ccomponents(); return result = Handle(Geom_Surface)(new Geom_SphericalSurface(gp_Ax3( - OpenCascadeKernel::convert_xyz2(m.col(3)), - OpenCascadeKernel::convert_xyz2(m.col(2)), - OpenCascadeKernel::convert_xyz2(m.col(0)) + open_cascade_kernel::convert_xyz2(m.col(3)), + open_cascade_kernel::convert_xyz2(m.col(2)), + open_cascade_kernel::convert_xyz2(m.col(0)) ), s->radius)); } Handle(Geom_Surface) operator()(const taxonomy::torus::ptr& t) { const auto& m = t->matrix->ccomponents(); return result = Handle(Geom_Surface)(new Geom_ToroidalSurface(gp_Ax3( - OpenCascadeKernel::convert_xyz2(m.col(3)), - OpenCascadeKernel::convert_xyz2(m.col(2)), - OpenCascadeKernel::convert_xyz2(m.col(0)) + open_cascade_kernel::convert_xyz2(m.col(3)), + open_cascade_kernel::convert_xyz2(m.col(2)), + open_cascade_kernel::convert_xyz2(m.col(0)) ), t->radius1, t->radius2)); } @@ -204,7 +203,7 @@ namespace { result = Handle(Geom_Surface)(new Geom_SurfaceOfLinearExtrusion( crv, - OpenCascadeKernel::convert_xyz(*e->direction) + open_cascade_kernel::convert_xyz(*e->direction) )); result->Transform(tr); @@ -214,8 +213,8 @@ namespace { Handle(Geom_Surface) operator()(const taxonomy::revolve::ptr& e) { gp_Ax1 ax( - OpenCascadeKernel::convert_xyz(*e->axis_origin), - OpenCascadeKernel::convert_xyz(*e->direction)); + open_cascade_kernel::convert_xyz(*e->axis_origin), + open_cascade_kernel::convert_xyz(*e->direction)); gp_Trsf tr; if (e->matrix && !e->matrix->is_identity()) { @@ -257,7 +256,7 @@ namespace { }; } -Handle(Geom_Surface) OpenCascadeKernel::convert_surface(const taxonomy::ptr surface) { +Handle(Geom_Surface) open_cascade_kernel::convert_surface(const taxonomy::ptr surface) { surface_creation_visitor v{ this }; if (dispatch_surface_creation::dispatch(surface, v)) { return v.result; @@ -266,7 +265,7 @@ Handle(Geom_Surface) OpenCascadeKernel::convert_surface(const taxonomy::ptr surf } } -bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& result, bool reversed_surface) { +bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& result, bool reversed_surface) { #ifdef IFOPSH_DEBUG std::ostringstream oss; face->print(oss); @@ -625,16 +624,16 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re return true; } -bool OpenCascadeKernel::convert_impl(const taxonomy::face::ptr face, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::face::ptr face, ifcopenshell::geom::conversion_results& results) { return handle_occt_exception([&]() -> bool { TopoDS_Shape shape; if (!convert(face, shape)) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( face->instance.id(), - new OpenCascadeShape(shape), + new open_cascade_shape(shape), face->surface_style )); return true; diff --git a/src/ifcgeom/kernels/opencascade/face_definition.cpp b/src/ifcgeom/kernels/opencascade/face_definition.cpp index 4111c6c675..2a42486334 100644 --- a/src/ifcgeom/kernels/opencascade/face_definition.cpp +++ b/src/ifcgeom/kernels/opencascade/face_definition.cpp @@ -6,7 +6,7 @@ #include /* Returns whether wire conforms to a polyhedron, i.e. only edges with linear curves*/ -bool IfcGeom::util::is_polyhedron(const TopoDS_Wire & wire) { +bool ifcopenshell::geom::util::is_polyhedron(const TopoDS_Wire & wire) { double a, b; TopLoc_Location l; diff --git a/src/ifcgeom/kernels/opencascade/face_definition.h b/src/ifcgeom/kernels/opencascade/face_definition.h index 6fe982055b..8e4b4b0d8b 100644 --- a/src/ifcgeom/kernels/opencascade/face_definition.h +++ b/src/ifcgeom/kernels/opencascade/face_definition.h @@ -26,7 +26,7 @@ #include #include -namespace IfcGeom { +namespace ifcopenshell::geom { namespace util { /* Returns whether wire conforms to a polyhedron, i.e. only edges with linear curves*/ diff --git a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp index 1fa862de0e..3fe43777e8 100644 --- a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp +++ b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp @@ -4,7 +4,7 @@ #include "wire_utils.h" namespace { - void find_neighbours(IfcGeom::impl::tree& tree, std::vector>& pnts, std::set& visited, int p, double eps) { + void find_neighbours(ifcopenshell::geom::impl::tree& tree, std::vector>& pnts, std::set& visited, int p, double eps) { visited.insert(p); Bnd_Box b; @@ -25,16 +25,16 @@ namespace { } } -IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( - OpenCascadeKernel* kernel, - const ifcopenshell::geometry::taxonomy::shell::ptr shell +ifcopenshell::geom::open_cascade_kernel::faceset_helper::faceset_helper( + open_cascade_kernel* kernel, + const ifcopenshell::geom::taxonomy::shell::ptr shell ) : kernel_(kernel) , non_manifold_(false) { // @todo use pointers? - std::vector points; - std::vector loops; + std::vector points; + std::vector loops; std::set point_identities_visited; for (auto& f : shell->children) { @@ -43,7 +43,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( for (auto& e : l->children) { for (size_t i = 0; i < 2; ++i) { // @todo make sure only cartesian points are provided here - auto& p = std::get(i == 0 ? e->start : e->end); + auto& p = std::get(i == 0 ? e->start : e->end); if (point_identities_visited.find(p->identity()) == point_identities_visited.end()) { point_identities_visited.insert(p->identity()); points.push_back(p); @@ -56,7 +56,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( std::vector> pnts(points.size()); std::vector vertices(pnts.size()); - IfcGeom::impl::tree tree; + ifcopenshell::geom::impl::tree tree; BRep_Builder B; @@ -64,7 +64,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( for (size_t i = 0; i < points.size(); ++i) { gp_Pnt* p = new gp_Pnt(convert_xyz(*points[i])); pnts[i].reset(p); - B.MakeVertex(vertices[i], *p, Precision::Confusion()); + B.MakeVertex(vertices[i], *p, ::Precision::Confusion()); tree.add(i, vertices[i]); box.Add(*p); } @@ -86,12 +86,12 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( double bdiff = std::numeric_limits::infinity(); for (size_t i = 0; i < 3; ++i) { const double d = bmax[i] - bmin[i]; - if (d > kernel->settings().get().get() * 10. && d < bdiff) { + if (d > kernel->settings().get().get() * 10. && d < bdiff) { bdiff = d; } } - eps_ = kernel->settings().get().get() * 10. * (std::min)(1.0, bdiff); + eps_ = kernel->settings().get().get() * 10. * (std::min)(1.0, bdiff); size_t loops_removed, non_manifold, duplicate_faces; @@ -111,10 +111,10 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( edge_use.clear(); - if (eps_ < Precision::Confusion()) { + if (eps_ < ::Precision::Confusion()) { // occt uses some hard coded precision values, don't go smaller than that. // @todo, can be reset though with BRepLib::Precision(double) - eps_ = Precision::Confusion(); + eps_ = ::Precision::Confusion(); } std::vector retained(pnts.size()); @@ -210,14 +210,14 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( } } -void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const ifcopenshell::geometry::taxonomy::loop::ptr ps, const std::function& callback) { +void ifcopenshell::geom::open_cascade_kernel::faceset_helper::loop_(const ifcopenshell::geom::taxonomy::loop::ptr ps, const std::function& callback) { if (ps->children.size() < 3) { return; } for (auto& edge : ps->children) { - auto A = std::get(edge->start)->identity(); - auto B = std::get(edge->end)->identity(); + auto A = std::get(edge->start)->identity(); + auto B = std::get(edge->end)->identity(); auto C = vertex_mapping_[A], D = vertex_mapping_[B]; bool fwd = C < D; if (!fwd) { @@ -232,7 +232,7 @@ void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const ifcopenshell::geome } } -bool IfcGeom::OpenCascadeKernel::faceset_helper::edge(int A, int B, TopoDS_Edge& e) { +bool ifcopenshell::geom::open_cascade_kernel::faceset_helper::edge(int A, int B, TopoDS_Edge& e) { auto it = edges_.find({ A, B }); if (it == edges_.end()) { return false; @@ -241,7 +241,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::edge(int A, int B, TopoDS_Edge& return true; } -bool IfcGeom::OpenCascadeKernel::faceset_helper::wire(const ifcopenshell::geometry::taxonomy::loop::ptr loop, TopoDS_Wire& w) { +bool ifcopenshell::geom::open_cascade_kernel::faceset_helper::wire(const ifcopenshell::geom::taxonomy::loop::ptr loop, TopoDS_Wire& w) { NCollection_List ws; if (!wires(loop, ws)) { return false; @@ -250,7 +250,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wire(const ifcopenshell::geomet return true; } -bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geometry::taxonomy::loop::ptr loop, NCollection_List& wires) { +bool ifcopenshell::geom::open_cascade_kernel::faceset_helper::wires(const ifcopenshell::geom::taxonomy::loop::ptr loop, NCollection_List& wires) { if (duplicates_.find(loop->identity()) != duplicates_.end()) { return false; } @@ -272,10 +272,10 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geome wire.Closed(true); NCollection_List results; - if (!kernel_->settings().get().get() && util::wire_intersections(wire, results, { - !kernel_->settings().get().get(), - !kernel_->settings().get().get(), 0., - kernel_->settings().get().get()})) + if (!kernel_->settings().get().get() && util::wire_intersections(wire, results, { + !kernel_->settings().get().get(), + !kernel_->settings().get().get(), 0., + kernel_->settings().get().get()})) { ::logger::root().warning("GEO", 170, "Self-intersections with " + boost::lexical_cast(results.Extent()) + " cycles detected"); non_manifold_ = true; @@ -290,7 +290,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geome } } -IfcGeom::OpenCascadeKernel::faceset_helper::~faceset_helper() { +ifcopenshell::geom::open_cascade_kernel::faceset_helper::~faceset_helper() { // @todo this is super ugly, but how else can we be notified that the unique_ptr goes out of scope? // Perhaps just supply a custom std::deleter? kernel_->faceset_helper_ = nullptr; diff --git a/src/ifcgeom/kernels/opencascade/layerset.cpp b/src/ifcgeom/kernels/opencascade/layerset.cpp index 0668871ca0..668c5d16a5 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.cpp +++ b/src/ifcgeom/kernels/opencascade/layerset.cpp @@ -34,7 +34,7 @@ #include #include -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; namespace { @@ -152,8 +152,8 @@ namespace { surf = BRep_Tool::Surface(TopoDS::Face(s)); } - if ((s.ShapeType() == TopAbs_FACE && IfcGeom::util::split_solid_by_surface(i, surf, a, b)) || - (s.ShapeType() == TopAbs_SHELL && IfcGeom::util::split_solid_by_shell(i, s, a, b))) { + if ((s.ShapeType() == TopAbs_FACE && ifcopenshell::geom::util::split_solid_by_surface(i, surf, a, b)) || + (s.ShapeType() == TopAbs_SHELL && ifcopenshell::geom::util::split_solid_by_shell(i, s, a, b))) { slices.push_back(b); i = a; } else { @@ -167,7 +167,7 @@ namespace { } -bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const std::vector< std::vector>>& surfaces, const std::vector& styles, ConversionResults& result, double tol) { +bool ifcopenshell::geom::util::apply_folded_layerset(const conversion_results& items, const std::vector< std::vector>>& surfaces, const std::vector& styles, conversion_results& result, double tol) { Bnd_Box bb; TopoDS_Shape input; flatten_shape_list(items, input, false, false, tol); @@ -249,11 +249,11 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const } else if (shells.Extent() == 1) { - for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) { + for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) { TopoDS_Shape a, b; - if (split_solid_by_shell(std::static_pointer_cast(it->Shape())->shape(), shells.First(), a, b, tol)) { - result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr()))); - result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr()))); + if (split_solid_by_shell(std::static_pointer_cast(it->Shape())->shape(), shells.First(), a, b, tol)) { + result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr()))); + result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr()))); } else { continue; } @@ -263,15 +263,15 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const } else { - for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) { + for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) { - const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); + const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol); std::vector slices; if (split(s, shells, tol, slices) && slices.size() == styles.size()) { for (size_t i = 0; i < slices.size(); ++i) { - result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr()))); + result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr()))); } } else { return false; @@ -284,18 +284,18 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const } -bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector>& surfaces, const std::vector& styles, ConversionResults& result, double tol) { +bool ifcopenshell::geom::util::apply_layerset(const conversion_results& items, const std::vector>& surfaces, const std::vector& styles, conversion_results& result, double tol) { if (surfaces.size() < 3) { return false; } else if (surfaces.size() == 3) { - for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) { + for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) { TopoDS_Shape a, b; - if (split_solid_by_surface(std::static_pointer_cast(it->Shape())->shape(), surfaces[1], a, b, tol)) { - result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr()))); - result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr()))); + if (split_solid_by_surface(std::static_pointer_cast(it->Shape())->shape(), surfaces[1], a, b, tol)) { + result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr()))); + result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr()))); } else { continue; } @@ -309,7 +309,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve // Determine whether sequence of surfaces is consistent with surface normal, so that // layer operations are applied in the correct order. This seems to be always the case. Bnd_Box bb; - for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) { + for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) { BRepBndLib::Add(it->Shape(), bb); } @@ -334,9 +334,9 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve mass.ChangeCoord() += n1.XYZ(); */ - for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) { + for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) { - const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); + const TopoDS_Shape& s = std::static_pointer_cast(it->Shape())->shape(); TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol); NCollection_List operands; @@ -354,14 +354,14 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve /* // enable this is you want to see how IfcOpenShell has placed the layer surfaces for (auto& x : operands) { - result.push_back(ConversionResult(it->ItemId(), it->Placement(), x, nullptr)); + result.push_back(conversion_result(it->ItemId(), it->Placement(), x, nullptr)); } */ std::vector slices; if (split(s, operands, tol, slices) && slices.size() == styles.size()) { for (size_t i = 0; i < slices.size(); ++i) { - result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr()))); + result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr()))); } } else { return false; @@ -373,7 +373,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve } -bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const opencascade::handle& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) { +bool ifcopenshell::geom::util::split_solid_by_surface(const TopoDS_Shape& input, const opencascade::handle& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) { // Use an unbounded surface, that isolate part of the input shape, // to split this shape into two parts. Make sure that the addition // of the two result volumes matches that of the input. @@ -394,7 +394,7 @@ bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const open return b; } -bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS_Shape& shell, TopoDS_Shape& front, TopoDS_Shape& back, double tol) { +bool ifcopenshell::geom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS_Shape& shell, TopoDS_Shape& front, TopoDS_Shape& back, double tol) { // Use a shell, typically one or more connected faces, that isolate part // of the input shape, to split this shape into two parts. Make sure that // the addition of the two result volumes matches that of the input. diff --git a/src/ifcgeom/kernels/opencascade/layerset.h b/src/ifcgeom/kernels/opencascade/layerset.h index 07207ab228..9b581a5f9a 100644 --- a/src/ifcgeom/kernels/opencascade/layerset.h +++ b/src/ifcgeom/kernels/opencascade/layerset.h @@ -9,11 +9,11 @@ #include #include -namespace IfcGeom { +namespace ifcopenshell::geom { namespace util { - bool apply_layerset(const ConversionResults&, const std::vector>&, const std::vector&, ConversionResults&, double tol); + bool apply_layerset(const conversion_results&, const std::vector>&, const std::vector&, conversion_results&, double tol); - bool apply_folded_layerset(const ConversionResults&, const std::vector>>&, const std::vector&, ConversionResults&, double tol); + bool apply_folded_layerset(const conversion_results&, const std::vector>>&, const std::vector&, conversion_results&, double tol); bool split_solid_by_surface(const TopoDS_Shape&, const opencascade::handle&, TopoDS_Shape&, TopoDS_Shape&, double tol); @@ -21,4 +21,4 @@ namespace IfcGeom { } } -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/kernels/opencascade/loft.cpp b/src/ifcgeom/kernels/opencascade/loft.cpp index 706515b4df..14a2ad0568 100644 --- a/src/ifcgeom/kernels/opencascade/loft.cpp +++ b/src/ifcgeom/kernels/opencascade/loft.cpp @@ -29,10 +29,9 @@ #include #include -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; -using namespace IfcGeom::util; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; +using namespace ifcopenshell::geom::util; // @todo duplicated namespace { @@ -55,7 +54,7 @@ bool has_intersection(const std::set& A, } } -bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& result) { +bool open_cascade_kernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& result) { if (loft->children.size() < 2) { return false; } @@ -453,15 +452,15 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re return true; } -bool OpenCascadeKernel::convert_impl(const taxonomy::loft::ptr loft, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::loft::ptr loft, ifcopenshell::geom::conversion_results& results) { TopoDS_Shape shape; if (!convert(loft, shape)) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( loft->instance.id(), loft->matrix, - new OpenCascadeShape(shape), + new open_cascade_shape(shape), loft->surface_style )); return true; diff --git a/src/ifcgeom/kernels/opencascade/loop.cpp b/src/ifcgeom/kernels/opencascade/loop.cpp index 630da6ebef..6259ce1f46 100644 --- a/src/ifcgeom/kernels/opencascade/loop.cpp +++ b/src/ifcgeom/kernels/opencascade/loop.cpp @@ -26,17 +26,16 @@ #include #endif -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; -using namespace IfcGeom::util; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; +using namespace ifcopenshell::geom::util; namespace { struct curve_creation_visitor { - OpenCascadeKernel* kernel; - OpenCascadeKernel::curve_creation_visitor_result_type result; + open_cascade_kernel* kernel; + open_cascade_kernel::curve_creation_visitor_result_type result; - OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve::ptr& bc) { + open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve::ptr& bc) { const bool is_rational = !!bc->weights; @@ -60,7 +59,7 @@ namespace { i = 0; for (auto it = bc->control_points.begin(); it != bc->control_points.end(); ++it, ++i) { - Poles(i) = OpenCascadeKernel::convert_xyz(**it); + Poles(i) = open_cascade_kernel::convert_xyz(**it); } i = 0; @@ -80,22 +79,22 @@ namespace { } } - OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::line::ptr& l) { + open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::line::ptr& l) { const auto& m = l->matrix->ccomponents(); - return result = Handle(Geom_Curve)(new Geom_Line(OpenCascadeKernel::convert_xyz2(m.col(3)), OpenCascadeKernel::convert_xyz2(m.col(2)))); + return result = Handle(Geom_Curve)(new Geom_Line(open_cascade_kernel::convert_xyz2(m.col(3)), open_cascade_kernel::convert_xyz2(m.col(2)))); } - OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::circle::ptr& c) { + open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::circle::ptr& c) { const auto& m = c->matrix->ccomponents(); - return result = Handle(Geom_Curve)(new Geom_Circle(gp_Ax2(OpenCascadeKernel::convert_xyz2(m.col(3)), OpenCascadeKernel::convert_xyz2(m.col(2)), OpenCascadeKernel::convert_xyz2(m.col(0))), c->radius)); + return result = Handle(Geom_Curve)(new Geom_Circle(gp_Ax2(open_cascade_kernel::convert_xyz2(m.col(3)), open_cascade_kernel::convert_xyz2(m.col(2)), open_cascade_kernel::convert_xyz2(m.col(0))), c->radius)); } - OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::ellipse::ptr& e) { + open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::ellipse::ptr& e) { const auto& m = e->matrix->ccomponents(); - return result = Handle(Geom_Curve)(new Geom_Ellipse(gp_Ax2(OpenCascadeKernel::convert_xyz2(m.col(3)), OpenCascadeKernel::convert_xyz2(m.col(2)), OpenCascadeKernel::convert_xyz2(m.col(0))), e->radius, e->radius2)); + return result = Handle(Geom_Curve)(new Geom_Ellipse(gp_Ax2(open_cascade_kernel::convert_xyz2(m.col(3)), open_cascade_kernel::convert_xyz2(m.col(2)), open_cascade_kernel::convert_xyz2(m.col(0))), e->radius, e->radius2)); } - OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::loop::ptr& l) { + open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::loop::ptr& l) { TopoDS_Wire wire; if (!kernel->convert(l, wire)) { throw std::runtime_error("Failed to convert loop to wire"); @@ -103,7 +102,7 @@ namespace { return result = wire; } - OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::edge::ptr& e) { + open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::edge::ptr& e) { // @todo for polyloops/-lines we should probably construct edges based on correct oriented TopoDS_Vertex instead. if (e->start.index() != e->end.index()) { @@ -156,8 +155,8 @@ namespace { if (e_start.index() == 0) { E = BRepBuilderAPI_MakeEdge(curve).Edge(); } else if (e_start.index() == 1) { - auto p1 = OpenCascadeKernel::convert_xyz(*std::get(e_start)); - auto p2 = OpenCascadeKernel::convert_xyz(*std::get(e_end)); + auto p1 = open_cascade_kernel::convert_xyz(*std::get(e_start)); + auto p2 = open_cascade_kernel::convert_xyz(*std::get(e_end)); if (curve->IsClosed() && p1.Distance(p2) <= kernel->settings().get().get()) { E = BRepBuilderAPI_MakeEdge(curve).Edge(); @@ -186,8 +185,8 @@ namespace { if (e->start.index() != 1) { throw std::runtime_error("Non-cartesian trim on edge without curve"); } - auto p1 = OpenCascadeKernel::convert_xyz(*std::get(e->start)); - auto p2 = OpenCascadeKernel::convert_xyz(*std::get(e->end)); + auto p1 = open_cascade_kernel::convert_xyz(*std::get(e->start)); + auto p2 = open_cascade_kernel::convert_xyz(*std::get(e->end)); E = BRepBuilderAPI_MakeEdge(p1, p2).Edge(); } @@ -214,7 +213,7 @@ namespace { return result = W; } - OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::offset_curve::ptr&) { + open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::offset_curve::ptr&) { // @todo throw std::runtime_error("Offset curves not supported as part of loop"); } @@ -222,7 +221,7 @@ namespace { } -OpenCascadeKernel::curve_creation_visitor_result_type OpenCascadeKernel::convert_curve(const taxonomy::ptr curve) { +open_cascade_kernel::curve_creation_visitor_result_type open_cascade_kernel::convert_curve(const taxonomy::ptr curve) { curve_creation_visitor v{ this }; if (dispatch_curve_creation::dispatch(curve, v)) { return v.result; @@ -233,7 +232,7 @@ OpenCascadeKernel::curve_creation_visitor_result_type OpenCascadeKernel::convert #include "../../../ifcparse/file.h" -bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wire) { +bool open_cascade_kernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wire) { NCollection_List converted_segments; /* @@ -294,14 +293,14 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir NCollection_List::Iterator it(converted_segments); bool force_close = false; - if (loop->instance && loop->instance.as()) { - auto inst = loop->instance.as(); - auto file = loop->instance.as().file(); + if (loop->instance && loop->instance.as()) { + auto inst = loop->instance.as(); + auto file = loop->instance.as().file(); auto profile = file->get_inverse(inst.id(), file->schema()->declaration_by_name("IfcProfileDef"), -1); force_close = profile.size() > 0; } - wire_builder bld(precision_, loop->instance ? loop->instance.as() : express::Base{}); + wire_builder bld(precision_, loop->instance ? loop->instance.as() : express::base{}); shape_pair_enumerate(it, bld, force_close); wire = bld.wire(); @@ -395,26 +394,26 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir return true; } -bool OpenCascadeKernel::convert_impl(const taxonomy::loop::ptr loop, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::loop::ptr loop, ifcopenshell::geom::conversion_results& results) { TopoDS_Wire shape; if (!convert(loop, shape)) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( loop->instance.id(), - new OpenCascadeShape(shape), + new open_cascade_shape(shape), loop->surface_style )); return true; } -bool OpenCascadeKernel::convert_impl(const taxonomy::edge::ptr edge, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::edge::ptr edge, ifcopenshell::geom::conversion_results& results) { TopoDS_Wire shape = std::get(convert_curve(edge)); - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( edge->instance.id(), - new OpenCascadeShape(shape), + new open_cascade_shape(shape), edge->surface_style )); return true; diff --git a/src/ifcgeom/kernels/opencascade/matrix4.cpp b/src/ifcgeom/kernels/opencascade/matrix4.cpp index 40ac0305ab..89d9be3e05 100644 --- a/src/ifcgeom/kernels/opencascade/matrix4.cpp +++ b/src/ifcgeom/kernels/opencascade/matrix4.cpp @@ -1,11 +1,10 @@ #include "OpenCascadeKernel.h" -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; -using namespace IfcGeom::util; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; +using namespace ifcopenshell::geom::util; -bool OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf) { +bool open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf) { // @todo check const auto& m = matrix->ccomponents(); gp_Mat mat( @@ -43,4 +42,4 @@ bool OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& t } return true; -} \ No newline at end of file +} diff --git a/src/ifcgeom/kernels/opencascade/plugin.cpp b/src/ifcgeom/kernels/opencascade/plugin.cpp index 2c934fe9ba..b41171a0f3 100644 --- a/src/ifcgeom/kernels/opencascade/plugin.cpp +++ b/src/ifcgeom/kernels/opencascade/plugin.cpp @@ -23,7 +23,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace kernels { namespace opencascade_plugin { @@ -35,8 +35,8 @@ namespace ifcopenshell { return kernel_plugin_metadata("opencascade"); } - AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) { - return new IfcGeom::OpenCascadeKernel(settings); + abstract_kernel* create_kernel(ifcopenshell::file*, ifcopenshell::geom::settings& settings) { + return new ifcopenshell::geom::open_cascade_kernel(settings); } void register_plugin(kernel_registry& registry, const plugin::module& module) { @@ -51,6 +51,6 @@ namespace ifcopenshell { } } -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::opencascade_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::opencascade_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::opencascade_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::opencascade_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::opencascade_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::opencascade_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) diff --git a/src/ifcgeom/kernels/opencascade/shell.cpp b/src/ifcgeom/kernels/opencascade/shell.cpp index 0a7d80cbfd..38f01727a3 100644 --- a/src/ifcgeom/kernels/opencascade/shell.cpp +++ b/src/ifcgeom/kernels/opencascade/shell.cpp @@ -2,10 +2,9 @@ #include "base_utils.h" -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; -using namespace IfcGeom::util; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; +using namespace ifcopenshell::geom::util; namespace { // @todo move into taxonomy; @@ -24,7 +23,7 @@ namespace { } } -bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shape) { +bool open_cascade_kernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shape) { std::unique_ptr helper_scope; if (shell_polyhedral(l)) { helper_scope.reset(new faceset_helper(this, l)); @@ -106,17 +105,17 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap return true; } -bool OpenCascadeKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::shell::ptr shell, ifcopenshell::geom::conversion_results& results) { return handle_occt_exception([&]() -> bool { TopoDS_Shape shape; if (!convert(shell, shape)) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( shell->instance.id(), shell->matrix, - new OpenCascadeShape(shape), + new open_cascade_shape(shape), shell->surface_style )); return true; diff --git a/src/ifcgeom/kernels/opencascade/solid.cpp b/src/ifcgeom/kernels/opencascade/solid.cpp index 14ff26f3a9..22bca85edc 100644 --- a/src/ifcgeom/kernels/opencascade/solid.cpp +++ b/src/ifcgeom/kernels/opencascade/solid.cpp @@ -26,12 +26,11 @@ #include #include -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; -using namespace IfcGeom::util; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; +using namespace ifcopenshell::geom::util; -bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) { +bool open_cascade_kernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) { TopoDS_Shape S; if (solid->instance.declaration().is("IfcHalfSpaceSolid")) { @@ -101,17 +100,17 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& return !result.IsNull(); } -bool OpenCascadeKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::solid::ptr solid, ifcopenshell::geom::conversion_results& results) { return handle_occt_exception([&]() -> bool { TopoDS_Shape shape; if (!convert(solid, shape)) { return false; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( solid->instance.id(), solid->matrix, - new OpenCascadeShape(shape), + new open_cascade_shape(shape), solid->surface_style )); return true; diff --git a/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp b/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp index 86ebcf5cac..8ab4339764 100644 --- a/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp +++ b/src/ifcgeom/kernels/opencascade/sweep_along_curve.cpp @@ -31,10 +31,9 @@ #include #include -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; -using namespace IfcGeom; -using namespace IfcGeom::util; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; +using namespace ifcopenshell::geom::util; namespace { bool wire_is_c1_continuous(const TopoDS_Wire& w, double tol) { @@ -83,8 +82,8 @@ namespace { } } -bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, TopoDS_Shape& result) { - using namespace ifcopenshell::geometry; +bool open_cascade_kernel::convert(const taxonomy::sweep_along_curve::ptr scs, TopoDS_Shape& result) { + using namespace ifcopenshell::geom; bool applied_temporary_offset = false; Eigen::Vector3d mean; @@ -150,7 +149,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo 0., settings_.get().get() }; - if (!IfcGeom::util::convert_wire_to_face(TopoDS::Wire(face_), face, settings)) { + if (!ifcopenshell::geom::util::convert_wire_to_face(TopoDS::Wire(face_), face, settings)) { return false; } } else { @@ -316,7 +315,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo return true; } -bool OpenCascadeKernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs, IfcGeom::ConversionResults& results) { +bool open_cascade_kernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs, ifcopenshell::geom::conversion_results& results) { return handle_occt_exception([&]() -> bool { TopoDS_Shape shape; @@ -356,10 +355,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs, } else { m = scs->matrix; } - results.emplace_back(ConversionResult( + results.emplace_back(conversion_result( scs->instance.id(), m, - new OpenCascadeShape(shape), + new open_cascade_shape(shape), scs->surface_style )); return true; diff --git a/src/ifcgeom/kernels/opencascade/sweep_utils.cpp b/src/ifcgeom/kernels/opencascade/sweep_utils.cpp index 246531dea3..3b4d7c36d6 100644 --- a/src/ifcgeom/kernels/opencascade/sweep_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/sweep_utils.cpp @@ -24,7 +24,7 @@ #include "../../../ifcparse/logger.h" #include "base_utils.h" -bool IfcGeom::util::wire_is_c1_continuous(const TopoDS_Wire & w, double tol) { +bool ifcopenshell::geom::util::wire_is_c1_continuous(const TopoDS_Wire & w, double tol) { // NB Note that c0 continuity is NOT checked! NCollection_IndexedDataMap, TopTools_ShapeMapHasher> map; @@ -57,7 +57,7 @@ bool IfcGeom::util::wire_is_c1_continuous(const TopoDS_Wire & w, double tol) { return true; } -bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) { +bool ifcopenshell::geom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) { gp_Pnt directrix_origin; gp_Vec directrix_tangent; @@ -106,7 +106,7 @@ bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) { return true; } -bool IfcGeom::util::is_single_linear_edge(const TopoDS_Wire & wire) { +bool ifcopenshell::geom::util::is_single_linear_edge(const TopoDS_Wire & wire) { TopExp_Explorer exp(wire, TopAbs_EDGE); if (!exp.More()) { return false; @@ -121,7 +121,7 @@ bool IfcGeom::util::is_single_linear_edge(const TopoDS_Wire & wire) { return crv->DynamicType() == STANDARD_TYPE(Geom_Line); } -bool IfcGeom::util::is_single_circular_edge(const TopoDS_Wire & wire) { +bool ifcopenshell::geom::util::is_single_circular_edge(const TopoDS_Wire & wire) { TopExp_Explorer exp(wire, TopAbs_EDGE); if (!exp.More()) { return false; @@ -136,7 +136,7 @@ bool IfcGeom::util::is_single_circular_edge(const TopoDS_Wire & wire) { return crv->DynamicType() == STANDARD_TYPE(Geom_Circle); } -void IfcGeom::util::process_sweep_as_extrusion(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) { +void ifcopenshell::geom::util::process_sweep_as_extrusion(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) { TopExp_Explorer exp(wire, TopAbs_EDGE); TopoDS_Edge e = TopoDS::Edge(exp.Current()); double u, v; @@ -149,7 +149,7 @@ void IfcGeom::util::process_sweep_as_extrusion(const TopoDS_Wire & wire, const T result = BRepPrimAPI_MakePrism(face, depth*dir).Shape(); } -void IfcGeom::util::process_sweep_as_revolution(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) { +void ifcopenshell::geom::util::process_sweep_as_revolution(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) { TopExp_Explorer exp(wire, TopAbs_EDGE); TopoDS_Edge e = TopoDS::Edge(exp.Current()); double u, v; @@ -161,7 +161,7 @@ void IfcGeom::util::process_sweep_as_revolution(const TopoDS_Wire & wire, const result = BRepPrimAPI_MakeRevol(face, circ->Axis(), depth).Shape(); } -void IfcGeom::util::process_sweep_as_pipe(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result, bool force_transformed) { +void ifcopenshell::geom::util::process_sweep_as_pipe(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result, bool force_transformed) { // This tolerance is fairly high due to the linear edge substitution for small (or large radii) conical curves. const bool is_continuous = wire_is_c1_continuous(wire, 1.e-2); BRepOffsetAPI_MakePipeShell builder(wire); @@ -181,7 +181,7 @@ void IfcGeom::util::process_sweep_as_pipe(const TopoDS_Wire & wire, const TopoDS result = builder.Shape(); } -void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector& sorted_edges) { +void ifcopenshell::geom::util::sort_edges(const TopoDS_Wire & wire, std::vector& sorted_edges) { NCollection_IndexedDataMap, TopTools_ShapeMapHasher> map; TopExp::MapShapesAndAncestors(wire, TopAbs_VERTEX, TopAbs_EDGE, map); @@ -232,7 +232,7 @@ void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector& wires) { +void ifcopenshell::geom::util::break_closed(const TopoDS_Wire & wire, std::vector& wires) { std::vector sorted_edges; sort_edges(wire, sorted_edges); @@ -257,7 +257,7 @@ void IfcGeom::util::break_closed(const TopoDS_Wire & wire, std::vector& wires) { +void ifcopenshell::geom::util::segment_adjacent_non_linear(const TopoDS_Wire & wire, std::vector& wires) { std::vector sorted_edges; sort_edges(wire, sorted_edges); @@ -290,7 +290,7 @@ void IfcGeom::util::segment_adjacent_non_linear(const TopoDS_Wire & wire, std::v } // @todo make this generic for other sweeps not just swept disk -void IfcGeom::util::process_sweep(const TopoDS_Wire & wire, double radius, TopoDS_Shape & result) { +void ifcopenshell::geom::util::process_sweep(const TopoDS_Wire & wire, double radius, TopoDS_Shape & result) { std::vector wires, wires_tmp; segment_adjacent_non_linear(wire, wires_tmp); for (auto& w : wires_tmp) { diff --git a/src/ifcgeom/kernels/opencascade/sweep_utils.h b/src/ifcgeom/kernels/opencascade/sweep_utils.h index 033891d9c9..a989813c04 100644 --- a/src/ifcgeom/kernels/opencascade/sweep_utils.h +++ b/src/ifcgeom/kernels/opencascade/sweep_utils.h @@ -25,7 +25,7 @@ #include -namespace IfcGeom { +namespace ifcopenshell::geom { namespace util { bool wire_is_c1_continuous(const TopoDS_Wire& w, double tol); diff --git a/src/ifcgeom/kernels/opencascade/tree_backends.h b/src/ifcgeom/kernels/opencascade/tree_backends.h index e6c669623c..3bc2a546a6 100644 --- a/src/ifcgeom/kernels/opencascade/tree_backends.h +++ b/src/ifcgeom/kernels/opencascade/tree_backends.h @@ -26,15 +26,15 @@ #include "IfcGeomTree.h" namespace ifcopenshell { - namespace geometry { + namespace geom { namespace trees { namespace opencascade_tree_backends { - inline gp_Pnt make_point(const IfcGeom::tree_point& point) { + inline gp_Pnt make_point(const ifcopenshell::geom::tree_point& point) { return gp_Pnt(point[0], point[1], point[2]); } - inline Bnd_Box make_box(const IfcGeom::tree_box& bounds) { + inline Bnd_Box make_box(const ifcopenshell::geom::tree_box& bounds) { Bnd_Box box; box.Add(make_point(bounds[0])); box.Add(make_point(bounds[1])); @@ -47,13 +47,13 @@ namespace ifcopenshell { return "opencascade.brep"; } - void add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings) override { + void add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings) override { auto settings_ = settings; - settings_.get().value = ifcopenshell::geometry::settings::NATIVE; - settings_.get().value = true; - settings_.get().value = true; + settings_.get().value = ifcopenshell::geom::settings::NATIVE; + settings_.get().value = true; + settings_.get().value = true; - IfcGeom::Iterator iterator(ifcopenshell::geometry::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1); + ifcopenshell::geom::iterator iterator(ifcopenshell::geom::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1); if (iterator.initialize()) { do { add_element(iterator.get()); @@ -61,43 +61,43 @@ namespace ifcopenshell { } } - void add_element(IfcGeom::Element* element) override { - auto* brep = dynamic_cast(element); + void add_element(ifcopenshell::geom::element* element) override { + auto* brep = dynamic_cast(element); if (!brep) { - throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires native BRep elements"); + throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires native brep elements"); } tree_.add_element(brep); } - std::vector select_box(const express::Entity& entity, bool completely_within, double extend) const override { + std::vector select_box(const express::entity& entity, bool completely_within, double extend) const override { return tree_.select_box(entity, completely_within, extend); } - std::vector select_box(const IfcGeom::tree_point& point) const override { + std::vector select_box(const ifcopenshell::geom::tree_point& point) const override { return tree_.select_box(make_point(point)); } - std::vector select_box(const IfcGeom::tree_box& bounds, bool completely_within) const override { + std::vector select_box(const ifcopenshell::geom::tree_box& bounds, bool completely_within) const override { return tree_.select_box(make_box(bounds), completely_within); } - std::vector select(const express::Entity& entity, bool completely_within, double extend) const override { + std::vector select(const express::entity& entity, bool completely_within, double extend) const override { return tree_.select(entity, completely_within, extend); } - std::vector select(const IfcGeom::Element* element, bool completely_within, double extend) const override { - auto* brep = dynamic_cast(element); + std::vector select(const ifcopenshell::geom::element* element, bool completely_within, double extend) const override { + auto* brep = dynamic_cast(element); if (!brep) { - throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires BRep elements for select()"); + throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires brep elements for select()"); } return tree_.select(brep, completely_within, extend); } - std::vector select(const IfcGeom::tree_point& point, double extend) const override { + std::vector select(const ifcopenshell::geom::tree_point& point, double extend) const override { return tree_.select(make_point(point), extend); } - std::vector select_ray(const IfcGeom::tree_point& origin, const IfcGeom::tree_point& direction, double length) const override { + std::vector select_ray(const ifcopenshell::geom::tree_point& origin, const ifcopenshell::geom::tree_point& direction, double length) const override { return tree_.select_ray(make_point(origin), gp_Dir(direction[0], direction[1], direction[2]), length); } @@ -117,12 +117,12 @@ namespace ifcopenshell { tree_.enable_face_styles(enable); } - const std::vector& styles() const override { + const std::vector& styles() const override { return tree_.styles(); } private: - IfcGeom::opencascade_tree tree_; + ifcopenshell::geom::opencascade_tree tree_; }; class trianglebvh_tree : public abstract_tree { @@ -131,12 +131,12 @@ namespace ifcopenshell { return "opencascade.trianglebvh"; } - void add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings) override { + void add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings) override { auto settings_ = settings; - settings_.get().value = ifcopenshell::geometry::settings::TRIANGULATED; - settings_.get().value = true; + settings_.get().value = ifcopenshell::geom::settings::TRIANGULATED; + settings_.get().value = true; - IfcGeom::Iterator iterator(ifcopenshell::geometry::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1); + ifcopenshell::geom::iterator iterator(ifcopenshell::geom::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1); if (iterator.initialize()) { do { add_element(iterator.get()); @@ -144,28 +144,28 @@ namespace ifcopenshell { } } - void add_element(IfcGeom::Element* element) override { - auto* triangulation = dynamic_cast(element); + void add_element(ifcopenshell::geom::element* element) override { + auto* triangulation = dynamic_cast(element); if (!triangulation) { throw ifcopenshell::exception("Tree backend 'opencascade.trianglebvh' requires triangulation elements"); } tree_.add_element(triangulation); } - std::vector clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance, bool check_all) const override { + std::vector clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance, bool check_all) const override { return tree_.clash_intersection_many(set_a, set_b, tolerance, check_all); } - std::vector clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching) const override { + std::vector clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching) const override { return tree_.clash_collision_many(set_a, set_b, allow_touching); } - std::vector clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance, bool check_all) const override { + std::vector clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance, bool check_all) const override { return tree_.clash_clearance_many(set_a, set_b, clearance, check_all); } private: - IfcGeom::opencascade_tree tree_; + ifcopenshell::geom::opencascade_tree tree_; }; } diff --git a/src/ifcgeom/kernels/opencascade/tree_brep_plugin.cpp b/src/ifcgeom/kernels/opencascade/tree_brep_plugin.cpp index 2dea2bed1b..df02eef26a 100644 --- a/src/ifcgeom/kernels/opencascade/tree_brep_plugin.cpp +++ b/src/ifcgeom/kernels/opencascade/tree_brep_plugin.cpp @@ -23,7 +23,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace trees { namespace opencascade_brep_tree_plugin { @@ -50,6 +50,6 @@ namespace ifcopenshell { } } -BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_brep_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_brep_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_brep_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_brep_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_brep_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_brep_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1) diff --git a/src/ifcgeom/kernels/opencascade/tree_trianglebvh_plugin.cpp b/src/ifcgeom/kernels/opencascade/tree_trianglebvh_plugin.cpp index 71d262cc99..d4387acf61 100644 --- a/src/ifcgeom/kernels/opencascade/tree_trianglebvh_plugin.cpp +++ b/src/ifcgeom/kernels/opencascade/tree_trianglebvh_plugin.cpp @@ -23,7 +23,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace trees { namespace opencascade_trianglebvh_tree_plugin { @@ -50,6 +50,6 @@ namespace ifcopenshell { } } -BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_trianglebvh_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_trianglebvh_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_trianglebvh_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_trianglebvh_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_trianglebvh_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_trianglebvh_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1) diff --git a/src/ifcgeom/kernels/opencascade/wire_builder.cpp b/src/ifcgeom/kernels/opencascade/wire_builder.cpp index 8c33172d0b..d82e1f851f 100644 --- a/src/ifcgeom/kernels/opencascade/wire_builder.cpp +++ b/src/ifcgeom/kernels/opencascade/wire_builder.cpp @@ -15,7 +15,7 @@ #include // Returns the first edge of a wire -TopoDS_Edge IfcGeom::util::first_edge(const TopoDS_Wire & w) { +TopoDS_Edge ifcopenshell::geom::util::first_edge(const TopoDS_Wire & w) { TopoDS_Vertex v1, v2; TopExp::Vertices(w, v1, v2); NCollection_IndexedDataMap, TopTools_ShapeMapHasher> wm; @@ -24,7 +24,7 @@ TopoDS_Edge IfcGeom::util::first_edge(const TopoDS_Wire & w) { } // Returns new wire with the edge replaced by a linear edge with the vertex v moved to p -TopoDS_Wire IfcGeom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v, const gp_Pnt & p) { +TopoDS_Wire ifcopenshell::geom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v, const gp_Pnt & p) { NCollection_IndexedDataMap, TopTools_ShapeMapHasher> map; TopExp::MapShapesAndAncestors(w, TopAbs_VERTEX, TopAbs_EDGE, map); @@ -66,7 +66,7 @@ TopoDS_Wire IfcGeom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v GC_MakeCircle mc(p1, p2, p3); if (!mc.IsDone()) { - throw IfcGeom::geometry_exception("Failed to adjust circle"); + throw ifcopenshell::geom::geometry_exception("Failed to adjust circle"); } TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(mc.Value(), p1, p3).Edge(); @@ -74,15 +74,15 @@ TopoDS_Wire IfcGeom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v builder.Add(edge); return builder.Wire(); } else { - throw IfcGeom::geometry_exception("Unexpected wire to adjust"); + throw ifcopenshell::geom::geometry_exception("Unexpected wire to adjust"); } } -double IfcGeom::util::deflection_for_approximating_circle(double radius, double param) { +double ifcopenshell::geom::util::deflection_for_approximating_circle(double radius, double param) { return -radius * std::cos(1. / 2. * param) * std::cos(param) - radius * std::sin(1. / 2. * param) * std::sin(param) + radius; } -bool IfcGeom::util::create_edge_over_curve_with_log_messages(const opencascade::handle& crv, const double eps, const gp_Pnt& p1, const gp_Pnt& p2, TopoDS_Edge& result) { +bool ifcopenshell::geom::util::create_edge_over_curve_with_log_messages(const opencascade::handle& crv, const double eps, const gp_Pnt& p1, const gp_Pnt& p2, TopoDS_Edge& result) { if (crv->IsClosed() && p1.Distance(p2) <= eps) { BRepBuilderAPI_MakeEdge me(crv); if (me.IsDone()) { @@ -132,7 +132,7 @@ bool IfcGeom::util::create_edge_over_curve_with_log_messages(const opencascade:: return true; } -void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a) { +void ifcopenshell::geom::util::wire_builder::operator()(const TopoDS_Shape& a) { const TopoDS_Wire& w = TopoDS::Wire(a); if (override_next_) { override_next_ = false; @@ -143,7 +143,7 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a) { } } -void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS_Shape& b, bool last) { +void ifcopenshell::geom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS_Shape& b, bool last) { TopoDS_Wire w1 = TopoDS::Wire(a); const TopoDS_Wire& w2 = TopoDS::Wire(b); diff --git a/src/ifcgeom/kernels/opencascade/wire_builder.h b/src/ifcgeom/kernels/opencascade/wire_builder.h index 591073041b..f73adf5482 100644 --- a/src/ifcgeom/kernels/opencascade/wire_builder.h +++ b/src/ifcgeom/kernels/opencascade/wire_builder.h @@ -31,7 +31,7 @@ #include #include -namespace IfcGeom { +namespace ifcopenshell::geom { namespace util { // Returns the first edge of a wire TopoDS_Edge first_edge(const TopoDS_Wire& w); @@ -46,10 +46,10 @@ namespace IfcGeom { double p_; bool override_next_; gp_Pnt next_override_; - express::Base inst_; + express::base inst_; public: - wire_builder(double p, const express::Base& inst = express::Base()) : p_(p), override_next_(false), inst_(inst) {} + wire_builder(double p, const express::base& inst = express::base()) : p_(p), override_next_(false), inst_(inst) {} void operator()(const TopoDS_Shape& a); diff --git a/src/ifcgeom/kernels/opencascade/wire_utils.cpp b/src/ifcgeom/kernels/opencascade/wire_utils.cpp index 399e32e929..67d2fb7db0 100644 --- a/src/ifcgeom/kernels/opencascade/wire_utils.cpp +++ b/src/ifcgeom/kernels/opencascade/wire_utils.cpp @@ -36,7 +36,7 @@ #include -bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_Pln& plane, double eps_) { +bool ifcopenshell::geom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_Pln& plane, double eps_) { // Newell's Method is used for the normal calculation // as a simple edge cross product can give opposite results // for a concave face boundary. @@ -108,7 +108,7 @@ bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_P return true; } -bool IfcGeom::util::flatten_wire(TopoDS_Wire& wire, double eps) { +bool ifcopenshell::geom::util::flatten_wire(TopoDS_Wire& wire, double eps) { gp_Pln pln; if (!approximate_plane_through_wire(wire, pln, eps)) { return false; @@ -129,7 +129,7 @@ bool IfcGeom::util::flatten_wire(TopoDS_Wire& wire, double eps) { return true; } -IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std::vector& wires, NCollection_List& faces) { +ifcopenshell::geom::util::triangulate_wire_result ifcopenshell::geom::util::triangulate_wire(const std::vector& wires, NCollection_List& faces) { // This is a bit of a precarious approach, but seems to work for the // versions of OCCT tested for. OCCT has a Delaunay triangulation function // BRepMesh_Delaun, but it is notoriously hard to interpret the results @@ -210,7 +210,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std const TopoDS_Face& face = mf->Face(); // Create a triangular mesh from the face - BRepMesh_IncrementalMesh(face, Precision::Confusion()); + BRepMesh_IncrementalMesh(face, ::Precision::Confusion()); int n123[3]; TopLoc_Location loc; @@ -364,13 +364,13 @@ namespace { } namespace { - double get_wire_intersection_tolerance(const IfcGeom::util::wire_tolerance_settings& settings, const TopoDS_Wire& wire) { + double get_wire_intersection_tolerance(const ifcopenshell::geom::util::wire_tolerance_settings& settings, const TopoDS_Wire& wire) { if (settings.use_wire_intersection_tolerance) { // This corresponds to faceset_helper::epsilon if (settings.vertex_clustering_epsilon > 0.) { return settings.vertex_clustering_epsilon / 3.; } else { - return (std::min)(IfcGeom::util::min_edge_length(wire) / 2., settings.precision * 10.); + return (std::min)(ifcopenshell::geom::util::min_edge_length(wire) / 2., settings.precision * 10.); } } else { return 0.; @@ -378,7 +378,7 @@ namespace { } } -bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List& wires, const wire_tolerance_settings& settings) { +bool ifcopenshell::geom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List& wires, const wire_tolerance_settings& settings) { double eps = get_wire_intersection_tolerance(settings, wire); double eps_real = settings.precision; @@ -398,7 +398,7 @@ bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List // ... to be sure to get consecutive edges BRepTools_WireExplorer exp(wire); - IfcGeom::impl::tree tree; + ifcopenshell::geom::impl::tree tree; int edge_idx = 0; for (; exp.More(); exp.Next()) { @@ -561,7 +561,7 @@ bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List return intersected; } -void IfcGeom::util::select_largest(const NCollection_List& shapes, TopoDS_Shape& largest) { +void ifcopenshell::geom::util::select_largest(const NCollection_List& shapes, TopoDS_Shape& largest) { double mass = 0.; NCollection_List::Iterator it(shapes); for (; it.More(); it.Next()) { @@ -584,10 +584,10 @@ void IfcGeom::util::select_largest(const NCollection_List& shapes, double m = 1.; for (int i = 0; i < 3; ++i) { - if (Precision::IsNegativeInfinite(xyz_min[i])) { + if (::Precision::IsNegativeInfinite(xyz_min[i])) { xyz_min[i] = 0.; } - if (Precision::IsInfinite(xyz_max[i])) { + if (::Precision::IsInfinite(xyz_max[i])) { xyz_max[i] = 0.; } m *= (xyz_max[i] + eps) - (xyz_min[i] - eps); @@ -601,7 +601,7 @@ void IfcGeom::util::select_largest(const NCollection_List& shapes, } -bool IfcGeom::util::wire_to_sequence_of_point(const TopoDS_Wire& w, NCollection_Sequence& p) { +bool ifcopenshell::geom::util::wire_to_sequence_of_point(const TopoDS_Wire& w, NCollection_Sequence& p) { TopExp_Explorer exp(w, TopAbs_EDGE); for (; exp.More(); exp.Next()) { double a, b; @@ -628,7 +628,7 @@ bool IfcGeom::util::wire_to_sequence_of_point(const TopoDS_Wire& w, NCollection_ return true; } -void IfcGeom::util::sequence_of_point_to_wire(const NCollection_Sequence& p, TopoDS_Wire& w, bool close) { +void ifcopenshell::geom::util::sequence_of_point_to_wire(const NCollection_Sequence& p, TopoDS_Wire& w, bool close) { BRepBuilderAPI_MakePolygon builder; for (int i = 1; i <= p.Length(); ++i) { builder.Add(p.Value(i)); @@ -639,7 +639,7 @@ void IfcGeom::util::sequence_of_point_to_wire(const NCollection_Sequence w = builder.Wire(); } -void IfcGeom::util::remove_collinear_points_from_loop(NCollection_Sequence& polygon, bool closed, double tol) { +void ifcopenshell::geom::util::remove_collinear_points_from_loop(NCollection_Sequence& polygon, bool closed, double tol) { const int start = closed ? 1 : 2; const int end = polygon.Length() - (closed ? 0 : 1); std::vector to_remove(polygon.Length(), false); @@ -663,7 +663,7 @@ void IfcGeom::util::remove_collinear_points_from_loop(NCollection_Sequence& polygon, bool closed, double tol) { +void ifcopenshell::geom::util::remove_duplicate_points_from_loop(NCollection_Sequence& polygon, bool closed, double tol) { tol *= tol; for (;;) { @@ -716,7 +716,7 @@ namespace { } -bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape, double tol) { +bool ifcopenshell::geom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape, double tol) { BRepOffsetAPI_Sewing sew; sew.Add(shape); @@ -806,7 +806,7 @@ bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape } -bool IfcGeom::util::convert_curve_to_wire(const opencascade::handle& curve, TopoDS_Wire& wire) { +bool ifcopenshell::geom::util::convert_curve_to_wire(const opencascade::handle& curve, TopoDS_Wire& wire) { try { wire = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(curve)); return true; @@ -823,7 +823,7 @@ bool IfcGeom::util::convert_curve_to_wire(const opencascade::handle& } -void IfcGeom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) { +void ifcopenshell::geom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) { if (wire.Closed() == 0) { TopoDS_Vertex v0, v1; TopExp::Vertices(wire, v0, v1); @@ -842,7 +842,7 @@ void IfcGeom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) { } } -bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face, const IfcGeom::util::wire_tolerance_settings& settings) { +bool ifcopenshell::geom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face, const ifcopenshell::geom::util::wire_tolerance_settings& settings) { TopoDS_Wire wire = w; NCollection_List results; @@ -887,7 +887,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face return true; } -bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound& faces, const IfcGeom::util::wire_tolerance_settings& settings) { +bool ifcopenshell::geom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound& faces, const ifcopenshell::geom::util::wire_tolerance_settings& settings) { bool is_2d = true; TopExp_Explorer exp(w, TopAbs_EDGE); for (; exp.More(); exp.Next()) { diff --git a/src/ifcgeom/kernels/opencascade/wire_utils.h b/src/ifcgeom/kernels/opencascade/wire_utils.h index 995f272233..85c4debc17 100644 --- a/src/ifcgeom/kernels/opencascade/wire_utils.h +++ b/src/ifcgeom/kernels/opencascade/wire_utils.h @@ -18,7 +18,7 @@ #include -namespace IfcGeom { +namespace ifcopenshell::geom { namespace util { IFC_GEOMLIBRARY_API bool approximate_plane_through_wire(const TopoDS_Wire& wire, gp_Pln& plane, double eps); @@ -44,9 +44,9 @@ namespace IfcGeom { IFC_GEOMLIBRARY_API void select_largest(const NCollection_List& shapes, TopoDS_Shape& largest); - IFC_GEOMLIBRARY_API bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face, const IfcGeom::util::wire_tolerance_settings& settings); + IFC_GEOMLIBRARY_API bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face, const ifcopenshell::geom::util::wire_tolerance_settings& settings); - IFC_GEOMLIBRARY_API bool convert_wire_to_faces(const TopoDS_Wire& wire, TopoDS_Compound& face, const IfcGeom::util::wire_tolerance_settings& settings); + IFC_GEOMLIBRARY_API bool convert_wire_to_faces(const TopoDS_Wire& wire, TopoDS_Compound& face, const ifcopenshell::geom::util::wire_tolerance_settings& settings); IFC_GEOMLIBRARY_API void assert_closed_wire(TopoDS_Wire& wire, double tol); diff --git a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp index 3d20e5c6e4..526b688465 100644 --- a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp +++ b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.cpp @@ -12,21 +12,21 @@ #include #include -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; namespace { - struct VertexKey { + struct vertex_key { long long x; long long y; long long z; - bool operator==(const VertexKey& other) const { + bool operator==(const vertex_key& other) const { return x == other.x && y == other.y && z == other.z; } }; - struct VertexKeyHash { - size_t operator()(const VertexKey& key) const { + struct vertex_key_hash { + size_t operator()(const vertex_key& key) const { auto h = std::hash()(key.x); h ^= std::hash()(key.y) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); h ^= std::hash()(key.z) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); @@ -34,37 +34,37 @@ namespace { } }; - struct EdgeKey { + struct edge_key { int a; int b; - bool operator==(const EdgeKey& other) const { + bool operator==(const edge_key& other) const { return a == other.a && b == other.b; } }; - struct EdgeKeyHash { - size_t operator()(const EdgeKey& key) const { + struct edge_key_hash { + size_t operator()(const edge_key& key) const { auto h = std::hash()(key.a); h ^= std::hash()(key.b) + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2); return h; } }; - struct Box { + struct bounding_box_data { bool valid = false; Eigen::Vector3d min = Eigen::Vector3d::Zero(); Eigen::Vector3d max = Eigen::Vector3d::Zero(); }; - struct MeshData { + struct mesh_data { std::vector vertices; std::vector> triangles; - std::unordered_map edge_counts; - std::unordered_map vertex_map; + std::unordered_map edge_counts; + std::unordered_map vertex_map; }; - VertexKey make_vertex_key(const Eigen::Vector3d& p) { + vertex_key make_vertex_key(const Eigen::Vector3d& p) { constexpr double scale = 1.e9; return { (long long)std::llround(p(0) * scale), @@ -73,8 +73,8 @@ namespace { }; } - EdgeKey make_edge_key(int a, int b) { - return a < b ? EdgeKey{ a, b } : EdgeKey{ b, a }; + edge_key make_edge_key(int a, int b) { + return a < b ? edge_key{ a, b } : edge_key{ b, a }; } Eigen::Matrix4d item_matrix(const taxonomy::geom_item::ptr& item) { @@ -118,7 +118,7 @@ namespace { return loop_points(loop, points); } - int add_vertex(MeshData& mesh, const Eigen::Vector3d& p) { + int add_vertex(mesh_data& mesh, const Eigen::Vector3d& p) { auto key = make_vertex_key(p); auto it = mesh.vertex_map.find(key); if (it != mesh.vertex_map.end()) { @@ -130,7 +130,7 @@ namespace { return idx; } - void add_face(MeshData& mesh, const std::vector& indices) { + void add_face(mesh_data& mesh, const std::vector& indices) { if (indices.size() == 3) { mesh.triangles.push_back({ indices[0], indices[1], indices[2] }); } else if (indices.size() == 4) { @@ -142,8 +142,8 @@ namespace { } } - MeshData build_mesh(const std::vector& parts, const taxonomy::matrix4* place = nullptr) { - MeshData mesh; + mesh_data build_mesh(const std::vector& parts, const taxonomy::matrix4* place = nullptr) { + mesh_data mesh; auto external = place ? place->ccomponents() : Eigen::Matrix4d::Identity(); std::vector points; for (const auto& part : parts) { @@ -171,7 +171,7 @@ namespace { return 0.5 * ((b - a).cross(c - a)).norm(); } - double mesh_area(const MeshData& mesh) { + double mesh_area(const mesh_data& mesh) { double total = 0.; for (const auto& tri : mesh.triangles) { total += triangle_area(mesh.vertices[tri[0]], mesh.vertices[tri[1]], mesh.vertices[tri[2]]); @@ -179,7 +179,7 @@ namespace { return total; } - double mesh_volume(const MeshData& mesh) { + double mesh_volume(const mesh_data& mesh) { double total = 0.; for (const auto& tri : mesh.triangles) { const auto& a = mesh.vertices[tri[0]]; @@ -190,7 +190,7 @@ namespace { return std::abs(total) / 6.; } - double mesh_length(const MeshData& mesh) { + double mesh_length(const mesh_data& mesh) { double total = 0.; for (const auto& edge : mesh.edge_counts) { total += (mesh.vertices[edge.first.a] - mesh.vertices[edge.first.b]).norm(); @@ -198,7 +198,7 @@ namespace { return total; } - void update_box(Box& box, const MeshData& mesh) { + void update_box(bounding_box_data& box, const mesh_data& mesh) { for (const auto& vertex : mesh.vertices) { if (!box.valid) { box.valid = true; @@ -211,7 +211,7 @@ namespace { } } - double box_volume(const Box& box) { + double box_volume(const bounding_box_data& box) { if (!box.valid) { return 0.; } @@ -256,7 +256,7 @@ namespace { return shell; } - PassthroughPart normalize_part(const PassthroughPart& part) { + passthrough_part normalize_part(const passthrough_part& part) { return { part.shell, part.matrix ? taxonomy::make(part.matrix->ccomponents()) : taxonomy::make(), @@ -264,8 +264,8 @@ namespace { }; } - std::vector normalize_parts(const std::vector& parts) { - std::vector result; + std::vector normalize_parts(const std::vector& parts) { + std::vector result; result.reserve(parts.size()); for (const auto& part : parts) { result.push_back(normalize_part(part)); @@ -274,19 +274,19 @@ namespace { } } -ifcopenshell::geometry::PassthroughShape::PassthroughShape(const PassthroughPart& part) +ifcopenshell::geom::passthrough_shape::passthrough_shape(const passthrough_part& part) : parts_{ normalize_part(part) } {} -ifcopenshell::geometry::PassthroughShape::PassthroughShape(PassthroughPart&& part) +ifcopenshell::geom::passthrough_shape::passthrough_shape(passthrough_part&& part) : parts_{ normalize_part(part) } {} -ifcopenshell::geometry::PassthroughShape::PassthroughShape(const std::vector& parts) +ifcopenshell::geom::passthrough_shape::passthrough_shape(const std::vector& parts) : parts_(normalize_parts(parts)) {} -ifcopenshell::geometry::PassthroughShape::PassthroughShape(std::vector&& parts) +ifcopenshell::geom::passthrough_shape::passthrough_shape(std::vector&& parts) : parts_(normalize_parts(parts)) {} -void ifcopenshell::geometry::PassthroughShape::Triangulate(ifcopenshell::geometry::Settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger&) const { +void ifcopenshell::geom::passthrough_shape::Triangulate(ifcopenshell::geom::settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger&) const { auto mesh = build_mesh(parts_, &place); std::vector indices(mesh.vertices.size()); for (size_t i = 0; i < mesh.vertices.size(); ++i) { @@ -302,7 +302,7 @@ void ifcopenshell::geometry::PassthroughShape::Triangulate(ifcopenshell::geometr } } -void ifcopenshell::geometry::PassthroughShape::Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string& result) const { +void ifcopenshell::geom::passthrough_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& result) const { auto mesh = build_mesh(parts_, &place); std::stringstream stream; for (const auto& vertex : mesh.vertices) { @@ -314,176 +314,176 @@ void ifcopenshell::geometry::PassthroughShape::Serialize(const ifcopenshell::geo result = stream.str(); } -int ifcopenshell::geometry::PassthroughShape::surface_genus() const { +int ifcopenshell::geom::passthrough_shape::surface_genus() const { return 0; } -bool ifcopenshell::geometry::PassthroughShape::is_manifold() const { +bool ifcopenshell::geom::passthrough_shape::is_manifold() const { return std::all_of(parts_.begin(), parts_.end(), [](const auto& part) { return part.manifold; }); } -int ifcopenshell::geometry::PassthroughShape::num_vertices() const { +int ifcopenshell::geom::passthrough_shape::num_vertices() const { return (int)build_mesh(parts_).vertices.size(); } -int ifcopenshell::geometry::PassthroughShape::num_edges() const { +int ifcopenshell::geom::passthrough_shape::num_edges() const { return (int)build_mesh(parts_).edge_counts.size(); } -int ifcopenshell::geometry::PassthroughShape::num_faces() const { +int ifcopenshell::geom::passthrough_shape::num_faces() const { return (int)build_mesh(parts_).triangles.size(); } -double ifcopenshell::geometry::PassthroughShape::bounding_box(void*& box_ptr) const { - auto* box = static_cast(box_ptr); +double ifcopenshell::geom::passthrough_shape::bounding_box(void*& box_ptr) const { + auto* box = static_cast(box_ptr); if (!box) { - box = new Box(); + box = new bounding_box_data(); box_ptr = box; } else { - *box = Box(); + *box = bounding_box_data(); } update_box(*box, build_mesh(parts_)); return box_volume(*box); } -std::pair, IfcGeom::OpaqueCoordinate<3>> ifcopenshell::geometry::PassthroughShape::bounding_box() const { +std::pair, ifcopenshell::geom::opaque_coordinate<3>> ifcopenshell::geom::passthrough_shape::bounding_box() const { void* box_ptr = nullptr; bounding_box(box_ptr); - auto* box = static_cast(box_ptr); + auto* box = static_cast(box_ptr); if (!box || !box->valid) { delete box; throw std::runtime_error("Invalid shape"); } auto result = std::make_pair( - IfcGeom::OpaqueCoordinate<3>( - IfcGeom::OpaqueNumber(box->min(0)), - IfcGeom::OpaqueNumber(box->min(1)), - IfcGeom::OpaqueNumber(box->min(2))), - IfcGeom::OpaqueCoordinate<3>( - IfcGeom::OpaqueNumber(box->max(0)), - IfcGeom::OpaqueNumber(box->max(1)), - IfcGeom::OpaqueNumber(box->max(2)))); + ifcopenshell::geom::opaque_coordinate<3>( + ifcopenshell::geom::opaque_number(box->min(0)), + ifcopenshell::geom::opaque_number(box->min(1)), + ifcopenshell::geom::opaque_number(box->min(2))), + ifcopenshell::geom::opaque_coordinate<3>( + ifcopenshell::geom::opaque_number(box->max(0)), + ifcopenshell::geom::opaque_number(box->max(1)), + ifcopenshell::geom::opaque_number(box->max(2)))); delete box; return result; } -void ifcopenshell::geometry::PassthroughShape::set_box(void* box_ptr) { - auto* box = static_cast(box_ptr); +void ifcopenshell::geom::passthrough_shape::set_box(void* box_ptr) { + auto* box = static_cast(box_ptr); if (!box || !box->valid) { throw std::runtime_error("Invalid shape"); } parts_ = { { make_box_shell(box->min, box->max), taxonomy::make(), true } }; } -IfcGeom::OpaqueNumber ifcopenshell::geometry::PassthroughShape::length() { - return IfcGeom::OpaqueNumber(mesh_length(build_mesh(parts_))); +ifcopenshell::geom::opaque_number ifcopenshell::geom::passthrough_shape::length() { + return ifcopenshell::geom::opaque_number(mesh_length(build_mesh(parts_))); } -IfcGeom::OpaqueNumber ifcopenshell::geometry::PassthroughShape::area() { - return IfcGeom::OpaqueNumber(mesh_area(build_mesh(parts_))); +ifcopenshell::geom::opaque_number ifcopenshell::geom::passthrough_shape::area() { + return ifcopenshell::geom::opaque_number(mesh_area(build_mesh(parts_))); } -IfcGeom::OpaqueNumber ifcopenshell::geometry::PassthroughShape::volume() { - return IfcGeom::OpaqueNumber(is_manifold() ? mesh_volume(build_mesh(parts_)) : 0.); +ifcopenshell::geom::opaque_number ifcopenshell::geom::passthrough_shape::volume() { + return ifcopenshell::geom::opaque_number(is_manifold() ? mesh_volume(build_mesh(parts_)) : 0.); } -IfcGeom::OpaqueCoordinate<3> ifcopenshell::geometry::PassthroughShape::position() { +ifcopenshell::geom::opaque_coordinate<3> ifcopenshell::geom::passthrough_shape::position() { throw std::runtime_error("Invalid shape"); } -IfcGeom::OpaqueCoordinate<3> ifcopenshell::geometry::PassthroughShape::axis() { +ifcopenshell::geom::opaque_coordinate<3> ifcopenshell::geom::passthrough_shape::axis() { throw std::runtime_error("Invalid shape"); } -IfcGeom::OpaqueCoordinate<4> ifcopenshell::geometry::PassthroughShape::plane_equation() { +ifcopenshell::geom::opaque_coordinate<4> ifcopenshell::geom::passthrough_shape::plane_equation() { throw std::runtime_error("Invalid shape"); } -std::vector ifcopenshell::geometry::PassthroughShape::convex_decomposition() { +std::vector ifcopenshell::geom::passthrough_shape::convex_decomposition() { throw std::runtime_error("Not implemented"); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::halfspaces() { +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::halfspaces() { throw std::runtime_error("Not implemented"); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::box() { +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::box() { void* box_ptr = nullptr; bounding_box(box_ptr); - auto* box = static_cast(box_ptr); + auto* box = static_cast(box_ptr); if (!box || !box->valid) { delete box; throw std::runtime_error("Invalid shape"); } - auto* result = new PassthroughShape(PassthroughPart{ make_box_shell(box->min, box->max), taxonomy::make(), true }); + auto* result = new passthrough_shape(passthrough_part{ make_box_shell(box->min, box->max), taxonomy::make(), true }); delete box; return result; } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::solid() { +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::solid() { if (!is_manifold()) { throw std::runtime_error("Invalid shape"); } - return new PassthroughShape(parts_); + return new passthrough_shape(parts_); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::wrap_in_compound() { - return new PassthroughShape(parts_); +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::wrap_in_compound() { + return new passthrough_shape(parts_); } -std::vector ifcopenshell::geometry::PassthroughShape::vertices() { +std::vector ifcopenshell::geom::passthrough_shape::vertices() { throw std::runtime_error("Not implemented"); } -std::vector ifcopenshell::geometry::PassthroughShape::edges() { +std::vector ifcopenshell::geom::passthrough_shape::edges() { throw std::runtime_error("Not implemented"); } -std::vector ifcopenshell::geometry::PassthroughShape::facets() { +std::vector ifcopenshell::geom::passthrough_shape::facets() { throw std::runtime_error("Not implemented"); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::add(IfcGeom::ConversionResultShape*) { +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::add(ifcopenshell::geom::conversion_result_shape*) { throw std::runtime_error("Not implemented"); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::subtract(IfcGeom::ConversionResultShape*) { +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::subtract(ifcopenshell::geom::conversion_result_shape*) { throw std::runtime_error("Not implemented"); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::intersect(IfcGeom::ConversionResultShape*) { +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::intersect(ifcopenshell::geom::conversion_result_shape*) { throw std::runtime_error("Not implemented"); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::concat(IfcGeom::ConversionResultShape* other) { - auto* rhs = dynamic_cast(other); +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::concat(ifcopenshell::geom::conversion_result_shape* other) { + auto* rhs = dynamic_cast(other); if (!rhs) { throw std::runtime_error("Invalid shape"); } auto parts = parts_; parts.insert(parts.end(), rhs->parts_.begin(), rhs->parts_.end()); - return new PassthroughShape(std::move(parts)); + return new passthrough_shape(std::move(parts)); } -std::size_t ifcopenshell::geometry::PassthroughShape::map(IfcGeom::OpaqueCoordinate<4>&, IfcGeom::OpaqueCoordinate<4>&) { +std::size_t ifcopenshell::geom::passthrough_shape::map(ifcopenshell::geom::opaque_coordinate<4>&, ifcopenshell::geom::opaque_coordinate<4>&) { throw std::runtime_error("Not implemented"); } -std::size_t ifcopenshell::geometry::PassthroughShape::map(const std::vector>&, const std::vector>&) { +std::size_t ifcopenshell::geom::passthrough_shape::map(const std::vector>&, const std::vector>&) { throw std::runtime_error("Not implemented"); } -IfcGeom::ConversionResultShape* ifcopenshell::geometry::PassthroughShape::moved(ifcopenshell::geometry::taxonomy::matrix4::ptr place) const { - std::vector moved_parts; +ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::passthrough_shape::moved(ifcopenshell::geom::taxonomy::matrix4::ptr place) const { + std::vector moved_parts; moved_parts.reserve(parts_.size()); for (const auto& part : parts_) { auto matrix = part.matrix ? taxonomy::make(place->ccomponents() * part.matrix->ccomponents()) : taxonomy::make(place->ccomponents()); moved_parts.push_back({ part.shell, matrix, part.manifold }); } - return new PassthroughShape(std::move(moved_parts)); + return new passthrough_shape(std::move(moved_parts)); } -bool ifcopenshell::geometry::PassthroughShape::surface_area_along_direction(double, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { +bool ifcopenshell::geom::passthrough_shape::surface_area_along_direction(double, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const { along_x = along_y = along_z = 0.; auto mesh = build_mesh(parts_, place.get()); for (const auto& tri : mesh.triangles) { diff --git a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h index 5ed9bd7465..348e49fa06 100644 --- a/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h +++ b/src/ifcgeom/kernels/passthrough/PassthroughConversionResult.h @@ -5,27 +5,27 @@ #include "../../../ifcgeom/kernels/ifc_geomlibrary_api.h" namespace ifcopenshell { -namespace geometry { +namespace geom { -struct IFC_GEOMLIBRARY_API PassthroughPart { +struct IFC_GEOMLIBRARY_API passthrough_part { taxonomy::shell::ptr shell; taxonomy::matrix4::ptr matrix; bool manifold; }; -class IFC_GEOMLIBRARY_API PassthroughShape : public IfcGeom::ConversionResultShape { +class IFC_GEOMLIBRARY_API passthrough_shape : public ifcopenshell::geom::conversion_result_shape { public: - PassthroughShape() = default; - explicit PassthroughShape(const PassthroughPart& part); - explicit PassthroughShape(PassthroughPart&& part); - explicit PassthroughShape(const std::vector& parts); - explicit PassthroughShape(std::vector&& parts); + passthrough_shape() = default; + explicit passthrough_shape(const passthrough_part& part); + explicit passthrough_shape(passthrough_part&& part); + explicit passthrough_shape(const std::vector& parts); + explicit passthrough_shape(std::vector&& parts); - const std::vector& parts() const { return parts_; } + const std::vector& parts() const { return parts_; } virtual std::string_view backend_id() const { return "passthrough"; } - virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; - virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const; + virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const; + virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const; virtual int surface_genus() const; virtual bool is_manifold() const; @@ -35,40 +35,40 @@ public: virtual int num_faces() const; virtual double bounding_box(void*&) const; - virtual std::pair, IfcGeom::OpaqueCoordinate<3>> bounding_box() const; + virtual std::pair, ifcopenshell::geom::opaque_coordinate<3>> bounding_box() const; virtual void set_box(void* b); - virtual IfcGeom::OpaqueNumber length(); - virtual IfcGeom::OpaqueNumber area(); - virtual IfcGeom::OpaqueNumber volume(); + virtual ifcopenshell::geom::opaque_number length(); + virtual ifcopenshell::geom::opaque_number area(); + virtual ifcopenshell::geom::opaque_number volume(); - virtual IfcGeom::OpaqueCoordinate<3> position(); - virtual IfcGeom::OpaqueCoordinate<3> axis(); - virtual IfcGeom::OpaqueCoordinate<4> plane_equation(); + virtual ifcopenshell::geom::opaque_coordinate<3> position(); + virtual ifcopenshell::geom::opaque_coordinate<3> axis(); + virtual ifcopenshell::geom::opaque_coordinate<4> plane_equation(); - virtual std::vector convex_decomposition(); - virtual IfcGeom::ConversionResultShape* halfspaces(); - virtual IfcGeom::ConversionResultShape* box(); - virtual IfcGeom::ConversionResultShape* solid(); - virtual IfcGeom::ConversionResultShape* wrap_in_compound(); + virtual std::vector convex_decomposition(); + virtual ifcopenshell::geom::conversion_result_shape* halfspaces(); + virtual ifcopenshell::geom::conversion_result_shape* box(); + virtual ifcopenshell::geom::conversion_result_shape* solid(); + virtual ifcopenshell::geom::conversion_result_shape* wrap_in_compound(); - virtual std::vector vertices(); - virtual std::vector edges(); - virtual std::vector facets(); + virtual std::vector vertices(); + virtual std::vector edges(); + virtual std::vector facets(); - virtual IfcGeom::ConversionResultShape* add(IfcGeom::ConversionResultShape*); - virtual IfcGeom::ConversionResultShape* subtract(IfcGeom::ConversionResultShape*); - virtual IfcGeom::ConversionResultShape* intersect(IfcGeom::ConversionResultShape*); - virtual IfcGeom::ConversionResultShape* concat(IfcGeom::ConversionResultShape*); + virtual ifcopenshell::geom::conversion_result_shape* add(ifcopenshell::geom::conversion_result_shape*); + virtual ifcopenshell::geom::conversion_result_shape* subtract(ifcopenshell::geom::conversion_result_shape*); + virtual ifcopenshell::geom::conversion_result_shape* intersect(ifcopenshell::geom::conversion_result_shape*); + virtual ifcopenshell::geom::conversion_result_shape* concat(ifcopenshell::geom::conversion_result_shape*); - virtual std::size_t map(IfcGeom::OpaqueCoordinate<4>& from, IfcGeom::OpaqueCoordinate<4>& to); - virtual std::size_t map(const std::vector>& from, const std::vector>& to); - virtual IfcGeom::ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const; + virtual std::size_t map(ifcopenshell::geom::opaque_coordinate<4>& from, ifcopenshell::geom::opaque_coordinate<4>& to); + virtual std::size_t map(const std::vector>& from, const std::vector>& to); + virtual ifcopenshell::geom::conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const; - virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; + virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const; private: - std::vector parts_; + std::vector parts_; }; } diff --git a/src/ifcgeom/kernels/passthrough/PassthroughKernel.cpp b/src/ifcgeom/kernels/passthrough/PassthroughKernel.cpp index 3579194de0..da0081054a 100644 --- a/src/ifcgeom/kernels/passthrough/PassthroughKernel.cpp +++ b/src/ifcgeom/kernels/passthrough/PassthroughKernel.cpp @@ -8,8 +8,8 @@ #include #include -using namespace ifcopenshell::geometry; -using namespace ifcopenshell::geometry::kernels; +using namespace ifcopenshell::geom; +using namespace ifcopenshell::geom::kernels; namespace { taxonomy::style::ptr fallback_style(const taxonomy::geom_item::ptr& item, const taxonomy::geom_item::ptr& fallback) { @@ -252,19 +252,19 @@ namespace { } } -bool PassthroughKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::ConversionResults& results) { +bool passthrough_kernel::convert_impl(const taxonomy::shell::ptr shell, ifcopenshell::geom::conversion_results& results) { if (!shell_supported(shell)) { return false; } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( shell->instance.id(), shell->matrix, - new ifcopenshell::geometry::PassthroughShape(PassthroughPart{ shell, taxonomy::make(), shell->closed.value_or(false) }), + new ifcopenshell::geom::passthrough_shape(passthrough_part{ shell, taxonomy::make(), shell->closed.value_or(false) }), shell->surface_style)); return true; } -bool PassthroughKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::ConversionResults& results) { +bool passthrough_kernel::convert_impl(const taxonomy::solid::ptr solid, ifcopenshell::geom::conversion_results& results) { if (!solid || solid->children.size() != 1) { return false; } @@ -272,10 +272,10 @@ bool PassthroughKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom:: if (!shell_supported(shell)) { return false; } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( solid->instance.id(), solid->matrix, - new ifcopenshell::geometry::PassthroughShape(PassthroughPart{ + new ifcopenshell::geom::passthrough_shape(passthrough_part{ shell, shell->matrix ? taxonomy::make(shell->matrix->ccomponents()) : taxonomy::make(), true @@ -284,20 +284,20 @@ bool PassthroughKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom:: return true; } -bool PassthroughKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, IfcGeom::ConversionResults& results) { +bool passthrough_kernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ifcopenshell::geom::conversion_results& results) { auto shell = shell_from_extrusion(extrusion, settings_.get().get()); if (!shell) { return false; } - results.emplace_back(IfcGeom::ConversionResult( + results.emplace_back(ifcopenshell::geom::conversion_result( extrusion->instance.id(), extrusion->matrix, - new ifcopenshell::geometry::PassthroughShape(PassthroughPart{ shell, taxonomy::make(), true }), + new ifcopenshell::geom::passthrough_shape(passthrough_part{ shell, taxonomy::make(), true }), extrusion->surface_style)); return true; } -bool PassthroughKernel::convert_openings(const express::Base&, const std::vector>&, - const IfcGeom::ConversionResults&, const ifcopenshell::geometry::taxonomy::matrix4&, IfcGeom::ConversionResults&) { +bool passthrough_kernel::convert_openings(const express::base&, const std::vector>&, + const ifcopenshell::geom::conversion_results&, const ifcopenshell::geom::taxonomy::matrix4&, ifcopenshell::geom::conversion_results&) { return false; } diff --git a/src/ifcgeom/kernels/passthrough/PassthroughKernel.h b/src/ifcgeom/kernels/passthrough/PassthroughKernel.h index cdda057a7d..d072118b4c 100644 --- a/src/ifcgeom/kernels/passthrough/PassthroughKernel.h +++ b/src/ifcgeom/kernels/passthrough/PassthroughKernel.h @@ -6,26 +6,26 @@ #include "../../../ifcgeom/kernels/passthrough/PassthroughConversionResult.h" namespace ifcopenshell { -namespace geometry { +namespace geom { namespace kernels { -class IFC_GEOMLIBRARY_API PassthroughKernel : public AbstractKernel { +class IFC_GEOMLIBRARY_API passthrough_kernel : public abstract_kernel { public: - PassthroughKernel(const Settings& settings, ::logger& logger = ::logger::root()) - : AbstractKernel("passthrough", settings, logger) {} + passthrough_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) + : abstract_kernel("passthrough", settings, logger) {} - virtual AbstractKernel* clone(::logger& logger) const { - return new PassthroughKernel(settings(), logger); + virtual abstract_kernel* clone(::logger& logger) const { + return new passthrough_kernel(settings(), logger); } virtual bool supports_boolean_operations() const { return false; } - virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&); - virtual bool convert_impl(const taxonomy::extrusion::ptr, IfcGeom::ConversionResults&); + virtual bool convert_impl(const taxonomy::shell::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const taxonomy::solid::ptr, ifcopenshell::geom::conversion_results&); + virtual bool convert_impl(const taxonomy::extrusion::ptr, ifcopenshell::geom::conversion_results&); - virtual bool convert_openings(const express::Base&, const std::vector>&, - const IfcGeom::ConversionResults&, const ifcopenshell::geometry::taxonomy::matrix4&, IfcGeom::ConversionResults&); + virtual bool convert_openings(const express::base&, const std::vector>&, + const ifcopenshell::geom::conversion_results&, const ifcopenshell::geom::taxonomy::matrix4&, ifcopenshell::geom::conversion_results&); }; } diff --git a/src/ifcgeom/kernels/passthrough/plugin.cpp b/src/ifcgeom/kernels/passthrough/plugin.cpp index 34e8f877a7..ce51624cb3 100644 --- a/src/ifcgeom/kernels/passthrough/plugin.cpp +++ b/src/ifcgeom/kernels/passthrough/plugin.cpp @@ -23,7 +23,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace kernels { namespace passthrough_plugin { @@ -35,8 +35,8 @@ namespace ifcopenshell { return kernel_plugin_metadata("passthrough"); } - AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) { - return new PassthroughKernel(settings); + abstract_kernel* create_kernel(ifcopenshell::file*, ifcopenshell::geom::settings& settings) { + return new passthrough_kernel(settings); } void register_plugin(kernel_registry& registry, const plugin::module& module) { @@ -51,6 +51,6 @@ namespace ifcopenshell { } } -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::passthrough_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::passthrough_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::passthrough_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::passthrough_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::passthrough_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::passthrough_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1) diff --git a/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp b/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp index 878ec23b60..fe0bbac498 100644 --- a/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp +++ b/src/ifcgeom/mapping/IfcAnnotationFillArea.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAnnotationFillArea& inst) { auto loop = taxonomy::cast(map(inst.OuterBoundary())); diff --git a/src/ifcgeom/mapping/IfcArbitraryClosedProfileDef.cpp b/src/ifcgeom/mapping/IfcArbitraryClosedProfileDef.cpp index 5f2e77847d..177da03e6d 100644 --- a/src/ifcgeom/mapping/IfcArbitraryClosedProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcArbitraryClosedProfileDef.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcArbitraryClosedProfileDef& inst) { auto loop = taxonomy::cast(map(inst.OuterCurve())); diff --git a/src/ifcgeom/mapping/IfcArbitraryOpenProfileDef.cpp b/src/ifcgeom/mapping/IfcArbitraryOpenProfileDef.cpp index a7e683cf58..c770dc52d2 100644 --- a/src/ifcgeom/mapping/IfcArbitraryOpenProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcArbitraryOpenProfileDef.cpp @@ -21,7 +21,7 @@ #define _USE_MATH_DEFINES #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcArbitraryOpenProfileDef& inst) { auto mapped = map(inst.Curve()); diff --git a/src/ifcgeom/mapping/IfcAsymmetricIShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcAsymmetricIShapeProfileDef.cpp index 2ea2664781..9063d83115 100644 --- a/src/ifcgeom/mapping/IfcAsymmetricIShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcAsymmetricIShapeProfileDef.cpp @@ -20,7 +20,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcAxis1Placement.cpp b/src/ifcgeom/mapping/IfcAxis1Placement.cpp index c10f2cf2d2..393f9ac214 100644 --- a/src/ifcgeom/mapping/IfcAxis1Placement.cpp +++ b/src/ifcgeom/mapping/IfcAxis1Placement.cpp @@ -20,7 +20,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis1Placement& inst) { Eigen::Vector3d P(0, 0, 0), axis(0, 0, 1), ref; diff --git a/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp b/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp index d286934d2e..24448b5ba8 100644 --- a/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp +++ b/src/ifcgeom/mapping/IfcAxis2Placement2D.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement2D& inst) { Eigen::Vector3d P(0, 0, 0), axis(0, 0, 1), V(1, 0, 0); diff --git a/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp b/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp index c1f41f78ca..c6fe6af6d2 100644 --- a/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp +++ b/src/ifcgeom/mapping/IfcAxis2Placement3D.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2Placement3D& inst) { Eigen::Vector3d o(0, 0, 0), axis(0, 0, 1), refDirection, X(1, 0, 0); diff --git a/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp b/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp index 6673a75ae5..330e65c0d4 100644 --- a/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp +++ b/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #if defined SCHEMA_HAS_IfcAxis2PlacementLinear diff --git a/src/ifcgeom/mapping/IfcBSplineCurveWithKnots.cpp b/src/ifcgeom/mapping/IfcBSplineCurveWithKnots.cpp index ac1ee91d0c..751ad2b975 100644 --- a/src/ifcgeom/mapping/IfcBSplineCurveWithKnots.cpp +++ b/src/ifcgeom/mapping/IfcBSplineCurveWithKnots.cpp @@ -22,7 +22,7 @@ #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineCurveWithKnots& inst) { @@ -43,4 +43,4 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineCurveWithKnots& inst) return bc; } -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/mapping/IfcBSplineSurfaceWithKnots.cpp b/src/ifcgeom/mapping/IfcBSplineSurfaceWithKnots.cpp index 786d427c65..22102a64e7 100644 --- a/src/ifcgeom/mapping/IfcBSplineSurfaceWithKnots.cpp +++ b/src/ifcgeom/mapping/IfcBSplineSurfaceWithKnots.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots diff --git a/src/ifcgeom/mapping/IfcBlock.cpp b/src/ifcgeom/mapping/IfcBlock.cpp index 98d6407960..86fdb1b208 100644 --- a/src/ifcgeom/mapping/IfcBlock.cpp +++ b/src/ifcgeom/mapping/IfcBlock.cpp @@ -20,7 +20,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBlock& inst) { const double dx = inst.XLength() * length_unit_; diff --git a/src/ifcgeom/mapping/IfcBooleanResult.cpp b/src/ifcgeom/mapping/IfcBooleanResult.cpp index 3cad401bcb..524fb66ab7 100644 --- a/src/ifcgeom/mapping/IfcBooleanResult.cpp +++ b/src/ifcgeom/mapping/IfcBooleanResult.cpp @@ -21,7 +21,7 @@ #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; namespace { taxonomy::boolean_result::operation_t boolean_op_type(IfcSchema::IfcBooleanOperator::Value op) { diff --git a/src/ifcgeom/mapping/IfcBoundingBox.cpp b/src/ifcgeom/mapping/IfcBoundingBox.cpp index 993f4215ac..997f6abebb 100644 --- a/src/ifcgeom/mapping/IfcBoundingBox.cpp +++ b/src/ifcgeom/mapping/IfcBoundingBox.cpp @@ -20,7 +20,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBoundingBox& inst) { if (!settings_.get().get()) { diff --git a/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp index 6bff1e2b45..0f41ce1e4b 100644 --- a/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcCartesianPoint.cpp b/src/ifcgeom/mapping/IfcCartesianPoint.cpp index 005510fe7e..1c38412f46 100644 --- a/src/ifcgeom/mapping/IfcCartesianPoint.cpp +++ b/src/ifcgeom/mapping/IfcCartesianPoint.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianPoint& inst) { std::vector xyz = inst.Coordinates(); diff --git a/src/ifcgeom/mapping/IfcCartesianTransformationOperator2D.cpp b/src/ifcgeom/mapping/IfcCartesianTransformationOperator2D.cpp index 43bcbb8925..a67102560c 100644 --- a/src/ifcgeom/mapping/IfcCartesianTransformationOperator2D.cpp +++ b/src/ifcgeom/mapping/IfcCartesianTransformationOperator2D.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator2D& inst) { auto m = taxonomy::make(); diff --git a/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp b/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp index 799047cdd1..ad06f6bb98 100644 --- a/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp +++ b/src/ifcgeom/mapping/IfcCartesianTransformationOperator3D.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCartesianTransformationOperator3D& inst) { diff --git a/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp b/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp index 6ada1f4a29..04c32ef73b 100644 --- a/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCenterLineProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCenterLineProfileDef& inst) { return nullptr; diff --git a/src/ifcgeom/mapping/IfcCircle.cpp b/src/ifcgeom/mapping/IfcCircle.cpp index c7bd9cf0ff..5cf9adef5e 100644 --- a/src/ifcgeom/mapping/IfcCircle.cpp +++ b/src/ifcgeom/mapping/IfcCircle.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircle& inst) { const double r = inst.Radius() * length_unit_; diff --git a/src/ifcgeom/mapping/IfcCircleProfileDef.cpp b/src/ifcgeom/mapping/IfcCircleProfileDef.cpp index 654ecd9934..9c75bfc1aa 100644 --- a/src/ifcgeom/mapping/IfcCircleProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCircleProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include diff --git a/src/ifcgeom/mapping/IfcCompositeCurve.cpp b/src/ifcgeom/mapping/IfcCompositeCurve.cpp index dc2a04358b..cbe3dffcd0 100644 --- a/src/ifcgeom/mapping/IfcCompositeCurve.cpp +++ b/src/ifcgeom/mapping/IfcCompositeCurve.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve& inst) { auto loop = taxonomy::make(); @@ -95,7 +95,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve& inst) { } if (spans.empty()) { - std::vector profile = inst.file()->get_inverse(inst.id(), &IfcSchema::IfcProfileDef::Class(), -1); + std::vector profile = inst.file()->get_inverse(inst.id(), &IfcSchema::IfcProfileDef::Class(), -1); const bool force_close = !profile.empty(); loop->closed = force_close; loop->instance = inst; @@ -182,7 +182,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi TopTools_ListIteratorOfListOfShape it(converted_segments); - std::vector profile = inst.data().get_inverse(&IfcSchema::IfcProfileDef::Class(), -1); + std::vector profile = inst.data().get_inverse(&IfcSchema::IfcProfileDef::Class(), -1); const bool force_close = profile && profile->size() > 0; util::wire_builder bld(getValue(GV_PRECISION), l); @@ -192,4 +192,4 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wi return true; } -*/ \ No newline at end of file +*/ diff --git a/src/ifcgeom/mapping/IfcCompositeProfileDef.cpp b/src/ifcgeom/mapping/IfcCompositeProfileDef.cpp index caef09837e..27e3a62fca 100644 --- a/src/ifcgeom/mapping/IfcCompositeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCompositeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeProfileDef& inst) { // @todo double check that this is actually supported diff --git a/src/ifcgeom/mapping/IfcConnectedFaceSet.cpp b/src/ifcgeom/mapping/IfcConnectedFaceSet.cpp index 14d20acf60..b4e1e523e7 100644 --- a/src/ifcgeom/mapping/IfcConnectedFaceSet.cpp +++ b/src/ifcgeom/mapping/IfcConnectedFaceSet.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcConnectedFaceSet& inst) { auto shell = map_to_collection(this, inst.CfsFaces()); diff --git a/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp index d1e97a264b..ae4eda3153 100644 --- a/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcCsgSolid.cpp b/src/ifcgeom/mapping/IfcCsgSolid.cpp index 03323b51f2..9f2747b8d6 100644 --- a/src/ifcgeom/mapping/IfcCsgSolid.cpp +++ b/src/ifcgeom/mapping/IfcCsgSolid.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCsgSolid& inst) { return map(inst.TreeRootExpression()); diff --git a/src/ifcgeom/mapping/IfcCurveBoundedPlane.cpp b/src/ifcgeom/mapping/IfcCurveBoundedPlane.cpp index c3d750b2a4..4b2a7c2d84 100644 --- a/src/ifcgeom/mapping/IfcCurveBoundedPlane.cpp +++ b/src/ifcgeom/mapping/IfcCurveBoundedPlane.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCurveBoundedPlane& inst) { taxonomy::plane::ptr pl = taxonomy::cast(map(inst.BasisSurface())); diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index 28a50126cc..5f1761e0d1 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcCurveSegment diff --git a/src/ifcgeom/mapping/IfcCylindricalSurface.cpp b/src/ifcgeom/mapping/IfcCylindricalSurface.cpp index 2456adcd22..3b270d8c7e 100644 --- a/src/ifcgeom/mapping/IfcCylindricalSurface.cpp +++ b/src/ifcgeom/mapping/IfcCylindricalSurface.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcCylindricalSurface diff --git a/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp b/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp index 42d08b667e..f6721d0a3a 100644 --- a/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDerivedProfileDef& inst) { auto it = map(inst.ParentProfile()); diff --git a/src/ifcgeom/mapping/IfcDirection.cpp b/src/ifcgeom/mapping/IfcDirection.cpp index d02e56b99f..9d5925e2b1 100644 --- a/src/ifcgeom/mapping/IfcDirection.cpp +++ b/src/ifcgeom/mapping/IfcDirection.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDirection& inst) { auto coords = inst.DirectionRatios(); @@ -28,4 +28,4 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDirection& inst) { coords.size() >= 2 ? coords[1] : 0., coords.size() >= 3 ? coords[2] : 0. ); -} \ No newline at end of file +} diff --git a/src/ifcgeom/mapping/IfcEdge.cpp b/src/ifcgeom/mapping/IfcEdge.cpp index 16d272082f..fed2926670 100644 --- a/src/ifcgeom/mapping/IfcEdge.cpp +++ b/src/ifcgeom/mapping/IfcEdge.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge& inst) { auto v1 = inst.EdgeStart().as(); diff --git a/src/ifcgeom/mapping/IfcEdgeLoop.cpp b/src/ifcgeom/mapping/IfcEdgeLoop.cpp index 6f47d7244f..b907b26f7d 100644 --- a/src/ifcgeom/mapping/IfcEdgeLoop.cpp +++ b/src/ifcgeom/mapping/IfcEdgeLoop.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdgeLoop& inst) { return map_to_collection(this, inst.EdgeList()); diff --git a/src/ifcgeom/mapping/IfcEllipse.cpp b/src/ifcgeom/mapping/IfcEllipse.cpp index 2c72f71974..dc91e77c7b 100644 --- a/src/ifcgeom/mapping/IfcEllipse.cpp +++ b/src/ifcgeom/mapping/IfcEllipse.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipse& inst) { double x = inst.SemiAxis1() * length_unit_; diff --git a/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp b/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp index 0d79ee8104..04afa75e04 100644 --- a/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEllipseProfileDef& inst) { double rx = inst.SemiAxis1() * length_unit_; diff --git a/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp b/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp index d756b2ec67..8fb31ce122 100644 --- a/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcExtrudedAreaSolid.cpp @@ -22,7 +22,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcExtrudedAreaSolid& inst) { const double height = inst.Depth() * length_unit_; diff --git a/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp b/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp index f497db1019..9e05e1edf1 100644 --- a/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp +++ b/src/ifcgeom/mapping/IfcExtrudedAreaSolidTapered.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered diff --git a/src/ifcgeom/mapping/IfcFace.cpp b/src/ifcgeom/mapping/IfcFace.cpp index 6b8a5c2d09..99c9108eeb 100644 --- a/src/ifcgeom/mapping/IfcFace.cpp +++ b/src/ifcgeom/mapping/IfcFace.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFace& inst) { auto face = taxonomy::make(); diff --git a/src/ifcgeom/mapping/IfcFaceBasedSurfaceModel.cpp b/src/ifcgeom/mapping/IfcFaceBasedSurfaceModel.cpp index 200f5b9f7d..48d01b3d2b 100644 --- a/src/ifcgeom/mapping/IfcFaceBasedSurfaceModel.cpp +++ b/src/ifcgeom/mapping/IfcFaceBasedSurfaceModel.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFaceBasedSurfaceModel& inst) { // @todo check styles? diff --git a/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp b/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp index 91e9d29a40..3bed9cc374 100644 --- a/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcFixedReferenceSweptAreaSolid.cpp @@ -20,7 +20,7 @@ #include "../function_item_evaluator.h" #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcFixedReferenceSweptAreaSolid diff --git a/src/ifcgeom/mapping/IfcGeometricSet.cpp b/src/ifcgeom/mapping/IfcGeometricSet.cpp index 5b7590033b..41fbbc2e45 100644 --- a/src/ifcgeom/mapping/IfcGeometricSet.cpp +++ b/src/ifcgeom/mapping/IfcGeometricSet.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGeometricSet& inst) { return map_to_collection(this, inst.Elements()); diff --git a/src/ifcgeom/mapping/IfcGradientCurve.cpp b/src/ifcgeom/mapping/IfcGradientCurve.cpp index e512f9bdc6..0d6ff4ef9c 100644 --- a/src/ifcgeom/mapping/IfcGradientCurve.cpp +++ b/src/ifcgeom/mapping/IfcGradientCurve.cpp @@ -20,7 +20,7 @@ #include "mapping.h" #include "../function_item_evaluator.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcGradientCurve @@ -80,4 +80,4 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcGradientCurve& inst) { return gradient_function; } -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp b/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp index f101cb8f64..c9d0963a19 100644 --- a/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp +++ b/src/ifcgeom/mapping/IfcHalfSpaceSolid.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcHalfSpaceSolid& inst) { auto surface = inst.BaseSurface(); diff --git a/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp index dfc913477d..73c75a7b80 100644 --- a/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp b/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp index b935803e13..710c15dcaa 100644 --- a/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp +++ b/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcIndexedPolyCurve diff --git a/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp index 3cd8c41c9e..4dd7ddd543 100644 --- a/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcLine.cpp b/src/ifcgeom/mapping/IfcLine.cpp index 7f4b50dbe3..c7bb6b7383 100644 --- a/src/ifcgeom/mapping/IfcLine.cpp +++ b/src/ifcgeom/mapping/IfcLine.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcLine& inst) { // @todo test with trimmed curve on non-normalized direction diff --git a/src/ifcgeom/mapping/IfcManifoldSolidBrep.cpp b/src/ifcgeom/mapping/IfcManifoldSolidBrep.cpp index a72b5b939c..2d7854279c 100644 --- a/src/ifcgeom/mapping/IfcManifoldSolidBrep.cpp +++ b/src/ifcgeom/mapping/IfcManifoldSolidBrep.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcManifoldSolidBrep& inst) { std::vector voids; diff --git a/src/ifcgeom/mapping/IfcMappedItem.cpp b/src/ifcgeom/mapping/IfcMappedItem.cpp index 2565233472..b4d8a4e1cc 100644 --- a/src/ifcgeom/mapping/IfcMappedItem.cpp +++ b/src/ifcgeom/mapping/IfcMappedItem.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMappedItem& inst) { auto transform = inst.MappingTarget(); diff --git a/src/ifcgeom/mapping/IfcObjectPlacement.cpp b/src/ifcgeom/mapping/IfcObjectPlacement.cpp index 7560e632b0..b4b9da53af 100644 --- a/src/ifcgeom/mapping/IfcObjectPlacement.cpp +++ b/src/ifcgeom/mapping/IfcObjectPlacement.cpp @@ -19,14 +19,14 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) { if (placement_rel_to_type_ || placement_rel_to_instance_) { - using QueueItem = std::pair; - std::deque q = {{inst, 0}}; + using queue_item = std::pair; + std::deque q = {{inst, 0}}; while (!q.empty()) { auto [placement, depth] = q.front(); q.pop_front(); @@ -59,7 +59,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement& inst) { } IfcSchema::IfcObjectPlacement relative_to; - express::Base transform; + express::base transform; IfcSchema::IfcAxis2Placement3D fallback; diff --git a/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp b/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp index 008d0fb581..9a2f1045f8 100644 --- a/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp +++ b/src/ifcgeom/mapping/IfcOffsetCurveByDistance.cpp @@ -21,7 +21,7 @@ #include "../profile_helper.h" #include "../function_item_evaluator.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; // ifc4x1 //#define SCHEMA_IfcOffsetCurveByDistances_HAS_OffsetValues @@ -186,4 +186,4 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOffsetCurveByDistances& inst return fn; } -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp b/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp index 8b375ded4f..b81227d190 100644 --- a/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcOpenCrossProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../../ifcgeom/profile_helper.h" #include "../../ifcgeom/infra_sweep_helper.h" diff --git a/src/ifcgeom/mapping/IfcOrientedEdge.cpp b/src/ifcgeom/mapping/IfcOrientedEdge.cpp index 7f719dbfc4..c068e8bc1c 100644 --- a/src/ifcgeom/mapping/IfcOrientedEdge.cpp +++ b/src/ifcgeom/mapping/IfcOrientedEdge.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcOrientedEdge& inst) { auto e = taxonomy::cast(map(inst.EdgeElement())); diff --git a/src/ifcgeom/mapping/IfcPlane.cpp b/src/ifcgeom/mapping/IfcPlane.cpp index 30be44a793..7d31bbc4c1 100644 --- a/src/ifcgeom/mapping/IfcPlane.cpp +++ b/src/ifcgeom/mapping/IfcPlane.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPlane& inst) { auto p = taxonomy::make(); diff --git a/src/ifcgeom/mapping/IfcPointByDistanceExpression.cpp b/src/ifcgeom/mapping/IfcPointByDistanceExpression.cpp index b028e72b71..29bbfd20c3 100644 --- a/src/ifcgeom/mapping/IfcPointByDistanceExpression.cpp +++ b/src/ifcgeom/mapping/IfcPointByDistanceExpression.cpp @@ -22,7 +22,7 @@ #include "../function_item_evaluator.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #if defined SCHEMA_HAS_IfcPointByDistanceExpression diff --git a/src/ifcgeom/mapping/IfcPolyLoop.cpp b/src/ifcgeom/mapping/IfcPolyLoop.cpp index 371ff6d975..67724f8fcf 100644 --- a/src/ifcgeom/mapping/IfcPolyLoop.cpp +++ b/src/ifcgeom/mapping/IfcPolyLoop.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcPolygonalBoundedHalfSpace.cpp b/src/ifcgeom/mapping/IfcPolygonalBoundedHalfSpace.cpp index 77acf88824..ed5e29dc4a 100644 --- a/src/ifcgeom/mapping/IfcPolygonalBoundedHalfSpace.cpp +++ b/src/ifcgeom/mapping/IfcPolygonalBoundedHalfSpace.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolygonalBoundedHalfSpace& inst) { auto s = taxonomy::cast(map_impl((IfcSchema::IfcHalfSpaceSolid&) inst)); diff --git a/src/ifcgeom/mapping/IfcPolygonalFaceSet.cpp b/src/ifcgeom/mapping/IfcPolygonalFaceSet.cpp index 45f0186c32..c56caeeae8 100644 --- a/src/ifcgeom/mapping/IfcPolygonalFaceSet.cpp +++ b/src/ifcgeom/mapping/IfcPolygonalFaceSet.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcPolygonalFaceSet diff --git a/src/ifcgeom/mapping/IfcPolyline.cpp b/src/ifcgeom/mapping/IfcPolyline.cpp index 2d22cb3b23..687f9a8e75 100644 --- a/src/ifcgeom/mapping/IfcPolyline.cpp +++ b/src/ifcgeom/mapping/IfcPolyline.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcProduct.cpp b/src/ifcgeom/mapping/IfcProduct.cpp index d1c51310d5..8321bde2a0 100644 --- a/src/ifcgeom/mapping/IfcProduct.cpp +++ b/src/ifcgeom/mapping/IfcProduct.cpp @@ -1,8 +1,6 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; - -using namespace IfcGeom; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcProduct& inst) { // @todo decide on this, what happens in the product mapping? @@ -54,7 +52,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcProduct& inst) { ci.setIdentity(); } - std::vector operands(new aggregate_of_instance); + std::vector operands(new aggregate_of_instance); operands->push(body); operands->push(openings); auto n = map_to_collection(this, operands); diff --git a/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp b/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp index 6caa9a0d67..797365cf76 100644 --- a/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp b/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp index 9f5acc7890..a4fe40903a 100644 --- a/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcRectangularPyramid.cpp b/src/ifcgeom/mapping/IfcRectangularPyramid.cpp index 2c9b12dfcf..e8dad3afcb 100644 --- a/src/ifcgeom/mapping/IfcRectangularPyramid.cpp +++ b/src/ifcgeom/mapping/IfcRectangularPyramid.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp b/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp index 03d636cc6f..a05c364d42 100644 --- a/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp +++ b/src/ifcgeom/mapping/IfcRectangularTrimmedSurface.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface& inst) { // @todo we'll need to add support for p-curves at some point, but not now. @@ -31,7 +31,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularTrimmedSurface& i return false; } gp_Pln pln; - IfcGeom::Kernel::convert((IfcSchema::IfcPlane*) inst.BasisSurface(), pln); + ifcopenshell::geom::Kernel::convert((IfcSchema::IfcPlane*) inst.BasisSurface(), pln); BRepBuilderAPI_MakeFace mf(pln, inst.U1(), inst.U2(), inst.V1(), inst.V2()); diff --git a/src/ifcgeom/mapping/IfcRepresentation.cpp b/src/ifcgeom/mapping/IfcRepresentation.cpp index 3ea437afca..68e26546c4 100644 --- a/src/ifcgeom/mapping/IfcRepresentation.cpp +++ b/src/ifcgeom/mapping/IfcRepresentation.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation& inst) { auto items_to_include = this->settings_.get().get(); diff --git a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp index e24c1bca8f..efd51bc204 100644 --- a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include diff --git a/src/ifcgeom/mapping/IfcRightCircularCone.cpp b/src/ifcgeom/mapping/IfcRightCircularCone.cpp index 42f4cc5a70..6b8b3a0328 100644 --- a/src/ifcgeom/mapping/IfcRightCircularCone.cpp +++ b/src/ifcgeom/mapping/IfcRightCircularCone.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCone& inst) { // @todo @@ -30,7 +30,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCone& inst) { BRepPrimAPI_MakeCone builder(r, 0., h); gp_Trsf trsf; - IfcGeom::Kernel::convert(inst.Position(),trsf); + ifcopenshell::geom::Kernel::convert(inst.Position(),trsf); // IfcCsgPrimitive3D.Position has unit scale factor shape = builder.Solid().Moved(trsf); diff --git a/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp b/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp index 1de3a76848..c035bfcc0b 100644 --- a/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp +++ b/src/ifcgeom/mapping/IfcRightCircularCylinder.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCylinder& inst) { // @todo @@ -31,7 +31,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRightCircularCylinder& inst) BRepPrimAPI_MakeCylinder builder(r, h); gp_Trsf trsf; - IfcGeom::Kernel::convert(inst.Position(),trsf); + ifcopenshell::geom::Kernel::convert(inst.Position(),trsf); // IfcCsgPrimitive3D.Position has unit scale factor shape = builder.Solid().Moved(trsf); diff --git a/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp b/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp index f03b81f3f3..521371a05b 100644 --- a/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp b/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp index 36baea8d26..c775b44c09 100644 --- a/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp +++ b/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../../ifcgeom/profile_helper.h" #include "../../ifcgeom/infra_sweep_helper.h" diff --git a/src/ifcgeom/mapping/IfcSectionedSurface.cpp b/src/ifcgeom/mapping/IfcSectionedSurface.cpp index 7499cfc07c..4947663377 100644 --- a/src/ifcgeom/mapping/IfcSectionedSurface.cpp +++ b/src/ifcgeom/mapping/IfcSectionedSurface.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../../ifcgeom/profile_helper.h" #include "../../ifcgeom/infra_sweep_helper.h" diff --git a/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp b/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp index 4e7bfb2dd1..7e23ee5cf9 100644 --- a/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp +++ b/src/ifcgeom/mapping/IfcSegmentedReferenceCurve.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../function_item_evaluator.h" @@ -73,4 +73,4 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSegmentedReferenceCurve& ins return cant_function; } -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/mapping/IfcShellBasedSurfaceModel.cpp b/src/ifcgeom/mapping/IfcShellBasedSurfaceModel.cpp index 02a797b2aa..ad68cbd4fc 100644 --- a/src/ifcgeom/mapping/IfcShellBasedSurfaceModel.cpp +++ b/src/ifcgeom/mapping/IfcShellBasedSurfaceModel.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcShellBasedSurfaceModel& inst) { return map_to_collection(this, inst.SbsmBoundary()); diff --git a/src/ifcgeom/mapping/IfcSphere.cpp b/src/ifcgeom/mapping/IfcSphere.cpp index 0c403c0e87..2e0ba7157e 100644 --- a/src/ifcgeom/mapping/IfcSphere.cpp +++ b/src/ifcgeom/mapping/IfcSphere.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphere& inst) { auto sol = taxonomy::make(); diff --git a/src/ifcgeom/mapping/IfcSphericalSurface.cpp b/src/ifcgeom/mapping/IfcSphericalSurface.cpp index 713fa110b9..06c9246a30 100644 --- a/src/ifcgeom/mapping/IfcSphericalSurface.cpp +++ b/src/ifcgeom/mapping/IfcSphericalSurface.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcSphericalSurface @@ -28,7 +28,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSphericalSurface& inst) { /* gp_Trsf trsf; - IfcGeom::Kernel::convert(inst.Position(), trsf); + ifcopenshell::geom::Kernel::convert(inst.Position(), trsf); // IfcElementarySurface.Position has unit scale factor face = BRepBuilderAPI_MakeFace(new Geom_SphericalSurface(gp::XOY(), inst.Radius() * length_unit_), getValue(GV_PRECISION)).Face().Moved(trsf); diff --git a/src/ifcgeom/mapping/IfcSubedge.cpp b/src/ifcgeom/mapping/IfcSubedge.cpp index c84714c516..91502a2b80 100644 --- a/src/ifcgeom/mapping/IfcSubedge.cpp +++ b/src/ifcgeom/mapping/IfcSubedge.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; /* taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSubedge& inst) { diff --git a/src/ifcgeom/mapping/IfcSurfaceCurve.cpp b/src/ifcgeom/mapping/IfcSurfaceCurve.cpp index 71e595b20a..dc242dbef5 100644 --- a/src/ifcgeom/mapping/IfcSurfaceCurve.cpp +++ b/src/ifcgeom/mapping/IfcSurfaceCurve.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcSurfaceCurve taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurve& inst) { diff --git a/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp b/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp index b20f39475d..cce8dc61d6 100644 --- a/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcSurfaceCurveSweptAreaSolid.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid& inst) { taxonomy::face::ptr f = taxonomy::cast(map(inst.SweptArea())); @@ -65,7 +65,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid& bool directrix_on_plane = is_plane; if (is_plane) { - IfcGeom::Kernel::convert((IfcSchema::IfcPlane*) inst.ReferenceSurface(), pln); + ifcopenshell::geom::Kernel::convert((IfcSchema::IfcPlane*) inst.ReferenceSurface(), pln); // As per Informal propositions 2: The Directrix shall lie on the ReferenceSurface. // This is not always the case with the test files in the repository. I am not sure @@ -91,7 +91,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid& crv->D1(u0, directrix_origin, directrix_tangent); } - if (is_plane && pln.Axis().Direction().IsNormal(directrix_tangent, Precision::Approximation()) && directrix_on_plane) { + if (is_plane && pln.Axis().Direction().IsNormal(directrix_tangent, ::Precision::Approximation()) && directrix_on_plane) { directrix.SetTransformation(gp_Ax3(directrix_origin, directrix_tangent, pln.Axis().Direction()), gp::XOY()); } else if (!is_plane) { ShapeAnalysis_Surface sas(BRep_Tool::Surface(surface_face)); diff --git a/src/ifcgeom/mapping/IfcSurfaceOfLinearExtrusion.cpp b/src/ifcgeom/mapping/IfcSurfaceOfLinearExtrusion.cpp index 562c6d42b6..df879187f6 100644 --- a/src/ifcgeom/mapping/IfcSurfaceOfLinearExtrusion.cpp +++ b/src/ifcgeom/mapping/IfcSurfaceOfLinearExtrusion.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfLinearExtrusion& inst) { taxonomy::matrix4::ptr matrix; diff --git a/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp b/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp index 9ae0e0e389..ba62d21a22 100644 --- a/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp +++ b/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution& inst) { taxonomy::matrix4::ptr matrix; diff --git a/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp b/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp index ea6e70a538..ff0d1c0a67 100644 --- a/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp +++ b/src/ifcgeom/mapping/IfcSweptDiskSolid.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp index 521db4c8b7..e4e433057a 100644 --- a/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcToroidalSurface.cpp b/src/ifcgeom/mapping/IfcToroidalSurface.cpp index abbaa6d7c6..3b0c8a2a54 100644 --- a/src/ifcgeom/mapping/IfcToroidalSurface.cpp +++ b/src/ifcgeom/mapping/IfcToroidalSurface.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcToroidalSurface diff --git a/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp b/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp index 205242cff3..c15264433b 100644 --- a/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp b/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp index 9e35e7abd4..9b97f4afb3 100644 --- a/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp +++ b/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #ifdef SCHEMA_HAS_IfcTriangulatedFaceSet @@ -85,4 +85,4 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet& inst) { return shell; } -#endif \ No newline at end of file +#endif diff --git a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp index ede59d2488..664c338f60 100644 --- a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp +++ b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include diff --git a/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp index 05869ac58d..48674ee36a 100644 --- a/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/IfcVector.cpp b/src/ifcgeom/mapping/IfcVector.cpp index 9b7b23bbad..07bd602b20 100644 --- a/src/ifcgeom/mapping/IfcVector.cpp +++ b/src/ifcgeom/mapping/IfcVector.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcVector& inst) { auto d = taxonomy::cast(map(inst.Orientation())); diff --git a/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp index dc09b12de4..19f0ebf2e4 100644 --- a/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp @@ -19,7 +19,7 @@ #include "mapping.h" #define mapping POSTFIX_SCHEMA(mapping) -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; #include "../profile_helper.h" diff --git a/src/ifcgeom/mapping/bind_convert_decl.i b/src/ifcgeom/mapping/bind_convert_decl.i index 4239f4e112..302fd7d9da 100644 --- a/src/ifcgeom/mapping/bind_convert_decl.i +++ b/src/ifcgeom/mapping/bind_convert_decl.i @@ -2,6 +2,6 @@ #undef BIND #endif -#define BIND(T) ifcopenshell::geometry::taxonomy::ptr map_impl(const IfcSchema::T&); +#define BIND(T) ifcopenshell::geom::taxonomy::ptr map_impl(const IfcSchema::T&); #include "mapping.i" diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index c7e6562af5..63acf01bc4 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -36,19 +36,18 @@ #include using namespace ifcopenshell; -using namespace ifcopenshell::geometry; -using namespace IfcGeom; +using namespace ifcopenshell::geom; namespace { struct POSTFIX_SCHEMA(factory_t) { - abstract_mapping* operator()(ifcopenshell::file* file, Settings& settings, ::logger& logger) const { - ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geometry::POSTFIX_SCHEMA(mapping)(file, settings, logger); + abstract_mapping* operator()(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger) const { + ifcopenshell::geom::POSTFIX_SCHEMA(mapping)* m = new ifcopenshell::geom::POSTFIX_SCHEMA(mapping)(file, settings, logger); return m; } }; } -void MAKE_INIT_FN(MappingImplementation)(ifcopenshell::geometry::impl::mapping_registry* mapping) { +void MAKE_INIT_FN(MappingImplementation)(ifcopenshell::geom::impl::mapping_registry* mapping) { static const std::string schema_name = STRINGIFY(IfcSchema); POSTFIX_SCHEMA(factory_t) factory; mapping->bind(schema_name, factory); @@ -132,7 +131,7 @@ std::vector filter_products(const std::vector& products) { // With world coords enabled, object transformations are directly applied to - // the BRep. There is no way to re-use the geometry for multiple products. + // the brep. There is no way to re-use the geometry for multiple products. if (settings_.get().get()) { return false; } @@ -141,7 +140,7 @@ bool mapping::reuse_ok_(const std::vector& products) { return true; } - std::set> associated_single_materials; + std::set> associated_single_materials; for (auto& product : products) { if (!settings_.get().get() && !find_openings(product).empty()) { @@ -161,15 +160,15 @@ bool mapping::reuse_ok_(const std::vector& products) { } auto mat = get_single_material_association(product); - associated_single_materials.insert(mat ? std::optional{mat} : std::nullopt); + associated_single_materials.insert(mat ? std::optional{mat} : std::nullopt); if (associated_single_materials.size() > 1) return false; } return associated_single_materials.size() == 1; } -std::vector mapping::find_openings(const express::Base& inst) { - std::vector openings; +std::vector mapping::find_openings(const express::base& inst) { + std::vector openings; if (auto rep = inst.as()) { // @todo this is essentially only for hybrid kernel trying to guess @@ -328,7 +327,7 @@ void mapping::get_representations(std::vector& tasks, } } -const express::Base mapping::get_product_type(const express::Base& product_) { +const express::base mapping::get_product_type(const express::base& product_) { auto product = product_.as(); #ifdef SCHEMA_IfcObject_HAS_IsTypedBy auto rels = product.IsTypedBy(); @@ -350,10 +349,10 @@ const express::Base mapping::get_product_type(const express::Base& product_) { } return rel.RelatingType(); } - return express::Base{}; + return express::base{}; } -const express::Base mapping::get_single_material_association(const express::Base& product_) { +const express::base mapping::get_single_material_association(const express::base& product_) { auto product = product_.as(); IfcSchema::IfcMaterial single_material; auto associations = product.HasAssociations(); @@ -364,7 +363,7 @@ const express::Base mapping::get_single_material_association(const express::Base } } if (associated_materials.size() == 1) { - express::Base associated_material; + express::base associated_material; try { associated_material = associated_materials.front().RelatingMaterial().concrete(); @@ -383,7 +382,7 @@ const express::Base mapping::get_single_material_association(const express::Base if (auto m = associated_material.as()) { if (m.get("ForLayerSet").isNull()) { logger_.warning("GEO", 302, "Missing ForLayerSet for:", m); - return express::Base{}; + return express::base{}; } layerset = m.ForLayerSet(); } else { @@ -403,7 +402,7 @@ const express::Base mapping::get_single_material_association(const express::Base if (auto m = associated_material.as()) { if (m.get("ForProfileSet").isNull()) { logger_.warning("GEO", 303, "Missing ForProfileSet for:", m); - return express::Base{}; + return express::base{}; } profileset = m.ForProfileSet(); } else { @@ -642,7 +641,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcMaterial& material) { */ // @todo - // IfcGeom::SurfaceStyle material_style = IfcGeom::SurfaceStyle(material->data().id(), material->Name()); + // ifcopenshell::geom::SurfaceStyle material_style = ifcopenshell::geom::SurfaceStyle(material->data().id(), material->Name()); // return &(style_cache[material->data().id()] = material_style); } @@ -746,7 +745,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle& style) { return surface_style; } -taxonomy::ptr mapping::map(const express::Base& inst) { +taxonomy::ptr mapping::map(const express::base& inst) { if (!inst) { logger_.error("GEO", 306, "Warning nullptr passed to map() function"); return nullptr; @@ -781,7 +780,7 @@ taxonomy::ptr mapping::map(const express::Base& inst) { } namespace { - express::Base get_RelatingObject(IfcSchema::IfcRelDecomposes& decompose) { + express::base get_RelatingObject(IfcSchema::IfcRelDecomposes& decompose) { #ifdef SCHEMA_IfcRelDecomposes_HAS_RelatingObject return decompose.RelatingObject(); #else @@ -789,12 +788,12 @@ namespace { if (aggr) { return aggr.RelatingObject(); } - return express::Base{}; + return express::base{}; #endif } } -express::Base mapping::get_decomposing_entity(const express::Base& inst, bool include_openings) { +express::base mapping::get_decomposing_entity(const express::base& inst, bool include_openings) { IfcSchema::IfcObjectDefinition parent; auto product = inst.as(); @@ -833,12 +832,12 @@ express::Base mapping::get_decomposing_entity(const express::Base& inst, bool in /* Parent decompositions to the RelatingObject */ if (!parent) { - std::vector parents = product.file()->get_inverse(product.id(), (&IfcSchema::IfcRelAggregates::Class()), -1); + std::vector parents = product.file()->get_inverse(product.id(), (&IfcSchema::IfcRelAggregates::Class()), -1); auto nests = product.file()->get_inverse(product.id(), (&IfcSchema::IfcRelNests::Class()), -1); parents.insert(parents.end(), nests.begin(), nests.end()); for (auto it = parents.begin(); it != parents.end(); ++it) { IfcSchema::IfcRelDecomposes decompose = (*it).as(); - express::Base ifc_objectdef; + express::base ifc_objectdef; ifc_objectdef = get_RelatingObject(decompose); @@ -849,11 +848,11 @@ express::Base mapping::get_decomposing_entity(const express::Base& inst, bool in return parent; } -std::map mapping::get_layers(const express::Base& inst) { +std::map mapping::get_layers(const express::base& inst) { auto prod = inst.as(); - std::map layers; + std::map layers; if (prod.Representation()) { - std::vector representations = ifcopenshell::traverse(prod.Representation()); + std::vector representations = ifcopenshell::traverse(prod.Representation()); for (auto& inst : representations) { if (auto repr = inst.as()) { std::vector a = repr.LayerAssignments(); @@ -948,8 +947,8 @@ void mapping::initialize_units_() { } // Translation is applied first, then rotation. - if (settings_.get().has()) { - auto vs = settings_.get().get(); + if (settings_.get().has()) { + auto vs = settings_.get().get(); if (vs.size() == 3) { offset_and_rotation_ *= Eigen::Affine3d(Eigen::Translation3d(vs[0], vs[1], vs[2])).matrix(); } else { @@ -957,8 +956,8 @@ void mapping::initialize_units_() { } } - if (settings_.get().has()) { - auto vs = settings_.get().get(); + if (settings_.get().has()) { + auto vs = settings_.get().get(); if (vs.size() == 4) { // @nb W, X, Y, Z auto m3 = Eigen::Quaterniond(vs[3], vs[0], vs[1], vs[2]).normalized().matrix(); @@ -1020,10 +1019,10 @@ void mapping::initialize_settings() { } } - settings_.get().value = precision_to_set; + settings_.get().value = precision_to_set; } -bool mapping::get_layerset_information(const express::Base& p, layerset_information& info, int &) +bool mapping::get_layerset_information(const express::base& p, layerset_information& info, int &) { auto product = p.as(); @@ -1215,7 +1214,7 @@ bool mapping::get_layerset_information(const express::Base& p, layerset_informat return true; } -bool mapping::get_wall_neighbours(const express::Base&, std::vector&) { +bool mapping::get_wall_neighbours(const express::base&, std::vector&) { return false; } @@ -1555,7 +1554,7 @@ void mapping::ensureRepresentationContextCache_() { representation_context_cache_valid_ = true; } -express::Base mapping::representation_of(const express::Base& product) { +express::base mapping::representation_of(const express::base& product) { std::vector of_product; std::vector intersection; std::vector intersection_no_box; @@ -1595,7 +1594,7 @@ express::Base mapping::representation_of(const express::Base& product) { } if (intersection.size() == 0) { - return express::Base{}; + return express::base{}; } else { for (auto& r : intersection) { auto resources = ifcopenshell::traverse(r); diff --git a/src/ifcgeom/mapping/mapping.h b/src/ifcgeom/mapping/mapping.h index 9f4dfc652c..631575525d 100644 --- a/src/ifcgeom/mapping/mapping.h +++ b/src/ifcgeom/mapping/mapping.h @@ -15,7 +15,7 @@ namespace ifcopenshell { -namespace geometry { +namespace geom { class POSTFIX_SCHEMA(mapping) : public abstract_mapping { private: @@ -23,11 +23,11 @@ namespace geometry { double length_unit_, angle_unit_; std::string length_unit_name_; - std::map cache_; + std::map cache_; std::mutex cache_guard_; // provides mutually exclusive access to cache_ const ifcopenshell::declaration* placement_rel_to_type_; - const express::Base placement_rel_to_instance_; + const express::base placement_rel_to_instance_; Eigen::Matrix4d offset_and_rotation_ = Eigen::Matrix4d::Identity(); @@ -39,7 +39,7 @@ namespace geometry { // Set of instances to mark failures that are intended, such as representations not // resulting in any items due to dimensionality filters. - std::set failed_on_purpose_; + std::set failed_on_purpose_; std::set not_reusable_maps_; std::unordered_set representation_context_cache_; std::vector representation_context_priority_cache_; @@ -52,7 +52,7 @@ namespace geometry { std::mutex representation_context_cache_guard_; template - void process_mapping(bool& matched, taxonomy::ptr& item, const express::Base& inst) { + void process_mapping(bool& matched, taxonomy::ptr& item, const express::base& inst) { if (!item && inst.as()) { matched = true; try { @@ -87,27 +87,27 @@ namespace geometry { } IfcSchema::IfcStyledItem find_style(const IfcSchema::IfcRepresentationItem&); public: - POSTFIX_SCHEMA(mapping)(ifcopenshell::file* file, Settings& settings, ::logger& logger = ::logger::root()) : abstract_mapping(settings, logger), file_(file), placement_rel_to_type_(nullptr) { + POSTFIX_SCHEMA(mapping)(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root()) : abstract_mapping(settings, logger), file_(file), placement_rel_to_type_(nullptr) { initialize_units_(); } - virtual ifcopenshell::geometry::taxonomy::ptr map(const express::Base&); + virtual ifcopenshell::geom::taxonomy::ptr map(const express::base&); virtual void get_representations(std::vector& tasks, std::vector& filters); - virtual std::map get_layers(const express::Base&); + virtual std::map get_layers(const express::base&); virtual void initialize_settings(); virtual double get_length_unit() const { return length_unit_; } virtual const std::string& get_length_unit_name() const { return length_unit_name_; } - virtual std::vector find_openings(const express::Base&); - virtual express::Base representation_of(const express::Base& product); + virtual std::vector find_openings(const express::base&); + virtual express::base representation_of(const express::base& product); - virtual const express::Base get_product_type(const express::Base& product_); - virtual const express::Base get_single_material_association(const express::Base& product); + virtual const express::base get_product_type(const express::base& product_); + virtual const express::base get_single_material_association(const express::base& product); IfcSchema::IfcRepresentation representation_mapped_to(const IfcSchema::IfcRepresentation& representation); std::vector products_represented_by(const IfcSchema::IfcRepresentation& representation, IfcSchema::IfcRepresentationMap& rmap, bool only_direct = false); bool reuse_ok_(const std::vector& products); - express::Base get_decomposing_entity(const express::Base& product, bool include_openings); + express::base get_decomposing_entity(const express::base& product, bool include_openings); - bool get_layerset_information(const express::Base&, layerset_information&, int&); - bool get_wall_neighbours(const express::Base&, std::vector&); + bool get_layerset_information(const express::base&, layerset_information&, int&); + bool get_wall_neighbours(const express::base&, std::vector&); IfcSchema::IfcRepresentation find_representation(const IfcSchema::IfcProduct&, const std::string&); #include "bind_convert_decl.i" diff --git a/src/ifcgeom/mapping/plugin.cpp b/src/ifcgeom/mapping/plugin.cpp index e89c75075a..4d6710e837 100644 --- a/src/ifcgeom/mapping/plugin.cpp +++ b/src/ifcgeom/mapping/plugin.cpp @@ -23,13 +23,13 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace impl { namespace mapping_plugin { namespace { struct POSTFIX_SCHEMA(factory_t) { - abstract_mapping* operator()(ifcopenshell::file* file, Settings& settings, ::logger& logger) const { + abstract_mapping* operator()(ifcopenshell::file* file, ifcopenshell::geom::settings& settings, ::logger& logger) const { return new POSTFIX_SCHEMA(mapping)(file, settings, logger); } }; @@ -53,6 +53,6 @@ namespace ifcopenshell { } } -BOOST_DLL_ALIAS(ifcopenshell::geometry::impl::mapping_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::impl::mapping_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) -BOOST_DLL_ALIAS(ifcopenshell::geometry::impl::mapping_plugin::register_plugin, ifcopenshell_register_mapping_plugin_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::impl::mapping_plugin::plugin_abi, ifcopenshell_plugin_abi_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::impl::mapping_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1) +BOOST_DLL_ALIAS(ifcopenshell::geom::impl::mapping_plugin::register_plugin, ifcopenshell_register_mapping_plugin_v1) diff --git a/src/ifcgeom/mapping_plugin.cpp b/src/ifcgeom/mapping_plugin.cpp index 49736ce087..883ce39c8d 100644 --- a/src/ifcgeom/mapping_plugin.cpp +++ b/src/ifcgeom/mapping_plugin.cpp @@ -31,11 +31,11 @@ namespace { constexpr const char* mapping_plugin_prefix = "geometry.mapping."; } -const char* ifcopenshell::geometry::impl::mapping_plugin_registration_symbol() { +const char* ifcopenshell::geom::impl::mapping_plugin_registration_symbol() { return "ifcopenshell_register_mapping_plugin_v1"; } -ifcopenshell::plugin::metadata ifcopenshell::geometry::impl::mapping_plugin_metadata(const std::string& schema_name) { +ifcopenshell::plugin::metadata ifcopenshell::geom::impl::mapping_plugin_metadata(const std::string& schema_name) { plugin::metadata metadata; metadata.kind_ = plugin::kind::mapping; metadata.id = mapping_plugin_prefix + boost::to_lower_copy(schema_name); @@ -43,11 +43,11 @@ ifcopenshell::plugin::metadata ifcopenshell::geometry::impl::mapping_plugin_meta return metadata; } -std::filesystem::path ifcopenshell::geometry::impl::mapping_plugin_directory() { - return plugin::module_directory(reinterpret_cast(&ifcopenshell::geometry::impl::load_mapping_plugins)); +std::filesystem::path ifcopenshell::geom::impl::mapping_plugin_directory() { + return plugin::module_directory(reinterpret_cast(&ifcopenshell::geom::impl::load_mapping_plugins)); } -void ifcopenshell::geometry::impl::load_mapping_plugins(mapping_registry& registry) { +void ifcopenshell::geom::impl::load_mapping_plugins(mapping_registry& registry) { plugin::manager manager; plugin::add_search_paths_or_default(manager, &mapping_plugin_directory); @@ -62,7 +62,7 @@ void ifcopenshell::geometry::impl::load_mapping_plugins(mapping_registry& regist } } -bool ifcopenshell::geometry::impl::load_mapping_plugin(mapping_registry& registry, const std::string& schema_name) { +bool ifcopenshell::geom::impl::load_mapping_plugin(mapping_registry& registry, const std::string& schema_name) { plugin::manager manager; plugin::add_search_paths_or_default(manager, &mapping_plugin_directory); diff --git a/src/ifcgeom/mapping_plugin.h b/src/ifcgeom/mapping_plugin.h index 9a5483cd51..59e6b5681f 100644 --- a/src/ifcgeom/mapping_plugin.h +++ b/src/ifcgeom/mapping_plugin.h @@ -25,7 +25,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace impl { typedef void register_mapping_plugin_fn(mapping_registry&, const ifcopenshell::plugin::module&); diff --git a/src/ifcgeom/profile_helper.cpp b/src/ifcgeom/profile_helper.cpp index 1b9d1899cc..e33e1d846c 100644 --- a/src/ifcgeom/profile_helper.cpp +++ b/src/ifcgeom/profile_helper.cpp @@ -1,8 +1,8 @@ #include "profile_helper.h" -using namespace ifcopenshell::geometry; +using namespace ifcopenshell::geom; -taxonomy::loop::ptr ifcopenshell::geometry::fillet_loop(taxonomy::loop::ptr loop, double radius) { +taxonomy::loop::ptr ifcopenshell::geom::fillet_loop(taxonomy::loop::ptr loop, double radius) { std::vector pps(loop->children.size()); for (int b = 0; b < loop->children.size(); ++b) { int c = (b - 1) % loop->children.size(); @@ -54,7 +54,7 @@ taxonomy::loop::ptr ifcopenshell::geometry::fillet_loop(taxonomy::loop::ptr loop return loop; } -void ifcopenshell::geometry::remove_duplicate_points_from_loop(std::vector& polygon, bool closed, double tol) { +void ifcopenshell::geom::remove_duplicate_points_from_loop(std::vector& polygon, bool closed, double tol) { tol *= tol; for (;;) { @@ -80,7 +80,7 @@ void ifcopenshell::geometry::remove_duplicate_points_from_loop(std::vector& ps, bool external) { +taxonomy::loop::ptr ifcopenshell::geom::polygon_from_points(const std::vector& ps, bool external) { auto loop = taxonomy::make(); loop->external = external; taxonomy::point3::ptr previous; @@ -96,7 +96,7 @@ taxonomy::loop::ptr ifcopenshell::geometry::polygon_from_points(const std::vecto return loop; } -taxonomy::loop::ptr ifcopenshell::geometry::profile_helper(const taxonomy::matrix4::ptr& m4, const std::vector& points) { +taxonomy::loop::ptr ifcopenshell::geom::profile_helper(const taxonomy::matrix4::ptr& m4, const std::vector& points) { /* TopoDS_Vertex* vertices = new TopoDS_Vertex[numVerts]; for (int i = 0; i < numVerts; i++) { diff --git a/src/ifcgeom/profile_helper.h b/src/ifcgeom/profile_helper.h index 5d8b99e712..eeb03896f1 100644 --- a/src/ifcgeom/profile_helper.h +++ b/src/ifcgeom/profile_helper.h @@ -6,7 +6,7 @@ namespace ifcopenshell { - namespace geometry { + namespace geom { struct profile_point { std::array xy; std::optional radius; diff --git a/src/ifcgeom/taxonomy.cpp b/src/ifcgeom/taxonomy.cpp index e36701b43c..25718cbe02 100644 --- a/src/ifcgeom/taxonomy.cpp +++ b/src/ifcgeom/taxonomy.cpp @@ -3,7 +3,7 @@ #include "profile_helper.h" #include "function_item_evaluator.h" -using namespace ifcopenshell::geometry::taxonomy; +using namespace ifcopenshell::geom::taxonomy; namespace { bool compare(const trimmed_curve& a, const trimmed_curve& b); @@ -223,9 +223,9 @@ namespace { }; } -ifcopenshell::geometry::taxonomy::topology_error::~topology_error() = default; +ifcopenshell::geom::taxonomy::topology_error::~topology_error() = default; -bool ifcopenshell::geometry::taxonomy::less(item::const_ptr a, item::const_ptr b) { +bool ifcopenshell::geom::taxonomy::less(item::const_ptr a, item::const_ptr b) { if (a == b) { return false; } @@ -347,11 +347,11 @@ namespace { } } -ifcopenshell::geometry::taxonomy::solid::ptr ifcopenshell::geometry::create_box(double dx, double dy, double dz) { +ifcopenshell::geom::taxonomy::solid::ptr ifcopenshell::geom::create_box(double dx, double dy, double dz) { return create_box(0., 0., 0., dx, dy, dz); } -ifcopenshell::geometry::taxonomy::solid::ptr ifcopenshell::geometry::create_box(double x, double y, double z, double dx, double dy, double dz) { +ifcopenshell::geom::taxonomy::solid::ptr ifcopenshell::geom::create_box(double x, double y, double z, double dx, double dy, double dz) { auto solid = make(); auto shell = make(); solid->children.push_back(shell); @@ -486,10 +486,10 @@ ifcopenshell::geometry::taxonomy::solid::ptr ifcopenshell::geometry::create_box( } /////////////////// -piecewise_function::piecewise_function(double start, const spans_t& s, const express::Base& instance) : function_item(instance), start_(start), spans_(s) { +piecewise_function::piecewise_function(double start, const spans_t& s, const express::base& instance) : function_item(instance), start_(start), spans_(s) { } -piecewise_function::piecewise_function(double start, const std::vector& pwfs, const express::Base& instance) : function_item(instance), start_(start) { +piecewise_function::piecewise_function(double start, const std::vector& pwfs, const express::base& instance) : function_item(instance), start_(start) { for (auto& pwf : pwfs) { spans_.insert(spans_.end(), pwf->spans().begin(), pwf->spans().end()); } @@ -512,7 +512,7 @@ double piecewise_function::length() const { } -gradient_function::gradient_function(piecewise_function::const_ptr horizontal, piecewise_function::const_ptr vertical, const express::Base& instance) : +gradient_function::gradient_function(piecewise_function::const_ptr horizontal, piecewise_function::const_ptr vertical, const express::base& instance) : function_item(instance), horizontal_(horizontal), vertical_(vertical) { } double gradient_function::start() const { return std::max(horizontal_->start(), vertical_->start()); } @@ -521,7 +521,7 @@ piecewise_function::const_ptr gradient_function::get_horizontal() const { return piecewise_function::const_ptr gradient_function::get_vertical() const { return vertical_; } -cant_function::cant_function(gradient_function::const_ptr gradient, piecewise_function::const_ptr cant, const express::Base& instance) : +cant_function::cant_function(gradient_function::const_ptr gradient, piecewise_function::const_ptr cant, const express::base& instance) : function_item(instance), gradient_(gradient), cant_(cant) { } double cant_function::start() const { return std::max(gradient_->start(), cant_->start()); } @@ -530,7 +530,7 @@ gradient_function::const_ptr cant_function::get_gradient() const { return gradie piecewise_function::const_ptr cant_function::get_cant() const { return cant_; } -offset_function::offset_function(function_item::const_ptr basis, piecewise_function::const_ptr offset, const express::Base& instance) : function_item(instance), +offset_function::offset_function(function_item::const_ptr basis, piecewise_function::const_ptr offset, const express::base& instance) : function_item(instance), basis_(basis), offset_(offset) { } @@ -540,15 +540,15 @@ function_item::const_ptr offset_function::get_basis() const { return basis_; } piecewise_function::const_ptr offset_function::get_offset() const { return offset_; } -ifcopenshell::geometry::taxonomy::collection::ptr ifcopenshell::geometry::flatten(const taxonomy::collection::ptr& deep) { +ifcopenshell::geom::taxonomy::collection::ptr ifcopenshell::geom::flatten(const taxonomy::collection::ptr& deep) { auto flat = make(); - ifcopenshell::geometry::visit(deep, [&flat](taxonomy::ptr i) { + ifcopenshell::geom::visit(deep, [&flat](taxonomy::ptr i) { flat->children.push_back(taxonomy::cast(clone(i))); }); return flat; } -const std::string& ifcopenshell::geometry::taxonomy::kind_to_string(kinds k) { +const std::string& ifcopenshell::geom::taxonomy::kind_to_string(kinds k) { using namespace std::string_literals; static std::string values[] = { @@ -592,19 +592,19 @@ const std::string& ifcopenshell::geometry::taxonomy::kind_to_string(kinds k) { IFC_GEOM_API std::atomic_uint32_t item::counter_(0); -void ifcopenshell::geometry::taxonomy::item::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::item::print(std::ostream& o, int indent) const { o << std::string(indent, ' ') << kind_to_string(kind()) << std::endl; } -void ifcopenshell::geometry::taxonomy::matrix4::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::matrix4::print(std::ostream& o, int indent) const { print_impl(o, kind_to_string(kind()), indent); } -void ifcopenshell::geometry::taxonomy::colour::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::colour::print(std::ostream& o, int indent) const { print_impl(o, kind_to_string(kind()), indent); } -void ifcopenshell::geometry::taxonomy::style::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::style::print(std::ostream& o, int indent) const { o << std::string(indent, ' ') << "style" << std::endl; o << std::string(indent, ' ') << " " << "name " << (name) << std::endl; if (diffuse.components_) { @@ -618,29 +618,29 @@ void ifcopenshell::geometry::taxonomy::style::print(std::ostream& o, int indent) // @todo } -void ifcopenshell::geometry::taxonomy::point3::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::point3::print(std::ostream& o, int indent) const { print_impl(o, kind_to_string(kind()), indent); } -void ifcopenshell::geometry::taxonomy::direction3::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::direction3::print(std::ostream& o, int indent) const { print_impl(o, kind_to_string(kind()), indent); } -void ifcopenshell::geometry::taxonomy::line::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::line::print(std::ostream& o, int indent) const { print_impl(o, kind_to_string(kind()), indent); } -void ifcopenshell::geometry::taxonomy::circle::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::circle::print(std::ostream& o, int indent) const { print_impl(o, kind_to_string(kind()), indent); o << std::string(indent + 4, ' ') << "radius " << radius << std::endl; } -void ifcopenshell::geometry::taxonomy::ellipse::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::ellipse::print(std::ostream& o, int indent) const { print_impl(o, kind_to_string(kind()), indent); o << std::string(indent + 4, ' ') << "radii " << radius << " " << radius2 << std::endl; } -void ifcopenshell::geometry::taxonomy::trimmed_curve::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::trimmed_curve::print(std::ostream& o, int indent) const { o << std::string(indent, ' ') << kind_to_string(kind()); if (!this->orientation.value_or(true)) { o << " [R]"; @@ -674,13 +674,13 @@ void ifcopenshell::geometry::taxonomy::trimmed_curve::print(std::ostream& o, int } } -void ifcopenshell::geometry::taxonomy::extrusion::print(std::ostream& o, int indent) const { +void ifcopenshell::geom::taxonomy::extrusion::print(std::ostream& o, int indent) const { o << std::string(indent, ' ') << "extrusion " << depth << std::endl; direction->print(o, indent + 4); basis->print(o, indent + 4); } -std::optional ifcopenshell::geometry::taxonomy::loop_to_face_upgrade_impl(ptr item) { +std::optional ifcopenshell::geom::taxonomy::loop_to_face_upgrade_impl(ptr item) { std::optional face_; auto loop_ = dcast(item); if (loop_) { @@ -694,7 +694,7 @@ std::optional ifcopenshell::geometry::taxonomy::loop_to_face_upgrade_ return face_; } -std::optional ifcopenshell::geometry::taxonomy::curve_to_edge_upgrade_impl(ptr item) { +std::optional ifcopenshell::geom::taxonomy::curve_to_edge_upgrade_impl(ptr item) { std::optional edge_; auto circle_ = dcast(item); auto ellipse_ = dcast(item); @@ -725,7 +725,7 @@ std::optional ifcopenshell::geometry::taxonomy::curve_to_edge_upgrade return edge_; } -std::optional ifcopenshell::geometry::taxonomy::curve_to_loop_upgrade_impl(ptr item) { +std::optional ifcopenshell::geom::taxonomy::curve_to_loop_upgrade_impl(ptr item) { std::optional loop_; auto circle_ = dcast(item); auto ellipse_ = dcast(item); @@ -755,7 +755,7 @@ std::optional ifcopenshell::geometry::taxonomy::curve_to_loop_upgrade return loop_; } -std::optional ifcopenshell::geometry::taxonomy::edge_to_loop_upgrade_impl(ptr item) { +std::optional ifcopenshell::geom::taxonomy::edge_to_loop_upgrade_impl(ptr item) { std::optional loop_; auto edge_ = dcast(item); if (edge_) { @@ -765,7 +765,7 @@ std::optional ifcopenshell::geometry::taxonomy::edge_to_loop_upgrade_ return loop_; } -std::optional ifcopenshell::geometry::taxonomy::curve_to_face_upgrade_impl(ptr item) { +std::optional ifcopenshell::geom::taxonomy::curve_to_face_upgrade_impl(ptr item) { std::optional face_; auto circle_ = dcast(item); auto ellipse_ = dcast(item); @@ -821,7 +821,7 @@ namespace { } -std::optional ifcopenshell::geometry::taxonomy::loop_to_function_item_upgrade_impl(ptr item) { +std::optional ifcopenshell::geom::taxonomy::loop_to_function_item_upgrade_impl(ptr item) { std::optional fi_; auto loop_ = dcast(item); if (loop_) { @@ -861,7 +861,7 @@ std::optional ifcopenshell::geometry::taxonomy::loop_to_func spans.emplace_back(taxonomy::make(l, fn)); } else if (edge_->start.index() == 1 && edge_->end.index() == 1) { if (edge_->basis && edge_->basis->kind() != LINE) { - ::logger::root().message(::logger::Severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge"); + ::logger::root().message(::logger::severity::LOG_WARNING, "UNS", 20, "Basis curve not supported - edge is treated as a straight line edge"); } const auto& s = std::get(edge_->start)->ccomponents(); const auto& e = std::get(edge_->end)->ccomponents(); @@ -876,7 +876,7 @@ std::optional ifcopenshell::geometry::taxonomy::loop_to_func }; spans.emplace_back(taxonomy::make(l, fn)); } else { - ::logger::root().message(::logger::Severity::LOG_ERROR, "UNS", 21, "Basis curve not supported"); + ::logger::root().message(::logger::severity::LOG_ERROR, "UNS", 21, "Basis curve not supported"); return std::nullopt; } } diff --git a/src/ifcgeom/taxonomy.h b/src/ifcgeom/taxonomy.h index 75cdc6951c..0545804d03 100644 --- a/src/ifcgeom/taxonomy.h +++ b/src/ifcgeom/taxonomy.h @@ -41,7 +41,7 @@ namespace boost { inline std::size_t hash_value(const blank&) { return 0; } } namespace ifcopenshell { - namespace geometry { + namespace geom { namespace taxonomy { @@ -113,7 +113,7 @@ typedef item const* ptr; // Implementer note: If you add a new item type, be sure to do the following // 1) Add a new kind to this list // 2) Update the values array used by kind_to_string() - // 3) Update the KindsTuple with the class name of the new item + // 3) Update the kinds_tuple with the class name of the new item // 4) Add compare function (see compare functions in taxonomy.cpp starting around line 9) // 4) Update Python bindings // a) update list of assign_repr in IfcGeomWrapper.i @@ -165,7 +165,7 @@ typedef item const* ptr; public: DECLARE_PTR(item) - express::Base instance; + express::base instance; std::optional orientation; @@ -185,7 +185,7 @@ typedef item const* ptr; return computed_hash_; } - item(const express::Base& instance = express::Base()) : identity_(counter_++), computed_hash_(0), instance(instance) {} + item(const express::base& instance = express::base()) : identity_(counter_++), computed_hash_(0), instance(instance) {} virtual ~item() {} @@ -416,8 +416,8 @@ typedef item const* ptr; style::ptr surface_style; matrix4::ptr matrix; - geom_item(const express::Base& instance = express::Base()) : item(instance), surface_style(nullptr) {} - geom_item(const express::Base instance, matrix4::ptr m) : item(instance), surface_style(nullptr), matrix(m) {} + geom_item(const express::base& instance = express::base()) : item(instance), surface_style(nullptr) {} + geom_item(const express::base instance, matrix4::ptr m) : item(instance), surface_style(nullptr), matrix(m) {} geom_item(matrix4::ptr m) : surface_style(nullptr), matrix(m) {} }; @@ -429,7 +429,7 @@ typedef item const* ptr; struct IFC_GEOM_API function_item : public implicit_item { DECLARE_PTR(function_item) - function_item(const express::Base& instance = express::Base()) : implicit_item(instance) {} + function_item(const express::base& instance = express::base()) : implicit_item(instance) {} function_item(function_item&&) = default; function_item(const function_item&) = default; @@ -450,7 +450,7 @@ typedef item const* ptr; struct IFC_GEOM_API functor_item : public function_item { DECLARE_PTR(functor_item) - functor_item(double length, std::function fn, const express::Base& instance = express::Base()) : function_item(instance), + functor_item(double length, std::function fn, const express::base& instance = express::base()) : function_item(instance), length_(length), fn_(fn) {} functor_item(functor_item&&) = default; functor_item(const functor_item&) = default; @@ -478,8 +478,8 @@ typedef item const* ptr; using spans_t = std::vector; - piecewise_function(double start, const spans_t& s, const express::Base& instance = express::Base()); - piecewise_function(double start, const std::vector& pwfs, const express::Base& instance = express::Base()); + piecewise_function(double start, const spans_t& s, const express::base& instance = express::base()); + piecewise_function(double start, const std::vector& pwfs, const express::base& instance = express::base()); piecewise_function(piecewise_function&&) = default; piecewise_function(const piecewise_function&) = default; virtual ~piecewise_function() = default; @@ -507,7 +507,7 @@ typedef item const* ptr; struct IFC_GEOM_API gradient_function : public function_item { DECLARE_PTR(gradient_function) - gradient_function(piecewise_function::const_ptr horizontal, piecewise_function::const_ptr vertical, const express::Base& instance = express::Base()); + gradient_function(piecewise_function::const_ptr horizontal, piecewise_function::const_ptr vertical, const express::base& instance = express::base()); gradient_function(gradient_function&&) = default; gradient_function(const gradient_function&) = default; virtual ~gradient_function() = default; @@ -533,7 +533,7 @@ typedef item const* ptr; struct IFC_GEOM_API cant_function : public function_item { DECLARE_PTR(cant_function) - cant_function(gradient_function::const_ptr gradient, piecewise_function::const_ptr cant, const express::Base& instance = express::Base()); + cant_function(gradient_function::const_ptr gradient, piecewise_function::const_ptr cant, const express::base& instance = express::base()); cant_function(cant_function&&) = default; cant_function(const cant_function&) = default; virtual ~cant_function() = default; @@ -560,7 +560,7 @@ typedef item const* ptr; struct IFC_GEOM_API offset_function : public function_item { DECLARE_PTR(offset_function) - offset_function(function_item::const_ptr basis, piecewise_function::const_ptr offset, const express::Base& instance = express::Base()); + offset_function(function_item::const_ptr basis, piecewise_function::const_ptr offset, const express::base& instance = express::base()); offset_function(offset_function&&) = default; offset_function(const offset_function&) = default; virtual ~offset_function() = default; @@ -1292,38 +1292,38 @@ typedef item const* ptr; }; namespace impl { - typedef std::tuple KindsTuple; - typedef std::tuple CurvesTuple; - typedef std::tuple SurfacesTuple; - typedef std::tuple UpgradesTuple; + typedef std::tuple kinds_tuple; + typedef std::tuple curves_tuple; + typedef std::tuple surfaces_tuple; + typedef std::tuple upgrades_tuple; } struct type_by_kind { template - using type = typename std::tuple_element::type; + using type = typename std::tuple_element::type; - static const size_t max = std::tuple_size::value; + static const size_t max = std::tuple_size::value; }; struct curves { template - using type = typename std::tuple_element::type; + using type = typename std::tuple_element::type; - static const size_t max = std::tuple_size::value; + static const size_t max = std::tuple_size::value; }; struct surfaces { template - using type = typename std::tuple_element::type; + using type = typename std::tuple_element::type; - static const size_t max = std::tuple_size::value; + static const size_t max = std::tuple_size::value; }; struct upgrades { template - using type = typename std::tuple_element::type; + using type = typename std::tuple_element::type; - static const size_t max = std::tuple_size::value; + static const size_t max = std::tuple_size::value; }; IFC_GEOM_API std::optional loop_to_face_upgrade_impl(ptr item); @@ -1630,19 +1630,19 @@ typedef item const* ptr; // @todo Sad... now that we have templated collection members, // we can't generally use collection_base anymore as a cast target. if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geometry::visit(s, fn); + ifcopenshell::geom::visit(s, fn); } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geometry::visit(s, fn); + ifcopenshell::geom::visit(s, fn); } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geometry::visit(s, fn); + ifcopenshell::geom::visit(s, fn); } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geometry::visit(s, fn); + ifcopenshell::geom::visit(s, fn); } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geometry::visit(s, fn); + ifcopenshell::geom::visit(s, fn); } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geometry::visit(s, fn); + ifcopenshell::geom::visit(s, fn); } else if (auto s = std::dynamic_pointer_cast(i)) { - ifcopenshell::geometry::visit(s, fn); + ifcopenshell::geom::visit(s, fn); } else { fn(i); @@ -1741,8 +1741,8 @@ typedef item const* ptr; struct IFC_GEOM_API layerset_information { std::vector thicknesses; - std::vector layers; - std::vector styles; + std::vector layers; + std::vector styles; }; enum connection_type { @@ -1752,7 +1752,7 @@ typedef item const* ptr; NOTDEFINED }; - typedef std::tuple endpoint_connection; + typedef std::tuple endpoint_connection; } } diff --git a/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp b/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp index 5090961a8b..6d072318b8 100644 --- a/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp +++ b/src/ifcgeom/tests/test_ifcopenshell_geometry.cpp @@ -57,13 +57,13 @@ IfcSchema::IfcWallStandardCase create_wall_with_voids(hierarchy_helper& file, const IfcSchema::IfcWallStandardCase& wall) { - ifcopenshell::geometry::Settings settings; + ifcopenshell::geom::settings settings; settings.set("max-voids-per-element", MAX_VOIDS); logger log; log.output_format(logger::FMT_INMEMORY); - ifcopenshell::geometry::Converter converter( - ifcopenshell::geometry::kernels::construct(&file, "opencascade", settings), &file, settings, log); + ifcopenshell::geom::converter converter( + ifcopenshell::geom::kernels::construct(&file, "opencascade", settings), &file, settings, log); delete converter.create_brep_for_representation_and_product(wall.Representation().Representations().back(), wall); return log.count("GEO403"); } @@ -88,13 +88,13 @@ IfcSchema::IfcRepresentation select_representation( const IfcSchema::IfcWallStandardCase& wall, const std::vector& context_priorities) { - ifcopenshell::geometry::Settings settings; + ifcopenshell::geom::settings settings; settings.set("context-priorities", std::vector(context_priorities)); logger log; log.output_format(logger::FMT_INMEMORY); - ifcopenshell::geometry::Converter converter( - ifcopenshell::geometry::kernels::construct(&file, "passthrough", settings), &file, settings, log); + ifcopenshell::geom::converter converter( + ifcopenshell::geom::kernels::construct(&file, "passthrough", settings), &file, settings, log); auto selected = converter.mapping()->representation_of(wall).as(); REQUIRE(selected); @@ -116,30 +116,30 @@ IfcSchema::IfcWallStandardCase add_wall_with_representations( return wall; } -std::vector representation_tasks( +std::vector representation_tasks( hierarchy_helper& file, const std::vector& context_priorities) { - ifcopenshell::geometry::Settings settings; + ifcopenshell::geom::settings settings; settings.set("context-priorities", std::vector(context_priorities)); logger log; log.output_format(logger::FMT_INMEMORY); - ifcopenshell::geometry::Converter converter( - ifcopenshell::geometry::kernels::construct(&file, "passthrough", settings), &file, settings, log); + ifcopenshell::geom::converter converter( + ifcopenshell::geom::kernels::construct(&file, "passthrough", settings), &file, settings, log); - std::vector tasks; - std::vector filters; + std::vector tasks; + std::vector filters; converter.mapping()->get_representations(tasks, filters); return tasks; } -const ifcopenshell::geometry::geometry_conversion_task* task_for_product( - const std::vector& tasks, - const express::Base& product) +const ifcopenshell::geom::geometry_conversion_task* task_for_product( + const std::vector& tasks, + const express::base& product) { for (const auto& task : tasks) { - if (std::any_of(task.products.begin(), task.products.end(), [&](const express::Base& task_product) { + if (std::any_of(task.products.begin(), task.products.end(), [&](const express::base& task_product) { return task_product.id() == product.id(); })) { return &task; diff --git a/src/ifcgeom/tree.cpp b/src/ifcgeom/tree.cpp index f391bf518f..c9f8ca40df 100644 --- a/src/ifcgeom/tree.cpp +++ b/src/ifcgeom/tree.cpp @@ -38,13 +38,13 @@ namespace { return values; } - const std::vector& empty_style_vector() { - static const std::vector values; + const std::vector& empty_style_vector() { + static const std::vector values; return values; } - std::vector to_product_entities(const std::vector& instances) { - std::vector entities; + std::vector to_product_entities(const std::vector& instances) { + std::vector entities; entities.reserve(instances.size()); for (const auto& instance : instances) { @@ -52,7 +52,7 @@ namespace { throw ifcopenshell::exception("All instances should be of type IfcProduct"); } - auto entity = instance.as(); + auto entity = instance.as(); if (!entity || !instance.declaration().is("IfcProduct")) { throw ifcopenshell::exception("All instances should be of type IfcProduct"); } @@ -63,7 +63,7 @@ namespace { } } -class IfcGeom::tree::impl { +class ifcopenshell::geom::tree::impl { public: impl() = default; @@ -71,81 +71,81 @@ public: : backend_id_(backend_id) {} - ifcopenshell::geometry::trees::abstract_tree& backend() const { + ifcopenshell::geom::trees::abstract_tree& backend() const { if (!backend_) { if (backend_id_.empty()) { throw ifcopenshell::exception("No geometry tree backend configured"); } - backend_ = ifcopenshell::geometry::trees::construct(backend_id_); + backend_ = ifcopenshell::geom::trees::construct(backend_id_); } return *backend_; } - ifcopenshell::geometry::trees::abstract_tree& backend(const std::string& default_backend_id) const { + ifcopenshell::geom::trees::abstract_tree& backend(const std::string& default_backend_id) const { if (backend_id_.empty()) { backend_id_ = default_backend_id; } return backend(); } - ifcopenshell::geometry::trees::abstract_tree& backend_for_element(IfcGeom::Element* element) const { - if (dynamic_cast(element)) { + ifcopenshell::geom::trees::abstract_tree& backend_for_element(ifcopenshell::geom::element* element) const { + if (dynamic_cast(element)) { return backend(default_selection_backend_id); } - if (dynamic_cast(element)) { + if (dynamic_cast(element)) { return backend(default_clash_backend_id); } throw ifcopenshell::exception("Unsupported tree element type"); } - const ifcopenshell::geometry::trees::abstract_tree* backend_or_null() const { + const ifcopenshell::geom::trees::abstract_tree* backend_or_null() const { return backend_.get(); } private: mutable std::string backend_id_; - mutable std::unique_ptr backend_; + mutable std::unique_ptr backend_; }; -IfcGeom::tree::tree() +ifcopenshell::geom::tree::tree() : impl_(new impl()) {} -IfcGeom::tree::tree(const std::string& backend_id) +ifcopenshell::geom::tree::tree(const std::string& backend_id) : impl_(new impl(backend_id)) {} -IfcGeom::tree::tree(ifcopenshell::file& file) +ifcopenshell::geom::tree::tree(ifcopenshell::file& file) : tree() { - add_file(file, ifcopenshell::geometry::Settings{}); + add_file(file, ifcopenshell::geom::settings{}); } -IfcGeom::tree::tree(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings) +ifcopenshell::geom::tree::tree(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings) : tree() { add_file(file, settings); } -IfcGeom::tree::tree(IfcGeom::Iterator& iterator) +ifcopenshell::geom::tree::tree(ifcopenshell::geom::iterator& iterator) : tree() { add_file(iterator); } -IfcGeom::tree::~tree() = default; +ifcopenshell::geom::tree::~tree() = default; -IfcGeom::tree::tree(tree&& other) noexcept = default; +ifcopenshell::geom::tree::tree(tree&& other) noexcept = default; -IfcGeom::tree& IfcGeom::tree::operator=(tree&& other) noexcept = default; +ifcopenshell::geom::tree& ifcopenshell::geom::tree::operator=(tree&& other) noexcept = default; -void IfcGeom::tree::add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings) { +void ifcopenshell::geom::tree::add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings) { impl_->backend(default_selection_backend_id).add_file(file, settings); } -void IfcGeom::tree::add_file(IfcGeom::Iterator& iterator) { +void ifcopenshell::geom::tree::add_file(ifcopenshell::geom::iterator& iterator) { if (!iterator.initialize()) { return; } @@ -155,7 +155,7 @@ void IfcGeom::tree::add_file(IfcGeom::Iterator& iterator) { } while (iterator.next()); } -void IfcGeom::tree::add_element(IfcGeom::Element* element) { +void ifcopenshell::geom::tree::add_element(ifcopenshell::geom::element* element) { if (!element) { return; } @@ -163,71 +163,71 @@ void IfcGeom::tree::add_element(IfcGeom::Element* element) { impl_->backend_for_element(element).add_element(element); } -std::vector IfcGeom::tree::select_box(const express::Entity& entity, bool completely_within, double extend) const { +std::vector ifcopenshell::geom::tree::select_box(const express::entity& entity, bool completely_within, double extend) const { return impl_->backend(default_selection_backend_id).select_box(entity, completely_within, extend); } -std::vector IfcGeom::tree::select_box(const tree_point& point) const { +std::vector ifcopenshell::geom::tree::select_box(const tree_point& point) const { return impl_->backend(default_selection_backend_id).select_box(point); } -std::vector IfcGeom::tree::select_box(const tree_box& bounds, bool completely_within) const { +std::vector ifcopenshell::geom::tree::select_box(const tree_box& bounds, bool completely_within) const { return impl_->backend(default_selection_backend_id).select_box(bounds, completely_within); } -std::vector IfcGeom::tree::select(const express::Entity& entity, bool completely_within, double extend) const { +std::vector ifcopenshell::geom::tree::select(const express::entity& entity, bool completely_within, double extend) const { return impl_->backend(default_selection_backend_id).select(entity, completely_within, extend); } -std::vector IfcGeom::tree::select(const IfcGeom::Element* element, bool completely_within, double extend) const { +std::vector ifcopenshell::geom::tree::select(const ifcopenshell::geom::element* element, bool completely_within, double extend) const { return impl_->backend(default_selection_backend_id).select(element, completely_within, extend); } -std::vector IfcGeom::tree::select(const tree_point& point, double extend) const { +std::vector ifcopenshell::geom::tree::select(const tree_point& point, double extend) const { return impl_->backend(default_selection_backend_id).select(point, extend); } -std::vector IfcGeom::tree::select_ray(const tree_point& origin, const tree_point& direction, double length) const { +std::vector ifcopenshell::geom::tree::select_ray(const tree_point& origin, const tree_point& direction, double length) const { return impl_->backend(default_selection_backend_id).select_ray(origin, direction, length); } -std::vector IfcGeom::tree::clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance, bool check_all) const { +std::vector ifcopenshell::geom::tree::clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance, bool check_all) const { return impl_->backend(default_clash_backend_id).clash_intersection_many(to_product_entities(set_a), to_product_entities(set_b), tolerance, check_all); } -std::vector IfcGeom::tree::clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching) const { +std::vector ifcopenshell::geom::tree::clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching) const { return impl_->backend(default_clash_backend_id).clash_collision_many(to_product_entities(set_a), to_product_entities(set_b), allow_touching); } -std::vector IfcGeom::tree::clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance, bool check_all) const { +std::vector ifcopenshell::geom::tree::clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance, bool check_all) const { return impl_->backend(default_clash_backend_id).clash_clearance_many(to_product_entities(set_a), to_product_entities(set_b), clearance, check_all); } -const std::vector& IfcGeom::tree::distances() const { +const std::vector& ifcopenshell::geom::tree::distances() const { const auto* backend = impl_->backend_or_null(); return backend ? backend->distances() : empty_double_vector(); } -const std::vector& IfcGeom::tree::protrusion_distances() const { +const std::vector& ifcopenshell::geom::tree::protrusion_distances() const { const auto* backend = impl_->backend_or_null(); return backend ? backend->protrusion_distances() : empty_double_vector(); } -bool IfcGeom::tree::enable_face_styles() const { +bool ifcopenshell::geom::tree::enable_face_styles() const { const auto* backend = impl_->backend_or_null(); return backend ? backend->enable_face_styles() : false; } -void IfcGeom::tree::enable_face_styles(bool enable) { +void ifcopenshell::geom::tree::enable_face_styles(bool enable) { impl_->backend(default_selection_backend_id).enable_face_styles(enable); } -const std::vector& IfcGeom::tree::styles() const { +const std::vector& ifcopenshell::geom::tree::styles() const { const auto* backend = impl_->backend_or_null(); return backend ? backend->styles() : empty_style_vector(); } -std::string IfcGeom::tree::uint8_to_b64(const std::vector& uuids_array) const { +std::string ifcopenshell::geom::tree::uint8_to_b64(const std::vector& uuids_array) const { std::string hex_str; hex_str.reserve(uuids_array.size() * 2); @@ -240,7 +240,7 @@ std::string IfcGeom::tree::uint8_to_b64(const std::vector& uuids_array) return hex_str; } -bool IfcGeom::tree::is_manifold(const std::vector& faces) { +bool ifcopenshell::geom::tree::is_manifold(const std::vector& faces) { std::unordered_set, boost::hash>> directed_edges; for (size_t i = 0; i < faces.size(); i += 3) { diff --git a/src/ifcgeom/tree.h b/src/ifcgeom/tree.h index 43a1558969..1365e01bb1 100644 --- a/src/ifcgeom/tree.h +++ b/src/ifcgeom/tree.h @@ -31,13 +31,13 @@ namespace ifcopenshell { class file; - namespace geometry { - class Settings; + namespace geom { + class settings; } } -namespace IfcGeom { - class Iterator; +namespace ifcopenshell::geom { + class iterator; using tree_point = std::array; using tree_box = std::array; @@ -45,7 +45,7 @@ namespace IfcGeom { struct IFC_GEOM_API ray_intersection_result { double distance; int style_index; - express::Entity instance; + express::entity instance; tree_point position; tree_point normal; double ray_distance; @@ -54,8 +54,8 @@ namespace IfcGeom { struct IFC_GEOM_API clash { int clash_type; - express::Base a; - express::Base b; + express::base a; + express::base b; double distance; tree_point p1; tree_point p2; @@ -66,8 +66,8 @@ namespace IfcGeom { tree(); explicit tree(const std::string& backend_id); explicit tree(ifcopenshell::file& file); - tree(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings); - explicit tree(IfcGeom::Iterator& iterator); + tree(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings); + explicit tree(ifcopenshell::geom::iterator& iterator); ~tree(); tree(tree&& other) noexcept; @@ -76,29 +76,29 @@ namespace IfcGeom { tree(const tree& other) = delete; tree& operator=(const tree& other) = delete; - void add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings); - void add_file(IfcGeom::Iterator& iterator); - void add_element(IfcGeom::Element* element); + void add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings); + void add_file(ifcopenshell::geom::iterator& iterator); + void add_element(ifcopenshell::geom::element* element); - std::vector select_box(const express::Entity& entity, bool completely_within = false, double extend = -1.e-5) const; - std::vector select_box(const tree_point& point) const; - std::vector select_box(const tree_box& bounds, bool completely_within = false) const; + std::vector select_box(const express::entity& entity, bool completely_within = false, double extend = -1.e-5) const; + std::vector select_box(const tree_point& point) const; + std::vector select_box(const tree_box& bounds, bool completely_within = false) const; - std::vector select(const express::Entity& entity, bool completely_within = false, double extend = 0.0) const; - std::vector select(const IfcGeom::Element* element, bool completely_within = false, double extend = -1.e-5) const; - std::vector select(const tree_point& point, double extend = 0.0) const; + std::vector select(const express::entity& entity, bool completely_within = false, double extend = 0.0) const; + std::vector select(const ifcopenshell::geom::element* element, bool completely_within = false, double extend = -1.e-5) const; + std::vector select(const tree_point& point, double extend = 0.0) const; std::vector select_ray(const tree_point& origin, const tree_point& direction, double length = 1000.) const; - std::vector clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance = 0.002, bool check_all = true) const; - std::vector clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching = false) const; - std::vector clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance = 0.05, bool check_all = false) const; + std::vector clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance = 0.002, bool check_all = true) const; + std::vector clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching = false) const; + std::vector clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance = 0.05, bool check_all = false) const; const std::vector& distances() const; const std::vector& protrusion_distances() const; bool enable_face_styles() const; void enable_face_styles(bool enable); - const std::vector& styles() const; + const std::vector& styles() const; std::string uint8_to_b64(const std::vector& uuids_array) const; static bool is_manifold(const std::vector& faces); diff --git a/src/ifcgeom/tree_plugin.cpp b/src/ifcgeom/tree_plugin.cpp index c5ee31a58a..506fbf0ddb 100644 --- a/src/ifcgeom/tree_plugin.cpp +++ b/src/ifcgeom/tree_plugin.cpp @@ -31,22 +31,22 @@ namespace { constexpr const char* tree_plugin_prefix = "geometry.tree."; } -const char* ifcopenshell::geometry::trees::tree_plugin_registration_symbol() { +const char* ifcopenshell::geom::trees::tree_plugin_registration_symbol() { return "ifcopenshell_register_tree_plugin_v1"; } -ifcopenshell::plugin::metadata ifcopenshell::geometry::trees::tree_plugin_metadata(const std::string& plugin_name) { +ifcopenshell::plugin::metadata ifcopenshell::geom::trees::tree_plugin_metadata(const std::string& plugin_name) { plugin::metadata metadata; metadata.kind_ = plugin::kind::tree; metadata.id = std::string(tree_plugin_prefix) + plugin_name; return metadata; } -std::filesystem::path ifcopenshell::geometry::trees::tree_plugin_directory() { - return plugin::module_directory(reinterpret_cast(&ifcopenshell::geometry::trees::load_tree_plugins)); +std::filesystem::path ifcopenshell::geom::trees::tree_plugin_directory() { + return plugin::module_directory(reinterpret_cast(&ifcopenshell::geom::trees::load_tree_plugins)); } -void ifcopenshell::geometry::trees::load_tree_plugins(tree_registry& registry) { +void ifcopenshell::geom::trees::load_tree_plugins(tree_registry& registry) { plugin::manager manager; plugin::add_search_paths_or_default(manager, &tree_plugin_directory); @@ -61,7 +61,7 @@ void ifcopenshell::geometry::trees::load_tree_plugins(tree_registry& registry) { } } -bool ifcopenshell::geometry::trees::load_tree_plugin(tree_registry& registry, const std::string& backend_id) { +bool ifcopenshell::geom::trees::load_tree_plugin(tree_registry& registry, const std::string& backend_id) { plugin::manager manager; plugin::add_search_paths_or_default(manager, &tree_plugin_directory); diff --git a/src/ifcgeom/tree_plugin.h b/src/ifcgeom/tree_plugin.h index 818883d4c8..9ce954cbbf 100644 --- a/src/ifcgeom/tree_plugin.h +++ b/src/ifcgeom/tree_plugin.h @@ -25,7 +25,7 @@ #include namespace ifcopenshell { - namespace geometry { + namespace geom { namespace trees { typedef void register_tree_plugin_fn(tree_registry&, const ifcopenshell::plugin::module&); diff --git a/src/ifcgeom/tree_registry.cpp b/src/ifcgeom/tree_registry.cpp index 57cd05719e..df54aa7cb4 100644 --- a/src/ifcgeom/tree_registry.cpp +++ b/src/ifcgeom/tree_registry.cpp @@ -34,77 +34,77 @@ namespace { } } -ifcopenshell::geometry::trees::abstract_tree::~abstract_tree() = default; +ifcopenshell::geom::trees::abstract_tree::~abstract_tree() = default; -void ifcopenshell::geometry::trees::abstract_tree::add_file(ifcopenshell::file&, const ifcopenshell::geometry::Settings&) { +void ifcopenshell::geom::trees::abstract_tree::add_file(ifcopenshell::file&, const ifcopenshell::geom::settings&) { unsupported_tree_operation(std::string(backend_id()), "add_file()"); } -void ifcopenshell::geometry::trees::abstract_tree::add_element(IfcGeom::Element*) { +void ifcopenshell::geom::trees::abstract_tree::add_element(ifcopenshell::geom::element*) { unsupported_tree_operation(std::string(backend_id()), "add_element()"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::select_box(const express::Entity&, bool, double) const { +std::vector ifcopenshell::geom::trees::abstract_tree::select_box(const express::entity&, bool, double) const { unsupported_tree_operation(std::string(backend_id()), "select_box(entity)"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::select_box(const IfcGeom::tree_point&) const { +std::vector ifcopenshell::geom::trees::abstract_tree::select_box(const ifcopenshell::geom::tree_point&) const { unsupported_tree_operation(std::string(backend_id()), "select_box(point)"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::select_box(const IfcGeom::tree_box&, bool) const { +std::vector ifcopenshell::geom::trees::abstract_tree::select_box(const ifcopenshell::geom::tree_box&, bool) const { unsupported_tree_operation(std::string(backend_id()), "select_box(bounds)"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::select(const express::Entity&, bool, double) const { +std::vector ifcopenshell::geom::trees::abstract_tree::select(const express::entity&, bool, double) const { unsupported_tree_operation(std::string(backend_id()), "select(entity)"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::select(const IfcGeom::Element*, bool, double) const { +std::vector ifcopenshell::geom::trees::abstract_tree::select(const ifcopenshell::geom::element*, bool, double) const { unsupported_tree_operation(std::string(backend_id()), "select(element)"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::select(const IfcGeom::tree_point&, double) const { +std::vector ifcopenshell::geom::trees::abstract_tree::select(const ifcopenshell::geom::tree_point&, double) const { unsupported_tree_operation(std::string(backend_id()), "select(point)"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::select_ray(const IfcGeom::tree_point&, const IfcGeom::tree_point&, double) const { +std::vector ifcopenshell::geom::trees::abstract_tree::select_ray(const ifcopenshell::geom::tree_point&, const ifcopenshell::geom::tree_point&, double) const { unsupported_tree_operation(std::string(backend_id()), "select_ray()"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::clash_intersection_many(const std::vector&, const std::vector&, double, bool) const { +std::vector ifcopenshell::geom::trees::abstract_tree::clash_intersection_many(const std::vector&, const std::vector&, double, bool) const { unsupported_tree_operation(std::string(backend_id()), "clash_intersection_many()"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::clash_collision_many(const std::vector&, const std::vector&, bool) const { +std::vector ifcopenshell::geom::trees::abstract_tree::clash_collision_many(const std::vector&, const std::vector&, bool) const { unsupported_tree_operation(std::string(backend_id()), "clash_collision_many()"); } -std::vector ifcopenshell::geometry::trees::abstract_tree::clash_clearance_many(const std::vector&, const std::vector&, double, bool) const { +std::vector ifcopenshell::geom::trees::abstract_tree::clash_clearance_many(const std::vector&, const std::vector&, double, bool) const { unsupported_tree_operation(std::string(backend_id()), "clash_clearance_many()"); } -const std::vector& ifcopenshell::geometry::trees::abstract_tree::distances() const { +const std::vector& ifcopenshell::geom::trees::abstract_tree::distances() const { unsupported_tree_operation(std::string(backend_id()), "distances()"); } -const std::vector& ifcopenshell::geometry::trees::abstract_tree::protrusion_distances() const { +const std::vector& ifcopenshell::geom::trees::abstract_tree::protrusion_distances() const { unsupported_tree_operation(std::string(backend_id()), "protrusion_distances()"); } -bool ifcopenshell::geometry::trees::abstract_tree::enable_face_styles() const { +bool ifcopenshell::geom::trees::abstract_tree::enable_face_styles() const { unsupported_tree_operation(std::string(backend_id()), "enable_face_styles()"); } -void ifcopenshell::geometry::trees::abstract_tree::enable_face_styles(bool) { +void ifcopenshell::geom::trees::abstract_tree::enable_face_styles(bool) { unsupported_tree_operation(std::string(backend_id()), "enable_face_styles(bool)"); } -const std::vector& ifcopenshell::geometry::trees::abstract_tree::styles() const { +const std::vector& ifcopenshell::geom::trees::abstract_tree::styles() const { unsupported_tree_operation(std::string(backend_id()), "styles()"); } -void ifcopenshell::geometry::trees::tree_registry::bind(const tree_info& info, create_fn create, const plugin::module& module) { +void ifcopenshell::geom::trees::tree_registry::bind(const tree_info& info, create_fn create, const plugin::module& module) { entry entry; entry.info_ = info; entry.create_ = create; @@ -112,11 +112,11 @@ void ifcopenshell::geometry::trees::tree_registry::bind(const tree_info& info, c entries_[tree_key(info.backend_id)] = entry; } -bool ifcopenshell::geometry::trees::tree_registry::has(const std::string& backend_id) const { +bool ifcopenshell::geom::trees::tree_registry::has(const std::string& backend_id) const { return entries_.find(tree_key(backend_id)) != entries_.end(); } -std::unique_ptr ifcopenshell::geometry::trees::tree_registry::create(const std::string& backend_id) const { +std::unique_ptr ifcopenshell::geom::trees::tree_registry::create(const std::string& backend_id) const { const auto iter = entries_.find(tree_key(backend_id)); if (iter == entries_.end()) { throw ifcopenshell::exception("No geometry tree registered for " + backend_id); @@ -124,12 +124,12 @@ std::unique_ptr ifcopenshell::geom return std::unique_ptr(iter->second.create_()); } -ifcopenshell::geometry::trees::tree_registry& ifcopenshell::geometry::trees::tree_registry_instance() { +ifcopenshell::geom::trees::tree_registry& ifcopenshell::geom::trees::tree_registry_instance() { static tree_registry registry; return registry; } -std::unique_ptr ifcopenshell::geometry::trees::construct(const std::string& backend_id) { +std::unique_ptr ifcopenshell::geom::trees::construct(const std::string& backend_id) { auto& registry = tree_registry_instance(); if (!registry.has(backend_id)) { load_tree_plugin(registry, backend_id); diff --git a/src/ifcgeom/tree_registry.h b/src/ifcgeom/tree_registry.h index 6d116f29c9..de431ef22c 100644 --- a/src/ifcgeom/tree_registry.h +++ b/src/ifcgeom/tree_registry.h @@ -33,8 +33,8 @@ namespace ifcopenshell { class file; - namespace geometry { - class Settings; + namespace geom { + class settings; namespace trees { @@ -48,27 +48,27 @@ namespace ifcopenshell { virtual std::string_view backend_id() const = 0; - virtual void add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings); - virtual void add_element(IfcGeom::Element* element); + virtual void add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings); + virtual void add_element(ifcopenshell::geom::element* element); - virtual std::vector select_box(const express::Entity& entity, bool completely_within, double extend) const; - virtual std::vector select_box(const IfcGeom::tree_point& point) const; - virtual std::vector select_box(const IfcGeom::tree_box& bounds, bool completely_within) const; + virtual std::vector select_box(const express::entity& entity, bool completely_within, double extend) const; + virtual std::vector select_box(const ifcopenshell::geom::tree_point& point) const; + virtual std::vector select_box(const ifcopenshell::geom::tree_box& bounds, bool completely_within) const; - virtual std::vector select(const express::Entity& entity, bool completely_within, double extend) const; - virtual std::vector select(const IfcGeom::Element* element, bool completely_within, double extend) const; - virtual std::vector select(const IfcGeom::tree_point& point, double extend) const; - virtual std::vector select_ray(const IfcGeom::tree_point& origin, const IfcGeom::tree_point& direction, double length) const; + virtual std::vector select(const express::entity& entity, bool completely_within, double extend) const; + virtual std::vector select(const ifcopenshell::geom::element* element, bool completely_within, double extend) const; + virtual std::vector select(const ifcopenshell::geom::tree_point& point, double extend) const; + virtual std::vector select_ray(const ifcopenshell::geom::tree_point& origin, const ifcopenshell::geom::tree_point& direction, double length) const; - virtual std::vector clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance, bool check_all) const; - virtual std::vector clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching) const; - virtual std::vector clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance, bool check_all) const; + virtual std::vector clash_intersection_many(const std::vector& set_a, const std::vector& set_b, double tolerance, bool check_all) const; + virtual std::vector clash_collision_many(const std::vector& set_a, const std::vector& set_b, bool allow_touching) const; + virtual std::vector clash_clearance_many(const std::vector& set_a, const std::vector& set_b, double clearance, bool check_all) const; virtual const std::vector& distances() const; virtual const std::vector& protrusion_distances() const; virtual bool enable_face_styles() const; virtual void enable_face_styles(bool enable); - virtual const std::vector& styles() const; + virtual const std::vector& styles() const; }; diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index 8f46e73c37..d5c7ebbcc5 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -292,7 +292,7 @@ public: class Entity : public Command { private: - const IfcGeom::TriangulationElement* geom; + const ifcopenshell::geom::triangulation_element* geom; bool append_line_data; EntityExtension* eext_; protected: @@ -401,7 +401,7 @@ protected: } } public: - Entity(const IfcGeom::TriangulationElement* geom, EntityExtension* eext = 0) : Command(ENTITY), geom(geom), append_line_data(false), eext_(eext) {}; + Entity(const ifcopenshell::geom::triangulation_element* geom, EntityExtension* eext = 0) : Command(ENTITY), geom(geom), append_line_data(false), eext_(eext) {}; }; class Next : public Command { @@ -467,9 +467,9 @@ static const std::array XYZ = { "X", "Y", "Z" }; class QuantityWriter_v0 : public EntityExtension { private: - const IfcGeom::BRepElement* elem_; + const ifcopenshell::geom::brep_element* elem_; public: - QuantityWriter_v0(const IfcGeom::BRepElement* elem) : + QuantityWriter_v0(const ifcopenshell::geom::brep_element* elem) : elem_(elem) { put_json(TOTAL_SURFACE_AREA, 0.); @@ -482,9 +482,9 @@ public: class QuantityWriter_v1 : public EntityExtension { private: - const IfcGeom::BRepElement* elem_; + const ifcopenshell::geom::brep_element* elem_; public: - QuantityWriter_v1(const IfcGeom::BRepElement* elem) : + QuantityWriter_v1(const ifcopenshell::geom::brep_element* elem) : elem_(elem) { double a, b, c, largest_face_area = 0.; @@ -506,7 +506,7 @@ public: { auto shp = elem_->geometry().as_compound(true); - auto compound = ((ifcopenshell::geometry::OpenCascadeShape*)shp)->shape(); + auto compound = ((ifcopenshell::geom::open_cascade_shape*)shp)->shape(); delete shp; TopExp_Explorer exp(compound, TopAbs_FACE); for (; exp.More(); exp.Next()) { @@ -567,7 +567,7 @@ int main () { double deflection = 1.e-3; bool has_more = false; - IfcGeom::Iterator* iterator = 0; + ifcopenshell::geom::iterator* iterator = 0; ifcopenshell::file* file = 0; std::vector< std::pair > setting_pairs; @@ -583,18 +583,18 @@ int main () { char* data = new char[len]; memcpy(data, m.string().c_str(), len); - ifcopenshell::geometry::Settings settings; - settings.get().value = false; - settings.get().value = false; - settings.get().value = true; - // settings.set(IfcGeom::IteratorSettings::INCLUDE_CURVES, true); + ifcopenshell::geom::settings settings; + settings.get().value = false; + settings.get().value = false; + settings.get().value = true; + // settings.set(ifcopenshell::geom::IteratorSettings::INCLUDE_CURVES, true); /* // @todo std::vector< std::pair >::const_iterator it = setting_pairs.begin(); for (; it != setting_pairs.end(); ++it) { settings.get(it->first, it->second != 0); - if (it->first == IfcGeom::IteratorSettings::SEW_SHELLS && it->second) { + if (it->first == ifcopenshell::geom::IteratorSettings::SEW_SHELLS && it->second) { // Quantities (especially volume) can be emitted if there are proper // topologically valid geometries being created. emit_quantities = true; @@ -602,10 +602,10 @@ int main () { } */ - settings.get().value = deflection; + settings.get().value = deflection; file = new ifcopenshell::file(data, (int)len); - iterator = new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, "opencascade", settings), settings, file); + iterator = new ifcopenshell::geom::iterator(ifcopenshell::geom::kernels::construct(file, "opencascade", settings), settings, file); has_more = iterator->initialize(); More(has_more).write(std::cout); @@ -617,7 +617,7 @@ int main () { exit_code = 1; break; } - const IfcGeom::TriangulationElement* geom = static_cast(iterator->get()); + const ifcopenshell::geom::triangulation_element* geom = static_cast(iterator->get()); std::unique_ptr eext; if (emit_quantities) { eext.reset(new QuantityWriter_v1(iterator->get_native())); diff --git a/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst b/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst index 6058781de4..b0592968f5 100644 --- a/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst +++ b/src/ifcopenshell-python/docs/ifcopenshell-python/geometry_processing.rst @@ -307,8 +307,8 @@ Here is a typical example to serialising to glTF / glb. Example settings to serialise to other formats are shown commented out. Different serialisations may require different settings. -In addition to geometry settings, serialisation has its own set of -:doc:`../ifcopenshell/serialiser_settings`. +The same settings object also exposes the +:doc:`serialisation options <../ifcopenshell/serialiser_settings>`. .. code-block:: python @@ -331,15 +331,14 @@ In addition to geometry settings, serialisation has its own set of # settings.set("apply-default-materials", True) # settings.set("use-world-coords", True) - serialiser_settings = ifcopenshell.geom.serializer_settings() # Setting element GUIDs is optional, but useful to uniquely identify objects in non-semantic formats. - serialiser_settings.set("use-element-guids", True) + settings.set("use-element-guids", True) # Serialise to glTF / glb - serialiser = ifcopenshell.geom.serializers.gltf("output.glb", settings, serialiser_settings) + serialiser = ifcopenshell.geom.serializers.gltf("output.glb", settings) # Serialise to obj - # serialiser = ifcopenshell.geom.serializers.obj('output.obj', 'output.mtl', settings, serialiser_settings) + # serialiser = ifcopenshell.geom.serializers.obj('output.obj', 'output.mtl', settings) serialiser.setFile(ifc_file) serialiser.setUnitNameAndMagnitude("METER", 1.0) diff --git a/src/ifcopenshell-python/docs/ifcopenshell/geometry_settings.rst b/src/ifcopenshell-python/docs/ifcopenshell/geometry_settings.rst index 6862088c6c..bb2a4d1fed 100644 --- a/src/ifcopenshell-python/docs/ifcopenshell/geometry_settings.rst +++ b/src/ifcopenshell-python/docs/ifcopenshell/geometry_settings.rst @@ -10,8 +10,8 @@ Here's an example of changing settings in C++: .. code-block:: c++ - SerializerSettings settings; - settings.set(IfcGeom::IteratorSettings::APPLY_DEFAULT_MATERIALS, true); + ifcopenshell::geom::settings settings; + settings.get().value = true; Here's an example of changing settings in Python: @@ -78,7 +78,7 @@ In C++, this is set when the iterator is constructed: .. code-block:: c++ - IfcGeom::Iterator geom_iterator(settings, ifc_file, filter_funcs, num_threads); + ifcopenshell::geom::iterator geom_iterator(settings, ifc_file, filter_funcs, num_threads); In Python, this is set when the iterator is constructed, and requires a list of IFC entity instances: @@ -102,7 +102,7 @@ In C++, this is set when the iterator is constructed: .. code-block:: c++ - IfcGeom::Iterator geom_iterator(settings, ifc_file, filter_funcs, num_threads); + ifcopenshell::geom::iterator geom_iterator(settings, ifc_file, filter_funcs, num_threads); In Python, this is set when the iterator is constructed: @@ -272,10 +272,10 @@ Here is an example in C++: .. code-block:: c++ - SerializerSettings settings; - std::vector context_ids; + ifcopenshell::geom::settings settings; + std::set context_ids; // ... - settings.set_context_ids(context_ids); + settings.get().value = context_ids; Here is an example in Python: @@ -582,10 +582,10 @@ Here is an example in C++: .. code-block:: c++ - SerializerSettings settings; + ifcopenshell::geom::settings settings; double tolerance; // ... - settings.set_angular_tolerance(tolerance); + settings.get().value = tolerance; Here is an example in Python: @@ -609,10 +609,10 @@ Here is an example in C++: .. code-block:: c++ - SerializerSettings settings; + ifcopenshell::geom::settings settings; double tolerance; // ... - settings.set_deflection_tolerance(tolerance); + settings.get().value = tolerance; Here is an example in Python: diff --git a/src/ifcopenshell-python/docs/ifcopenshell/serialiser_settings.rst b/src/ifcopenshell-python/docs/ifcopenshell/serialiser_settings.rst index 717214df29..f444cc217d 100644 --- a/src/ifcopenshell-python/docs/ifcopenshell/serialiser_settings.rst +++ b/src/ifcopenshell-python/docs/ifcopenshell/serialiser_settings.rst @@ -1,15 +1,15 @@ Serialiser settings =================== -The geometry serialiser has a variety of settings which can impact its output. -This is set during the construction of the serialiser. +Geometry serialisers use the same settings object as geometry conversion. These +options affect serialised output and are set before constructing a serialiser. Here's an example of changing settings in Python: .. code-block:: python - serialiser_settings = ifcopenshell.geom.serializer_settings() - serialiser_settings.set("use-element-guids", True) + settings = ifcopenshell.geom.settings() + settings.set("use-element-guids", True) base-uri ^^^^^^^^ diff --git a/src/ifcopenshell-python/ifcopenshell/draw.py b/src/ifcopenshell-python/ifcopenshell/draw.py index 65d9bfd56d..d499929526 100644 --- a/src/ifcopenshell-python/ifcopenshell/draw.py +++ b/src/ifcopenshell-python/ifcopenshell/draw.py @@ -161,9 +161,8 @@ def main( # Initialize serializer buffer = ifcopenshell.geom.serializers.buffer() - serialiser_settings = ifcopenshell.geom.serializer_settings() if settings.auto_floorplan: - serialiser_settings.set("section-height-from-storeys", True) + geom_settings.set("section-height-from-storeys", True) # elevation-ref-guid and elevation-ref are also mutually exclusive in C-code. # Note that guid or object type are not checked anywhere to be valid, @@ -172,38 +171,38 @@ def main( if settings.drawing_guid: if not by_guid(settings.drawing_guid): raise ValueError(f"Unable to find guid {settings.drawing_guid!r}") - serialiser_settings.set("elevation-ref-guid", settings.drawing_guid) + geom_settings.set("elevation-ref-guid", settings.drawing_guid) elif settings.drawing_object_type: - serialiser_settings.set("elevation-ref", settings.drawing_object_type) - serialiser_settings.set("svg-without-storeys", True) + geom_settings.set("elevation-ref", settings.drawing_object_type) + geom_settings.set("svg-without-storeys", True) # required for svgfill - serialiser_settings.set("svg-write-poly", True) - serialiser_settings.set("svg-xmlns", True) + geom_settings.set("svg-write-poly", True) + geom_settings.set("svg-xmlns", True) - serialiser_settings.set("svg-project", settings.include_projection) - serialiser_settings.set("profile-threshold", settings.profile_threshold) - serialiser_settings.set("bounds", f"{settings.width}x{settings.height}") - serialiser_settings.set("scale", str(settings.scale)) - serialiser_settings.set("auto-elevation", settings.auto_elevation) - serialiser_settings.set("auto-section", settings.auto_section) - serialiser_settings.set("print-space-names", settings.space_names) - serialiser_settings.set("print-space-areas", settings.space_areas) - serialiser_settings.set("door-arcs", settings.door_arcs) - serialiser_settings.set("svg-no-css", bool(settings.css)) + geom_settings.set("svg-project", settings.include_projection) + geom_settings.set("profile-threshold", settings.profile_threshold) + geom_settings.set("bounds", f"{settings.width}x{settings.height}") + geom_settings.set("scale", str(settings.scale)) + geom_settings.set("auto-elevation", settings.auto_elevation) + geom_settings.set("auto-section", settings.auto_section) + geom_settings.set("print-space-names", settings.space_names) + geom_settings.set("print-space-areas", settings.space_areas) + geom_settings.set("door-arcs", settings.door_arcs) + geom_settings.set("svg-no-css", bool(settings.css)) if settings.subtract_before_hlr: - serialiser_settings.set("svg-subtract-before", "always") + geom_settings.set("svg-subtract-before", "always") - serialiser_settings.set("svg-poly", settings.hlr_poly) - serialiser_settings.set("svg-prefilter", settings.prefilter) - serialiser_settings.set("svg-unify-inputs", settings.unify_inputs) - serialiser_settings.set("svg-mirror-y", settings.mirror_y) + geom_settings.set("svg-poly", settings.hlr_poly) + geom_settings.set("svg-prefilter", settings.prefilter) + geom_settings.set("svg-unify-inputs", settings.unify_inputs) + geom_settings.set("svg-mirror-y", settings.mirror_y) if settings.storey_heights not in {"none", "full", "left"}: raise ValueError("storey_heights should be one of {'none', 'full', 'left'}") - serialiser_settings.set("draw-storey-heights", settings.storey_heights) + geom_settings.set("draw-storey-heights", settings.storey_heights) - sr = ifcopenshell.geom.serializers.svg(buffer, geom_settings, serialiser_settings) + sr = ifcopenshell.geom.serializers.svg(buffer, geom_settings) sr.setFile(files[0]) """ @@ -378,7 +377,7 @@ def main( # Put the IFC element entity type on the path for CSS-based styling p.setAttribute("class", elements[0].instance.is_a()) - # Obtain style (IfcOpenShell IfcGeom::Material) + # Obtain style (IfcOpenShell ifcopenshell::geom::Material) style = tree.styles()[elements[0].style_index] # This is just a demonstration. We compose a factor of using: diff --git a/src/ifcopenshell-python/ifcopenshell/express/header.py b/src/ifcopenshell-python/ifcopenshell/express/header.py index 9686539ce4..303c936ba2 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/header.py +++ b/src/ifcopenshell-python/ifcopenshell/express/header.py @@ -102,7 +102,7 @@ class Header(codegen.Base): all_superclasses.append(superclass) superclass = mapping.simple_type_parent(superclass) else: - superclasses.append("express::DeclaredType") + superclasses.append("express::declared_type") # This is no longer used, previously virtual inheritance was used, now # a variant-like approach is used instead, so the definition of selects @@ -110,7 +110,7 @@ class Header(codegen.Base): # superclasses.extend(get_select_super_types(name, bases=all_superclasses)) is_emitted = ( - lambda nm: nm == "express::DeclaredType" + lambda nm: nm == "express::declared_type" or nm in mapping.schema.selects or nm.lower() in emitted_simpletypes ) @@ -191,7 +191,7 @@ class Header(codegen.Base): all_supertypes.append(tt.supertypes[0]) tt = mapping.schema.entities[tt.supertypes[0]] - supertypes = list(type.supertypes) if len(type.supertypes) else ["express::Entity"] + supertypes = list(type.supertypes) if len(type.supertypes) else ["express::entity"] # supertypes.extend(get_select_super_types(name, bases=all_supertypes)) supertypes = list(map(case_normalize, supertypes)) assert len(supertypes) == 1 diff --git a/src/ifcopenshell-python/ifcopenshell/express/implementation.py b/src/ifcopenshell-python/ifcopenshell/express/implementation.py index 165ec32fa5..5a2bbaf1f9 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/implementation.py +++ b/src/ifcopenshell-python/ifcopenshell/express/implementation.py @@ -239,12 +239,12 @@ class Implementation(codegen.Base): for i in type.inverse ] - superclass = "%s(e)" % type.supertypes[0] if len(type.supertypes) == 1 else "express::Entity(e)" + superclass = "%s(e)" % type.supertypes[0] if len(type.supertypes) == 1 else "express::entity(e)" superclass_num_attrs = ( "%s(const std::weak_ptr&(in_memory_attribute_storage(%%d)))" % type.supertypes[0] if len(type.supertypes) == 1 - else "express::Entity(const std::weak_ptr&(in_memory_attribute_storage(%d)))" + else "express::entity(const std::weak_ptr&(in_memory_attribute_storage(%d)))" ) % len(constructor_arguments) write( @@ -309,7 +309,7 @@ class Implementation(codegen.Base): for class_name, type in mapping.schema.simpletypes.items(): type_str = mapping.make_type_string(mapping.flatten_type_string(type)) attr_type = mapping.make_argument_type(type) - superclass = mapping.simple_type_parent(class_name) or "express::DeclaredType" + superclass = mapping.simple_type_parent(class_name) or "express::declared_type" simpletype_impl_is = ( templates.simpletype_impl_is_with_supertype @@ -378,7 +378,7 @@ class Implementation(codegen.Base): ("%s v" % type_str,), ( "set_attribute_value(0, %s(v));" - % ("cast_vector" if mapping.is_templated_list(type) else "") + % ("cast_vector" if mapping.is_templated_list(type) else "") ), ), # ("v", "", constructor, "", ("%s v" % type_str,), ""), diff --git a/src/ifcopenshell-python/ifcopenshell/express/templates.py b/src/ifcopenshell-python/ifcopenshell/express/templates.py index 737a5db948..283e5cf0f5 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/templates.py +++ b/src/ifcopenshell-python/ifcopenshell/express/templates.py @@ -130,10 +130,10 @@ simpletype_impl_type = "return *((ifcopenshell::type_declaration*)%(schema_name_ simpletype_impl_class = "return *((ifcopenshell::type_declaration*)%(schema_name_upper)s_types[%(index_in_schema)d]);" simpletype_impl_explicit_constructor = "data_ = e;" simpletype_impl_constructor = "data_ = new const std::weak_ptr&(%(schema_name_upper)s_types[%(index_in_schema)d]); set_attribute_value(0, v);" -simpletype_impl_constructor_templated = "data_ = new const std::weak_ptr&(%(schema_name_upper)s_types[%(index_in_schema)d]); set_attribute_value(0, cast_vector(v));" +simpletype_impl_constructor_templated = "data_ = new const std::weak_ptr&(%(schema_name_upper)s_types[%(index_in_schema)d]); set_attribute_value(0, cast_vector(v));" simpletype_impl_cast = "return get_attribute_value(0);" simpletype_impl_cast_templated = ( - "std::vector es = get_attribute_value(0); return cast_vector<%(underlying_type)s>(es);" + "std::vector es = get_attribute_value(0); return cast_vector<%(underlying_type)s>(es);" ) simpletype_impl_declaration = ( @@ -141,9 +141,9 @@ simpletype_impl_declaration = ( ) select = """%(documentation)s -class IFC_SCHEMA_API %(name)s : public express::Select { +class IFC_SCHEMA_API %(name)s : public express::select { public: - using express::Select::Select; + using express::select::select; static const ifcopenshell::select_type& Class(); %(template_items)s @@ -153,16 +153,16 @@ public: select_list_item = """ // let's just use the as<>() from Base instead directly... // template, int> = 0> - // %(item_name)s as() const { return express::Base::as<%(item_name)s>(); } + // %(item_name)s as() const { return express::base::as<%(item_name)s>(); } """ -select_cast_function = """ %(name)s(const %(item_name)s& c) : express::Select(c) {}; +select_cast_function = """ %(name)s(const %(item_name)s& c) : express::select(c) {}; """ enumeration = """%(documentation)s -class IFC_SCHEMA_API %(name)s : public express::DeclaredType { +class IFC_SCHEMA_API %(name)s : public express::declared_type { public: - using express::DeclaredType::DeclaredType; + using express::declared_type::declared_type; typedef enum {%(values)s} Value; static const char* ToString(Value v); @@ -196,7 +196,7 @@ const ifcopenshell::enumeration_type& %(schema_name)s::%(name)s::Class() { retur /* %(schema_name)s::%(name)s::%(name)s(const std::weak_ptr& e) - : express::DeclaredType(e) + : express::declared_type(e) {} %(schema_name)s::%(name)s::%(name)s(Value v) { @@ -259,22 +259,22 @@ optional_attr_stmt = "return !get_attribute_value(%(index)d).isNull();" get_attr_stmt = "%(null_check)s %(non_optional_type)s v = get_attribute_value(%(index)d); return v;" get_attr_stmt_enum = "%(null_check)s return %(non_optional_type)s::FromString(get_attribute_value(%(index)d));" get_attr_stmt_entity = ( - "%(null_check)s return ((express::Base)(get_attribute_value(%(index)d))).as<%(non_optional_type_no_pointer)s>();" + "%(null_check)s return ((express::base)(get_attribute_value(%(index)d))).as<%(non_optional_type_no_pointer)s>();" ) -get_attr_stmt_array = "%(null_check)s std::vector es = get_attribute_value(%(index)d); return cast_vector<%(list_instance_type)s>(es);" -get_attr_stmt_nested_array = "%(null_check)s std::vector> es = get_attribute_value(%(index)d); return cast_vector<%(list_instance_type)s>(es);" +get_attr_stmt_array = "%(null_check)s std::vector es = get_attribute_value(%(index)d); return cast_vector<%(list_instance_type)s>(es);" +get_attr_stmt_nested_array = "%(null_check)s std::vector> es = get_attribute_value(%(index)d); return cast_vector<%(list_instance_type)s>(es);" get_inverse = "return cast_vector<%(type)s>(file()->get_inverse(data()->id(), %(schema_name_upper)s_types[%(type_index)d], %(index)d));" set_attr_stmt = "%(check_optional_set_begin)sset_attribute_value(%(index)d, %(star_if_optional)sv);%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" set_attr_instance = "%(check_optional_set_begin)sset_attribute_value(%(index)d, v);%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" set_attr_stmt_enum = "%(check_optional_set_begin)sset_attribute_value(%(index)d, enumeration_reference(&%(non_optional_type)s::Class(), (size_t) %(star_if_optional)sv));%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" -set_attr_stmt_array = "%(check_optional_set_begin)sset_attribute_value(%(index)d, cast_vector(%(star_if_optional)sv));%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" -set_attr_stmt_nested_array = "%(check_optional_set_begin)sset_attribute_value(%(index)d, cast_vector(%(star_if_optional)sv));%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" +set_attr_stmt_array = "%(check_optional_set_begin)sset_attribute_value(%(index)d, cast_vector(%(star_if_optional)sv));%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" +set_attr_stmt_nested_array = "%(check_optional_set_begin)sset_attribute_value(%(index)d, cast_vector(%(star_if_optional)sv));%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" constructor_stmt = "set_attribute_value(%(index)d, (%(name)s));" constructor_stmt_enum = "set_attribute_value(%(index)d, (enumeration_reference(&%(type)s::Class(),(size_t)%(name)s)));" -constructor_stmt_array = "set_attribute_value(%(index)d, cast_vector(%(name)s));" +constructor_stmt_array = "set_attribute_value(%(index)d, cast_vector(%(name)s));" constructor_stmt_derived = "" constructor_stmt_instance = "set_attribute_value(%(index)d, %(name)s);" diff --git a/src/ifcopenshell-python/ifcopenshell/geom/main.py b/src/ifcopenshell-python/ifcopenshell/geom/main.py index 5e517e3d51..40b7a7ff3a 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/main.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/main.py @@ -65,8 +65,12 @@ SETTING = Literal[ "angle-unit", "apply-default-materials", "apply-offset", + "auto-elevation", + "auto-section", + "base-uri", "boolean-attempt-2d", "building-local-placement", + "bounds", "cache-shapes", "cgal-original-edges", "cgal-smooth-angle-degrees", @@ -80,9 +84,13 @@ SETTING = Literal[ "debug", "defer-processing-first-element", "dimensionality", + "digits", "disable-boolean-result", "disable-opening-subtractions", "edge-arrows", + "ecef", + "elevation-ref", + "elevation-ref-guid", "element-hierarchy", "enable-layerset-slicing", "force-space-transparency", @@ -107,65 +115,55 @@ SETTING = Literal[ "no-wire-intersection-check", "no-wire-intersection-tolerance", "permissive-shape-reuse", + "print-space-areas", + "print-space-names", "precision-factor", "precision", + "profile-threshold", "reorient-shells", "site-local-placement", + "scale", + "section-height", + "section-height-from-storeys", + "section-ref", + "separate-z-up-node", + "space-name-transform", + "storey-height-line-length", "surface-colour", "svg-emit-flush-edges", + "svg-mirror-x", + "svg-mirror-y", + "svg-no-css", + "svg-poly", + "svg-prefilter", + "svg-project", "svg-render-crease-edges", "svg-render-sharp-edges", "svg-ridge-angle-min-degrees", + "svg-segment-projection", + "svg-subtract-before", + "svg-unify-inputs", "svg-use-edge-classification", "svg-valley-angle-min-degrees", + "svg-without-storeys", + "svg-write-poly", + "svg-xmlns", "triangulation-type", "unify-shapes", "use-material-names", + "use-element-guids", + "use-element-names", + "use-element-step-ids", + "use-element-types", "use-python-opencascade", "use-world-coords", "validate", "weld-vertices", -] -SERIALIZER_SETTING = Literal[ - "base-uri", - "use-element-names", - "use-element-guids", - "use-element-step-ids", - "use-element-types", "y-up", - "ecef", - "digits", "wkt-use-section", - "separate-z-up-node", - "bounds", - "scale", "center", - "section-ref", - "elevation-ref", - "elevation-ref-guid", - "auto-section", - "auto-elevation", "draw-storey-heights", - "profile-threshold", - "storey-height-line-length", - "svg-xmlns", - "svg-poly", - "svg-prefilter", - "svg-unify-inputs", - "svg-segment-projection", - "svg-subtract-before", - "svg-write-poly", - "svg-project", - "svg-without-storeys", - "svg-no-css", - "svg-mirror-y", - "svg-mirror-x", "door-arcs", - "section-height", - "section-height-from-storeys", - "print-space-names", - "print-space-areas", - "space-name-transform", ] # NOTE: hybrid-cgal-simple-opencascade is added just as an example @@ -203,18 +201,14 @@ class settings_mixin: return "%s(%s)" % (type(self).__name__, ", ".join(map(fmt_pair, self.setting_names()))) @staticmethod - def name(k: str) -> Union[SETTING, SERIALIZER_SETTING]: + def name(k: str) -> SETTING: return k.lower().replace("_", "-") @staticmethod - def rname(k: Union[SETTING, SERIALIZER_SETTING]) -> str: + def rname(k: SETTING) -> str: return k.upper().replace("-", "_") - @overload - def set(self: settings, k: SETTING, v: Any) -> None: ... - @overload - def set(self: serializer_settings, k: SERIALIZER_SETTING, v: Any) -> None: ... - def set(self, k: Union[SETTING, SERIALIZER_SETTING], v: Any) -> None: + def set(self, k: SETTING, v: Any) -> None: """ Set value of the setting named `k` to `v`. @@ -231,10 +225,6 @@ class settings_mixin: else: self.set_(self.name(k), v) - @overload - def get(self: settings, k: SETTING) -> Any: ... - @overload - def get(self: serializer_settings, k: SERIALIZER_SETTING) -> Any: ... def get(self, k: str) -> Any: """ Return value of the setting named `k`. @@ -246,20 +236,12 @@ class settings_mixin: return self.use_python_opencascade return self.get_(k) - @overload - def setting_names(self: settings) -> tuple[SETTING, ...]: ... - @overload - def setting_names(self: serializer_settings) -> tuple[SERIALIZER_SETTING, ...]: ... def setting_names(self) -> tuple[str, ...]: setting_names = super().setting_names() if isinstance(self, settings): setting_names += ("use-python-opencascade",) return setting_names - @overload - def __getattr__(self: settings, k: str) -> SETTING: ... - @overload - def __getattr__(self: serializer_settings, k: str) -> SERIALIZER_SETTING: ... def __getattr__(self, k: str) -> str: # Swig wrapper will try to access "this", # ensure we won't accidentally call any c-extension methods @@ -322,10 +304,6 @@ class settings_mixin: self.set(k.replace("_", "-"), v) -class serializer_settings(settings_mixin, ifcopenshell_wrapper.SerializerSettings): - pass - - class settings(settings_mixin, ifcopenshell_wrapper.Settings): use_python_opencascade = False @@ -687,18 +665,18 @@ class _serializer_factory: self.__name__ = name def __call__(self, out_filename: Union[str, PathLike[str]], *args: Any) -> ifcopenshell_wrapper.GeometrySerializer: - if self.name == "obj" and len(args) == 3: + if self.name == "obj" and len(args) == 2: output_filename = args[0] output_temp_filename = out_filename - geometry_settings, serializer_settings = args[1], args[2] - elif len(args) == 2: + settings = args[1] + elif len(args) == 1: output_filename = out_filename output_temp_filename = out_filename - geometry_settings, serializer_settings = args + settings = args[0] else: - obj_signature = " or (out_filename, mtl_filename, geometry_settings, serializer_settings)" + obj_signature = " or (out_filename, mtl_filename, settings)" raise TypeError( - f"serializers.{self.name}() expects (out_filename, geometry_settings, serializer_settings)" + f"serializers.{self.name}() expects (out_filename, settings)" + (obj_signature if self.name == "obj" else "") ) @@ -711,9 +689,7 @@ class _serializer_factory: output_filename = self._path(output_filename) output_temp_filename = self._path(output_temp_filename) - return ifcopenshell_wrapper.create_geometry_serializer( - self.extension, output_filename, output_temp_filename, geometry_settings, serializer_settings - ) + return ifcopenshell_wrapper.create_geometry_serializer(self.extension, output_filename, output_temp_filename, settings) def _is_buffer(self, value: Any) -> bool: return isinstance(value, ifcopenshell_wrapper.buffer) diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index 26e9b42e59..4c5953547f 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -257,7 +257,6 @@ class GeometrySerializer: READ_TRIANGULATION: Any def __init__(self, *args, **kwargs): ... def finalize(self): ... - def geometry_settings(self, *args): ... def isTesselated(self): ... def is_streaming(self) -> bool: ... def object_id(self, o): ... @@ -265,7 +264,7 @@ class GeometrySerializer: def ready(self): ... def setFile(self, file: file) -> None: ... def setUnitNameAndMagnitude(self, name, magnitude): ... - def settings(self, *args): ... + def settings(self, *args) -> "Settings": ... def write(self, *args): ... def writeHeader(self): ... @@ -370,7 +369,7 @@ class Representation: - 2468 - IfcRelVoidsElement """ - def settings(self): ... + def settings(self) -> "Settings": ... class RocksDBPrefixIterator: def __init__(self, storage, prefix): ... @@ -401,12 +400,6 @@ class SerializedElement(Element): @property def geometry(self) -> Serialization: ... -class SerializerSettings: - def get_(self, name): ... - def get_type(self, name): ... - def set_(self, *args): ... - def setting_names(self): ... - class Settings: def get_(self, name): ... def get_type(self, name): ... diff --git a/src/ifcopenshell-python/test/test_create_shape.py b/src/ifcopenshell-python/test/test_create_shape.py index 51f9b23044..65c6edb501 100644 --- a/src/ifcopenshell-python/test/test_create_shape.py +++ b/src/ifcopenshell-python/test/test_create_shape.py @@ -47,21 +47,8 @@ class TestGeomSettings: settings.set(settings.USE_PYTHON_OPENCASCADE, True) assert "USE_PYTHON_OPENCASCADE = False" in repr(settings) - def test_serializer_settings(self): - settings = ifcopenshell.geom.serializer_settings() - assert set(get_args(ifcopenshell.geom.SERIALIZER_SETTING)) == set( - settings.setting_names() - ), "Also need to update IfcPython.i, if new settings were added/removed." - - # Only for settings. - assert "use-python-opencascade" not in settings.setting_names() - with pytest.raises(AttributeError): - settings.get(settings.USE_PYTHON_OPENCASCADE) - with pytest.raises(RuntimeError): - settings.get("use-python-opencascade") - with pytest.raises(RuntimeError): - settings.set("use-python-opencascade", True) - assert "USE_PYTHON_OPENCASCADE" not in repr(settings) + settings.set("base-uri", "https://example.test/") + assert settings.get("base-uri") == "https://example.test/" class TestTriangulationAttributes(test.bootstrap.IFC4): diff --git a/src/ifcparse/entity_instance_data.cpp b/src/ifcparse/entity_instance_data.cpp index 9c5a806bf3..0df6b8ec51 100644 --- a/src/ifcparse/entity_instance_data.cpp +++ b/src/ifcparse/entity_instance_data.cpp @@ -4,7 +4,7 @@ #include "file.h" // @todo is size() still needed? -class SizeVisitor { +class size_visitor { public: typedef int result_type; @@ -25,9 +25,9 @@ public: int operator()(const std::vector& i) const { return (int)i.size(); } int operator()(const std::vector>& i) const { return (int)i.size(); } int operator()(const enumeration_reference& /*i*/) const { return -1; } - int operator()(const express::Base& /*i*/) const { return -1; } - int operator()(const std::vector& i) const { return (int)i.size(); } - int operator()(const std::vector>& i) const { return (int)i.size(); } + int operator()(const express::base& /*i*/) const { return -1; } + int operator()(const std::vector& i) const { return (int)i.size(); } + int operator()(const std::vector>& i) const { return (int)i.size(); } }; namespace { @@ -59,7 +59,7 @@ namespace { if constexpr ( // the following types cannot be directly deserialized from rocksdb, but need to be constructed !std::is_same_v && - !std::is_same_v, express::Base>) + !std::is_same_v, express::base>) { std::string str; array_.db_ptr->db->Get(rocksdb::ReadOptions{}, @@ -70,8 +70,8 @@ namespace { } else { static_assert( std::is_same_v || - std::is_same_v, express::Base>, - "RocksDB deserialization must be specialized for this enumeration_reference and express::Base" + std::is_same_v, express::base>, + "RocksDB deserialization must be specialized for this enumeration_reference and express::base" ); } return val; @@ -98,7 +98,7 @@ namespace { return true; } } - return str[0] == TypeEncoder::encode_type(); + return str[0] == type_encoder::encode_type(); } #endif } @@ -116,7 +116,7 @@ namespace { (is_header ? "h|" : (entity_or_type->as_entity() ? "i|" : "t|")) + (is_header ? entity_or_type->name() : std::to_string(instance_name_)) + "|" + std::to_string(index_), &str).ok()) { - return TypeEncoder::encode_type() - 'A'; + return type_encoder::encode_type() - 'A'; } return (size_t) str[0] - 'A'; } @@ -201,10 +201,10 @@ attribute_value::operator boost::dynamic_bitset<>() const return dispatch_get_>(array_, storage_model_, instance_name_, entity_or_type_, index_); } -attribute_value::operator express::Base () const +attribute_value::operator express::base () const { if (storage_model_ == 0) { - return dispatch_get_(array_, storage_model_, instance_name_, entity_or_type_, index_); + return dispatch_get_(array_, storage_model_, instance_name_, entity_or_type_, index_); } #ifdef IFOPSH_WITH_ROCKSDB else { @@ -249,9 +249,9 @@ attribute_value::operator std::vector>() const return dispatch_get_>>(array_, storage_model_, instance_name_, entity_or_type_, index_); } -attribute_value::operator std::vector() const +attribute_value::operator std::vector() const { - return dispatch_get_>(array_, storage_model_, instance_name_, entity_or_type_, index_); + return dispatch_get_>(array_, storage_model_, instance_name_, entity_or_type_, index_); } attribute_value::operator std::vector>() const @@ -264,9 +264,9 @@ attribute_value::operator std::vector>() const return dispatch_get_>>(array_, storage_model_, instance_name_, entity_or_type_, index_); } -attribute_value::operator std::vector>() const +attribute_value::operator std::vector>() const { - return dispatch_get_>>(array_, storage_model_, instance_name_, entity_or_type_, index_); + return dispatch_get_>>(array_, storage_model_, instance_name_, entity_or_type_, index_); } bool attribute_value::isNull() const @@ -277,7 +277,7 @@ bool attribute_value::isNull() const unsigned int attribute_value::size() const { // @todo - return array_.storage_ptr->apply_visitor(SizeVisitor{}, index_); + return array_.storage_ptr->apply_visitor(size_visitor{}, index_); } ifcopenshell::argument_type attribute_value::type() const @@ -287,11 +287,11 @@ ifcopenshell::argument_type attribute_value::type() const #ifdef IFOPSH_WITH_ROCKSDB -bool impl::serialize(std::string& val, const express::Base& t) +bool impl::serialize(std::string& val, const express::base& t) { auto s = sizeof(size_t); val.resize(s + 2); - val[0] = TypeEncoder::encode_type(); + val[0] = type_encoder::encode_type(); // 1 = entity - stored by id (entity name) // 2 = type - stored by identity (internal counter in class) val[1] = t.declaration().as_entity() ? 'i' : 't'; @@ -304,7 +304,7 @@ bool impl::serialize(std::string& val, const enumeration_reference& v) { auto s = sizeof(size_t); val.resize(s * 2 + 1); - val[0] = TypeEncoder::encode_type(); + val[0] = type_encoder::encode_type(); size_t vv = v.enumeration()->index_in_schema(); memcpy(val.data() + 1, &vv, sizeof(size_t)); vv = v.index(); @@ -312,11 +312,11 @@ bool impl::serialize(std::string& val, const enumeration_reference& v) return true; } -bool impl::serialize(std::string& val, const std::vector& t) +bool impl::serialize(std::string& val, const std::vector& t) { // no attempt at alignment val.resize(t.size() * (sizeof(size_t) + 1) + 1); - val[0] = TypeEncoder::encode_type>(); + val[0] = type_encoder::encode_type>(); char* ptr = val.data() + 1; for (auto& inst : t) { *ptr = inst.declaration().as_entity() ? 'i' : 't'; @@ -328,10 +328,10 @@ bool impl::serialize(std::string& val, const std::vector& t) return true; } -bool impl::serialize(std::string& val, const std::vector>& t) +bool impl::serialize(std::string& val, const std::vector>& t) { std::ostringstream oss; - oss.put(TypeEncoder::encode_type>>()); + oss.put(type_encoder::encode_type>>()); auto write_size = [&oss](size_t sz) { std::string size_str; @@ -366,28 +366,28 @@ bool impl::serialize(std::string& val, const std::vector(); + val[0] = type_encoder::encode_type(); return true; } bool impl::serialize(std::string& val, const derived&) { val.resize(1); - val[0] = TypeEncoder::encode_type(); + val[0] = type_encoder::encode_type(); return true; } bool impl::serialize(std::string& val, const empty_aggregate_t&) { val.resize(1); - val[0] = TypeEncoder::encode_type(); + val[0] = type_encoder::encode_type(); return true; } bool impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t&) { val.resize(1); - val[0] = TypeEncoder::encode_type(); + val[0] = type_encoder::encode_type(); return true; } @@ -395,7 +395,7 @@ bool impl::serialize(std::string& val, const boost::logic::tribool& t) { char tt = t == boost::logic::indeterminate ? 2 : t ? 1 : 0; val.resize(sizeof(char) + 1); - val[0] = TypeEncoder::encode_type(); + val[0] = type_encoder::encode_type(); memcpy(val.data() + 1, &tt, sizeof(char)); return true; } @@ -404,12 +404,12 @@ bool impl::serialize(std::string& val, const boost::dynamic_bitset<>& t) { std::string tmp; boost::to_string(t, tmp); - val = std::string(TypeEncoder::encode_type>(), 1) + tmp; + val = std::string(type_encoder::encode_type>(), 1) + tmp; return true; } bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::logic::tribool& t) { - if (val[0] != TypeEncoder::encode_type()) { + if (val[0] != type_encoder::encode_type()) { return false; } if (val[1] == 0) { @@ -425,14 +425,14 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::st } bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::dynamic_bitset<>& t) { - if (val[0] != TypeEncoder::encode_type>()) { + if (val[0] != type_encoder::encode_type>()) { return false; } t = boost::dynamic_bitset<>(val.substr(1)); return true; } -bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector& t) { +bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector& t) { auto n = (val.size() - 1) / (sizeof(size_t) + 1); for (int i = 0; i < n; ++i) { auto ptr = val.data() + 1 + (sizeof(size_t) + 1) * i; @@ -451,7 +451,7 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const return true; } -bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector>& t) { +bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector>& t) { char const* ptr = val.data() + 1; // size_t outer_size; @@ -505,7 +505,7 @@ bool rocks_db_attribute_storage::has(void* storage, const ifcopenshell::declarat return true; } } - return v.size() && v[0] == TypeEncoder::encode_type(); + return v.size() && v[0] == type_encoder::encode_type(); } template @@ -530,15 +530,15 @@ template IFC_PARSE_API void rocks_db_attribute_storage::set(void* storag template IFC_PARSE_API void rocks_db_attribute_storage::set(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::string& value); template IFC_PARSE_API void rocks_db_attribute_storage::set>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const boost::dynamic_bitset<>& value); template IFC_PARSE_API void rocks_db_attribute_storage::set(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const enumeration_reference& value); -template IFC_PARSE_API void rocks_db_attribute_storage::set(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, express::Base const& value); +template IFC_PARSE_API void rocks_db_attribute_storage::set(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, express::base const& value); template IFC_PARSE_API void rocks_db_attribute_storage::set>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector& value); template IFC_PARSE_API void rocks_db_attribute_storage::set>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector& value); template IFC_PARSE_API void rocks_db_attribute_storage::set>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector& value); template IFC_PARSE_API void rocks_db_attribute_storage::set>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector>& value); -template IFC_PARSE_API void rocks_db_attribute_storage::set>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector& value); +template IFC_PARSE_API void rocks_db_attribute_storage::set>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector& value); template IFC_PARSE_API void rocks_db_attribute_storage::set>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector>& value); template IFC_PARSE_API void rocks_db_attribute_storage::set>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector>& value); -template IFC_PARSE_API void rocks_db_attribute_storage::set>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector>& value); +template IFC_PARSE_API void rocks_db_attribute_storage::set>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector>& value); // @todo why do these need to be included, but are not in BaseEntity::set()? template IFC_PARSE_API void rocks_db_attribute_storage::set(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const derived& value); @@ -553,15 +553,15 @@ template IFC_PARSE_API bool rocks_db_attribute_storage::has(void* storag template IFC_PARSE_API bool rocks_db_attribute_storage::has(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; -template IFC_PARSE_API bool rocks_db_attribute_storage::has(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; +template IFC_PARSE_API bool rocks_db_attribute_storage::has(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; -template IFC_PARSE_API bool rocks_db_attribute_storage::has>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; +template IFC_PARSE_API bool rocks_db_attribute_storage::has>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; template IFC_PARSE_API bool rocks_db_attribute_storage::has>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; -template IFC_PARSE_API bool rocks_db_attribute_storage::has>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; +template IFC_PARSE_API bool rocks_db_attribute_storage::has>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; // @todo why do these need to be included, but are not in BaseEntity::set()? template IFC_PARSE_API bool rocks_db_attribute_storage::has(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const; diff --git a/src/ifcparse/express.cpp b/src/ifcparse/express.cpp index 71df55387b..71ad0cb3b7 100644 --- a/src/ifcparse/express.cpp +++ b/src/ifcparse/express.cpp @@ -1,14 +1,14 @@ #include "express.h" #include "instance_data.h" -const ifcopenshell::declaration& express::Base::declaration() const { +const ifcopenshell::declaration& express::base::declaration() const { return *data()->declaration(); } -uint32_t express::Base::identity() const { return data()->identity(); } +uint32_t express::base::identity() const { return data()->identity(); } -uint32_t express::Base::id() const { return data()->id(); } +uint32_t express::base::id() const { return data()->id(); } -const instance_data* express::Base::data() const { +const instance_data* express::base::data() const { #ifdef IFOPSH_SAFE_INSTANCE auto sp = data_.lock(); if (sp) { @@ -21,7 +21,7 @@ const instance_data* express::Base::data() const { #endif } -instance_data* express::Base::data() { +instance_data* express::base::data() { #ifdef IFOPSH_SAFE_INSTANCE auto sp = data_.lock(); if (sp) { diff --git a/src/ifcparse/express.h b/src/ifcparse/express.h index abb501a1d8..47f9459b19 100644 --- a/src/ifcparse/express.h +++ b/src/ifcparse/express.h @@ -59,12 +59,12 @@ class attribute_value; namespace express { -class Base; -class Select; -class Entity; -class DeclaredType; +class base; +class select; +class entity; +class declared_type; -class IFC_PARSE_API Base { +class IFC_PARSE_API base { protected: ifcopenshell::pointer_type data_; const instance_data* data() const; @@ -78,25 +78,25 @@ class IFC_PARSE_API Base { #endif } - bool operator<(const Base& other) const { + bool operator<(const base& other) const { return data() < other.data(); } - bool operator==(const Base& other) const { + bool operator==(const base& other) const { return data() == other.data(); } - bool operator!=(const Base& other) const { + bool operator!=(const base& other) const { return !(*this == other); } - Base() { + base() { #ifndef IFOPSH_SAFE_INSTANCE data_ = nullptr; #endif }; - Base(std::nullopt_t) noexcept : Base() {} - Base(const ifcopenshell::pointer_type& data) : data_(data) {} + base(std::nullopt_t) noexcept : base() {} + base(const ifcopenshell::pointer_type& data) : data_(data) {} // @todo try and make this private over time too const ifcopenshell::pointer_type& data_weak() const { return data_; } @@ -105,18 +105,18 @@ class IFC_PARSE_API Base { template typename std::enable_if< - (!std::is_base_of_v || std::is_same_v), + (!std::is_base_of_v || std::is_same_v), void>::type set_attribute_value(size_t attribute_index, const T& value); template typename std::enable_if< - (!std::is_base_of_v || std::is_same_v), + (!std::is_base_of_v || std::is_same_v), void>::type set_attribute_value(const std::string& attribute_name, const T& value); - void set_attribute_value(size_t attribute_index, const express::Base& value); - void set_attribute_value(const std::string& attribute_name, const express::Base& value); + void set_attribute_value(size_t attribute_index, const express::base& value); + void set_attribute_value(const std::string& attribute_name, const express::base& value); void unset_attribute_value(size_t attribute_index); @@ -130,20 +130,20 @@ class IFC_PARSE_API Base { template T as() const { - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { if (declaration().as_entity() != nullptr) { return T(data_weak()); } else { return T{}; } - } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { if (declaration().as_entity() == nullptr) { return T(data_weak()); } else { return T{}; } - } else if constexpr (std::is_same_v) { - static_assert(std::is_same_v, "Select is abstract"); + } else if constexpr (std::is_same_v) { + static_assert(std::is_same_v, "select is abstract"); } else { if (declaration().is(T::Class())) { return T(data_weak()); @@ -156,9 +156,9 @@ class IFC_PARSE_API Base { ifcopenshell::file* file() const; }; -class IFC_PARSE_API Entity : public Base { +class IFC_PARSE_API entity : public base { public: - using Base::Base; + using base::base; attribute_value get(const std::string& attribute_name) const; @@ -168,44 +168,51 @@ class IFC_PARSE_API Entity : public Base { template T get_value(const std::string& attribute_name, const T& default_value) const; - std::vector get_inverse(const std::string& attribute_name) const; + std::vector get_inverse(const std::string& attribute_name) const; }; -class IFC_PARSE_API Select : public Base { +class IFC_PARSE_API select : public base { public: - Select() {} - Select(std::nullopt_t) noexcept : Base() {} - Select(const ifcopenshell::pointer_type& data) : Base(data) {} - Select(const Base& base) : Base(base.data_weak()) {} + select() {} + select(std::nullopt_t) noexcept : base() {} + select(const ifcopenshell::pointer_type& data) : base(data) {} + select(const base& value) : base(value.data_weak()) {} - Base concrete() const { - return Base(data_weak()); + base concrete() const { + return base(data_weak()); } }; // @todo Investigate whether these should be template classes instead // @todo currently this class doesn't do much, decide whether to keep -// it or move certain functionality from Base downwards to -// Entity and DeclaredType -class IFC_PARSE_API DeclaredType : public Base { +// it or move certain functionality from base downwards to +// entity and declared_type +class IFC_PARSE_API declared_type : public base { public: - using Base::Base; + using base::base; }; +// Compatibility aliases for checked-in generated schema sources. New generated +// sources use the snake_case names directly. +using Base = base; +using Entity = entity; +using Select = select; +using DeclaredType = declared_type; + } // namespace express namespace std { template <> -struct hash { - std::size_t operator()(const express::Base& value) const noexcept { +struct hash { + std::size_t operator()(const express::base& value) const noexcept { return std::hash{}(value.identity()); } }; template <> -struct hash { - std::size_t operator()(const express::Entity& value) const noexcept { +struct hash { + std::size_t operator()(const express::entity& value) const noexcept { return std::hash{}(value.identity()); } }; @@ -215,15 +222,15 @@ struct hash { namespace boost { template <> -struct hash { - std::size_t operator()(const express::Base& value) const noexcept { +struct hash { + std::size_t operator()(const express::base& value) const noexcept { return std::hash{}(value.identity()); } }; template <> -struct hash { - std::size_t operator()(const express::Entity& value) const noexcept { +struct hash { + std::size_t operator()(const express::entity& value) const noexcept { return std::hash{}(value.identity()); } }; @@ -257,7 +264,7 @@ typename std::conditional_t< std::vector> cast_vector(const std::vector& values) { if constexpr (is_std_vector::value) { - using V = typename U::value_type; + using value_type = typename U::value_type; std::vector> result; result.reserve(values.size()); for (const auto& value : values) { @@ -270,7 +277,7 @@ cast_vector(const std::vector& values) { if constexpr (std::is_base_of_v) { // For a base or identity transform we can just rely on static cast result.push_back(value); - } else if constexpr (std::is_base_of_v && std::is_same_v) { + } else if constexpr (std::is_base_of_v && std::is_same_v) { // From a select to concrete we simply call the appropriate method result.push_back(value.concrete()); } else { diff --git a/src/ifcparse/file.cpp b/src/ifcparse/file.cpp index 652be45adc..88ddd48c00 100644 --- a/src/ifcparse/file.cpp +++ b/src/ifcparse/file.cpp @@ -32,19 +32,19 @@ ifcopenshell::impl::rocks_db_file_storage::rocksdb_types_iterator::value_type co return storage_->file->schema()->declarations()[*read_id_()]; } -express::Base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t number, instance_ref r) { +express::base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t number, instance_ref r) { #ifdef IFOPSH_WITH_ROCKSDB std::lock_guard lock(instance_cache_mutex_); if (r == ifcopenshell::impl::rocks_db_file_storage::entityinstance_ref) { auto it = instance_cache_.find(number); if (it != instance_cache_.end()) { - return express::Base(it->second); + return express::base(it->second); } } else { auto it = type_instance_cache_.find(number); if (it != type_instance_cache_.end()) { - return express::Base(it->second); + return express::base(it->second); } } @@ -70,7 +70,7 @@ express::Base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t } else { type_instance_cache_.insert({number, data}); } - return express::Base(data); + return express::base(data); } else { throw exception("Instance #" + boost::lexical_cast(number) + " not found"); } @@ -147,7 +147,7 @@ ifcopenshell::impl::rocks_db_file_storage::rocks_db_file_storage(const std::stri , db(init_db(filepath, readonly)) // @todo streaming serializer does not populate the byguid map , byguid_internal_(db.get(), "g|"), - byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::Base& v) { return v.identity(); }) + byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::base& v) { return v.identity(); }) , instance_ids_(db.get(), "i|") , instance_by_name_(&instance_ids_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }) , bytype_(db.get(), "t|") @@ -183,14 +183,14 @@ ifcopenshell::impl::rocks_db_file_storage::~rocks_db_file_storage() } -express::Base ifcopenshell::impl::rocks_db_file_storage::instance_by_id(int id) +express::base ifcopenshell::impl::rocks_db_file_storage::instance_by_id(int id) { // @todo rename assert_existance() -> instance_by_id(); // - no cannot be done, because it needs to differentiate between entity instances and typedecls return assert_existance(id, entityinstance_ref); } -void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const express::Base& inst) +void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const express::base& inst) { #ifdef IFOPSH_WITH_ROCKSDB auto id = inst.id(); @@ -248,13 +248,13 @@ void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const e #endif } -express::Base ifcopenshell::impl::in_memory_file_storage::instance_by_id(int id) +express::base ifcopenshell::impl::in_memory_file_storage::instance_by_id(int id) { auto it = byid_.find(id); if (it == byid_.end()) { throw exception("Instance #" + boost::lexical_cast(id) + " not found"); } - return express::Base(it->second); + return express::base(it->second); } ifcopenshell::file::~file() {} @@ -336,8 +336,8 @@ ifcopenshell::filetype ifcopenshell::guess_file_type(const std::string& fn) { } } -express::Base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshell::declaration* decl, int id) { - return express::Base{}; +express::base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshell::declaration* decl, int id) { + return express::base{}; /* if (decl->as_entity() || decl->as_type_declaration()) { auto* inst = file->schema()->instantiate(decl, rocks_db_attribute_storage{}); @@ -350,7 +350,7 @@ express::Base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshe */ } -express::Base ifcopenshell::impl::in_memory_file_storage::create(const ifcopenshell::declaration* decl, int id) { +express::base ifcopenshell::impl::in_memory_file_storage::create(const ifcopenshell::declaration* decl, int id) { uint32_t instance_name; if (decl->as_entity() != nullptr) { instance_name = id == -1 ? (int)file->fresh_id() : id; @@ -366,13 +366,13 @@ express::Base ifcopenshell::impl::in_memory_file_storage::create(const ifcopensh tbyid_.insert({data->identity(), data}); } - express::Base inst(data); + express::base inst(data); add_type_ref(inst); return inst; } -express::Base ifcopenshell::file::create(const ifcopenshell::declaration* decl, int id) { +express::base ifcopenshell::file::create(const ifcopenshell::declaration* decl, int id) { if (id != -1) { if (decl->as_entity() == nullptr) { throw ifcopenshell::exception("Assigning instance id during creation is only valid for entity declarations"); @@ -393,12 +393,12 @@ express::Base ifcopenshell::file::create(const ifcopenshell::declaration* decl, } } - return std::visit([&](auto& m) -> express::Base { + return std::visit([&](auto& m) -> express::base { if constexpr (std::is_same_v, impl::in_memory_file_storage> || std::is_same_v, impl::rocks_db_file_storage>) { return m.create(decl, id); } else { - return express::Base{}; + return express::base{}; } }, storage_); } diff --git a/src/ifcparse/file.h b/src/ifcparse/file.h index a610c1f60c..3a6f3f4f65 100644 --- a/src/ifcparse/file.h +++ b/src/ifcparse/file.h @@ -184,7 +184,7 @@ class uninitialized_tag {}; /// The file takes ownership of instances added to this file and deletes them when the file is deleted. class IFC_PARSE_API file { private: - typedef std::map entity_entity_map_t; + typedef std::map entity_entity_map_t; // @todo determine the constness of things (probably needs to be all const, we don't want to overwrite) // @todo we have variant_iterator and MapVariant, we probably need to retain only one? @@ -232,7 +232,7 @@ public: batch_deletion_ids_t; batch_deletion_ids_t batch_deletion_ids_; bool batch_mode_ = false; - void process_deletion_(const express::Base& entity); + void process_deletion_(const express::base& entity); public: #ifdef USE_MMAP @@ -311,7 +311,7 @@ public: /// IfcWall will also return IfcWallStandardCase entities template typename std::vector instances_by_type() { - std::vector untyped_list = instances_by_type(&T::Class()); + std::vector untyped_list = instances_by_type(&T::Class()); std::vector return_value; for (auto& untyped : untyped_list) { return_value.push_back(untyped.as()); @@ -321,7 +321,7 @@ public: template typename std::vector instances_by_type_excl_subtypes() { - std::vector untyped_list = instances_by_type_excl_subtypes(&T::Class()); + std::vector untyped_list = instances_by_type_excl_subtypes(&T::Class()); std::vector return_value; for (auto& untyped : untyped_list) { return_value.push_back(untyped.as()); @@ -332,36 +332,36 @@ public: /// Returns all entities in the file that match the positional argument. /// NOTE: This also returns subtypes of the requested type, for example: /// IfcWall will also return IfcWallStandardCase entities - std::vector instances_by_type(const ifcopenshell::declaration* declaration); + std::vector instances_by_type(const ifcopenshell::declaration* declaration); /// Returns all entities in the file that match the positional argument. - std::vector instances_by_type_excl_subtypes(const ifcopenshell::declaration* declaration); + std::vector instances_by_type_excl_subtypes(const ifcopenshell::declaration* declaration); /// Returns all entities in the file that match the positional argument. /// NOTE: This also returns subtypes of the requested type, for example: /// IfcWall will also return IfcWallStandardCase entities - std::vector instances_by_type(const std::string& type_name); + std::vector instances_by_type(const std::string& type_name); /// Returns all entities in the file that match the positional argument. - std::vector instances_by_type_excl_subtypes(const std::string& type_name); + std::vector instances_by_type_excl_subtypes(const std::string& type_name); /// Returns all entities in the file that reference the id - std::vector instances_by_reference(int reference_id); + std::vector instances_by_reference(int reference_id); /// Returns the entity with the specified id - express::Base instance_by_id(int instance_id); + express::base instance_by_id(int instance_id); /// Returns the entity with the specified GlobalId - express::Base instance_by_guid(const std::string& global_id); + express::base instance_by_guid(const std::string& global_id); /// Performs a depth-first traversal, returning all entity instance /// attributes as a flat list. NB: includes the root instance specified /// in the first function argument. - static std::vector traverse(const express::Base& instance, int max_depth = -1); + static std::vector traverse(const express::base& instance, int max_depth = -1); /// Same as traverse() but maintains topological order by using a /// breadth-first search - static std::vector traverse_breadth_first(const express::Base& instance, int max_depth = -1); + static std::vector traverse_breadth_first(const express::base& instance, int max_depth = -1); /// Get the attribute indices corresponding to the list of entity instances /// returned by get_inverse(). @@ -372,7 +372,7 @@ public: return get_inverse(instance_id, &T::Class(), attribute_index)->template as(); } - std::vector get_inverse(int instance_id, const ifcopenshell::declaration* declaration, int attribute_index); + std::vector get_inverse(int instance_id, const ifcopenshell::declaration* declaration, int attribute_index); size_t get_total_inverses(int instance_id); @@ -384,7 +384,7 @@ public: void recalculate_id_counter(); - express::Base add_entity(const express::Base& entity, int instance_id = -1); + express::base add_entity(const express::base& entity, int instance_id = -1); /// Removes entity instance from file and unsets references. /// @@ -395,7 +395,7 @@ public: /// ifcopenshell::IfcBaseClass *const inst = *it; /// model->remove_entity(inst); /// } - void remove_entity(const express::Base& entity); + void remove_entity(const express::base& entity); const spf_header& header() const { return *header_; } spf_header& header() { return *header_; } @@ -404,27 +404,27 @@ public: const ifcopenshell::schema_definition* schema() const; - std::pair get_unit(const std::string& unit_type); + std::pair get_unit(const std::string& unit_type); void build_inverses(); void register_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, int instance_id, int attribute_index); - void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::Base& entity, int attribute_index); + void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::base& entity, int attribute_index); entity_instance_by_guid_t internal_guid_map() { return byguid_; }; - void add_type_ref(const express::Base& new_entity); - void remove_type_ref(const express::Base& new_entity); - void process_deletion_inverse(const express::Base& entity); + void add_type_ref(const express::base& new_entity); + void remove_type_ref(const express::base& new_entity); + void process_deletion_inverse(const express::base& entity); - void build_inverses_(const express::Base& entity); + void build_inverses_(const express::base& entity); template T create(int instance_id = -1) { return create(&T::Class(), instance_id).template as(); } - express::Base create(const ifcopenshell::declaration* declaration, int instance_id = -1); + express::base create(const ifcopenshell::declaration* declaration, int instance_id = -1); void batch() { batch_mode_ = true; diff --git a/src/ifcparse/file_reader.cpp b/src/ifcparse/file_reader.cpp index 27a426383d..75d5b92213 100644 --- a/src/ifcparse/file_reader.cpp +++ b/src/ifcparse/file_reader.cpp @@ -218,12 +218,12 @@ const file_reader_page& paged_file_impl::fetchPage_(size_t idx) const { } lru_.push_front(idx); auto lit = lru_.begin(); - auto [emplaced_it, ok] = map_.emplace(idx, Entry{std::move(pg), lit}); + auto [emplaced_it, ok] = map_.emplace(idx, entry{std::move(pg), lit}); (void)ok; return emplaced_it->second.page; } -void paged_file_impl::touch_(std::unordered_map::iterator it) const { +void paged_file_impl::touch_(std::unordered_map::iterator it) const { lru_.erase(it->second.it); lru_.push_front(it->first); it->second.it = lru_.begin(); diff --git a/src/ifcparse/file_reader.h b/src/ifcparse/file_reader.h index 1fce946efd..a8f924782a 100644 --- a/src/ifcparse/file_reader.h +++ b/src/ifcparse/file_reader.h @@ -68,7 +68,7 @@ template class file_reader { public: using impl_type = Impl; - using Page = file_reader_page; + using page = file_reader_page; file_reader() = default; @@ -215,7 +215,7 @@ private: class IFC_PARSE_API paged_file_impl { public: - struct Entry { + struct entry { file_reader_page page; std::list::iterator it; }; @@ -232,7 +232,7 @@ public: private: const file_reader_page& fetchPage_(size_t page_index) const; - void touch_(std::unordered_map::iterator entry_it) const; + void touch_(std::unordered_map::iterator entry_it) const; void evict_() const; std::string fn_; @@ -241,7 +241,7 @@ private: size_t page_size_ = 4096; size_t capacity_ = 8; mutable std::list lru_; - mutable std::unordered_map map_; + mutable std::unordered_map map_; }; #ifdef USE_MMAP diff --git a/src/ifcparse/hierarchy_helper.h b/src/ifcparse/hierarchy_helper.h index 0d16db8a59..a740d88f06 100644 --- a/src/ifcparse/hierarchy_helper.h +++ b/src/ifcparse/hierarchy_helper.h @@ -49,17 +49,17 @@ inline const char* children_attribute_name(const ifcopenshell::declaration& decl } template -express::Base get_parent_of_relation(const Relation& relation) { - return relation.template as().get(parent_attribute_name(relation.declaration())); +express::base get_parent_of_relation(const Relation& relation) { + return relation.template as().get(parent_attribute_name(relation.declaration())); } template -std::vector get_children_of_relation(const Relation& relation) { - return relation.template as().get(children_attribute_name(relation.declaration())); +std::vector get_children_of_relation(const Relation& relation) { + return relation.template as().get(children_attribute_name(relation.declaration())); } template -void set_children_of_relation(Relation& relation, std::vector& children) { +void set_children_of_relation(Relation& relation, std::vector& children) { relation.set_attribute_value(children_attribute_name(relation.declaration()), children); } @@ -193,7 +193,7 @@ class IFC_SCHEMA_API hierarchy_helper : public ifcopenshell::file { owner_history = addOwnerHistory(); } - std::vector related_objects; + std::vector related_objects; related_objects.push_back(related_object); T t = create(); diff --git a/src/ifcparse/instance_data.h b/src/ifcparse/instance_data.h index 46bd1f4580..883eadc5c9 100644 --- a/src/ifcparse/instance_data.h +++ b/src/ifcparse/instance_data.h @@ -75,72 +75,72 @@ class IFC_PARSE_API empty_aggregate_of_aggregate_t {}; namespace impl { template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "null"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "derived"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "int"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "int"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "bool"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "logical"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "real"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "string"; } }; template <> - struct VariantTypeName> { + struct variant_type_name> { static std::string get() { return "binary"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "enumeration"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "instance"; } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "aggregate"; } }; template - struct VariantTypeName> { - static std::string get() { return "aggregate of " + VariantTypeName::get(); } + struct variant_type_name> { + static std::string get() { return "aggregate of " + variant_type_name::get(); } }; template <> - struct VariantTypeName { + struct variant_type_name { static std::string get() { return "aggregate of aggregate"; } }; } @@ -182,7 +182,7 @@ typedef parameter_pack < // An entity instance argument. It will either serialize to // e.g. #123 or datatype identifier for simple types, e.g. // IFCREAL(12.3) - express::Base, + express::base, // AGGREGATES: empty_aggregate_t, @@ -198,7 +198,7 @@ typedef parameter_pack < // An aggregate of entity instances. It will either serialize to // e.g. (#1,#2,#3) or datatype identifier for simple types, // e.g. (IFCREAL(1.2),IFCINTEGER(3.)) - std::vector, + std::vector, // AGGREGATES OF AGGREGATES: empty_aggregate_of_aggregate_t, @@ -207,7 +207,7 @@ typedef parameter_pack < // An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.)) std::vector>, // An aggregate of an aggregate of entities. E.g. ((#1, #2), (#3)) - std::vector>> + std::vector>> type_variant_parameter_pack; template @@ -221,17 +221,17 @@ struct pack_to_variant_array> { using in_memory_attribute_storage = pack_to_variant_array::type; template -struct TypeEncoder_t; +struct type_encoder_t; template -struct TypeEncoder_t> { +struct type_encoder_t> { template static char encode_type() { return 'A' + ::impl::TypeIndex_v; } }; -using TypeEncoder = TypeEncoder_t; +using type_encoder = type_encoder_t; class IFC_PARSE_API mutable_attribute_value { public: @@ -261,14 +261,14 @@ namespace impl { bool serialize(std::string& buffer, const T& value) { auto byte_count = sizeof(typename T::value_type) * value.size(); buffer.resize(byte_count + 1); - buffer[0] = TypeEncoder::encode_type(); + buffer[0] = type_encoder::encode_type(); memcpy(buffer.data() + 1, value.data(), byte_count); return true; } template ::value&& is_contiguous_container::value, int>::type = 0> bool serialize(std::string& buffer, const T& value) { - buffer = std::string(1, TypeEncoder::encode_type()); + buffer = std::string(1, type_encoder::encode_type()); for (auto& nested_value : value) { std::string nested_buffer; serialize(nested_buffer, nested_value); @@ -285,7 +285,7 @@ namespace impl { template || std::is_floating_point_v, int>::type = 0> bool serialize(std::string& buffer, const T& value) { buffer.resize(sizeof(T) + 1); - buffer[0] = TypeEncoder::encode_type(); + buffer[0] = type_encoder::encode_type(); memcpy(buffer.data() + 1, &value, sizeof(T)); return true; } @@ -300,18 +300,18 @@ namespace impl { bool serialize(std::string& buffer, const boost::dynamic_bitset<>& value); - bool serialize(std::string& buffer, const express::Base& value); + bool serialize(std::string& buffer, const express::base& value); bool serialize(std::string& buffer, const enumeration_reference& value); - bool serialize(std::string& buffer, const std::vector& value); + bool serialize(std::string& buffer, const std::vector& value); - bool serialize(std::string& buffer, const std::vector>& value); + bool serialize(std::string& buffer, const std::vector>& value); template ::value && !is_contiguous_container::value, int>::type = 0> bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, T& value, bool has_type_prefix = true) { static_cast(storage); - if (has_type_prefix && buffer[0] != TypeEncoder::encode_type()) { + if (has_type_prefix && buffer[0] != type_encoder::encode_type()) { return false; } auto element_count = (buffer.size() - (has_type_prefix ? 1 : 0)) / sizeof(typename T::value_type); @@ -324,7 +324,7 @@ namespace impl { bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, T& value) { // @todo auto ptr = buffer.data(); - if (*ptr != TypeEncoder::encode_type()) { + if (*ptr != type_encoder::encode_type()) { return false; } ptr++; @@ -345,7 +345,7 @@ namespace impl { template || std::is_floating_point_v, int>::type = 0> bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, T& value) { static_cast(storage); - if (buffer[0] != TypeEncoder::encode_type()) { + if (buffer[0] != type_encoder::encode_type()) { return false; } memcpy(&value, buffer.data() + 1, sizeof(T)); @@ -356,9 +356,9 @@ namespace impl { bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, boost::dynamic_bitset<>& value); - bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector& value); + bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector& value); - bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector>& value); + bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector>& value); } #endif @@ -408,17 +408,17 @@ public: operator double() const; operator std::string() const; operator boost::dynamic_bitset<>() const; - operator express::Base() const; + operator express::base() const; operator std::vector() const; operator std::vector() const; operator std::vector() const; operator std::vector>() const; - operator std::vector() const; + operator std::vector() const; operator std::vector>() const; operator std::vector>() const; - operator std::vector>() const; + operator std::vector>() const; operator enumeration_reference() const; @@ -449,7 +449,7 @@ public: case ifcopenshell::Argument_ENUMERATION: return visitor((enumeration_reference)*this); case ifcopenshell::Argument_ENTITY_INSTANCE: - return visitor((express::Base) * this); + return visitor((express::base) * this); case ifcopenshell::Argument_AGGREGATE_OF_INT: return visitor((std::vector)*this); case ifcopenshell::Argument_AGGREGATE_OF_DOUBLE: @@ -459,13 +459,13 @@ public: case ifcopenshell::Argument_AGGREGATE_OF_BINARY: return visitor((std::vector>)*this); case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE: - return visitor((std::vector)*this); + return visitor((std::vector)*this); case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_INT: return visitor((std::vector>)*this); case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: return visitor((std::vector>)*this); case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: - return visitor((std::vector>)*this); + return visitor((std::vector>)*this); case ifcopenshell::Argument_EMPTY_AGGREGATE: return visitor(empty_aggregate_t{}); case ifcopenshell::Argument_AGGREGATE_OF_EMPTY_AGGREGATE: diff --git a/src/ifcparse/logger.cpp b/src/ifcparse/logger.cpp index 09bb1ad8b9..8fc27460dc 100644 --- a/src/ifcparse/logger.cpp +++ b/src/ifcparse/logger.cpp @@ -73,12 +73,12 @@ void write_code(T& out, const std::string& code) { } template -void plain_text_message(T& out, const express::Base& current_product, logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) { +void plain_text_message(T& out, const express::base& current_product, logger::severity type, const std::string& code, const std::string& message, const express::base& instance) { out << "[" << severity_strings::value[type] << "] "; write_code(out, code); out << "[" << get_time(type <= logger::LOG_PERF).c_str() << "] "; if (current_product) { - express::Entity entity = current_product.as(); + express::entity entity = current_product.as(); if (entity) { std::string global_id = entity.get("GlobalId"); out << "{" << global_id.c_str() << "} "; @@ -104,7 +104,7 @@ std::basic_string string_as(const std::string& string) { } template -void json_message(T& out, const express::Base& current_product, logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) { +void json_message(T& out, const express::base& current_product, logger::severity type, const std::string& code, const std::string& message, const express::base& instance) { boost::property_tree::basic_ptree, std::basic_string> property_tree; static const typename T::char_type time_string[] = {'t', 'i', 'm', 'e', 0}; @@ -146,8 +146,8 @@ log_message::log_message( const std::string& code, const std::string& timestamp, const std::string& message, - const express::Base& instance, - const express::Base& current_product) + const express::base& instance, + const express::base& current_product) : severity(severity) , timestamp(timestamp) , message(message) @@ -170,15 +170,15 @@ logger& logger::root() { return root_logger; } -const express::Base& logger::current_product() const { +const express::base& logger::current_product() const { return current_product_; } -void logger::current_product(const express::Base& product) { +void logger::current_product(const express::base& product) { current_product_ = product; } -void logger::set_product(std::optional product) { +void logger::set_product(std::optional product) { if (verbosity_ <= LOG_DEBUG && product) { message(LOG_DEBUG, "SYS", 3, "Begin processing", *product); } @@ -186,7 +186,7 @@ void logger::set_product(std::optional product) { print_performance_stats(); performance_statistics_.clear(); } - current_product(product.value_or(express::Base{})); + current_product(product.value_or(express::base{})); } void logger::set_output(std::ostream* stream1, std::ostream* stream2) { @@ -204,23 +204,23 @@ void logger::set_output(std::wostream* stream1, std::wostream* stream2) { wlog2_ = stream2; } -void logger::message(logger::Severity type, const std::string& text, const express::Base& instance) { +void logger::message(logger::severity type, const std::string& text, const express::base& instance) { message(type, std::string(), text, instance); } -void logger::message(logger::Severity type, const std::exception& exception, const express::Base& instance) { +void logger::message(logger::severity type, const std::exception& exception, const express::base& instance) { message(type, std::string(exception.what()), instance); } -void logger::message(logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& text, const express::Base& instance) { +void logger::message(logger::severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& text, const express::base& instance) { message(type, format_code(code_prefix, code_number), text, instance); } -void logger::message(logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance) { +void logger::message(logger::severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance) { message(type, code_prefix, code_number, std::string(exception.what()), instance); } -void logger::message(logger::Severity type, const std::string& code, const std::string& text, const express::Base& instance) { +void logger::message(logger::severity type, const std::string& code, const std::string& text, const express::base& instance) { if (type < verbosity_) { return; } @@ -359,22 +359,22 @@ void logger::print_performance_stats() { } } -void logger::verbosity(logger::Severity severity) { +void logger::verbosity(logger::severity severity) { verbosity_ = severity; } -logger::Severity logger::verbosity() const { +logger::severity logger::verbosity() const { return verbosity_; } -logger::Severity logger::max_severity() const { +logger::severity logger::max_severity() const { return max_severity_; } -void logger::output_format(Format format) { +void logger::output_format(format format) { format_ = format; } -logger::Format logger::output_format() const { +logger::format logger::output_format() const { return format_; } diff --git a/src/ifcparse/logger.h b/src/ifcparse/logger.h index b356f57c0e..af111059db 100644 --- a/src/ifcparse/logger.h +++ b/src/ifcparse/logger.h @@ -45,8 +45,8 @@ class IFC_PARSE_API log_message { const std::string& code, const std::string& timestamp, const std::string& message, - const express::Base& instance = express::Base(), - const express::Base& current_product = express::Base()); + const express::base& instance = express::base(), + const express::base& current_product = express::base()); }; class IFC_PARSE_API logger { @@ -57,13 +57,13 @@ class IFC_PARSE_API logger { LOG_NOTICE, LOG_WARNING, LOG_ERROR - } Severity; + } severity; typedef enum { FMT_PLAIN, FMT_JSON, FMT_INMEMORY - } Format; + } format; private: std::vector log_messages_; @@ -75,11 +75,11 @@ class IFC_PARSE_API logger { std::wostream* wlog2_ = nullptr; std::stringstream log_stream_; - express::Base current_product_; + express::base current_product_; - Severity verbosity_ = LOG_NOTICE; - Format format_ = FMT_PLAIN; - Severity max_severity_ = LOG_NOTICE; + severity verbosity_ = LOG_NOTICE; + format format_ = FMT_PLAIN; + severity max_severity_ = LOG_NOTICE; std::optional first_timepoint_; std::map performance_statistics_; @@ -88,9 +88,9 @@ class IFC_PARSE_API logger { bool print_perf_stats_on_element_ = false; std::mutex mutex_; - const express::Base& current_product() const; - void current_product(const express::Base& product); - void message(Severity type, const std::string& code, const std::string& message, const express::Base& instance); + const express::base& current_product() const; + void current_product(const express::base& product); + void message(severity type, const std::string& code, const std::string& message, const express::base& instance); public: logger() = default; @@ -99,39 +99,39 @@ class IFC_PARSE_API logger { static logger& root(); - void set_product(std::optional product); - void set_product(const express::Base& product) { set_product(std::optional(product)); } + void set_product(std::optional product); + void set_product(const express::base& product) { set_product(std::optional(product)); } void set_output(std::wostream* stream1, std::wostream* stream2); void set_output(std::ostream* stream1, std::ostream* stream2); - void verbosity(Severity severity); - Severity verbosity() const; - Severity max_severity() const; + void verbosity(severity severity); + severity verbosity() const; + severity max_severity() const; - void output_format(Format format); - Format output_format() const; + void output_format(format format); + format output_format() const; - void message(Severity type, const std::string& message, const express::Base& instance = express::Base()); - void message(Severity type, const std::exception& exception, const express::Base& instance = express::Base()); - void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()); - void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()); + void message(severity type, const std::string& message, const express::base& instance = express::base()); + void message(severity type, const std::exception& exception, const express::base& instance = express::base()); + void message(severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base()); + void message(severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base()); - void notice(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_NOTICE, message, instance); } - void warning(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_WARNING, message, instance); } - void error(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_ERROR, message, instance); } + void notice(const std::string& message, const express::base& instance = express::base()) { this->message(LOG_NOTICE, message, instance); } + void warning(const std::string& message, const express::base& instance = express::base()) { this->message(LOG_WARNING, message, instance); } + void error(const std::string& message, const express::base& instance = express::base()) { this->message(LOG_ERROR, message, instance); } - void notice(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_NOTICE, exception, instance); } - void warning(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_WARNING, exception, instance); } - void error(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_ERROR, exception, instance); } + void notice(const std::exception& exception, const express::base& instance = express::base()) { message(LOG_NOTICE, exception, instance); } + void warning(const std::exception& exception, const express::base& instance = express::base()) { message(LOG_WARNING, exception, instance); } + void error(const std::exception& exception, const express::base& instance = express::base()) { message(LOG_ERROR, exception, instance); } - void notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_NOTICE, code_prefix, code_number, message, instance); } - void warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_WARNING, code_prefix, code_number, message, instance); } - void error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_ERROR, code_prefix, code_number, message, instance); } + void notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base()) { this->message(LOG_NOTICE, code_prefix, code_number, message, instance); } + void warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base()) { this->message(LOG_WARNING, code_prefix, code_number, message, instance); } + void error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base()) { this->message(LOG_ERROR, code_prefix, code_number, message, instance); } - void notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_NOTICE, code_prefix, code_number, exception, instance); } - void warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_WARNING, code_prefix, code_number, exception, instance); } - void error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_ERROR, code_prefix, code_number, exception, instance); } + void notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base()) { message(LOG_NOTICE, code_prefix, code_number, exception, instance); } + void warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base()) { message(LOG_WARNING, code_prefix, code_number, exception, instance); } + void error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base()) { message(LOG_ERROR, code_prefix, code_number, exception, instance); } void status(const std::string& message, bool new_line = true); diff --git a/src/ifcparse/parse.cpp b/src/ifcparse/parse.cpp index 1ee02ecc3f..aab635a458 100644 --- a/src/ifcparse/parse.cpp +++ b/src/ifcparse/parse.cpp @@ -940,7 +940,7 @@ direct_aggregate read_direct_aggregate( tokens->next(); auto data = storage.load(tokens, entity_instance_name, declaration, entity, attribute_index); storage.read_simple_type_instances.push_back(data); - aggregate.append(ifcopenshell::reference_or_simple_type{express::Base(data)}); + aggregate.append(ifcopenshell::reference_or_simple_type{express::base(data)}); } catch (exception& e) { logger.error("SYN", 123, std::string(e.what()) + " at offset " + std::to_string(next.start_pos)); } @@ -1016,7 +1016,7 @@ shared_pointer_type ifcopenshell::impl::in_memory_file_storage::load( if (retain_value) { auto data = load(tokens, entity_instance_name, simple_declaration, entity, reference_attribute_index); read_simple_type_instances.push_back(data); - storage.set(attribute_index_within_data, express::Base(data)); + storage.set(attribute_index_within_data, express::base(data)); } else { skip_aggregate(tokens); } @@ -1056,7 +1056,7 @@ void ifcopenshell::impl::in_memory_file_storage::register_inverse(unsigned id_fr byref_excl_.add((uint32_t)inst_id, (uint32_t)id_from, (uint16_t)from_entity->index_in_schema(), attribute_index); } -void ifcopenshell::impl::in_memory_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::Base& inst, int attribute_index) { +void ifcopenshell::impl::in_memory_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index) { if (!byref_excl_.remove((uint32_t)inst.id(), (uint32_t)id_from, (uint16_t)from_entity->index_in_schema(), attribute_index)) { // @todo inverses also need to be populated when multiple instances are added to a new file. // throw ifcopenshell::exception("Instance not found among inverses"); @@ -1095,7 +1095,7 @@ void ifcopenshell::impl::rocks_db_file_storage::register_inverse(unsigned id_fro #endif } -void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::Base& inst, int attribute_index) { +void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index) { #ifdef IFOPSH_WITH_ROCKSDB static std::string s; auto inst_id = inst.id(); @@ -1116,7 +1116,7 @@ void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_f #endif } -void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::Base& new_entity) +void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::base& new_entity) { #ifdef IFOPSH_WITH_ROCKSDB size_t v; @@ -1146,7 +1146,7 @@ void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::Base #endif } -void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::Base& new_entity) +void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::base& new_entity) { #ifdef IFOPSH_WITH_ROCKSDB if (new_entity.declaration().as_entity()) { @@ -1167,10 +1167,10 @@ void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::B } namespace { - class StringBuilderVisitor : public boost::static_visitor { + class string_builder_visitor : public boost::static_visitor { private: - StringBuilderVisitor(const StringBuilderVisitor&); //N/A - StringBuilderVisitor& operator=(const StringBuilderVisitor&); //N/A + string_builder_visitor(const string_builder_visitor&); //N/A + string_builder_visitor& operator=(const string_builder_visitor&); //N/A std::ostream& data_; template @@ -1269,7 +1269,7 @@ namespace { bool upper_; public: - StringBuilderVisitor(std::ostream& stream, bool upper = false) + string_builder_visitor(std::ostream& stream, bool upper = false) : data_(stream), upper_(upper) {} void operator()(const blank& /*i*/) { data_ << "$"; } @@ -1294,14 +1294,14 @@ namespace { void operator()(const enumeration_reference& i) { data_ << "." << i.value() << "."; } - void operator()(const express::Base& i) { + void operator()(const express::base& i) { if (i.declaration().as_entity() == nullptr || i.declaration().schema() == &Header_section_schema::get_schema()) { i.to_string(data_, upper_); } else { data_ << "#" << i.id(); } } - void operator()(const std::vector& i) { + void operator()(const std::vector& i) { data_ << "("; for (auto it = i.begin(); it != i.end(); ++it) { if (it != i.begin()) { @@ -1313,7 +1313,7 @@ namespace { } void operator()(const std::vector>& i); void operator()(const std::vector>& i); - void operator()(const std::vector>& i) { + void operator()(const std::vector>& i) { data_ << "("; for (auto outer_it = i.begin(); outer_it != i.end(); ++outer_it) { if (outer_it != i.begin()) { @@ -1335,7 +1335,7 @@ namespace { }; template <> - void StringBuilderVisitor::serialize(const std::vector& i) { + void string_builder_visitor::serialize(const std::vector& i) { data_ << "("; for (std::vector::const_iterator it = i.begin(); it != i.end(); ++it) { if (it != i.begin()) { @@ -1348,7 +1348,7 @@ namespace { } template <> - void StringBuilderVisitor::serialize(const std::vector& i) { + void string_builder_visitor::serialize(const std::vector& i) { data_ << "("; for (std::vector::const_iterator it = i.begin(); it != i.end(); ++it) { if (it != i.begin()) { @@ -1360,7 +1360,7 @@ namespace { } template <> - void StringBuilderVisitor::serialize(const std::vector>& i) { + void string_builder_visitor::serialize(const std::vector>& i) { data_ << "("; for (std::vector>::const_iterator it = i.begin(); it != i.end(); ++it) { if (it != i.begin()) { @@ -1371,11 +1371,11 @@ namespace { data_ << ")"; } - void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } - void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } - void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } - void StringBuilderVisitor::operator()(const std::vector>& i) { serialize(i); } - void StringBuilderVisitor::operator()(const std::vector>& i) { + void string_builder_visitor::operator()(const std::vector& i) { serialize(i); } + void string_builder_visitor::operator()(const std::vector& i) { serialize(i); } + void string_builder_visitor::operator()(const std::vector& i) { serialize(i); } + void string_builder_visitor::operator()(const std::vector>& i) { serialize(i); } + void string_builder_visitor::operator()(const std::vector>& i) { data_ << "("; for (std::vector>::const_iterator it = i.begin(); it != i.end(); ++it) { if (it != i.begin()) { @@ -1385,7 +1385,7 @@ namespace { } data_ << ")"; } - void StringBuilderVisitor::operator()(const std::vector>& i) { + void string_builder_visitor::operator()(const std::vector>& i) { data_ << "("; for (std::vector>::const_iterator it = i.begin(); it != i.end(); ++it) { if (it != i.begin()) { @@ -1406,7 +1406,7 @@ void instance_data::to_string(std::ostream& ss, bool upper) const { ss << "("; - StringBuilderVisitor vis(ss, upper); + string_builder_visitor vis(ss, upper); // In almost all cases, storage is initialized with the size of the schema declaration, // apparently except in case of header entities and invalid in-line type declarations. @@ -1467,14 +1467,14 @@ ifcopenshell::argument_type get_argument_type(const ifcopenshell::declaration* d class unregister_inverse_visitor { private: file& file_; - const express::Base data_; + const express::base data_; public: - unregister_inverse_visitor(file& file, const express::Base& data) + unregister_inverse_visitor(file& file, const express::base& data) : file_(file), data_(data) {} - void operator()(const express::Base& inst, int index) { + void operator()(const express::base& inst, int index) { file_.unregister_inverse(data_.id(), data_.declaration().as_entity(), inst, index); } }; @@ -1482,27 +1482,27 @@ class unregister_inverse_visitor { class register_inverse_visitor { private: file& file_; - const express::Base data_; + const express::base data_; public: - register_inverse_visitor(file& file, const express::Base& data) + register_inverse_visitor(file& file, const express::base& data) : file_(file), data_(data) {} - void operator()(const express::Base& inst, int index) { + void operator()(const express::base& inst, int index) { file_.register_inverse(data_.id(), data_.declaration().as_entity(), inst.id(), index); } }; class add_to_instance_list_visitor { private: - std::vector* list_; + std::vector* list_; public: - add_to_instance_list_visitor(std::vector* list) + add_to_instance_list_visitor(std::vector* list) : list_(list) {} - void operator()(const express::Base& inst) { + void operator()(const express::base& inst) { list_->push_back(inst); } }; @@ -1512,26 +1512,26 @@ class apply_individual_instance_visitor { std::optional attribute_; int attribute_index_; - const express::Base inst_; + const express::base inst_; template void apply_attribute_(T& t, const attribute_value& attr, int index) const { switch (attr.type()) { case ifcopenshell::Argument_ENTITY_INSTANCE: { - express::Base inst = attr; + express::base inst = attr; t(inst, index); break; } case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE: { - std::vector entity_list_attribute = attr; + std::vector entity_list_attribute = attr; for (auto& inst : entity_list_attribute) { t(inst, index); } break; } case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: { - std::vector> nested_list_attr = attr; + std::vector> nested_list_attr = attr; for (auto& vec : nested_list_attr) { for (auto& inst : vec) { t(inst, index); @@ -1549,7 +1549,7 @@ class apply_individual_instance_visitor { , attribute_index_(idx) {} - apply_individual_instance_visitor(const express::Base& data) + apply_individual_instance_visitor(const express::base& data) : inst_(data) {} @@ -1569,9 +1569,9 @@ class apply_individual_instance_visitor { template typename std::enable_if< - (!std::is_base_of_v || std::is_same_v), + (!std::is_base_of_v || std::is_same_v), void>::type -express::Base::set_attribute_value(size_t i, const T& t) { +express::base::set_attribute_value(size_t i, const T& t) { if constexpr (std::is_same_v, double>) { if (!std::isfinite(t)) { throw ifcopenshell::exception("Only finite values are allowed"); @@ -1597,7 +1597,7 @@ express::Base::set_attribute_value(size_t i, const T& t) { auto guid = (std::string) current_attribute; auto it = file()->internal_guid_map().find(guid); if (it != file()->internal_guid_map().end()) { - const std::pair& p = *it; + const std::pair& p = *it; if (p.second == *this) { file()->internal_guid_map().erase(it); } @@ -1607,7 +1607,7 @@ express::Base::set_attribute_value(size_t i, const T& t) { } } - if constexpr (std::is_same_v || std::is_same_v> || std::is_same_v>> || std::is_same_v) { + if constexpr (std::is_same_v || std::is_same_v> || std::is_same_v>> || std::is_same_v) { // Deregister inverse indices in file unregister_inverse_visitor visitor(*file(), *this); apply_individual_instance_visitor(current_attribute, (int)i).apply(visitor); @@ -1620,7 +1620,7 @@ express::Base::set_attribute_value(size_t i, const T& t) { auto new_attribute = get_attribute_value(i); // Register inverse indices in file - if constexpr (std::is_same_v || std::is_same_v> || std::is_same_v>>) { + if constexpr (std::is_same_v || std::is_same_v> || std::is_same_v>>) { register_inverse_visitor visitor(*file(), *this); apply_individual_instance_visitor(new_attribute, (int)i).apply(visitor); } @@ -1642,9 +1642,9 @@ express::Base::set_attribute_value(size_t i, const T& t) { template typename std::enable_if< - (!std::is_base_of_v || std::is_same_v), + (!std::is_base_of_v || std::is_same_v), void>::type -express::Base::set_attribute_value(const std::string& s, const T& t) +express::base::set_attribute_value(const std::string& s, const T& t) { set_attribute_value(declaration().as_entity()->attribute_index(s), t); } @@ -2285,7 +2285,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } auto current_id = std::get<0>(*inst); - express::Base instance(std::get<2>(*inst)); + express::base instance(std::get<2>(*inst)); if (instance.declaration().is(*ifcroot_type_)) { try { @@ -2350,8 +2350,8 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con auto& storage = owner; auto attr_index = p.first.index_; - if (storage->template has_attribute_value(attr_index)) { - express::Base inst = storage->get_attribute_value(attr_index); + if (storage->template has_attribute_value(attr_index)) { + express::base inst = storage->get_attribute_value(attr_index); if (inst && !inst.declaration().as_entity()) { // Probably a case of IfcPropertySetDefinitionSet, divert storage of reference to the simply type instance #ifdef IFOPSH_SAFE_INSTANCE @@ -2364,16 +2364,16 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con } if (storage->template has_attribute_value(attr_index)) { - storage->set_attribute_value(attr_index, express::Base(it->second)); + storage->set_attribute_value(attr_index, express::base(it->second)); } else { logger_.get().error("Duplicate definition for instance reference"); } } - } else if (auto inst = std::get_if(v)) { + } else if (auto inst = std::get_if(v)) { owner->set_attribute_value(p.first.index_, *inst); } } else if (auto* vv = std::get_if>(&p.second)) { - std::vector instances; + std::vector instances; instances.reserve(vv->size()); for (const auto& vi : *vv) { if (auto* name = std::get_if(&vi)) { @@ -2384,9 +2384,9 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (it == byid_.end()) { logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { - instances.push_back(express::Base(it->second)); + instances.push_back(express::base(it->second)); } - } else if (auto* inst = std::get_if(&vi)) { + } else if (auto* inst = std::get_if(&vi)) { instances.push_back(*inst); } } @@ -2394,8 +2394,8 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con auto& storage = owner; auto attr_index = p.first.index_; - if (storage->template has_attribute_value(attr_index)) { - express::Base inst = storage->get_attribute_value(attr_index); + if (storage->template has_attribute_value(attr_index)) { + express::base inst = storage->get_attribute_value(attr_index); if (inst && !inst.declaration().as_entity()) { // Probably a case of IfcPropertySetDefinitionSet, divert storage of reference to the simply type instance #ifdef IFOPSH_SAFE_INSTANCE @@ -2413,7 +2413,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con logger_.get().error("Duplicate definition for instance reference"); } } else if (auto* vvv = std::get_if>>(&p.second)) { - std::vector> instances; + std::vector> instances; for (const auto& vi : *vvv) { auto& inner = instances.emplace_back(); for (const auto& vii : vi) { @@ -2425,9 +2425,9 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con if (it == byid_.end()) { logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset)); } else { - inner.push_back(express::Base(it->second)); + inner.push_back(express::base(it->second)); } - } else if (auto* inst = std::get_if(&vii)) { + } else if (auto* inst = std::get_if(&vii)) { inner.push_back(*inst); } } @@ -2436,8 +2436,8 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con auto& storage = owner; auto attr_index = p.first.index_; - if (storage->template has_attribute_value(attr_index)) { - express::Base inst = storage->get_attribute_value(attr_index); + if (storage->template has_attribute_value(attr_index)) { + express::base inst = storage->get_attribute_value(attr_index); if (inst && !inst.declaration().as_entity()) { // Probably a case of IfcPropertySetDefinitionSet, divert storage of reference to the simply type instance #ifdef IFOPSH_SAFE_INSTANCE @@ -2480,15 +2480,15 @@ void file::recalculate_id_counter() { } class traversal_recorder { - std::vector list_; - std::map> instances_by_level_; + std::vector list_; + std::map> instances_by_level_; int mode_; public: traversal_recorder(int mode) : mode_(mode) { }; - void push_back(int level, const express::Base& instance) { + void push_back(int level, const express::base& instance) { if (mode_ == 0) { list_.push_back(instance); } else { @@ -2497,11 +2497,11 @@ class traversal_recorder { } } - std::vector get_list() const { + std::vector get_list() const { if (mode_ == 0) { return list_; } - std::vector l; + std::vector l; for (const auto& p : instances_by_level_) { l.insert(l.end(), p.second.begin(), p.second.end()); } @@ -2511,22 +2511,22 @@ class traversal_recorder { class traversal_visitor { private: - std::set& visited_; + std::set& visited_; traversal_recorder& list_; int level_; int max_level_; public: - traversal_visitor(std::set& visited, traversal_recorder& list, int level, int max_level) + traversal_visitor(std::set& visited, traversal_recorder& list, int level, int max_level) : visited_(visited), list_(list), level_(level), max_level_(max_level) {} - void operator()(const express::Base& inst, int index); + void operator()(const express::base& inst, int index); }; -void traverse_(const express::Base& instance, std::set& visited, traversal_recorder& list, int level, int max_level) { +void traverse_(const express::base& instance, std::set& visited, traversal_recorder& list, int level, int max_level) { if (visited.find(instance) != visited.end()) { return; } @@ -2541,12 +2541,12 @@ void traverse_(const express::Base& instance, std::set& visited, apply_individual_instance_visitor(instance).apply(visit); } -void traversal_visitor::operator()(const express::Base& inst, int /* index */) { +void traversal_visitor::operator()(const express::base& inst, int /* index */) { traverse_(inst, visited_, list_, level_, max_level_); } -std::vector ifcopenshell::traverse(const express::Base& instance, int max_level) { - std::set visited; +std::vector ifcopenshell::traverse(const express::base& instance, int max_level) { + std::set visited; traversal_recorder recorder(0); traverse_(instance, visited, recorder, 0, max_level); return recorder.get_list(); @@ -2554,24 +2554,24 @@ std::vector ifcopenshell::traverse(const express::Base& instance, // I'm cheating this isn't breadth-first, but rather we record visited instances // keeping track of their rank and return a list ordered by rank. Is this equivalent? -std::vector ifcopenshell::traverse_breadth_first(const express::Base& instance, int max_level) { - std::set visited; +std::vector ifcopenshell::traverse_breadth_first(const express::base& instance, int max_level) { + std::set visited; traversal_recorder recorder(1); traverse_(instance, visited, recorder, 0, max_level); return recorder.get_list(); } /// @note: for backwards compatibility -std::vector file::traverse(const express::Base& instance, int max_level) { +std::vector file::traverse(const express::base& instance, int max_level) { return ifcopenshell::traverse(instance, max_level); } /// @note: for backwards compatibility -std::vector file::traverse_breadth_first(const express::Base& instance, int max_level) { +std::vector file::traverse_breadth_first(const express::base& instance, int max_level) { return ifcopenshell::traverse_breadth_first(instance, max_level); } -express::Base file::add_entity(const express::Base& entity, int id) { +express::base file::add_entity(const express::base& entity, int id) { if (entity.file() == this) { return entity; } @@ -2613,13 +2613,13 @@ express::Base file::add_entity(const express::Base& entity, int id) { auto num_attributes = (decl->as_entity() ? decl->as_entity()->attribute_count() : 1); for (size_t i = 0; i < num_attributes; ++i) { entity.get_attribute_value(i).apply_visitor([this, i, decl, &new_entity](const auto& v) { - using U = std::decay_t; + using u = std::decay_t; // only need to copy non-instance attribute values, others are assigned below after mapping - if constexpr (std::is_same_v) { - } else if constexpr (std::is_same_v>) { - } else if constexpr (std::is_same_v>>) { - } else if constexpr (std::is_same_v) { - } else if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v>) { + } else if constexpr (std::is_same_v>>) { + } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { } else { new_entity.set_attribute_value(i, v); } @@ -2648,15 +2648,15 @@ express::Base file::add_entity(const express::Base& entity, int id) { } if (attr_type == ifcopenshell::Argument_ENTITY_INSTANCE) { - entity_entity_map_t::const_iterator eit = entity_file_map_.find(((express::Base)(attr)).identity()); + entity_entity_map_t::const_iterator eit = entity_file_map_.find(((express::base)(attr)).identity()); if (eit == entity_file_map_.end()) { throw ifcopenshell::exception("Unable to map instance to file"); } // @todo previously, we directly use storage::set() not to trigger inverse recalculation which happens at the end new_entity.set_attribute_value(i, eit->second); } else if (attr_type == ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE) { - std::vector instances = attr; - std::vector new_instances; + std::vector instances = attr; + std::vector new_instances; for (auto& i : instances) { entity_entity_map_t::const_iterator eit = entity_file_map_.find(i.identity()); if (eit == entity_file_map_.end()) { @@ -2666,8 +2666,8 @@ express::Base file::add_entity(const express::Base& entity, int id) { } new_entity.set_attribute_value(i, new_instances); } else if (attr_type == ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) { - std::vector> instances = attr; - std::vector> new_instances; + std::vector> instances = attr; + std::vector> new_instances; for (auto& v : instances) { new_instances.emplace_back(); @@ -2683,8 +2683,8 @@ express::Base file::add_entity(const express::Base& entity, int id) { new_entity.set_attribute_value(i, new_instances); } else if ((potentially_length_measure_decl != nullptr) && potentially_length_measure_decl->is(*schema()->declaration_by_name("IfcLengthMeasure"))) { if (boost::math::isnan(conversion_factor)) { - std::pair this_file_unit = {express::Base{}, 1.0}; - std::pair other_file_unit = {express::Base{}, 1.0}; + std::pair this_file_unit = {express::base{}, 1.0}; + std::pair other_file_unit = {express::base{}, 1.0}; try { this_file_unit = get_unit("LENGTHUNIT"); other_file_unit = other_file->get_unit("LENGTHUNIT"); @@ -2743,7 +2743,7 @@ express::Base file::add_entity(const express::Base& entity, int id) { return new_entity; } -void file::remove_entity(const express::Base& entity) { +void file::remove_entity(const express::base& entity) { auto id = entity.id(); auto file_entity = instance_by_id(id); @@ -2752,7 +2752,7 @@ void file::remove_entity(const express::Base& entity) { // This invalidates the iterator. A workaround is to reverse the loop: // boost::shared_ptr entities = ...; // for (auto it = entities->end() - 1; it >= entities->begin(); --it) { - // express::Base *const inst = *it; + // express::base *const inst = *it; // model->remove_entity(inst); // } @@ -2775,7 +2775,7 @@ void file::remove_entity(const express::Base& entity) { } } -void file::process_deletion_(const express::Base& entity) { +void file::process_deletion_(const express::base& entity) { auto references = instances_by_reference(entity.id()); @@ -2800,13 +2800,13 @@ void file::process_deletion_(const express::Base& entity) { ifcopenshell::argument_type attr_type = attr.type(); switch (attr_type) { case ifcopenshell::Argument_ENTITY_INSTANCE: { - express::Base instance_attribute = attr; + express::base instance_attribute = attr; if (instance_attribute == entity) { related_instance.set_attribute_value(i, blank{}); } } break; case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE: { - std::vector instance_list = attr; + std::vector instance_list = attr; auto it = std::remove(instance_list.begin(), instance_list.end(), entity); if (it != instance_list.end()) { instance_list.erase(it, instance_list.end()); @@ -2819,7 +2819,7 @@ void file::process_deletion_(const express::Base& entity) { } } break; case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: { - std::vector> instance_list_list = attr; + std::vector> instance_list_list = attr; bool updated = false; for (auto& li : instance_list_list) { auto it = std::remove(li.begin(), li.end(), entity); @@ -2864,7 +2864,7 @@ void file::process_deletion_(const express::Base& entity) { } } -void ifcopenshell::impl::in_memory_file_storage::process_deletion_inverse(const express::Base& entity) { +void ifcopenshell::impl::in_memory_file_storage::process_deletion_inverse(const express::base& entity) { auto id = entity.id(); // Delete inverses into entity @@ -2890,8 +2890,8 @@ namespace { } } -std::vector file::instances_by_type(const ifcopenshell::declaration* t) { - std::vector insts; +std::vector file::instances_by_type(const ifcopenshell::declaration* t) { + std::vector insts; if (t->as_entity() != nullptr) { visit_subtypes(t->as_entity(), [this, &insts](const ifcopenshell::entity* ent) { auto subtype_insts = instances_by_type_excl_subtypes(ent); @@ -2901,13 +2901,13 @@ std::vector file::instances_by_type(const ifcopenshell::declarati return insts; } -std::vector file::instances_by_type_excl_subtypes(const ifcopenshell::declaration* t) { +std::vector file::instances_by_type_excl_subtypes(const ifcopenshell::declaration* t) { return std::visit([t](auto& x) { if constexpr (std::is_same_v, impl::in_memory_file_storage>) { auto it = x.bytype_excl_.find(t); - return (it == x.bytype_excl_.end()) ? std::vector{} : it->second; + return (it == x.bytype_excl_.end()) ? std::vector{} : it->second; } else if constexpr (std::is_same_v, impl::rocks_db_file_storage>) { - std::vector ret; + std::vector ret; auto it = x.bytype_.find(t->index_in_schema()); if (it != x.bytype_.end()) { const auto& s = it->second; @@ -2921,22 +2921,22 @@ std::vector file::instances_by_type_excl_subtypes(const ifcopensh return ret; } else { throw std::runtime_error("Storage not initialized"); - std::vector ret; + std::vector ret; return ret; } }, storage_); } -std::vector file::instances_by_type(const std::string& t) { +std::vector file::instances_by_type(const std::string& t) { return instances_by_type(schema()->declaration_by_name(t)); } -std::vector file::instances_by_type_excl_subtypes(const std::string& t) { +std::vector file::instances_by_type_excl_subtypes(const std::string& t) { return instances_by_type_excl_subtypes(schema()->declaration_by_name(t)); } -std::vector file::instances_by_reference(int t) { - std::vector ret; +std::vector file::instances_by_reference(int t) { + std::vector ret; std::visit([this, t, &ret](auto& x) { if constexpr (std::is_same_v, impl::in_memory_file_storage>) { auto range = x.byref_excl_.equal_range((uint32_t)t); @@ -2968,18 +2968,18 @@ std::vector file::instances_by_reference(int t) { return ret; } -express::Base file::instance_by_id(int id) { +express::base file::instance_by_id(int id) { return std::visit([id](auto& x) { if constexpr (std::is_same_v, std::monostate>) { throw std::runtime_error("Storage not initialized"); - return express::Base{}; + return express::base{}; } else { return x.instance_by_id(id); } }, storage_); } -void ifcopenshell::file::add_type_ref(const express::Base& new_entity) +void ifcopenshell::file::add_type_ref(const express::base& new_entity) { std::visit([new_entity](auto& x) { if constexpr (std::is_same_v, std::monostate>) { @@ -2991,7 +2991,7 @@ void ifcopenshell::file::add_type_ref(const express::Base& new_entity) } -void ifcopenshell::file::remove_type_ref(const express::Base& new_entity) { +void ifcopenshell::file::remove_type_ref(const express::base& new_entity) { std::visit([new_entity](auto& x) { if constexpr (std::is_same_v, std::monostate>) { throw std::runtime_error("Storage not initialized"); @@ -3001,7 +3001,7 @@ void ifcopenshell::file::remove_type_ref(const express::Base& new_entity) { }, storage_); } -void ifcopenshell::file::process_deletion_inverse(const express::Base& inst) { +void ifcopenshell::file::process_deletion_inverse(const express::base& inst) { std::visit([inst](auto& x) { if constexpr (std::is_same_v, std::monostate>) { throw std::runtime_error("Storage not initialized"); @@ -3011,7 +3011,7 @@ void ifcopenshell::file::process_deletion_inverse(const express::Base& inst) { }, storage_); } -express::Base file::instance_by_guid(const std::string& guid) { +express::base file::instance_by_guid(const std::string& guid) { auto it = byguid_.find(guid); if (it == byguid_.end()) { throw exception("Instance with GlobalId '" + guid + "' not found"); @@ -3046,7 +3046,7 @@ file::type_iterator file::types_end() const { std::ostream& operator<<(std::ostream& out, const ifcopenshell::file& file) { file.header().write(out); - typedef std::vector vector_t; + typedef std::vector vector_t; vector_t sorted; std::transform(file.begin(), file.end(), std::back_inserter(sorted), [&file](const auto& x) { return x.second; }); std::sort(sorted.begin(), sorted.end(), [](const auto& a, const auto& b) { return a.id() < b.id(); }); @@ -3149,14 +3149,14 @@ std::vector file::get_inverse_indices_by_id(int instance_id) { return return_value; } -std::vector file::get_inverse(int instance_id, const ifcopenshell::declaration* type, int attribute_index) { - std::vector return_value; +std::vector file::get_inverse(int instance_id, const ifcopenshell::declaration* type, int attribute_index) { + std::vector return_value; if (type == nullptr && attribute_index == -1) { // @todo this is silly. auto r = instances_by_reference(instance_id); for (auto& i : r) { - return_value.push_back(i.as()); + return_value.push_back(i.as()); } return return_value; } @@ -3172,7 +3172,7 @@ std::vector file::get_inverse(int instance_id, const ifcopenshe for (auto it = range.first; it != range.second; ++it) { if (it->source_entity < source_types.size() && source_types[it->source_entity] && (attribute_index == -1 || it->attribute_index == attribute_index)) { - return_value.push_back(instance_by_id(it->source_id).template as()); + return_value.push_back(instance_by_id(it->source_id).template as()); } } } @@ -3188,7 +3188,7 @@ std::vector file::get_inverse(int instance_id, const ifcopenshe std::vector vals(it->value().size() / sizeof(uint32_t)); memcpy(vals.data(), it->value().data(), it->value().size()); for (auto& v : vals) { - return_value.push_back(instance_by_id(v).template as()); + return_value.push_back(instance_by_id(v).template as()); } it->Next(); } @@ -3196,7 +3196,7 @@ std::vector file::get_inverse(int instance_id, const ifcopenshe auto it = x.byref_excl_.find({instance_id, ent->index_in_schema(), attribute_index}); if (it != x.byref_excl_.end()) { for (auto& i : it->second) { - return_value.push_back(instance_by_id(i).template as()); + return_value.push_back(instance_by_id(i).template as()); } } } @@ -3251,8 +3251,8 @@ void file::set_default_header_values() { header().file_schema().setschema_identifiers(schema_identifiers); } -std::pair file::get_unit(const std::string& unit_type) { - std::pair return_value(express::Base{}, 1.); +std::pair file::get_unit(const std::string& unit_type) { + std::pair return_value(express::base{}, 1.); auto projects = instances_by_type(schema()->declaration_by_name("IfcProject")); if (projects.empty()) { @@ -3265,23 +3265,23 @@ std::pair file::get_unit(const std::string& unit_type) { if (!projects.empty()) { auto project = *projects.begin(); - express::Base unit_assignment = project.as().get("UnitsInContext"); + express::base unit_assignment = project.as().get("UnitsInContext"); - std::vector units = unit_assignment.as().get("Units"); + std::vector units = unit_assignment.as().get("Units"); for (auto& unit : units) { if (unit.declaration().is("IfcNamedUnit")) { - const std::string file_unit_type = unit.as().get("UnitType"); + const std::string file_unit_type = unit.as().get("UnitType"); if (file_unit_type != unit_type) { continue; } - express::Base siunit; + express::base siunit; if (unit.declaration().is("IfcConversionBasedUnit")) { - express::Base mu = unit.as().get("ConversionFactor"); - express::Base vlc = mu.as().get("ValueComponent"); - express::Base unc = mu.as().get("UnitComponent"); + express::base mu = unit.as().get("ConversionFactor"); + express::base vlc = mu.as().get("ValueComponent"); + express::base unc = mu.as().get("UnitComponent"); return_value.second *= static_cast(vlc.get_attribute_value(0)); return_value.first = unit; @@ -3294,7 +3294,7 @@ std::pair file::get_unit(const std::string& unit_type) { } if (siunit) { - attribute_value prefix = siunit.as().get("Prefix"); + attribute_value prefix = siunit.as().get("Prefix"); if (!prefix.isNull()) { return_value.second *= si_prefix_to_value(prefix); } @@ -3306,8 +3306,8 @@ std::pair file::get_unit(const std::string& unit_type) { return return_value; } -void ifcopenshell::file::build_inverses_(const express::Base& inst) { - std::function fn = [this, inst](const express::Base& attr, int idx) { +void ifcopenshell::file::build_inverses_(const express::base& inst) { + std::function fn = [this, inst](const express::base& attr, int idx) { if (attr.declaration().as_entity() != nullptr) { unsigned entity_attribute_id = attr.id(); const auto* decl = inst.declaration().as_entity(); @@ -3350,7 +3350,7 @@ void ifcopenshell::file::reset_identity_cache() { void ifcopenshell::file::build_inverses() { for (const auto& pair : *this) { - build_inverses_(express::Base(pair.second)); + build_inverses_(express::base(pair.second)); } } @@ -3365,7 +3365,7 @@ void ifcopenshell::file::register_inverse(unsigned id_from, const ifcopenshell:: }, storage_); } -void ifcopenshell::file::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::Base& inst, int attribute_index) +void ifcopenshell::file::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index) { std::visit([id_from, from_entity, inst, attribute_index](auto& x) { if constexpr (std::is_same_v, std::monostate>) { @@ -3380,15 +3380,15 @@ std::atomic_uint32_t instance_data::counter_(0); // bool ifcopenshell::file::guid_map_ = true; -void express::Base::unset_attribute_value(size_t index) { +void express::base::unset_attribute_value(size_t index) { data()->set_attribute_value(index, blank{}); } -attribute_value express::Base::get_attribute_value(size_t index) const { +attribute_value express::base::get_attribute_value(size_t index) const { return data()->get_attribute_value(index); } -void express::Base::to_string(std::ostream& out, bool upper) const +void express::base::to_string(std::ostream& out, bool upper) const { const auto *ent = declaration().as_entity(); if (ent != nullptr && declaration().schema() != &Header_section_schema::get_schema()) { @@ -3402,7 +3402,7 @@ void express::Base::to_string(std::ostream& out, bool upper) const data()->to_string(out, upper); } -ifcopenshell::file* express::Base::file() const { +ifcopenshell::file* express::base::file() const { return data()->file(); } @@ -3450,7 +3450,7 @@ bool ifcopenshell::impl::rocks_db_file_storage::read_schema(const ifcopenshell:: } /* -express::Base::IfcBaseClass(instance_data&& data) +express::base::IfcBaseClass(instance_data&& data) : identity_(counter_++) , id_(0) , file_(nullptr) @@ -3465,48 +3465,48 @@ express::Base::IfcBaseClass(instance_data&& data) } */ -void express::Base::set_attribute_value(size_t i, const express::Base& p) { - set_attribute_value(i, p); +void express::base::set_attribute_value(size_t i, const express::base& p) { + set_attribute_value(i, p); } -void express::Base::set_attribute_value(const std::string& name, const express::Base& p) { - set_attribute_value(name, p); +void express::base::set_attribute_value(const std::string& name, const express::base& p) { + set_attribute_value(name, p); } -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const blank& value); -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const derived& value); -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const int64_t& value); -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const bool& value); -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const boost::logic::tribool& value); -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const double& value); -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const std::string& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(size_t index, const boost::dynamic_bitset<>& value); -template void IFC_PARSE_API express::Base::set_attribute_value(size_t index, const enumeration_reference& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(size_t index, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(size_t index, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(size_t index, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(size_t index, const std::vector>& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(size_t index, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(size_t index, const std::vector>& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(size_t index, const std::vector>& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(size_t index, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const blank& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const derived& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const int64_t& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const bool& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const boost::logic::tribool& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const double& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const std::string& value); +template void IFC_PARSE_API express::base::set_attribute_value>(size_t index, const boost::dynamic_bitset<>& value); +template void IFC_PARSE_API express::base::set_attribute_value(size_t index, const enumeration_reference& value); +template void IFC_PARSE_API express::base::set_attribute_value>(size_t index, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>(size_t index, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>(size_t index, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(size_t index, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value>(size_t index, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(size_t index, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(size_t index, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(size_t index, const std::vector>& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const blank& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const derived& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const int64_t& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const bool& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const boost::logic::tribool& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const double& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const std::string& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(const std::string& name, const boost::dynamic_bitset<>& value); -template void IFC_PARSE_API express::Base::set_attribute_value(const std::string& name, const enumeration_reference& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(const std::string& name, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(const std::string& name, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(const std::string& name, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(const std::string& name, const std::vector>& value); -template void IFC_PARSE_API express::Base::set_attribute_value>(const std::string& name, const std::vector& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(const std::string& name, const std::vector>& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(const std::string& name, const std::vector>& value); -template void IFC_PARSE_API express::Base::set_attribute_value>>(const std::string& name, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const blank& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const derived& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const int64_t& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const bool& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const boost::logic::tribool& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const double& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const std::string& value); +template void IFC_PARSE_API express::base::set_attribute_value>(const std::string& name, const boost::dynamic_bitset<>& value); +template void IFC_PARSE_API express::base::set_attribute_value(const std::string& name, const enumeration_reference& value); +template void IFC_PARSE_API express::base::set_attribute_value>(const std::string& name, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>(const std::string& name, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>(const std::string& name, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(const std::string& name, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value>(const std::string& name, const std::vector& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(const std::string& name, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(const std::string& name, const std::vector>& value); +template void IFC_PARSE_API express::base::set_attribute_value>>(const std::string& name, const std::vector>& value); namespace express { template @@ -3527,36 +3527,36 @@ T Entity::get_value(const std::string& name, const T& default_value) const { } } // namespace express -template int64_t IFC_PARSE_API express::Entity::get_value(const std::string&) const; -template bool IFC_PARSE_API express::Entity::get_value(const std::string&) const; -template boost::logic::tribool IFC_PARSE_API express::Entity::get_value(const std::string&) const; -template double IFC_PARSE_API express::Entity::get_value(const std::string&) const; -template std::string IFC_PARSE_API express::Entity::get_value(const std::string&) const; -template express::Base IFC_PARSE_API express::Entity::get_value(const std::string&) const; -template boost::dynamic_bitset<> IFC_PARSE_API express::Entity::get_value>(const std::string&) const; -template enumeration_reference IFC_PARSE_API express::Entity::get_value(const std::string&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&) const; +template int64_t IFC_PARSE_API express::entity::get_value(const std::string&) const; +template bool IFC_PARSE_API express::entity::get_value(const std::string&) const; +template boost::logic::tribool IFC_PARSE_API express::entity::get_value(const std::string&) const; +template double IFC_PARSE_API express::entity::get_value(const std::string&) const; +template std::string IFC_PARSE_API express::entity::get_value(const std::string&) const; +template express::base IFC_PARSE_API express::entity::get_value(const std::string&) const; +template boost::dynamic_bitset<> IFC_PARSE_API express::entity::get_value>(const std::string&) const; +template enumeration_reference IFC_PARSE_API express::entity::get_value(const std::string&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&) const; -template int64_t IFC_PARSE_API express::Entity::get_value(const std::string&, const int64_t&) const; -template bool IFC_PARSE_API express::Entity::get_value(const std::string&, const bool&) const; -template boost::logic::tribool IFC_PARSE_API express::Entity::get_value(const std::string&, const boost::logic::tribool&) const; -template double IFC_PARSE_API express::Entity::get_value(const std::string&, const double&) const; -template std::string IFC_PARSE_API express::Entity::get_value(const std::string&, const std::string&) const; -template express::Base IFC_PARSE_API express::Entity::get_value(const std::string&, const express::Base&) const; -template boost::dynamic_bitset<> IFC_PARSE_API express::Entity::get_value>(const std::string&, const boost::dynamic_bitset<>&) const; -template enumeration_reference IFC_PARSE_API express::Entity::get_value(const std::string&, const enumeration_reference&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&, const std::vector&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&, const std::vector&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&, const std::vector&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&, const std::vector>&) const; -template std::vector IFC_PARSE_API express::Entity::get_value>(const std::string&, const std::vector&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&, const std::vector>&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&, const std::vector>&) const; -template std::vector> IFC_PARSE_API express::Entity::get_value>>(const std::string&, const std::vector>&) const; +template int64_t IFC_PARSE_API express::entity::get_value(const std::string&, const int64_t&) const; +template bool IFC_PARSE_API express::entity::get_value(const std::string&, const bool&) const; +template boost::logic::tribool IFC_PARSE_API express::entity::get_value(const std::string&, const boost::logic::tribool&) const; +template double IFC_PARSE_API express::entity::get_value(const std::string&, const double&) const; +template std::string IFC_PARSE_API express::entity::get_value(const std::string&, const std::string&) const; +template express::base IFC_PARSE_API express::entity::get_value(const std::string&, const express::base&) const; +template boost::dynamic_bitset<> IFC_PARSE_API express::entity::get_value>(const std::string&, const boost::dynamic_bitset<>&) const; +template enumeration_reference IFC_PARSE_API express::entity::get_value(const std::string&, const enumeration_reference&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&, const std::vector&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&, const std::vector&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&, const std::vector&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&, const std::vector>&) const; +template std::vector IFC_PARSE_API express::entity::get_value>(const std::string&, const std::vector&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&, const std::vector>&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&, const std::vector>&) const; +template std::vector> IFC_PARSE_API express::entity::get_value>>(const std::string&, const std::vector>&) const; diff --git a/src/ifcparse/parse.h b/src/ifcparse/parse.h index 2350a961b0..e1c944b316 100644 --- a/src/ifcparse/parse.h +++ b/src/ifcparse/parse.h @@ -83,9 +83,9 @@ class IFC_PARSE_API spf_lexer { // void TokenString(size_t offset, std::string& result); }; -IFC_PARSE_API std::vector traverse(const express::Base& instance, int max_depth = -1); +IFC_PARSE_API std::vector traverse(const express::base& instance, int max_depth = -1); -IFC_PARSE_API std::vector traverse_breadth_first(const express::Base& instance, int max_depth = -1); +IFC_PARSE_API std::vector traverse_breadth_first(const express::base& instance, int max_depth = -1); } // namespace ifcopenshell IFC_PARSE_API std::ostream& operator<<(std::ostream& stream, const ifcopenshell::file& file); diff --git a/src/ifcparse/spf_header.cpp b/src/ifcparse/spf_header.cpp index 75517f0c1d..791655dd9d 100644 --- a/src/ifcparse/spf_header.cpp +++ b/src/ifcparse/spf_header.cpp @@ -101,15 +101,15 @@ Header_section_schema::file_schema ifcopenshell::spf_header::file_schema() { void ifcopenshell::spf_header::assign(const spf_header& other) { if (this != &other) { - auto copy_inst = [](express::Entity& new_entity, const express::Entity& entity) { + auto copy_inst = [](express::entity& new_entity, const express::entity& entity) { for (size_t i = 0; i < entity.declaration().as_entity()->attribute_count(); ++i) { entity.get_attribute_value(i).apply_visitor([i, &entity, &new_entity](const auto& v) { - using U = std::decay_t; - if constexpr (std::is_same_v) { - } else if constexpr (std::is_same_v>) { - } else if constexpr (std::is_same_v>>) { - } else if constexpr (std::is_same_v) { - } else if constexpr (std::is_same_v) { + using u = std::decay_t; + if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v>) { + } else if constexpr (std::is_same_v>>) { + } else if constexpr (std::is_same_v) { + } else if constexpr (std::is_same_v) { } else { new_entity.set_attribute_value(i, v); } @@ -118,8 +118,8 @@ void ifcopenshell::spf_header::assign(const spf_header& other) { }; for (size_t i = 0; i < header_entities_.size(); ++i) { - express::Entity tmp(header_entities_[i]); - copy_inst(tmp, express::Entity(other.header_entities_[i])); + express::entity tmp(header_entities_[i]); + copy_inst(tmp, express::entity(other.header_entities_[i])); } } } diff --git a/src/ifcparse/storage.h b/src/ifcparse/storage.h index 447fc1c097..73ae671166 100644 --- a/src/ifcparse/storage.h +++ b/src/ifcparse/storage.h @@ -135,7 +135,7 @@ namespace ifcopenshell { } }; - typedef std::variant reference_or_simple_type; + typedef std::variant reference_or_simple_type; typedef std::vector, std::vector>>>> unresolved_references; class file; @@ -421,15 +421,15 @@ namespace ifcopenshell { unresolved_references* references_to_resolve = nullptr; - typedef std::map> entities_by_type_t; + typedef std::map> entities_by_type_t; typedef std::unordered_map entity_instance_by_name_storage_t; - typedef map_transformer> entity_instance_by_name_t; + typedef map_transformer> entity_instance_by_name_t; typedef std::unordered_map type_instance_by_name_t; - typedef std::map entity_instance_by_guid_t; + typedef std::map entity_instance_by_guid_t; typedef inverse_index entities_by_ref_t; typedef entity_instance_by_name_t::iterator iterator; - in_memory_file_storage(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()) : logger_(logger), file(owner_file), schema(nullptr), byid_read_(&byid_, [this](const shared_pointer_type& data) { return express::Base(data); }) {}; + in_memory_file_storage(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()) : logger_(logger), file(owner_file), schema(nullptr), byid_read_(&byid_, [this](const shared_pointer_type& data) { return express::base(data); }) {}; in_memory_file_storage(const in_memory_file_storage& other) = delete; in_memory_file_storage(const in_memory_file_storage&& other) = delete; @@ -480,21 +480,21 @@ namespace ifcopenshell { void try_read_semicolon(ifcopenshell::spf_lexer* tokens) const; void register_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, int instance_id, int attribute_index); - void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::Base& entity, int attribute_index); + void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::base& entity, int attribute_index); template void read_from_stream(Reader* stream, const ifcopenshell::schema_definition*& schema, unsigned int& max_id, const std::set& types_to_bypass); file_open_status good_ = file_open_status::SUCCESS; - express::Base instance_by_id(int instance_id); + express::base instance_by_id(int instance_id); - void add_type_ref(const express::Base& new_entity) { + void add_type_ref(const express::base& new_entity) { if (auto* ty = new_entity.declaration().as_entity()) { bytype_excl_[ty].push_back(new_entity); } } - void remove_type_ref(const express::Base& new_entity) { + void remove_type_ref(const express::base& new_entity) { if (auto* ty = new_entity.declaration().as_entity()) { auto it = bytype_excl_.find(ty); if (it != bytype_excl_.end()) { @@ -506,12 +506,12 @@ namespace ifcopenshell { } } - void process_deletion_inverse(const express::Base& entity); + void process_deletion_inverse(const express::base& entity); template T create(int instance_id = -1); - express::Base create(const ifcopenshell::declaration* declaration, int instance_id = -1); + express::base create(const ifcopenshell::declaration* declaration, int instance_id = -1); }; class IFC_PARSE_API rocks_db_file_storage { @@ -540,7 +540,7 @@ namespace ifcopenshell { // identity_by_id_t byid_; typedef rocksdb_set_view instance_name_view_t; instance_name_view_t instance_ids_; - typedef set_to_map_transformer> entity_instance_by_name_t; + typedef set_to_map_transformer> entity_instance_by_name_t; entity_instance_by_name_t instance_by_name_; // typedef map_transformer, std::function, std::function> entity_by_id_t; @@ -556,7 +556,7 @@ namespace ifcopenshell { instance_id_by_guid_str_t byguid_internal_; // guid -> id -> instance - typedef map_transformer, std::function, std::function> entity_instance_by_guid_t; + typedef map_transformer, std::function, std::function> entity_instance_by_guid_t; entity_instance_by_guid_t byguid_; typedef std::tuple inverse_attr_record; @@ -576,7 +576,7 @@ namespace ifcopenshell { bool read_schema(const ifcopenshell::schema_definition*& schema); - express::Base assert_existance(size_t instance_id, instance_ref reference_type); + express::base assert_existance(size_t instance_id, instance_ref reference_type); // @todo merge iterators (template?) class IFC_PARSE_API rocksdb_types_iterator { @@ -678,20 +678,20 @@ namespace ifcopenshell { using const_iterator = entity_instance_by_name_t::iterator; void register_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, int instance_id, int attribute_index); - void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::Base& entity, int attribute_index); + void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::base& entity, int attribute_index); // @todo a bit hard as a map because of value_type being an aggregate - void add_type_ref(const express::Base& new_entity); - void remove_type_ref(const express::Base& new_entity); + void add_type_ref(const express::base& new_entity); + void remove_type_ref(const express::base& new_entity); - express::Base instance_by_id(int instance_id); + express::base instance_by_id(int instance_id); - void process_deletion_inverse(const express::Base& entity); + void process_deletion_inverse(const express::base& entity); template T create(int instance_id = -1); - express::Base create(const ifcopenshell::declaration* declaration, int instance_id = -1); + express::base create(const ifcopenshell::declaration* declaration, int instance_id = -1); }; } } diff --git a/src/ifcparse/utils.cpp b/src/ifcparse/utils.cpp index 4ca451c45a..837437aed0 100644 --- a/src/ifcparse/utils.cpp +++ b/src/ifcparse/utils.cpp @@ -143,7 +143,7 @@ void instance_data::populate_derived_() { } } -attribute_value express::Entity::get(const std::string& name) const { +attribute_value express::entity::get(const std::string& name) const { auto attrs = declaration().as_entity()->all_attributes(); auto iter = attrs.begin(); size_t idx = 0; @@ -155,7 +155,7 @@ attribute_value express::Entity::get(const std::string& name) const { throw ifcopenshell::exception(name + " not found on " + declaration().name()); } -std::vector express::Entity::get_inverse(const std::string& name) const { +std::vector express::entity::get_inverse(const std::string& name) const { const std::vector attrs = declaration().as_entity()->all_inverse_attributes(); std::vector::const_iterator iter = attrs.begin(); for (; iter != attrs.end(); ++iter) { diff --git a/src/ifcparse/variant_array.h b/src/ifcparse/variant_array.h index 885f0bb561..c9bf3a5a01 100644 --- a/src/ifcparse/variant_array.h +++ b/src/ifcparse/variant_array.h @@ -57,7 +57,7 @@ namespace impl { }; template - struct VariantTypeName; + struct variant_type_name; // Trait to detect unique_ptr template struct is_unique_ptr : std::false_type {}; @@ -66,23 +66,23 @@ namespace impl { // Trait to find index of type in parameter pack considering inheritance template - struct TypeIndex; + struct type_index; // Base case: When the first type in the pack is the type we're looking for, or is a base class of it template - struct TypeIndex + struct type_index : std::integral_constant ? std::is_base_of_v, std::remove_pointer_t> : std::is_same_v) ? 0 : - (TypeIndex::value == std::numeric_limits::max() + (type_index::value == std::numeric_limits::max() ? std::numeric_limits::max() - : 1 + TypeIndex::value)> {}; + : 1 + type_index::value)> {}; // Recursion termination: When the parameter pack is empty template - struct TypeIndex : std::integral_constant::max()> {}; + struct type_index : std::integral_constant::max()> {}; // Helper variable template template - constexpr std::size_t TypeIndex_v = TypeIndex::value; + constexpr std::size_t TypeIndex_v = type_index::value; // Trait to determine if a type is small enough to be stored directly template @@ -92,7 +92,7 @@ namespace impl { // Metafunction to transform T to unique_ptr based on size template - struct TransformType { + struct transform_type { using type = typename std::conditional< is_small_object::value, T, @@ -102,28 +102,28 @@ namespace impl { // Helper to prepend a type to a tuple template - struct TuplePrepend; + struct tuple_prepend; template - struct TuplePrepend> { + struct tuple_prepend> { using type = std::tuple; }; // Map types based on above size transform template - struct MapTypes; + struct map_types; template - struct MapTypes { - using type = typename TuplePrepend< - typename TransformType::type, - typename MapTypes::type + struct map_types { + using type = typename tuple_prepend< + typename transform_type::type, + typename map_types::type >::type; }; template <> - struct MapTypes<> { + struct map_types<> { using type = std::tuple<>; }; template - using MapTypes_t = typename MapTypes::type; + using map_types_t = typename map_types::type; // Create aligned_union from paramater pack stored in tuple for storage in variant template @@ -138,11 +138,11 @@ namespace impl { template class variant_array { public: - using TypesTuple = ::impl::MapTypes_t; + using types_tuple = ::impl::map_types_t; variant_array(size_t size) : size_and_indices_(size ? new uint8_t[size + 1] : nullptr) - , storage_(size ? new StorageType[size] : nullptr) + , storage_(size ? new storage_type[size] : nullptr) { if (size) { size_and_indices_[0] = (uint8_t)size; @@ -181,20 +181,20 @@ public: template, variant_array>>> void set(std::size_t index, T&& value) { - using U = std::decay_t; - static_assert(::impl::TypeIndex_v < sizeof...(Types), "Type not supported by variant"); + using u = std::decay_t; + static_assert(::impl::TypeIndex_v < sizeof...(Types), "Type not supported by variant"); if (index >= size()) { throw std::out_of_range("Index " + std::to_string(index) + " is out of range for storage of size " + std::to_string(size())); } destroy_at_index(index); - size_and_indices_[index + 1] = ::impl::TypeIndex_v; - using V = typename std::tuple_element<::impl::TypeIndex_v, ::impl::MapTypes_t>::type; - if constexpr (::impl::is_unique_ptr::value) { - new(&storage_[index]) V(new U(value)); + size_and_indices_[index + 1] = ::impl::TypeIndex_v; + using v = typename std::tuple_element<::impl::TypeIndex_v, ::impl::map_types_t>::type; + if constexpr (::impl::is_unique_ptr::value) { + new(&storage_[index]) v(new u(value)); } else { - new(&storage_[index]) U(std::forward(value)); + new(&storage_[index]) u(std::forward(value)); } } @@ -221,17 +221,17 @@ public: if (!has(index)) { throw std::bad_cast(); } - using V = typename std::tuple_element<::impl::TypeIndex_v, ::impl::MapTypes_t>::type; - if constexpr (::impl::is_unique_ptr::value) { - return **reinterpret_cast(&storage_[index]); + using v = typename std::tuple_element<::impl::TypeIndex_v, ::impl::map_types_t>::type; + if constexpr (::impl::is_unique_ptr::value) { + return **reinterpret_cast(&storage_[index]); } else { - return *reinterpret_cast(&storage_[index]); + return *reinterpret_cast(&storage_[index]); } } template bool has(std::size_t index) const { - return index < size() && size_and_indices_[index + 1] == ::impl::TypeIndex::value; + return index < size() && size_and_indices_[index + 1] == ::impl::type_index::value; } template @@ -241,19 +241,19 @@ public: "Index " + std::to_string(index) + " is out of range for storage of size " + std::to_string(size()) ); } - if (size_and_indices_[index + 1] != ::impl::TypeIndex::value) { + if (size_and_indices_[index + 1] != ::impl::type_index::value) { // @todo this exception is silly. Figure out what // to do, but at the moment it is specifically caught // in various places. throw impl::storage_type_mismatch( - ::impl::VariantTypeName::get(), get_type_name(size_and_indices_[index + 1]) + ::impl::variant_type_name::get(), get_type_name(size_and_indices_[index + 1]) ); } - using V = typename std::tuple_element<::impl::TypeIndex_v, ::impl::MapTypes_t>::type; - if constexpr (::impl::is_unique_ptr::value) { - return **reinterpret_cast(&storage_[index]); + using v = typename std::tuple_element<::impl::TypeIndex_v, ::impl::map_types_t>::type; + if constexpr (::impl::is_unique_ptr::value) { + return **reinterpret_cast(&storage_[index]); } else { - return *reinterpret_cast(&storage_[index]); + return *reinterpret_cast(&storage_[index]); } } @@ -272,10 +272,10 @@ public: } private: - using StorageType = typename ::impl::make_union_from_tuple<::impl::MapTypes_t>::type; + using storage_type = typename ::impl::make_union_from_tuple<::impl::map_types_t>::type; uint8_t* size_and_indices_; - StorageType* storage_; + storage_type* storage_; void destroy_at_index(std::size_t index) { destroy_type_at_index(index, std::integral_constant{}); @@ -294,9 +294,9 @@ private: template void destroy_type_at_index(std::size_t index, std::integral_constant) { if (size_and_indices_[index + 1] == Index - 1) { - using T = typename std::tuple_element_t>; - if constexpr (!std::is_trivially_destructible::value) { - reinterpret_cast(&storage_[index])->~T(); + using t = typename std::tuple_element_t>; + if constexpr (!std::is_trivially_destructible::value) { + reinterpret_cast(&storage_[index])->~t(); } size_and_indices_[index + 1] = sizeof...(Types); } else { @@ -311,11 +311,11 @@ private: template auto apply_visitor_impl(Visitor&& visitor, std::size_t index, std::integral_constant) const { if (size_and_indices_[index + 1] == Index - 1) { - using T = typename std::tuple_element_t>; - if constexpr (::impl::is_unique_ptr::value) { - return visitor(**reinterpret_cast(&storage_[index])); + using t = typename std::tuple_element_t>; + if constexpr (::impl::is_unique_ptr::value) { + return visitor(**reinterpret_cast(&storage_[index])); } else { - return visitor(*reinterpret_cast(&storage_[index])); + return visitor(*reinterpret_cast(&storage_[index])); } } return apply_visitor_impl(std::forward(visitor), index, std::integral_constant{}); @@ -326,8 +326,8 @@ private: static_cast(visitor); static_cast(index); throw std::runtime_error("Invalid variant index"); - if constexpr (!std::is_void_v()(std::declval> &>()))>) { - return decltype(std::declval()(std::declval> &>())){}; + if constexpr (!std::is_void_v()(std::declval> &>()))>) { + return decltype(std::declval()(std::declval> &>())){}; } } @@ -337,7 +337,7 @@ private: return ""; } else { if (type_index == I - 1) { - return ::impl::VariantTypeName>>::get(); + return ::impl::variant_type_name>>::get(); } else { return get_type_name_impl(type_index); } diff --git a/src/ifcviewer/GeometryStreamer.cpp b/src/ifcviewer/GeometryStreamer.cpp index f51fe786ca..ec39451c43 100644 --- a/src/ifcviewer/GeometryStreamer.cpp +++ b/src/ifcviewer/GeometryStreamer.cpp @@ -41,7 +41,7 @@ struct MaterialInfo { float r = 0.75f, g = 0.75f, b = 0.78f, a = 1.0f; }; -static MaterialInfo materialFromStyle(const ifcopenshell::geometry::taxonomy::style::ptr& style) { +static MaterialInfo materialFromStyle(const ifcopenshell::geom::taxonomy::style::ptr& style) { MaterialInfo material; if (!style) return material; const auto& color = style->get_color(); @@ -155,7 +155,7 @@ std::vector GeometryStreamer::drainElements() { // the magnitude off the float-precision-sensitive vertex column. static StreamedMesh buildStreamedMesh(uint32_t session_model_id, uint32_t local_mesh_id, - const IfcGeom::TriangulationElement* elem, + const ifcopenshell::geom::triangulation_element* elem, const Eigen::Vector3d& offset) { StreamedMesh mesh; mesh.session_model_id = session_model_id; @@ -389,7 +389,7 @@ void GeometryStreamer::run(const std::string& path, int num_threads) { return; } - ifcopenshell::geometry::Settings settings; + ifcopenshell::geom::settings settings; // Instancing path: geometry stays in local coords; the transform is // applied on the GPU per instance. settings.set("use-world-coords", false); @@ -501,7 +501,7 @@ void GeometryStreamer::run(const std::string& path, int num_threads) { bool is_gross) -> bool { if (include_ids.empty()) return true; - ifcopenshell::geometry::Settings base_settings = settings; + ifcopenshell::geom::settings base_settings = settings; if (is_gross) { base_settings.set("disable-opening-subtractions", true); } @@ -509,21 +509,21 @@ void GeometryStreamer::run(const std::string& path, int num_threads) { // Elements that haven't yet produced geometry from any context. std::set remaining = include_ids; - auto run_iterator = [&](ifcopenshell::geometry::Settings& iter_settings) -> bool { + auto run_iterator = [&](ifcopenshell::geom::settings& iter_settings) -> bool { if (remaining.empty()) return true; - std::vector filters; - IfcGeom::instance_id_filter idf{ + std::vector filters; + ifcopenshell::geom::instance_id_filter idf{ /*include=*/true, /*traverse=*/false, remaining}; filters.push_back(idf); - std::unique_ptr iterator; + std::unique_ptr iterator; try { const std::string geometry_library = AppSettings::instance().geometryLibrary().toStdString(); - auto kernel = ifcopenshell::geometry::kernels::construct( + auto kernel = ifcopenshell::geom::kernels::construct( ifc_file_.get(), geometry_library, iter_settings); - iterator = std::make_unique( + iterator = std::make_unique( std::move(kernel), iter_settings, ifc_file_.get(), filters, num_threads); } catch (const std::exception& e) { @@ -539,10 +539,10 @@ void GeometryStreamer::run(const std::string& path, int num_threads) { do { if (cancel_requested_.load()) break; - const IfcGeom::Element* elem = iterator->get(); + const ifcopenshell::geom::element* elem = iterator->get(); if (!elem) continue; - const auto* tri_elem = dynamic_cast(elem); + const auto* tri_elem = dynamic_cast(elem); if (!tri_elem) continue; const auto& geom = tri_elem->geometry(); @@ -678,7 +678,7 @@ void GeometryStreamer::run(const std::string& path, int num_threads) { if (cancel_requested_.load()) break; if (remaining.empty()) break; - ifcopenshell::geometry::Settings iter_settings = base_settings; + ifcopenshell::geom::settings iter_settings = base_settings; iter_settings.set("context-ids", std::set{ prioritised_contexts[i] }); diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 89bf7ef5df..eed6168f7e 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -19,10 +19,29 @@ %rename("buffer") stream_or_filename; +// Keep the established Python API names while the underlying C++ types use +// snake_case. +%rename("BRep") ifcopenshell::geom::Representation::brep; +%rename("BRepElement") ifcopenshell::geom::brep_element; +%rename("ConversionResult") ifcopenshell::geom::conversion_result; +%rename("ConversionResultShape") ifcopenshell::geom::conversion_result_shape; +%rename("Element") ifcopenshell::geom::element; +%rename("GeometrySerializer") ifcopenshell::geom::geometry_serializer; +%rename("Iterator") ifcopenshell::geom::iterator; +%rename("OpaqueNumber") ifcopenshell::geom::opaque_number; +%rename("Representation") ifcopenshell::geom::Representation::representation; +%rename("Serialization") ifcopenshell::geom::Representation::serialization; +%rename("SerializedElement") ifcopenshell::geom::serialized_element; +%rename("Settings") ifcopenshell::geom::settings; +%rename("Transformation") ifcopenshell::geom::transformation; +%rename("Triangulation") ifcopenshell::geom::Representation::triangulation; +%rename("TriangulationElement") ifcopenshell::geom::triangulation_element; +%rename("WriteOnlyGeometrySerializer") ifcopenshell::geom::write_only_geometry_serializer; + %ignore stream_or_filename::stream; %ignore boost::hash_value; -%ignore IfcGeom::BRepElement::geometry_pointer; -%ignore IfcGeom::TriangulationElement::geometry_pointer; +%ignore ifcopenshell::geom::brep_element::geometry_pointer; +%ignore ifcopenshell::geom::triangulation_element::geometry_pointer; // This is only used for RGB colours, hence the size of 3 %typemap(out) const double* { @@ -44,7 +63,7 @@ } // SWIG does not support bool references in a meaningful way, so the -// ifcopenshell::geometry::Settings functions degrade to return a read only value +// ifcopenshell::geom::settings functions degrade to return a read only value %typemap(out) double& { $result = SWIG_From_double(*$1); } @@ -52,50 +71,50 @@ $result = PyBool_FromLong(static_cast(*$1)); } -%typemap(out) IfcGeom::OpaqueNumber { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(new IfcGeom::OpaqueNumber($1)), SWIGTYPE_p_IfcGeom__OpaqueNumber, SWIG_POINTER_OWN); +%typemap(out) ifcopenshell::geom::opaque_number { + $result = SWIG_NewPointerObj(SWIG_as_voidptr(new ifcopenshell::geom::opaque_number($1)), SWIGTYPE_p_ifcopenshell__geom__opaque_number, SWIG_POINTER_OWN); } -%typemap(in) const IfcGeom::OpaqueNumber& (IfcGeom::OpaqueNumber temp) { +%typemap(in) const ifcopenshell::geom::opaque_number& (ifcopenshell::geom::opaque_number temp) { void* argp = nullptr; - int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_IfcGeom__OpaqueNumber, 0); + int res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_ifcopenshell__geom__opaque_number, 0); if (!SWIG_IsOK(res) || !argp) { - SWIG_exception_fail(SWIG_ArgError(res), "Expected IfcGeom::OpaqueNumber"); + SWIG_exception_fail(SWIG_ArgError(res), "Expected ifcopenshell::geom::opaque_number"); } - temp = *reinterpret_cast(argp); + temp = *reinterpret_cast(argp); $1 = &temp; } // Using RTTI return a more specialized type of Element // Note that these elements are not to be owned by SWIG/Python as they will be freed automatically upon the next iteration -// except for the IfcGeom::Element instances which are returned by Iterator::getObject() calls -%typemap(out) IfcGeom::Element* { - IfcGeom::SerializedElement* serialized_elem = dynamic_cast($1); - IfcGeom::TriangulationElement* triangulation_elem = dynamic_cast($1); - IfcGeom::BRepElement* brep_elem = dynamic_cast($1); +// except for the ifcopenshell::geom::element instances which are returned by Iterator::getObject() calls +%typemap(out) ifcopenshell::geom::element* { + ifcopenshell::geom::serialized_element* serialized_elem = dynamic_cast($1); + ifcopenshell::geom::triangulation_element* triangulation_elem = dynamic_cast($1); + ifcopenshell::geom::brep_element* brep_elem = dynamic_cast($1); if (triangulation_elem) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_IfcGeom__TriangulationElement, 0); + $result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_ifcopenshell__geom__triangulation_element, 0); } else if (serialized_elem) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_IfcGeom__SerializedElement, 0); + $result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_ifcopenshell__geom__serialized_element, 0); } else if (brep_elem) { - $result = SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_IfcGeom__BRepElement, 0); + $result = SWIG_NewPointerObj(SWIG_as_voidptr(brep_elem), SWIGTYPE_p_ifcopenshell__geom__brep_element, 0); } else { - $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_IfcGeom__Element, SWIG_POINTER_OWN); + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_ifcopenshell__geom__element, SWIG_POINTER_OWN); } } -%newobject IfcGeom::Representation::BRep::item; -%newobject IfcGeom::Representation::BRep::as_compound; +%newobject ifcopenshell::geom::Representation::brep::item; +%newobject ifcopenshell::geom::Representation::brep::as_compound; -%newobject IfcGeom::ConversionResultShape::halfspaces; -%newobject IfcGeom::ConversionResultShape::box; -%newobject IfcGeom::ConversionResultShape::solid; -%newobject IfcGeom::ConversionResultShape::add; -%newobject IfcGeom::ConversionResultShape::subtract; -%newobject IfcGeom::ConversionResultShape::intersect; -%newobject IfcGeom::ConversionResultShape::concat; -%newobject IfcGeom::ConversionResultShape::moved; -%newobject IfcGeom::ConversionResultShape::wrap_in_compound; +%newobject ifcopenshell::geom::conversion_result_shape::halfspaces; +%newobject ifcopenshell::geom::conversion_result_shape::box; +%newobject ifcopenshell::geom::conversion_result_shape::solid; +%newobject ifcopenshell::geom::conversion_result_shape::add; +%newobject ifcopenshell::geom::conversion_result_shape::subtract; +%newobject ifcopenshell::geom::conversion_result_shape::intersect; +%newobject ifcopenshell::geom::conversion_result_shape::concat; +%newobject ifcopenshell::geom::conversion_result_shape::moved; +%newobject ifcopenshell::geom::conversion_result_shape::wrap_in_compound; %newobject nary_union; @@ -104,19 +123,19 @@ %inline %{ template std::pair vector_to_buffer(const T& t) { - using V = typename std::remove_reference::type; - return { reinterpret_cast(t.data()), t.size() * sizeof(typename V::value_type) }; + using v = typename std::remove_reference::type; + return { reinterpret_cast(t.data()), t.size() * sizeof(typename v::value_type) }; } %} -%ignore ifcopenshell::geometry::taxonomy::item::print; +%ignore ifcopenshell::geom::taxonomy::item::print; -%typemap(out) std::variant { +%typemap(out) std::variant { if ($1.index() == 0) { Py_INCREF(Py_None); return Py_None; } else if ($1.index() == 1) { - return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::get($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__point3_t, 0 | SWIG_POINTER_OWN); + return SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr(std::get($1))), SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geom__taxonomy__point3_t, 0 | SWIG_POINTER_OWN); } else { return PyFloat_FromDouble(std::get($1)); } @@ -131,47 +150,47 @@ std::pair vector_to_buffer(const T& t) { } } -%typemap(in) ifcopenshell::geometry::taxonomy::item::ptr { +%typemap(in) ifcopenshell::geom::taxonomy::item::ptr { // @this is really annoying, but apparently inheritance // is lost in swig in the shared_ptr type hiearchy - using namespace ifcopenshell::geometry::taxonomy; - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__boolean_result_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_curve_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__bspline_surface_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__circle_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__collection_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__colour_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__cylinder_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__direction3_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__edge_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__ellipse_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__extrusion_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__face_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__line_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loft_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__loop_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__matrix4_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__node_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__offset_curve_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__function_item_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__functor_item_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__piecewise_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__gradient_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__cant_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__offset_function_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__plane_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__point3_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__revolve_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__shell_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__solid_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__sphere_t); - if (!$1) $1 = try_upcast($input, SWIGTYPE_p_std__shared_ptrT_ifcopenshell__geometry__taxonomy__torus_t); - if (!$1) $1 = try_upcast