- if hyp.GetDistrType() == 1:
- if IsEqual(hyp.GetScaleFactor(), args[1]):
- return True
- return False
-
- ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
- # @param start for the length of the first segment
- # @param end for the length of the last segment
- # @param UseExisting if ==true - search existing hypothesis created with
- # same parameters, else (default) - create new
- # @return an instance of StdMeshers_Arithmetic1D hypothesis
- def Arithmetic1D(self, start, end, UseExisting=0):
- hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
- CompareMethod=self.CompareArithmetic1D)
- hyp.SetLength(start, 1)
- hyp.SetLength(end , 0)
- return hyp
-
- ## Private method
- ## Check if the given "Arithmetic1D" hypothesis has the same parameters as given arguments
- def CompareArithmetic1D(self, hyp, args):
- if IsEqual(hyp.GetLength(1), args[0]):
- if IsEqual(hyp.GetLength(0), args[1]):
- return True
- return False
-
- ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
- # @param start for the length of the first segment
- # @param end for the length of the last segment
- # @param UseExisting if ==true - search existing hypothesis created with
- # same parameters, else (default) - create new
- # @return an instance of StdMeshers_StartEndLength hypothesis
- def StartEndLength(self, start, end, UseExisting=0):
- hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
- CompareMethod=self.CompareStartEndLength)
- hyp.SetLength(start, 1)
- hyp.SetLength(end , 0)
- return hyp
-
- ## Check if the given "StartEndLength" hypothesis has the same parameters as given arguments
- def CompareStartEndLength(self, hyp, args):
- if IsEqual(hyp.GetLength(1), args[0]):
- if IsEqual(hyp.GetLength(0), args[1]):
- return True
- return False
-
- ## Define "Deflection1D" hypothesis
- # @param d for the deflection
- # @param UseExisting if ==true - search existing hypothesis created with
- # same parameters, else (default) - create new
- def Deflection1D(self, d, UseExisting=0):
- hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
- CompareMethod=self.CompareDeflection1D)
- hyp.SetDeflection(d)
- return hyp
-
- ## Check if the given "Deflection1D" hypothesis has the same parameters as given arguments
- def CompareDeflection1D(self, hyp, args):
- return IsEqual(hyp.GetDeflection(), args[0])
-
- ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
- # the opposite side in the case of quadrangular faces
- def Propagation(self):
- return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
-
- ## Define "AutomaticLength" hypothesis
- # @param fineness for the fineness [0-1]
- # @param UseExisting if ==true - search existing hypothesis created with
- # same parameters, else (default) - create new
- def AutomaticLength(self, fineness=0, UseExisting=0):
- hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
- CompareMethod=self.CompareAutomaticLength)
- hyp.SetFineness( fineness )
- return hyp
-
- ## Check if the given "AutomaticLength" hypothesis has the same parameters as given arguments
- def CompareAutomaticLength(self, hyp, args):
- return IsEqual(hyp.GetFineness(), args[0])
-
- ## Define "SegmentLengthAroundVertex" hypothesis
- # @param length for the segment length
- # @param vertex for the length localization: vertex index [0,1] | vertex object.
- # Any other integer value means what hypo will be set on the
- # whole 1D shape, where Mesh_Segment algorithm is assigned.
- # @param UseExisting if ==true - search existing hypothesis created with
- # same parameters, else (default) - create new
- def LengthNearVertex(self, length, vertex=0, UseExisting=0):
- import types
- store_geom = self.geom
- if type(vertex) is types.IntType:
- if vertex == 0 or vertex == 1:
- vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
- self.geom = vertex
- pass
- pass
- else:
- self.geom = vertex
- pass
- ### 0D algorithm
- if self.geom is None:
- raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
- name = GetName(self.geom)
- if name == NO_NAME:
- piece = self.mesh.geom
- name = self.mesh.geompyD.SubShapeName(self.geom, piece)
- self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
- algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
- if algo is None:
- algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
- pass
- status = self.mesh.mesh.AddHypothesis(self.geom, algo)
- TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
- ###
- hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
- CompareMethod=self.CompareLengthNearVertex)
- self.geom = store_geom
- hyp.SetLength( length )
- return hyp
-
- ## Check if the given "LengthNearVertex" hypothesis has the same parameters as given arguments
- def CompareLengthNearVertex(self, hyp, args):
- return IsEqual(hyp.GetLength(), args[0])
-
- ## Define "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
- # If the 2D mesher sees that all boundary edges are quadratic ones,
- # it generates quadratic faces, else it generates linear faces using
- # medium nodes as if they were vertex ones.
- # The 3D mesher generates quadratic volumes only if all boundary faces
- # are quadratic ones, else it fails.
- def QuadraticMesh(self):
- hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
- return hyp
-
-# Public class: Mesh_CompositeSegment
-# --------------------------
-
-## Class to define a segment 1D algorithm for discretization
-#
-# More details.
-class Mesh_CompositeSegment(Mesh_Segment):
-
- ## Private constructor.
- def __init__(self, mesh, geom=0):
- self.Create(mesh, geom, "CompositeSegment_1D")
-
-
-# Public class: Mesh_Segment_Python
-# ---------------------------------
-
-## Class to define a segment 1D algorithm for discretization with python function
-#
-# More details.
-class Mesh_Segment_Python(Mesh_Segment):
-
- ## Private constructor.
- def __init__(self, mesh, geom=0):
- import Python1dPlugin
- self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
-
- ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
- # @param n for the number of segments that cut an edge
- # @param func for the python function that calculate the length of all segments
- # @param UseExisting if ==true - search existing hypothesis created with
- # same parameters, else (default) - create new
- def PythonSplit1D(self, n, func, UseExisting=0):
- hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
- UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
- hyp.SetNumberOfSegments(n)
- hyp.SetPythonLog10RatioFunction(func)
- return hyp
-
- ## Check if the given "PythonSplit1D" hypothesis has the same parameters as given arguments
- def ComparePythonSplit1D(self, hyp, args):
- #if hyp.GetNumberOfSegments() == args[0]:
- # if hyp.GetPythonLog10RatioFunction() == args[1]:
- # return True
- return False
-
-# Public class: Mesh_Triangle
-# ---------------------------
-
-## Class to define a triangle 2D algorithm
-#
-# More details.
-class Mesh_Triangle(Mesh_Algorithm):
-
- # default values
- algoType = 0
- params = 0
-
- _angleMeshS = 8
- _gradation = 1.1
-
- ## Private constructor.
- def __init__(self, mesh, algoType, geom=0):
- Mesh_Algorithm.__init__(self)
-
- self.algoType = algoType
- if algoType == MEFISTO:
- self.Create(mesh, geom, "MEFISTO_2D")
- pass
- elif algoType == BLSURF:
- import BLSURFPlugin
- self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
- self.SetPhysicalMesh()
- elif algoType == NETGEN:
- if noNETGENPlugin:
- print "Warning: NETGENPlugin module unavailable"
- pass
- self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
- pass
- elif algoType == NETGEN_2D:
- if noNETGENPlugin:
- print "Warning: NETGENPlugin module unavailable"
- pass
- self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
- pass
-
- ## Define "MaxElementArea" hypothesis to give the maximum area of each triangle
- # @param area for the maximum area of each triangle
- # @param UseExisting if ==true - search existing hypothesis created with
- # same parameters, else (default) - create new
- #
- # Only for algoType == MEFISTO || NETGEN_2D
- def MaxElementArea(self, area, UseExisting=0):
- if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
- hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
- CompareMethod=self.CompareMaxElementArea)
- hyp.SetMaxElementArea(area)
- return hyp
- elif self.algoType == NETGEN:
- print "Netgen 1D-2D algo doesn't support this hypothesis"
- return None
-
- ## Check if the given "MaxElementArea" hypothesis has the same parameters as given arguments
- def CompareMaxElementArea(self, hyp, args):
- return IsEqual(hyp.GetMaxElementArea(), args[0])
-
- ## Define "LengthFromEdges" hypothesis to build triangles
- # based on the length of the edges taken from the wire
- #
- # Only for algoType == MEFISTO || NETGEN_2D
- def LengthFromEdges(self):
- if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
- hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
- return hyp
- elif self.algoType == NETGEN:
- print "Netgen 1D-2D algo doesn't support this hypothesis"
- return None
-
- ## Set PhysicalMesh
- # @param thePhysicalMesh is:
- # DefaultSize or Custom
- def SetPhysicalMesh(self, thePhysicalMesh=1):
- if self.params == 0:
- self.Parameters()
- self.params.SetPhysicalMesh(thePhysicalMesh)
-
- ## Set PhySize flag
- def SetPhySize(self, theVal):
- if self.params == 0:
- self.Parameters()
- self.params.SetPhySize(theVal)
-
- ## Set GeometricMesh
- # @param theGeometricMesh is:
- # DefaultGeom or Custom
- def SetGeometricMesh(self, theGeometricMesh=0):
- if self.params == 0:
- self.Parameters()
- if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
- self.params.SetGeometricMesh(theGeometricMesh)
-
- ## Set AngleMeshS flag
- def SetAngleMeshS(self, theVal=_angleMeshS):
- if self.params == 0:
- self.Parameters()
- if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
- self.params.SetAngleMeshS(theVal)
-
- ## Set Gradation flag
- def SetGradation(self, theVal=_gradation):
- if self.params == 0:
- self.Parameters()
- if self.params.GetGeometricMesh() == 0: theVal = self._gradation
- self.params.SetGradation(theVal)
-
- ## Set QuadAllowed flag
- #
- # Only for algoType == NETGEN || NETGEN_2D
- def SetQuadAllowed(self, toAllow=True):
- if self.algoType == NETGEN_2D:
- if toAllow: # add QuadranglePreference
- self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
- else: # remove QuadranglePreference
- for hyp in self.mesh.GetHypothesisList( self.geom ):
- if hyp.GetName() == "QuadranglePreference":
- self.mesh.RemoveHypothesis( self.geom, hyp )
- pass
- pass
- pass
- return
- if self.params == 0:
- self.Parameters()
- if self.params:
- self.params.SetQuadAllowed(toAllow)
- return
-
- ## Define "Netgen 2D Parameters" hypothesis
- #
- # Only for algoType == NETGEN
- def Parameters(self):
- if self.algoType == NETGEN:
- self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
- "libNETGENEngine.so", UseExisting=0)
- return self.params
- elif self.algoType == MEFISTO:
- print "Mefisto algo doesn't support NETGEN_Parameters_2D hypothesis"
- return None
- elif self.algoType == NETGEN_2D:
- print "NETGEN_2D_ONLY algo doesn't support 'NETGEN_Parameters_2D' hypothesis"
- print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
- return None
- elif self.algoType == BLSURF:
- self.params = self.Hypothesis("BLSURF_Parameters", [],
- "libBLSURFEngine.so", UseExisting=0)
- return self.params
- return None
-
- ## Set MaxSize
- #
- # Only for algoType == NETGEN
- def SetMaxSize(self, theSize):
- if self.params == 0:
- self.Parameters()
- if self.params is not None:
- self.params.SetMaxSize(theSize)
-
- ## Set SecondOrder flag
- #
- # Only for algoType == NETGEN
- def SetSecondOrder(self, theVal):
- if self.params == 0:
- self.Parameters()
- if self.params is not None:
- self.params.SetSecondOrder(theVal)
-
- ## Set Optimize flag
- #
- # Only for algoType == NETGEN
- def SetOptimize(self, theVal):
- if self.params == 0:
- self.Parameters()
- if self.params is not None:
- self.params.SetOptimize(theVal)
-
- ## Set Fineness
- # @param theFineness is:
- # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
- #
- # Only for algoType == NETGEN
- def SetFineness(self, theFineness):
- if self.params == 0:
- self.Parameters()
- if self.params is not None:
- self.params.SetFineness(theFineness)
-
- ## Set GrowthRate
- #
- # Only for algoType == NETGEN
- def SetGrowthRate(self, theRate):
- if self.params == 0:
- self.Parameters()
- if self.params is not None:
- self.params.SetGrowthRate(theRate)
-
- ## Set NbSegPerEdge
+ return twoGroups[ int(theMakeNodeGroup) ]
+ return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
+
+ ## 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
+ # @param theNodesNot - group of nodes not to replicated
+ # @param theShape - shape to detect affected elements (element which geometric center
+ # located on or inside shape).
+ # The replicated nodes should be associated to affected elements.
+ # @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
+ # @param theNodesNot - list of groups of nodes not to replicated
+ # @param theAffectedElems - group of elements to which the replicated nodes
+ # should be associated to.
+ # @param theMakeGroup forces the generation of a group containing new elements.
+ # @param theMakeNodeGroup forces the generation of a group containing new nodes.
+ # @return TRUE or created groups (one or two) if operation has been completed successfully,
+ # FALSE or None otherwise
+ # @ingroup l2_modif_edit
+ def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems,
+ theMakeGroup=False, theMakeNodeGroup=False):
+ if theMakeGroup or theMakeNodeGroup:
+ twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot,
+ theAffectedElems,
+ theMakeGroup, theMakeNodeGroup)
+ if theMakeGroup and theMakeNodeGroup:
+ return twoGroups
+ else:
+ return twoGroups[ int(theMakeNodeGroup) ]
+ return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
+
+ ## 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
+ # @param theNodesNot - list of groups of nodes not to replicated
+ # @param theShape - shape to detect affected elements (element which geometric center
+ # located on or inside shape).
+ # The replicated nodes should be associated to affected elements.
+ # @return TRUE if operation has been completed successfully, FALSE otherwise
+ # @ingroup l2_modif_edit
+ def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
+ return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
+
+ ## Identify the elements that will be affected by node duplication (actual duplication is not performed.
+ # This method is the first step of DoubleNodeElemGroupsInRegion.
+ # @param theElems - list of groups of elements (edges or faces) to be replicated
+ # @param theNodesNot - list of groups of nodes not to replicated
+ # @param theShape - shape to detect affected elements (element which geometric center
+ # located on or inside shape).
+ # The replicated nodes should be associated to affected elements.
+ # @return groups of affected elements
+ # @ingroup l2_modif_edit
+ def AffectedElemGroupsInRegion(self, theElems, theNodesNot, theShape):
+ return self.editor.AffectedElemGroupsInRegion(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.
+ # In option, the internal faces are replaced by flat elements.
+ # Triangles are transformed in prisms, and quadrangles in hexahedrons.
+ # @param theDomains - list of groups of volumes
+ # @param createJointElems - if TRUE, create the elements
+ # @return TRUE if operation has been completed successfully, FALSE otherwise
+ def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
+ return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
+
+ ## Double nodes on some external faces and create flat elements.
+ # Flat elements are mainly used by some types of mechanic calculations.