Пример #1
0
 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()))
Пример #2
0
    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)")
Пример #3
0
for e in t.all_edges():
    if not t.is_infinite(e):
        print(t.segment(e))
    else:
        print("infinite edge")

for e in lst:
    print(e)

print("Try point range insertion")
t.insert(lst)

edges = []

for v in t.finite_vertices():
    t.incident_constraints(v, edges)

rf = Ref_Constrained_Delaunay_triangulation_plus_2_Face_handle()
ri = Ref_int()
t.is_edge(edges[0][0].vertex(t.cw(edges[0][1])),
          edges[0][0].vertex(t.ccw(edges[0][1])), rf, ri)
assert (rf.object() == edges[0][0]
        or rf.object() == edges[0][0].neighbor(edges[1]))

print("Nb incident constraints ", len(edges))

print(t.number_of_vertices())

for v in t.finite_vertices():
    print(v.point())
T = Delaunay_triangulation_3(L)

n = T.number_of_vertices()

V = []
V.append(Point_3(0, 0, 1))
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)
T=Delaunay_triangulation_3(L)

n=T.number_of_vertices()

V=[]
V.append( Point_3(0,0,1) )
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)