1 // Copyright (C) 2013-2016 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>
42 #define DEBTRACE(msg) {std::cerr<<std::flush<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<std::endl<<std::flush;}
46 //=======================================================================
47 // function: Constructor
49 //=======================================================================
50 CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimension )
52 myDimension (theDimension),
63 //=======================================================================
64 // function: Destructor
66 //=======================================================================
67 CurveCreator_Curve::~CurveCreator_Curve()
69 // Delete all allocated data.
73 //=======================================================================
74 // function: getDimension
76 //=======================================================================
77 CurveCreator::Dimension CurveCreator_Curve::getDimension() const
82 //=======================================================================
83 // function: getUniqSectionName
84 // purpose: return unique section name
85 //=======================================================================
86 std::string CurveCreator_Curve::getUniqSectionName() const
88 CurveCreator_Section* aSection;
89 for( int i = 0 ; i < 1000000 ; i++ ){
91 sprintf( aBuffer, "Section_%d", i+1 );
92 std::string aName(aBuffer);
94 for( j = 0 ; j < mySections.size() ; j++ ){
95 aSection = (CurveCreator_Section*)getSection( j );
96 if ( aSection && aSection->myName == aName )
99 if( j == mySections.size() )
105 //=======================================================================
106 // function: setDisplayer
107 // purpose: set curve changes Displayer
108 //=======================================================================
109 void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer )
111 myDisplayer = theDisplayer;
114 //=======================================================================
115 // function: getDisplayer
116 // purpose: get curve changes Displayer
117 //=======================================================================
118 CurveCreator_Displayer* CurveCreator_Curve::getDisplayer()
123 //=======================================================================
124 // function: removeDisplayer
125 // purpose: remove the attached Displayer
126 //=======================================================================
127 void CurveCreator_Curve::removeDisplayer()
132 //=======================================================================
135 //=======================================================================
136 bool CurveCreator_Curve::addEmptyDiff()
138 bool isEnabled = false;
140 if (myUndoDepth != 0) {
141 // Forget all Redos after the current one.
144 myListDiffs.erase(myCurrenPos, myListDiffs.end());
147 if (myUndoDepth == -1 || myNbUndos < myUndoDepth) {
148 // Increase the number of undos.
151 // If there are too many differences, remove the first one.
152 myListDiffs.pop_front();
155 // Add new difference.
156 myListDiffs.push_back(CurveCreator_Diff());
157 myCurrenPos = myListDiffs.end();
164 void CurveCreator_Curve::startOperation()
169 void CurveCreator_Curve::finishOperation()
174 //=======================================================================
175 // function: toICoord
177 //=======================================================================
178 int CurveCreator_Curve::toICoord(const int theIPnt) const
180 return theIPnt * myDimension;
183 //=======================================================================
184 // function: setUndoDepth
186 //=======================================================================
187 void CurveCreator_Curve::setUndoDepth(const int theDepth)
190 // Reset all undo/redo data.
194 myCurrenPos = myListDiffs.end();
196 } else if (theDepth == -1) {
197 // There is nothing to do as the depth become unlimited.
199 } else if (theDepth > 0) {
200 // The new "real" depth is set.
201 if (theDepth < myNbRedos) {
202 // The new depth is less then number of redos. Remove the latest redos.
203 int aShift = (myNbRedos - theDepth);
204 ListDiff::iterator aFromPos = myListDiffs.end();
210 myListDiffs.erase(aFromPos, myListDiffs.end());
211 myNbRedos = theDepth;
214 if (theDepth < myNbUndos + myNbRedos) {
215 // The new depth is less then the total number of differences.
216 // Remove the first undos.
217 int aShift = (myNbUndos + myNbRedos - theDepth);
218 ListDiff::iterator aToPos = myListDiffs.begin();
224 myListDiffs.erase(myListDiffs.begin(), aToPos);
225 myNbUndos = theDepth - myNbRedos;
228 myUndoDepth = theDepth;
232 //=======================================================================
233 // function: getUndoDepth
235 //=======================================================================
236 int CurveCreator_Curve::getUndoDepth() const
241 void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
243 CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
247 if( getDimension() == CurveCreator::Dim3d ){
252 void CurveCreator_Curve::redisplayCurve()
254 //DEBTRACE("redisplayCurve");
256 myDisplayer->eraseAll( false );
259 myDisplayer->display( getAISObject( true ), true );
263 //! For internal use only! Undo/Redo are not used here.
264 bool CurveCreator_Curve::moveSectionInternal(const int theISection,
265 const int theNewIndex)
268 int aMovedSectionId = theISection >= 0 ? theISection : mySections.size()-1;
270 if (aMovedSectionId != theNewIndex) {
271 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( aMovedSectionId );
274 CurveCreator::Sections::iterator anIter = mySections.begin() + aMovedSectionId;
276 mySections.erase(anIter);
279 anIter = mySections.begin() + theNewIndex;
280 mySections.insert(anIter, aSection);
286 //=======================================================================
287 // function: moveSection
289 //=======================================================================
290 bool CurveCreator_Curve::moveSection(const int theISection,
291 const int theNewIndex)
294 // Set the difference.
296 if (addEmptyDiff()) {
297 myListDiffs.back().init(this, CurveCreator_Operation::MoveSection,
298 theISection, theNewIndex);
302 res = moveSectionInternal(theISection, theNewIndex);
307 /************ Implementation of INTERFACE methods ************/
309 /***********************************************/
310 /*** Undo/Redo methods ***/
311 /***********************************************/
313 //! Get number of available undo operations
314 int CurveCreator_Curve::getNbUndo() const
319 //! Undo previous operation
320 bool CurveCreator_Curve::undo()
327 myCurrenPos->applyUndo(this);
333 //! Get number of available redo operations
334 int CurveCreator_Curve::getNbRedo() const
339 //! Redo last previously "undone" operation
340 bool CurveCreator_Curve::redo()
344 myCurrenPos->applyRedo(this);
353 /***********************************************/
354 /*** Section methods ***/
355 /***********************************************/
356 //! For internal use only! Undo/Redo are not used here.
357 bool CurveCreator_Curve::clearInternal()
359 // erase curve from the viewer
361 myDisplayer->eraseAll( true );
364 // Delete all allocated data.
366 const int aNbSections = getNbSections();
368 CurveCreator_Section* aSection;
369 for (; i < aNbSections; i++) {
370 aSection = (CurveCreator_Section*)getSection( i );
380 //=======================================================================
383 //=======================================================================
384 bool CurveCreator_Curve::clear()
388 // Set the difference.
389 if (addEmptyDiff()) {
390 myListDiffs.back().init(this);
392 res = clearInternal();
397 //! For internal use only! Undo/Redo are not used here.
398 bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
401 if ( theSections.empty() )
404 int anISectionMain = theSections.front();
405 CurveCreator_Section* aSectionMain =
406 (CurveCreator_Section*)getSection( anISectionMain );
408 std::list <int> aSectionsToJoin = theSections;
409 aSectionsToJoin.erase( aSectionsToJoin.begin() ); // skip the main section
410 // it is important to sort and reverse the section ids in order to correctly remove them
411 aSectionsToJoin.sort();
412 aSectionsToJoin.reverse();
414 std::list<int>::const_iterator anIt = aSectionsToJoin.begin(), aLast = aSectionsToJoin.end();
415 CurveCreator_Section* aSection;
416 for (; anIt != aLast; anIt++) {
417 aSection = (CurveCreator_Section*)getSection( *anIt );
418 aSectionMain->myPoints.insert(aSectionMain->myPoints.end(), aSection->myPoints.begin(),
419 aSection->myPoints.end());
420 res = removeSectionInternal(*anIt);
429 bool CurveCreator_Curve::join( const std::list<int>& theSections )
433 if ( !theSections.empty() )
437 myListDiffs.back().init(this, CurveCreator_Operation::Join, theSections);
439 res = joinInternal( theSections );
446 //! Get number of sections
447 int CurveCreator_Curve::getNbSections() const
449 return mySections.size();
452 //! For internal use only! Undo/Redo are not used here.
453 int CurveCreator_Curve::addSectionInternal
454 (const std::string& theName, const CurveCreator::SectionType theType,
455 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
457 CurveCreator_Section *aSection = new CurveCreator_Section;
459 std::string aName = theName;
461 aName = getUniqSectionName();
463 aSection->myName = aName;
464 aSection->myType = theType;
465 aSection->myIsClosed = theIsClosed;
466 aSection->myPoints = thePoints;
467 mySections.push_back(aSection);
469 return mySections.size()-1;
472 //=======================================================================
473 // function: addSection
474 // purpose: adds an empty section
475 //=======================================================================
476 int CurveCreator_Curve::addSection
477 (const std::string& theName, const CurveCreator::SectionType theType,
478 const bool theIsClosed)
480 int resISection = -1;
481 // Set the difference.
483 CurveCreator::Coordinates aCoords; //empty list
484 if (addEmptyDiff()) {
485 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
486 theName, aCoords, theType, theIsClosed);
489 resISection = addSectionInternal(theName, theType, theIsClosed, aCoords);
494 //=======================================================================
495 // function: addSection
496 // purpose: adds a section with the given points
497 //=======================================================================
498 int CurveCreator_Curve::addSection
499 (const std::string& theName, const CurveCreator::SectionType theType,
500 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
502 int resISection = -1;
503 // Set the difference.
505 if (addEmptyDiff()) {
506 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
507 theName, thePoints, theType, theIsClosed);
510 resISection = addSectionInternal(theName, theType, theIsClosed, thePoints);
516 //! For internal use only! Undo/Redo are not used here.
517 bool CurveCreator_Curve::removeSectionInternal( const int theISection )
519 if (theISection == -1) {
520 delete mySections.back();
521 mySections.pop_back();
523 CurveCreator::Sections::iterator anIterRm = mySections.begin() + theISection;
526 mySections.erase(anIterRm);
532 //! Removes the given sections.
533 bool CurveCreator_Curve::removeSection( const int theISection )
536 // Set the difference.
539 myListDiffs.back().init(this, CurveCreator_Operation::RemoveSection, theISection);
541 res = removeSectionInternal( theISection );
548 * Get number of points in specified section or (the total number of points
549 * in Curve if theISection is equal to -1).
551 int CurveCreator_Curve::getNbPoints( const int theISection ) const
555 CurveCreator_Section* aSection;
556 if (theISection == -1) {
558 const int aNbSections = getNbSections();
560 for (; i < aNbSections; i++) {
561 aSection = (CurveCreator_Section*)getSection( i );
563 aNbCoords += aSection->myPoints.size();
566 aSection = (CurveCreator_Section*)getSection( theISection );
568 aNbCoords = aSection->myPoints.size();
571 return aNbCoords/myDimension;
574 void CurveCreator_Curve::setSkipSorting( const bool theIsToSkip )
576 mySkipSorting = theIsToSkip;
579 bool CurveCreator_Curve::canPointsBeSorted()
585 * Saves points coordinates difference.
586 * \param theOldCoords the old points coordinates
588 void CurveCreator_Curve::saveCoordDiff( const SectionToPointCoordsList &theOldCoords )
590 // Set the difference.
592 if (addEmptyDiff()) {
593 myListDiffs.back().init(this, theOldCoords);
598 //! Get "closed" flag of the specified section
599 bool CurveCreator_Curve::isClosed( const int theISection ) const
601 const CurveCreator_Section* aSection =
602 (CurveCreator_Section*)getSection( theISection );
603 return aSection ? aSection->myIsClosed : false;
606 //! For internal use only! Undo/Redo are not used here.
607 bool CurveCreator_Curve::setClosedInternal( const int theISection,
608 const bool theIsClosed )
610 CurveCreator_Section* aSection = 0;
611 if (theISection == -1) {
612 int aSize = mySections.size();
615 for (i = 0; i < aSize; i++) {
616 aSection = (CurveCreator_Section*)getSection( i );
618 aSection->myIsClosed = theIsClosed;
623 aSection = (CurveCreator_Section*)getSection( theISection );
625 aSection->myIsClosed = theIsClosed;
633 * Set "closed" flag of the specified section (all sections if
634 * \a theISection is -1).
636 bool CurveCreator_Curve::setClosed( const int theISection,
637 const bool theIsClosed )
640 // Set the difference.
642 if (addEmptyDiff()) {
643 myListDiffs.back().init(this, CurveCreator_Operation::SetClosed,
644 theIsClosed, theISection);
646 res = setClosedInternal( theISection, theIsClosed );
651 //! Returns specified section name
652 std::string CurveCreator_Curve::getSectionName( const int theISection ) const
654 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
655 return aSection ? aSection->myName : "";
658 //! For internal use only! Undo/Redo are not used here.
659 bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
660 const std::string& theName )
663 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
665 aSection->myName = theName;
671 /** Set name of the specified section */
672 bool CurveCreator_Curve::setSectionName( const int theISection,
673 const std::string& theName )
676 // Set the difference.
678 if (addEmptyDiff()) {
679 myListDiffs.back().init(this, CurveCreator_Operation::RenameSection,
680 theName, theISection);
682 res = setSectionNameInternal( theISection, theName );
687 //! Get type of the specified section
688 CurveCreator::SectionType CurveCreator_Curve::getSectionType
689 ( const int theISection ) const
691 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
692 return aSection ? aSection->myType : CurveCreator::Polyline;
695 //! For internal use only! Undo/Redo are not used here.
696 bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
697 const CurveCreator::SectionType theType )
699 CurveCreator_Section* aSection;
700 if (theISection == -1) {
702 const int aNbSections = getNbSections();
704 for (; i < aNbSections; i++) {
705 aSection = (CurveCreator_Section*)getSection( i );
707 aSection->myType = theType;
711 aSection = (CurveCreator_Section*)getSection( theISection );
712 if ( aSection && aSection->myType != theType ){
713 aSection->myType = theType;
721 * Set type of the specified section (or all sections
722 * if \a theISection is -1).
724 bool CurveCreator_Curve::setSectionType( const int theISection,
725 const CurveCreator::SectionType theType )
729 // Set the difference.
730 if (addEmptyDiff()) {
731 myListDiffs.back().init(this, CurveCreator_Operation::SetType,
732 theType, theISection);
735 res = setSectionTypeInternal( theISection, theType );
742 /***********************************************/
743 /*** Point methods ***/
744 /***********************************************/
746 //! For internal use only! Undo/Redo are not used here.
747 bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap )
750 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
751 CurveCreator_Section *aSection = 0;
752 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
753 int anISection = anIt->first;
754 aSection = (CurveCreator_Section*)getSection( anISection );
756 CurveCreator::PosPointsList aSectionPoints = anIt->second;
757 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
758 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
759 int anIPnt = (*aPntIt)->myID;
760 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
761 CurveCreator::Coordinates::iterator anIterPosition;
763 anIterPosition = aSection->myPoints.end();
765 anIterPosition = aSection->myPoints.begin() + toICoord(anIPnt);
766 CurveCreator::Coordinates::const_iterator aFirstPosition =
768 aSection->myPoints.insert(anIterPosition,
769 aCoords.begin(), aCoords.end());
780 * Add one point to the specified section starting from the given theIPnt index
781 * (or at the end of points if \a theIPnt is -1).
783 bool CurveCreator_Curve::addPoints( const CurveCreator::Coordinates& theCoords,
784 const int theISection,
787 //DEBTRACE("addPoints");
789 CurveCreator::Coordinates aCoords = theCoords;
790 // Set the difference.
792 if (addEmptyDiff()) {
793 CurveCreator_ICurve::SectionToPointCoordsList aList;
794 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theCoords));
795 myListDiffs.back().init(this, CurveCreator_Operation::InsertPoints,
798 CurveCreator::SectionsMap aSectionsMap;
799 CurveCreator::PosPointsList aPoints;
800 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theCoords );
801 aPoints.push_back( aPosPoint );
802 aSectionsMap[theISection] = aPoints;
804 res = addPointsInternal( aSectionsMap );
810 //! For internal use only! Undo/Redo are not used here.
811 bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theSectionsMap )
815 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
816 CurveCreator_Section *aSection = 0;
817 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
818 int anISection = anIt->first;
819 aSection = (CurveCreator_Section*)getSection( anISection );
821 CurveCreator::PosPointsList aSectionPoints = anIt->second;
822 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
823 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
824 int anIPnt = (*aPntIt)->myID;
825 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
826 for ( int i = 0; i < myDimension; i++)
827 aSection->myPoints.at(toICoord(anIPnt) + i) = aCoords[i];
838 //! Set coordinates of specified point
839 bool CurveCreator_Curve::setPoint( const int theISection,
841 const CurveCreator::Coordinates& theNewCoords )
843 //DEBTRACE("setPoint");
845 // Set the difference.
847 if (addEmptyDiff()) {
848 CurveCreator_ICurve::SectionToPointCoordsList aList;
849 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theNewCoords));
850 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
853 CurveCreator::SectionsMap aSectionsMap;
854 CurveCreator::PosPointsList aPoints;
855 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theNewCoords );
856 aPoints.push_back( aPosPoint );
857 aSectionsMap[theISection] = aPoints;
859 int aSize1 = getNbPoints( theISection );
860 res = setPointInternal( aSectionsMap );
861 int aSize2 = getNbPoints( theISection );
868 //! Set coordinates of specified points from different sections
869 bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
870 const bool theIsToSaveDiff )
872 //DEBTRACE("setSeveralPoints");
874 // Set the difference.
876 if (theIsToSaveDiff && addEmptyDiff()) {
877 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
878 theSectionToPntCoords);
880 CurveCreator::SectionsMap aSectionsMap;
881 CurveCreator::PosPointsList aPosPoints;
882 CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
883 theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
884 int aSectionId, aPointId;
885 for ( ; anIt != aLast; anIt++ ) {
887 aSectionId = anIt->first.first;
888 aPointId = anIt->first.second;
889 CurveCreator::Coordinates aNewCoords = anIt->second;
890 CurveCreator_PosPoint* aPosPoint =
891 new CurveCreator_PosPoint( aPointId, aNewCoords );
892 if( aSectionsMap.find(aSectionId) != aSectionsMap.end() )
893 aPosPoints = aSectionsMap[aSectionId];
894 aPosPoints.push_back( aPosPoint );
895 aSectionsMap[aSectionId] = aPosPoints;
898 res = setPointInternal( aSectionsMap );
904 //! For internal use only! Undo/Redo are not used here.
905 bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoints )
908 std::map<int, std::list<int> > aConvPoints;
909 convert( thePoints, aConvPoints );
910 std::map<int, std::list<int> >::const_iterator anIt = aConvPoints.begin(),
911 aLast = aConvPoints.end();
912 for ( ; anIt != aLast; anIt++ ) {
913 int aSectionId = anIt->first;
914 aRes = removeSectionPoints(aSectionId, anIt->second);
922 //! Remove point with given id
923 bool CurveCreator_Curve::removePoint( const int theISection, const int theIPnt )
926 // Set the difference.
928 SectionToPointList aListOfSectionsToPoints;
929 aListOfSectionsToPoints.push_back(std::make_pair(theISection, theIPnt));
930 if (addEmptyDiff()) {
931 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
932 aListOfSectionsToPoints);
934 res = removePointsInternal( aListOfSectionsToPoints );
939 //! Remove several points from different sections with given ids
940 bool CurveCreator_Curve::removeSeveralPoints( const SectionToPointList &theSectionToPntIDs)
943 // Set the difference.
945 if (addEmptyDiff()) {
946 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
949 res = removePointsInternal( theSectionToPntIDs );
954 //=======================================================================
955 // function: getCoordinates
957 //=======================================================================
958 CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection,
959 const int theIPnt) const
961 //DEBTRACE("getPoint");
962 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
963 CurveCreator::Coordinates::const_iterator
964 anIter = aSection->myPoints.begin() + toICoord(theIPnt);
965 CurveCreator::Coordinates aResult(anIter, anIter + myDimension);
970 //=======================================================================
971 // function: getPoints
973 //=======================================================================
974 CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
976 //DEBTRACE("getPoints");
977 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
978 return aSection ? aSection->myPoints : CurveCreator::Coordinates();
981 void CurveCreator_Curve::constructAISObject()
983 //DEBTRACE("constructAISObject");
985 CurveCreator_Utils::constructShape( this, aShape );
987 myAISShape = new AIS_Shape( aShape );
988 Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
989 anAspect->SetScale( 3.0 );
990 anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT);
991 anAspect->SetColor(Quantity_NOC_ROYALBLUE4);
992 myAISShape->Attributes()->SetPointAspect( anAspect );
996 Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
998 //DEBTRACE("getAISObject");
999 if ( !myAISShape && theNeedToBuild ) {
1000 CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
1001 aCurve->constructAISObject();
1006 bool CurveCreator_Curve::removeSectionPoints( const int theSectionId,
1007 const std::list<int>& thePointIds )
1011 CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theSectionId );
1015 std::list<int> aSectionPoints = thePointIds;
1016 aSectionPoints.sort();
1017 std::list<int>::const_reverse_iterator aPntIt = aSectionPoints.rbegin();
1018 for ( ; aPntIt != aSectionPoints.rend(); aPntIt++ ) {
1019 int aPntIndx = *aPntIt;
1020 CurveCreator::Coordinates::iterator aFirstPosition;
1021 if ( aPntIndx == -1 )
1022 aFirstPosition = aSection->myPoints.end() - getDimension();
1024 aFirstPosition = aSection->myPoints.begin() + toICoord( aPntIndx );
1025 aSection->myPoints.erase( aFirstPosition, aFirstPosition + getDimension() );
1031 void CurveCreator_Curve::convert( const SectionToPointList& thePoints,
1032 std::map< int, std::list<int> >& theConvPoints )
1034 theConvPoints.clear();
1036 SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end();
1037 std::list<int> aPoints;
1038 int aSectionId, aPointId;
1039 for ( ; anIt != aLast; anIt++ ) {
1040 aSectionId = anIt->first;
1041 aPointId = anIt->second;
1043 if ( theConvPoints.find( aSectionId ) != theConvPoints.end() )
1044 aPoints = theConvPoints[aSectionId];
1045 aPoints.push_back( aPointId );
1046 theConvPoints[aSectionId] = aPoints;