MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / svg_to_polygons

Method svg_to_polygons

src/svgfill/src/svgfill.cpp:190–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190bool svgfill::svg_to_polygons(const std::string& data, const boost::optional<std::string>& class_name, std::vector<polygon_2>& polygons) {
191 Context context;
192 context.class_name = class_name;
193 xmlDoc* doc = xmlReadMemory(data.c_str(), data.size(), nullptr, nullptr, 0);
194 xmlNode* elem = xmlDocGetRootElement(doc);
195
196 try {
197 document_traversal<
198 processed_elements<processed_elements_t>,
199 processed_attributes<processed_attributes_t>
200 >::load_document(elem, context);
201 } catch (std::exception& e) {
202 std::cerr << e.what() << std::endl;
203 return false;
204 }
205 std::function<void(float)> fn = [](float f) {};
206 std::vector<std::vector<polygon_2>> ps;
207 if (!line_segments_to_polygons(svgfill::EXACT_PREDICATES, 0., context.segments, ps, fn)) {
208 return false;
209 }
210 if (ps.empty()) {
211 return false;
212 }
213 for (auto& p : ps) {
214 polygons.insert(polygons.end(), p.begin(), p.end());
215 }
216 return true;
217}
218
219template <typename Kernel>
220class cgal_arrangement : public svgfill::abstract_arrangement {

Callers

nothing calls this directly

Calls 6

whatMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected