From: admin Date: Thu, 1 Apr 2004 11:58:40 +0000 (+0000) Subject: This commit was generated by cvs2git to create branch 'V1_4_1a'. X-Git-Tag: Base_Ecole_Ete~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5980f7c6cc925471e77507c48b92b84742432348;p=modules%2Fsmesh.git This commit was generated by cvs2git to create branch 'V1_4_1a'. Sprout from master 2004-01-29 17:52:25 UTC jrt 'Upgrade to version 1.4.0.' Cherrypick from master 2004-04-01 11:58:39 UTC nadir 'adding python scripts to illustrate the way to mesh a shape giving different hypothesis on its sub-shapes.': doc/html/SMESHTutorial_1/ControlFeature.png doc/html/SMESHTutorial_1/ImportResult.png doc/html/SMESHTutorial_1/MeshInit.png doc/html/SMESHTutorial_1/MeshResult.png doc/html/SMESHTutorial_1/MeshResult2.png doc/html/SMESHTutorial_1/SMESHOverview.png doc/html/SMESHTutorial_1/SMESHTutorial_1.html doc/html/SMESHTutorial_1/SelectAlgorithms.png doc/html/SMESHTutorial_1/SetColor.png doc/html/SMESHTutorial_1/SubMeshContruction.png doc/html/SMESHTutorial_1/SubShapesSelection.png src/SMESH_SWIG/SMESH_box_hexa.py src/SMESH_SWIG/SMESH_demo_hexa.py src/SMESH_SWIG/SMESH_demo_hexa2.py src/SMESH_SWIG/SMESH_demo_tetra.py src/SMESH_SWIG/SMESH_demo_tetra2.py Cherrypick from master 2004-01-30 15:42:52 UTC jrt 'update.': ChangeLog Cherrypick from IMPORT 2003-07-10 08:13:02 UTC yfr 'sources v1.2': src/DriverMED/DriverMED_R_SMESHDS_Document.h src/DriverMED/DriverMED_W_SMESHDS_Document.h src/SMESHGUI/SMESHGUI_msg_en.po --- diff --git a/ChangeLog b/ChangeLog index 77da70fb1..46cf0c992 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,20 @@ #cvs2cl.pl -l "-b" -U users.cvs2cl --header header.cvs2cl -T -b --utc ############################################################################### +2004-01-30 13:18 Nicolas Rejneri + + * doc/html/INPUT/: doxyfile, sources/static/tree.js: NRI : 1.4.0 + version + +2004-01-29 17:52 Jerome Robert + + * INSTALL, bin/VERSION: Upgrade to version 1.4.0. + +2004-01-29 17:33 Jerome Robert + + * src/: SMESHGUI/SMESHGUI_StudyAPI.cxx, SMESHGUI/SMESHGUI_Swig.cxx, + SMESH_I/SMESH_Gen_i.cxx: Merge branch merge_1_2_d + 2004-01-14 09:24 Nicolas Rejneri * doc/html/Makefile.in: NRI : bug KERNEL5014 fixed. @@ -28,10 +42,6 @@ 2004-01-05 14:28 tag V1_3_1 -2004-01-05 14:28 Jerome Robert - - * ChangeLog, cvs-tags: update - 2004-01-05 13:53 Jerome Robert * src/NETGEN/: ReadMeForNgUsers, netgen43ForSalome.patch: Add a @@ -149,10 +159,6 @@ * src/MEFISTO2/trte.f: Remove "pause" primitive call. -2003-11-27 11:47 Jerome Robert - - * ChangeLog, cvs-tags: update - 2003-11-27 11:45 Jerome Robert * resources/SMESH_en.xml, resources/SMESH_fr.xml, @@ -201,10 +207,6 @@ nadir_update_MED_v1_3_0 (branch to build the V1_3_0 version of the module. -2003-11-17 09:22 Jerome Robert - - * cvs-tags: update - 2003-11-12 13:20 tag V1_3_0_b1 2003-11-12 13:20 Jerome Robert @@ -248,10 +250,6 @@ * src/SMDS/SMDS_Mesh.cxx: Fix a bug. Quadrangles were added as triangles. -2003-10-17 12:35 Jerome Robert - - * cvs-tags: Create branch merge_1_2_c__1_2_2 - 2003-10-06 10:50 tag MergeV1_2c-1 2003-10-06 10:50 Jerome Robert @@ -304,10 +302,6 @@ * src/SMDS/SMDS_VolumeOfNodes.cxx: Fix bug. Was always printing 8 nodes -2003-09-08 15:11 Jerome Robert - - * ChangeLog: update - 2003-09-08 15:04 Jerome Robert * src/SMDS/: SMDS_Mesh.cxx, SMDS_VolumeOfNodes.cxx, @@ -556,10 +550,6 @@ SMDS_VertexPosition.cdl, SMDS_VertexPosition.ixx, SMDS_VertexPosition.jxx: Remove no longer needed files -2003-09-04 14:09 Jerome Robert - - * ChangeLog: Add a ChangeLog file - 2003-09-04 13:28 Jerome Robert * build_configure: It seems "make_omniorb" and "make_commence" need @@ -738,40 +728,6 @@ SMDS_VolumeOfNodes.cxx, SMDS_VolumeOfNodes.hxx: Add needed class for the new DS -2003-07-18 12:19 tag V_02092003 - -2003-07-18 12:19 tag V_03092003 - -2003-07-18 12:19 tag V_04092003 - -2003-07-18 12:19 tag V_05092003 - -2003-07-18 12:19 tag V_06092003 - -2003-07-18 12:19 tag V_07092003 - -2003-07-18 12:19 tag V_08092003 - -2003-07-18 12:19 tag V_09092003 - -2003-07-18 12:19 tag V_10092003 - -2003-07-18 12:19 tag V_11092003 - -2003-07-18 12:19 tag V_12092003 - -2003-07-18 12:19 tag V_13092003 - -2003-07-18 12:19 tag V_14092003 - -2003-07-18 12:19 tag V_15092003 - -2003-07-18 12:19 tag V_16092003 - -2003-07-18 12:19 tag V_17092003 - -2003-07-18 12:19 tag V_18092003 - 2003-07-18 12:19 Nicolas Rejneri * src/SMESHGUI/SMESHGUI_StudyAPI.cxx: NRI : correction wrong merge. diff --git a/doc/html/SMESHTutorial_1/ControlFeature.png b/doc/html/SMESHTutorial_1/ControlFeature.png new file mode 100644 index 000000000..82222c47c Binary files /dev/null and b/doc/html/SMESHTutorial_1/ControlFeature.png differ diff --git a/doc/html/SMESHTutorial_1/ImportResult.png b/doc/html/SMESHTutorial_1/ImportResult.png new file mode 100644 index 000000000..55c5a2b31 Binary files /dev/null and b/doc/html/SMESHTutorial_1/ImportResult.png differ diff --git a/doc/html/SMESHTutorial_1/MeshInit.png b/doc/html/SMESHTutorial_1/MeshInit.png new file mode 100644 index 000000000..c9c4c1603 Binary files /dev/null and b/doc/html/SMESHTutorial_1/MeshInit.png differ diff --git a/doc/html/SMESHTutorial_1/MeshResult.png b/doc/html/SMESHTutorial_1/MeshResult.png new file mode 100644 index 000000000..4072ea8f3 Binary files /dev/null and b/doc/html/SMESHTutorial_1/MeshResult.png differ diff --git a/doc/html/SMESHTutorial_1/MeshResult2.png b/doc/html/SMESHTutorial_1/MeshResult2.png new file mode 100644 index 000000000..c7e9e37c2 Binary files /dev/null and b/doc/html/SMESHTutorial_1/MeshResult2.png differ diff --git a/doc/html/SMESHTutorial_1/SMESHOverview.png b/doc/html/SMESHTutorial_1/SMESHOverview.png new file mode 100644 index 000000000..2e61dd3ec Binary files /dev/null and b/doc/html/SMESHTutorial_1/SMESHOverview.png differ diff --git a/doc/html/SMESHTutorial_1/SMESHTutorial_1.html b/doc/html/SMESHTutorial_1/SMESHTutorial_1.html new file mode 100644 index 000000000..bac9ce618 --- /dev/null +++ b/doc/html/SMESHTutorial_1/SMESHTutorial_1.html @@ -0,0 +1,230 @@ + + + + + Geometry module in SALOME environnement + + + +

