Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aothms committed Nov 23, 2024
1 parent b47dfd0 commit 0c32361
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 13 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ jobs:
-DUSE_BUILD_SCRIPT_OUTPUT=Off `
-DBoost_USE_STATIC_LIBS=On `
-DBoost_NO_BOOST_CMAKE=On `
-DCMAKE_INSTALL_PREFIX=../install `
-DIFC_INCLUDE_DIR=../IfcOpenShell/_installed-vs2019-x64/include `
-DIFC_LIBRARY_DIR=../IfcOpenShell/_installed-vs2019-x64/ifcopenshell/lib `
-DOCC_INCLUDE_DIR=../IfcOpenShell/_deps-vs2022-x64-installed/opencascade-7.8.1/inc `
-DOCC_LIBRARY_DIR=../IfcOpenShell/_deps-vs2022-x64-installed/opencascade-7.8.1/win64/lib `
-DCMAKE_INSTALL_PREFIX=$env:GITHUB_WORKSPACE\install `
-DIFC_INCLUDE_DIR=$env:GITHUB_WORKSPACE\IfcOpenShell\_installed-vs2019-x64\include `
-DIFC_LIBRARY_DIR=$env:GITHUB_WORKSPACE\IfcOpenShell\_installed-vs2019-x64\ifcopenshell\lib `
-DOCC_INCLUDE_DIR=$env:GITHUB_WORKSPACE\IfcOpenShell\_deps-vs2019-x64-installed\opencascade-7.8.1\inc `
-DOCC_LIBRARY_DIR=$env:GITHUB_WORKSPACE\IfcOpenShell\_deps-vs2019-x64-installed\opencascade-7.8.1\win64\lib `
-DPython_EXECUTABLE=C:\Python\${{ matrix.python }}\python.exe `
-DBOOST_ROOT=../IfcOpenShell/_deps/boost_1_86_0 `
-DSWIG_DIR=../IfcOpenShell/_installed-vs2019-x64/swigwin
-DBOOST_ROOT=$env:GITHUB_WORKSPACE\IfcOpenShell\_deps\boost_1_86_0 `
-DSWIG_DIR=$env:GITHUB_WORKSPACE\IfcOpenShell\_installed-vs2019-x64\swigwin
cmake --build . --target install --config Release
- name: Package .zip Archives
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,15 @@ if (IFC_SUPPORT)
list(APPEND SCHEMA_VERSIONS ${schema_name})
endforeach()

if(${ifcopenshell_major_version} STREQUAL "0.7")
add_definitions("-DIFCOPENSHELL_07")
if(${ifcopenshell_major_version} STREQUAL "0.7" OR
${ifcopenshell_major_version} STREQUAL "0.8")

if(${ifcopenshell_major_version} STREQUAL "0.8")
add_definitions("-DIFCOPENSHELL_08")
else()
add_definitions("-DIFCOPENSHELL_07")
endif()

set(SWIG_DEFINES ${SWIG_DEFINES} -DIFCOPENSHELL_07)

string(REPLACE ";" ")(" schema_version_seq "(${SCHEMA_VERSIONS})")
Expand Down
6 changes: 6 additions & 0 deletions processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

#ifdef WITH_IFC

#ifdef IFCOPENSHELL_08
#include <ifcgeom/IfcGeomElement.h>

typedef IfcGeom::BRepElement elem_t;
#else
#ifdef IFCOPENSHELL_07
#include <ifcparse/IfcLogger.h> // @todo < commit in IfcopenShell
#include <ifcgeom_schema_agnostic/IfcGeomElement.h>
Expand All @@ -29,6 +34,7 @@ typedef IfcGeom::BRepElement elem_t;
typedef IfcGeom::BRepElement<double> elem_t;
#endif
#endif
#endif

typedef TopoDS_Shape geometry_t;
typedef std::vector<std::pair<std::pair<void*, int>, TopoDS_Compound > > geometry_collection_t;
Expand Down
45 changes: 41 additions & 4 deletions voxec.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
#ifdef IFCOPENSHELL_05
#include <ifcgeom/IfcGeomIterator.h>
#else
#ifdef IFCOPENSHELL_08
#include <ifcgeom/Iterator.h>
#include <ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h>
#else
#include <ifcgeom_schema_agnostic/IfcGeomIterator.h>
#endif
#endif

