- std::shared_ptr<GeomAPI_Pnt2d> aStartA = aPointA1->pnt();
- std::shared_ptr<GeomAPI_Pnt2d> aEndA = aPointA2->pnt();
- std::shared_ptr<GeomAPI_Pnt2d> aStartB = aPointB1->pnt();
- std::shared_ptr<GeomAPI_Pnt2d> aEndB = aPointB2->pnt();
-
- double aDist[2][2] = {
- { anInter->distance(aStartA), anInter->distance(aEndA) },
- { anInter->distance(aStartB), anInter->distance(aEndB) }
- };
-
- // Directions of lines
- if (aDist[0][1] < tolerance)
- aEndA = aStartA;
- if (aDist[1][1] < tolerance)
- aEndB = aStartB;
- std::shared_ptr<GeomAPI_Dir2d> aDirA(new GeomAPI_Dir2d(aEndA->xy()->decreased(anInter->xy())));
- std::shared_ptr<GeomAPI_Dir2d> aDirB(new GeomAPI_Dir2d(aEndB->xy()->decreased(anInter->xy())));
-
- anAngle = fabs(aDirA->angle(aDirB)) * 180.0 / PI;
-
- // If the lines intersected inside one of them, the angle selected is less than 90 degrees
- if ((aDist[0][0] >= tolerance && aDist[0][1] >= tolerance &&
- aDist[0][0] + aDist[0][1] < aStartA->distance(aEndA) + 2.0 * tolerance) ||
- (aDist[1][0] >= tolerance && aDist[1][1] >= tolerance &&
- aDist[1][0] + aDist[1][1] < aStartB->distance(aEndB) + 2.0 * tolerance)) {
- if (anAngle > 90.0)
- anAngle = 180.0 - anAngle;
+ std::shared_ptr<GeomAPI_Angle2d> anAng;
+ if (!attribute(ANGLE_REVERSED_FIRST_LINE_ID())->isInitialized() ||
+ !attribute(ANGLE_REVERSED_SECOND_LINE_ID())->isInitialized())
+ anAng = std::shared_ptr<GeomAPI_Angle2d>(new GeomAPI_Angle2d(
+ aStartA->pnt(), aEndA->pnt(), aStartB->pnt(), aEndB->pnt()));
+ else {
+ std::shared_ptr<GeomAPI_Lin2d> aLine1(new GeomAPI_Lin2d(aStartA->pnt(), aEndA->pnt()));
+ bool isReversed1 = boolean(ANGLE_REVERSED_FIRST_LINE_ID())->value();
+ std::shared_ptr<GeomAPI_Lin2d> aLine2(new GeomAPI_Lin2d(aStartB->pnt(), aEndB->pnt()));
+ bool isReversed2 = boolean(ANGLE_REVERSED_SECOND_LINE_ID())->value();
+ anAng = std::shared_ptr<GeomAPI_Angle2d>(
+ new GeomAPI_Angle2d(aLine1, isReversed1, aLine2, isReversed2));