]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_StreamLinearInterpolation.cxx
Salome HOME
#refs 1990
[modules/hydro.git] / src / HYDROData / HYDROData_StreamLinearInterpolation.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROData_StreamLinearInterpolation.h"
24 #include <HYDROData_Profile.h>
25 #include <HYDROData_ProfileUZ.h>
26
27 #include <gp_Lin2d.hxx>
28 #include <BRepAdaptor_Curve.hxx>
29 #include <HYDROData_ShapesTool.h>
30 #include <GCPnts_UniformAbscissa.hxx>
31 #include <Geom2dAPI_InterCurveCurve.hxx>
32 #include <Geom2d_Line.hxx>
33 #include <TopoDS_Shape.hxx>
34 #include <TopoDS.hxx>
35 #include <HYDROData_Tool.h>
36 #include <GCE2d_MakeLine.hxx>
37 #include <TopoDS_Iterator.hxx>
38 #include <TopExp_Explorer.hxx>
39 #include <BRepAlgo.hxx>
40 #include <Geom2dAdaptor_Curve.hxx>
41 #include <assert.h>
42 #include <vector>
43 #include <map>
44 #include <set>
45 #include <BRepBuilderAPI_MakeEdge2d.hxx>
46 #include <BRepBuilderAPI_MakeEdge.hxx>
47 #include <BRep_Tool.hxx>
48 #include <BRepBuilderAPI_MakeWire.hxx>
49 #include <TopoDS_Face.hxx>
50 #include <gp_Pln.hxx>
51 #include <BRepBuilderAPI_MakeFace.hxx>
52 #include <gp.hxx>
53 #include <gp_Ax2.hxx>
54 #include <Geom_Plane.hxx>
55 #include <TopoDS_Wire.hxx>
56 #include <BRepLib.hxx>
57 #include <BRepLib_MakePolygon.hxx>
58 #include <TopoDS_Compound.hxx>
59 #include <BRep_Builder.hxx>
60
61 static std::vector<gp_Pnt2d> GetProfileUZPoints(const Handle(HYDROData_Profile)& theProfile)
62 {
63   Handle(HYDROData_ProfileUZ) aProfileUZ = theProfile->GetProfileUZ( false );
64   HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints();
65   std::vector<gp_Pnt2d> points;
66   points.reserve(aSectPointsList.Size());
67   for ( int i = 1; i <= aSectPointsList.Size(); i++ )
68   {
69     const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList(i);
70     points.push_back( gp_Pnt2d(aSectPoint.X(), aSectPoint.Y()));
71   }
72   return points;
73 }
74
75 static void GetMaxDist(const std::vector<gp_Pnt2d>& PNTS, 
76   double& dmax, 
77   double& dmax2,
78   int& imax)
79 {
80   dmax = 0;
81   dmax2 = 0; 
82   imax = -1;
83   std::vector<double> dist;
84   dist.reserve(PNTS.size()-1);
85   for (int i=0; i<PNTS.size()-1; i++)
86   {
87     //dist.push_back(PNTS[i].Distance(PNTS[i+1])); //via distance between p1/p2 
88     dist.push_back(std::abs(PNTS[i].X()-PNTS[i+1].X())); //via U-diff of p1/p2
89   }
90   for (int i=0; i<dist.size(); i++)
91   {
92     double d = dist[i];
93     if (d > dmax)
94     {
95       dmax = d;
96       imax = i;
97     }
98   }
99   for (int i=0; i<dist.size(); i++)
100   {
101     double d = dist[i];
102     if (d > dmax2 && d < dmax)
103       dmax2 = d;
104   }
105 }
106
107 static void InsertPoints(std::vector<gp_Pnt2d>& points, int nbpoints)
108 {
109   points.reserve(points.size() + nbpoints);
110   while (nbpoints)
111   {
112     double dmax=0, dmax2=0;
113     int imax=-1;
114     GetMaxDist(points, dmax, dmax2, imax);
115     int nbPins = 0;
116     if (dmax2 != 0)
117       nbPins = floor(dmax/dmax2);
118     else
119       nbPins = nbpoints; //one segment, put all points here
120     //insert nbPins points in [imax, imax+1] segment
121     gp_Pnt2d p1 = points[imax];
122     gp_Pnt2d p2 = points[imax+1];
123     double X0 = p1.X();
124     double Y0 = p1.Y();
125     double X1 = p2.X();
126     double Y1 = p2.Y();
127     for (int i=0;i<nbPins;i++)
128     {
129       double t = ((double)i+1)/((double)nbPins+1);
130       double Xp = X0 + (X1-X0)*t;
131       double Yp = Y0 + (Y1-Y0)*t;
132       gp_Pnt2d P(Xp, Yp);
133       points.insert(points.begin() + imax + 1, P);
134     }
135     nbpoints-=nbPins;
136   }
137 }
138
139 static void PolyToCurve2d(const Handle(HYDROData_PolylineXY)& poly, Handle(Geom2d_Curve)& c2d)
140 {
141   if (poly.IsNull())
142     return;
143   TopoDS_Shape sh = poly->GetShape();
144   if (sh.ShapeType() == TopAbs_COMPOUND)
145   {
146     TopoDS_Iterator it(sh);
147     if (it.More())
148       sh = it.Value();
149   }
150     
151   if (sh.IsNull())
152     return;
153
154   TopoDS_Edge ee;
155   if (sh.ShapeType() == TopAbs_EDGE)
156     ee = TopoDS::Edge(sh);
157   else if (sh.ShapeType() == TopAbs_WIRE)
158     ee = BRepAlgo::ConcatenateWireC0(TopoDS::Wire(sh)); //convert to bspline
159  
160   if (ee.IsNull())
161     return;
162
163   BRepAdaptor_Curve Ad(ee);
164
165   c2d = HYDROData_Tool::BRepAdaptorTo2DCurve(Ad);
166 }
167
168 static void InterProfilesAndHAX(const HYDROData_SequenceOfObjects& profiles, 
169   const Handle(Geom2d_Curve)& Hax2d, 
170   std::map<double, Handle(HYDROData_Profile)>& profToInterParam,
171   std::vector<std::string>* warnings)
172 {
173   for (int i=1;i<=profiles.Size();i++)
174   {
175     Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(profiles(i)); 
176     gp_XY LP, RP;
177     aProfile->GetLeftPoint( LP, false, true );
178     aProfile->GetRightPoint( RP, false, true );
179     gp_Pnt2d P1(LP), P2(RP);
180     double d = P2.Distance(P1);
181     if (d < gp::Resolution())
182     {
183       if (warnings)
184         warnings->push_back(aProfile->GetName().toStdString() + " is skipped: Left and Right points is the same");
185       continue;
186     }
187     Handle(Geom2d_Line) lin2d = new Geom2d_Line(P1,gp_Dir2d(P2.XY()-P1.XY()));
188
189     Geom2dAdaptor_Curve linAd(lin2d, 0, d);
190     Geom2dAdaptor_Curve haxAd(Hax2d);
191     Geom2dInt_GInter isec( linAd, haxAd, 1.0e-6, 1.0e-6);
192     if (!isec.IsDone())
193     {
194       if (warnings)
195         warnings->push_back(aProfile->GetName().toStdString() + " is skipped: intersection between hydraulic axis & profile is failed");
196       continue;
197     }
198     if (isec.NbPoints() == 0)
199     {
200       if (warnings)
201         warnings->push_back(aProfile->GetName().toStdString() + " is skipped: no intersection between hydraulic axis & profile");
202       continue; 
203     }
204     if (isec.NbPoints() > 1)
205     {
206       if (warnings)
207         warnings->push_back(aProfile->GetName().toStdString() + " is skipped; intersection between hydraulic axis & profile produces more than 1 point");
208       continue; 
209     }
210     double param = isec.Point(1).ParamOnSecond();
211     profToInterParam[param] = aProfile;
212   }
213 }
214
215 static bool EquidParamsOnHAX(const Handle(Geom2d_Curve)& Hax2d, double step, double fp, double lp, std::set<double>& params)
216 {
217   Geom2dAdaptor_Curve ad(Hax2d);
218   GCPnts_UniformAbscissa GUA(ad, step, fp, lp);
219   if (!GUA.IsDone())
220     return false;
221
222   for(int i = 1; i<= GUA.NbPoints(); i++)
223     params.insert(GUA.Parameter(i));
224
225   return true;
226 }
227
228 static void GetPointsOnBanks(const std::vector<double>& gua_params,
229   const Handle(Geom2d_Curve)& Hax2d,
230   const Handle(Geom2d_Curve)& LB2d, 
231   const Handle(Geom2d_Curve)& RB2d,
232   std::map<double, std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>>& parToBankPoints,  
233   std::vector<std::string>* warnings,
234   const std::map<double, std::pair<Handle(HYDROData_Profile), Handle(HYDROData_Profile)>>* intermParamToProfPair)
235
236   for(int i = 0; i < gua_params.size(); i++)
237   {
238     double par = gua_params[i];
239     gp_Pnt2d p;
240     gp_Vec2d v;
241     Hax2d->D1(par, p, v); //if non-diff?
242     gp_Pnt2d outpLB, outpRB; 
243           
244     gp_Dir2d n2d(v.X(), v.Y()); //ignore Z (Z==0)
245     n2d.Rotate(M_PI/2);
246     //nLine2d is an orthogonal line to hydr. axis
247     gp_Pnt2d p2d(gp_Pnt2d(p.X(), p.Y()));
248     Handle(Geom2d_Line) nLine2d = new Geom2d_Line(p2d, n2d);
249     //intersect nLine2d with banks
250     Geom2dAPI_InterCurveCurve intL(LB2d, nLine2d);
251     Geom2dAPI_InterCurveCurve intR(RB2d, nLine2d);
252
253     if (warnings && intL.NbPoints()==0 )
254     {
255       std::string coord = (QString::number(p2d.X()) + ", "+QString::number(p2d.Y())).toStdString();
256       if (intermParamToProfPair && intermParamToProfPair->count(par) != 0)
257       {
258         std::string fpn = intermParamToProfPair->at(par).first->GetName().toStdString();
259         std::string spn = intermParamToProfPair->at(par).second->GetName().toStdString();
260         warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ 
261           coord +"), located between " + fpn + " & " + spn + ") and left bank found; skipped");
262       }
263       else
264         warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and left bank found; skipped");
265     }
266
267     if (warnings && intR.NbPoints()==0)
268     {
269       std::string coord = (QString::number(p2d.X()) + ", "+QString::number(p2d.Y())).toStdString();
270       if (intermParamToProfPair && intermParamToProfPair->count(par) != 0)
271       {
272         std::string fpn = intermParamToProfPair->at(par).first->GetName().toStdString();
273         std::string spn = intermParamToProfPair->at(par).second->GetName().toStdString();
274         warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ 
275           coord +"), located between " + fpn + " & " + spn + ") and right bank found; skipped");
276       }
277       else
278         warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and right bank found; skipped");
279     }
280
281     if ( intL.NbPoints()==0 || intR.NbPoints()==0)
282       continue;
283
284     IntRes2d_IntersectionPoint aNearSolL, aNearSolR;
285     double min_sq_dist = Precision::Infinite();
286     for (int j=1;j<=intL.NbPoints();j++)
287     {
288       double sq_dist = p2d.SquareDistance(intL.Point(j));
289       if (min_sq_dist > sq_dist)
290       {
291         min_sq_dist = sq_dist;
292         //aNearSolL = intL.Point(j);
293         aNearSolL = intL.Intersector().Point(j);
294       }
295     }
296     min_sq_dist = Precision::Infinite();
297     for (int j=1;j<=intR.NbPoints();j++)
298     {
299       double sq_dist = p2d.SquareDistance(intR.Point(j));
300       if (min_sq_dist > sq_dist)
301       {
302         min_sq_dist = sq_dist;
303         //aNearSolR = intR.Point(j);
304         aNearSolR =  intR.Intersector().Point(j);
305       }
306     }
307
308     std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint> int_pair(aNearSolL, aNearSolR);
309     parToBankPoints[par]=int_pair;
310   }
311 }
312
313
314 void BuildFace(const std::map<double, std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>>& parToBankPoints, 
315   const Handle(Geom2d_Curve)& LB2d,
316   const Handle(Geom2d_Curve)& RB2d,
317   HYDROData_Stream::PrsDefinition& prsDef)
318 {
319   prsDef.myPrs3D.Nullify();
320   prsDef.myPrs2D.Nullify();
321   prsDef.myLeftBank.Nullify();   
322   prsDef.myRightBank.Nullify();  
323   prsDef.myInlet.Nullify();     
324   prsDef.myOutlet.Nullify();  
325
326   double lb_1, lb_2, rb_1, rb_2;
327   lb_1 = parToBankPoints.begin()->second.first.ParamOnFirst();
328   rb_1 = parToBankPoints.begin()->second.second.ParamOnFirst();
329
330   lb_2 = parToBankPoints.rbegin()->second.first.ParamOnFirst();
331   rb_2 = parToBankPoints.rbegin()->second.second.ParamOnFirst();
332
333   //stat = GetItersectionParam(F_prof, LB2d, lb_1) && GetItersectionParam(F_prof, RB2d, rb_1)
334   //  && GetItersectionParam(S_prof, LB2d, lb_2) && GetItersectionParam(S_prof, RB2d, rb_2);
335   
336   BRepBuilderAPI_MakeEdge2d LEM(LB2d, lb_1, lb_2);
337   if (!LEM.IsDone())
338     return;
339   BRepBuilderAPI_MakeEdge2d REM(RB2d, rb_1, rb_2);
340   if (!REM.IsDone())
341     return;
342   TopoDS_Edge LBE = LEM.Edge();
343   TopoDS_Edge RBE = REM.Edge();
344   if (LBE.IsNull() || RBE.IsNull())
345     return;
346   BRepBuilderAPI_MakeEdge PFEM(BRep_Tool::Pnt(LEM.Vertex1()), BRep_Tool::Pnt(REM.Vertex1()));
347   BRepBuilderAPI_MakeEdge PLEM(BRep_Tool::Pnt(LEM.Vertex2()), BRep_Tool::Pnt(REM.Vertex2()));
348   if (!PFEM.IsDone())
349     return;
350   if (!PLEM.IsDone())
351     return;
352   TopoDS_Edge FProfE = PFEM.Edge();
353   TopoDS_Edge SProfE = PLEM.Edge();
354   BRepBuilderAPI_MakeWire WM(FProfE, LBE, SProfE, RBE);
355   if (WM.IsDone())
356   {
357     TopoDS_Wire W = WM.Wire();
358     BRepLib::BuildCurves3d(W);
359     BRepBuilderAPI_MakeFace FM(Geom_Plane(gp::XOY()).Pln(), WM.Wire()); 
360     if (FM.IsDone())
361     {
362       prsDef.myPrs2D = FM.Face();
363       prsDef.myLeftBank = LBE;
364       prsDef.myRightBank = RBE;
365       prsDef.myInlet = FProfE;
366       prsDef.myOutlet = SProfE;
367     }
368   }  
369 }
370
371 void HYDROData_StreamLinearInterpolation::Perform(const HYDROData_SequenceOfObjects& profiles,
372   int pointsToInsert,
373   double stepOnHA, 
374   const Handle(HYDROData_PolylineXY)& hax,  
375   const Handle(HYDROData_PolylineXY)& LB, 
376   const Handle(HYDROData_PolylineXY)& RB,
377   HYDROData_Bathymetry::AltitudePoints& outBathypoints,
378   bool buildPresentationShapes,
379   bool estimateWarnOnly,
380   HYDROData_Stream::PrsDefinition& prsDef,
381   std::vector<std::string>* warnings)
382 {
383   //intersect profiles with given hydr.axis
384   if (hax.IsNull() || LB.IsNull() || RB.IsNull())
385     return;
386
387   Handle(Geom2d_Curve) Hax2d;
388   PolyToCurve2d(hax, Hax2d);
389   if (hax->IsClosed() || Hax2d->IsClosed()) //can't be closed
390   {
391     if (warnings)
392       warnings->push_back(hax->GetName().toStdString() + " is closed; abort");
393     return;
394   }
395
396   std::map<double, Handle(HYDROData_Profile)> InterParamToProf;
397   //profToInterParam is output param map: profile to intersection param on hydr.axis
398   InterProfilesAndHAX(profiles, Hax2d, InterParamToProf, warnings);
399   //
400   std::vector<std::vector<gp_Pnt2d>> profilesPoints;
401   profilesPoints.reserve(InterParamToProf.size());
402   int maxNbPoints = 0;
403   
404   //for (int i=1;i<=InterParamToProf.Extent();i++)
405   for( std::map<double, Handle(HYDROData_Profile)>::iterator it = InterParamToProf.begin(); it != InterParamToProf.end(); ++it )
406   {
407     //ordered by param on hydr axis
408     Handle(HYDROData_Profile) aProfile = it->second; 
409     const std::vector<gp_Pnt2d>& profile_points = GetProfileUZPoints(aProfile);
410     profilesPoints.push_back(profile_points);
411     if (profile_points.size() > maxNbPoints)
412       maxNbPoints = profile_points.size();
413   }
414   std::set<double> paramsOnHAX;
415
416   if (InterParamToProf.size() <= 1)
417   {
418     if (warnings)
419       warnings->push_back("Insufficient count of correct input profiles; abort");
420     return;
421   }
422
423   EquidParamsOnHAX(Hax2d, stepOnHA, InterParamToProf.begin()->first, 
424     InterParamToProf.rbegin()->first, paramsOnHAX);
425
426   //prepare ParamsPerSegm - number of interm.profiles for profile_points
427   std::vector<std::vector<double>> ParamsPerSegm;
428   std::set<double>::iterator it_params_hax = paramsOnHAX.begin();
429   std::map<double, Handle(HYDROData_Profile)>::iterator it_p = InterParamToProf.begin();
430   //
431   std::map<double, std::pair<Handle(HYDROData_Profile), Handle(HYDROData_Profile)>> intermParamToProfPair; //for warnings only
432   //
433   it_p++; 
434   ParamsPerSegm.resize(profilesPoints.size()-1);
435   for( int k=0; it_p != InterParamToProf.end(); )
436   {
437     if (*it_params_hax < it_p->first)
438     {
439       double val = *it_params_hax;
440       ParamsPerSegm[k].push_back(val);
441       it_params_hax++;
442
443       it_p--;
444       const Handle(HYDROData_Profile)& cp = it_p->second;
445       it_p++;
446       const Handle(HYDROData_Profile)& np = it_p->second;
447       std::pair<Handle(HYDROData_Profile), Handle(HYDROData_Profile)> profPair(cp, np);
448       intermParamToProfPair[val] = profPair;
449     }
450     else
451     {
452       it_p++;
453       k++;
454     }
455   }
456   ParamsPerSegm.back().push_back(*paramsOnHAX.rbegin());
457   //
458   std::map<double, std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>> parToBankPoints;
459   std::vector<double> paramHAXVec;
460   paramHAXVec.reserve(paramsOnHAX.size());
461   for( std::set<double>::iterator it = paramsOnHAX.begin(); it != paramsOnHAX.end(); ++it )
462     paramHAXVec.push_back(*it);
463   //
464   Handle(Geom2d_Curve) LB2d, RB2d;
465   PolyToCurve2d(LB, LB2d);
466   PolyToCurve2d(RB, RB2d);
467   GetPointsOnBanks( paramHAXVec, Hax2d, LB2d, RB2d, parToBankPoints, warnings, &intermParamToProfPair);
468
469   if (buildPresentationShapes)
470   {
471     //parToBankPoints.begin()->second.;
472     //double lp1 = parToBankPoints.rbegin()->first;
473
474     //Handle(HYDROData_Profile) F_prof = InterParamToProf.begin()->second;
475     //Handle(HYDROData_Profile) S_prof = InterParamToProf.rbegin()->second;
476     BuildFace(parToBankPoints, LB2d, RB2d, prsDef);
477   }
478   //
479
480   if (estimateWarnOnly)
481     return;
482
483   maxNbPoints = Max(pointsToInsert, maxNbPoints);
484
485   //insert points to profiles
486   for (int i=0;i<profilesPoints.size();i++)
487   {
488     int nbPointsToInsert = maxNbPoints - profilesPoints[i].size();
489     //insert nbPointsToInsert points to current profile
490     InsertPoints(profilesPoints[i], nbPointsToInsert);
491   }
492
493   TopoDS_Compound cmp2d;
494   if ( buildPresentationShapes)
495   {
496     BRep_Builder().MakeCompound(cmp2d);
497     BRep_Builder().Add(cmp2d, prsDef.myLeftBank);
498     BRep_Builder().Add(cmp2d, prsDef.myRightBank);
499   }
500
501   for (int i=0;i<profilesPoints.size()-1;i++)
502   {
503     const std::vector<gp_Pnt2d>& prof1 = profilesPoints[i];
504     const std::vector<gp_Pnt2d>& prof2 = profilesPoints[i+1];
505     std::vector<std::vector<gp_Pnt2d>> IntermProf;
506
507     std::map<int, double> indToParam; //index of im.profile to param on hax. ()
508     for (int j=0;j<ParamsPerSegm[i].size();j++)
509     {
510       double param = ParamsPerSegm[i][j];
511       if (parToBankPoints.count(param) > 0) //not intersected with banks; skip this
512         indToParam[j]=param;
513     }
514     int NbIntermProf = indToParam.size();
515     IntermProf.resize(NbIntermProf);
516
517     for (int l=0;l<NbIntermProf;l++)
518       IntermProf[l].resize(prof1.size());
519     //calc interm. between prof1 & prof2
520     assert (prof1.size() == prof2.size());
521     for (int j=0;j<prof1.size();j++)
522     {
523       gp_Pnt2d P1 = prof1[j];
524       gp_Pnt2d P2 = prof2[j];
525       double X0 = P1.X();
526       double Y0 = P1.Y();
527       double X1 = P2.X();
528       double Y1 = P2.Y();
529       std::map<int, double>::iterator it = indToParam.begin();
530       for ( int m=0; it != indToParam.end(); it++, m++ )
531       {
532         int ind = it->first;
533         double t = ((double)ind+1)/((double)NbIntermProf+1);
534         double Xp = X0 + (X1-X0)*t;
535         double Yp = Y0 + (Y1-Y0)*t;
536         gp_Pnt2d P(Xp, Yp);
537         IntermProf[m][j] = P;
538       }
539     }
540     std::map<int, double>::iterator it = indToParam.begin();
541     for ( int m=0; it != indToParam.end(); it++, m++ )
542     {
543       const std::vector<gp_Pnt2d>& im_prof = IntermProf[m];
544       double param = it->second;
545       const std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>& BB = parToBankPoints[param]; //param is included in map; no checks
546       gp_Pnt2d LP = BB.first.Value();
547       gp_Pnt2d RP = BB.second.Value();
548       HYDROData_ProfileUZ::PointsList pl;
549       for (int k=0;k<im_prof.size();k++)
550         pl.Append(im_prof[k].XY());
551       HYDROData_Profile::ProfilePoints profile_points3d = HYDROData_Profile::CalculateProfilePoints(pl, LP.XY(), RP.XY());
552       for (int k=1;k<=profile_points3d.Length();k++)
553       {
554         HYDROData_Bathymetry::AltitudePoint AP(profile_points3d(k).X(), profile_points3d(k).Y(), profile_points3d(k).Z());
555         outBathypoints.push_back(AP);
556       }
557       if (buildPresentationShapes)
558       {
559         if (m==0 || i == profilesPoints.size()-2 && param == indToParam.rbegin()->second) //if last prof1/prof2 segment => take a last profile too
560         {
561           BRepLib_MakePolygon PM;
562           for (int k=1;k<=profile_points3d.Length();k++)
563             PM.Add(gp_Pnt(profile_points3d(k)));
564           if (PM.IsDone())
565           {
566             const TopoDS_Wire& resW = PM.Wire();
567             BRep_Builder().Add(cmp2d, resW);
568           }
569         }
570       }
571     }
572   }
573   if (buildPresentationShapes)
574   {
575     prsDef.myPrs3D = cmp2d;
576   }
577   //outBathy->SetAltitudePoints(bathypoints);
578 }
579
580
581