1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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 <TNaming_NamedShape.hxx>
25 #include <TDataStd_Name.hxx>
28 Selector_Primitive::Selector_Primitive() : Selector_Algo()
32 void Selector_Primitive::select(const TDF_Label theFinalLabel)
34 myFinal = theFinalLabel;
37 void Selector_Primitive::store()
39 storeType(Selector_Algo::SELTYPE_PRIMITIVE);
40 static const TDF_LabelList anEmptyRefList;
41 storeBaseArray(anEmptyRefList, myFinal);
44 bool Selector_Primitive::restore()
46 static TDF_LabelList anEmptyRefList;
47 return restoreBaseArray(anEmptyRefList, myFinal);
50 TDF_Label Selector_Primitive::restoreByName(std::string theName,
51 const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator)
54 if (theNameGenerator->restoreContext(theName, aContext, myFinal)) {
61 bool Selector_Primitive::solve(const TopoDS_Shape& theContext)
63 Handle(TNaming_NamedShape) aNS;
64 if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
65 TopoDS_Shape aResult = aNS->Get();
66 // if shape was modified and not exists in the context anymore, check evolution of this shape
67 // issue 2254 and similar (document CEA parametric first issue description)
68 findNewVersion(theContext, aResult);
69 Selector_Algo::store(aResult);
75 std::string Selector_Primitive::name(Selector_NameGenerator* theNameGenerator)
77 Handle(TDataStd_Name) aName;
78 if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
80 std::string aResult = theNameGenerator->contextName(myFinal);
82 aResult += "/" + std::string(TCollection_AsciiString(aName->Get()).ToCString());