#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 -3
View File
@@ -53,12 +53,12 @@ IF (WIN32 AND NOT PYTHON_DEBUG_LIBRARIES)
ENDIF()
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")
# 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()
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()
if ((NOT WIN32) AND BUILD_SHARED_LIBS)
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);
}
%}
%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_vector.i"
%include "std_string.i"
%include "exception.i"
@@ -111,6 +112,8 @@
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/utils.h"
#include "../svgfill/src/svgfill.h"
#include <BRepTools_ShapeSet.hxx>
%}
@@ -155,6 +158,8 @@
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/utils.h"
#include "../svgfill/src/svgfill.h"
#include <BRepTools_ShapeSet.hxx>
%}
Submodule
+1
Submodule src/svgfill added at 77f2329351