+Handle_AIS_Point CurveCreator_Curve::getAISPoint( int theISection, int theIPoint ) const
+{
+ double anX, anY, aZ;
+ getCoordinates( theISection, theIPoint, anX, anY, aZ );
+ gp_Pnt aPoint( anX, anY, aZ);
+
+ AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
+ return aPnt;
+}
+
+Handle_AIS_Line CurveCreator_Curve::getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const
+{
+ double anX, anY, aZ;
+ getCoordinates( theISection, theIPoint1, anX, anY, aZ );
+ gp_Pnt aPoint1( anX, anY, aZ);
+
+ double anX2, anY2, aZ2;
+ getCoordinates( theISection, theIPoint2, anX2, anY2, aZ2 );
+//MTN to avoid crash during line construction
+ if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
+ aZ2 += 1e-7;
+ }
+
+ gp_Pnt aPoint2( anX2, anY2, aZ2 );
+
+ AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
+ return aLine;
+}
+
+void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
+{
+ CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
+ theX = aCoords[0];
+ theY = aCoords[1];
+ theZ = 0.;
+ if( getDimension() == CurveCreator::Dim3d ){
+ theZ = aCoords[2];
+ }
+}
+
+void CurveCreator_Curve::redisplayCurve()
+{
+ if( myDisplayer ) {
+ myDisplayer->erase();
+ myDisplayer->display( constructWire() );
+ }
+}
+
+//! For internal use only! Undo/Redo are not used here.
+bool CurveCreator_Curve::moveSectionInternal(const int theISection,
+ const int theNewIndex)
+{
+ bool res = false;
+ if (theISection != theNewIndex) {
+ CurveCreator_Section *aSection = mySections.at(theISection);
+
+ // Remove section
+ CurveCreator::Sections::iterator anIter = mySections.begin() + theISection;
+
+ mySections.erase(anIter);
+
+ // Insert section.
+ anIter = mySections.begin() + theNewIndex;
+ mySections.insert(anIter, aSection);
+ res = true;
+ }
+ return res;
+}
+
+//=======================================================================
+// function: moveSection
+// purpose:
+//=======================================================================
+bool CurveCreator_Curve::moveSection(const int theISection,
+ const int theNewIndex)
+{
+ bool res = false;
+ // Set the difference.
+ startOperation();
+ if (addEmptyDiff()) {
+ myListDiffs.back().init(this, CurveCreator_Operation::MoveSection,
+ theISection, theNewIndex);
+ }
+
+ // Update the curve.
+ res = moveSectionInternal(theISection, theNewIndex);
+ finishOperation();
+ return res;
+}
+
+void CurveCreator_Curve::convert( const SectionToPointList& thePoints,
+ std::map< int, std::list<int> >& theConvPoints )
+{
+ theConvPoints.clear();
+
+ SectionToPointList::const_iterator anIt = thePoints.begin(), aLast = thePoints.end();
+ std::list<int> aPoints;
+ int aSectionId, aPointId;
+ for ( ; anIt != aLast; anIt++ ) {
+ aSectionId = anIt->first;
+ aPointId = anIt->second;
+ aPoints.clear();
+ if ( theConvPoints.find( aSectionId ) != theConvPoints.end() )
+ aPoints = theConvPoints[aSectionId];
+ aPoints.push_back( aPointId );
+ theConvPoints[aSectionId] = aPoints;
+ }
+}
+