Lines 1-26
Link Here
|
1 |
# Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, |
|
|
2 |
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS |
3 |
# |
4 |
# This library is free software; you can redistribute it and/or |
5 |
# modify it under the terms of the GNU Lesser General Public |
6 |
# License as published by the Free Software Foundation; either |
7 |
# version 2.1 of the License. |
8 |
# |
9 |
# This library is distributed in the hope that it will be useful, |
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 |
# Lesser General Public License for more details. |
13 |
# |
14 |
# You should have received a copy of the GNU Lesser General Public |
15 |
# License along with this library; if not, write to the Free Software |
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 |
# |
18 |
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com |
19 |
# |
20 |
# File : smesh.py |
21 |
# Author : Francis KLOSS, OCC |
22 |
# Module : SMESH |
23 |
|
24 |
""" |
1 |
""" |
25 |
\namespace smesh |
2 |
\namespace smesh |
26 |
\brief Module smesh |
3 |
\brief Module smesh |
Lines 30-49
Link Here
|
30 |
import geompy |
7 |
import geompy |
31 |
import StdMeshers |
8 |
import StdMeshers |
32 |
import SMESH |
9 |
import SMESH |
|
|
10 |
from SMESH import * |
33 |
|
11 |
|
34 |
|
12 |
## Types of algo |
35 |
REGULAR = 1 |
13 |
REGULAR = 1 |
36 |
PYTHON = 2 |
14 |
PYTHON = 2 |
37 |
|
15 |
|
38 |
NETGEN = 3 |
16 |
MEFISTO = 3 |
39 |
GHS3D = 4 |
17 |
NETGEN = 4 |
|
|
18 |
GHS3D = 5 |
19 |
FULL_NETGEN = 6 |
20 |
|
21 |
## MirrorType enumeration |
22 |
POINT = SMESH_MeshEditor.POINT |
23 |
AXIS = SMESH_MeshEditor.AXIS |
24 |
PLANE = SMESH_MeshEditor.PLANE |
25 |
|
26 |
## Smooth_Method enumeration |
27 |
LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH |
28 |
CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH |
29 |
|
30 |
## Fineness enumeration(for NETGEN) |
31 |
VeryCoarse = 0 |
32 |
Coarse = 1 |
33 |
Moderate = 2 |
34 |
Fine = 3 |
35 |
VeryFine = 4 |
36 |
Custom = 5 |
37 |
|
38 |
|
39 |
NO_NAME = "NoName" |
40 |
|
40 |
|
41 |
|
41 |
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") |
42 |
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") |
42 |
smesh.SetCurrentStudy(salome.myStudy) |
43 |
smesh.SetCurrentStudy(salome.myStudy) |
43 |
|
44 |
|
|
|
45 |
## Global functions |
44 |
|
46 |
|
45 |
NO_NAME = "NoName" |
47 |
## Gets object name |
46 |
|
|
|
47 |
def GetName(obj): |
48 |
def GetName(obj): |
48 |
ior = salome.orb.object_to_string(obj) |
49 |
ior = salome.orb.object_to_string(obj) |
49 |
sobj = salome.myStudy.FindObjectIOR(ior) |
50 |
sobj = salome.myStudy.FindObjectIOR(ior) |
Lines 53-65
Link Here
|
53 |
attr = sobj.FindAttribute("AttributeName")[1] |
54 |
attr = sobj.FindAttribute("AttributeName")[1] |
54 |
return attr.Value() |
55 |
return attr.Value() |
55 |
|
56 |
|
|
|
57 |
## Sets name to object |
56 |
def SetName(obj, name): |
58 |
def SetName(obj, name): |
57 |
ior = salome.orb.object_to_string(obj) |
59 |
ior = salome.orb.object_to_string(obj) |
58 |
sobj = salome.myStudy.FindObjectIOR(ior) |
60 |
sobj = salome.myStudy.FindObjectIOR(ior) |
59 |
if not sobj is None: |
61 |
if not sobj is None: |
60 |
attr = sobj.FindAttribute("AttributeName")[1] |
62 |
attr = sobj.FindAttribute("AttributeName")[1] |
61 |
attr.SetValue(name) |
63 |
attr.SetValue(name) |
|
|
64 |
|
65 |
## Returns long value from enumeration |
66 |
# Uses for FT_... enumeration |
67 |
def EnumToLong(theItem): |
68 |
return theItem._v |
69 |
|
70 |
## Get PointStruct from vertex |
71 |
# @param theVertex is GEOM object(vertex) |
72 |
# @return SMESH.PointStruct |
73 |
def GetPointStruct(theVertex): |
74 |
[x, y, z] = geompy.PointCoordinates(theVertex) |
75 |
return PointStruct(x,y,z) |
76 |
|
77 |
## Get DirStruct from vector |
78 |
# @param theVector is GEOM object(vector) |
79 |
# @return SMESH.DirStruct |
80 |
def GetDirStruct(theVector): |
81 |
vertices = geompy.SubShapeAll( theVector, geompy.ShapeType["VERTEX"] ) |
82 |
if(len(vertices) != 2): |
83 |
print "Error: vector object is incorrect." |
84 |
return None |
85 |
p1 = geompy.PointCoordinates(vertices[0]) |
86 |
p2 = geompy.PointCoordinates(vertices[1]) |
87 |
pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) |
88 |
dir = DirStruct(pnt) |
89 |
return dir |
90 |
|
91 |
## Get AxisStruct from object |
92 |
# @param theObj is GEOM object(line or plane) |
93 |
# @return SMESH.AxisStruct |
94 |
def GetAxisStruct(theObj): |
95 |
edges = geompy.SubShapeAll( theObj, geompy.ShapeType["EDGE"] ) |
96 |
if len(edges) > 1: |
97 |
vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] ) |
98 |
vertex3, vertex4 = geompy.SubShapeAll( edges[1], geompy.ShapeType["VERTEX"] ) |
99 |
vertex1 = geompy.PointCoordinates(vertex1) |
100 |
vertex2 = geompy.PointCoordinates(vertex2) |
101 |
vertex3 = geompy.PointCoordinates(vertex3) |
102 |
vertex4 = geompy.PointCoordinates(vertex4) |
103 |
v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]] |
104 |
v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]] |
105 |
normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ] |
106 |
axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2]) |
107 |
return axis |
108 |
elif len(edges) == 1: |
109 |
vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] ) |
110 |
p1 = geompy.PointCoordinates( vertex1 ) |
111 |
p2 = geompy.PointCoordinates( vertex2 ) |
112 |
axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) |
113 |
return axis |
114 |
return None |
115 |
|
116 |
## From SMESH_Gen interface: |
117 |
# ------------------------ |
118 |
|
119 |
## Set the current mode |
120 |
def SetEmbeddedMode( theMode ): |
121 |
smesh.SetEmbeddedMode(theMode) |
122 |
|
123 |
## Get the current mode |
124 |
def IsEmbeddedMode(): |
125 |
return smesh.IsEmbeddedMode() |
126 |
|
127 |
## Set the current study |
128 |
def SetCurrentStudy( theStudy ): |
129 |
smesh.SetCurrentStudy(theStudy) |
130 |
|
131 |
## Get the current study |
132 |
def GetCurrentStudy(): |
133 |
return smesh.GetCurrentStudy() |
134 |
|
135 |
## Create Mesh object importing data from given UNV file |
136 |
# @return an instance of Mesh class |
137 |
def CreateMeshesFromUNV( theFileName ): |
138 |
aSmeshMesh = smesh.CreateMeshesFromUNV(theFileName) |
139 |
aMesh = Mesh(aSmeshMesh) |
140 |
return aMesh |
141 |
|
142 |
## Create Mesh object(s) importing data from given MED file |
143 |
# @return a list of Mesh class instances |
144 |
def CreateMeshesFromMED( theFileName ): |
145 |
aSmeshMeshes, aStatus = smesh.CreateMeshesFromMED(theFileName) |
146 |
aMeshes = [] |
147 |
for iMesh in range(len(aSmeshMeshes)) : |
148 |
aMesh = Mesh(aSmeshMeshes[iMesh]) |
149 |
aMeshes.append(aMesh) |
150 |
return aMeshes, aStatus |
151 |
|
152 |
## Create Mesh object importing data from given STL file |
153 |
# @return an instance of Mesh class |
154 |
def CreateMeshesFromSTL( theFileName ): |
155 |
aSmeshMesh = smesh.CreateMeshesFromSTL(theFileName) |
156 |
aMesh = Mesh(aSmeshMesh) |
157 |
return aMesh |
158 |
|
159 |
## From SMESH_Gen interface |
160 |
def GetSubShapesId( theMainObject, theListOfSubObjects ): |
161 |
return smesh.GetSubShapesId(theMainObject, theListOfSubObjects) |
162 |
|
163 |
|
164 |
## Filtering. Auxiliary functions: |
165 |
# ------------------------------ |
166 |
|
167 |
## Creates an empty criterion |
168 |
# @return SMESH.Filter.Criterion |
169 |
def GetEmptyCriterion(): |
170 |
Type = EnumToLong(FT_Undefined) |
171 |
Compare = EnumToLong(FT_Undefined) |
172 |
Threshold = 0 |
173 |
ThresholdStr = "" |
174 |
ThresholdID = "" |
175 |
UnaryOp = EnumToLong(FT_Undefined) |
176 |
BinaryOp = EnumToLong(FT_Undefined) |
177 |
Tolerance = 1e-07 |
178 |
TypeOfElement = ALL |
179 |
Precision = -1 ##@1e-07 |
180 |
return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID, |
181 |
UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision) |
182 |
|
183 |
## Creates a criterion by given parameters |
184 |
# @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME) |
185 |
# @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. ) |
186 |
# @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo} |
187 |
# @param Treshold is threshold value (range of ids as string, shape, numeric) |
188 |
# @param UnaryOp is FT_LogicalNOT or FT_Undefined |
189 |
# @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or |
190 |
# FT_Undefined(must be for the last criterion in criteria) |
191 |
# @return SMESH.Filter.Criterion |
192 |
def GetCriterion(elementType, |
193 |
CritType, |
194 |
Compare = FT_EqualTo, |
195 |
Treshold="", |
196 |
UnaryOp=FT_Undefined, |
197 |
BinaryOp=FT_Undefined): |
198 |
aCriterion = GetEmptyCriterion() |
199 |
aCriterion.TypeOfElement = elementType |
200 |
aCriterion.Type = EnumToLong(CritType) |
201 |
|
202 |
aTreshold = Treshold |
203 |
|
204 |
if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]: |
205 |
aCriterion.Compare = EnumToLong(Compare) |
206 |
else: |
207 |
aCriterion.Compare = EnumToLong(FT_EqualTo) |
208 |
aTreshold = Compare |
62 |
|
209 |
|
|
|
210 |
if CritType in [FT_BelongToGeom, FT_BelongToPlane, |
211 |
FT_BelongToCylinder, FT_LyingOnGeom]: |
212 |
# Check treshold |
213 |
if isinstance(aTreshold, geompy.GEOM._objref_GEOM_Object): |
214 |
aCriterion.ThresholdStr = GetName(aTreshold) |
215 |
aCriterion.ThresholdID = salome.ObjectToID(aTreshold) |
216 |
else: |
217 |
print "Error: Treshold should be a shape." |
218 |
return None |
219 |
elif CritType == FT_RangeOfIds: |
220 |
# Check treshold |
221 |
if isinstance(aTreshold, str): |
222 |
aCriterion.ThresholdStr = aTreshold |
223 |
else: |
224 |
print "Error: Treshold should be a string." |
225 |
return None |
226 |
elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]: |
227 |
# Here we don't need treshold |
228 |
if aTreshold == FT_LogicalNOT: |
229 |
aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT) |
230 |
elif aTreshold in [FT_LogicalAND, FT_LogicalOR]: |
231 |
aCriterion.BinaryOp = aTreshold |
232 |
else: |
233 |
# Check treshold |
234 |
try: |
235 |
aTreshold = float(aTreshold) |
236 |
aCriterion.Threshold = aTreshold |
237 |
except: |
238 |
print "Error: Treshold should be a number." |
239 |
return None |
240 |
|
241 |
if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT: |
242 |
aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT) |
243 |
|
244 |
if Treshold in [FT_LogicalAND, FT_LogicalOR]: |
245 |
aCriterion.BinaryOp = EnumToLong(Treshold) |
246 |
|
247 |
if UnaryOp in [FT_LogicalAND, FT_LogicalOR]: |
248 |
aCriterion.BinaryOp = EnumToLong(UnaryOp) |
249 |
|
250 |
if BinaryOp in [FT_LogicalAND, FT_LogicalOR]: |
251 |
aCriterion.BinaryOp = EnumToLong(BinaryOp) |
252 |
|
253 |
return aCriterion |
254 |
|
255 |
|
63 |
## Mother class to define algorithm, recommended to don't use directly. |
256 |
## Mother class to define algorithm, recommended to don't use directly. |
64 |
# |
257 |
# |
65 |
# More details. |
258 |
# More details. |
Lines 83-118
Link Here
|
83 |
def GetAlgorithm(self): |
276 |
def GetAlgorithm(self): |
84 |
return self.algo |
277 |
return self.algo |
85 |
|
278 |
|
|
|
279 |
## Get list of hypothesis that can be used with this algorithm |
280 |
def GetCompatibleHypothesis(self): |
281 |
list = [] |
282 |
if self.algo: |
283 |
list = self.algo.GetCompatibleHypothesis() |
284 |
return list |
285 |
|
286 |
## Get name of algo |
287 |
def GetName(self): |
288 |
GetName(self.algo) |
289 |
|
290 |
## Set name to algo |
291 |
def SetName(self, name): |
292 |
SetName(self.algo, name) |
293 |
|
294 |
## Get id of algo |
295 |
def GetId(self): |
296 |
return self.algo.GetId() |
297 |
|
86 |
## Private method. Print error message if a hypothesis was not assigned. |
298 |
## Private method. Print error message if a hypothesis was not assigned. |
87 |
def TreatHypoStatus(self, status, hypName, geomName, isAlgo): |
299 |
def TreatHypoStatus(self, status, hypName, geomName, isAlgo): |
88 |
if isAlgo: |
300 |
if isAlgo: |
89 |
hypType = "algorithm" |
301 |
hypType = "algorithm" |
90 |
else: |
302 |
else: |
91 |
hypType = "hypothesis" |
303 |
hypType = "hypothesis" |
92 |
if status == SMESH.HYP_UNKNOWN_FATAL : |
304 |
if status == HYP_UNKNOWN_FATAL : |
93 |
reason = "for unknown reason" |
305 |
reason = "for unknown reason" |
94 |
elif status == SMESH.HYP_INCOMPATIBLE : |
306 |
elif status == HYP_INCOMPATIBLE : |
95 |
reason = "this hypothesis mismatches algorithm" |
307 |
reason = "this hypothesis mismatches algorithm" |
96 |
elif status == SMESH.HYP_NOTCONFORM : |
308 |
elif status == HYP_NOTCONFORM : |
97 |
reason = "not conform mesh would be built" |
309 |
reason = "not conform mesh would be built" |
98 |
elif status == SMESH.HYP_ALREADY_EXIST : |
310 |
elif status == HYP_ALREADY_EXIST : |
99 |
reason = hypType + " of the same dimension already assigned to this shape" |
311 |
reason = hypType + " of the same dimension already assigned to this shape" |
100 |
elif status == SMESH.HYP_BAD_DIM : |
312 |
elif status == HYP_BAD_DIM : |
101 |
reason = hypType + " mismatches shape" |
313 |
reason = hypType + " mismatches shape" |
102 |
elif status == SMESH.HYP_CONCURENT : |
314 |
elif status == HYP_CONCURENT : |
103 |
reason = "there are concurrent hypotheses on sub-shapes" |
315 |
reason = "there are concurrent hypotheses on sub-shapes" |
104 |
elif status == SMESH.HYP_BAD_SUBSHAPE : |
316 |
elif status == HYP_BAD_SUBSHAPE : |
105 |
reason = "shape is neither the main one, nor its subshape, nor a valid group" |
317 |
reason = "shape is neither the main one, nor its subshape, nor a valid group" |
106 |
else: |
318 |
else: |
107 |
return |
319 |
return |
108 |
hypName = '"' + hypName + '"' |
320 |
hypName = '"' + hypName + '"' |
109 |
geomName= '"' + geomName+ '"' |
321 |
geomName= '"' + geomName+ '"' |
110 |
if status < SMESH.HYP_UNKNOWN_FATAL: |
322 |
if status < HYP_UNKNOWN_FATAL: |
111 |
print hypName, "was assigned to", geomName,"but", reason |
323 |
print hypName, "was assigned to", geomName,"but", reason |
112 |
else: |
324 |
else: |
113 |
print hypName, "was not assigned to",geomName,":", reason |
325 |
print hypName, "was not assigned to",geomName,":", reason |
114 |
pass |
326 |
pass |
115 |
|
327 |
|
116 |
## Private method. |
328 |
## Private method. |
117 |
def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"): |
329 |
def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"): |
118 |
if geom is None: |
330 |
if geom is None: |
Lines 134-140
Link Here
|
134 |
SetName(self.algo, name + "/" + hypo) |
346 |
SetName(self.algo, name + "/" + hypo) |
135 |
status = mesh.mesh.AddHypothesis(self.geom, self.algo) |
347 |
status = mesh.mesh.AddHypothesis(self.geom, self.algo) |
136 |
self.TreatHypoStatus( status, hypo, name, 1 ) |
348 |
self.TreatHypoStatus( status, hypo, name, 1 ) |
137 |
|
349 |
|
138 |
## Private method |
350 |
## Private method |
139 |
def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"): |
351 |
def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"): |
140 |
hypo = smesh.CreateHypothesis(hyp, so) |
352 |
hypo = smesh.CreateHypothesis(hyp, so) |
Lines 151-157
Link Here
|
151 |
status = self.mesh.mesh.AddHypothesis(self.geom, hypo) |
363 |
status = self.mesh.mesh.AddHypothesis(self.geom, hypo) |
152 |
self.TreatHypoStatus( status, hyp, name, 0 ) |
364 |
self.TreatHypoStatus( status, hyp, name, 0 ) |
153 |
return hypo |
365 |
return hypo |
154 |
|
366 |
|
155 |
# Public class: Mesh_Segment |
367 |
# Public class: Mesh_Segment |
156 |
# -------------------------- |
368 |
# -------------------------- |
157 |
|
369 |
|
Lines 163-176
Link Here
|
163 |
## Private constructor. |
375 |
## Private constructor. |
164 |
def __init__(self, mesh, geom=0): |
376 |
def __init__(self, mesh, geom=0): |
165 |
self.Create(mesh, geom, "Regular_1D") |
377 |
self.Create(mesh, geom, "Regular_1D") |
166 |
|
378 |
|
167 |
## Define "LocalLength" hypothesis to cut an edge in several segments with the same length |
379 |
## Define "LocalLength" hypothesis to cut an edge in several segments with the same length |
168 |
# @param l for the length of segments that cut an edge |
380 |
# @param l for the length of segments that cut an edge |
169 |
def LocalLength(self, l): |
381 |
def LocalLength(self, l): |
170 |
hyp = self.Hypothesis("LocalLength", [l]) |
382 |
hyp = self.Hypothesis("LocalLength", [l]) |
171 |
hyp.SetLength(l) |
383 |
hyp.SetLength(l) |
172 |
return hyp |
384 |
return hyp |
173 |
|
385 |
|
174 |
## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments |
386 |
## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments |
175 |
# @param n for the number of segments that cut an edge |
387 |
# @param n for the number of segments that cut an edge |
176 |
# @param s for the scale factor (optional) |
388 |
# @param s for the scale factor (optional) |
Lines 183-189
Link Here
|
183 |
hyp.SetScaleFactor(s) |
395 |
hyp.SetScaleFactor(s) |
184 |
hyp.SetNumberOfSegments(n) |
396 |
hyp.SetNumberOfSegments(n) |
185 |
return hyp |
397 |
return hyp |
186 |
|
398 |
|
187 |
## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing |
399 |
## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing |
188 |
# @param start for the length of the first segment |
400 |
# @param start for the length of the first segment |
189 |
# @param end for the length of the last segment |
401 |
# @param end for the length of the last segment |
Lines 192-198
Link Here
|
192 |
hyp.SetLength(start, 1) |
404 |
hyp.SetLength(start, 1) |
193 |
hyp.SetLength(end , 0) |
405 |
hyp.SetLength(end , 0) |
194 |
return hyp |
406 |
return hyp |
195 |
|
407 |
|
196 |
## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing |
408 |
## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing |
197 |
# @param start for the length of the first segment |
409 |
# @param start for the length of the first segment |
198 |
# @param end for the length of the last segment |
410 |
# @param end for the length of the last segment |
Lines 201-214
Link Here
|
201 |
hyp.SetLength(start, 1) |
413 |
hyp.SetLength(start, 1) |
202 |
hyp.SetLength(end , 0) |
414 |
hyp.SetLength(end , 0) |
203 |
return hyp |
415 |
return hyp |
204 |
|
416 |
|
205 |
## Define "Deflection1D" hypothesis |
417 |
## Define "Deflection1D" hypothesis |
206 |
# @param d for the deflection |
418 |
# @param d for the deflection |
207 |
def Deflection1D(self, d): |
419 |
def Deflection1D(self, d): |
208 |
hyp = self.Hypothesis("Deflection1D", [d]) |
420 |
hyp = self.Hypothesis("Deflection1D", [d]) |
209 |
hyp.SetDeflection(d) |
421 |
hyp.SetDeflection(d) |
210 |
return hyp |
422 |
return hyp |
211 |
|
423 |
|
212 |
## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in |
424 |
## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in |
213 |
# the opposite side in the case of quadrangular faces |
425 |
# the opposite side in the case of quadrangular faces |
214 |
def Propagation(self): |
426 |
def Propagation(self): |
Lines 243-249
Link Here
|
243 |
def __init__(self, mesh, geom=0): |
455 |
def __init__(self, mesh, geom=0): |
244 |
import Python1dPlugin |
456 |
import Python1dPlugin |
245 |
self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so") |
457 |
self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so") |
246 |
|
458 |
|
247 |
## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality |
459 |
## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality |
248 |
# @param n for the number of segments that cut an edge |
460 |
# @param n for the number of segments that cut an edge |
249 |
# @param func for the python function that calculate the length of all segments |
461 |
# @param func for the python function that calculate the length of all segments |
Lines 252-258
Link Here
|
252 |
hyp.SetNumberOfSegments(n) |
464 |
hyp.SetNumberOfSegments(n) |
253 |
hyp.SetPythonLog10RatioFunction(func) |
465 |
hyp.SetPythonLog10RatioFunction(func) |
254 |
return hyp |
466 |
return hyp |
255 |
|
467 |
|
256 |
# Public class: Mesh_Triangle |
468 |
# Public class: Mesh_Triangle |
257 |
# --------------------------- |
469 |
# --------------------------- |
258 |
|
470 |
|
Lines 261-281
Link Here
|
261 |
# More details. |
473 |
# More details. |
262 |
class Mesh_Triangle(Mesh_Algorithm): |
474 |
class Mesh_Triangle(Mesh_Algorithm): |
263 |
|
475 |
|
|
|
476 |
algoType = 0 |
477 |
params = 0 |
478 |
|
264 |
## Private constructor. |
479 |
## Private constructor. |
265 |
def __init__(self, mesh, geom=0): |
480 |
def __init__(self, mesh, algoType, geom=0): |
266 |
self.Create(mesh, geom, "MEFISTO_2D") |
481 |
if algoType == MEFISTO: |
|
|
482 |
self.Create(mesh, geom, "MEFISTO_2D") |
483 |
elif algoType == NETGEN: |
484 |
self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so") |
485 |
self.algoType = algoType |
267 |
|
486 |
|
268 |
## Define "MaxElementArea" hypothesis to give the maximun area of each triangles |
487 |
## Define "MaxElementArea" hypothesis to give the maximun area of each triangles |
269 |
# @param area for the maximum area of each triangles |
488 |
# @param area for the maximum area of each triangles |
270 |
def MaxElementArea(self, area): |
489 |
def MaxElementArea(self, area): |
271 |
hyp = self.Hypothesis("MaxElementArea", [area]) |
490 |
if self.algoType == MEFISTO: |
272 |
hyp.SetMaxElementArea(area) |
491 |
hyp = self.Hypothesis("MaxElementArea", [area]) |
273 |
return hyp |
492 |
hyp.SetMaxElementArea(area) |
274 |
|
493 |
return hyp |
|
|
494 |
elif self.algoType == NETGEN: |
495 |
print "Netgen 1D-2D algo doesn't support this hypothesis" |
496 |
return None |
497 |
|
275 |
## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire |
498 |
## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire |
276 |
def LengthFromEdges(self): |
499 |
def LengthFromEdges(self): |
277 |
return self.Hypothesis("LengthFromEdges") |
500 |
if self.algoType == MEFISTO: |
278 |
|
501 |
hyp = self.Hypothesis("LengthFromEdges") |
|
|
502 |
return hyp |
503 |
elif self.algoType == NETGEN: |
504 |
print "Netgen 1D-2D algo doesn't support this hypothesis" |
505 |
return None |
506 |
|
507 |
## Define "Netgen 2D Parameters" hypothesis |
508 |
def Parameters(self): |
509 |
if self.algoType == NETGEN: |
510 |
self.params = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so") |
511 |
return self.params |
512 |
elif self.algoType == MEFISTO: |
513 |
print "Mefisto algo doesn't support this hypothesis" |
514 |
return None |
515 |
|
516 |
## Set MaxSize |
517 |
def SetMaxSize(self, theSize): |
518 |
if self.params == 0: |
519 |
self.Parameters() |
520 |
self.params.SetMaxSize(theSize) |
521 |
|
522 |
## Set SecondOrder flag |
523 |
def SetSecondOrder(seld, theVal): |
524 |
if self.params == 0: |
525 |
self.Parameters() |
526 |
self.params.SetSecondOrder(theVal) |
527 |
|
528 |
## Set Optimize flag |
529 |
def SetOptimize(self, theVal): |
530 |
if self.params == 0: |
531 |
self.Parameters() |
532 |
self.params.SetOptimize(theVal) |
533 |
|
534 |
## Set Fineness |
535 |
# @param theFineness is: |
536 |
# VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom |
537 |
def SetFineness(self, theFineness): |
538 |
if self.params == 0: |
539 |
self.Parameters() |
540 |
self.params.SetFineness(theFineness) |
541 |
|
542 |
## Set GrowthRate |
543 |
def SetGrowthRate(self, theRate): |
544 |
if self.params == 0: |
545 |
self.Parameters() |
546 |
self.params.SetGrowthRate(theRate) |
547 |
|
548 |
## Set NbSegPerEdge |
549 |
def SetNbSegPerEdge(self, theVal): |
550 |
if self.params == 0: |
551 |
self.Parameters() |
552 |
self.params.SetNbSegPerEdge(theVal) |
553 |
|
554 |
## Set NbSegPerRadius |
555 |
def SetNbSegPerRadius(self, theVal): |
556 |
if self.params == 0: |
557 |
self.Parameters() |
558 |
self.params.SetNbSegPerRadius(theVal) |
559 |
|
560 |
## Set QuadAllowed flag |
561 |
def SetQuadAllowed(self, toAllow): |
562 |
if self.params == 0: |
563 |
self.Parameters() |
564 |
self.params.SetQuadAllowed(toAllow) |
565 |
|
566 |
|
279 |
# Public class: Mesh_Quadrangle |
567 |
# Public class: Mesh_Quadrangle |
280 |
# ----------------------------- |
568 |
# ----------------------------- |
281 |
|
569 |
|
Lines 287-300
Link Here
|
287 |
## Private constructor. |
575 |
## Private constructor. |
288 |
def __init__(self, mesh, geom=0): |
576 |
def __init__(self, mesh, geom=0): |
289 |
self.Create(mesh, geom, "Quadrangle_2D") |
577 |
self.Create(mesh, geom, "Quadrangle_2D") |
290 |
|
578 |
|
291 |
## Define "QuadranglePreference" hypothesis, forcing construction |
579 |
## Define "QuadranglePreference" hypothesis, forcing construction |
292 |
# of quadrangles if the number of nodes on opposite edges is not the same |
580 |
# of quadrangles if the number of nodes on opposite edges is not the same |
293 |
# in the case where the global number of nodes on edges is even |
581 |
# in the case where the global number of nodes on edges is even |
294 |
def QuadranglePreference(self): |
582 |
def QuadranglePreference(self): |
295 |
hyp = self.Hypothesis("QuadranglePreference") |
583 |
hyp = self.Hypothesis("QuadranglePreference") |
296 |
return hyp |
584 |
return hyp |
297 |
|
585 |
|
298 |
# Public class: Mesh_Tetrahedron |
586 |
# Public class: Mesh_Tetrahedron |
299 |
# ------------------------------ |
587 |
# ------------------------------ |
300 |
|
588 |
|
Lines 303-315
Link Here
|
303 |
# More details. |
591 |
# More details. |
304 |
class Mesh_Tetrahedron(Mesh_Algorithm): |
592 |
class Mesh_Tetrahedron(Mesh_Algorithm): |
305 |
|
593 |
|
|
|
594 |
params = 0 |
595 |
algoType = 0 |
596 |
|
306 |
## Private constructor. |
597 |
## Private constructor. |
307 |
def __init__(self, mesh, algo, geom=0): |
598 |
def __init__(self, mesh, algoType, geom=0): |
308 |
if algo == NETGEN: |
599 |
if algoType == NETGEN: |
309 |
self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so") |
600 |
self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so") |
310 |
elif algo == GHS3D: |
601 |
elif algoType == GHS3D: |
311 |
import GHS3DPlugin |
602 |
import GHS3DPlugin |
312 |
self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so") |
603 |
self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so") |
|
|
604 |
elif algoType == FULL_NETGEN: |
605 |
self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so") |
606 |
self.algoType = algoType |
313 |
|
607 |
|
314 |
## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral |
608 |
## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral |
315 |
# @param vol for the maximum volume of each tetrahedral |
609 |
# @param vol for the maximum volume of each tetrahedral |
Lines 318-323
Link Here
|
318 |
hyp.SetMaxElementVolume(vol) |
612 |
hyp.SetMaxElementVolume(vol) |
319 |
return hyp |
613 |
return hyp |
320 |
|
614 |
|
|
|
615 |
## Define "Netgen 3D Parameters" hypothesis |
616 |
def Parameters(self): |
617 |
if (self.algoType == FULL_NETGEN): |
618 |
self.params = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so") |
619 |
return self.params |
620 |
else: |
621 |
print "Algo doesn't support this hypothesis" |
622 |
return None |
623 |
|
624 |
## Set MaxSize |
625 |
def SetMaxSize(self, theSize): |
626 |
if self.params == 0: |
627 |
self.Parameters() |
628 |
self.params.SetMaxSize(theSize) |
629 |
|
630 |
## Set SecondOrder flag |
631 |
def SetSecondOrder(self, theVal): |
632 |
if self.params == 0: |
633 |
self.Parameters() |
634 |
self.params.SetSecondOrder(theVal) |
635 |
|
636 |
## Set Optimize flag |
637 |
def SetOptimize(self, theVal): |
638 |
if self.params == 0: |
639 |
self.Parameters() |
640 |
self.params.SetOptimize(theVal) |
641 |
|
642 |
## Set Fineness |
643 |
# @param theFineness is: |
644 |
# VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom |
645 |
def SetFineness(self, theFineness): |
646 |
if self.params == 0: |
647 |
self.Parameters() |
648 |
self.params.SetFineness(theFineness) |
649 |
|
650 |
## Set GrowthRate |
651 |
def SetGrowthRate(self, theRate): |
652 |
if self.params == 0: |
653 |
self.Parameters() |
654 |
self.params.SetGrowthRate(theRate) |
655 |
|
656 |
## Set NbSegPerEdge |
657 |
def SetNbSegPerEdge(self, theVal): |
658 |
if self.params == 0: |
659 |
self.Parameters() |
660 |
self.params.SetNbSegPerEdge(theVal) |
661 |
|
662 |
## Set NbSegPerRadius |
663 |
def SetNbSegPerRadius(self, theVal): |
664 |
if self.params == 0: |
665 |
self.Parameters() |
666 |
self.params.SetNbSegPerRadius(theVal) |
667 |
|
321 |
# Public class: Mesh_Hexahedron |
668 |
# Public class: Mesh_Hexahedron |
322 |
# ------------------------------ |
669 |
# ------------------------------ |
323 |
|
670 |
|
Lines 330-335
Link Here
|
330 |
def __init__(self, mesh, geom=0): |
677 |
def __init__(self, mesh, geom=0): |
331 |
self.Create(mesh, geom, "Hexa_3D") |
678 |
self.Create(mesh, geom, "Hexa_3D") |
332 |
|
679 |
|
|
|
680 |
# Deprecated, only for compatibility! |
333 |
# Public class: Mesh_Netgen |
681 |
# Public class: Mesh_Netgen |
334 |
# ------------------------------ |
682 |
# ------------------------------ |
335 |
|
683 |
|
Lines 356-395
Link Here
|
356 |
else: |
704 |
else: |
357 |
hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so") |
705 |
hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so") |
358 |
return hyp |
706 |
return hyp |
359 |
|
707 |
|
360 |
# Public class: Mesh |
708 |
# Public class: Mesh |
361 |
# ================== |
709 |
# ================== |
362 |
|
710 |
|
363 |
## Class to define a mesh |
711 |
## Class to define a mesh |
364 |
# |
712 |
# |
|
|
713 |
# The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor |
365 |
# More details. |
714 |
# More details. |
366 |
class Mesh: |
715 |
class Mesh: |
367 |
|
716 |
|
368 |
geom = 0 |
717 |
geom = 0 |
369 |
mesh = 0 |
718 |
mesh = 0 |
|
|
719 |
editor = 0 |
370 |
|
720 |
|
371 |
## Constructor |
721 |
## Constructor |
372 |
# |
722 |
# |
373 |
# Creates mesh on the shape \a geom, |
723 |
# Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0), |
374 |
# sets GUI name of this mesh to \a name. |
724 |
# sets GUI name of this mesh to \a name. |
375 |
# @param geom Shape to be meshed |
725 |
# @param obj Shape to be meshed or SMESH_Mesh object |
376 |
# @param name Study name of the mesh |
726 |
# @param name Study name of the mesh |
377 |
def __init__(self, geom, name=0): |
727 |
def __init__(self, obj=0, name=0): |
378 |
self.geom = geom |
728 |
if obj != 0: |
379 |
self.mesh = smesh.CreateMesh(geom) |
729 |
if isinstance(obj, geompy.GEOM._objref_GEOM_Object): |
380 |
if name == 0: |
730 |
self.geom = obj |
381 |
SetName(self.mesh, GetName(geom)) |
731 |
self.mesh = smesh.CreateMesh(self.geom) |
|
|
732 |
elif isinstance(obj, SMESH._objref_SMESH_Mesh): |
733 |
self.SetMesh(obj) |
382 |
else: |
734 |
else: |
|
|
735 |
self.mesh = smesh.CreateEmptyMesh() |
736 |
if name != 0: |
383 |
SetName(self.mesh, name) |
737 |
SetName(self.mesh, name) |
|
|
738 |
elif obj != 0: |
739 |
SetName(self.mesh, GetName(obj)) |
384 |
|
740 |
|
|
|
741 |
self.editor = self.mesh.GetMeshEditor() |
742 |
|
743 |
## Method that inits the Mesh object from SMESH_Mesh interface |
744 |
# @param theMesh is SMESH_Mesh object |
745 |
def SetMesh(self, theMesh): |
746 |
self.mesh = theMesh |
747 |
self.geom = self.mesh.GetShapeToMesh() |
748 |
|
385 |
## Method that returns the mesh |
749 |
## Method that returns the mesh |
|
|
750 |
# @return SMESH_Mesh object |
386 |
def GetMesh(self): |
751 |
def GetMesh(self): |
387 |
return self.mesh |
752 |
return self.mesh |
388 |
|
753 |
|
|
|
754 |
## Get mesh name |
755 |
def GetName(self): |
756 |
name = GetName(self.GetMesh()) |
757 |
return name |
758 |
|
759 |
## Set name to mesh |
760 |
def SetName(self, name): |
761 |
SetName(self.GetMesh(), name) |
762 |
|
763 |
## Get the subMesh object associated to a subShape. The subMesh object |
764 |
# gives access to nodes and elements IDs. |
765 |
# SubMesh will be used instead of SubShape in a next idl version to |
766 |
# adress a specific subMesh... |
767 |
def GetSubMesh(self, theSubObject, name): |
768 |
submesh = self.mesh.GetSubMesh(theSubObject, name) |
769 |
return submesh |
770 |
|
389 |
## Method that returns the shape associated to the mesh |
771 |
## Method that returns the shape associated to the mesh |
|
|
772 |
# @return GEOM_Object |
390 |
def GetShape(self): |
773 |
def GetShape(self): |
391 |
return self.geom |
774 |
return self.geom |
392 |
|
775 |
|
|
|
776 |
## Method that associates given shape to the mesh(entails the mesh recreation) |
777 |
# @param geom shape to be meshed(GEOM_Object) |
778 |
def SetShape(self, geom): |
779 |
self.mesh = smesh.CreateMesh(geom) |
780 |
|
781 |
## Return true if hypotheses are defined well |
782 |
# @param theMesh is an instance of Mesh class |
783 |
# @param theSubObject subshape of a mesh shape |
784 |
def IsReadyToCompute(self, theSubObject): |
785 |
return smesh.IsReadyToCompute(self.mesh, theSubObject) |
786 |
|
787 |
## Return errors of hypotheses definintion |
788 |
# error list is empty if everything is OK |
789 |
# @param theMesh is an instance of Mesh class |
790 |
# @param theSubObject subshape of a mesh shape |
791 |
# @return a list of errors |
792 |
def GetAlgoState(self, theSubObject): |
793 |
return smesh.GetAlgoState(self.mesh, theSubObject) |
794 |
|
795 |
## Return geometrical object the given element is built on. |
796 |
# The returned geometrical object, if not nil, is either found in the |
797 |
# study or is published by this method with the given name |
798 |
# @param theMesh is an instance of Mesh class |
799 |
# @param theElementID an id of the mesh element |
800 |
# @param theGeomName user defined name of geometrical object |
801 |
# @return GEOM::GEOM_Object instance |
802 |
def GetGeometryByMeshElement(self, theElementID, theGeomName): |
803 |
return smesh.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName ) |
804 |
|
393 |
## Returns mesh dimension depending on shape one |
805 |
## Returns mesh dimension depending on shape one |
394 |
def MeshDimension(self): |
806 |
def MeshDimension(self): |
395 |
shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] ) |
807 |
shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] ) |
Lines 402-408
Link Here
|
402 |
else: |
814 |
else: |
403 |
return 0; |
815 |
return 0; |
404 |
pass |
816 |
pass |
405 |
|
817 |
|
406 |
## Creates a segment discretization 1D algorithm. |
818 |
## Creates a segment discretization 1D algorithm. |
407 |
# If the optional \a algo parameter is not sets, this algorithm is REGULAR. |
819 |
# If the optional \a algo parameter is not sets, this algorithm is REGULAR. |
408 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
820 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
Lines 420-433
Link Here
|
420 |
return Mesh_Segment_Python(self, geom) |
832 |
return Mesh_Segment_Python(self, geom) |
421 |
else: |
833 |
else: |
422 |
return Mesh_Segment(self, geom) |
834 |
return Mesh_Segment(self, geom) |
423 |
|
835 |
|
424 |
## Creates a triangle 2D algorithm for faces. |
836 |
## Creates a triangle 2D algorithm for faces. |
425 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
837 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
426 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
838 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
|
|
839 |
# @param algo values are: smesh.MEFISTO or smesh.NETGEN |
427 |
# @param geom If defined, subshape to be meshed |
840 |
# @param geom If defined, subshape to be meshed |
428 |
def Triangle(self, geom=0): |
841 |
def Triangle(self, algo=MEFISTO, geom=0): |
429 |
return Mesh_Triangle(self, geom) |
842 |
## if Triangle(geom) is called by mistake |
430 |
|
843 |
if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)): |
|
|
844 |
geom = algo |
845 |
algo = MEFISTO |
846 |
|
847 |
return Mesh_Triangle(self, algo, geom) |
848 |
|
431 |
## Creates a quadrangle 2D algorithm for faces. |
849 |
## Creates a quadrangle 2D algorithm for faces. |
432 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
850 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
433 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
851 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
Lines 439-453
Link Here
|
439 |
# The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D |
857 |
# The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D |
440 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
858 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
441 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
859 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
442 |
# @param algo values are: smesh.NETGEN, smesh.GHS3D |
860 |
# @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN |
443 |
# @param geom If defined, subshape to be meshed |
861 |
# @param geom If defined, subshape to be meshed |
444 |
def Tetrahedron(self, algo, geom=0): |
862 |
def Tetrahedron(self, algo=NETGEN, geom=0): |
445 |
## if Tetrahedron(geom) is called by mistake |
863 |
## if Tetrahedron(geom) is called by mistake |
446 |
if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)): |
864 |
if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)): |
447 |
algo, geom = geom, algo |
865 |
algo, geom = geom, algo |
448 |
pass |
866 |
pass |
449 |
return Mesh_Tetrahedron(self, algo, geom) |
867 |
return Mesh_Tetrahedron(self, algo, geom) |
450 |
|
868 |
|
451 |
## Creates a hexahedron 3D algorithm for solids. |
869 |
## Creates a hexahedron 3D algorithm for solids. |
452 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
870 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
453 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
871 |
# Otherwise, this algorithm define a submesh based on \a geom subshape. |
Lines 455-461
Link Here
|
455 |
def Hexahedron(self, geom=0): |
873 |
def Hexahedron(self, geom=0): |
456 |
return Mesh_Hexahedron(self, geom) |
874 |
return Mesh_Hexahedron(self, geom) |
457 |
|
875 |
|
458 |
## Creates a NETGEN-based 2D or 3D independent algorithm (i.e. needs no |
876 |
## Deprecated, only for compatibility! |
|
|
877 |
# Creates a NETGEN-based 2D or 3D independent algorithm (i.e. needs no |
459 |
# discrete boundary). |
878 |
# discrete boundary). |
460 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
879 |
# If the optional \a geom parameter is not sets, this algorithm is global. |
461 |
# Otherwise, this algorithm defines a submesh based on \a geom subshape. |
880 |
# Otherwise, this algorithm defines a submesh based on \a geom subshape. |
Lines 463-474
Link Here
|
463 |
# @param geom If defined, subshape to be meshed |
882 |
# @param geom If defined, subshape to be meshed |
464 |
def Netgen(self, is3D, geom=0): |
883 |
def Netgen(self, is3D, geom=0): |
465 |
return Mesh_Netgen(self, is3D, geom) |
884 |
return Mesh_Netgen(self, is3D, geom) |
466 |
|
885 |
|
467 |
## Compute the mesh and return the status of the computation |
886 |
## Compute the mesh and return the status of the computation |
468 |
def Compute(self): |
887 |
def Compute(self, geom=0): |
469 |
ok = smesh.Compute(self.mesh, self.geom) |
888 |
if geom == 0 or not isinstance(geom, geompy.GEOM._objref_GEOM_Object): |
|
|
889 |
if self.geom == 0: |
890 |
print "Compute impossible: mesh is not constructed on geom shape." |
891 |
return 0 |
892 |
else: |
893 |
geom = self.geom |
894 |
ok = smesh.Compute(self.mesh, geom) |
470 |
if not ok: |
895 |
if not ok: |
471 |
errors = smesh.GetAlgoState( self.mesh, self.geom ) |
896 |
errors = smesh.GetAlgoState( self.mesh, geom ) |
472 |
allReasons = "" |
897 |
allReasons = "" |
473 |
for err in errors: |
898 |
for err in errors: |
474 |
if err.isGlobalAlgo: |
899 |
if err.isGlobalAlgo: |
Lines 477-485
Link Here
|
477 |
glob = " local " |
902 |
glob = " local " |
478 |
pass |
903 |
pass |
479 |
dim = str(err.algoDim) |
904 |
dim = str(err.algoDim) |
480 |
if err.name == SMESH.MISSING_ALGO: |
905 |
if err.name == MISSING_ALGO: |
481 |
reason = glob + dim + "D algorithm is missing" |
906 |
reason = glob + dim + "D algorithm is missing" |
482 |
elif err.name == SMESH.MISSING_HYPO: |
907 |
elif err.name == MISSING_HYPO: |
483 |
name = '"' + err.algoName + '"' |
908 |
name = '"' + err.algoName + '"' |
484 |
reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis" |
909 |
reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis" |
485 |
else: |
910 |
else: |
Lines 517-523
Link Here
|
517 |
self.Tetrahedron(NETGEN) |
942 |
self.Tetrahedron(NETGEN) |
518 |
pass |
943 |
pass |
519 |
return self.Compute() |
944 |
return self.Compute() |
520 |
|
945 |
|
521 |
## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron |
946 |
## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron |
522 |
# The parameter \a fineness [0.-1.] defines mesh fineness |
947 |
# The parameter \a fineness [0.-1.] defines mesh fineness |
523 |
def AutomaticHexahedralization(self, fineness=0): |
948 |
def AutomaticHexahedralization(self, fineness=0): |
Lines 532-538
Link Here
|
532 |
self.Hexahedron() |
957 |
self.Hexahedron() |
533 |
pass |
958 |
pass |
534 |
return self.Compute() |
959 |
return self.Compute() |
535 |
|
960 |
|
|
|
961 |
## Get the list of hypothesis added on a geom |
962 |
# @param geom is subhape of mesh geometry |
963 |
def GetHypothesisList(self, geom): |
964 |
return self.mesh.GetHypothesisList( geom ) |
965 |
|
536 |
## Removes all global hypotheses |
966 |
## Removes all global hypotheses |
537 |
def RemoveGlobalHypotheses(self): |
967 |
def RemoveGlobalHypotheses(self): |
538 |
current_hyps = self.mesh.GetHypothesisList( self.geom ) |
968 |
current_hyps = self.mesh.GetHypothesisList( self.geom ) |
Lines 540-610
Link Here
|
540 |
self.mesh.RemoveHypothesis( self.geom, hyp ) |
970 |
self.mesh.RemoveHypothesis( self.geom, hyp ) |
541 |
pass |
971 |
pass |
542 |
pass |
972 |
pass |
543 |
|
973 |
|
544 |
## Create a mesh group based on geometric object \a grp |
974 |
## Create a mesh group based on geometric object \a grp |
545 |
# and give a \a name, if this parameter is not defined |
975 |
# and give a \a name, if this parameter is not defined |
546 |
# the name is the same as the geometric group name |
976 |
# the name is the same as the geometric group name |
|
|
977 |
# Note: this function is obsolete. Works like GroupOnGeom(). |
547 |
# @param grp is a geometric group, a vertex, an edge, a face or a solid |
978 |
# @param grp is a geometric group, a vertex, an edge, a face or a solid |
548 |
# @param name is the name of the mesh group |
979 |
# @param name is the name of the mesh group |
|
|
980 |
# @return SMESH_GroupOnGeom |
549 |
def Group(self, grp, name=""): |
981 |
def Group(self, grp, name=""): |
550 |
if name == "": |
982 |
return self.GroupOnGeom(grp, name) |
551 |
name = grp.GetName() |
983 |
|
552 |
|
984 |
## Deprecated, only for compatibility! Please, use ExportMED() method instead. |
553 |
type = [] |
985 |
# Export the mesh in a file with the MED format and choice the \a version of MED format |
554 |
tgeo = str(grp.GetShapeType()) |
|
|
555 |
if tgeo == "VERTEX": |
556 |
type = SMESH.NODE |
557 |
elif tgeo == "EDGE": |
558 |
type = SMESH.EDGE |
559 |
elif tgeo == "FACE": |
560 |
type = SMESH.FACE |
561 |
elif tgeo == "SOLID": |
562 |
type = SMESH.VOLUME |
563 |
elif tgeo == "SHELL": |
564 |
type = SMESH.VOLUME |
565 |
elif tgeo == "COMPOUND": |
566 |
if len( geompy.GetObjectIDs( grp )) == 0: |
567 |
print "Mesh.Group: empty geometric group", GetName( grp ) |
568 |
return 0 |
569 |
tgeo = geompy.GetType(grp) |
570 |
if tgeo == geompy.ShapeType["VERTEX"]: |
571 |
type = SMESH.NODE |
572 |
elif tgeo == geompy.ShapeType["EDGE"]: |
573 |
type = SMESH.EDGE |
574 |
elif tgeo == geompy.ShapeType["FACE"]: |
575 |
type = SMESH.FACE |
576 |
elif tgeo == geompy.ShapeType["SOLID"]: |
577 |
type = SMESH.VOLUME |
578 |
|
579 |
if type == []: |
580 |
print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid" |
581 |
return 0 |
582 |
else: |
583 |
return self.mesh.CreateGroupFromGEOM(type, name, grp) |
584 |
|
585 |
## Export the mesh in a file with the MED format and choice the \a version of MED format |
586 |
# @param f is the file name |
986 |
# @param f is the file name |
587 |
# @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2 |
987 |
# @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2 |
588 |
def ExportToMED(self, f, version, opt=0): |
988 |
def ExportToMED(self, f, version, opt=0): |
589 |
self.mesh.ExportToMED(f, opt, version) |
989 |
self.mesh.ExportToMED(f, opt, version) |
590 |
|
990 |
|
591 |
## Export the mesh in a file with the MED format |
991 |
## Export the mesh in a file with the MED format |
592 |
# @param f is the file name |
992 |
# @param f is the file name |
593 |
def ExportMED(self, f, opt=0): |
993 |
# @param auto_groups boolean parameter for creating/not creating |
594 |
self.mesh.ExportMED(f, opt) |
994 |
# the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; |
595 |
|
995 |
# the typical use is auto_groups=false. |
|
|
996 |
# @param version MED format version(MED_V2_1 or MED_V2_2) |
997 |
def ExportMED(self, f, auto_groups=0, version=MED_V2_2): |
998 |
self.mesh.ExportToMED(f, auto_groups, version) |
999 |
|
596 |
## Export the mesh in a file with the DAT format |
1000 |
## Export the mesh in a file with the DAT format |
597 |
# @param f is the file name |
1001 |
# @param f is the file name |
598 |
def ExportDAT(self, f): |
1002 |
def ExportDAT(self, f): |
599 |
self.mesh.ExportDAT(f) |
1003 |
self.mesh.ExportDAT(f) |
600 |
|
1004 |
|
601 |
## Export the mesh in a file with the UNV format |
1005 |
## Export the mesh in a file with the UNV format |
602 |
# @param f is the file name |
1006 |
# @param f is the file name |
603 |
def ExportUNV(self, f): |
1007 |
def ExportUNV(self, f): |
604 |
self.mesh.ExportUNV(f) |
1008 |
self.mesh.ExportUNV(f) |
605 |
|
1009 |
|
606 |
## Export the mesh in a file with the STL format |
1010 |
## Export the mesh in a file with the STL format |
607 |
# @param f is the file name |
1011 |
# @param f is the file name |
608 |
# @param ascii defined the kind of file contents |
1012 |
# @param ascii defined the kind of file contents |
609 |
def ExportSTL(self, f, ascii=1): |
1013 |
def ExportSTL(self, f, ascii=1): |
610 |
self.mesh.ExportSTL(f, ascii) |
1014 |
self.mesh.ExportSTL(f, ascii) |
|
|
1015 |
|
1016 |
################################################################################### |
1017 |
|
1018 |
## Operations with groups |
1019 |
# ---------------------- |
1020 |
|
1021 |
## Creates an empty mesh group |
1022 |
# @param elementType is the type of elements in the group |
1023 |
# @param name is the name of the mesh group |
1024 |
# @return SMESH_Group |
1025 |
def CreateEmptyGroup(self, elementType, name): |
1026 |
return self.mesh.CreateGroup(elementType, name) |
1027 |
|
1028 |
## Creates a mesh group based on geometric object \a grp |
1029 |
# and give a \a name, if this parameter is not defined |
1030 |
# the name is the same as the geometric group name |
1031 |
# @param grp is a geometric group, a vertex, an edge, a face or a solid |
1032 |
# @param name is the name of the mesh group |
1033 |
# @return SMESH_GroupOnGeom |
1034 |
def GroupOnGeom(self, grp, name="", type=None): |
1035 |
if name == "": |
1036 |
name = grp.GetName() |
1037 |
|
1038 |
if type == None: |
1039 |
tgeo = str(grp.GetShapeType()) |
1040 |
if tgeo == "VERTEX": |
1041 |
type = NODE |
1042 |
elif tgeo == "EDGE": |
1043 |
type = EDGE |
1044 |
elif tgeo == "FACE": |
1045 |
type = FACE |
1046 |
elif tgeo == "SOLID": |
1047 |
type = VOLUME |
1048 |
elif tgeo == "SHELL": |
1049 |
type = VOLUME |
1050 |
elif tgeo == "COMPOUND": |
1051 |
if len( geompy.GetObjectIDs( grp )) == 0: |
1052 |
print "Mesh.Group: empty geometric group", GetName( grp ) |
1053 |
return 0 |
1054 |
tgeo = geompy.GetType(grp) |
1055 |
if tgeo == geompy.ShapeType["VERTEX"]: |
1056 |
type = NODE |
1057 |
elif tgeo == geompy.ShapeType["EDGE"]: |
1058 |
type = EDGE |
1059 |
elif tgeo == geompy.ShapeType["FACE"]: |
1060 |
type = FACE |
1061 |
elif tgeo == geompy.ShapeType["SOLID"]: |
1062 |
type = VOLUME |
1063 |
|
1064 |
if type == None: |
1065 |
print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid" |
1066 |
return 0 |
1067 |
else: |
1068 |
return self.mesh.CreateGroupFromGEOM(type, name, grp) |
1069 |
|
1070 |
## Create a mesh group by the given ids of elements |
1071 |
# @param groupName is the name of the mesh group |
1072 |
# @param elementType is the type of elements in the group |
1073 |
# @param elemIDs is the list of ids |
1074 |
# @return SMESH_Group |
1075 |
def MakeGroupByIds(self, groupName, elementType, elemIDs): |
1076 |
group = self.mesh.CreateGroup(elementType, groupName) |
1077 |
group.Add(elemIDs) |
1078 |
return group |
1079 |
|
1080 |
## Create a mesh group by the given conditions |
1081 |
# @param groupName is the name of the mesh group |
1082 |
# @param elementType is the type of elements in the group |
1083 |
# @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. ) |
1084 |
# @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo} |
1085 |
# @param Treshold is threshold value (range of id ids as string, shape, numeric) |
1086 |
# @param UnaryOp is FT_LogicalNOT or FT_Undefined |
1087 |
# @return SMESH_Group |
1088 |
def MakeGroup(self, |
1089 |
groupName, |
1090 |
elementType, |
1091 |
CritType=FT_Undefined, |
1092 |
Compare=FT_EqualTo, |
1093 |
Treshold="", |
1094 |
UnaryOp=FT_Undefined): |
1095 |
aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined) |
1096 |
group = self.MakeGroupByCriterion(groupName, aCriterion) |
1097 |
return group |
1098 |
|
1099 |
## Create a mesh group by the given criterion |
1100 |
# @param groupName is the name of the mesh group |
1101 |
# @param Criterion is the instance of Criterion class |
1102 |
# @return SMESH_Group |
1103 |
def MakeGroupByCriterion(self, groupName, Criterion): |
1104 |
aFilterMgr = smesh.CreateFilterManager() |
1105 |
aFilter = aFilterMgr.CreateFilter() |
1106 |
aCriteria = [] |
1107 |
aCriteria.append(Criterion) |
1108 |
aFilter.SetCriteria(aCriteria) |
1109 |
group = self.MakeGroupByFilter(groupName, aFilter) |
1110 |
return group |
1111 |
|
1112 |
## Create a mesh group by the given criteria(list of criterions) |
1113 |
# @param groupName is the name of the mesh group |
1114 |
# @param Criteria is the list of criterions |
1115 |
# @return SMESH_Group |
1116 |
def MakeGroupByCriteria(self, groupName, theCriteria): |
1117 |
aFilterMgr = smesh.CreateFilterManager() |
1118 |
aFilter = aFilterMgr.CreateFilter() |
1119 |
aFilter.SetCriteria(theCriteria) |
1120 |
group = self.MakeGroupByFilter(groupName, aFilter) |
1121 |
return group |
1122 |
|
1123 |
## Create a mesh group by the given filter |
1124 |
# @param groupName is the name of the mesh group |
1125 |
# @param Criterion is the instance of Filter class |
1126 |
# @return SMESH_Group |
1127 |
def MakeGroupByFilter(self, groupName, theFilter): |
1128 |
anIds = theFilter.GetElementsId(self.mesh) |
1129 |
anElemType = theFilter.GetElementType() |
1130 |
group = self.MakeGroupByIds(groupName, anElemType, anIds) |
1131 |
return group |
1132 |
|
1133 |
## Creates filter by given parameters of criterion |
1134 |
# @param elementType is the type of elements in the group |
1135 |
# @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. ) |
1136 |
# @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo} |
1137 |
# @param Treshold is threshold value (range of id ids as string, shape, numeric) |
1138 |
# @param UnaryOp is FT_LogicalNOT or FT_Undefined |
1139 |
# @return SMESH_Filter |
1140 |
def GetFilter(self, |
1141 |
elementType, |
1142 |
CritType=FT_Undefined, |
1143 |
Compare=FT_EqualTo, |
1144 |
Treshold="", |
1145 |
UnaryOp=FT_Undefined): |
1146 |
aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined) |
1147 |
aFilterMgr = smesh.CreateFilterManager() |
1148 |
aFilter = aFilterMgr.CreateFilter() |
1149 |
aCriteria = [] |
1150 |
aCriteria.append(aCriterion) |
1151 |
aFilter.SetCriteria(aCriteria) |
1152 |
return aFilter |
1153 |
|
1154 |
## Remove a group |
1155 |
def RemoveGroup(self, group): |
1156 |
self.mesh.RemoveGroup(group) |
1157 |
|
1158 |
## Remove group with its contents |
1159 |
def RemoveGroupWithContents(self, group): |
1160 |
self.mesh.RemoveGroupWithContents(group) |
1161 |
|
1162 |
## Get the list of groups existing in the mesh |
1163 |
def GetGroups(self): |
1164 |
return self.mesh.GetGroups() |
1165 |
|
1166 |
## Get the list of names of groups existing in the mesh |
1167 |
def GetGroupNames(self): |
1168 |
groups = self.GetGroups() |
1169 |
names = [] |
1170 |
for group in groups: |
1171 |
names.append(group.GetName()) |
1172 |
return names |
1173 |
|
1174 |
## Union of two groups |
1175 |
# New group is created. All mesh elements that are |
1176 |
# present in initial groups are added to the new one |
1177 |
def UnionGroups(self, group1, group2, name): |
1178 |
return self.mesh.UnionGroups(group1, group2, name) |
1179 |
|
1180 |
## Intersection of two groups |
1181 |
# New group is created. All mesh elements that are |
1182 |
# present in both initial groups are added to the new one. |
1183 |
def IntersectGroups(self, group1, group2, name): |
1184 |
return self.mesh.IntersectGroups(group1, group2, name) |
1185 |
|
1186 |
## Cut of two groups |
1187 |
# New group is created. All mesh elements that are present in |
1188 |
# main group but do not present in tool group are added to the new one |
1189 |
def CutGroups(self, mainGroup, toolGroup, name): |
1190 |
return self.mesh.CutGroups(mainGroup, toolGroup, name) |
1191 |
|
1192 |
|
1193 |
## Get some info about mesh: |
1194 |
# ------------------------ |
1195 |
|
1196 |
## Get the log of nodes and elements added or removed since previous |
1197 |
# clear of the log. |
1198 |
# @param clearAfterGet log is emptied after Get (safe if concurrents access) |
1199 |
# @return list of log_block structures: |
1200 |
# commandType |
1201 |
# number |
1202 |
# coords |
1203 |
# indexes |
1204 |
def GetLog(self, clearAfterGet): |
1205 |
return self.mesh.GetLog(clearAfterGet) |
1206 |
|
1207 |
## Clear the log of nodes and elements added or removed since previous |
1208 |
# clear. Must be used immediately after GetLog if clearAfterGet is false. |
1209 |
def ClearLog(self): |
1210 |
self.mesh.ClearLog() |
1211 |
|
1212 |
## Get the internal Id |
1213 |
def GetId(self): |
1214 |
return self.mesh.GetId() |
1215 |
|
1216 |
## Get the study Id |
1217 |
def GetStudyId(self): |
1218 |
return self.mesh.GetStudyId() |
1219 |
|
1220 |
## Check group names for duplications. |
1221 |
# Consider maximum group name length stored in MED file. |
1222 |
def HasDuplicatedGroupNamesMED(self): |
1223 |
return self.mesh.GetStudyId() |
1224 |
|
1225 |
## Obtain instance of SMESH_MeshEditor |
1226 |
def GetMeshEditor(self): |
1227 |
return self.mesh.GetMeshEditor() |
1228 |
|
1229 |
## Get MED Mesh |
1230 |
def GetMEDMesh(self): |
1231 |
return self.mesh.GetMEDMesh() |
1232 |
|
1233 |
|
1234 |
## Get informations about mesh contents: |
1235 |
# ------------------------------------ |
1236 |
|
1237 |
## Returns number of nodes in mesh |
1238 |
def NbNodes(self): |
1239 |
return self.mesh.NbNodes() |
1240 |
|
1241 |
## Returns number of elements in mesh |
1242 |
def NbElements(self): |
1243 |
return self.mesh.NbElements() |
1244 |
|
1245 |
## Returns number of edges in mesh |
1246 |
def NbEdges(self): |
1247 |
return self.mesh.NbEdges() |
1248 |
|
1249 |
## Returns number of edges with given order in mesh |
1250 |
# @param elementOrder is order of elements: |
1251 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1252 |
def NbEdgesOfOrder(self, elementOrder): |
1253 |
return self.mesh.NbEdgesOfOrder(elementOrder) |
1254 |
|
1255 |
## Returns number of faces in mesh |
1256 |
def NbFaces(self): |
1257 |
return self.mesh.NbFaces() |
1258 |
|
1259 |
## Returns number of faces with given order in mesh |
1260 |
# @param elementOrder is order of elements: |
1261 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1262 |
def NbFacesOfOrder(self, elementOrder): |
1263 |
return self.mesh.NbFacesOfOrder(elementOrder) |
1264 |
|
1265 |
## Returns number of triangles in mesh |
1266 |
def NbTriangles(self): |
1267 |
return self.mesh.NbTriangles() |
1268 |
|
1269 |
## Returns number of triangles with given order in mesh |
1270 |
# @param elementOrder is order of elements: |
1271 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1272 |
def NbTrianglesOfOrder(self, elementOrder): |
1273 |
return self.mesh.NbTrianglesOfOrder(elementOrder) |
1274 |
|
1275 |
## Returns number of quadrangles in mesh |
1276 |
def NbQuadrangles(self): |
1277 |
return self.mesh.NbQuadrangles() |
1278 |
|
1279 |
## Returns number of quadrangles with given order in mesh |
1280 |
# @param elementOrder is order of elements: |
1281 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1282 |
def NbQuadranglesOfOrder(self, elementOrder): |
1283 |
return self.mesh.NbQuadranglesOfOrder(elementOrder) |
1284 |
|
1285 |
## Returns number of polygons in mesh |
1286 |
def NbPolygons(self): |
1287 |
return self.mesh.NbPolygons() |
1288 |
|
1289 |
## Returns number of volumes in mesh |
1290 |
def NbVolumes(self): |
1291 |
return self.mesh.NbVolumes() |
1292 |
|
1293 |
## Returns number of volumes with given order in mesh |
1294 |
# @param elementOrder is order of elements: |
1295 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1296 |
def NbVolumesOfOrder(self, elementOrder): |
1297 |
return self.mesh.NbVolumesOfOrder(elementOrder) |
1298 |
|
1299 |
## Returns number of tetrahedrons in mesh |
1300 |
def NbTetras(self): |
1301 |
return self.mesh.NbTetras() |
1302 |
|
1303 |
## Returns number of tetrahedrons with given order in mesh |
1304 |
# @param elementOrder is order of elements: |
1305 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1306 |
def NbTetrasOfOrder(self, elementOrder): |
1307 |
return self.mesh.NbTetrasOfOrder(elementOrder) |
1308 |
|
1309 |
## Returns number of hexahedrons in mesh |
1310 |
def NbHexas(self): |
1311 |
return self.mesh.NbHexas() |
1312 |
|
1313 |
## Returns number of hexahedrons with given order in mesh |
1314 |
# @param elementOrder is order of elements: |
1315 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1316 |
def NbHexasOfOrder(self, elementOrder): |
1317 |
return self.mesh.NbHexasOfOrder(elementOrder) |
1318 |
|
1319 |
## Returns number of pyramids in mesh |
1320 |
def NbPyramids(self): |
1321 |
return self.mesh.NbPyramids() |
1322 |
|
1323 |
## Returns number of pyramids with given order in mesh |
1324 |
# @param elementOrder is order of elements: |
1325 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1326 |
def NbPyramidsOfOrder(self, elementOrder): |
1327 |
return self.mesh.NbPyramidsOfOrder(elementOrder) |
1328 |
|
1329 |
## Returns number of prisms in mesh |
1330 |
def NbPrisms(self): |
1331 |
return self.mesh.NbPrisms() |
1332 |
|
1333 |
## Returns number of prisms with given order in mesh |
1334 |
# @param elementOrder is order of elements: |
1335 |
# ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC |
1336 |
def NbPrismsOfOrder(self, elementOrder): |
1337 |
return self.mesh.NbPrismsOfOrder(elementOrder) |
1338 |
|
1339 |
## Returns number of polyhedrons in mesh |
1340 |
def NbPolyhedrons(self): |
1341 |
return self.mesh.NbPolyhedrons() |
1342 |
|
1343 |
## Returns number of submeshes in mesh |
1344 |
def NbSubMesh(self): |
1345 |
return self.mesh.NbSubMesh() |
1346 |
|
1347 |
## Returns list of mesh elements ids |
1348 |
def GetElementsId(self): |
1349 |
return self.mesh.GetElementsId() |
1350 |
|
1351 |
## Returns list of ids of mesh elements with given type |
1352 |
# @param elementType is required type of elements |
1353 |
def GetElementsByType(self, elementType): |
1354 |
return self.mesh.GetElementsByType(elementType) |
1355 |
|
1356 |
## Returns list of mesh nodes ids |
1357 |
def GetNodesId(self): |
1358 |
return self.mesh.GetNodesId() |
1359 |
|
1360 |
## Get informations about mesh elements: |
1361 |
# ------------------------------------ |
1362 |
|
1363 |
## Returns type of mesh element |
1364 |
def GetElementType(self, id, iselem): |
1365 |
return self.mesh.GetElementType(id, iselem) |
1366 |
|
1367 |
## Returns list of submesh elements ids |
1368 |
# @param shapeID is geom object(subshape) IOR |
1369 |
def GetSubMeshElementsId(self, shapeID): |
1370 |
return self.mesh.GetSubMeshElementsId(shapeID) |
1371 |
|
1372 |
## Returns list of submesh nodes ids |
1373 |
# @param shapeID is geom object(subshape) IOR |
1374 |
def GetSubMeshNodesId(self, shapeID, all): |
1375 |
return self.mesh.GetSubMeshNodesId(shapeID, all) |
1376 |
|
1377 |
## Returns list of ids of submesh elements with given type |
1378 |
# @param shapeID is geom object(subshape) IOR |
1379 |
def GetSubMeshElementType(self, shapeID): |
1380 |
return self.mesh.GetSubMeshElementType(shapeID) |
1381 |
|
1382 |
## Get mesh description |
1383 |
def Dump(self): |
1384 |
return self.mesh.Dump() |
1385 |
|
1386 |
|
1387 |
## Get information about nodes and elements of mesh by its ids: |
1388 |
# ----------------------------------------------------------- |
1389 |
|
1390 |
## Get XYZ coordinates of node as list of double |
1391 |
# If there is not node for given ID - returns empty list |
1392 |
def GetNodeXYZ(self, id): |
1393 |
return self.mesh.GetNodeXYZ(id) |
1394 |
|
1395 |
## For given node returns list of IDs of inverse elements |
1396 |
# If there is not node for given ID - returns empty list |
1397 |
def GetNodeInverseElements(self, id): |
1398 |
return self.mesh.GetNodeInverseElements(id) |
1399 |
|
1400 |
## If given element is node returns IDs of shape from position |
1401 |
# else - return ID of result shape after Mesh.FindShape() |
1402 |
# If there is not element for given ID - returns -1 |
1403 |
def GetShapeID(self, id): |
1404 |
return self.mesh.GetShapeID(id) |
1405 |
|
1406 |
## Returns number of nodes for given element |
1407 |
# If there is not element for given ID - returns -1 |
1408 |
def GetElemNbNodes(self, id): |
1409 |
return self.mesh.GetElemNbNodes(id) |
1410 |
|
1411 |
## Returns ID of node by given index for given element |
1412 |
# If there is not element for given ID - returns -1 |
1413 |
# If there is not node for given index - returns -2 |
1414 |
def GetElemNode(self, id, index): |
1415 |
return self.mesh.GetElemNode(id, index) |
1416 |
|
1417 |
## Returns true if given node is medium node |
1418 |
# in given quadratic element |
1419 |
def IsMediumNode(self, elementID, nodeID): |
1420 |
return self.mesh.IsMediumNode(elementID, nodeID) |
1421 |
|
1422 |
## Returns true if given node is medium node |
1423 |
# in one of quadratic elements |
1424 |
def IsMediumNodeOfAnyElem(self, nodeID, elementType): |
1425 |
return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType) |
1426 |
|
1427 |
## Returns number of edges for given element |
1428 |
def ElemNbEdges(self, id): |
1429 |
return self.mesh.ElemNbEdges(id) |
1430 |
|
1431 |
## Returns number of faces for given element |
1432 |
def ElemNbFaces(self, id): |
1433 |
return self.mesh.ElemNbFaces(id) |
1434 |
|
1435 |
## Returns true if given element is polygon |
1436 |
def IsPoly(self, id): |
1437 |
return self.mesh.IsPoly(id) |
1438 |
|
1439 |
## Returns true if given element is quadratic |
1440 |
def IsQuadratic(self, id): |
1441 |
return self.mesh.IsQuadratic(id) |
1442 |
|
1443 |
## Returns XYZ coordinates of bary center for given element |
1444 |
# as list of double |
1445 |
# If there is not element for given ID - returns empty list |
1446 |
def BaryCenter(self, id): |
1447 |
return self.mesh.BaryCenter(id) |
1448 |
|
1449 |
|
1450 |
## Mesh edition (SMESH_MeshEditor functionality): |
1451 |
# --------------------------------------------- |
1452 |
|
1453 |
## Removes elements from mesh by ids |
1454 |
# @param IDsOfElements is list of ids of elements to remove |
1455 |
def RemoveElements(self, IDsOfElements): |
1456 |
return self.editor.RemoveElements(IDsOfElements) |
1457 |
|
1458 |
## Removes nodes from mesh by ids |
1459 |
# @param IDsOfNodes is list of ids of nodes to remove |
1460 |
def RemoveNodes(self, IDsOfNodes): |
1461 |
return self.editor.RemoveNodes(IDsOfNodes) |
1462 |
|
1463 |
## Add node to mesh by coordinates |
1464 |
def AddNode(self, x, y, z): |
1465 |
return self.editor.AddNode( x, y, z) |
1466 |
|
1467 |
|
1468 |
## Create edge both similar and quadratic (this is determed |
1469 |
# by number of given nodes). |
1470 |
# @param IdsOfNodes List of node IDs for creation of element. |
1471 |
# Needed order of nodes in this list corresponds to description |
1472 |
# of MED. This description is located by the following link: |
1473 |
# http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3. |
1474 |
def AddEdge(self, IDsOfNodes): |
1475 |
return self.editor.AddEdge(IDsOfNodes) |
1476 |
|
1477 |
## Create face both similar and quadratic (this is determed |
1478 |
# by number of given nodes). |
1479 |
# @param IdsOfNodes List of node IDs for creation of element. |
1480 |
# Needed order of nodes in this list corresponds to description |
1481 |
# of MED. This description is located by the following link: |
1482 |
# http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3. |
1483 |
def AddFace(self, IDsOfNodes): |
1484 |
return self.editor.AddFace(IDsOfNodes) |
1485 |
|
1486 |
## Add polygonal face to mesh by list of nodes ids |
1487 |
def AddPolygonalFace(self, IdsOfNodes): |
1488 |
return self.editor.AddPolygonalFace(IdsOfNodes) |
1489 |
|
1490 |
## Create volume both similar and quadratic (this is determed |
1491 |
# by number of given nodes). |
1492 |
# @param IdsOfNodes List of node IDs for creation of element. |
1493 |
# Needed order of nodes in this list corresponds to description |
1494 |
# of MED. This description is located by the following link: |
1495 |
# http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3. |
1496 |
def AddVolume(self, IDsOfNodes): |
1497 |
return self.editor.AddVolume(IDsOfNodes) |
1498 |
|
1499 |
## Create volume of many faces, giving nodes for each face. |
1500 |
# @param IdsOfNodes List of node IDs for volume creation face by face. |
1501 |
# @param Quantities List of integer values, Quantities[i] |
1502 |
# gives quantity of nodes in face number i. |
1503 |
def AddPolyhedralVolume (self, IdsOfNodes, Quantities): |
1504 |
return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities) |
1505 |
|
1506 |
## Create volume of many faces, giving IDs of existing faces. |
1507 |
# @param IdsOfFaces List of face IDs for volume creation. |
1508 |
# |
1509 |
# Note: The created volume will refer only to nodes |
1510 |
# of the given faces, not to the faces itself. |
1511 |
def AddPolyhedralVolumeByFaces (self, IdsOfFaces): |
1512 |
return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces) |
1513 |
|
1514 |
## Move node with given id |
1515 |
# @param NodeID id of the node |
1516 |
# @param x displacing along the X axis |
1517 |
# @param y displacing along the Y axis |
1518 |
# @param z displacing along the Z axis |
1519 |
def MoveNode(self, NodeID, x, y, z): |
1520 |
return self.editor.MoveNode(NodeID, x, y, z) |
1521 |
|
1522 |
## Replace two neighbour triangles sharing Node1-Node2 link |
1523 |
# with ones built on the same 4 nodes but having other common link. |
1524 |
# @param NodeID1 first node id |
1525 |
# @param NodeID2 second node id |
1526 |
# @return false if proper faces not found |
1527 |
def InverseDiag(self, NodeID1, NodeID2): |
1528 |
return self.editor.InverseDiag(NodeID1, NodeID2) |
1529 |
|
1530 |
## Replace two neighbour triangles sharing Node1-Node2 link |
1531 |
# with a quadrangle built on the same 4 nodes. |
1532 |
# @param NodeID1 first node id |
1533 |
# @param NodeID2 second node id |
1534 |
# @return false if proper faces not found |
1535 |
def DeleteDiag(self, NodeID1, NodeID2): |
1536 |
return self.editor.DeleteDiag(NodeID1, NodeID2) |
1537 |
|
1538 |
## Reorient elements by ids |
1539 |
# @param IDsOfElements if undefined reorient all mesh elements |
1540 |
def Reorient(self, IDsOfElements=None): |
1541 |
if IDsOfElements == None: |
1542 |
IDsOfElements = self.GetElementsId() |
1543 |
return self.editor.Reorient(IDsOfElements) |
1544 |
|
1545 |
## Reorient all elements of the object |
1546 |
# @param theObject is mesh, submesh or group |
1547 |
def ReorientObject(self, theObject): |
1548 |
return self.editor.ReorientObject(theObject) |
1549 |
|
1550 |
## Fuse neighbour triangles into quadrangles. |
1551 |
# @param IDsOfElements The triangles to be fused, |
1552 |
# @param Criterion is used to choose a neighbour to fuse with. |
1553 |
# @param MaxAngle is a max angle between element normals at which fusion |
1554 |
# is still performed; theMaxAngle is mesured in radians. |
1555 |
# @return TRUE in case of success, FALSE otherwise. |
1556 |
def TriToQuad(self, IDsOfElements, Criterion, MaxAngle): |
1557 |
if IDsOfElements == []: |
1558 |
IDsOfElements = self.GetElementsId() |
1559 |
return self.editor.TriToQuad(IDsOfElements, Criterion, MaxAngle) |
1560 |
|
1561 |
## Fuse neighbour triangles of the object into quadrangles |
1562 |
# @param theObject is mesh, submesh or group |
1563 |
# @param Criterion is used to choose a neighbour to fuse with. |
1564 |
# @param MaxAngle is a max angle between element normals at which fusion |
1565 |
# is still performed; theMaxAngle is mesured in radians. |
1566 |
# @return TRUE in case of success, FALSE otherwise. |
1567 |
def TriToQuadObject (self, theObject, Criterion, MaxAngle): |
1568 |
return self.editor.TriToQuadObject(theObject, Criterion, MaxAngle) |
1569 |
|
1570 |
## Split quadrangles into triangles. |
1571 |
# @param IDsOfElements the faces to be splitted. |
1572 |
# @param theCriterion is used to choose a diagonal for splitting. |
1573 |
# @param @return TRUE in case of success, FALSE otherwise. |
1574 |
def QuadToTri (self, IDsOfElements, Criterion): |
1575 |
if IDsOfElements == []: |
1576 |
IDsOfElements = self.GetElementsId() |
1577 |
return self.editor.QuadToTri(IDsOfElements, Criterion) |
1578 |
|
1579 |
## Split quadrangles into triangles. |
1580 |
# @param theObject object to taking list of elements from, is mesh, submesh or group |
1581 |
def QuadToTriObject (self, theObject, Criterion): |
1582 |
return self.editor.QuadToTriObject(theObject, Criterion) |
1583 |
|
1584 |
## Split quadrangles into triangles. |
1585 |
# @param theElems The faces to be splitted |
1586 |
# @param the13Diag is used to choose a diagonal for splitting. |
1587 |
# @return TRUE in case of success, FALSE otherwise. |
1588 |
def SplitQuad (self, IDsOfElements, Diag13): |
1589 |
if IDsOfElements == []: |
1590 |
IDsOfElements = self.GetElementsId() |
1591 |
return self.editor.SplitQuad(IDsOfElements, Diag13) |
1592 |
|
1593 |
## Split quadrangles into triangles. |
1594 |
# @param theObject is object to taking list of elements from, is mesh, submesh or group |
1595 |
def SplitQuadObject (self, theObject, Diag13): |
1596 |
return self.editor.SplitQuadObject(theObject, Diag13) |
1597 |
|
1598 |
## Find better splitting of the given quadrangle. |
1599 |
# @param IDOfQuad ID of the quadrangle to be splitted. |
1600 |
# @param Criterion is a criterion to choose a diagonal for splitting. |
1601 |
# @return 1 if 1-3 diagonal is better, 2 if 2-4 |
1602 |
# diagonal is better, 0 if error occurs. |
1603 |
def BestSplit (self, IDOfQuad, Criterion): |
1604 |
return self.editor.BestSplit(IDOfQuad, Criterion) |
1605 |
|
1606 |
## Smooth elements |
1607 |
# @param IDsOfElements list if ids of elements to smooth |
1608 |
# @param IDsOfFixedNodes list of ids of fixed nodes. |
1609 |
# Note that nodes built on edges and boundary nodes are always fixed. |
1610 |
# @param MaxNbOfIterations maximum number of iterations |
1611 |
# @param MaxAspectRatio varies in range [1.0, inf] |
1612 |
# @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) |
1613 |
def Smooth(self, IDsOfElements, IDsOfFixedNodes, |
1614 |
MaxNbOfIterations, MaxAspectRatio, Method): |
1615 |
if IDsOfElements == []: |
1616 |
IDsOfElements = self.GetElementsId() |
1617 |
return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes, |
1618 |
MaxNbOfIterations, MaxAspectRatio, Method) |
1619 |
|
1620 |
## Smooth elements belong to given object |
1621 |
# @param theObject object to smooth |
1622 |
# @param IDsOfFixedNodes list of ids of fixed nodes. |
1623 |
# Note that nodes built on edges and boundary nodes are always fixed. |
1624 |
# @param MaxNbOfIterations maximum number of iterations |
1625 |
# @param MaxAspectRatio varies in range [1.0, inf] |
1626 |
# @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) |
1627 |
def SmoothObject(self, theObject, IDsOfFixedNodes, |
1628 |
MaxNbOfIterations, MaxxAspectRatio, Method): |
1629 |
return self.editor.SmoothObject(theObject, IDsOfFixedNodes, |
1630 |
MaxNbOfIterations, MaxxAspectRatio, Method) |
1631 |
|
1632 |
## Parametric smooth the given elements |
1633 |
# @param IDsOfElements list if ids of elements to smooth |
1634 |
# @param IDsOfFixedNodes list of ids of fixed nodes. |
1635 |
# Note that nodes built on edges and boundary nodes are always fixed. |
1636 |
# @param MaxNbOfIterations maximum number of iterations |
1637 |
# @param MaxAspectRatio varies in range [1.0, inf] |
1638 |
# @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) |
1639 |
def SmoothParametric(IDsOfElements, IDsOfFixedNodes, |
1640 |
MaxNbOfIterations, MaxAspectRatio, Method): |
1641 |
if IDsOfElements == []: |
1642 |
IDsOfElements = self.GetElementsId() |
1643 |
return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes, |
1644 |
MaxNbOfIterations, MaxAspectRatio, Method) |
1645 |
|
1646 |
## Parametric smooth elements belong to given object |
1647 |
# @param theObject object to smooth |
1648 |
# @param IDsOfFixedNodes list of ids of fixed nodes. |
1649 |
# Note that nodes built on edges and boundary nodes are always fixed. |
1650 |
# @param MaxNbOfIterations maximum number of iterations |
1651 |
# @param MaxAspectRatio varies in range [1.0, inf] |
1652 |
# @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) |
1653 |
def SmoothParametricObject(self, theObject, IDsOfFixedNodes, |
1654 |
MaxNbOfIterations, MaxAspectRatio, Method): |
1655 |
return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes, |
1656 |
MaxNbOfIterations, MaxAspectRatio, Method) |
1657 |
|
1658 |
## Converts all mesh to quadratic one, deletes old elements, replacing |
1659 |
# them with quadratic ones with the same id. |
1660 |
def ConvertToQuadratic(self, theForce3d): |
1661 |
self.editor.ConvertToQuadratic(theForce3d) |
1662 |
|
1663 |
## Converts all mesh from quadratic to ordinary ones, |
1664 |
# deletes old quadratic elements, replacing |
1665 |
# them with ordinary mesh elements with the same id. |
1666 |
def ConvertFromQuadratic(self): |
1667 |
return self.editor.ConvertFromQuadratic() |
1668 |
|
1669 |
## Renumber mesh nodes |
1670 |
def RenumberNodes(self): |
1671 |
self.editor.RenumberNodes() |
1672 |
|
1673 |
## Renumber mesh elements |
1674 |
def RenumberElements(self): |
1675 |
self.editor.RenumberElements() |
1676 |
|
1677 |
## Generate new elements by rotation of the elements around the axis |
1678 |
# @param IDsOfElements list of ids of elements to sweep |
1679 |
# @param Axix axis of rotation, AxisStruct or line(geom object) |
1680 |
# @param AngleInRadians angle of Rotation |
1681 |
# @param NbOfSteps number of steps |
1682 |
# @param Tolerance tolerance |
1683 |
def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance): |
1684 |
if IDsOfElements == []: |
1685 |
IDsOfElements = self.GetElementsId() |
1686 |
if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)): |
1687 |
Axix = GetAxisStruct(Axix) |
1688 |
self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance) |
1689 |
|
1690 |
## Generate new elements by rotation of the elements of object around the axis |
1691 |
# @param theObject object wich elements should be sweeped |
1692 |
# @param Axix axis of rotation, AxisStruct or line(geom object) |
1693 |
# @param AngleInRadians angle of Rotation |
1694 |
# @param NbOfSteps number of steps |
1695 |
# @param Tolerance tolerance |
1696 |
def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance): |
1697 |
if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)): |
1698 |
Axix = GetAxisStruct(Axix) |
1699 |
self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance) |
1700 |
|
1701 |
## Generate new elements by extrusion of the elements with given ids |
1702 |
# @param IDsOfElements list of elements ids for extrusion |
1703 |
# @param StepVector vector, defining the direction and value of extrusion |
1704 |
# @param NbOfSteps the number of steps |
1705 |
def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps): |
1706 |
if IDsOfElements == []: |
1707 |
IDsOfElements = self.GetElementsId() |
1708 |
if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)): |
1709 |
StepVector = GetDirStruct(StepVector) |
1710 |
self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps) |
1711 |
|
1712 |
## Generate new elements by extrusion of the elements with given ids |
1713 |
# @param IDsOfElements is ids of elements |
1714 |
# @param StepVector vector, defining the direction and value of extrusion |
1715 |
# @param NbOfSteps the number of steps |
1716 |
# @param ExtrFlags set flags for performing extrusion |
1717 |
# @param SewTolerance uses for comparing locations of nodes if flag |
1718 |
# EXTRUSION_FLAG_SEW is set |
1719 |
def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance): |
1720 |
if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)): |
1721 |
StepVector = GetDirStruct(StepVector) |
1722 |
self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance) |
1723 |
|
1724 |
## Generate new elements by extrusion of the elements belong to object |
1725 |
# @param theObject object wich elements should be processed |
1726 |
# @param StepVector vector, defining the direction and value of extrusion |
1727 |
# @param NbOfSteps the number of steps |
1728 |
def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps): |
1729 |
if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)): |
1730 |
StepVector = GetDirStruct(StepVector) |
1731 |
self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps) |
1732 |
|
1733 |
## Generate new elements by extrusion of the elements belong to object |
1734 |
# @param theObject object wich elements should be processed |
1735 |
# @param StepVector vector, defining the direction and value of extrusion |
1736 |
# @param NbOfSteps the number of steps |
1737 |
def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps): |
1738 |
if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)): |
1739 |
StepVector = GetDirStruct(StepVector) |
1740 |
self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps) |
1741 |
|
1742 |
## Generate new elements by extrusion of the elements belong to object |
1743 |
# @param theObject object wich elements should be processed |
1744 |
# @param StepVector vector, defining the direction and value of extrusion |
1745 |
# @param NbOfSteps the number of steps |
1746 |
def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps): |
1747 |
if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)): |
1748 |
StepVector = GetDirStruct(StepVector) |
1749 |
self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps) |
1750 |
|
1751 |
## Generate new elements by extrusion of the given elements |
1752 |
# A path of extrusion must be a meshed edge. |
1753 |
# @param IDsOfElements is ids of elements |
1754 |
# @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion |
1755 |
# @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path |
1756 |
# @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion |
1757 |
# @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion |
1758 |
# @param Angles list of angles |
1759 |
# @param HasRefPoint allows to use base point |
1760 |
# @param RefPoint point around which the shape is rotated(the mass center of the shape by default). |
1761 |
# User can specify any point as the Base Point and the shape will be rotated with respect to this point. |
1762 |
def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart, |
1763 |
HasAngles, Angles, HasRefPoint, RefPoint): |
1764 |
if IDsOfElements == []: |
1765 |
IDsOfElements = self.GetElementsId() |
1766 |
if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)): |
1767 |
RefPoint = GetPointStruct(RefPoint) |
1768 |
return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape, NodeStart, |
1769 |
HasAngles, Angles, HasRefPoint, RefPoint) |
1770 |
|
1771 |
## Generate new elements by extrusion of the elements belong to object |
1772 |
# A path of extrusion must be a meshed edge. |
1773 |
# @param IDsOfElements is ids of elements |
1774 |
# @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion |
1775 |
# @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path |
1776 |
# @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion |
1777 |
# @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion |
1778 |
# @param Angles list of angles |
1779 |
# @param HasRefPoint allows to use base point |
1780 |
# @param RefPoint point around which the shape is rotated(the mass center of the shape by default). |
1781 |
# User can specify any point as the Base Point and the shape will be rotated with respect to this point. |
1782 |
def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart, |
1783 |
HasAngles, Angles, HasRefPoint, RefPoint): |
1784 |
if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)): |
1785 |
RefPoint = GetPointStruct(RefPoint) |
1786 |
return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape, NodeStart, |
1787 |
HasAngles, Angles, HasRefPoint, RefPoint) |
1788 |
|
1789 |
## Symmetrical copy of mesh elements |
1790 |
# @param IDsOfElements list of elements ids |
1791 |
# @param Mirror is AxisStruct or geom object(point, line, plane) |
1792 |
# @param theMirrorType is POINT, AXIS or PLANE |
1793 |
# If the Mirror is geom object this parameter is unnecessary |
1794 |
# @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0) |
1795 |
def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0): |
1796 |
if IDsOfElements == []: |
1797 |
IDsOfElements = self.GetElementsId() |
1798 |
if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)): |
1799 |
Mirror = GetAxisStruct(Mirror) |
1800 |
self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy) |
1801 |
|
1802 |
## Symmetrical copy of object |
1803 |
# @param theObject mesh, submesh or group |
1804 |
# @param Mirror is AxisStruct or geom object(point, line, plane) |
1805 |
# @param theMirrorType is POINT, AXIS or PLANE |
1806 |
# If the Mirror is geom object this parameter is unnecessary |
1807 |
# @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0) |
1808 |
def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0): |
1809 |
if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)): |
1810 |
Mirror = GetAxisStruct(Mirror) |
1811 |
self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy) |
1812 |
|
1813 |
## Translates the elements |
1814 |
# @param IDsOfElements list of elements ids |
1815 |
# @param Vector direction of translation(DirStruct or vector) |
1816 |
# @param Copy allows to copy the translated elements |
1817 |
def Translate(self, IDsOfElements, Vector, Copy): |
1818 |
if IDsOfElements == []: |
1819 |
IDsOfElements = self.GetElementsId() |
1820 |
if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)): |
1821 |
Vector = GetDirStruct(Vector) |
1822 |
self.editor.Translate(IDsOfElements, Vector, Copy) |
1823 |
|
1824 |
## Translates the object |
1825 |
# @param theObject object to translate(mesh, submesh, or group) |
1826 |
# @param Vector direction of translation(DirStruct or geom vector) |
1827 |
# @param Copy allows to copy the translated elements |
1828 |
def TranslateObject(self, theObject, Vector, Copy): |
1829 |
if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)): |
1830 |
Vector = GetDirStruct(Vector) |
1831 |
self.editor.TranslateObject(theObject, Vector, Copy) |
1832 |
|
1833 |
## Rotates the elements |
1834 |
# @param IDsOfElements list of elements ids |
1835 |
# @param Axis axis of rotation(AxisStruct or geom line) |
1836 |
# @param AngleInRadians angle of rotation(in radians) |
1837 |
# @param Copy allows to copy the rotated elements |
1838 |
def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy): |
1839 |
if IDsOfElements == []: |
1840 |
IDsOfElements = self.GetElementsId() |
1841 |
if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)): |
1842 |
Axis = GetAxisStruct(Axis) |
1843 |
self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy) |
1844 |
|
1845 |
## Rotates the object |
1846 |
# @param theObject object to rotate(mesh, submesh, or group) |
1847 |
# @param Axis axis of rotation(AxisStruct or geom line) |
1848 |
# @param AngleInRadians angle of rotation(in radians) |
1849 |
# @param Copy allows to copy the rotated elements |
1850 |
def RotateObject (self, theObject, Axis, AngleInRadians, Copy): |
1851 |
self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy) |
1852 |
|
1853 |
## Find group of nodes close to each other within Tolerance. |
1854 |
# @param Tolerance tolerance value |
1855 |
# @param list of group of nodes |
1856 |
def FindCoincidentNodes (self, Tolerance): |
1857 |
return self.editor.FindCoincidentNodes(Tolerance) |
1858 |
|
1859 |
## Merge nodes |
1860 |
# @param list of group of nodes |
1861 |
def MergeNodes (self, GroupsOfNodes): |
1862 |
self.editor.MergeNodes(GroupsOfNodes) |
1863 |
|
1864 |
## Remove all but one of elements built on the same nodes. |
1865 |
def MergeEqualElements(self): |
1866 |
self.editor.MergeEqualElements() |
1867 |
|
1868 |
## Sew free borders |
1869 |
def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1, |
1870 |
FirstNodeID2, SecondNodeID2, LastNodeID2, |
1871 |
CreatePolygons, CreatePolyedrs): |
1872 |
return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1, |
1873 |
FirstNodeID2, SecondNodeID2, LastNodeID2, |
1874 |
CreatePolygons, CreatePolyedrs) |
1875 |
|
1876 |
## Sew conform free borders |
1877 |
def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1, |
1878 |
FirstNodeID2, SecondNodeID2): |
1879 |
return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1, |
1880 |
FirstNodeID2, SecondNodeID2) |
1881 |
|
1882 |
## Sew border to side |
1883 |
def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, |
1884 |
FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs): |
1885 |
return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, |
1886 |
FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs) |
1887 |
|
1888 |
## Sew two sides of a mesh. Nodes belonging to Side1 are |
1889 |
# merged with nodes of elements of Side2. |
1890 |
# Number of elements in theSide1 and in theSide2 must be |
1891 |
# equal and they should have similar node connectivity. |
1892 |
# The nodes to merge should belong to sides borders and |
1893 |
# the first node should be linked to the second. |
1894 |
def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements, |
1895 |
NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, |
1896 |
NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge): |
1897 |
return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements, |
1898 |
NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, |
1899 |
NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge) |
1900 |
|
1901 |
## Set new nodes for given element. |
1902 |
# @param ide the element id |
1903 |
# @param newIDs nodes ids |
1904 |
# @return If number of nodes is not corresponded to type of element - returns false |
1905 |
def ChangeElemNodes(self, ide, newIDs): |
1906 |
return self.editor.ChangeElemNodes(ide, newIDs) |
1907 |
|
1908 |
## If during last operation of MeshEditor some nodes were |
1909 |
# created this method returns list of it's IDs, if new nodes |
1910 |
# not created - returns empty list |
1911 |
def GetLastCreatedNodes(self): |
1912 |
return self.editor.GetLastCreatedNodes() |
1913 |
|
1914 |
## If during last operation of MeshEditor some elements were |
1915 |
# created this method returns list of it's IDs, if new elements |
1916 |
# not creared - returns empty list |
1917 |
def GetLastCreatedElems(self): |
1918 |
return self.editor.GetLastCreatedElems() |