]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
limitation of the points number in preview for DTM (stream)
authorasl <asl@opencascade.com>
Tue, 15 Nov 2016 06:19:28 +0000 (09:19 +0300)
committerasl <asl@opencascade.com>
Tue, 15 Nov 2016 06:19:28 +0000 (09:19 +0300)
src/HYDROData/HYDROData_DTM.cxx
src/HYDROData/HYDROData_DTM.h
src/HYDROGUI/HYDROGUI_StreamOp.cxx

index 704284887750be8b101ba2ed5503326b47de6e42..16f82e4c78d2bbcc2b49e3a902cf0f4cde674cd2 100644 (file)
@@ -202,7 +202,7 @@ void HYDROData_DTM::Update()
   double ddz = GetDDZ();
   double step = GetSpatialStep();
   std::set<int> InvInd;
-  CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd );
+  CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1 );
   SetAltitudePoints( points );  
 
   SetShape( DataTag_LeftBankShape, OutLeftB);
@@ -243,9 +243,9 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In
                                            TopoDS_Shape& OutOutlet,
                                            bool Create3dPres,
                                            bool Create2dPres,
-                                           std::set<int>& InvInd)
+                                           std::set<int>& InvInd,
+                                           int thePntsLimit )
 {
-
   int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper();
   size_t n = anUpper - aLower + 1;
 
@@ -262,6 +262,13 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In
   AltitudePoints right;
   std::vector<AltitudePoints> main_profiles;
 
+  if( thePntsLimit > 0 )
+  {
+    int aNbPoints = EstimateNbPoints( profiles, ddz, step );
+    if( aNbPoints < 0 || aNbPoints > thePntsLimit )
+      return;
+  }
+
   if( ddz>EPS && step>EPS )
     CreateProfiles(profiles, ddz, step, left, right, points, main_profiles, 
     Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd );
@@ -802,10 +809,10 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
       theProfiles[i+1], distances[i+1], theDDZ, aNbSteps, isAddSecond, inter_nb_1, inter_nb_2 );
     int lps = local_points.size();
 
-    if (inter_nb_1 >= 2)
+    if (inter_nb_1 > 2)
       invalInd.insert(i);
 
-    if (inter_nb_2 >= 2)
+    if (inter_nb_2 > 2)
       invalInd.insert(i+1);
 
     // 2. Put all points into the global container
@@ -838,3 +845,31 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
   }
   return points;
 }
+
+int HYDROData_DTM::EstimateNbPoints( const std::vector<Handle_HYDROData_Profile>& theProfiles,
+                                     double theDDZ, double theSpatialStep )
+{
+  size_t n = theProfiles.size();
+  if( n<=1 )
+    return 0;
+  if( theDDZ<1E-6 || theSpatialStep<1E-6 )
+    return 1 << 20;
+
+  std::vector<double> distances;
+  Handle_Geom2d_BSplineCurve aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances );
+  if( aHydraulicAxis.IsNull() )
+    return 0;
+
+  double aCompleteDistance = distances[n-1];
+  int aNbSteps = int( aCompleteDistance / theSpatialStep ) + 1;
+  gp_Pnt aLowest;
+  gp_Vec2d aDir;
+  double aZMin, aZMax;
+  GetProperties( theProfiles[0], aLowest, aDir, true, aZMin, aZMax );
+  int aNbZSteps = (aZMax-aZMin)/theDDZ;
+
+  if( aNbSteps > ( 1<<16 ) || aNbZSteps > ( 1<<16 ) )
+    return 1 << 20;
+
+  return aNbSteps * aNbZSteps;
+}
index 4835cef14578d30dc088a1b6ebe8acdbfca3a4d6..9d1cd477ccd397e4c0d98cb74bce33274449c8dc 100644 (file)
@@ -177,7 +177,10 @@ protected:
                              std::set<int>& InvInd );
 
   static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF );
-    
+  
+  static int EstimateNbPoints( const std::vector<Handle_HYDROData_Profile>& theProfiles,
+                               double theDDZ, double theSpatialStep );
+
   void GetPresentationShapes( TopoDS_Shape& Out3dPres,
                               TopoDS_Shape& Out2dPres,
                               TopoDS_Shape& OutLeftB,
@@ -198,7 +201,8 @@ public:
                                                        TopoDS_Shape& OutOutlet,
                                                        bool Create3dPres,
                                                        bool Create2dPres,
-                                                       std::set<int>& InvInd );
+                                                       std::set<int>& InvInd,
+                                                       int thePntsLimit );
 };
 
 
index 95f499919eb608e6dee0a6d517091ac0ff95bbe4..bceea8f7666b1c4d176981bb58ad0abfa9b3d9ec 100755 (executable)
@@ -357,10 +357,16 @@ void HYDROGUI_StreamOp::createPreview()
   double ss = aPanel->getSpatialStep();
 
   std::set<int> InvInd;
-    
+
+#ifdef _DEBUG
+  const int MAX_POINTS_IN_PREVIEW = 50000;
+#else
+  const int MAX_POINTS_IN_PREVIEW = 500000;
+#endif
+
   HYDROData_Bathymetry::AltitudePoints points;
   HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB,
-    OutInlet, OutOutlet, true, true, InvInd);
+    OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW );
 
   aPanel->clearAllBackgroundColorsForProfileList();
   for (std::set<int>::const_iterator it = InvInd.begin(); it != InvInd.end(); it++)