def half_edge_from_vertices_pair(self, va, vb): """ Make a CGAL half edge (Face_handle, index) from a pair of pair of vertices handles """ # fh and i are output arguments a la C++ fh = Ref_Face_handle() i = Ref_int() is_edge = self.cdt.is_edge(va, vb, fh, i) if is_edge: return (fh.object(), i.object()) else: raise ValueError("This is not an edge (%s, %s)" % (va.point(), vb.point()))
def locate_point(self, p, face_hint=None): """Locate a point in the triangulation and return a pair whose first element is the finite face handle of a face on which the point lies and the second element a complementary information : * if the point is out of the convex hull of the triangulation, the first face handle is None and the second if the witness infinite face handle return by CGAL locate method. * if the point lies within the face, the second element is None * if the point is on an edge, then the second element is the index of the edge and thus the returned (face _andle, index) forms an half-edge representation * if the point is a vertex the second element is its vertex handle An optional Face_handle can be passed as the face_hint argument. It can be used to make the search in the triangulation start from the given face (cf CGAL doc for CDT::locate(...)). """ face_hint = face_hint or Face_handle() p = to_cgal_point(p) locate_type = Ref_locate_type() index = Ref_int() face_handle = self.cdt.locate(p, locate_type, index, face_hint) locate_type = locate_type.object() if locate_type == OUTSIDE_CONVEX_HULL: return None, face_handle elif locate_type == FACE: return face_handle, None elif locate_type == EDGE: return (face_handle, index.object()) elif locate_type == VERTEX: return face_handle, face_handle.vertex(index.object()) else: assert locate_type == OUTSIDE_AFFINE_HULL raise InconsistentGeometricModel( "Degenerate triangulation (0D or 1D)")
V.append(Point_3(1, 1, 1)) V.append(Point_3(2, 2, 2)) n = n + T.insert(V) assert n == 6 assert T.is_valid() lt = Ref_Locate_type_3() li = Ref_int() lj = Ref_int() p = Point_3(0, 0, 0) c = T.locate(p, lt, li, lj) assert lt.object() == VERTEX assert c.vertex(li.object()).point() == p v = c.vertex((li.object()+1) & 3) nc = c.neighbor(li.object()) nli = Ref_int() assert nc.has_vertex(v, nli) T.write_to_file("output", 14) T1 = Delaunay_triangulation_3() T1.read_from_file("output") assert T1.is_valid() assert T1.number_of_vertices() == T.number_of_vertices()
V.append( Point_3(1,1,1) ) V.append( Point_3(2,2,2) ) n = n + T.insert(V) assert n==6 assert T.is_valid() lt=Ref_Locate_type_3() li=Ref_int() lj=Ref_int() p=Point_3(0,0,0) c = T.locate(p, lt, li, lj) assert lt.object() == VERTEX assert c.vertex(li.object()).point() == p v = c.vertex( (li.object()+1)&3 ) nc = c.neighbor(li.object()) nli=Ref_int() assert nc.has_vertex( v, nli ) T.write_to_file("output",14) T1 = Delaunay_triangulation_3() T1.read_from_file("output") assert T1.is_valid() assert T1.number_of_vertices() == T.number_of_vertices()