SMESH starting tutorial

+ +

2D meshing with MEFISTO

+ +

Overview

+ +

Before following this tutorial you need to create or import a geometry. +Please refere to the GEOM module documentation to do so.

+ +

Now we have to load SMESH component. To do so :

+
    +
  • click on the SMESH icon or on 'SMESH' into the combo box of resources + on botton left.
  • +
+ +

SMESH is used to mesh edges, faces and volums each one thanks to a +specialised algorithm. To mesh an entity which degree is n, one must have all +its lower degree entities meshed. For instance, to mesh a face requires a +previous meshing of all its edges. In the example MEFISTO meshes faces, and +Regular_1D meshes edges. MEFISTO doesn't check how edges are meshed. The only +test it does is to verify that edges are meshed before starting its work. +MEFISTO requires an hypothesis : maximum area of triangles. Regular_1D +requires one hypothesis among two: number of segments per edge or +length of segment. 

+ +

The entire operation is done by :

+
    +
  1. init a mesh object associated to a geometrical object
  2. +
  3. choosing an algorithm for meshing faces, here MEFISTO is + choosen
  4. +
  5. choosing an algorithm for meshing edges, here Regular1d is + choosen
  6. +
  7. creating hypothesis of calculation. We need to inform : +
      +
    • the number of segments per edge
    • +
    • the maximum area per triangle of meshing
    • +
    +
  8. +
  9. setting or attaching algorithm and hypothesis to the object loaded
  10. +
  11. launching computation
  12. +
  13. displaying the result in the best mode.
  14. +
+ + +

Details

+ +

Below are explained those 6 steps precisely :

+
    +
  1. init a mesh object associated to a geometrical object :

    +

    +
      +
    • In the menu bar on the top, find the Mesh menu and click on + Init.
    • +
    • Then in the dialog box select the topology into Geometry field of + ObjectBrowser or Viewer, give a name an click on Ok.
    • +
    • The topology is now known inside SMESH component.
    • +
    +
  2. +
  3. define algorithms for meshing :

    +

    +
      +
    • In the menu bar, find Hypothesis, Algorithm then + click on Mefisto.
    • +
    • Do the same to load 'Regular1D'.
    • +
    • Remember, Regular1D is needed for edge meshing.
    • +
    +
  4. +
  5. define hypothesis of calculation :
    + In the menu bar, find Hypothesis then Hypothesis and click on + Segments. Then in the dialog box give a name for hypothesis and a + value that is the number of segments per edge. Enter 7 segments for + example.
    + Do the same for 'Max. Element Area' argument that is the maximum surface + of triangles builded during meshing. Enter 2500 here.

    +
  6. +
  7. Attach previous arguments (hypothesis) and algorithm to the + topology :
    + Select the object in the Object Browser then using pop up menu (right + click on object),
    + 'Set algorithm' and 'Set Hypothesis' into specialized dialog boxes.
    + You can also find these methods in the menu 'Hypothesis'.

    +
  8. +
  9. Selecting the mesh object before, start computation in the pop up + menu; click on 'Compute'.

    +
  10. +
  11. Update the display using 'Update' if necessary.
    + Note : in Preferencies / Mesh menu there is an + option to have an automatic update of the display after operations that + modify it such as Compute, adding nodes… If this option is not + setted user must make an update of the display manually.
    +
    + You may also adjust the display 'Properties' / 'Display Mode' has + you prefer ; shading, wireframe or shrink,
    + and adjust color and size attributs in a specific dialog box shown + below.

    +

    +
  12. +
+ +

Final result of meshing

+ +

At this final step you can observe the result of 2D meshing of faces by +MEFISTO.

+ +

Note : it is possible to change an hypothesis by mean the pop up then +Edit and finally compute again.

+ +

+ +

Meshing with global and local hypothesis

+ +

details

+ +

We would now make a mesh as before but with a local modification of +parameter (hypothesis) on an edge. We first have to explode the initial +topology in GEOMETRY component. This operation will give us access to sub +shapes edges of geom.brep.

