0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / IntTools / IntTools_EdgeFace.hxx
CommitLineData
42cf5bc1 1// Created on: 2001-02-26
2// Created by: Peter KURNEV
3// Copyright (c) 2001-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _IntTools_EdgeFace_HeaderFile
17#define _IntTools_EdgeFace_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_DefineAlloc.hxx>
21#include <Standard_Handle.hxx>
22
23#include <TopoDS_Edge.hxx>
24#include <TopoDS_Face.hxx>
25#include <Standard_Real.hxx>
26#include <Standard_Integer.hxx>
27#include <BRepAdaptor_Curve.hxx>
28#include <BRepAdaptor_Surface.hxx>
29#include <Standard_Boolean.hxx>
30#include <IntTools_SequenceOfRanges.hxx>
42cf5bc1 31#include <IntTools_SequenceOfCommonPrts.hxx>
32#include <IntTools_Range.hxx>
33class IntTools_Context;
34class TopoDS_Edge;
35class TopoDS_Face;
36class IntTools_Range;
37class gp_Pnt;
38class BRepAdaptor_Surface;
42cf5bc1 39class IntTools_CommonPrt;
40
03cca6f7 41//! The class provides Edge/Face intersection algorithm to determine
42//! common parts between edge and face in 3-d space.
43//! Common parts between Edge and Face can be:
44//! - Vertices - in case of intersection or touching;
45//! - Edge - in case of full coincidence of the edge with the face.
42cf5bc1 46class IntTools_EdgeFace
47{
48public:
49
50 DEFINE_STANDARD_ALLOC
51
03cca6f7 52public: //! @name Constructors
42cf5bc1 53
54 //! Empty Constructor
55 Standard_EXPORT IntTools_EdgeFace();
42cf5bc1 56
03cca6f7 57public: //! @name Setters/Getters
42cf5bc1 58
03cca6f7 59 //! Sets the edge for intersection
60 void SetEdge(const TopoDS_Edge& theEdge)
61 {
62 myEdge = theEdge;
63 }
42cf5bc1 64
03cca6f7 65 //! Returns the edge
66 const TopoDS_Edge& Edge() const
67 {
68 return myEdge;
69 }
42cf5bc1 70
03cca6f7 71 //! Sets the face for intersection
72 void SetFace(const TopoDS_Face& theFace)
73 {
74 myFace = theFace;
75 }
42cf5bc1 76
03cca6f7 77 //! Returns the face
78 const TopoDS_Face& Face() const
79 {
80 return myFace;
81 }
42cf5bc1 82
03cca6f7 83 //! Sets the boundaries for the edge.
42cf5bc1 84 //! The algorithm processes edge inside these boundaries.
03cca6f7 85 void SetRange(const IntTools_Range& theRange)
86 {
87 myRange = theRange;
88 }
42cf5bc1 89
03cca6f7 90 //! Sets the boundaries for the edge.
42cf5bc1 91 //! The algorithm processes edge inside these boundaries.
03cca6f7 92 void SetRange(const Standard_Real theFirst, const Standard_Real theLast)
93 {
94 myRange.SetFirst(theFirst);
95 myRange.SetLast(theLast);
96 }
42cf5bc1 97
03cca6f7 98 //! Returns intersection range of the edge
99 const IntTools_Range& Range() const
100 {
101 return myRange;
102 }
103
104 //! Sets the intersection context
105 void SetContext(const Handle(IntTools_Context)& theContext)
106 {
107 myContext = theContext;
108 }
109
110 //! Returns the intersection context
111 const Handle(IntTools_Context)& Context() const
112 {
113 return myContext;
114 }
42cf5bc1 115
0d0481c7 116 //! Sets the Fuzzy value
03cca6f7 117 void SetFuzzyValue(const Standard_Real theFuzz)
118 {
119 myFuzzyValue = Max(theFuzz, Precision::Confusion());
120 }
0d0481c7 121
03cca6f7 122 //! Returns the Fuzzy value
0d0481c7 123 Standard_Real FuzzyValue() const
124 {
125 return myFuzzyValue;
126 }
42cf5bc1 127
03cca6f7 128 //! Sets the flag for quick coincidence check.
129 //! It is safe to use the quick check for coincidence only if both
130 //! of the following conditions are met:
131 //! - The vertices of edge are lying on the face;
132 //! - The edge does not intersect the boundaries of the face on the given range.
133 void UseQuickCoincidenceCheck(const Standard_Boolean theFlag)
134 {
135 myQuickCoincidenceCheck = theFlag;
136 }
137
138 //! Returns the flag myQuickCoincidenceCheck
139 Standard_Boolean IsCoincidenceCheckedQuickly()
140 {
141 return myQuickCoincidenceCheck;
142 }
143
144
145
146public: //! @name Performing the operation
147
42cf5bc1 148 //! Launches the process
149 Standard_EXPORT void Perform();
42cf5bc1 150
42cf5bc1 151
03cca6f7 152public: //! @name Checking validity of the intersection
42cf5bc1 153
03cca6f7 154 //! Returns TRUE if computation was successful.
155 //! Otherwise returns FALSE.
156 Standard_Boolean IsDone() const
157 {
158 return myIsDone;
159 }
42cf5bc1 160
03cca6f7 161 //! Returns the code of completion:
162 //! 0 - means successful completion;
163 //! 1 - the process was not started;
164 //! 2,3 - invalid source data for the algorithm;
165 //! 4 - projection failed.
166 Standard_Integer ErrorStatus() const
167 {
168 return myErrorStatus;
6dc83e21 169 }
42cf5bc1 170
03cca6f7 171
172public: //! @name Obtaining results
173
174 //! Returns resulting common parts
175 const IntTools_SequenceOfCommonPrts& CommonParts() const
176 {
177 return mySeqOfCommonPrts;
6dc83e21 178 }
42cf5bc1 179
180
03cca6f7 181protected: //! @name Protected methods performing the intersection
182
6dc83e21 183 Standard_EXPORT static Standard_Boolean IsEqDistance (const gp_Pnt& aP, const BRepAdaptor_Surface& aS, const Standard_Real aT, Standard_Real& aD);
42cf5bc1 184 Standard_EXPORT void CheckData();
185
42cf5bc1 186 Standard_EXPORT Standard_Boolean IsProjectable (const Standard_Real t) const;
187
42cf5bc1 188 Standard_EXPORT Standard_Real DistanceFunction (const Standard_Real t);
189
42cf5bc1 190 Standard_EXPORT Standard_Integer MakeType (IntTools_CommonPrt& aCP);
6dc83e21 191
42cf5bc1 192 Standard_EXPORT Standard_Boolean CheckTouch (const IntTools_CommonPrt& aCP, Standard_Real& aTX);
193
194 Standard_EXPORT Standard_Boolean CheckTouchVertex (const IntTools_CommonPrt& aCP, Standard_Real& aTX);
195
6dc83e21 196 //! Checks if the edge is in the face really.
197 Standard_EXPORT Standard_Boolean IsCoincident();
42cf5bc1 198
42cf5bc1 199private:
200
42cf5bc1 201 TopoDS_Edge myEdge;
202 TopoDS_Face myFace;
0d0481c7 203 Standard_Real myFuzzyValue;
42cf5bc1 204 BRepAdaptor_Curve myC;
42cf5bc1 205 BRepAdaptor_Surface myS;
206 Standard_Real myCriteria;
207 Standard_Boolean myIsDone;
208 Standard_Integer myErrorStatus;
209 Handle(IntTools_Context) myContext;
42cf5bc1 210 IntTools_SequenceOfCommonPrts mySeqOfCommonPrts;
42cf5bc1 211 IntTools_Range myRange;
6dc83e21 212 Standard_Boolean myQuickCoincidenceCheck;
42cf5bc1 213};
214
42cf5bc1 215#endif // _IntTools_EdgeFace_HeaderFile