Test for 0022778: Bug in BRepMesh
[occt.git] / src / Intf / Intf_SectionPoint.cxx
1 // Created on: 1991-06-24
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #include <Intf_SectionPoint.ixx>
23
24
25 #define DEBUG_INTFSECTIONPOINT 0
26
27
28 //=======================================================================
29 //function : Pnt
30 //purpose  : 
31 //=======================================================================
32
33 const gp_Pnt& Intf_SectionPoint::Pnt () const {return myPnt;}
34
35
36 //=======================================================================
37 //function : GetElemO
38 //purpose  : 
39 //=======================================================================
40
41 void Intf_SectionPoint::InfoFirst (Intf_PIType& Dim,
42                                    Standard_Integer&     Add1,
43                                    Standard_Integer&     Add2,
44                                    Standard_Real&        Param) const
45 {
46   Dim =DimenObje;
47   Add1=IndexO1;
48   Add2=IndexO2;
49   Param=ParamObje;
50 }
51
52 //=======================================================================
53 //function : GetElemO
54 //purpose  : 
55 //=======================================================================
56
57 void Intf_SectionPoint::InfoFirst (Intf_PIType& Dim,
58                                    Standard_Integer&     Add,
59                                    Standard_Real&        Param) const
60 {
61   Dim =DimenObje;
62   Add=IndexO2;
63   Param=ParamObje;
64 }
65
66
67 //=======================================================================
68 //function : GetElemT
69 //purpose  : 
70 //=======================================================================
71
72 void Intf_SectionPoint::InfoSecond (Intf_PIType& Dim,
73                                     Standard_Integer&     Add1,
74                                     Standard_Integer&     Add2,
75                                     Standard_Real&        Param) const 
76 {
77   Dim =DimenTool;
78   Add1=IndexT1;
79   Add2=IndexT2;
80   Param=ParamTool;
81 }
82
83 //=======================================================================
84 //function : GetElemT
85 //purpose  : 
86 //=======================================================================
87
88 void Intf_SectionPoint::InfoSecond (Intf_PIType& Dim,
89                                     Standard_Integer&     Add,
90                                     Standard_Real&        Param) const 
91 {
92   Dim =DimenTool;
93   Add=IndexT2;
94   Param=ParamTool;
95 }
96
97 //=======================================================================
98 //function : GetIncidence
99 //purpose  : 
100 //=======================================================================
101
102 Standard_Real Intf_SectionPoint::Incidence () const 
103 {return Incide;}
104
105
106 //=======================================================================
107 //function : IsOnSameEdge
108 //purpose  : 
109 //=======================================================================
110
111 Standard_Boolean Intf_SectionPoint::IsOnSameEdge
112   (const Intf_SectionPoint& Other) const
113 {
114   Standard_Boolean isOn=Standard_False;
115   if (DimenObje==Intf_EDGE) {
116     if (Other.DimenObje==Intf_EDGE) {
117       isOn=(IndexO1==Other.IndexO1 && IndexO2==Other.IndexO2);
118     }
119     else if (Other.DimenObje==Intf_VERTEX) {
120       isOn=(IndexO1==Other.IndexO1 || IndexO2==Other.IndexO1);
121     }
122   }
123   else if (DimenObje == Intf_VERTEX) {
124     if (Other.DimenObje==Intf_EDGE) {
125       isOn=(IndexO1==Other.IndexO1 || IndexO1==Other.IndexO2);
126     }
127     else if (Other.DimenObje==Intf_VERTEX) {
128 #if DEBUG_INTFSECTIONPOINT
129       cout << " IsOnSameEdge on Intersection VERTEX VERTEX Obje !" << endl;
130 #endif
131         isOn=(IndexT1==Other.IndexT1);
132     }
133   }
134   if (!isOn) {
135     if (DimenTool==Intf_EDGE) {
136       if (Other.DimenTool==Intf_EDGE) {
137         isOn=(IndexT1==Other.IndexT1 && IndexT2==Other.IndexT2);
138       }
139       else if (Other.DimenTool==Intf_VERTEX) {
140         isOn=(IndexT1==Other.IndexT1 || IndexT2==Other.IndexT1);
141       }
142     }
143     else if (DimenTool == Intf_VERTEX) {
144       if (Other.DimenTool==Intf_EDGE) {
145         isOn=(IndexT1==Other.IndexT1 || IndexT1==Other.IndexT2);
146       }
147       else if (Other.DimenTool==Intf_VERTEX) {
148 #if DEBUG_INTFSECTIONPOINT
149         cout << " IsOnSameEdge on Intersection VERTEX VERTEX Tool !" << endl;
150 #endif
151         isOn=(IndexT1==Other.IndexT1);
152       }
153     }
154   }
155   return isOn;
156 }
157
158 //=======================================================================
159 //function : Intf_SectionPoint
160 //purpose  : 
161 //=======================================================================
162
163 Intf_SectionPoint::Intf_SectionPoint  ()
164      : myPnt(0.,0.,0.),
165        DimenObje(Intf_EXTERNAL), IndexO1(0), IndexO2(0), ParamObje(0.),
166        DimenTool(Intf_EXTERNAL), IndexT1(0), IndexT2(0), ParamTool(0.),
167        Incide(0.)
168 {
169 }
170
171 //=======================================================================
172 //function : Intf_SectionPoint
173 //purpose  : 
174 //=======================================================================
175
176 Intf_SectionPoint::Intf_SectionPoint  (const gp_Pnt& Where,
177                                        const Intf_PIType Dim1,
178                                        const Standard_Integer Addr1,
179                                        const Standard_Integer Addr2,
180                                        const Standard_Real Param1,
181                                        const Intf_PIType Dim2,
182                                        const Standard_Integer Addr3,
183                                        const Standard_Integer Addr4,
184                                        const Standard_Real Param2,
185                                        const Standard_Real Incid)
186      : myPnt(Where),
187        DimenObje(Dim1), IndexO1(Addr1), IndexO2(Addr2), ParamObje(Param1),
188        DimenTool(Dim2), IndexT1(Addr3), IndexT2(Addr4), ParamTool(Param2),
189        Incide(Incid)
190 {
191 }
192
193 //=======================================================================
194 //function : Intf_SectionPoint
195 //purpose  : 
196 //=======================================================================
197
198 Intf_SectionPoint::Intf_SectionPoint  (const gp_Pnt2d& Where,
199                                        const Intf_PIType Dim1,
200                                        const Standard_Integer Addr1,
201                                        const Standard_Real Param1,
202                                        const Intf_PIType Dim2,
203                                        const Standard_Integer Addr2,
204                                        const Standard_Real Param2,
205                                        const Standard_Real Incid)
206      : myPnt(Where.X(),Where.Y(),0.),
207        DimenObje(Dim1), IndexO1(0), IndexO2(Addr1), ParamObje(Param1),
208        DimenTool(Dim2), IndexT1(0), IndexT2(Addr2), ParamTool(Param2),
209        Incide(Incid)
210 {
211 }
212
213
214 //=======================================================================
215 //function : Merge
216 //purpose  : 
217 //=======================================================================
218
219 void Intf_SectionPoint::Merge  (Intf_SectionPoint& Other) {
220   Other.myPnt=myPnt;
221   if (DimenObje >= Other.DimenObje) {
222     Other.DimenObje=DimenObje;
223     Other.IndexO1=IndexO1;
224     Other.IndexO2=IndexO2;
225     Other.ParamObje=ParamObje;
226   }
227   else {
228     DimenObje=Other.DimenObje;
229     IndexO1=Other.IndexO1;
230     IndexO2=Other.IndexO2;
231     ParamObje=Other.ParamObje;
232   }
233   if (DimenTool >= Other.DimenTool) {
234     Other.DimenTool=DimenTool;
235     Other.IndexT1=IndexT1;
236     Other.IndexT2=IndexT2;
237     Other.ParamTool=ParamTool;
238   }
239   else {
240     DimenTool=Other.DimenTool;
241     IndexT1=Other.IndexT1;
242     IndexT2=Other.IndexT2;
243     ParamTool=Other.ParamTool;
244   }
245 }
246
247 //=======================================================================
248 //function : Dump
249 //purpose  : 
250 //=======================================================================
251
252 void Intf_SectionPoint::Dump (const Standard_Integer
253 #if DEBUG_INTFSECTIONPOINT 
254                                                      Indent
255 #endif
256                              ) const
257 {
258 #if DEBUG_INTFSECTIONPOINT 
259   for (Standard_Integer id=0; id<Indent; id++) cout << " ";
260
261   cout << "PIType(" << DimenObje << "," << DimenTool << ")  entre(" 
262         << IndexO1 << "," << IndexO2 << ") par(" << ParamObje 
263           << ") et ("
264         << IndexT1 << "," << IndexT2 << ") par(" << ParamTool  
265           << ")" << endl;
266
267   for (id=0; id<Indent; id++) cout << " ";
268
269   cout << "  Lieu(" << myPnt.X() << ","
270                     << myPnt.Y() << "," 
271                     << myPnt.Z() << 
272          ")  Incidence(" << Incide << ")" << endl;
273 #endif
274 }