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

Function pointInPolygon

src/utilities/geometry/Intersection.cpp:644–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642}
643
644bool pointInPolygon(const Point3d& point, const std::vector<Point3d>& polygon, double tol) {
645 // convert vertices to boost rings
646 std::vector<Point3d> allPoints;
647
648 boost::optional<BoostRing> boostPolygon = nonIntersectingBoostRingFromVertices(polygon, allPoints, tol);
649 if (!boostPolygon) {
650 return false;
651 }
652
653 if (std::abs(point.z()) > tol) {
654 return false;
655 }
656
657 boost::tuple<double, double> p = boostPointFromPoint3d(point, allPoints, tol);
658 const BoostPoint boostPoint(p.get<0>(), p.get<1>());
659
660 //boost::geometry::strategy::within::winding<BoostPoint> strategy;
661 //boost::geometry::strategy::within::franklin<BoostPoint> strategy;
662 //boost::geometry::strategy::within::crossings_multiply<BoostPoint> strategy;
663 //bool result = boost::geometry::within(boostPoint, *boostPolygon, strategy);
664
665 //bool result = boost::geometry::intersects(boostPoint, *boostPolygon);
666
667 //bool result = boost::geometry::overlaps(boostPoint, *boostPolygon);
668
669 const double distance = boost::geometry::distance(boostPoint, *boostPolygon);
670 const bool result = (distance <= 0.0001);
671
672 return result;
673}
674
675boost::optional<std::vector<Point3d>> join(const std::vector<Point3d>& polygon1, const std::vector<Point3d>& polygon2, double tol) {
676 // convert vertices to boost rings

Callers 4

pointInPolygonMethod · 0.85
insideMethod · 0.85
TEST_FFunction · 0.85

Calls 4

absFunction · 0.85
boostPointFromPoint3dFunction · 0.85
zMethod · 0.45

Tested by 1

TEST_FFunction · 0.68