MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / boostRingFromVertices

Function boostRingFromVertices

src/utilities/geometry/Intersection.cpp:387–418  ·  view source on GitHub ↗

convert vertices to a boost ring, all vertices must lie on z = 0 plane

Source from the content-addressed store, hash-verified

385
386// convert vertices to a boost ring, all vertices must lie on z = 0 plane
387boost::optional<BoostRing> boostRingFromVertices(const std::vector<Point3d>& vertices, std::vector<Point3d>& allPoints, double tol) {
388 if (vertices.size() < 3) {
389 return boost::none;
390 }
391
392 BoostRing ring;
393 for (const Point3d& vertex : vertices) {
394
395 // should all have zero z coordinate now
396 const double z = vertex.z();
397 if (std::abs(z) > tol) {
398 LOG_FREE(Error, "utilities.geometry.boostRingFromVertices", "All points must be on z = 0 plane");
399 return boost::none;
400 }
401
402 // use helper method which combines close points
403 boost::geometry::append(ring, boostPointFromPoint3d(vertex, allPoints, tol));
404 }
405
406 // close polygon, use helper method which combines close points
407 boost::geometry::append(ring, boostPointFromPoint3d(vertices[0], allPoints, tol));
408
409 //boost::geometry::correct(ring);
410
411 boost::optional<double> testArea = boost::geometry::area(ring);
412 if (!testArea || (*testArea < 0)) {
413 // DLM: we could offer to reverse these vertices here but that might not be the best idea
414 return boost::none;
415 }
416
417 return ring;
418}
419
420boost::optional<BoostRing> nonIntersectingBoostRingFromVertices(const std::vector<Point3d>& polygon, std::vector<Point3d>& allPoints, double tol) {
421 boost::optional<BoostRing> result = boostRingFromVertices(polygon, allPoints, tol);

Callers 1

Calls 5

absFunction · 0.85
boostPointFromPoint3dFunction · 0.85
areaFunction · 0.85
sizeMethod · 0.45
zMethod · 0.45

Tested by

no test coverage detected