]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
deux cas tests
authorPaul RASCLE <paul.rascle@edf.fr>
Wed, 28 Oct 2015 15:55:01 +0000 (16:55 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Wed, 28 Oct 2015 15:55:01 +0000 (16:55 +0100)
doc/salome/examples/CMakeLists.txt
doc/salome/examples/CTestTestfileInstall.cmake
doc/salome/examples/h007_createPolySplineClosed.py [new file with mode: 0644]
doc/salome/examples/h008_simpleCase.py [new file with mode: 0644]

index 3b3d33e245f09ee889383e44d0f669139c0b6320..a6950c2ca1d079fbb47d278a223f99418c6e5249 100644 (file)
@@ -26,6 +26,8 @@ SET(EXAMPLES_TESTS
   h004_importBathyXYZ.py
   h005_importImageBad.py
   h006_importBathyXYZBad.py
+  h007_createPolySplineClosed.py
+  h008_simpleCase.py
 )
 
 SET(HYDRO_SAMPLES
index cbad141c9504c6e2b8545ae23c6f984d9c607934..cb27a5ca4646f2a0b98921ba59bcdd499bf31aa9 100644 (file)
@@ -28,6 +28,8 @@ SET(EXAMPLES_TESTS
   h004_importBathyXYZ
   h005_importImageBad
   h006_importBathyXYZBad
+  h007_createPolySplineClosed
+  h008_simpleCase
 )
 
 FOREACH(tfile ${EXAMPLES_TESTS})
diff --git a/doc/salome/examples/h007_createPolySplineClosed.py b/doc/salome/examples/h007_createPolySplineClosed.py
new file mode 100644 (file)
index 0000000..e796988
--- /dev/null
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+
+import sys
+import salome
+
+salome.salome_init()
+theStudy = salome.myStudy
+
+from HYDROPy import *
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() )
+
+hydro_doc.SetLocalCS( 0, 0 )
+
+Polyline_1 = hydro_doc.CreateObject( KIND_POLYLINEXY )
+Polyline_1.SetName( "Polyline_1" )
+
+Polyline_1.SetZLevel( 0 )
+
+Polyline_1.SetWireColor( QColor( 0, 0, 0, 255 ) )
+
+Polyline_1.AddSection( "Section_1", 1, 1 )
+Polyline_1.AddPoint( 0, gp_XY( -293.23, 276.54 ) )
+Polyline_1.AddPoint( 0, gp_XY( -270.98, 163.29 ) )
+Polyline_1.AddPoint( 0, gp_XY( -207.28, 251.26 ) )
+Polyline_1.AddPoint( 0, gp_XY( -158.75, 160.26 ) )
+Polyline_1.AddPoint( 0, gp_XY( -109.20, 131.95 ) )
+Polyline_1.AddPoint( 0, gp_XY( -59.66, 126.90 ) )
+Polyline_1.AddPoint( 0, gp_XY( -54.60, 187.56 ) )
+Polyline_1.AddPoint( 0, gp_XY( -82.91, 220.93 ) )
+Polyline_1.AddPoint( 0, gp_XY( 76.84, 251.27 ) )
+Polyline_1.AddPoint( 0, gp_XY( -60.67, 285.65 ) )
+Polyline_1.AddPoint( 0, gp_XY( -73.81, 330.13 ) )
+
+Polyline_1.Update()
+
+
+
+if salome.sg.hasDesktop():
+  salome.sg.updateObjBrowser(1)
diff --git a/doc/salome/examples/h008_simpleCase.py b/doc/salome/examples/h008_simpleCase.py
new file mode 100644 (file)
index 0000000..74434db
--- /dev/null
@@ -0,0 +1,92 @@
+# -*- coding: utf-8 -*-
+
+import sys
+import salome
+
+salome.salome_init()
+theStudy = salome.myStudy
+
+from HYDROPy import *
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() )
+
+hydro_doc.SetLocalCS( 0, 0 )
+
+Polyline_1 = hydro_doc.CreateObject( KIND_POLYLINEXY )
+Polyline_1.SetName( "Polyline_1" )
+
+Polyline_1.SetZLevel( 0 )
+
+Polyline_1.AddSection( "Section_1", 1, 1 )
+Polyline_1.AddPoint( 0, gp_XY( -123.36, 57.13 ) )
+Polyline_1.AddPoint( 0, gp_XY( -74.82, 122.85 ) )
+Polyline_1.AddPoint( 0, gp_XY( -2.02, 179.47 ) )
+Polyline_1.AddPoint( 0, gp_XY( 79.88, 98.58 ) )
+Polyline_1.AddPoint( 0, gp_XY( 138.52, 23.76 ) )
+Polyline_1.AddPoint( 0, gp_XY( 30.33, -27.81 ) )
+Polyline_1.AddPoint( 0, gp_XY( -21.23, -101.62 ) )
+Polyline_1.AddPoint( 0, gp_XY( -48.53, 7.58 ) )
+Polyline_1.AddPoint( 0, gp_XY( -121.33, -13.65 ) )
+Polyline_1.AddPoint( 0, gp_XY( -288.17, 86.45 ) )
+
+Polyline_1.Update()
+
+
+Immersible_zone_1 = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
+Immersible_zone_1.SetName( "Immersible zone_1" )
+
+Immersible_zone_1.SetZLevel( 1 )
+
+Immersible_zone_1.SetPolyline( Polyline_1 )
+
+Immersible_zone_1.Update()
+
+
+# Calculation case
+Case_1 = hydro_doc.CreateObject( KIND_CALCULATION )
+Case_1.SetName( "Case_1" )
+
+Case_1.SetAssignmentMode( HYDROData_CalculationCase.AUTOMATIC )
+Case_1.SetAssignmentLandCoverMode( HYDROData_CalculationCase.AUTOMATIC )
+Case_1.AddGeometryObject( Immersible_zone_1 )
+
+Case_1.SetBoundaryPolyline( Polyline_1 )
+
+# Start the algorithm of the partition and assignment
+Case_1.Update()
+
+# Export of the calculation case
+Case_1_entry = Case_1.Export( theStudy._get_StudyId() )
+
+# Get geometry shape and print debug information
+import GEOM
+from salome.geom import geomBuilder
+import math
+import SALOMEDS
+
+geompy = geomBuilder.New(theStudy)
+
+print "Entry:", Case_1_entry
+Case_1_geom = salome.IDToObject( str( Case_1_entry ) )
+print "Geom shape:", Case_1_geom
+print "Geom shape name:", Case_1_geom.GetName()
+
+props = geompy.BasicProperties(Case_1_geom)
+print " Wires length: ", props[0]
+print " Surface area: ", props[1]
+print " Volume      : ", props[2]
+refLength = 1218.7373973
+refArea   = 49697.2117918
+deltaLength = 2.0*abs((props[0] - refLength)/(props[0] + refLength))
+deltaArea   = 2.0*abs((props[1] - refArea)/(props[1] + refArea))
+if deltaLength > 1e-7 or deltaArea > 1e-7 or props[2] != 0:
+  print "While must be:"
+  print " Wires length: ", refLength
+  print " Surface area: ", refArea
+  print " Volume      : ", 0.
+  raise ValueError("Bad length or area") 
+   
+if salome.sg.hasDesktop():
+  salome.sg.updateObjBrowser(1)