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>
40 #include <Prs3d_PointAspect.hxx>
41 #include <Handle_Prs3d_PointAspect.hxx>
43 #define DEBTRACE(msg) {std::cerr<<std::flush<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<std::endl<<std::flush;}
47 //=======================================================================
48 // function: Constructor
50 //=======================================================================
51 CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimension )
53 myDimension (theDimension),
64 //=======================================================================
65 // function: Destructor
67 //=======================================================================
68 CurveCreator_Curve::~CurveCreator_Curve()
70 // Delete all allocated data.
74 //=======================================================================
75 // function: getDimension
77 //=======================================================================
78 CurveCreator::Dimension CurveCreator_Curve::getDimension() const
83 //=======================================================================
84 // function: getUniqSectionName
85 // purpose: return unique section name
86 //=======================================================================
87 std::string CurveCreator_Curve::getUniqSectionName() const
89 CurveCreator_Section* aSection;
90 for( int i = 0 ; i < 1000000 ; i++ ){
92 sprintf( aBuffer, "Section_%d", i+1 );
93 std::string aName(aBuffer);
95 for( j = 0 ; j < mySections.size() ; j++ ){
96 aSection = (CurveCreator_Section*)getSection( j );
97 if ( aSection && aSection->myName == aName )
100 if( j == mySections.size() )
106 //=======================================================================
107 // function: setDisplayer
108 // purpose: set curve changes Displayer
109 //=======================================================================
110 void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer )
112 myDisplayer = theDisplayer;
115 //=======================================================================
116 // function: getDisplayer
117 // purpose: get curve changes Displayer
118 //=======================================================================
119 CurveCreator_Displayer* CurveCreator_Curve::getDisplayer()
124 //=======================================================================
125 // function: removeDisplayer
126 // purpose: remove the attached Displayer
127 //=======================================================================
128 void CurveCreator_Curve::removeDisplayer()
133 //=======================================================================
136 //=======================================================================
137 bool CurveCreator_Curve::addEmptyDiff()
139 bool isEnabled = false;
141 if (myUndoDepth != 0) {
142 // Forget all Redos after the current one.
145 myListDiffs.erase(myCurrenPos, myListDiffs.end());
148 if (myUndoDepth == -1 || myNbUndos < myUndoDepth) {
149 // Increase the number of undos.
152 // If there are too many differences, remove the first one.
153 myListDiffs.pop_front();
156 // Add new difference.
157 myListDiffs.push_back(CurveCreator_Diff());
158 myCurrenPos = myListDiffs.end();
165 void CurveCreator_Curve::startOperation()
170 void CurveCreator_Curve::finishOperation()
175 //=======================================================================
176 // function: toICoord
178 //=======================================================================
179 int CurveCreator_Curve::toICoord(const int theIPnt) const
181 return theIPnt * myDimension;
184 //=======================================================================
185 // function: setUndoDepth
187 //=======================================================================
188 void CurveCreator_Curve::setUndoDepth(const int theDepth)
191 // Reset all undo/redo data.
195 myCurrenPos = myListDiffs.end();
197 } else if (theDepth == -1) {
198 // There is nothing to do as the depth become unlimited.
200 } else if (theDepth > 0) {
201 // The new "real" depth is set.
202 if (theDepth < myNbRedos) {
203 // The new depth is less then number of redos. Remove the latest redos.
204 int aShift = (myNbRedos - theDepth);
205 ListDiff::iterator aFromPos = myListDiffs.end();
211 myListDiffs.erase(aFromPos, myListDiffs.end());
212 myNbRedos = theDepth;
215 if (theDepth < myNbUndos + myNbRedos) {
216 // The new depth is less then the total number of differences.
217 // Remove the first undos.
218 int aShift = (myNbUndos + myNbRedos - theDepth);
219 ListDiff::iterator aToPos = myListDiffs.begin();
225 myListDiffs.erase(myListDiffs.begin(), aToPos);
226 myNbUndos = theDepth - myNbRedos;
229 myUndoDepth = theDepth;
233 //=======================================================================
234 // function: getUndoDepth
236 //=======================================================================
237 int CurveCreator_Curve::getUndoDepth() const
242 void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
244 CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
248 if( getDimension() == CurveCreator::Dim3d ){
253 void CurveCreator_Curve::redisplayCurve()
255 //DEBTRACE("redisplayCurve");
257 myDisplayer->eraseAll( false );
260 myDisplayer->display( getAISObject( true ), true );
264 //! For internal use only! Undo/Redo are not used here.
265 bool CurveCreator_Curve::moveSectionInternal(const int theISection,
266 const int theNewIndex)
269 int aMovedSectionId = theISection >= 0 ? theISection : mySections.size()-1;
271 if (aMovedSectionId != theNewIndex) {
272 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( aMovedSectionId );
275 CurveCreator::Sections::iterator anIter = mySections.begin() + aMovedSectionId;
277 mySections.erase(anIter);
280 anIter = mySections.begin() + theNewIndex;
281 mySections.insert(anIter, aSection);
287 //=======================================================================
288 // function: moveSection
290 //=======================================================================
291 bool CurveCreator_Curve::moveSection(const int theISection,
292 const int theNewIndex)
295 // Set the difference.
297 if (addEmptyDiff()) {
298 myListDiffs.back().init(this, CurveCreator_Operation::MoveSection,
299 theISection, theNewIndex);
303 res = moveSectionInternal(theISection, theNewIndex);
308 /************ Implementation of INTERFACE methods ************/
310 /***********************************************/
311 /*** Undo/Redo methods ***/
312 /***********************************************/
314 //! Get number of available undo operations
315 int CurveCreator_Curve::getNbUndo() const
320 //! Undo previous operation
321 bool CurveCreator_Curve::undo()
328 myCurrenPos->applyUndo(this);
334 //! Get number of available redo operations
335 int CurveCreator_Curve::getNbRedo() const
340 //! Redo last previously "undone" operation
341 bool CurveCreator_Curve::redo()
345 myCurrenPos->applyRedo(this);
354 /***********************************************/
355 /*** Section methods ***/
356 /***********************************************/
357 //! For internal use only! Undo/Redo are not used here.
358 bool CurveCreator_Curve::clearInternal()
360 // erase curve from the viewer
362 myDisplayer->eraseAll( true );
365 // Delete all allocated data.
367 const int aNbSections = getNbSections();
369 CurveCreator_Section* aSection;
370 for (; i < aNbSections; i++) {
371 aSection = (CurveCreator_Section*)getSection( i );
381 //=======================================================================
384 //=======================================================================
385 bool CurveCreator_Curve::clear()
389 // Set the difference.
390 if (addEmptyDiff()) {
391 myListDiffs.back().init(this);
393 res = clearInternal();
398 //! For internal use only! Undo/Redo are not used here.
399 bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
402 if ( theSections.empty() )
405 int anISectionMain = theSections.front();
406 CurveCreator_Section* aSectionMain =
407 (CurveCreator_Section*)getSection( anISectionMain );
409 std::list <int> aSectionsToJoin = theSections;
410 aSectionsToJoin.erase( aSectionsToJoin.begin() ); // skip the main section
411 // it is important to sort and reverse the section ids in order to correctly remove them
412 aSectionsToJoin.sort();
413 aSectionsToJoin.reverse();
415 std::list<int>::const_iterator anIt = aSectionsToJoin.begin(), aLast = aSectionsToJoin.end();
416 CurveCreator_Section* aSection;
417 for (; anIt != aLast; anIt++) {
418 aSection = (CurveCreator_Section*)getSection( *anIt );
419 aSectionMain->myPoints.insert(aSectionMain->myPoints.end(), aSection->myPoints.begin(),
420 aSection->myPoints.end());
421 res = removeSectionInternal(*anIt);
430 bool CurveCreator_Curve::join( const std::list<int>& theSections )
434 if ( !theSections.empty() )
438 myListDiffs.back().init(this, CurveCreator_Operation::Join, theSections);
440 res = joinInternal( theSections );
447 //! Get number of sections
448 int CurveCreator_Curve::getNbSections() const
450 return mySections.size();
453 //! For internal use only! Undo/Redo are not used here.
454 int CurveCreator_Curve::addSectionInternal
455 (const std::string& theName, const CurveCreator::SectionType theType,
456 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
458 CurveCreator_Section *aSection = new CurveCreator_Section;
460 std::string aName = theName;
462 aName = getUniqSectionName();
464 aSection->myName = aName;
465 aSection->myType = theType;
466 aSection->myIsClosed = theIsClosed;
467 aSection->myPoints = thePoints;
468 mySections.push_back(aSection);
470 return mySections.size()-1;
473 //=======================================================================
474 // function: addSection
475 // purpose: adds an empty section
476 //=======================================================================
477 int CurveCreator_Curve::addSection
478 (const std::string& theName, const CurveCreator::SectionType theType,
479 const bool theIsClosed)
481 int resISection = -1;
482 // Set the difference.
484 CurveCreator::Coordinates aCoords; //empty list
485 if (addEmptyDiff()) {
486 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
487 theName, aCoords, theType, theIsClosed);
490 resISection = addSectionInternal(theName, theType, theIsClosed, aCoords);
495 //=======================================================================
496 // function: addSection
497 // purpose: adds a section with the given points
498 //=======================================================================
499 int CurveCreator_Curve::addSection
500 (const std::string& theName, const CurveCreator::SectionType theType,
501 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
503 int resISection = -1;
504 // Set the difference.
506 if (addEmptyDiff()) {
507 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
508 theName, thePoints, theType, theIsClosed);
511 resISection = addSectionInternal(theName, theType, theIsClosed, thePoints);
517 //! For internal use only! Undo/Redo are not used here.
518 bool CurveCreator_Curve::removeSectionInternal( const int theISection )
520 if (theISection == -1) {
521 delete mySections.back();
522 mySections.pop_back();
524 CurveCreator::Sections::iterator anIterRm = mySections.begin() + theISection;
527 mySections.erase(anIterRm);
533 //! Removes the given sections.
534 bool CurveCreator_Curve::removeSection( const int theISection )
537 // Set the difference.
540 myListDiffs.back().init(this, CurveCreator_Operation::RemoveSection, theISection);
542 res = removeSectionInternal( theISection );
549 * Get number of points in specified section or (the total number of points
550 * in Curve if theISection is equal to -1).
552 int CurveCreator_Curve::getNbPoints( const int theISection ) const
556 CurveCreator_Section* aSection;
557 if (theISection == -1) {
559 const int aNbSections = getNbSections();
561 for (; i < aNbSections; i++) {
562 aSection = (CurveCreator_Section*)getSection( i );
564 aNbCoords += aSection->myPoints.size();
567 aSection = (CurveCreator_Section*)getSection( theISection );
569 aNbCoords = aSection->myPoints.size();
572 return aNbCoords/myDimension;
575 void CurveCreator_Curve::setSkipSorting( const bool theIsToSkip )
577 mySkipSorting = theIsToSkip;
580 bool CurveCreator_Curve::canPointsBeSorted()
586 * Saves points coordinates difference.
587 * \param theOldCoords the old points coordinates
589 void CurveCreator_Curve::saveCoordDiff( const SectionToPointCoordsList &theOldCoords )
591 // Set the difference.
593 if (addEmptyDiff()) {
594 myListDiffs.back().init(this, theOldCoords);
599 //! Get "closed" flag of the specified section
600 bool CurveCreator_Curve::isClosed( const int theISection ) const
602 const CurveCreator_Section* aSection =
603 (CurveCreator_Section*)getSection( theISection );
604 return aSection ? aSection->myIsClosed : false;
607 //! For internal use only! Undo/Redo are not used here.
608 bool CurveCreator_Curve::setClosedInternal( const int theISection,
609 const bool theIsClosed )
611 CurveCreator_Section* aSection = 0;
612 if (theISection == -1) {
613 int aSize = mySections.size();
616 for (i = 0; i < aSize; i++) {
617 aSection = (CurveCreator_Section*)getSection( i );
619 aSection->myIsClosed = theIsClosed;
624 aSection = (CurveCreator_Section*)getSection( theISection );
626 aSection->myIsClosed = theIsClosed;
634 * Set "closed" flag of the specified section (all sections if
635 * \a theISection is -1).
637 bool CurveCreator_Curve::setClosed( const int theISection,
638 const bool theIsClosed )
641 // Set the difference.
643 if (addEmptyDiff()) {
644 myListDiffs.back().init(this, CurveCreator_Operation::SetClosed,
645 theIsClosed, theISection);
647 res = setClosedInternal( theISection, theIsClosed );
652 //! Returns specified section name
653 std::string CurveCreator_Curve::getSectionName( const int theISection ) const
655 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
656 return aSection ? aSection->myName : "";
659 //! For internal use only! Undo/Redo are not used here.
660 bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
661 const std::string& theName )
664 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
666 aSection->myName = theName;
672 /** Set name of the specified section */
673 bool CurveCreator_Curve::setSectionName( const int theISection,
674 const std::string& theName )
677 // Set the difference.
679 if (addEmptyDiff()) {
680 myListDiffs.back().init(this, CurveCreator_Operation::RenameSection,
681 theName, theISection);
683 res = setSectionNameInternal( theISection, theName );
688 //! Get type of the specified section
689 CurveCreator::SectionType CurveCreator_Curve::getSectionType
690 ( const int theISection ) const
692 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
693 return aSection ? aSection->myType : CurveCreator::Polyline;
696 //! For internal use only! Undo/Redo are not used here.
697 bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
698 const CurveCreator::SectionType theType )
700 CurveCreator_Section* aSection;
701 if (theISection == -1) {
703 const int aNbSections = getNbSections();
705 for (; i < aNbSections; i++) {
706 aSection = (CurveCreator_Section*)getSection( i );
708 aSection->myType = theType;
712 aSection = (CurveCreator_Section*)getSection( theISection );
713 if ( aSection && aSection->myType != theType ){
714 aSection->myType = theType;
722 * Set type of the specified section (or all sections
723 * if \a theISection is -1).
725 bool CurveCreator_Curve::setSectionType( const int theISection,
726 const CurveCreator::SectionType theType )
730 // Set the difference.
731 if (addEmptyDiff()) {
732 myListDiffs.back().init(this, CurveCreator_Operation::SetType,
733 theType, theISection);
736 res = setSectionTypeInternal( theISection, theType );
743 /***********************************************/
744 /*** Point methods ***/
745 /***********************************************/
747 //! For internal use only! Undo/Redo are not used here.
748 bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap )
751 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
752 CurveCreator_Section *aSection = 0;
753 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
754 int anISection = anIt->first;
755 aSection = (CurveCreator_Section*)getSection( anISection );
757 CurveCreator::PosPointsList aSectionPoints = anIt->second;
758 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
759 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
760 int anIPnt = (*aPntIt)->myID;
761 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
762 CurveCreator::Coordinates::iterator anIterPosition;
764 anIterPosition = aSection->myPoints.end();
766 anIterPosition = aSection->myPoints.begin() + toICoord(anIPnt);
767 CurveCreator::Coordinates::const_iterator aFirstPosition =
769 aSection->myPoints.insert(anIterPosition,
770 aCoords.begin(), aCoords.end());
781 * Add one point to the specified section starting from the given theIPnt index
782 * (or at the end of points if \a theIPnt is -1).
784 bool CurveCreator_Curve::addPoints( const CurveCreator::Coordinates& theCoords,
785 const int theISection,
788 //DEBTRACE("addPoints");
790 CurveCreator::Coordinates aCoords = theCoords;
791 // Set the difference.
793 if (addEmptyDiff()) {
794 CurveCreator_ICurve::SectionToPointCoordsList aList;
795 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theCoords));
796 myListDiffs.back().init(this, CurveCreator_Operation::InsertPoints,
799 CurveCreator::SectionsMap aSectionsMap;
800 CurveCreator::PosPointsList aPoints;
801 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theCoords );
802 aPoints.push_back( aPosPoint );
803 aSectionsMap[theISection] = aPoints;
805 res = addPointsInternal( aSectionsMap );
811 //! For internal use only! Undo/Redo are not used here.
812 bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theSectionsMap )
816 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
817 CurveCreator_Section *aSection = 0;
818 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
819 int anISection = anIt->first;
820 aSection = (CurveCreator_Section*)getSection( anISection );
822 CurveCreator::PosPointsList aSectionPoints = anIt->second;
823 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
824 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
825 int anIPnt = (*aPntIt)->myID;
826 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
827 for ( int i = 0; i < myDimension; i++)
828 aSection->myPoints.at(toICoord(anIPnt) + i) = aCoords[i];
839 //! Set coordinates of specified point
840 bool CurveCreator_Curve::setPoint( const int theISection,
842 const CurveCreator::Coordinates& theNewCoords )
844 //DEBTRACE("setPoint");
846 // Set the difference.
848 if (addEmptyDiff()) {
849 CurveCreator_ICurve::SectionToPointCoordsList aList;
850 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theNewCoords));
851 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
854 CurveCreator::SectionsMap aSectionsMap;
855 CurveCreator::PosPointsList aPoints;
856 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theNewCoords );
857 aPoints.push_back( aPosPoint );
858 aSectionsMap[theISection] = aPoints;
860 int aSize1 = getNbPoints( theISection );
861 res = setPointInternal( aSectionsMap );
862 int aSize2 = getNbPoints( theISection );
869 //! Set coordinates of specified points from different sections
870 bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
871 const bool theIsToSaveDiff )
873 //DEBTRACE("setSeveralPoints");
875 // Set the difference.
877 if (theIsToSaveDiff && addEmptyDiff()) {
878 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
879 theSectionToPntCoords);
881 CurveCreator::SectionsMap aSectionsMap;
882 CurveCreator::PosPointsList aPosPoints;
883 CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
884 theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
885 int aSectionId, aPointId;
886 for ( ; anIt != aLast; anIt++ ) {
888 aSectionId = anIt->first.first;
889 aPointId = anIt->first.second;
890 CurveCreator::Coordinates aNewCoords = anIt->second;
891 CurveCreator_PosPoint* aPosPoint =
892 new CurveCreator_PosPoint( aPointId, aNewCoords );
893 if( aSectionsMap.find(aSectionId) != aSectionsMap.end() )
894 aPosPoints = aSectionsMap[aSectionId];
895 aPosPoints.push_back( aPosPoint );
896 aSectionsMap[aSectionId] = aPosPoints;
899 res = setPointInternal( aSectionsMap );
905 //! For internal use only! Undo/Redo are not used here.
906 bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoints )
909 std::map<int, std::list<int> > aConvPoints;
910 convert( thePoints, aConvPoints );
911 std::map<int, std::list<int> >::const_iterator anIt = aConvPoints.begin(),
912 aLast = aConvPoints.end();
913 for ( ; anIt != aLast; anIt++ ) {
914 int aSectionId = anIt->first;
915 aRes = removeSectionPoints(aSectionId, anIt->second);
923 //! Remove point with given id
924 bool CurveCreator_Curve::removePoint( const int theISection, const int theIPnt )
927 // Set the difference.
929 SectionToPointList aListOfSectionsToPoints;
930 aListOfSectionsToPoints.push_back(std::make_pair(theISection, theIPnt));
931 if (addEmptyDiff()) {
932 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
933 aListOfSectionsToPoints);
935 res = removePointsInternal( aListOfSectionsToPoints );
940 //! Remove several points from different sections with given ids
941 bool CurveCreator_Curve::removeSeveralPoints( const SectionToPointList &theSectionToPntIDs)
944 // Set the difference.
946 if (addEmptyDiff()) {
947 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
950 res = removePointsInternal( theSectionToPntIDs );
955 //=======================================================================
956 // function: getCoordinates
958 //=======================================================================
959 CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection,
960 const int theIPnt) const
962 //DEBTRACE("getPoint");
963 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
964 CurveCreator::Coordinates::const_iterator
965 anIter = aSection->myPoints.begin() + toICoord(theIPnt);
966 CurveCreator::Coordinates aResult(anIter, anIter + myDimension);
971 //=======================================================================
972 // function: getPoints
974 //=======================================================================
975 CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
977 //DEBTRACE("getPoints");
978 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
979 return aSection ? aSection->myPoints : CurveCreator::Coordinates();
982 void CurveCreator_Curve::constructAISObject()
984 //DEBTRACE("constructAISObject");
986 CurveCreator_Utils::constructShape( this, aShape );
988 myAISShape = new AIS_Shape( aShape );
989 Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
990 anAspect->SetScale( 3.0 );
991 anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT);
992 anAspect->SetColor(Quantity_NOC_ROYALBLUE4);
993 myAISShape->Attributes()->SetPointAspect( anAspect );
997 Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
999 //DEBTRACE("getAISObject");
1000 if ( !myAISShape && theNeedToBuild ) {
1001 CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
1002 aCurve->constructAISObject();
1007 bool CurveCreator_Curve::removeSectionPoints( const int theSectionId,
1008 const std::list<int>& thePointIds )
1012 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theSectionId );
1016 std::list<int> aSectionPoints = thePointIds;
1017 aSectionPoints.sort();
1018 std::list<int>::const_reverse_iterator aPntIt = aSectionPoints.rbegin();
1019 for ( ; aPntIt != aSectionPoints.rend(); aPntIt++ ) {
1020 int aPntIndx = *aPntIt;
1021 CurveCreator::Coordinates::iterator aFirstPosition;
1022 if ( aPntIndx == -1 )
1023 aFirstPosition = aSection->myPoints.end() - getDimension();
1025 aFirstPosition = aSection->myPoints.begin() + toICoord( aPntIndx );
1026 aSection->myPoints.erase( aFirstPosition, aFirstPosition + getDimension() );
1032 void CurveCreator_Curve::convert( const SectionToPointList& thePoints,
1033 std::map< int, std::list<int> >& theConvPoints )
1035 theConvPoints.clear();
1037 SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end();
1038 std::list<int> aPoints;
1039 int aSectionId, aPointId;
1040 for ( ; anIt != aLast; anIt++ ) {
1041 aSectionId = anIt->first;
1042 aPointId = anIt->second;
1044 if ( theConvPoints.find( aSectionId ) != theConvPoints.end() )
1045 aPoints = theConvPoints[aSectionId];
1046 aPoints.push_back( aPointId );
1047 theConvPoints[aSectionId] = aPoints;