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