from __future__ import print_function
from CGAL.CGAL_Polyhedron_3 import Polyhedron_modifier
from CGAL.CGAL_Polyhedron_3 import Polyhedron_3
from CGAL.CGAL_Polyhedron_3 import ABSOLUTE_INDEXING
from CGAL.CGAL_Kernel import Point_3

# declare a modifier interfacing the incremental_builder
m = Polyhedron_modifier()

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

P = Polyhedron_3()
# create the triangle in P
P.delegate(m)
print("(v,f,e) = ", P.size_of_vertices(), P.size_of_facets(),
      divmod(P.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)
示例#2
0
 def to_polyhedron(self):
     polyhedron_modifier = Polyhedron_modifier()
     polyhedron_modifier.begin_surface(len(self.vertices), len(self.faces))
     for vertex in self.vertices[1:]:
         polyhedron_modifier.add_vertex(Point_3(vertex[0], vertex[1], vertex[2]))
     for face in self.faces[1:]:
         polyhedron_modifier.begin_facet()
         for vertex in face:
             polyhedron_modifier.add_vertex_to_facet(vertex - 1)
         polyhedron_modifier.end_facet()
     polyhedron = Polyhedron_3()
     polyhedron.delegate(polyhedron_modifier)
     return polyhedron
from __future__ import print_function
from CGAL.CGAL_Polyhedron_3 import Polyhedron_modifier
from CGAL.CGAL_Polyhedron_3 import Polyhedron_3
from CGAL.CGAL_Polyhedron_3 import ABSOLUTE_INDEXING
from CGAL.CGAL_Kernel import Point_3

#declare a modifier interfacing the incremental_builder
m=Polyhedron_modifier()

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


P=Polyhedron_3()
#create the triangle in P
P.delegate(m)
print("(v,f,e) = ", P.size_of_vertices(), P.size_of_facets(), divmod(P.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)
示例#4
0
    def to_cgal(self):
        from CGAL.CGAL_Polyhedron_3 import Polyhedron_modifier
        from CGAL.CGAL_Polyhedron_3 import Polyhedron_3
        from CGAL.CGAL_Polyhedron_3 import ABSOLUTE_INDEXING
        from CGAL.CGAL_Kernel import Point_3

        # declare a modifier interfacing the incremental_builder
        m = Polyhedron_modifier()
        m.begin_surface(len(self.faces), len(self.triangles))
        for vertex in self.vertices.astype(np.float64):
            m.add_vertex(Point_3(*vertex))
        for face in self.faces:
            m.begin_facet()
            for vertex in face:
                m.add_vertex_to_facet(vertex)
            m.end_facet()
        m.end_surface()
        P = Polyhedron_3()
        P.delegate(m)

        # FIXME: need a lib where this works
        import CGAL.CGAL_Polygon_mesh_processing

        flist = [fh for fh in P.facets()]
        CGAL.CGAL_Polygon_mesh_processing.isotropic_remeshing(flist, 0.25, P)