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 #ifndef Selector_Selector_H_
22 #define Selector_Selector_H_
26 #include <TDF_Label.hxx>
27 #include <TDF_LabelList.hxx>
28 #include <TopoDS_Shape.hxx>
31 /**\class Selector_Selector
33 * \brief Main object for selection of the sub-shapes in the parametrically updated
34 * shapes using topological naming mechanism.
37 class Selector_Selector
39 /// Type of a selector: on this type depends what is stored in this label and how to
40 /// restore it on update.
42 SELTYPE_CONTAINER, ///< just a container of sub-elements, keeps the shape type of container
43 SELTYPE_INTERSECT, ///< sub-shape is intersection of higher level objects
44 SELTYPE_PRIMITIVE, ///< sub-shape found as a primitive on some label
45 SELTYPE_MODIFICATION, ///< modification of base shapes to the final label
46 SELTYPE_FILTER_BY_NEIGHBOR, ///< identification by neighbor shapes in context
49 Selector_Type myType; ///< Type of this selector.
50 TopAbs_ShapeEnum myShapeType; ///< type of this shape: in container, intersection or neighbors
51 std::list<Selector_Selector> mySubSelList; ///< list of sub-selectors if needed
52 TDF_Label myFinal; ///< final label of the primitive or generation, where the value is
53 TDF_LabelList myBases; ///< initial labels that contain shapes that produce the modification
55 std::list<int> myNBLevel; ///< list of integers corresponding to subsellist neighborhood level
57 TDF_Label myLab; ///< main label where selector is performed
60 /// Initializes selector on the label
61 SELECTOR_EXPORT Selector_Selector(TDF_Label theLab);
62 /// Returns label of this selector
63 SELECTOR_EXPORT TDF_Label label();
65 /// Initializes the selector structure on the label.
66 /// Stores the name data to restore after modification.
67 SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
68 const bool theUseNeighbors = false);
70 /// Stores the name to the label and sub-labels tree
71 SELECTOR_EXPORT void store();
73 /// Restores the selected shape by the topological naming kept in the data structure
74 /// Returns true if it can restore structure correctly
75 SELECTOR_EXPORT bool restore();
77 /// Updates the current shape by the stored topological name
78 SELECTOR_EXPORT bool solve(const TopoDS_Shape& theContext);
80 /// Returns the current sub-shape value (null if can not resolve)
81 SELECTOR_EXPORT TopoDS_Shape value();
85 /// Create and keep in the list the sub-sulector that select the given value.
86 /// Returns true if selection is correct.
87 bool selectBySubSelector(const TopoDS_Shape theContext, const TopoDS_Shape theValue);