mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
start work on improving support for IfcFixedReferenceSweptAreaSolid
This commit is contained in:
@@ -107,3 +107,5 @@ src/bonsai/bonsai/bim/schema/Brick.ttl
|
||||
|
||||
bonsaiDecoratorForLoads.code-workspace
|
||||
dev_environment.bat
|
||||
|
||||
.pixi/
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"version": 6,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "shared",
|
||||
"generator": "Ninja",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"BUILD_IFCPYTHON": "ON",
|
||||
"BUILD_IFCGEOM": "ON",
|
||||
"COLLADA_SUPPORT": "OFF",
|
||||
"BUILD_EXAMPLES": "OFF",
|
||||
"BUILD_GEOMSERVER": "OFF",
|
||||
"GLTF_SUPPORT": "ON",
|
||||
"BUILD_CONVERT": "ON",
|
||||
"BUILD_IFCMAX": "OFF",
|
||||
"IFCXML_SUPPORT": "ON",
|
||||
"HDF5_SUPPORT": "ON",
|
||||
"SCHEMA_VERSIONS": "4x3_add2",
|
||||
"CITYJSON_SUPPORT": "OFF",
|
||||
"CMAKE_GENERATOR_PLATFORM": "",
|
||||
"CMAKE_GENERATOR_TOOLSET": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "win-shared",
|
||||
"inherits": [
|
||||
"shared"
|
||||
],
|
||||
"hidden": true,
|
||||
"environment": {
|
||||
"CONDA_BUILD": "ON",
|
||||
"CONDA_PY": "312"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"Boost_USE_STATIC_LIBS": "OFF",
|
||||
"CMAKE_INSTALL_PREFIX": "$env{LIBRARY_PREFIX}",
|
||||
"PYTHON_EXECUTABLE": "$env{PREFIX}/python.exe",
|
||||
"PYTHON_INCLUDE_DIR": "$env{PREFIX}/include",
|
||||
"PYTHON_LIBRARY": "$env{PREFIX}/libs/python$env{CONDA_PY}.lib",
|
||||
"CMAKE_FIND_ROOT_PATH": "$env{LIBRARY_PREFIX}",
|
||||
"CMAKE_PREFIX_PATH": "$env{LIBRARY_PREFIX}",
|
||||
"LIBXML2_LIBRARIES": "$env{LIBRARY_PREFIX}/lib/libxml2.lib",
|
||||
"OCC_INCLUDE_DIR": "$env{LIBRARY_PREFIX}/include/opencascade",
|
||||
"OCC_LIBRARY_DIR": "$env{LIBRARY_PREFIX}/lib",
|
||||
"CGAL_INCLUDE_DIR": "$env{LIBRARY_PREFIX}/include",
|
||||
"EIGEN_DIR": "$env{LIBRARY_PREFIX}/include/eigen3",
|
||||
"JSON_INCLUDE_DIR": "$env{LIBRARY_PREFIX}/include",
|
||||
"GMP_INCLUDE_DIR": "$env{LIBRARY_PREFIX}/include",
|
||||
"GMP_LIBRARY_DIR": "$env{LIBRARY_PREFIX}/lib",
|
||||
"MPFR_LIBRARY_DIR": "$env{LIBRARY_PREFIX}/lib",
|
||||
"Boost_LIBRARY_DIR": "$env{LIBRARY_PREFIX}/lib",
|
||||
"Boost_INCLUDE_DIR": "$env{LIBRARY_PREFIX}/include",
|
||||
"HDF5_INCLUDE_DIR": "$env{LIBRARY_PREFIX}/include",
|
||||
"HDF5_LIBRARY_DIR": "$env{LIBRARY_PREFIX}/lib",
|
||||
"ZLIB_INCLUDE_DIR": "$env{LIBRARY_PREFIX}/include"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "win-release",
|
||||
"inherits": [
|
||||
"win-shared"
|
||||
],
|
||||
"hidden": false,
|
||||
"warnings": {
|
||||
"dev": false
|
||||
},
|
||||
"environment": {
|
||||
"PREFIX": "${sourceDir}/../.pixi/envs/prod",
|
||||
"LIBRARY_PREFIX": "${sourceDir}/../.pixi/envs/prod/Library"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "win-debug",
|
||||
"inherits": [
|
||||
"win-shared"
|
||||
],
|
||||
"hidden": false,
|
||||
"binaryDir": "${sourceDir}/../build/win-debug",
|
||||
"warnings": {
|
||||
"dev": false
|
||||
},
|
||||
"environment": {
|
||||
"PREFIX": "${sourceDir}/../.pixi/envs/dev",
|
||||
"LIBRARY_PREFIX": "${sourceDir}/../.pixi/envs/dev/Library"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
[project]
|
||||
name = "IfcOpenShell"
|
||||
version = "0.8.2"
|
||||
description = "IfcOpenShell is a library to support the IFC file format"
|
||||
channels = ["conda-forge"]
|
||||
platforms = ["win-64", "linux-64", "osx-64"]
|
||||
|
||||
[environments]
|
||||
common = { features = ["common"], no-default-feature = true }
|
||||
prod = { features = ["prod", "common"], no-default-feature = true }
|
||||
dev = { features = ["dev", "common"], no-default-feature = true }
|
||||
|
||||
[feature.common.dependencies]
|
||||
# Build deps
|
||||
cmake = "==3.30.5"
|
||||
ninja = "*"
|
||||
swig = "*"
|
||||
c-compiler = "*"
|
||||
cxx-compiler = "*"
|
||||
|
||||
# Runtime deps
|
||||
python = "3.12.*"
|
||||
libboost-devel = "*"
|
||||
occt = { version = "*", build = "*novtk*" }
|
||||
cgal-cpp = "*"
|
||||
numpy = "*"
|
||||
lark = "*"
|
||||
hdf5 = "*"
|
||||
eigen = "*"
|
||||
mpfr = "*"
|
||||
gmp = "*"
|
||||
nlohmann_json = "*"
|
||||
zlib = "*"
|
||||
|
||||
|
||||
[feature.common.target.win-64.dependencies]
|
||||
vs2022_win-64 = "*"
|
||||
#vs_win-64 = "*" # Visual Studio
|
||||
#vswhere = "*" # Visual Studio
|
||||
|
||||
[feature.common.target.win-64.tasks]
|
||||
init-submodules = { cmd = "git submodule update --init --recursive", outputs =["$PIXI_PROJECT_ROOT/src/svgfill/3rdparty/svgpp/*"]}
|
||||
|
||||
[feature.prod.target.win-64.tasks]
|
||||
configure-release = { cmd = ["cmake", "--preset", "win-release", "-B", "build/win-release", "cmake"], description = "Configure the project", depends-on=["init-submodules"] }
|
||||
build-release = { cmd = ["cmake", "--build", "build/win-release", "--config", "Release"], description = "Build the project" }
|
||||
|
||||
[feature.dev.target.win-64.tasks]
|
||||
configure-debug = { cmd = ["cmake", "--preset", "win-debug", "-B", "build/win-debug", "cmake"], description = "Configure the project", depends-on=["init-submodules"], outputs=["$PIXI_PROJECT_ROOT/build/win-debug/CMakeCache.txt"] }
|
||||
build-debug = { cmd = ["cmake", "--build", "build/win-debug", "--config", "Debug"], description = "Build the project" }
|
||||
install-debug = { cmd = ["cmake", "--install", "build/win-debug", "--config", "Debug"], description = "Install the project" }
|
||||
|
||||
vsdebug = { cmd = ["python"], description = "Run a python script with vs debugger attached" }
|
||||
|
||||
[feature.common.target.win-64.activation]
|
||||
#scripts = ["cmake/activate.bat"]
|
||||
@@ -17,106 +17,133 @@
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "mapping.h"
|
||||
#include "../function_item_evaluator.h"
|
||||
#include "mapping.h"
|
||||
#define mapping POSTFIX_SCHEMA(mapping)
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcFixedReferenceSweptAreaSolid
|
||||
|
||||
namespace {
|
||||
// Helper function to check if an IFC instance has alignment elements
|
||||
bool has_alignment_elements(const IfcSchema::IfcFixedReferenceSweptAreaSolid* inst) {
|
||||
if (inst->Directrix()->declaration().name() == "IfcGradientCurve") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFixedReferenceSweptAreaSolid* inst) {
|
||||
auto dir = map(inst->Directrix());
|
||||
auto ref = taxonomy::cast<taxonomy::direction3>(map(inst->FixedReference()));
|
||||
auto profile = taxonomy::cast<taxonomy::face>(map(inst->SweptArea()));
|
||||
auto dir = map(inst->Directrix());
|
||||
auto ref = taxonomy::cast<taxonomy::direction3>(map(inst->FixedReference()));
|
||||
auto profile = taxonomy::cast<taxonomy::face>(map(inst->SweptArea()));
|
||||
|
||||
auto loft = taxonomy::make<taxonomy::loft>();
|
||||
// @todo intialize as default
|
||||
loft->axis = nullptr;
|
||||
|
||||
// @todo currently only the case is handled where directrix returns a piecewise_function
|
||||
if (auto fn = taxonomy::dcast<taxonomy::function_item>(dir)) {
|
||||
function_item_evaluator evaluator(settings_,fn);
|
||||
double start = 0;
|
||||
double end = fn->length();
|
||||
auto loft = taxonomy::make<taxonomy::loft>();
|
||||
// @todo intialize as default
|
||||
loft->axis = nullptr;
|
||||
// Check if this instance has alignment elements
|
||||
if (has_alignment_elements(inst)) {
|
||||
// @todo currently only the case is handled where directrix returns a piecewise_function
|
||||
if (auto fn = taxonomy::dcast<taxonomy::function_item>(dir)) {
|
||||
function_item_evaluator evaluator(settings_, fn);
|
||||
double start = 0;
|
||||
double end = fn->length();
|
||||
#ifdef SCHEMA_HAS_IfcDirectrixCurveSweptAreaSolid
|
||||
// IfcDirectrixCurveSweptAreaSolid introduced in 4.3 changed attribute type
|
||||
// from optional IfcParamValue to optional IfcCurveMeasureSelect.
|
||||
// Invocation of mapping on pre-4.3 models can never result in a piecewise_function.
|
||||
if (inst->StartParam() && inst->StartParam()->as<IfcSchema::IfcLengthMeasure>()) {
|
||||
double s = *inst->StartParam()->as<IfcSchema::IfcLengthMeasure>();
|
||||
if (s > start) {
|
||||
start = s;
|
||||
}
|
||||
}
|
||||
if (inst->EndParam() && inst->EndParam()->as<IfcSchema::IfcLengthMeasure>()) {
|
||||
double e = *inst->EndParam()->as<IfcSchema::IfcLengthMeasure>();
|
||||
if (e < end) {
|
||||
end = e;
|
||||
}
|
||||
}
|
||||
// IfcDirectrixCurveSweptAreaSolid introduced in 4.3 changed attribute type
|
||||
// from optional IfcParamValue to optional IfcCurveMeasureSelect.
|
||||
// Invocation of mapping on pre-4.3 models can never result in a piecewise_function.
|
||||
if (inst->StartParam() && inst->StartParam()->as<IfcSchema::IfcLengthMeasure>()) {
|
||||
double s = *inst->StartParam()->as<IfcSchema::IfcLengthMeasure>();
|
||||
if (s > start) {
|
||||
start = s;
|
||||
}
|
||||
}
|
||||
if (inst->EndParam() && inst->EndParam()->as<IfcSchema::IfcLengthMeasure>()) {
|
||||
double e = *inst->EndParam()->as<IfcSchema::IfcLengthMeasure>();
|
||||
if (e < end) {
|
||||
end = e;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
auto evaluation_points = evaluator.evaluation_points();
|
||||
for (const auto& dist_along : evaluation_points) {
|
||||
auto m4 = evaluator.evaluate(dist_along);
|
||||
|
||||
/*
|
||||
std::stringstream ss;
|
||||
ss << m4;
|
||||
auto s = ss.str();
|
||||
std::wcout << s.c_str() << std::endl;
|
||||
auto evaluation_points = evaluator.evaluation_points();
|
||||
for (const auto& dist_along : evaluation_points) {
|
||||
auto m4 = evaluator.evaluate(dist_along);
|
||||
|
||||
/*
|
||||
std::stringstream ss;
|
||||
ss << m4;
|
||||
auto s = ss.str();
|
||||
std::wcout << s.c_str() << std::endl;
|
||||
std::wcout << "determinant: " << m4.determinant() << std::endl;
|
||||
*/
|
||||
*/
|
||||
|
||||
Eigen::Matrix4d m4b = Eigen::Matrix4d::Identity();
|
||||
bool is_directrix_derived = false;
|
||||
|
||||
Eigen::Matrix4d m4b = Eigen::Matrix4d::Identity();
|
||||
bool is_directrix_derived = false;
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcDirectrixDerivedReferenceSweptAreaSolid
|
||||
if (inst->as<IfcSchema::IfcDirectrixDerivedReferenceSweptAreaSolid>()) {
|
||||
is_directrix_derived = true;
|
||||
}
|
||||
if (inst->as<IfcSchema::IfcDirectrixDerivedReferenceSweptAreaSolid>()) {
|
||||
is_directrix_derived = true;
|
||||
}
|
||||
#endif
|
||||
auto pos = m4.col(3).head<3>();
|
||||
auto pos = m4.col(3).head<3>();
|
||||
|
||||
if (is_directrix_derived) {
|
||||
m4b.col(0).head<3>() = m4.col(1).head<3>();
|
||||
m4b.col(1).head<3>() = m4.col(0).head<3>().cross(m4.col(1).head<3>());
|
||||
m4b.col(2).head<3>() = m4.col(0).head<3>();
|
||||
m4b.col(3).head<3>() = pos;
|
||||
} else {
|
||||
Eigen::Vector3d tangent = m4.col(0).head<3>().normalized();
|
||||
Eigen::Vector3d proj = (ref->components() - tangent * tangent.dot(ref->components()));
|
||||
proj.normalize();
|
||||
auto ref = proj.cross(tangent);
|
||||
if (is_directrix_derived) {
|
||||
m4b.col(0).head<3>() = m4.col(1).head<3>();
|
||||
m4b.col(1).head<3>() = m4.col(0).head<3>().cross(m4.col(1).head<3>());
|
||||
m4b.col(2).head<3>() = m4.col(0).head<3>();
|
||||
m4b.col(3).head<3>() = pos;
|
||||
} else {
|
||||
Eigen::Vector3d tangent = m4.col(0).head<3>().normalized();
|
||||
Eigen::Vector3d proj = (ref->components() - tangent * tangent.dot(ref->components()));
|
||||
proj.normalize();
|
||||
auto ref = proj.cross(tangent);
|
||||
|
||||
m4b.col(0).head<3>() = proj;
|
||||
m4b.col(1).head<3>() = ref;
|
||||
m4b.col(2).head<3>() = tangent;
|
||||
m4b.col(3).head<3>() = pos;
|
||||
m4b.col(0).head<3>() = proj;
|
||||
m4b.col(1).head<3>() = ref;
|
||||
m4b.col(2).head<3>() = tangent;
|
||||
m4b.col(3).head<3>() = pos;
|
||||
|
||||
/*
|
||||
Eigen::JacobiSVD<decltype(m4b)> svd(m4b);
|
||||
auto condition_number = svd.singularValues()(0)
|
||||
/ svd.singularValues()(svd.singularValues().size() - 1);
|
||||
if (condition_number > 1.e10) {
|
||||
Logger::Error("Non-invertible matrix at " + std::to_string(distalong) + " conversion will likely fail.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
/*
|
||||
Eigen::JacobiSVD<decltype(m4b)> svd(m4b);
|
||||
auto condition_number = svd.singularValues()(0)
|
||||
/ svd.singularValues()(svd.singularValues().size() - 1);
|
||||
if (condition_number > 1.e10) {
|
||||
Logger::Error("Non-invertible matrix at " + std::to_string(distalong) + " conversion will likely fail.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// @todo taxonomy::clone() does not actually clone. That's really confusing.
|
||||
// loft->children.push_back(taxonomy::clone(profile));
|
||||
loft->children.push_back(taxonomy::face::ptr(profile->clone_()));
|
||||
loft->children.back()->matrix = taxonomy::make<taxonomy::matrix4>();
|
||||
|
||||
if (profile->matrix) {
|
||||
loft->children.back()->matrix->components() = (m4b * profile->matrix->ccomponents()).eval();
|
||||
} else {
|
||||
loft->children.back()->matrix->components() = m4b;
|
||||
}
|
||||
}
|
||||
}
|
||||
// @todo taxonomy::clone() does not actually clone. That's really confusing.
|
||||
// loft->children.push_back(taxonomy::clone(profile));
|
||||
loft->children.push_back(taxonomy::face::ptr(profile->clone_()));
|
||||
loft->children.back()->matrix = taxonomy::make<taxonomy::matrix4>();
|
||||
|
||||
return loft;
|
||||
if (profile->matrix) {
|
||||
loft->children.back()->matrix->components() = (m4b * profile->matrix->ccomponents()).eval();
|
||||
} else {
|
||||
loft->children.back()->matrix->components() = m4b;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: Implement handling for non-alignment curves using sweep_along_curve
|
||||
auto sweep = taxonomy::make<taxonomy::sweep_along_curve>(
|
||||
nullptr, // matrix4::ptr - no transformation needed
|
||||
profile, // face::ptr - the profile to sweep
|
||||
nullptr, // item::ptr surface - not used for fixed reference sweep
|
||||
dir // item::ptr curve - the directrix curve
|
||||
|
||||
);
|
||||
|
||||
// Set the fixed reference direction for the sweep
|
||||
sweep->direction = ref; // The fixed reference direction
|
||||
|
||||
return sweep;
|
||||
}
|
||||
|
||||
return loft;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1158,6 +1158,7 @@ typedef item const* ptr;
|
||||
|
||||
item::ptr surface;
|
||||
item::ptr curve;
|
||||
direction3::ptr direction = nullptr;
|
||||
|
||||
virtual sweep_along_curve* clone_() const { return new sweep_along_curve(*this); }
|
||||
virtual kinds kind() const { return SWEEP_ALONG_CURVE; }
|
||||
|
||||
Reference in New Issue
Block a user