#include <QColor>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
+#include <HYDROData_CompleteCalcCase.h>
+#include <QSet>
+#include <HYDROData_Region.h>
+#include <TopExp.hxx>
+#include <GProp_GProps.hxx>
+#include <BRepGProp.hxx>
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()
{
{
}
+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<Handle(HYDROData_Entity)> 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<Handle(HYDROData_Region)> theNewRegions;
+ QSet<QString> 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<std::string> 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<std::string> 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<Handle(HYDROData_Entity)> 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<Handle(HYDROData_Region)> theNewRegions;
+ QSet<QString> 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();
+}
+
#include <HYDROData_Tool.h>
#include <HYDROGUI_Shape.h>
#include <HYDROGUI_Polyline.h>
+#include <HYDROData_SinusX.h>
+#include <BRep_Builder.hxx>
#include <AIS_DisplayMode.hxx>
#include <AIS_PointCloud.hxx>
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<Handle(HYDROData_Entity)> 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
+}
#include <HYDROData_PolylineXY.h>
#include <HYDROData_Iterator.h>
#include <AIS_InteractiveContext.hxx>
+#include <AIS_ColorScale.hxx>
#include <TestViewer.h>
#include <QApplication>
#include <QTest>
+#include <HYDROData_LISM.h>
+#include <HYDROData_SinusX.h>
+#include <HYDROGUI_ShapeBathymetry.h>
+
extern QString REF_DATA_PATH;
NCollection_Sequence<HYDROData_IPolyline::Point> points2;
const double EPS = 1E-3;
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();
+}
+