1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModelGeomAlgo_Point2D_H
22 #define ModelGeomAlgo_Point2D_H
24 #include "ModelGeomAlgo.h"
25 #include "ModelAPI_Feature.h"
27 class ModelAPI_Feature;
28 class ModelAPI_Object;
33 class GeomDataAPI_Point2D;
41 class ModelGeomAlgo_Point2D
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 = "");
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
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);
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;
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);
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);
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);
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);
135 /// Finds projected point to the given shape, which does not placed on the shape boundaries
136 /// \param theBaseShape a shape of check
137 /// \param thePoint [in] a point to project
138 /// \param theProjectedPoint [out] a projected point
139 static MODELGEOMALGO_EXPORT bool isInnerPointOnEdge(
140 const std::shared_ptr<GeomAPI_Shape> theBaseShape,
141 const std::shared_ptr<GeomAPI_Pnt>& thePoint,
142 std::shared_ptr<GeomAPI_Pnt>& theProjectedPoint);
145 /// Return feature name, kind and point values united in a string info
146 /// \param theFeature an investigated feature
147 /// \param theAttributesOnly a container of necessary attributes, if empty, all
148 /// \return string value
149 static MODELGEOMALGO_EXPORT std::string getPontAttributesInfo(
150 const std::shared_ptr<ModelAPI_Feature>& theFeature,
151 const std::set<std::shared_ptr<ModelAPI_Attribute> >& theAttributesOnly);
153 /// Return point attribute string info
154 /// \param theAttribute an investigated attribute
155 /// \return string value
156 static MODELGEOMALGO_EXPORT std::string getPointAttributeInfo(
157 const std::shared_ptr<ModelAPI_Attribute>& theAttribute);