X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG%2FsmeshBuilder.py;h=c6e1eabb45b8766ef572d75d31cc4f269217b336;hp=423d8542ef70df5728e5055e294a7f20e83ae275;hb=b22e182dd1a2c30be324b21074158390d00714b3;hpb=6fd64f7678b99d921aad3e227708c8700d389cb4 diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 423d8542e..c6e1eabb4 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -732,7 +732,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface, FT_BelongToCylinder, FT_LyingOnGeom]: - # Checks that Threshold is GEOM object + # Check that Threshold is GEOM object if isinstance(aThreshold, geomBuilder.GEOM._objref_GEOM_Object): aCriterion.ThresholdStr = GetName(aThreshold) aCriterion.ThresholdID = aThreshold.GetStudyEntry() @@ -745,21 +745,35 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): elif isinstance( aThreshold, str ): aCriterion.ThresholdStr = aThreshold else: - print "Error: The Threshold should be a shape." - return None + raise TypeError, "The Threshold should be a shape." if isinstance(UnaryOp,float): aCriterion.Tolerance = UnaryOp UnaryOp = FT_Undefined pass + elif CritType == FT_BelongToMeshGroup: + # Check that Threshold is a group + if isinstance(aThreshold, SMESH._objref_SMESH_GroupBase): + if aThreshold.GetType() != elementType: + raise ValueError, "Group type mismatches Element type" + aCriterion.ThresholdStr = aThreshold.GetName() + aCriterion.ThresholdID = salome.orb.object_to_string( aThreshold ) + study = self.GetCurrentStudy() + if study: + so = study.FindObjectIOR( aCriterion.ThresholdID ) + if so: + entry = so.GetID() + if entry: + aCriterion.ThresholdID = entry + else: + raise TypeError, "The Threshold should be a Mesh Group" elif CritType == FT_RangeOfIds: - # Checks that Threshold is string + # Check that Threshold is string if isinstance(aThreshold, str): aCriterion.ThresholdStr = aThreshold else: - print "Error: The Threshold should be a string." - return None + raise TypeError, "The Threshold should be a string." elif CritType == FT_CoplanarFaces: - # Checks the Threshold + # Check the Threshold if isinstance(aThreshold, int): aCriterion.ThresholdID = str(aThreshold) elif isinstance(aThreshold, str): @@ -768,10 +782,10 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold aCriterion.ThresholdID = aThreshold else: - raise ValueError,\ + raise TypeError,\ "The Threshold should be an ID of mesh face and not '%s'"%aThreshold elif CritType == FT_ConnectedElements: - # Checks the Threshold + # Check the Threshold if isinstance(aThreshold, geomBuilder.GEOM._objref_GEOM_Object): # shape aCriterion.ThresholdID = aThreshold.GetStudyEntry() if not aCriterion.ThresholdID: @@ -791,11 +805,11 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): else: aCriterion.ThresholdStr = aThreshold # hope that it's point coordinates else: - raise ValueError,\ + raise TypeError,\ "The Threshold should either a VERTEX, or a node ID, "\ "or a list of point coordinates and not '%s'"%aThreshold elif CritType == FT_ElemGeomType: - # Checks the Threshold + # Check the Threshold try: aCriterion.Threshold = self.EnumToLong(aThreshold) assert( aThreshold in SMESH.GeometryType._items ) @@ -803,12 +817,11 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): if isinstance(aThreshold, int): aCriterion.Threshold = aThreshold else: - print "Error: The Threshold should be an integer or SMESH.GeometryType." - return None + raise TypeError, "The Threshold should be an integer or SMESH.GeometryType." pass pass elif CritType == FT_EntityType: - # Checks the Threshold + # Check the Threshold try: aCriterion.Threshold = self.EnumToLong(aThreshold) assert( aThreshold in SMESH.EntityType._items ) @@ -816,18 +829,16 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): if isinstance(aThreshold, int): aCriterion.Threshold = aThreshold else: - print "Error: The Threshold should be an integer or SMESH.EntityType." - return None + raise TypeError, "The Threshold should be an integer or SMESH.EntityType." pass pass elif CritType == FT_GroupColor: - # Checks the Threshold + # Check the Threshold try: aCriterion.ThresholdStr = self.ColorToString(aThreshold) except: - print "Error: The threshold value should be of SALOMEDS.Color type" - return None + raise TypeError, "The threshold value should be of SALOMEDS.Color type" pass elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces, FT_LinearOrQuadratic, FT_BadOrientedVolume, @@ -845,7 +856,7 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen): aThreshold = float(aThreshold) aCriterion.Threshold = aThreshold except: - print "Error: The Threshold should be a number." + raise TypeError, "The Threshold should be a number." return None if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT: @@ -1247,7 +1258,6 @@ class Mesh: for attrName in dir(self): attr = getattr( self, attrName ) if isinstance( attr, algoCreator ): - #print "algoCreator ", attrName setattr( self, attrName, attr.copy( self )) pass pass @@ -2232,11 +2242,11 @@ class Mesh: def NbBiQuadQuadrangles(self): return self.mesh.NbBiQuadQuadrangles() - ## Returns the number of polygons in the mesh + ## Returns the number of polygons of given order in the mesh # @return an integer value # @ingroup l1_meshinfo - def NbPolygons(self): - return self.mesh.NbPolygons() + def NbPolygons(self, elementOrder = SMESH.ORDER_ANY): + return self.mesh.NbPolygons(elementOrder) ## Returns the number of volumes in the mesh # @return an integer value @@ -2357,7 +2367,7 @@ class Mesh: ## Returns the type of mesh element # @return the value from SMESH::ElementType enumeration # @ingroup l1_meshinfo - def GetElementType(self, id, iselem): + def GetElementType(self, id, iselem=True): return self.mesh.GetElementType(id, iselem) ## Returns the geometric type of mesh element @@ -2445,24 +2455,22 @@ class Mesh: def GetElementPosition(self,ElemID): return self.mesh.GetElementPosition(ElemID) - ## If the given element is a node, returns the ID of shape - # \n If there is no node for the given ID - returns -1 - # @return an integer value + ## Returns the ID of the shape, on which the given node was generated. + # @return an integer value > 0 or -1 if there is no node for the given + # ID or the node is not assigned to any geometry # @ingroup l1_meshinfo def GetShapeID(self, id): return self.mesh.GetShapeID(id) - ## Returns the ID of the result shape after - # FindShape() from SMESH_MeshEditor for the given element - # \n If there is no element for the given ID - returns -1 - # @return an integer value + ## Returns the ID of the shape, on which the given element was generated. + # @return an integer value > 0 or -1 if there is no element for the given + # ID or the element is not assigned to any geometry # @ingroup l1_meshinfo def GetShapeIDForElem(self,id): return self.mesh.GetShapeIDForElem(id) - ## Returns the number of nodes for the given element - # \n If there is no element for the given ID - returns -1 - # @return an integer value + ## Returns the number of nodes of the given element + # @return an integer value > 0 or -1 if there is no element for the given ID # @ingroup l1_meshinfo def GetElemNbNodes(self, id): return self.mesh.GetElemNbNodes(id) @@ -2488,7 +2496,7 @@ class Mesh: ## Returns true if the given node is the medium node in one of quadratic elements # @ingroup l1_meshinfo - def IsMediumNodeOfAnyElem(self, nodeID, elementType): + def IsMediumNodeOfAnyElem(self, nodeID, elementType = SMESH.ALL ): return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType) ## Returns the number of edges for the given element @@ -2746,6 +2754,14 @@ class Mesh: def AddPolygonalFace(self, IdsOfNodes): return self.editor.AddPolygonalFace(IdsOfNodes) + ## Adds a quadratic polygonal face to the mesh by the list of node IDs + # @param IdsOfNodes the list of node IDs for creation of the element; + # corner nodes follow first. + # @return the Id of the new face + # @ingroup l2_modif_add + def AddQuadPolygonalFace(self, IdsOfNodes): + return self.editor.AddQuadPolygonalFace(IdsOfNodes) + ## Creates both simple and quadratic volume (this is determined # by the number of given nodes). # @param IDsOfNodes the list of node IDs for creation of the element. @@ -3554,7 +3570,7 @@ class Mesh: faces = self._getIdSourceList( faces, SMESH.FACE, unRegister ) if isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object): - Axis = self.smeshpyD.GetDirStruct( Axis ) + Axis = self.smeshpyD.GetAxisStruct( Axis ) if isinstance( Axis, list ): Axis = SMESH.AxisStruct( *Axis ) @@ -3581,24 +3597,9 @@ class Mesh: # @ingroup l2_modif_extrurev def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False, TotalAngle=False): - unRegister = genObjUnRegister() - if IDsOfElements == []: - IDsOfElements = self.mesh - if IDsOfElements and \ - isinstance( IDsOfElements, list ) and \ - isinstance( IDsOfElements[0], int ): - IDsOfElements = self.GetIDSource( IDsOfElements, SMESH.ALL ) - unRegister.set( IDsOfElements ) - if isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - return self.editor.RotationSweepObjects([],[IDsOfElements],[IDsOfElements], Axis, - AngleInRadians, NbOfSteps, Tolerance, MakeGroups) + return self.RotationSweepObjects([], IDsOfElements, IDsOfElements, Axis, + AngleInRadians, NbOfSteps, Tolerance, + MakeGroups, TotalAngle) ## Generates new elements by rotation of the elements of object around the axis # @param theObject object which elements should be sweeped. @@ -3614,18 +3615,9 @@ class Mesh: # @ingroup l2_modif_extrurev def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False, TotalAngle=False): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - return self.editor.RotationSweepObjects([],[theObject],[theObject], Axis, - AngleInRadians, NbOfSteps, Tolerance ) + return self.RotationSweepObjects( [], theObject, theObject, Axis, + AngleInRadians, NbOfSteps, Tolerance, + MakeGroups, TotalAngle ) ## Generates new elements by rotation of the elements of object around the axis # @param theObject object which elements should be sweeped. @@ -3641,18 +3633,9 @@ class Mesh: # @ingroup l2_modif_extrurev def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False, TotalAngle=False): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - return self.editor.RotationSweepObjects([],[theObject],[], Axis, - AngleInRadians, NbOfSteps, Tolerance) + return self.RotationSweepObjects([],theObject,[], Axis, + AngleInRadians, NbOfSteps, Tolerance, + MakeGroups, TotalAngle) ## Generates new elements by rotation of the elements of object around the axis # @param theObject object which elements should be sweeped. @@ -3668,18 +3651,8 @@ class Mesh: # @ingroup l2_modif_extrurev def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False, TotalAngle=False): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - return self.editor.RotationSweepObjects([],[],[theObject], Axis, AngleInRadians, - NbOfSteps, Tolerance) + return self.RotationSweepObjects([],[],theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance, MakeGroups, TotalAngle) ## Generates new elements by extrusion of the given elements and nodes # @param nodes - nodes to extrude: a list including ids, groups, sub-meshes or a mesh @@ -3707,7 +3680,8 @@ class Mesh: Parameters = StepVector.PS.parameters + var_separator + Parameters self.mesh.SetParameters(Parameters) - return self.editor.ExtrusionSweepObjects( nodes, edges, faces, StepVector, NbOfSteps, MakeGroups) + return self.editor.ExtrusionSweepObjects( nodes, edges, faces, + StepVector, NbOfSteps, MakeGroups) ## Generates new elements by extrusion of the elements with given ids @@ -3721,25 +3695,10 @@ class Mesh: # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_extrurev def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False): - if IDsOfElements == []: - IDsOfElements = self.mesh - unRegister = genObjUnRegister() - if IDsOfElements and \ - isinstance( IDsOfElements, list ) and \ - isinstance( IDsOfElements[0], int ): - IDsOfElements = self.GetIDSource( IDsOfElements, SMESH.ALL ) - unRegister.set( IDsOfElements ) - if isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) n,e,f = [],[],[] - if IsNodes: n = [IDsOfElements] - else : e,f, = [IDsOfElements],[IDsOfElements] - return self.editor.ExtrusionSweepObjects(n,e,f, StepVector, NbOfSteps, MakeGroups) + if IsNodes: n = IDsOfElements + else : e,f, = IDsOfElements,IDsOfElements + return self.ExtrusionSweepObjects(n,e,f, StepVector, NbOfSteps, MakeGroups) ## Generates new elements by extrusion along the normal to a discretized surface or wire # @param Elements elements to extrude - a list including ids, groups, sub-meshes or a mesh @@ -3772,12 +3731,12 @@ class Mesh: if isinstance( Elements[0], int ): Elements = self.GetIDSource( Elements, SMESH.ALL ) unRegister.set( Elements ) - else: + if not isinstance( Elements, list ): Elements = [ Elements ] StepSize,NbOfSteps,Parameters,hasVars = ParseParameters(StepSize,NbOfSteps) self.mesh.SetParameters(Parameters) return self.editor.ExtrusionByNormal(Elements, StepSize, NbOfSteps, - UseInputElemsOnly, ByAverageNormal, MakeGroups, Dim) + ByAverageNormal, UseInputElemsOnly, MakeGroups, Dim) ## Generates new elements by extrusion of the elements which belong to the object # @param theObject the object which elements should be processed. @@ -3791,19 +3750,10 @@ class Mesh: # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_extrurev def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) n,e,f = [],[],[] - if IsNodes: n = [theObject] - else : e,f, = [theObject],[theObject] - return self.editor.ExtrusionSweepObjects(n,e,f, StepVector, NbOfSteps, MakeGroups) + if IsNodes: n = theObject + else : e,f, = theObject,theObject + return self.ExtrusionSweepObjects(n,e,f, StepVector, NbOfSteps, MakeGroups) ## Generates new elements by extrusion of the elements which belong to the object # @param theObject object which elements should be processed. @@ -3816,17 +3766,7 @@ class Mesh: # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_extrurev def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object)): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - return self.editor.ExtrusionSweepObjects([],[theObject],[], - StepVector, NbOfSteps, MakeGroups) + return self.ExtrusionSweepObjects([],theObject,[], StepVector, NbOfSteps, MakeGroups) ## Generates new elements by extrusion of the elements which belong to the object # @param theObject object which elements should be processed. @@ -3839,17 +3779,7 @@ class Mesh: # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_extrurev def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object)): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - return self.editor.ExtrusionSweepObjects([],[],[theObject], - StepVector, NbOfSteps, MakeGroups) + return self.ExtrusionSweepObjects([],[],theObject, StepVector, NbOfSteps, MakeGroups) ## Generates new elements by extrusion of the elements with given ids # @param IDsOfElements is ids of elements @@ -3937,41 +3867,15 @@ class Mesh: def ExtrusionAlongPathX(self, Base, Path, NodeStart, HasAngles, Angles, LinearVariation, HasRefPoint, RefPoint, MakeGroups, ElemType): - if isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - pass - elif isinstance( RefPoint, list ): - RefPoint = PointStruct(*RefPoint) - pass - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - - if isinstance(Path, Mesh): Path = Path.GetMesh() - - unRegister = genObjUnRegister() - if isinstance(Base, list): - if Base: - Base = self.GetIDSource( Base, ElemType ) - unRegister.set( Base ) - else: - Base = self.mesh - else: - if isinstance(Base, Mesh): - Base = Base.GetMesh() - if isinstance(Base, SMESH._objref_SMESH_IDSource): - n,e,f = [],[],[] - if ElemType == SMESH.NODE: n = [Base] - if ElemType == SMESH.EDGE: e = [Base] - if ElemType == SMESH.FACE: f = [Base] - gr,er = self.editor.ExtrusionAlongPathObjects(n,e,f, Path, None, NodeStart, - HasAngles, Angles, LinearVariation, - HasRefPoint, RefPoint, MakeGroups) - if MakeGroups: return gr,er - return er - else: - raise RuntimeError, "Invalid Base for ExtrusionAlongPathX" - + n,e,f = [],[],[] + if ElemType == SMESH.NODE: n = Base + if ElemType == SMESH.EDGE: e = Base + if ElemType == SMESH.FACE: f = Base + gr,er = self.ExtrusionAlongPathObjects(n,e,f, Path, None, NodeStart, + HasAngles, Angles, LinearVariation, + HasRefPoint, RefPoint, MakeGroups) + if MakeGroups: return gr,er + return er ## Generates new elements by extrusion of the given elements # The path of extrusion must be a meshed edge. @@ -3994,21 +3898,11 @@ class Mesh: def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart, HasAngles, Angles, HasRefPoint, RefPoint, MakeGroups=False, LinearVariation=False): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - pass - if isinstance( PathMesh, Mesh ): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - n,e,f = [],[IDsOfElements],[IDsOfElements] - gr,er = self.editor.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, - NodeStart, HasAngles, Angles, - LinearVariation, - HasRefPoint, RefPoint, MakeGroups) + n,e,f = [],IDsOfElements,IDsOfElements + gr,er = self.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, + NodeStart, HasAngles, Angles, + LinearVariation, + HasRefPoint, RefPoint, MakeGroups) if MakeGroups: return gr,er return er @@ -4034,19 +3928,10 @@ class Mesh: def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart, HasAngles, Angles, HasRefPoint, RefPoint, MakeGroups=False, LinearVariation=False): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - if isinstance( PathMesh, Mesh ): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - n,e,f = [],[theObject],[theObject] - gr,er = self.editor.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, NodeStart, - HasAngles, Angles, LinearVariation, - HasRefPoint, RefPoint, MakeGroups) + n,e,f = [],theObject,theObject + gr,er = self.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, NodeStart, + HasAngles, Angles, LinearVariation, + HasRefPoint, RefPoint, MakeGroups) if MakeGroups: return gr,er return er @@ -4072,19 +3957,10 @@ class Mesh: def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart, HasAngles, Angles, HasRefPoint, RefPoint, MakeGroups=False, LinearVariation=False): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - if isinstance( PathMesh, Mesh ): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - n,e,f = [],[theObject],[] - gr,er = self.editor.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, NodeStart, - HasAngles, Angles, LinearVariation, - HasRefPoint, RefPoint, MakeGroups) + n,e,f = [],theObject,[] + gr,er = self.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, NodeStart, + HasAngles, Angles, LinearVariation, + HasRefPoint, RefPoint, MakeGroups) if MakeGroups: return gr,er return er @@ -4110,27 +3986,18 @@ class Mesh: def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart, HasAngles, Angles, HasRefPoint, RefPoint, MakeGroups=False, LinearVariation=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object)): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - if ( isinstance( PathMesh, Mesh )): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - n,e,f = [],[],[theObject] - gr,er = self.editor.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, NodeStart, - HasAngles, Angles, LinearVariation, - HasRefPoint, RefPoint, MakeGroups) + n,e,f = [],[],theObject + gr,er = self.ExtrusionAlongPathObjects(n,e,f, PathMesh, PathShape, NodeStart, + HasAngles, Angles, LinearVariation, + HasRefPoint, RefPoint, MakeGroups) if MakeGroups: return gr,er return er ## Creates a symmetrical copy of mesh elements # @param IDsOfElements list of elements ids # @param Mirror is AxisStruct or geom object(point, line, plane) - # @param theMirrorType is POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary + # @param theMirrorType smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE + # If the Mirror is a geom object this parameter is unnecessary # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0) # @param MakeGroups forces the generation of new groups from existing ones (if Copy) # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise @@ -4151,8 +4018,8 @@ class Mesh: ## Creates a new mesh by a symmetrical copy of mesh elements # @param IDsOfElements the list of elements ids # @param Mirror is AxisStruct or geom object (point, line, plane) - # @param theMirrorType is POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary + # @param theMirrorType smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE + # If the Mirror is a geom object this parameter is unnecessary # @param MakeGroups to generate new groups from existing ones # @param NewMeshName a name of the new mesh to create # @return instance of Mesh class @@ -4172,8 +4039,8 @@ class Mesh: ## Creates a symmetrical copy of the object # @param theObject mesh, submesh or group # @param Mirror AxisStruct or geom object (point, line, plane) - # @param theMirrorType is POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary + # @param theMirrorType smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE + # If the Mirror is a geom object this parameter is unnecessary # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0) # @param MakeGroups forces the generation of new groups from existing ones (if Copy) # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise @@ -4194,8 +4061,8 @@ class Mesh: ## Creates a new mesh by a symmetrical copy of the object # @param theObject mesh, submesh or group # @param Mirror AxisStruct or geom object (point, line, plane) - # @param theMirrorType POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary + # @param theMirrorType smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE + # If the Mirror is a geom object this parameter is unnecessary # @param MakeGroups forces the generation of new groups from existing ones # @param NewMeshName the name of the new mesh to create # @return instance of Mesh class @@ -4432,31 +4299,39 @@ class Mesh: ## Finds groups of adjacent nodes within Tolerance. # @param Tolerance the value of tolerance - # @return the list of pairs of nodes IDs (e.g. [[1,12],[25,4]]) + # @param SeparateCornerAndMediumNodes if @c True, in quadratic mesh puts + # corner and medium nodes in separate groups thus preventing + # their further merge. + # @return the list of groups of nodes IDs (e.g. [[1,12,13],[4,25]]) # @ingroup l2_modif_trsf - def FindCoincidentNodes (self, Tolerance): - return self.editor.FindCoincidentNodes(Tolerance) + def FindCoincidentNodes (self, Tolerance, SeparateCornerAndMediumNodes=False): + return self.editor.FindCoincidentNodes( Tolerance, SeparateCornerAndMediumNodes ) ## Finds groups of ajacent nodes within Tolerance. # @param Tolerance the value of tolerance # @param SubMeshOrGroup SubMesh or Group # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search - # @return the list of pairs of nodes IDs (e.g. [[1,12],[25,4]]) + # @param SeparateCornerAndMediumNodes if @c True, in quadratic mesh puts + # corner and medium nodes in separate groups thus preventing + # their further merge. + # @return the list of groups of nodes IDs (e.g. [[1,12,13],[4,25]]) # @ingroup l2_modif_trsf - def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]): + def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, + exceptNodes=[], SeparateCornerAndMediumNodes=False): unRegister = genObjUnRegister() if (isinstance( SubMeshOrGroup, Mesh )): SubMeshOrGroup = SubMeshOrGroup.GetMesh() - if not isinstance( exceptNodes, list): + if not isinstance( exceptNodes, list ): exceptNodes = [ exceptNodes ] - if exceptNodes and isinstance( exceptNodes[0], int): - exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)] + if exceptNodes and isinstance( exceptNodes[0], int ): + exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE )] unRegister.set( exceptNodes ) - return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes) + return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance, + exceptNodes, SeparateCornerAndMediumNodes) ## Merges nodes - # @param GroupsOfNodes a list of pairs of nodes IDs for merging - # (e.g. [[1,12],[25,4]], then nodes 12 and 4 will be removed and replaced + # @param GroupsOfNodes a list of groups of nodes IDs for merging + # (e.g. [[1,12,13],[25,4]], then nodes 12, 13 and 4 will be removed and replaced # by nodes 1 and 25 correspondingly in all elements and groups # @ingroup l2_modif_trsf def MergeNodes (self, GroupsOfNodes): @@ -4464,7 +4339,7 @@ class Mesh: ## Finds the elements built on the same nodes. # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching - # @return the list of pairs of equal elements IDs (e.g. [[1,12],[25,4]]) + # @return the list of groups of equal elements IDs (e.g. [[1,12,13],[4,25]]) # @ingroup l2_modif_trsf def FindEqualElements (self, MeshOrSubMeshOrGroup=None): if not MeshOrSubMeshOrGroup: @@ -4474,8 +4349,8 @@ class Mesh: return self.editor.FindEqualElements( MeshOrSubMeshOrGroup ) ## Merges elements in each given group. - # @param GroupsOfElementsID a list of pairs of elements IDs for merging - # (e.g. [[1,12],[25,4]], then elements 12 and 4 will be removed and + # @param GroupsOfElementsID a list of groups of elements IDs for merging + # (e.g. [[1,12,13],[25,4]], then elements 12, 13 and 4 will be removed and # replaced by elements 1 and 25 in all groups) # @ingroup l2_modif_trsf def MergeElements(self, GroupsOfElementsID): @@ -4559,8 +4434,9 @@ class Mesh: ## Creates Duplicates given elements, i.e. creates new elements based on the # same nodes as the given ones. # @param theElements - container of elements to duplicate. It can be a Mesh, - # sub-mesh, group, filter or a list of element IDs. - # @param theGroupName - a name of group to contain the generated elements. + # sub-mesh, group, filter or a list of element IDs. If \a theElements is + # a Mesh, elements of highest dimension are duplicated + # @param theGroupName - a name of group to contain the generated elements. # If a group with such a name already exists, the new elements # are added to the existng group, else a new group is created. # If \a theGroupName is empty, new elements are not added @@ -4884,6 +4760,24 @@ class Mesh: pass # end of Mesh class +## class used to add to SMESH_MeshEditor methods removed from its CORBA API +# +class meshEditor(SMESH._objref_SMESH_MeshEditor): + def __init__(self): + SMESH._objref_SMESH_MeshEditor.__init__(self) + self.mesh = None + def __getattr__(self, name ): # method called if an attribute not found + if not self.mesh: # look for name() method in Mesh class + self.mesh = Mesh( None, None, SMESH._objref_SMESH_MeshEditor.GetMesh(self)) + if hasattr( self.mesh, name ): + return getattr( self.mesh, name ) + if name == "ExtrusionAlongPathObjX": + return getattr( self.mesh, "ExtrusionAlongPathX" ) + print name, "NOT FOUND" + return None + pass +omniORB.registerObjref(SMESH._objref_SMESH_MeshEditor._NP_RepositoryId, meshEditor) + ## Helper class for wrapping of SMESH.SMESH_Pattern CORBA class # class Pattern(SMESH._objref_SMESH_Pattern):