Salome HOME
lot 10 - warnings for DTM - untested
authorisn <isn@opencascade.com>
Thu, 31 Jan 2019 16:21:36 +0000 (19:21 +0300)
committerisn <isn@opencascade.com>
Fri, 1 Feb 2019 16:53:50 +0000 (19:53 +0300)
src/HYDROData/HYDROData_DTM.cxx
src/HYDROData/HYDROData_DTM.h
src/HYDROData/HYDROData_Stream.cxx
src/HYDROData/HYDROData_Stream.h
src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx
src/HYDROGUI/HYDROGUI_OrderedListWidget.h
src/HYDROGUI/HYDROGUI_StreamDlg.cxx
src/HYDROGUI/HYDROGUI_StreamDlg.h
src/HYDROGUI/HYDROGUI_StreamOp.cxx
src/HYDRO_tests/test_HYDROData_DTM.cxx

index 207530f8df59e3a0c37bc80081e3315a3197bbcc..84951093fb07c6b0d2788249019ba87eabdedab7 100644 (file)
@@ -30,6 +30,7 @@
 #include <GCPnts_AbscissaPoint.hxx>
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <limits>
+#include <Bnd_Box2d.hxx>
 
 #include <BRepLib_MakeEdge.hxx>
 #include <BRepLib_MakeWire.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_SequenceOfShape.hxx>
 #include <assert.h>
+#include <NCollection_DataMap.hxx>
+#include <QSet>
+#include <QString>
 #include <float.h>
 
+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<int> 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<int>& InvInd,
                                            int thePntsLimit,
-                                           bool& WireIntersections)
+                                           bool& WireIntersections, 
+                                           NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& 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<AltitudePoints> 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<Handle(HYDROData_Profile)>&
                                    bool Create3dPres,
                                    bool Create2dPres,
                                    std::set<int>& InvInd,
-                                   bool& ProjStat)
+                                   bool& ProjStat,
+                                   NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& 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<Handle(Geom2d_Curve)> HYDROData_DTM::ProfileToParametric(
 }
 
 
-bool CalcMidWidth( const std::set<double>& intersections, double& theMid, double& theWid )
+//bool CalcMidWidth( const std::set<double>& intersections, double& theMid, double& theWid )
+//{
+//  double umin = std::numeric_limits<double>::max(),
+//         umax = -umin;
+//
+//  size_t n = intersections.size();
+//  if( n <= 0 )
+//    return false;
+//
+//  std::set<double>::const_iterator it = intersections.begin(), last = intersections.end();
+//  for( ; it!=last; it++ )
+//  {
+//    double u = *it;
+//    if( u<umin )
+//      umin = u;
+//    if( u>umax )
+//      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<double>::const_iterator it = intersections.begin(), last = intersections.end();
-  for( ; it!=last; it++ )
-  {
-    double u = *it;
-    if( u<umin )
-      umin = u;
-    if( u>umax )
-      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<QString>& warnings)
 {
-  double aDblMax = DBL_MAX,
+  warnings.clear();
+  double aDblMax = std::numeric_limits<double>::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<gp_Pnt2d> 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<gp_Pnt2d> interm_intersections;
+    for (int i=0;i<intersections.size();i++)
+    {
+      gp_Pnt2d int_p2d = intersections[i];
+      //check for intermid. points: shoudl be higher than ZminExtr and not in intersection with first,last points
+      if (aFirst.Distance(int_p2d) > 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<gp_Pnt2d> 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<double> 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_Bathymetry::AltitudePoints> 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<Handle(HYDROData_Profile), QSet<QString>>& warnings,
+    bool ToEstimateWarningsOnly)
 {
   double zminA, zmaxA, zminB, zmaxB;
   gp_Pnt lowestA, lowestB;
@@ -868,8 +1023,33 @@ std::vector<HYDROData_Bathymetry::AltitudePoints> 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<QString> 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<QString>& 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<QString>& 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<AltitudePoints>();
 
   std::vector<CurveUZ> mid, wid;
   Interpolate( midA, midB, theNbSteps, mid, isAddSecond );
@@ -895,7 +1075,9 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
     AltitudePoints& theLeft,
     AltitudePoints& theRight,
     std::vector<AltitudePoints>& theMainProfiles,
-    std::set<int>& invalInd)
+    std::set<int>& invalInd,
+    NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
+    bool ToEstimateWarningsOnly)
 {
   AltitudePoints points;
   size_t n = theProfiles.size();
@@ -903,24 +1085,43 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
     return points;
 
   std::vector<double> 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<n1; i++ )
   {
-    double aDistance = distances[i+1]-distances[i];
-    int aNbSteps = int(aDistance/theSpatialStep);
-    bool isAddSecond = i==n1-1;
+    double aDistance = 0;
+    int aNbSteps = -1;
+    bool isAddSecond = false;
+  
+    if (!ToEstimateWarningsOnly)
+    {
+      aDistance = distances[i+1]-distances[i];
+      aNbSteps = int(aDistance/theSpatialStep);
+      isAddSecond = i==n1-1;
+    }
 
     // 1. Calculate interpolated profiles
     int inter_nb_1, inter_nb_2;
-    std::vector<AltitudePoints> 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<AltitudePoints> 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<Handle(HYDROData_Profile)
 
   return aNbSteps * aNbZSteps;
 }
+
+void HYDROData_DTM::GetWarnings(NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings)
+{
+  warnings = myWarnings;
+}
index 59d3cd6811e8a7f60c67620e63f6512661e8cc50..d564d56c6728771cca43caaad7fdc0268ca6d791 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <vector>
 #include <set>
+#include <NCollection_DataMap.hxx>
 
 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<QString>& 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<CurveUZ>& theInterpolation,
-                           bool isAddSecond );
+                           bool isAddSecond);
 
   static std::vector<AltitudePoints> 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<Handle(HYDROData_Profile), QSet<QString>>& warnings,
