From: Paul RASCLE Date: Fri, 25 Nov 2016 10:16:45 +0000 (+0100) Subject: Merge branch 'BR_HYDRO_IMPS_2016' into pre/IMPS_2016 X-Git-Tag: v1.6~9^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9082efb75ca2505f8b4c5096d37e8d87491cd5d9;hp=89c7928d864f9be4f35aaa7409896c264849f273;p=modules%2Fhydro.git Merge branch 'BR_HYDRO_IMPS_2016' into pre/IMPS_2016 --- diff --git a/doc/salome/CMakeLists.txt b/doc/salome/CMakeLists.txt index 2a1bc39a..a466cf9e 100644 --- a/doc/salome/CMakeLists.txt +++ b/doc/salome/CMakeLists.txt @@ -20,7 +20,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -ADD_SUBDIRECTORY(gui) +#ADD_SUBDIRECTORY(gui) ADD_SUBDIRECTORY(examples) -ADD_SUBDIRECTORY(tutorial) -ADD_SUBDIRECTORY(tui) +#ADD_SUBDIRECTORY(tutorial) +#ADD_SUBDIRECTORY(tui) diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 71eac864..5c89302e 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -58,7 +58,7 @@ SET(HYDRO_SAMPLES # Application tests -SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test) +SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/HYDRO) INSTALL(FILES ${EXAMPLES_TESTS} ${HYDRO_SAMPLES} DESTINATION ${TEST_INSTALL_DIRECTORY}) INSTALL(FILES CTestTestfileInstall.cmake diff --git a/doc/salome/examples/h008_simpleCase.py b/doc/salome/examples/h008_simpleCase.py index 3779bc97..c36b8180 100644 --- a/doc/salome/examples/h008_simpleCase.py +++ b/doc/salome/examples/h008_simpleCase.py @@ -83,7 +83,7 @@ Case_1_geom = salome.IDToObject( str( Case_1_entry ) ) print "Geom shape:", Case_1_geom print "Geom shape name:", Case_1_geom.GetName() -controlGeomProps(geompy, Case_1_geom, 1218.7373973, 49578.1516521) +controlGeomProps(geompy, Case_1_geom, 1218.7373973, 49697.2117918) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h009_normalCaseManual.py b/doc/salome/examples/h009_normalCaseManual.py index f44f63b2..0cc76679 100644 --- a/doc/salome/examples/h009_normalCaseManual.py +++ b/doc/salome/examples/h009_normalCaseManual.py @@ -326,8 +326,8 @@ geompy.addToStudyInFather( HYDRO_garonne_1, litMineur, 'litMineur' ) geompy.addToStudyInFather( HYDRO_garonne_1, riveDroite, 'riveDroite' ) controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +controlGeomProps(geompy, litMineur, 30337.5484919, 3263628.55399) +controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h010_normalCaseManualMesh.py b/doc/salome/examples/h010_normalCaseManualMesh.py index 4b205db5..4d591350 100644 --- a/doc/salome/examples/h010_normalCaseManualMesh.py +++ b/doc/salome/examples/h010_normalCaseManualMesh.py @@ -343,13 +343,20 @@ geompy.addToStudyInFather( HYDRO_garonne_1, bordDroiteDomaine, 'bordDroiteDomain # --- basic properties control: edges length, surfaces controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) - +controlGeomProps(geompy, litMineur, 30337.5484919, 3263628.55399) +controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) #---------------------- # --- Meshing #---------------------- +med_file = r'/garonne_1.med' + +try: + os.remove(med_file) +except OSError: + pass + + import SMESH, SALOMEDS from salome.smesh import smeshBuilder from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats @@ -416,12 +423,12 @@ bordDroiteDomaine_2 = garonne_1.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine SectionsGaronne_3 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) garonne_1.SetAutoColor( 1 ) -garonne_1.ExportMED( r'/tmp/garonne_1.med', 0, SMESH.MED_V2_2, 1, None ,1) +garonne_1.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) -controlMeshStats(garonne_1, 3888, 475, 7597) -controlSubMeshStats(litMineur_2, 2384) -controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlMeshStats(garonne_1, 1763, 180, 3360) +controlSubMeshStats(litMineur_2, 48) +controlSubMeshStats(riveDroite_1, 1360) +controlSubMeshStats(riveGauche_1, 1952) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index 071974fb..70b756b9 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -342,14 +342,22 @@ geompy.addToStudyInFather( HYDRO_garonne_1, bordGaucheDomaine, 'bordGaucheDomain geompy.addToStudyInFather( HYDRO_garonne_1, bordDroiteDomaine, 'bordDroiteDomaine' ) # --- basic properties control: edges length, surfaces + controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +controlGeomProps(geompy, litMineur, 30337.5484919, 3263628.55399) +controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) #---------------------- # --- Meshing #---------------------- +med_file = r'/garonne_1.med' +try: + os.remove(med_file) +except OSError: + pass + + import SMESH, SALOMEDS from salome.smesh import smeshBuilder from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats @@ -416,12 +424,12 @@ bordDroiteDomaine_2 = garonne_1.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine SectionsGaronne_3 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) garonne_1.SetAutoColor( 1 ) -garonne_1.ExportMED( r'/tmp/garonne_1.med', 0, SMESH.MED_V2_2, 1, None ,1) +garonne_1.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) -controlMeshStats(garonne_1, 3888, 475, 7597) -controlSubMeshStats(litMineur_2, 2384) -controlSubMeshStats(riveDroite_1, 2342) -controlSubMeshStats(riveGauche_1, 2871) +controlMeshStats(garonne_1, 1763, 180, 3360) +controlSubMeshStats(litMineur_2, 48) +controlSubMeshStats(riveDroite_1, 1360) +controlSubMeshStats(riveGauche_1, 1952) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) @@ -437,7 +445,7 @@ from salome.hydrotools.controls import controlStatZ nomCas = 'garonne_1' # --- med file 2D(x,y) of the case produced by SMESH -fichierMaillage = '/tmp/garonne_1.med' +fichierMaillage = med_file # --- dictionary [med group name] = region name dicoGroupeRegion= dict(litMineur = 'garonne_1_litMineur', diff --git a/doc/salome/examples/h012_caseDigueManual.py b/doc/salome/examples/h012_caseDigueManual.py index 7bb8be11..10928b39 100644 --- a/doc/salome/examples/h012_caseDigueManual.py +++ b/doc/salome/examples/h012_caseDigueManual.py @@ -395,10 +395,10 @@ geompy.addToStudyInFather( HYDRO_garonne_2, digue, 'digue' ) geompy.addToStudyInFather( HYDRO_garonne_2, litMineur, 'litMineur' ) geompy.addToStudyInFather( HYDRO_garonne_2, riveDroite, 'riveDroite' ) -controlGeomProps(geompy, riveGauche, 39493.270283, 35845790.613557) -controlGeomProps(geompy, digue, 10343.901103, 103037.738504) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +controlGeomProps(geompy, riveGauche, 39489.5116033, 35889668.8348) +controlGeomProps(geompy, digue, 10340.1424233, 102887.6201) +controlGeomProps(geompy, litMineur, 30337.5484919, 3646827.74981) +controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h013_caseDigueManualMesh.py b/doc/salome/examples/h013_caseDigueManualMesh.py index 234958df..032dc234 100644 --- a/doc/salome/examples/h013_caseDigueManualMesh.py +++ b/doc/salome/examples/h013_caseDigueManualMesh.py @@ -417,10 +417,10 @@ geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' ) #garonne_2_digue_Right_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) #geompy.UnionIDs(garonne_2_digue_Right_Bank, [48]) -controlGeomProps(geompy, riveGauche, 39493.270283, 35845790.613557) -controlGeomProps(geompy, digue, 10343.901103, 103037.738504) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +controlGeomProps(geompy, riveGauche, 39489.5116033, 35889668.8348) +controlGeomProps(geompy, digue, 10340.1424233, 102887.6201) +controlGeomProps(geompy, litMineur, 30337.5484919, 3646827.74981) +controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) #---------------------- # --- Meshing @@ -506,14 +506,22 @@ digue_2 = garonne_2.GroupOnGeom(digue,'digue',SMESH.NODE) #bordDroiteDomaine_2 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE) SectionsGaronne_3 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) + +med_file = r'/garonne_2.med' + +try: + os.remove(med_file) +except OSError: + pass + garonne_2.SetAutoColor( 1 ) -garonne_2.ExportMED( r'/tmp/garonne_2.med', 0, SMESH.MED_V2_2, 1, None ,1) +garonne_2.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) -controlMeshStats(garonne_2, 6190, 691, 12201) +controlMeshStats(garonne_2, 5247, 717, 10075) controlSubMeshStats(litMineur_2, 2384) -controlSubMeshStats(riveDroite_1, 2400) -controlSubMeshStats(riveGauche_1, 6585) -controlSubMeshStats(digue_1, 832) +controlSubMeshStats(riveDroite_1, 2348) +controlSubMeshStats(riveGauche_1, 5343) +controlSubMeshStats(digue_1, 0) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h014_caseDigueManualInterpolZ.py b/doc/salome/examples/h014_caseDigueManualInterpolZ.py index ec45d249..ca0c2457 100644 --- a/doc/salome/examples/h014_caseDigueManualInterpolZ.py +++ b/doc/salome/examples/h014_caseDigueManualInterpolZ.py @@ -417,10 +417,10 @@ geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' ) #garonne_2_digue_Right_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) #geompy.UnionIDs(garonne_2_digue_Right_Bank, [48]) -controlGeomProps(geompy, riveGauche, 39493.270283, 35845790.613557) -controlGeomProps(geompy, digue, 10343.901103, 103037.738504) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +controlGeomProps(geompy, riveGauche, 39489.5116033, 35889668.8348) +controlGeomProps(geompy, digue, 10340.1424233, 102887.6201) +controlGeomProps(geompy, litMineur, 30337.5484919, 3646827.74981) +controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) #---------------------- # --- Meshing @@ -506,14 +506,23 @@ digue_2 = garonne_2.GroupOnGeom(digue,'digue',SMESH.NODE) #bordDroiteDomaine_2 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE) SectionsGaronne_3 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) + +med_file = r'/garonne_2.med' + +try: + os.remove(med_file) +except OSError: + pass + + garonne_2.SetAutoColor( 1 ) -garonne_2.ExportMED( r'/tmp/garonne_2.med', 0, SMESH.MED_V2_2, 1, None ,1) +garonne_2.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) -controlMeshStats(garonne_2, 6190, 691, 12201) +controlMeshStats(garonne_2, 5247, 717, 10075) controlSubMeshStats(litMineur_2, 2384) -controlSubMeshStats(riveDroite_1, 2400) -controlSubMeshStats(riveGauche_1, 6585) -controlSubMeshStats(digue_1, 832) +controlSubMeshStats(riveDroite_1, 2348) +controlSubMeshStats(riveGauche_1, 5343) +controlSubMeshStats(digue_1, 0) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) @@ -529,7 +538,7 @@ from salome.hydrotools.controls import controlStatZ nomCas = 'garonne_2' # --- med file 2D(x,y) of the case produced by SMESH -fichierMaillage = '/tmp/garonne_2.med' +fichierMaillage = med_file # --- dictionary [med group name] = region name dicoGroupeRegion= dict(litMineur = 'garonne_2_litMineur', diff --git a/doc/salome/examples/h016_pilesPontManualMesh.py b/doc/salome/examples/h016_pilesPontManualMesh.py index 35a4e795..7bbdb91b 100644 --- a/doc/salome/examples/h016_pilesPontManualMesh.py +++ b/doc/salome/examples/h016_pilesPontManualMesh.py @@ -1123,11 +1123,11 @@ geompy.addToStudyInFather( HYDRO_casGaronne_1, bordGauche, 'bordGauche' ) geompy.addToStudyInFather( HYDRO_casGaronne_1, piles, 'piles' ) # --- basic properties control: edges length, surfaces -controlGeomProps(geompy, riveGauche, 29149.1353799, 35949580.6716) -controlGeomProps(geompy, litMineur_aval, 7965.23431497, 935955.786347) -controlGeomProps(geompy, litMineur_pont, 961.8255222, 19618.016847) -controlGeomProps(geompy, litMineur_amont, 22635.6212065, 2531409.65041) -controlGeomProps(geompy, riveDroite, 32012.2241814, 25998085.6892) +controlGeomProps(geompy, riveGauche, 29149.1353799, 35950762.8967) +controlGeomProps(geompy, litMineur_aval, 7965.23431497, 938890.904721) +controlGeomProps(geompy, litMineur_pont, 961.8255222, 19618.0787789) +controlGeomProps(geompy, litMineur_amont, 22635.6212065, 2548509.17447) +controlGeomProps(geompy, riveDroite, 32012.2241814, 26188706.2202) ### ### SMESH component @@ -1218,15 +1218,23 @@ smesh.SetName(nbseg_litMineur_aval, 'nbseg_litMineur_aval') smesh.SetName(nbseg_litMineur_amont, 'nbseg_litMineur_amont') smesh.SetName(sections_1, 'sections') +med_file = r'/casGaronne_1.med' + +try: + os.remove(med_file) +except OSError: + pass + + casGaronne_1.SetAutoColor( 1 ) -casGaronne_1.ExportMED( r'/tmp/casGaronne_1.med', 0, SMESH.MED_V2_2, 1, None ,1) +casGaronne_1.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) -controlMeshStats(casGaronne_1, 6985, 745, 13761) -controlSubMeshStats(litMineur_pont_2, 185) +controlMeshStats(casGaronne_1, 7040, 746, 13871) +controlSubMeshStats(litMineur_pont_2, 204) controlSubMeshStats(litMineur_amont_2, 3000) controlSubMeshStats(litMineur_aval_2, 2000) -controlSubMeshStats(riveDroite_1, 3941) -controlSubMeshStats(riveGauche_1, 4635) +controlSubMeshStats(riveDroite_1, 4040) +controlSubMeshStats(riveGauche_1, 4627) if salome.sg.hasDesktop(): diff --git a/doc/salome/examples/h017_interpolationLineaire.py b/doc/salome/examples/h017_interpolationLineaire.py index 63073d54..9d313a69 100644 --- a/doc/salome/examples/h017_interpolationLineaire.py +++ b/doc/salome/examples/h017_interpolationLineaire.py @@ -316,8 +316,17 @@ isDone = relief.Compute() domaine_1 = relief.GroupOnGeom(domaine,'domaine',SMESH.FACE) domaine_2 = relief.GroupOnGeom(domaine,'domaine',SMESH.NODE) smesh.SetName(relief, 'relief') + +med_file = r'/relief.med' + +try: + os.remove(med_file) +except OSError: + pass + + try: - relief.ExportMED( r'/tmp/relief.med', 0, SMESH.MED_V2_2, 1, None ,1) + relief.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) except: print 'ExportToMEDX() failed. Invalid file name?' @@ -344,7 +353,7 @@ from salome.hydrotools.controls import controlStatZ nomCas = 'etude' # --- fichier med 2D(x,y) du cas, produit par SMESH -fichierMaillage = '/tmp/relief.med' +fichierMaillage = med_file # --- dictionnaire: (clé = nom de groupe med, valeur= nom de région) dicoGroupeRegion= dict(domaine = 'etude_Reg_1', diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index f7d31037..f0a871a3 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -71,6 +71,24 @@ std::map HYDROData_Bathymetry::myQuadtrees; std::map HYDROData_Bathymetry::myDelaunay2D; #endif +inline double sqr( double x ) +{ + return x*x; +} + +HYDROData_Bathymetry::AltitudePoint::AltitudePoint( double x, double y, double z ) +{ + X=x; Y=y; Z=z; +} + +double HYDROData_Bathymetry::AltitudePoint::SquareDistance( const HYDROData_Bathymetry::AltitudePoint& p ) const +{ + double d = 0; + d += sqr( X - p.X ); + d += sqr( Y - p.Y ); + d += sqr( Z - p.Z ); + return d; +} HYDROData_Bathymetry::HYDROData_Bathymetry() : HYDROData_IAltitudeObject() @@ -169,7 +187,7 @@ HYDROData_QuadtreeNode* HYDROData_Bathymetry::GetQuadtreeNodes() const // if (myQuadtree->isEmpty() ) if (myQuadtrees.find(labkey) == myQuadtrees.end()) { - DEBTRACE("GetQuadtreeNodes init " << this << " " << labkey); + //DEBTRACE("GetQuadtreeNodes init " << this << " " << labkey); HYDROData_QuadtreeNode* aQuadtree = new HYDROData_QuadtreeNode(0, 30, 5, 0.); myQuadtrees[labkey] = aQuadtree; TDF_Label aLabel = myLab.FindChild(DataTag_AltitudePoints, false); @@ -195,7 +213,7 @@ HYDROData_QuadtreeNode* HYDROData_Bathymetry::GetQuadtreeNodes() const index++; aListOfNodes->push_back(aPoint); } - DEBTRACE(" GetQuadtreeNodes call setNodesAndCompute"); + //DEBTRACE(" GetQuadtreeNodes call setNodesAndCompute"); aQuadtree->setNodesAndCompute(aListOfNodes); return aQuadtree; } @@ -214,7 +232,7 @@ vtkPolyData* HYDROData_Bathymetry::GetVtkDelaunay2D() const //DEBTRACE("GetVtkDelaunay2D this labkey altkey "<SetPoints(points); - DEBTRACE("Number of Points: "<< points->GetNumberOfPoints()); + //DEBTRACE("Number of Points: "<< points->GetNumberOfPoints()); vtkDelaunay2D* delaunay2D = vtkDelaunay2D::New(); delaunay2D->SetInputData(profile); @@ -321,7 +339,7 @@ bool interpolZtriangle(const gp_XY& point, vtkPolyData* delaunay2D, vtkIdList* t int nbPts = triangle->GetNumberOfIds(); if (nbPts != 3) { - DEBTRACE("not a triangle ?"); + //DEBTRACE("not a triangle ?"); return false; } vtkIdType s[3]; @@ -341,7 +359,7 @@ bool interpolZtriangle(const gp_XY& point, vtkPolyData* delaunay2D, vtkIdList* t double det = (v[1][1]-v[2][1])*(v[0][0]-v[2][0]) + (v[2][0]-v[1][0])*(v[0][1]-v[2][1]); if (det == 0) { - DEBTRACE("flat triangle ?"); + //DEBTRACE("flat triangle ?"); return false; } @@ -367,7 +385,7 @@ bool interpolZtriangle(const gp_XY& point, vtkPolyData* delaunay2D, vtkIdList* t double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint, int theMethod) const { - DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << "), interpolation method: " << theMethod); + //DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << "), interpolation method: " << theMethod); double anInvalidAltitude = GetInvalidAltitude(); double aResAltitude = anInvalidAltitude; @@ -376,7 +394,7 @@ double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint, int theM HYDROData_QuadtreeNode* aQuadtree = GetQuadtreeNodes(); if (!aQuadtree) { - DEBTRACE(" no Quadtree"); + //DEBTRACE(" no Quadtree"); return aResAltitude; } @@ -385,13 +403,13 @@ double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint, int theM while (dist2nodes.size() == 0) { aQuadtree->setPrecision(aQuadtree->getPrecision() *2); - DEBTRACE("adjust precision to: " << aQuadtree->getPrecision()); + //DEBTRACE("adjust precision to: " << aQuadtree->getPrecision()); aQuadtree->NodesAround(thePoint, dist2nodes, aQuadtree->getPrecision()); } std::map::const_iterator it = dist2nodes.begin(); aResAltitude = it->second->Z(); int nodeIndex = it->second->getIndex(); - DEBTRACE(" number of points found: " << dist2nodes.size() << " nearest z: " << aResAltitude << " point index: " << nodeIndex); + //DEBTRACE(" number of points found: " << dist2nodes.size() << " nearest z: " << aResAltitude << " point index: " << nodeIndex); // --- for coarse bathymetry clouds (when the TELEMAC mesh is more refined than the bathymetry cloud) // interpolation is required. @@ -413,7 +431,7 @@ double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint, int theM points->Allocate(64); aDelaunay2D->GetPointCells(nodeIndex, cells); vtkIdType nbCells = cells->GetNumberOfIds(); - DEBTRACE(" triangles on nearest point: " << nbCells); + //DEBTRACE(" triangles on nearest point: " << nbCells); bool isInside = false; for (int i=0; i AltitudePoints; diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 610e96a1..ebfd1803 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -1046,7 +1046,8 @@ QString HYDROData_CalculationCase::Export( int theStudyId ) const SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId ); QString aGeomObjEntry, anErrorMsg; - bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg ); + QString statMess; + bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg, statMess ); return isOK ? aGeomObjEntry : QString(); #endif } @@ -1055,7 +1056,8 @@ QString HYDROData_CalculationCase::Export( int theStudyId ) const bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, QString& theGeomObjEntry, - QString& theErrorMsg ) const + QString& theErrorMsg, + QString& statMess) const { HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs; @@ -1122,7 +1124,9 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, if( aRes && !GetLandCoverMap().IsNull() && !GetStricklerTable().IsNull() ) { QString aTelemacFileName = GetName() + ".telemac"; - aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable() ); + aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable(), statMess ); + if (!aRes) + theErrorMsg = QString( "The export to TELEMAC %1 failed" ).arg( aTelemacFileName ); } return aRes; } @@ -1446,6 +1450,8 @@ bool HYDROData_CalculationCase::AddInterPoly( const Handle(HYDROData_PolylineXY) AddReferenceObject( theInterPolyline, aDataTag ); + Changed( Geom_2d ); + return true; } diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 242a8b68..b88a108e 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -301,7 +301,8 @@ public: HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, QString& theGeomObjEntry, - QString& theErrorMsg ) const; + QString& theErrorMsg, + QString& statMess) const; #endif public: diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 5134765d..bdbac0cb 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -46,15 +46,16 @@ #include #include #include +#include +#include IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry ) IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry ) - -HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir ) - : myXcurv( theXCurv ), myProfileDir( theProfileDir ) +HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir, double theDeltaZ ) + : myXcurv( theXCurv ), myProfileDir( theProfileDir ), myDeltaZ( theDeltaZ ) { } @@ -72,10 +73,19 @@ gp_Vec2d HYDROData_DTM::CurveUZ::ProfileDir() const return myProfileDir; } +double HYDROData_DTM::CurveUZ::DeltaZ() const +{ + return myDeltaZ; +} + HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator + ( const CurveUZ& c ) const { - HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir() ); - size_t n = size(); + HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir(), DeltaZ() + c.DeltaZ() ); + size_t n = size(), n1 = c.size(); + if( n!=n1 ) + { + std::cout << "Warning: different number of points in curves: " << n << ", " << n1 << std::endl; + } res.reserve( n ); for( int i=0; i InvInd; - CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd ); + bool WireIntersections; //__TODO + CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1, WireIntersections ); SetAltitudePoints( points ); SetShape( DataTag_LeftBankShape, OutLeftB); @@ -230,7 +244,6 @@ void HYDROData_DTM::GetPresentationShapes( TopoDS_Shape& Out3dPres, Out3dPres = GetShape( DataTag_3DShape ); Out2dPres = GetShape( DataTag_2DShape ); } - void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& InpProfiles, double ddz, double step, @@ -243,9 +256,10 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set& InvInd) + std::set& InvInd, + int thePntsLimit, + bool& WireIntersections) { - int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper(); size_t n = anUpper - aLower + 1; @@ -262,15 +276,21 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In AltitudePoints right; std::vector main_profiles; + if( thePntsLimit > 0 ) + { + int aNbPoints = EstimateNbPoints( profiles, ddz, step ); + if( aNbPoints < 0 || aNbPoints > thePntsLimit ) + return; + } + if( ddz>EPS && step>EPS ) CreateProfiles(profiles, ddz, step, left, right, points, main_profiles, - Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd ); + Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd, WireIntersections ); } void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire) { - //its also possible to use BrepAlgo_NormalProjection here! - BRepTools_WireExplorer ex(TopoDS::Wire(inpWire.Oriented(TopAbs_FORWARD))); + /*BRepTools_WireExplorer ex(TopoDS::Wire(inpWire.Oriented(TopAbs_FORWARD))); BRepLib_MakeWire WM; for (;ex.More();ex.Next()) { @@ -278,15 +298,39 @@ void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geo double f, l; Handle(Geom_Curve) C3d = BRep_Tool::Curve(CE, f, l); Handle(Geom_Curve) ProjectedCurve = GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d, f, l), RefPlane, RefPlane->Position().Direction(), Standard_True); - TopoDS_Edge ProjEdge = BRepLib_MakeEdge(ProjectedCurve); - WM.Add(ProjEdge); //auto sharing between edges if vertex is coincident - } + if (!ProjectedCurve.IsNull()) + { + TopoDS_Edge ProjEdge = BRepLib_MakeEdge(ProjectedCurve, f, l ); + if (!BRep_Tool::Degenerated(ProjEdge)) + WM.Add(ProjEdge); //auto sharing between edges if vertex is coincident + } + }*/ + + BRep_Builder BB; + TopoDS_Face F; + BB.MakeFace(F, RefPlane, Precision::Confusion()); + BRepLib_MakeWire WM; + + BRepAlgo_NormalProjection nproj(F); + nproj.Add(inpWire); + nproj.SetDefaultParams(); + nproj.Build(); + if(!nproj.IsDone()) + return; + TopoDS_Shape projRes = nproj.Projection(); + TopExp_Explorer exp(projRes, TopAbs_EDGE); + TopTools_ListOfShape llE; + for (;exp.More();exp.Next()) + llE.Append(exp.Current()); + + WM.Add(llE); outWire = WM.Wire(); + outWire.Orientation(inpWire.Orientation()); //take from the original wire } -void HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF ) +bool HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF ) { Handle_Geom_Plane refpl = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1)); BRepLib_MakeWire WM; @@ -312,9 +356,13 @@ void HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& TopoDS_Wire outW; ProjWireOnPlane(WM.Wire(), refpl, outW); - BRepBuilderAPI_MakeFace mf(refpl, outW); //check inside is true by def + BRepBuilderAPI_MakeFace mf(refpl, outW, true); //check inside is true by def outF = mf.Face(); + ShapeAnalysis_Wire WA(outW, outF, Precision::Confusion()); + bool res = WA.CheckSelfIntersection(); + return res; + ///!!! the internal wires cant be added with 'internal' ori. // it's possible to do with brep builder yet the result will not be correct! // more proper way is to use BOP operation here. @@ -342,7 +390,8 @@ void HYDROData_DTM::CreateProfiles(const std::vector& TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set& InvInd) + std::set& InvInd, + bool& WireIntersections) { if (theProfiles.empty()) return; @@ -371,7 +420,7 @@ void HYDROData_DTM::CreateProfiles(const std::vector& if (Create2dPres) { TopoDS_Face outF; - Get2dFaceFrom3dPres(cmp, outF); + WireIntersections = Get2dFaceFrom3dPres(cmp, outF); //__TODO Out2dPres = outF; }; } @@ -535,7 +584,7 @@ std::vector HYDROData_DTM::ProfileToParametric( GetProperties( theProfile, aLowest, theDir, false, zmin, zmax ); gp_Ax3 aStd3d( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( 1, 0, 0 ) ); - gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( theDir.X(), theDir.Y(), 0 ) ); + gp_Ax3 aLocal( gp_Pnt( aLowest.X(), aLowest.Y(), 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( theDir.X(), theDir.Y(), 0 ) ); gp_Trsf aTransf; aTransf.SetTransformation( aStd3d, aLocal ); @@ -562,18 +611,19 @@ std::vector HYDROData_DTM::ProfileToParametric( } -bool CalcMidWidth( const std::vector& intersections, double& theMid, double& theWid ) +bool CalcMidWidth( const std::set& intersections, double& theMid, double& theWid ) { double umin = std::numeric_limits::max(), umax = -umin; size_t n = intersections.size(); - if( n <= 1 ) + if( n <= 0 ) return false; - for( size_t i = 0; i < n; i++ ) + std::set::const_iterator it = intersections.begin(), last = intersections.end(); + for( ; it!=last; it++ ) { - double u = intersections[i].X(); + double u = *it; if( uumax ) @@ -617,32 +667,33 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr curves.push_back( aT2 ); int psize = ( int )( ( theMaxZ-theMinZ ) / theDDZ + 1 ); - theMidPointCurve = CurveUZ( theXCurv, aProfileDir ); + theMidPointCurve = CurveUZ( theXCurv, aProfileDir, theMinZ ); theMidPointCurve.reserve( psize ); - theWidthCurve = CurveUZ( theXCurv, aProfileDir ); + theWidthCurve = CurveUZ( theXCurv, aProfileDir, theMinZ ); theWidthCurve.reserve( psize ); n = curves.size(); // for each discrete value of z we search intersection with profile - for( double z = theMinZ; z <= theMaxZ; z += theDDZ ) + for( double z1 = theMinZ; z1 <= theMaxZ; z1 += theDDZ ) { - Handle(Geom2d_Line) aLine = new Geom2d_Line( gp_Pnt2d( 0, z ), gp_Dir2d( 1, 0 ) ); - std::vector intersections; + Handle(Geom2d_Line) aLine = new Geom2d_Line( gp_Pnt2d( 0, z1 ), gp_Dir2d( 1, 0 ) ); + std::set intersections; for( size_t i = 0; i < n; i++ ) { Handle_Geom2d_Curve aCurve = curves[i]; Geom2dAPI_InterCurveCurve anIntersect( aCurve, aLine, theTolerance ); for( int k=1, m=anIntersect.NbPoints(); k<=m; k++ ) - intersections.push_back( anIntersect.Point( k ) ); + intersections.insert( anIntersect.Point( k ).X() ); } intersection_nb = intersections.size(); - if( intersection_nb >= 2 ) + if( intersection_nb >= 1 ) { double u_mid, u_wid; if( !CalcMidWidth( intersections, u_mid, u_wid ) ) continue; + double z = z1 - theMinZ; PointUZ p_mid; p_mid.U = u_mid; p_mid.Z = z; @@ -677,7 +728,7 @@ void HYDROData_DTM::Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCur #include void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis, const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve, - AltitudePoints& thePoints, double dz ) + AltitudePoints& thePoints ) { Geom2dAdaptor_Curve anAdaptor( theHydraulicAxis ); TopoDS_Edge E2d = BRepLib_MakeEdge2d(theHydraulicAxis).Edge(); @@ -687,7 +738,7 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi gp_Pnt2d point; anAdaptor.D0( aParam, point ); gp_Vec2d profile_dir = theMidCurve.ProfileDir(); - gp_Dir tangent_n( -profile_dir.Y(), profile_dir.X(), dz ); + //gp_Dir tangent_n( -profile_dir.Y(), profile_dir.X(), dz ); profile_dir.Normalize(); size_t n = theMidCurve.size(); @@ -700,7 +751,7 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi gp_Pnt2d p1 = point.Translated( param1 * profile_dir); gp_Pnt2d p2 = point.Translated( param2 * profile_dir); - double z = theMidCurve[i].Z; + double z = theMidCurve[i].Z + theMidCurve.DeltaZ(); AltitudePoint p3d_1( p1.X(), p1.Y(), z ), p3d_2( p2.X(), p2.Y(), z ); @@ -709,9 +760,11 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi } thePoints.reserve( sorted_points.size() ); + const double EPS = 1E-12; std::map::const_iterator it = sorted_points.begin(), last = sorted_points.end(); for( ; it!=last; it++ ) - thePoints.push_back( it->second ); + if( thePoints.empty() || thePoints.back().SquareDistance( it->second ) > EPS ) + thePoints.push_back( it->second ); } inline double max( double a, double b ) @@ -722,6 +775,14 @@ inline double max( double a, double b ) return b; } +inline double min( double a, double b ) +{ + if( a std::vector HYDROData_DTM::Interpolate @@ -740,16 +801,18 @@ std::vector HYDROData_DTM::Interpolate GetProperties( theProfileA, lowestA, dirA, false, zminA, zmaxA ); GetProperties( theProfileB, lowestB, dirB, false, zminB, zmaxB ); - double dz = zminB - zminA; + + double hmax = max( zmaxA-zminA, zmaxB-zminB ); - double zmin = max( zminA, zminB ); - double zmax = max( zmaxA, zmaxB ); + //double dz = zminB - zminA; + //double zmin = min( zminA, zminB ); + //double zmax = max( zmaxA, zmaxB ); - CurveUZ midA(0, gp_Vec2d()), midB(0, gp_Vec2d()); - CurveUZ widA(0, gp_Vec2d()), widB(0, gp_Vec2d()); + CurveUZ midA(0, gp_Vec2d(), 0), midB(0, gp_Vec2d(), 0); + CurveUZ widA(0, gp_Vec2d(), 0), widB(0, gp_Vec2d(), 0); - ProfileDiscretization( theProfileA, theXCurvA, zmin, zmax, theDDZ, midA, widA, inter_nb_1 ); - ProfileDiscretization( theProfileB, theXCurvB, zmin, zmax, theDDZ, midB, widB, inter_nb_2 ); + ProfileDiscretization( theProfileA, theXCurvA, zminA, zminA+hmax, theDDZ, midA, widA, inter_nb_1 ); + ProfileDiscretization( theProfileB, theXCurvB, zminB, zminB+hmax, theDDZ, midB, widB, inter_nb_2 ); std::vector mid, wid; Interpolate( midA, midB, theNbSteps, mid, isAddSecond ); @@ -763,7 +826,7 @@ std::vector HYDROData_DTM::Interpolate for( size_t i=0; i= 2) + if (inter_nb_1 > 2) invalInd.insert(i); - if (inter_nb_2 >= 2) + if (inter_nb_2 > 2) invalInd.insert(i+1); // 2. Put all points into the global container @@ -837,3 +900,31 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate } return points; } + +int HYDROData_DTM::EstimateNbPoints( const std::vector& theProfiles, + double theDDZ, double theSpatialStep ) +{ + size_t n = theProfiles.size(); + if( n<=1 ) + return 0; + if( theDDZ<1E-6 || theSpatialStep<1E-6 ) + return 1 << 20; + + std::vector distances; + Handle_Geom2d_BSplineCurve aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances ); + if( aHydraulicAxis.IsNull() ) + return 0; + + double aCompleteDistance = distances[n-1]; + int aNbSteps = int( aCompleteDistance / theSpatialStep ) + 1; + gp_Pnt aLowest; + gp_Vec2d aDir; + double aZMin, aZMax; + GetProperties( theProfiles[0], aLowest, aDir, true, aZMin, aZMax ); + int aNbZSteps = (aZMax-aZMin)/theDDZ; + + if( aNbSteps > ( 1<<16 ) || aNbZSteps > ( 1<<16 ) ) + return 1 << 20; + + return aNbSteps * aNbZSteps; +} diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h index 4835cef1..2a60f75a 100644 --- a/src/HYDROData/HYDROData_DTM.h +++ b/src/HYDROData/HYDROData_DTM.h @@ -85,11 +85,12 @@ public: class CurveUZ : public std::vector { public: - CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir = gp_Vec2d() ); + CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir, double theDeltaZ ); ~CurveUZ(); double Xcurv() const; - gp_Vec2d ProfileDir() const; + gp_Vec2d ProfileDir() const; + double DeltaZ() const; CurveUZ operator + ( const CurveUZ& ) const; CurveUZ operator * ( double ) const; @@ -97,6 +98,7 @@ public: private: double myXcurv; gp_Vec2d myProfileDir; + double myDeltaZ; }; protected: @@ -129,7 +131,7 @@ protected: static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis, const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve, - AltitudePoints& thePoints, double dz ); + AltitudePoints& thePoints ); static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, int theNbSteps, std::vector& theInterpolation, @@ -174,10 +176,14 @@ protected: TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set& InvInd ); + std::set& InvInd, + bool& WireIntersections); + + static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF ); + + static int EstimateNbPoints( const std::vector& theProfiles, + double theDDZ, double theSpatialStep ); - static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF ); - void GetPresentationShapes( TopoDS_Shape& Out3dPres, TopoDS_Shape& Out2dPres, TopoDS_Shape& OutLeftB, @@ -198,7 +204,9 @@ public: TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set& InvInd ); + std::set& InvInd, + int thePntsLimit, + bool& WireIntersections); }; diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index 3f3942a6..5e38d577 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -237,7 +237,7 @@ bool HYDROData_Document::DumpToPython( const QString& thePyScriptPath, { // Try to open the file QFile aFile( thePyScriptPath ); - if ( !aFile.open( QIODevice::WriteOnly ) ) + if ( !aFile.open( QIODevice::WriteOnly | QFile::Text ) ) return false; MapOfTreatedObjects aTreatedObjects; diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index c582b16f..046e61fd 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -62,6 +62,7 @@ #include #include #include +#include #include @@ -367,7 +368,8 @@ bool EdgeDiscretization( const TopoDS_Edge& theEdge, */ bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName, double theDeflection, - const Handle(HYDROData_StricklerTable)& theTable ) const + const Handle(HYDROData_StricklerTable)& theTable, + QString& statMessage) const { TopoDS_Shape aLandCoverMapShape = GetShape(); TopTools_ListOfShape aListOfFaces; @@ -418,7 +420,19 @@ bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName, QFile aFile( theFileName ); if( !aFile.open( QFile::WriteOnly | QFile::Text ) ) - return false; + { + QString homeFilePath = QDir::home().absoluteFilePath( theFileName ); + aFile.setFileName(homeFilePath); + if (aFile.open( QFile::WriteOnly | QFile::Text ) ) + statMessage = "Telemac file have been exported to the home directory: " + homeFilePath; + else + return false; + } + else + { + QString absFilePath = QDir::current().absoluteFilePath( theFileName ); + statMessage = "Telemac file have been exported to the current directory: " + absFilePath; + } QTextStream aStream( &aFile ); aStream << "# nodes\n"; diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index e009351a..f6e681b0 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -111,7 +111,8 @@ public: HYDRODATA_EXPORT bool ExportTelemac( const QString& theFileName, double theDeflection, - const Handle_HYDROData_StricklerTable& theTable ) const; + const Handle_HYDROData_StricklerTable& theTable, + QString& statMessage) const; HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType ); HYDRODATA_EXPORT bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType ); diff --git a/src/HYDROData/HYDROData_QuadtreeNode.cxx b/src/HYDROData/HYDROData_QuadtreeNode.cxx index 547b8a47..11fe12cd 100644 --- a/src/HYDROData/HYDROData_QuadtreeNode.cxx +++ b/src/HYDROData/HYDROData_QuadtreeNode.cxx @@ -49,12 +49,12 @@ HYDROData_QuadtreeNode::HYDROData_QuadtreeNode(Nodes_3D* theNodes, const double minBoxSize) : HYDROData_Quadtree(new Limit(maxLevel, minBoxSize, maxNbNodes)), myNodes(theNodes), myPrecision(0.25) { - DEBTRACE("---------------------------- HYDROData_QuadtreeNode root constructor"); + //DEBTRACE("---------------------------- HYDROData_QuadtreeNode root constructor"); if (myNodes) { - DEBTRACE(" --- start compute"); + //DEBTRACE(" --- start compute"); compute(); - DEBTRACE(" --- end compute"); + //DEBTRACE(" --- end compute"); } } @@ -88,11 +88,11 @@ void HYDROData_QuadtreeNode::setNodesAndCompute(Nodes_3D* theNodes) myNodes = theNodes; if (myNodes) { - DEBTRACE(" --- start compute"); + //DEBTRACE(" --- start compute"); compute(); - DEBTRACE(" --- end compute : children & height " << this->nbChildren() << " " << this->getHeight()); - DEBTRACE("Bounding box min: " << this->myBox->CornerMin().X() << " " << this->myBox->CornerMin().Y()); - DEBTRACE("Bounding box max: " << this->myBox->CornerMax().X() << " " << this->myBox->CornerMax().Y()); + //DEBTRACE(" --- end compute : children & height " << this->nbChildren() << " " << this->getHeight()); + //DEBTRACE("Bounding box min: " << this->myBox->CornerMin().X() << " " << this->myBox->CornerMin().Y()); + //DEBTRACE("Bounding box max: " << this->myBox->CornerMax().X() << " " << this->myBox->CornerMax().Y()); } } diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index d4a04ef4..022cc306 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -185,6 +185,8 @@ void HYDROData_Stream::Update() Handle_HYDROData_DTM dtm = DTM(); dtm->Update(); UpdatePrs( dtm ); + + HYDROData_NaturalObject::Update(); } bool HYDROData_Stream::IsHas2dPrs() const @@ -337,6 +339,7 @@ double HYDROData_Stream::GetDDZ() const void HYDROData_Stream::SetDDZ( double theDDZ ) { DTM()->SetDDZ( theDDZ ); + Changed( Geom_3d ); } double HYDROData_Stream::GetSpatialStep() const @@ -347,6 +350,7 @@ double HYDROData_Stream::GetSpatialStep() const void HYDROData_Stream::SetSpatialStep( double theSpatialStep ) { DTM()->SetSpatialStep( theSpatialStep ); + Changed( Geom_3d ); } bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis ) @@ -1087,6 +1091,6 @@ void HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt) thePrs.myPrs3D = newCmp; - HYDROData_DTM::Get2dFaceFrom3dPres( newCmp, TopoDS::Face(thePrs.myPrs2D) ); + HYDROData_DTM::Get2dFaceFrom3dPres( newCmp, TopoDS::Face(thePrs.myPrs2D) ); //__TODO } \ No newline at end of file diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index 7d133924..091b31d5 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -56,7 +56,7 @@ void HYDROData_Tool::WriteStringsToFile( QFile& theFile, return; QTextStream anOutStream( &theFile ); - anOutStream << aWriteStr << theSep << theSep; + anOutStream << aWriteStr.toUtf8() << theSep << theSep; } QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& theDoc, diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 024b5487..734964c9 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -154,7 +154,10 @@ void HYDROGUI_CalculationOp::startOperation() aPanel->setBoundary( aPolylineName ); } - aSeq = myEditedObject->GetGeometryObjects(); + aSeq = myEditedObject->GetGeometryObjects(); + HYDROData_SequenceOfObjects anInterPolyList = myEditedObject->GetInterPolyObjects(); + aSeq.Append(anInterPolyList); + getNamesAndEntries( aSeq, aList, anEntryList ); aPanel->includeGeomObjects( aList ); diff --git a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx index 93467ea1..77978ee5 100644 --- a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx @@ -65,7 +65,7 @@ void HYDROGUI_ExportCalculationOp::commitOperation() bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags, QString& theErrorMsg, - QStringList& theBrowseObjectsEntries ) + QStringList& theBrowseObjectsEntries) { // Get the selected calculation case Handle(HYDROData_CalculationCase) aCalculation = @@ -84,12 +84,13 @@ bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags, dynamic_cast( module()->getApp()->activeStudy() ); // Export + myStatMess.clear(); QString anErrorMsg; if ( aStudy ) { SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() ); GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen(); QString anEntry; - if ( aCalculation->Export( aGeomEngine, aDSStudy, anEntry, theErrorMsg ) ) { + if ( aCalculation->Export( aGeomEngine, aDSStudy, anEntry, theErrorMsg, myStatMess ) ) { theUpdateFlags = UF_ObjBrowser; isOk = true; } @@ -132,7 +133,7 @@ void HYDROGUI_ExportCalculationOp::onApply() // Show message box SUIT_MessageBox::information( module()->getApp()->desktop(), tr( "EXPORT_STATUS" ), - tr( "EXPORT_FINISHED") ); + tr( "EXPORT_FINISHED") + "\n" + getStatMess() ); } else { abort(); @@ -147,3 +148,8 @@ void HYDROGUI_ExportCalculationOp::onApply() anErrorMsg ); } } + +QString HYDROGUI_ExportCalculationOp::getStatMess() +{ + return myStatMess; +} diff --git a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h index f7c0d0b3..e73883ce 100644 --- a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h @@ -38,6 +38,10 @@ protected: virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ); virtual void onApply(); + + QString getStatMess(); + + QString myStatMess; }; #endif \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ImagePrs.cxx b/src/HYDROGUI/HYDROGUI_ImagePrs.cxx index d9c0076a..b85450eb 100644 --- a/src/HYDROGUI/HYDROGUI_ImagePrs.cxx +++ b/src/HYDROGUI/HYDROGUI_ImagePrs.cxx @@ -113,6 +113,9 @@ void HYDROGUI_ImagePrs::Compute( const Handle(PrsMgr_PresentationManager3d)&, aPrs->Clear(); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs ); + if( myImage.IsNull() ) + return; + if ( aMode == 0 ) { Handle(Graphic3d_ArrayOfPolylines) aSegments = new Graphic3d_ArrayOfPolylines( 5 ); diff --git a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx index e130caa1..238acf07 100644 --- a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx @@ -117,7 +117,7 @@ void HYDROGUI_ImportPolylineOp::onApply() { commitDocOperation(); commit(); - module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init ); + module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init | UF_OCCViewer ); } else abort(); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index cd5a630b..38090fe5 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -1821,7 +1821,7 @@ void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis ); - update( UF_OCCViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) ); + update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) ); } Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const diff --git a/src/HYDROGUI/HYDROGUI_Polyline.cxx b/src/HYDROGUI/HYDROGUI_Polyline.cxx index 532c6071..ccd259aa 100644 --- a/src/HYDROGUI/HYDROGUI_Polyline.cxx +++ b/src/HYDROGUI/HYDROGUI_Polyline.cxx @@ -87,10 +87,20 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d( aColor, aType, anWidth ); TopExp_Explorer Exp1 ( myshape, TopAbs_EDGE ); + Bnd_Box BB; + BRepBndLib::AddClose(myshape, BB); + double xmin, xmax, ymin, ymax, zmin, zmax; + double devCoeff = 0.1; + if (!BB.IsVoid()) + { + BB.Get(xmin, ymin, zmin, xmax, ymax, zmax); //ignore Z coord + double minSide = Min(Abs(xmax - xmin), Abs(ymax - ymin)); + devCoeff = minSide > 50 ? 0.1 : minSide / 500; + } for ( ; Exp1.More(); Exp1.Next() ) { TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() ); - Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, 0.1 ); + Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, devCoeff ); if( !anArray.IsNull() ) { aGroup->SetPrimitivesAspect( anAspect ); @@ -154,7 +164,8 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre gp_Pnt aPnt1 = C->Value (aMaxRatioStep); gp_Vec aDir; - if (!UseD1) { + if (!UseD1) + { GCPnts_AbscissaPoint aAbsPoint(aAdC, -aArrLen, aMaxRatioStep); double aParam = aAbsPoint.Parameter(); gp_Pnt aPnt2 = C->Value (aParam); @@ -162,7 +173,8 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre D.Subtract (aPnt2.XYZ()); aDir = D; } - else + + if (UseD1 || aDir.IsEqual (gp_Vec(0,0,0), Precision::Confusion(), Precision::Angular())) C->D1(aMaxRatioStep, aPnt1, aDir); if ( anEdge.Orientation() == TopAbs_REVERSED ) diff --git a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx index 0575b946..e8e7941b 100644 --- a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx +++ b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx @@ -48,7 +48,7 @@ void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivate Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( getObject() ); - if ( !aBath.IsNull() ) + if ( !aBath.IsNull() && !aBath->GetAltitudePoints().empty()) { buildShape(); updateShape( false, false ); @@ -104,6 +104,8 @@ void HYDROGUI_ShapeBathymetry::GetRange( double& theMin, double& theMax ) const void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(Aspect_ColorScale)& theColorScale ) { + if (!myCoords) + return; for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ ) { double z = myCoords->Value( i ).Z(); diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx index 9a4419ab..a07c5fe7 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx @@ -36,6 +36,7 @@ #include #include #include +#include HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) @@ -100,9 +101,18 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin aParamGroup->setLayout( aParamLayout ); + // Warnings + QGroupBox* aWarnGroup = new QGroupBox( tr( "STREAM_WARNINGS" ), mainFrame() ); + myWarnText = new QTextEdit(); + myWarnText->setReadOnly(true); + QBoxLayout* aWarnLayout = new QVBoxLayout(); + aWarnLayout->addWidget( myWarnText ); + aWarnGroup->setLayout( aWarnLayout ); + // Common addWidget( myObjectNameGroup ); addWidget( aParamGroup ); + addWidget( aWarnGroup ); addStretch(); // Create selector @@ -262,3 +272,13 @@ void HYDROGUI_StreamDlg::clearAllBackgroundColorsForProfileList () myProfiles->clearAllBackgroundColors(); } +void HYDROGUI_StreamDlg::addWarning( const QString& theWarnMess ) +{ + myWarnText->append( theWarnMess ); +} + +void HYDROGUI_StreamDlg::clearWarnings() +{ + myWarnText->clear(); +} + diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.h b/src/HYDROGUI/HYDROGUI_StreamDlg.h index 2e4e4626..3d49be1b 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.h +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.h @@ -29,6 +29,7 @@ class QLineEdit; class QListWidget; class QPushButton; class QDoubleSpinBox; +class QTextEdit; class HYDROGUI_StreamDlg : public HYDROGUI_InputPanel { @@ -56,6 +57,9 @@ public: void setSpatialStep( const double ); double getSpatialStep() const; + void addWarning( const QString& theWarnMess ); + void clearWarnings(); + void setBackgroundColorForProfileList (int theInd, QColor theColor); QColor getBackgroundColorForProfileList (int theInd) const; void clearAllBackgroundColorsForProfileList (); @@ -82,6 +86,8 @@ private: HYDROGUI_OrderedListWidget* myProfiles; QPushButton* myRemoveButton; QPushButton* myAddButton; + QTextEdit* myWarnText; + }; #endif diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 72702a6a..2a178d83 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -38,6 +38,8 @@ #include #include #include +#include + #include #include @@ -117,32 +119,33 @@ void HYDROGUI_StreamOp::startOperation() // Hydraulic axis Handle(HYDROData_PolylineXY) aHydraulicAxis = myEditedObject->GetHydraulicAxis(); + + TopoDS_Face aPlane; + HYDROData_Stream::BuildRefFace( aPlane ) ; if ( !aHydraulicAxis.IsNull() ) - { myHydAxis = aHydraulicAxis->GetName(); - TopoDS_Face aPlane; - HYDROData_Stream::BuildRefFace( aPlane ) ; - - // Stream profiles - HYDROData_SequenceOfObjects aStreamProfiles = myEditedObject->GetProfiles(); - for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i ) - { - Handle(HYDROData_Profile) aProfile = - Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) ); - if ( aProfile.IsNull() ) - continue; + // Stream profiles + HYDROData_SequenceOfObjects aStreamProfiles = myEditedObject->GetProfiles(); + for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i ) + { + Handle(HYDROData_Profile) aProfile = + Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) ); + if ( aProfile.IsNull() ) + continue; - QString aProfileName = aProfile->GetName(); + QString aProfileName = aProfile->GetName(); + myProfiles << aProfileName; + if (!aHydraulicAxis.IsNull()) + { Standard_Real aProfilePar = 0.0; HYDROData_Stream::HasIntersection( aHydraulicAxis, aProfile, aPlane, aProfilePar ); - - myProfiles << aProfileName; myProfileParams << aProfilePar; - } - } + + } + } } @@ -193,6 +196,58 @@ HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const return aPanel; } +void HYDROGUI_StreamOp::apply() +{ + QApplication::setOverrideCursor( Qt::WaitCursor ); + + startDocOperation(); + + int anUpdateFlags = 0; + QString anErrorMsg; + + bool aResult = false; + QStringList aBrowseObjectsEntries; + + try + { + aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries ); + } + catch ( Standard_Failure ) + { + Handle(Standard_Failure) aFailure = Standard_Failure::Caught(); + anErrorMsg = aFailure->GetMessageString(); + aResult = false; + } + catch ( ... ) + { + aResult = false; + } + + QApplication::restoreOverrideCursor(); + + if ( aResult ) + { + module()->update( anUpdateFlags ); + commitDocOperation(); + commit(); + browseObjects( aBrowseObjectsEntries ); + } + else + { + myEditedObject->Remove(); + module()->setObjectRemoved( myEditedObject ); + + if ( isToAbortOnApply() ) + abortDocOperation(); + + abort(); + SUIT_MessageBox::critical( module()->getApp()->desktop(), + tr( "CREATE_STREAM_ERROR" ), + anErrorMsg ); + + } +} + bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) @@ -356,10 +411,18 @@ void HYDROGUI_StreamOp::createPreview() double ss = aPanel->getSpatialStep(); std::set InvInd; - + +#ifdef _DEBUG + const int MAX_POINTS_IN_PREVIEW = 50000; +#else + const int MAX_POINTS_IN_PREVIEW = 500000; +#endif + HYDROData_Bathymetry::AltitudePoints points; + + bool WireIntersections = false; HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, - OutInlet, OutOutlet, true, true, InvInd); + OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, WireIntersections ); aPanel->clearAllBackgroundColorsForProfileList(); for (std::set::const_iterator it = InvInd.begin(); it != InvInd.end(); it++) @@ -369,9 +432,13 @@ void HYDROGUI_StreamOp::createPreview() aPrsDef.myOutlet = TopoDS::Wire(OutOutlet); aPrsDef.myLeftBank = TopoDS::Wire(OutLeftB); aPrsDef.myRightBank = TopoDS::Wire(OutRightB); - aPrsDef.myPrs2D = Out2dPres; + if (!WireIntersections) + aPrsDef.myPrs2D = Out2dPres; aPrsDef.myPrs3D = Out3dPres; + if (WireIntersections) + aPanel->addWarning(tr("STREAM_SELF_INTERSECTIONS")); + myPreviewPrs->setShape( aPrsDef.myPrs2D ); } diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.h b/src/HYDROGUI/HYDROGUI_StreamOp.h index cb45e50d..5e3a9160 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.h +++ b/src/HYDROGUI/HYDROGUI_StreamOp.h @@ -47,6 +47,8 @@ protected: virtual bool isToAbortOnApply() const { return false; } + virtual void apply(); + private slots: void onAddProfiles(); void onRemoveProfiles( const QStringList& ); diff --git a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx index 08f6ef08..6833acec 100644 --- a/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx +++ b/src/HYDROGUI/HYDROGUI_VTKPrsBathymetry.cxx @@ -87,7 +87,7 @@ void HYDROGUI_VTKPrsBathymetry::compute() double aZ; int anInvalidZ = InvalidZValue(); - for (int i = 1; i <= aNbPoints; i++ ) + for (int i = 0; i < aNbPoints; i++ ) { anAltPnt = anAltPoints[i]; aZ = anAltPnt.Z; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 94f9b019..e19e9fad 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -250,6 +250,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) STREAM_PROFILES Profiles + + STREAM_WARNINGS + Stream Warnings + + + STREAM_SELF_INTERSECTIONS + Warning: intersection(s) of banks/profiles are found + PREF_TAB_GENERAL General @@ -2694,6 +2702,10 @@ file cannot be correctly imported for an Obstacle definition. HYDROGUI_StreamOp + CREATE_STREAM_ERROR + Stream creation error + + CREATE_STREAM Create stream diff --git a/src/HYDROPy/HYDROData_LandCoverMap.sip b/src/HYDROPy/HYDROData_LandCoverMap.sip index a502140d..b20417de 100644 --- a/src/HYDROPy/HYDROData_LandCoverMap.sip +++ b/src/HYDROPy/HYDROData_LandCoverMap.sip @@ -75,8 +75,9 @@ public: if ( !aRef.IsNull() ) { Py_BEGIN_ALLOW_THREADS - sipRes = sipSelfWasArg ? sipCpp->HYDROData_LandCoverMap::ExportTelemac( *a0, a1, aRef ): - sipCpp->ExportTelemac( *a0, a1, aRef ); + QString messStat; + sipRes = sipSelfWasArg ? sipCpp->HYDROData_LandCoverMap::ExportTelemac( *a0, a1, aRef, messStat ): + sipCpp->ExportTelemac( *a0, a1, aRef, messStat ); Py_END_ALLOW_THREADS } %End diff --git a/src/HYDRO_tests/TestShape.cxx b/src/HYDRO_tests/TestShape.cxx index 3cf4ea20..70ce0866 100644 --- a/src/HYDRO_tests/TestShape.cxx +++ b/src/HYDRO_tests/TestShape.cxx @@ -27,7 +27,7 @@ #include #include -TopoDS_Edge Edge( const QList& theXYList, bool isClosed ) +TopoDS_Edge Edge2d( const QList& theXYList, bool isClosed ) { int n = theXYList.size()/2; Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n ); @@ -50,14 +50,48 @@ TopoDS_Edge Edge( const QList& theXYList, bool isClosed ) return TopoDS_Edge(); } -TopoDS_Wire Wire( const QList& theXYList, bool isClosed ) +TopoDS_Wire Wire2d( const QList& theXYList, bool isClosed ) { - return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire(); + return BRepBuilderAPI_MakeWire( Edge2d( theXYList, isClosed ) ).Wire(); } -TopoDS_Face Face( const QList& theXYList ) +TopoDS_Edge Edge3d( const QList& theXYZList, bool isClosed ) { - return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face(); + int n = theXYZList.size()/3; + Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n ); + for( int i=1; i<=n; i++ ) + { + double x = theXYZList[3*i-3]; + double y = theXYZList[3*i-2]; + double z = theXYZList[3*i-1]; + gp_Pnt aPnt( x, y, z ); + aPointsArray->SetValue( i, aPnt ); + } + GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 ); + anInterpolator.Perform(); + bool aResult = anInterpolator.IsDone() == Standard_True; + if( aResult ) + { + Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve(); + return BRepBuilderAPI_MakeEdge( aCurve ).Edge(); + } + else + return TopoDS_Edge(); +} + +TopoDS_Wire Wire3d( const QList& theXYZList, bool isClosed ) +{ + return BRepBuilderAPI_MakeWire( Edge3d( theXYZList, isClosed ) ).Wire(); +} + +TopoDS_Face Face2d( const QList& theXYList ) +{ + return BRepBuilderAPI_MakeFace( Wire2d( theXYList, true ), Standard_True ).Face(); +} + +TopoDS_Face Face3d( const QList& theXYZList ) +{ + return BRepBuilderAPI_MakeFace( Wire3d( theXYZList, true ), Standard_True ).Face(); } TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius ) diff --git a/src/HYDRO_tests/TestShape.h b/src/HYDRO_tests/TestShape.h index b1e12378..470d3049 100644 --- a/src/HYDRO_tests/TestShape.h +++ b/src/HYDRO_tests/TestShape.h @@ -25,8 +25,14 @@ class TopoDS_Wire; class TopoDS_Face; class gp_Pnt; -TopoDS_Edge Edge( const QList& theXYList, bool isClosed = false ); -TopoDS_Wire Wire( const QList& theXYList, bool isClosed = false ); +TopoDS_Edge Edge2d( const QList& theXYList, bool isClosed = false ); +TopoDS_Wire Wire2d( const QList& theXYList, bool isClosed = false ); + +TopoDS_Edge Edge3d( const QList& theXYZList, bool isClosed = false ); +TopoDS_Wire Wire3d( const QList& theXYZList, bool isClosed = false ); + + TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius ); -TopoDS_Face Face( const QList& theXYList ); +TopoDS_Face Face2d( const QList& theXYList ); +TopoDS_Face Face3d( const QList& theXYZList ); diff --git a/src/HYDRO_tests/reference_data/Channel.png b/src/HYDRO_tests/reference_data/Channel.png index de597b40..028435ec 100644 Binary files a/src/HYDRO_tests/reference_data/Channel.png and b/src/HYDRO_tests/reference_data/Channel.png differ diff --git a/src/HYDRO_tests/reference_data/DTM_2.png b/src/HYDRO_tests/reference_data/DTM_2.png index 02660014..612a4be5 100644 Binary files a/src/HYDRO_tests/reference_data/DTM_2.png and b/src/HYDRO_tests/reference_data/DTM_2.png differ diff --git a/src/HYDRO_tests/reference_data/Extraction_Channel.png b/src/HYDRO_tests/reference_data/Extraction_Channel.png index 09ce9a9e..9ef6188a 100644 Binary files a/src/HYDRO_tests/reference_data/Extraction_Channel.png and b/src/HYDRO_tests/reference_data/Extraction_Channel.png differ diff --git a/src/HYDRO_tests/reference_data/st_dump.py b/src/HYDRO_tests/reference_data/st_dump.py index 9051a8ef..bedd58fa 100644 --- a/src/HYDRO_tests/reference_data/st_dump.py +++ b/src/HYDRO_tests/reference_data/st_dump.py @@ -1,4 +1,4 @@ -from HYDROPy import * +from HYDROPy import * from PyQt4.QtCore import * from PyQt4.QtGui import * diff --git a/src/HYDRO_tests/reference_data/stream_dtm_2d.png b/src/HYDRO_tests/reference_data/stream_dtm_2d.png index 2da077fd..83044a05 100644 Binary files a/src/HYDRO_tests/reference_data/stream_dtm_2d.png and b/src/HYDRO_tests/reference_data/stream_dtm_2d.png differ diff --git a/src/HYDRO_tests/reference_data/stream_dtm_3d.png b/src/HYDRO_tests/reference_data/stream_dtm_3d.png index b4aafc80..caa7ef13 100644 Binary files a/src/HYDRO_tests/reference_data/stream_dtm_3d.png and b/src/HYDRO_tests/reference_data/stream_dtm_3d.png differ diff --git a/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx b/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx index 202d1a71..1c0fc6ed 100644 --- a/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx +++ b/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx @@ -136,7 +136,7 @@ void test_HYDROData_Bathymetry::testFileImport() aTestPoint = gp_XY( 0.5, 0.5 ); anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.7127, anAltitude, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.591602, anAltitude, EPS ); aTestPoint = gp_XY( 1.5, 1 ); anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 ); @@ -144,15 +144,15 @@ void test_HYDROData_Bathymetry::testFileImport() aTestPoint = gp_XY( 1.5, 0.7 ); anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.4116, anAltitude, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.591602, anAltitude, EPS ); aTestPoint = gp_XY( 1.5, -0.7 ); anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.0479, anAltitude, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.271267, anAltitude, EPS ); aTestPoint = gp_XY( 2, 3.5 ); anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.2525, anAltitude, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.9454, anAltitude, EPS ); aDoc->Close(); } diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index 153f3c44..3a84e0bc 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -338,7 +338,7 @@ void test_HYDROData_DTM::test_profile_discretization_polyline() aProfile->SetLeftPoint( gp_XY( 10, 10 ) ); aProfile->SetRightPoint( gp_XY( 20, 20 ) ); - HYDROData_DTM::CurveUZ aMid( 0.0 ), aWid( 0.0 ); + HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0 ), aWid( 0.0, gp_Vec2d(), 0 ); int dummy = 0; HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy ); CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() ); @@ -376,7 +376,7 @@ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); aProfile->SetLeftPoint( gp_XY( 10, 10 ) ); aProfile->SetRightPoint( gp_XY( 20, 20 ) ); - HYDROData_DTM::CurveUZ aMid( 0.0 ), aWid( 0.0 ); + HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0 ), aWid( 0.0, gp_Vec2d(), 0 ); int dummy = 0 ; HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy ); CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() ); @@ -431,7 +431,7 @@ void operator << ( std::ostream& s, const HYDROData_DTM::CurveUZ& c ) void test_HYDROData_DTM::test_curves_interpolation() { - HYDROData_DTM::CurveUZ A(1.0), B(2.0); + HYDROData_DTM::CurveUZ A(1.0, gp_Vec2d(), 0), B(2.0, gp_Vec2d(), 0); A.push_back( HYDROData_DTM::PointUZ( 0, 0 ) ); A.push_back( HYDROData_DTM::PointUZ( 1, 1 ) ); A.push_back( HYDROData_DTM::PointUZ( 2, 2 ) ); @@ -498,13 +498,13 @@ void test_HYDROData_DTM::test_curve_to_3d() Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances ); HYDROData_DTM::AltitudePoints points; - HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10) ); + HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10), 0 ); mid.push_back( HYDROData_DTM::PointUZ( 0, 5 ) ); mid.push_back( HYDROData_DTM::PointUZ( 1, 6 ) ); - HYDROData_DTM::CurveUZ wid( 5.0, gp_Vec2d(-10,10) ); + HYDROData_DTM::CurveUZ wid( 5.0, gp_Vec2d(-10,10), 0 ); wid.push_back( HYDROData_DTM::PointUZ( 2, 5 ) ); wid.push_back( HYDROData_DTM::PointUZ( 6, 6 ) ); - HYDROData_DTM::CurveTo3D( HA, mid, wid, points, 0.0 ); + HYDROData_DTM::CurveTo3D( HA, mid, wid, points ); CPPUNIT_ASSERT_EQUAL( 4, (int)points.size() ); CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 16.380, -2.186, 6.0 ), points[0] ); @@ -600,7 +600,7 @@ void test_HYDROData_DTM::test_garonne() CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS ); DTM->Update(); - CPPUNIT_ASSERT_EQUAL( 275690, (int)DTM->GetAltitudePoints().size() ); + CPPUNIT_ASSERT_EQUAL( 282338, (int)DTM->GetAltitudePoints().size() ); Handle_AIS_InteractiveContext aContext = TestViewer::context(); HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM ); diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index 07474877..96d67057 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -61,11 +61,11 @@ void test_HYDROData_LandCoverMap::test_add_2_objects() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC1 = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC1 = Face2d( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); //DEBTRACE("--- ajout test1 " << aLC1); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); - TopoDS_Face aLC2 = Face( QList() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 ); + TopoDS_Face aLC2 = Face2d( QList() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 ); //DEBTRACE("--- ajout test2 " << aLC2); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) ); @@ -107,12 +107,12 @@ void test_HYDROData_LandCoverMap::test_split() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC = Face2d( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) ); Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - TopoDS_Wire aWire = Wire( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false ); + TopoDS_Wire aWire = Wire2d( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false ); aPolyline->SetShape( aWire ); CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) ); @@ -142,12 +142,12 @@ void test_HYDROData_LandCoverMap::test_incomplete_split() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC = Face2d( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) ); Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - TopoDS_Wire aWire = Wire( QList() << 10 << 40 << 30 << 10 << 40 << 10, false ); + TopoDS_Wire aWire = Wire2d( QList() << 10 << 40 << 30 << 10 << 40 << 10, false ); aPolyline->SetShape( aWire ); CPPUNIT_ASSERT_EQUAL( false, aMap->Split( aPolyline ) ); @@ -174,17 +174,17 @@ void test_HYDROData_LandCoverMap::test_merge() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face2d( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); - TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + TopoDS_Face aLC2 = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) ); - TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + TopoDS_Face aLC3 = Face2d( QList() << 4 << 54 << 1 << 47 << 51 << 45 << 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) ); @@ -279,17 +279,17 @@ void test_HYDROData_LandCoverMap::test_remove() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face2d( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); - TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + TopoDS_Face aLC2 = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) ); - TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + TopoDS_Face aLC3 = Face2d( QList() << 4 << 54 << 1 << 47 << 51 << 45 << 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) ); @@ -552,11 +552,11 @@ void test_HYDROData_LandCoverMap::test_import_dbf() // aST.size() == aDBFV.size()!! Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - TopoDS_Wire aWire = Wire( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ); + TopoDS_Wire aWire = Wire2d( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ); aPolyline->SetShape( aWire ); for (int i = 0; i < 3; i++) aMap->Add(aPolyline, ""); - TopoDS_Face aLC1 = Face( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + TopoDS_Face aLC1 = Face2d( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) ); @@ -581,16 +581,16 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types() Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); - TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face2d( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Zones de champs cultivé à végétation basse")) ); - TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + TopoDS_Face aLC2 = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, QString::fromUtf8("Zones de champs cultivé à végétation haute")) ); - TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + TopoDS_Face aLC3 = Face2d( QList() << 4 << 54 << 1 << 47 << 51 << 45 << 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, QString::fromUtf8("Zones de champs, prairies, sans cultures")) ); @@ -617,16 +617,16 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff() Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); - TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face2d( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Zones de champs cultivé à végétation basse")) ); - TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + TopoDS_Face aLC2 = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, QString::fromUtf8("Zones de champs cultivé à végétation haute")) ); - TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + TopoDS_Face aLC3 = Face2d( QList() << 4 << 54 << 1 << 47 << 51 << 45 << 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, QString::fromUtf8("Zones de champs, prairies, sans cultures")) ); @@ -656,17 +656,17 @@ void test_HYDROData_LandCoverMap::test_dump_python() CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); - TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face2d( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) ); - TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + TopoDS_Face aLC2 = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) ); - TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + TopoDS_Face aLC3 = Face2d( QList() << 4 << 54 << 1 << 47 << 51 << 45 << 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) ); @@ -706,8 +706,8 @@ void test_HYDROData_LandCoverMap::test_transparent_prs() Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); - aMap->LocalPartition( Face( QList() << 1 << 1 << 10 << 10 << 10 << 20 ), QString::fromUtf8("Zones de champs cultivé à végétation haute")); - aMap->LocalPartition( Face( QList() << 5 << 5 << 10 << 5 << 10 << 8 << 5 << 12 << 5 << 8 ), QString::fromUtf8("Zones de champs cultivé à végétation haute")); + aMap->LocalPartition( Face2d( QList() << 1 << 1 << 10 << 10 << 10 << 20 ), QString::fromUtf8("Zones de champs cultivé à végétation haute")); + aMap->LocalPartition( Face2d( QList() << 5 << 5 << 10 << 5 << 10 << 8 << 5 << 12 << 5 << 8 ), QString::fromUtf8("Zones de champs cultivé à végétation haute")); aMap->SetName( "test_LCM" ); TestViewer::show( aZone->GetTopShape(), AIS_Shaded, true, "LandCoverMap_TransparentPrs" ); @@ -1085,22 +1085,23 @@ void test_HYDROData_LandCoverMap::test_export_telemac() Handle(HYDROData_LandCoverMap) aMap = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); - TopoDS_Face aLC1 = Face( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); + TopoDS_Face aLC1 = Face2d( QList() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Forêt et végétation arbustive en mutation")) ); - TopoDS_Face aLC2 = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + TopoDS_Face aLC2 = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, QString::fromUtf8("Forêts de conifères")) ); - TopoDS_Face aLC3 = Face( QList() << 4 << 54 << 1 << 47 << 51 << 45 << + TopoDS_Face aLC3 = Face2d( QList() << 4 << 54 << 1 << 47 << 51 << 45 << 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, QString::fromUtf8("Forêts de feuillus")) ); QString aTmpFileName = "test.telemac"; QString aTmpPath = QDir::tempPath() + "/" + aTmpFileName; - CPPUNIT_ASSERT_EQUAL( true, aMap->ExportTelemac( aTmpPath, 1E-4, aTable ) ); + QString messStat; + CPPUNIT_ASSERT_EQUAL( true, aMap->ExportTelemac( aTmpPath, 1E-4, aTable, messStat ) ); CPPUNIT_ASSERT_SCRIPTS_EQUAL( aTmpFileName, true, true, 0 ); aDoc->Close(); @@ -1114,10 +1115,10 @@ void test_HYDROData_LandCoverMap::test_copy() Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); aMap->SetName( "map_1" ); - TopoDS_Face aLC1 = Face( QList() << 10 << 10 << 30 << 10 << 20 << 20 ); + TopoDS_Face aLC1 = Face2d( QList() << 10 << 10 << 30 << 10 << 20 << 20 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, QString::fromUtf8("Forêts de conifères")) ); - TopoDS_Face aLC2 = Face( QList() << 110 << 10 << 130 << 10 << 120 << 20 ); + TopoDS_Face aLC2 = Face2d( QList() << 110 << 10 << 130 << 10 << 120 << 20 ); CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, QString::fromUtf8("Forêts de feuillus")) ); Handle(HYDROData_LandCoverMap) aMap2 = diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index 1ec755ff..57d6435f 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -102,7 +102,7 @@ void test_HYDROData_PolylineXY::test_split_refs_624() aPolyline->SetName( "test" ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, true ); + TopoDS_Wire aWire = Wire2d( aCoords, true ); aPolyline->SetShape( aWire ); gp_Pnt2d aPnt( 20, 20 ); @@ -135,7 +135,7 @@ void test_HYDROData_PolylineXY::test_extraction_immersible_zone() aPolyline->SetName( "test" ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, true ); + TopoDS_Wire aWire = Wire2d( aCoords, true ); aPolyline->SetShape( aWire ); Handle(HYDROData_ImmersibleZone) aZone = @@ -175,7 +175,7 @@ void test_HYDROData_PolylineXY::test_extraction_channel_refs_611() aPolyline3d->SetPolylineXY( aPolyline2d ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, false ); + TopoDS_Wire aWire = Wire2d( aCoords, false ); aPolyline2d->SetShape( aWire ); aPolyline3d->SetTopShape( aWire ); aPolyline3d->SetShape3D( aWire ); @@ -184,8 +184,8 @@ void test_HYDROData_PolylineXY::test_extraction_channel_refs_611() Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); aProfile->SetName( "profile_1" ); - QList aCoordsPr = QList() << 0.0 << 0.1 << 0.5 << 0.0 << 1.0 << 0.1; - TopoDS_Wire aWirePr = Wire( aCoordsPr, false ); + QList aCoordsPr = QList() << 0.0 << 0.1 << 0.0 << 0.0 << 1.0 << 0.0; + TopoDS_Wire aWirePr = Wire3d( aCoordsPr, false ); aProfile->SetTopShape( aWirePr ); aProfile->SetShape3D( aWirePr ); @@ -273,7 +273,7 @@ void test_HYDROData_PolylineXY::test_split_refs_627() aPolyline->SetName( "test" ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, false ); + TopoDS_Wire aWire = Wire2d( aCoords, false ); aPolyline->SetShape( aWire ); aPolyline->SetWireColor( Qt::red ); @@ -338,7 +338,7 @@ void test_HYDROData_PolylineXY::test_custom_polylines() CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() ); CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() ); - aPolyline2->SetShape( Wire( QList() << 0 << 0 << 10 << 10 << 20 << 0 ) ); + aPolyline2->SetShape( Wire2d( QList() << 0 << 0 << 10 << 10 << 20 << 0 ) ); CPPUNIT_ASSERT_EQUAL( true, aPolyline2->IsCustom() ); HYDROData_PolylineXY::PointsList aPointsList = aPolyline2->GetPoints( 0 ); diff --git a/src/HYDRO_tests/test_HYDROData_Stream.cxx b/src/HYDRO_tests/test_HYDROData_Stream.cxx index 3341e77a..6bf3c37d 100644 --- a/src/HYDRO_tests/test_HYDROData_Stream.cxx +++ b/src/HYDRO_tests/test_HYDROData_Stream.cxx @@ -73,6 +73,8 @@ void test_HYDROData_Stream::test_alt_object() Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) ); CPPUNIT_ASSERT_EQUAL( false, (bool)aStream.IsNull() ); + CPPUNIT_ASSERT_EQUAL( true, (bool)aStream->GetAltitudeObject().IsNull() ); + CPPUNIT_ASSERT_EQUAL( false, (bool)aStream->DTM().IsNull() ); CPPUNIT_ASSERT_EQUAL( false, (bool)aStream->GetAltitudeObject().IsNull() ); CPPUNIT_ASSERT_EQUAL( KIND_DTM, aStream->getAltitudeObjectType() ); @@ -90,7 +92,7 @@ void test_HYDROData_Stream::test_params_sync() Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) ); Handle(HYDROData_DTM) aDTM = - Handle(HYDROData_DTM)::DownCast( aStream->GetAltitudeObject() ); + Handle(HYDROData_DTM)::DownCast( aStream->DTM() ); CPPUNIT_ASSERT_EQUAL( false, (bool)aDTM.IsNull() ); Handle(HYDROData_Profile) aProfile1 = diff --git a/src/HYDRO_tests/test_HYDROGUI_Shape.cxx b/src/HYDRO_tests/test_HYDROGUI_Shape.cxx index e99db415..2d696144 100644 --- a/src/HYDRO_tests/test_HYDROGUI_Shape.cxx +++ b/src/HYDRO_tests/test_HYDROGUI_Shape.cxx @@ -26,7 +26,7 @@ void test_HYDROGUI_Shape::test_face_in_preview() { - TopoDS_Face aFace = Face( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << + TopoDS_Face aFace = Face2d( QList() << 21 << 34 << 24 << 25 << 37 << 37 << 40 << 61 << 44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 << 128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 << 31 << 114 );