X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_SWIG%2FsmeshDC.py;h=624030f9f21d990349e1b10201b9d871b3da0ca3;hb=d6600c3aeb374236e63adc6c285deacb3ae23dab;hp=ab1c52ecc29528bfbcddeec9152a4130d4af060c;hpb=097db70a03990939619fb8a2cc658badd813ab4d;p=modules%2Fsmesh.git diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index ab1c52ecc..624030f9f 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -276,15 +276,15 @@ def AssureGeomPublished(mesh, geom, name=''): ## Return the first vertex of a geomertical edge by ignoring orienation def FirstVertexOnCurve(edge): - from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates + from geompy import SubShapeAll, ShapeType, MakeVertexOnCurve, PointCoordinates vv = SubShapeAll( edge, ShapeType["VERTEX"]) if not vv: raise TypeError, "Given object has no vertices" if len( vv ) == 1: return vv[0] - info = KindOfShape(edge) - xyz = info[1:4] # coords of the first vertex - xyz1 = PointCoordinates( vv[0] ) - xyz2 = PointCoordinates( vv[1] ) + v0 = MakeVertexOnCurve(edge,0.) + xyz = PointCoordinates( v0 ) # coords of the first vertex + xyz1 = PointCoordinates( vv[0] ) + xyz2 = PointCoordinates( vv[1] ) dist1, dist2 = 0,0 for i in range(3): dist1 += abs( xyz[i] - xyz1[i] ) @@ -691,6 +691,20 @@ class smeshDC(SMESH._objref_SMESH_Gen): return None pass pass + elif CritType == FT_EntityType: + # Checks the Threshold + try: + aCriterion.Threshold = self.EnumToLong(aThreshold) + assert( aThreshold in SMESH.EntityType._items ) + except: + if isinstance(aThreshold, int): + aCriterion.Threshold = aThreshold + else: + print "Error: The Threshold should be an integer or SMESH.EntityType." + return None + pass + pass + elif CritType == FT_GroupColor: # Checks the Threshold try: @@ -1323,8 +1337,7 @@ class Mesh: self.Triangle().LengthFromEdges() pass if dim > 2 : - from NETGENPluginDC import NETGEN - self.Tetrahedron(NETGEN) + self.Tetrahedron() pass return self.Compute() @@ -2161,7 +2174,7 @@ class Mesh: def GetElemNbNodes(self, id): return self.mesh.GetElemNbNodes(id) - ## Returns the node ID the given index for the given element + ## Returns the node ID the given (zero based) index for the given element # \n If there is no element for the given ID - returns -1 # \n If there is no node for the given index - returns -2 # @return an integer value @@ -3002,19 +3015,23 @@ class Mesh: return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method) - ## Converts the mesh to quadratic, deletes old elements, replacing + ## Converts the mesh to quadratic or bi-quadratic, deletes old elements, replacing # them with quadratic with the same id. # @param theForce3d new node creation method: # 0 - the medium node lies at the geometrical entity from which the mesh element is built # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal + # @param theToBiQuad If True, converts the mesh to bi-quadratic # @ingroup l2_modif_tofromqu - def ConvertToQuadratic(self, theForce3d, theSubMesh=None): - if theSubMesh: - self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh) + def ConvertToQuadratic(self, theForce3d, theSubMesh=None, theToBiQuad=False): + if theToBiQuad: + self.editor.ConvertToBiQuadratic(theForce3d,theSubMesh) else: - self.editor.ConvertToQuadratic(theForce3d) - + if theSubMesh: + self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh) + else: + self.editor.ConvertToQuadratic(theForce3d) + ## Converts the mesh from quadratic to ordinary, # deletes old quadratic elements, \n replacing # them with ordinary mesh elements with the same id. @@ -3648,7 +3665,7 @@ class Mesh: ## Translates the elements # @param IDsOfElements list of elements ids - # @param Vector the direction of translation (DirStruct or vector) + # @param Vector the direction of translation (DirStruct or vector or 3 vector components) # @param Copy allows copying the translated elements # @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 @@ -3658,6 +3675,8 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) self.mesh.SetParameters(Vector.PS.parameters) if Copy and MakeGroups: return self.editor.TranslateMakeGroups(IDsOfElements, Vector) @@ -3666,7 +3685,7 @@ class Mesh: ## Creates a new mesh of translated elements # @param IDsOfElements list of elements ids - # @param Vector the direction of translation (DirStruct or vector) + # @param Vector the direction of translation (DirStruct or vector or 3 vector components) # @param MakeGroups forces the generation of new groups from existing ones # @param NewMeshName the name of the newly created mesh # @return instance of Mesh class @@ -3676,13 +3695,15 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) self.mesh.SetParameters(Vector.PS.parameters) mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName) return Mesh ( self.smeshpyD, self.geompyD, mesh ) ## Translates the object # @param theObject the object to translate (mesh, submesh, or group) - # @param Vector direction of translation (DirStruct or geom vector) + # @param Vector direction of translation (DirStruct or geom vector or 3 vector components) # @param Copy allows copying the translated elements # @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 @@ -3692,6 +3713,8 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) self.mesh.SetParameters(Vector.PS.parameters) if Copy and MakeGroups: return self.editor.TranslateObjectMakeGroups(theObject, Vector) @@ -3700,16 +3723,18 @@ class Mesh: ## Creates a new mesh from the translated object # @param theObject the object to translate (mesh, submesh, or group) - # @param Vector the direction of translation (DirStruct or geom vector) + # @param Vector the direction of translation (DirStruct or geom vector or 3 vector components) # @param MakeGroups forces the generation of new groups from existing ones # @param NewMeshName the name of the newly created mesh # @return instance of Mesh class # @ingroup l2_modif_trsf def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""): - if (isinstance(theObject, Mesh)): + if isinstance( theObject, Mesh ): theObject = theObject.GetMesh() - if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)): + if isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object ): Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) self.mesh.SetParameters(Vector.PS.parameters) mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName) return Mesh( self.smeshpyD, self.geompyD, mesh )