Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / Model / Model_SelectionNaming.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #ifndef Model_SelectionNaming_H_
21 #define Model_SelectionNaming_H_
22
23 #include <ModelAPI_Result.h>
24 #include <GeomAPI_Shape.h>
25 #include <Model_Document.h>
26 #include <TDF_Label.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <NCollection_DataMap.hxx>
29 #include <Geom_Curve.hxx>
30 #include <TopoDS_Edge.hxx>
31
32 /**\class Model_SelectionNaming
33  * \ingroup DataModel
34  * \brief The set of methods that allow to generate a string-name for the selection attribute.
35  */
36
37 class Model_SelectionNaming
38 {
39   TDF_Label myLab; ///< Selection label of the selection attribute
40 public:
41   /// Constructor for the selection attribute by the selection label
42   Model_SelectionNaming(TDF_Label theSelectionLab);
43
44   /// Produces the string-name for the selected shape
45   std::string namingName(ResultPtr& theContext, std::shared_ptr<GeomAPI_Shape> theSubSh,
46     const std::string& theDefaultName, const bool theAnotherDoc);
47
48   /// Makes a selection by the string-name
49   /// \param theType string of the type of the shape
50   /// \param theSubShapeName string-identifier of the selected shape
51   /// \param theDoc document where the selected shape is searched
52   /// \param theShapeToBeSelected resulting selected shape
53   /// \param theCont the selection context of the resulting selected shape
54   bool selectSubShape(const std::string& theType, const std::string& theSubShapeName,
55     std::shared_ptr<Model_Document> theDoc, std::shared_ptr<GeomAPI_Shape>& theShapeToBeSelected,
56     std::shared_ptr<ModelAPI_Result>& theCont);
57
58   /// Searches the face more appropriate to the given curves
59   /// (with higher level of matched parameters)
60   /// \param theConstr construction result that contains one or several  faces
61   /// \param theCurves map from the face edges curves to orientation
62   ///                  (-1 reversed, 0 unknown, 1 forward)
63   /// \param theIsWire for wire algorithm isquite the same,
64   ///                  but if in face several wires, it returns the needed wire
65   /// \returns faces fron this construction if found
66   static std::shared_ptr<GeomAPI_Shape> findAppropriateFace(
67     std::shared_ptr<ModelAPI_Result>& theConstr,
68     NCollection_DataMap<Handle(Geom_Curve), int>& theCurves, const bool theIsWire);
69
70   /// Returns orientation of the edge in the context shape
71   static int edgeOrientation(const TopoDS_Shape& theContext, TopoDS_Edge& theEdge);
72
73   /// Returns the name of sketch sub-element, shortened by exclusion of some symbols and with added
74   /// the vertex position (if needed)
75   /// \param theConstr result with name - basis for the name
76   /// \param theEdgeVertexPos position of the vertex on edge: 1 - first , 2 - second
77   /// \returns the generated name
78   static std::string shortName(std::shared_ptr<ModelAPI_ResultConstruction>& theConstr,
79     const int theEdgeVertexPos = 0);
80
81 protected:
82   /// Gets the stored name from the document
83   std::string getShapeName(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape& theShape,
84     ResultPtr& theContext, const bool theAnotherDoc, const bool theWholeContext);
85 };
86
87 #endif