Salome HOME
Updated copyright comment
[modules/geom.git] / src / CurveCreator / CurveCreator_Curve.cxx
index e20705c46b2c779655a90a8df2a3e08dd893c831..856885bfba258fde7a2b9af5453c65b7b2256bd1 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013-2024  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include <AIS_Shape.hxx>
 #include <AIS_InteractiveObject.hxx>
 #include <Geom_CartesianPoint.hxx>
+#include <TopoDS_Iterator.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Lin.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Wire.hxx>
+#include <TopoDS_Shape.hxx>
+#include <AIS_ColoredShape.hxx>
+
+#include <Prs3d_PointAspect.hxx>
+#include <iostream>
+#define DEBTRACE(msg) {std::cerr<<std::flush<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<std::endl<<std::flush;}
 
 #include <stdio.h>
 
 // purpose:
 //=======================================================================
 CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimension )
-: myIsLocked  (false),
+: mySkipSorting (false),
+  myIsLocked (false),
   myDimension (theDimension),
   myDisplayer (NULL),
-  myAISShape  (NULL),
-  myNbUndos   (0),
-  myNbRedos   (0),
+  myPointAspectColor (Quantity_NOC_ROYALBLUE4),
+  //myCurveColor (Quantity_NOC_RED),
+  myLineWidth (1),
+  myNbUndos (0),
+  myNbRedos (0),
   myUndoDepth (-1),
-  myOpLevel(0),
-  mySkipSorting(false)
+  myOpLevel (0),
+  myAISShape (NULL),
+  myEraseAll (true)
 {
 }
 
@@ -87,12 +98,12 @@ std::string CurveCreator_Curve::getUniqSectionName() const
         sprintf( aBuffer, "Section_%d", i+1 );
         std::string aName(aBuffer);
         int j;
-        for( j = 0 ; j < mySections.size() ; j++ ){
-            aSection = getSection( j );
+        for( j = 0 ; j < (int)mySections.size() ; j++ ){
+            aSection = (CurveCreator_Section*)getSection( j );
             if ( aSection && aSection->myName == aName )
               break;
         }
-        if( j == mySections.size() )
+        if( j == (int)mySections.size() )
             return aName;
     }
     return "";
@@ -245,12 +256,16 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double&
   }
 }
 
