20 #include <boost/polygon/voronoi.hpp> 27 typedef point_concept
type;
34 static inline coordinate_type
get(
const dcel2d::Point& point, orientation_2d orient)
36 return (orient == HORIZONTAL) ? std::get<1>(point) : std::get<0>(point);
50 : fHalfEdgeList(halfEdgeList)
51 , fVertexList(vertexList)
57 , fVoronoiDiagramArea(0.)
94 double deltaX = std::get<0>(p1) - std::get<0>(p0);
95 double deltaY = std::get<1>(p1) - std::get<1>(p0);
96 double dCheckX = std::get<0>(p2) - std::get<0>(p0);
97 double dCheckY = std::get<1>(p2) - std::get<1>(p0);
99 return ((deltaX * dCheckY) - (deltaY * dCheckX));
118 if (point != lastPoint) area += 0.5 *
crossProduct(center, lastPoint, point);
130 return *left < *
right;
147 std::cout <<
"*********************************************************************************" 148 "*********************************" 150 std::cout <<
"*********************************************************************************" 151 "*********************************" 153 std::cout <<
"*********************************************************************************" 154 "*********************************" 156 std::cout <<
"==> # input points: " << pointList.size() << std::endl;
162 for (
const auto& point : pointList) {
165 eventQueue.push(iEvent);
175 while (!eventQueue.empty()) {
176 IEvent*
event = eventQueue.top();
183 else if (
event->isValid())
187 std::cout <<
"*******> # input points: " << pointList.size()
188 <<
", remaining leaves: " << beachLine.
countLeaves() <<
", " 196 std::cout <<
" Range min/maxes, x: " <<
fXMin <<
", " <<
fXMax <<
", y: " <<
fYMin 197 <<
", " <<
fYMax << std::endl;
205 std::map<int, int> edgeCountMap;
206 std::map<int, int> openCountMap;
215 if (halfEdge->getFace() != &face) {
216 std::cout <<
" ===> halfEdge does not match face: " << halfEdge
217 <<
", face: " << halfEdge->
getFace() <<
", base: " << &face << std::endl;
220 if (halfEdge == startEdge) {
225 halfEdge = halfEdge->getNextHalfEdge();
231 halfEdge && !closed;) {
232 if (halfEdge->getFace() != &face) {
233 std::cout <<
" ===> halfEdge does not match face: " << halfEdge
234 <<
", face: " << halfEdge->getFace() <<
", base: " << &face << std::endl;
237 if (halfEdge == startEdge) {
242 halfEdge = halfEdge->getLastHalfEdge();
248 openCountMap[nEdges]++;
251 edgeCountMap[nEdges]++;
254 std::cout <<
"==> Found " << nOpenFaces <<
" open faces from total of " << fFaceList.size()
256 for (
const auto& edgeCount : edgeCountMap)
257 std::cout <<
" -> all edges, # edges: " << edgeCount.first
258 <<
", count: " << edgeCount.second << std::endl;
259 for (
const auto& edgeCount : openCountMap)
260 std::cout <<
" -> open edges, # edges: " << edgeCount.first
261 <<
", count: " << edgeCount.second << std::endl;
262 std::cout <<
"*********************************************************************************" 263 "*********************************" 265 std::cout <<
"*********************************************************************************" 266 "*********************************" 268 std::cout <<
"*********************************************************************************" 269 "*********************************" 294 std::cout <<
"*********************************************************************************" 295 "*********************************" 297 std::cout <<
"*********************************************************************************" 298 "*********************************" 300 std::cout <<
"*********************************************************************************" 301 "*********************************" 303 std::cout <<
"==> # input points: " << pointList.size() << std::endl;
306 boost::polygon::voronoi_diagram<double> vd;
307 boost::polygon::construct_voronoi(pointList.begin(), pointList.end(), &vd);
313 std::map<const boost::polygon::voronoi_vertex<double>*,
dcel2d::Vertex*>;
316 BoostEdgeToEdgeMap boostEdgeToEdgeMap;
321 for (
const auto& edge : vd.edges()) {
322 const boost::polygon::voronoi_edge<double>* twin = edge.twin();
325 pointList, &edge, twin, boostEdgeToEdgeMap, boostVertexToVertexMap, boostCellToFaceMap);
327 pointList, twin, &edge, boostEdgeToEdgeMap, boostVertexToVertexMap, boostCellToFaceMap);
334 <<
" faces, " <<
fVertexList.size() <<
" vertices " << std::endl;
335 std::cout <<
" " << vd.edges().size() <<
" edges, " << vd.cells().size()
336 <<
" faces, " << vd.vertices().size() <<
" vertices" << std::endl;
337 std::cout <<
"*********************************************************************************" 338 "*********************************" 340 std::cout <<
"*********************************************************************************" 341 "*********************************" 343 std::cout <<
"*********************************************************************************" 344 "*********************************" 356 const boost::polygon::voronoi_edge<double>* edge,
357 const boost::polygon::voronoi_edge<double>* twin,
365 if (boostEdgeToEdgeMap.find(edge) != boostEdgeToEdgeMap.end())
366 halfEdge = boostEdgeToEdgeMap.at(edge);
372 boostEdgeToEdgeMap[edge] = halfEdge;
375 if (boostEdgeToEdgeMap.find(twin) != boostEdgeToEdgeMap.end())
376 twinEdge = boostEdgeToEdgeMap.at(twin);
382 boostEdgeToEdgeMap[twin] = twinEdge;
386 const boost::polygon::voronoi_vertex<double>* boostVertex = edge->vertex1();
391 if (boostVertexToVertexMap.find(boostVertex) == boostVertexToVertexMap.end()) {
398 boostVertexToVertexMap[boostVertex] = vertex;
401 vertex = boostVertexToVertexMap.at(boostVertex);
404 const boost::polygon::voronoi_cell<double>* boostCell = edge->cell();
407 if (boostCellToFaceMap.find(boostCell) == boostCellToFaceMap.end()) {
409 int pointIdx = boostCell->source_index();
411 std::advance(pointItr, pointIdx);
414 dcel2d::Coords coords(std::get<0>(point), std::get<1>(point), 0.);
416 fFaceList.emplace_back(halfEdge, coords, std::get<2>(point));
420 boostCellToFaceMap[boostCell] = face;
428 if (boostEdgeToEdgeMap.find(edge->next()) != boostEdgeToEdgeMap.end()) {
435 if (boostEdgeToEdgeMap.find(edge->prev()) != boostEdgeToEdgeMap.end()) {
515 std::cout <<
">>>> Face mismatch in circle handling, left face: " << leftHalfEdge->
getFace()
517 <<
", right: " << rightHalfEdge->
getFace()
519 <<
", arc face: " << arcNode->
getFace() << std::endl;
624 eventQueue.push(circleEvent);
664 eventQueue.push(circleEvent);
694 double circleBottomX = center[0] -
radius;
697 if (beachLinePos >= circleBottomX - 10. * deltaR) {
705 else if (circleBottomX - beachLinePos < 1.
e-4)
706 std::cout <<
"==> Circle close, beachLine: " << beachLinePos
707 <<
", circleBottomX: " << circleBottomX <<
", deltaR: " << deltaR
708 <<
", d: " << circleBottomX - beachLinePos << std::endl;
725 double xCoord = p1[0];
726 double yCoord = p1[1];
728 double x2 = p2[0] - xCoord;
729 double y2 = p2[1] - yCoord;
730 double x3 = p3[0] - xCoord;
731 double y3 = p3[1] - yCoord;
733 double det = x2 * y3 - x3 *
y2;
741 if (det > -std::numeric_limits<double>::epsilon())
742 std::cout <<
" --->Circle failure, det: " << det <<
", mid x: " << p2[0]
743 <<
", y: " << p2[1] <<
", l x: " << p1[0] <<
", y: " << p1[1]
744 <<
", r x: " << p3[0] <<
", y: " << p3[1] << std::endl;
749 double p2sqr = x2 * x2 + y2 *
y2;
750 double p3sqr = x3 * x3 + y3 *
y3;
752 double cxpr = 0.5 * (y3 * p2sqr - y2 * p3sqr) / det;
753 double cypr = 0.5 * (x2 * p3sqr - x3 * p2sqr) / det;
755 radius = std::sqrt(cxpr * cxpr + cypr * cypr);
756 center[0] = cxpr + xCoord;
757 center[1] = cypr + yCoord;
767 std::vector<float> radSqrVec;
769 radSqrVec.push_back(p1Rad.norm());
770 radSqrVec.push_back(p2Rad.norm());
771 radSqrVec.push_back(p3Rad.norm());
773 double maxRadius = *std::max_element(radSqrVec.begin(), radSqrVec.end());
775 delta = std::max(5.
e-7, maxRadius - radius);
777 if (radius > 1000.) {
792 double slope12 = (p2[1] - p1[1]) / (p2[0] - p1[0]);
793 double slope32 = (p3[1] - p2[1]) / (p3[0] - p2[0]);
795 if (
std::abs(slope12 - slope32) <= std::numeric_limits<double>::epsilon()) {
796 std::cout <<
" >>>> Matching slopes! points: (" << p1[0] <<
"," << p1[1] <<
"), (" 797 << p2[0] <<
"," << p2[1] <<
"), (" << p3[0] <<
"," << p3[1] <<
")" << std::endl;
802 center[0] = (slope12 * slope32 * (p3[1] - p1[1]) + slope12 * (p2[0] + p3[0]) -
803 slope32 * (p1[0] + p2[0])) /
804 (2. * (slope12 - slope32));
805 center[1] = 0.5 * (p1[1] + p2[1]) - (center[0] - 0.5 * (p1[0] + p2[0])) / slope12;
807 radius = std::sqrt(std::pow((p2[0] - center[0]), 2) + std::pow((p2[1] - center[1]), 2));
810 std::cout <<
" ***> Rad2 = " << radius <<
", circ x,y: " << center[0] <<
"," 811 << center[1] <<
", p1: " << p1[0] <<
"," << p1[1] <<
", p2: " << p2[0] <<
"," 812 << p2[1] <<
", p3: " << p3[0] <<
", " << p3[1] << std::endl;
825 double temp = p2[0] * p2[0] + p2[1] * p2[1];
826 double p1p2 = (p1[0] * p1[0] + p1[1] * p1[1] - temp) / 2.0;
827 double p2p3 = (temp - p3[0] * p3[0] - p3[1] * p3[1]) / 2.0;
828 double det = (p1[0] - p2[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p2[1]);
830 if (
std::abs(det) < 10. * std::numeric_limits<double>::epsilon()) {
831 std::cout <<
" >>>> Determinant zero! points: (" << p1[0] <<
"," << p1[1] <<
"), (" 832 << p2[0] <<
"," << p2[1] <<
"), (" << p3[0] <<
"," << p3[1] <<
")" << std::endl;
839 center[0] = (p1p2 * (p2[1] - p3[1]) - p2p3 * (p1[1] - p2[1])) * det;
840 center[1] = (p2p3 * (p1[0] - p2[0]) - p1p2 * (p2[0] - p3[0])) * det;
843 radius = std::sqrt(std::pow((p1[0] - center[0]), 2) + std::pow((p1[1] - center[1]), 2));
846 std::cout <<
" ***> Rad3 = " << radius <<
", circ x,y: " << center[0] <<
"," 847 << center[1] <<
", p1: " << p1[0] <<
"," << p1[1] <<
", p2: " << p2[0] <<
"," 848 << p2[1] <<
", p3: " << p3[0] <<
", " << p3[1] << std::endl;
872 double lastBreakPoint = std::numeric_limits<double>::lowest();
877 std::cout <<
"-----------------------------------------------------------------------------" 883 std::cout <<
"node " << nodeCount <<
" has leaf: " << node
884 <<
", face: " << node->
getFace()
904 std::cout <<
"node " << nodeCount <<
" has break: " << breakPoint
905 <<
", beachPos: " << beachLinePos <<
" (last: " << lastBreakPoint
906 <<
"), leftArcVal: " << leftArcVal <<
", rightArcVal: " << rightArcVal
908 if (lastBreakPoint > breakPoint)
909 std::cout <<
" ***** lastBreakPoint larger than current break point *****" 915 std::cout <<
" halfEdge: " << halfEdge <<
", target vtx: " << vertex
916 <<
", face: " << halfEdge->
getFace() <<
", twin: " << halfTwin
918 <<
", twin face: " << halfTwin->
getFace()
924 Eigen::Vector3f lrPosDiff = rightLeafPos - leftLeafPos;
925 Eigen::Vector3f lrPosSum = rightLeafPos + leftLeafPos;
927 lrPosDiff.normalize();
940 double arcLenToLine = breakToLeafPos.dot(breakDir);
943 dcel2d::Coords breakVertexPos = vertexPos + arcLenToLine * breakDir;
945 std::cout <<
" halfEdge position: " << breakPos[0] <<
"/" << breakPos[1]
946 <<
", vertex: " << vertexPos[0] <<
"/" << vertexPos[1]
947 <<
", end: " << breakVertexPos[0] <<
"/" << breakVertexPos[1]
948 <<
", dir: " << breakDir[0] <<
"/" << breakDir[1]
949 <<
", arclen: " << arcLenToLine << std::endl;
959 std::cout <<
"****** null vertex!!! Skipping to next node... *********" << std::endl;
962 if (lastBreakPoint > breakPoint) nBadBreaks++;
964 lastBreakPoint = breakPoint;
971 std::cout <<
" -> associated circle: " << iEvent->
isCircle()
972 <<
", is valid: " << iEvent->
isValid() << std::endl;
992 if (outsideHull) { curVertexItr =
fVertexList.erase(curVertexItr); }
1000 std::cout <<
"Loop over beachline done, saved " <<
fConvexHullList.size()
1001 <<
" arcs, encountered " << nBadBreaks <<
" bad break points" << std::endl;
1002 std::cout <<
"-- started with " << nVerticesInitial <<
" vertices, found " 1003 <<
fVertexList.size() <<
" inside convex hull" << std::endl;
1016 const BSTNode* node = topNode;
1027 Eigen::Vector3f prevVec(0., 0., 0.);
1041 Eigen::Vector3f curVec = nextPoint - lastPoint;
1045 double dotProd = prevVec.dot(curVec);
1047 std::cout <<
"--> lastPoint: " << lastPoint[0] <<
"/" << lastPoint[1]
1048 <<
", tan: " << std::atan2(lastPoint[1], lastPoint[0])
1049 <<
", curPoint: " << nextPoint[0] <<
"/" << nextPoint[1]
1050 <<
", tan: " << std::atan2(nextPoint[1], nextPoint[0]) <<
", dot: " << dotProd
1054 lastPoint = nextPoint;
1064 localList.emplace_back(
1065 std::get<0>(edgePoint), std::get<1>(edgePoint), std::get<2>(edgePoint));
1068 localList.sort([](
const auto&
left,
const auto&
right) {
1070 std::numeric_limits<float>::epsilon()) ?
1071 std::get<0>(
left) < std::get<0>(
right) :
1081 std::cout <<
"~~~>> there are " << convexHull.
getConvexHull().size()
1082 <<
" convex hull points and " << fConvexHullList.size() <<
" infinite cells" 1089 std::cout <<
"~~~ Convex hull Point: " << std::get<0>(hullPoint) <<
", " 1090 << std::get<1>(hullPoint) << std::endl;
1102 float maxSeparation(0.);
1110 Eigen::Vector2f firstEdge(std::get<0>(*firstPointItr) - std::get<0>(firstPoint),
1111 std::get<1>(*firstPointItr) - std::get<1>(firstPoint));
1114 firstEdge.normalize();
1120 Eigen::Vector2f nextEdge(std::get<0>(endPoint) - std::get<0>(nextPoint),
1121 std::get<1>(endPoint) - std::get<1>(nextPoint));
1124 nextEdge.normalize();
1127 if (firstEdge.dot(nextEdge) < 0.) {
1128 Eigen::Vector2f separation(std::get<0>(nextPoint) - std::get<0>(firstPoint),
1129 std::get<1>(nextPoint) - std::get<1>(firstPoint));
1130 float separationDistance = separation.norm();
1132 if (separationDistance > maxSeparation) {
1133 extremePoints.first = firstPoint;
1134 extremePoints.second = nextPoint;
1135 maxSeparation = separationDistance;
1143 nextPointItr = endPointItr;
1144 nextPoint = endPoint;
1152 if (firstPointItr == nextPointItr) nextPointItr++;
1155 return extremePoints;
1160 bool insideHull(
true);
1174 if (!
isLeft(firstPoint, secondPoint, vertexPos)) {
1179 firstPoint = secondPoint;
1188 double& distToConvexHull)
const 1190 bool outsideHull(
false);
1193 distToConvexHull = std::numeric_limits<double>::max();
1204 double xPrevToPoint = (std::get<0>(vertexPos) - std::get<0>(*firstPointItr));
1205 double yPrevToPoint = (std::get<1>(vertexPos) - std::get<1>(*firstPointItr));
1206 double xPrevToCur = (std::get<0>(*secondPointItr) - std::get<0>(*firstPointItr));
1207 double yPrevToCur = (std::get<1>(*secondPointItr) - std::get<1>(*firstPointItr));
1208 double edgeLength = std::sqrt(xPrevToCur * xPrevToCur + yPrevToCur * yPrevToCur);
1211 double projection = ((xPrevToPoint * xPrevToCur) + (yPrevToPoint * yPrevToCur)) / edgeLength;
1214 dcel2d::Point docaPoint(std::get<0>(*firstPointItr) + projection * xPrevToCur / edgeLength,
1215 std::get<1>(*firstPointItr) + projection * yPrevToCur / edgeLength,
1218 if (projection > edgeLength) docaPoint = *secondPointItr;
1219 if (projection < 0) docaPoint = *firstPointItr;
1221 double xDocaDist = std::get<0>(vertexPos) - std::get<0>(docaPoint);
1222 double yDocaDist = std::get<1>(vertexPos) - std::get<1>(docaPoint);
1223 double docaDist = xDocaDist * xDocaDist + yDocaDist * yDocaDist;
1225 if (docaDist < distToConvexHull) {
1226 firstHullPointItr = firstPointItr;
1227 intersection =
dcel2d::Coords(std::get<0>(docaPoint), std::get<1>(docaPoint), 0.);
1228 distToConvexHull = docaDist;
1232 if (
isLeft(*firstPointItr, *secondPointItr, vertexPos)) outsideHull =
true;
1234 firstPointItr = secondPointItr;
1253 if (vtxPosDiff.norm() < 1.e-3) {
1254 std::cout <<
"***>> found a degenerate vertex! " 1280 double totalArea(0.);
1281 int nNonInfiniteFaces(0);
1282 double smallestArea(std::numeric_limits<double>::max());
1283 double largestArea(0.);
1285 std::vector<std::pair<double, const dcel2d::Face*>> areaFaceVec;
1292 double faceArea(0.);
1306 faceArea = std::numeric_limits<double>::max();
1310 if (halfEdge == face.getHalfEdge()) doNext =
false;
1313 faceCenter /= numEdges;
1315 halfEdge = face.getHalfEdge();
1322 faceArea = std::numeric_limits<double>::max();
1331 double dp1p0X = p1[0] - faceCenter[0];
1332 double dp1p0Y = p1[1] - faceCenter[1];
1333 double dp2p0X = p2[0] - faceCenter[0];
1334 double dp2p0Y = p2[1] - faceCenter[1];
1337 double crossProduct = dp1p0X * dp2p0Y - dp1p0Y * dp2p0X;
1341 if (crossProduct < 0.) {
1343 std::cout <<
"--- negative cross: " << crossProduct <<
", edgeLen: " << edgeVec.norm()
1344 <<
", x/y: " << edgeVec[0] <<
"/" << edgeVec[1] << std::endl;
1352 faceArea = std::numeric_limits<double>::max();
1356 if (halfEdge == face.getHalfEdge()) doNext =
false;
1359 areaFaceVec.emplace_back(faceArea, &face);
1361 if (faceArea < std::numeric_limits<double>::max() && faceArea > 0.) {
1362 nNonInfiniteFaces++;
1363 totalArea += faceArea;
1364 smallestArea = std::min(faceArea, smallestArea);
1365 largestArea = std::max(faceArea, largestArea);
1368 if (faceArea < 1.
e-4)
1369 std::cout <<
"---> face area <= 0: " << faceArea <<
", with " << numEdges <<
" edges" 1372 face.setFaceArea(faceArea);
1376 std::sort(areaFaceVec.begin(), areaFaceVec.end(), [](
const auto&
left,
const auto&
right) {
1380 std::vector<std::pair<double, const dcel2d::Face*>>
::iterator firstItr = std::find_if(
1381 areaFaceVec.begin(), areaFaceVec.end(), [](
const auto& val) {
return val.first > 0.; });
1382 std::vector<std::pair<double, const dcel2d::Face*>>
::iterator lastItr =
1383 std::find_if(areaFaceVec.begin(), areaFaceVec.end(), [](
const auto& val) {
1384 return !(val.first < std::numeric_limits<double>::max());
1387 size_t nToKeep = 0.8 * std::distance(firstItr, lastItr);
1389 std::cout <<
">>>>> nToKeep: " << nToKeep
1390 <<
", last non infinite entry: " << std::distance(areaFaceVec.begin(), lastItr)
1393 double totalTruncArea = std::accumulate(
1394 firstItr, firstItr + nToKeep, 0., [](
auto sum,
const auto& val) {
return sum + val.first; });
1395 double aveTruncArea = totalTruncArea / double(nToKeep);
1397 if (nNonInfiniteFaces > 0)
1398 std::cout <<
">>>> Face area for " << nNonInfiniteFaces
1399 <<
", ave area: " << totalArea / nNonInfiniteFaces
1400 <<
", ave trunc area: " << aveTruncArea <<
", ratio: " << totalTruncArea / totalArea
1401 <<
", smallest: " << smallestArea <<
", largest: " << largestArea << std::endl;
1403 std::cout <<
">>>>> there are no non infinite faces" << std::endl;
1411 std::pair<dcel2d::VertexList::const_iterator, dcel2d::VertexList::const_iterator> minMaxItrX =
1412 std::minmax_element(
1413 vertexList.begin(), vertexList.end(), [](
const auto&
left,
const auto&
right) {
1414 return left.getCoords()[0] <
right.getCoords()[0];
1417 fXMin = minMaxItrX.first->getCoords()[0];
1418 fXMax = minMaxItrX.second->getCoords()[0];
1421 std::pair<dcel2d::VertexList::const_iterator, dcel2d::VertexList::const_iterator> minMaxItrY =
1422 std::minmax_element(
1423 vertexList.begin(), vertexList.end(), [](
const auto&
left,
const auto&
right) {
1424 return left.getCoords()[1] <
right.getCoords()[1];
1427 fYMin = minMaxItrY.first->getCoords()[1];
1428 fYMax = minMaxItrY.second->getCoords()[1];
1434 double& closestDistance)
const 1445 PointPair closestEdge(prevPoint, curPoint);
1447 closestDistance = std::numeric_limits<double>::max();
1451 if (curPoint != prevPoint) {
1453 double xPrevToPoint = (std::get<0>(point) - std::get<0>(prevPoint));
1454 double yPrevToPoint = (std::get<1>(point) - std::get<1>(prevPoint));
1455 double xPrevToCur = (std::get<0>(curPoint) - std::get<0>(prevPoint));
1456 double yPrevToCur = (std::get<1>(curPoint) - std::get<1>(prevPoint));
1457 double edgeLength = std::sqrt(xPrevToCur * xPrevToCur + yPrevToCur * yPrevToCur);
1461 ((xPrevToPoint * xPrevToCur) + (yPrevToPoint * yPrevToCur)) / edgeLength;
1464 dcel2d::Point docaPoint(std::get<0>(prevPoint) + projection * xPrevToCur / edgeLength,
1465 std::get<1>(prevPoint) + projection * yPrevToCur / edgeLength,
1468 if (projection > edgeLength) docaPoint = curPoint;
1469 if (projection < 0) docaPoint = prevPoint;
1471 double xDocaDist = std::get<0>(point) - std::get<0>(docaPoint);
1472 double yDocaDist = std::get<1>(point) - std::get<1>(docaPoint);
1473 double docaDist = xDocaDist * xDocaDist + yDocaDist * yDocaDist;
1475 if (docaDist < closestDistance) {
1476 closestEdge =
PointPair(prevPoint, curPoint);
1477 closestDistance = docaDist;
1481 prevPoint = curPoint;
1482 curPoint = *curPointItr++;
1485 closestDistance = std::sqrt(closestDistance);
1489 if (
isLeft(closestEdge.first, closestEdge.second, point)) closestDistance = -closestDistance;
1496 double closestDistance;
1500 return closestDistance;
This defines the actual beach line. The idea is to implement this as a self balancing binary search t...
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
HalfEdge * getLastHalfEdge() const
HalfEdge * getNextHalfEdge() const
dcel2d::HalfEdgeList & fHalfEdgeList
std::list< HalfEdge > HalfEdgeList
void setHalfEdge(HalfEdge *half)
HalfEdge * getTwinHalfEdge() const
std::pair< dcel2d::Point, dcel2d::Point > PointPair
BSTNode class definiton specifically for use in constructing Voronoi diagrams. We are trying to follo...
Float_t x3[n_points_geant4]
std::list< Point > PointList
The list of the projected points.
bool isInsideConvexHull(const dcel2d::Vertex &) const
Is a vertex inside the convex hull - meant to be a fast check.
constexpr auto abs(T v)
Returns the absolute value of the argument.
double Area() const
Computes the area of the enclosed convext hull.
virtual BSTNode * getBSTNode() const =0
bool computeCircleCenter2(const dcel2d::Coords &, const dcel2d::Coords &, const dcel2d::Coords &, dcel2d::Coords &, double &) const
dcel2d::FaceList & fFaceList
std::list< BSTNode > BSTNodeList
~VoronoiDiagram()
Destructor.
void makeLeftCircleEvent(EventQueue &, BSTNode *, double)
double computeArcVal(const double, const double, const IEvent *) const
Float_t y2[n_points_geant4]
bool computeCircleCenter(const dcel2d::Coords &, const dcel2d::Coords &, const dcel2d::Coords &, dcel2d::Coords &, double &, double &) const
virtual const dcel2d::Coords & circleCenter() const =0
BSTNodeList fCircleNodeList
void setLastHalfEdge(HalfEdge *last)
BSTNode * getAssociated() const
void setTwinHalfEdge(HalfEdge *twin)
Implements a ConvexHull for use in clustering.
double fVoronoiDiagramArea
IEvent * makeCircleEvent(BSTNode *, BSTNode *, BSTNode *, double)
There are two types of events in the queue, here we handle circle events.
void handleCircleEvents(BeachLine &, EventQueue &, IEvent *)
There are two types of events in the queue, here we handle circle events.
std::list< Face > FaceList
CircleEventList fCircleEventList
SiteEventList fSiteEventList
double ComputeFaceArea()
Compute the area of the faces.
EventUtilities fUtilities
std::pair< double, double > RootsPair
BSTNode * insertNewLeaf(IEvent *)
void buildVoronoiDiagram(const dcel2d::PointList &)
Given an input set of 2D points construct a 2D voronoi diagram.
bool compareSiteEventPtrs(const IEvent *left, const IEvent *right)
double findNearestDistance(const dcel2d::Point &) const
Given an input point, find the distance to the nearest edge/point.
virtual double yPos() const =0
void findBoundingBox(const dcel2d::VertexList &)
Find the min/max values in x-y to use as a bounding box.
dcel2d::VertexList & fVertexList
std::priority_queue< IEvent *, std::vector< IEvent * >, bool(*)(const IEvent *, const IEvent *)> EventQueue
BSTNode * getRightChild() const
void mergeDegenerateVertices()
merge degenerate vertices (found by zero length edges)
const PointList & getConvexHull() const
recover the list of convex hull vertices
dcel2d::Coords fConvexHullCenter
virtual bool isCircle() const =0
void makeRightCircleEvent(EventQueue &, BSTNode *, double)
BSTNode * removeLeaf(BSTNode *)
void setAssociated(BSTNode *node)
virtual bool isValid() const =0
dcel2d::PointList fPointList
const BSTNode * getTopNode() const
ConvexHull class definiton.
double crossProduct(const dcel2d::Point &p0, const dcel2d::Point &p1, const dcel2d::Point &p2) const
Gets the cross product of line from p0 to p1 and p0 to p2.
virtual double xPos() const =0
PointPair findNearestEdge(const dcel2d::Point &, double &) const
Given an input Point, find the nearest edge.
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
const HalfEdge * getHalfEdge() const
int traverseBeach() const
dcel2d::PointList fConvexHullList
void setNextHalfEdge(HalfEdge *next)
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
double computeBreak(const double, const IEvent *, const IEvent *, RootsPair &) const
void setHalfEdge(HalfEdge *half)
const dcel2d::PointList & getConvexHull() const
recover the point list representing the convex hull
void boostTranslation(const dcel2d::PointList &, const boost::polygon::voronoi_edge< double > *, const boost::polygon::voronoi_edge< double > *, BoostEdgeToEdgeMap &, BoostVertexToVertexMap &, BoostCellToFaceMap &)
PointPair getExtremePoints() const
Given an input Point, find the nearest edge.
BSTNode * getPredecessor() const
std::map< const boost::polygon::voronoi_edge< double > *, dcel2d::HalfEdge * > BoostEdgeToEdgeMap
Translate boost to dcel.
std::map< const boost::polygon::voronoi_vertex< double > *, dcel2d::Vertex * > BoostVertexToVertexMap
void terminateInfiniteEdges(BeachLine &, double)
this aims to process remaining elements in the beachline after the event queue has been depleted ...
bool computeCircleCenter3(const dcel2d::Coords &, const dcel2d::Coords &, const dcel2d::Coords &, dcel2d::Coords &, double &) const
dcel2d::Face * getFace() const
std::list< Point > PointList
void buildVoronoiDiagramBoost(const dcel2d::PointList &)
void setFace(dcel2d::Face *face)
dcel2d::HalfEdge * getHalfEdge() const
Vertex * getTargetVertex() const
Float_t x2[n_points_geant4]
Float_t y3[n_points_geant4]
const Coords & getCoords() const
std::list< Vertex > VertexList
virtual void setInvalid() const =0
Interface for configuring the particular algorithm tool.
void setTargetVertex(Vertex *vertex)
IEvent * getEvent() const
BSTNode * getSuccessor() const
BSTNode * getLeftChild() const
std::map< const boost::polygon::voronoi_cell< double > *, dcel2d::Face * > BoostCellToFaceMap
bool isOutsideConvexHull(const dcel2d::Vertex &, dcel2d::PointList::const_iterator, dcel2d::Coords &, double &) const
is vertex outside the convex hull and if so return some useful information
virtual const dcel2d::Coords & getCoords() const =0
Event finding and building.
void setHalfEdge(dcel2d::HalfEdge *half)
virtual const dcel2d::Point & getPoint() const =0
bool isLeft(const dcel2d::Point &p0, const dcel2d::Point &p1, const dcel2d::Point &pCheck) const
Determines whether a point is to the left, right or on line specifiec by p0 and p1.
void handleSiteEvents(BeachLine &, EventQueue &, IEvent *)
There are two types of events in the queue, here we handle site events.