From: Paul RASCLE Date: Wed, 28 Oct 2015 15:55:01 +0000 (+0100) Subject: deux cas tests X-Git-Tag: BR_quadtree_20151126~10^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f4f6b17ecbe438de369e7a0f0f66104b01d7e2bc;p=modules%2Fhydro.git deux cas tests --- diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 3b3d33e2..a6950c2c 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -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 diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index cbad141c..cb27a5ca 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -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 index 00000000..e7969884 --- /dev/null +++ b/doc/salome/examples/h007_createPolySplineClosed.py @@ -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 index 00000000..74434dba --- /dev/null +++ b/doc/salome/examples/h008_simpleCase.py @@ -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)