-void CurveCreator_Curve::redisplayCurve()
+void CurveCreator_Curve::redisplayCurve(bool preEraseAllObjects)
 {
-  if( myDisplayer ) {
-    myDisplayer->eraseAll( false );
+  //DEBTRACE("redisplayCurve");
+  if( myDisplayer )
+  {
+    if (preEraseAllObjects)
+      myDisplayer->eraseAll( false );
+    else
+      myDisplayer->erase( myAISShape, false);
     myAISShape = NULL;
-
     myDisplayer->display( getAISObject( true ), true );
   }
 }
@@ -263,7 +278,7 @@ bool CurveCreator_Curve::moveSectionInternal(const int theISection,
   int aMovedSectionId = theISection >= 0 ? theISection : mySections.size()-1;
 
   if (aMovedSectionId != theNewIndex) {
-    CurveCreator_Section* aSection = getSection( aMovedSectionId );
+    CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( aMovedSectionId );
 
     // Remove section
     CurveCreator::Sections::iterator anIter = mySections.begin() + aMovedSectionId;
@@ -352,8 +367,12 @@ bool CurveCreator_Curve::redo()
 bool CurveCreator_Curve::clearInternal()
 {
   // erase curve from the viewer
-  if( myDisplayer ) {
-    myDisplayer->eraseAll( true );
+  if( myDisplayer )
+  {
+    if (myEraseAll)
+      myDisplayer->eraseAll( true );
+    else
+      myDisplayer->erase(myAISShape, false);
     myAISShape = NULL;
   }
   // Delete all allocated data.
@@ -362,13 +381,13 @@ bool CurveCreator_Curve::clearInternal()
 
   CurveCreator_Section* aSection;
   for (; i < aNbSections; i++) {
-    aSection = getSection( i );
+    aSection = (CurveCreator_Section*)getSection( i );
     if ( aSection )
       delete aSection;
   }
 
   mySections.clear();
-  
+
   return true;
 }
 
@@ -389,6 +408,23 @@ bool CurveCreator_Curve::clear()
   return res;
 }
 
+//=======================================================================
+// function: clear
+// purpose:
+//=======================================================================
+void CurveCreator_Curve::SetEraseAllState(bool toEraseAll)
+{
+  myEraseAll = toEraseAll;
+}
+//=======================================================================
+// function: clear
+// purpose:
+//=======================================================================
+bool CurveCreator_Curve::GetEraseAllState() const
+{
+  return myEraseAll;
+}
+
 //! For internal use only! Undo/Redo are not used here.
 bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
 {
@@ -397,7 +433,8 @@ bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
     return res;
 
   int anISectionMain = theSections.front();
-  CurveCreator_Section* aSectionMain = getSection( anISectionMain );
+  CurveCreator_Section* aSectionMain =
+    (CurveCreator_Section*)getSection( anISectionMain );
 
   std::list <int> aSectionsToJoin = theSections;
   aSectionsToJoin.erase( aSectionsToJoin.begin() ); // skip the main section
@@ -408,7 +445,7 @@ bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
   std::list<int>::const_iterator anIt = aSectionsToJoin.begin(), aLast = aSectionsToJoin.end();
   CurveCreator_Section* aSection;
   for (; anIt != aLast; anIt++) {
-    aSection = getSection( *anIt );
+    aSection = (CurveCreator_Section*)getSection( *anIt );
     aSectionMain->myPoints.insert(aSectionMain->myPoints.end(), aSection->myPoints.begin(),
                                   aSection->myPoints.end());
     res = removeSectionInternal(*anIt);
@@ -416,7 +453,7 @@ bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
       break;
   }
 
-  redisplayCurve();
+  redisplayCurve(false);
   return res;
 }
 
@@ -446,7 +483,8 @@ int CurveCreator_Curve::getNbSections() const
 //! For internal use only! Undo/Redo are not used here.
 int CurveCreator_Curve::addSectionInternal
         (const std::string& theName, const CurveCreator::SectionType theType,
-         const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
+         const bool theIsClosed, const CurveCreator::Coordinates &thePoints,
+         const Quantity_Color& aColor)
 {
   CurveCreator_Section *aSection = new CurveCreator_Section;
 
@@ -458,8 +496,9 @@ int CurveCreator_Curve::addSectionInternal
   aSection->myType     = theType;
   aSection->myIsClosed = theIsClosed;
   aSection->myPoints   = thePoints;
+  aSection->myColor    = aColor;//getRandColor();  //TODO temp
   mySections.push_back(aSection);
-  redisplayCurve();
+  redisplayCurve(false);
   return mySections.size()-1;
 }
 
@@ -480,7 +519,9 @@ int CurveCreator_Curve::addSection
                             theName, aCoords, theType, theIsClosed);
   }
 
-  resISection = addSectionInternal(theName, theType, theIsClosed, aCoords);
+  Quantity_Color aRColor = CurveCreator_Utils::getRandColor();
+
+  resISection = addSectionInternal(theName, theType, theIsClosed, aCoords, aRColor);
 
   finishOperation();
   return resISection;
@@ -501,7 +542,7 @@ int CurveCreator_Curve::addSection
                             theName, thePoints, theType, theIsClosed);
   }
 
-  resISection = addSectionInternal(theName, theType, theIsClosed, thePoints);
+  resISection = addSectionInternal(theName, theType, theIsClosed, thePoints, Quantity_NOC_YELLOW);
 
   finishOperation();
   return resISection;
