0027828: Reference documentation of AIS_Trihedron contains invalid information about...
[occt.git] / src / AIS / AIS_LengthDimension.hxx
CommitLineData
a6eb515f 1// Copyright (c) 1999-2013 OPEN CASCADE SAS
2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
a6eb515f 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
a6eb515f 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
a6eb515f 13
14#ifndef _AIS_LengthDimension_HeaderFile
15#define _AIS_LengthDimension_HeaderFile
16
17#include <AIS.hxx>
18#include <AIS_Dimension.hxx>
a6eb515f 19#include <AIS_KindOfDimension.hxx>
20#include <Geom_Plane.hxx>
21#include <Geom_Transformation.hxx>
22#include <gp_Pnt.hxx>
23#include <gp_Dir.hxx>
24#include <Prs3d_DimensionAspect.hxx>
6262338c 25#include <Prs3d_Drawer.hxx>
a6eb515f 26#include <Prs3d_Presentation.hxx>
27#include <Prs3d_Projector.hxx>
28#include <PrsMgr_PresentationManager3d.hxx>
29#include <SelectMgr_Selection.hxx>
30#include <Standard.hxx>
31#include <Standard_Macro.hxx>
ec357c5c 32#include <Standard_Type.hxx>
a6eb515f 33#include <TopoDS.hxx>
34#include <TopoDS_Vertex.hxx>
35#include <TCollection_ExtendedString.hxx>
36
37class TopoDS_Face;
38class TCollection_ExtendedString;
39class gp_Pnt;
40class TopoDS_Edge;
41class TopoDS_Shape;
42class Geom_Plane;
a6eb515f 43class Prs3d_Presentation;
44class Prs3d_Projector;
45class Geom_Transformation;
46class SelectMgr_Selection;
a6eb515f 47class Bnd_Box;
48class gp_Dir;
49class TopoDS_Vertex;
50class Standard_Transient;
a6eb515f 51class AIS_LengthDimension;
52
60bf98ae 53DEFINE_STANDARD_HANDLE (AIS_LengthDimension, AIS_Dimension)
a6eb515f 54
60bf98ae 55//! Length dimension. Can be constructued:
56//! - Between two generic points.
57//! - Between two vertices.
58//! - Between two faces.
59//! - Between two parallel edges.
60//! - Between face and edge.
61//!
62//! In case of two points (vertices) or one linear edge the user-defined plane
63//! that includes this geometry is necessary to be set.
64//!
65//! In case of face-edge, edge-vertex or face-face lengthes the automatic plane
66//! computing is allowed. For this plane the third point is found on the
67//! edge or on the face.
1c078d3b 68//!
60bf98ae 69//! Please note that if the inappropriate geometry is defined
70//! or the distance between measured points is less than
71//! Precision::Confusion(), the dimension is invalid and its
72//! presentation can not be computed.
a6eb515f 73class AIS_LengthDimension : public AIS_Dimension
74{
75public:
76
60bf98ae 77 //! Construct length dimension between face and edge.
78 //! Here dimension can be built without user-defined plane.
79 //! @param theFace [in] the face (first shape).
80 //! @param theEdge [in] the edge (second shape).
81 Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace,
82 const TopoDS_Edge& theEdge);
a6eb515f 83
60bf98ae 84 //! Construct length dimension between two faces.
85 //! @param theFirstFace [in] the first face (first shape).
86 //! @param theSecondFace [in] the second face (second shape).
87 Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFirstFace,
88 const TopoDS_Face& theSecondFace);
89
90 //! Construct length dimension between two points in
91 //! the specified plane.
92 //! @param theFirstPoint [in] the first point.
93 //! @param theSecondPoint [in] the second point.
94 //! @param thePlane [in] the plane to orient dimension.
95 Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
96 const gp_Pnt& theSecondPoint,
97 const gp_Pln& thePlane);
98
99 //! Construct length dimension between two arbitrary shapes in
100 //! the specified plane.
101 //! @param theFirstShape [in] the first shape.
102 //! @param theSecondShape [in] the second shape.
103 //! @param thePlane [in] the plane to orient dimension.
a6eb515f 104 Standard_EXPORT AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
105 const TopoDS_Shape& theSecondShape,
60bf98ae 106 const gp_Pln& thePlane);
a6eb515f 107
60bf98ae 108 //! Construct length dimension of linear edge.
109 //! @param theEdge [in] the edge to measure.
110 //! @param thePlane [in] the plane to orient dimension.
111 Standard_EXPORT AIS_LengthDimension (const TopoDS_Edge& theEdge,
112 const gp_Pln& thePlane);
a6eb515f 113
60bf98ae 114public:
a6eb515f 115
60bf98ae 116 //! @return first attachement point.
117 const gp_Pnt& FirstPoint() const
118 {
119 return myFirstPoint;
120 }
121
122 //! @return second attachement point.
123 const gp_Pnt& SecondPoint() const
124 {
125 return mySecondPoint;
126 }
127
128 //! @return first attachement shape.
129 const TopoDS_Shape& FirstShape() const
130 {
131 return myFirstShape;
132 }
133
134 //! @return second attachement shape.
135 const TopoDS_Shape& SecondShape() const
136 {
137 return mySecondShape;
138 }
139
140public:
141
142 //! Measure distance between two points.
143 //! The dimension will become invalid if the new distance between
144 //! attachement points is less than Precision::Confusion().
145 //! @param theFirstPoint [in] the first point.
146 //! @param theSecondPoint [in] the second point.
147 //! @param thePlane [in] the user-defined plane
148 Standard_EXPORT void SetMeasuredGeometry (const gp_Pnt& theFirstPoint,
149 const gp_Pnt& theSecondPoint,
150 const gp_Pln& thePlane);
151
152 //! Measure length of edge.
153 //! The dimension will become invalid if the new length of edge
154 //! is less than Precision::Confusion().
155 //! @param theEdge [in] the edge to measure.
156 //! @param thePlane [in] the user-defined plane
157 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Edge& theEdge,
158 const gp_Pln& thePlane);
159
160 //! Measure distance between two faces.
161 //! The dimension will become invalid if the distance can not
162 //! be measured or it is less than Precision::Confusion().
163 //! @param theFirstFace [in] the first face (first shape).
164 //! @param theSecondFace [in] the second face (second shape).
165 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
166 const TopoDS_Face& theSecondFace);
167
168 //! Measure distance between face and edge.
169 //! The dimension will become invalid if the distance can not
170 //! be measured or it is less than Precision::Confusion().
171 //! @param theFace [in] the face (first shape).
172 //! @param theEdge [in] the edge (second shape).
173 Standard_EXPORT void SetMeasuredGeometry (const TopoDS_Face& theFace,
174 const TopoDS_Edge& theEdge);
175
176 //! Measure distance between generic pair of shapes (edges, vertices, length),
177 //! where measuring is applicable.
178 //! @param theFirstShape [in] the first shape.
179 //! @param theSecondShape [in] the second shape.
180 Standard_EXPORT void SetMeasuredShapes (const TopoDS_Shape& theFirstShape,
181 const TopoDS_Shape& theSecondShape);
182
183 //! @return the display units string.
79104795 184 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const Standard_OVERRIDE;
af203d54 185
60bf98ae 186 //! @return the model units string.
79104795 187 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const Standard_OVERRIDE;
60bf98ae 188
79104795 189 Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
60bf98ae 190
79104795 191 Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& theUnits) Standard_OVERRIDE;
a6eb515f 192
79104795 193 Standard_EXPORT virtual void SetTextPosition (const gp_Pnt& theTextPos) Standard_OVERRIDE;
af203d54 194
79104795 195 Standard_EXPORT virtual const gp_Pnt GetTextPosition() const Standard_OVERRIDE;
af203d54 196
d7bffd44 197public:
198
92efcf78 199 DEFINE_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
d7bffd44 200
60bf98ae 201protected:
d7bffd44 202
60bf98ae 203 //! Checks if the plane includes first and second points to build dimension.
79104795 204 Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
d7bffd44 205
60bf98ae 206 Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const;
d7bffd44 207
79104795 208 Standard_EXPORT Standard_Real ComputeValue() const Standard_OVERRIDE;
d7bffd44 209
60bf98ae 210 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
211 const Handle(Prs3d_Presentation)& thePresentation,
79104795 212 const Standard_Integer theMode = 0) Standard_OVERRIDE;
d7bffd44 213
60bf98ae 214 Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
79104795 215 const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
a6eb515f 216
60bf98ae 217protected:
218
219 //! Checks that distance between two points is valid.
220 //! @param theFirstPoint [in] the first point.
221 //! @param theSecondPoint [in] the second point.
222 Standard_EXPORT Standard_Boolean IsValidPoints (const gp_Pnt& theFirstPoint,
223 const gp_Pnt& theSecondPoint) const;
224
225 Standard_EXPORT Standard_Boolean InitTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
226 const TopoDS_Edge& theSecondEdge,
227 gp_Dir& theEdgeDir);
228
229 //! Auxiliary method for InitTwoShapesPoints()
230 //! in case of the distance between edge and vertex.
231 //! Finds the point on the edge that is the closest one to <theVertex>.
232 //! @param theEdgeDir [out] is the direction on the edge to build
233 //! automatical plane.
234 Standard_EXPORT Standard_Boolean InitEdgeVertexLength (const TopoDS_Edge& theEdge,
235 const TopoDS_Vertex& theVertex,
236 gp_Dir& theEdgeDir,
237 Standard_Boolean isInfinite);
238
239 //! Auxiliary method for InitTwoShapesPoints()
240 //! in case of the distance between face and edge.
241 //! The first attachment point is first parameter point from <theEdge>.
242 //! Find the second attachment point which belongs to <theFace>
243 //! Iterate over the edges of the face and find the closest point according
244 //! to finded point on edge.
245 //! @param theEdgeDir [out] is the direction on the edge to build
246 //! automatical plane.
247 Standard_EXPORT Standard_Boolean InitEdgeFaceLength (const TopoDS_Edge& theEdge,
248 const TopoDS_Face& theFace,
249 gp_Dir& theEdgeDir);
250
251 //! Initialization of two attach points in case of two owner shapes.
252 Standard_EXPORT Standard_Boolean InitTwoShapesPoints (const TopoDS_Shape& theFirstShape,
253 const TopoDS_Shape& theSecondShape,
254 gp_Pln& theComputedPlane,
255 Standard_Boolean& theIsPlaneComputed);
256
257 //! Initialization of two attach points in case of one owner shape.
258 Standard_EXPORT Standard_Boolean InitOneShapePoints (const TopoDS_Shape& theShape);
259
260private:
a6eb515f 261
60bf98ae 262 gp_Pnt myFirstPoint;
263 gp_Pnt mySecondPoint;
264 TopoDS_Shape myFirstShape;
265 TopoDS_Shape mySecondShape;
a6eb515f 266};
267
60bf98ae 268#endif // _AIS_LengthDimension_HeaderFile