0024510: Remove unused local variables
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_EdgeInterferenceTool.cxx
CommitLineData
b311480e 1// Created on: 1994-11-08
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <TopOpeBRepDS_EdgeInterferenceTool.ixx>
18
19#include <TopOpeBRepDS_CurvePointInterference.hxx>
20#include <TopOpeBRepDS_EdgeVertexInterference.hxx>
21#include <BRepLProp_CLProps.hxx>
22#include <BRep_Tool.hxx>
23#include <TopoDS_Iterator.hxx>
24#include <Precision.hxx>
25#include <TopoDS.hxx>
26#include <TopOpeBRepTool_ShapeTool.hxx>
27#include <Standard_ProgramError.hxx>
28
29#ifdef DEB
30Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettracePEI();
31#endif
32
33//=======================================================================
34//function : TopOpeBRepDS_EdgeInterferenceTool
35//purpose :
36//=======================================================================
37
38 TopOpeBRepDS_EdgeInterferenceTool::TopOpeBRepDS_EdgeInterferenceTool()
39{
40}
41
42static Standard_Real Parameter(const Handle(TopOpeBRepDS_Interference)& I)
43{
44 Standard_Real p = 0;
45 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) )
46 p = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->Parameter();
47 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) )
48 p = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I)->Parameter();
49 else {
50#ifdef DEB
51 cout<<"EdgeInterference : mauvais type d'interference"<<endl;
52#endif
53 Standard_ProgramError::Raise("TopOpeBRepDS_EdgeInterferenceTool1");
54 }
55 return p;
56}
57
58
59//=======================================================================
60//function : Init
61//purpose :
62//=======================================================================
63
64void TopOpeBRepDS_EdgeInterferenceTool::Init
65(const TopoDS_Shape& E, const Handle(TopOpeBRepDS_Interference)& I)
66{
67 myEdgeOrientation = E.Orientation();
68 myEdgeOriented = I->Support();
69
70 // NYI 971219 : on ne tient pas compte de l'orientation de E = arete-mere de l'interference I
71 if (myEdgeOrientation == TopAbs_INTERNAL ||
72 myEdgeOrientation == TopAbs_EXTERNAL) {
73 return;
74 }
75
76 // la premiere arete orientee est gardee dans myEdgeOriented pour MAJ de
77 // l'arete croisee dans l'interference resultat.
78
79 // par = parametre sur l'arete croisee
80 Standard_Real par = ::Parameter(I);
81 gp_Dir T,N; Standard_Real C;
82 TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
83 myTool.Reset(T,N,C);
84}
85
86//=======================================================================
87//function : Add
88//purpose :
89//=======================================================================
90
91void TopOpeBRepDS_EdgeInterferenceTool::Add
92(const TopoDS_Shape& E,
93 const TopoDS_Shape& V,
94 const Handle(TopOpeBRepDS_Interference)& I)
95{
96 TopAbs_Orientation Eori = E.Orientation();
97 if (Eori == TopAbs_INTERNAL ||
98 Eori == TopAbs_EXTERNAL) {
99 return;
100 }
101
102 // premiere interference sur arete orientee : Init
103 if (myEdgeOrientation == TopAbs_INTERNAL ||
104 myEdgeOrientation == TopAbs_EXTERNAL) {
105 Init(E,I);
106 return;
107 }
108
109 // V est un sommet de E ?
96a95605 110#ifdef DEB
7fd59977 111 Standard_Boolean VofE = Standard_False;
96a95605 112#endif
7fd59977 113 TopoDS_Iterator it(E,Standard_False);
114 for ( ; it.More(); it.Next() ) {
115 const TopoDS_Shape& S = it.Value();
116 if ( S.IsSame(V) ) {
96a95605 117#ifdef DEB
7fd59977 118 VofE = Standard_True;
96a95605 119#endif
7fd59977 120 break;
121 }
122 }
123
124#ifdef DEB
125 if (TopOpeBRepDS_GettracePEI() && !VofE) {
126 cout<<"===================== VofE = False"<<endl;
127 }
128#endif
129
130 // V est un sommet de E
131 const TopoDS_Vertex& VV = TopoDS::Vertex(V);
132 const TopoDS_Edge& EE = TopoDS::Edge(E);
133 Standard_Real par = BRep_Tool::Parameter(VV,EE);
134
135 gp_Dir T,N; Standard_Real C;
136 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
137 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
138 TopAbs_Orientation oritan = it.Value().Orientation();
139 myTool.Compare(tol,T,N,C,oriloc,oritan);
140}
141
142//=======================================================================
143//function : Add
144//purpose :
145//=======================================================================
146
147void TopOpeBRepDS_EdgeInterferenceTool::Add
148(const TopoDS_Shape& E,
149// const TopOpeBRepDS_Point& P,
150 const TopOpeBRepDS_Point& ,
151 const Handle(TopOpeBRepDS_Interference)& I)
152{
153 TopAbs_Orientation Eori = E.Orientation();
154 if (Eori == TopAbs_INTERNAL ||
155 Eori == TopAbs_EXTERNAL) {
156 return;
157 }
158
159 // premiere interference sur arete orientee : Init
160 if (myEdgeOrientation == TopAbs_INTERNAL ||
161 myEdgeOrientation == TopAbs_EXTERNAL) {
162 Init(E,I);
163 return;
164 }
165
166 Standard_Real par = ::Parameter(I);
167
168 gp_Dir T,N; Standard_Real C;
169 Standard_Real tol = TopOpeBRepTool_ShapeTool::EdgeData(E,par,T,N,C);
170 TopAbs_Orientation oriloc = I->Transition().Orientation(TopAbs_IN);
171 TopAbs_Orientation oritan = TopAbs_INTERNAL;
172 myTool.Compare(tol,T,N,C,oriloc,oritan);
173}
174
175//=======================================================================
176//function : Transition
177//purpose :
178//=======================================================================
179
180void TopOpeBRepDS_EdgeInterferenceTool::Transition
181(const Handle(TopOpeBRepDS_Interference)& I) const
182{
183 TopOpeBRepDS_Transition& T = I->ChangeTransition();
184
185 if (myEdgeOrientation == TopAbs_INTERNAL) {
186 T.Set(TopAbs_IN,TopAbs_IN);
187 }
188 else if (myEdgeOrientation == TopAbs_EXTERNAL) {
189 T.Set(TopAbs_OUT,TopAbs_OUT);
190 }
191 else {
192 I->Support(myEdgeOriented);
193 T.Set(myTool.StateBefore(),myTool.StateAfter());
194 }
195}