1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2013 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_AngleDimension_HeaderFile
20 #define _AIS_AngleDimension_HeaderFile
22 #include <AIS_Dimension.hxx>
23 #include <Geom_Plane.hxx>
24 #include <Geom_Line.hxx>
25 #include <Geom_Transformation.hxx>
30 #include <Prs3d_DimensionAspect.hxx>
31 #include <Prs3d_Projector.hxx>
32 #include <Prs3d_Presentation.hxx>
33 #include <Standard.hxx>
34 #include <Standard_Macro.hxx>
35 #include <Standard_DefineHandle.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <TopoDS_Face.hxx>
39 #include <TopoDS_Vertex.hxx>
41 DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
43 //! Angle dimension. Can be constructed:
44 //! - on two intersected edges.
45 //! - on three points or vertices.
46 //! - on conical face.
47 //! - between two intersected faces.
49 //! In case of three points or two intersected edges the dimension plane
50 //! (on which dimension presentation is built) can be computed uniquely
51 //! as through three defined points can be built only one plane.
52 //! Therefore, if user-defined plane differs from this one, the dimension can't be built.
54 //! In cases of two planes automatical plane by default is built on point of the
55 //! origin of parametrical space of the first face (the basis surface) so, that
56 //! the working plane and two faces intersection forms minimal angle between the faces.
57 //! User can define the other point which the dimension plane should pass through
58 //! using the appropriate constructor. This point can lay on the one of the faces or not.
59 //! Also user can define his own plane but it should pass through the three points
60 //! computed on the geometry initialization step (when the constructor or SetMeasuredGeometry() method
63 //! In case of the conical face the center point of the angle is the apex of the conical surface.
64 //! The attachment points are points of the first and the last parameter of the basis circle of the cone.
66 class AIS_AngleDimension : public AIS_Dimension
70 //! Constructs minimum angle dimension between two linear edges (where possible).
71 //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
72 //! @param theFirstEdge [in] the first edge.
73 //! @param theSecondEdge [in] the second edge.
74 Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
75 const TopoDS_Edge& theSecondEdge);
77 //! Constructs the angle display object defined by three points.
78 //! @param theFirstPoint [in] the first point (point on first angle flyout).
79 //! @param theSecondPoint [in] the center point of angle dimension.
80 //! @param theThirdPoint [in] the second point (point on second angle flyout).
81 Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
82 const gp_Pnt& theSecondPoint,
83 const gp_Pnt& theThirdPoint);
85 //! Constructs the angle display object defined by three vertices.
86 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
87 //! @param theSecondVertex [in] the center vertex of angle dimension.
88 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
89 Standard_EXPORT AIS_AngleDimension (const TopoDS_Vertex& theFirstVertex,
90 const TopoDS_Vertex& theSecondVertex,
91 const TopoDS_Vertex& theThirdVertex);
93 //! Constructs angle dimension for the cone face.
94 //! @param theCone [in] the conical face.
95 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
97 //! Constructs angle dimension between two planar faces.
98 //! @param theFirstFace [in] the first face.
99 //! @param theSecondFace [in] the second face.
100 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
101 const TopoDS_Face& theSecondFace);
103 //! Constructs angle dimension between two planar faces.
104 //! @param theFirstFace [in] the first face.
105 //! @param theSecondFace [in] the second face.
106 //! @param thePoint [in] the point which the dimension plane should pass through.
107 //! This point can lay on the one of the faces or not.
108 Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace,
109 const TopoDS_Face& theSecondFace,
110 const gp_Pnt& thePoint);
114 //! @return first point forming the angle.
115 const gp_Pnt& FirstPoint() const
120 //! @return second point forming the angle.
121 const gp_Pnt& SecondPoint() const
123 return mySecondPoint;
126 //! @return center point forming the angle.
127 const gp_Pnt& CenterPoint() const
129 return myCenterPoint;
132 //! @return first argument shape.
133 const TopoDS_Shape& FirstShape() const
138 //! @return second argument shape.
139 const TopoDS_Shape& SecondShape() const
141 return mySecondShape;
144 //! @return third argument shape.
145 const TopoDS_Shape& ThirdShape() const
152 //! Measures minimum angle dimension between two linear edges.
153 //! These two edges should be intersected by each other. Otherwise the geometry is not valid.
154 //! @param theFirstEdge [in] the first edge.
155 //! @param theSecondEdge [in] the second edge.
156 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theFirstEdge,
157 const TopoDS_Edge& theSecondEdge);
159 //! Measures angle defined by three points.
160 //! @param theFirstPoint [in] the first point (point on first angle flyout).
161 //! @param theSecondPoint [in] the center point of angle dimension.
162 //! @param theThirdPoint [in] the second point (point on second angle flyout).
163 Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
164 const gp_Pnt& theSecondPoint,
165 const gp_Pnt& theThridPoint);
167 //! Measures angle defined by three vertices.
168 //! @param theFirstVertex [in] the first vertex (vertex for first angle flyout).
169 //! @param theSecondVertex [in] the center vertex of angle dimension.
170 //! @param theThirdPoint [in] the second vertex (vertex for second angle flyout).
171 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Vertex& theFirstVertex,
172 const TopoDS_Vertex& theSecondVertex,
173 const TopoDS_Vertex& theThirdVertex);
175 //! Measures angle of conical face.
176 //! @param theCone [in] the shape to measure.
177 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theCone);
179 //! Measures angle between two planar faces.
180 //! @param theFirstFace [in] the first face.
181 //! @param theSecondFace [in] the second face..
182 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
183 const TopoDS_Face& theSecondFace);
185 //! Measures angle between two planar faces.
186 //! @param theFirstFace [in] the first face.
187 //! @param theSecondFace [in] the second face.
188 //! @param thePoint [in] the point which the dimension plane should pass through.
189 //! This point can lay on the one of the faces or not.
190 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
191 const TopoDS_Face& theSecondFace,
192 const gp_Pnt& thePoint);
194 //! @return the display units string.
195 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits () const;
197 //! @return the model units string.
198 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits () const;
200 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits);
202 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits);
206 DEFINE_STANDARD_RTTI (AIS_AngleDimension)
210 //! Initialization of fields that is common to all constructors.
211 Standard_EXPORT void Init();
213 //! @param theFirstAttach [in] the first attachment point.
214 //! @param theSecondAttach [in] the second attachment point.
215 //! @param theCenter [in] the center point (center point of the angle).
216 //! @return the center of the dimension arc (the main dimension line in case of angle).
217 Standard_EXPORT gp_Pnt GetCenterOnArc (const gp_Pnt& theFirstAttach,
218 const gp_Pnt& theSecondAttach,
219 const gp_Pnt& theCenter);
221 //! Draws main dimension line (arc).
222 //! @param thePresentation [in] the dimension presentation.
223 //! @param theFirstAttach [in] the first attachment point.
224 //! @param theSecondAttach [in] the second attachment point.
225 //! @param theCenter [in] the center point (center point of the angle).
226 //! @param theRadius [in] the radius of the dimension arc.
227 //! @param theMode [in] the display mode.
228 Standard_EXPORT void DrawArc (const Handle(Prs3d_Presentation)& thePresentation,
229 const gp_Pnt& theFirstAttach,
230 const gp_Pnt& theSecondAttach,
231 const gp_Pnt& theCenter,
232 const Standard_Real theRadius,
233 const Standard_Integer theMode);
235 //! Draws main dimension line (arc) with text.
236 //! @param thePresentation [in] the dimension presentation.
237 //! @param theFirstAttach [in] the first attachment point.
238 //! @param theSecondAttach [in] the second attachment point.
239 //! @param theCenter [in] the center point (center point of the angle).
240 //! @param theText [in] the text label string.
241 //! @param theTextWidth [in] the text label width.
242 //! @param theMode [in] the display mode.
243 //! @param theLabelPosition [in] the text label vertical and horizontal positioning option
244 //! respectively to the main dimension line.
245 Standard_EXPORT void DrawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
246 const gp_Pnt& theFirstAttach,
247 const gp_Pnt& theSecondAttach,
248 const gp_Pnt& theCenter,
249 const TCollection_ExtendedString& theText,
250 const Standard_Real theTextWidth,
251 const Standard_Integer theMode,
252 const Standard_Integer theLabelPosition);
256 Standard_EXPORT virtual void ComputePlane();
258 //! Checks if the plane includes three angle points to build dimension.
259 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
261 Standard_EXPORT virtual Standard_Real ComputeValue() const;
263 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
264 const Handle(Prs3d_Presentation)& thePresentation,
265 const Standard_Integer theMode = 0);
267 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
268 const Handle(SelectMgr_EntityOwner)& theOwner);
272 //! Init angular dimension to measure angle between two linear edges.
273 //! @return TRUE if the angular dimension can be constructured
274 //! for the passed edges.
275 Standard_EXPORT Standard_Boolean InitTwoEdgesAngle (gp_Pln& theComputedPlane);
277 //! Init angular dimension to measure angle between two planar faces.
278 //! there is no user-defined poisitoning. So attach points are set
279 //! according to faces geometry (in origin of the first face basis surface).
280 //! @return TRUE if the angular dimension can be constructed
281 //! for the passed faces.
282 Standard_EXPORT Standard_Boolean InitTwoFacesAngle();
284 //! Init angular dimension to measure angle between two planar faces.
285 //! @param thePointOnFirstFace [in] the point which the dimension plane should pass through.
286 //! This point can lay on the one of the faces or not.
287 //! It will be projected on the first face and this point will be set
288 //! as the first point attach point.
289 //! It defines some kind of dimension positioning over the faces.
290 //! @return TRUE if the angular dimension can be constructed
291 //! for the passed faces.
292 Standard_EXPORT Standard_Boolean InitTwoFacesAngle (const gp_Pnt thePointOnFirstFace);
294 //! Init angular dimension to measure cone face.
295 //! @return TRUE if the angular dimension can be constructed
296 //! for the passed cone.
297 Standard_EXPORT Standard_Boolean InitConeAngle();
299 //! Check that the points forming angle are valid.
300 //! @return TRUE if the points met the following requirements:
301 //! The (P1, Center), (P2, Center) can be built.
302 //! The angle between the vectors > Precision::Angular().
303 Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
304 const gp_Pnt& theCenterPoint,
305 const gp_Pnt& theSecondPoint) const;
310 gp_Pnt mySecondPoint;
311 gp_Pnt myCenterPoint;
312 TopoDS_Shape myFirstShape;
313 TopoDS_Shape mySecondShape;
314 TopoDS_Shape myThirdShape;
317 #endif // _AIS_AngleDimension_HeaderFile