def addCube(faces, inradius, vertexes, xmlElement): """Add cube by inradius.""" square = [ complex(-inradius.x, -inradius.y), complex(inradius.x, -inradius.y), complex(inradius.x, inradius.y), complex(-inradius.x, inradius.y)] bottomTopSquare = triangle_mesh.getAddIndexedLoops(square, vertexes, [-inradius.z, inradius.z]) triangle_mesh.addPillarByLoops(faces, bottomTopSquare)
def addCube(elementNode, faces, inradius, vertexes): 'Add cube by inradius.' square = [ complex(-inradius.x, -inradius.y), complex(inradius.x, -inradius.y), complex(inradius.x, inradius.y), complex(-inradius.x, inradius.y)] bottomTopSquare = triangle_mesh.getAddIndexedLoops(square, vertexes, [-inradius.z, inradius.z]) triangle_mesh.addPillarByLoops(faces, bottomTopSquare)
def createShape(self): "Create the shape." square = [ complex( - self.inradius.x, - self.inradius.y ), complex( self.inradius.x, - self.inradius.y ), complex( self.inradius.x, self.inradius.y ), complex( - self.inradius.x, self.inradius.y ) ] bottomTopSquare = triangle_mesh.getAddIndexedLoops( square, self.vertexes, [ - self.inradius.z, self.inradius.z ] ) triangle_mesh.addPillarByLoops( self.faces, bottomTopSquare )
def createShape(self): "Create the shape." square = [ complex(-self.inradius.x, -self.inradius.y), complex(self.inradius.x, -self.inradius.y), complex(self.inradius.x, self.inradius.y), complex(-self.inradius.x, self.inradius.y) ] bottomTopSquare = triangle_mesh.getAddIndexedLoops( square, self.vertexes, [-self.inradius.z, self.inradius.z]) triangle_mesh.addPillarByLoops(self.faces, bottomTopSquare)
def addCylinder(faces, inradius, sides, topOverBottom, vertexes): 'Add cylinder by inradius.' polygonBottom = euclidean.getComplexPolygonByComplexRadius(complex(inradius.x, inradius.y), sides) polygonTop = polygonBottom if topOverBottom <= 0.0: polygonTop = [complex()] elif topOverBottom != 1.0: polygonTop = euclidean.getComplexPathByMultiplier(topOverBottom, polygonTop) bottomTopPolygon = [ triangle_mesh.getAddIndexedLoop(polygonBottom, vertexes, -inradius.z), triangle_mesh.getAddIndexedLoop(polygonTop, vertexes, inradius.z)] triangle_mesh.addPillarByLoops(faces, bottomTopPolygon)
def addSphere(faces, radius, vertexes, xmlElement): 'Add sphere by radius.' bottom = -radius.z sides = evaluate.getSidesMinimumThreeBasedOnPrecision(max(radius.x, radius.y, radius.z), xmlElement ) sphereSlices = max(sides / 2, 2) equator = euclidean.getComplexPolygonByComplexRadius(complex(radius.x, radius.y), sides) polygons = [triangle_mesh.getAddIndexedLoop([complex()], vertexes, bottom)] zIncrement = (radius.z + radius.z) / float(sphereSlices) z = bottom for sphereSlice in xrange(1, sphereSlices): z += zIncrement zPortion = abs(z) / radius.z multipliedPath = euclidean.getComplexPathByMultiplier(math.sqrt(1.0 - zPortion * zPortion), equator) polygons.append(triangle_mesh.getAddIndexedLoop(multipliedPath, vertexes, z)) polygons.append(triangle_mesh.getAddIndexedLoop([complex()], vertexes, radius.z)) triangle_mesh.addPillarByLoops(faces, polygons)