1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #ifndef _AIS_DiameterDimension_HeaderFile
17 #define _AIS_DiameterDimension_HeaderFile
20 #include <AIS_Dimension.hxx>
22 #include <gp_Circ.hxx>
23 #include <Standard.hxx>
24 #include <Standard_Macro.hxx>
25 #include <Standard_Type.hxx>
27 DEFINE_STANDARD_HANDLE (AIS_DiameterDimension, AIS_Dimension)
29 //! Diameter dimension. Can be constructued:
30 //! - On generic circle.
31 //! - On generic circle with user-defined anchor point on that circle
32 //! (dimension plane is oriented to follow the anchor point).
33 //! - On generic circle in the specified plane.
34 //! - On generic shape containing geometry that can be measured
35 //! by diameter dimension: circle wire, circular face, etc.
36 //! The anchor point is the location of the left attachement point of
37 //! dimension on the circle.
38 //! The anchor point computation is processed after dimension plane setting
39 //! so that positive flyout direction stands with normal of the circle and
40 //! the normal of the plane.
41 //! If the plane is user-defined the anchor point was computed as intersection
42 //! of the plane and the basis circle. Among two intersection points
43 //! the one is selected so that positive flyout direction vector and
44 //! the circle normal on the one side form the circle plane.
45 //! (corner between positive flyout directio nand the circle normal is acute.)
46 //! If the plane is computed automatically (by default it is the circle plane),
47 //! the anchor point is the zero parameter point of the circle.
49 //! The dimension is considered as invalid if the user-defined plane
50 //! does not include th enachor point and th ecircle center,
51 //! if the diameter of the circle is less than Precision::Confusion().
52 //! In case if the dimension is built on the arbitrary shape, it can be considered
53 //! as invalid if the shape does not contain circle geometry.
55 class AIS_DiameterDimension : public AIS_Dimension
59 //! Construct diameter dimension for the circle.
60 //! @param theCircle [in] the circle to measure.
61 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle);
63 //! Construct diameter dimension for the circle and orient it correspondingly
64 //! to the passed plane.
65 //! @param theCircle [in] the circle to measure.
66 //! @param thePlane [in] the plane defining preferred orientation
68 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
69 const gp_Pln& thePlane);
71 //! Construct diameter on the passed shape, if applicable.
72 //! @param theShape [in] the shape to measure.
73 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
75 //! Construct diameter on the passed shape, if applicable - and
76 //! define the preferred plane to orient the dimension.
77 //! @param theShape [in] the shape to measure.
78 //! @param thePlane [in] the plane defining preferred orientation
80 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape,
81 const gp_Pln& thePlane);
85 //! @return measured geometry circle.
86 const gp_Circ& Circle() const
91 //! @return anchor point on circle for diameter dimension.
92 Standard_EXPORT gp_Pnt AnchorPoint();
94 //! @return the measured shape.
95 const TopoDS_Shape& Shape() const
102 //! Measure diameter of the circle.
103 //! The actual dimension plane is used for determining anchor points
104 //! on the circle to attach the dimension lines to.
105 //! The dimension will become invalid if the diameter of the circle
106 //! is less than Precision::Confusion().
107 //! @param theCircle [in] the circle to measure.
108 Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
110 //! Measure diameter on the passed shape, if applicable.
111 //! The dimension will become invalid if the passed shape is not
112 //! measurable or if measured diameter value is less than Precision::Confusion().
113 //! @param theShape [in] the shape to measure.
114 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
116 //! @return the display units string.
117 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
119 //! @return the model units string.
120 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
122 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
124 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
126 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos);
128 Standard_EXPORT virtual const gp_Pnt GetTextPosition() const;
132 DEFINE_STANDARD_RTTI(AIS_DiameterDimension, AIS_Dimension)
136 //! Override this method to change logic of anchor point computation.
137 //! Computes anchor point. Its computation is based on the current
138 //! dimension plane. Therfore, anchor point is an intersection of plane
141 //! 1) The plane should be set or computed before.
142 //! 2) The plane should inclide th ecircle center to be valid.
143 Standard_EXPORT virtual void ComputeAnchorPoint();
145 Standard_EXPORT virtual void ComputePlane();
147 //! Checks if the center of the circle is on the plane.
148 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
150 Standard_EXPORT virtual Standard_Real ComputeValue() const;
152 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
153 const Handle(Prs3d_Presentation)& thePresentation,
154 const Standard_Integer theMode = 0);
156 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
157 const Handle(SelectMgr_EntityOwner)& theEntityOwner);
161 //! Compute points on the circle sides for the dimension plane.
162 //! Program error exception is raised if the dimension plane "x" direction
163 //! is orthogonal to plane (the "impossible" case). The passed dimension plane
164 //! is the one specially computed to locate dimension presentation in circle.
165 //! @param theCircle [in] the circle.
166 //! @param theFirstPnt [out] the first point.
167 //! @param theSecondPnt [out] the second point.
168 Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
170 gp_Pnt& theSecondPnt);
172 Standard_EXPORT Standard_Boolean IsValidCircle (const gp_Circ& theCircle) const;
174 Standard_EXPORT Standard_Boolean IsValidAnchor (const gp_Circ& theCircle,
175 const gp_Pnt& thePnt) const;
180 gp_Pnt myAnchorPoint;
181 TopoDS_Shape myShape;
184 #endif // _AIS_DiameterDimension_HeaderFile