1 // Copyright (C) 2014-2023 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Selector_Primitive.h>
22 #include <Selector_NameGenerator.h>
24 #include <Locale_Convert.h>
26 #include <TNaming_NamedShape.hxx>
27 #include <TDataStd_Name.hxx>
30 Selector_Primitive::Selector_Primitive() : Selector_Algo()
34 void Selector_Primitive::select(const TDF_Label theFinalLabel)
36 myFinal = theFinalLabel;
39 void Selector_Primitive::store()
41 storeType(Selector_Algo::SELTYPE_PRIMITIVE);
42 static const TDF_LabelList anEmptyRefList;
43 storeBaseArray(anEmptyRefList, myFinal);
46 bool Selector_Primitive::restore()
48 static TDF_LabelList anEmptyRefList;
49 return restoreBaseArray(anEmptyRefList, myFinal);
52 TDF_Label Selector_Primitive::restoreByName(std::wstring theName,
53 const TopAbs_ShapeEnum /*theShapeType*/, Selector_NameGenerator* theNameGenerator)
56 if (theNameGenerator->restoreContext(theName, aContext, myFinal)) {
63 bool Selector_Primitive::solve(const TopoDS_Shape& theContext)
65 Handle(TNaming_NamedShape) aNS;
66 if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
67 TopoDS_Shape aResult = aNS->Get();
68 // if shape was modified and not exists in the context anymore, check evolution of this shape
69 // issue 2254 and similar (document CEA parametric first issue description)
70 findNewVersion(theContext, aResult);
71 Selector_Algo::store(aResult);
77 std::wstring Selector_Primitive::name(Selector_NameGenerator* theNameGenerator)
79 Handle(TDataStd_Name) aName;
80 if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
82 std::wstring aResult = theNameGenerator->contextName(myFinal);
83 if (!aResult.empty()) {
85 aResult += Locale::Convert::toWString(aName->Get().ToExtString());