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