#include <QPixmap>
#include <QApplication>
#include <QTest>
+#include <QSet>
+#include <QString>
const double EPS = 1E-3;
myD = d;
int n = pp->VertexNumber();
-
+
for( int i=1; i<=n; i++ )
{
gp_Pnt pnt = pp->Vertice( i );
void test_HYDROData_DTM::test_creation()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
- Handle(HYDROData_DTM) DTM =
+ Handle(HYDROData_DTM) DTM =
Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
CPPUNIT_ASSERT_EQUAL( false, (bool)DTM.IsNull() );
-
+
aDoc->Close();
}
void test_HYDROData_DTM::test_hydraulic_axis()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
- Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile) aProfile1 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
- Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile) aProfile2 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
- Handle(HYDROData_Profile) aProfile3 =
+ Handle(HYDROData_Profile) aProfile3 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
aProfile1->SetParametricPoints( points );
void test_HYDROData_DTM::test_profile_conversion_to_2d()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
- Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile) aProfile1 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
- Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile) aProfile2 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
aProfile1->SetParametricPoints( points );
void test_HYDROData_DTM::test_profile_properties()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
- Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile) aProfile =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
aProfile->SetParametricPoints( points );
void test_HYDROData_DTM::test_profile_discretization_polyline()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
- Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile) aProfile =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
aProfile->SetParametricPoints( points );
HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
int dummy = 0;
- HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy );
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].U, EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );
void test_HYDROData_DTM::test_profile_discretization_spline()
{
-Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
- Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile) aProfile =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
aProfile->SetParametricPoints( points );
HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
int dummy = 0 ;
- HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy );
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.242, aMid[0].U, EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );
void test_HYDROData_DTM::test_curve_to_3d()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
- Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile) aProfile1 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
- Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile) aProfile2 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
aProfile1->SetParametricPoints( points );
void test_HYDROData_DTM::test_presentation()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
- Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile) aProfile1 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
- Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile) aProfile2 =
Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
aProfile1->SetParametricPoints( points );
DTM->SetSpatialStep( 1.0 );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
DTM->Update();
-
- CPPUNIT_ASSERT_EQUAL( 9108, (int)DTM->GetAltitudePoints().size() );
+
+ CPPUNIT_ASSERT_EQUAL( 9108, (int)DTM->GetAltitudePoints().size() );
Handle(AIS_InteractiveContext) aContext = TestViewer::context();
HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
void test_HYDROData_DTM::test_garonne()
{
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
+
TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
fname += "/Profiles.xyz";
NCollection_Sequence<int> bad_ids;
int aSize = HYDROData_Profile::ImportFromFile( aDoc, fname, bad_ids, true );
-
+
CPPUNIT_ASSERT_EQUAL( 0, bad_ids.Size() );
CPPUNIT_ASSERT_EQUAL( 46, aSize );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
DTM->Update();
-
- CPPUNIT_ASSERT_EQUAL( 281898, (int)DTM->GetAltitudePoints().size() );
-
+
+ CPPUNIT_ASSERT_EQUAL( 281898, (int)DTM->GetAltitudePoints().size() );
+
Handle(AIS_InteractiveContext) aContext = TestViewer::context();
HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
aBathPrs->update( true, false );
aBathPrs->RescaleDefault();
-
+
bool ColorScaleIsDisp = TestViewer::ColorScaleIsDisplayed();
TestViewer::showColorScale( true );
aCS->SetMax( 25.0 );
aCS->SetNumberOfIntervals( 30 );
aBathPrs->UpdateWithColorScale( aCS );
-
+
QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
CPPUNIT_ASSERT_IMAGES3( &aDTMPrs, "DTM_2", false );
TestViewer::showColorScale( ColorScaleIsDisp );
{
TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
fname += "/pb_1066.cbf";
- CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString(), 1 ) );
+ CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString() ) );
- Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-
- Handle(HYDROData_CalculationCase) aCase =
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
+
+ Handle(HYDROData_CalculationCase) aCase =
Handle(HYDROData_CalculationCase)::DownCast( aDoc->FindObjectByName( "Case_1" ) );
- CPPUNIT_ASSERT_EQUAL( false, aCase.IsNull() );
+ CPPUNIT_ASSERT_EQUAL( false, aCase.IsNull() );
std::vector<gp_XY> points;
points.push_back( gp_XY( 43.4842, 3.33176 ) );
points.push_back( gp_XY( -125.777, 2.24728 ) );
aDoc->Close();
}
+void test_HYDROData_DTM::test_profile_discretization_warnings()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
+
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ NCollection_Sequence<gp_XY> pnts;
+ pnts.Append( gp_XY( 0.0, 1.0 ) );
+ pnts.Append( gp_XY( 1.0, 0.0 ) );
+ pnts.Append( gp_XY( 2.0, 4.0 ) );
+ pnts.Append( gp_XY( 3.0, 5.0 ) );
+
+ aProfile->SetParametricPoints( pnts );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+ int dummy = 0;
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+ //CPPUNIT_ASSERT_EQUAL(1, warnings.size());
+ CPPUNIT_ASSERT( warnings.contains("One of the extreme points is higher than another"));
+ }
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ NCollection_Sequence<gp_XY> pnts;
+ pnts.Append( gp_XY( 0.0, 1.0 ) );
+ pnts.Append( gp_XY( 1.0, 0.0 ) );
+ pnts.Append( gp_XY( 2.0, 5.0 ) );
+ pnts.Append( gp_XY( 3.0, 0.0 ) );
+ pnts.Append( gp_XY( 4.0, 1.0 ) );
+
+ aProfile->SetParametricPoints( pnts );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+ int dummy = 0;
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+ CPPUNIT_ASSERT_EQUAL(1, warnings.size());
+ CPPUNIT_ASSERT( warnings.contains("More than 2 intersections between profile & altitude Z-lines found"));
+ }
+ {
+ //plato case
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ NCollection_Sequence<gp_XY> pnts;
+ pnts.Append( gp_XY( 0.0, 5.0 ) );
+ pnts.Append( gp_XY( 1.0, 5.0 ) );
+ pnts.Append( gp_XY( 2.0, 0.5 ) );
+ pnts.Append( gp_XY( 3.0, 5.0 ) );
+ pnts.Append( gp_XY( 4.0, 5.0 ) );
+
+ aProfile->SetParametricPoints( pnts );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+ int dummy = 0;
+ QSet<QString> warnings;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+ CPPUNIT_ASSERT_EQUAL(2, warnings.size());
+ CPPUNIT_ASSERT( warnings.contains("Plato case on extremes"));
+ }
+
+ aDoc->Close();
+}