}
void CurveCreator_Curve::convert( const SectionToPointList& thePoints,
- std::map<int,std::list<int>>& theConvPoints )
+ std::map< int, std::list<int> >& theConvPoints )
{
theConvPoints.clear();
const int theISectionFrom )
{
bool res = false;
- if (theISectionTo != theISectionFrom) {
+ if (mySections.size() >= 2 &&
+ ( theISectionTo != theISectionFrom || (theISectionTo == -1 && theISectionFrom == -1) )) {
startOperation();
+ int aISectionTo = getNbSections()-1;
+ int aISectionFrom = 0;
if (addEmptyDiff())
- myListDiffs.back().init(this, CurveCreator_Operation::Join, theISectionTo, theISectionFrom);
+ myListDiffs.back().init(this, CurveCreator_Operation::Join, aISectionTo, aISectionFrom);
- res = joinInternal( theISectionTo, theISectionFrom );
+ res = joinInternal( aISectionTo, aISectionFrom );
finishOperation();
}
aNbCoords += mySections[i]->myPoints.size();
}
} else {
- aNbCoords = mySections.at(theISection)->myPoints.size();
+ if ( ( theISection >= 0 ) && ( theISection < mySections.size() ) )
+ aNbCoords = mySections.at(theISection)->myPoints.size();
}
return aNbCoords/myDimension;
for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
int anIPnt = (*aPntIt)->myID;
CurveCreator::Coordinates aCoords = (*aPntIt)->myCoords;
- aSection->myPoints.assign(aCoords.begin(), aCoords.end());
+ for ( int i = 0; i < myDimension; i++)
+ aSection->myPoints.at(toICoord(anIPnt) + i) = aCoords[i];
}
res = true;
}
aPoints.push_back( aPosPoint );
aSectionsMap[theISection] = aPoints;
+ int aSize1 = getNbPoints( theISection );
res = setPointInternal( aSectionsMap );
+ int aSize2 = getNbPoints( theISection );
+
finishOperation();
return res;
//! Set coordinates of specified points from different sections
bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords)
{
- return false;
+ bool res = false;
+ // Set the difference.
+ startOperation();
+ if (addEmptyDiff()) {
+ myListDiffs.back().init(this, CurveCreator_Operation::SetCoordinates,
+ theSectionToPntCoords);
+ }
+ CurveCreator::SectionsMap aSectionsMap;
+ CurveCreator::PosPointsList aPosPoints;
+ CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
+ theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
+ int aSectionId, aPointId;
+ for ( ; anIt != aLast; anIt++ ) {
+ aPosPoints.clear();
+ aSectionId = anIt->first.first;
+ aPointId = anIt->first.second;
+ CurveCreator::Coordinates aNewCoords = anIt->second;
+ 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;
}
//! For internal use only! Undo/Redo are not used here.
//=======================================================================
CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
{
- return mySections.at(theISection)->myPoints;
+ CurveCreator::Coordinates aCoords;
+ if ( ( theISection >= 0 ) && ( theISection < mySections.size() ) )
+ {
+ aCoords = mySections.at(theISection)->myPoints;
+ }
+ return aCoords;
}