-# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2012 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
## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
-## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
-## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
-## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
-## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
## @defgroup l3_hypos_additi Additional Hypotheses
def ParseParameters(*args):
Result = []
Parameters = ""
+ hasVariables = False
varModifFun=None
if args and callable( args[-1] ):
args, varModifFun = args[:-1], args[-1]
if not notebook.isVariable(parameter):
raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
parameter = notebook.get(parameter)
+ hasVariables = True
if varModifFun:
parameter = varModifFun(parameter)
pass
pass
Parameters = Parameters[:-1]
Result.append( Parameters )
+ Result.append( hasVariables )
return Result
# Parse parameters converting variables to radians
# Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
# Parameters are stored in PointStruct.parameters attribute
def __initPointStruct(point,*args):
- point.x, point.y, point.z, point.parameters = ParseParameters(*args)
+ point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
pass
SMESH.PointStruct.__init__ = __initPointStruct
# Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
# Parameters are stored in AxisStruct.parameters attribute
def __initAxisStruct(ax,*args):
- ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters = ParseParameters(*args)
+ ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
pass
SMESH.AxisStruct.__init__ = __initAxisStruct
def AssureGeomPublished(mesh, geom, name=''):
if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
return
- if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
+ if not geom.IsSame( mesh.geom ) and \
+ not geom.GetStudyEntry() and \
+ mesh.smeshpyD.GetCurrentStudy():
## set the study
studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
if studyID != mesh.geompyD.myStudyId:
self.geompyD=geompyD
self.SetGeomEngine(geompyD)
SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
+ global notebook
+ if theStudy:
+ notebook = salome_notebook.NoteBook( theStudy )
+ else:
+ notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
## Gets the current study
# @ingroup l1_auxiliary
for i,m in enumerate(meshes):
if isinstance(m, Mesh):
meshes[i] = m.GetMesh()
- mergeTolerance,Parameters = ParseParameters(mergeTolerance)
+ mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
meshes[0].SetParameters(Parameters)
if allGroups:
aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
self.geom = obj
# publish geom of mesh (issue 0021122)
- if not self.geom.GetStudyEntry():
+ if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
if studyID != geompyD.myStudyId:
geompyD.init_geom( smeshpyD.GetCurrentStudy())
if errText: errText += ". "
errText += err.comment
if allReasons != "":allReasons += "\n"
- allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
+ allReasons += '- "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
pass
# Treat hyp errors
" Revise Mesh.Compute() implementation in smeshDC.py!"
pass
if allReasons != "":allReasons += "\n"
- allReasons += reason
+ allReasons += "- " + reason
pass
- if allReasons != "":
- print '"' + GetName(self.mesh) + '"',"has not been computed:"
+ if not ok or allReasons != "":
+ msg = '"' + GetName(self.mesh) + '"'
+ if ok: msg += " has been computed with warnings"
+ else: msg += " has not been computed"
+ if allReasons != "": msg += ":"
+ else: msg += "."
+ print msg
print allReasons
- ok = False
- elif not ok:
- print '"' + GetName(self.mesh) + '"',"has not been computed."
- pass
pass
- if salome.sg.hasDesktop():
+ if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init(self.mesh.GetStudyId())
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
# @return Id of the new node
# @ingroup l2_modif_add
def AddNode(self, x, y, z):
- x,y,z,Parameters = ParseParameters(x,y,z)
- self.mesh.SetParameters(Parameters)
+ x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
+ if hasVars: self.mesh.SetParameters(Parameters)
return self.editor.AddNode( x, y, z)
## Creates a 0D element on a node with given number.
# @return True if succeed else False
# @ingroup l2_modif_movenode
def MoveNode(self, NodeID, x, y, z):
- x,y,z,Parameters = ParseParameters(x,y,z)
- self.mesh.SetParameters(Parameters)
+ x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
+ if hasVars: self.mesh.SetParameters(Parameters)
return self.editor.MoveNode(NodeID, x, y, z)
## Finds the node closest to a point and moves it to a point location
# @return the ID of a node
# @ingroup l2_modif_throughp
def MoveClosestNodeToPoint(self, x, y, z, NodeID):
- x,y,z,Parameters = ParseParameters(x,y,z)
- self.mesh.SetParameters(Parameters)
+ x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
+ if hasVars: self.mesh.SetParameters(Parameters)
return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
## Finds the node closest to a point
flag = False
if isinstance(MaxAngle,str):
flag = True
- MaxAngle,Parameters = ParseAngles(MaxAngle)
+ MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
self.mesh.SetParameters(Parameters)
if not IDsOfElements:
IDsOfElements = self.GetElementsId()
# @return TRUE in case of success, FALSE otherwise.
# @ingroup l2_modif_unitetri
def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
- MaxAngle,Parameters = ParseAngles(MaxAngle)
+ MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
self.mesh.SetParameters(Parameters)
if ( isinstance( theObject, Mesh )):
theObject = theObject.GetMesh()
MaxNbOfIterations, MaxAspectRatio, Method):
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
- MaxNbOfIterations,MaxAspectRatio,Parameters = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
+ MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
self.mesh.SetParameters(Parameters)
return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
MaxNbOfIterations, MaxAspectRatio, Method)
MaxNbOfIterations, MaxAspectRatio, Method):
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
- MaxNbOfIterations,MaxAspectRatio,Parameters = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
+ MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
self.mesh.SetParameters(Parameters)
return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
MaxNbOfIterations, MaxAspectRatio, Method)
IDsOfElements = self.GetElementsId()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ 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:
theObject = theObject.GetMesh()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ 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:
theObject = theObject.GetMesh()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ 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:
theObject = theObject.GetMesh()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ 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:
IDsOfElements = self.GetElementsId()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
pass
- Angles,AnglesParameters = ParseAngles(Angles)
+ Angles,AnglesParameters,hasVars = ParseAngles(Angles)
Parameters = AnglesParameters + var_separator + RefPoint.parameters
self.mesh.SetParameters(Parameters)
pass
if ( isinstance( PathMesh, Mesh )):
PathMesh = PathMesh.GetMesh()
- Angles,AnglesParameters = ParseAngles(Angles)
+ Angles,AnglesParameters,hasVars = ParseAngles(Angles)
Parameters = AnglesParameters + var_separator + RefPoint.parameters
self.mesh.SetParameters(Parameters)
if HasAngles and Angles and LinearVariation:
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
if ( isinstance( PathMesh, Mesh )):
PathMesh = PathMesh.GetMesh()
- Angles,AnglesParameters = ParseAngles(Angles)
+ Angles,AnglesParameters,hasVars = ParseAngles(Angles)
Parameters = AnglesParameters + var_separator + RefPoint.parameters
self.mesh.SetParameters(Parameters)
if HasAngles and Angles and LinearVariation:
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
if ( isinstance( PathMesh, Mesh )):
PathMesh = PathMesh.GetMesh()
- Angles,AnglesParameters = ParseAngles(Angles)
+ Angles,AnglesParameters,hasVars = ParseAngles(Angles)
Parameters = AnglesParameters + var_separator + RefPoint.parameters
self.mesh.SetParameters(Parameters)
if HasAngles and Angles and LinearVariation:
RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
if ( isinstance( PathMesh, Mesh )):
PathMesh = PathMesh.GetMesh()
- Angles,AnglesParameters = ParseAngles(Angles)
+ Angles,AnglesParameters,hasVars = ParseAngles(Angles)
Parameters = AnglesParameters + var_separator + RefPoint.parameters
self.mesh.SetParameters(Parameters)
if HasAngles and Angles and LinearVariation:
IDsOfElements = self.GetElementsId()
if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
Mirror = self.smeshpyD.GetAxisStruct(Mirror)
- mesh.SetParameters(Mirror.parameters)
+ self.mesh.SetParameters(Mirror.parameters)
mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
MakeGroups, NewMeshName)
return Mesh(self.smeshpyD,self.geompyD,mesh)
IDsOfElements = self.GetElementsId()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,Parameters = ParseAngles(AngleInRadians)
+ AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
Parameters = Axis.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if Copy and MakeGroups:
IDsOfElements = self.GetElementsId()
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,Parameters = ParseAngles(AngleInRadians)
+ AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
Parameters = Axis.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
theObject = theObject.GetMesh()
if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,Parameters = ParseAngles(AngleInRadians)
+ AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
Parameters = Axis.parameters + ":" + Parameters
self.mesh.SetParameters(Parameters)
if Copy and MakeGroups:
theObject = theObject.GetMesh()
if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
- AngleInRadians,Parameters = ParseAngles(AngleInRadians)
+ AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
Parameters = Axis.parameters + ":" + Parameters
mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
MakeGroups, NewMeshName)
# @return SMESH.SMESH_Algo
def FindAlgorithm (self, algoname, smeshpyD):
study = smeshpyD.GetCurrentStudy()
+ if not study: return None
#to do: find component by smeshpyD object, not by its data type
scomp = study.FindComponent(smeshpyD.ComponentDataType())
if scomp is not None:
## Returns entry of the shape to mesh in the study
def MainShapeEntry(self):
- entry = ""
- if not self.mesh or not self.mesh.GetMesh(): return entry
- if not self.mesh.GetMesh().HasShapeToMesh(): return entry
- study = self.mesh.smeshpyD.GetCurrentStudy()
- ior = salome.orb.object_to_string( self.mesh.GetShape() )
- sobj = study.FindObjectIOR(ior)
- if sobj: entry = sobj.GetID()
- if not entry: return ""
- return entry
+ if not self.mesh or not self.mesh.GetMesh(): return ""
+ if not self.mesh.GetMesh().HasShapeToMesh(): return ""
+ shape = self.mesh.GetShape()
+ return shape.GetStudyEntry()
## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
# near mesh boundary. This hypothesis can be used by several 3D algorithms:
def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
decrFun = lambda i: i-1
- theNodeIndexOnKeyPoint1,Parameters = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
+ theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
theMesh.SetParameters(Parameters)
return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
decrFun = lambda i: i-1
- theNode000Index,theNode001Index,Parameters = ParseParameters(theNode000Index,theNode001Index, decrFun)
+ theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
theMesh.SetParameters(Parameters)
return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
# creates an instance of algorithm
def __call__(self,algo="",geom=0,*args):
algoType = self.defaultAlgoType
- for arg in args + (algo,):
+ for arg in args + (algo,geom):
if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
geom = arg
if isinstance( arg, str ) and arg:
if self.algoTypeToClass.has_key( algoType ):
#print "Create algo",algoType
return self.algoTypeToClass[ algoType ]( self.mesh, geom )
- raise RuntimeError, "No class found for algo type" % algoType
+ raise RuntimeError, "No class found for algo type %s" % algoType
return None
# Private class used to substitute and store variable parameters of hypotheses.
#print "MethWrapper.__call__",self.method.__name__, args
try:
parsed = ParseParameters(*args) # replace variables with their values
- self.hyp.SetVarParameter( parsed[-1], self.method.__name__ )
- result = self.method( self.hyp, *parsed[:-1] ) # call hypothesis method
+ self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
+ result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
# maybe there is a replaced string arg which is not variable
result = self.method( self.hyp, *args )