+ if (aPointAttr.get()) {
+ theAttributes.insert(aPointAttr);
+ }
+ }
+ }
+ // find by results
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ if (aFeature.get()) {
+ const std::list<std::shared_ptr<ModelAPI_Result> > aResults = aFeature->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+ for (; aRIter != aResults.cend(); aRIter++) {
+ ResultPtr aResult = *aRIter;
+ getPointsOfReference(aResult, theReferenceFeatureKind, theAttributes, theObjectFeatureKind,
+ theObjectFeatureAttribute);
+ }
+ }
+}
+
+void appendPoint(const std::shared_ptr<GeomAPI_Pnt>& thePoint,
+ const std::shared_ptr<ModelAPI_Result>& theResult,
+ ModelGeomAlgo_Point2D::PointToRefsMap& thePointToAttributeOrObject)
+{
+ bool aPointFound = false;
+ FeaturePtr aPointFeature = ModelAPI_Feature::feature(theResult);
+ // check if the given point is already in the container in attribute list
+ for (ModelGeomAlgo_Point2D::PointToRefsMap::const_iterator
+ anIt = thePointToAttributeOrObject.begin();
+ anIt != thePointToAttributeOrObject.end() && !aPointFound; anIt++) {
+ std::shared_ptr<GeomAPI_Pnt> aPoint = anIt->first;
+ if (aPoint->isEqual(thePoint)) {
+ std::list<std::shared_ptr<GeomDataAPI_Point2D> > anAttributes = anIt->second.first;
+ for (std::list<AttributePoint2DPtr>::const_iterator anAttrIt = anAttributes.begin();
+ anAttrIt != anAttributes.end() && !aPointFound; anAttrIt++) {
+ AttributePtr anAttribute = *anAttrIt;
+ aPointFound = ModelAPI_Feature::feature(anAttribute->owner()) == aPointFeature;
+ }
+ }
+ }
+
+ if (!aPointFound) {
+ if (thePointToAttributeOrObject.find(thePoint) != thePointToAttributeOrObject.end())
+ thePointToAttributeOrObject.at(thePoint).second.push_back(theResult);
+ else {
+ std::list<std::shared_ptr<GeomDataAPI_Point2D> > anAttributes;
+ std::list<std::shared_ptr<ModelAPI_Object> > anObjects;
+ anObjects.push_back(theResult);
+ thePointToAttributeOrObject[thePoint] = std::make_pair(anAttributes, anObjects);
+ }
+#ifdef DEBUG_POINT_INSIDE_SHAPE
+ std::cout << "["<< thePoint->x() << ", " << thePoint->y() << "," << thePoint->z() << "]";
+#endif
+ }
+}
+
+void appendShapePoints(const GeomShapePtr& theShape,
+ const std::shared_ptr<ModelAPI_Result>& theResult,
+ ModelGeomAlgo_Point2D::PointToRefsMap& thePointToAttributeOrObject)
+{
+ if (!theShape.get())
+ return;
+
+ switch (theShape->shapeType()) {
+ case GeomAPI_Shape::VERTEX: {
+ std::shared_ptr<GeomAPI_Vertex> aVertex =
+ std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(theShape));
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
+ appendPoint(aPnt, theResult, thePointToAttributeOrObject);
+ }
+ break;
+ case GeomAPI_Shape::EDGE: {
+ std::shared_ptr<GeomAPI_Edge> anEdge =
+ std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(theShape));
+ appendPoint(anEdge->firstPoint(), theResult, thePointToAttributeOrObject);
+ appendPoint(anEdge->lastPoint(), theResult, thePointToAttributeOrObject);
+ }
+ break;
+ case GeomAPI_Shape::COMPOUND: {
+ for(GeomAPI_ShapeIterator anIt(theShape); anIt.more(); anIt.next()) {
+ appendShapePoints(anIt.current(), theResult, thePointToAttributeOrObject);
+ }