#1153 work on embedding svgfill in ifcopenshell wrapper

This commit is contained in:
Thomas Krijnen
2021-08-07 23:09:19 +02:00
parent 872306fdd0
commit 2f8ff9391c
13 changed files with 197 additions and 9 deletions
+3
View File
@@ -5,3 +5,6 @@
[submodule "src/ifcopenshell-python/ifcopenshell/mvd"] [submodule "src/ifcopenshell-python/ifcopenshell/mvd"]
path = src/ifcopenshell-python/ifcopenshell/mvd path = src/ifcopenshell-python/ifcopenshell/mvd
url = https://github.com/opensourceBIM/python-mvdxml/ url = https://github.com/opensourceBIM/python-mvdxml/
[submodule "src/svgfill"]
path = src/svgfill
url = https://github.com/IfcOpenShell/svgfill
+15 -1
View File
@@ -21,7 +21,12 @@ cmake_minimum_required(VERSION 3.1.3)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # not necessary, but encouraged set(CMAKE_CXX_STANDARD_REQUIRED ON) # not necessary, but encouraged
project (IfcOpenShell VERSION 0.6.0) project (IfcOpenShell VERSION 0.7.0)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0078 OLD)
cmake_policy(SET CMP0086 NEW)
# use extra version to make pre-release using eg semver # use extra version to make pre-release using eg semver
set( EXTRA_VERSION "-alpha.3") set( EXTRA_VERSION "-alpha.3")
@@ -123,6 +128,13 @@ UNIFY_ENVVARS_AND_CACHE(HDF5_LIBRARIES)
UNIFY_ENVVARS_AND_CACHE(BOOST_ROOT) UNIFY_ENVVARS_AND_CACHE(BOOST_ROOT)
UNIFY_ENVVARS_AND_CACHE(BOOST_LIBRARYDIR) UNIFY_ENVVARS_AND_CACHE(BOOST_LIBRARYDIR)
UNIFY_ENVVARS_AND_CACHE(CGAL_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(CGAL_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(GMP_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(GMP_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(MPFR_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(MPFR_LIBRARY_DIR)
if (GLTF_SUPPORT AND BUILD_CONVERT) if (GLTF_SUPPORT AND BUILD_CONVERT)
UNIFY_ENVVARS_AND_CACHE(JSON_INCLUDE_DIR) UNIFY_ENVVARS_AND_CACHE(JSON_INCLUDE_DIR)
FIND_FILE(json_hpp "json.hpp" ${JSON_INCLUDE_DIR}/nlohmann) FIND_FILE(json_hpp "json.hpp" ${JSON_INCLUDE_DIR}/nlohmann)
@@ -779,6 +791,8 @@ IF(BUILD_IFCMAX)
ADD_SUBDIRECTORY(../src/ifcmax ifcmax) ADD_SUBDIRECTORY(../src/ifcmax ifcmax)
ENDIF() ENDIF()
ADD_SUBDIRECTORY(../src/svgfill svgfill)
# CMake installation targets # CMake installation targets
INSTALL(FILES ${IFCPARSE_H_FILES} INSTALL(FILES ${IFCPARSE_H_FILES}
DESTINATION ${INCLUDEDIR}/ifcparse DESTINATION ${INCLUDEDIR}/ifcparse
+3 -3
View File
@@ -53,12 +53,12 @@ IF (WIN32 AND NOT PYTHON_DEBUG_LIBRARIES)
ENDIF() ENDIF()
SET_SOURCE_FILES_PROPERTIES(IfcPython.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(IfcPython.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_MODULE(ifcopenshell_wrapper python IfcPython.i) swig_add_library(ifcopenshell_wrapper LANGUAGE python SOURCES IfcPython.i)
if("$ENV{LDFLAGS}" MATCHES ".undefined.suppress") if("$ENV{LDFLAGS}" MATCHES ".undefined.suppress")
# On osx there is some state in the python dylib. With `-Wl,undefined,suppress` we can ignore the missing symbols at compile time. # On osx there is some state in the python dylib. With `-Wl,undefined,suppress` we can ignore the missing symbols at compile time.
SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES}) SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${IFCOPENSHELL_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} libsvgfill)
else() else()
SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${IFCOPENSHELL_LIBRARIES} ${PYTHON_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES}) SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${IFCOPENSHELL_LIBRARIES} ${PYTHON_LIBRARIES} ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} libsvgfill)
endif() endif()
if ((NOT WIN32) AND BUILD_SHARED_LIBS) if ((NOT WIN32) AND BUILD_SHARED_LIBS)
SET_INSTALL_RPATHS(${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} "${IFCDIRS};${OCC_LIBRARY_DIR}") SET_INSTALL_RPATHS(${SWIG_MODULE_ifcopenshell_wrapper_REAL_NAME} "${IFCDIRS};${OCC_LIBRARY_DIR}")
+39
View File
@@ -502,3 +502,42 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
return IfcGeom::tesselate(schema_name, shp, d); return IfcGeom::tesselate(schema_name, shp, d);
} }
%} %}
%ignore svgfill::svg_to_line_segments;
%ignore svgfill::line_segments_to_polygons;
%template(svg_line_segments) std::vector<std::array<svgfill::point_2, 2>>;
%template(svg_groups_of_line_segments) std::vector<std::vector<std::array<svgfill::point_2, 2>>>;
%template(svg_point) std::array<double, 2>;
%template(line_segment) std::array<svgfill::point_2, 2>;
%template(svg_polygons) std::vector<svgfill::polygon_2>;
%template(svg_groups_of_polygons) std::vector<std::vector<svgfill::polygon_2>>;
%template(svg_loop) std::vector<std::array<double, 2>>;
%template(svg_loops) std::vector<std::vector<std::array<double, 2>>>;
%naturalvar svgfill::polygon_2::boundary;
%naturalvar svgfill::polygon_2::inner_boundaries;
%naturalvar svgfill::polygon_2::point_inside;
%include "../svgfill/src/svgfill.h"
%inline %{
std::vector<std::vector<svgfill::line_segment_2>> svg_to_line_segments(const std::string& data, const boost::optional<std::string>& class_name) {
std::vector<std::vector<svgfill::line_segment_2>> r;
if (svgfill::svg_to_line_segments(data, class_name, r)) {
return r;
} else {
throw std::runtime_error("Failed to read SVG");
}
}
std::vector<std::vector<svgfill::polygon_2>> line_segments_to_polygons(svgfill::solver s, double eps, const std::vector<std::vector<svgfill::line_segment_2>>& segments) {
std::vector<std::vector<svgfill::polygon_2>> r;
if (svgfill::line_segments_to_polygons(s, eps, segments, r)) {
return r;
} else {
throw std::runtime_error("Failed to read SVG");
}
}
%}
+5
View File
@@ -48,6 +48,7 @@
%} %}
%include "std_array.i" %include "std_array.i"
%include "std_vector.i"
%include "std_string.i" %include "std_string.i"
%include "exception.i" %include "exception.i"
@@ -111,6 +112,8 @@
#include "../ifcparse/IfcSchema.h" #include "../ifcparse/IfcSchema.h"
#include "../ifcparse/utils.h" #include "../ifcparse/utils.h"
#include "../svgfill/src/svgfill.h"
#include <BRepTools_ShapeSet.hxx> #include <BRepTools_ShapeSet.hxx>
%} %}
@@ -155,6 +158,8 @@
#include "../ifcparse/IfcSchema.h" #include "../ifcparse/IfcSchema.h"
#include "../ifcparse/utils.h" #include "../ifcparse/utils.h"
#include "../svgfill/src/svgfill.h"
#include <BRepTools_ShapeSet.hxx> #include <BRepTools_ShapeSet.hxx>
%} %}
Submodule
+1
Submodule src/svgfill added at 77f2329351
+69 -5
View File
@@ -116,6 +116,11 @@ if "%CMAKE_VERSION%" LSS "cmake version 3.11.4" (
goto :ErrorAndPrintUsage goto :ErrorAndPrintUsage
) )
:: NOTE Boost < 1.64 doesn't work without tricks if the user has only VS 2017 installed and no earlier versions.
set BOOST_VERSION=1.74.0
:: Version string with underscores instead of dots.
set BOOST_VER=%BOOST_VERSION:.=_%
:: Print build configuration information :: Print build configuration information
call cecho.cmd 0 10 "Script configuration:" call cecho.cmd 0 10 "Script configuration:"
@@ -191,10 +196,6 @@ popd
:: Note all of the dependencies have appropriate label so that user can easily skip something if wanted :: Note all of the dependencies have appropriate label so that user can easily skip something if wanted
:: by modifying this file and using goto. :: by modifying this file and using goto.
:Boost :Boost
:: NOTE Boost < 1.64 doesn't work without tricks if the user has only VS 2017 installed and no earlier versions.
set BOOST_VERSION=1.74.0
:: Version string with underscores instead of dots.
set BOOST_VER=%BOOST_VERSION:.=_%
:: DEPENDENCY_NAME is used for logging and DEPENDENCY_DIR for saving from some redundant typing :: DEPENDENCY_NAME is used for logging and DEPENDENCY_DIR for saving from some redundant typing
set DEPENDENCY_NAME=Boost %BOOST_VERSION% set DEPENDENCY_NAME=Boost %BOOST_VERSION%
set DEPENDENCY_DIR=%DEPS_DIR%\boost_%BOOST_VER% set DEPENDENCY_DIR=%DEPS_DIR%\boost_%BOOST_VER%
@@ -428,6 +429,68 @@ IF EXIST "%DEPS_DIR%\swigwin-%SWIG_VERSION%". (
) )
IF EXIST "%DEPS_DIR%\swigwin\". robocopy "%DEPS_DIR%\swigwin" "%INSTALL_DIR%\swigwin" /E /IS /MOVE /njh /njs IF EXIST "%DEPS_DIR%\swigwin\". robocopy "%DEPS_DIR%\swigwin" "%INSTALL_DIR%\swigwin" /E /IS /MOVE /njh /njs
:mpir
set DEPENDENCY_NAME=mpir
set DEPENDENCY_DIR=%DEPS_DIR%\mpir
call :GitCloneAndCheckoutRevision https://github.com/BrianGladman/mpir.git "%DEPENDENCY_DIR%"
IF NOT %ERRORLEVEL%==0 GOTO :Error
cd "%DEPENDENCY_DIR%"
git reset --hard
REM There probably need to be quotes here around the filename
powershell -c "get-content %~dp0patches\mpir.patch | %%{$_ -replace \"sdk\",\"%UCRTVersion%\"} | %%{$_ -replace \"fn\",\"lib_mpir_cxx\"}" | git apply --unidiff-zero
IF NOT %ERRORLEVEL%==0 GOTO :Error
powershell -c "get-content %~dp0patches\mpir.patch | %%{$_ -replace \"sdk\",\"%UCRTVersion%\"} | %%{$_ -replace \"fn\",\"lib_mpir_gc\"}" | git apply --unidiff-zero
IF NOT %ERRORLEVEL%==0 GOTO :Error
if NOT "%USE_STATIC_RUNTIME%"=="FALSE" git apply "%~dp0patches\mpir_runtime.patch" --unidiff-zero
IF NOT %ERRORLEVEL%==0 GOTO :Error
cd msvc
cd vs%VS_VER:~2,2%
call .\msbuild.bat gc LIB %VS_PLATFORM% Release
IF NOT %ERRORLEVEL%==0 GOTO :Error
IF NOT EXIST "%INSTALL_DIR%\mpir". mkdir "%INSTALL_DIR%\mpir"
copy ..\..\lib\%VS_PLATFORM%\Release\* "%INSTALL_DIR%\mpir"
IF NOT %ERRORLEVEL%==0 GOTO :Error
:mpfr
set DEPENDENCY_NAME=mpfr
set DEPENDENCY_DIR=%DEPS_DIR%\mpfr
call :GitCloneAndCheckoutRevision https://github.com/BrianGladman/mpfr.git "%DEPENDENCY_DIR%" 2ebbe10fd029a480cf6e8a64c493afa9f3654251
IF NOT %ERRORLEVEL%==0 GOTO :Error
cd "%DEPENDENCY_DIR%"
git reset --hard
powershell -c "get-content %~dp0patches\mpfr.patch | %%{$_ -replace \"sdk\",\"%UCRTVersion%\"} | %%{$_ -replace \"fn\",\"lib_mpfr\"}" | git apply --unidiff-zero
IF NOT %ERRORLEVEL%==0 GOTO :Error
if NOT "%USE_STATIC_RUNTIME%"=="FALSE" git apply "%~dp0patches\mpfr_runtime.patch" --unidiff-zero
IF NOT %ERRORLEVEL%==0 GOTO :Error
call :BuildSolution "%DEPENDENCY_DIR%\build.vc15\lib_mpfr.sln" %DEBUG_OR_RELEASE% lib_mpfr
REM This command fails because not all msvc projects are patched with the right sdk version
IF NOT EXIST lib\%VS_PLATFORM%\Release\mpfr.lib GOTO :Error
IF NOT EXIST "%INSTALL_DIR%\mpfr". mkdir "%INSTALL_DIR%\mpfr"
copy lib\%VS_PLATFORM%\Release\* "%INSTALL_DIR%\mpfr"
IF NOT %ERRORLEVEL%==0 GOTO :Error
:cgal
set DEPENDENCY_NAME=cgal
set DEPENDENCY_DIR=%DEPS_DIR%\cgal
call :GitCloneAndCheckoutRevision https://github.com/CGAL/cgal.git "%DEPENDENCY_DIR%" v5.2.3
IF NOT %ERRORLEVEL%==0 GOTO :Error
cd "%DEPENDENCY_DIR%"
git reset --hard
git apply "%~dp0patches\cgal_no_zlib.patch"
call :RunCMake -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%\cgal" ^
-DBOOST_ROOT="%DEPS_DIR%\boost_%BOOST_VER%" ^
-DGMP_INCLUDE_DIR="%INSTALL_DIR%\mpir" ^
-DGMP_LIBRARIES="%INSTALL_DIR%\mpir\mpir.lib" ^
-DMPFR_INCLUDE_DIR="%INSTALL_DIR%\mpfr" ^
-DMPFR_LIBRARIES="%INSTALL_DIR%\mpfr\mpfr.lib" ^
-DBUILD_SHARED_LIBS=On ^
-DBOOST_LIBRARYDIR="%DEPS_DIR%\boost_%BOOST_VER%\stage\vs%VS_VER%-%VS_PLATFORM%\lib"
IF NOT %ERRORLEVEL%==0 GOTO :Error
call :BuildSolution "%DEPENDENCY_DIR%\%BUILD_DIR%\CGAL.sln" %BUILD_CFG%
IF NOT %ERRORLEVEL%==0 GOTO :Error
call :InstallCMakeProject "%DEPENDENCY_DIR%\%BUILD_DIR%" %BUILD_CFG%
IF NOT %ERRORLEVEL%==0 GOTO :Error
:Successful :Successful
echo. echo.
call "%~dp0\utils\cecho.cmd" 0 10 "%PROJECT_NAME% dependencies built." call "%~dp0\utils\cecho.cmd" 0 10 "%PROJECT_NAME% dependencies built."
@@ -504,6 +567,7 @@ if not exist "%~2". (
set RET=%ERRORLEVEL% set RET=%ERRORLEVEL%
) else ( ) else (
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned. Pulling latest changes." call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned. Pulling latest changes."
git reset --hard
pushd %2 pushd %2
call git pull call git pull
set RET=0 set RET=0
@@ -520,7 +584,7 @@ if not exist "%~2". (
pushd "%DEPS_DIR%" pushd "%DEPS_DIR%"
call git clone %1 %2 call git clone %1 %2
set RET=%ERRORLEVEL% set RET=%ERRORLEVEL%
if not %RET%==0 exit /b %RET% if not "%RET%"=="0" exit /b %RET%
popd popd
) else ( ) else (
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned." call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned."
+13
View File
@@ -0,0 +1,13 @@
diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_ImageIODependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_ImageIODependencies.cmake
index 8ac856d037..742fa8df69 100644
--- a/Installation/cmake/modules/CGAL_SetupCGAL_ImageIODependencies.cmake
+++ b/Installation/cmake/modules/CGAL_SetupCGAL_ImageIODependencies.cmake
@@ -23,7 +23,7 @@ set(CGAL_SetupCGAL_ImageIODependencies_included TRUE)
# Used Modules
# ^^^^^^^^^^^^
# - :module:`FindZLIB`
-find_package( ZLIB )
+# find_package( ZLIB )
define_property(TARGET PROPERTY CGAL_TARGET_USES_ZLIB
BRIEF_DOCS "Tells if the target uses ZLIB as a dependency"
+5
View File
@@ -0,0 +1,5 @@
--- a/build.vc15/fn/fn.vcxproj
+++ a/build.vc15/fn/fn.vcxproj
@@ -25 +25 @@
- <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>sdk</WindowsTargetPlatformVersion>
+10
View File
@@ -0,0 +1,10 @@
diff --git a/build.vc15/lib_mpfr/lib_mpfr.vcxproj b/build.vc15/lib_mpfr/lib_mpfr.vcxproj
index a3c72e48..85da0bcc 100644
--- a/build.vc15/lib_mpfr/lib_mpfr.vcxproj
+++ b/build.vc15/lib_mpfr/lib_mpfr.vcxproj
@@ -148 +148 @@
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -179 +179 @@
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+7
View File
@@ -0,0 +1,7 @@
diff --git a/msvc/vs17/fn/fn.vcxproj b/msvc/vs17/fn/fn.vcxproj
index d8d87f8f..e543adc8 100644
--- a/msvc/vs17/fn/fn.vcxproj
+++ b/msvc/vs17/fn/fn.vcxproj
@@ -25 +25 @@
- <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
+ <WindowsTargetPlatformVersion>sdk</WindowsTargetPlatformVersion>
+13
View File
@@ -0,0 +1,13 @@
diff --git a/msvc/mpir_release_lib.props b/msvc/mpir_release_lib.props
index d46f9649..832c6937 100644
--- a/msvc/mpir_release_lib.props
+++ b/msvc/mpir_release_lib.props
@@ -9,7 +9,7 @@
<ItemDefinitionGroup>
<ClCompile>
<ObjectFileName>$(IntDir)du\m\my\%(RelativeDir)</ObjectFileName>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<ProgramDataBaseFileName>$(TargetDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
+14
View File
@@ -102,6 +102,13 @@ set SWIG_DIR=%INSTALL_DIR%\swigwin
set PATH=%PATH%;%SWIG_DIR%;%PYTHONHOME% set PATH=%PATH%;%SWIG_DIR%;%PYTHONHOME%
set JSON_INCLUDE_DIR=%INSTALL_DIR%\json set JSON_INCLUDE_DIR=%INSTALL_DIR%\json
set CGAL_INCLUDE_DIR=%INSTALL_DIR%\cgal\include
set CGAL_LIBRARY_DIR=%INSTALL_DIR%\cgal\lib
set GMP_INCLUDE_DIR=%INSTALL_DIR%\mpir
set GMP_LIBRARY_DIR=%INSTALL_DIR%\mpir
set MPFR_INCLUDE_DIR=%INSTALL_DIR%\mpfr
set MPFR_LIBRARY_DIR=%INSTALL_DIR%\mpfr
echo. echo.
call cecho.cmd 0 10 "Script configuration:" call cecho.cmd 0 10 "Script configuration:"
echo Generator = %GENERATOR% echo Generator = %GENERATOR%
@@ -127,6 +134,13 @@ echo PYTHON_EXECUTABLE = %PYTHON_EXECUTABLE%
echo SWIG_DIR = %SWIG_DIR% echo SWIG_DIR = %SWIG_DIR%
echo JSON_INCLUDE_DIR = %JSON_INCLUDE_DIR% echo JSON_INCLUDE_DIR = %JSON_INCLUDE_DIR%
echo. echo.
echo CGAL_INCLUDE_DIR = %CGAL_INCLUDE_DIR%
echo CGAL_LIBRARY_DIR = %CGAL_LIBRARY_DIR%
echo GMP_INCLUDE_DIR = %GMP_INCLUDE_DIR%
echo GMP_LIBRARY_DIR = %GMP_LIBRARY_DIR%
echo MPFR_INCLUDE_DIR = %MPFR_INCLUDE_DIR%
echo MPFR_LIBRARY_DIR = %MPFR_LIBRARY_DIR%
echo.
echo CMAKE_INSTALL_PREFIX = %CMAKE_INSTALL_PREFIX% echo CMAKE_INSTALL_PREFIX = %CMAKE_INSTALL_PREFIX%
echo. echo.