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