Salome HOME
updated copyright message
[modules/shaper.git] / src / Model / Model_ResultConstruction.cpp
index 87f3ec6b859d8b156509aa3d960bf673489d60e2..6307b4130304394146105430a78de62fd9b587fa 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -59,7 +59,7 @@ static void indexingSketchEdges(
     const CompositeFeaturePtr& theComposite,
     NCollection_DataMap<Handle(Geom_Curve), int>& theCurvesIndices,
     NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
-    std::map<int, std::string>& theEdgesNames);
+    std::map<int, std::wstring>& theEdgesNames);
 
 /// Convert each face to the list of indices of its edges
 /// \param[in]  theFaces          list of faces to proceed
@@ -82,13 +82,13 @@ static void faceToEdgeIndices(
 /// \param theEdgesNames      named of edges
 static void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
                               TDF_Label& theShapeLabel,
-                              const std::string& theName,
+                              const std::wstring& theName,
                               const TopoDS_Shape& theShape,
                               NCollection_DataMap<int, TopoDS_Face>& theFacesOrder,
                               NCollection_List<TopoDS_Face>& theUnorderedFaces,
                               const MapFaceToEdgeIndices& theFaceEdges,
                               const NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
-                              const std::map<int, std::string>& theEdgesNames);
+                              const std::map<int, std::wstring>& theEdgesNames);
 
 
 // identifier of the infinite result
@@ -100,7 +100,7 @@ void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::str
                                        std::string& theDefault)
 {
   theSection = "Visualization";
-  theName = "result_construction_color";
+  theName = RESULT_COLOR_NAME();
   theDefault = DEFAULT_COLOR();
 }
 
@@ -121,19 +121,19 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultConstruction::shape()
   return myShape;
 }
 
