1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 #ifndef _AIS_RadiusDimension_HeaderFile
20 #define _AIS_RadiusDimension_HeaderFile
23 #include <AIS_Dimension.hxx>
25 #include <gp_Circ.hxx>
26 #include <Standard.hxx>
27 #include <Standard_Macro.hxx>
29 DEFINE_STANDARD_HANDLE (AIS_RadiusDimension,AIS_Dimension)
31 //! Radius dimension. Can be constructued:
32 //! - On generic circle.
33 //! - On generic circle with user-defined anchor point on that circle.
34 //! - On generic shape containing geometry that can be measured
35 //! by diameter dimension: circle wire, arc, circular face, etc.
36 //! The anchor point is the location of left attachement point of
37 //! dimension on the circle. It can be user-specified, or computed as
38 //! middle point on the arc. The radius dimension always lies in the
39 //! plane of the measured circle. The dimension is considered as
40 //! invalid if the user-specified anchor point is not lying on the circle,
41 //! if the radius of the circle is less than Precision::Confusion().
42 //! In case if the dimension is built on the arbitrary shape,
43 //! it can be considered as invalid if the shape does not contain
45 class AIS_RadiusDimension : public AIS_Dimension
49 //! Create radius dimension for the circle geometry.
50 //! @param theCircle [in] the circle to measure.
51 Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle);
53 //! Create radius dimension for the circle geometry and define its
54 //! orientation by location of the first point on that circle.
55 //! @param theCircle [in] the circle to measure.
56 //! @param theAnchorPoint [in] the point to define the position
57 //! of the dimension attachement on the circle.
58 Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
59 const gp_Pnt& theAnchorPoint);
61 //! Create radius dimension for the arbitrary shape (if possible).
62 //! @param theShape [in] the shape to measure.
63 Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& theShape);
67 //! @return measured geometry circle.
68 const gp_Circ& Circle() const
73 //! @return anchor point on circle for radius dimension.
74 const gp_Pnt& AnchorPoint() const
79 //! @return the measured shape.
80 const TopoDS_Shape& Shape() const
87 //! Measure radius of the circle.
88 //! The dimension will become invalid if the radius of the circle
89 //! is less than Precision::Confusion().
90 //! @param theCircle [in] the circle to measure.
91 Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
93 //! Measure radius of the circle and orient the dimension so
94 //! the dimension lines attaches to anchor point on the circle.
95 //! The dimension will become invalid if the radiuss of the circle
96 //! is less than Precision::Confusion().
97 //! @param theCircle [in] the circle to measure.
98 //! @param theAnchorPoint [in] the point to attach the dimension lines.
99 Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle,
100 const gp_Pnt& theAnchorPoint);
102 //! Measure radius on the passed shape, if applicable.
103 //! The dimension will become invalid if the passed shape is not
104 //! measurable or if measured diameter value is less than Precision::Confusion().
105 //! @param theShape [in] the shape to measure.
106 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
108 //! @return the display units string.
109 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits () const;
111 //! @return the model units string.
112 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits () const;
114 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
116 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
120 DEFINE_STANDARD_RTTI (AIS_RadiusDimension)
124 Standard_EXPORT virtual void ComputePlane();
126 //! Checks if anchor point and the center of the circle are on the plane.
127 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
129 Standard_EXPORT virtual Standard_Real ComputeValue() const;
131 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
132 const Handle(Prs3d_Presentation)& thePresentation,
133 const Standard_Integer theMode = 0);
137 Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
139 Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
140 const gp_Pnt& thePnt) const;
145 gp_Pnt myAnchorPoint;
146 TopoDS_Shape myShape;
149 #endif // _AIS_RadiusDimension_HeaderFile