Salome HOME
e9973deb3c3d6f8ee48ba0f7d60d6d27d8ac73e4
[modules/shaper.git] / src / Model / Model_SelectionNaming.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_SelectionNaming.h
4 // Created:     11 Aug 2015
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_SelectionNaming_H_
8 #define Model_SelectionNaming_H_
9
10 #include <ModelAPI_Result.h>
11 #include <GeomAPI_Shape.h>
12 #include <Model_Document.h>
13 #include <TDF_Label.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <NCollection_DataMap.hxx>
16 #include <Geom_Curve.hxx>
17 #include <TopoDS_Edge.hxx>
18
19 /**\class Model_SelectionNaming
20  * \ingroup DataModel
21  * \brief The set of methods that allow to generate a string-name for the selection attribute.
22  */
23
24 class Model_SelectionNaming
25 {
26   TDF_Label myLab; ///< Selection label of the selection attribute
27 public:
28   /// Constructor for the selection attribute by the selection label
29   Model_SelectionNaming(TDF_Label theSelectionLab);
30
31   /// Produces the string-name for the selected shape
32   std::string namingName(ResultPtr& theContext, std::shared_ptr<GeomAPI_Shape> theSubSh,
33     const std::string& theDefaultName, const bool theAnotherDoc);
34
35   /// Makes a selection by the string-name
36   /// \param theType string of the type of the shape
37   /// \param theSubShapeName string-identifier of the selected shape
38   /// \param theDoc document where the selected shape is searched
39   /// \param theShapeToBeSelected resulting selected shape
40   /// \param theCont the selection context of the resulting selected shape
41   bool selectSubShape(const std::string& theType, const std::string& theSubShapeName,
42     std::shared_ptr<Model_Document> theDoc, std::shared_ptr<GeomAPI_Shape>& theShapeToBeSelected,
43     std::shared_ptr<ModelAPI_Result>& theCont);
44
45   /// Searches the face more appropriate to the given curves
46   /// (with higher level of matched parameters)
47   /// \param theConstr construction result that contains one or several  faces
48   /// \param theCurves map from the face edges curves to orientation
49   ///                  (-1 reversed, 0 unknown, 1 forward)
50   /// \param theIsWire for wire algorithm isquite the same,
51   ///                  but if in face several wires, it returns the needed wire
52   /// \returns faces fron this construction if found
53   static std::shared_ptr<GeomAPI_Shape> findAppropriateFace(
54     std::shared_ptr<ModelAPI_Result>& theConstr,
55     NCollection_DataMap<Handle(Geom_Curve), int>& theCurves, const bool theIsWire);
56
57   /// Returns orientation of the edge in the context shape
58   static int edgeOrientation(const TopoDS_Shape& theContext, TopoDS_Edge& theEdge);
59
60   /// Returns the name of sketch sub-element, shortened by exclusion of some symbols and with added
61   /// the vertex position (if needed)
62   /// \param theConstr result with name - basis for the name
63   /// \param theEdgeVertexPos position of the vertex on edge: 1 - first , 2 - second
64   /// \returns the generated name
65   static std::string shortName(std::shared_ptr<ModelAPI_ResultConstruction>& theConstr,
66     const int theEdgeVertexPos = 0);
67
68 protected:
69   /// Gets the stored name from the document
70   std::string getShapeName(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape& theShape,
71     ResultPtr& theContext, const bool theAnotherDoc, const bool theWholeContext);
72 };
73
74 #endif