0024101: Self-Interference Checker provides results that are inconsistent with the...
[occt.git] / src / BOPDS / BOPDS_Interf.hxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
8 //
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 //
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
18
19
20 #ifndef BOPDS_Interf_HeaderFile
21 #define BOPDS_Interf_HeaderFile
22
23 #ifndef _Standard_HeaderFile
24 #include <Standard.hxx>
25 #endif
26 #ifndef _Standard_Macro_HeaderFile
27 #include <Standard_Macro.hxx>
28 #endif
29
30 #ifndef _Standard_Integer_HeaderFile
31 #include <Standard_Integer.hxx>
32 #endif
33
34 #ifndef _IntTools_CommonPrt_HeaderFile
35 #include <IntTools_CommonPrt.hxx>
36 #endif
37
38 #include <NCollection_BaseAllocator.hxx>
39 #include <BOPDS_VectorOfCurve.hxx>
40 #include <BOPDS_VectorOfPoint.hxx>
41 /**
42  * The class BOPDS_Interf is is to store the information about
43  * the interference between two shapes. 
44  * The class BOPDS_Interf is root class 
45  *
46 */
47 //=======================================================================
48 //function : BOPDS_Interf
49 //purpose  : 
50 //=======================================================================
51 class BOPDS_Interf  {
52  public:
53   //
54   /**
55    * Sets the indices of interferred shapes
56    * @param theIndex1
57    *   index of the first shape
58    * @param theIndex2
59    *   index of the second shape
60    */
61   void SetIndices(const Standard_Integer theIndex1,
62                   const Standard_Integer theIndex2) {
63     myIndex1=theIndex1; 
64     myIndex2=theIndex2; 
65   }; 
66   //
67   /**
68    * Returns the indices of interferred shapes
69    * @param theIndex1
70    *   index of the first shape
71    * @param theIndex2
72    *   index of the second shape
73    */
74   void Indices(Standard_Integer& theIndex1,
75                Standard_Integer& theIndex2) const {
76                  theIndex1=myIndex1; 
77                  theIndex2=myIndex2; 
78                };
79   //
80   /**
81    * Sets the index of the first interferred shape
82    * @param theIndex
83    *   index of the first shape 
84    */
85   void SetIndex1(const Standard_Integer theIndex) {
86     myIndex1=theIndex; 
87   };
88   //
89   /**
90    * Sets the index of the second interferred shape
91    * @param theIndex
92    *   index of the second shape 
93    */
94   void SetIndex2(const Standard_Integer theIndex) {
95     myIndex2=theIndex;
96   };
97   //
98   /**
99    * Returns the index of the first interferred shape
100    * @return
101    *   index of the first shape 
102    */
103   Standard_Integer Index1() const {
104     return myIndex1; 
105   };
106   //
107   /**
108    * Returns the index of the second interferred shape
109    * @return
110    *   index of the second shape 
111    */
112   Standard_Integer Index2() const {
113     return myIndex2; 
114   };
115   //
116   /**
117    * Returns the index of that are opposite to the given index
118    * @param theI
119    *   the index
120    * @return
121    *   index of opposite shape 
122    */
123   Standard_Integer OppositeIndex(const Standard_Integer theI) const {
124     if (theI==myIndex1) {
125       return myIndex2;
126     }
127     else if(theI==myIndex2) {
128       return myIndex1;
129     }
130     else {
131       return -1;
132     }
133   };
134   //
135   /**
136    * Returns true if the interference contains given index
137    * @param theIndex 
138    *   the index
139    * @return
140    *   true if the interference contains given index
141    */
142   Standard_Boolean Contains(const Standard_Integer theIndex)const {
143     return (myIndex1==theIndex || myIndex2==theIndex);
144   }
145   //
146   /**
147    * Sets the index of new shape 
148    * @param theIndex 
149    *   the index
150    */
151   void SetIndexNew(const Standard_Integer theIndex) {
152     myIndexNew=theIndex;
153   };
154   //
155   //
156   /**
157    * Returns the index of new shape 
158    * @return theIndex 
159    *   the index of new shape 
160    */
161   Standard_Integer IndexNew() const {
162     return myIndexNew; 
163   };
164   //
165   /**
166    * Returns true if the interference has index of new shape
167    * that is equal to the given index 
168    * @param theIndex 
169    *   the index
170    * @return true if the interference has index of new shape
171    * that is equal to the given index 
172    */
173   Standard_Boolean HasIndexNew(Standard_Integer& theIndex) const {
174     theIndex=myIndexNew;
175     return (myIndexNew>=0);
176   };
177   //
178   /**
179    * Returns true if the interference has index of new shape
180    *   the index
181    * @return true if the interference has index of new shape
182    */
183   Standard_Boolean HasIndexNew() const {
184     return (myIndexNew>=0);
185   };
186   //
187  protected:     
188   BOPDS_Interf() :
189     myIndex1(-1), 
190     myIndex2(-1),
191     myIndexNew(-1),
192     myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()) {
193   };
194   //
195   BOPDS_Interf(const Handle(NCollection_BaseAllocator)& theAllocator) :
196     myIndex1(-1), 
197     myIndex2(-1),
198     myIndexNew(-1),
199     myAllocator(theAllocator) {
200   };
201   //
202   virtual ~BOPDS_Interf() {
203   };
204   
205  protected:     
206   Standard_Integer myIndex1;
207   Standard_Integer myIndex2;
208   Standard_Integer myIndexNew;
209   Handle(NCollection_BaseAllocator) myAllocator;
210 };
211 /**
212  * The class BOPDS_InterfVV is is to store the information about
213  * the interference of the type vertex/vertex. 
214 */
215 //=======================================================================
216 //function : BOPDS_InterfVV
217 //purpose  : 
218 //=======================================================================
219 class BOPDS_InterfVV  : public BOPDS_Interf {
220  public:
221   //
222   /**
223    *  Constructor
224    */
225   BOPDS_InterfVV() : BOPDS_Interf() {
226   };
227   //
228   /**
229    *  Constructor
230    * @param theAllocator
231    *   allocator to manage the memory
232    */
233   BOPDS_InterfVV(const Handle(NCollection_BaseAllocator)& theAllocator) 
234     : BOPDS_Interf(theAllocator) {
235   };
236   //
237   /**
238    *  Destructor
239    */
240   virtual ~BOPDS_InterfVV() {
241   };
242   //
243 };
244 /**
245  * The class BOPDS_InterfVE is is to store the information about
246  * the interference of the type vertex/edge. 
247 */
248 //=======================================================================
249 //function : BOPDS_InterfVE
250 //purpose  : 
251 //=======================================================================
252 class BOPDS_InterfVE  : public BOPDS_Interf {
253  public:
254   //
255   /**
256    *  Constructor
257    */
258   BOPDS_InterfVE() 
259     :
260       BOPDS_Interf(),
261       myParameter(0.) {
262   };
263   //
264   /**
265    *  Constructor
266    * @param theAllocator
267    *   allocator to manage the memory
268    */
269   BOPDS_InterfVE(const Handle(NCollection_BaseAllocator)& theAllocator) 
270     :
271       BOPDS_Interf(theAllocator),
272       myParameter(0.) {
273   };
274   //
275   /**
276    *  Destructor
277    */
278   virtual ~BOPDS_InterfVE() {
279   };
280   //
281   /**
282    *  Modifier
283    * Sets the value of parameter 
284    * of the point of the vertex 
285    * on the curve of the edge
286    * @param theT
287    *   value of parameter 
288    */
289   void SetParameter(const Standard_Real theT) {
290     myParameter=theT;
291   };
292   //
293   /**
294    *  Selector
295    * Returrns the value of parameter 
296    * of the point of the vertex 
297    * on the curve of the edge
298    * @return
299    *   value of parameter 
300    */
301   Standard_Real Parameter() const {
302     return myParameter;
303   };
304   
305  protected:
306   Standard_Real myParameter;
307   
308 };
309 /**
310  * The class BOPDS_InterfVF is is to store the information about
311  * the interference of the type vertex/face 
312 */
313 //=======================================================================
314 //function : BOPDS_InterfVF
315 //purpose  : 
316 //=======================================================================
317 class BOPDS_InterfVF  : public BOPDS_Interf {
318  public:
319   //
320   /**
321    *  Constructor
322    */
323   BOPDS_InterfVF()
324     : BOPDS_Interf(),
325       myU(0.),
326       myV(0.) {
327   };
328   //
329   /**
330    *  Constructor
331    * @param theAllocator
332    *   allocator to manage the memory
333    */
334   BOPDS_InterfVF(const Handle(NCollection_BaseAllocator)& theAllocator)
335     : BOPDS_Interf(theAllocator),
336       myU(0.),
337       myV(0.) {
338   };
339   //
340   /**
341    *  Destructor
342    */  
343   virtual ~BOPDS_InterfVF() {
344   };
345   //
346   /**
347    * Modifier
348    * Sets the value of parameters 
349    * of the point of the vertex 
350    * on the surface of of the face
351    * @param theU
352    *   value of U parameter
353    * @param theV 
354    *   value of U parameter 
355    */
356   void SetUV(const Standard_Real theU,
357              const Standard_Real theV) {
358     myU=theU;
359     myV=theV;
360   };
361   //
362   /**
363    * Selector
364    * Returns the value of parameters 
365    * of the point of the vertex 
366    * on the surface of of the face
367    * @param theU
368    *   value of U parameter
369    * @param theV 
370    *   value of U parameter 
371    */
372   void UV(Standard_Real& theU,Standard_Real& theV) const {
373     theU=myU;
374     theV=myV;
375   };
376   
377  protected:
378   Standard_Real myU;
379   Standard_Real myV;
380       
381 };
382 /**
383  * The class BOPDS_InterfEE is is to store the information about
384  * the interference of the type edge/edge. 
385 */
386 //=======================================================================
387 //function : BOPDS_InterfEE
388 //purpose  : 
389 //=======================================================================
390 class BOPDS_InterfEE  : public BOPDS_Interf {
391  public:
392   //
393   /**
394    *  Constructor
395    */
396   BOPDS_InterfEE() : BOPDS_Interf() {
397   };
398   //
399   /**
400    *  Constructor
401    * @param theAllocator
402    *   allocator to manage the memory
403    */
404   BOPDS_InterfEE(const Handle(NCollection_BaseAllocator)& theAllocator)
405     : BOPDS_Interf(theAllocator) {
406   };
407   //
408   /**
409    *  Destructor
410    */
411   virtual ~BOPDS_InterfEE() {
412   };
413   //
414   /**
415    *  Modifier
416    * Sets the info of common part 
417    * @param theCP
418    *   common part
419    */
420   void SetCommonPart(const IntTools_CommonPrt& theCP) {
421     myCommonPart=theCP;
422   };
423   //
424   /**
425    *  Selector
426    * Returns the info of common part 
427    * @return
428    *   common part
429    */
430   const IntTools_CommonPrt& CommonPart() const {
431     return myCommonPart;
432   };
433   
434  protected:
435   IntTools_CommonPrt myCommonPart;
436 };
437 /**
438  * The class BOPDS_InterfEF is is to store the information about
439  * the interference of the type edge/face. 
440 */
441 //=======================================================================
442 //function : BOPDS_InterfEF
443 //purpose  : 
444 //=======================================================================
445 class BOPDS_InterfEF  : public BOPDS_Interf {
446  public:
447   //
448   /**
449    *  Constructor
450    */
451   BOPDS_InterfEF(): BOPDS_Interf() {
452   };
453   //
454   /**
455    *  Constructor
456    * @param theAllocator
457    *   allocator to manage the memory
458    */
459   /**
460    *  Constructor
461    * @param theAllocator
462    *   allocator to manage the memory
463    */
464   BOPDS_InterfEF(const Handle(NCollection_BaseAllocator)& theAllocator)
465     : BOPDS_Interf(theAllocator) {
466   };
467   //
468   /**
469    *  Destructor
470    */
471   virtual ~BOPDS_InterfEF() {
472   };
473   //
474   /**
475    * Modifier
476    * Sets the info of common part 
477    * @param theCP
478    *   common part
479    */
480   void SetCommonPart(const IntTools_CommonPrt& theCP){
481     myCommonPart=theCP;
482   };
483   //
484   /**
485    *  Selector
486    * Returns the info of common part 
487    * @return
488    *   common part
489    */
490   const IntTools_CommonPrt& CommonPart() const {
491     return myCommonPart;
492   };
493   //
494  protected:
495   IntTools_CommonPrt myCommonPart;
496 }
497 /**
498  * The class BOPDS_InterfFF is is to store the information about
499  * the interference of the type face/face. 
500 */;
501 //=======================================================================
502 //function : BOPDS_InterfFF
503 //purpose  : 
504 //=======================================================================
505 class BOPDS_InterfFF  : public BOPDS_Interf {
506  public:
507   //
508   /**
509    *  Constructor
510    */
511   BOPDS_InterfFF()
512     : 
513       BOPDS_Interf(),
514       myTangentFaces(Standard_False),
515       myTolR3D(1.e-7),
516       myTolR2D(1.e-7),
517       myCurves(myAllocator),
518       myPoints(myAllocator) {
519   };
520   //
521   /**
522    *  Constructor
523    * @param theAllocator
524    *   allocator to manage the memory
525    */
526   /**
527   BOPDS_InterfFF(const Handle(NCollection_BaseAllocator)& theAllocator)
528     : 
529       BOPDS_Interf(theAllocator),
530       myTangentFaces(Standard_False),
531       myTolR3D(1.e-7),
532       myTolR2D(1.e-7),
533       myCurves(myAllocator),
534       myPoints(myAllocator) {
535   };
536   //
537   /**
538    *  Destructor
539    */
540   virtual ~BOPDS_InterfFF() {
541   };
542   //
543   /**
544    * Initializer
545    * @param theNbCurves
546    *   number of intersection curves
547    * @param theNbPoints
548    *   number of intersection points
549    */
550   void Init(const Standard_Integer theNbCurves,
551             const Standard_Integer theNbPoints) {
552     if (theNbCurves>0) {
553       myCurves.SetStartSize(theNbCurves);
554       myCurves.SetIncrement(theNbCurves);
555       myCurves.Init();
556     }
557     if (theNbPoints>0) {
558       myPoints.SetStartSize(theNbPoints);
559       myPoints.SetIncrement(theNbPoints);
560       myPoints.Init();
561     }
562   }
563   /**
564    * Modifier
565    * Sets the flag of whether the faces are tangent  
566    * @param theFlag
567    *   the flag 
568    */
569   void SetTangentFaces(const Standard_Boolean theFlag) {
570      myTangentFaces=theFlag;
571   }
572   /**
573    * Selector
574    * Returns the flag whether the faces are tangent  
575    * @return
576    *   the flag 
577    */
578   Standard_Boolean TangentFaces()const {
579     return myTangentFaces;
580   }
581   /**
582    * Modifier
583    * Sets the value of 3D tolerance  
584    * @param theTol
585    *   3D tolerance
586    */
587   void SetTolR3D(const Standard_Real theTol) {
588      myTolR3D=theTol;
589   }
590   //
591   /**
592    * Selector
593    * Returns the value of 3D tolerance  
594    * @return
595    *   3D tolerance
596    */
597   Standard_Real TolR3D()const {
598     return myTolR3D;
599   }
600   //
601   /**
602    * Modifier
603    * Sets the value of 2D tolerance  
604    * @param theTol
605    *   2D tolerance
606    */
607   void SetTolR2D(const Standard_Real theTol) {
608      myTolR2D=theTol;;
609   }
610   //
611   /**
612    * Selector 
613    * Returns the value of 2D tolerance  
614    * @return
615    *   2D tolerance
616    */
617   Standard_Real TolR2D()const {
618     return myTolR2D;
619   }
620   //
621   /**
622    * Selector
623    * Returns the intersection curves  
624    * @return
625    *   intersection curves 
626    */
627   const BOPDS_VectorOfCurve& Curves()const{
628     return myCurves;
629   };
630   //
631   /**
632    * Selector/Modifier
633    * Returns the intersection curves  
634    * @return
635    *   intersection curves 
636    */
637   BOPDS_VectorOfCurve& ChangeCurves(){
638     return myCurves;
639   };
640   //
641   /**
642    * Selector
643    * Returns the intersection points  
644    * @return
645    *   intersection points
646    */
647   const BOPDS_VectorOfPoint& Points()const{
648     return myPoints;
649   };
650   //
651   /**
652    * Selector/Modifier
653    * Returns the intersection points  
654    * @return
655    *   intersection points
656    */
657   BOPDS_VectorOfPoint& ChangePoints(){
658     return myPoints;
659   };
660   //
661  protected:
662   Standard_Boolean myTangentFaces;
663   Standard_Real myTolR3D;
664   Standard_Real myTolR2D;
665   BOPDS_VectorOfCurve myCurves;
666   BOPDS_VectorOfPoint myPoints;
667 };
668
669 #endif