本文整理汇总了C++中Triangulation::flip方法的典型用法代码示例。如果您正苦于以下问题:C++ Triangulation::flip方法的具体用法?C++ Triangulation::flip怎么用?C++ Triangulation::flip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Triangulation
的用法示例。
在下文中一共展示了Triangulation::flip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char ** argv) {
H.init ("Random triangulation", argc,argv, "n=10,t=-1");
int t = H['t']; if (t==-1) t=50*int(H['n'])*int(H['n']);
Triangulation T (H['n']); T.inscribe(T.face(Edge(0,1)));
{ ProgressBar P (t); for (int i=0; i<t; ++i) { T.flip(T.random_edge()); P.set(i); } }
T.show();
T.inscribe (T.face (Edge (0,*(T.v[0]->adj.begin())))); T.balance_old(); T.pause();
std::cout << T;
}
示例2: compute
void FlipGraph::compute(int n) {
graph_.clear();
int count = 0;
std::queue<std::pair<Triangulation *, int> > queue;
std::map<Code, int> indices;
// build canonical triangulation on n vertices
Triangulation *triangulation = new Triangulation(n);
Code *code = new Code(*triangulation);
// add canonical triangulation
int index = count++;
indices[*code] = 0;
graph_.push_back(std::vector<int>());
codes_.push_back(*code);
queue.push(std::make_pair(triangulation, index));
delete code;
// explore flip graph_ using a bfs
while (!queue.empty()) {
// get current triangulation
triangulation = queue.front().first;
index = queue.front().second;
queue.pop();
// loop through neighboring triangulations
int m = triangulation->size();
for (int i = 0; i < m; ++i) {
Halfedge *halfedge = triangulation->halfedge(i);
if (triangulation->is_representative(halfedge) && triangulation->is_flippable(halfedge)) {
triangulation->flip(halfedge);
Code triangulation_code(*triangulation);
int other_index = 0;
if (indices.count(triangulation_code) == 0) {
// add newly discovered triangulation
other_index = count++;
indices[triangulation_code] = other_index;
graph_.push_back(std::vector<int>());
codes_.push_back(triangulation_code);
queue.push(std::make_pair(new Triangulation(*triangulation), other_index));
} else {
// get index of triangulation
other_index = indices[triangulation_code];
}
// add edge if not already present
if (std::count(graph_[index].begin(), graph_[index].end(), other_index) == 0
&& index != other_index) {
graph_[index].push_back(other_index);
}
// note: after two flips the halfedge and its twin are swapped
// all other edges stay in place. this is crucial since
// we loop over all edges.
triangulation->flip(halfedge);
}
}
delete triangulation;
}
}