From 5d9d91864aab8dbe20e478dec92fb47b6bc39eb7 Mon Sep 17 00:00:00 2001 From: isn Date: Fri, 7 Jun 2019 14:45:39 +0300 Subject: [PATCH] refs #2002 swap LB/RB points of profile depending on orientation of profile relative to h.axis --- .../HYDROData_StreamLinearInterpolation.cxx | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx b/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx index 9cecdf09..68a06bac 100644 --- a/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx +++ b/src/HYDROData/HYDROData_StreamLinearInterpolation.cxx @@ -168,6 +168,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 +186,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 +210,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 +379,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 +410,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 +507,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) { -- 2.39.2