from CGAL.CGAL_HalfedgeDS import HalfedgeDS
from CGAL.CGAL_HalfedgeDS import HalfedgeDS_decorator
from CGAL.CGAL_HalfedgeDS import HDS_Halfedge_handle


hds = HalfedgeDS()
decorator = HalfedgeDS_decorator(hds)
decorator.create_loop()
decorator.create_segment()
assert decorator.is_valid()

n = 0
for h in hds.halfedges():
  n+=1

assert n == 4
示例#2
0
# declare a modifier interfacing the incremental_builder
m = HalfedgeDS_modifier()

# define a triangle
m.begin_surface(3, 1)
m.add_vertex(Point_2(0, 0))
m.add_vertex(Point_2(0, 1))
m.add_vertex(Point_2(1, 0.5))
m.begin_facet()
m.add_vertex_to_facet(0)
m.add_vertex_to_facet(1)
m.add_vertex_to_facet(2)
m.end_facet()

hds = HalfedgeDS()
# create the triangle in P
hds.delegate(m)
print("(v,f,e) = ", hds.size_of_vertices(), hds.size_of_faces(),
      divmod(hds.size_of_halfedges(), 2)[0])

# clear the modifier
m.clear()

# define another triangle, reusing vertices in the polyhedron
m.begin_surface(1, 1, 0, ABSOLUTE_INDEXING)
m.add_vertex(Point_2(-1, 0.5))
m.begin_facet()
m.add_vertex_to_facet(1)
m.add_vertex_to_facet(0)
m.add_vertex_to_facet(3)
#declare a modifier interfacing the incremental_builder
m=HalfedgeDS_modifier()

#define a triangle
m.begin_surface(3,1)
m.add_vertex(Point_2(0,0))
m.add_vertex(Point_2(0,1))
m.add_vertex(Point_2(1,0.5))
m.begin_facet()
m.add_vertex_to_facet(0)
m.add_vertex_to_facet(1)
m.add_vertex_to_facet(2)
m.end_facet()


hds=HalfedgeDS()
#create the triangle in P
hds.delegate(m)
print "(v,f,e) = ", hds.size_of_vertices(), hds.size_of_faces(), hds.size_of_halfedges()/2

#clear the modifier
m.clear()

#define another triangle, reusing vertices in the polyhedron
m.begin_surface(1,1,0,ABSOLUTE_INDEXING)
m.add_vertex(Point_2(-1,0.5))
m.begin_facet()
m.add_vertex_to_facet(1)
m.add_vertex_to_facet(0)
m.add_vertex_to_facet(3)
m.end_facet()
from CGAL.CGAL_HalfedgeDS import HalfedgeDS
from CGAL.CGAL_HalfedgeDS import HalfedgeDS_decorator
from CGAL.CGAL_HalfedgeDS import HDS_Halfedge_handle

hds = HalfedgeDS()
decorator = HalfedgeDS_decorator(hds)
decorator.create_loop()
decorator.create_segment()
assert decorator.is_valid()

n = 0
for h in hds.halfedges():
    n += 1

assert n == 4
#declare a modifier interfacing the incremental_builder
m=HalfedgeDS_modifier()

#define a triangle
m.begin_surface(3,1)
m.add_vertex(Point_2(0,0))
m.add_vertex(Point_2(0,1))
m.add_vertex(Point_2(1,0.5))
m.begin_facet()
m.add_vertex_to_facet(0)
m.add_vertex_to_facet(1)
m.add_vertex_to_facet(2)
m.end_facet()


hds=HalfedgeDS()
#create the triangle in P
hds.delegate(m)
print("(v,f,e) = ", hds.size_of_vertices(), hds.size_of_faces(), divmod(hds.size_of_halfedges(),2)[0])

#clear the modifier
m.clear()

#define another triangle, reusing vertices in the polyhedron
m.begin_surface(1,1,0,ABSOLUTE_INDEXING)
m.add_vertex(Point_2(-1,0.5))
m.begin_facet()
m.add_vertex_to_facet(1)
m.add_vertex_to_facet(0)
m.add_vertex_to_facet(3)
m.end_facet()