-static std::string shortName(
+static std::wstring shortName(
   std::shared_ptr<ModelAPI_ResultConstruction>& theConstr)
 {
-  std::string aName = theConstr->data()->name();
+  std::wstring aName = theConstr->data()->name();
   // remove "-", "/" and "&" command-symbols
   aName.erase(std::remove(aName.begin(), aName.end(), '-'), aName.end());
   aName.erase(std::remove(aName.begin(), aName.end(), '/'), aName.end());
   aName.erase(std::remove(aName.begin(), aName.end(), '&'), aName.end());
   // remove the last 's', 'e', 'f' and 'r' symbols:
   // they are used as markers of start/end/forward/reversed indicators
-  static const std::string aSyms("sefr");
-  std::string::iterator aSuffix = aName.end() - 1;
-  while(aSyms.find(*aSuffix) != std::string::npos) {
+  static const std::wstring aSyms(L"sefr");
+  std::wstring::iterator aSuffix = aName.end() - 1;
+  while(aSyms.find(*aSuffix) != std::wstring::npos) {
     --aSuffix;
   }
   aName.erase(aSuffix + 1, aName.end());
@@ -222,7 +222,7 @@ void Model_ResultConstruction::setInfinite(const bool theInfinite)
   }
 }
 
-int Model_ResultConstruction::facesNum(const bool theUpdateNaming)
+int Model_ResultConstruction::facesNum(const bool /*theUpdateNaming*/)
 {
   int aResult = 0;
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
@@ -270,7 +270,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr<GeomAPI_Shape> theShap
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   if (aData && aData->isValid()) {
-    std::string aMyName = data()->name();
+    std::wstring aMyName = data()->name();
     TDF_Label aShapeLab = aData->shapeLab();
     if (!theShape.get() || theShape->isNull()) {
       aShapeLab.ForgetAllAttributes();
@@ -294,9 +294,10 @@ void Model_ResultConstruction::storeShape(std::shared_ptr<GeomAPI_Shape> theShap
       TopExp_Explorer anExp(aShape, TopAbs_VERTEX);
       for(int anIndex = 1; anExp.More(); anExp.Next(), anIndex++) {
         TDF_Label aSubLab = aShapeLab.FindChild(anIndex);
-        TNaming_Builder aBuilder(aSubLab);
-        aBuilder.Generated(anExp.Current());
-        std::string aVertexName = aMyName + "_" + (anIndex == 1 ? "StartVertex" : "EndVertex");
+        TNaming_Builder aSubBuilder(aSubLab);
+        aSubBuilder.Generated(anExp.Current());
+        std::wstring aVertexName = aMyName + L"_" +
+          (anIndex == 1 ? L"StartVertex" : L"EndVertex");
         TDataStd_Name::Set(aSubLab, aVertexName.c_str());
         aMyDoc->addNamingName(aSubLab, aVertexName);
       }
@@ -316,7 +317,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr<GeomAPI_Shape> theShap
       // collect indices of curves of current composite
       NCollection_DataMap<Handle(Geom_Curve), int> aCurvesIndices;
       NCollection_DataMap<int, TopoDS_Edge> anEdgeIndices;
-      std::map<int, std::string> aComponentsNames; // names of components that lay on index
+      std::map<int, std::wstring> aComponentsNames; // names of components that lay on index
       indexingSketchEdges(aComposite, aCurvesIndices, anEdgeIndices, aComponentsNames);
 
       GeomAlgoAPI_SketchBuilder aSketchBuilder(aWirePtr->origin(), aWirePtr->dirX(),
@@ -379,7 +380,7 @@ void Model_ResultConstruction::setFacesOrder(const std::list<GeomFacePtr>& theFa
 {
   std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
   if (aData && aData->isValid()) {
-    std::string aMyName = data()->name();
+    std::wstring aMyName = data()->name();
     TDF_Label aShapeLab = aData->shapeLab();
     GeomShapePtr aResShape = shape();
     if (!aResShape.get() || aResShape->isNull()) {
@@ -400,7 +401,7 @@ void Model_ResultConstruction::setFacesOrder(const std::list<GeomFacePtr>& theFa
       // collect indices of curves of current composite
       NCollection_DataMap<Handle(Geom_Curve), int> aCurvesIndices;
       NCollection_DataMap<int, TopoDS_Edge> anEdgeIndices;
-      std::map<int, std::string> aComponentsNames; // names of components that lay on index
+      std::map<int, std::wstring> aComponentsNames; // names of components that lay on index
       indexingSketchEdges(aComposite, aCurvesIndices, anEdgeIndices, aComponentsNames);
 
       ListOfShape aFaces;
@@ -426,13 +427,13 @@ void Model_ResultConstruction::setFacesOrder(const std::list<GeomFacePtr>& theFa
 
 void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
                        TDF_Label& theShapeLabel,
-                       const std::string& theName,
+                       const std::wstring& theName,
                        const TopoDS_Shape& theShape,
                        NCollection_DataMap<int, TopoDS_Face>& theFacesOrder,
                        NCollection_List<TopoDS_Face>& theUnorderedFaces,
                        const MapFaceToEdgeIndices& theFaceEdges,
                        const NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
-                       const std::map<int, std::string>& theEdgesNames)
+                       const std::map<int, std::wstring>& theEdgesNames)
 {
   theShapeLabel.ForgetAllAttributes(); // clear all previously stored
   TDataStd_Name::Set(theShapeLabel, theName.c_str()); // restore name forgotten
@@ -440,7 +441,6 @@ void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
   aBuilder.Generated(theShape);
   theDocument->addNamingName(theShapeLabel, theName);
   // set new faces to the labels
-  int aCurrentTag = 1;
   NCollection_List<TopoDS_Face>::Iterator anUnordered(theUnorderedFaces);
   for (int aCurrentTag = 1; !theFacesOrder.IsEmpty() || anUnordered.More(); aCurrentTag++) {
     TopoDS_Face aFaceToPut;
@@ -466,7 +466,7 @@ void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
     // store also indices of the new face edges
     Handle(TDataStd_IntPackedMap) aNewMap = TDataStd_IntPackedMap::Set(aLab);
     const TColStd_ListOfInteger& aNewInd = theFaceEdges.FindFromKey(aFaceToPut);
-    std::stringstream aName;
+    std::wstringstream aName;
     aName<<"Face";
     TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE);
     TNaming_Builder *anEdgesBuilder = 0, *aVerticesBuilder = 0;
@@ -525,8 +525,8 @@ void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
       TDF_Label aWireLab = aLab.FindChild(aWireTag);
       TNaming_Builder aWireBuilder(aWireLab);
       aWireBuilder.Generated(aWires.Current());
-      std::ostringstream aWireName;
-      aWireName<<aName.str()<<"_wire";
+      std::wostringstream aWireName;
+      aWireName<<aName.str()<<L"_wire";
       if (aWireTag > 3)
         aWireName<<"_"<<aWireTag - 2;
       TDataStd_Name::Set(aWireLab, aWireName.str().c_str());
@@ -539,7 +539,7 @@ void storeFacesOnLabel(std::shared_ptr<Model_Document>& theDocument,
 void indexingSketchEdges(const CompositeFeaturePtr& theComposite,
                          NCollection_DataMap<Handle(Geom_Curve), int>& theCurvesIndices,
                          NCollection_DataMap<int, TopoDS_Edge>& theEdgesIndices,
-                         std::map<int, std::string>& theEdgesNames)
+                         std::map<int, std::wstring>& theEdgesNames)
 {
   const int aSubNum = theComposite->numberOfSubs();
   for (int a = 0; a < aSubNum; a++) {