diff --git a/.gitmodules b/.gitmodules index e15dfb45d8..d21535b7f8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,4 +10,7 @@ url = https://github.com/IfcOpenShell/svgfill [submodule "src/ifcopenshell-python/test/Sample-BIM-Files"] path = src/ifcopenshell-python/test/Sample-BIM-Files - url = https://github.com/IfcOpenShell/ids-test-files \ No newline at end of file + url = https://github.com/IfcOpenShell/ids-test-files +[submodule "src/ifcconvert/cityjson"] + path = src/ifcconvert/cityjson + url = https://github.com/IfcOpenShell/ifc-to-cityjson diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 69b4c7e122..2d4855b2bc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -919,6 +919,23 @@ endif() if (BUILD_CONVERT) +if (WITH_CGAL) +set(CITYJSON_CONVERT_FILES + ../src/ifcconvert/cityjson/geobim.cpp + ../src/ifcconvert/cityjson/global_execution_context.cpp + ../src/ifcconvert/cityjson/opening_collector.cpp + ../src/ifcconvert/cityjson/processing.cpp + ../src/ifcconvert/cityjson/radius_comparison.cpp + ../src/ifcconvert/cityjson/radius_execution_context.cpp + ../src/ifcconvert/cityjson/settings.cpp + ../src/ifcconvert/cityjson/writer.cpp +) + +add_library(cityjson_converter ${CITYJSON_CONVERT_FILES}) +target_include_directories(cityjson_converter PRIVATE ../src) +set(IFCOPENSHELL_LIBRARIES ${IFCOPENSHELL_LIBRARIES} cityjson_converter) +endif() + # IfcConvert file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp) file(GLOB IFCCONVERT_H_FILES ../src/ifcconvert/*.h) @@ -1010,6 +1027,7 @@ ENDIF() IF(NOT MINIMAL_BUILD AND BUILD_IFCMAX) ADD_SUBDIRECTORY(../src/ifcmax ifcmax) ENDIF() + if (NOT MINIMAL_BUILD) if (WITH_CGAL) ADD_SUBDIRECTORY(../src/svgfill svgfill) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 0ca7e6e185..85bce2b50d 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -41,6 +41,10 @@ #include "../ifcparse/utils.h" +#ifdef IFOPSH_WITH_CGAL +#include "./cityjson/geobim.h" +#endif + #ifdef IFOPSH_WITH_OPENCASCADE #include @@ -116,6 +120,9 @@ void print_usage(bool suggest_help = true) << " .svg SVG Scalable Vector Graphics (2D floor plan)\n" #ifdef WITH_HDF5 << " .h5 HDF Hierarchical Data Format storing positions, normals and indices\n" +#endif +#ifdef IFOPSH_WITH_CGAL + << " .city.json City JSON format for geospatial data\n" #endif << " .ifc IFC-SPF Industry Foundation Classes\n" << "\n" @@ -730,6 +737,7 @@ int main(int argc, char** argv) { CACHE = IfcUtil::path::from_utf8(".cache"), HDF = IfcUtil::path::from_utf8(".h5"), XML = IfcUtil::path::from_utf8(".xml"), + CITY_JSON = IfcUtil::path::from_utf8(".cityjson"), IFC = IfcUtil::path::from_utf8(".ifc"); // @todo clean up serializer selection @@ -779,6 +787,36 @@ int main(int argc, char** argv) { write_log(!quiet); return exit_code; } +#ifdef IFOPSH_WITH_CGAL + else if (output_extension == CITY_JSON) { + geobim_settings settings; + settings.input_filenames = { IfcUtil::path::to_utf8(input_filename) }; + settings.cityjson_output_filename = IfcUtil::path::to_utf8(output_filename); + // @todo + settings.radii = { "0.05" }; + settings.apply_openings = false; + settings.apply_openings_posthoc = true; + settings.debug = false; + settings.exact_segmentation = false; + settings.minkowski_triangles = false; + settings.no_erosion = false; + settings.spherical_padding = false; + + settings.settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, false); + settings.settings.set(IfcGeom::IteratorSettings::WELD_VERTICES, false); + settings.settings.set(IfcGeom::IteratorSettings::SEW_SHELLS, true); + settings.settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, true); + settings.settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); + settings.settings.set(IfcGeom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS, !settings.apply_openings); + + settings.entity_names = include_filter.values; + settings.entity_names_included = true; + + perform(settings); + + return 0; + } +#endif /// @todo Clean up this filter code further. std::vector used_filters; diff --git a/src/ifcconvert/cityjson b/src/ifcconvert/cityjson new file mode 160000 index 0000000000..36f8678962 --- /dev/null +++ b/src/ifcconvert/cityjson @@ -0,0 +1 @@ +Subproject commit 36f86789623fadc9660aa5f65668ae09435728fb