Back to index

salome-smesh  6.5.0
StdMeshersDC.py
Go to the documentation of this file.
00001 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 from smesh import Mesh_Algorithm, AssureGeomPublished, IsEqual, ParseParameters
00021 from smesh import GetName, TreatHypoStatus
00022 from smeshDC import Mesh
00023 
00024 import StdMeshers
00025 
00026 # Types of algorithms
00027 REGULAR     = "Regular_1D"
00028 PYTHON      = "Python_1D"
00029 COMPOSITE   = "CompositeSegment_1D"
00030 MEFISTO     = "MEFISTO_2D"
00031 Hexa        = "Hexa_3D"
00032 QUADRANGLE  = "Quadrangle_2D"
00033 RADIAL_QUAD = "RadialQuadrangle_1D2D"
00034 
00035 
00036 # import items of enum QuadType
00037 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
00038 
00039 
00040 # Public class: Mesh_Segment
00041 # --------------------------
00042 
00043 ## Class to define a REGULAR 1D algorithm for discretization. It is created by
00044 #  calling Mesh.Segment(geom=0)
00045 #
00046 #  @ingroup l3_algos_basic
00047 class StdMeshersDC_Segment(Mesh_Algorithm):
00048 
00049     ## Name of method of class Mesh creating an instance of this class
00050     meshMethod = "Segment"
00051     ## Name of algorithm type
00052     algoType   = REGULAR
00053     isDefault  = True
00054 
00055     ## Private constructor.
00056     def __init__(self, mesh, geom=0):
00057         Mesh_Algorithm.__init__(self)
00058         self.Create(mesh, geom, self.algoType)
00059 
00060     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
00061     #  @param l for the length of segments that cut an edge
00062     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
00063     #                    the same parameters, else (default) - creates a new one
00064     #  @param p precision, used for calculation of the number of segments.
00065     #           The precision should be a positive, meaningful value within the range [0,1].
00066     #           In general, the number of segments is calculated with the formula:
00067     #           nb = ceil((edge_length / l) - p)
00068     #           Function ceil rounds its argument to the higher integer.
00069     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
00070     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
00071     #               p=1 means rounding of (edge_length / l) to the lower integer.
00072     #           Default value is 1e-07.
00073     #  @return an instance of StdMeshers_LocalLength hypothesis
00074     #  @ingroup l3_hypos_1dhyps
00075     def LocalLength(self, l, UseExisting=0, p=1e-07):
00076         comFun=lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) and IsEqual(hyp.GetPrecision(), args[1])
00077         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting, CompareMethod=comFun)
00078         hyp.SetLength(l)
00079         hyp.SetPrecision(p)
00080         return hyp
00081 
00082     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
00083     #  @param length is optional maximal allowed length of segment, if it is omitted
00084     #                the preestimated length is used that depends on geometry size
00085     #  @param UseExisting if ==true - searches for an existing hypothesis created with
00086     #                     the same parameters, else (default) - creates a new one
00087     #  @return an instance of StdMeshers_MaxLength hypothesis
00088     #  @ingroup l3_hypos_1dhyps
00089     def MaxSize(self, length=0.0, UseExisting=0):
00090         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
00091         if length > 0.0:
00092             # set given length
00093             hyp.SetLength(length)
00094         if not UseExisting:
00095             # set preestimated length
00096             gen = self.mesh.smeshpyD
00097             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
00098                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
00099                                                        False) # <- byMesh
00100             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
00101             if preHyp:
00102                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
00103                 pass
00104             pass
00105         hyp.SetUsePreestimatedLength( length == 0.0 )
00106         return hyp
00107 
00108     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
00109     #  @param n for the number of segments that cut an edge
00110     #  @param s for the scale factor (optional)
00111     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
00112     #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
00113     #  @param UseExisting if ==true - searches for an existing hypothesis created with
00114     #                     the same parameters, else (default) - create a new one
00115     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
00116     #  @ingroup l3_hypos_1dhyps
00117     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
00118         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
00119             reversedEdges, UseExisting = [], reversedEdges
00120         entry = self.MainShapeEntry()
00121         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
00122         if s == []:
00123             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
00124                                   UseExisting=UseExisting,
00125                                   CompareMethod=self._compareNumberOfSegments)
00126         else:
00127             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
00128                                   UseExisting=UseExisting,
00129                                   CompareMethod=self._compareNumberOfSegments)
00130             hyp.SetDistrType( 1 )
00131             hyp.SetScaleFactor(s)
00132         hyp.SetNumberOfSegments(n)
00133         hyp.SetReversedEdges( reversedEdgeInd )
00134         hyp.SetObjectEntry( entry )
00135         return hyp
00136 
00137     ## Private method
00138     ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
00139     def _compareNumberOfSegments(self, hyp, args):
00140         if hyp.GetNumberOfSegments() == args[0]:
00141             if len(args) == 3:
00142                 if hyp.GetReversedEdges() == args[1]:
00143                     if not args[1] or hyp.GetObjectEntry() == args[2]:
00144                         return True
00145             else:
00146                 if hyp.GetReversedEdges() == args[2]:
00147                     if not args[2] or hyp.GetObjectEntry() == args[3]:
00148                         if hyp.GetDistrType() == 1:
00149                             if IsEqual(hyp.GetScaleFactor(), args[1]):
00150                                 return True
00151         return False
00152 
00153     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
00154     #  @param start defines the length of the first segment
00155     #  @param end   defines the length of the last  segment
00156     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
00157     #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
00158     #  @param UseExisting if ==true - searches for an existing hypothesis created with
00159     #                     the same parameters, else (default) - creates a new one
00160     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
00161     #  @ingroup l3_hypos_1dhyps
00162     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
00163         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
00164             reversedEdges, UseExisting = [], reversedEdges
00165         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
00166         entry = self.MainShapeEntry()
00167         compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
00168                                       IsEqual(hyp.GetLength(0), args[1]) and \
00169                                       hyp.GetReversedEdges() == args[2]  and \
00170                                       (not args[2] or hyp.GetObjectEntry() == args[3]))
00171         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
00172                               UseExisting=UseExisting, CompareMethod=compFun)
00173         hyp.SetStartLength(start)
00174         hyp.SetEndLength(end)
00175         hyp.SetReversedEdges( reversedEdgeInd )
00176         hyp.SetObjectEntry( entry )
00177         return hyp
00178 
00179     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
00180     # on curve from 0 to 1 (additionally it is neecessary to check
00181     # orientation of edges and create list of reversed edges if it is
00182     # needed) and sets numbers of segments between given points (default
00183     # values are equals 1
00184     #  @param points defines the list of parameters on curve
00185     #  @param nbSegs defines the list of numbers of segments
00186     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
00187     #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
00188     #  @param UseExisting if ==true - searches for an existing hypothesis created with
00189     #                     the same parameters, else (default) - creates a new one
00190     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
00191     #  @ingroup l3_hypos_1dhyps
00192     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
00193         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
00194             reversedEdges, UseExisting = [], reversedEdges
00195         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
00196         entry = self.MainShapeEntry()
00197         compFun = lambda hyp, args: ( hyp.GetPoints() == args[0] and \
00198                                       hyp.GetNbSegments() == args[1] and \
00199                                       hyp.GetReversedEdges() == args[2] and \
00200                                       (not args[2] or hyp.GetObjectEntry() == args[3]))
00201         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
00202                               UseExisting=UseExisting, CompareMethod=compFun)
00203         hyp.SetPoints(points)
00204         hyp.SetNbSegments(nbSegs)
00205         hyp.SetReversedEdges(reversedEdgeInd)
00206         hyp.SetObjectEntry(entry)
00207         return hyp
00208 
00209     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
00210     #  @param start defines the length of the first segment
00211     #  @param end   defines the length of the last  segment
00212     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
00213     #                       A list item can also be a tuple (edge 1st_vertex_of_edge)
00214     #  @param UseExisting if ==true - searches for an existing hypothesis created with
00215     #                     the same parameters, else (default) - creates a new one
00216     #  @return an instance of StdMeshers_StartEndLength hypothesis
00217     #  @ingroup l3_hypos_1dhyps
00218     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
00219         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
00220             reversedEdges, UseExisting = [], reversedEdges
00221         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
00222         entry = self.MainShapeEntry()
00223         compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
00224                                       IsEqual(hyp.GetLength(0), args[1]) and \
00225                                       hyp.GetReversedEdges() == args[2]  and \
00226                                       (not args[2] or hyp.GetObjectEntry() == args[3]))
00227         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
00228                               UseExisting=UseExisting, CompareMethod=compFun)
00229         hyp.SetStartLength(start)
00230         hyp.SetEndLength(end)
00231         hyp.SetReversedEdges( reversedEdgeInd )
00232         hyp.SetObjectEntry( entry )
00233         return hyp
00234 
00235     ## Defines "Deflection1D" hypothesis
00236     #  @param d for the deflection
00237     #  @param UseExisting if ==true - searches for an existing hypothesis created with
00238     #                     the same parameters, else (default) - create a new one
00239     #  @ingroup l3_hypos_1dhyps
00240     def Deflection1D(self, d, UseExisting=0):
00241         compFun = lambda hyp, args: IsEqual(hyp.GetDeflection(), args[0])
00242         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting, CompareMethod=compFun)
00243         hyp.SetDeflection(d)
00244         return hyp
00245 
00246     ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
00247     #  the opposite side in case of quadrangular faces
00248     #  @ingroup l3_hypos_additi
00249     def Propagation(self):
00250         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
00251 
00252     ## Defines "AutomaticLength" hypothesis
00253     #  @param fineness for the fineness [0-1]
00254     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
00255     #                     same parameters, else (default) - create a new one
00256     #  @ingroup l3_hypos_1dhyps
00257     def AutomaticLength(self, fineness=0, UseExisting=0):
00258         compFun = lambda hyp, args: IsEqual(hyp.GetFineness(), args[0])
00259         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
00260                               CompareMethod=compFun)
00261         hyp.SetFineness( fineness )
00262         return hyp
00263 
00264     ## Defines "SegmentLengthAroundVertex" hypothesis
00265     #  @param length for the segment length
00266     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
00267     #         Any other integer value means that the hypothesis will be set on the
00268     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
00269     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
00270     #                   the same parameters, else (default) - creates a new one
00271     #  @ingroup l3_algos_segmarv
00272     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
00273         import types
00274         store_geom = self.geom
00275         if type(vertex) is types.IntType:
00276             if vertex == 0 or vertex == 1:
00277                 import geompyDC
00278                 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
00279                 self.geom = vertex
00280                 pass
00281             pass
00282         else:
00283             self.geom = vertex
00284             pass
00285         ### 0D algorithm
00286         if self.geom is None:
00287             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
00288         AssureGeomPublished( self.mesh, self.geom )
00289         name = GetName(self.geom)
00290 
00291         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
00292         if algo is None:
00293             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
00294             pass
00295         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
00296         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
00297         ###
00298         comFun = lambda hyp, args: IsEqual(hyp.GetLength(), args[0])
00299         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
00300                               CompareMethod=comFun)
00301         self.geom = store_geom
00302         hyp.SetLength( length )
00303         return hyp
00304 
00305     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
00306     #  If the 2D mesher sees that all boundary edges are quadratic,
00307     #  it generates quadratic faces, else it generates linear faces using
00308     #  medium nodes as if they are vertices.
00309     #  The 3D mesher generates quadratic volumes only if all boundary faces
00310     #  are quadratic, else it fails.
00311     #
00312     #  @ingroup l3_hypos_additi
00313     def QuadraticMesh(self):
00314         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
00315         return hyp
00316 
00317 # Public class: Mesh_CompositeSegment
00318 # --------------------------
00319 
00320 ## A regular 1D algorithm for discretization of a set of adjacent edges as one.
00321 #  It is created by calling Mesh.Segment(COMPOSITE,geom=0)
00322 #
00323 #  @ingroup l3_algos_basic
00324 class StdMeshersDC_CompositeSegment(StdMeshersDC_Segment):
00325 
00326     ## Name of method of class Mesh creating an instance of this class
00327     meshMethod = "Segment"
00328     ## Name of algorithm type
00329     algoType   = COMPOSITE
00330     isDefault  = False
00331 
00332     ## Private constructor.
00333     def __init__(self, mesh, geom=0):
00334         self.Create(mesh, geom, self.algoType)
00335 
00336 
00337 # Public class: Mesh_Segment_Python
00338 # ---------------------------------
00339 
00340 ## Defines a segment 1D algorithm for discretization with python function
00341 #  It is created by calling Mesh.Segment(PYTHON,geom=0)
00342 #
00343 #  @ingroup l3_algos_basic
00344 class StdMeshersDC_Segment_Python(Mesh_Algorithm):
00345 
00346     ## Name of method of class Mesh creating an instance of this class
00347     meshMethod = "Segment"
00348     ## Name of algorithm type
00349     algoType   = PYTHON
00350 
00351     ## Private constructor.
00352     def __init__(self, mesh, geom=0):
00353         import Python1dPlugin
00354         self.Create(mesh, geom, self.algoType, "libPython1dEngine.so")
00355 
00356     ## Defines "PythonSplit1D" hypothesis
00357     #  @param n for the number of segments that cut an edge
00358     #  @param func for the python function that calculates the length of all segments
00359     #  @param UseExisting if ==true - searches for the existing hypothesis created with
00360     #                     the same parameters, else (default) - creates a new one
00361     #  @ingroup l3_hypos_1dhyps
00362     def PythonSplit1D(self, n, func, UseExisting=0):
00363         compFun = lambda hyp, args: False
00364         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
00365                               UseExisting=UseExisting, CompareMethod=compFun)
00366         hyp.SetNumberOfSegments(n)
00367         hyp.SetPythonLog10RatioFunction(func)
00368         return hyp
00369 
00370 # Public class: Mesh_Triangle_MEFISTO
00371 # -----------------------------------
00372 
00373 ## Triangle MEFISTO 2D algorithm
00374 #  It is created by calling Mesh.Triangle(MEFISTO,geom=0)
00375 #
00376 #  @ingroup l3_algos_basic
00377 class StdMeshersDC_Triangle_MEFISTO(Mesh_Algorithm):
00378 
00379     ## Name of method of class Mesh creating an instance of this class
00380     meshMethod = "Triangle"
00381     ## Name of algorithm type
00382     algoType   = MEFISTO
00383     isDefault  = True
00384 
00385     ## Private constructor.
00386     def __init__(self, mesh, geom=0):
00387         Mesh_Algorithm.__init__(self)
00388         self.Create(mesh, geom, self.algoType)
00389 
00390     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
00391     #  @param area for the maximum area of each triangle
00392     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
00393     #                     same parameters, else (default) - creates a new one
00394     #
00395     #  @ingroup l3_hypos_2dhyps
00396     def MaxElementArea(self, area, UseExisting=0):
00397         comparator = lambda hyp, args: IsEqual(hyp.GetMaxElementArea(), args[0])
00398         hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
00399                               CompareMethod=comparator)
00400         hyp.SetMaxElementArea(area)
00401         return hyp
00402 
00403     ## Defines "LengthFromEdges" hypothesis to build triangles
00404     #  based on the length of the edges taken from the wire
00405     #
00406     #  @ingroup l3_hypos_2dhyps
00407     def LengthFromEdges(self):
00408         hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
00409         return hyp
00410 
00411 # Public class: Mesh_Quadrangle
00412 # -----------------------------
00413 
00414 ## Defines a quadrangle 2D algorithm
00415 #  It is created by calling Mesh.Quadrangle(geom=0)
00416 #
00417 #  @ingroup l3_algos_basic
00418 class StdMeshersDC_Quadrangle(Mesh_Algorithm):
00419 
00420     ## Name of method of class Mesh creating an instance of this class
00421     meshMethod = "Quadrangle"
00422     ## Name of algorithm type
00423     algoType   = QUADRANGLE
00424     isDefault  = True
00425 
00426     params=0
00427 
00428     ## Private constructor.
00429     def __init__(self, mesh, geom=0):
00430         Mesh_Algorithm.__init__(self)
00431         self.Create(mesh, geom, self.algoType)
00432         return
00433 
00434     ## Defines "QuadrangleParameters" hypothesis
00435     #  @param quadType defines the algorithm of transition between differently descretized
00436     #                  sides of a geometrical face:
00437     #  - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
00438     #                    area along the finer meshed sides.
00439     #  - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
00440     #                    finer meshed sides.
00441     #  - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
00442     #                    the finer meshed sides, iff the total quantity of segments on
00443     #                    all four sides of the face is even (divisible by 2).
00444     #  - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
00445     #                    area is located along the coarser meshed sides.
00446     #  - QUAD_REDUCED - only quadrangles are built and the transition between the sides
00447     #                    is made gradually, layer by layer. This type has a limitation on
00448     #                    the number of segments: one pair of opposite sides must have the
00449     #                    same number of segments, the other pair must have an even difference
00450     #                    between the numbers of segments on the sides.
00451     #  @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
00452     #                  will be created while other elements will be quadrangles.
00453     #                  Vertex can be either a GEOM_Object or a vertex ID within the
00454     #                  shape to mesh
00455     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
00456     #                  the same parameters, else (default) - creates a new one
00457     #  @ingroup l3_hypos_quad
00458     def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
00459         import GEOM
00460         vertexID = triangleVertex
00461         if isinstance( triangleVertex, GEOM._objref_GEOM_Object ):
00462             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
00463         if not self.params:
00464             compFun = lambda hyp,args: \
00465                       hyp.GetQuadType() == args[0] and \
00466                       ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
00467             self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
00468                                           UseExisting = UseExisting, CompareMethod=compFun)
00469             pass
00470         if self.params.GetQuadType() != quadType:
00471             self.params.SetQuadType(quadType)
00472         if vertexID > 0:
00473             self.params.SetTriaVertex( vertexID )
00474         return self.params
00475 
00476     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
00477     #   quadrangles are built in the transition area along the finer meshed sides,
00478     #   iff the total quantity of segments on all four sides of the face is even.
00479     #  @param reversed if True, transition area is located along the coarser meshed sides.
00480     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
00481     #                  the same parameters, else (default) - creates a new one
00482     #  @ingroup l3_hypos_quad
00483     def QuadranglePreference(self, reversed=False, UseExisting=0):
00484         if reversed:
00485             return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
00486         return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
00487 
00488     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
00489     #   triangles are built in the transition area along the finer meshed sides.
00490     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
00491     #                  the same parameters, else (default) - creates a new one
00492     #  @ingroup l3_hypos_quad
00493     def TrianglePreference(self, UseExisting=0):
00494         return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
00495 
00496     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
00497     #   quadrangles are built and the transition between the sides is made gradually,
00498     #   layer by layer. This type has a limitation on the number of segments: one pair
00499     #   of opposite sides must have the same number of segments, the other pair must
00500     #   have an even difference between the numbers of segments on the sides.
00501     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
00502     #                  the same parameters, else (default) - creates a new one
00503     #  @ingroup l3_hypos_quad
00504     def Reduced(self, UseExisting=0):
00505         return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
00506 
00507     ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
00508     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
00509     #                 will be created while other elements will be quadrangles.
00510     #                 Vertex can be either a GEOM_Object or a vertex ID within the
00511     #                 shape to mesh
00512     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
00513     #                   the same parameters, else (default) - creates a new one
00514     #  @ingroup l3_hypos_quad
00515     def TriangleVertex(self, vertex, UseExisting=0):
00516         return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
00517 
00518 
00519 # Public class: Mesh_Hexahedron
00520 # ------------------------------
00521 
00522 ## Defines a hexahedron 3D algorithm
00523 #  It is created by calling Mesh.Hexahedron(geom=0)
00524 #
00525 #  @ingroup l3_algos_basic
00526 class StdMeshersDC_Hexahedron(Mesh_Algorithm):
00527 
00528     ## Name of method of class Mesh creating an instance of this class
00529     meshMethod = "Hexahedron"
00530     ## Name of algorithm type
00531     algoType   = Hexa
00532     isDefault  = True
00533 
00534     ## Private constructor.
00535     def __init__(self, mesh, geom=0):
00536         Mesh_Algorithm.__init__(self)
00537         self.Create(mesh, geom, Hexa)
00538         pass
00539 
00540 # Public class: Mesh_Projection1D
00541 # -------------------------------
00542 
00543 ## Defines a projection 1D algorithm
00544 #  It is created by calling Mesh.Projection1D(geom=0)
00545 #  @ingroup l3_algos_proj
00546 #
00547 class StdMeshersDC_Projection1D(Mesh_Algorithm):
00548 
00549     ## Name of method of class Mesh creating an instance of this class
00550     meshMethod = "Projection1D"
00551     ## Name of algorithm type
00552     algoType   = "Projection_1D"
00553     isDefault  = True
00554 
00555     ## Private constructor.
00556     def __init__(self, mesh, geom=0):
00557         Mesh_Algorithm.__init__(self)
00558         self.Create(mesh, geom, self.algoType)
00559 
00560     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
00561     #  a mesh pattern is taken, and, optionally, the association of vertices
00562     #  between the source edge and a target edge (to which a hypothesis is assigned)
00563     #  @param edge from which nodes distribution is taken
00564     #  @param mesh from which nodes distribution is taken (optional)
00565     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
00566     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
00567     #  to associate with \a srcV (optional)
00568     #  @param UseExisting if ==true - searches for the existing hypothesis created with
00569     #                     the same parameters, else (default) - creates a new one
00570     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
00571         AssureGeomPublished( self.mesh, edge )
00572         AssureGeomPublished( self.mesh, srcV )
00573         AssureGeomPublished( self.mesh, tgtV )
00574         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
00575                               UseExisting=0)
00576         # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
00577                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
00578         hyp.SetSourceEdge( edge )
00579         if not mesh is None and isinstance(mesh, Mesh):
00580             mesh = mesh.GetMesh()
00581         hyp.SetSourceMesh( mesh )
00582         hyp.SetVertexAssociation( srcV, tgtV )
00583         return hyp
00584 
00585 
00586 # Public class: Mesh_Projection2D
00587 # ------------------------------
00588 
00589 ## Defines a projection 2D algorithm
00590 #  It is created by calling Mesh.Projection2D(geom=0)
00591 #  @ingroup l3_algos_proj
00592 #
00593 class StdMeshersDC_Projection2D(Mesh_Algorithm):
00594 
00595     ## Name of method of class Mesh creating an instance of this class
00596     meshMethod = "Projection2D"
00597     ## Name of algorithm type
00598     algoType   = "Projection_2D"
00599     isDefault  = True
00600 
00601     ## Private constructor.
00602     def __init__(self, mesh, geom=0):
00603         Mesh_Algorithm.__init__(self)
00604         self.Create(mesh, geom, self.algoType)
00605 
00606     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
00607     #  a mesh pattern is taken, and, optionally, the association of vertices
00608     #  between the source face and the target face (to which a hypothesis is assigned)
00609     #  @param face from which the mesh pattern is taken
00610     #  @param mesh from which the mesh pattern is taken (optional)
00611     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
00612     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
00613     #               to associate with \a srcV1 (optional)
00614     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
00615     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
00616     #               to associate with \a srcV2 (optional)
00617     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
00618     #                     the same parameters, else (default) - forces the creation a new one
00619     #
00620     #  Note: all association vertices must belong to one edge of a face
00621     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
00622                    srcV2=None, tgtV2=None, UseExisting=0):
00623         from smeshDC import Mesh
00624         if isinstance(mesh, Mesh):
00625             mesh = mesh.GetMesh()
00626         for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
00627             AssureGeomPublished( self.mesh, geom )
00628         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
00629                               UseExisting=0)
00630         # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
00631                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
00632         hyp.SetSourceFace( face )
00633         hyp.SetSourceMesh( mesh )
00634         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
00635         return hyp
00636 
00637 # Public class: Mesh_Projection1D2D
00638 # ---------------------------------
00639 
00640 ## Defines a projection 1D-2D algorithm
00641 #  It is created by calling Mesh.Projection1D2D(geom=0)
00642 #
00643 #  @ingroup l3_algos_proj
00644 
00645 class StdMeshersDC_Projection1D2D(StdMeshersDC_Projection2D):
00646 
00647     ## Name of method of class Mesh creating an instance of this class
00648     meshMethod = "Projection1D2D"
00649     ## Name of algorithm type
00650     algoType   = "Projection_1D2D"
00651 
00652     ## Private constructor.
00653     def __init__(self, mesh, geom=0):
00654         StdMeshersDC_Projection2D.__init__(self, mesh, geom)
00655 
00656 # Public class: Mesh_Projection3D
00657 # ------------------------------
00658 
00659 ## Defines a projection 3D algorithm
00660 #  It is created by calling Mesh.Projection3D(COMPOSITE)
00661 #
00662 #  @ingroup l3_algos_proj
00663 #
00664 class StdMeshersDC_Projection3D(Mesh_Algorithm):
00665 
00666     ## Name of method of class Mesh creating an instance of this class
00667     meshMethod = "Projection3D"
00668     ## Name of algorithm type
00669     algoType   = "Projection_3D"
00670 
00671     ## Private constructor.
00672     def __init__(self, mesh, geom=0):
00673         Mesh_Algorithm.__init__(self)
00674         self.Create(mesh, geom, self.algoType)
00675 
00676     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
00677     #  the mesh pattern is taken, and, optionally, the  association of vertices
00678     #  between the source and the target solid  (to which a hipothesis is assigned)
00679     #  @param solid from where the mesh pattern is taken
00680     #  @param mesh from where the mesh pattern is taken (optional)
00681     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
00682     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
00683     #  to associate with \a srcV1 (optional)
00684     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
00685     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
00686     #  to associate with \a srcV2 (optional)
00687     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
00688     #                     the same parameters, else (default) - creates a new one
00689     #
00690     #  Note: association vertices must belong to one edge of a solid
00691     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
00692                       srcV2=0, tgtV2=0, UseExisting=0):
00693         for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
00694             AssureGeomPublished( self.mesh, geom )
00695         hyp = self.Hypothesis("ProjectionSource3D",
00696                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
00697                               UseExisting=0)
00698         # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
00699                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
00700         hyp.SetSource3DShape( solid )
00701         if isinstance(mesh, Mesh):
00702             mesh = mesh.GetMesh()
00703         if mesh:
00704             hyp.SetSourceMesh( mesh )
00705         if srcV1 and srcV2 and tgtV1 and tgtV2:
00706             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
00707         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
00708         return hyp
00709 
00710 # Public class: Mesh_Prism
00711 # ------------------------
00712 
00713 ## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism"
00714 #  depending on geometry
00715 #  It is created by calling Mesh.Prism(geom=0)
00716 #
00717 #  @ingroup l3_algos_3dextr
00718 #
00719 class StdMeshersDC_Prism3D(Mesh_Algorithm):
00720 
00721     ## Name of method of class Mesh creating an instance of this class
00722     meshMethod = "Prism"
00723     ## Name of algorithm type
00724     algoType   = "Prism_3D"
00725 
00726     ## Private constructor.
00727     def __init__(self, mesh, geom=0):
00728         Mesh_Algorithm.__init__(self)
00729         
00730         shape = geom
00731         if not shape:
00732             shape = mesh.geom
00733         from geompy import SubShapeAll, ShapeType
00734         nbSolids = len( SubShapeAll( shape, ShapeType["SOLID"] ))
00735         nbShells = len( SubShapeAll( shape, ShapeType["SHELL"] ))
00736         if nbSolids == 0 or nbSolids == nbShells:
00737             self.Create(mesh, geom, "Prism_3D")
00738         else:
00739             self.algoType = "RadialPrism_3D"
00740             self.Create(mesh, geom, "RadialPrism_3D")
00741             self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
00742             self.nbLayers = None
00743 
00744     ## Return 3D hypothesis holding the 1D one
00745     def Get3DHypothesis(self):
00746         if self.algoType != "RadialPrism_3D":
00747             print "Prism_3D algorith doesn't support any hyposesis"
00748             return None
00749         return self.distribHyp
00750 
00751     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
00752     #  hypothesis. Returns the created hypothesis
00753     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
00754         if self.algoType != "RadialPrism_3D":
00755             print "Prism_3D algorith doesn't support any hyposesis"
00756             return None
00757         if not self.nbLayers is None:
00758             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
00759             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
00760         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
00761         self.mesh.smeshpyD.SetCurrentStudy( None )
00762         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
00763         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
00764         self.distribHyp.SetLayerDistribution( hyp )
00765         return hyp
00766 
00767     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
00768     #  prisms to build between the inner and outer shells
00769     #  @param n number of layers
00770     #  @param UseExisting if ==true - searches for the existing hypothesis created with
00771     #                     the same parameters, else (default) - creates a new one
00772     def NumberOfLayers(self, n, UseExisting=0):
00773         if self.algoType != "RadialPrism_3D":
00774             print "Prism_3D algorith doesn't support any hyposesis"
00775             return None
00776         self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
00777         compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
00778         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
00779                                         CompareMethod=compFun)
00780         self.nbLayers.SetNumberOfLayers( n )
00781         return self.nbLayers
00782 
00783     ## Defines "LocalLength" hypothesis, specifying the segment length
00784     #  to build between the inner and the outer shells
00785     #  @param l the length of segments
00786     #  @param p the precision of rounding
00787     def LocalLength(self, l, p=1e-07):
00788         if self.algoType != "RadialPrism_3D":
00789             print "Prism_3D algorith doesn't support any hyposesis"
00790             return None
00791         hyp = self.OwnHypothesis("LocalLength", [l,p])
00792         hyp.SetLength(l)
00793         hyp.SetPrecision(p)
00794         return hyp
00795 
00796     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
00797     #  prisms to build between the inner and the outer shells.
00798     #  @param n the number of layers
00799     #  @param s the scale factor (optional)
00800     def NumberOfSegments(self, n, s=[]):
00801         if self.algoType != "RadialPrism_3D":
00802             print "Prism_3D algorith doesn't support any hyposesis"
00803             return None
00804         if s == []:
00805             hyp = self.OwnHypothesis("NumberOfSegments", [n])
00806         else:
00807             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
00808             hyp.SetDistrType( 1 )
00809             hyp.SetScaleFactor(s)
00810         hyp.SetNumberOfSegments(n)
00811         return hyp
00812 
00813     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
00814     #  to build between the inner and the outer shells with a length that changes in arithmetic progression
00815     #  @param start  the length of the first segment
00816     #  @param end    the length of the last  segment
00817     def Arithmetic1D(self, start, end ):
00818         if self.algoType != "RadialPrism_3D":
00819             print "Prism_3D algorith doesn't support any hyposesis"
00820             return None
00821         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
00822         hyp.SetLength(start, 1)
00823         hyp.SetLength(end  , 0)
00824         return hyp
00825 
00826     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
00827     #  to build between the inner and the outer shells as geometric length increasing
00828     #  @param start for the length of the first segment
00829     #  @param end   for the length of the last  segment
00830     def StartEndLength(self, start, end):
00831         if self.algoType != "RadialPrism_3D":
00832             print "Prism_3D algorith doesn't support any hyposesis"
00833             return None
00834         hyp = self.OwnHypothesis("StartEndLength", [start, end])
00835         hyp.SetLength(start, 1)
00836         hyp.SetLength(end  , 0)
00837         return hyp
00838 
00839     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
00840     #  to build between the inner and outer shells
00841     #  @param fineness defines the quality of the mesh within the range [0-1]
00842     def AutomaticLength(self, fineness=0):
00843         if self.algoType != "RadialPrism_3D":
00844             print "Prism_3D algorith doesn't support any hyposesis"
00845             return None
00846         hyp = self.OwnHypothesis("AutomaticLength")
00847         hyp.SetFineness( fineness )
00848         return hyp
00849 
00850 
00851 # Public class: Mesh_RadialQuadrangle1D2D
00852 # -------------------------------
00853 
00854 ## Defines a Radial Quadrangle 1D2D algorithm
00855 #  It is created by calling Mesh.Quadrangle(RADIAL_QUAD,geom=0)
00856 #
00857 #  @ingroup l2_algos_radialq
00858 class StdMeshersDC_RadialQuadrangle1D2D(Mesh_Algorithm):
00859 
00860     ## Name of method of class Mesh creating an instance of this class
00861     meshMethod = "Quadrangle"
00862     ## Name of algorithm type
00863     algoType   = RADIAL_QUAD
00864 
00865     ## Private constructor.
00866     def __init__(self, mesh, geom=0):
00867         Mesh_Algorithm.__init__(self)
00868         self.Create(mesh, geom, self.algoType)
00869 
00870         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
00871         self.nbLayers = None
00872 
00873     ## Return 2D hypothesis holding the 1D one
00874     def Get2DHypothesis(self):
00875         if not self.distribHyp:
00876             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
00877         return self.distribHyp
00878 
00879     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
00880     #  hypothesis. Returns the created hypothesis
00881     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
00882         if self.nbLayers:
00883             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
00884         if self.distribHyp is None:
00885             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
00886         else:
00887             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
00888         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
00889         self.mesh.smeshpyD.SetCurrentStudy( None )
00890         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
00891         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
00892         self.distribHyp.SetLayerDistribution( hyp )
00893         return hyp
00894 
00895     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
00896     #  @param n number of layers
00897     #  @param UseExisting if ==true - searches for the existing hypothesis created with
00898     #                     the same parameters, else (default) - creates a new one
00899     def NumberOfLayers(self, n, UseExisting=0):
00900         if self.distribHyp:
00901             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
00902         compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
00903         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
00904                                         CompareMethod=compFun)
00905         self.nbLayers.SetNumberOfLayers( n )
00906         return self.nbLayers
00907 
00908     ## Defines "LocalLength" hypothesis, specifying the segment length
00909     #  @param l the length of segments
00910     #  @param p the precision of rounding
00911     def LocalLength(self, l, p=1e-07):
00912         hyp = self.OwnHypothesis("LocalLength", [l,p])
00913         hyp.SetLength(l)
00914         hyp.SetPrecision(p)
00915         return hyp
00916 
00917     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
00918     #  @param n the number of layers
00919     #  @param s the scale factor (optional)
00920     def NumberOfSegments(self, n, s=[]):
00921         if s == []:
00922             hyp = self.OwnHypothesis("NumberOfSegments", [n])
00923         else:
00924             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
00925             hyp.SetDistrType( 1 )
00926             hyp.SetScaleFactor(s)
00927         hyp.SetNumberOfSegments(n)
00928         return hyp
00929 
00930     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
00931     #  with a length that changes in arithmetic progression
00932     #  @param start  the length of the first segment
00933     #  @param end    the length of the last  segment
00934     def Arithmetic1D(self, start, end ):
00935         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
00936         hyp.SetLength(start, 1)
00937         hyp.SetLength(end  , 0)
00938         return hyp
00939 
00940     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
00941     #  as geometric length increasing
00942     #  @param start for the length of the first segment
00943     #  @param end   for the length of the last  segment
00944     def StartEndLength(self, start, end):
00945         hyp = self.OwnHypothesis("StartEndLength", [start, end])
00946         hyp.SetLength(start, 1)
00947         hyp.SetLength(end  , 0)
00948         return hyp
00949 
00950     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
00951     #  @param fineness defines the quality of the mesh within the range [0-1]
00952     def AutomaticLength(self, fineness=0):
00953         hyp = self.OwnHypothesis("AutomaticLength")
00954         hyp.SetFineness( fineness )
00955         return hyp
00956 
00957 
00958 # Public class: Mesh_UseExistingElements
00959 # --------------------------------------
00960 ## Defines a Radial Quadrangle 1D2D algorithm
00961 #  It is created by calling Mesh.UseExisting1DElements(geom=0)
00962 #
00963 #  @ingroup l3_algos_basic
00964 class StdMeshersDC_UseExistingElements_1D(Mesh_Algorithm):
00965 
00966     ## Name of method of class Mesh creating an instance of this class
00967     meshMethod = "UseExisting1DElements"
00968     ## Name of algorithm type
00969     algoType   = "Import_1D"
00970     isDefault  = True
00971 
00972     def __init__(self, mesh, geom=0):
00973         Mesh_Algorithm.__init__(self)
00974         self.Create(mesh, geom, self.algoType)
00975         return
00976 
00977     ## Defines "Source edges" hypothesis, specifying groups of edges to import
00978     #  @param groups list of groups of edges
00979     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
00980     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
00981     #  @param UseExisting if ==true - searches for the existing hypothesis created with
00982     #                     the same parameters, else (default) - creates a new one
00983     def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
00984         for group in groups:
00985             AssureGeomPublished( self.mesh, group )
00986         compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \
00987                                       hyp.GetCopySourceMesh() == args[1], args[2] )
00988         hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
00989                               UseExisting=UseExisting, CompareMethod=compFun)
00990         hyp.SetSourceEdges(groups)
00991         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
00992         return hyp
00993 
00994 # Public class: Mesh_UseExistingElements
00995 # --------------------------------------
00996 ## Defines a Radial Quadrangle 1D2D algorithm
00997 #  It is created by calling Mesh.UseExisting2DElements(geom=0)
00998 #
00999 #  @ingroup l3_algos_basic
01000 class StdMeshersDC_UseExistingElements_1D2D(Mesh_Algorithm):
01001 
01002     ## Name of method of class Mesh creating an instance of this class
01003     meshMethod = "UseExisting2DElements"
01004     ## Name of algorithm type
01005     algoType   = "Import_1D2D"
01006     isDefault  = True
01007 
01008     def __init__(self, mesh, geom=0):
01009         Mesh_Algorithm.__init__(self)
01010         self.Create(mesh, geom, self.algoType)
01011         return
01012 
01013     ## Defines "Source faces" hypothesis, specifying groups of faces to import
01014     #  @param groups list of groups of faces
01015     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
01016     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
01017     #  @param UseExisting if ==true - searches for the existing hypothesis created with
01018     #                     the same parameters, else (default) - creates a new one
01019     def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
01020         for group in groups:
01021             AssureGeomPublished( self.mesh, group )
01022         compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \
01023                                       hyp.GetCopySourceMesh() == args[1], args[2] )
01024         hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
01025                               UseExisting=UseExisting, CompareMethod=compFun)
01026         hyp.SetSourceFaces(groups)
01027         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
01028         return hyp
01029 
01030 
01031 # Public class: Mesh_Cartesian_3D
01032 # --------------------------------------
01033 ## Defines a Body Fitting 3D algorithm
01034 #  It is created by calling Mesh.BodyFitted(geom=0)
01035 #
01036 #  @ingroup l3_algos_basic
01037 class StdMeshersDC_Cartesian_3D(Mesh_Algorithm):
01038 
01039     ## Name of method of class Mesh creating an instance of this class
01040     meshMethod = "BodyFitted"
01041     ## Name of algorithm type
01042     algoType   = "Cartesian_3D"
01043     isDefault  = True
01044 
01045     def __init__(self, mesh, geom=0):
01046         self.Create(mesh, geom, self.algoType)
01047         self.hyp = None
01048         return
01049 
01050     ## Defines "Body Fitting parameters" hypothesis
01051     #  @param xGridDef is definition of the grid along the X asix.
01052     #  It can be in either of two following forms:
01053     #  - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
01054     #  - Functions f(t) defining grid spacing at each point on grid axis. If there are
01055     #    several functions, they must be accompanied by relative coordinates of
01056     #    points dividing the whole shape into ranges where the functions apply; points
01057     #    coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
01058     #    function f(t) varies from 0.0 to 1.0 witin a shape range. 
01059     #    Examples:
01060     #    - "10.5" - defines a grid with a constant spacing
01061     #    - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
01062     #  @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
01063     #  @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
01064     #  @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
01065     #         a polyhedron of size less than hexSize/sizeThreshold is not created
01066     #  @param UseExisting if ==true - searches for the existing hypothesis created with
01067     #                     the same parameters, else (default) - creates a new one
01068     def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
01069         if not self.hyp:
01070             compFun = lambda hyp, args: False
01071             self.hyp = self.Hypothesis("CartesianParameters3D",
01072                                        [xGridDef, yGridDef, zGridDef, sizeThreshold],
01073                                        UseExisting=UseExisting, CompareMethod=compFun)
01074         if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
01075             self.mesh.AddHypothesis( self.hyp, self.geom )
01076 
01077         for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
01078             if not gridDef: raise ValueError, "Empty grid definition"
01079             if isinstance( gridDef, str ):
01080                 self.hyp.SetGridSpacing( [gridDef], [], axis )
01081             elif isinstance( gridDef[0], str ):
01082                 self.hyp.SetGridSpacing( gridDef, [], axis )
01083             elif isinstance( gridDef[0], int ) or \
01084                  isinstance( gridDef[0], float ):
01085                 self.hyp.SetGrid(gridDef, axis )
01086             else:
01087                 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
01088         self.hyp.SetSizeThreshold( sizeThreshold )
01089         return self.hyp
01090 
01091 # Public class: Mesh_UseExisting_1D
01092 # ---------------------------------
01093 ## Defines a stub 1D algorithm, which enables "manual" creation of nodes and
01094 #  segments usable by 2D algoritms
01095 #  It is created by calling Mesh.UseExistingSegments(geom=0)
01096 #
01097 #  @ingroup l3_algos_basic
01098 
01099 class StdMeshersDC_UseExisting_1D(Mesh_Algorithm):
01100 
01101     ## Name of method of class Mesh creating an instance of this class
01102     meshMethod = "UseExistingSegments"
01103     ## Name of algorithm type
01104     algoType   = "UseExisting_1D"
01105 
01106     def __init__(self, mesh, geom=0):
01107         self.Create(mesh, geom, self.algoType)
01108 
01109 
01110 # Public class: Mesh_UseExisting
01111 # -------------------------------
01112 ## Defines a stub 2D algorithm, which enables "manual" creation of nodes and
01113 #  faces usable by 3D algoritms
01114 #  It is created by calling Mesh.UseExistingFaces(geom=0)
01115 #
01116 #  @ingroup l3_algos_basic
01117 
01118 class StdMeshersDC_UseExisting_2D(Mesh_Algorithm):
01119 
01120     ## Name of method of class Mesh creating an instance of this class
01121     meshMethod = "UseExistingFaces"
01122     ## Name of algorithm type
01123     algoType   = "UseExisting_2D"
01124 
01125     def __init__(self, mesh, geom=0):
01126         self.Create(mesh, geom, self.algoType)