+static void getPointAndLine(const ConstraintPtr& theConstraint, const StoragePtr& theStorage,
+ EntityWrapperPtr& thePoint, EntityWrapperPtr& theLine)
+{
+ for (int i = 0; i < 2; ++i) {
+ AttributePtr anAttr = theConstraint->attribute(SketchPlugin_Constraint::ATTRIBUTE(i));
+ EntityWrapperPtr anEntity = theStorage->entity(anAttr);
+ if (anEntity->type() == ENTITY_POINT)
+ thePoint = anEntity;
+ else if (anEntity->type() == ENTITY_LINE)
+ theLine = anEntity;
+ }
+}
+
+static void adjustOddPoint(const EntityWrapperPtr& theDistPoint,
+ const EntityWrapperPtr& theDistLine,
+ GCSPointPtr& theOddPoint)
+{
+ if (!theOddPoint)
+ return;
+
+ std::shared_ptr<GeomAPI_Lin2d> aLine = PlaneGCSSolver_Tools::line(theDistLine);
+ std::shared_ptr<GeomAPI_Pnt2d> aPoint = PlaneGCSSolver_Tools::point(theDistPoint);
+
+ std::shared_ptr<GeomAPI_XY> aLineVec = aLine->direction()->xy();
+ std::shared_ptr<GeomAPI_XY> aPtLineVec = aPoint->xy()->decreased(aLine->location()->xy());
+
+ double aDot = aPtLineVec->dot(aLineVec);
+ std::shared_ptr<GeomAPI_XY> aProjectedPnt =
+ aLine->location()->xy()->added(aLineVec->multiplied(aDot));
+
+ *(theOddPoint->x) = aProjectedPnt->x();
+ *(theOddPoint->y) = aProjectedPnt->y();
+}
+
+