SetFlyout (0.0);
}
-//=======================================================================
-//function : SetMeasuredGeometry
-//purpose :
-//=======================================================================
-void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
-{
- myCircle = theCircle;
- myGeometryType = GeometryType_Edge;
- myShape = BRepLib_MakeEdge (theCircle);
- myAnchorPoint = ElCLib::Value (0, myCircle);
- myIsGeometryValid = IsValidCircle (myCircle);
-
- if (myIsGeometryValid)
- {
- ComputePlane();
- }
-
- SetToUpdate();
-}
-
//=======================================================================
//function : SetMeasuredGeometry
//purpose :
//=======================================================================
void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
- const gp_Pnt& theAnchorPoint)
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor)
{
myCircle = theCircle;
myGeometryType = GeometryType_Edge;
myShape = BRepLib_MakeEdge (theCircle);
- myAnchorPoint = theAnchorPoint;
- myIsGeometryValid = IsValidCircle (myCircle) && IsValidAnchor (myCircle, theAnchorPoint);
+ myAnchorPoint = theHasAnchor ? theAnchorPoint : ElCLib::Value (0, myCircle);
+ myIsGeometryValid = IsValidCircle (myCircle) && IsValidAnchor (myCircle, myAnchorPoint);
if (myIsGeometryValid)
{
//function : SetMeasuredGeometry
//purpose :
//=======================================================================
-void AIS_RadiusDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape)
+void AIS_RadiusDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape,
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor)
{
Standard_Boolean isClosed = Standard_False;
myShape = theShape;
myGeometryType = GeometryType_UndefShapes;
myIsGeometryValid = InitCircularDimension (theShape, myCircle, myAnchorPoint, isClosed)
- && IsValidCircle (myCircle);
+ && IsValidCircle (myCircle);
+ if (theHasAnchor)
+ {
+ myAnchorPoint = theAnchorPoint;
+ myIsGeometryValid = myIsGeometryValid && IsValidAnchor (myCircle, myAnchorPoint);
+ }
if (myIsGeometryValid)
{
Standard_Real anAnchorDist = theAnchor.Distance (theCircle.Location());
Standard_Real aRadius = myCircle.Radius();
- return Abs (anAnchorDist - aRadius) > Precision::Confusion()
+ return Abs (anAnchorDist - aRadius) <= Precision::Confusion()
&& aCirclePlane.Contains (theAnchor, Precision::Confusion());
}
//! The dimension will become invalid if the radius of the circle
//! is less than Precision::Confusion().
//! @param theCircle [in] the circle to measure.
- Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
+ void SetMeasuredGeometry (const gp_Circ& theCircle) { SetMeasuredGeometry (theCircle, gp_Pnt(), Standard_False); }
//! Measure radius of the circle and orient the dimension so
//! the dimension lines attaches to anchor point on the circle.
//! The dimension will become invalid if the radius of the circle
//! is less than Precision::Confusion().
//! @param theCircle [in] the circle to measure.
- //! @param theAnchorPoint [in] the point to attach the dimension lines.
+ //! @param theAnchorPoint [in] the point to attach the dimension lines, should be on the circle
+ //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle,
- const gp_Pnt& theAnchorPoint);
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor = Standard_True);
//! Measure radius on the passed shape, if applicable.
//! The dimension will become invalid if the passed shape is not
//! measurable or if measured diameter value is less than Precision::Confusion().
//! @param theShape [in] the shape to measure.
- Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
+ void SetMeasuredGeometry (const TopoDS_Shape& theShape) { SetMeasuredGeometry (theShape, gp_Pnt(), Standard_False); }
+
+ //! Measure radius on the passed shape, if applicable.
+ //! The dimension will become invalid if the passed shape is not
+ //! measurable or if measured diameter value is less than Precision::Confusion().
+ //! @param theShape [in] the shape to measure.
+ //! @param theAnchorPoint [in] the point to attach the dimension lines, should be on the circle
+ //! @param theHasAnchor [in] should be set TRUE if theAnchorPoint should be used
+ Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape,
+ const gp_Pnt& theAnchorPoint,
+ const Standard_Boolean theHasAnchor = Standard_True);
//! @return the display units string.
Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE;
}
case AIS_KOD_RADIUS: // radius of the circle
{
- if (aShapes.Extent() == 1)
+ gp_Pnt anAnchor;
+ bool hasAnchor = false;
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator aShapeIter (aShapes); aShapeIter.More(); aShapeIter.Next())
{
- if (aShapes.First()->DynamicType() == STANDARD_TYPE(AIS_Circle))
+ if (Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(aShapeIter.Value()))
{
- Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
- gp_Circ aCircle = aShape->Circle()->Circ();
- aDim = new AIS_RadiusDimension (aCircle);
+ hasAnchor = true;
+ anAnchor = aPoint->Component()->Pnt();
+ aShapes.Remove (aShapeIter);
+ break;
+ }
+ }
+ if (aShapes.Extent() != 1)
+ {
+ std::cout << "Syntax error: wrong number of shapes to build dimension.\n";
+ return 1;
+ }
+
+ if (Handle(AIS_Circle) aShapeCirc = Handle(AIS_Circle)::DownCast(aShapes.First()))
+ {
+ gp_Circ aCircle = aShapeCirc->Circle()->Circ();
+ if (hasAnchor)
+ {
+ aDim = new AIS_RadiusDimension (aCircle, anAnchor);
}
else
{
- Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (aShapes.First());
- if (aShape.IsNull())
- {
- std::cerr << "Error: shape for radius is of wrong type.\n";
- return 1;
- }
- aDim = new AIS_RadiusDimension (aShape->Shape());
+ aDim = new AIS_RadiusDimension (aCircle);
}
}
+ else if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aShapes.First()))
+ {
+ Handle(AIS_RadiusDimension) aRadDim = new AIS_RadiusDimension (aShape->Shape());
+ if (hasAnchor)
+ {
+ aRadDim->SetMeasuredGeometry (aShape->Shape(), anAnchor);
+ }
+ aDim = aRadDim;
+ }
else
{
- std::cerr << theArgs[0] << ": wrong number of shapes to build dimension.\n";
+ std::cout << "Error: shape for radius has wrong type.\n";
return 1;
}
-
break;
}
case AIS_KOD_DIAMETER: