Salome HOME
[bos #29933] [CEA 29931] Redundant constraint in SHAPER SIGSEGV
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroBSpline.cpp
index 48158f1a826c86f48da608976153abbee07f3261..a887c1aa61bde2e8e0e60317f109b6d629d7219e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2019-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include <SketchPlugin_Tools.h>
 #include <SketchPlugin_Sketch.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_AttributeDoubleArray.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeRefAttrList.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomDataAPI_Point2DArray.h>
 
@@ -84,7 +87,7 @@ void SketchPlugin_MacroBSpline::execute()
 
   if (boolean(CONTROL_POLYGON_ID())->value()) {
     std::list<FeaturePtr> aControlPoles;
-    createControlPolygon(aBSpline, aControlPoles);
+    createControlPolygon(aBSpline, myIsPeriodic, aControlPoles);
     constraintsForPoles(aControlPoles);
   }
 }
@@ -147,6 +150,7 @@ FeaturePtr SketchPlugin_MacroBSpline::createBSplineFeature()
 }
 
 void SketchPlugin_MacroBSpline::createControlPolygon(FeaturePtr theBSpline,
+                                                     bool thePeriodic,
                                                      std::list<FeaturePtr>& thePoles)
 {
   AttributePoint2DArrayPtr aPoles = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(
@@ -158,7 +162,7 @@ void SketchPlugin_MacroBSpline::createControlPolygon(FeaturePtr theBSpline,
   // segments
   for (int index = 1; index < aSize; ++index)
     createAuxiliarySegment(aPoles, index - 1, index);
-  if (myIsPeriodic) {
+  if (thePeriodic) {
     // additional segment to close the control polygon
     createAuxiliarySegment(aPoles, aSize - 1, 0);
   }
@@ -265,10 +269,10 @@ void SketchPlugin_MacroBSpline::assignDefaultNameForAux(FeaturePtr theAuxFeature
 {
   FeaturePtr aBSpline = ModelAPI_Feature::feature(theBSplinePoles->owner());
 
-  std::ostringstream aName;
+  std::wostringstream aName;
   aName << aBSpline->name();
   if (theAuxFeature->getKind() == SketchPlugin_Point::ID())
-    aName << "_" << theBSplinePoles->id() << "_" << thePoleIndex1;
+    aName << "_" << Locale::Convert::toWString(theBSplinePoles->id()) << "_" << thePoleIndex1;
   else
     aName << "_segment_" << thePoleIndex1 << "_" << thePoleIndex2;