const Handle(Geom2d_Curve)& Hax2d,
const Handle(Geom2d_Curve)& LB2d,
const Handle(Geom2d_Curve)& RB2d,
- std::map<double, std::pair<gp_Pnt2d, gp_Pnt2d>>& parToBankPoints,
- std::vector<std::string>* warnings)
+ std::map<double, std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>>& parToBankPoints,
+ std::vector<std::string>* warnings,
+ const std::map<double, std::pair<Handle(HYDROData_Profile), Handle(HYDROData_Profile)>>* intermParamToProfPair)
{
for(int i = 0; i < gua_params.size(); i++)
{
if (warnings && intL.NbPoints()==0 )
{
std::string coord = (QString::number(p2d.X()) + ", "+QString::number(p2d.Y())).toStdString();
- warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and left bank found; skipped");
+ if (intermParamToProfPair && intermParamToProfPair->count(par) != 0)
+ {
+ std::string fpn = intermParamToProfPair->at(par).first->GetName().toStdString();
+ std::string spn = intermParamToProfPair->at(par).second->GetName().toStdString();
+ warnings->push_back("no intersection between intermediate profile (point on h.axis:("+
+ coord +"), located between " + fpn + " & " + spn + ") and left bank found; skipped");
+ }
+ else
+ warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and left bank found; skipped");
}
if (warnings && intR.NbPoints()==0)
{
std::string coord = (QString::number(p2d.X()) + ", "+QString::number(p2d.Y())).toStdString();
- warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and right bank found; skipped");
+ if (intermParamToProfPair && intermParamToProfPair->count(par) != 0)
+ {
+ std::string fpn = intermParamToProfPair->at(par).first->GetName().toStdString();
+ std::string spn = intermParamToProfPair->at(par).second->GetName().toStdString();
+ warnings->push_back("no intersection between intermediate profile (point on h.axis:("+
+ coord +"), located between " + fpn + " & " + spn + ") and right bank found; skipped");
+ }
+ else
+ warnings->push_back("no intersection between intermediate profile (point on h.axis:("+ coord +")) and right bank found; skipped");
}
if ( intL.NbPoints()==0 || intR.NbPoints()==0)
continue;
- gp_Pnt2d aNearSolL, aNearSolR;
+ IntRes2d_IntersectionPoint aNearSolL, aNearSolR;
double min_sq_dist = Precision::Infinite();
for (int j=1;j<=intL.NbPoints();j++)
{
if (min_sq_dist > sq_dist)
{
min_sq_dist = sq_dist;
- aNearSolL = intL.Point(j);
+ //aNearSolL = intL.Point(j);
+ aNearSolL = intL.Intersector().Point(j);
}
}
min_sq_dist = Precision::Infinite();
if (min_sq_dist > sq_dist)
{
min_sq_dist = sq_dist;
- aNearSolR = intR.Point(j);
+ //aNearSolR = intR.Point(j);
+ aNearSolR = intR.Intersector().Point(j);
}
}
- std::pair<gp_Pnt2d, gp_Pnt2d> int_pair(aNearSolL, aNearSolR);
+ std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint> int_pair(aNearSolL, aNearSolR);
parToBankPoints[par]=int_pair;
}
}
-bool GetItersectionParam(const Handle(HYDROData_Profile)& aProfile, const Handle(Geom2d_Curve)& B2d, double& outIntersectionParam)
-{
- gp_XY LP, RP;
- aProfile->GetLeftPoint( LP, true, true );
- aProfile->GetRightPoint( RP, true, true );
- gp_Pnt2d P1(LP), P2(RP);
- double d = P2.Distance(P1);
- if (d < gp::Resolution())
- return false;
- Handle(Geom2d_Line) lin2d = new Geom2d_Line(P1,gp_Dir2d(P2.XY()-P1.XY()));
-
- Geom2dAdaptor_Curve linAd(lin2d, 0, d);
- Geom2dAdaptor_Curve BAd(B2d);
- Geom2dInt_GInter isec( linAd, BAd, 1.0e-6, 1.0e-6);
- if (!isec.IsDone())
- return false;
- if (isec.NbPoints() == 0)
- return false;
- if (isec.NbPoints() > 1)
- return false;
- outIntersectionParam = isec.Point(1).ParamOnSecond();
- return true;
-}
-
-void BuildFace(const Handle(HYDROData_Profile)& F_prof,
- const Handle(HYDROData_Profile)& S_prof,
+void BuildFace(const std::map<double, std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>>& parToBankPoints,
const Handle(Geom2d_Curve)& LB2d,
const Handle(Geom2d_Curve)& RB2d,
HYDROData_Stream::PrsDefinition& prsDef)
prsDef.myInlet.Nullify();
prsDef.myOutlet.Nullify();
- bool stat = true;
double lb_1, lb_2, rb_1, rb_2;
- stat = GetItersectionParam(F_prof, LB2d, lb_1) && GetItersectionParam(F_prof, RB2d, rb_1)
- && GetItersectionParam(S_prof, LB2d, lb_2) && GetItersectionParam(S_prof, RB2d, rb_2);
- if (stat)
+ lb_1 = parToBankPoints.begin()->second.first.ParamOnFirst();
+ rb_1 = parToBankPoints.begin()->second.second.ParamOnFirst();
+
+ lb_2 = parToBankPoints.rbegin()->second.first.ParamOnFirst();
+ rb_2 = parToBankPoints.rbegin()->second.second.ParamOnFirst();
+
+ //stat = GetItersectionParam(F_prof, LB2d, lb_1) && GetItersectionParam(F_prof, RB2d, rb_1)
+ // && GetItersectionParam(S_prof, LB2d, lb_2) && GetItersectionParam(S_prof, RB2d, rb_2);
+
+ BRepBuilderAPI_MakeEdge2d LEM(LB2d, lb_1, lb_2);
+ if (!LEM.IsDone())
+ return;
+ BRepBuilderAPI_MakeEdge2d REM(RB2d, rb_1, rb_2);
+ if (!REM.IsDone())
+ return;
+ TopoDS_Edge LBE = LEM.Edge();
+ TopoDS_Edge RBE = REM.Edge();
+ if (LBE.IsNull() || RBE.IsNull())
+ return;
+ BRepBuilderAPI_MakeEdge PFEM(BRep_Tool::Pnt(LEM.Vertex1()), BRep_Tool::Pnt(REM.Vertex1()));
+ BRepBuilderAPI_MakeEdge PLEM(BRep_Tool::Pnt(LEM.Vertex2()), BRep_Tool::Pnt(REM.Vertex2()));
+ if (!PFEM.IsDone())
+ return;
+ if (!PLEM.IsDone())
+ return;
+ TopoDS_Edge FProfE = PFEM.Edge();
+ TopoDS_Edge SProfE = PLEM.Edge();
+ BRepBuilderAPI_MakeWire WM(FProfE, LBE, SProfE, RBE);
+ if (WM.IsDone())
{
- BRepBuilderAPI_MakeEdge2d LEM(LB2d, lb_1, lb_2);
- if (!LEM.IsDone())
- return;
- BRepBuilderAPI_MakeEdge2d REM(RB2d, rb_1, rb_2);
- if (!REM.IsDone())
- return;
- TopoDS_Edge LBE = LEM.Edge();
- TopoDS_Edge RBE = REM.Edge();
- if (LBE.IsNull() || RBE.IsNull())
- return;
- BRepBuilderAPI_MakeEdge PFEM(BRep_Tool::Pnt(LEM.Vertex1()), BRep_Tool::Pnt(REM.Vertex1()));
- BRepBuilderAPI_MakeEdge PLEM(BRep_Tool::Pnt(LEM.Vertex2()), BRep_Tool::Pnt(REM.Vertex2()));
- if (!PFEM.IsDone())
- return;
- if (!PLEM.IsDone())
- return;
- TopoDS_Edge FProfE = PFEM.Edge();
- TopoDS_Edge SProfE = PLEM.Edge();
- BRepBuilderAPI_MakeWire WM(FProfE, LBE, SProfE, RBE);
- if (WM.IsDone())
+ TopoDS_Wire W = WM.Wire();
+ BRepLib::BuildCurves3d(W);
+ BRepBuilderAPI_MakeFace FM(Geom_Plane(gp::XOY()).Pln(), WM.Wire());
+ if (FM.IsDone())
{
- TopoDS_Wire W = WM.Wire();
- BRepLib::BuildCurves3d(W);
- BRepBuilderAPI_MakeFace FM(Geom_Plane(gp::XOY()).Pln(), WM.Wire());
- if (FM.IsDone())
- {
- prsDef.myPrs2D = FM.Face();
- prsDef.myLeftBank = LBE;
- prsDef.myRightBank = RBE;
- prsDef.myInlet = FProfE;
- prsDef.myOutlet = SProfE;
- }
+ prsDef.myPrs2D = FM.Face();
+ prsDef.myLeftBank = LBE;
+ prsDef.myRightBank = RBE;
+ prsDef.myInlet = FProfE;
+ prsDef.myOutlet = SProfE;
}
- }
+ }
}
void HYDROData_StreamLinearInterpolation::Perform(const HYDROData_SequenceOfObjects& profiles,
std::vector<std::vector<double>> ParamsPerSegm;
std::set<double>::iterator it_params_hax = paramsOnHAX.begin();
std::map<double, Handle(HYDROData_Profile)>::iterator it_p = InterParamToProf.begin();
+ //
+ std::map<double, std::pair<Handle(HYDROData_Profile), Handle(HYDROData_Profile)>> intermParamToProfPair; //for warnings only
+ //
it_p++;
ParamsPerSegm.resize(profilesPoints.size()-1);
for( int k=0; it_p != InterParamToProf.end(); )
{
if (*it_params_hax < it_p->first)
{
- ParamsPerSegm[k].push_back(*it_params_hax);
- it_params_hax++;
+ double val = *it_params_hax;
+ ParamsPerSegm[k].push_back(val);
+ it_params_hax++;
+
+ it_p--;
+ const Handle(HYDROData_Profile)& cp = it_p->second;
+ it_p++;
+ const Handle(HYDROData_Profile)& np = it_p->second;
+ std::pair<Handle(HYDROData_Profile), Handle(HYDROData_Profile)> profPair(cp, np);
+ intermParamToProfPair[val] = profPair;
}
else
{
}
ParamsPerSegm.back().push_back(*paramsOnHAX.rbegin());
//
- std::map<double, std::pair<gp_Pnt2d, gp_Pnt2d>> parToBankPoints;
+ std::map<double, std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>> parToBankPoints;
std::vector<double> paramHAXVec;
paramHAXVec.reserve(paramsOnHAX.size());
for( std::set<double>::iterator it = paramsOnHAX.begin(); it != paramsOnHAX.end(); ++it )
Handle(Geom2d_Curve) LB2d, RB2d;
PolyToCurve2d(LB, LB2d);
PolyToCurve2d(RB, RB2d);
- GetPointsOnBanks( paramHAXVec, Hax2d, LB2d, RB2d, parToBankPoints, warnings);
+ GetPointsOnBanks( paramHAXVec, Hax2d, LB2d, RB2d, parToBankPoints, warnings, &intermParamToProfPair);
if (buildPresentationShapes)
{
- Handle(HYDROData_Profile) F_prof = InterParamToProf.begin()->second;
- Handle(HYDROData_Profile) S_prof = InterParamToProf.rbegin()->second;
- BuildFace(F_prof, S_prof, LB2d, RB2d, prsDef);
+ //parToBankPoints.begin()->second.;
+ //double lp1 = parToBankPoints.rbegin()->first;
+
+ //Handle(HYDROData_Profile) F_prof = InterParamToProf.begin()->second;
+ //Handle(HYDROData_Profile) S_prof = InterParamToProf.rbegin()->second;
+ BuildFace(parToBankPoints, LB2d, RB2d, prsDef);
}
//
{
const std::vector<gp_Pnt2d>& im_prof = IntermProf[m];
double param = it->second;
- const std::pair<gp_Pnt2d, gp_Pnt2d>& BB = parToBankPoints[param]; //param is included in map; no checks
- gp_Pnt2d LP = BB.first;
- gp_Pnt2d RP = BB.second;
+ const std::pair<IntRes2d_IntersectionPoint, IntRes2d_IntersectionPoint>& BB = parToBankPoints[param]; //param is included in map; no checks
+ gp_Pnt2d LP = BB.first.Value();
+ gp_Pnt2d RP = BB.second.Value();
HYDROData_ProfileUZ::PointsList pl;
for (int k=0;k<im_prof.size();k++)
pl.Append(im_prof[k].XY());