X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchAPI%2FSketchAPI_BSpline.cpp;h=eab7e8308b0451e8ff67b5feb57b22471ea5f81a;hb=77ce6d35ac8d2f0fdaecb4f23e0870bf74e36103;hp=e804d164b850d38acc37d9bcafd90e6347bbda3e;hpb=bb4ab20a1f03f936d4d8511eb9e9733ee965bb72;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_BSpline.cpp b/src/SketchAPI/SketchAPI_BSpline.cpp index e804d164b..eab7e8308 100644 --- a/src/SketchAPI/SketchAPI_BSpline.cpp +++ b/src/SketchAPI/SketchAPI_BSpline.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2020 CEA/DEN, EDF R&D +// Copyright (C) 2019-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -24,12 +24,16 @@ #include +#include + #include #include #include #include #include +#include + #include #include #include @@ -152,8 +156,9 @@ static void createPole(const CompositeFeaturePtr& theSketch, aPointFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theBSpline); aPointFeature->execute(); - std::ostringstream aName; - aName << theBSpline->name() << "_" << thePoles->id() << "_" << thePoleIndex; + std::wostringstream aName; + aName << theBSpline->name() << "_" << Locale::Convert::toWString(thePoles->id()) + << "_" << thePoleIndex; aPointFeature->data()->setName(aName.str()); aPointFeature->lastResult()->data()->setName(aName.str()); @@ -185,7 +190,7 @@ static void createSegment(const CompositeFeaturePtr& theSketch, aLineFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theBSpline); aLineFeature->execute(); - std::ostringstream aName; + std::wostringstream aName; aName << theBSpline->name() << "_segment_" << theStartPoleIndex << "_" << aEndPoleIndex; aLineFeature->data()->setName(aName.str()); aLineFeature->lastResult()->data()->setName(aName.str()); @@ -473,6 +478,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; +} + // =================================================================================================