import StdMeshers
+import SALOME
+
# import NETGENPlugin module if possible
noNETGENPlugin = 0
try:
print "Error: given parameter is not numerucal functor type."
-## Private method. Print error message if a hypothesis was not assigned.
+## Print error message if a hypothesis was not assigned.
def TreatHypoStatus(status, hypName, geomName, isAlgo):
if isAlgo:
hypType = "algorithm"
## Define "SegmentLengthAroundVertex" hypothesis
# @param length for the segment length
# @param vertex for the length localization: vertex index [0,1] | verext object
- def LengthNearVertex(self, length, vertex):
+ def LengthNearVertex(self, length, vertex=0):
import types
- if type(vertex) is types.IntType:
- vertex = geompy.SubShapeAllSorted(self.geom,geompy.ShapeType["VERTEX"])[vertex]
- pass
store_geom = self.geom
- self.geom = vertex
+ if vertex:
+ if type(vertex) is types.IntType:
+ vertex = geompy.SubShapeAllSorted(self.geom,geompy.ShapeType["VERTEX"])[vertex]
+ pass
+ self.geom = vertex
+ pass
+ hyp = self.Hypothesis("SegmentAroundVertex_0D")
hyp = self.Hypothesis("SegmentLengthAroundVertex")
self.geom = store_geom
hyp.SetLength( length )
return 0
else:
geom = self.geom
- ok = smesh.Compute(self.mesh, geom)
+ ok = False
+ try:
+ ok = smesh.Compute(self.mesh, geom)
+ except SALOME.SALOME_Exception, ex:
+ print "Mesh computation failed, exception cought:"
+ print " ", ex.details.text
+ except:
+ import traceback
+ print "Mesh computation failed, exception cought:"
+ traceback.print_exc()
if not ok:
errors = smesh.GetAlgoState( self.mesh, geom )
allReasons = ""
allReasons += reason
pass
if allReasons != "":
- print '"' + GetName(self.mesh) + '"',"not computed:"
+ print '"' + GetName(self.mesh) + '"',"has not been computed:"
print allReasons
+ else:
+ print '"' + GetName(self.mesh) + '"',"has not been computed."
pass
pass
if salome.sg.hasDesktop():
self.Hexahedron()
pass
return self.Compute()
+
+ ## Assign hypothesis
+ # @param hyp is a hypothesis to assign
+ # @param geom is subhape of mesh geometry
+ def AddHypothesis(self, hyp, geom=0 ):
+ if isinstance( hyp, Mesh_Algorithm ):
+ hyp = hyp.GetAlgorithm()
+ pass
+ if not geom:
+ geom = self.geom
+ pass
+ status = self.mesh.AddHypothesis(geom, hyp)
+ isAlgo = ( hyp._narrow( SMESH.SMESH_Algo ) is not None )
+ TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
+ return status
## Get the list of hypothesis added on a geom
# @param geom is subhape of mesh geometry
# @param y Y coordinate of a point
# @param z Z coordinate of a point
# @return id of a moved node
- def MeshToPassTroughAPoint(self, x, y, z):
+ def MeshToPassThroughAPoint(self, x, y, z):
return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
## Replace two neighbour triangles sharing Node1-Node2 link
def MergeNodes (self, GroupsOfNodes):
self.editor.MergeNodes(GroupsOfNodes)
+ ## Find elements built on the same nodes.
+ # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
+ # @return a list of groups of equal elements
+ def FindEqualElements (self, MeshOrSubMeshOrGroup):
+ return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
+
+ ## Merge elements in each given group.
+ # @param GroupsOfElementsID groups of elements for merging
+ def MergeElements(self, GroupsOfElementsID):
+ self.editor.MergeElements(GroupsOfElementsID)
+
## Remove all but one of elements built on the same nodes.
def MergeEqualElements(self):
self.editor.MergeEqualElements()