From: asl Date: Tue, 15 Nov 2016 06:19:28 +0000 (+0300) Subject: limitation of the points number in preview for DTM (stream) X-Git-Tag: v1.6~45 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ada2732bcf5c4b531a7d6dd2696883b188ae34a3;p=modules%2Fhydro.git limitation of the points number in preview for DTM (stream) --- diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 70428488..16f82e4c 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -202,7 +202,7 @@ void HYDROData_DTM::Update() double ddz = GetDDZ(); double step = GetSpatialStep(); std::set 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& InvInd) + std::set& 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 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& 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 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; +} diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h index 4835cef1..9d1cd477 100644 --- a/src/HYDROData/HYDROData_DTM.h +++ b/src/HYDROData/HYDROData_DTM.h @@ -177,7 +177,10 @@ protected: std::set& InvInd ); static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF ); - + + static int EstimateNbPoints( const std::vector& 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& InvInd ); + std::set& InvInd, + int thePntsLimit ); }; diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 95f49991..bceea8f7 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -357,10 +357,16 @@ void HYDROGUI_StreamOp::createPreview() double ss = aPanel->getSpatialStep(); std::set 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::const_iterator it = InvInd.begin(); it != InvInd.end(); it++)