#include <ifcparse/IfcFile.h>
#include <boost/filesystem.hpp>
Expand Down Expand Up @@ -293,15 +298,22 @@ class op_parse_ifc_file : public voxel_operation {
std::vector<IfcUtil::IfcBaseClass*> projects_copy(projects->begin(), projects->end());
if (projects->size() > 1) {
for (auto it = projects_copy.begin() + 1; it != projects_copy.end(); ++it) {
#ifdef IFCOPENSHELL_08
auto inverses = f->getInverse((*it)->id(), nullptr, -1);
#else
auto inverses = f->getInverse((*it)->data().id(), nullptr, -1);

#endif
f->removeEntity(*it);

for (auto& inv : *inverses) {
if (inv->declaration().name() == "IFCRELAGGREGATES") {
#ifdef IFCOPENSHELL_08
inv->set_attribute_value(4, projects_copy[0]);
#else
auto attr = new IfcWrite::IfcWriteArgument;
attr->set(projects_copy[0]);
inv->data().setArgument(4, attr);
#endif
}
}
}
Expand All @@ -324,7 +336,7 @@ class op_parse_ifc_file : public voxel_operation {
};

#ifdef WITH_IFC
#ifdef IFCOPENSHELL_07
#if defined(IFCOPENSHELL_07) || defined(IFCOPENSHELL_08)
typedef IfcGeom::Iterator iterator_t;
typedef aggregate_of_instance instance_list_t;
#else
Expand Down Expand Up @@ -376,6 +388,11 @@ class op_create_geometry : public voxel_operation {

const filtered_files_t& ifc_files = scope.get_value<filtered_files_t>("input");

#ifdef IFCOPENSHELL_08
ifcopenshell::geometry::Settings settings_surface;
settings_surface.get<ifcopenshell::geometry::settings::UseElementHierarchy>().value = true;
settings_surface.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
#else
IfcGeom::IteratorSettings settings_surface;
settings_surface.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
// settings_surface.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, true);
Expand All @@ -384,6 +401,7 @@ class op_create_geometry : public voxel_operation {
settings_surface.set(IfcGeom::IteratorSettings::ELEMENT_HIERARCHY, true);
#else
settings_surface.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, true);
#endif
#endif

boost::optional<bool> include, roof_slabs;
Expand Down Expand Up @@ -454,13 +472,17 @@ class op_create_geometry : public voxel_operation {

#ifdef IFCOPENSHELL_05
iterator.reset(iterator_t(settings_surface, ifc_file, filters_surface));
#else
#ifdef IFCOPENSHELL_08
iterator.reset(new iterator_t("opencascade", settings_surface, ifc_file, filters_surface, threads.get_value_or(1)));
#else
if (threads) {
iterator.reset(new iterator_t(settings_surface, ifc_file, filters_surface, *threads));
} else {
iterator.reset(new iterator_t(settings_surface, ifc_file, filters_surface));
}
#endif
#endif


// For debugging geometry creation from IfcOpenShell
Expand Down Expand Up @@ -503,7 +525,11 @@ class op_create_geometry : public voxel_operation {
}
if (roof_slabs && elem_product->declaration().is("IfcSlab")) {
auto attr_value = elem_product->get("PredefinedType");
#ifdef IFCOPENSHELL_08
std::string pdt = attr_value.type() == IfcUtil::Argument_STRING ? (std::string)attr_value : std::string("");
#else
std::string pdt = attr_value->isNull() ? std::string("") : (std::string)(*attr_value);
#endif
process = process && (pdt == "ROOF") == *roof_slabs;
}
#endif
Expand All @@ -514,15 +540,26 @@ class op_create_geometry : public voxel_operation {
} catch (...) {
#ifdef IFCOPENSHELL_05
throw std::runtime_error("Error evaluating filter on " + elem_product->toString());
#else
#ifdef IFCOPENSHELL_08
std::ostringstream oss;
elem_product->toString(oss);
throw std::runtime_error("Error evaluating filter on " + oss.str());
#else
throw std::runtime_error("Error evaluating filter on " + elem_product->data().toString());
#endif
#endif
}
}

if (process) {
#ifdef IFCOPENSHELL_08
auto comp = elem->geometry().as_compound();
TopoDS_Compound compound = TopoDS::Compound(((ifcopenshell::geometry::OpenCascadeShape*)comp)->shape());
delete comp;
#else
TopoDS_Compound compound = elem->geometry().as_compound();
#endif
bool filtered_non_empty = true;
if (only_transparent || only_opaque) {
filtered_non_empty = false;
Expand All @@ -532,7 +569,7 @@ class op_create_geometry : public voxel_operation {

auto it = elem->geometry().begin();
for (TopoDS_Iterator jt(compound); jt.More(); ++it, jt.Next()) {
bool is_transparent = it->hasStyle() && it->Style().Transparency().get_value_or(0.0) > 1.e-9;
bool is_transparent = it->hasStyle() && it->Style().has_transparency() && it->Style().transparency > 1.e-9;
if (only_transparent == is_transparent) {
B.Add(filtered, jt.Value());
filtered_non_empty = true;
Expand Down

0 comments on commit 0c32361

Please sign in to comment.