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