Beispiel #1
0
def test_triangulation():

    #random points on the sphere
    points = util.normalize(np.random.randn(10000,3))

    #build curve. add sharp convex corners, as well as additional cuts
    N = 267#9
    radius = np.cos( np.linspace(0,np.pi*2*12,N, False)) +1.1
    curve = np.array([(np.cos(a)*r,np.sin(a)*r,1) for a,r in zip( np.linspace(0,np.pi*2,N, endpoint=False), radius)])
    curve = np.append(curve, [[1,0,-4],[-1,0,-4]], axis=0)      #add bottom slit
    curve = util.normalize(curve)
    curve = cg.Curve(curve)
#    print curve

    #do triangulation
    mesh, curve = cg.triangulate(points, curve)
    #add partitioning of points here too?
    partitions = mesh.partition(curve)
Beispiel #2
0
    def partition(self):
        """
        take a datamodel, and subdivide it into surface meshes, according to a list of boundary curves
        take standard boundary prop for now
        """
##        level = 7
##        from . import multicomplex
##        hierarchy = multicomplex.generate(self.group, level)
        hierarchy = self.hierarchy
        complex = hierarchy[-1]

        #concat all curves
        curve = [cg.Curve(transform)
                 for e in self.edges if e.boundary
                 for mirrors in e.instantiate()
                 for transform in mirrors]
        curve = reduce(lambda x,y: x.merge(y), curve)

        #instantiate a geometry
        vertices = complex.geometry.generate_vertices(self.group)
        # triangulate
        mesh, curve = cg.triangulate(vertices, curve)
        # return partitions
        return mesh.partition(curve)