aEndA = aStartA;
if (aDist[1][0] > aDist[1][1])
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;
+ double aDirAngle = aDirA->angle(aDirB);
+ if (aDirAngle < 0)
+ aDirAngle += 2.0 * PI;
+ anAngle = fabs(aDirAngle) * 180.0 / PI;
+ //anAngle = fabs(aDirA->angle(aDirB)) * 180.0 / PI;
+
return anAngle;
}
//=======================================================================
void AIS_AngleDimension::Init()
{
+ SetGeometryOrientedAngle (Standard_False);
SetSpecialSymbol (THE_DEGREE_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_After);
SetFlyout (15.0);
}
gp_Pln aPlane = aConstructPlane.Value();
-
+ if (myGeometryOrientedAngle) {
+ gp_Ax1 anAxis = aPlane.Axis();
+ gp_Dir aDir = anAxis.Direction();
+ aDir.Reverse();
+ aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir));
+ }
+
// construct circle forming the arc
gce_MakeCirc aConstructCircle (theCenter, aPlane, theRadius);
if (!aConstructCircle.IsDone())
gp_Circ aCircle = aConstructCircle.Value();
// construct the arc
- GC_MakeArcOfCircle aConstructArc (aCircle, theFirstAttach, theSecondAttach, Standard_True);
+ Standard_Boolean isArcSense = !myGeometryOrientedAngle;
+ GC_MakeArcOfCircle aConstructArc(aCircle, theFirstAttach, theSecondAttach, isArcSense);
if (!aConstructArc.IsDone())
{
return;
gp_Vec aCenterToFirstVec (theCenter, theFirstAttach);
gp_Vec aCenterToSecondVec (theCenter, theSecondAttach);
const Standard_Real anAngle = aCenterToFirstVec.Angle (aCenterToSecondVec);
- const Standard_Integer aNbPoints = Max (4, Standard_Integer (50.0 * anAngle / M_PI));
+ const Standard_Integer aNbPoints = myGeometryOrientedAngle ? 40 :
+ Max (4, Standard_Integer (50.0 * anAngle / M_PI));
GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints);
if (!aMakePnts.IsDone())
myFixedTextPosition = theTextPos;
}
+//=======================================================================
+//function : SetGeometryOrientedAngle
+//purpose :
+//=======================================================================
+void AIS_AngleDimension::SetGeometryOrientedAngle(const Standard_Boolean& theState)
+{
+ myGeometryOrientedAngle = theState;
+}
+
//=======================================================================
//function : AdjustParameters
//purpose :
Standard_EXPORT virtual const gp_Pnt GetTextPosition () const;
+ //! Sets state if the create arc should be built depending on the input geometry orientation
+ //! or to be always oriented in [0,0,1]. The last case propose angles more than 180 degree.
+ //! @param theSecondAttach [in] the second attachment point.
+ void SetGeometryOrientedAngle(const Standard_Boolean& theState);
+
public:
DEFINE_STANDARD_RTTI (AIS_AngleDimension)
const gp_Pnt& theSecondPoint) const;
private:
+ Standard_Boolean myGeometryOrientedAngle;
gp_Pnt myFirstPoint;
gp_Pnt mySecondPoint;
SketcherPrs_Mirror.h
SketcherPrs_Transformation.h
SketcherPrs_Angle.h
+ AIS_AngleDimension.hxx
)
SET(PROJECT_SOURCES
SketcherPrs_Mirror.cpp
SketcherPrs_Transformation.cpp
SketcherPrs_Angle.cpp
+ AIS_AngleDimension.cxx
)
SET(PROJECT_LIBRARIES
switch (anAngleType) {
case ANGLE_DIRECT: {
- /*gp_Pnt aPnt1(200, 100, 0);
- gp_Pnt aPnt2(100, 100, 0);
- gp_Pnt aPnt3(200, 200, 0);
- //SetMeasuredGeometry(aPnt1, aPnt2, aPnt3);
- SetMeasuredGeometry(aPnt3, aPnt2, aPnt1);
- gp_Pln aPlane(aPnt2, gp_Dir(0, 0, 1));
- SetCustomPlane(aPlane);
- */
+ SetGeometryOrientedAngle(false);
SetMeasuredGeometry(aEdge1, aEdge2);
}
break;
case ANGLE_SUPPLEMENTARY: {
// to calculate center, first and end points
+ SetGeometryOrientedAngle(false);
SetMeasuredGeometry(aEdge1, aEdge2);
- /*
gp_Pnt aCenterPnt = CenterPoint();
gp_Pnt aFirstPnt = FirstPoint();
gp_Pnt aSecondPnt = SecondPoint();
-
- //gp_Pnt aFirstPnt(200, 100, 0);
- //gp_Pnt aCenterPnt(100, 100, 0);
- //gp_Pnt aSecondPnt(200, 200, 0);
double anEdge2Length = aCenterPnt.Distance(aSecondPnt);
-
aSecondPnt = aCenterPnt.Translated (gp_Vec(aCenterPnt, aSecondPnt).Normalized() * (-anEdge2Length));
SetMeasuredGeometry(aFirstPnt, aCenterPnt, aSecondPnt);
- */
}
break;
case ANGLE_BACKWARD: {
- SetMeasuredGeometry(aEdge2, aEdge1);
+ SetGeometryOrientedAngle(true);
+ SetMeasuredGeometry(aEdge1, aEdge2);
}
break;
default: