1 // Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: CurveCreator_Curve.cxx
21 // Author: Sergey KHROMOV
23 #include "CurveCreator_Curve.hxx"
25 #include "CurveCreator.hxx"
26 #include "CurveCreator_PosPoint.hxx"
27 #include "CurveCreator_Section.hxx"
28 #include "CurveCreator_Displayer.hxx"
29 #include "CurveCreator_Utils.hxx"
31 #include <AIS_Shape.hxx>
32 #include <AIS_InteractiveObject.hxx>
33 #include <Geom_CartesianPoint.hxx>
36 #include <TopoDS_Edge.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Wire.hxx>
42 //=======================================================================
43 // function: Constructor
45 //=======================================================================
46 CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimension )
48 myDimension (theDimension),
59 //=======================================================================
60 // function: Destructor
62 //=======================================================================
63 CurveCreator_Curve::~CurveCreator_Curve()
65 // Delete all allocated data.
69 //=======================================================================
70 // function: getDimension
72 //=======================================================================
73 CurveCreator::Dimension CurveCreator_Curve::getDimension() const
78 //=======================================================================
79 // function: getUniqSectionName
80 // purpose: return unique section name
81 //=======================================================================
82 std::string CurveCreator_Curve::getUniqSectionName() const
84 CurveCreator_Section* aSection;
85 for( int i = 0 ; i < 1000000 ; i++ ){
87 sprintf( aBuffer, "Section_%d", i+1 );
88 std::string aName(aBuffer);
90 for( j = 0 ; j < mySections.size() ; j++ ){
91 aSection = (CurveCreator_Section*)getSection( j );
92 if ( aSection && aSection->myName == aName )
95 if( j == mySections.size() )
101 //=======================================================================
102 // function: setDisplayer
103 // purpose: set curve changes Displayer
104 //=======================================================================
105 void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer )
107 myDisplayer = theDisplayer;
110 //=======================================================================
111 // function: getDisplayer
112 // purpose: get curve changes Displayer
113 //=======================================================================
114 CurveCreator_Displayer* CurveCreator_Curve::getDisplayer()
119 //=======================================================================
120 // function: removeDisplayer
121 // purpose: remove the attached Displayer
122 //=======================================================================
123 void CurveCreator_Curve::removeDisplayer()
128 //=======================================================================
131 //=======================================================================
132 bool CurveCreator_Curve::addEmptyDiff()
134 bool isEnabled = false;
136 if (myUndoDepth != 0) {
137 // Forget all Redos after the current one.
140 myListDiffs.erase(myCurrenPos, myListDiffs.end());
143 if (myUndoDepth == -1 || myNbUndos < myUndoDepth) {
144 // Increase the number of undos.
147 // If there are too many differences, remove the first one.
148 myListDiffs.pop_front();
151 // Add new difference.
152 myListDiffs.push_back(CurveCreator_Diff());
153 myCurrenPos = myListDiffs.end();
160 void CurveCreator_Curve::startOperation()
165 void CurveCreator_Curve::finishOperation()
170 //=======================================================================
171 // function: toICoord
173 //=======================================================================
174 int CurveCreator_Curve::toICoord(const int theIPnt) const
176 return theIPnt * myDimension;
179 //=======================================================================
180 // function: setUndoDepth
182 //=======================================================================
183 void CurveCreator_Curve::setUndoDepth(const int theDepth)
186 // Reset all undo/redo data.
190 myCurrenPos = myListDiffs.end();
192 } else if (theDepth == -1) {
193 // There is nothing to do as the depth become unlimited.
195 } else if (theDepth > 0) {
196 // The new "real" depth is set.
197 if (theDepth < myNbRedos) {
198 // The new depth is less then number of redos. Remove the latest redos.
199 int aShift = (myNbRedos - theDepth);
200 ListDiff::iterator aFromPos = myListDiffs.end();
206 myListDiffs.erase(aFromPos, myListDiffs.end());
207 myNbRedos = theDepth;
210 if (theDepth < myNbUndos + myNbRedos) {
211 // The new depth is less then the total number of differences.
212 // Remove the first undos.
213 int aShift = (myNbUndos + myNbRedos - theDepth);
214 ListDiff::iterator aToPos = myListDiffs.begin();
220 myListDiffs.erase(myListDiffs.begin(), aToPos);
221 myNbUndos = theDepth - myNbRedos;
224 myUndoDepth = theDepth;
228 //=======================================================================
229 // function: getUndoDepth
231 //=======================================================================
232 int CurveCreator_Curve::getUndoDepth() const
237 void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
239 CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
243 if( getDimension() == CurveCreator::Dim3d ){
248 void CurveCreator_Curve::redisplayCurve()
251 myDisplayer->eraseAll( false );
254 myDisplayer->display( getAISObject( true ), true );
258 //! For internal use only! Undo/Redo are not used here.
259 bool CurveCreator_Curve::moveSectionInternal(const int theISection,
260 const int theNewIndex)
263 int aMovedSectionId = theISection >= 0 ? theISection : mySections.size()-1;
265 if (aMovedSectionId != theNewIndex) {
266 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( aMovedSectionId );
269 CurveCreator::Sections::iterator anIter = mySections.begin() + aMovedSectionId;
271 mySections.erase(anIter);
274 anIter = mySections.begin() + theNewIndex;
275 mySections.insert(anIter, aSection);
281 //=======================================================================
282 // function: moveSection
284 //=======================================================================
285 bool CurveCreator_Curve::moveSection(const int theISection,
286 const int theNewIndex)
289 // Set the difference.
291 if (addEmptyDiff()) {
292 myListDiffs.back().init(this, CurveCreator_Operation::MoveSection,
293 theISection, theNewIndex);
297 res = moveSectionInternal(theISection, theNewIndex);
302 /************ Implementation of INTERFACE methods ************/
304 /***********************************************/
305 /*** Undo/Redo methods ***/
306 /***********************************************/
308 //! Get number of available undo operations
309 int CurveCreator_Curve::getNbUndo() const
314 //! Undo previous operation
315 bool CurveCreator_Curve::undo()
322 myCurrenPos->applyUndo(this);
328 //! Get number of available redo operations
329 int CurveCreator_Curve::getNbRedo() const
334 //! Redo last previously "undone" operation
335 bool CurveCreator_Curve::redo()
339 myCurrenPos->applyRedo(this);
348 /***********************************************/
349 /*** Section methods ***/
350 /***********************************************/
351 //! For internal use only! Undo/Redo are not used here.
352 bool CurveCreator_Curve::clearInternal()
354 // erase curve from the viewer
356 myDisplayer->eraseAll( true );
359 // Delete all allocated data.
361 const int aNbSections = getNbSections();
363 CurveCreator_Section* aSection;
364 for (; i < aNbSections; i++) {
365 aSection = (CurveCreator_Section*)getSection( i );
375 //=======================================================================
378 //=======================================================================
379 bool CurveCreator_Curve::clear()
383 // Set the difference.
384 if (addEmptyDiff()) {
385 myListDiffs.back().init(this);
387 res = clearInternal();
392 //! For internal use only! Undo/Redo are not used here.
393 bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
396 if ( theSections.empty() )
399 int anISectionMain = theSections.front();
400 CurveCreator_Section* aSectionMain =
401 (CurveCreator_Section*)getSection( anISectionMain );
403 std::list <int> aSectionsToJoin = theSections;
404 aSectionsToJoin.erase( aSectionsToJoin.begin() ); // skip the main section
405 // it is important to sort and reverse the section ids in order to correctly remove them
406 aSectionsToJoin.sort();
407 aSectionsToJoin.reverse();
409 std::list<int>::const_iterator anIt = aSectionsToJoin.begin(), aLast = aSectionsToJoin.end();
410 CurveCreator_Section* aSection;
411 for (; anIt != aLast; anIt++) {
412 aSection = (CurveCreator_Section*)getSection( *anIt );
413 aSectionMain->myPoints.insert(aSectionMain->myPoints.end(), aSection->myPoints.begin(),
414 aSection->myPoints.end());
415 res = removeSectionInternal(*anIt);
424 bool CurveCreator_Curve::join( const std::list<int>& theSections )
428 if ( !theSections.empty() )
432 myListDiffs.back().init(this, CurveCreator_Operation::Join, theSections);
434 res = joinInternal( theSections );
441 //! Get number of sections
442 int CurveCreator_Curve::getNbSections() const
444 return mySections.size();
447 //! For internal use only! Undo/Redo are not used here.
448 int CurveCreator_Curve::addSectionInternal
449 (const std::string& theName, const CurveCreator::SectionType theType,
450 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
452 CurveCreator_Section *aSection = new CurveCreator_Section;
454 std::string aName = theName;
456 aName = getUniqSectionName();
458 aSection->myName = aName;
459 aSection->myType = theType;
460 aSection->myIsClosed = theIsClosed;
461 aSection->myPoints = thePoints;
462 mySections.push_back(aSection);
464 return mySections.size()-1;
467 //=======================================================================
468 // function: addSection
469 // purpose: adds an empty section
470 //=======================================================================
471 int CurveCreator_Curve::addSection
472 (const std::string& theName, const CurveCreator::SectionType theType,
473 const bool theIsClosed)
475 int resISection = -1;
476 // Set the difference.
478 CurveCreator::Coordinates aCoords; //empty list
479 if (addEmptyDiff()) {
480 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
481 theName, aCoords, theType, theIsClosed);
484 resISection = addSectionInternal(theName, theType, theIsClosed, aCoords);
489 //=======================================================================
490 // function: addSection
491 // purpose: adds a section with the given points
492 //=======================================================================
493 int CurveCreator_Curve::addSection
494 (const std::string& theName, const CurveCreator::SectionType theType,
495 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
497 int resISection = -1;
498 // Set the difference.
500 if (addEmptyDiff()) {
501 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
502 theName, thePoints, theType, theIsClosed);
505 resISection = addSectionInternal(theName, theType, theIsClosed, thePoints);
511 //! For internal use only! Undo/Redo are not used here.
512 bool CurveCreator_Curve::removeSectionInternal( const int theISection )
514 if (theISection == -1) {
515 delete mySections.back();
516 mySections.pop_back();
518 CurveCreator::Sections::iterator anIterRm = mySections.begin() + theISection;
521 mySections.erase(anIterRm);
527 //! Removes the given sections.
528 bool CurveCreator_Curve::removeSection( const int theISection )
531 // Set the difference.
534 myListDiffs.back().init(this, CurveCreator_Operation::RemoveSection, theISection);
536 res = removeSectionInternal( theISection );
543 * Get number of points in specified section or (the total number of points
544 * in Curve if theISection is equal to -1).
546 int CurveCreator_Curve::getNbPoints( const int theISection ) const
550 CurveCreator_Section* aSection;
551 if (theISection == -1) {
553 const int aNbSections = getNbSections();
555 for (; i < aNbSections; i++) {
556 aSection = (CurveCreator_Section*)getSection( i );
558 aNbCoords += aSection->myPoints.size();
561 aSection = (CurveCreator_Section*)getSection( theISection );
563 aNbCoords = aSection->myPoints.size();
566 return aNbCoords/myDimension;
569 void CurveCreator_Curve::setSkipSorting( const bool theIsToSkip )
571 mySkipSorting = theIsToSkip;
574 bool CurveCreator_Curve::canPointsBeSorted()
580 * Saves points coordinates difference.
581 * \param theOldCoords the old points coordinates
583 void CurveCreator_Curve::saveCoordDiff( const SectionToPointCoordsList &theOldCoords )
585 // Set the difference.
587 if (addEmptyDiff()) {
588 myListDiffs.back().init(this, theOldCoords);
593 //! Get "closed" flag of the specified section
594 bool CurveCreator_Curve::isClosed( const int theISection ) const
596 const CurveCreator_Section* aSection =
597 (CurveCreator_Section*)getSection( theISection );
598 return aSection ? aSection->myIsClosed : false;
601 //! For internal use only! Undo/Redo are not used here.
602 bool CurveCreator_Curve::setClosedInternal( const int theISection,
603 const bool theIsClosed )
605 CurveCreator_Section* aSection = 0;
606 if (theISection == -1) {
607 int aSize = mySections.size();
610 for (i = 0; i < aSize; i++) {
611 aSection = (CurveCreator_Section*)getSection( i );
613 aSection->myIsClosed = theIsClosed;
618 aSection = (CurveCreator_Section*)getSection( theISection );
620 aSection->myIsClosed = theIsClosed;
628 * Set "closed" flag of the specified section (all sections if
629 * \a theISection is -1).
631 bool CurveCreator_Curve::setClosed( const int theISection,
632 const bool theIsClosed )
635 // Set the difference.
637 if (addEmptyDiff()) {
638 myListDiffs.back().init(this, CurveCreator_Operation::SetClosed,
639 theIsClosed, theISection);
641 res = setClosedInternal( theISection, theIsClosed );
646 //! Returns specified section name
647 std::string CurveCreator_Curve::getSectionName( const int theISection ) const
649 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
650 return aSection ? aSection->myName : "";
653 //! For internal use only! Undo/Redo are not used here.
654 bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
655 const std::string& theName )
658 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
660 aSection->myName = theName;
666 /** Set name of the specified section */
667 bool CurveCreator_Curve::setSectionName( const int theISection,
668 const std::string& theName )
671 // Set the difference.
673 if (addEmptyDiff()) {
674 myListDiffs.back().init(this, CurveCreator_Operation::RenameSection,
675 theName, theISection);
677 res = setSectionNameInternal( theISection, theName );
682 //! Get type of the specified section
683 CurveCreator::SectionType CurveCreator_Curve::getSectionType
684 ( const int theISection ) const
686 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
687 return aSection ? aSection->myType : CurveCreator::Polyline;
690 //! For internal use only! Undo/Redo are not used here.
691 bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
692 const CurveCreator::SectionType theType )
694 CurveCreator_Section* aSection;
695 if (theISection == -1) {
697 const int aNbSections = getNbSections();
699 for (; i < aNbSections; i++) {
700 aSection = (CurveCreator_Section*)getSection( i );
702 aSection->myType = theType;
706 aSection = (CurveCreator_Section*)getSection( theISection );
707 if ( aSection && aSection->myType != theType ){
708 aSection->myType = theType;
716 * Set type of the specified section (or all sections
717 * if \a theISection is -1).
719 bool CurveCreator_Curve::setSectionType( const int theISection,
720 const CurveCreator::SectionType theType )
724 // Set the difference.
725 if (addEmptyDiff()) {
726 myListDiffs.back().init(this, CurveCreator_Operation::SetType,
727 theType, theISection);
730 res = setSectionTypeInternal( theISection, theType );
737 /***********************************************/
738 /*** Point methods ***/
739 /***********************************************/
741 //! For internal use only! Undo/Redo are not used here.
742 bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap )
745 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
746 CurveCreator_Section *aSection = 0;
747 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
748 int anISection = anIt->first;
749 aSection = (CurveCreator_Section*)getSection( anISection );
751 CurveCreator::PosPointsList aSectionPoints = anIt->second;
752 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
753 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
754 int anIPnt = (*aPntIt)->myID;
755 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
756 CurveCreator::Coordinates::iterator anIterPosition;
758 anIterPosition = aSection->myPoints.end();
760 anIterPosition = aSection->myPoints.begin() + toICoord(anIPnt);
761 CurveCreator::Coordinates::const_iterator aFirstPosition =
763 aSection->myPoints.insert(anIterPosition,
764 aCoords.begin(), aCoords.end());
775 * Add one point to the specified section starting from the given theIPnt index
776 * (or at the end of points if \a theIPnt is -1).
778 bool CurveCreator_Curve::addPoints( const CurveCreator::Coordinates& theCoords,
779 const int theISection,
783 CurveCreator::Coordinates aCoords = theCoords;
784 // Set the difference.
786 if (addEmptyDiff()) {
787 CurveCreator_ICurve::SectionToPointCoordsList aList;
788 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theCoords));
789 myListDiffs.back().init(this, CurveCreator_Operation::InsertPoints,
792 CurveCreator::SectionsMap aSectionsMap;
793 CurveCreator::PosPointsList aPoints;
794 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theCoords );
795 aPoints.push_back( aPosPoint );
796 aSectionsMap[theISection] = aPoints;
798 res = addPointsInternal( aSectionsMap );
804 //! For internal use only! Undo/Redo are not used here.
805 bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theSectionsMap )
809 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
810 CurveCreator_Section *aSection = 0;
811 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
812 int anISection = anIt->first;
813 aSection = (CurveCreator_Section*)getSection( anISection );
815 CurveCreator::PosPointsList aSectionPoints = anIt->second;
816 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
817 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
818 int anIPnt = (*aPntIt)->myID;
819 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
820 for ( int i = 0; i < myDimension; i++)
821 aSection->myPoints.at(toICoord(anIPnt) + i) = aCoords[i];
832 //! Set coordinates of specified point
833 bool CurveCreator_Curve::setPoint( const int theISection,
835 const CurveCreator::Coordinates& theNewCoords )
838 // Set the difference.
840 if (addEmptyDiff()) {
841 CurveCreator_ICurve::SectionToPointCoordsList aList;
842 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theNewCoords));
843 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
846 CurveCreator::SectionsMap aSectionsMap;
847 CurveCreator::PosPointsList aPoints;
848 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theNewCoords );
849 aPoints.push_back( aPosPoint );
850 aSectionsMap[theISection] = aPoints;
852 int aSize1 = getNbPoints( theISection );
853 res = setPointInternal( aSectionsMap );
854 int aSize2 = getNbPoints( theISection );
861 //! Set coordinates of specified points from different sections
862 bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
863 const bool theIsToSaveDiff )
866 // Set the difference.
868 if (theIsToSaveDiff && addEmptyDiff()) {
869 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
870 theSectionToPntCoords);
872 CurveCreator::SectionsMap aSectionsMap;
873 CurveCreator::PosPointsList aPosPoints;
874 CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
875 theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
876 int aSectionId, aPointId;
877 for ( ; anIt != aLast; anIt++ ) {
879 aSectionId = anIt->first.first;
880 aPointId = anIt->first.second;
881 CurveCreator::Coordinates aNewCoords = anIt->second;
882 CurveCreator_PosPoint* aPosPoint =
883 new CurveCreator_PosPoint( aPointId, aNewCoords );
884 if( aSectionsMap.find(aSectionId) != aSectionsMap.end() )
885 aPosPoints = aSectionsMap[aSectionId];
886 aPosPoints.push_back( aPosPoint );
887 aSectionsMap[aSectionId] = aPosPoints;
890 res = setPointInternal( aSectionsMap );
896 //! For internal use only! Undo/Redo are not used here.
897 bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoints )
900 std::map<int, std::list<int> > aConvPoints;
901 convert( thePoints, aConvPoints );
902 std::map<int, std::list<int> >::const_iterator anIt = aConvPoints.begin(),
903 aLast = aConvPoints.end();
904 for ( ; anIt != aLast; anIt++ ) {
905 int aSectionId = anIt->first;
906 aRes = removeSectionPoints(aSectionId, anIt->second);
914 //! Remove point with given id
915 bool CurveCreator_Curve::removePoint( const int theISection, const int theIPnt )
918 // Set the difference.
920 SectionToPointList aListOfSectionsToPoints;
921 aListOfSectionsToPoints.push_back(std::make_pair(theISection, theIPnt));
922 if (addEmptyDiff()) {
923 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
924 aListOfSectionsToPoints);
926 res = removePointsInternal( aListOfSectionsToPoints );
931 //! Remove several points from different sections with given ids
932 bool CurveCreator_Curve::removeSeveralPoints( const SectionToPointList &theSectionToPntIDs)
935 // Set the difference.
937 if (addEmptyDiff()) {
938 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
941 res = removePointsInternal( theSectionToPntIDs );
946 //=======================================================================
947 // function: getCoordinates
949 //=======================================================================
950 CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection,
951 const int theIPnt) const
953 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
954 CurveCreator::Coordinates::const_iterator
955 anIter = aSection->myPoints.begin() + toICoord(theIPnt);
956 CurveCreator::Coordinates aResult(anIter, anIter + myDimension);
961 //=======================================================================
962 // function: getPoints
964 //=======================================================================
965 CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
967 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
968 return aSection ? aSection->myPoints : CurveCreator::Coordinates();
971 void CurveCreator_Curve::constructAISObject()
974 CurveCreator_Utils::constructShape( this, aShape );
976 myAISShape = new AIS_Shape( aShape );
979 Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
981 if ( !myAISShape && theNeedToBuild ) {
982 CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
983 aCurve->constructAISObject();
988 bool CurveCreator_Curve::removeSectionPoints( const int theSectionId,
989 const std::list<int>& thePointIds )
993 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theSectionId );
997 std::list<int> aSectionPoints = thePointIds;
998 aSectionPoints.sort();
999 std::list<int>::const_reverse_iterator aPntIt = aSectionPoints.rbegin();
1000 for ( ; aPntIt != aSectionPoints.rend(); aPntIt++ ) {
1001 int aPntIndx = *aPntIt;
1002 CurveCreator::Coordinates::iterator aFirstPosition;
1003 if ( aPntIndx == -1 )
1004 aFirstPosition = aSection->myPoints.end() - getDimension();
1006 aFirstPosition = aSection->myPoints.begin() + toICoord( aPntIndx );
1007 aSection->myPoints.erase( aFirstPosition, aFirstPosition + getDimension() );
1013 void CurveCreator_Curve::convert( const SectionToPointList& thePoints,
1014 std::map< int, std::list<int> >& theConvPoints )
1016 theConvPoints.clear();
1018 SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end();
1019 std::list<int> aPoints;
1020 int aSectionId, aPointId;
1021 for ( ; anIt != aLast; anIt++ ) {
1022 aSectionId = anIt->first;
1023 aPointId = anIt->second;
1025 if ( theConvPoints.find( aSectionId ) != theConvPoints.end() )
1026 aPoints = theConvPoints[aSectionId];
1027 aPoints.push_back( aPointId );
1028 theConvPoints[aSectionId] = aPoints;