20 #include <boost/polygon/voronoi.hpp> 30 typedef point_concept
type;
38 static inline coordinate_type
get(
const dcel2d::Point& point, orientation_2d orient)
40 return (orient == HORIZONTAL) ? std::get<1>(point) : std::get<0>(point);
52 fHalfEdgeList(halfEdgeList),
53 fVertexList(vertexList),
59 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));
119 if (point != lastPoint) area += 0.5 *
crossProduct(center,lastPoint,point);
145 std::cout <<
"******************************************************************************************************************" <<
std::endl;
146 std::cout <<
"******************************************************************************************************************" <<
std::endl;
147 std::cout <<
"******************************************************************************************************************" <<
std::endl;
148 std::cout <<
"==> # input points: " << pointList.size() <<
std::endl;
154 for(
const auto& point : pointList)
158 eventQueue.push(iEvent);
168 while(!eventQueue.empty())
170 IEvent*
event = eventQueue.top();
193 std::map<int,int> edgeCountMap;
194 std::map<int,int> openCountMap;
205 if (halfEdge->getFace() != &face)
207 std::cout <<
" ===> halfEdge does not match face: " << halfEdge <<
", face: " << halfEdge->
getFace() <<
", base: " << &face <<
std::endl;
210 if (halfEdge == startEdge)
216 halfEdge = halfEdge->getNextHalfEdge();
224 if (halfEdge->getFace() != &face)
226 std::cout <<
" ===> halfEdge does not match face: " << halfEdge <<
", face: " << halfEdge->getFace() <<
", base: " << &face <<
std::endl;
229 if (halfEdge == startEdge)
235 halfEdge = halfEdge->getLastHalfEdge();
242 openCountMap[nEdges]++;
245 edgeCountMap[nEdges]++;
248 std::cout <<
"==> Found " << nOpenFaces <<
" open faces from total of " << fFaceList.size() <<
std::endl;
249 for(
const auto& edgeCount : edgeCountMap) std::cout <<
" -> all edges, # edges: " << edgeCount.first <<
", count: " << edgeCount.second <<
std::endl;
250 for(
const auto& edgeCount : openCountMap) std::cout <<
" -> open edges, # edges: " << edgeCount.first <<
", count: " << edgeCount.second <<
std::endl;
251 std::cout <<
"******************************************************************************************************************" <<
std::endl;
252 std::cout <<
"******************************************************************************************************************" <<
std::endl;
253 std::cout <<
"******************************************************************************************************************" <<
std::endl;
277 std::cout <<
"******************************************************************************************************************" <<
std::endl;
278 std::cout <<
"******************************************************************************************************************" <<
std::endl;
279 std::cout <<
"******************************************************************************************************************" <<
std::endl;
280 std::cout <<
"==> # input points: " << pointList.size() <<
std::endl;
283 boost::polygon::voronoi_diagram<double> vd;
284 boost::polygon::construct_voronoi(pointList.begin(),pointList.end(),&vd);
291 BoostEdgeToEdgeMap boostEdgeToEdgeMap;
296 for(
const auto& edge : vd.edges())
298 const boost::polygon::voronoi_edge<double>* twin = edge.twin();
300 boostTranslation(pointList, &edge, twin, boostEdgeToEdgeMap, boostVertexToVertexMap, boostCellToFaceMap);
301 boostTranslation(pointList, twin, &edge, boostEdgeToEdgeMap, boostVertexToVertexMap, boostCellToFaceMap);
308 std::cout <<
" " << vd.edges().size() <<
" edges, " << vd.cells().size() <<
" faces, " << vd.vertices().size() <<
" vertices" <<
std::endl;
309 std::cout <<
"******************************************************************************************************************" <<
std::endl;
310 std::cout <<
"******************************************************************************************************************" <<
std::endl;
311 std::cout <<
"******************************************************************************************************************" <<
std::endl;
322 const boost::polygon::voronoi_edge<double>* edge,
323 const boost::polygon::voronoi_edge<double>* twin,
331 if (boostEdgeToEdgeMap.find(edge) != boostEdgeToEdgeMap.end()) halfEdge = boostEdgeToEdgeMap.at(edge);
338 boostEdgeToEdgeMap[edge] = halfEdge;
341 if (boostEdgeToEdgeMap.find(twin) != boostEdgeToEdgeMap.end()) twinEdge = boostEdgeToEdgeMap.at(twin);
348 boostEdgeToEdgeMap[twin] = twinEdge;
352 const boost::polygon::voronoi_vertex<double>* boostVertex = edge->vertex1();
358 if (boostVertexToVertexMap.find(boostVertex) == boostVertexToVertexMap.end())
366 boostVertexToVertexMap[boostVertex] = vertex;
368 else vertex = boostVertexToVertexMap.at(boostVertex);
371 const boost::polygon::voronoi_cell<double>* boostCell = edge->cell();
374 if (boostCellToFaceMap.find(boostCell) == boostCellToFaceMap.end())
377 int pointIdx = boostCell->source_index();
379 std::advance(pointItr, pointIdx);
384 fFaceList.emplace_back(halfEdge,coords,std::get<2>(point));
388 boostCellToFaceMap[boostCell] = face;
396 if (boostEdgeToEdgeMap.find(edge->next()) != boostEdgeToEdgeMap.end())
404 if (boostEdgeToEdgeMap.find(edge->prev()) != boostEdgeToEdgeMap.end())
597 eventQueue.push(circleEvent);
644 eventQueue.push(circleEvent);
671 double circleBottomX = center[0] - radius;
674 if (beachLinePos >= circleBottomX - 10. * deltaR)
683 else if (circleBottomX - beachLinePos < 1.
e-4)
684 std::cout <<
"==> Circle close, beachLine: " << beachLinePos <<
", circleBottomX: " << circleBottomX <<
", deltaR: " << deltaR <<
", d: " << circleBottomX - beachLinePos <<
std::endl;
701 double xCoord = p1[0];
702 double yCoord = p1[1];
704 double x2 = p2[0] - xCoord;
705 double y2 = p2[1] - yCoord;
706 double x3 = p3[0] - xCoord;
707 double y3 = p3[1] - yCoord;
709 double det = x2 * y3 - x3 * y2;
717 if (det > -std::numeric_limits<double>::epsilon())
718 std::cout <<
" --->Circle failure, det: " << det <<
", mid x: " << p2[0] <<
", y: " << p2[1]
719 <<
", l x: " << p1[0] <<
", y: " << p1[1]
720 <<
", r x: " << p3[0] <<
", y: " << p3[1] <<
std::endl;
725 double p2sqr = x2 * x2 + y2 * y2;
726 double p3sqr = x3 * x3 + y3 * y3;
728 double cxpr = 0.5 * (y3 * p2sqr - y2 * p3sqr) / det;
729 double cypr = 0.5 * (x2 * p3sqr - x3 * p2sqr) / det;
731 radius = std::sqrt(cxpr * cxpr + cypr * cypr);
732 center[0] = cxpr + xCoord;
733 center[1] = cypr + yCoord;
743 std::vector<float> radSqrVec;
745 radSqrVec.push_back(p1Rad.norm());
746 radSqrVec.push_back(p2Rad.norm());
747 radSqrVec.push_back(p3Rad.norm());
749 double maxRadius = *std::max_element(radSqrVec.begin(),radSqrVec.end());
751 delta =
std::max(5.
e-7, maxRadius - radius);
770 double slope12 = (p2[1] - p1[1]) / (p2[0] - p1[0]);
771 double slope32 = (p3[1] - p2[1]) / (p3[0] - p2[0]);
773 if (
std::abs(slope12 - slope32) <= std::numeric_limits<double>::epsilon())
775 std::cout <<
" >>>> Matching slopes! points: (" << p1[0] <<
"," << p1[1] <<
"), ("<< p2[0] <<
"," << p2[1] <<
"), ("<< p3[0] <<
"," << p3[1] <<
")" <<
std::endl;
780 center[0] = (slope12 * slope32 * (p3[1] - p1[1]) + slope12 * (p2[0] + p3[0]) - slope32 * (p1[0] + p2[0])) / (2. * (slope12 - slope32));
781 center[1] = 0.5 * (p1[1] + p2[1]) - (center[0] - 0.5 * (p1[0] + p2[0])) / slope12;
783 radius = std::sqrt(
std::pow((p2[0] - center[0]),2) +
std::pow((p2[1] - center[1]),2));
787 std::cout <<
" ***> Rad2 = " << radius <<
", circ x,y: " << center[0] <<
"," << center[1] <<
", p1: " << p1[0] <<
"," << p1[1] <<
", p2: " << p2[0] <<
"," << p2[1] <<
", p3: " << p3[0] <<
", " << p3[1] <<
std::endl;
801 double temp = p2[0] * p2[0] + p2[1] * p2[1];
802 double p1p2 = (p1[0] * p1[0] + p1[1] * p1[1] -
temp) / 2.0;
803 double p2p3 = (temp - p3[0] * p3[0] - p3[1] * p3[1]) / 2.0;
804 double det = (p1[0] - p2[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p2[1]);
806 if (
std::abs(det) < 10. * std::numeric_limits<double>::epsilon())
808 std::cout <<
" >>>> Determinant zero! points: (" << p1[0] <<
"," << p1[1] <<
"), ("<< p2[0] <<
"," << p2[1] <<
"), ("<< p3[0] <<
"," << p3[1] <<
")" <<
std::endl;
815 center[0] = (p1p2 * (p2[1] - p3[1]) - p2p3 * (p1[1] - p2[1])) * det;
816 center[1] = (p2p3 * (p1[0] - p2[0]) - p1p2 * (p2[0] - p3[0])) * det;
819 radius = std::sqrt(
std::pow((p1[0] - center[0]),2) +
std::pow((p1[1] - center[1]),2));
823 std::cout <<
" ***> Rad3 = " << radius <<
", circ x,y: " << center[0] <<
"," << center[1] <<
", p1: " << p1[0] <<
"," << p1[1] <<
", p2: " << p2[0] <<
"," << p2[1] <<
", p3: " << p3[0] <<
", " << p3[1] <<
std::endl;
847 double lastBreakPoint = std::numeric_limits<double>::lowest();
853 std::cout <<
"--------------------------------------------------------------------------------------------" <<
std::endl;
872 std::cout <<
"node " << nodeCount <<
" has break: " << breakPoint <<
", beachPos: " << beachLinePos <<
" (last: " << lastBreakPoint <<
"), leftArcVal: " << leftArcVal <<
", rightArcVal: " << rightArcVal <<
std::endl;
873 if (lastBreakPoint > breakPoint) std::cout <<
" ***** lastBreakPoint larger than current break point *****" <<
std::endl;
879 Eigen::Vector3f lrPosDiff = rightLeafPos - leftLeafPos;
880 Eigen::Vector3f lrPosSum = rightLeafPos + leftLeafPos;
882 lrPosDiff.normalize();
896 double arcLenToLine = breakToLeafPos.dot(breakDir);
899 dcel2d::Coords breakVertexPos = vertexPos + arcLenToLine * breakDir;
901 std::cout <<
" halfEdge position: " << breakPos[0] <<
"/" << breakPos[1] <<
", vertex: " << vertexPos[0] <<
"/" << vertexPos[1] <<
", end: " << breakVertexPos[0] <<
"/" << breakVertexPos[1] <<
", dir: " << breakDir[0] <<
"/" << breakDir[1] <<
", arclen: " << arcLenToLine <<
std::endl;
912 std::cout <<
"****** null vertex!!! Skipping to next node... *********" <<
std::endl;
915 if (lastBreakPoint > breakPoint) nBadBreaks++;
917 lastBreakPoint = breakPoint;
956 std::cout <<
"Loop over beachline done, saved " <<
fConvexHullList.size() <<
" arcs, encountered " << nBadBreaks <<
" bad break points" <<
std::endl;
957 std::cout <<
"-- started with " << nVerticesInitial <<
" vertices, found " <<
fVertexList.size() <<
" inside convex hull" <<
std::endl;
981 Eigen::Vector3f prevVec(0.,0.,0.);
997 Eigen::Vector3f curVec = nextPoint - lastPoint;
1001 double dotProd = prevVec.dot(curVec);
1003 std::cout <<
"--> lastPoint: " << lastPoint[0] <<
"/" << lastPoint[1] <<
", tan: " << std::atan2(lastPoint[1],lastPoint[0]) <<
", curPoint: " << nextPoint[0] <<
"/" << nextPoint[1] <<
", tan: " << std::atan2(nextPoint[1],nextPoint[0]) <<
", dot: " << dotProd <<
std::endl;
1006 lastPoint = nextPoint;
1015 for(
const auto& edgePoint :
fConvexHullList) localList.emplace_back(std::get<0>(edgePoint),std::get<1>(edgePoint),std::get<2>(edgePoint));
1018 localList.sort([](
const auto&
left,
const auto&
right){
return (
std::abs(std::get<0>(
left) - std::get<0>(
right)) > std::numeric_limits<float>::epsilon()) ? std::get<0>(
left) < std::get<0>(
right) : std::get<1>(
left) < std::get<1>(
right);});
1026 std::cout <<
"~~~>> there are " << convexHull.
getConvexHull().size() <<
" convex hull points and " << fConvexHullList.size() <<
" infinite cells" <<
std::endl;
1033 std::cout <<
"~~~ Convex hull Point: " << std::get<0>(hullPoint) <<
", " << std::get<1>(hullPoint) <<
std::endl;
1045 float maxSeparation(0.);
1054 Eigen::Vector2f firstEdge(std::get<0>(*firstPointItr) - std::get<0>(firstPoint), std::get<1>(*firstPointItr) - std::get<1>(firstPoint));
1057 firstEdge.normalize();
1064 Eigen::Vector2f nextEdge(std::get<0>(endPoint) - std::get<0>(nextPoint), std::get<1>(endPoint) - std::get<1>(nextPoint));
1067 nextEdge.normalize();
1070 if (firstEdge.dot(nextEdge) < 0.)
1072 Eigen::Vector2f separation(std::get<0>(nextPoint) - std::get<0>(firstPoint), std::get<1>(nextPoint) - std::get<1>(firstPoint));
1073 float separationDistance = separation.norm();
1075 if (separationDistance > maxSeparation)
1077 extremePoints.first = firstPoint;
1078 extremePoints.second = nextPoint;
1079 maxSeparation = separationDistance;
1087 nextPointItr = endPointItr;
1088 nextPoint = endPoint;
1096 if (firstPointItr == nextPointItr) nextPointItr++;
1099 return extremePoints;
1104 bool insideHull(
true);
1119 if (!
isLeft(firstPoint,secondPoint,vertexPos))
1125 firstPoint = secondPoint;
1134 double& distToConvexHull)
const 1136 bool outsideHull(
false);
1151 double xPrevToPoint = (std::get<0>(vertexPos) - std::get<0>(*firstPointItr));
1152 double yPrevToPoint = (std::get<1>(vertexPos) - std::get<1>(*firstPointItr));
1153 double xPrevToCur = (std::get<0>(*secondPointItr) - std::get<0>(*firstPointItr));
1154 double yPrevToCur = (std::get<1>(*secondPointItr) - std::get<1>(*firstPointItr));
1155 double edgeLength = std::sqrt(xPrevToCur * xPrevToCur + yPrevToCur * yPrevToCur);
1158 double projection = ((xPrevToPoint * xPrevToCur) + (yPrevToPoint * yPrevToCur)) / edgeLength;
1161 dcel2d::Point docaPoint(std::get<0>(*firstPointItr) + projection * xPrevToCur / edgeLength,
1162 std::get<1>(*firstPointItr) + projection * yPrevToCur / edgeLength, 0);
1164 if (projection > edgeLength) docaPoint = *secondPointItr;
1165 if (projection < 0) docaPoint = *firstPointItr;
1167 double xDocaDist = std::get<0>(vertexPos) - std::get<0>(docaPoint);
1168 double yDocaDist = std::get<1>(vertexPos) - std::get<1>(docaPoint);
1169 double docaDist = xDocaDist * xDocaDist + yDocaDist * yDocaDist;
1171 if (docaDist < distToConvexHull)
1173 firstHullPointItr = firstPointItr;
1174 intersection =
dcel2d::Coords(std::get<0>(docaPoint),std::get<1>(docaPoint),0.);
1175 distToConvexHull = docaDist;
1179 if (
isLeft(*firstPointItr,*secondPointItr,vertexPos)) outsideHull =
true;
1181 firstPointItr = secondPointItr;
1201 if (vtxPosDiff.norm() < 1.e-3)
1225 double totalArea(0.);
1226 int nNonInfiniteFaces(0);
1228 double largestArea(0.);
1230 std::vector<std::pair<double,const dcel2d::Face*>> areaFaceVec;
1238 double faceArea(0.);
1259 if (halfEdge == face.getHalfEdge()) doNext =
false;
1262 faceCenter /= numEdges;
1264 halfEdge = face.getHalfEdge();
1282 double dp1p0X = p1[0] - faceCenter[0];
1283 double dp1p0Y = p1[1] - faceCenter[1];
1284 double dp2p0X = p2[0] - faceCenter[0];
1285 double dp2p0Y = p2[1] - faceCenter[1];
1288 double crossProduct = dp1p0X * dp2p0Y - dp1p0Y * dp2p0X;
1292 if (crossProduct < 0.)
1295 std::cout <<
"--- negative cross: " << crossProduct <<
", edgeLen: " << edgeVec.norm() <<
", x/y: " << edgeVec[0] <<
"/" << edgeVec[1] <<
std::endl;
1308 if (halfEdge == face.getHalfEdge()) doNext =
false;
1311 areaFaceVec.emplace_back(faceArea,&face);
1315 nNonInfiniteFaces++;
1316 totalArea += faceArea;
1317 smallestArea =
std::min(faceArea,smallestArea);
1318 largestArea =
std::max(faceArea,largestArea);
1321 if (faceArea < 1.
e-4) std::cout <<
"---> face area <= 0: " << faceArea <<
", with " << numEdges <<
" edges" <<
std::endl;
1323 face.setFaceArea(faceArea);
1327 std::sort(areaFaceVec.begin(),areaFaceVec.end(),[](
const auto&
left,
const auto&
right){
return left.first <
right.first;});
1329 std::vector<std::pair<double,const dcel2d::Face*>>
::iterator firstItr = std::find_if(areaFaceVec.begin(),areaFaceVec.end(),[](
const auto&
val){
return val.first > 0.;});
1334 std::cout <<
">>>>> nToKeep: " << nToKeep <<
", last non infinite entry: " <<
std::distance(areaFaceVec.begin(),lastItr) <<
std::endl;
1336 double totalTruncArea = std::accumulate(firstItr,firstItr+nToKeep,0.,[](
auto sum,
const auto&
val){
return sum+
val.first;});
1337 double aveTruncArea = totalTruncArea / double(nToKeep);
1339 if (nNonInfiniteFaces > 0) std::cout <<
">>>> Face area for " << nNonInfiniteFaces <<
", ave area: " << totalArea / nNonInfiniteFaces <<
", ave trunc area: " << aveTruncArea <<
", ratio: " << totalTruncArea / totalArea <<
", smallest: " << smallestArea <<
", largest: " << largestArea <<
std::endl;
1340 else std::cout <<
">>>>> there are no non infinite faces" <<
std::endl;
1349 std::pair<dcel2d::VertexList::const_iterator,dcel2d::VertexList::const_iterator> minMaxItrX = std::minmax_element(vertexList.begin(),vertexList.end(),[](
const auto&
left,
const auto&
right){
return left.getCoords()[0] <
right.getCoords()[0];});
1351 fXMin = minMaxItrX.first->getCoords()[0];
1352 fXMax = minMaxItrX.second->getCoords()[0];
1355 std::pair<dcel2d::VertexList::const_iterator,dcel2d::VertexList::const_iterator> minMaxItrY = std::minmax_element(vertexList.begin(),vertexList.end(),[](
const auto&
left,
const auto&
right){
return left.getCoords()[1] <
right.getCoords()[1];});
1357 fYMin = minMaxItrY.first->getCoords()[1];
1358 fYMax = minMaxItrY.second->getCoords()[1];
1374 PointPair closestEdge(prevPoint,curPoint);
1381 if (curPoint != prevPoint)
1384 double xPrevToPoint = (std::get<0>(point) - std::get<0>(prevPoint));
1385 double yPrevToPoint = (std::get<1>(point) - std::get<1>(prevPoint));
1386 double xPrevToCur = (std::get<0>(curPoint) - std::get<0>(prevPoint));
1387 double yPrevToCur = (std::get<1>(curPoint) - std::get<1>(prevPoint));
1388 double edgeLength = std::sqrt(xPrevToCur * xPrevToCur + yPrevToCur * yPrevToCur);
1391 double projection = ((xPrevToPoint * xPrevToCur) + (yPrevToPoint * yPrevToCur)) / edgeLength;
1394 dcel2d::Point docaPoint(std::get<0>(prevPoint) + projection * xPrevToCur / edgeLength,
1395 std::get<1>(prevPoint) + projection * yPrevToCur / edgeLength, 0);
1397 if (projection > edgeLength) docaPoint = curPoint;
1398 if (projection < 0) docaPoint = prevPoint;
1400 double xDocaDist = std::get<0>(point) - std::get<0>(docaPoint);
1401 double yDocaDist = std::get<1>(point) - std::get<1>(docaPoint);
1402 double docaDist = xDocaDist * xDocaDist + yDocaDist * yDocaDist;
1404 if (docaDist < closestDistance)
1406 closestEdge =
PointPair(prevPoint,curPoint);
1407 closestDistance = docaDist;
1411 prevPoint = curPoint;
1412 curPoint = *curPointItr++;
1415 closestDistance = std::sqrt(closestDistance);
1419 if (
isLeft(closestEdge.first,closestEdge.second,point)) closestDistance = -closestDistance;
1426 double closestDistance;
1430 return closestDistance;
This defines the actual beach line. The idea is to implement this as a self balancing binary search t...
bool computeCircleCenter2(const dcel2d::Coords &, const dcel2d::Coords &, const dcel2d::Coords &, dcel2d::Coords &, double &, double &) const
HalfEdge * getLastHalfEdge() const
HalfEdge * getNextHalfEdge() const
dcel2d::HalfEdgeList & fHalfEdgeList
std::list< HalfEdge > HalfEdgeList
void setHalfEdge(HalfEdge *half)
HalfEdge * getTwinHalfEdge() const
BSTNode class definiton specifically for use in constructing Voronoi diagrams. We are trying to follo...
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.
double Area() const
Computes the area of the enclosed convext hull.
virtual BSTNode * getBSTNode() const =0
dcel2d::FaceList & fFaceList
std::list< BSTNode > BSTNodeList
~VoronoiDiagram()
Destructor.
void makeLeftCircleEvent(EventQueue &, BSTNode *, double)
double computeArcVal(const double, const double, const IEvent *) const
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::priority_queue< IEvent *, std::vector< IEvent * >, bool(*)(const IEvent *, const IEvent *)> EventQueue
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
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
BSTNode * getRightChild() const
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
void mergeDegenerateVertices()
merge degenerate vertices (found by zero length edges)
static int max(int a, int b)
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.
const HalfEdge * getHalfEdge() const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
int traverseBeach() const
dcel2d::PointList fConvexHullList
void setNextHalfEdge(HalfEdge *next)
std::pair< dcel2d::Point, dcel2d::Point > PointPair
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
bool computeCircleCenter3(const dcel2d::Coords &, const dcel2d::Coords &, const dcel2d::Coords &, dcel2d::Coords &, double &, double &) const
std::pair< double, double > RootsPair
void terminateInfiniteEdges(BeachLine &, double)
this aims to process remaining elements in the beachline after the event queue has been depleted ...
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
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
QTextStream & endl(QTextStream &s)
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.