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