### GEOM component ### import GEOM import geompy import math import SALOMEDS Lplq = 500. lplq = 100. lfin = 20. geompy.init_geom(theStudy) O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) Sommet_1 = geompy.MakeVertex(0, 0, 0) Sommet_2 = geompy.MakeVertex(Lplq, 0, 0) Sommet_3 = geompy.MakeVertex(Lplq, lfin, 0) Sommet_4 = geompy.MakeVertex(Lplq, lplq, 0) Sommet_5 = geompy.MakeVertex(0, lplq, 0) Sommet_6 = geompy.MakeVertex(0, lfin, 0) Ligne_1 = geompy.MakeLineTwoPnt(Sommet_1, Sommet_2) Ligne_2 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_3) Ligne_3 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_6) Ligne_4 = geompy.MakeLineTwoPnt(Sommet_1, Sommet_6) Ligne_5 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4) Ligne_6 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_5)
def generateFilmGeometry(self): if self.percentageCoverage < 0: print "Error: Cannot compute negative coverage percentages!!!" raise Exception elif self.percentageCoverage < 100: theta = (math.pi) * float(self.percentageCoverage / 100) zetha = theta / 2 + self.filmOrient[0] - (math.pi) / 2 gamma = self.filmOrient[0] - theta / 2 print theta, zetha, gamma arc1Pt1 = [ -math.sin(zetha) * self.radius + self.position[0], math.cos(zetha) * self.radius + self.position[1], self.position[2] ] arc1Pt2 = [ math.sin(gamma) * self.radius + self.position[0], math.cos(gamma) * self.radius + self.position[1], self.position[2] ] arc2Pt1 = [ arc1Pt1[0] - math.sin(zetha) * self.filmThickness, arc1Pt1[1] + math.cos(zetha) * self.filmThickness, arc1Pt1[2] ] arc2Pt2 = [ arc1Pt2[0] + math.sin(gamma) * self.filmThickness, arc1Pt2[1] + math.cos(gamma) * self.filmThickness, arc1Pt2[2] ] circleCentre = geompy.MakeVertex(self.position[0], self.position[1], self.position[2]) arc1V1 = geompy.MakeVertex(arc1Pt1[0], arc1Pt1[1], arc1Pt1[2]) arc1V2 = geompy.MakeVertex(arc1Pt2[0], arc1Pt2[1], arc1Pt2[2]) arc2V1 = geompy.MakeVertex(arc2Pt1[0], arc2Pt1[1], arc2Pt1[2]) arc2V2 = geompy.MakeVertex(arc2Pt2[0], arc2Pt2[1], arc2Pt2[2]) print arc1Pt1, arc1Pt2, arc2Pt1, arc2Pt2 arc1 = geompy.MakeArcCenter(circleCentre, arc1V1, arc1V2) arc2 = geompy.MakeArcCenter(circleCentre, arc2V1, arc2V2) line1 = geompy.MakeLineTwoPnt(arc1V1, arc2V1) line2 = geompy.MakeLineTwoPnt(arc1V2, arc2V2) face1 = geompy.MakeFaceWires([arc1, arc2, line1, line2], 1) circleVector = geompy.MakeVectorDXDYDZ(self.filmOrient[0], self.filmOrient[1], self.filmOrient[2]) circle1 = geompy.MakeCircle(circleCentre, circleVector, self.radius) self.__ionomerPipe = geompy.MakePipe(face1, circle1) elif self.percentageCoverage == 100: circleCentre = geompy.MakeVertex(self.position[0], self.position[1], self.position[2]) circle1 = geompy.MakeCircle(circleCentre, None, self.radius) circle2 = geompy.MakeCircle(circleCentre, None, self.radius + self.filmThickness) face1 = geompy.MakeFaceWires([circle1, circle2], 1) vector1 = geompy.MakeVectorDXDYDZ(0, 1, 0) circle3 = geompy.MakeCircle(circleCentre, vector1, 1) self.__ionomerPipe = geompy.MakePipe(face1, circle3)
def RebuildData(theStudy): geompy.init_geom(theStudy) global Edge_1, Edge_2, Vertex_3, Revolution_1, Vertex_5, Vertex_4, Vertex_6, Face_1, Cone_1, Edge_5, Edge_3, Cylinder_1, Edge_4, Translation_1, Y, Vertex_2, Common_1, Cut_1, Compound_1, Vector_1, Fillet_1, X, Box_1, Rotation_1, Partition_1, Cone_1_edge_7, Torus_1, Vertex_1, Circle_1 Vertex_1 = geompy.MakeVertex(200, 200, 0) Vertex_2 = geompy.MakeVertexWithRef(Vertex_1, 0, 0, 200) Vector_1 = geompy.MakeVector(Vertex_1, Vertex_2) Cone_1 = geompy.MakeConeR1R2H(100, 0, 300) Cylinder_1 = geompy.MakeCylinder(Vertex_2, Vector_1, 100, 100) geomObj_1 = geompy.GetSubShape(Cone_1, [7]) Circle_1 = geompy.MakeCircle(Vertex_1, Vector_1, 100) Cone_1_edge_7 = geompy.GetSubShape(Cone_1, [7]) Revolution_1 = geompy.MakeRevolution2Ways(Circle_1, Cone_1_edge_7, 45*math.pi/180.0) Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) Torus_1 = geompy.MakeTorusRR(200, 75) Common_1 = geompy.MakeCommon(Torus_1, Box_1) Cut_1 = geompy.MakeCut(Torus_1, Box_1) Translation_1 = geompy.MakeTranslation(Torus_1, 190, 190, 0) Y = geompy.MakeVectorDXDYDZ(0, 100, 0) X = geompy.MakeVectorDXDYDZ(100, 0, 0) Rotation_1 = geompy.MakeRotation(Translation_1, Y, -90*math.pi/180.0) Compound_1 = geompy.MakeCompound([Translation_1, Torus_1, Rotation_1]) Fillet_1 = geompy.MakeFilletAll(Box_1, 35) Vertex_3 = geompy.MakeVertex(0, 0, 0) Vertex_4 = geompy.MakeVertex(0, 0, 200) Vertex_5 = geompy.MakeVertex(200, 0, 200) Vertex_6 = geompy.MakeVertex(200, 0, 0) Edge_1 = geompy.MakeEdge(Vertex_3, Vertex_4) Edge_2 = geompy.MakeEdge(Vertex_4, Vertex_5) Edge_3 = geompy.MakeEdge(Vertex_5, Vertex_6) Edge_4 = geompy.MakeEdge(Vertex_6, Vertex_3) Face_1 = geompy.MakeFaceWires([Edge_1, Edge_2, Edge_3, Edge_4], 1) Edge_5 = geompy.MakeEdge(Vertex_3, Vertex_5) Partition_1 = geompy.MakePartition([Face_1], [Edge_5], [], [], geompy.ShapeType["FACE"], 0, [], 0) geompy.addToStudy( Vertex_1, "Vertex_1" ) geompy.addToStudy( Vertex_2, "Vertex_2" ) geompy.addToStudy( Vector_1, "Vector_1" ) geompy.addToStudy( Cone_1, "Cone_1" ) geompy.addToStudy( Cylinder_1, "Cylinder_1" ) geompy.addToStudy( Circle_1, "Circle_1" ) geompy.addToStudyInFather( Cone_1, Cone_1_edge_7, "Cone_1:edge_7" ) geompy.addToStudy( Revolution_1, "Revolution_1" ) geompy.addToStudy( Box_1, "Box_1" ) geompy.addToStudy( Torus_1, "Torus_1" ) geompy.addToStudy( Common_1, "Common_1" ) geompy.addToStudy( Cut_1, "Cut_1" ) geompy.addToStudy( Translation_1, "Translation_1" ) geompy.addToStudy( Y, "Y" ) geompy.addToStudy( X, "X" ) geompy.addToStudy( Rotation_1, "Rotation_1" ) geompy.addToStudy( Compound_1, "Compound_1" ) geompy.addToStudy( Fillet_1, "Fillet_1" ) geompy.addToStudy( Vertex_3, "Vertex_3" ) geompy.addToStudy( Vertex_4, "Vertex_4" ) geompy.addToStudy( Vertex_5, "Vertex_5" ) geompy.addToStudy( Vertex_6, "Vertex_6" ) geompy.addToStudy( Edge_1, "Edge_1" ) geompy.addToStudy( Edge_2, "Edge_2" ) geompy.addToStudy( Edge_3, "Edge_3" ) geompy.addToStudy( Edge_4, "Edge_4" ) geompy.addToStudy( Face_1, "Face_1" ) geompy.addToStudy( Edge_5, "Edge_5" ) geompy.addToStudy( Partition_1, "Partition_1" ) ### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters(theStudy.GetModuleParameters("Interface Applicative", "GEOM", 1)) #Set up entries: # set up entry GEOM_11 (Cut_1) parameters ipar.setParameter("GEOM_11", "OCCViewer_0_Visibility", "On") ipar.setParameter("GEOM_11", "OCCViewer_0_DisplayMode", "1") ipar.setParameter("GEOM_11", "OCCViewer_0_Transparency", "0") ipar.setParameter("GEOM_11", "OCCViewer_0_Isos", "1:1") pass
spiralStep = 20.0 # Step between two segments of spiral tubeRadius = 5.0 # tube radius nStepPoints = 10 # Number of interpolation points in spiral rotTolerance = 1.0E-6 # rot. tolerance # # directionLength = math.sqrt(spiralDirectionX * spiralDirectionX + spiralDirectionY * spiralDirectionY + spiralDirectionZ * spiralDirectionZ) normalSDX = spiralDirectionX / directionLength normalSDY = spiralDirectionY / directionLength normalSDZ = spiralDirectionZ / directionLength # #base elements # baseOX = geompy.MakeVectorDXDYDZ(1, 0, 0) baseOY = geompy.MakeVectorDXDYDZ(0, 1, 0) baseOZ = geompy.MakeVectorDXDYDZ(0, 0, 1) # startingPoint = geompy.MakeVertex(startX, startY, startZ) endingPoint = geompy.MakeVertexWithRef(startingPoint, normalSDX * spiralLength, normalSDY * spiralLength, normalSDZ * spiralLength) endingPoint0 = geompy.MakeVertexWithRef(startingPoint, 0, 0, spiralLength) baseDirectionVector = geompy.MakeVectorDXDYDZ(normalSDX * spiralLength, normalSDY * spiralLength, normalSDZ * spiralLength) realStartingPoint = geompy.MakeVertex(startX + spiralRadius, startY, startZ) startingVector = geompy.MakeVectorDXDYDZ(0, 1, 0) tubeCircle = geompy.MakeCircle(realStartingPoint, startingVector, tubeRadius)