From: nds Date: Fri, 20 Dec 2013 03:40:49 +0000 (+0000) Subject: A fix for a problem with repeated in the table. X-Git-Tag: BR_hydro_v_0_6~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a669e7b51b24e2e6ba94412fc5efabec364cdecb;p=modules%2Fhydro.git A fix for a problem with repeated in the table. The problem study has two polylines(opened, spline-3points, polyline-2points). The polylines begin and end concur. --- diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.cxx b/src/HYDROCurveCreator/CurveCreator_Utils.cxx index f0ee1127..52911526 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Utils.cxx @@ -180,26 +180,27 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, theShape = aComp; } -class ComparePnt +class CompareSectionToPoint { public: - ComparePnt( const gp_Pnt& thePoint ) : myPoint( thePoint) {}; - ~ComparePnt() {} + CompareSectionToPoint( const int theISection = -1, const int theIPoint = -1 ) + : mySectionId( theISection ), myPointId( theIPoint ) {}; + ~CompareSectionToPoint() {} - bool operator < ( const ComparePnt& theOtherPoint ) const + bool operator < ( const CompareSectionToPoint& theOther ) const { - bool isLess = myPoint.X() < theOtherPoint.myPoint.X(); - if ( !isLess && myPoint.X() == theOtherPoint.myPoint.X() ) { - isLess = myPoint.Y() < theOtherPoint.myPoint.Y(); - if ( !isLess && myPoint.Y() == theOtherPoint.myPoint.Y() ) - isLess = myPoint.Z() < theOtherPoint.myPoint.Z(); - } + bool isLess = mySectionId < theOther.mySectionId; + if ( !isLess && mySectionId == theOther.mySectionId ) + isLess = myPointId < theOther.myPointId; return isLess; } + private: - gp_Pnt myPoint; + int mySectionId; + int myPointId; }; + void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext, const CurveCreator_ICurve* theCurve, CurveCreator_ICurve::SectionToPointList& thePoints ) @@ -208,7 +209,7 @@ void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theCo std::list aSelectedPoints; gp_Pnt aPnt; - std::map aPntMap; + std::map aPointsMap; CurveCreator_ICurve::SectionToPointList aPoints; for ( theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected() ) { @@ -220,15 +221,19 @@ void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theCo if ( aVertex.IsNull() ) continue; aPnt = BRep_Tool::Pnt( aVertex ); - if ( aPntMap.find( aPnt ) != aPntMap.end() ) - continue; - aPntMap[aPnt] = 0; CurveCreator_UtilsICurve::findSectionsToPoints( theCurve, aPnt.X(), aPnt.Y(), aPoints ); CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(), aLast = aPoints.end(); - for ( ; anIt != aLast; anIt++ ) + CompareSectionToPoint aPoint; + for ( ; anIt != aLast; anIt++ ) { + aPoint = CompareSectionToPoint( (*anIt).first, (*anIt).second ); + if ( aPointsMap.find( aPoint ) != aPointsMap.end() ) + continue; + aPointsMap[aPoint] = 0; + thePoints.push_back( *anIt ); + } } }