Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / ModelGeomAlgo / ModelGeomAlgo_Point2D.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelGeomAlgo_Point2D.h
4 // Created:     20 Jul 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef ModelGeomAlgo_Point2D_H
8 #define ModelGeomAlgo_Point2D_H
9
10 #include "ModelGeomAlgo.h"
11 #include "ModelAPI_Feature.h"
12
13 class ModelAPI_Feature;
14 class ModelAPI_Object;
15 class GeomAPI_Shape;
16 class GeomAPI_Pnt;
17 class GeomAPI_Dir;
18
19 class GeomDataAPI_Point2D;
20
21 #include <memory>
22 #include <string>
23 #include <set>
24 #include <map>
25
26
27 class ModelGeomAlgo_Point2D
28 {
29 public:
30   /// Searches Point2D attribute of reference of the attribute of given feature
31   /// \param theFeature a feature to obtain AttributeRefAttr
32   /// \param theAttribute a name of AttributeRefAttr on the given feature
33   /// \param theObjectFeatureKind a feature kind in object of attribute that satisfies the search
34   /// \param theObjectFeatureAttribute a feature attribute in object that satisfies the search
35   /// \param isSkipFeatureAttributes a boolean value if coincidences to the feature attributes
36   /// \returns found point attribute or NULL
37   static MODELGEOMALGO_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getPointOfRefAttr(
38                         ModelAPI_Feature* theFeature,
39                         const std::string& theAttribute,
40                         const std::string& theObjectFeatureKind = "",
41                         const std::string& theObjectFeatureAttribute = "");
42
43   /// Fills container of point 2D attributes, which refer to the feature through the references
44   /// features with the given kind
45   /// \param theObject an object where references should be searched (e.g. a sketch line or result)
46   /// \param theReferenceFeatureKind a kind of the feature to be processed
47   ///                                (e.g. coincidence constraint)
48   /// \param theAttributes a container of found point 2D attributes
49   /// \param theObjectFeatureKind a feature kind in object of attribute that satisfies the search
50   /// \param theObjectFeatureAttribute a feature attribute in object that satisfies the search
51   /// \param isSkipFeatureAttributes a boolean value if coincidences to the feature attributes
52   /// should be skipped
53   /// \returns found point attribute or NULL
54   static MODELGEOMALGO_EXPORT
55         void getPointsOfReference(const std::shared_ptr<ModelAPI_Object>& theObject,
56                                   const std::string& theReferenceFeatureKind,
57                                   std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theAttributes,
58                                   const std::string& theObjectFeatureKind = "",
59                                   const std::string& theObjectFeatureAttribute = "",
60                                   const bool isSkipFeatureAttributes = true);
61
62   /// Find points of intersection between the shape of the feature and all features in the sketch
63   /// \param theBaseFeature a feature: line, arc or circle that will be intersected
64   /// \param theFeatures a container of features to intersect with the base feature
65   /// \param thePoints a container of 3D points belong to the shape
66   /// \param theObjectToPoint a container of object to point
67   typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
68                    std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
69                              std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
70
71   static MODELGEOMALGO_EXPORT void getPointsIntersectedShape(
72                   const std::shared_ptr<ModelAPI_Feature>& theBaseFeature,
73                   const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
74                   PointToRefsMap& thePointToAttributeOrObject);
75
76   static MODELGEOMALGO_EXPORT std::list<std::shared_ptr<GeomAPI_Pnt> > getSetOfPntIntersectedShape(
77                   const std::shared_ptr<ModelAPI_Feature>& theBaseFeature,
78                   const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures);
79
80   /// Removes attributes which points are out of the base shape
81   /// \param theBaseShape a shape of check
82   /// \param theAttributes a container of point 2D attributes
83   /// \param theOrigin origin of a plane to generate 3D point by 2D attribute point
84   /// \param theDirX plane X direction to generate 3D point by 2D attribute point
85   /// \param theDirY plane X direction to generate 3D point by 2D attribute point
86   /// \param thePoints a container of 3D points belong to the shape
87   /// \param theAttributeToPoint a container of attribute to point
88   static MODELGEOMALGO_EXPORT void getPointsInsideShape(
89                         const std::shared_ptr<GeomAPI_Shape> theBaseShape,
90                         const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theAttributes,
91                         const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
92                         const std::shared_ptr<GeomAPI_Dir>& theDirX,
93                         const std::shared_ptr<GeomAPI_Dir>& theDirY,
94                         PointToRefsMap& thePointToAttributeOrObject);
95
96   /// Removes attributes which points are out of the base shape
97   /// \param theBaseShape a shape of check
98   /// \param theAttributes a container of point 2D attributes
99   /// \param theOrigin origin of a plane to generate 3D point by 2D attribute point
100   /// \param theDirX plane X direction to generate 3D point by 2D attribute point
101   /// \param theDirY plane X direction to generate 3D point by 2D attribute point
102   /// \param thePoints a container of 3D points belong to the shape
103   /// \param theAttributeToPoint a container of attribute to point
104   static MODELGEOMALGO_EXPORT void getPointsInsideShape_p(
105                               const std::shared_ptr<GeomAPI_Shape> theBaseShape,
106                               const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theAttributes,
107                               const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
108                               const std::shared_ptr<GeomAPI_Dir>& theDirX,
109                               const std::shared_ptr<GeomAPI_Dir>& theDirY,
110                               std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints,
111                               std::map<std::shared_ptr<GeomDataAPI_Point2D>,
112                                        std::shared_ptr<GeomAPI_Pnt> >& theAttributeToPoint);
113   /// Finds projected point to the given shape line
114   /// \param theBaseShape a shape of check
115   /// \param thePoint [in] a point to project
116   /// \param theProjectedPoint [out] a projected point
117   static MODELGEOMALGO_EXPORT bool isPointOnEdge(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
118                                           const std::shared_ptr<GeomAPI_Pnt>& thePoint,
119                                           std::shared_ptr<GeomAPI_Pnt>& theProjectedPoint);
120
121
122 #ifdef _DEBUG
123   /// Return feature name, kind and point values united in a string info
124   /// \param theFeature an investigated feature
125   /// \param theAttributesOnly a container of necessary attributes, if empty, all
126   /// \return string value
127   static MODELGEOMALGO_EXPORT std::string getPontAttributesInfo(
128                       const std::shared_ptr<ModelAPI_Feature>& theFeature,
129                       const std::set<std::shared_ptr<ModelAPI_Attribute> >& theAttributesOnly);
130
131   /// Return point attribute string info
132   /// \param theAttribute an investigated attribute
133   /// \return string value
134   static MODELGEOMALGO_EXPORT std::string getPointAttributeInfo(
135                       const std::shared_ptr<ModelAPI_Attribute>& theAttribute);
136
137 #endif
138 };
139
140 #endif