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 class AIS_DiameterDimension;
28 DEFINE_STANDARD_HANDLE (AIS_DiameterDimension, AIS_Dimension)
30 //! Diameter dimension. Can be constructued:
31 //! - On generic circle.
32 //! - On generic circle with user-defined anchor point on that circle
33 //! (dimension plane is oriented to follow the anchor point).
34 //! - On generic circle in the specified plane.
35 //! - On generic shape containing geometry that can be measured
36 //! by diameter dimension: circle wire, circular face, etc.
37 //! The anchor point is the location of the left attachement point of
38 //! dimension on the circle.
39 //! The anchor point computation is processed after dimension plane setting
40 //! so that positive flyout direction stands with normal of the circle and
41 //! the normal of the plane.
42 //! If the plane is user-defined the anchor point was computed as intersection
43 //! of the plane and the basis circle. Among two intersection points
44 //! the one is selected so that positive flyout direction vector and
45 //! the circle normal on the one side form the circle plane.
46 //! (corner between positive flyout directio nand the circle normal is acute.)
47 //! If the plane is computed automatically (by default it is the circle plane),
48 //! the anchor point is the zero parameter point of the circle.
50 //! The dimension is considered as invalid if the user-defined plane
51 //! does not include th enachor point and th ecircle center,
52 //! if the diameter of the circle is less than Precision::Confusion().
53 //! In case if the dimension is built on the arbitrary shape, it can be considered
54 //! as invalid if the shape does not contain circle geometry.
56 class AIS_DiameterDimension : public AIS_Dimension
60 //! Construct diameter dimension for the circle.
61 //! @param theCircle [in] the circle to measure.
62 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle);
64 //! Construct diameter dimension for the circle and orient it correspondingly
65 //! to the passed plane.
66 //! @param theCircle [in] the circle to measure.
67 //! @param thePlane [in] the plane defining preferred orientation
69 Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
70 const gp_Pln& thePlane);
72 //! Construct diameter on the passed shape, if applicable.
73 //! @param theShape [in] the shape to measure.
74 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
76 //! Construct diameter on the passed shape, if applicable - and
77 //! define the preferred plane to orient the dimension.
78 //! @param theShape [in] the shape to measure.
79 //! @param thePlane [in] the plane defining preferred orientation
81 Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape,
82 const gp_Pln& thePlane);
86 //! @return measured geometry circle.
87 const gp_Circ& Circle() const
92 //! @return anchor point on circle for diameter dimension.
93 Standard_EXPORT gp_Pnt AnchorPoint();
95 //! @return the measured shape.
96 const TopoDS_Shape& Shape() const
103 //! Measure diameter of the circle.
104 //! The actual dimension plane is used for determining anchor points
105 //! on the circle to attach the dimension lines to.
106 //! The dimension will become invalid if the diameter of the circle
107 //! is less than Precision::Confusion().
108 //! @param theCircle [in] the circle to measure.
109 Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
111 //! Measure diameter on the passed shape, if applicable.
112 //! The dimension will become invalid if the passed shape is not
113 //! measurable or if measured diameter value is less than Precision::Confusion().
114 //! @param theShape [in] the shape to measure.
115 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Shape& theShape);
117 //! @return the display units string.
118 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const;
120 //! @return the model units string.
121 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const;
123 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
125 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
127 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos);
129 Standard_EXPORT virtual const gp_Pnt GetTextPosition() const;
133 DEFINE_STANDARD_RTTI(AIS_DiameterDimension, AIS_Dimension)
137 //! Override this method to change logic of anchor point computation.
138 //! Computes anchor point. Its computation is based on the current
139 //! dimension plane. Therfore, anchor point is an intersection of plane
142 //! 1) The plane should be set or computed before.
143 //! 2) The plane should inclide th ecircle center to be valid.
144 Standard_EXPORT virtual void ComputeAnchorPoint();
146 Standard_EXPORT virtual void ComputePlane();
148 //! Checks if the center of the circle is on the plane.
149 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
151 Standard_EXPORT virtual Standard_Real ComputeValue() const;
153 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
154 const Handle(Prs3d_Presentation)& thePresentation,
155 const Standard_Integer theMode = 0);
157 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
158 const Handle(SelectMgr_EntityOwner)& theEntityOwner);
162 //! Compute points on the circle sides for the dimension plane.
163 //! Program error exception is raised if the dimension plane "x" direction
164 //! is orthogonal to plane (the "impossible" case). The passed dimension plane
165 //! is the one specially computed to locate dimension presentation in circle.
166 //! @param theCircle [in] the circle.
167 //! @param theFirstPnt [out] the first point.
168 //! @param theSecondPnt [out] the second point.
169 Standard_EXPORT void ComputeSidePoints (const gp_Circ& theCircle,
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