b311480e |
1 | // Created on: 1997-04-17 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1997-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 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
733a0e55 |
16 | |
7fd59977 |
17 | #ifndef No_Exception |
18 | #define No_Exception |
19 | #endif |
7fd59977 |
20 | |
42cf5bc1 |
21 | |
22 | #include <HLRAlgo_Interference.hxx> |
7fd59977 |
23 | #include <HLRAlgo_ListIteratorOfInterferenceList.hxx> |
42cf5bc1 |
24 | #include <HLRBRep_EdgeIList.hxx> |
25 | #include <HLRBRep_EdgeInterferenceTool.hxx> |
26 | #include <TopCnx_EdgeFaceTransition.hxx> |
7fd59977 |
27 | |
28 | //======================================================================= |
29 | //function : AddInterference |
30 | //purpose : insert an interference in a sorted list |
31 | //======================================================================= |
7fd59977 |
32 | void HLRBRep_EdgeIList:: |
33 | AddInterference(HLRAlgo_InterferenceList& IL, |
34 | const HLRAlgo_Interference& I, |
35 | const HLRBRep_EdgeInterferenceTool& T) |
36 | { |
37 | HLRAlgo_ListIteratorOfInterferenceList It(IL); |
38 | Standard_Real p = T.ParameterOfInterference(I); |
39 | while (It.More()) { |
40 | if (p < T.ParameterOfInterference(It.Value())) { |
41 | IL.InsertBefore(I,It); |
42 | return; |
43 | } |
44 | It.Next(); |
45 | } |
46 | IL.Append(I); |
47 | } |
48 | |
49 | //======================================================================= |
50 | //function : ProcessComplex |
51 | //purpose : |
52 | //======================================================================= |
0797d9d3 |
53 | #ifdef OCCT_DEBUG_SI |
7fd59977 |
54 | static Standard_Boolean SimilarInterference(const HLRAlgo_Interference& I1, |
55 | const HLRAlgo_Interference& I2) |
56 | { |
57 | Standard_Real p1, p2; |
58 | Standard_Real eps = 1.e-7; |
59 | TopAbs_Orientation or1, or2; |
60 | //Standard_Integer l1, l2; //levels |
61 | |
62 | p1 = I1.Intersection().Parameter(); |
63 | //l1 = I1.Intersection().Level(); |
64 | or1 = I1.Transition(); |
65 | |
66 | p2 = I2.Intersection().Parameter(); |
67 | //l2 = I2.Intersection().Level(); |
68 | or2 = I2.Transition(); |
69 | |
70 | Standard_Boolean IsSimilar = Abs(p1-p2) <= eps && or1 == or2; |
71 | return IsSimilar; |
72 | |
73 | } |
4e18e72a |
74 | #endif |
7fd59977 |
75 | void HLRBRep_EdgeIList:: |
76 | ProcessComplex(HLRAlgo_InterferenceList& IL, |
77 | const HLRBRep_EdgeInterferenceTool& T) |
78 | { |
79 | TopCnx_EdgeFaceTransition transTool; |
80 | gp_Dir TgtE, NormE, TgtI, NormI; |
81 | const Standard_Real TolAng = 0.0001; |
82 | Standard_Real CurvE, CurvI; |
83 | HLRAlgo_ListIteratorOfInterferenceList It1(IL); |
84 | |
85 | while (It1.More()) { |
86 | HLRAlgo_ListIteratorOfInterferenceList It2(It1); |
87 | It2.Next(); |
88 | if (It2.More()) { |
4e18e72a |
89 | if (T.SameInterferences(It1.Value(),It2.Value()) |
0797d9d3 |
90 | #ifdef OCCT_DEBUG_SI |
4e18e72a |
91 | || SimilarInterference(It1.Value(),It2.Value()) |
92 | #endif |
93 | ) |
94 | { |
7fd59977 |
95 | T.EdgeGeometry(T.ParameterOfInterference(It1.Value()), |
96 | TgtE, NormE, CurvE); |
97 | transTool.Reset(TgtE,NormE,CurvE); |
98 | T.InterferenceBoundaryGeometry(It1.Value(),TgtI,NormI,CurvI); |
99 | transTool.AddInterference(TolAng, |
100 | TgtI,NormI,CurvI, |
101 | It1.Value().Orientation(), |
102 | It1.Value().Transition(), |
103 | It1.Value().BoundaryTransition()); |
104 | |
105 | while (It2.More()) { |
4e18e72a |
106 | if (!(T.SameInterferences(It1.Value(),It2.Value()) |
0797d9d3 |
107 | #ifdef OCCT_DEBUG_SI |
4e18e72a |
108 | || SimilarInterference(It1.Value(),It2.Value()) |
109 | #endif |
110 | )) break; |
7fd59977 |
111 | |
112 | T.InterferenceBoundaryGeometry(It2.Value(),TgtI,NormI,CurvI); |
113 | transTool.AddInterference(TolAng, |
114 | TgtI,NormI,CurvI, |
115 | It2.Value().Orientation(), |
116 | It2.Value().Transition(), |
117 | It2.Value().BoundaryTransition()); |
118 | IL.Remove(It2); |
119 | } |
120 | // get the cumulated results |
121 | It1.Value().Transition(transTool.Transition()); |
122 | It1.Value().BoundaryTransition(transTool.BoundaryTransition()); |
123 | } |
124 | } |
125 | It1.Next(); |
126 | } |
127 | |
128 | /* |
129 | //Removing "coinciding" interference |
130 | |
131 | Standard_Real p1, p2; |
132 | Standard_Real eps = 1.e-7; |
133 | HLRAlgo_InterferenceList ILNew; |
134 | HLRAlgo_Interference I1, I2; |
135 | TopAbs_Orientation or1, or2; |
136 | Standard_Integer l1, l2; //levels |
137 | It1.Initialize(IL); |
138 | |
139 | if(It1.More()) { |
140 | I1 = It1.Value(); |
141 | p1 = I1.Intersection().Parameter(); |
142 | l1 = I1.Intersection().Level(); |
143 | or1 = I1.Transition(); |
144 | |
145 | ILNew.Append(I1); |
146 | HLRAlgo_ListIteratorOfInterferenceList It2(ILNew); |
147 | |
148 | It1.Next(); |
149 | |
150 | while(It1.More()) { |
151 | I2 = It1.Value(); |
152 | p2 = I2.Intersection().Parameter(); |
153 | l2 = I2.Intersection().Level(); |
154 | or2 = I2.Transition(); |
155 | |
156 | if(p2 - p1 <= eps && or1 == or2) { |
157 | ILNew.Remove(It2); |
158 | if(l2 < l1) { |
159 | ILNew.Append(I2); |
160 | } |
161 | else { |
162 | ILNew.Append(I1); |
163 | } |
164 | } |
165 | else { |
166 | ILNew.Append(I2); |
167 | } |
168 | It1.Next(); |
169 | if(It2.More()) It2.Next(); |
170 | p1 = p2; |
171 | l1 = l2; |
172 | or1 = or2; |
173 | I1 = I2; |
174 | } |
175 | |
176 | IL = ILNew; |
177 | |
178 | } |
179 | */ |
180 | |
181 | } |