+
    +
  1. import or create a geometry as before

    +
  2. +
  3. call 'Explode' method found in 'New Entity' on the menu bar ; + (remember the tip about Automatic/Store !)

    +

    +
  4. +
  5. select the main object, choose 'Edge' in the combo box and click on + Ok.
    + Note : do not click on 'select sub shape' at anytime. This + function is used with OCC viewer for individual sub shape selection not + yet available with VTK.
    +
    + Now the object browser contents all edges as sub shapes of the main + topology. Select the first edge Edge_ 1 and display only it. + Use the pop up 'Display only' mode for this.
    + You may also rename the edge to remember it for future meshing.
    + Our scope : apply a local hypothesis on this edge.
    +

    +
  6. +
  7. The job is now finished for GEOMETRY component.

    +
  8. +
  9. Load SMESH component and use menus 'Mesh' and 'Init' to load the + topology into SMESH as before.
    + (Already defined if you have kept the previous study.)

    +
  10. +
  11. Define algorithms Regular_1D and Mefisto using menus 'Hypothesis' + and 'Algorithm'.

    +
  12. +
  13. Define hypothesis 'Segments' = 7 and 'Max. Element Area' = 2500. + (Already defined if…)

    +
  14. +
  15. Define another hypothesis 'Local length' = 100 to be used only as + local parameter for the edge.

    +
  16. +
  17. Now we have to attach algorithms and hypothesis to topologies, the + global and the sub shape edge.
    + For the main topology, select it and use 'Set algorithms' and 'Set + Hypothesis' and attach :
    + hypothesis 'Segments' = 7 and 'Max. Element Area' = 2500.

    +
  18. +
  19. To set a local parameter of meshing on the edge we do :
    + click on 'Mesh' menu then 'Add Sub Mesh'. On the dialog box select the + main object then sub object edge from Object Browser and GEOMETRY field. + Give it a local name; for example myEdge or anyone.

    +

    +
  20. +
  21. Set the algorithm used for edge meshing. Here use Regular_ 1D. +

    +
  22. +
  23. Set a local hypothesis to the edge. Use 'Local length' = 100.

    +
  24. +
  25. 'Compute' (and 'Update' display if necessary see + before) the main mesh object. This will compute also the edge sub + shape.
    + Do not forget to activate the display mode Wireframe, + Shading or Shrink; see in pop up menu 'Properties', + 'Display mode'…

    +
  26. +
  27. Move the point of view to watch the edge meshed with a local + hypothesis 'Local length' = 100.

    +
  28. +
+ +

The result of second meshing

+ +

As we see below, the effect produced by setting a local hypothesis setted +on the edge Edge_ 1.

+ +

Compare to another edge that have the same physical +length.

+ +

+ +

Using PYTHON interpretor to import an example script

+It is easy to import an example of meshing procedure using PYTHON interpretor +: +
    +
  • Load SMESH component with VTK viewer.
  • +
  • Just type 'import geomMesh.py' in the textual window of + PYTHON.
  • +
  • Validate with the Enter key.
  • +
  • You just have to run 'Compute' then choose a display mode to see the + result.
  • +
+This imported example is very similar to the last exercice. It uses a local +hypothesis on an edge too. + +

+ +

Control features

+ +

Test now a control function of area for mesh resulting triangles.

+ +

Find Control on the menu bar then Cells and Area. The +image below displays areas with a color depending on its value in the scalar +bar shown on the left.
+Scalar bar general parameters are setted in Preferencies / +Mesh / Scalar Bar.

+ +

Specific range parameters are changed with the pop up menu.

+ +

