From: isn Date: Fri, 19 Apr 2019 18:46:50 +0000 (+0300) Subject: tests for lism/sx/complete_case X-Git-Tag: SH_V2_2_0~99^2~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5be45427adca25a8cd6a27ead91657b5fee5d954;p=modules%2Fhydro.git tests for lism/sx/complete_case --- diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index 4e2a6be6..37887cfb 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -293,11 +293,14 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* } // zones iterator DEBTRACE("--- IntSh->Length():" << IntSh->Length()); - for (int i = 1; i <= IntSh->Length(); i++) + if (IntSh) { - const TopoDS_Shape& CS = (*IntSh)(i); - if (AllE.Contains(CS)) - IE.Add(CS); + for (int i = 1; i <= IntSh->Length(); i++) + { + const TopoDS_Shape& CS = (*IntSh)(i); + if (AllE.Contains(CS)) + IE.Add(CS); + } } if ( aRegionFacesList.IsEmpty() ) diff --git a/src/HYDRO_tests/ExternalFiles.cmake b/src/HYDRO_tests/ExternalFiles.cmake index 23fae5e5..86c5ab5d 100644 --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@ -10,6 +10,7 @@ set( EXTERNAL_FILES ../HYDROData/HYDROData_Bathymetry.cxx ../HYDROData/HYDROData_BSplineOperation.cxx ../HYDROData/HYDROData_CalculationCase.cxx + ../HYDROData/HYDROData_CompleteCalcCase.cxx ../HYDROData/HYDROData_Channel.cxx ../HYDROData/HYDROData_ChannelAltitude.cxx ../HYDROData/HYDROData_Confluence.cxx diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index cb701d8b..ec70488b 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -154,6 +154,15 @@ SET(REFERENCE_DATA Polyline_import_XY.png Polyline_import_XYZ.png Polyline_import_XYZ_3D.png + Polylines_import_SX.png + polylines_sx.sx + ax_lb_rb.sx + lism_prs.png + study_cc_1.cbf + study_cc_2.cbf + cc_complete_1.png + cc_complete_2.png + study_lism_1.cbf ) # Application tests diff --git a/src/HYDRO_tests/reference_data/linux/Polylines_import_SX.png b/src/HYDRO_tests/reference_data/linux/Polylines_import_SX.png new file mode 100644 index 00000000..c5102b1c Binary files /dev/null and b/src/HYDRO_tests/reference_data/linux/Polylines_import_SX.png differ diff --git a/src/HYDRO_tests/reference_data/linux/ax_lb_rb.sx b/src/HYDRO_tests/reference_data/linux/ax_lb_rb.sx new file mode 100644 index 00000000..dd4f1b38 --- /dev/null +++ b/src/HYDRO_tests/reference_data/linux/ax_lb_rb.sx @@ -0,0 +1,61 @@ +C Generated by HYDRO Module +C +B N +CN AX +CP 0 1 +CP 0.0 +CP 0 + 109.284 30.638 0.000 + 146.037 3.297 0.000 + 195.490 -15.378 0.000 + 222.382 -18.815 0.000 + 238.817 -19.412 0.000 + 316.181 -25.549 0.000 + 396.329 -48.180 0.000 + 545.312 -114.185 0.000 + 666.006 -179.246 0.000 + 767.842 -240.537 0.000 + 854.591 -302.770 0.000 + 942.578 -373.048 0.000 + 1008.583 -435.281 0.000 +B N +CN LB +CP 0 1 +CP 0.0 +CP 0 + 116.158 29.239 0.000 + 139.119 18.100 0.000 + 166.853 5.597 0.000 + 195.042 -4.179 0.000 + 225.732 -2.815 0.000 + 246.419 -4.179 0.000 + 281.883 -5.088 0.000 + 317.574 -6.679 0.000 + 403.624 -27.482 0.000 + 515.090 -66.135 0.000 + 638.242 -122.767 0.000 + 723.639 -175.803 0.000 + 791.957 -221.648 0.000 + 853.982 -280.977 0.000 + 902.524 -324.125 0.000 + 951.964 -363.677 0.000 + 974.437 -391.544 0.000 + 998.708 -414.017 0.000 +B N +CN RB +CP 0 1 +CP 0.0 +CP 0 + 107.881 19.262 0.000 + 151.029 -12.200 0.000 + 212.155 -31.078 0.000 + 273.281 -52.652 0.000 + 372.162 -90.406 0.000 + 479.134 -151.533 0.000 + 606.780 -203.670 0.000 + 693.076 -252.211 0.000 + 775.776 -307.944 0.000 + 830.610 -332.215 0.000 + 905.220 -367.273 0.000 + 955.560 -400.533 0.000 + 990.618 -426.601 0.000 diff --git a/src/HYDRO_tests/reference_data/linux/cc_complete_1.png b/src/HYDRO_tests/reference_data/linux/cc_complete_1.png new file mode 100644 index 00000000..98060659 Binary files /dev/null and b/src/HYDRO_tests/reference_data/linux/cc_complete_1.png differ diff --git a/src/HYDRO_tests/reference_data/linux/cc_complete_2.png b/src/HYDRO_tests/reference_data/linux/cc_complete_2.png new file mode 100644 index 00000000..4ab52e9b Binary files /dev/null and b/src/HYDRO_tests/reference_data/linux/cc_complete_2.png differ diff --git a/src/HYDRO_tests/reference_data/linux/lism_prs.png b/src/HYDRO_tests/reference_data/linux/lism_prs.png new file mode 100644 index 00000000..4eddcd9e Binary files /dev/null and b/src/HYDRO_tests/reference_data/linux/lism_prs.png differ diff --git a/src/HYDRO_tests/reference_data/linux/polylines_sx.sx b/src/HYDRO_tests/reference_data/linux/polylines_sx.sx new file mode 100644 index 00000000..68d0bbcc --- /dev/null +++ b/src/HYDRO_tests/reference_data/linux/polylines_sx.sx @@ -0,0 +1,38 @@ +C Generated by HYDRO Module +C +B N +CN AXIS +CP 0 1 +CP 0.0 +CP 0 + -205.732 -218.471 0.000 + -93.631 -172.611 0.000 + 37.580 -75.796 0.000 + 150.955 40.127 0.000 + 212.102 152.229 0.000 + 324.204 241.401 0.000 + 404.459 306.369 0.000 +B N +CN LB +CP 0 1 +CP 0.0 +CP 0 + -273.248 -126.752 0.000 + -83.439 -47.771 0.000 + 32.484 40.127 0.000 + 126.752 126.752 0.000 + 190.446 213.376 0.000 + 243.949 289.809 0.000 + 357.325 349.682 0.000 + 410.828 387.898 0.000 +B N +CN RB +CP 0 1 +CP 0.0 +CP 0 + -226.115 -325.478 0.000 + 156.051 -178.981 0.000 + 306.369 -42.675 0.000 + 364.968 74.522 0.000 + 503.822 161.146 0.000 + 568.790 243.949 0.000 diff --git a/src/HYDRO_tests/reference_data/linux/study_cc_1.cbf b/src/HYDRO_tests/reference_data/linux/study_cc_1.cbf new file mode 100644 index 00000000..dc4ca63a Binary files /dev/null and b/src/HYDRO_tests/reference_data/linux/study_cc_1.cbf differ diff --git a/src/HYDRO_tests/reference_data/linux/study_cc_2.cbf b/src/HYDRO_tests/reference_data/linux/study_cc_2.cbf new file mode 100644 index 00000000..e4914fb1 Binary files /dev/null and b/src/HYDRO_tests/reference_data/linux/study_cc_2.cbf differ diff --git a/src/HYDRO_tests/reference_data/linux/study_lism_1.cbf b/src/HYDRO_tests/reference_data/linux/study_lism_1.cbf new file mode 100644 index 00000000..e69efea5 Binary files /dev/null and b/src/HYDRO_tests/reference_data/linux/study_lism_1.cbf differ diff --git a/src/HYDRO_tests/reference_data/win32/Polylines_import_SX.png b/src/HYDRO_tests/reference_data/win32/Polylines_import_SX.png new file mode 100644 index 00000000..e996fbbf Binary files /dev/null and b/src/HYDRO_tests/reference_data/win32/Polylines_import_SX.png differ diff --git a/src/HYDRO_tests/reference_data/win32/ax_lb_rb.sx b/src/HYDRO_tests/reference_data/win32/ax_lb_rb.sx new file mode 100644 index 00000000..dd4f1b38 --- /dev/null +++ b/src/HYDRO_tests/reference_data/win32/ax_lb_rb.sx @@ -0,0 +1,61 @@ +C Generated by HYDRO Module +C +B N +CN AX +CP 0 1 +CP 0.0 +CP 0 + 109.284 30.638 0.000 + 146.037 3.297 0.000 + 195.490 -15.378 0.000 + 222.382 -18.815 0.000 + 238.817 -19.412 0.000 + 316.181 -25.549 0.000 + 396.329 -48.180 0.000 + 545.312 -114.185 0.000 + 666.006 -179.246 0.000 + 767.842 -240.537 0.000 + 854.591 -302.770 0.000 + 942.578 -373.048 0.000 + 1008.583 -435.281 0.000 +B N +CN LB +CP 0 1 +CP 0.0 +CP 0 + 116.158 29.239 0.000 + 139.119 18.100 0.000 + 166.853 5.597 0.000 + 195.042 -4.179 0.000 + 225.732 -2.815 0.000 + 246.419 -4.179 0.000 + 281.883 -5.088 0.000 + 317.574 -6.679 0.000 + 403.624 -27.482 0.000 + 515.090 -66.135 0.000 + 638.242 -122.767 0.000 + 723.639 -175.803 0.000 + 791.957 -221.648 0.000 + 853.982 -280.977 0.000 + 902.524 -324.125 0.000 + 951.964 -363.677 0.000 + 974.437 -391.544 0.000 + 998.708 -414.017 0.000 +B N +CN RB +CP 0 1 +CP 0.0 +CP 0 + 107.881 19.262 0.000 + 151.029 -12.200 0.000 + 212.155 -31.078 0.000 + 273.281 -52.652 0.000 + 372.162 -90.406 0.000 + 479.134 -151.533 0.000 + 606.780 -203.670 0.000 + 693.076 -252.211 0.000 + 775.776 -307.944 0.000 + 830.610 -332.215 0.000 + 905.220 -367.273 0.000 + 955.560 -400.533 0.000 + 990.618 -426.601 0.000 diff --git a/src/HYDRO_tests/reference_data/win32/cc_complete_1.png b/src/HYDRO_tests/reference_data/win32/cc_complete_1.png new file mode 100644 index 00000000..f79dfac5 Binary files /dev/null and b/src/HYDRO_tests/reference_data/win32/cc_complete_1.png differ diff --git a/src/HYDRO_tests/reference_data/win32/cc_complete_2.png b/src/HYDRO_tests/reference_data/win32/cc_complete_2.png new file mode 100644 index 00000000..378538de Binary files /dev/null and b/src/HYDRO_tests/reference_data/win32/cc_complete_2.png differ diff --git a/src/HYDRO_tests/reference_data/win32/lism_prs.png b/src/HYDRO_tests/reference_data/win32/lism_prs.png new file mode 100644 index 00000000..23de6046 Binary files /dev/null and b/src/HYDRO_tests/reference_data/win32/lism_prs.png differ diff --git a/src/HYDRO_tests/reference_data/win32/polylines_sx.sx b/src/HYDRO_tests/reference_data/win32/polylines_sx.sx new file mode 100644 index 00000000..68d0bbcc --- /dev/null +++ b/src/HYDRO_tests/reference_data/win32/polylines_sx.sx @@ -0,0 +1,38 @@ +C Generated by HYDRO Module +C +B N +CN AXIS +CP 0 1 +CP 0.0 +CP 0 + -205.732 -218.471 0.000 + -93.631 -172.611 0.000 + 37.580 -75.796 0.000 + 150.955 40.127 0.000 + 212.102 152.229 0.000 + 324.204 241.401 0.000 + 404.459 306.369 0.000 +B N +CN LB +CP 0 1 +CP 0.0 +CP 0 + -273.248 -126.752 0.000 + -83.439 -47.771 0.000 + 32.484 40.127 0.000 + 126.752 126.752 0.000 + 190.446 213.376 0.000 + 243.949 289.809 0.000 + 357.325 349.682 0.000 + 410.828 387.898 0.000 +B N +CN RB +CP 0 1 +CP 0.0 +CP 0 + -226.115 -325.478 0.000 + 156.051 -178.981 0.000 + 306.369 -42.675 0.000 + 364.968 74.522 0.000 + 503.822 161.146 0.000 + 568.790 243.949 0.000 diff --git a/src/HYDRO_tests/reference_data/win32/study_cc_1.cbf b/src/HYDRO_tests/reference_data/win32/study_cc_1.cbf new file mode 100644 index 00000000..dc4ca63a Binary files /dev/null and b/src/HYDRO_tests/reference_data/win32/study_cc_1.cbf differ diff --git a/src/HYDRO_tests/reference_data/win32/study_cc_2.cbf b/src/HYDRO_tests/reference_data/win32/study_cc_2.cbf new file mode 100644 index 00000000..e4914fb1 Binary files /dev/null and b/src/HYDRO_tests/reference_data/win32/study_cc_2.cbf differ diff --git a/src/HYDRO_tests/reference_data/win32/study_lism_1.cbf b/src/HYDRO_tests/reference_data/win32/study_lism_1.cbf new file mode 100644 index 00000000..e69efea5 Binary files /dev/null and b/src/HYDRO_tests/reference_data/win32/study_lism_1.cbf differ diff --git a/src/HYDRO_tests/test_HYDROData_CalcCase.cxx b/src/HYDRO_tests/test_HYDROData_CalcCase.cxx index 1ea686c7..4fd6a868 100644 --- a/src/HYDRO_tests/test_HYDROData_CalcCase.cxx +++ b/src/HYDRO_tests/test_HYDROData_CalcCase.cxx @@ -32,9 +32,38 @@ #include #include #include +#include +#include +#include +#include +#include +#include extern QString REF_DATA_PATH; +static TopoDS_Shape GetCalcCaseShape(Handle(HYDROData_CalculationCase) theCalcCase) +{ + BRep_Builder B; + TopoDS_Compound cmp; + B.MakeCompound(cmp); + HYDROData_SequenceOfObjects aRegions = theCalcCase->GetRegions(); + for ( int i = 1; i <= aRegions.Size(); i++ ) + { + Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast( aRegions(i) ); + if ( !aRegion.IsNull() ) + { + HYDROData_SequenceOfObjects aZones = aRegion->GetZones(); + for ( int j = 1; j <= aZones.Size(); j++ ) + { + Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZones(j) ); + TopoDS_Shape aSh = aZone->GetShape(); + B.Add(cmp, aSh); + } + } + } + return cmp; +} + void test_HYDROData_CalcCase::test_add_int_wires() { { @@ -102,4 +131,197 @@ void test_HYDROData_CalcCase::test_add_int_wires() } +void test_HYDROData_CalcCase::test_complete_1() +{ + TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); + fname += "/study_cc_1.cbf"; + CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString(), 1 ) ); + + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_CalculationCase) aCase = + Handle(HYDROData_CalculationCase)::DownCast( aDoc->FindObjectByName( "Case_1" ) ); + CPPUNIT_ASSERT_EQUAL( false, aCase.IsNull() ); + { + //before complet eeop + TopoDS_Shape cmp = GetCalcCaseShape(aCase); + TopTools_IndexedMapOfShape M; + TopExp::MapShapes(cmp, M); + CPPUNIT_ASSERT_EQUAL(29, M.Extent()); + GProp_GProps G; + BRepGProp::SurfaceProperties(cmp, G); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 179876.15713670343, G.Mass(), 0.001 ); + } + + NCollection_Sequence theNewObjects; + Handle(HYDROData_Entity) aNewZone = aDoc->FindObjectByName( "Immersible zone_4" ); + Handle(HYDROData_Entity) aNewPoly = aDoc->FindObjectByName( "Polyline_5__BB" ); + theNewObjects.Append(aNewZone); + theNewObjects.Append(aNewPoly); + + + bool is_int = false; + NCollection_Sequence theNewRegions; + QSet newRegionEntries; + HYDROData_CompleteCalcCase::AddObjects(aDoc, aCase, theNewObjects, true, is_int, theNewRegions); + + /// check the result + CPPUNIT_ASSERT_EQUAL(false, is_int); + + HYDROData_SequenceOfObjects aRegions = aCase->GetRegions(); + CPPUNIT_ASSERT_EQUAL(4, aRegions.Size()); + + CPPUNIT_ASSERT_EQUAL(QString("OREG1"), aRegions(1)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("OREGMIN"), aRegions(2)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("OREG2"), aRegions(3)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("Immersible zone_4_reg"), aRegions(4)->GetName()); + + HYDROData_SequenceOfObjects aZonesReg1 = Handle(HYDROData_Region)::DownCast( aRegions(1) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(3, aZonesReg1.Size()); + + HYDROData_SequenceOfObjects aZonesReg2 = Handle(HYDROData_Region)::DownCast( aRegions(2) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(1, aZonesReg2.Size()); + + HYDROData_SequenceOfObjects aZonesReg3 = Handle(HYDROData_Region)::DownCast( aRegions(3) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(3, aZonesReg3.Size()); + + HYDROData_SequenceOfObjects aZonesReg4 = Handle(HYDROData_Region)::DownCast( aRegions(4) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(5, aZonesReg4.Size()); + + { + //REG 1; "OREG1" + std::set aZonesReg1Names; + for ( int j = 1; j <= 3; j++ ) + { + Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZonesReg1(j) ); + aZonesReg1Names.insert( aZone->GetName().toStdString()); + } + + std::set aZonesReg1NamesExpect; + aZonesReg1NamesExpect.insert("Case_1_Zone_2"); + aZonesReg1NamesExpect.insert("Case_1_Zone_1_1"); + aZonesReg1NamesExpect.insert("Case_1_Zone_1_2"); + CPPUNIT_ASSERT(aZonesReg1NamesExpect == aZonesReg1Names); + } + { + TopoDS_Shape cmp = GetCalcCaseShape(aCase); + TopTools_IndexedMapOfShape M; + TopExp::MapShapes(cmp, M); + CPPUNIT_ASSERT_EQUAL(72, M.Extent()); + GProp_GProps G; + BRepGProp::SurfaceProperties(cmp, G); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 196013.5, G.Mass(), 0.1 ); + TestViewer::show( cmp, AIS_Shaded, true, "cc_complete_1" ); + CPPUNIT_ASSERT_IMAGES + } + + aDoc->Close(); +} + +void test_HYDROData_CalcCase::test_complete_2() +{ + TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); + fname += "/study_cc_2.cbf"; + CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString(), 1 ) ); + + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_CalculationCase) aCase = + Handle(HYDROData_CalculationCase)::DownCast( aDoc->FindObjectByName( "Case_1" ) ); + + NCollection_Sequence theNewObjects; + Handle(HYDROData_Entity) aNewZone1 = aDoc->FindObjectByName( "Immersible zone_4" ); + Handle(HYDROData_Entity) aNewZone2 = aDoc->FindObjectByName( "Immersible zone_5" ); + Handle(HYDROData_Entity) aNewZone3 = aDoc->FindObjectByName( "Immersible zone_6" ); + Handle(HYDROData_Entity) aNewPoly1 = aDoc->FindObjectByName( "Polyline___BB" ); + Handle(HYDROData_Entity) aNewPoly2 = aDoc->FindObjectByName( "Polyline_1" ); + Handle(HYDROData_Entity) aNewPoly3 = aDoc->FindObjectByName( "Polyline_2" ); + Handle(HYDROData_Entity) aNewPoly4 = aDoc->FindObjectByName( "Polyline_3" ); + Handle(HYDROData_Entity) aNewPoly5 = aDoc->FindObjectByName( "Polyline_4" ); + Handle(HYDROData_Entity) aNewPoly6 = aDoc->FindObjectByName( "Polyline_5" ); + Handle(HYDROData_Entity) aNewPoly7 = aDoc->FindObjectByName( "Polyline_6" ); + Handle(HYDROData_Entity) aNewPoly8 = aDoc->FindObjectByName( "Polyline_7" ); + Handle(HYDROData_Entity) aNewPoly9 = aDoc->FindObjectByName( "Polyline_8" ); + + theNewObjects.Append(aNewZone1); + theNewObjects.Append(aNewZone2); + theNewObjects.Append(aNewZone3); + theNewObjects.Append(aNewPoly1); + theNewObjects.Append(aNewPoly2); + theNewObjects.Append(aNewPoly3); + theNewObjects.Append(aNewPoly4); + theNewObjects.Append(aNewPoly5); + theNewObjects.Append(aNewPoly6); + theNewObjects.Append(aNewPoly7); + theNewObjects.Append(aNewPoly8); + theNewObjects.Append(aNewPoly9); + + bool is_int = false; + NCollection_Sequence theNewRegions; + QSet newRegionEntries; + HYDROData_CompleteCalcCase::AddObjects(aDoc, aCase, theNewObjects, true, is_int, theNewRegions); + + /// check the result + CPPUNIT_ASSERT_EQUAL(true, is_int); + + HYDROData_SequenceOfObjects aRegions = aCase->GetRegions(); + CPPUNIT_ASSERT_EQUAL(6, aRegions.Size()); + + CPPUNIT_ASSERT_EQUAL(QString("OREG1"), aRegions(1)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("OREGMIN"), aRegions(2)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("OREG2"), aRegions(3)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("Immersible zone_4_reg"), aRegions(4)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("Immersible zone_5_reg"), aRegions(5)->GetName()); + CPPUNIT_ASSERT_EQUAL(QString("Immersible zone_6_reg"), aRegions(6)->GetName()); + + HYDROData_SequenceOfObjects aZonesReg1 = Handle(HYDROData_Region)::DownCast( aRegions(1) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(3, aZonesReg1.Size()); + HYDROData_SequenceOfObjects aZonesReg2 = Handle(HYDROData_Region)::DownCast( aRegions(2) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(2, aZonesReg2.Size()); + HYDROData_SequenceOfObjects aZonesReg3 = Handle(HYDROData_Region)::DownCast( aRegions(3) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(3, aZonesReg3.Size()); + HYDROData_SequenceOfObjects aZonesReg4 = Handle(HYDROData_Region)::DownCast( aRegions(4) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(11, aZonesReg4.Size()); + HYDROData_SequenceOfObjects aZonesReg5 = Handle(HYDROData_Region)::DownCast( aRegions(5) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(6, aZonesReg5.Size()); + HYDROData_SequenceOfObjects aZonesReg6 = Handle(HYDROData_Region)::DownCast( aRegions(6) )->GetZones(); + CPPUNIT_ASSERT_EQUAL(5, aZonesReg6.Size()); + + { + //REG 4; imm.zone4 + //first priority; shouldn't change the area after complete (surf.mass) + double m=0; + BRep_Builder B; TopoDS_Compound ccc; B.MakeCompound(ccc); + for ( int j = 1; j <= 11; j++ ) + { + Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZonesReg4(j) ); + TopoDS_Shape sh = aZone->GetShape(); + B.Add(ccc, sh); + GProp_GProps G; + BRepGProp::SurfaceProperties(sh, G); + m+=G.Mass(); + } + GProp_GProps G1; + Handle(HYDROData_Object) aNewZone1c = Handle(HYDROData_Object)::DownCast( aNewZone1 ); + BRepGProp::SurfaceProperties(aNewZone1c->GetTopShape(), G1); + + double diff = abs(G1.Mass()-m); //there is still a difference after calling of general fuse on complicated cases + CPPUNIT_ASSERT(diff < 20.0); + CPPUNIT_ASSERT_DOUBLES_EQUAL(23387.2, G1.Mass(), 0.1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(23370.1, m, 0.1); + } + { + TopoDS_Shape cmp = GetCalcCaseShape(aCase); + TopTools_IndexedMapOfShape M; + TopExp::MapShapes(cmp, M); + CPPUNIT_ASSERT_EQUAL(197, M.Extent()); + GProp_GProps G; + BRepGProp::SurfaceProperties(cmp, G); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 225164.3, G.Mass(), 0.1 ); + TestViewer::show( cmp, AIS_Shaded, true, "cc_complete_2" ); + CPPUNIT_ASSERT_IMAGES + } + aDoc->Close(); +} + diff --git a/src/HYDRO_tests/test_HYDROData_CalcCase.h b/src/HYDRO_tests/test_HYDROData_CalcCase.h index c4dbda7f..aeb72bf7 100644 --- a/src/HYDRO_tests/test_HYDROData_CalcCase.h +++ b/src/HYDRO_tests/test_HYDROData_CalcCase.h @@ -27,11 +27,16 @@ class test_HYDROData_CalcCase : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( test_HYDROData_CalcCase ); CPPUNIT_TEST( test_add_int_wires ); + CPPUNIT_TEST( test_complete_1 ); + CPPUNIT_TEST( test_complete_2 ); + CPPUNIT_TEST_SUITE_END(); public: void test_add_int_wires(); + void test_complete_1(); + void test_complete_2(); }; diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index b804b1ab..91409768 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include @@ -571,4 +573,53 @@ void test_HYDROData_PolylineXY::test_import_from_xyz() TestViewer::show( aPolyXY->GetShape(), 0, false, "Polyline_import_XYZ" ); TestViewer::show( aPoly3D->GetShape3D(), 0, false, "Polyline_import_XYZ_3D" ); CPPUNIT_ASSERT_IMAGES -} \ No newline at end of file +} + + +void test_HYDROData_PolylineXY::test_import_from_sx() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); + TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); + fname += "/polylines_sx.sx"; + + HYDROData_SinusX aSinusXImporter; + NCollection_Sequence importedEntities; + //bool stat = aSinusXImporter.Import(QString(fname.ToCString()), aDoc, importedEntities); + bool ParseStat = aSinusXImporter.OpenAndParse(QString(fname.ToCString())); + CPPUNIT_ASSERT (ParseStat); + aSinusXImporter.Import(aDoc, importedEntities, NULL); + CPPUNIT_ASSERT_EQUAL (importedEntities.Size(), 9); + + Handle(HYDROData_PolylineXY) aPolyXY1 = Handle(HYDROData_PolylineXY)::DownCast(importedEntities(1)); + Handle(HYDROData_PolylineXY) aPolyXY2 = Handle(HYDROData_PolylineXY)::DownCast(importedEntities(4)); + Handle(HYDROData_PolylineXY) aPolyXY3 = Handle(HYDROData_PolylineXY)::DownCast(importedEntities(7)); + + CPPUNIT_ASSERT (!aPolyXY1.IsNull()); + CPPUNIT_ASSERT (!aPolyXY2.IsNull()); + CPPUNIT_ASSERT (!aPolyXY3.IsNull()); + + aPolyXY1->Update(); + aPolyXY2->Update(); + aPolyXY3->Update(); + + CPPUNIT_ASSERT_EQUAL (aPolyXY1->GetName(), QString("AXIS")); + CPPUNIT_ASSERT_EQUAL (aPolyXY2->GetName(), QString("LB")); + CPPUNIT_ASSERT_EQUAL (aPolyXY3->GetName(), QString("RB")); + + TopoDS_Shape sh1 = aPolyXY1->GetShape(); + TopoDS_Shape sh2 = aPolyXY2->GetShape(); + TopoDS_Shape sh3 = aPolyXY3->GetShape(); + CPPUNIT_ASSERT (!sh1.IsNull()); + CPPUNIT_ASSERT (!sh2.IsNull()); + CPPUNIT_ASSERT (!sh3.IsNull()); + + BRep_Builder BB; + TopoDS_Compound cmp; + BB.MakeCompound(cmp); + BB.Add(cmp, sh1); + BB.Add(cmp, sh2); + BB.Add(cmp, sh3); + + TestViewer::show( cmp, 0, true, "Polylines_import_SX" ); + CPPUNIT_ASSERT_IMAGES +} diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.h b/src/HYDRO_tests/test_HYDROData_PolylineXY.h index b03ac734..dcb531c7 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.h +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.h @@ -31,6 +31,7 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture { CPPUNIT_TEST( test_merge_refs_630 ); CPPUNIT_TEST( test_split_straight_refs_634 ); CPPUNIT_TEST( test_import_from_xyz ); + CPPUNIT_TEST( test_import_from_sx ); CPPUNIT_TEST_SUITE_END(); @@ -58,6 +59,7 @@ public: void test_merge_refs_630(); void test_split_straight_refs_634(); void test_import_from_xyz(); + void test_import_from_sx(); }; diff --git a/src/HYDRO_tests/test_HYDROData_Stream.cxx b/src/HYDRO_tests/test_HYDROData_Stream.cxx index 7de6815c..6d63658f 100644 --- a/src/HYDRO_tests/test_HYDROData_Stream.cxx +++ b/src/HYDRO_tests/test_HYDROData_Stream.cxx @@ -26,10 +26,15 @@ #include #include #include +#include #include #include #include +#include +#include +#include + extern QString REF_DATA_PATH; NCollection_Sequence points2; const double EPS = 1E-3; @@ -281,3 +286,68 @@ void test_HYDROData_Stream::test_presentation() aDoc->Close(); } + +void test_HYDROData_Stream::test_lism_1() +{ + TCollection_AsciiString ref_path = REF_DATA_PATH.toLatin1().data(); + + TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); + fname += "/study_lism_1.cbf"; + CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString(), 1 ) ); + + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + HYDROData_SequenceOfObjects profiles; + HYDROData_Iterator it( aDoc, KIND_PROFILE ); + for( int i=0; it.More(); it.Next(), i++ ) + { + if( i>=15 && i<=42 ) + profiles.Append( Handle(HYDROData_Profile)::DownCast( it.Current() ) ); + } + CPPUNIT_ASSERT_EQUAL( 28, (int)profiles.Size() ); + /// + + Handle(HYDROData_PolylineXY) aPolyXY_AX = Handle(HYDROData_PolylineXY)::DownCast(aDoc->FindObjectByName("AX")); + Handle(HYDROData_PolylineXY) aPolyXY_LB = Handle(HYDROData_PolylineXY)::DownCast(aDoc->FindObjectByName("LB")); + Handle(HYDROData_PolylineXY) aPolyXY_RB = Handle(HYDROData_PolylineXY)::DownCast(aDoc->FindObjectByName("RB")); + + aPolyXY_AX->Update(); + aPolyXY_LB->Update(); + aPolyXY_RB->Update(); + // + Handle(HYDROData_LISM) aLISM = Handle(HYDROData_LISM)::DownCast( aDoc->CreateObject( KIND_LISM ) ); + aLISM->SetProfiles( profiles ); + aLISM->SetHaxStep(2.0); + aLISM->SetNbProfilePoints( 200 ); + aLISM->SetHydraulicAxis(aPolyXY_AX); + aLISM->SetLeftBank(aPolyXY_LB); + aLISM->SetRightBank(aPolyXY_RB); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0, aLISM->GetHaxStep(), EPS ); + CPPUNIT_ASSERT_EQUAL( 200, aLISM->GetNbProfilePoints() ); + aLISM->Update(); + + CPPUNIT_ASSERT_EQUAL( 99000, (int)aLISM->GetAltitudePoints().size() ); + + Handle(AIS_InteractiveContext) aContext = TestViewer::context(); + HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, aLISM ); + //aBathPrs->Build(); + aBathPrs->update( true, false ); + aBathPrs->RescaleDefault(); + double min, max; + aBathPrs->GetRange( min, max ); + TestViewer::colorScale()->SetRange( min, max ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.98390276785714281, min, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 25.991840625000002, max, EPS ); + + aBathPrs->UpdateWithColorScale( TestViewer::colorScale() ); + + Handle(AIS_InteractiveObject) lism_prs = aBathPrs->getAISObjects()[0]; + CPPUNIT_ASSERT( !lism_prs.IsNull() ); + + TestViewer::show( lism_prs, 0, 0, true, "lism_prs" ); + CPPUNIT_ASSERT_IMAGES + + delete aBathPrs; + aDoc->Close(); +} + diff --git a/src/HYDRO_tests/test_HYDROData_Stream.h b/src/HYDRO_tests/test_HYDROData_Stream.h index 40eb2100..3ebcbc78 100644 --- a/src/HYDRO_tests/test_HYDROData_Stream.h +++ b/src/HYDRO_tests/test_HYDROData_Stream.h @@ -26,6 +26,7 @@ class test_HYDROData_Stream : public CppUnit::TestFixture CPPUNIT_TEST( test_params_sync ); CPPUNIT_TEST( test_dump ); CPPUNIT_TEST( test_presentation ); + CPPUNIT_TEST( test_lism_1 ); CPPUNIT_TEST_SUITE_END(); public: @@ -37,6 +38,7 @@ public: void test_params_sync(); void test_dump(); void test_presentation(); + void test_lism_1(); }; CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_Stream );