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