@@ -511,18 +552,21 @@ int CurveCreator_Curve::addSection
 bool CurveCreator_Curve::removeSectionInternal( const int theISection )
 {
   if (theISection == -1) {
+    myRemColors.push_back(mySections.back()->myColor);
     delete mySections.back();
     mySections.pop_back();
   } else {
     CurveCreator::Sections::iterator anIterRm = mySections.begin() + theISection;
 
+    myRemColors.push_back((*anIterRm)->myColor);
+
     delete *anIterRm;
     mySections.erase(anIterRm);
   }
-  redisplayCurve();
+  redisplayCurve(false);
   return true;
 }
-  
+
 //! Removes the given sections.
 bool CurveCreator_Curve::removeSection( const int theISection )
 {
@@ -538,6 +582,49 @@ bool CurveCreator_Curve::removeSection( const int theISection )
   return res;
 }
 
+bool CurveCreator_Curve::setColorSection( int SectInd, Quantity_Color theNewColor )
+{
+  bool res = false;
+  // Set the difference.
+  startOperation();
+
+  int ColorParam[3] = { (int)( theNewColor.Red() * 255 ),
+    (int)( theNewColor.Green() * 255 ),
+    (int)( theNewColor.Blue() * 255 ) };
+
+  if (addEmptyDiff())
+    myListDiffs.back().init(this, CurveCreator_Operation::SetColorSection, SectInd, ColorParam);
+
+  setColorSectionInternal(SectInd, theNewColor);
+
+  finishOperation();
+  return res;
+}
+
+void CurveCreator_Curve::setColorSectionInternal( int SectInd, Quantity_Color theNewColor )
+{
+  CurveCreator_Section* aSec = (CurveCreator_Section*)(getSection(SectInd));
+  aSec->myColor = theNewColor;
+
+  redisplayCurve(false);
+}
+
+Quantity_Color CurveCreator_Curve::getColorSection( int SectInd ) const
+{
+  CurveCreator_Section* aSec = (CurveCreator_Section*)(getSection(SectInd));
+  return aSec->myColor;
+}
+
+Quantity_Color CurveCreator_Curve::getLastRemovedColor() const
+{
+  return myRemColors.empty() ? Quantity_NOC_BLACK : myRemColors.back();
+}
+
+void CurveCreator_Curve::popLastRemovedColor()
+{
+  myRemColors.pop_back();
+}
+
 /**
  *  Get number of points in specified section or (the total number of points
  *  in Curve if theISection is equal to -1).
@@ -552,12 +639,12 @@ int CurveCreator_Curve::getNbPoints( const int theISection ) const
     const int aNbSections = getNbSections();
 
     for (; i < aNbSections; i++) {
-      aSection = getSection( i );
+      aSection = (CurveCreator_Section*)getSection( i );
       if ( aSection )
         aNbCoords += aSection->myPoints.size();
     }
   } else {
-    aSection = getSection( theISection );
+    aSection = (CurveCreator_Section*)getSection( theISection );
     if ( aSection )
       aNbCoords = aSection->myPoints.size();
   }
@@ -592,12 +679,13 @@ void CurveCreator_Curve::saveCoordDiff( const SectionToPointCoordsList &theOldCo
 //! Get "closed" flag of the specified section
 bool CurveCreator_Curve::isClosed( const int theISection ) const
 {
-  CurveCreator_Section* aSection = getSection( theISection );
+  const CurveCreator_Section* aSection =
+    (CurveCreator_Section*)getSection( theISection );
   return aSection ? aSection->myIsClosed : false;
 }
 
 //! For internal use only! Undo/Redo are not used here.
-bool CurveCreator_Curve::setClosedInternal( const int theISection, 
+bool CurveCreator_Curve::setClosedInternal( const int theISection,
                                             const bool theIsClosed )
 {
   CurveCreator_Section* aSection = 0;
@@ -606,17 +694,17 @@ bool CurveCreator_Curve::setClosedInternal( const int theISection,
     int i;
 
     for (i = 0; i < aSize; i++) {
-      aSection = getSection( i );
+      aSection = (CurveCreator_Section*)getSection( i );
       if( aSection ) {
         aSection->myIsClosed = theIsClosed;
-        redisplayCurve();
+        redisplayCurve(false);
       }
     }
   } else {
-    aSection = getSection( theISection );
+    aSection = (CurveCreator_Section*)getSection( theISection );
     if ( aSection ) {
       aSection->myIsClosed = theIsClosed;
-      redisplayCurve();
+      redisplayCurve(false);
     }
   }
   return true;
@@ -626,7 +714,7 @@ bool CurveCreator_Curve::setClosedInternal( const int theISection,
  *  Set "closed" flag of the specified section (all sections if
  *  \a theISection is -1).
  */
