|
在DelaunayTriangulator.cpp里 有如下代码- // begin triangulation
- GLuint pidx = 0;
- osg::Vec3Array::const_iterator i;
-
- OSG_INFO << "DelaunayTriangulator: triangulating vertex grid (" << (points->size()-3) <<" points)\n";
- for (i=points->begin(); i!=points->end(); ++i, ++pidx)
- {
- // don't process supertriangle vertices
- if (pidx > last_valid_index) break;
- Edge_set edges;
- // iterate through triangles
- Triangle_list::iterator j, next_j;
- for (j=triangles.begin(); j!=triangles.end(); j = next_j)
- {
- next_j = j;
- ++next_j;
- // get the circumcircle (x,y centre & radius)
- osg::Vec3 cc = j->get_circumcircle();
- // OPTIMIZATION: since points are pre-sorted by the X component,
- // check whether we can discard this triangle for future operations
- float xdist = i->x() - cc.x();
- // this is where the circumcircles radius rather than R^2 is faster.
- // original code used r^2 and needed to test xdist*xdist>cc.z && i->x()>cc.x().
- if ((xdist ) > cc.z() )
- {
- discarded_tris.push_back(*j); // these are not needed for further tests as no more
- // points will ever lie inside this triangle.
- triangles.erase(j);
- }
- else
- {
- // if the point lies in the triangle's circumcircle then add
- // its edges to the edge list and remove the triangle
- if (point_in_circle(*i, cc))
- {
- for (int ei=0; ei<3; ++ei)
- {
- std::pair<Edge_set::iterator, bool> result = edges.insert(j->get_edge(ei));
- if (!result.second)
- {
- // cast away constness of a set element, which is
- // safe in this case since the set_duplicate is
- // not used as part of the Less operator.
- Edge& edge = const_cast<Edge&>(*(result.first));
- // not clear why this change is needed? But prevents removal of twice referenced edges??
- // edge.set_duplicate(true);
- edge.set_duplicate(!edge.get_duplicate());
- }
- }
- triangles.erase(j);
- }
- //add my own code for remove the triangles where at least one edge is above a threshold
- }
-
- }
复制代码 我想在//add my own code for remove the triangles where at least one edge is above a threshold 这里添加一些处理 就是去掉那些边长大于一个阈值的三角形 但是不知道他的数据结构是什么? 应该去哪里看? 或者有知道的告诉下 怎么获得三角形的边长?感激不尽! |
|