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_DiameterDimension_HeaderFile
20 #define _AIS_DiameterDimension_HeaderFile
23 #include <AIS_Dimension.hxx>
25 #include <gp_Circ.hxx>
26 #include <Standard.hxx>
27 #include <Standard_Macro.hxx>
28 #include <Standard_DefineHandle.hxx>
30 DEFINE_STANDARD_HANDLE (AIS_DiameterDimension, AIS_Dimension)
32 //! Diameter dimension. Can be constructued:
33 //! - On generic circle.
34 //! - On generic circle with user-defined anchor point on that circle
35 //! (dimension plane is oriented to follow the anchor point).
36 //! - On generic circle in the specified plane.
37 //! - On generic shape containing geometry that can be measured
38 //! by diameter dimension: circle wire, circular face, etc.
39 //! The anchor point is the location of the left attachement point of
40 //! dimension on the circle.
41 //! The anchor point computation is processed after dimension plane setting
42 //! so that positive flyout direction stands with normal of the circle and
43 //! the normal of the plane.
44 //! If the plane is user-defined the anchor point was computed as intersection
45 //! of the plane and the basis circle. Among two intersection points
46 //! the one is selected so that positive flyout direction vector and
47 //! the circle normal on the one side form the circle plane.
48 //! (corner between positive flyout directio nand the circle normal is acute.)
49 //! If the plane is computed automatically (by default it is the circle plane),
50 //! the anchor point is the zero parameter point of the circle.
52 //! The dimension is considered as invalid if the user-defined plane
53 //! does not include th enachor point and th ecircle center,
54 //! if the diameter of the circle is less than Precision::Confusion().
55 //! In case if the dimension is built on the arbitrary shape, it can be considered
56 //! as invalid if the shape does not contain circle geometry.
58 class AIS_DiameterDimension : public AIS_Dimension
62 //! Construct diameter dimension for the circle.
63 //! @param theCircle [in] the circle to measure.
64 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle);
66 //! Construct diameter dimension for the circle and orient it correspondingly
67 //! to the passed plane.
68 //! @param theCircle [in] the circle to measure.
69 //! @param thePlane [in] the plane defining preferred orientation
71 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
72 const gp_Pln& thePlane);
74 //! Construct diameter on the passed shape, if applicable.
75 //! @param theShape [in] the shape to measure.
76 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
78 //! Construct diameter on the passed shape, if applicable - and
79 //! define the preferred plane to orient the dimension.
80 //! @param theShape [in] the shape to measure.
81 //! @param thePlane [in] the plane defining preferred orientation
83 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape,
84 const gp_Pln& thePlane);
88 //! @return measured geometry circle.
89 const gp_Circ& Circle() const
94 //! @return anchor point on circle for diameter dimension.
95 Standard_EXPORT gp_Pnt AnchorPoint();
97 //! @return the measured shape.
98 const TopoDS_Shape& Shape() const
105 //! Measure diameter of the circle.
106 //! The actual dimension plane is used for determining anchor points
107 //! on the circle to attach the dimension lines to.
108 //! The dimension will become invalid if the diameter of the circle
109 //! is less than Precision::Confusion().
110 //! @param theCircle [in] the circle to measure.
111 Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
113 //! Measure diameter on the passed shape, if applicable.
114 //! The dimension will become invalid if the passed shape is not
115 //! measurable or if measured diameter value is less than Precision::Confusion().
116 //! @param theShape [in] the shape to measure.
117 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
119 //! @return the display units string.
120 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits () const;
122 //! @return the model units string.
123 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits () const;
125 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
127 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
131 DEFINE_STANDARD_RTTI(AIS_DiameterDimension)
135 //! Override this method to change logic of anchor point computation.
136 //! Computes anchor point. Its computation is based on the current
137 //! dimension plane. Therfore, anchor point is an intersection of plane
140 //! 1) The plane should be set or computed before.
141 //! 2) The plane should inclide th ecircle center to be valid.
142 Standard_EXPORT virtual void ComputeAnchorPoint();
144 Standard_EXPORT virtual void ComputePlane();
146 //! Checks if the center of the circle is on the plane.
147 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
149 Standard_EXPORT virtual Standard_Real ComputeValue() const;
151 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
152 const Handle(Prs3d_Presentation)& thePresentation,
153 const Standard_Integer theMode = 0);
155 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
156 const Handle(SelectMgr_EntityOwner)& theEntityOwner);
160 //! Compute points on the circle sides for the specified dimension plane.
161 //! Program error exception is raised if the dimension plane "x" direction
162 //! is orthogonal to plane (the "impossible" case). The passed dimension plane
163 //! is the one specially computed to locate dimension presentation in circle.
164 //! @param theCircle [in] the circle.
165 //! @param thePlane [in] the dimension presentation plane computed.
166 //! @param theFirstPnt [out] the first point.
167 //! @param theSecondPnt [out] the second point.
168 Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
169 const gp_Pln& thePlane,
171 gp_Pnt& theSecondPnt);
173 Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
175 Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
176 const gp_Pnt& thePnt) const;
181 gp_Pnt myAnchorPoint;
182 TopoDS_Shape myShape;
185 #endif // _AIS_DiameterDimension_HeaderFile