1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include <Selector_Primitive.h>
23 #include <Selector_NameGenerator.h>
25 #include <TNaming_NamedShape.hxx>
26 #include <TDataStd_Name.hxx>
29 Selector_Primitive::Selector_Primitive() : Selector_Algo()
33 void Selector_Primitive::select(const TDF_Label theFinalLabel)
35 myFinal = theFinalLabel;
38 void Selector_Primitive::store()
40 storeType(Selector_Algo::SELTYPE_PRIMITIVE);
41 static const TDF_LabelList anEmptyRefList;
42 storeBaseArray(anEmptyRefList, myFinal);
45 bool Selector_Primitive::restore()
47 static TDF_LabelList anEmptyRefList;
48 return restoreBaseArray(anEmptyRefList, myFinal);
51 TDF_Label Selector_Primitive::restoreByName(std::string theName,
52 const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator)
55 if (theNameGenerator->restoreContext(theName, aContext, myFinal)) {
62 bool Selector_Primitive::solve(const TopoDS_Shape& theContext)
64 Handle(TNaming_NamedShape) aNS;
65 if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
66 Selector_Algo::store(aNS->Get());
72 std::string Selector_Primitive::name(Selector_NameGenerator* theNameGenerator)
74 Handle(TDataStd_Name) aName;
75 if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName))
77 std::string aResult = theNameGenerator->contextName(myFinal);
79 aResult += "/" + std::string(TCollection_AsciiString(aName->Get()).ToCString());