#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-
# File : smesh.py
# Author : Francis KLOSS, OCC
# Module : SMESH
-#
+
"""
\namespace smesh
\brief Module smesh
pntStr = Dir.pointStruct
if isinstance(pntStr, PointStructStr6):
Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
- Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
+ Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
else:
else:
Result.append(parameter)
pass
-
+
Parameters = Parameters + str(parameter)
Parameters = Parameters + var_separator
pass
Parameters = Parameters[:len(Parameters)-1]
return Result, Parameters
-
+
def IsEqual(val1, val2, tol=PrecisionConfusion):
if abs(val1 - val2) < tol:
return True
print "Warning: BLSURFPlugin module unavailable"
return False
return True
-
+
# end of l1_auxiliary
## @}
obj = obj.GetMesh()
d = {}
if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
- values = obj.GetMeshInfo()
+ values = obj.GetMeshInfo()
for i in range(SMESH.Entity_Last._v):
if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
pass
# If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
# If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
#
- # @param src1 first source object
+ # @param src1 first source object
# @param src2 second source object
# @param id1 node/element id from the first source
# @param id2 node/element id from the second (or first) source
else:
result = result.value
return result
-
+
## Get measure structure specifying minimum distance data between two objects
#
# If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
# If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
#
- # @param src1 first source object
+ # @param src1 first source object
# @param src2 second source object
# @param id1 node/element id from the first source
# @param id2 node/element id from the second (or first) source
result = aMeasurements.MinDistance(src1, src2)
aMeasurements.Destroy()
return result
-
+
## Get bounding box of the specified object(s)
# @param objects single source object or list of source objects
# @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
except:
shapeText = " on subshape #%s" % (err.subShapeID)
errText = ""
- stdErrors = ["OK", #COMPERR_OK
+ stdErrors = ["OK", #COMPERR_OK
"Invalid input mesh", #COMPERR_BAD_INPUT_MESH
- "std::exception", #COMPERR_STD_EXCEPTION
- "OCC exception", #COMPERR_OCC_EXCEPTION
- "SALOME exception", #COMPERR_SLM_EXCEPTION
- "Unknown exception", #COMPERR_EXCEPTION
- "Memory allocation problem", #COMPERR_MEMORY_PB
- "Algorithm failed", #COMPERR_ALGO_FAILED
+ "std::exception", #COMPERR_STD_EXCEPTION
+ "OCC exception", #COMPERR_OCC_EXCEPTION
+ "SALOME exception", #COMPERR_SLM_EXCEPTION
+ "Unknown exception", #COMPERR_EXCEPTION
+ "Memory allocation problem", #COMPERR_MEMORY_PB
+ "Algorithm failed", #COMPERR_ALGO_FAILED
"Unexpected geometry"]#COMPERR_BAD_SHAPE
if err.code > 0:
if err.code < len(stdErrors): errText = stdErrors[err.code]
# @ingroup l2_grps_operon
def UnionGroups(self, group1, group2, name):
return self.mesh.UnionGroups(group1, group2, name)
-
+
## Produces a union list of groups
- # New group is created. All mesh elements that are present in
+ # New group is created. All mesh elements that are present in
# initial groups are added to the new one
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
def UnionListOfGroups(self, groups, name):
return self.mesh.UnionListOfGroups(groups, name)
-
+
## Prodices an intersection of two groups
# A new group is created. All mesh elements that are common
# for the two initial groups are added to the new one.
# @ingroup l2_grps_operon
def IntersectGroups(self, group1, group2, name):
return self.mesh.IntersectGroups(group1, group2, name)
-
+
## Produces an intersection of groups
- # New group is created. All mesh elements that are present in all
+ # New group is created. All mesh elements that are present in all
# initial groups simultaneously are added to the new one
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
# @ingroup l2_grps_operon
def CutGroups(self, main_group, tool_group, name):
return self.mesh.CutGroups(main_group, tool_group, name)
-
+
## Produces a cut of groups
- # A new group is created. All mesh elements that are present in main groups
+ # A new group is created. All mesh elements that are present in main groups
# but do not present in tool groups are added to the new one
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
def CutListOfGroups(self, main_groups, tool_groups, name):
return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
-
+
## Produces a group of elements with specified element type using list of existing groups
- # A new group is created. System
+ # A new group is created. System
# 1) extract all nodes on which groups elements are built
# 2) combine all elements of specified dimension laying on these nodes
# @return an instance of SMESH_Group
def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
return aMeasure.value
-
+
## Get measure structure specifying minimum distance data between two objects
# @param id1 first node/element id
# @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
pass
else:
id2 = None
-
+
aMeasurements = self.smeshpyD.CreateMeasurements()
aMeasure = aMeasurements.MinDistance(id1, id2)
aMeasurements.Destroy()
return aMeasure
-
+
## Get bounding box of the specified object(s)
# @param objects single source object or list of source objects or list of nodes/elements IDs
# @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
aMeasure = aMeasurements.BoundingBox(srclist)
aMeasurements.Destroy()
return aMeasure
-
+
# Mesh edition (SMESH_MeshEditor functionality):
# ---------------------------------------------
# @ingroup l2_modif_throughp
def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
return self.editor.FindElementsByPoint(x, y, z, elementType)
-
+
# Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
# TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
-
+
def GetPointState(self, x, y, z):
return self.editor.GetPointState(x, y, z)
IDsOfElements = self.GetElementsId()
self.mesh.SetParameters(Parameters)
Functor = 0
- if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
+ if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
Functor = theCriterion
else:
Functor = self.smeshpyD.GetFunctor(theCriterion)
# @param meshName - a name of new mesh to store created boundary elements in,
# "" means not to create the new mesh
# @param toCopyElements - if true, the checked elements will be copied into the new mesh
- # @param toCopyExistingBondary - if true, not only new but also pre-existing
+ # @param toCopyExistingBondary - if true, not only new but also pre-existing
# boundary elements will be copied into the new mesh
# @return tuple (mesh, group) where bondary elements were added to
# @ingroup l2_modif_edit
Parameters = AnglesParameters + var_separator + RefPointParameters
self.mesh.SetParameters(Parameters)
- if isinstance(Base,list):
+ if (isinstance(Path, Mesh)):
+ Path = Path.GetMesh()
+
+ if isinstance(Base, list):
IDsOfElements = []
if Base == []: IDsOfElements = self.GetElementsId()
else: IDsOfElements = Base
HasAngles, Angles, LinearVariation,
HasRefPoint, RefPoint, MakeGroups, ElemType)
else:
- if isinstance(Base,Mesh):
+ if isinstance(Base, Mesh): Base = Base.GetMesh()
+ if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
HasAngles, Angles, LinearVariation,
HasRefPoint, RefPoint, MakeGroups, ElemType)
## Creates a hole in a mesh by doubling the nodes of some particular elements
# @param theNodes identifiers of nodes to be doubled
- # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
- # nodes. If list of element identifiers is empty then nodes are doubled but
+ # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
+ # nodes. If list of element identifiers is empty then nodes are doubled but
# they not assigned to elements
# @return TRUE if operation has been completed successfully, FALSE otherwise
# @ingroup l2_modif_edit
def DoubleNodes(self, theNodes, theModifiedElems):
return self.editor.DoubleNodes(theNodes, theModifiedElems)
-
+
## Creates a hole in a mesh by doubling the nodes of some particular elements
# This method provided for convenience works as DoubleNodes() described above.
# @param theNodeId identifiers of node to be doubled
# @ingroup l2_modif_edit
def DoubleNode(self, theNodeId, theModifiedElems):
return self.editor.DoubleNode(theNodeId, theModifiedElems)
-
+
## Creates a hole in a mesh by doubling the nodes of some particular elements
# This method provided for convenience works as DoubleNodes() described above.
# @param theNodes group of nodes to be doubled
# @ingroup l2_modif_edit
def DoubleNodeGroups(self, theNodes, theModifiedElems):
return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
-
+
## Creates a hole in a mesh by doubling the nodes of some particular elements
# @param theElems - the list of elements (edges or faces) to be replicated
# The nodes for duplication could be found from these elements
# @param theNodesNot - list of nodes to NOT replicate
- # @param theAffectedElems - the list of elements (cells and edges) to which the
+ # @param theAffectedElems - the list of elements (cells and edges) to which the
# replicated nodes should be associated to.
# @return TRUE if operation has been completed successfully, FALSE otherwise
# @ingroup l2_modif_edit
def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
-
+
## Creates a hole in a mesh by doubling the nodes of some particular elements
# @param theElems - the list of elements (edges or faces) to be replicated
# The nodes for duplication could be found from these elements
# @ingroup l2_modif_edit
def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
-
+
## Creates a hole in a mesh by doubling the nodes of some particular elements
# This method provided for convenience works as DoubleNodes() described above.
# @param theElems - group of of elements (edges or faces) to be replicated
# @ingroup l2_modif_edit
def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
-
+
## Creates a hole in a mesh by doubling the nodes of some particular elements
# This method provided for convenience works as DoubleNodes() described above.
# @param theElems - list of groups of elements (edges or faces) to be replicated
# @ingroup l2_modif_edit
def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
-
+
## Double nodes on shared faces between groups of volumes and create flat elements on demand.
# The list of groups must describe a partition of the mesh volumes.
# The nodes of the internal faces at the boundaries of the groups are doubled.
else:
val = 0
return val
-
+
## Get length of 1D element.
# @param elemId mesh element ID
# @return element's length value
# @ingroup l1_measurements
def GetLength(self, elemId):
- return self._valueFromFunctor(SMESH.FT_Length, elemId)
+ return self._valueFromFunctor(SMESH.FT_Length, elemId)
## Get area of 2D element.
# @param elemId mesh element ID
# @return element's area value
# @ingroup l1_measurements
def GetArea(self, elemId):
- return self._valueFromFunctor(SMESH.FT_Area, elemId)
+ return self._valueFromFunctor(SMESH.FT_Area, elemId)
## Get volume of 3D element.
# @param elemId mesh element ID
# @return element's volume value
# @ingroup l1_measurements
def GetVolume(self, elemId):
- return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
+ return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
## Get maximum element length.
# @param elemId mesh element ID
ftype = SMESH.FT_MaxElementLength3D
else:
ftype = SMESH.FT_MaxElementLength2D
- return self._valueFromFunctor(ftype, elemId)
+ return self._valueFromFunctor(ftype, elemId)
## Get aspect ratio of 2D or 3D element.
# @param elemId mesh element ID
ftype = SMESH.FT_AspectRatio3D
else:
ftype = SMESH.FT_AspectRatio
- return self._valueFromFunctor(ftype, elemId)
+ return self._valueFromFunctor(ftype, elemId)
## Get warping angle of 2D element.
# @param elemId mesh element ID
pass
hyp.SetUsePreestimatedLength( length == 0.0 )
return hyp
-
+
## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
# @param n for the number of segments that cut an edge
# @param s for the scale factor (optional)
# @param quadType defines the algorithm of transition between differently descretized
# sides of a geometrical face:
# - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
- # area along the finer meshed sides.
+ # area along the finer meshed sides.
# - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
# finer meshed sides.
# - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
# the finer meshed sides, iff the total quantity of segments on
# all four sides of the face is even (divisible by 2).
# - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
- # area is located along the coarser meshed sides.
+ # area is located along the coarser meshed sides.
# - QUAD_REDUCED - only quadrangles are built and the transition between the sides
# is made gradually, layer by layer. This type has a limitation on
# the number of segments: one pair of opposite sides must have the
#Wrapper class for StdMeshers_LayerDistribution hypothesis
class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
-
+
def SetLayerDistribution(self, hypo):
StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
hypo.ClearParameters();
#Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
-
+
## Set Length parameter value
- # @param length numerical value or name of variable from notebook
+ # @param length numerical value or name of variable from notebook
def SetLength(self, length):
length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
#Wrapper class for StdMeshers_Arithmetic1D hypothesis
class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
-
+
## Set Length parameter value
# @param length numerical value or name of variable from notebook
# @param isStart true is length is Start Length, otherwise false
length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
-
+
#Registering the new proxy for Arithmetic1D
omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
#Wrapper class for StdMeshers_Deflection1D hypothesis
class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
-
+
## Set Deflection parameter value
- # @param deflection numerical value or name of variable from notebook
+ # @param deflection numerical value or name of variable from notebook
def SetDeflection(self, deflection):
deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
#Wrapper class for StdMeshers_StartEndLength hypothesis
class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
-
+
## Set Length parameter value
# @param length numerical value or name of variable from notebook
# @param isStart true is length is Start Length, otherwise false
length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
-
+
#Registering the new proxy for StartEndLength
omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
#Wrapper class for StdMeshers_MaxElementArea hypothesis
class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
-
+
## Set Max Element Area parameter value
# @param area numerical value or name of variable from notebook
def SetMaxElementArea(self, area):
area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
-
+
#Registering the new proxy for MaxElementArea
omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
#Wrapper class for StdMeshers_MaxElementVolume hypothesis
class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
-
+
## Set Max Element Volume parameter value
# @param volume numerical value or name of variable from notebook
def SetMaxElementVolume(self, volume):
volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
-
+
#Registering the new proxy for MaxElementVolume
omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
#Wrapper class for StdMeshers_NumberOfLayers hypothesis
class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
-
+
## Set Number Of Layers parameter value
# @param nbLayers numerical value or name of variable from notebook
def SetNumberOfLayers(self, nbLayers):
nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
-
+
#Registering the new proxy for NumberOfLayers
omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
#Wrapper class for StdMeshers_NumberOfSegments hypothesis
class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
-
+
## Set Number Of Segments parameter value
# @param nbSeg numerical value or name of variable from notebook
def SetNumberOfSegments(self, nbSeg):
nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
-
+
## Set Scale Factor parameter value
# @param factor numerical value or name of variable from notebook
def SetScaleFactor(self, factor):
factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
-
+
#Registering the new proxy for NumberOfSegments
omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
## Set Max Element Area parameter value
- # @param area numerical value or name of variable from notebook
+ # @param area numerical value or name of variable from notebook
def SetMaxElementArea(self, area):
lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
area, parameters = ParseParameters(lastParameters,2,2,area)
#Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
## Set Max Element Volume parameter value
- # @param volume numerical value or name of variable from notebook
+ # @param volume numerical value or name of variable from notebook
def SetMaxElementVolume(self, volume):
lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
volume, parameters = ParseParameters(lastParameters,3,3,volume)