42cf5bc1 |
1 | // Created on: 1996-12-11 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _AIS_HeaderFile |
18 | #define _AIS_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Boolean.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <Standard_Real.hxx> |
27 | #include <AIS_KindOfSurface.hxx> |
28 | #include <Prs3d_Drawer.hxx> |
29 | #include <Quantity_NameOfColor.hxx> |
30 | #include <Aspect_TypeOfLine.hxx> |
31 | #include <Aspect_TypeOfMarker.hxx> |
32 | class gp_Pnt; |
33 | class TopoDS_Shape; |
34 | class gp_Lin; |
35 | class Geom_Curve; |
36 | class TopoDS_Edge; |
37 | class Geom_Plane; |
38 | class TopoDS_Vertex; |
39 | class TopoDS_Face; |
40 | class gp_Pln; |
41 | class Geom_Surface; |
42 | class gp_Dir; |
43 | class Bnd_Box; |
44 | class gp_Elips; |
45 | class Prs3d_Presentation; |
46 | class AIS_Triangulation; |
47 | class AIS_InteractiveContext; |
48 | class AIS_GraphicTool; |
49 | class AIS_LocalContext; |
50 | class AIS_LocalStatus; |
51 | class AIS_GlobalStatus; |
52 | class AIS_InteractiveObject; |
53 | class AIS_Point; |
54 | class AIS_Axis; |
55 | class AIS_Trihedron; |
56 | class AIS_PlaneTrihedron; |
57 | class AIS_Line; |
58 | class AIS_Circle; |
59 | class AIS_Plane; |
60 | class AIS_Shape; |
61 | class AIS_ConnectedInteractive; |
62 | class AIS_MultipleConnectedInteractive; |
63 | class AIS_DimensionOwner; |
64 | class AIS_Relation; |
65 | class AIS_EllipseRadiusDimension; |
66 | class AIS_MaxRadiusDimension; |
67 | class AIS_MinRadiusDimension; |
68 | class AIS_Chamf2dDimension; |
69 | class AIS_Chamf3dDimension; |
70 | class AIS_OffsetDimension; |
71 | class AIS_FixRelation; |
72 | class AIS_PerpendicularRelation; |
73 | class AIS_ParallelRelation; |
74 | class AIS_TangentRelation; |
75 | class AIS_ConcentricRelation; |
76 | class AIS_IdenticRelation; |
77 | class AIS_SymmetricRelation; |
78 | class AIS_MidPointRelation; |
79 | class AIS_EqualRadiusRelation; |
80 | class AIS_EqualDistanceRelation; |
81 | class AIS_TypeFilter; |
82 | class AIS_SignatureFilter; |
83 | class AIS_ExclusionFilter; |
84 | class AIS_AttributeFilter; |
85 | class AIS_C0RegularityFilter; |
86 | class AIS_BadEdgeFilter; |
87 | class AIS_Selection; |
88 | |
89 | |
90 | //! Application Interactive Services provide the means to |
91 | //! create links between an application GUI viewer and |
92 | //! the packages which are used to manage selection |
93 | //! and presentation. The tools AIS defined in order to |
94 | //! do this include different sorts of entities: both the |
95 | //! selectable viewable objects themselves and the |
96 | //! context and attribute managers to define their |
97 | //! selection and display. |
98 | //! To orient the user as he works in a modeling |
99 | //! environment, views and selections must be |
100 | //! comprehensible. There must be several different sorts |
101 | //! of selectable and viewable object defined. These must |
102 | //! also be interactive, that is, connecting graphic |
103 | //! representation and the underlying reference |
104 | //! geometry. These entities are called Interactive |
105 | //! Objects, and are divided into four types: |
106 | //! - the Datum |
107 | //! - the Relation |
108 | //! - the Object |
109 | //! - None. |
110 | //! The Datum groups together the construction elements |
111 | //! such as lines, circles, points, trihedra, plane trihedra, |
112 | //! planes and axes. |
113 | //! The Relation is made up of constraints on one or |
114 | //! more interactive shapes and the corresponding |
115 | //! reference geometry. For example, you might want to |
116 | //! constrain two edges in a parallel relation. This |
117 | //! contraint is considered as an object in its own right, |
118 | //! and is shown as a sensitive primitive. This takes the |
119 | //! graphic form of a perpendicular arrow marked with |
120 | //! the || symbol and lying between the two edges. |
121 | //! The Object type includes topological shapes, and |
122 | //! connections between shapes. |
123 | //! None, in order not to eliminate the object, tells the |
124 | //! application to look further until it finds an object |
125 | //! definition in its generation which is accepted. |
126 | //! Inside these categories, you have the possibility |
127 | //! of an additional characterization by means of a |
128 | //! signature. The signature provides an index to the |
129 | //! further characterization. By default, the Interactive |
130 | //! Object has a None type and a signature of 0 |
131 | //! (equivalent to None.) If you want to give a particular |
132 | //! type and signature to your interactive object, you must |
133 | //! redefine the two virtual methods: Type and Signature. |
134 | //! In the C++ inheritance structure of the package, each |
135 | //! class representing a specific Interactive Object |
136 | //! inherits AIS_InteractiveObject. Among these |
137 | //! inheriting classes, AIS_Relation functions as the |
138 | //! abstract mother class for tinheriting classes defining |
139 | //! display of specific relational constraints and types of |
140 | //! dimension. Some of these include: |
141 | //! - display of constraints based on relations of |
142 | //! symmetry, tangency, parallelism and concentricity |
143 | //! - display of dimensions for angles, offsets, |
144 | //! diameters, radii and chamfers. |
145 | //! No viewer can show everything at once with any |
146 | //! coherence or clarity. Views must be managed |
147 | //! carefully both sequentially and at any given instant. |
148 | //! Another function of the view is that of a context to |
149 | //! carry out design in. The design changes are applied |
150 | //! to the objects in the view and then extended to the |
151 | //! underlying reference geometry by a solver. To make |
152 | //! sense of this complicated visual data, several display |
153 | //! and selection tools are required. To facilitate |
154 | //! management, each object and each construction |
155 | //! element has a selection priority. There are also |
156 | //! means to modify the default priority. |
157 | //! To define an environment of dynamic detection, you |
158 | //! can use standard filter classes or create your own. A |
159 | //! filter questions the owner of the sensitive primitive in |
160 | //! local context to determine if it has the the desired |
161 | //! qualities. If it answers positively, it is kept. If not, it is rejected. |
162 | //! The standard filters supplied in AIS include: |
163 | //! AIS_AttributeFilter |
164 | //! AIS_SignatureFilter |
165 | //! AIS_TypeFilter. |
166 | //! Only the type filter can be used in the default |
167 | //! operating mode, the neutral point. The others can |
168 | //! only be used in open local contexts. |
169 | //! Neutral point and local context constitute the two |
170 | //! operating modes of the central entity which pilots |
171 | //! visualizations and selections, the Interactive Context. |
172 | //! It is linked to a main viewer and if you like, a trash bin |
173 | //! viewer as well. |
174 | //! The neutral point, which is the default mode, allows |
175 | //! you to easily visualize and select interactive objects |
176 | //! which have been loaded into the context. Opening |
177 | //! local contexts allows you to prepare and use a |
178 | //! temporary selection environment without disturbing |
179 | //! the neutral point. A set of functions allows you to |
180 | //! choose the interactive objects which you want to act |
181 | //! on, the selection modes which you want to activate, |
182 | //! and the temporary visualizations which you will |
183 | //! execute. When the operation is finished, you close the |
184 | //! current local context and return to the state in which |
185 | //! you were before opening it (neutral point or previous |
186 | //! local context). |
187 | //! An interactive object can have a certain number of |
188 | //! graphic attributes which are specific to it, such as |
189 | //! visualization mode, color, and material. By the same |
190 | //! token, the interactive context has a set of graphic |
191 | //! attributes, the Drawer which is valid by default for the |
192 | //! objects it controls. When an interactive object is |
193 | //! visualized, the required graphic attributes are first |
194 | //! taken from the object's own Drawer if one exists, or |
195 | //! from the context drawer for the others. |
196 | class AIS |
197 | { |
198 | public: |
199 | |
200 | DEFINE_STANDARD_ALLOC |
201 | |
202 | |
203 | |
204 | //! Returns the nearest point in a shape. This is used by |
205 | //! several classes in calculation of dimensions. |
206 | Standard_EXPORT static gp_Pnt Nearest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint); |
207 | |
208 | |
209 | //! @return the nearest point on the line. |
210 | Standard_EXPORT static gp_Pnt Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint); |
211 | |
212 | |
213 | //! For the given point finds nearest point on the curve, |
214 | //! @return TRUE if found point is belongs to the curve |
215 | //! and FALSE otherwise. |
216 | Standard_EXPORT static Standard_Boolean Nearest (const Handle(Geom_Curve)& theCurve, const gp_Pnt& thePoint, const gp_Pnt& theFirstPoint, const gp_Pnt& theLastPoint, gp_Pnt& theNearestPoint); |
217 | |
218 | Standard_EXPORT static gp_Pnt Farest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint); |
219 | |
220 | //! Used by 2d Relation only |
221 | //! Computes the 3d geometry of <anEdge> in the current WorkingPlane |
222 | //! and the extremities if any |
223 | //! Return TRUE if ok. |
224 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt); |
225 | |
226 | //! Used by dimensions only. |
227 | //! Computes the 3d geometry of <anEdge>. |
228 | //! Return TRUE if ok. |
229 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Standard_Boolean& theIsInfinite); |
230 | |
231 | //! Used by 2d Relation only |
232 | //! Computes the 3d geometry of <anEdge> in the current WorkingPlane |
233 | //! and the extremities if any. |
234 | //! If <aCurve> is not in the current plane, <extCurve> contains |
235 | //! the not projected curve associated to <anEdge>. |
236 | //! If <anEdge> is infinite, <isinfinite> = true and the 2 |
237 | //! parameters <FirstPnt> and <LastPnt> have no signification. |
238 | //! Return TRUE if ok. |
239 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsInfinite, Standard_Boolean& theIsOnPlane, const Handle(Geom_Plane)& thePlane); |
240 | |
241 | //! Used by 2d Relation only |
242 | //! Computes the 3d geometry of <anEdge> in the current WorkingPlane |
243 | //! and the extremities if any |
244 | //! Return TRUE if ok. |
245 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, const Handle(Geom_Plane)& thePlane); |
246 | |
247 | //! Used by dimensions only.Computes the 3d geometry |
248 | //! of<anEdge1> and <anEdge2> and checks if they are infinite. |
249 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2); |
250 | |
251 | //! Used by 2d Relation only Computes the 3d geometry |
252 | //! of<anEdge1> and <anEdge2> in the current Plane and the |
253 | //! extremities if any. Return in ExtCurve the 3d curve |
254 | //! (not projected in the plane) of the first edge if |
255 | //! <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If |
256 | //! <indexExt> = 0, ExtCurve is Null. if there is an edge |
257 | //! external to the plane, <isinfinite> is true if this |
258 | //! edge is infinite. So, the extremities of it are not |
259 | //! significant. Return TRUE if ok |
260 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, Standard_Integer& theExtIndex, Handle(Geom_Curve)& theFirstCurve, Handle(Geom_Curve)& theSecondCurve, gp_Pnt& theFirstPnt1, gp_Pnt& theLastPnt1, gp_Pnt& theFirstPnt2, gp_Pnt& theLastPnt2, Handle(Geom_Curve)& theExtCurve, Standard_Boolean& theIsinfinite1, Standard_Boolean& theIsinfinite2, const Handle(Geom_Plane)& thePlane); |
261 | |
262 | //! Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane |
263 | //! and returns aCurve; |
264 | //! Return TRUE if ok |
265 | Standard_EXPORT static Standard_Boolean ComputeGeomCurve (Handle(Geom_Curve)& aCurve, const Standard_Real first1, const Standard_Real last1, gp_Pnt& FirstPnt1, gp_Pnt& LastPnt1, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane); |
266 | |
267 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Vertex& aVertex, gp_Pnt& point, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane); |
268 | |
269 | //! Tryes to get Plane from Face. Returns Surface of Face |
270 | //! in aSurf. Returns Standard_True and Plane of Face in |
271 | //! aPlane in following cases: |
272 | //! Face is Plane, Offset of Plane, |
273 | //! Extrusion of Line and Offset of Extrusion of Line |
274 | //! Returns pure type of Surface which can be: |
275 | //! Plane, Cylinder, Cone, Sphere, Torus, |
276 | //! SurfaceOfRevolution, SurfaceOfExtrusion |
277 | Standard_EXPORT static Standard_Boolean GetPlaneFromFace (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurf, AIS_KindOfSurface& aSurfType, Standard_Real& Offset); |
278 | |
279 | Standard_EXPORT static void InitFaceLength (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurface, AIS_KindOfSurface& aSurfaceType, Standard_Real& anOffset); |
280 | |
281 | //! Finds attachment points on two curvilinear faces for length dimension. |
282 | //! @param thePlaneDir [in] the direction on the dimension plane to |
283 | //! compute the plane automatically. It will not be taken into account if |
284 | //! plane is defined by user. |
285 | Standard_EXPORT static void InitLengthBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, Handle(Geom_Surface)& theFirstSurf, Handle(Geom_Surface)& theSecondSurf, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, gp_Dir& theDirOnPlane); |
286 | |
287 | //! Finds three points for the angle dimension between |
288 | //! two planes. |
289 | Standard_EXPORT static Standard_Boolean InitAngleBetweenPlanarFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False); |
290 | |
291 | //! Finds three points for the angle dimension between |
292 | //! two curvilinear surfaces. |
293 | Standard_EXPORT static Standard_Boolean InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, const AIS_KindOfSurface theFirstSurfType, const AIS_KindOfSurface theSecondSurfType, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False); |
294 | |
295 | Standard_EXPORT static gp_Pnt ProjectPointOnPlane (const gp_Pnt& aPoint, const gp_Pln& aPlane); |
296 | |
297 | Standard_EXPORT static gp_Pnt ProjectPointOnLine (const gp_Pnt& aPoint, const gp_Lin& aLine); |
298 | |
299 | Standard_EXPORT static gp_Pnt TranslatePointToBound (const gp_Pnt& aPoint, const gp_Dir& aDir, const Bnd_Box& aBndBox); |
300 | |
301 | //! returns True if point with anAttachPar is |
302 | //! in domain of arc |
303 | Standard_EXPORT static Standard_Boolean InDomain (const Standard_Real aFirstPar, const Standard_Real aLastPar, const Standard_Real anAttachPar); |
304 | |
305 | //! computes nearest to ellipse arc apex |
306 | Standard_EXPORT static gp_Pnt NearestApex (const gp_Elips& elips, const gp_Pnt& pApex, const gp_Pnt& nApex, const Standard_Real fpara, const Standard_Real lpara, Standard_Boolean& IsInDomain); |
307 | |
308 | //! computes length of ellipse arc in parametric units |
309 | Standard_EXPORT static Standard_Real DistanceFromApex (const gp_Elips& elips, const gp_Pnt& Apex, const Standard_Real par); |
310 | |
311 | Standard_EXPORT static void ComputeProjEdgePresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Edge& anEdge, const Handle(Geom_Curve)& ProjCurve, const gp_Pnt& FirstP, const gp_Pnt& LastP, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfLine aProjTOL = Aspect_TOL_DASH, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT); |
312 | |
313 | Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT); |
314 | |
315 | |
316 | |
317 | |
318 | protected: |
319 | |
320 | |
321 | |
322 | |
323 | |
324 | private: |
325 | |
326 | |
327 | |
328 | |
329 | friend class AIS_Triangulation; |
330 | friend class AIS_InteractiveContext; |
331 | friend class AIS_GraphicTool; |
332 | friend class AIS_LocalContext; |
333 | friend class AIS_LocalStatus; |
334 | friend class AIS_GlobalStatus; |
335 | friend class AIS_InteractiveObject; |
336 | friend class AIS_Point; |
337 | friend class AIS_Axis; |
338 | friend class AIS_Trihedron; |
339 | friend class AIS_PlaneTrihedron; |
340 | friend class AIS_Line; |
341 | friend class AIS_Circle; |
342 | friend class AIS_Plane; |
343 | friend class AIS_Shape; |
344 | friend class AIS_ConnectedInteractive; |
345 | friend class AIS_MultipleConnectedInteractive; |
346 | friend class AIS_DimensionOwner; |
347 | friend class AIS_Relation; |
348 | friend class AIS_EllipseRadiusDimension; |
349 | friend class AIS_MaxRadiusDimension; |
350 | friend class AIS_MinRadiusDimension; |
351 | friend class AIS_Chamf2dDimension; |
352 | friend class AIS_Chamf3dDimension; |
353 | friend class AIS_OffsetDimension; |
354 | friend class AIS_FixRelation; |
355 | friend class AIS_PerpendicularRelation; |
356 | friend class AIS_ParallelRelation; |
357 | friend class AIS_TangentRelation; |
358 | friend class AIS_ConcentricRelation; |
359 | friend class AIS_IdenticRelation; |
360 | friend class AIS_SymmetricRelation; |
361 | friend class AIS_MidPointRelation; |
362 | friend class AIS_EqualRadiusRelation; |
363 | friend class AIS_EqualDistanceRelation; |
364 | friend class AIS_TypeFilter; |
365 | friend class AIS_SignatureFilter; |
366 | friend class AIS_ExclusionFilter; |
367 | friend class AIS_AttributeFilter; |
368 | friend class AIS_C0RegularityFilter; |
369 | friend class AIS_BadEdgeFilter; |
370 | friend class AIS_Selection; |
371 | |
372 | }; |
373 | |
374 | |
375 | |
376 | |
377 | |
378 | |
379 | |
380 | #endif // _AIS_HeaderFile |