mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 17:11:02 +00:00
First start plug-in architecture
This commit is contained in:
+11
-10
@@ -1,11 +1,3 @@
|
||||
add_subdirectory(kernels)
|
||||
set(kernel_libraries ${kernel_libraries} PARENT_SCOPE)
|
||||
|
||||
if((BUILD_CONVERT OR BUILD_IFCPYTHON) AND WITH_OPENCASCADE)
|
||||
add_subdirectory(Serialization)
|
||||
set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(mapping)
|
||||
|
||||
# IfcGeom (schema agnostic)
|
||||
@@ -16,6 +8,7 @@ set(SCHEMA_AGNOSTIC_FILES ${SCHEMA_AGNOSTIC_H_FILES} ${SCHEMA_AGNOSTIC_CPP_FILES
|
||||
add_library(IfcGeom ${SCHEMA_AGNOSTIC_FILES})
|
||||
add_library(geometry ALIAS IfcGeom)
|
||||
set_target_properties(IfcGeom PROPERTIES COMPILE_FLAGS -DIFC_GEOM_EXPORTS VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||
target_compile_definitions(IfcGeom PRIVATE BOOST_DLL_USE_STD_FS)
|
||||
|
||||
if(UNIX)
|
||||
find_package(Threads)
|
||||
@@ -23,10 +16,18 @@ endif()
|
||||
|
||||
find_package(Eigen3 REQUIRED)
|
||||
|
||||
add_subdirectory(kernels)
|
||||
set(kernel_libraries ${kernel_libraries} PARENT_SCOPE)
|
||||
|
||||
if(WASM_BUILD)
|
||||
target_link_libraries(IfcGeom plugin ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen")
|
||||
target_link_libraries(IfcGeom plugin ${Boost_LIBRARIES} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen")
|
||||
else()
|
||||
target_link_libraries(IfcGeom plugin IfcParse ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen")
|
||||
target_link_libraries(IfcGeom plugin IfcParse ${Boost_LIBRARIES} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen")
|
||||
endif()
|
||||
|
||||
if((BUILD_CONVERT OR BUILD_IFCPYTHON) AND WITH_OPENCASCADE)
|
||||
add_subdirectory(Serialization)
|
||||
set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
install(FILES ${SCHEMA_AGNOSTIC_H_FILES}
|
||||
|
||||
@@ -621,15 +621,6 @@ const IfcGeom::Element* IfcGeom::Iterator::get_object(int id) {
|
||||
} catch (const std::exception& e) {
|
||||
logger::error(e);
|
||||
}
|
||||
#ifdef IFOPSH_WITH_OPENCASCADE
|
||||
catch (const Standard_Failure& e) {
|
||||
if (e.GetMessageString() && strlen(e.GetMessageString())) {
|
||||
logger::error(e.GetMessageString());
|
||||
} else {
|
||||
logger::error("Unknown error returning product");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
catch (...) {
|
||||
logger::error("Unknown error returning product");
|
||||
}
|
||||
@@ -646,16 +637,6 @@ express::Base IfcGeom::Iterator::create() {
|
||||
logger::error(e);
|
||||
had_error_processing_elements_ = true;
|
||||
}
|
||||
#ifdef IFOPSH_WITH_OPENCASCADE
|
||||
catch (const Standard_Failure& e) {
|
||||
if (e.GetMessageString() && strlen(e.GetMessageString())) {
|
||||
logger::error(e.GetMessageString());
|
||||
} else {
|
||||
logger::error("Unknown error creating geometry");
|
||||
}
|
||||
had_error_processing_elements_ = true;
|
||||
}
|
||||
#endif
|
||||
catch (...) {
|
||||
logger::error("Unknown error creating geometry");
|
||||
had_error_processing_elements_ = true;
|
||||
|
||||
@@ -68,10 +68,6 @@
|
||||
#include "../ifcgeom/abstract_mapping.h"
|
||||
#include "../ifcgeom/GeometrySerializer.h"
|
||||
|
||||
#ifdef IFOPSH_WITH_OPENCASCADE
|
||||
#include <Standard_Failure.hxx>
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -3,7 +3,8 @@ add_subdirectory(schema)
|
||||
add_library(geometry_serializer Serialization.cpp)
|
||||
add_library(opencascade_geometry_ifc_writer ALIAS geometry_serializer)
|
||||
set_target_properties(geometry_serializer PROPERTIES COMPILE_FLAGS "-DIFC_GEOMSERIALIZATION_EXPORTS")
|
||||
target_link_libraries(geometry_serializer plugin ${geometry_serializer_libraries} IfcParse)
|
||||
target_link_libraries(geometry_serializer plugin ${geometry_serializer_libraries} IfcGeom IfcParse)
|
||||
target_link_libraries(geometry_serializer geometry_kernel_opencascade)
|
||||
set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} "geometry_serializer" ${geometry_serializer_libraries})
|
||||
set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} PARENT_SCOPE)
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#ifndef IFC_GEOMSERIALIZATION_API_H
|
||||
#define IFC_GEOMSERIALIZATION_API_H
|
||||
|
||||
#ifdef IFC_SHARED_BUILD
|
||||
#ifdef _WIN32
|
||||
#ifdef IFC_GEOMSERIALIZATION_EXPORTS
|
||||
#define IFC_GEOMSERIALIZATION_API __declspec(dllexport)
|
||||
@@ -30,8 +29,5 @@
|
||||
#else // simply assume *nix + GCC-like compiler
|
||||
#define IFC_GEOMSERIALIZATION_API __attribute__((visibility("default")))
|
||||
#endif
|
||||
#else
|
||||
#define IFC_GEOMSERIALIZATION_API
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,18 +20,14 @@
|
||||
#ifndef IFC_GEOM_API_H
|
||||
#define IFC_GEOM_API_H
|
||||
|
||||
#ifdef IFC_SHARED_BUILD
|
||||
#ifdef _WIN32
|
||||
#ifdef IFC_GEOM_EXPORTS
|
||||
#define IFC_GEOM_API __declspec(dllexport)
|
||||
#else
|
||||
#define IFC_GEOM_API __declspec(dllimport)
|
||||
#endif
|
||||
#else // simply assume *nix + GCC-like compiler
|
||||
#define IFC_GEOM_API __attribute__((visibility("default")))
|
||||
#ifdef _WIN32
|
||||
#ifdef IFC_GEOM_EXPORTS
|
||||
#define IFC_GEOM_API __declspec(dllexport)
|
||||
#else
|
||||
#define IFC_GEOM_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define IFC_GEOM_API
|
||||
#define IFC_GEOM_API __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "kernel_plugin.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <dlfcn.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
constexpr const char* kernel_plugin_prefix = "geometry.kernel.";
|
||||
}
|
||||
|
||||
const char* ifcopenshell::geometry::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) {
|
||||
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() {
|
||||
#ifdef _WIN32
|
||||
HMODULE module_handle = nullptr;
|
||||
if (!GetModuleHandleExW(
|
||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
reinterpret_cast<LPCWSTR>(&ifcopenshell::geometry::kernels::load_kernel_plugins),
|
||||
&module_handle)) {
|
||||
throw std::runtime_error("Unable to resolve IfcGeom module path");
|
||||
}
|
||||
|
||||
wchar_t buffer[MAX_PATH];
|
||||
const DWORD length = GetModuleFileNameW(module_handle, buffer, MAX_PATH);
|
||||
if (length == 0) {
|
||||
throw std::runtime_error("Unable to read IfcGeom module filename");
|
||||
}
|
||||
|
||||
return std::filesystem::path(std::wstring(buffer, length)).parent_path();
|
||||
#else
|
||||
Dl_info info;
|
||||
if (dladdr(reinterpret_cast<const void*>(&ifcopenshell::geometry::kernels::load_kernel_plugins), &info) == 0 || !info.dli_fname) {
|
||||
throw std::runtime_error("Unable to resolve IfcGeom module path");
|
||||
}
|
||||
|
||||
return std::filesystem::path(info.dli_fname).parent_path();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ifcopenshell::geometry::kernels::load_kernel_plugins(kernel_registry& registry) {
|
||||
plugin::manager manager;
|
||||
manager.add_search_path(kernel_plugin_directory());
|
||||
|
||||
for (const auto& path : manager.discover(kernel_plugin_prefix)) {
|
||||
auto module = manager.load(path);
|
||||
if (module.meta().kind_ != plugin::kind::kernel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto register_plugin = module.get_alias<register_kernel_plugin_fn>(kernel_plugin_registration_symbol());
|
||||
register_plugin(registry, module);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef IFCOPENSHELL_KERNEL_PLUGIN_H
|
||||
#define IFCOPENSHELL_KERNEL_PLUGIN_H
|
||||
|
||||
#include "../ifcgeom/kernel_registry.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace ifcopenshell {
|
||||
namespace geometry {
|
||||
namespace kernels {
|
||||
|
||||
typedef void register_kernel_plugin_fn(kernel_registry&, const plugin::module&);
|
||||
|
||||
IFC_GEOM_API const char* kernel_plugin_registration_symbol();
|
||||
IFC_GEOM_API plugin::metadata kernel_plugin_metadata(const std::string& plugin_name);
|
||||
IFC_GEOM_API std::filesystem::path kernel_plugin_directory();
|
||||
IFC_GEOM_API void load_kernel_plugins(kernel_registry& registry);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "kernel_registry.h"
|
||||
|
||||
#include "../ifcgeom/kernel_plugin.h"
|
||||
#include "../ifcgeom/hybrid_kernel.h"
|
||||
#include "../ifcparse/file.h"
|
||||
|
||||
@@ -27,68 +28,11 @@
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
|
||||
#ifdef IFOPSH_WITH_OPENCASCADE
|
||||
#include "../ifcgeom/kernels/opencascade/OpenCascadeKernel.h"
|
||||
#undef Handle
|
||||
#endif
|
||||
|
||||
#ifdef IFOPSH_WITH_CGAL
|
||||
#include "../ifcgeom/kernels/cgal/CgalKernel.h"
|
||||
#undef CGAL_KERNEL_H
|
||||
#undef CGALCONVERSIONRESULT_H
|
||||
#define IFOPSH_SIMPLE_KERNEL
|
||||
#include "../ifcgeom/kernels/cgal/CgalKernel.h"
|
||||
#undef CgalKernel
|
||||
#undef IFOPSH_SIMPLE_KERNEL
|
||||
#endif
|
||||
|
||||
#ifdef IFOPSH_WITH_MANIFOLD
|
||||
#include "../ifcgeom/kernels/manifold/ManifoldKernel.h"
|
||||
#endif
|
||||
#include "../ifcgeom/kernels/passthrough/PassthroughKernel.h"
|
||||
|
||||
namespace {
|
||||
std::string kernel_key(const std::string& backend_id) {
|
||||
return boost::to_lower_copy(backend_id);
|
||||
}
|
||||
|
||||
ifcopenshell::plugin::module builtin_kernel_module(const std::string& backend_id) {
|
||||
ifcopenshell::plugin::metadata metadata;
|
||||
metadata.kind_ = ifcopenshell::plugin::kind::kernel;
|
||||
metadata.id = "geometry.kernel." + kernel_key(backend_id);
|
||||
return ifcopenshell::plugin::module::builtin(metadata);
|
||||
}
|
||||
|
||||
void register_builtin_kernels(ifcopenshell::geometry::kernels::kernel_registry& registry) {
|
||||
#ifdef IFOPSH_WITH_OPENCASCADE
|
||||
ifcopenshell::geometry::kernels::kernel_info opencascade_info;
|
||||
opencascade_info.backend_id = "opencascade";
|
||||
opencascade_info.supports_boolean_operations = true;
|
||||
registry.bind(opencascade_info, [](ifcopenshell::file*, ifcopenshell::geometry::Settings& settings) { return new IfcGeom::OpenCascadeKernel(settings); }, builtin_kernel_module("opencascade"));
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_CGAL
|
||||
ifcopenshell::geometry::kernels::kernel_info cgal_info;
|
||||
cgal_info.backend_id = "cgal";
|
||||
cgal_info.supports_boolean_operations = true;
|
||||
registry.bind(cgal_info, [](ifcopenshell::file*, ifcopenshell::geometry::Settings& settings) { return new ifcopenshell::geometry::kernels::CgalKernel(settings); }, builtin_kernel_module("cgal"));
|
||||
|
||||
ifcopenshell::geometry::kernels::kernel_info cgal_simple_info;
|
||||
cgal_simple_info.backend_id = "cgal-simple";
|
||||
cgal_simple_info.supports_boolean_operations = false;
|
||||
registry.bind(cgal_simple_info, [](ifcopenshell::file*, ifcopenshell::geometry::Settings& settings) { return new ifcopenshell::geometry::kernels::SimpleCgalKernel(settings); }, builtin_kernel_module("cgal-simple"));
|
||||
#endif
|
||||
#ifdef IFOPSH_WITH_MANIFOLD
|
||||
ifcopenshell::geometry::kernels::kernel_info manifold_info;
|
||||
manifold_info.backend_id = "manifold";
|
||||
manifold_info.supports_boolean_operations = true;
|
||||
registry.bind(manifold_info, [](ifcopenshell::file*, ifcopenshell::geometry::Settings& settings) { return new ifcopenshell::geometry::kernels::ManifoldKernel(settings); }, builtin_kernel_module("manifold"));
|
||||
#endif
|
||||
ifcopenshell::geometry::kernels::kernel_info passthrough_info;
|
||||
passthrough_info.backend_id = "passthrough";
|
||||
passthrough_info.supports_boolean_operations = false;
|
||||
registry.bind(passthrough_info, [](ifcopenshell::file*, ifcopenshell::geometry::Settings& settings) { return new ifcopenshell::geometry::kernels::PassthroughKernel(settings); }, builtin_kernel_module("passthrough"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ifcopenshell::geometry::kernels::kernel_registry::bind(const kernel_info& info, create_fn create, const plugin::module& module) {
|
||||
@@ -122,7 +66,7 @@ std::vector<ifcopenshell::geometry::kernels::kernel_info> ifcopenshell::geometry
|
||||
ifcopenshell::geometry::kernels::kernel_registry& ifcopenshell::geometry::kernels::kernel_registry_instance() {
|
||||
static kernel_registry registry;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, register_builtin_kernels, std::ref(registry));
|
||||
std::call_once(once, load_kernel_plugins, std::ref(registry));
|
||||
return registry;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
find_package(Eigen3 REQUIRED)
|
||||
|
||||
message(STATUS "GEOMETRY_KERNELS ${GEOMETRY_KERNELS}")
|
||||
|
||||
set(kernel_plugin_runtime_dir "${CMAKE_BINARY_DIR}/ifcgeom/$<CONFIG>")
|
||||
|
||||
foreach(kernel ${GEOMETRY_KERNELS})
|
||||
string(TOUPPER ${kernel} KERNEL_UPPER)
|
||||
file(GLOB IFCGEOM_H_FILES ${kernel}/*.h)
|
||||
@@ -9,25 +9,34 @@ foreach(kernel ${GEOMETRY_KERNELS})
|
||||
set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES})
|
||||
|
||||
set(KERNEL_TARGET "geometry_kernel_${kernel}")
|
||||
|
||||
add_library(${KERNEL_TARGET} OBJECT ${IFCGEOM_FILES})
|
||||
set_property(TARGET ${KERNEL_TARGET} APPEND PROPERTY COMPILE_FLAGS "-DIFC_GEOM_EXPORTS")
|
||||
add_library(${KERNEL_TARGET} SHARED ${IFCGEOM_FILES})
|
||||
set_target_properties(${KERNEL_TARGET} PROPERTIES
|
||||
COMPILE_FLAGS "-DIFC_GEOMLIBRARY_EXPORTS"
|
||||
OUTPUT_NAME "geometry.kernel.${kernel}"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${kernel_plugin_runtime_dir}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${kernel_plugin_runtime_dir}"
|
||||
)
|
||||
list(APPEND kernel_libraries ${KERNEL_TARGET})
|
||||
target_link_libraries(${KERNEL_TARGET} ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
|
||||
target_link_libraries(${KERNEL_TARGET} PRIVATE plugin IfcGeom ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
|
||||
|
||||
install(TARGETS ${KERNEL_TARGET})
|
||||
|
||||
if(${kernel} STREQUAL "cgal")
|
||||
set_property(TARGET ${KERNEL_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " -DCGAL_HAS_THREADS")
|
||||
|
||||
|
||||
set(KERNEL_TARGET_SIMPLE "${KERNEL_TARGET}_simple")
|
||||
add_library(${KERNEL_TARGET_SIMPLE} OBJECT ${IFCGEOM_FILES})
|
||||
set_target_properties(${KERNEL_TARGET_SIMPLE} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIFOPSH_SIMPLE_KERNEL -DCGAL_HAS_THREADS")
|
||||
add_library(${KERNEL_TARGET_SIMPLE} SHARED ${IFCGEOM_FILES})
|
||||
set_target_properties(${KERNEL_TARGET_SIMPLE} PROPERTIES
|
||||
COMPILE_FLAGS "-DIFC_GEOMLIBRARY_EXPORTS -DIFOPSH_SIMPLE_KERNEL -DCGAL_HAS_THREADS"
|
||||
OUTPUT_NAME "geometry.kernel.cgalsimple"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${kernel_plugin_runtime_dir}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${kernel_plugin_runtime_dir}"
|
||||
)
|
||||
list(APPEND kernel_libraries ${KERNEL_TARGET_SIMPLE})
|
||||
target_link_libraries(${KERNEL_TARGET_SIMPLE} ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
|
||||
target_link_libraries(${KERNEL_TARGET_SIMPLE} PRIVATE plugin IfcGeom ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
|
||||
install(TARGETS ${KERNEL_TARGET_SIMPLE})
|
||||
elseif(${kernel} STREQUAL "opencascade")
|
||||
target_link_libraries(${KERNEL_TARGET} ${OpenCASCADE_LIBRARIES})
|
||||
target_link_libraries(${KERNEL_TARGET} PRIVATE ${OpenCASCADE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
install(FILES ${IFCGEOM_H_FILES}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "../../kernel_plugin.h"
|
||||
#include "CgalKernel.h"
|
||||
|
||||
#include <boost/dll/alias.hpp>
|
||||
|
||||
namespace ifcopenshell {
|
||||
namespace geometry {
|
||||
namespace kernels {
|
||||
namespace cgal_plugin {
|
||||
|
||||
#ifdef IFOPSH_SIMPLE_KERNEL
|
||||
constexpr const char* plugin_name = "cgalsimple";
|
||||
constexpr const char* backend_id = "cgal-simple";
|
||||
constexpr bool supports_boolean_operations = false;
|
||||
using kernel_type = SimpleCgalKernel;
|
||||
#else
|
||||
constexpr const char* plugin_name = "cgal";
|
||||
constexpr const char* backend_id = "cgal";
|
||||
constexpr bool supports_boolean_operations = true;
|
||||
using kernel_type = CgalKernel;
|
||||
#endif
|
||||
|
||||
plugin::abi_info plugin_abi() {
|
||||
return plugin::host_abi();
|
||||
}
|
||||
|
||||
plugin::metadata plugin_metadata() {
|
||||
return kernel_plugin_metadata(plugin_name);
|
||||
}
|
||||
|
||||
AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) {
|
||||
return new kernel_type(settings);
|
||||
}
|
||||
|
||||
void register_plugin(kernel_registry& registry, const plugin::module& module) {
|
||||
kernel_info info;
|
||||
info.backend_id = backend_id;
|
||||
info.supports_boolean_operations = supports_boolean_operations;
|
||||
registry.bind(info, create_kernel, module);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -20,9 +20,8 @@
|
||||
#ifndef IFC_GEOMLIBRARY_API_H
|
||||
#define IFC_GEOMLIBRARY_API_H
|
||||
|
||||
#ifdef IFC_SHARED_BUILD
|
||||
#ifdef _WIN32
|
||||
#ifdef IFC_GEOM_EXPORTS
|
||||
#ifdef IFC_GEOMLIBRARY_EXPORTS
|
||||
#define IFC_GEOMLIBRARY_API __declspec(dllexport)
|
||||
#else
|
||||
#define IFC_GEOMLIBRARY_API __declspec(dllimport)
|
||||
@@ -30,8 +29,5 @@
|
||||
#else // simply assume *nix + GCC-like compiler
|
||||
#define IFC_GEOMLIBRARY_API __attribute__((visibility("default")))
|
||||
#endif
|
||||
#else
|
||||
#define IFC_GEOMLIBRARY_API
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "../../kernel_plugin.h"
|
||||
#include "ManifoldKernel.h"
|
||||
|
||||
#include <boost/dll/alias.hpp>
|
||||
|
||||
namespace ifcopenshell {
|
||||
namespace geometry {
|
||||
namespace kernels {
|
||||
namespace manifold_plugin {
|
||||
|
||||
plugin::abi_info plugin_abi() {
|
||||
return plugin::host_abi();
|
||||
}
|
||||
|
||||
plugin::metadata plugin_metadata() {
|
||||
return kernel_plugin_metadata("manifold");
|
||||
}
|
||||
|
||||
AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) {
|
||||
return new ManifoldKernel(settings);
|
||||
}
|
||||
|
||||
void register_plugin(kernel_registry& registry, const plugin::module& module) {
|
||||
kernel_info info;
|
||||
info.backend_id = "manifold";
|
||||
info.supports_boolean_operations = true;
|
||||
registry.bind(info, create_kernel, module);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -47,6 +47,28 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape(const TopoDS_Shape& shape)
|
||||
: shape_(shape) {}
|
||||
|
||||
ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape(TopoDS_Shape&& shape)
|
||||
: shape_(std::move(shape)) {}
|
||||
|
||||
const TopoDS_Shape& ifcopenshell::geometry::OpenCascadeShape::shape() const {
|
||||
return shape_;
|
||||
}
|
||||
|
||||
ifcopenshell::geometry::OpenCascadeShape::operator const TopoDS_Shape& () {
|
||||
return shape_;
|
||||
}
|
||||
|
||||
std::string_view ifcopenshell::geometry::OpenCascadeShape::backend_id() const {
|
||||
return "opencascade";
|
||||
}
|
||||
|
||||
IfcGeom::ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::clone() const {
|
||||
return new OpenCascadeShape(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) const {
|
||||
|
||||
// @todo remove duplication with OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
|
||||
|
||||
@@ -45,21 +45,17 @@ namespace ifcopenshell {
|
||||
|
||||
class IFC_GEOMLIBRARY_API OpenCascadeShape : public IfcGeom::ConversionResultShape {
|
||||
public:
|
||||
OpenCascadeShape(const TopoDS_Shape& shape)
|
||||
: shape_(shape) {}
|
||||
OpenCascadeShape(TopoDS_Shape&& shape)
|
||||
: shape_(std::move(shape)) {}
|
||||
OpenCascadeShape(const TopoDS_Shape& shape);
|
||||
OpenCascadeShape(TopoDS_Shape&& shape);
|
||||
|
||||
const TopoDS_Shape& shape() const { return shape_; }
|
||||
operator const TopoDS_Shape& () { return shape_; }
|
||||
virtual std::string_view backend_id() const { return "opencascade"; }
|
||||
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) const;
|
||||
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
|
||||
|
||||
virtual IfcGeom::ConversionResultShape* clone() const {
|
||||
return new OpenCascadeShape(shape_);
|
||||
}
|
||||
virtual IfcGeom::ConversionResultShape* clone() const;
|
||||
|
||||
virtual double bounding_box(void*&) const {
|
||||
throw std::runtime_error("Not implemented");
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
namespace IfcGeom {
|
||||
namespace util {
|
||||
|
||||
void copy_operand(const TopTools_ListOfShape& l, TopTools_ListOfShape& r);
|
||||
IFC_GEOMLIBRARY_API void copy_operand(const TopTools_ListOfShape& l, TopTools_ListOfShape& r);
|
||||
|
||||
TopoDS_Shape copy_operand(const TopoDS_Shape& s);
|
||||
IFC_GEOMLIBRARY_API TopoDS_Shape copy_operand(const TopoDS_Shape& s);
|
||||
|
||||
double min_edge_length(const TopoDS_Shape& a);
|
||||
IFC_GEOMLIBRARY_API double min_edge_length(const TopoDS_Shape& a);
|
||||
|
||||
double min_vertex_edge_distance(const TopoDS_Shape& a, double min_search, double max_search);
|
||||
IFC_GEOMLIBRARY_API double min_vertex_edge_distance(const TopoDS_Shape& a, double min_search, double max_search);
|
||||
|
||||
class points_on_planar_face_generator {
|
||||
private:
|
||||
@@ -69,35 +69,35 @@ namespace IfcGeom {
|
||||
bool operator()(gp_Pnt& p);
|
||||
};
|
||||
|
||||
bool faces_overlap(const TopoDS_Face& f, const TopoDS_Face& g);
|
||||
IFC_GEOMLIBRARY_API bool faces_overlap(const TopoDS_Face& f, const TopoDS_Face& g);
|
||||
|
||||
double min_face_face_distance(const TopoDS_Shape& a, double max_search);
|
||||
IFC_GEOMLIBRARY_API double min_face_face_distance(const TopoDS_Shape& a, double max_search);
|
||||
|
||||
int bounding_box_overlap(double p, const TopoDS_Shape& a, const TopTools_ListOfShape& b, TopTools_ListOfShape& c);
|
||||
IFC_GEOMLIBRARY_API int bounding_box_overlap(double p, const TopoDS_Shape& a, const TopTools_ListOfShape& b, TopTools_ListOfShape& c);
|
||||
|
||||
bool get_edge_axis(const TopoDS_Edge& e, gp_Ax1& ax);
|
||||
IFC_GEOMLIBRARY_API bool get_edge_axis(const TopoDS_Edge& e, gp_Ax1& ax);
|
||||
|
||||
bool is_subset(const TopTools_IndexedMapOfShape& lhs, const TopTools_IndexedMapOfShape& rhs);
|
||||
IFC_GEOMLIBRARY_API bool is_subset(const TopTools_IndexedMapOfShape& lhs, const TopTools_IndexedMapOfShape& rhs);
|
||||
|
||||
bool is_extrusion(const gp_Vec& v, const TopoDS_Shape& s, TopoDS_Face& base, std::pair<double, double>& interval);
|
||||
IFC_GEOMLIBRARY_API bool is_extrusion(const gp_Vec& v, const TopoDS_Shape& s, TopoDS_Face& base, std::pair<double, double>& interval);
|
||||
|
||||
int eliminate_touching_operands(double prec, const TopoDS_Shape& a, const TopTools_ListOfShape& bs, TopTools_ListOfShape& c);
|
||||
IFC_GEOMLIBRARY_API int eliminate_touching_operands(double prec, const TopoDS_Shape& a, const TopTools_ListOfShape& bs, TopTools_ListOfShape& c);
|
||||
|
||||
int eliminate_narrow_operands(double prec, const TopTools_ListOfShape& bs, TopTools_ListOfShape & c);
|
||||
IFC_GEOMLIBRARY_API int eliminate_narrow_operands(double prec, const TopTools_ListOfShape& bs, TopTools_ListOfShape & c);
|
||||
|
||||
bool boolean_subtraction_2d_using_builder(const TopoDS_Shape& a_input, const TopTools_ListOfShape& b_input, TopoDS_Shape& result, double eps);
|
||||
IFC_GEOMLIBRARY_API bool boolean_subtraction_2d_using_builder(const TopoDS_Shape& a_input, const TopTools_ListOfShape& b_input, TopoDS_Shape& result, double eps);
|
||||
|
||||
struct boolean_settings {
|
||||
bool debug, attempt_2d;
|
||||
double precision;
|
||||
};
|
||||
|
||||
bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const TopTools_ListOfShape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
|
||||
IFC_GEOMLIBRARY_API bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const TopTools_ListOfShape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
|
||||
|
||||
bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const TopoDS_Shape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
|
||||
IFC_GEOMLIBRARY_API bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const TopoDS_Shape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
|
||||
|
||||
TopoDS_Shape ensure_fit_for_subtraction(const TopoDS_Shape& shape, double tol);
|
||||
IFC_GEOMLIBRARY_API TopoDS_Shape ensure_fit_for_subtraction(const TopoDS_Shape& shape, double tol);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "../../kernel_plugin.h"
|
||||
#include "OpenCascadeKernel.h"
|
||||
|
||||
#include <boost/dll/alias.hpp>
|
||||
|
||||
namespace ifcopenshell {
|
||||
namespace geometry {
|
||||
namespace kernels {
|
||||
namespace opencascade_plugin {
|
||||
|
||||
plugin::abi_info plugin_abi() {
|
||||
return plugin::host_abi();
|
||||
}
|
||||
|
||||
plugin::metadata plugin_metadata() {
|
||||
return kernel_plugin_metadata("opencascade");
|
||||
}
|
||||
|
||||
AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) {
|
||||
return new IfcGeom::OpenCascadeKernel(settings);
|
||||
}
|
||||
|
||||
void register_plugin(kernel_registry& registry, const plugin::module& module) {
|
||||
kernel_info info;
|
||||
info.backend_id = "opencascade";
|
||||
info.supports_boolean_operations = true;
|
||||
registry.bind(info, create_kernel, module);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -0,0 +1,56 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "../../kernel_plugin.h"
|
||||
#include "PassthroughKernel.h"
|
||||
|
||||
#include <boost/dll/alias.hpp>
|
||||
|
||||
namespace ifcopenshell {
|
||||
namespace geometry {
|
||||
namespace kernels {
|
||||
namespace passthrough_plugin {
|
||||
|
||||
plugin::abi_info plugin_abi() {
|
||||
return plugin::host_abi();
|
||||
}
|
||||
|
||||
plugin::metadata plugin_metadata() {
|
||||
return kernel_plugin_metadata("passthrough");
|
||||
}
|
||||
|
||||
AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) {
|
||||
return new PassthroughKernel(settings);
|
||||
}
|
||||
|
||||
void register_plugin(kernel_registry& registry, const plugin::module& module) {
|
||||
kernel_info info;
|
||||
info.backend_id = "passthrough";
|
||||
info.supports_boolean_operations = false;
|
||||
registry.bind(info, create_kernel, module);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user