1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_SelectionNaming.h
4 // Created: 11 Aug 2015
5 // Author: Mikhail PONIKAROV
7 #ifndef Model_SelectionNaming_H_
8 #define Model_SelectionNaming_H_
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>
19 /**\class Model_SelectionNaming
21 * \brief The set of methods that allow to generate a string-name for the selection attribute.
24 class Model_SelectionNaming
26 TDF_Label myLab; ///< Selection label of the selection attribute
28 /// Constructor for the selection attribute by the selection label
29 Model_SelectionNaming(TDF_Label theSelectionLab);
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);
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);
45 /// Searches the face more appropriate to the given curves (with higher level of matched parameters)
46 /// \param theConstr construction result that contains one or several faces
47 /// \param theCurves map from the face edges curves to orientation (-1 reversed, 0 unknown, 1 forward)
48 /// \returns faces fron this construction if found
49 static std::shared_ptr<GeomAPI_Shape> findAppropriateFace(
50 std::shared_ptr<ModelAPI_Result>& theConstr,
51 NCollection_DataMap<Handle(Geom_Curve), int>& theCurves);
53 /// Returns orientation of the edge in the context shape
54 static int edgeOrientation(const TopoDS_Shape& theContext, TopoDS_Edge& theEdge);
56 /// Returns the name of sketch sub-element, shortened by exclusion of some symbols and with added
57 /// the vertex position (if needed)
58 /// \param theConstr result with name - basis for the name
59 /// \param theEdgeVertexPos position of the vertex on edge: 1 - first , 2 - second
60 /// \returns the generated name
61 static std::string shortName(std::shared_ptr<ModelAPI_ResultConstruction>& theConstr,
62 const int theEdgeVertexPos = 0);
65 /// Gets the stored name from the document
66 std::string getShapeName(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape& theShape,
67 const bool theAddContextName);