787ff240 |
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 _PrsDim_HeaderFile |
18 | #define _PrsDim_HeaderFile |
19 | |
20 | #include <PrsDim_KindOfSurface.hxx> |
21 | #include <Aspect_TypeOfLine.hxx> |
22 | #include <Aspect_TypeOfMarker.hxx> |
23 | #include <gp_Dir.hxx> |
d5477f8c |
24 | #include <gp_Elips.hxx> |
787ff240 |
25 | #include <gp_Pnt.hxx> |
26 | #include <Quantity_NameOfColor.hxx> |
27 | #include <Prs3d_Drawer.hxx> |
28 | #include <Prs3d_Presentation.hxx> |
29 | #include <Standard.hxx> |
30 | #include <Standard_DefineAlloc.hxx> |
31 | #include <Standard_Handle.hxx> |
32 | |
33 | class Bnd_Box; |
34 | class Geom_Curve; |
35 | class Geom_Plane; |
36 | class Geom_Surface; |
37 | class TopoDS_Edge; |
38 | class TopoDS_Face; |
39 | class TopoDS_Shape; |
40 | class TopoDS_Vertex; |
41 | |
42 | //! Auxiliary methods for computing dimensions. |
43 | class PrsDim |
44 | { |
45 | public: |
46 | |
47 | DEFINE_STANDARD_ALLOC |
48 | |
49 | //! Returns the nearest point in a shape. This is used by |
50 | //! several classes in calculation of dimensions. |
51 | Standard_EXPORT static gp_Pnt Nearest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint); |
52 | |
53 | //! @return the nearest point on the line. |
54 | Standard_EXPORT static gp_Pnt Nearest (const gp_Lin& theLine, const gp_Pnt& thePoint); |
55 | |
56 | //! For the given point finds nearest point on the curve, |
57 | //! @return TRUE if found point is belongs to the curve |
58 | //! and FALSE otherwise. |
59 | 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); |
60 | |
61 | Standard_EXPORT static gp_Pnt Farest (const TopoDS_Shape& aShape, const gp_Pnt& aPoint); |
62 | |
63 | //! Used by 2d Relation only |
64 | //! Computes the 3d geometry of <anEdge> in the current WorkingPlane |
65 | //! and the extremities if any |
66 | //! Return TRUE if ok. |
67 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt); |
68 | |
69 | //! Used by dimensions only. |
70 | //! Computes the 3d geometry of <anEdge>. |
71 | //! Return TRUE if ok. |
72 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Edge& theEdge, Handle(Geom_Curve)& theCurve, gp_Pnt& theFirstPnt, gp_Pnt& theLastPnt, Standard_Boolean& theIsInfinite); |
73 | |
74 | //! Used by 2d Relation only |
75 | //! Computes the 3d geometry of <anEdge> in the current WorkingPlane |
76 | //! and the extremities if any. |
77 | //! If <aCurve> is not in the current plane, <extCurve> contains |
78 | //! the not projected curve associated to <anEdge>. |
79 | //! If <anEdge> is infinite, <isinfinite> = true and the 2 |
80 | //! parameters <FirstPnt> and <LastPnt> have no signification. |
81 | //! Return TRUE if ok. |
82 | 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); |
83 | |
84 | //! Used by 2d Relation only |
85 | //! Computes the 3d geometry of <anEdge> in the current WorkingPlane |
86 | //! and the extremities if any |
87 | //! Return TRUE if ok. |
88 | 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); |
89 | |
90 | //! Used by dimensions only.Computes the 3d geometry |
91 | //! of<anEdge1> and <anEdge2> and checks if they are infinite. |
92 | 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); |
93 | |
94 | //! Used by 2d Relation only Computes the 3d geometry |
95 | //! of<anEdge1> and <anEdge2> in the current Plane and the |
96 | //! extremities if any. Return in ExtCurve the 3d curve |
97 | //! (not projected in the plane) of the first edge if |
98 | //! <indexExt> =1 or of the 2nd edge if <indexExt> = 2. If |
99 | //! <indexExt> = 0, ExtCurve is Null. if there is an edge |
100 | //! external to the plane, <isinfinite> is true if this |
101 | //! edge is infinite. So, the extremities of it are not |
102 | //! significant. Return TRUE if ok |
103 | 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); |
104 | |
105 | //! Checks if aCurve belongs to aPlane; if not, projects aCurve in aPlane |
106 | //! and returns aCurve; |
107 | //! Return TRUE if ok |
108 | 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); |
109 | |
110 | Standard_EXPORT static Standard_Boolean ComputeGeometry (const TopoDS_Vertex& aVertex, gp_Pnt& point, const Handle(Geom_Plane)& aPlane, Standard_Boolean& isOnPlane); |
111 | |
112 | //! Tryes to get Plane from Face. Returns Surface of Face |
113 | //! in aSurf. Returns Standard_True and Plane of Face in |
114 | //! aPlane in following cases: |
115 | //! Face is Plane, Offset of Plane, |
116 | //! Extrusion of Line and Offset of Extrusion of Line |
117 | //! Returns pure type of Surface which can be: |
118 | //! Plane, Cylinder, Cone, Sphere, Torus, |
119 | //! SurfaceOfRevolution, SurfaceOfExtrusion |
120 | Standard_EXPORT static Standard_Boolean GetPlaneFromFace (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurf, PrsDim_KindOfSurface& aSurfType, Standard_Real& Offset); |
121 | |
122 | Standard_EXPORT static void InitFaceLength (const TopoDS_Face& aFace, gp_Pln& aPlane, Handle(Geom_Surface)& aSurface, PrsDim_KindOfSurface& aSurfaceType, Standard_Real& anOffset); |
123 | |
124 | //! Finds attachment points on two curvilinear faces for length dimension. |
125 | //! @param thePlaneDir [in] the direction on the dimension plane to |
126 | //! compute the plane automatically. It will not be taken into account if |
127 | //! plane is defined by user. |
128 | 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); |
129 | |
130 | //! Finds three points for the angle dimension between |
131 | //! two planes. |
132 | 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); |
133 | |
134 | //! Finds three points for the angle dimension between |
135 | //! two curvilinear surfaces. |
136 | Standard_EXPORT static Standard_Boolean InitAngleBetweenCurvilinearFaces (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, const PrsDim_KindOfSurface theFirstSurfType, const PrsDim_KindOfSurface theSecondSurfType, gp_Pnt& theCenter, gp_Pnt& theFirstAttach, gp_Pnt& theSecondAttach, const Standard_Boolean theIsFirstPointSet = Standard_False); |
137 | |
138 | Standard_EXPORT static gp_Pnt ProjectPointOnPlane (const gp_Pnt& aPoint, const gp_Pln& aPlane); |
139 | |
140 | Standard_EXPORT static gp_Pnt ProjectPointOnLine (const gp_Pnt& aPoint, const gp_Lin& aLine); |
141 | |
142 | Standard_EXPORT static gp_Pnt TranslatePointToBound (const gp_Pnt& aPoint, const gp_Dir& aDir, const Bnd_Box& aBndBox); |
143 | |
144 | //! returns True if point with anAttachPar is |
145 | //! in domain of arc |
146 | Standard_EXPORT static Standard_Boolean InDomain (const Standard_Real aFirstPar, const Standard_Real aLastPar, const Standard_Real anAttachPar); |
147 | |
148 | //! computes nearest to ellipse arc apex |
149 | 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); |
150 | |
151 | //! computes length of ellipse arc in parametric units |
152 | Standard_EXPORT static Standard_Real DistanceFromApex (const gp_Elips& elips, const gp_Pnt& Apex, const Standard_Real par); |
153 | |
154 | 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); |
155 | |
156 | 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); |
157 | |
158 | }; |
159 | |
160 | #endif // _PrsDim_HeaderFile |