本文整理汇总了C++中Graph::ExtractPrimitives方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::ExtractPrimitives方法的具体用法?C++ Graph::ExtractPrimitives怎么用?C++ Graph::ExtractPrimitives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::ExtractPrimitives方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: determine_faces_from_edges
IndexArrayPtr PGL::determine_faces_from_edges(const Point2ArrayPtr& points, const std::vector<std::pair<uint32_t, uint32_t> >& edges)
{
typedef Wm5::PlanarGraph<Vector2> Graph;
Graph graph;
int i = 0;
for (Point2Array::const_iterator it = points->begin(); it != points->end(); ++it)
graph.InsertVertex(*it,i++);
for (std::vector<std::pair<uint32_t, uint32_t> >::const_iterator itedge = edges.begin(); itedge != edges.end(); ++itedge)
graph.InsertEdge(itedge->first,itedge->second);
std::vector<Graph::Primitive*> mPrimitives;
graph.ExtractPrimitives(mPrimitives);
IndexArrayPtr result(new IndexArray());
for (std::vector<Graph::Primitive*>::const_iterator itPrim = mPrimitives.begin(); itPrim != mPrimitives.end(); ++itPrim){
if ((*itPrim)->Type == Graph::PT_MINIMAL_CYCLE){
Index lresult;
for (std::vector<std::pair<Vector2,int> >::const_iterator itSequence = (*itPrim)->Sequence.begin(); itSequence != (*itPrim)->Sequence.end(); ++itSequence)
lresult.push_back(itSequence->second);
result->push_back(lresult);
}
}
return result;
}
示例2: Load
void Load(Graph& mGraph, vector<Graph::Primitive*>& mPrimitives)
{
// std::string path = Environment::GetPathR("tri.txt");
//std::ifstream inFile(path.c_str());
ifstream inFile("./PlanarGraph.txt");
//ofstream verify;
//verify.open("verify.txt",ios::out|ios::app);
int numVertices;
inFile >> numVertices;
//verify<< numVertices<<"\n";
int i;
for (i = 0; i < numVertices; ++i)
{
double x, y;
inFile >> x;
inFile >> y;
// verify<< x <<"\t"<< y <<"\n";
//y = GetHeight() - 1 - y;
mGraph.InsertVertex(Vec2(x, y), i);
}
int numEdges;
inFile >> numEdges;
//verify<< numEdges<<"\n";
for (i = 0; i < numEdges; ++i)
{
int v0, v1;
inFile >> v0;
inFile >> v1;
// verify<< v0 <<"\t"<< v1 <<"\n";
mGraph.InsertEdge(v0, v1);
}
#ifdef EXTRACT_PRIMITIVES
mGraph.ExtractPrimitives(mPrimitives);
#endif
}