本文整理汇总了C++中TPPLPoly::GetNumPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ TPPLPoly::GetNumPoints方法的具体用法?C++ TPPLPoly::GetNumPoints怎么用?C++ TPPLPoly::GetNumPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPPLPoly
的用法示例。
在下文中一共展示了TPPLPoly::GetNumPoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::vector<sf::Vector2f> _getEdges(TPPLPoly& A)
{
std::vector<sf::Vector2f> edges;
for(unsigned int i=0; i < (A.GetNumPoints()+1) ; ++i)
{
sf::Vector2f P1( A[i].x, A[i].y);
sf::Vector2f P2( A[(i+1)%A.GetNumPoints()].x, A[(i+1)%A.GetNumPoints()].y );
edges.push_back( P2 - P1 );
}
return edges;
}
示例2: P
std::vector<sf::Vector2f> _getPoints(TPPLPoly& A)
{
std::vector<sf::Vector2f> points;
for(unsigned int i=0; i < A.GetNumPoints() ; ++i)
{
sf::Vector2f P( A[i].x, A[i].y);
points.push_back( P );
}
return points;
}
示例3: MonotonePartition
//triangulates a set of polygons by first partitioning them into monotone polygons
//O(n*log(n)) time complexity, O(n) space complexity
//the algorithm used here is outlined in the book
//"Computational Geometry: Algorithms and Applications"
//by Mark de Berg, Otfried Cheong, Marc van Kreveld and Mark Overmars
int TPPLPartition::MonotonePartition(list<TPPLPoly> *inpolys, list<TPPLPoly> *monotonePolys) {
list<TPPLPoly>::iterator iter;
MonotoneVertex *vertices;
long i,numvertices,vindex,vindex2,newnumvertices,maxnumvertices;
long polystartindex, polyendindex;
TPPLPoly *poly;
MonotoneVertex *v,*v2,*vprev,*vnext;
ScanLineEdge newedge;
bool error = false;
numvertices = 0;
for(iter = inpolys->begin(); iter != inpolys->end(); iter++) {
numvertices += iter->GetNumPoints();
}
maxnumvertices = numvertices*3;
vertices = new MonotoneVertex[maxnumvertices];
newnumvertices = numvertices;
polystartindex = 0;
for(iter = inpolys->begin(); iter != inpolys->end(); iter++) {
poly = &(*iter);
polyendindex = polystartindex + poly->GetNumPoints()-1;
for(i=0;i<poly->GetNumPoints();i++) {
vertices[i+polystartindex].p = poly->GetPoint(i);
if(i==0) vertices[i+polystartindex].previous = polyendindex;
else vertices[i+polystartindex].previous = i+polystartindex-1;
if(i==(poly->GetNumPoints()-1)) vertices[i+polystartindex].next = polystartindex;
else vertices[i+polystartindex].next = i+polystartindex+1;
}
polystartindex = polyendindex+1;
}
//construct the priority queue
long *priority = new long [numvertices];
for(i=0;i<numvertices;i++) priority[i] = i;
std::sort(priority,&(priority[numvertices]),VertexSorter(vertices));
//determine vertex types
char *vertextypes = new char[maxnumvertices];
for(i=0;i<numvertices;i++) {
v = &(vertices[i]);
vprev = &(vertices[v->previous]);
vnext = &(vertices[v->next]);
if(Below(vprev->p,v->p)&&Below(vnext->p,v->p)) {
if(IsConvex(vnext->p,vprev->p,v->p)) {
vertextypes[i] = TPPL_VERTEXTYPE_START;
} else {
vertextypes[i] = TPPL_VERTEXTYPE_SPLIT;
}
} else if(Below(v->p,vprev->p)&&Below(v->p,vnext->p)) {
if(IsConvex(vnext->p,vprev->p,v->p))
{
vertextypes[i] = TPPL_VERTEXTYPE_END;
} else {
vertextypes[i] = TPPL_VERTEXTYPE_MERGE;
}
} else {
vertextypes[i] = TPPL_VERTEXTYPE_REGULAR;
}
}
//helpers
long *helpers = new long[maxnumvertices];
//binary search tree that holds edges intersecting the scanline
//note that while set doesn't actually have to be implemented as a tree
//complexity requirements for operations are the same as for the balanced binary search tree
set<ScanLineEdge> edgeTree;
//store iterators to the edge tree elements
//this makes deleting existing edges much faster
set<ScanLineEdge>::iterator *edgeTreeIterators,edgeIter;
edgeTreeIterators = new set<ScanLineEdge>::iterator[maxnumvertices];
pair<set<ScanLineEdge>::iterator,bool> edgeTreeRet;
for(i = 0; i<numvertices; i++) edgeTreeIterators[i] = edgeTree.end();
//for each vertex
for(i=0;i<numvertices;i++) {
vindex = priority[i];
v = &(vertices[vindex]);
vindex2 = vindex;
v2 = v;
//depending on the vertex type, do the appropriate action
//comments in the following sections are copied from "Computational Geometry: Algorithms and Applications"
switch(vertextypes[vindex]) {
case TPPL_VERTEXTYPE_START:
//Insert ei in T and set helper(ei) to vi.
newedge.p1 = v->p;
newedge.p2 = vertices[v->next].p;
newedge.index = vindex;
edgeTreeRet = edgeTree.insert(newedge);
edgeTreeIterators[vindex] = edgeTreeRet.first;
helpers[vindex] = vindex;
//.........这里部分代码省略.........