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 class ModelGeomAlgo_Point2D
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 = "");
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
53 /// \returns found point attribute or NULL
54 static MODELGEOMALGO_EXPORT void getPointsOfReference(const std::shared_ptr<ModelAPI_Object>& theObject,
55 const std::string& theReferenceFeatureKind,
56 std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theAttributes,
57 const std::string& theObjectFeatureKind = "",
58 const std::string& theObjectFeatureAttribute = "",
59 const bool isSkipFeatureAttributes = true);
61 /// Find points of intersection between the shape of the feature and all features in the sketch
62 /// \param theBaseFeature a feature: line, arc or circle that will be intersected
63 /// \param theFeatures a container of features to intersect with the base feature
64 /// \param thePoints a container of 3D points belong to the shape
65 /// \param theObjectToPoint a container of object to point
66 typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
67 std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
68 std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
70 static MODELGEOMALGO_EXPORT void getPointsIntersectedShape(
71 const std::shared_ptr<ModelAPI_Feature>& theBaseFeature,
72 const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
73 PointToRefsMap& thePointToAttributeOrObject);
75 static MODELGEOMALGO_EXPORT std::list<std::shared_ptr<GeomAPI_Pnt> > getSetOfPntIntersectedShape(
76 const std::shared_ptr<ModelAPI_Feature>& theBaseFeature,
77 const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures);
79 /// Removes attributes which points are out of the base shape
80 /// \param theBaseShape a shape of check
81 /// \param theAttributes a container of point 2D attributes
82 /// \param theOrigin origin of a plane to generate 3D point by 2D attribute point
83 /// \param theDirX plane X direction to generate 3D point by 2D attribute point
84 /// \param theDirY plane X direction to generate 3D point by 2D attribute point
85 /// \param thePoints a container of 3D points belong to the shape
86 /// \param theAttributeToPoint a container of attribute to point
87 static MODELGEOMALGO_EXPORT void getPointsInsideShape(
88 const std::shared_ptr<GeomAPI_Shape> theBaseShape,
89 const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theAttributes,
90 const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
91 const std::shared_ptr<GeomAPI_Dir>& theDirX,
92 const std::shared_ptr<GeomAPI_Dir>& theDirY,
93 PointToRefsMap& thePointToAttributeOrObject);
95 /// Removes attributes which points are out of the base shape
96 /// \param theBaseShape a shape of check
97 /// \param theAttributes a container of point 2D attributes
98 /// \param theOrigin origin of a plane to generate 3D point by 2D attribute point
99 /// \param theDirX plane X direction to generate 3D point by 2D attribute point
100 /// \param theDirY plane X direction to generate 3D point by 2D attribute point
101 /// \param thePoints a container of 3D points belong to the shape
102 /// \param theAttributeToPoint a container of attribute to point
103 static MODELGEOMALGO_EXPORT void getPointsInsideShape_p(
104 const std::shared_ptr<GeomAPI_Shape> theBaseShape,
105 const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theAttributes,
106 const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
107 const std::shared_ptr<GeomAPI_Dir>& theDirX,
108 const std::shared_ptr<GeomAPI_Dir>& theDirY,
109 std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints,
110 std::map<std::shared_ptr<GeomDataAPI_Point2D>,
111 std::shared_ptr<GeomAPI_Pnt> >& theAttributeToPoint);
112 /// Finds projected point to the given shape line
113 /// \param theBaseShape a shape of check
114 /// \param thePoint [in] a point to project
115 /// \param theProjectedPoint [out] a projected point
116 static MODELGEOMALGO_EXPORT bool isPointOnEdge(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
117 const std::shared_ptr<GeomAPI_Pnt>& thePoint,
118 std::shared_ptr<GeomAPI_Pnt>& theProjectedPoint);
122 /// Return feature name, kind and point values united in a string info
123 /// \param theFeature an investigated feature
124 /// \param theAttributesOnly a container of necessary attributes, if empty, all
125 /// \return string value
126 static MODELGEOMALGO_EXPORT std::string getPontAttributesInfo(
127 const std::shared_ptr<ModelAPI_Feature>& theFeature,
128 const std::set<std::shared_ptr<ModelAPI_Attribute> >& theAttributesOnly);
130 /// Return point attribute string info
131 /// \param theAttribute an investigated attribute
132 /// \return string value
133 static MODELGEOMALGO_EXPORT std::string getPointAttributeInfo(
134 const std::shared_ptr<ModelAPI_Attribute>& theAttribute);