Salome HOME
debug of DTM object
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_DTM.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include <test_HYDROData_DTM.h>
20 #include <HYDROData_Document.h>
21 #include <HYDROData_Profile.h>
22 #include <HYDROData_DTM.h>
23 #include <Geom2d_Curve.hxx>
24 #include <Geom2d_BSplineCurve.hxx>
25 #include <gp_XY.hxx>
26 #include <gp_Pnt2d.hxx>
27 #include <TColgp_Array1OfPnt2d.hxx>
28 #include <TestViewer.h>
29 #include <AIS_InteractiveContext.hxx>
30 #include <AIS_PointCloud.hxx>
31 #include <HYDROGUI_ShapeBathymetry.h>
32 #include <Aspect_ColorScale.hxx>
33 #include <QTest>
34
35 const double EPS = 1E-3;
36
37 NCollection_Sequence<HYDROData_IPolyline::Point> points;
38
39 void test_HYDROData_DTM::setUp()
40 {
41   points.Clear();
42   points.Append( gp_XY( 0.0, 5.0 ) );
43   points.Append( gp_XY( 1.0, 1.0 ) );
44   points.Append( gp_XY( 1.5, 0.0 ) );
45   points.Append( gp_XY( 4.0, 4.0 ) );
46 }
47
48 void test_HYDROData_DTM::test_creation()
49 {
50   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
51
52   Handle(HYDROData_DTM) DTM = 
53     Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
54
55   CPPUNIT_ASSERT_EQUAL( false, (bool)DTM.IsNull() );
56    
57   aDoc->Close();
58 }
59
60 void test_HYDROData_DTM::test_hydraulic_axis()
61 {
62   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
63
64   Handle(HYDROData_Profile) aProfile1 = 
65     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
66
67   Handle(HYDROData_Profile) aProfile2 = 
68     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
69
70   Handle(HYDROData_Profile) aProfile3 = 
71     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
72
73   aProfile1->SetParametricPoints( points );
74   aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
75   aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
76   aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
77
78   aProfile2->SetParametricPoints( points );
79   aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
80   aProfile2->SetLeftPoint( gp_XY( 50, 0 ) );
81   aProfile2->SetRightPoint( gp_XY( 60, 10 ) );
82
83   aProfile3->SetParametricPoints( points );
84   aProfile3->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
85   aProfile3->SetLeftPoint( gp_XY( 200, 50 ) );
86   aProfile3->SetRightPoint( gp_XY( 210, 40 ) );
87
88   std::vector<double> distances;
89   std::vector<Handle(HYDROData_Profile)> profiles;
90   profiles.push_back( aProfile1 );
91   profiles.push_back( aProfile2 );
92   profiles.push_back( aProfile3 );
93
94   Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances );
95   CPPUNIT_ASSERT_EQUAL( false, (bool)HA.IsNull() );
96   CPPUNIT_ASSERT_EQUAL( 3, (int)distances.size() );
97
98   CPPUNIT_ASSERT_DOUBLES_EQUAL(   0.0,   distances[0], EPS );
99   CPPUNIT_ASSERT_DOUBLES_EQUAL(  43.499, distances[1], EPS );
100   CPPUNIT_ASSERT_DOUBLES_EQUAL( 211.474, distances[2], EPS );
101
102   aDoc->Close();
103 }
104
105 void test_HYDROData_DTM::test_profile_conversion_to_2d()
106 {
107   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
108
109   Handle(HYDROData_Profile) aProfile1 = 
110     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
111
112   Handle(HYDROData_Profile) aProfile2 = 
113     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
114
115   aProfile1->SetParametricPoints( points );
116   aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
117   aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
118   aProfile1->SetRightPoint( gp_XY( 20, 20 ) );
119
120   aProfile2->SetParametricPoints( points );
121   aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
122   aProfile2->SetLeftPoint( gp_XY( 10, 10 ) );
123   aProfile2->SetRightPoint( gp_XY( 20, 20 ) );
124
125   double aUMin1 = std::numeric_limits<double>::max(),
126          aUMax1 = -aUMin1,
127          aUMin2 = aUMin1,
128          aUMax2 = aUMax1;
129   std::vector<Handle_Geom2d_Curve> curves1 = HYDROData_DTM::ProfileToParametric( aProfile1, aUMin1, aUMax1 );
130   std::vector<Handle_Geom2d_Curve> curves2 = HYDROData_DTM::ProfileToParametric( aProfile2, aUMin2, aUMax2 );
131
132   gp_Pnt2d aFirst, aLast;
133   CPPUNIT_ASSERT_EQUAL( 3, (int)curves1.size() );
134   CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aUMin1, EPS );
135   CPPUNIT_ASSERT_DOUBLES_EQUAL(  8.839, aUMax1, EPS );
136   curves1[0]->D0( curves1[0]->FirstParameter(), aFirst );
137   curves1[0]->D0( curves1[0]->LastParameter(), aLast );
138   CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aFirst.X(), EPS );
139   CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   aFirst.Y(), EPS );
140   CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aLast.X(),  EPS );
141   CPPUNIT_ASSERT_DOUBLES_EQUAL(  1.0,   aLast.Y(),  EPS );
142   curves1[1]->D0( curves1[1]->FirstParameter(), aFirst );
143   curves1[1]->D0( curves1[1]->LastParameter(), aLast );
144   CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aFirst.X(), EPS );
145   CPPUNIT_ASSERT_DOUBLES_EQUAL(  1.0,   aFirst.Y(), EPS );
146   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aLast.X(),  EPS );
147   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aLast.Y(),  EPS );
148   curves1[2]->D0( curves1[2]->FirstParameter(), aFirst );
149   curves1[2]->D0( curves1[2]->LastParameter(), aLast );
150   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aFirst.X(), EPS );
151   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aFirst.Y(), EPS );
152   CPPUNIT_ASSERT_DOUBLES_EQUAL(  8.839, aLast.X(),  EPS );
153   CPPUNIT_ASSERT_DOUBLES_EQUAL(  4.0,   aLast.Y(),  EPS );
154
155   CPPUNIT_ASSERT_EQUAL( 1, (int)curves2.size() );
156   CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aUMin2, EPS );
157   CPPUNIT_ASSERT_DOUBLES_EQUAL(  8.839, aUMax2, EPS );
158   Handle(Geom2d_BSplineCurve) aBSpline = Handle(Geom2d_BSplineCurve)::DownCast( curves2[0] );
159   CPPUNIT_ASSERT_EQUAL( false, (bool)aBSpline.IsNull() );
160   const TColgp_Array1OfPnt2d& poles = aBSpline->Poles();
161   CPPUNIT_ASSERT_EQUAL( 1, (int)poles.Lower() );
162   CPPUNIT_ASSERT_EQUAL( 8, (int)poles.Upper() );
163   CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, poles.Value( 1 ).X(), EPS );
164   CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   poles.Value( 1 ).Y(), EPS );
165   CPPUNIT_ASSERT_DOUBLES_EQUAL( -4.125, poles.Value( 2 ).X(), EPS );
166   CPPUNIT_ASSERT_DOUBLES_EQUAL(  3.667, poles.Value( 2 ).Y(), EPS );
167   CPPUNIT_ASSERT_DOUBLES_EQUAL( -3.150, poles.Value( 3 ).X(), EPS );
168   CPPUNIT_ASSERT_DOUBLES_EQUAL(  2.120, poles.Value( 3 ).Y(), EPS );
169   CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.242, poles.Value( 4 ).X(), EPS );
170   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.574, poles.Value( 4 ).Y(), EPS );
171
172   aDoc->Close();
173 }
174
175 void test_HYDROData_DTM::test_profile_properties()
176 {
177   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
178
179   Handle(HYDROData_Profile) aProfile = 
180     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
181
182   aProfile->SetParametricPoints( points );
183   aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
184   aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
185   aProfile->SetRightPoint( gp_XY( 20, 25 ) );
186
187   gp_Pnt lp;
188   gp_Vec2d dd;
189   double zmin, zmax;
190   HYDROData_DTM::GetProperties( aProfile, lp, dd, false, zmin, zmax );
191   CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.75, lp.X(), EPS );
192   CPPUNIT_ASSERT_DOUBLES_EQUAL( 15.625, lp.Y(), EPS );
193   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lp.Z(), EPS );
194   CPPUNIT_ASSERT_DOUBLES_EQUAL( 10, dd.X(), EPS );
195   CPPUNIT_ASSERT_DOUBLES_EQUAL( 15, dd.Y(), EPS );
196   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, zmin, EPS );
197   CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, zmax, EPS );
198
199   HYDROData_DTM::GetProperties( aProfile, lp, dd, true, zmin, zmax );
200   CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.75, lp.X(), EPS );
201   CPPUNIT_ASSERT_DOUBLES_EQUAL( 15.625, lp.Y(), EPS );
202   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lp.Z(), EPS );
203   CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, dd.X(), EPS );
204   CPPUNIT_ASSERT_DOUBLES_EQUAL( 10, dd.Y(), EPS );
205   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, zmin, EPS );
206   CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, zmax, EPS );
207
208   aDoc->Close();
209 }
210
211 void test_HYDROData_DTM::test_profile_discretization_polyline()
212 {
213   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
214
215   Handle(HYDROData_Profile) aProfile = 
216     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
217
218   aProfile->SetParametricPoints( points );
219   aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
220   aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
221   aProfile->SetRightPoint( gp_XY( 20, 20 ) );
222
223   HYDROData_DTM::CurveUZ aMid( 0.0 ), aWid( 0.0 );
224   HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid );
225   CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
226   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aMid[0].U, EPS );
227   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aMid[0].Z, EPS );
228   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.11,  aMid[1].U, EPS );
229   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.5,   aMid[1].Z, EPS );
230   CPPUNIT_ASSERT_DOUBLES_EQUAL(  1.215, aMid[5].U, EPS );
231   CPPUNIT_ASSERT_DOUBLES_EQUAL(  2.5,   aMid[5].Z, EPS );
232   CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.589, aMid[10].U, EPS );
233   CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   aMid[10].Z, EPS );
234
235   CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() );
236   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aWid[0].U, EPS );
237   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aWid[0].Z, EPS );
238   CPPUNIT_ASSERT_DOUBLES_EQUAL(  1.989, aWid[1].U, EPS );
239   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.5,   aWid[1].Z, EPS );
240   CPPUNIT_ASSERT_DOUBLES_EQUAL(  8.618, aWid[5].U, EPS );
241   CPPUNIT_ASSERT_DOUBLES_EQUAL(  2.5,   aWid[5].Z, EPS );
242   CPPUNIT_ASSERT_DOUBLES_EQUAL( 14.142, aWid[10].U, EPS );
243   CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   aWid[10].Z, EPS );
244
245   aDoc->Close();
246 }
247
248 void test_HYDROData_DTM::test_profile_discretization_spline()
249 {
250 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
251
252   Handle(HYDROData_Profile) aProfile = 
253     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
254
255   aProfile->SetParametricPoints( points );
256   aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
257   aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
258   aProfile->SetRightPoint( gp_XY( 20, 20 ) );
259
260   HYDROData_DTM::CurveUZ aMid( 0.0 ), aWid( 0.0 );
261   HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid );
262   CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
263   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.242, aMid[0].U, EPS );
264   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aMid[0].Z, EPS );
265   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.755, aMid[1].U, EPS );
266   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.5,   aMid[1].Z, EPS );
267   CPPUNIT_ASSERT_DOUBLES_EQUAL(  1.473, aMid[5].U, EPS );
268   CPPUNIT_ASSERT_DOUBLES_EQUAL(  2.5,   aMid[5].Z, EPS );
269   CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.589, aMid[10].U, EPS );
270   CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   aMid[10].Z, EPS );
271
272   CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() );
273   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.484, aWid[0].U, EPS );
274   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aWid[0].Z, EPS );
275   CPPUNIT_ASSERT_DOUBLES_EQUAL(  3.809, aWid[1].U, EPS );
276   CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.5,   aWid[1].Z, EPS );
277   CPPUNIT_ASSERT_DOUBLES_EQUAL(  9.472, aWid[5].U, EPS );
278   CPPUNIT_ASSERT_DOUBLES_EQUAL(  2.5,   aWid[5].Z, EPS );
279   CPPUNIT_ASSERT_DOUBLES_EQUAL( 14.142, aWid[10].U, EPS );
280   CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   aWid[10].Z, EPS );
281
282   aDoc->Close();
283 }
284
285 void operator << ( std::ostream& s, const HYDROData_DTM::PointUZ& p )
286 {
287   s << "(" << p.U << "; " << p.Z << ") ";
288 }
289
290 void operator << ( std::ostream& s, const HYDROData_DTM::AltitudePoint& p )
291 {
292   s << "(" << p.X << "; " << p.Y << "; " << p.Z << ") ";
293 }
294
295 bool operator == ( const HYDROData_DTM::PointUZ& p1, const HYDROData_DTM::PointUZ& p2 )
296 {
297   return fabs(p1.U-p2.U)<EPS && fabs(p1.Z-p2.Z)<EPS;
298 }
299
300 bool operator == ( const HYDROData_DTM::AltitudePoint& p1, const HYDROData_DTM::AltitudePoint& p2 )
301 {
302   return fabs(p1.X-p2.X)<EPS && fabs(p1.Y-p2.Y)<EPS && fabs(p1.Z-p2.Z)<EPS;
303 }
304
305 void operator << ( std::ostream& s, const HYDROData_DTM::CurveUZ& c )
306 {
307   size_t n = c.size();
308   for( size_t i=0; i<n; i++ )
309     s << c[i];
310 }
311
312 void test_HYDROData_DTM::test_curves_interpolation()
313 {
314   HYDROData_DTM::CurveUZ A(1.0), B(2.0);
315   A.push_back( HYDROData_DTM::PointUZ( 0, 0 ) );
316   A.push_back( HYDROData_DTM::PointUZ( 1, 1 ) );
317   A.push_back( HYDROData_DTM::PointUZ( 2, 2 ) );
318   B.push_back( HYDROData_DTM::PointUZ( 10, 0 ) );
319   B.push_back( HYDROData_DTM::PointUZ( 15, 1 ) );
320   B.push_back( HYDROData_DTM::PointUZ( 20, 2 ) );
321
322   std::vector<HYDROData_DTM::CurveUZ> i1;
323   HYDROData_DTM::Interpolate( A, B, 1, i1, false );
324
325   CPPUNIT_ASSERT_EQUAL( 2, (int)i1.size() );
326   CPPUNIT_ASSERT_EQUAL( A, i1[0] );
327   CPPUNIT_ASSERT_EQUAL( 3, (int)i1[1].size() );
328   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 5, 0 ), i1[1][0] );
329   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 8, 1 ), i1[1][1] );
330   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 11, 2 ), i1[1][2] );
331
332   std::vector<HYDROData_DTM::CurveUZ> i2;
333   HYDROData_DTM::Interpolate( A, B, 1, i2, true );
334
335   CPPUNIT_ASSERT_EQUAL( 3, (int)i2.size() );
336   CPPUNIT_ASSERT_EQUAL( A, i2[0] );
337   CPPUNIT_ASSERT_EQUAL( 3, (int)i2[1].size() );
338   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 5, 0 ), i2[1][0] );
339   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 8, 1 ), i2[1][1] );
340   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 11, 2 ), i2[1][2] );
341   CPPUNIT_ASSERT_EQUAL( B, i2[2] );
342
343   std::vector<HYDROData_DTM::CurveUZ> i3;
344   HYDROData_DTM::Interpolate( A, B, 3, i3, false );
345
346   CPPUNIT_ASSERT_EQUAL( 4, (int)i3.size() );
347   CPPUNIT_ASSERT_EQUAL( A, i3[0] );
348   CPPUNIT_ASSERT_EQUAL( 3, (int)i3[1].size() );
349   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 2.5, 0 ), i3[1][0] );
350   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 4.5, 1 ), i3[1][1] );
351   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 6.5, 2 ), i3[1][2] );
352 }
353
354 void test_HYDROData_DTM::test_curve_to_3d()
355 {
356   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
357
358   Handle(HYDROData_Profile) aProfile1 = 
359     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
360
361   Handle(HYDROData_Profile) aProfile2 = 
362     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
363
364   aProfile1->SetParametricPoints( points );
365   aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
366   aProfile1->SetLeftPoint( gp_XY( 20, 0 ) );
367   aProfile1->SetRightPoint( gp_XY( 10, 10 ) );
368
369   aProfile2->SetParametricPoints( points );
370   aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
371   aProfile2->SetLeftPoint( gp_XY( 100, 0 ) );
372   aProfile2->SetRightPoint( gp_XY( 110, 0 ) );
373
374   std::vector<double> distances;
375   std::vector<Handle(HYDROData_Profile)> profiles;
376   profiles.push_back( aProfile1 );
377   profiles.push_back( aProfile2 );
378
379   Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances );
380   HYDROData_DTM::AltitudePoints points;
381   HYDROData_DTM::CurveUZ mid( 5.0 );
382   mid.push_back( HYDROData_DTM::PointUZ( 0, 5 ) );
383   mid.push_back( HYDROData_DTM::PointUZ( 1, 6 ) );
384   HYDROData_DTM::CurveUZ wid( 5.0 );
385   wid.push_back( HYDROData_DTM::PointUZ( 2, 5 ) );
386   wid.push_back( HYDROData_DTM::PointUZ( 6, 6 ) );
387   HYDROData_DTM::CurveTo3D( HA, mid, wid, points );
388
389   CPPUNIT_ASSERT_EQUAL( 4, (int)points.size() );
390   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 15.434, -0.598, 5.0 ), points[0] );
391   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 14.497, -0.947, 5.0 ), points[1] );
392   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 15.903, -0.423, 6.0 ), points[2] );
393   CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 13.092, -1.471, 6.0 ), points[3] );
394
395   aDoc->Close();
396 }
397
398 void test_HYDROData_DTM::test_presentation()
399 {
400   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
401
402   Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
403
404   Handle(HYDROData_Profile) aProfile1 = 
405     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
406
407   Handle(HYDROData_Profile) aProfile2 = 
408     Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
409
410   aProfile1->SetParametricPoints( points );
411   aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
412   aProfile1->SetLeftPoint( gp_XY( 20, 0 ) );
413   aProfile1->SetRightPoint( gp_XY( 10, 10 ) );
414
415   aProfile2->SetParametricPoints( points );
416   aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
417   aProfile2->SetLeftPoint( gp_XY( 100, 0 ) );
418   aProfile2->SetRightPoint( gp_XY( 110, 0 ) );
419
420   HYDROData_SequenceOfObjects seq;
421   seq.Append( aProfile1 );
422   seq.Append( aProfile2 );
423   DTM->SetProfiles( seq );
424   DTM->SetDDZ( 0.1 );
425   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
426   DTM->SetSpatialStep( 1.0 );
427   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
428   DTM->Update();
429   
430   CPPUNIT_ASSERT_EQUAL( 10404, (int)DTM->GetAltitudePoints().size() ); 
431
432   Handle_AIS_InteractiveContext aContext = TestViewer::context();
433   HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
434   aBathPrs->update( true, false );
435
436   TestViewer::showColorScale( true );
437   Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
438   aCS->SetMin( 0.0 );
439   aCS->SetMax( 5.0 );
440   aCS->SetNumberOfIntervals( 10 );
441   aBathPrs->UpdateWithColorScale( aCS );
442   
443   TestViewer::show( aBathPrs->getAISObject(), AIS_PointCloud::DM_Points, 0, true, "DTM_1" );
444   CPPUNIT_ASSERT_IMAGES
445   delete aBathPrs;
446
447   aDoc->Close();
448 }
449
450 void test_HYDROData_DTM::test_garonne()
451 {
452   //TODO
453 }