std::shared_ptr<GeomDataAPI_Point2D> aPassedAttr =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(PASSED_POINT_ID()));
if (!aPassedAttr->isInitialized()) { // calculate the appropriate center for the presentation
- std::shared_ptr<GeomAPI_XY> aDir =
- aEndAttr->pnt()->xy()->decreased(aStartAttr->pnt()->xy())->multiplied(0.5);
- double x = aDir->x();
- double y = aDir->y();
- aDir->setX(x - y);
- aDir->setY(y + x);
- std::shared_ptr<GeomAPI_XY> aCenterXY = aStartAttr->pnt()->xy()->added(aDir);
- aCenter = aSketch->to3D(aCenterXY->x(), aCenterXY->y());
+ // check that center is bad for the current start and end and must be recomputed
+ std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(new GeomAPI_Circ2d(
+ aCenterAttr->pnt(), aStartAttr->pnt()));
+ std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(aEndAttr->pnt());
+ if (!aProjection.get() || aEndAttr->pnt()->distance(aProjection) > tolerance) {
+ std::shared_ptr<GeomAPI_XY> aDir =
+ aEndAttr->pnt()->xy()->decreased(aStartAttr->pnt()->xy())->multiplied(0.5);
+ double x = aDir->x();
+ double y = aDir->y();
+ aDir->setX(x - y);
+ aDir->setY(y + x);
+ std::shared_ptr<GeomAPI_XY> aCenterXY = aStartAttr->pnt()->xy()->added(aDir);
+ aCenter = aSketch->to3D(aCenterXY->x(), aCenterXY->y());
+ }
}
}
+ AttributeBooleanPtr isInversed =
+ std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(attribute(INVERSED_ID()));
+
+ std::shared_ptr<GeomAPI_Shape> aCircleShape =
+ (isInversed->isInitialized() && isInversed->value()) ?
+ GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aEndPoint, aStartPoint, aNormal) :
+ GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStartPoint, aEndPoint, aNormal);
- std::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(
- aCenter, aStartPoint, aEndPoint, aNormal);
if (aCircleShape)
aShapes.push_back(aCircleShape);
}