From 6607008a46f7444e5b6cc0f12e5415e0fabde862 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 12 Nov 2007 10:03:58 +0000 Subject: [PATCH] PAL16842 (Genertion of groups when a mesh is transformed) add MakeGroups=False argument --- src/SMESH_SWIG/smeshDC.py | 122 +++++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 20 deletions(-) diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index aea2f0569..a50e23fdb 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -169,6 +169,13 @@ class smeshDC(SMESH._objref_SMESH_Gen): dirst = DirStruct(pnt) return dirst + ## Make DirStruct from a triplet + # @param x,y,z are vector components + # @return SMESH.DirStruct + def MakeDirStruct(x,y,z): + pnt = PointStruct(x,y,z) + return DirStruct(pnt) + ## Get AxisStruct from object # @param theObj is GEOM object(line or plane) # @return SMESH.AxisStruct @@ -1850,6 +1857,10 @@ class Mesh: def GetGroups(self): return self.mesh.GetGroups() + ## Get number of groups existing in the mesh + def NbGroups(self): + return self.mesh.NbGroups() + ## Get the list of names of groups existing in the mesh def GetGroupNames(self): groups = self.GetGroups() @@ -2539,12 +2550,17 @@ class Mesh: # @param AngleInRadians angle of Rotation # @param NbOfSteps number of steps # @param Tolerance tolerance - def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance): + # @param MakeGroups to generate new groups from existing ones + def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False): if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)): Axix = self.smeshpyD.GetAxisStruct(Axix) + if MakeGroups: + return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix, + AngleInRadians, NbOfSteps, Tolerance) self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance) + return [] ## Generate new elements by rotation of the elements of object around the axis # @param theObject object wich elements should be sweeped @@ -2552,21 +2568,30 @@ class Mesh: # @param AngleInRadians angle of Rotation # @param NbOfSteps number of steps # @param Tolerance tolerance - def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance): + # @param MakeGroups to generate new groups from existing ones + def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False): if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)): Axix = self.smeshpyD.GetAxisStruct(Axix) + if MakeGroups: + return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians, + NbOfSteps, Tolerance) self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance) + return [] ## Generate new elements by extrusion of the elements with given ids # @param IDsOfElements list of elements ids for extrusion # @param StepVector vector, defining the direction and value of extrusion # @param NbOfSteps the number of steps - def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps): + # @param MakeGroups to generate new groups from existing ones + def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False): if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + if MakeGroups: + return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps) self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps) + return [] ## Generate new elements by extrusion of the elements with given ids # @param IDsOfElements is ids of elements @@ -2575,37 +2600,55 @@ class Mesh: # @param ExtrFlags set flags for performing extrusion # @param SewTolerance uses for comparing locations of nodes if flag # EXTRUSION_FLAG_SEW is set - def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance): + # @param MakeGroups to generate new groups from existing ones + def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance, MakeGroups=False): if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) - self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance) + if MakeGroups: + return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps, + ExtrFlags, SewTolerance) + self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, + ExtrFlags, SewTolerance) + return [] ## Generate new elements by extrusion of the elements belong to object # @param theObject object wich elements should be processed # @param StepVector vector, defining the direction and value of extrusion # @param NbOfSteps the number of steps - def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps): + # @param MakeGroups to generate new groups from existing ones + def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False): if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + if MakeGroups: + return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps) + return [] ## Generate new elements by extrusion of the elements belong to object # @param theObject object wich elements should be processed # @param StepVector vector, defining the direction and value of extrusion # @param NbOfSteps the number of steps - def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps): + # @param MakeGroups to generate new groups from existing ones + def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + if MakeGroups: + return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps) + return [] ## Generate new elements by extrusion of the elements belong to object # @param theObject object wich elements should be processed # @param StepVector vector, defining the direction and value of extrusion # @param NbOfSteps the number of steps - def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps): + # @param MakeGroups to generate new groups from existing ones + def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + if MakeGroups: + return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps) + return [] ## Generate new elements by extrusion of the given elements # A path of extrusion must be a meshed edge. @@ -2618,16 +2661,22 @@ class Mesh: # @param HasRefPoint allows to use base point # @param RefPoint point around which the shape is rotated(the mass center of the shape by default). # User can specify any point as the Base Point and the shape will be rotated with respect to this point. + # @param MakeGroups to generate new groups from existing ones # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False): + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): RefPoint = self.smeshpyD.GetPointStruct(RefPoint) pass - return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint) + if MakeGroups: + return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh.GetMesh(), + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh.GetMesh(), PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, RefPoint) ## Generate new elements by extrusion of the elements belong to object # A path of extrusion must be a meshed edge. @@ -2640,13 +2689,20 @@ class Mesh: # @param HasRefPoint allows to use base point # @param RefPoint point around which the shape is rotated(the mass center of the shape by default). # User can specify any point as the Base Point and the shape will be rotated with respect to this point. + # @param MakeGroups to generate new groups from existing ones # @param LinearVariation makes compute rotation angles as linear variation of given Angles along path steps def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation=False): + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint, LinearVariation) + if MakeGroups: + return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh.GetMesh(), + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject(theObject, PathMesh.GetMesh(), PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) ## Symmetrical copy of mesh elements # @param IDsOfElements list of elements ids @@ -2654,12 +2710,16 @@ class Mesh: # @param theMirrorType is POINT, AXIS or PLANE # If the Mirror is geom object this parameter is unnecessary # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0) - def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0): + # @param MakeGroups to generate new groups from existing ones (if Copy) + def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False): if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + if Copy and MakeGroups: + return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType) self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy) + return [] ## Symmetrical copy of object # @param theObject mesh, submesh or group @@ -2667,50 +2727,72 @@ class Mesh: # @param theMirrorType is POINT, AXIS or PLANE # If the Mirror is geom object this parameter is unnecessary # @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0) - def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0): + # @param MakeGroups to generate new groups from existing ones (if Copy) + def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False): if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + if Copy and MakeGroups: + return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType) self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy) + return [] ## Translates the elements # @param IDsOfElements list of elements ids # @param Vector direction of translation(DirStruct or vector) # @param Copy allows to copy the translated elements - def Translate(self, IDsOfElements, Vector, Copy): + # @param MakeGroups to generate new groups from existing ones (if Copy) + def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False): if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + if Copy and MakeGroups: + return self.editor.TranslateMakeGroups(IDsOfElements, Vector) self.editor.Translate(IDsOfElements, Vector, Copy) + return [] ## Translates the object # @param theObject object to translate(mesh, submesh, or group) # @param Vector direction of translation(DirStruct or geom vector) # @param Copy allows to copy the translated elements - def TranslateObject(self, theObject, Vector, Copy): + # @param MakeGroups to generate new groups from existing ones (if Copy) + def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False): if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + if Copy and MakeGroups: + return self.editor.TranslateObjectMakeGroups(theObject, Vector) self.editor.TranslateObject(theObject, Vector, Copy) + return [] ## Rotates the elements # @param IDsOfElements list of elements ids # @param Axis axis of rotation(AxisStruct or geom line) # @param AngleInRadians angle of rotation(in radians) # @param Copy allows to copy the rotated elements - def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy): + # @param MakeGroups to generate new groups from existing ones (if Copy) + def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False): if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + if Copy and MakeGroups: + return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians) self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy) + return [] ## Rotates the object # @param theObject object to rotate(mesh, submesh, or group) # @param Axis axis of rotation(AxisStruct or geom line) # @param AngleInRadians angle of rotation(in radians) # @param Copy allows to copy the rotated elements - def RotateObject (self, theObject, Axis, AngleInRadians, Copy): + # @param MakeGroups to generate new groups from existing ones (if Copy) + def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False): + if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + if Copy and MakeGroups: + return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians) self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy) + return [] ## Find group of nodes close to each other within Tolerance. # @param Tolerance tolerance value -- 2.39.2