Skip to content

Commit 9775dfc

Browse files
EstebanDugueperoux2aothms
authored andcommitted
Add svgfill directly in IfcOpenShell git repo
1 parent 658713f commit 9775dfc

13 files changed

Lines changed: 3597 additions & 0 deletions

File tree

File renamed without changes.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@
1717
[submodule "src/pyodide/demo-app/wheels"]
1818
path = src/pyodide/demo-app/wheels
1919
url = https://github.com/IfcOpenShell/wasm-wheels
20+
[submodule "src/svgfill/3rdparty/svgpp"]
21+
path = src/svgfill/3rdparty/svgpp
22+
url = https://github.com/svgpp/svgpp

src/svgfill/3rdparty/svgpp

Submodule svgpp added at 5f1870a

src/svgfill/CMakeLists.txt

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
cmake_minimum_required (VERSION 3.10)
2+
3+
set(CMAKE_CXX_STANDARD 17)
4+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5+
6+
project (svgfill)
7+
8+
cmake_policy(SET CMP0074 NEW) # find_package() uses <PackageName>_ROOT variables.
9+
if (POLICY CMP0144)
10+
cmake_policy(SET CMP0144 NEW) # find_package() uses upper-case <PACKAGENAME>_ROOT variables.
11+
endif()
12+
if(POLICY CMP0167) # 3.30 find_package(Boost) to use BoostConfig instead of FindBoost.
13+
cmake_policy(SET CMP0167 OLD)
14+
endif()
15+
16+
include(GNUInstallDirs)
17+
18+
# Specify paths to install files
19+
if(NOT BINDIR)
20+
set(BINDIR bin)
21+
endif()
22+
if(NOT IS_ABSOLUTE ${BINDIR})
23+
set(BINDIR ${CMAKE_INSTALL_BINDIR})
24+
endif()
25+
message(STATUS "BINDIR: ${BINDIR}")
26+
27+
if(NOT INCLUDEDIR)
28+
set(INCLUDEDIR include)
29+
endif()
30+
if(NOT IS_ABSOLUTE ${INCLUDEDIR})
31+
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
32+
endif()
33+
message(STATUS "INCLUDEDIR: ${INCLUDEDIR}")
34+
35+
if(NOT LIBDIR)
36+
set(LIBDIR lib)
37+
endif()
38+
if(NOT IS_ABSOLUTE ${LIBDIR})
39+
set(LIBDIR ${CMAKE_INSTALL_LIBDIR})
40+
endif()
41+
message(STATUS "LIBDIR: ${LIBDIR}")
42+
43+
set(CGAL_LIBRARY_NAMES libCGAL_Core libCGAL_ImageIO libCGAL)
44+
45+
if(NOT CGAL_INCLUDE_DIR)
46+
find_package(CGAL REQUIRED)
47+
if(NOT CGAL_DIR)
48+
message(
49+
FATAL_ERROR
50+
"CGAL_SUPPORT enabled, but CGAL_INCLUDE_DIR wasn't provided and CGAL package couldn't be found."
51+
)
52+
endif()
53+
message(STATUS "CGAL: found config at '${CGAL_DIR}'.")
54+
set(CGAL_LIBRARIES CGAL::CGAL)
55+
else()
56+
set(CGAL_INCLUDE_DIR ${CGAL_INCLUDE_DIR} CACHE FILEPATH "CGAL header files")
57+
message(STATUS "Looking for CGAL include files in: ${CGAL_INCLUDE_DIR}")
58+
59+
if(NOT "${CGAL_LIBRARY_DIR}" STREQUAL "")
60+
set(CGAL_LIBRARY_DIR ${CGAL_LIBRARY_DIR} CACHE FILEPATH "CGAL library files")
61+
message(STATUS "Looking for CGAL library files in: ${CGAL_LIBRARY_DIR}")
62+
endif()
63+
64+
if(WASM_BUILD)
65+
set(CMAKE_FIND_ROOT_PATH_BACKUP "${CMAKE_FIND_ROOT_PATH}")
66+
set(CMAKE_FIND_ROOT_PATH "")
67+
endif()
68+
69+
find_library(libCGAL NAMES CGAL PATHS ${CGAL_LIBRARY_DIR} NO_DEFAULT_PATH)
70+
71+
if(libCGAL)
72+
message(STATUS "CGAL library files found")
73+
foreach(lib ${CGAL_LIBRARY_NAMES})
74+
string(REPLACE libCGAL "${lib}" lib_path "${libCGAL}")
75+
list(APPEND CGAL_LIBRARIES "${lib_path}")
76+
endforeach()
77+
else()
78+
if(NOT "${CGAL_LIBRARY_DIR}" STREQUAL "")
79+
file(GLOB CGAL_LIBRARIES ${CGAL_LIBRARY_DIR}/CGAL*.lib)
80+
list(LENGTH CGAL_LIBRARY_NAMES num_cgal_library_names)
81+
list(LENGTH CGAL_LIBRARIES num_cgal_libraries)
82+
link_directories("${CGAL_LIBRARY_DIR}")
83+
if(NOT "${num_cgal_library_names}" STREQUAL "${num_cgal_libraries}")
84+
message(FATAL_ERROR "Unable to find CGAL library files, aborting")
85+
endif()
86+
message(STATUS "CGAL library files found")
87+
endif()
88+
endif()
89+
find_library(libGMP NAMES gmp mpir PATHS ${GMP_LIBRARY_DIR} NO_DEFAULT_PATH)
90+
find_library(libMPFR NAMES mpfr PATHS ${MPFR_LIBRARY_DIR} NO_DEFAULT_PATH)
91+
if(NOT libGMP)
92+
message(FATAL_ERROR "Unable to find GMP library files, aborting")
93+
endif()
94+
if(NOT libMPFR)
95+
message(FATAL_ERROR "Unable to find MPFR library files, aborting")
96+
endif()
97+
98+
list(APPEND CGAL_LIBRARIES "${libMPFR}")
99+
list(APPEND CGAL_LIBRARIES "${libGMP}")
100+
endif(NOT CGAL_INCLUDE_DIR)
101+
102+
if(WIN32 AND ("$ENV{CONDA_BUILD}" STREQUAL ""))
103+
set(Boost_USE_STATIC_LIBS ON)
104+
set(Boost_USE_MULTITHREADED ON)
105+
if (USE_STATIC_MSVC_RUNTIME)
106+
set(Boost_USE_STATIC_RUNTIME ON)
107+
endif()
108+
else()
109+
# Disable Boost's autolinking as the libraries to be linked to are supplied
110+
# already by CMake, and it's going to conflict if there are multiple, as is
111+
# the case in conda-forge's libboost feedstock.
112+
add_definitions(-DBOOST_ALL_NO_LIB)
113+
if(WIN32)
114+
# Necessary for boost version >= 1.67
115+
set(BCRYPT_LIBRARIES "bcrypt.lib")
116+
endif()
117+
endif()
118+
119+
if (MSVC)
120+
add_definitions(-bigobj)
121+
endif()
122+
123+
find_package(Boost)
124+
message(STATUS "Boost include files found in ${Boost_INCLUDE_DIRS}")
125+
find_package(LibXml2 REQUIRED)
126+
127+
if(WASM_BUILD)
128+
set(CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH_BACKUP}")
129+
endif()
130+
131+
132+
133+
include_directories(${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR}
134+
${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/svgpp/include
135+
)
136+
137+
file(GLOB LIB_H_FILES src/*.h)
138+
file(GLOB LIB_CPP_FILES src/svgfill.cpp src/arrange_polygons.cpp)
139+
set(LIB_SRC_FILES ${LIB_H_FILES} ${LIB_CPP_FILES})
140+
add_library(svgfill ${LIB_SRC_FILES})
141+
if(LibXml2_DIR)
142+
find_package(LibXml2 CONFIG REQUIRED)
143+
target_compile_definitions(svgfill PRIVATE ${LIBXML2_DEFINITIONS})
144+
endif()
145+
target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${LIBXML2_LIBRARIES} ${CGAL_LIBRARIES})
146+
147+
add_executable(svgfill_exe src/main.cpp)
148+
target_link_libraries(svgfill_exe svgfill)
149+
set_property(TARGET svgfill_exe PROPERTY OUTPUT_NAME svgfill)
150+
if(WIN32)
151+
# both the library and the executable now result in a file with basename svgfill,
152+
# on linux the the library is prefixed with lib as libsvgfill.a. Windows does not
153+
# have this mechanism, so on windows the linker would be created an import library
154+
# for the executable, also named svgfill.lib. This naming conflict results in:
155+
# LINK : fatal error LNK1149: output filename matches input filename
156+
# This flag tells the linker not to generate an import library and therefore no
157+
# conflict occurs.
158+
target_link_options(svgfill_exe PRIVATE "/NOIMPLIB")
159+
endif()
160+
161+
install(TARGETS svgfill_exe DESTINATION ${BINDIR})
162+
install(TARGETS svgfill DESTINATION ${LIBDIR})
163+
install(FILES ${LIB_H_FILES} DESTINATION ${INCLUDEDIR})

src/svgfill/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
svgfill
2+
=======
3+
4+
An application to fill areas bounded by unconnected lines in SVG.
5+
6+
Dependencies
7+
------------
8+
9+
* [CGAL 2D Arrangements](https://doc.cgal.org/latest/Arrangement_on_surface_2/index.html) GPL
10+
* [SVG++](http://svgpp.org/) Boost software license
11+
12+
Compilation
13+
-----------
14+
15+
Installation is shown based on the IfcOpenShell build script directory output:
16+
17+
git clone --recursive https://github.com/IfcOpenShell/svgfill
18+
cd svgfill
19+
mkdir build
20+
cd build
21+
22+
# windows
23+
24+
set IFCOPENSHELL_ROOT=..\path\to\ifcopenshell\directory\
25+
cmake -DBOOST_ROOT=%IFCOPENSHELL_ROOT%\deps\boost_1_67_0 ^
26+
-DBOOST_LIBRARYDIR=%IFCOPENSHELL_ROOT%\deps\boost_1_67_0\stage\vs2017-Win32\lib ^
27+
-DLIBXML2_INCLUDE_DIR=%IFCOPENSHELL_ROOT%\deps\OpenCOLLADA\Externals\LibXML\include ^
28+
-DLIBXML2_LIBRARIES=%IFCOPENSHELL_ROOT%\deps-vs2017-x86-installed\OpenCOLLADA\lib\opencollada\xml.lib ^
29+
-DCGAL_INCLUDE_DIR=%IFCOPENSHELL_ROOT%\deps-vs2017-x86-installed\cgal\include ^
30+
-DCGAL_LIBRARY_DIR=%IFCOPENSHELL_ROOT%\deps-vs2017-x86-installed\cgal\lib ^
31+
-DGMP_INCLUDE_DIR=%IFCOPENSHELL_ROOT%\deps-vs2017-x86-installed\mpir ^
32+
-DGMP_LIBRARY_DIR=%IFCOPENSHELL_ROOT%\deps-vs2017-x86-installed\mpir ^
33+
-DMPFR_INCLUDE_DIR=%IFCOPENSHELL_ROOT%\deps-vs2017-x86-installed\mpfr ^
34+
-DMPFR_LIBRARY_DIR=%IFCOPENSHELL_ROOT%\deps-vs2017-x86-installed\mpfr ^
35+
..
36+
37+
# nix
38+
39+
IFCOPENSHELL_INSTALL=~/IfcOpenShell/build/$(uname -s)/$(uname -m)/install
40+
cmake -DBOOST_ROOT=${IFCOPENSHELL_INSTALL}/boost-1.69.0 \
41+
-DLIBXML2_INCLUDE_DIR=${IFCOPENSHELL_INSTALL}/libxml2-2.9.9/include/libxml2 \
42+
-DLIBXML2_LIBRARIES=${IFCOPENSHELL_INSTALL}/libxml2-2.9.9/lib/libxml2.a \
43+
-DCGAL_INCLUDE_DIR=${IFCOPENSHELL_INSTALL}/cgal-5.2/include \
44+
-DCGAL_LIBRARY_DIR=${IFCOPENSHELL_INSTALL}/cgal-5.2/lib \
45+
-DGMP_INCLUDE_DIR=${IFCOPENSHELL_INSTALL}/gmp-6.1.2/include \
46+
-DGMP_LIBRARY_DIR=${IFCOPENSHELL_INSTALL}/gmp-6.1.2/lib \
47+
-DMPFR_INCLUDE_DIR=${IFCOPENSHELL_INSTALL}/mpfr-3.1.5/include \
48+
-DMPFR_LIBRARY_DIR=${IFCOPENSHELL_INSTALL}/mpfr-3.1.5/lib \
49+
..
50+
51+
License
52+
-------
53+
54+
LGPL
55+
56+
Example
57+
-------
58+
59+
in:
60+
61+
![](examples/rects.svg)
62+
63+
out:
64+
65+
![](examples/rects_output.svg)

src/svgfill/examples/rects.svg

Lines changed: 80 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)