0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / TopCnx / TopCnx_EdgeFaceTransition.cxx
1 // Created on: 1992-08-12
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-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
18 #include <gp_Dir.hxx>
19 #include <TopCnx_EdgeFaceTransition.hxx>
20
21 //=======================================================================
22 //function : TopCnx_EdgeFaceTransition
23 //purpose  : 
24 //=======================================================================
25 TopCnx_EdgeFaceTransition::TopCnx_EdgeFaceTransition() :
26        nbBoundForward(0),
27        nbBoundReversed(0)
28 {
29 }
30
31 //=======================================================================
32 //function : Reset
33 //purpose  : 
34 //=======================================================================
35
36 void  TopCnx_EdgeFaceTransition::Reset(const gp_Dir& Tgt,
37                                        const gp_Dir& Norm,
38                                        const Standard_Real Curv)
39 {
40   myCurveTransition.Reset(Tgt,Norm,Curv);
41   nbBoundForward = nbBoundReversed = 0;
42 }
43
44 //=======================================================================
45 //function : Reset
46 //purpose  : 
47 //=======================================================================
48
49 void  TopCnx_EdgeFaceTransition::Reset(const gp_Dir& Tgt)
50 {
51   myCurveTransition.Reset(Tgt);
52   nbBoundForward = nbBoundReversed = 0;
53 }
54
55 //=======================================================================
56 //function : AddInterference
57 //purpose  : 
58 //=======================================================================
59
60 void  TopCnx_EdgeFaceTransition::AddInterference(const Standard_Real Tole,
61                                                  const gp_Dir& Tang,
62                                                  const gp_Dir& Norm,
63                                                  const Standard_Real Curv, 
64                                                  const TopAbs_Orientation Or,
65                                                  const TopAbs_Orientation Tr,
66                                                  const TopAbs_Orientation BTr)
67 {
68   myCurveTransition.Compare(Tole,Tang,Norm,Curv,Tr,Or);
69   switch (BTr) {
70     
71   case TopAbs_FORWARD :
72     nbBoundForward++;
73     break;
74
75   case TopAbs_REVERSED :
76     nbBoundReversed++;
77     break;
78
79   case TopAbs_INTERNAL :
80   case TopAbs_EXTERNAL :
81     break;
82   }
83 }
84
85 //=======================================================================
86 //function : Transition
87 //purpose  : 
88 //=======================================================================
89
90 TopAbs_Orientation  TopCnx_EdgeFaceTransition::Transition()const 
91 {
92   TopAbs_State Bef = myCurveTransition.StateBefore();
93   TopAbs_State Aft = myCurveTransition.StateAfter();
94   if (Bef == TopAbs_IN) {
95     if      (Aft == TopAbs_IN ) 
96       return TopAbs_INTERNAL;
97     else if (Aft == TopAbs_OUT) 
98       return TopAbs_REVERSED;
99 #ifdef OCCT_DEBUG
100     else
101       std::cout << "\n*** Complex Transition : unprocessed state"<<std::endl;
102 #endif
103   }
104   else if (Bef == TopAbs_OUT) {
105     if      (Aft == TopAbs_IN ) 
106       return TopAbs_FORWARD;
107     else if (Aft == TopAbs_OUT) 
108       return TopAbs_EXTERNAL;
109 #ifdef OCCT_DEBUG
110     else 
111       std::cout << "\n*** Complex Transition : unprocessed state"<<std::endl;
112 #endif
113   }
114 #ifdef OCCT_DEBUG
115   else 
116     std::cout << "\n*** Complex Transition : unprocessed state"<<std::endl;
117 #endif
118   return TopAbs_INTERNAL;
119 }
120
121 //=======================================================================
122 //function : BoundaryTransition
123 //purpose  : 
124 //=======================================================================
125
126 TopAbs_Orientation  TopCnx_EdgeFaceTransition::BoundaryTransition()const 
127 {
128   if (nbBoundForward > nbBoundReversed) 
129     return TopAbs_FORWARD;
130   else if (nbBoundForward < nbBoundReversed) 
131     return TopAbs_REVERSED;
132   else if ((nbBoundReversed % 2) == 0)
133     return TopAbs_EXTERNAL;
134   else
135     return TopAbs_EXTERNAL;
136 }
137
138