+      bool ToEstimateWarningsOnly);
 
   static AltitudePoints Interpolate( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
                                      double theDDZ, double theSpatialStep,
                                      AltitudePoints& theLeft,
                                      AltitudePoints& theRight,
                                      std::vector<AltitudePoints>& theMainProfiles,
-                                     std::set<int>& invalInd );
+                                     std::set<int>& invalInd, 
+                                     NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
+                                     bool ToEstimateWarningsOnly);
 
   static void PointsToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
 
@@ -189,7 +195,9 @@ protected:
                              bool Create3dPres,
                              bool Create2dPres,
                              std::set<int>& InvInd,
-                             bool& ProjStat);
+                             bool& ProjStat,
+                             NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
+                             bool ToEstimateWarningsOnly);
 
   //static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF, 
     //TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
@@ -219,7 +227,14 @@ public:
                                                        bool Create2dPres,
                                                        std::set<int>& InvInd,
                                                        int thePntsLimit,
-                                                       bool& WireIntersections);
+                                                       bool& WireIntersections,
+                                                       NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings,
+                                                       bool& ToEstimateWarnings);
+
+  HYDRODATA_EXPORT void GetWarnings(NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings);
+
+  protected:
+    NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>> myWarnings;
 };
 
 
index 4b8e639a92708cc482e6eb376fe1e6ee6e29f3ae..2cf711653065978c1d331327b8b2a39ffb4761a1 100644 (file)
@@ -170,6 +170,11 @@ Handle(Geom_BSplineCurve) HYDROData_Stream::buildInterpolationCurve(
   return aBSpline; 
 }
 
+void HYDROData_Stream::GetWarnings(NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& 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();
 }
 
index 902ad5a0c9d46f886dbc0a58411c4be3b3e0fd90..b297484dc1ed068dd8fbd7e9f1473c7ef447507f 100644 (file)
@@ -27,6 +27,8 @@
 
 #include <Geom_BSplineCurve.hxx>
 #include <vector>
+#include <NCollection_DataMap.hxx>
+#include <QSet>
 
 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<Handle(HYDROData_Profile), QSet<QString>>& 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<Handle(HYDROData_Profile), QSet<QString>> myWarnings;
 };
 
 #endif
index f66e800965f70d7cf2517966f758516788441425..fe1cdce1dee59fee995ad9f55087b285b37a00b7 100644 (file)
@@ -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<Handle(HYDROData_Entity)> 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();
index fd272a293cc78dcab427162c85ec2e5956e4f3c1..109ed716bb28ef5931704db9805c1857963857e0 100644 (file)
@@ -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 ();
 
index a07c5fe7e79b5e5a178bfead856e8a6a2bf7e62c..3a06ca02ff602e90f09c2eac493cea74ba439fe5 100644 (file)
@@ -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);
index 3d49be1befa6c561d42b612297ed7c5551285c06..adb087bf2ead55c13fd87481bc68d42bc83f45f1 100644 (file)
@@ -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();
index 89f44d9997b97399b97559e2d379a1deb63634f7..87322f42e8db506ad01e820a1390d49dde571c3c 100755 (executable)
@@ -54,6 +54,7 @@
 #include <TopoDS_Face.hxx>
 #include <TopoDS.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
+#include <QSet>
 
 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<Handle(HYDROData_Profile), QSet<QString>> warnings;
+    myEditedObject->GetWarnings(warnings);
+    QString totalWarning;
+   //for (NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>::Iterator it(warnings); it.More(); it.Next())
+   //{
+   //  const QSet<QString>& 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<Handle(HYDROData_Profile), QSet<QString>> 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<int>::const_iterator it = InvInd.begin(); it != InvInd.end(); it++)
-    aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow));
// for (std::set<int>::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<Handle(HYDROData_Profile), QSet<QString>>::Iterator it(warnings); it.More(); it.Next())
+  {
+    const QSet<QString>& 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 );
 }
 
index 51de524a2aee4101d9c1956ba8114258b7917569..48a470691ea6d6f25058ff9a37caab63f9454b58 100644 (file)
@@ -38,6 +38,8 @@
 #include <QPixmap>
 #include <QApplication>
 #include <QTest>
+#include <QSet>
+#include <QString>
 
 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<QString> 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<QString> 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 );