X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROCurveCreator%2FCurveCreator_Profile.cxx;h=bcfc8fb0f816e884bc5ab8e63daa6fd24a4b7228;hb=09d10e66ba0fac5353c8d1f138055fc6fe86fb65;hp=0c11fc18e92643cfa9401a7717ed1c52fe2022ea;hpb=8a464e12ecf0be7b04e99307b7adb2207b470cb5;p=modules%2Fhydro.git diff --git a/src/HYDROCurveCreator/CurveCreator_Profile.cxx b/src/HYDROCurveCreator/CurveCreator_Profile.cxx index 0c11fc18..bcfc8fb0 100644 --- a/src/HYDROCurveCreator/CurveCreator_Profile.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Profile.cxx @@ -24,9 +24,6 @@ #include "CurveCreator_Section.hxx" #include "CurveCreator_Displayer.h" -#include -#include -#include #include #include #include @@ -71,22 +68,22 @@ bool CurveCreator_Profile::clearInternal() { // erase curve from the viewer if( myDisplayer ) - myDisplayer->erase( true ); + myDisplayer->eraseAll( true ); // Delete all allocated data. - mySections[ 0 ]->myPoints.clear(); + CurveCreator_Section* aSection = getSection( 0 ); + if ( aSection ) + aSection->myPoints.clear(); return true; } -bool CurveCreator_Profile::joinInternal( const int theISectionTo, - const int theISectionFrom ) +bool CurveCreator_Profile::joinInternal( const std::list& theSections ) { return false; } -bool CurveCreator_Profile::join( const int theISectionTo, - const int theISectionFrom ) +bool CurveCreator_Profile::join( const std::list& theSections ) { return false; } @@ -136,23 +133,11 @@ bool CurveCreator_Profile::setClosed( const int theISection, return false; } -bool CurveCreator_Profile::setSectionTypeInternal( const int theISection, - const CurveCreator::SectionType theType ) -{ - return false; -} - -bool CurveCreator_Profile::setSectionType( const int theISection, - const CurveCreator::SectionType theType ) -{ - return false; -} - bool CurveCreator_Profile::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap ) { bool res = false; - CurveCreator_Section* aSection = mySections.at( 0 ); + CurveCreator_Section* aSection = getSection( 0 ); if( !aSection ) return res; @@ -182,7 +167,7 @@ bool CurveCreator_Profile::addPointsInternal( const CurveCreator::SectionsMap &t if ( !aSection->myPoints.empty() ) aC = *(aSection->myPoints.end() - 2); - if ( aSection->myPoints.empty() || aCoordU > aC ) + if ( aSection->myPoints.empty() || aCoordU >= aC ) { aSection->myPoints.push_back( aCoordU ); aSection->myPoints.push_back( aCoordZ ); @@ -219,34 +204,77 @@ bool CurveCreator_Profile::addPointsInternal( const CurveCreator::SectionsMap &t //! For internal use only! Undo/Redo are not used here. bool CurveCreator_Profile::setPointInternal( const CurveCreator::SectionsMap &theSectionsMap ) { - bool res = false; + bool aRes = false; + + if ( mySkipSorting ) { + return CurveCreator_Curve::setPointInternal( theSectionsMap ); + } - CurveCreator_Section* aSection = mySections.at( 0 ); + int anISection = 0; + CurveCreator_Section* aSection = getSection( anISection ); if( !aSection ) - return res; + return aRes; CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin(); - for ( ; anIt != theSectionsMap.end(); anIt++ ) - { - int anISection = anIt->first; - if( anISection != 0 ) - continue; + if ( anIt == theSectionsMap.end() ) + return aRes; - const CurveCreator::PosPointsList& aSectionPoints = anIt->second; - - CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin(); - for( ; aPntIt != aSectionPoints.end(); aPntIt++ ) - { - int anIPnt = (*aPntIt)->myID; - aSection->myPoints.erase( aSection->myPoints.begin() + toICoord( anIPnt ), - aSection->myPoints.begin() + toICoord( anIPnt ) + 2 ); - } - } + const CurveCreator::PosPointsList& aSectionPoints = anIt->second; - res = addPointsInternal( theSectionsMap ); + std::list aConvPoints; + convert( aSectionPoints, aConvPoints ); + removeSectionPoints( anISection, aConvPoints ); - if ( res ) + aRes = addPointsInternal( theSectionsMap ); + if ( aRes ) redisplayCurve(); - return res; + return aRes; +} + +void CurveCreator_Profile::convert( const CurveCreator::PosPointsList& thePoints, + std::list& theConvPoints ) +{ + theConvPoints.clear(); + + CurveCreator::PosPointsList::const_iterator aPntIt = thePoints.begin(), + aPntLast = thePoints.end(); + for( ; aPntIt != aPntLast; aPntIt++ ) + { + int anIPnt = (*aPntIt)->myID; + theConvPoints.push_back( anIPnt ); + } +} + +bool CurveCreator_Profile::canPointsBeSorted() +{ + return true; } + +/** + * Add one point to the specified section starting from the given theIPnt index + * (or at the end of points if \a theIPnt is -1). + */ +bool CurveCreator_Profile::addPoints( const CurveCreator::Coordinates& theCoords, + const int theISection, + const int theIPnt ) +{ + int anIPnt = theIPnt; + + if ( anIPnt == - 1 && theCoords.size() > 1 ) { + CurveCreator::Coordinates aCoords; + for ( int i = 0, aNb = getNbPoints( theISection ); i < aNb; i++ ) { + aCoords = getPoint( theISection, i ); + if ( aCoords.size() < 2 ) { + continue; + } + + if ( theCoords[0] < aCoords[0] ) { + anIPnt = i; + break; + } + } + } + + return CurveCreator_Curve::addPoints( theCoords, theISection, anIPnt ); +} \ No newline at end of file