+ + diff --git a/doc/html/SMESHTutorial_1/SelectAlgorithms.png b/doc/html/SMESHTutorial_1/SelectAlgorithms.png new file mode 100644 index 000000000..c69f3e4ba Binary files /dev/null and b/doc/html/SMESHTutorial_1/SelectAlgorithms.png differ diff --git a/doc/html/SMESHTutorial_1/SetColor.png b/doc/html/SMESHTutorial_1/SetColor.png new file mode 100644 index 000000000..bda5fd568 Binary files /dev/null and b/doc/html/SMESHTutorial_1/SetColor.png differ diff --git a/doc/html/SMESHTutorial_1/SubMeshContruction.png b/doc/html/SMESHTutorial_1/SubMeshContruction.png new file mode 100644 index 000000000..1080f08fe Binary files /dev/null and b/doc/html/SMESHTutorial_1/SubMeshContruction.png differ diff --git a/doc/html/SMESHTutorial_1/SubShapesSelection.png b/doc/html/SMESHTutorial_1/SubShapesSelection.png new file mode 100644 index 000000000..c5df40b20 Binary files /dev/null and b/doc/html/SMESHTutorial_1/SubShapesSelection.png differ diff --git a/src/SMESH_SWIG/SMESH_box_hexa.py b/src/SMESH_SWIG/SMESH_box_hexa.py new file mode 100644 index 000000000..2c6b20ca5 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_box_hexa.py @@ -0,0 +1,215 @@ +# +# Hexahedrization of a simple box. Hypothesis and algorithms for +# the mesh generation are not global: the mesh of some edges is thinner +# + +import salome +from salome import sg + +import geompy + +import SMESH +import smeshpy + +# ----------------------------------------------------------------------------- + +geom = geompy.geom +myBuilder = geompy.myBuilder + +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeEdge = 6 + +# ---- define a boxe + +box = geompy.MakeBox(0., 0., 0., 1., 1., 1.) + +idbox = geompy.addToStudy(box,"box") + +print "Analysis of the geometry box :" +subShellList=geompy.SubShapeAllSorted(box,ShapeTypeShell) +subFaceList=geompy.SubShapeAllSorted(box,ShapeTypeFace) +subEdgeList=geompy.SubShapeAllSorted(box,ShapeTypeEdge) + +print "number of Shells in box : ",len(subShellList) +print "number of Faces in box : ",len(subFaceList) +print "number of Edges in box : ",len(subEdgeList) + +idSubEdge = [] +for k in range(len(subEdgeList)): + idSubEdge.append(geompy.addToStudyInFather(box,subEdgeList[k],"SubEdge"+str(k))) + +edgeX = [] +edgeX.append(subEdgeList[4]) +edgeX.append(subEdgeList[5]) +edgeX.append(subEdgeList[6]) +edgeX.append(subEdgeList[7]) + +edgeY = [] +edgeY.append(subEdgeList[1]) +edgeY.append(subEdgeList[2]) +edgeY.append(subEdgeList[9]) +edgeY.append(subEdgeList[10]) + +edgeZ = [] +edgeZ.append(subEdgeList[0]) +edgeZ.append(subEdgeList[3]) +edgeZ.append(subEdgeList[8]) +edgeZ.append(subEdgeList[11]) + +idEdgeX = [] +idEdgeY = [] +idEdgeZ = [] +for i in range(4): + idEdgeX.append(geompy.addToStudyInFather(box,edgeX[i],"EdgeX"+str(i+1))) + idEdgeY.append(geompy.addToStudyInFather(box,edgeY[i],"EdgeY"+str(i+1))) + idEdgeZ.append(geompy.addToStudyInFather(box,edgeZ[i],"EdgeZ"+str(i+1))) + +# ---- launch SMESH + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +gen=smeshpy.smeshpy() + +# ---- create Hypothesis + +print "-------------------------- create Hypothesis" + +print "-------------------------- NumberOfSegments in X, Y, Z direction" + +numberOfSegmentsX = 10 + +hyp1=gen.CreateHypothesis("NumberOfSegments") +hypNbSegX=hyp1._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSegX.SetNumberOfSegments(numberOfSegmentsX) +hypNbSegXID = hypNbSegX.GetId() +print hypNbSegX.GetName() +print hypNbSegXID +print hypNbSegX.GetNumberOfSegments() + +idsegX = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegX) ) +smeshgui.SetName(idsegX, "NumberOfSegmentsX") + +print "" + +numberOfSegmentsY = 20 + +hyp1=gen.CreateHypothesis("NumberOfSegments") +hypNbSegY=hyp1._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSegY.SetNumberOfSegments(numberOfSegmentsY) +hypNbSegYID = hypNbSegY.GetId() +print hypNbSegY.GetName() +print hypNbSegYID +print hypNbSegY.GetNumberOfSegments() + +idsegY = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegY) ) +smeshgui.SetName(idsegY, "NumberOfSegmentsY") + +print "" + +numberOfSegmentsZ = 40 + +hyp1=gen.CreateHypothesis("NumberOfSegments") +hypNbSegZ=hyp1._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ) +hypNbSegZID = hypNbSegZ.GetId() +print hypNbSegZ.GetName() +print hypNbSegZID +print hypNbSegZ.GetNumberOfSegments() + +idsegZ = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegZ) ) +smeshgui.SetName(idsegZ, "NumberOfSegmentsZ") + +# ---- create Algorithms + +print "-------------------------- create Algorithms" + +print "-------------------------- Regular_1D" + +hypothesis=gen.CreateHypothesis("Regular_1D") +regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D) +regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) ) +smeshgui.SetName(regularID, "Wire Discretisation") + +print "-------------------------- Quadrangle_2D" + +hypothesis=gen.CreateHypothesis("Quadrangle_2D") +quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D) +quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) ) +smeshgui.SetName(quadID, "Quadrangle_2D") + +print "-------------------------- Hexa_3D" + +hypothesis=gen.CreateHypothesis("Hexa_3D") +hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D) +hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) ) +smeshgui.SetName(hexaID, "Hexa_3D") + +# ---- init a Mesh with the boxe + +mesh=gen.Init(idbox) +idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) +smeshgui.SetName(idmesh, "MeshBox") +smeshgui.SetShape(idbox, idmesh) + +# ---- add hypothesis to the boxe + +print "-------------------------- add hypothesis to the boxe" +print " the number of segments is globally set to" +print " NumberOfSegmentsX = ", numberOfSegmentsX + +ret=mesh.AddHypothesis(box,regular1D) +print ret +ret=mesh.AddHypothesis(box,hypNbSegX) +print ret +ret=mesh.AddHypothesis(box,quad2D) +print ret +ret=mesh.AddHypothesis(box,hexa3D) +print ret + +print "-------------------------- set algoritms" + +smeshgui.SetAlgorithms( idmesh, regularID) +smeshgui.SetHypothesis( idmesh, idsegX ) +smeshgui.SetAlgorithms( idmesh, quadID ) +smeshgui.SetAlgorithms( idmesh, hexaID ) + +for i in range(4): + print "-------------------------- add hypothesis to edge in the Y and Z directions", (i+1) + + subMeshEdgeY = mesh.GetElementsOnShape(edgeY[i]) + subMeshEdgeZ = mesh.GetElementsOnShape(edgeZ[i]) + + retY = mesh.AddHypothesis(edgeY[i],hypNbSegY) + retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ) + print " add hyp Y ", retY, " Z ", retZ + + idsmY = smeshgui.AddSubMeshOnShape( + idmesh,idEdgeY[i],salome.orb.object_to_string(subMeshEdgeY), + ShapeTypeEdge) + idsmZ = smeshgui.AddSubMeshOnShape( + idmesh,idEdgeZ[i],salome.orb.object_to_string(subMeshEdgeZ), + ShapeTypeEdge) + + smeshgui.SetName(idsmY, "SubMeshEdgeY_"+str(i+1)) + smeshgui.SetName(idsmZ, "SubMeshEdgeZ_"+str(i+1)) + + smeshgui.SetHypothesis(idsmY, idsegY) + smeshgui.SetHypothesis(idsmZ, idsegZ) + +sg.updateObjBrowser(1) + +print "-------------------------- compute the mesh of the boxe" +ret=gen.Compute(mesh,idbox) +print ret +if ret != 0: + log=mesh.GetLog(0) # no erase trace + for linelog in log: + print linelog +else: + print "problem when Computing the mesh" + +sg.updateObjBrowser(1) + + diff --git a/src/SMESH_SWIG/SMESH_demo_hexa.py b/src/SMESH_SWIG/SMESH_demo_hexa.py new file mode 100644 index 000000000..5446936ba --- /dev/null +++ b/src/SMESH_SWIG/SMESH_demo_hexa.py @@ -0,0 +1,175 @@ +# +# Tetrahedrization of a geometry (box minus a inner cylinder). +# Hypothesis and algorithms for the mesh generation are global +# + +import math +import salome +from salome import sg + +import geompy + +import SMESH +import smeshpy + +# ----------------------------------------------------------------------------- + +geom = geompy.geom +myBuilder = geompy.myBuilder + +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeEdge = 6 + +a = math.sqrt(2.)/4. +ma = - a +zero = 0. +un = 1. +mun= - un +demi = 1./2. + +Orig = geom.MakePointStruct(zero,zero,zero) +P0 = geom.MakePointStruct(a,a,zero) +P1 = geom.MakePointStruct(zero,demi,zero) +P2 = geom.MakePointStruct(ma,a,zero) +P3 = geom.MakePointStruct(mun,un,zero) +P4 = geom.MakePointStruct(un,un,zero) +P5 = geom.MakePointStruct(zero,zero,un) + +arc = geompy.MakeArc(P0,P1,P2) +e1 = geompy.MakeEdge(P2,P3) +e2 = geompy.MakeEdge(P3,P4) +e3 = geompy.MakeEdge(P4,P0) + +list = [] +list.append(arc._get_Name()) +list.append(e1._get_Name()) +list.append(e2._get_Name()) +list.append(e3._get_Name()) + +wire = geompy.MakeWire(list) +face = geompy.MakeFace(wire,1) + +dir = geompy.MakeVector(Orig,P5) +vol1 = geompy.MakePipe(dir,face) + +angle = math.pi/2. +dir = geom.MakeAxisStruct(zero,zero,zero,zero,zero,un) +vol2 = geompy.MakeRotation(vol1,dir,angle) + +vol3 = geompy.MakeRotation(vol2,dir,angle) + +vol4 = geompy.MakeRotation(vol3,dir,angle) + +list = [] +list.append(vol1._get_Name()) +list.append(vol2._get_Name()) +list.append(vol3._get_Name()) +list.append(vol4._get_Name()) + +volComp = geompy.MakeCompound(list) + +tol3d = 1.e-3 +vol = geom.MakeGlueFaces(volComp,tol3d) +idVol = geompy.addToStudy(vol,"volume") + +print "Analysis of the final volume:" +subShellList=geompy.SubShapeAll(vol,ShapeTypeShell) +subFaceList=geompy.SubShapeAll(vol,ShapeTypeFace) +subEdgeList=geompy.SubShapeAll(vol,ShapeTypeEdge) + +print "number of Shells in the volume : ",len(subShellList) +print "number of Faces in the volume : ",len(subFaceList) +print "number of Edges in the volume : ",len(subEdgeList) + +# ---- launch SMESH + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +gen=smeshpy.smeshpy() + +# ---- create Hypothesis + +print "-------------------------- create Hypothesis" + +print "-------------------------- NumberOfSegments" + +numberOfSegments = 10 + +hypothesis=gen.CreateHypothesis("NumberOfSegments") +hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSeg.SetNumberOfSegments(numberOfSegments) +hypNbSegID = hypNbSeg.GetId() +print hypNbSeg.GetName() +print hypNbSegID +print hypNbSeg.GetNumberOfSegments() + +idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) ) +smeshgui.SetName(idseg, "NumberOfSegments") + +# ---- create Algorithms + +print "-------------------------- create Algorithms" + +print "-------------------------- Regular_1D" + +hypothesis=gen.CreateHypothesis("Regular_1D") +regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D) +regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) ) +smeshgui.SetName(regularID, "Wire Discretisation") + +print "-------------------------- Quadrangle_2D" + +hypothesis=gen.CreateHypothesis("Quadrangle_2D") +quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D) +quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) ) +smeshgui.SetName(quadID, "Quadrangle_2D") + +print "-------------------------- Hexa_3D" + +hypothesis=gen.CreateHypothesis("Hexa_3D") +hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D) +hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) ) +smeshgui.SetName(hexaID, "Hexa_3D") + +# ---- init a Mesh with the volume + +mesh=gen.Init(idVol) +idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) +smeshgui.SetName(idmesh, "meshVolume") +smeshgui.SetShape(idVol, idmesh) + +# ---- add hypothesis to the volume + +print "-------------------------- add hypothesis to the volume" + +ret=mesh.AddHypothesis(vol,regular1D) +print ret +ret=mesh.AddHypothesis(vol,hypNbSeg) +print ret +ret=mesh.AddHypothesis(vol,quad2D) +print ret +ret=mesh.AddHypothesis(vol,hexa3D) +print ret + +print "-------------------------- set algoritms" + +smeshgui.SetAlgorithms( idmesh, regularID) +smeshgui.SetHypothesis( idmesh, idseg ) +smeshgui.SetAlgorithms( idmesh, quadID ) +smeshgui.SetAlgorithms( idmesh, hexaID ) + +sg.updateObjBrowser(1) + +print "-------------------------- compute the mesh of the volume" +ret=gen.Compute(mesh,idVol) +print ret +if ret != 0: + log=mesh.GetLog(0) # no erase trace + for linelog in log: + print linelog +else: + print "problem when Computing the mesh" + +sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_demo_hexa2.py b/src/SMESH_SWIG/SMESH_demo_hexa2.py new file mode 100644 index 000000000..336bf01ef --- /dev/null +++ b/src/SMESH_SWIG/SMESH_demo_hexa2.py @@ -0,0 +1,225 @@ +# +# Tetrahedrization of a geometry (box minus a inner cylinder). +# Hypothesis and algorithms for the mesh generation are not global: +# the mesh of some edges is thinner +# + +import math +import salome +from salome import sg + +import geompy + +import SMESH +import smeshpy + +# ----------------------------------------------------------------------------- + +geom = geompy.geom +myBuilder = geompy.myBuilder + +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeEdge = 6 + +a = math.sqrt(2.)/4. +ma = - a +zero = 0. +un = 1. +mun= - un +demi = 1./2. + +Orig = geom.MakePointStruct(zero,zero,zero) +P0 = geom.MakePointStruct(a,a,zero) +P1 = geom.MakePointStruct(zero,demi,zero) +P2 = geom.MakePointStruct(ma,a,zero) +P3 = geom.MakePointStruct(mun,un,zero) +P4 = geom.MakePointStruct(un,un,zero) +P5 = geom.MakePointStruct(zero,zero,un) + +arc = geompy.MakeArc(P0,P1,P2) +e1 = geompy.MakeEdge(P2,P3) +e2 = geompy.MakeEdge(P3,P4) +e3 = geompy.MakeEdge(P4,P0) + +list = [] +list.append(arc._get_Name()) +list.append(e1._get_Name()) +list.append(e2._get_Name()) +list.append(e3._get_Name()) + +wire = geompy.MakeWire(list) +face = geompy.MakeFace(wire,1) + +dir = geompy.MakeVector(Orig,P5) +vol1 = geompy.MakePipe(dir,face) + +angle = math.pi/2. +dir = geom.MakeAxisStruct(zero,zero,zero,zero,zero,un) +vol2 = geompy.MakeRotation(vol1,dir,angle) + +vol3 = geompy.MakeRotation(vol2,dir,angle) + +vol4 = geompy.MakeRotation(vol3,dir,angle) + +list = [] +list.append(vol1._get_Name()) +list.append(vol2._get_Name()) +list.append(vol3._get_Name()) +list.append(vol4._get_Name()) + +volComp = geompy.MakeCompound(list) + +tol3d = 1.e-3 +vol = geom.MakeGlueFaces(volComp,tol3d) +idVol = geompy.addToStudy(vol,"volume") + +print "Analysis of the final volume:" +subShellList=geompy.SubShapeAllSorted(vol,ShapeTypeShell) +subFaceList=geompy.SubShapeAllSorted(vol,ShapeTypeFace) +subEdgeList=geompy.SubShapeAllSorted(vol,ShapeTypeEdge) + +print "number of Shells in the volume : ",len(subShellList) +print "number of Faces in the volume : ",len(subFaceList) +print "number of Edges in the volume : ",len(subEdgeList) + +idSubEdge = [] +for k in range(len(subEdgeList)): + idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k))) + +edgeZ = [] +edgeZ.append(subEdgeList[0]) +edgeZ.append(subEdgeList[3]) +edgeZ.append(subEdgeList[10]) +edgeZ.append(subEdgeList[11]) +edgeZ.append(subEdgeList[20]) +edgeZ.append(subEdgeList[21]) +edgeZ.append(subEdgeList[28]) +edgeZ.append(subEdgeList[31]) + +idEdgeZ = [] +for i in range(8): + idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1))) + +# ---- launch SMESH + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +gen=smeshpy.smeshpy() + +# ---- create Hypothesis + +print "-------------------------- create Hypothesis" + +print "-------------------------- NumberOfSegments the global one" + +numberOfSegments = 10 + +hypothesis=gen.CreateHypothesis("NumberOfSegments") +hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSeg.SetNumberOfSegments(numberOfSegments) +hypNbSegID = hypNbSeg.GetId() +print hypNbSeg.GetName() +print hypNbSegID +print hypNbSeg.GetNumberOfSegments() + +idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) ) +smeshgui.SetName(idseg, "NumberOfSegments") + +print "-------------------------- NumberOfSegments in the Z direction" + +numberOfSegmentsZ = 40 + +hypothesis=gen.CreateHypothesis("NumberOfSegments") +hypNbSegZ=hypothesis._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ) +hypNbSegZID = hypNbSegZ.GetId() +print hypNbSegZ.GetName() +print hypNbSegZID +print hypNbSegZ.GetNumberOfSegments() + +idsegZ = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegZ) ) +smeshgui.SetName(idsegZ, "NumberOfSegmentsZ") + +# ---- create Algorithms + +print "-------------------------- create Algorithms" + +print "-------------------------- Regular_1D" + +hypothesis=gen.CreateHypothesis("Regular_1D") +regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D) +regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) ) +smeshgui.SetName(regularID, "Wire Discretisation") + +print "-------------------------- Quadrangle_2D" + +hypothesis=gen.CreateHypothesis("Quadrangle_2D") +quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D) +quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) ) +smeshgui.SetName(quadID, "Quadrangle_2D") + +print "-------------------------- Hexa_3D" + +hypothesis=gen.CreateHypothesis("Hexa_3D") +hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D) +hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) ) +smeshgui.SetName(hexaID, "Hexa_3D") + +# ---- init a Mesh with the volume + +mesh=gen.Init(idVol) +idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) +smeshgui.SetName(idmesh, "meshVolume") +smeshgui.SetShape(idVol, idmesh) + +# ---- add hypothesis to the volume + +print "-------------------------- add hypothesis to the volume" + +ret=mesh.AddHypothesis(vol,regular1D) +print ret +ret=mesh.AddHypothesis(vol,hypNbSeg) +print ret +ret=mesh.AddHypothesis(vol,quad2D) +print ret +ret=mesh.AddHypothesis(vol,hexa3D) +print ret + +print "-------------------------- set algoritms" + +smeshgui.SetAlgorithms( idmesh, regularID) +smeshgui.SetHypothesis( idmesh, idseg ) +smeshgui.SetAlgorithms( idmesh, quadID ) +smeshgui.SetAlgorithms( idmesh, hexaID ) + +for i in range(8): + print "-------------------------- add hypothesis to edge in the Z directions", (i+1) + + subMeshEdgeZ = mesh.GetElementsOnShape(edgeZ[i]) + + retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ) + print " add hyp Z ", retZ + + idsmZ = smeshgui.AddSubMeshOnShape( + idmesh,idEdgeZ[i],salome.orb.object_to_string(subMeshEdgeZ), + ShapeTypeEdge) + + smeshgui.SetName(idsmZ, "SubMeshEdgeZ_"+str(i+1)) + + smeshgui.SetHypothesis(idsmZ, idsegZ) + +sg.updateObjBrowser(1) + +print "-------------------------- compute the mesh of the volume" +ret=gen.Compute(mesh,idVol) +print ret +if ret != 0: + log=mesh.GetLog(0) # no erase trace + for linelog in log: + print linelog +else: + print "problem when Computing the mesh" + +sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_demo_tetra.py b/src/SMESH_SWIG/SMESH_demo_tetra.py new file mode 100644 index 000000000..95a5ef0f2 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_demo_tetra.py @@ -0,0 +1,176 @@ +# +# Tetrahedrization of a geometry (box minus a inner cylinder). +# Hypothesis and algorithms for the mesh generation are global +# + +import salome +from salome import sg + +import geompy + +import SMESH +import smeshpy + +# ----------------------------------------------------------------------------- + +geom = geompy.geom +myBuilder = geompy.myBuilder + +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeEdge = 6 + +# ---- define a boxe and a cylinder +x0 = -1. +y0 = -1. +z0 = -1. + +x1 = 1. +y1 = 1. +z1 = 1. + +P0 = geom.MakePointStruct(0.,-1.,0.) +P1 = geom.MakePointStruct(0.,1.,0.) +Vect = geom.MakeDirection(P1) +radius = 0.5 +height = 2. + +boxe = geompy.MakeBox(x0,y0,z0,x1,y1,z1) + +cylinder = geompy.MakeCylinder(P0,Vect,radius,height) + +shape = geompy.MakeBoolean(boxe,cylinder,2) +idshape = geompy.addToStudy(shape,"shape") + +print "" + +print "Analysis of the shape :" +subShellList=geompy.SubShapeAll(shape,ShapeTypeShell) +subFaceList=geompy.SubShapeAll(shape,ShapeTypeFace) +subEdgeList=geompy.SubShapeAll(shape,ShapeTypeEdge) + +print "number of Shells in the shape : ",len(subShellList) +print "number of Faces in the shape : ",len(subFaceList) +print "number of Edges in the shape : ",len(subEdgeList) + +# ---- launch SMESH + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +gen=smeshpy.smeshpy() + +# ---- create Hypothesis + +print "-------------------------- create Hypothesis" + +print "-------------------------- NumberOfSegments" + +numberOfSegments = 10 + +hypothesis=gen.CreateHypothesis("NumberOfSegments") +hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSeg.SetNumberOfSegments(numberOfSegments) +hypNbSegID = hypNbSeg.GetId() +print hypNbSeg.GetName() +print hypNbSegID +print hypNbSeg.GetNumberOfSegments() + +idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) ) +smeshgui.SetName(idseg, "NumberOfSegments") + +print "-------------------------- LengthFromEdges" + +hypothesis=gen.CreateHypothesis("LengthFromEdges") +hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges) +hypLengthFromEdgeID = hypLengthFromEdge.GetId() +print hypLengthFromEdge.GetName() +print hypLengthFromEdgeID + +idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) ) +smeshgui.SetName(idlenfromedge, "LengthFromEdge") + +print "-------------------------- MaxElementVolume" + +maxElementVolume = 0.5 + +hypothesis=gen.CreateHypothesis("MaxElementVolume") +hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume) +hypVolume.SetMaxElementVolume(maxElementVolume) +print hypVolume.GetName() +print hypVolume.GetId() +print hypVolume.GetMaxElementVolume() + +idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) ) +smeshgui.SetName(idvolume, "MaxElementVolume") + +# ---- create Algorithms + +print "-------------------------- create Algorithms" + +print "-------------------------- Regular_1D" + +hypothesis=gen.CreateHypothesis("Regular_1D") +regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D) +regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) ) +smeshgui.SetName(regularID, "Wire Discretisation") + +print "-------------------------- MEFISTO_2D" + +hypothesis=gen.CreateHypothesis("MEFISTO_2D") +mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D) +mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) ) +smeshgui.SetName(mefistoID, "MEFISTO_2D") + +print "-------------------------- NETGEN_3D" + +hypothesis=gen.CreateHypothesis("NETGEN_3D") +netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D) +netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) ) +smeshgui.SetName(netgenID, "NETGEN_3D") + +# ---- init a Mesh with the shell + +mesh=gen.Init(idshape) +idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) +smeshgui.SetName(idmesh, "MeshShape") +smeshgui.SetShape(idshape, idmesh) + +# ---- add hypothesis to flight + +print "-------------------------- add hypothesis to the shape" + +ret=mesh.AddHypothesis(shape,regular1D) +print ret +ret=mesh.AddHypothesis(shape,hypNbSeg) +print ret +ret=mesh.AddHypothesis(shape,mefisto2D) +print ret +ret=mesh.AddHypothesis(shape,hypLengthFromEdge) +print ret +ret=mesh.AddHypothesis(shape,netgen3D) +print ret +ret=mesh.AddHypothesis(shape,hypVolume) +print ret + +smeshgui.SetAlgorithms( idmesh, regularID) +smeshgui.SetHypothesis( idmesh, idseg ) +smeshgui.SetAlgorithms( idmesh, mefistoID ) +smeshgui.SetHypothesis( idmesh, idlenfromedge) +smeshgui.SetAlgorithms( idmesh, netgenID ) +smeshgui.SetHypothesis( idmesh, idvolume ) + +sg.updateObjBrowser(1) + + +print "-------------------------- compute the mesh of the shape" +ret=gen.Compute(mesh,idshape) +print ret +if ret != 0: + log=mesh.GetLog(0) # no erase trace + for linelog in log: + print linelog +else: + print "probleme when computing the mesh" + +sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_demo_tetra2.py b/src/SMESH_SWIG/SMESH_demo_tetra2.py new file mode 100644 index 000000000..7aebfa509 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_demo_tetra2.py @@ -0,0 +1,243 @@ +# +# Tetrahedrization of a geometry (box minus a inner cylinder). +# Hypothesis and algorithms for the mesh generation are not +# global: the mesh of some edges is thinner. +# + +import salome +from salome import sg + +import geompy + +import SMESH +import smeshpy + +# ----------------------------------------------------------------------------- + +geom = geompy.geom +myBuilder = geompy.myBuilder + +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeEdge = 6 + +# ---- define a boxe and a cylinder +x0 = -1. +y0 = -1. +z0 = -1. + +x1 = 1. +y1 = 1. +z1 = 1. + +P0 = geom.MakePointStruct(0.,-1.,0.) +P1 = geom.MakePointStruct(0.,1.,0.) +Vect = geom.MakeDirection(P1) +radius = 0.5 +height = 2. + +boxe = geompy.MakeBox(x0,y0,z0,x1,y1,z1) + +cylinder = geompy.MakeCylinder(P0,Vect,radius,height) + +shape = geompy.MakeBoolean(boxe,cylinder,2) +idshape = geompy.addToStudy(shape,"shape") + +print "Analysis of the shape :" +subShellList=geompy.SubShapeAllSorted(shape,ShapeTypeShell) +subFaceList=geompy.SubShapeAllSorted(shape,ShapeTypeFace) +subEdgeList=geompy.SubShapeAllSorted(shape,ShapeTypeEdge) + +print "number of Shells in the shape : ",len(subShellList) +print "number of Faces in the shape : ",len(subFaceList) +print "number of Edges in the shape : ",len(subEdgeList) + +idSubEdge = [] +for k in range(len(subEdgeList)): + idSubEdge.append(geompy.addToStudyInFather(shape,subEdgeList[k],"SubEdge"+str(k))) + +circle1 = subEdgeList[5] +idCircle1 = geompy.addToStudyInFather(shape,circle1,"circle1") + +circle2 = subEdgeList[9] +idCircle2 = geompy.addToStudyInFather(shape,circle2,"circle2") + +height = subEdgeList[7] +idHeight = geompy.addToStudyInFather(shape,height,"height") + +# ---- launch SMESH + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +gen=smeshpy.smeshpy() + +# ---- create Hypothesis + +print "-------------------------- create Hypothesis" + +print "-------------------------- NumberOfSegments Edge of the boxe" + +numberOfSegmentsBoxe = 10 + +hypothesis=gen.CreateHypothesis("NumberOfSegments") +hypNbSegBoxe=hypothesis._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSegBoxe.SetNumberOfSegments(numberOfSegmentsBoxe) +hypNbSegID = hypNbSegBoxe.GetId() +print hypNbSegBoxe.GetName() +print hypNbSegID +print hypNbSegBoxe.GetNumberOfSegments() + +idSegBoxe = smeshgui.AddNewHypothesis(salome.orb.object_to_string(hypNbSegBoxe)) +smeshgui.SetName(idSegBoxe, "NumberOfSegmentsBoxe") + +print "-------------------------- NumberOfSegments Edge of the cylinder" + +numberOfSegmentsCylinder = 40 + +hypothesis=gen.CreateHypothesis("NumberOfSegments") +hypNbSegCylinder=hypothesis._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSegCylinder.SetNumberOfSegments(numberOfSegmentsCylinder) +hypNbSegID = hypNbSegCylinder.GetId() +print hypNbSegCylinder.GetName() +print hypNbSegID +print hypNbSegCylinder.GetNumberOfSegments() + +idSegCylinder = smeshgui.AddNewHypothesis(salome.orb.object_to_string(hypNbSegCylinder)) +smeshgui.SetName(idSegCylinder, "NumberOfSegmentsCylinder") + +print "-------------------------- LengthFromEdges" + +hypothesis=gen.CreateHypothesis("LengthFromEdges") +hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges) +hypLengthFromEdgeID = hypLengthFromEdge.GetId() +print hypLengthFromEdge.GetName() +print hypLengthFromEdgeID + +idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) ) +smeshgui.SetName(idlenfromedge, "LengthFromEdge") + +print "-------------------------- MaxElementVolume" + +maxElementVolume = 0.5 + +hypothesis=gen.CreateHypothesis("MaxElementVolume") +hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume) +hypVolume.SetMaxElementVolume(maxElementVolume) +print hypVolume.GetName() +print hypVolume.GetId() +print hypVolume.GetMaxElementVolume() + +idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) ) +smeshgui.SetName(idvolume, "MaxElementVolume") + +# ---- create Algorithms + +print "-------------------------- create Algorithms" + +print "-------------------------- Regular_1D" + +hypothesis=gen.CreateHypothesis("Regular_1D") +regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D) +regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) ) +smeshgui.SetName(regularID, "Wire Discretisation") + +print "-------------------------- MEFISTO_2D" + +hypothesis=gen.CreateHypothesis("MEFISTO_2D") +mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D) +mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) ) +smeshgui.SetName(mefistoID, "MEFISTO_2D") + +print "-------------------------- NETGEN_3D" + +hypothesis=gen.CreateHypothesis("NETGEN_3D") +netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D) +netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) ) +smeshgui.SetName(netgenID, "NETGEN_3D") + +# ---- init a Mesh with the shell + +mesh=gen.Init(idshape) +idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) +smeshgui.SetName(idmesh, "MeshShape") +smeshgui.SetShape(idshape, idmesh) + +# ---- add hypothesis to flight + +print "-------------------------- add hypothesis to the shape" + +ret=mesh.AddHypothesis(shape,regular1D) +print ret +ret=mesh.AddHypothesis(shape,hypNbSegBoxe) +print ret +ret=mesh.AddHypothesis(shape,mefisto2D) +print ret +ret=mesh.AddHypothesis(shape,hypLengthFromEdge) +print ret +ret=mesh.AddHypothesis(shape,netgen3D) +print ret +ret=mesh.AddHypothesis(shape,hypVolume) +print ret + +print "-------------------------- set algoritms" + +smeshgui.SetAlgorithms( idmesh, regularID) +smeshgui.SetHypothesis( idmesh, idSegBoxe ) +smeshgui.SetAlgorithms( idmesh, mefistoID ) +smeshgui.SetHypothesis( idmesh, idlenfromedge) +smeshgui.SetAlgorithms( idmesh, netgenID ) +smeshgui.SetHypothesis( idmesh, idvolume ) + +print "-------------------------- add hypothesis to the first circle" + +subMeshEdgeCircle1 = mesh.GetElementsOnShape(circle1) +retCircle1 = mesh.AddHypothesis(circle1,hypNbSegCylinder) +print " add hyp to C1 ", retCircle1 + +idsmCircle1 = smeshgui.AddSubMeshOnShape( + idmesh,idCircle1,salome.orb.object_to_string(subMeshEdgeCircle1), + ShapeTypeEdge) + +smeshgui.SetName(idsmCircle1, "SubMeshEdgeCircle1") +smeshgui.SetHypothesis(idsmCircle1, idSegCylinder) + +print "-------------------------- add hypothesis to the second circle" + +subMeshEdgeCircle2 = mesh.GetElementsOnShape(circle2) +retCircle2 = mesh.AddHypothesis(circle2,hypNbSegCylinder) +print " add hyp to C2 ", retCircle2 + +idsmCircle2 = smeshgui.AddSubMeshOnShape( + idmesh,idCircle2,salome.orb.object_to_string(subMeshEdgeCircle2), + ShapeTypeEdge) + +smeshgui.SetName(idsmCircle2, "SubMeshEdgeCircle2") +smeshgui.SetHypothesis(idsmCircle2, idSegCylinder) + +print "-------------------------- add hypothesis to the height of the cylinder" + +subMeshEdgeHeight = mesh.GetElementsOnShape(height) +retHeight = mesh.AddHypothesis(height,hypNbSegCylinder) +print " add hyp to H ", retHeight + +idsmHeight = smeshgui.AddSubMeshOnShape( + idmesh,idHeight,salome.orb.object_to_string(subMeshEdgeHeight), + ShapeTypeEdge) + +smeshgui.SetName(idsmHeight, "SubMeshEdgeHeight") +smeshgui.SetHypothesis(idsmHeight, idSegCylinder) + +sg.updateObjBrowser(1) + +print "-------------------------- compute the mesh of the shape" +ret=gen.Compute(mesh,idshape) +print ret +if ret != 0: + log=mesh.GetLog(0) # no erase trace + for linelog in log: + print linelog +else: + print "probleme when computing the mesh" + +sg.updateObjBrowser(1)