0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_traceDSX.cxx
1 // Created on: 1997-10-22
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1997-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 #ifdef DEB
18 #include <TopOpeBRepDS_traceDSX.hxx>
19
20 //////////////////////////////////////////////////////////////
21
22 TopOpeBRepDS_traceDS::TopOpeBRepDS_traceDS()
23 {}
24
25 void TopOpeBRepDS_traceDS::SetHDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
26 {
27   myHDS = HDS;
28   myne = 0;
29   myhe.Nullify();
30   Allocate();
31 }
32
33 void TopOpeBRepDS_traceDS::Allocate()
34 {
35   Standard_Integer n = Nelem();
36   Standard_Boolean all = (myhe.IsNull()) || (n > myne);
37   if (all) {
38     if (n == 0) n = 1000;
39     myhe = new TColStd_HArray1OfBoolean(0,n);
40     myhe->Init(Standard_False);
41   }
42   if (n) myne = n;
43 }
44
45 Standard_Integer TopOpeBRepDS_traceDS::Nelem() const 
46
47   return 0;
48 }
49
50 const Handle(TopOpeBRepDS_HDataStructure)& TopOpeBRepDS_traceDS::GetHDS() const 
51 {
52   return myHDS;
53 }
54
55 void TopOpeBRepDS_traceDS::Set(const Standard_Integer ie, const Standard_Boolean b)
56 {
57   Allocate();
58   if (!(ie>=1 && ie<=myne)) return;
59   myhe->SetValue(ie,b); 
60 }
61
62 void TopOpeBRepDS_traceDS::Set(const Standard_Boolean b, Standard_Integer na, char** a)
63 {
64   Allocate();
65   Standard_Integer ia;
66   if (!na) myhe->Init(b);
67   else for (ia=0; ia<na; ia++) Set(atoi(a[ia]),b);
68 }
69
70 Standard_Boolean TopOpeBRepDS_traceDS::GetI(const Standard_Integer ie) const
71 {
72   if (myhe.IsNull()) return Standard_False;
73   if (!(ie>=1 && ie<=myne)) return Standard_False;
74   return myhe->Value(ie);
75 }
76
77 //////////////////////////////////////////////////////////////
78
79 TopOpeBRepDS_traceCURVE::TopOpeBRepDS_traceCURVE(){}
80 Standard_Integer TopOpeBRepDS_traceCURVE::Nelem() const
81 {
82   if (myHDS.IsNull()) return 0;
83   else return myHDS->NbCurves();
84 }
85
86 //////////////////////////////////////////////////////////////
87
88 #include <TopExp.hxx>
89 #include <TopTools_IndexedMapOfShape.hxx>
90
91 TopOpeBRepDS_traceSHAPE::TopOpeBRepDS_traceSHAPE() {myns = 0;}
92 void TopOpeBRepDS_traceSHAPE::SetSS(const TopoDS_Shape& s1,const TopoDS_Shape& s2)
93 {
94   TopTools_IndexedMapOfShape M;
95   M.Clear();
96   //JMB s1 ou s2 peut etre nul (voir ChFi3d chez lvt)
97   if (!s1.IsNull()) {
98     TopExp::MapShapes(s1,M);
99   }
100   Standard_Integer n1 = M.Extent();
101   M.Clear();
102   if (!s2.IsNull()) {
103     TopExp::MapShapes(s2,M);
104   }
105   Standard_Integer n2 = M.Extent();
106   myns = n1+n2;
107 }
108
109 void TopOpeBRepDS_traceSHAPE::SetSSHDS(const TopoDS_Shape& s1,const TopoDS_Shape& s2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
110 {
111   SetSS(s1,s2);
112   SetHDS(HDS);
113 }
114
115 Standard_Integer TopOpeBRepDS_traceSHAPE::Nelem() const
116 {
117   return myns;
118 }
119
120 Standard_Integer TopOpeBRepDS_traceSHAPE::Index(const TopoDS_Shape& S) const
121 {
122   if (myHDS.IsNull()) return 0;
123   Standard_Integer i = myHDS->Shape(S);
124   return i;
125 }
126
127 Standard_Boolean TopOpeBRepDS_traceSHAPE::GetS(const TopoDS_Shape& S) const
128 {
129   if (myHDS.IsNull()) return Standard_False;
130   Standard_Integer is = myHDS->Shape(S);
131   Standard_Boolean b = GetI(is);
132   return b;
133 }
134
135 //////////////////////////////////////////////////////////////
136 static TopOpeBRepDS_traceCURVE VCX;
137 Standard_EXPORT void TopOpeBRepDS_SettraceCX(const Standard_Boolean b,Standard_Integer n,char** a) { VCX.Set(b,n,a); }
138 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceCX(const Standard_Integer i) { return VCX.GetI(i); }
139
140 //////////////////////////////////////////////////////////////
141 static TopOpeBRepDS_traceSHAPE VSPSX;
142 static TopOpeBRepDS_traceSHAPE VSPSXX;
143
144 Standard_EXPORT void TopOpeBRepDS_SettraceSPSX(const Standard_Boolean b,Standard_Integer n,char** a) { VSPSX.Set(b,n,a); }
145 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer i) { return VSPSX.GetI(i); }
146 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const TopoDS_Shape& S) { return VSPSX.GetS(S); }
147 Standard_EXPORT Standard_Integer TopOpeBRepDS_GetindexSPSX(const TopoDS_Shape& S) { return VSPSX.Index(S); }
148 Standard_EXPORT void TopOpeBRepDS_SettraceSPSX(const Standard_Integer i,const Standard_Boolean b) { VSPSX.Set(i,b); }
149 Standard_EXPORT void TopOpeBRepDS_SettraceSPSXX(const Standard_Boolean b, Standard_Integer n, char** a) { VSPSXX.Set(b,n,a);}
150 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSXX(const Standard_Integer i1,const Standard_Integer i2)
151 { Standard_Boolean b1 = VSPSXX.GetI(i1); Standard_Boolean b2 = VSPSXX.GetI(i2); return (b1 && b2); }
152 Standard_EXPORT void TopOpeBRepDS_SettraceSPSX_SS(const TopoDS_Shape& S1,const TopoDS_Shape& S2) 
153 { VSPSX.SetSS(S1,S2); VSPSXX.SetSS(S1,S2); }
154 Standard_EXPORT void TopOpeBRepDS_SettraceSPSX_HDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
155 { VSPSX.SetHDS(HDS); VSPSXX.SetHDS(HDS); }
156 Standard_EXPORT void TopOpeBRepDS_SettraceSPSX_SSHDS
157 (const TopoDS_Shape& a,const TopoDS_Shape& b,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
158 { VSPSX.SetSSHDS(a,b,HDS); VSPSXX.SetSSHDS(a,b,HDS); }
159
160 #endif