X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchAPI%2FSketchAPI_BSpline.cpp;fp=src%2FSketchAPI%2FSketchAPI_BSpline.cpp;h=c89abac78a995dcfba4af40eacc465f5e4c5638d;hb=c0c5763cf0cc9462b9bca9d1d272f862d921f130;hp=e804d164b850d38acc37d9bcafd90e6347bbda3e;hpb=270f4858b68cacf5a14f932de1762dd89c7be35b;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_BSpline.cpp b/src/SketchAPI/SketchAPI_BSpline.cpp index e804d164b..c89abac78 100644 --- a/src/SketchAPI/SketchAPI_BSpline.cpp +++ b/src/SketchAPI/SketchAPI_BSpline.cpp @@ -473,6 +473,46 @@ void SketchAPI_BSpline::dumpControlPolygon( theDumper << ")" << std::endl; } +static void setCoordinates(const FeaturePtr& theFeature, + const std::string& theAttrName, + const GeomPnt2dPtr& theCoordinates) +{ + AttributePoint2DPtr aPoint = + std::dynamic_pointer_cast(theFeature->attribute(theAttrName)); + aPoint->setValue(theCoordinates); +} + +bool SketchAPI_BSpline::insertPole(const int theIndex, + const GeomPnt2dPtr& theCoordinates, + const ModelHighAPI_Double& theWeight) +{ + std::ostringstream anActionName; + anActionName << SketchPlugin_BSplineBase::ADD_POLE_ACTION_ID() << "#" << theIndex; + bool isOk = feature()->customAction(anActionName.str()); + if (isOk) { + int anIndex = theIndex + 1; + if (feature()->getKind() == SketchPlugin_BSpline::ID() && anIndex + 1 >= poles()->size()) + anIndex = poles()->size() - 2; + // initialize coordinates and weight of new pole + poles()->setPnt(anIndex, theCoordinates); + weights()->setValue(anIndex, theWeight.value()); + + // update coordinates of points of control polygon + std::map aPoints, aLines; + collectAuxiliaryFeatures(feature(), aPoints, aLines); + std::map::iterator aFound = aPoints.find(anIndex); + if (aFound != aPoints.end()) + setCoordinates(aFound->second, SketchPlugin_Point::COORD_ID(), theCoordinates); + aFound = aLines.find(anIndex); + if (aFound != aLines.end()) + setCoordinates(aFound->second, SketchPlugin_Line::START_ID(), theCoordinates); + aFound = aLines.find(anIndex - 1); + if (aFound != aLines.end()) + setCoordinates(aFound->second, SketchPlugin_Line::END_ID(), theCoordinates); + } + return isOk; +} + // =================================================================================================