0022623: Use of uninitialized variables in HLRBRep_Curve::UpdateMinMax in debug mode
[occt.git] / src / HLRBRep / HLRBRep_EdgeIList.cxx
1 // File:      HLRBRep_EdgeIList.cxx
2 // Created:   Thu Apr 17 21:26:59 1997
3 // Author:    Christophe MARION
4 // Copyright: OPEN CASCADE 2000
5
6 #ifndef No_Exception
7 #define No_Exception
8 #endif
9 #include <HLRBRep_EdgeIList.ixx>
10
11 #include <TopCnx_EdgeFaceTransition.hxx>
12 #include <HLRAlgo_ListIteratorOfInterferenceList.hxx>
13
14 //=======================================================================
15 //function : AddInterference
16 //purpose  : insert an interference in a sorted list
17 //=======================================================================
18
19 void  HLRBRep_EdgeIList::
20 AddInterference(HLRAlgo_InterferenceList& IL,
21                 const HLRAlgo_Interference& I,
22                 const HLRBRep_EdgeInterferenceTool& T)
23 {
24   HLRAlgo_ListIteratorOfInterferenceList It(IL);
25   Standard_Real p = T.ParameterOfInterference(I);
26   while (It.More()) {
27     if (p < T.ParameterOfInterference(It.Value())) {
28       IL.InsertBefore(I,It);
29       return;
30     }
31     It.Next();
32   }
33   IL.Append(I);
34 }
35
36 //=======================================================================
37 //function : ProcessComplex
38 //purpose  : 
39 //=======================================================================
40 static Standard_Boolean SimilarInterference(const HLRAlgo_Interference& I1,
41                                             const HLRAlgo_Interference& I2)
42 {
43   Standard_Real p1, p2;
44   Standard_Real eps = 1.e-7;
45   TopAbs_Orientation or1, or2;
46   //Standard_Integer l1, l2; //levels
47
48   p1 = I1.Intersection().Parameter();
49   //l1 = I1.Intersection().Level();
50   or1 = I1.Transition();
51
52   p2 = I2.Intersection().Parameter();
53   //l2 = I2.Intersection().Level();
54   or2 = I2.Transition();
55
56   Standard_Boolean IsSimilar = Abs(p1-p2) <= eps && or1 == or2;
57   return IsSimilar;
58   
59 }
60 void  HLRBRep_EdgeIList::
61 ProcessComplex(HLRAlgo_InterferenceList& IL,
62                const HLRBRep_EdgeInterferenceTool& T)
63 {
64   TopCnx_EdgeFaceTransition transTool;
65   gp_Dir TgtE, NormE, TgtI, NormI;
66   const Standard_Real TolAng = 0.0001;
67   Standard_Real CurvE, CurvI;
68   HLRAlgo_ListIteratorOfInterferenceList It1(IL);
69
70   while (It1.More()) {
71     HLRAlgo_ListIteratorOfInterferenceList It2(It1);
72     It2.Next();
73     if (It2.More()) {
74       if (T.SameInterferences(It1.Value(),It2.Value())/* || 
75           SimilarInterference(It1.Value(),It2.Value())*/) {
76
77         T.EdgeGeometry(T.ParameterOfInterference(It1.Value()),
78                        TgtE, NormE, CurvE);
79         transTool.Reset(TgtE,NormE,CurvE);
80         T.InterferenceBoundaryGeometry(It1.Value(),TgtI,NormI,CurvI);
81         transTool.AddInterference(TolAng,
82                                   TgtI,NormI,CurvI,
83                                   It1.Value().Orientation(),
84                                   It1.Value().Transition(),
85                                   It1.Value().BoundaryTransition());
86
87         while (It2.More()) {
88           if (!(T.SameInterferences(It1.Value(),It2.Value())/* ||
89                 SimilarInterference(It1.Value(),It2.Value())*/)) break;
90
91           T.InterferenceBoundaryGeometry(It2.Value(),TgtI,NormI,CurvI);
92           transTool.AddInterference(TolAng,
93                                     TgtI,NormI,CurvI,
94                                     It2.Value().Orientation(),
95                                     It2.Value().Transition(),
96                                     It2.Value().BoundaryTransition());
97           IL.Remove(It2);
98         }
99         // get the cumulated results
100         It1.Value().Transition(transTool.Transition());
101         It1.Value().BoundaryTransition(transTool.BoundaryTransition());
102       }
103     }
104     It1.Next();
105   }
106
107 /*  
108   //Removing "coinciding" interference
109
110   Standard_Real p1, p2;
111   Standard_Real eps = 1.e-7;
112   HLRAlgo_InterferenceList ILNew;
113   HLRAlgo_Interference I1, I2;
114   TopAbs_Orientation or1, or2;
115   Standard_Integer l1, l2; //levels
116   It1.Initialize(IL);
117
118   if(It1.More()) {
119     I1 = It1.Value();
120     p1 = I1.Intersection().Parameter();
121     l1 = I1.Intersection().Level();
122     or1 = I1.Transition();
123
124     ILNew.Append(I1);
125     HLRAlgo_ListIteratorOfInterferenceList It2(ILNew);    
126
127     It1.Next(); 
128     
129     while(It1.More()) {
130       I2 = It1.Value();
131       p2 = I2.Intersection().Parameter();
132       l2 = I2.Intersection().Level();
133       or2 = I2.Transition();
134       
135       if(p2 - p1 <= eps && or1 == or2) {
136         ILNew.Remove(It2);
137         if(l2 < l1) {
138           ILNew.Append(I2);
139         }
140         else {
141           ILNew.Append(I1);
142         }
143       }
144       else {
145         ILNew.Append(I2);
146       }
147       It1.Next();
148       if(It2.More()) It2.Next();
149       p1 = p2;
150       l1 = l2;
151       or1 = or2;
152       I1 = I2;
153     }
154
155     IL = ILNew;
156             
157   }
158 */
159
160 }