-bool CurveCreator_Curve::setClosed( const int theISection, 
+bool CurveCreator_Curve::setClosed( const int theISection,
                                     const bool theIsClosed )
 {
   bool res = false;
@@ -644,16 +732,16 @@ bool CurveCreator_Curve::setClosed( const int theISection,
 //! Returns specified section name
 std::string CurveCreator_Curve::getSectionName( const int theISection ) const
 {
-  CurveCreator_Section* aSection = getSection( theISection );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
   return aSection ? aSection->myName : "";
 }
 
 //! For internal use only! Undo/Redo are not used here.
-bool CurveCreator_Curve::setSectionNameInternal( const int theISection, 
+bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
                                                  const std::string& theName )
 {
   bool res = false;
-  CurveCreator_Section* aSection = getSection( theISection );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
   if( aSection ) {
     aSection->myName = theName;
     res = true;
@@ -662,7 +750,7 @@ bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
 }
 
 /** Set name of the specified section */
-bool CurveCreator_Curve::setSectionName( const int theISection, 
+bool CurveCreator_Curve::setSectionName( const int theISection,
                                          const std::string& theName )
 {
   bool res = false;
@@ -681,12 +769,12 @@ bool CurveCreator_Curve::setSectionName( const int theISection,
 CurveCreator::SectionType CurveCreator_Curve::getSectionType
   ( const int theISection ) const
 {
-  CurveCreator_Section* aSection = getSection( theISection );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
   return aSection ? aSection->myType : CurveCreator::Polyline;
 }
 
 //! For internal use only! Undo/Redo are not used here.
-bool CurveCreator_Curve::setSectionTypeInternal( const int theISection, 
+bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
                                                  const CurveCreator::SectionType theType )
 {
   CurveCreator_Section* aSection;
@@ -695,16 +783,16 @@ bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
     const int aNbSections = getNbSections();
 
     for (; i < aNbSections; i++) {
-      aSection = getSection( i );
+      aSection = (CurveCreator_Section*)getSection( i );
       if ( aSection )
         aSection->myType = theType;
     }
-    redisplayCurve();
+    redisplayCurve(false);
   } else {
-    aSection = getSection( theISection );
+    aSection = (CurveCreator_Section*)getSection( theISection );
     if ( aSection && aSection->myType != theType ){
       aSection->myType = theType;
-      redisplayCurve();
+      redisplayCurve(false);
     }
   }
   return true;
@@ -714,7 +802,7 @@ bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
  *  Set type of the specified section (or all sections
  *  if \a theISection is -1).
  */
-bool CurveCreator_Curve::setSectionType( const int theISection, 
+bool CurveCreator_Curve::setSectionType( const int theISection,
                                          const CurveCreator::SectionType theType )
 {
   bool res = false;
@@ -744,7 +832,7 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the
   CurveCreator_Section *aSection = 0;
   for ( ; anIt != theSectionsMap.end(); anIt++ ) {
     int anISection = anIt->first;
-    aSection = getSection( anISection );
+    aSection = (CurveCreator_Section*)getSection( anISection );
     if( aSection ) {
       CurveCreator::PosPointsList aSectionPoints = anIt->second;
       CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
@@ -756,8 +844,8 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the
           anIterPosition = aSection->myPoints.end();
         else
           anIterPosition = aSection->myPoints.begin() + toICoord(anIPnt);
-        CurveCreator::Coordinates::const_iterator aFirstPosition = 
-          aCoords.begin();
+        /*CurveCreator::Coordinates::const_iterator aFirstPosition =
+          aCoords.begin();*/
         aSection->myPoints.insert(anIterPosition,
                                   aCoords.begin(), aCoords.end());
       }
@@ -765,7 +853,7 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the
     }
   }
   if(res)
-    redisplayCurve();
+    redisplayCurve(false);
   return res;
 }
 
@@ -777,6 +865,7 @@ bool CurveCreator_Curve::addPoints( const CurveCreator::Coordinates& theCoords,
                                     const int theISection,
                                     const int theIPnt )
 {
+  //DEBTRACE("addPoints");
   bool res = false;
   CurveCreator::Coordinates aCoords = theCoords;
   // Set the difference.
@@ -808,8 +897,8 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS
   CurveCreator_Section *aSection = 0;
   for ( ; anIt != theSectionsMap.end(); anIt++ ) {
     int anISection = anIt->first;
-    aSection = getSection( anISection );
-    if( aSection ) { 
+    aSection = (CurveCreator_Section*)getSection( anISection );
+    if( aSection ) {
       CurveCreator::PosPointsList aSectionPoints = anIt->second;
       CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
       for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
@@ -822,8 +911,8 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS
     }
   }
   if(res)
-    redisplayCurve();
-  
+    redisplayCurve(false);
+
   return res;
 }
 
@@ -832,6 +921,7 @@ bool CurveCreator_Curve::setPoint( const int theISection,
                                    const int theIPnt,
                                    const CurveCreator::Coordinates& theNewCoords )
 {
+  //DEBTRACE("setPoint");
   bool res = false;
   // Set the difference.
   startOperation();
@@ -847,19 +937,20 @@ bool CurveCreator_Curve::setPoint( const int theISection,
   aPoints.push_back( aPosPoint );
   aSectionsMap[theISection] = aPoints;
 
-  int aSize1 = getNbPoints( theISection );
+  /*int aSize1 = */getNbPoints( theISection ); // todo: unused variable
   res = setPointInternal( aSectionsMap );
-  int aSize2 = getNbPoints( theISection );
+  /*int aSize2 = */getNbPoints( theISection ); // todo: unused variable
 
   finishOperation();
 
-  return res; 
+  return res;
 }
 
 //! Set coordinates of specified points from different sections
 bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
                                            const bool theIsToSaveDiff )
 {
+  //DEBTRACE("setSeveralPoints");
   bool res = false;
   // Set the difference.
   startOperation();
@@ -869,7 +960,7 @@ bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSe
   }
   CurveCreator::SectionsMap aSectionsMap;
   CurveCreator::PosPointsList aPosPoints;
-  CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = 
+  CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
     theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
   int aSectionId, aPointId;
   for ( ; anIt != aLast; anIt++ ) {
@@ -877,18 +968,18 @@ bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSe
     aSectionId = anIt->first.first;
     aPointId = anIt->first.second;
     CurveCreator::Coordinates aNewCoords = anIt->second;
-    CurveCreator_PosPoint* aPosPoint = 
+    CurveCreator_PosPoint* aPosPoint =
       new CurveCreator_PosPoint( aPointId, aNewCoords );
     if( aSectionsMap.find(aSectionId) != aSectionsMap.end() )
       aPosPoints = aSectionsMap[aSectionId];
     aPosPoints.push_back( aPosPoint );
     aSectionsMap[aSectionId] = aPosPoints;
-    
+
   }
   res = setPointInternal( aSectionsMap );
   finishOperation();
 
-  return res; 
+  return res;
 }
 
 //! For internal use only! Undo/Redo are not used here.
@@ -904,7 +995,7 @@ bool CurveCreator_Curve::removePointsInternal( const SectionToPointList &thePoin
     aRes = removeSectionPoints(aSectionId, anIt->second);
   }
   if( aRes)
-    redisplayCurve();
+    redisplayCurve(false);
 
   return aRes;
 }
@@ -948,7 +1039,8 @@ bool CurveCreator_Curve::removeSeveralPoints( const SectionToPointList &theSecti
 CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection,
                                                         const int theIPnt) const
 {
-  CurveCreator_Section* aSection = getSection( theISection );
+  //DEBTRACE("getPoint");
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
   CurveCreator::Coordinates::const_iterator
     anIter = aSection->myPoints.begin() + toICoord(theIPnt);
   CurveCreator::Coordinates aResult(anIter, anIter + myDimension);
@@ -960,32 +1052,58 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection,
 // function: getPoints
 // purpose:
 //=======================================================================
-CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
+CurveCreator::Coordinates CurveCreator_Curve::getCoords( int theISection ) const
 {
-  CurveCreator_Section* aSection = getSection( theISection );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
   return aSection ? aSection->myPoints : CurveCreator::Coordinates();
 }
 
+Handle(TColgp_HArray1OfPnt) CurveCreator_Curve::GetDifferentPoints( int theISection ) const
+{
+  //DEBTRACE("getPoints");
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
+  return aSection ? aSection->GetDifferentPoints( (int)myDimension ) : Handle(TColgp_HArray1OfPnt)();
+}
+
 void CurveCreator_Curve::constructAISObject()
 {
+  //DEBTRACE("constructAISObject");
   TopoDS_Shape aShape;
-  CurveCreator_Utils::constructShape( this, aShape );
+  mySect2Shape.Clear();
+  CurveCreator_Utils::constructShape( this, aShape, &mySect2Shape );
+  myAISShape = new AIS_ColoredShape( aShape );
+  AIS_ColoredShape* AISColoredShape = dynamic_cast<AIS_ColoredShape*>(myAISShape);
 
-  myAISShape = new AIS_Shape( aShape );
-}
+  std::map<int, TopoDS_Shape>::iterator it;
 
-CurveCreator_Section* CurveCreator_Curve::getSection( const int theSectionId ) const
-{
-  CurveCreator_Section *aSection = 0;
-  if ( theSectionId >= 0 && theSectionId < mySections.size() )
-    aSection = mySections.at( theSectionId );
+  //for ( it = mySect2Shape.begin(); it != mySect2Shape.end(); it++ )
+  for (int i = 1; i <= mySect2Shape.Extent(); i++ )
+  {
+    CurveCreator_Section* aSect = (CurveCreator_Section*)getSection(mySect2Shape.FindKey(i));
+    Quantity_Color aColor = aSect->myColor;
+    const TopoDS_Shape& aShape = mySect2Shape.FindFromIndex(i); //should contain: one wire + vertices
+    TopoDS_Iterator it(aShape);
+    for (;it.More();it.Next())
+    {
+      if (it.Value().ShapeType() == TopAbs_WIRE)
+        AISColoredShape->SetCustomColor(it.Value(), aColor);
+    }
+  }
 
-  return aSection;
+  // myAISShape->SetColor( myCurveColor );
+  myAISShape->SetWidth( myLineWidth );
+  Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
+  anAspect->SetScale( 3.0 );
+  anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT);
+  anAspect->SetColor(myPointAspectColor);
+  myAISShape->Attributes()->SetPointAspect( anAspect );
 }
 
 Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
 {
-  if ( !myAISShape && theNeedToBuild ) {
+  //DEBTRACE("getAISObject");
+  if ( !myAISShape && theNeedToBuild )
+  {
     CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
     aCurve->constructAISObject();
   }
@@ -997,7 +1115,7 @@ bool CurveCreator_Curve::removeSectionPoints( const int theSectionId,
 {
   bool aRes = false;
 
-  CurveCreator_Section* aSection = getSection( theSectionId );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theSectionId );
   if ( !aSection )
     return aRes;