From 408ecb227467ecbca91271e98afa46f61cd83026 Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 31 Jan 2019 19:21:36 +0300 Subject: [PATCH] lot 10 - warnings for DTM - untested --- src/HYDROData/HYDROData_DTM.cxx | 280 +++++++++++++++++--- src/HYDROData/HYDROData_DTM.h | 27 +- src/HYDROData/HYDROData_Stream.cxx | 8 + src/HYDROData/HYDROData_Stream.h | 8 + src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx | 22 ++ src/HYDROGUI/HYDROGUI_OrderedListWidget.h | 2 + src/HYDROGUI/HYDROGUI_StreamDlg.cxx | 5 + src/HYDROGUI/HYDROGUI_StreamDlg.h | 7 +- src/HYDROGUI/HYDROGUI_StreamOp.cxx | 44 ++- src/HYDRO_tests/test_HYDROData_DTM.cxx | 8 +- 10 files changed, 360 insertions(+), 51 deletions(-) diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 207530f8..84951093 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -58,8 +59,12 @@ #include #include #include +#include +#include +#include #include +double PREC = 0.001; IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry ) HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir, double theDeltaZ, double theMaxZ ) @@ -244,7 +249,10 @@ void HYDROData_DTM::Update() double step = GetSpatialStep(); std::set InvInd; bool WireIntersections; //__TODO - CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1, WireIntersections ); + myWarnings.Clear(); + bool ToEstimateWarnings; //NOT NEEDED here + CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, + true, true, InvInd, -1, WireIntersections, myWarnings, ToEstimateWarnings ); SetAltitudePoints( points ); SetShape( DataTag_LeftBankShape, OutLeftB); @@ -286,7 +294,9 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In bool Create2dPres, std::set& InvInd, int thePntsLimit, - bool& WireIntersections) + bool& WireIntersections, + NCollection_DataMap>& warnings, + bool& ToEstimateWarnings) { int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper(); size_t n = anUpper - aLower + 1; @@ -304,16 +314,26 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In AltitudePoints right; std::vector main_profiles; + bool ToEstimateWarningsOnly = false; if( thePntsLimit > 0 ) { int aNbPoints = EstimateNbPoints( profiles, ddz, step ); if( aNbPoints < 0 || aNbPoints > thePntsLimit ) - return; + { + ToEstimateWarningsOnly = true; + //return; + } } + if( profiles.size() < 2 ) + return; + if( ddz>EPS && step>EPS ) CreateProfiles(profiles, ddz, step, left, right, points, main_profiles, - Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd, WireIntersections ); + Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, + Create2dPres, InvInd, WireIntersections, warnings, ToEstimateWarningsOnly ); + + ToEstimateWarnings = ToEstimateWarningsOnly; } bool HYDROData_DTM::GetPlanarFaceFromBanks( const TopoDS_Edge& LB, const TopoDS_Edge& RB, TopoDS_Face& outF, @@ -372,11 +392,14 @@ void HYDROData_DTM::CreateProfiles(const std::vector& bool Create3dPres, bool Create2dPres, std::set& InvInd, - bool& ProjStat) + bool& ProjStat, + NCollection_DataMap>& warnings, + bool ToEstimateWarningsOnly) { if (theProfiles.empty()) return; - theOutPoints = Interpolate( theProfiles, theDDZ, theSpatialStep, theOutLeft, theOutRight, theOutMainProfiles, InvInd ); + theOutPoints = Interpolate( theProfiles, theDDZ, theSpatialStep, theOutLeft, theOutRight, + theOutMainProfiles, InvInd, warnings, ToEstimateWarningsOnly ); //note that if Create3dPres is false => Create2dPres flag is meaningless! if( theOutPoints.empty() ) return; @@ -655,37 +678,64 @@ std::vector HYDROData_DTM::ProfileToParametric( } -bool CalcMidWidth( const std::set& intersections, double& theMid, double& theWid ) +//bool CalcMidWidth( const std::set& intersections, double& theMid, double& theWid ) +//{ +// double umin = std::numeric_limits::max(), +// umax = -umin; +// +// size_t n = intersections.size(); +// if( n <= 0 ) +// return false; +// +// std::set::const_iterator it = intersections.begin(), last = intersections.end(); +// for( ; it!=last; it++ ) +// { +// double u = *it; +// if( uumax ) +// umax = u; +// } +// theMid = ( umin+umax )/2; +// theWid = umax-umin; +// return true; +//} + + + +bool CalcMidWidth( const Bnd_Box2d& inters_bnd, double& theMid, double& theWid ) { double umin = DBL_MAX, umax = -umin; - size_t n = intersections.size(); - if( n <= 0 ) + if (inters_bnd.IsVoid()) return false; + //size_t n = intersections.size(); + //if( n <= 0 ) + // return false; - std::set::const_iterator it = intersections.begin(), last = intersections.end(); - for( ; it!=last; it++ ) - { - double u = *it; - if( uumax ) - umax = u; - } - theMid = ( umin+umax )/2; - theWid = umax-umin; + double xmin, ymin, xmax, ymax; + inters_bnd.Get(xmin, ymin, xmax, ymax); + if (Abs(ymax-ymin)>PREC) + return false; + + theMid = ( xmax+xmin )/2; + theWid = xmax-xmin; return true; } + + void HYDROData_DTM::ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile, double theXCurv, double theMinZ, double theMaxZ, double theTopZ, double theDDZ, CurveUZ& theMidPointCurve, CurveUZ& theWidthCurve, int& intersection_nb, - double theTolerance) + double theTolerance, + QSet& warnings) { - double aDblMax = DBL_MAX, + warnings.clear(); + double aDblMax = std::numeric_limits::max(), aUMin = aDblMax, aUMax = -aUMin, aVMax = 1000000; @@ -695,7 +745,10 @@ void HYDROData_DTM::ProfileDiscretization( const Handle(HYDROData_Profile)& theP size_t n = curves.size(); if( n==0 ) + { + warnings.insert("no curves for discretization; skipped"); return; + } // we add the "virtual" vertical lines to simulate the intersection with profile gp_Pnt2d aFirst, aLast; @@ -716,25 +769,105 @@ void HYDROData_DTM::ProfileDiscretization( const Handle(HYDROData_Profile)& theP theWidthCurve = CurveUZ( theXCurv, aProfileDir, theMinZ, theTopZ ); theWidthCurve.reserve( psize ); - n = curves.size(); + { + bool PlatoCase = false; + if (Abs(aFirst.Y() - aLast.Y() > PREC)) + { + warnings.insert("One of the extreme points is higher than another"); + } + double ZminExtr = Min(aFirst.Y(), aLast.Y()); + double ZmaxExtr = Max(aFirst.Y(), aLast.Y()); + Handle(Geom2d_Line) aLine = new Geom2d_Line( gp_Pnt2d( 0, ZminExtr ), gp_Dir2d( 1, 0 ) ); + std::vector intersections; + for( int i = 0; i < n; i++ ) + { + Handle(Geom2d_Curve) aCurve = curves[i]; + Geom2dAPI_InterCurveCurve anIntersect( aCurve, aLine, theTolerance ); + for( int k=1, m=anIntersect.NbPoints(); k<=m; k++ ) + intersections.push_back(anIntersect.Point(k)); + if (anIntersect.NbSegments() > 0 ) + PlatoCase = true; + } + std::vector interm_intersections; + for (int i=0;i PREC && aLast.Distance(int_p2d) > PREC && int_p2d.Y() > ZminExtr) + interm_intersections.push_back(int_p2d); + } + if (!interm_intersections.empty()) + warnings.insert("One of the internal points is higher than extreme points"); + if (ZminExtr != ZmaxExtr && !PlatoCase) + { + //additional check of plato for zmax + Handle(Geom2d_Line) aLine = new Geom2d_Line( gp_Pnt2d( 0, ZmaxExtr ), gp_Dir2d( 1, 0 ) ); + std::vector intersections; + for( int i = 0; i < n; i++ ) + { + Handle(Geom2d_Curve) aCurve = curves[i]; + Geom2dAPI_InterCurveCurve anIntersect( aCurve, aLine, theTolerance ); + if (anIntersect.NbSegments() > 0 ) + { + PlatoCase = true; + break; + } + } + } + if (PlatoCase) + warnings.insert("Plato case on extremes"); + } + + n = curves.size(); + // for each discrete value of z we search intersection with profile for( double z1 = theMinZ; z1 <= theMaxZ; z1 += theDDZ ) { Handle(Geom2d_Line) aLine = new Geom2d_Line( gp_Pnt2d( 0, z1 ), gp_Dir2d( 1, 0 ) ); std::set intersections; + Bnd_Box2d intersect_bndbox; for( size_t i = 0; i < n; i++ ) { Handle(Geom2d_Curve) aCurve = curves[i]; Geom2dAPI_InterCurveCurve anIntersect( aCurve, aLine, theTolerance ); for( int k=1, m=anIntersect.NbPoints(); k<=m; k++ ) + { intersections.insert( anIntersect.Point( k ).X() ); + intersect_bndbox.Add( anIntersect.Point(k)); + } + // + for( int k=1, m=anIntersect.NbSegments(); k<=m; k++ ) + { + Handle(Geom2d_Curve) Curve1,Curve2; + anIntersect.Segment(k, Curve1, Curve2 ); + double f = Curve2->FirstParameter(); + double l = Curve2->LastParameter(); + gp_Pnt2d Pf, Pl; + Curve2->D0(f, Pf); + Curve2->D0(l, Pl); + intersect_bndbox.Add( Pf ); + intersect_bndbox.Add( Pl ); + intersections.insert( Pf.X() ); + intersections.insert( Pl.X() ); + } } intersection_nb = intersections.size(); - if( intersection_nb >= 1 ) + if (intersection_nb == 0) + { + warnings.insert("No intersections between profile & altitude Z-lines found; skipped"); + return; + } + else if (intersection_nb > 2) + { + warnings.insert("More than 2 intersections between profile & altitude Z-lines found"); + } + double xmin, ymin, xmax, ymax; + intersect_bndbox.Get(xmin, ymin, xmax, ymax); + if (Abs(xmax-xmin)>PREC) { double u_mid, u_wid; - if( !CalcMidWidth( intersections, u_mid, u_wid ) ) + if( !CalcMidWidth( intersect_bndbox, u_mid, u_wid ) ) continue; double z = z1 - theMinZ; @@ -748,6 +881,26 @@ void HYDROData_DTM::ProfileDiscretization( const Handle(HYDROData_Profile)& theP p_wid.Z = z; theWidthCurve.push_back( p_wid ); } + + + //intersection_nb = intersections.size(); + //if( intersection_nb >= 1 ) + //{ + // double u_mid, u_wid; + // if( !CalcMidWidth( intersections, u_mid, u_wid ) ) + // continue; + // + // double z = z1 - theMinZ; + // PointUZ p_mid; + // p_mid.U = u_mid; + // p_mid.Z = z; + // theMidPointCurve.push_back( p_mid ); + // + // PointUZ p_wid; + // p_wid.U = u_wid; + // p_wid.Z = z; + // theWidthCurve.push_back( p_wid ); + //} } } @@ -849,7 +1002,9 @@ std::vector HYDROData_DTM::Interpolate const Handle(HYDROData_Profile)& theProfileB, double theXCurvB, double theDDZ, int theNbSteps, bool isAddSecond, - int& inter_nb_1, int& inter_nb_2) + int& inter_nb_1, int& inter_nb_2, + NCollection_DataMap>& warnings, + bool ToEstimateWarningsOnly) { double zminA, zmaxA, zminB, zmaxB; gp_Pnt lowestA, lowestB; @@ -868,8 +1023,33 @@ std::vector HYDROData_DTM::Interpolate CurveUZ midA(0, gp_Vec2d(), 0, 0), midB(0, gp_Vec2d(), 0, 0); CurveUZ widA(0, gp_Vec2d(), 0, 0), widB(0, gp_Vec2d(), 0, 0); - ProfileDiscretization( theProfileA, theXCurvA, zminA, zminA+hmax, zmaxA-zminA, theDDZ, midA, widA, inter_nb_1 ); - ProfileDiscretization( theProfileB, theXCurvB, zminB, zminB+hmax, zmaxB-zminB, theDDZ, midB, widB, inter_nb_2 ); + QSet warnings_per_profileA, warnings_per_profileB; + + ProfileDiscretization( theProfileA, theXCurvA, zminA, zminA+hmax, zmaxA-zminA, + theDDZ, midA, widA, inter_nb_1, 1E-6, warnings_per_profileA ); + ProfileDiscretization( theProfileB, theXCurvB, zminB, zminB+hmax, zmaxB-zminB, + theDDZ, midB, widB, inter_nb_2, 1E-6, warnings_per_profileB ); + + //process warnings + if (warnings.IsBound(theProfileA)) + { + QSet& warnings_per_profileA_old = warnings.ChangeFind(theProfileA); + warnings_per_profileA_old+=warnings_per_profileA; + } + else + warnings.Bind(theProfileA, warnings_per_profileA); + + if (warnings.IsBound(theProfileB)) + { + QSet& warnings_per_profileB_old = warnings.ChangeFind(theProfileB); + warnings_per_profileB_old+=warnings_per_profileB; + } + else + warnings.Bind(theProfileB, warnings_per_profileB); + // + + if (ToEstimateWarningsOnly) + return std::vector(); std::vector mid, wid; Interpolate( midA, midB, theNbSteps, mid, isAddSecond ); @@ -895,7 +1075,9 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate AltitudePoints& theLeft, AltitudePoints& theRight, std::vector& theMainProfiles, - std::set& invalInd) + std::set& invalInd, + NCollection_DataMap>& warnings, + bool ToEstimateWarningsOnly) { AltitudePoints points; size_t n = theProfiles.size(); @@ -903,24 +1085,43 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate return points; std::vector distances; - Handle(Geom2d_BSplineCurve) aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances ); - if( aHydraulicAxis.IsNull() ) - return points; + Handle(Geom2d_BSplineCurve) aHydraulicAxis; + + if (!ToEstimateWarningsOnly) + { + aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances ); + if( aHydraulicAxis.IsNull() ) + return points; + } theMainProfiles.reserve( n ); for( size_t i=0, n1=n-1; i local_points = Interpolate( aHydraulicAxis, theProfiles[i], distances[i], - theProfiles[i+1], distances[i+1], theDDZ, aNbSteps, isAddSecond, inter_nb_1, inter_nb_2 ); + std::vector local_points = Interpolate( aHydraulicAxis, theProfiles[i], + ToEstimateWarningsOnly ? 0 : distances[i], + theProfiles[i+1], + ToEstimateWarningsOnly ? 0 : distances[i+1], + theDDZ, aNbSteps, isAddSecond, inter_nb_1, inter_nb_2, warnings, + ToEstimateWarningsOnly); int lps = local_points.size(); + if (lps == 0) + continue; + if (inter_nb_1 > 2) invalInd.insert(i); @@ -985,3 +1186,8 @@ int HYDROData_DTM::EstimateNbPoints( const std::vector>& warnings) +{ + warnings = myWarnings; +} diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h index 59d3cd68..d564d56c 100644 --- a/src/HYDROData/HYDROData_DTM.h +++ b/src/HYDROData/HYDROData_DTM.h @@ -34,6 +34,7 @@ #include #include +#include class gp_Pnt; class gp_Vec2d; @@ -133,7 +134,8 @@ protected: CurveUZ& theMidPointCurve, CurveUZ& theWidthCurve, int& intersection_nb, - double theTolerance = 1E-6 ); + double theTolerance, + QSet& warnings); static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis, const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve, @@ -141,7 +143,7 @@ protected: static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, int theNbSteps, std::vector& theInterpolation, - bool isAddSecond ); + bool isAddSecond); static std::vector Interpolate ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis, @@ -150,14 +152,18 @@ protected: const Handle(HYDROData_Profile)& theProfileB, double theXCurvB, double theDDZ, int theNbSteps, bool isAddSecond, - int& inter_nb_1, int& inter_nb_2 ); + int& inter_nb_1, int& inter_nb_2, + NCollection_DataMap>& warnings, + bool ToEstimateWarningsOnly); static AltitudePoints Interpolate( const std::vector& theProfiles, double theDDZ, double theSpatialStep, AltitudePoints& theLeft, AltitudePoints& theRight, std::vector& theMainProfiles, - std::set& invalInd ); + std::set& invalInd, + NCollection_DataMap>& warnings, + bool ToEstimateWarningsOnly); static void PointsToWire(const AltitudePoints& pnts, TopoDS_Wire& W ); @@ -189,7 +195,9 @@ protected: bool Create3dPres, bool Create2dPres, std::set& InvInd, - bool& ProjStat); + bool& ProjStat, + NCollection_DataMap>& warnings, + bool ToEstimateWarningsOnly); //static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF, //TopTools_SequenceOfShape* Boundr = NULL, std::set ind = std::set() ); @@ -219,7 +227,14 @@ public: bool Create2dPres, std::set& InvInd, int thePntsLimit, - bool& WireIntersections); + bool& WireIntersections, + NCollection_DataMap>& warnings, + bool& ToEstimateWarnings); + + HYDRODATA_EXPORT void GetWarnings(NCollection_DataMap>& warnings); + + protected: + NCollection_DataMap> myWarnings; }; diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 4b8e639a..2cf71165 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -170,6 +170,11 @@ Handle(Geom_BSplineCurve) HYDROData_Stream::buildInterpolationCurve( return aBSpline; } +void HYDROData_Stream::GetWarnings(NCollection_DataMap>& warnings) +{ + warnings = myWarnings; +} + void HYDROData_Stream::Update() { if (!GetHydraulicAxis().IsNull()) @@ -191,6 +196,9 @@ void HYDROData_Stream::Update() dtm->Update(); UpdatePrs( dtm ); + myWarnings.Clear(); + dtm->GetWarnings(myWarnings); + HYDROData_NaturalObject::Update(); } diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 902ad5a0..b297484d 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -27,6 +27,8 @@ #include #include +#include +#include class HYDROData_DTM; class HYDROData_PolylineXY; @@ -262,6 +264,9 @@ public: HYDRODATA_EXPORT double GetSpatialStep() const; HYDRODATA_EXPORT void SetSpatialStep( double theSpatialStep ); + + HYDRODATA_EXPORT void GetWarnings(NCollection_DataMap>& warnings); + protected: @@ -318,6 +323,9 @@ protected: * Destructs properties of the object and object itself, removes it from the document. */ virtual HYDRODATA_EXPORT ~HYDROData_Stream(); + +protected: + NCollection_DataMap> myWarnings; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx b/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx index f66e8009..fe1cdce1 100644 --- a/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx +++ b/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx @@ -154,6 +154,28 @@ void HYDROGUI_OrderedListWidget::setBackgroundColor (int theInd, QColor theColor } } +void HYDROGUI_OrderedListWidget::setBackgroundColor (QString theName, QColor theColor) +{ + HYDROGUI_ListModel* aModel = getSourceModel(); + if (aModel) + { + QList anObjects = aModel->getObjects(); + int ind = -1; + int cur_ind = 0; + foreach (Handle(HYDROData_Entity) ent, anObjects) + { + if (ent->GetName() == theName) + { + ind = cur_ind; + break; + } + cur_ind++; + } + if (ind != -1) + aModel->setBackgroundColor( ind, theColor ); + } +} + void HYDROGUI_OrderedListWidget::clearAllBackgroundColors () { HYDROGUI_ListModel* aModel = getSourceModel(); diff --git a/src/HYDROGUI/HYDROGUI_OrderedListWidget.h b/src/HYDROGUI/HYDROGUI_OrderedListWidget.h index fd272a29..109ed716 100644 --- a/src/HYDROGUI/HYDROGUI_OrderedListWidget.h +++ b/src/HYDROGUI/HYDROGUI_OrderedListWidget.h @@ -59,6 +59,8 @@ public: QStringList getAllNames() const; void setBackgroundColor (int theInd, QColor theColor); + void setBackgroundColor (QString theName, QColor theColor); + QColor getBackgroundColor (int theInd) const; void clearAllBackgroundColors (); diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx index a07c5fe7..3a06ca02 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx @@ -262,6 +262,11 @@ void HYDROGUI_StreamDlg::setBackgroundColorForProfileList (int theInd, QColor th myProfiles->setBackgroundColor(theInd, theColor); } +void HYDROGUI_StreamDlg::setBackgroundColorForProfileList (QString name, QColor theColor) +{ + myProfiles->setBackgroundColor(name, theColor); +} + QColor HYDROGUI_StreamDlg::getBackgroundColorForProfileList (int theInd) const { return myProfiles->getBackgroundColor(theInd); diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.h b/src/HYDROGUI/HYDROGUI_StreamDlg.h index 3d49be1b..adb087bf 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.h +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.h @@ -60,9 +60,10 @@ public: void addWarning( const QString& theWarnMess ); void clearWarnings(); - void setBackgroundColorForProfileList (int theInd, QColor theColor); - QColor getBackgroundColorForProfileList (int theInd) const; - void clearAllBackgroundColorsForProfileList (); + void setBackgroundColorForProfileList (int theInd, QColor theColor); + void setBackgroundColorForProfileList (QString name, QColor theColor); + QColor getBackgroundColorForProfileList (int theInd) const; + void clearAllBackgroundColorsForProfileList (); signals: void AddProfiles(); diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 89f44d99..87322f42 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -54,6 +54,7 @@ #include #include #include +#include void insertProfileInToOrder( const QString& theProfileName, const double& theProfilePar, @@ -319,7 +320,26 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, myEditedObject->SetSpatialStep( aPanel->getSpatialStep() ); if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) + { myEditedObject->Update(); + NCollection_DataMap> warnings; + myEditedObject->GetWarnings(warnings); + QString totalWarning; + //for (NCollection_DataMap>::Iterator it(warnings); it.More(); it.Next()) + //{ + // const QSet& V = it.Value(); + // if (V.empty()) + // continue; + // const Handle(HYDROData_Profile)& K = it.Key(); + // QString ProfName = K->GetName(); + // foreach (QString str, V) + // { + // totalWarning + "Profile: " + ProfName + ": " + str + "\n"; + // } + //} + //if (totalWarning != "") + // SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "WARNING" ), totalWarning); + } if ( !myIsEdit ) { @@ -421,12 +441,14 @@ void HYDROGUI_StreamOp::createPreview() HYDROData_Bathymetry::AltitudePoints points; bool ProjStat = true; + NCollection_DataMap> warnings; + bool ToEstimateWarnings = false; HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, - OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, ProjStat ); + OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, ProjStat, warnings, ToEstimateWarnings ); aPanel->clearAllBackgroundColorsForProfileList(); - for (std::set::const_iterator it = InvInd.begin(); it != InvInd.end(); it++) - aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow)); + // for (std::set::const_iterator it = InvInd.begin(); it != InvInd.end(); it++) + // aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow)); aPrsDef.myInlet = OutInlet; aPrsDef.myOutlet = OutOutlet; @@ -436,9 +458,25 @@ void HYDROGUI_StreamOp::createPreview() aPrsDef.myPrs2D = Out2dPres; aPrsDef.myPrs3D = Out3dPres; + aPanel->clearWarnings(); if (!ProjStat) aPanel->addWarning(tr("STREAM_PROJECTION_FAILED")); + for (NCollection_DataMap>::Iterator it(warnings); it.More(); it.Next()) + { + const QSet& V = it.Value(); + if (V.empty()) + continue; + const Handle(HYDROData_Profile)& K = it.Key(); + QString ProfName = K->GetName(); + foreach (QString str, V) + { + aPanel->addWarning("Profile: " + ProfName + ": " + str); + } + + aPanel->setBackgroundColorForProfileList(ProfName, QColor(Qt::yellow)); + } + myPreviewPrs->setShape( aPrsDef.myPrs2D ); } diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx index 51de524a..48a47069 100644 --- a/src/HYDRO_tests/test_HYDROData_DTM.cxx +++ b/src/HYDRO_tests/test_HYDROData_DTM.cxx @@ -38,6 +38,8 @@ #include #include #include +#include +#include const double EPS = 1E-3; @@ -342,7 +344,8 @@ void test_HYDROData_DTM::test_profile_discretization_polyline() HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 ); int dummy = 0; - HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy ); + QSet warnings; + HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings ); CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].U, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS ); @@ -380,7 +383,8 @@ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 ); int dummy = 0 ; - HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy ); + QSet warnings; + HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings ); CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.242, aMid[0].U, EPS ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS ); -- 2.39.2