]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
patch for the crash in DTM creation
authorasl <asl@opencascade.com>
Tue, 22 Nov 2016 12:42:52 +0000 (15:42 +0300)
committerasl <asl@opencascade.com>
Tue, 22 Nov 2016 12:42:52 +0000 (15:42 +0300)
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROData/HYDROData_DTM.cxx

index 1bdb97f913b53eb5453a29c7d66c4ec36fa0d713..f0a871a30983d5e36769ddea4ba8a80eaac19ac9 100644 (file)
@@ -71,6 +71,24 @@ std::map<int, HYDROData_QuadtreeNode*> HYDROData_Bathymetry::myQuadtrees;
 std::map<int, vtkPolyData*> HYDROData_Bathymetry::myDelaunay2D;
 #endif
 
+inline double sqr( double x )
+{
+  return x*x;
+}
+
+HYDROData_Bathymetry::AltitudePoint::AltitudePoint( double x, double y, double z )
+{
+  X=x; Y=y; Z=z;
+}
+
+double HYDROData_Bathymetry::AltitudePoint::SquareDistance( const HYDROData_Bathymetry::AltitudePoint& p ) const
+{
+  double d = 0;
+  d += sqr( X - p.X );
+  d += sqr( Y - p.Y );
+  d += sqr( Z - p.Z );
+  return d;
+}
 
 HYDROData_Bathymetry::HYDROData_Bathymetry()
 : HYDROData_IAltitudeObject()
index 3797f19586eee6ace4c51b6fd59a6e90f985a371..8a0d8504aa2b07546d355556f0bd56ef973d7522 100644 (file)
@@ -41,12 +41,14 @@ DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
 class HYDROData_Bathymetry : public HYDROData_IAltitudeObject
 {
 public:
-  struct AltitudePoint
+  struct HYDRODATA_EXPORT AltitudePoint
   {
-    AltitudePoint( double x=0, double y=0, double z=0 ) { X=x; Y=y; Z=z; }
+    AltitudePoint( double x=0, double y=0, double z=0 );
     double X;
     double Y;
     double Z;
+
+    double SquareDistance( const AltitudePoint& ) const;
   };
   typedef std::vector<AltitudePoint> AltitudePoints;
 
index 96475a1bee1c9034af72fc1b4cd8100e9cd41a51..13861a4b6d9bffbe4ebc1e2736bcf3f1f794e84b 100644 (file)
@@ -53,7 +53,6 @@
 IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
 IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
 
-
 HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir, double theDeltaZ )
   : myXcurv( theXCurv ), myProfileDir( theProfileDir ), myDeltaZ( theDeltaZ )
 {
@@ -738,9 +737,11 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi
   }
 
   thePoints.reserve( sorted_points.size() );
+  const double EPS = 1E-12;
   std::map<double, AltitudePoint>::const_iterator it = sorted_points.begin(), last = sorted_points.end();
   for( ; it!=last; it++ )
-    thePoints.push_back( it->second );
+    if( thePoints.empty() || thePoints.back().SquareDistance( it->second ) > EPS )
+      thePoints.push_back( it->second );
 }
 
 inline double max( double a, double b )