示例#1
0
void Triangulation::calculate_boundaries()
{
    _VERBOSE("Triangulation::calculate_boundaries");

    get_neighbors();  // Ensure _neighbors has been created.

    // Create set of all boundary TriEdges, which are those which do not
    // have a neighbor triangle.
    typedef std::set<TriEdge> BoundaryEdges;
    BoundaryEdges boundary_edges;
    for (int tri = 0; tri < _ntri; ++tri) {
        if (!is_masked(tri)) {
            for (int edge = 0; edge < 3; ++edge) {
                if (get_neighbor(tri, edge) == -1) {
                    boundary_edges.insert(TriEdge(tri, edge));
                }
            }
        }
    }

    // Take any boundary edge and follow the boundary until return to start
    // point, removing edges from boundary_edges as they are used.  At the same
    // time, initialise the _tri_edge_to_boundary_map.
    while (!boundary_edges.empty()) {
        // Start of new boundary.
        BoundaryEdges::iterator it = boundary_edges.begin();
        int tri = it->tri;
        int edge = it->edge;
        _boundaries.push_back(Boundary());
        Boundary& boundary = _boundaries.back();

        while (true) {
            boundary.push_back(TriEdge(tri, edge));
            boundary_edges.erase(it);
            _tri_edge_to_boundary_map[TriEdge(tri, edge)] =
                BoundaryEdge(_boundaries.size()-1, boundary.size()-1);

            // Move to next edge of current triangle.
            edge = (edge+1) % 3;

            // Find start point index of boundary edge.
            int point = get_triangle_point(tri, edge);

            // Find next TriEdge by traversing neighbors until find one
            // without a neighbor.
            while (get_neighbor(tri, edge) != -1) {
                tri = get_neighbor(tri, edge);
                edge = get_edge_in_triangle(tri, point);
            }

            if (TriEdge(tri,edge) == boundary.front())
                break;  // Reached beginning of this boundary, so finished it.
            else
                it = boundary_edges.find(TriEdge(tri, edge));
        }
    }
}
示例#2
0
  BOOL Close()
  {
    while (true){
      //Find an open boundary and close it by a new facet.
      cHALF_EDGE *boundaryHalfEdge = BoundaryEdge();
      
      if(boundaryHalfEdge == NULL)
	break;
      
      if (!CloseHole(boundaryHalfEdge))
	return false;
    }

    return true;
  }
示例#3
0
  INT BoundaryLength() {
    cHALF_EDGE *boundaryEdge = BoundaryEdge();

    INT length = 0;
    if(boundaryEdge) {
      cHALF_EDGE *loopingHe = boundaryEdge;

      do {
	length++;
	loopingHe = loopingHe->Next();
      } while(boundaryEdge != loopingHe);
    }

    return length;
  }
示例#4
0
 BOOL IsClosed() {
   return BoundaryEdge() ? false : true ;
 }