SHAPER  9.12.0
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
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.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // Lesser General Public License for more details.
12 //
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
16 //
17 // See or email :
18 //
20 #ifndef Selector_Algo_H_
21 #define Selector_Algo_H_
23 #include "Selector.h"
25 #include <Standard_GUID.hxx>
26 #include <TDF_Label.hxx>
27 #include <TDF_LabelList.hxx>
28 #include <TopoDS_Shape.hxx>
37 {
38  TopAbs_ShapeEnum myShapeType;
40  TDF_Label myLab;
41  TDF_Label myBaseDocumentLab;
42  bool myGeometricalNaming;
43  bool myAlwaysGeometricalNaming;
44  bool myUseNeighbors;
45  bool myUseIntersections;
47 public:
57  };
60  SELECTOR_EXPORT Selector_Algo();
62  virtual ~Selector_Algo() {}
71  SELECTOR_EXPORT static Selector_Algo* select(
72  const TopoDS_Shape theContext, const TopoDS_Shape theValue,
73  const TDF_Label theAccess, const TDF_Label theBaseDocument,
74  const bool theGeometricalNaming = false,
75  const bool theUseNeighbors = true, const bool theUseIntersections = true,
76  const bool theAlwaysGeometricalNaming = false);
79  SELECTOR_EXPORT virtual void store() = 0;
83  SELECTOR_EXPORT virtual bool restore() = 0;
87  SELECTOR_EXPORT virtual TDF_Label restoreByName(std::wstring theName,
88  const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) = 0;
91  SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) = 0;
94  SELECTOR_EXPORT virtual std::wstring name(Selector_NameGenerator* theNameGenerator) = 0;
96  SELECTOR_EXPORT TopoDS_Shape value();
98  SELECTOR_EXPORT static Selector_Algo* restoreByLab(TDF_Label theLab, TDF_Label theBaseDocLab);
101  SELECTOR_EXPORT static Selector_Algo* restoreByName(
102  TDF_Label theLab, TDF_Label theBaseDocLab, std::wstring theName,
103  const TopAbs_ShapeEnum theShapeType, const bool theGeomNaming,
104  Selector_NameGenerator* theNameGenerator, TDF_Label& theContextLab);
107  static bool sameGeometry(const TopoDS_Shape theShape1, const TopoDS_Shape theShape2);
110  SELECTOR_EXPORT static Selector_Algo* relesectWithAllGeometry(
111  Selector_Algo* theOldAlgo, const TopoDS_Shape theContext);
114  {myGeometricalNaming = true;}
116 protected:
118  const TDF_Label& label() const
119  {return myLab;}
121  void storeBaseArray(const TDF_LabelList& theRef, const TDF_Label& theLast);
123  bool restoreBaseArray(TDF_LabelList& theRef, TDF_Label& theLast);
125  void store(const TopoDS_Shape theShape);
127  const TDF_Label& baseDocument() const
128  {return myBaseDocumentLab;}
130  bool geometricalNaming() const
131  {return myGeometricalNaming;}
134  {return myAlwaysGeometricalNaming;}
136  bool useNeighbors() const
137  {return myUseNeighbors;}
139  bool useIntersections() const
140  {return myUseIntersections;}
142  static const Standard_GUID& weakID()
143  {
144  static const Standard_GUID kWEAK_INDEX("e9373a61-cabc-4ee8-aabf-aea47c62ed87");
145  return kWEAK_INDEX;
146  }
148  static const Standard_GUID& shapeTypeID()
149  {
150  static const Standard_GUID kSHAPE_TYPE("864b3267-cb9d-4107-bf58-c3ce1775b171");
151  return kSHAPE_TYPE;
152  }
154  static const std::wstring& oldWeakNameID()
155  {
156  static const std::wstring kWEAK_NAME_IDENTIFIER = L"weak_name_";
158  }
160  static const std::wstring& oldPureWeakNameID()
161  {
162  static const std::wstring kPURE_WEAK_NAME_IDENTIFIER = L"_weak_name_";
164  }
166  static const std::wstring& weakNameID()
167  {
168  static const std::wstring kWEAK_NAME_IDENTIFIER = std::wstring(L"new_") + oldWeakNameID();
170  }
172  static const std::wstring& pureWeakNameID()
173  {
174  static const std::wstring kPURE_WEAK_NAME_IDENTIFIER =
175  std::wstring(L"_new") + oldPureWeakNameID();
177  }
179  void storeType(const Selector_Type theType);
183  bool findNewVersion(const TopoDS_Shape& theContext, TopoDS_Shape& theResult) const;
184 };
186 #endif
Definition: Selector_Algo.h:37
const TDF_Label & baseDocument() const
Returns an access-label of the document that may contain initial shapes.
Definition: Selector_Algo.h:127
virtual void store()=0
Stores the name to the label and sub-labels tree.
static const Standard_GUID & weakID()
Returns GUID for the weak index (integer attribute) of the sub-shape.
Definition: Selector_Algo.h:142
void setGeometricalNaming()
Sets geometrical naming flag to true.
Definition: Selector_Algo.h:113
virtual bool solve(const TopoDS_Shape &theContext)=0
Updates the current shape by the stored topological name.
bool useNeighbors() const
Returns use neighbors flag.
Definition: Selector_Algo.h:136
Initializes the algorithm.
Definition: Selector_Algo.cpp:63
bool geometricalNaming() const
Returns the geometrical naming flag.
Definition: Selector_Algo.h:130
virtual TDF_Label restoreByName(std::wstring theName, const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator *theNameGenerator)=0
Restores the selected shape by the topological name string.
static const Standard_GUID & shapeTypeID()
Returns GUID for the type of the shape, stored in case it is intersection or container.
Definition: Selector_Algo.h:148
static Selector_Algo * restoreByLab(TDF_Label theLab, TDF_Label theBaseDocLab)
Restores sub-algorithm of a given type by the storage-label.
Definition: Selector_Algo.cpp:365
bool findNewVersion(const TopoDS_Shape &theContext, TopoDS_Shape &theResult) const
Searches the newer version of the shape in the document if the base shape does not belong to context.
Definition: Selector_Algo.cpp:472
bool useIntersections() const
Returns use intersections flag.
Definition: Selector_Algo.h:139
bool alwaysGeometricalNaming() const
Returns always geometrical naming flag.
Definition: Selector_Algo.h:133
virtual bool restore()=0
Restores the selected shape by the topological naming kept in the data structure Returns true if it c...
TopoDS_Shape value()
Returns the current sub-shape value (null if can not resolve)
Definition: Selector_Algo.cpp:357
static const std::wstring & pureWeakNameID()
string identifier of the pure weak name
Definition: Selector_Algo.h:172
const TDF_Label & label() const
Returns label where this algorithm is attached to, or just an access label to the document.
Definition: Selector_Algo.h:118
bool restoreBaseArray(TDF_LabelList &theRef, TDF_Label &theLast)
Restores references to the labels: references to elements of ref-list, then the last.
Definition: Selector_Algo.cpp:294
static bool sameGeometry(const TopoDS_Shape theShape1, const TopoDS_Shape theShape2)
Returns true if the given shapes are based on the same geometry.
Definition: Selector_Algo.cpp:334
void storeBaseArray(const TDF_LabelList &theRef, const TDF_Label &theLast)
Stores the array of references to theLab: references to elements of ref-list, then the last.
Definition: Selector_Algo.cpp:268
static Selector_Algo * select(const TopoDS_Shape theContext, const TopoDS_Shape theValue, const TDF_Label theAccess, const TDF_Label theBaseDocument, const bool theGeometricalNaming=false, const bool theUseNeighbors=true, const bool theUseIntersections=true, const bool theAlwaysGeometricalNaming=false)
Initializes the selector structure on the label.
Definition: Selector_Algo.cpp:113
static const std::wstring & oldPureWeakNameID()
old string identifier of the pure weak name
Definition: Selector_Algo.h:160
static const std::wstring & weakNameID()
string identifier of the weak name in modification or intersection types of algorithm
Definition: Selector_Algo.h:166
void storeType(const Selector_Type theType)
Stores the type of an algorithm in the data tree (in myLab)
Definition: Selector_Algo.cpp:455
static const std::wstring & oldWeakNameID()
old string identifier of the weak name in modification or intersection types of algorithm
Definition: Selector_Algo.h:154
virtual std::wstring name(Selector_NameGenerator *theNameGenerator)=0
Returns the naming name of the selection.
static Selector_Algo * relesectWithAllGeometry(Selector_Algo *theOldAlgo, const TopoDS_Shape theContext)
Creates a new selection algorithm for selection of all topology based on the same geometry.
Definition: Selector_Algo.cpp:261
Type of a selector algorithm: on this type depends what is stored in this label and how to restore it...
Definition: Selector_Algo.h:50
identification by neighbor shapes in context
Definition: Selector_Algo.h:55
just a container of sub-elements, keeps the shape type of container
Definition: Selector_Algo.h:51
sub-shape found as a primitive on some label
Definition: Selector_Algo.h:53
modification of base shapes to the final label
Definition: Selector_Algo.h:54
pure weak naming by weak index in context
Definition: Selector_Algo.h:56
sub-shape is intersection of higher level objects
Definition: Selector_Algo.h:52
An interface for generation of the naming name basing on the current selection and document informati...
Definition: Selector_NameGenerator.h:34