1 // Copyright (C) 2013 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.
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.h"
29 #include "CurveCreator_Utils.h"
31 #include <AIS_Point.hxx>
32 #include <AIS_Line.hxx>
33 #include <AIS_Shape.hxx>
34 #include <Geom_CartesianPoint.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <TopoDS_Face.hxx>
39 #include <TopoDS_Wire.hxx>
43 //#define AIS_CURVE_DISPLAY
45 //=======================================================================
46 // function: Constructor
48 //=======================================================================
49 CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimension )
51 myDimension (theDimension),
58 #ifdef AIS_CURVE_DISPLAY
59 myAISCurve = new CurveCreator_AISCurve( this );
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 for( int i = 0 ; i < 1000000 ; i++ ){
90 sprintf( aBuffer, "Section_%d", i+1 );
91 std::string aName(aBuffer);
93 for( j = 0 ; j < mySections.size() ; j++ ){
94 if( mySections[j]->myName == aName )
97 if( j == mySections.size() )
103 //=======================================================================
104 // function: setDisplayer
105 // purpose: set curve changes Displayer
106 //=======================================================================
107 void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer )
109 myDisplayer = theDisplayer;
111 #ifdef AIS_CURVE_DISPLAY
112 myDisplayer->displayAIS( myAISCurve, false );
116 //=======================================================================
117 // function: getDisplayer
118 // purpose: get curve changes Displayer
119 //=======================================================================
120 CurveCreator_Displayer* CurveCreator_Curve::getDisplayer()
125 //=======================================================================
126 // function: removeDisplayer
127 // purpose: remove the attached Displayer
128 //=======================================================================
129 void CurveCreator_Curve::removeDisplayer()
134 //=======================================================================
137 //=======================================================================
138 bool CurveCreator_Curve::addEmptyDiff()
140 bool isEnabled = false;
142 if (myUndoDepth != 0) {
143 // Forget all Redos after the current one.
146 myListDiffs.erase(myCurrenPos, myListDiffs.end());
149 if (myUndoDepth == -1 || myNbUndos < myUndoDepth) {
150 // Increase the number of undos.
153 // If there are too many differences, remove the first one.
154 myListDiffs.pop_front();
157 // Add new difference.
158 myListDiffs.push_back(CurveCreator_Diff());
159 myCurrenPos = myListDiffs.end();
166 void CurveCreator_Curve::startOperation()
171 void CurveCreator_Curve::finishOperation()
176 //=======================================================================
177 // function: toICoord
179 //=======================================================================
180 int CurveCreator_Curve::toICoord(const int theIPnt) const
182 return theIPnt * myDimension;
185 std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructSection( int theISection ) const
187 std::vector<Handle_AIS_InteractiveObject> aSectionRepresentation;
190 CurveCreator_Utils::constructShape( this, theISection, aShape, aSectionRepresentation );
192 AIS_Shape* anAISShape = new AIS_Shape( aShape );
193 //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
194 aSectionRepresentation.push_back( anAISShape );
196 return aSectionRepresentation;
199 //=======================================================================
200 // function: setUndoDepth
202 //=======================================================================
203 void CurveCreator_Curve::setUndoDepth(const int theDepth)
206 // Reset all undo/redo data.
210 myCurrenPos = myListDiffs.end();
212 } else if (theDepth == -1) {
213 // There is nothing to do as the depth become unlimited.
215 } else if (theDepth > 0) {
216 // The new "real" depth is set.
217 if (theDepth < myNbRedos) {
218 // The new depth is less then number of redos. Remove the latest redos.
219 int aShift = (myNbRedos - theDepth);
220 ListDiff::iterator aFromPos = myListDiffs.end();
226 myListDiffs.erase(aFromPos, myListDiffs.end());
227 myNbRedos = theDepth;
230 if (theDepth < myNbUndos + myNbRedos) {
231 // The new depth is less then the total number of differences.
232 // Remove the first undos.
233 int aShift = (myNbUndos + myNbRedos - theDepth);
234 ListDiff::iterator aToPos = myListDiffs.begin();
240 myListDiffs.erase(myListDiffs.begin(), aToPos);
241 myNbUndos = theDepth - myNbRedos;
244 myUndoDepth = theDepth;
248 //=======================================================================
249 // function: getUndoDepth
251 //=======================================================================
252 int CurveCreator_Curve::getUndoDepth() const
257 Handle_AIS_Point CurveCreator_Curve::getAISPoint( int theISection, int theIPoint ) const
260 getCoordinates( theISection, theIPoint, anX, anY, aZ );
261 gp_Pnt aPoint( anX, anY, aZ);
263 AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
267 Handle_AIS_Line CurveCreator_Curve::getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const
270 getCoordinates( theISection, theIPoint1, anX, anY, aZ );
271 gp_Pnt aPoint1( anX, anY, aZ);
273 double anX2, anY2, aZ2;
274 getCoordinates( theISection, theIPoint2, anX2, anY2, aZ2 );
275 //MTN to avoid crash during line construction
276 if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
280 gp_Pnt aPoint2( anX2, anY2, aZ2 );
282 AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
286 void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
288 CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
292 if( getDimension() == CurveCreator::Dim3d ){
297 //#define USE_COMPOUND
298 void CurveCreator_Curve::redisplayCurve()
301 #ifdef AIS_CURVE_DISPLAY
302 myDisplayer->redisplayAIS(myAISCurve, false);
304 myDisplayer->erase( false );
305 //#ifndef USE_COMPOUND
306 myDisplayer->display( constructWire(), true );
308 /*std::vector<Handle_AIS_InteractiveObject> anAISObjects = constructWire();
309 int aSelMode = AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX );
310 Handle(AIS_InteractiveContext) aContext = myDisplayer->getAISContext();
311 for( int i = 0 ; i < anAISObjects.size() ; i++ ){
312 Handle_AIS_InteractiveObject anAISObject = anAISObjects[i];
313 //anAISObject->SetSelectionMode( aSelMode );
314 aContext->Display( anAISObject, Standard_False );
315 //aContext->Display( anAISObject, 0, aSelMode, Standard_False, Standard_True );
317 aContext->UpdateCurrentViewer();
324 //! For internal use only! Undo/Redo are not used here.
325 bool CurveCreator_Curve::moveSectionInternal(const int theISection,
326 const int theNewIndex)
329 if (theISection != theNewIndex) {
330 CurveCreator_Section *aSection = mySections.at(theISection);
333 CurveCreator::Sections::iterator anIter = mySections.begin() + theISection;
335 mySections.erase(anIter);
338 anIter = mySections.begin() + theNewIndex;
339 mySections.insert(anIter, aSection);
345 //=======================================================================
346 // function: moveSection
348 //=======================================================================
349 bool CurveCreator_Curve::moveSection(const int theISection,
350 const int theNewIndex)
353 // Set the difference.
355 if (addEmptyDiff()) {
356 myListDiffs.back().init(this, CurveCreator_Operation::MoveSection,
357 theISection, theNewIndex);
361 res = moveSectionInternal(theISection, theNewIndex);
366 void CurveCreator_Curve::convert( const SectionToPointList& thePoints,
367 std::map< int, std::list<int> >& theConvPoints )
369 theConvPoints.clear();
371 SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end();
372 std::list<int> aPoints;
373 int aSectionId, aPointId;
374 for ( ; anIt != aLast; anIt++ ) {
375 aSectionId = anIt->first;
376 aPointId = anIt->second;
378 if ( theConvPoints.find( aSectionId ) != theConvPoints.end() )
379 aPoints = theConvPoints[aSectionId];
380 aPoints.push_back( aPointId );
381 theConvPoints[aSectionId] = aPoints;
385 /************ Implementation of INTERFACE methods ************/
387 /***********************************************/
388 /*** Undo/Redo methods ***/
389 /***********************************************/
391 //! Get number of available undo operations
392 int CurveCreator_Curve::getNbUndo() const
397 //! Undo previous operation
398 bool CurveCreator_Curve::undo()
405 myCurrenPos->applyUndo(this);
411 //! Get number of available redo operations
412 int CurveCreator_Curve::getNbRedo() const
417 //! Redo last previously "undone" operation
418 bool CurveCreator_Curve::redo()
422 myCurrenPos->applyRedo(this);
431 /***********************************************/
432 /*** Section methods ***/
433 /***********************************************/
434 //! For internal use only! Undo/Redo are not used here.
435 bool CurveCreator_Curve::clearInternal()
437 // erase curve from the viewer
439 myDisplayer->erase( true );
440 // Delete all allocated data.
442 const int aNbSections = getNbSections();
444 for (; i < aNbSections; i++) {
445 delete mySections[i];
453 //=======================================================================
456 //=======================================================================
457 bool CurveCreator_Curve::clear()
461 // Set the difference.
462 if (addEmptyDiff()) {
463 myListDiffs.back().init(this, CurveCreator_Operation::Clear);
465 res = clearInternal();
470 //! For internal use only! Undo/Redo are not used here.
471 bool CurveCreator_Curve::joinInternal( const int theISectionTo,
472 const int theISectionFrom )
475 CurveCreator_Section *aSection1 = mySections.at(theISectionTo);
476 CurveCreator_Section *aSection2 = mySections.at(theISectionFrom);
478 aSection1->myPoints.insert(aSection1->myPoints.end(),
479 aSection2->myPoints.begin(),
480 aSection2->myPoints.end());
482 res = removeSection(theISectionFrom);
487 //! Join range of sections to one section (join all sections if -1 is passed in theISectionFrom argument)
488 bool CurveCreator_Curve::join( const int theISectionTo,
489 const int theISectionFrom )
493 if ( theISectionTo != theISectionFrom ) {
496 myListDiffs.back().init(this, CurveCreator_Operation::Join, theISectionTo, theISectionFrom);
498 res = joinInternal( theISectionTo, theISectionFrom );
505 //! Get number of sections
506 int CurveCreator_Curve::getNbSections() const
508 return mySections.size();
511 //! For internal use only! Undo/Redo are not used here.
512 int CurveCreator_Curve::addSectionInternal
513 (const std::string& theName, const CurveCreator::SectionType theType,
514 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
516 CurveCreator_Section *aSection = new CurveCreator_Section;
518 std::string aName = theName;
520 aName = getUniqSectionName();
522 aSection->myName = aName;
523 aSection->myType = theType;
524 aSection->myIsClosed = theIsClosed;
525 aSection->myPoints = thePoints;
526 mySections.push_back(aSection);
528 return mySections.size()-1;
531 //=======================================================================
532 // function: addSection
533 // purpose: adds an empty section
534 //=======================================================================
535 int CurveCreator_Curve::addSection
536 (const std::string& theName, const CurveCreator::SectionType theType,
537 const bool theIsClosed)
539 int resISection = -1;
540 // Set the difference.
542 CurveCreator::Coordinates aCoords; //empty list
543 if (addEmptyDiff()) {
544 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
545 theName, aCoords, theType, theIsClosed);
548 resISection = addSectionInternal(theName, theType, theIsClosed, aCoords);
553 //=======================================================================
554 // function: addSection
555 // purpose: adds a section with the given points
556 //=======================================================================
557 int CurveCreator_Curve::addSection
558 (const std::string& theName, const CurveCreator::SectionType theType,
559 const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
561 int resISection = -1;
562 // Set the difference.
564 if (addEmptyDiff()) {
565 myListDiffs.back().init(this, CurveCreator_Operation::AddSection,
566 theName, thePoints, theType, theIsClosed);
569 resISection = addSectionInternal(theName, theType, theIsClosed, thePoints);
575 //! For internal use only! Undo/Redo are not used here.
576 bool CurveCreator_Curve::removeSectionInternal( const int theISection )
578 if (theISection == -1) {
579 delete mySections.back();
580 mySections.pop_back();
582 CurveCreator::Sections::iterator anIterRm = mySections.begin() + theISection;
585 mySections.erase(anIterRm);
591 //! Removes the given sections.
592 bool CurveCreator_Curve::removeSection( const int theISection )
595 // Set the difference.
598 myListDiffs.back().init(this, CurveCreator_Operation::RemoveSection, theISection);
600 res = removeSectionInternal( theISection );
607 * Get number of points in specified section or (the total number of points
608 * in Curve if theISection is equal to -1).
610 int CurveCreator_Curve::getNbPoints( const int theISection ) const
614 if (theISection == -1) {
616 const int aNbSections = getNbSections();
618 for (; i < aNbSections; i++) {
619 aNbCoords += mySections[i]->myPoints.size();
622 if ( ( theISection >= 0 ) && ( theISection < mySections.size() ) )
623 aNbCoords = mySections.at(theISection)->myPoints.size();
626 return aNbCoords/myDimension;
629 //! Get "closed" flag of the specified section
630 bool CurveCreator_Curve::isClosed( const int theISection ) const
632 return mySections.at(theISection)->myIsClosed;
635 //! For internal use only! Undo/Redo are not used here.
636 bool CurveCreator_Curve::setClosedInternal( const int theISection,
637 const bool theIsClosed )
639 if (theISection == -1) {
640 int aSize = mySections.size();
643 for (i = 0; i < aSize; i++) {
644 mySections[i]->myIsClosed = theIsClosed;
648 mySections.at(theISection)->myIsClosed = theIsClosed;
655 * Set "closed" flag of the specified section (all sections if
656 * \a theISection is -1).
658 bool CurveCreator_Curve::setClosed( const int theISection,
659 const bool theIsClosed )
662 // Set the difference.
664 if (addEmptyDiff()) {
665 myListDiffs.back().init(this, CurveCreator_Operation::SetClosed,
666 theIsClosed, theISection);
668 res = setClosedInternal( theISection, theIsClosed );
673 //! Returns specified section name
674 std::string CurveCreator_Curve::getSectionName( const int theISection ) const
676 if( ( theISection >= 0 ) && ( theISection < mySections.size() ))
677 return mySections.at(theISection)->myName;
681 //! For internal use only! Undo/Redo are not used here.
682 bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
683 const std::string& theName )
686 if( ( theISection >= 0 ) && ( theISection < mySections.size() )){
687 mySections.at(theISection)->myName = theName;
693 /** Set name of the specified section */
694 bool CurveCreator_Curve::setSectionName( const int theISection,
695 const std::string& theName )
698 // Set the difference.
700 if (addEmptyDiff()) {
701 myListDiffs.back().init(this, CurveCreator_Operation::RenameSection,
702 theName, theISection);
704 res = setSectionNameInternal( theISection, theName );
709 //! Get type of the specified section
710 CurveCreator::SectionType CurveCreator_Curve::getSectionType
711 ( const int theISection ) const
713 return mySections.at(theISection)->myType;
716 //! For internal use only! Undo/Redo are not used here.
717 bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
718 const CurveCreator::SectionType theType )
720 if (theISection == -1) {
722 const int aNbSections = getNbSections();
724 for (; i < aNbSections; i++) {
725 mySections[i]->myType = theType;
729 if( mySections.at(theISection)->myType != theType ){
730 mySections.at(theISection)->myType = theType;
738 * Set type of the specified section (or all sections
739 * if \a theISection is -1).
741 bool CurveCreator_Curve::setSectionType( const int theISection,
742 const CurveCreator::SectionType theType )
746 // Set the difference.
747 if (addEmptyDiff()) {
748 myListDiffs.back().init(this, CurveCreator_Operation::SetType,
749 theType, theISection);
752 res = setSectionTypeInternal( theISection, theType );
759 /***********************************************/
760 /*** Point methods ***/
761 /***********************************************/
763 //! For internal use only! Undo/Redo are not used here.
764 bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap )
767 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
768 CurveCreator_Section *aSection = 0;
769 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
770 int anISection = anIt->first;
771 aSection = mySections.at(anISection);
773 CurveCreator::PosPointsList aSectionPoints = anIt->second;
774 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
775 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
776 int anIPnt = (*aPntIt)->myID;
777 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
778 CurveCreator::Coordinates::iterator anIterPosition;
780 anIterPosition = aSection->myPoints.end();
782 anIterPosition = aSection->myPoints.begin() + toICoord(anIPnt);
783 CurveCreator::Coordinates::const_iterator aFirstPosition =
785 aSection->myPoints.insert(anIterPosition,
786 aCoords.begin(), aCoords.end());
797 * Add one point to the specified section starting from the given theIPnt index
798 * (or at the end of points if \a theIPnt is -1).
800 bool CurveCreator_Curve::addPoints( const CurveCreator::Coordinates& theCoords,
801 const int theISection,
805 CurveCreator::Coordinates aCoords = theCoords;
806 // Set the difference.
808 if (addEmptyDiff()) {
809 CurveCreator_ICurve::SectionToPointCoordsList aList;
810 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theCoords));
811 myListDiffs.back().init(this, CurveCreator_Operation::InsertPoints,
814 CurveCreator::SectionsMap aSectionsMap;
815 CurveCreator::PosPointsList aPoints;
816 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theCoords );
817 aPoints.push_back( aPosPoint );
818 aSectionsMap[theISection] = aPoints;
820 res = addPointsInternal( aSectionsMap );
826 //! For internal use only! Undo/Redo are not used here.
827 bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theSectionsMap )
831 CurveCreator::SectionsMap::const_iterator anIt = theSectionsMap.begin();
832 CurveCreator_Section *aSection = 0;
833 for ( ; anIt != theSectionsMap.end(); anIt++ ) {
834 int anISection = anIt->first;
835 aSection = mySections.at(anISection);
837 CurveCreator::PosPointsList aSectionPoints = anIt->second;
838 CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
839 for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
840 int anIPnt = (*aPntIt)->myID;
841 CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
842 for ( int i = 0; i < myDimension; i++)
843 aSection->myPoints.at(toICoord(anIPnt) + i) = aCoords[i];
854 //! Set coordinates of specified point
855 bool CurveCreator_Curve::setPoint( const int theISection,
857 const CurveCreator::Coordinates& theNewCoords )
860 // Set the difference.
862 if (addEmptyDiff()) {
863 CurveCreator_ICurve::SectionToPointCoordsList aList;
864 aList.push_back(std::make_pair(std::make_pair(theISection, theIPnt), theNewCoords));
865 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
868 CurveCreator::SectionsMap aSectionsMap;
869 CurveCreator::PosPointsList aPoints;
870 CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( theIPnt, theNewCoords );
871 aPoints.push_back( aPosPoint );
872 aSectionsMap[theISection] = aPoints;
874 int aSize1 = getNbPoints( theISection );
875 res = setPointInternal( aSectionsMap );
876 int aSize2 = getNbPoints( theISection );
883 //! Set coordinates of specified points from different sections
884 bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords)
887 // Set the difference.
889 if (addEmptyDiff()) {
890 myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
891 theSectionToPntCoords);
893 CurveCreator::SectionsMap aSectionsMap;
894 CurveCreator::PosPointsList aPosPoints;
895 CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
896 theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
897 int aSectionId, aPointId;
898 for ( ; anIt != aLast; anIt++ ) {
900 aSectionId = anIt->first.first;
901 aPointId = anIt->first.second;
902 CurveCreator::Coordinates aNewCoords = anIt->second;
903 CurveCreator_PosPoint* aPosPoint =
904 new CurveCreator_PosPoint( aPointId, aNewCoords );
905 if( aSectionsMap.find(aSectionId) != aSectionsMap.end() )
906 aPosPoints = aSectionsMap[aSectionId];
907 aPosPoints.push_back( aPosPoint );
908 aSectionsMap[aSectionId] = aPosPoints;
911 res = setPointInternal( aSectionsMap );
917 //! For internal use only! Undo/Redo are not used here.
918 bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoints )
921 std::map<int, std::list<int> > aConvPoints;
922 convert( thePoints, aConvPoints );
923 std::map<int, std::list<int> >::const_iterator anIt = aConvPoints.begin(),
924 aLast = aConvPoints.end();
925 CurveCreator_Section *aSection = 0;
926 for ( ; anIt != aLast; anIt++ ) {
927 int aSectionId = anIt->first;
928 aSection = mySections.at(aSectionId);
930 std::list<int> aSectionPoints = anIt->second;
931 aSectionPoints.sort();
932 std::list<int>::const_reverse_iterator aPntIt = aSectionPoints.rbegin();
933 for( ; aPntIt != aSectionPoints.rend(); aPntIt++ ){
934 int aPntIndx = *aPntIt;
935 CurveCreator::Coordinates::iterator aFirstPosition;
937 aFirstPosition = aSection->myPoints.end() - getDimension();
939 aFirstPosition = aSection->myPoints.begin() + toICoord(aPntIndx);
940 aSection->myPoints.erase( aFirstPosition, aFirstPosition + getDimension() );
950 //! Remove point with given id
951 bool CurveCreator_Curve::removePoint( const int theISection, const int theIPnt )
954 // Set the difference.
956 if (addEmptyDiff()) {
957 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
958 theISection, theIPnt);
960 SectionToPointList aListOfSectionsToPoints;
961 aListOfSectionsToPoints.push_back(std::make_pair(theISection, theIPnt));
962 res = removePointsInternal( aListOfSectionsToPoints );
967 //! Remove several points from different sections with given ids
968 bool CurveCreator_Curve::removeSeveralPoints( const SectionToPointList &theSectionToPntIDs)
971 // Set the difference.
973 if (addEmptyDiff()) {
974 myListDiffs.back().init(this, CurveCreator_Operation::RemovePoints,
977 res = removePointsInternal( theSectionToPntIDs );
982 //=======================================================================
983 // function: getCoordinates
985 //=======================================================================
986 CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection,
987 const int theIPnt) const
989 CurveCreator_Section *aSection = mySections.at(theISection);
990 CurveCreator::Coordinates::const_iterator
991 anIter = aSection->myPoints.begin() + toICoord(theIPnt);
992 CurveCreator::Coordinates aResult(anIter, anIter + myDimension);
997 //=======================================================================
998 // function: getPoints
1000 //=======================================================================
1001 CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
1003 CurveCreator::Coordinates aCoords;
1004 if ( ( theISection >= 0 ) && ( theISection < mySections.size() ) )
1006 aCoords = mySections.at(theISection)->myPoints;
1012 /***********************************************/
1013 /*** Presentation methods ***/
1014 /***********************************************/
1015 std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire() const
1017 std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
1018 std::vector<Handle_AIS_InteractiveObject> aSectionObjects;
1019 for( int iSection = 0 ; iSection < getNbSections() ; iSection++ ){
1020 aSectionObjects = constructSection( iSection );
1021 for( int iObject = 0 ; iObject < aSectionObjects.size() ; iObject++ ){
1022 aCurveRepresentation.push_back( aSectionObjects.at(iObject) );
1025 return aCurveRepresentation;
1028 void CurveCreator_Curve::getPoint( const int theISection, const int theIPoint,
1029 gp_Pnt& thePoint ) const
1031 double anX, anY, aZ;
1032 getCoordinates( theISection, theIPoint, anX, anY, aZ );
1033 thePoint = gp_Pnt( anX, anY, aZ);