X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_StreamLinearInterpolation.cxx;h=23eab97ec0a30466d10ae142e26394099fac8f1f;hb=e7e76450be3fadf6ad263f78e10ceb8cd1f70deb;hp=9cecdf096761059c2fddb18e0c7b01662e92b813;hpb=3357c9444d7accdd6e46961cc2f5ea1457654750;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx b/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx index 9cecdf09..23eab97e 100644 --- a/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx +++ b/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx @@ -107,7 +107,7 @@ static void GetMaxDist(const std::vector& PNTS, static void InsertPoints(std::vector& points, int nbpoints) { points.reserve(points.size() + nbpoints); - while (nbpoints) + while (nbpoints>0) { double dmax=0, dmax2=0; int imax=-1; @@ -124,6 +124,8 @@ static void InsertPoints(std::vector& points, int nbpoints) double Y0 = p1.Y(); double X1 = p2.X(); double Y1 = p2.Y(); + if (nbPins>nbpoints) //deny to add more points than needed + nbPins = nbpoints; for (int i=0;i& points, int nbpoints) } nbpoints-=nbPins; } + assert (nbpoints == 0); } static void PolyToCurve2d(const Handle(HYDROData_PolylineXY)& poly, Handle(Geom2d_Curve)& c2d) @@ -168,6 +171,7 @@ static void PolyToCurve2d(const Handle(HYDROData_PolylineXY)& poly, Handle(Geom2 static void InterProfilesAndHAX(const HYDROData_SequenceOfObjects& profiles, const Handle(Geom2d_Curve)& Hax2d, std::map& profToInterParam, + std::vector& paramToSwapFlag, std::vector* warnings) { for (int i=1;i<=profiles.Size();i++) @@ -185,6 +189,7 @@ static void InterProfilesAndHAX(const HYDROData_SequenceOfObjects& profiles, continue; } Handle(Geom2d_Line) lin2d = new Geom2d_Line(P1,gp_Dir2d(P2.XY()-P1.XY())); + gp_Dir2d prof_dir2d = lin2d->Direction(); Geom2dAdaptor_Curve linAd(lin2d, 0, d); Geom2dAdaptor_Curve haxAd(Hax2d); @@ -208,6 +213,15 @@ static void InterProfilesAndHAX(const HYDROData_SequenceOfObjects& profiles, continue; } double param = isec.Point(1).ParamOnSecond(); + gp_Pnt2d int_p2d; + gp_Vec2d vec_on_hax_intersec; + haxAd.D1(param, int_p2d, vec_on_hax_intersec); + gp_Dir2d d_hax(vec_on_hax_intersec); + double ang = d_hax.Angle(prof_dir2d); + if (ang>0) + paramToSwapFlag.push_back(true); + else + paramToSwapFlag.push_back(false); profToInterParam[param] = aProfile; } } @@ -368,6 +382,11 @@ void BuildFace(const std::map& points) +{ + std::reverse(points.begin(), points.end()); +} + void HYDROData_StreamLinearInterpolation::Perform(const HYDROData_SequenceOfObjects& profiles, int pointsToInsert, double stepOnHA, @@ -394,8 +413,9 @@ void HYDROData_StreamLinearInterpolation::Perform(const HYDROData_SequenceOfObje } std::map InterParamToProf; + std::vector paramToSwapFlag; //profToInterParam is output param map: profile to intersection param on hydr.axis - InterProfilesAndHAX(profiles, Hax2d, InterParamToProf, warnings); + InterProfilesAndHAX(profiles, Hax2d, InterParamToProf, paramToSwapFlag, warnings); // std::vector> profilesPoints; profilesPoints.reserve(InterParamToProf.size()); @@ -490,6 +510,16 @@ void HYDROData_StreamLinearInterpolation::Perform(const HYDROData_SequenceOfObje InsertPoints(profilesPoints[i], nbPointsToInsert); } + for (int i=0;i& prof = profilesPoints[i]; + reversePoints(prof); + } + } + TopoDS_Compound cmp2d; if ( buildPresentationShapes) {