Example #1
0
 def chop(self,layerHeight):
     #This is chunky and bad. Needs to be done much more intelligently for anything beyond proof of concept. The number of layers calculation sucks.
     #Returns an ordered list of layers. Each layer consists of a list of edges which represent the intersection of self with the plane z=(layer #-1/2) * layerHeight. The first item in each layer is a point inside the mesh.
     height = self.region[0][2]-self.region[1][2]
     layers= []
     for layer in range(int(sp.floor(height/layerHeight))):
         #Adding 0.5*layerHeight to height of cutting plane so that the plane will be as representative as possible of the general layer volume.
         cuttingPlane = Basics.plane(sp.array([0,0,(layer+0.5)*layerHeight]),sp.array([[0,0,1],[0,0,0]]))
         edges = []
         for triangle in self.tris:
             intersect = triangle.plane_intersect(cuttingPlane)
             if intersect[1]==2:
                 edges.append(intersect[0])
         layers.append(layerClass.layer(edges,layerHeight,self))
     return layers
Example #2
0
 def chop(self, layerHeight):
     #This is chunky and bad. Needs to be done much more intelligently for anything beyond proof of concept. The number of layers calculation sucks.
     #Returns an ordered list of layers. Each layer consists of a list of edges which represent the intersection of self with the plane z=(layer #-1/2) * layerHeight. The first item in each layer is a point inside the mesh.
     height = self.region[0][2] - self.region[1][2]
     layers = []
     for layer in range(int(sp.floor(height / layerHeight))):
         #Adding 0.5*layerHeight to height of cutting plane so that the plane will be as representative as possible of the general layer volume.
         cuttingPlane = Basics.plane(
             sp.array([0, 0, (layer + 0.5) * layerHeight]),
             sp.array([[0, 0, 1], [0, 0, 0]]))
         edges = []
         for triangle in self.tris:
             intersect = triangle.plane_intersect(cuttingPlane)
             if intersect[1] == 2:
                 edges.append(intersect[0])
         layers.append(layerClass.layer(edges, layerHeight, self))
     return layers