def createShape(self): "Create the shape." halfHeight = 0.5 * self.height polygonBottom = [] polygonTop = [] imaginaryRadius = self.radiusZ if self.radiusZ == None: imaginaryRadius = self.radiusY sides = max(int(evaluate.getSides(max(imaginaryRadius, self.radiusX), self.xmlElement)), 3) sideAngle = 2.0 * math.pi / float(sides) for side in xrange(sides): angle = float(side) * sideAngle unitComplex = euclidean.getWiddershinsUnitPolar(angle) pointBottom = complex(unitComplex.real * self.radiusX, unitComplex.imag * imaginaryRadius) polygonBottom.append(pointBottom) if self.topOverBottom > 0.0: polygonTop.append(pointBottom * self.topOverBottom) if self.topOverBottom <= 0.0: polygonTop.append(complex()) bottomTopPolygon = [ trianglemesh.getAddIndexedLoop(polygonBottom, self.vertices, -halfHeight), trianglemesh.getAddIndexedLoop(polygonTop, self.vertices, halfHeight), ] trianglemesh.addPillarFromConvexLoops(self.faces, bottomTopPolygon) if self.radiusZ != None: for vertex in self.vertices: oldY = vertex.y vertex.y = vertex.z vertex.z = oldY
def createShape( self ): "Create the shape." halfHeight = 0.5 * self.height polygonBottom = [] polygonTop = [] imaginaryRadius = self.radiusZ if self.radiusZ == None: imaginaryRadius = self.radiusY sides = max( int( evaluate.getSides( max( imaginaryRadius, self.radiusX ), self.xmlElement ) ), 3 ) sideAngle = 2.0 * math.pi / float( sides ) for side in xrange( sides ): angle = float( side ) * sideAngle unitComplex = euclidean.getWiddershinsUnitPolar( angle ) pointBottom = complex( unitComplex.real * self.radiusX, unitComplex.imag * imaginaryRadius ) polygonBottom.append( pointBottom ) if self.topOverBottom > 0.0: polygonTop.append( pointBottom * self.topOverBottom ) if self.topOverBottom <= 0.0: polygonTop.append( complex() ) bottomTopPolygon = [ trianglemesh.getAddIndexedLoop( polygonBottom, self.vertices, - halfHeight ), trianglemesh.getAddIndexedLoop( polygonTop, self.vertices, halfHeight ) ] trianglemesh.addPillarFromConvexLoops( self.faces, bottomTopPolygon ) if self.radiusZ != None: for vertex in self.vertices: oldY = vertex.y vertex.y = vertex.z vertex.z = oldY
def createShape(self): "Create the shape." polygonBottom = [] polygonTop = [] sides = evaluate.getSidesMinimumThreeBasedOnPrecision(max(self.inradius.x, self.inradius.y), self.xmlElement ) sideAngle = 2.0 * math.pi / sides for side in xrange(int(sides)): angle = float(side) * sideAngle unitComplex = euclidean.getWiddershinsUnitPolar(angle) pointBottom = complex(unitComplex.real * self.inradius.x, unitComplex.imag * self.inradius.y) polygonBottom.append(pointBottom) if self.topOverBottom > 0.0: polygonTop.append(pointBottom * self.topOverBottom) if self.topOverBottom <= 0.0: polygonTop.append(complex()) bottomTopPolygon = [ trianglemesh.getAddIndexedLoop(polygonBottom, self.vertexes, - self.inradius.z), trianglemesh.getAddIndexedLoop(polygonTop, self.vertexes, self.inradius.z)] trianglemesh.addPillarFromConvexLoops(self.faces, bottomTopPolygon)
def addCylinderByInradius(faces, inradius, topOverBottom, vertexes, xmlElement): 'Add cylinder by radius.' polygonBottom = [] polygonTop = [] sides = evaluate.getSidesMinimumThreeBasedOnPrecision(max(inradius.x, inradius.y), xmlElement ) sideAngle = 2.0 * math.pi / sides for side in xrange(int(sides)): angle = float(side) * sideAngle unitComplex = euclidean.getWiddershinsUnitPolar(angle) pointBottom = complex(unitComplex.real * inradius.x, unitComplex.imag * inradius.y) polygonBottom.append(pointBottom) if topOverBottom > 0.0: polygonTop.append(pointBottom * topOverBottom) if topOverBottom <= 0.0: polygonTop.append(complex()) bottomTopPolygon = [ trianglemesh.getAddIndexedLoop(polygonBottom, vertexes, -inradius.z), trianglemesh.getAddIndexedLoop(polygonTop, vertexes, inradius.z)] trianglemesh.addPillarByLoops(faces, bottomTopPolygon)
def addCylinderByInradius(faces, inradius, topOverBottom, vertexes, xmlElement): 'Add cylinder by radius.' polygonBottom = [] polygonTop = [] sides = evaluate.getSidesMinimumThreeBasedOnPrecision( max(inradius.x, inradius.y), xmlElement) sideAngle = 2.0 * math.pi / sides for side in xrange(int(sides)): angle = float(side) * sideAngle unitComplex = euclidean.getWiddershinsUnitPolar(angle) pointBottom = complex(unitComplex.real * inradius.x, unitComplex.imag * inradius.y) polygonBottom.append(pointBottom) if topOverBottom > 0.0: polygonTop.append(pointBottom * topOverBottom) if topOverBottom <= 0.0: polygonTop.append(complex()) bottomTopPolygon = [ trianglemesh.getAddIndexedLoop(polygonBottom, vertexes, -inradius.z), trianglemesh.getAddIndexedLoop(polygonTop, vertexes, inradius.z) ] trianglemesh.addPillarByLoops(faces, bottomTopPolygon)