0032969: Coding - get rid of unused headers [IMeshData to PLib]
[occt.git] / src / IntCurveSurface / IntCurveSurface_Intersection.cxx
1 // Created on: 1993-04-16
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1993-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 <IntCurveSurface_Intersection.hxx>
19 #include <IntCurveSurface_IntersectionPoint.hxx>
20 #include <IntCurveSurface_IntersectionSegment.hxx>
21 #include <IntCurveSurface_TransitionOnCurve.hxx>
22 #include <StdFail_NotDone.hxx>
23
24 #define PARAMEQUAL(a,b) (Abs((a)-(b))< (1e-8))
25
26 //================================================================================
27 IntCurveSurface_Intersection::IntCurveSurface_Intersection(): 
28 done(Standard_False),
29 myIsParallel(Standard_False)
30
31 }
32 //================================================================================
33 Standard_Boolean IntCurveSurface_Intersection::IsDone() const { return(done); } 
34 //================================================================================
35 Standard_Boolean IntCurveSurface_Intersection::IsParallel() const 
36
37   return(myIsParallel); 
38 }
39 //================================================================================
40 Standard_Integer IntCurveSurface_Intersection::NbPoints() const { 
41   if (!done) {throw StdFail_NotDone();}
42   return lpnt.Length();
43 }
44 //================================================================================
45 Standard_Integer IntCurveSurface_Intersection::NbSegments() const { 
46   if (!done) {throw StdFail_NotDone();}
47   return lseg.Length();
48 }
49 //================================================================================
50 const IntCurveSurface_IntersectionPoint& IntCurveSurface_Intersection::Point( const Standard_Integer N) const {
51   if (!done) {throw StdFail_NotDone();}
52   return lpnt.Value(N);
53 }
54 //================================================================================
55 const IntCurveSurface_IntersectionSegment& IntCurveSurface_Intersection::Segment( const Standard_Integer N) const {
56   if (!done) {throw StdFail_NotDone();}
57   return lseg.Value(N);
58 }
59 //================================================================================
60 void IntCurveSurface_Intersection::SetValues(const IntCurveSurface_Intersection& Other) {
61   if(Other.done) {
62     lseg.Clear();
63     lpnt.Clear();
64     Standard_Integer N = Other.lpnt.Length();
65     Standard_Integer i ;
66     for( i=1; i<= N ; i++) { 
67       lpnt.Append(Other.lpnt.Value(i));
68     }
69     N = Other.lseg.Length();
70     for(i=1; i<= N ; i++) { 
71       lseg.Append(Other.lseg.Value(i));
72     } 
73     done=Standard_True;
74   }
75   else {
76     done=Standard_False;
77   }
78 }
79 //================================================================================
80 void IntCurveSurface_Intersection::Append(const IntCurveSurface_Intersection& Other,
81 //                                        const Standard_Real a,
82                                           const Standard_Real ,
83 //                                        const Standard_Real b) 
84                                           const Standard_Real ) 
85
86   Standard_Integer i,ni;
87   if(Other.done) { 
88     ni = Other.lpnt.Length();
89     for(i=1;i<=ni;i++) {   Append(Other.Point(i)); }
90     ni = Other.lseg.Length();
91     for(i=1;i<=ni;i++) {   Append(Other.Segment(i)); }
92   }
93 }
94 //================================================================================
95 void IntCurveSurface_Intersection::Append(const IntCurveSurface_IntersectionPoint& OtherPoint) { 
96   Standard_Integer i,ni;
97   Standard_Real anu,anv,anw,u,v,w;
98   IntCurveSurface_TransitionOnCurve   TrOnCurve,anTrOnCurve;
99   gp_Pnt P,anP;
100   ni = lpnt.Length();
101   for(i=1;i<=ni;i++) {
102     OtherPoint.Values(P,u,v,w,TrOnCurve);
103     lpnt(i).Values(anP,anu,anv,anw,anTrOnCurve);
104     if(PARAMEQUAL(u,anu)) { 
105       if(PARAMEQUAL(v,anv)) { 
106         if(PARAMEQUAL(w,anw)) { 
107           if(anTrOnCurve==TrOnCurve) { 
108             return;
109           }
110         }
111       }
112     }
113   }
114   lpnt.Append(OtherPoint);
115 }
116 //================================================================================
117 void IntCurveSurface_Intersection::Append(const IntCurveSurface_IntersectionSegment& OtherSegment) { 
118   lseg.Append(OtherSegment);
119 }
120 //================================================================================
121 void IntCurveSurface_Intersection::ResetFields() {
122   if(done) {
123     lseg.Clear();
124     lpnt.Clear();
125     done=Standard_False;
126     myIsParallel = Standard_False;
127   }
128 }
129 //================================================================================
130 void IntCurveSurface_Intersection::Dump() const { 
131   if(done) { 
132     Standard_Integer i,ni;
133     ni = lpnt.Length();
134     for(i=1;i<=ni;i++) {   Point(i).Dump(); }
135     ni = lseg.Length();
136     for(i=1;i<=ni;i++) {   Segment(i).Dump(); }
137   }
138   else { 
139     std::cout<<" Intersection NotDone"<<std::endl;
140   }
141 }