summaryrefslogtreecommitdiff
path: root/src/TopOpeBRepDS/TopOpeBRepDS_traceDSX.cxx
blob: 428ceb0dc4b0693591fd9da9d6ef7f39bab505dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// File:	TopOpeBRepDS_traceDSX.cxx
// Created:	Wed Oct 22 18:57:02 1997
// Author:	Jean Yves LEBEY
//		<jyl@bistrox.paris1.matra-dtv.fr>

#ifdef DEB
#include <TopOpeBRepDS_traceDSX.hxx>

//////////////////////////////////////////////////////////////

TopOpeBRepDS_traceDS::TopOpeBRepDS_traceDS()
{}

void TopOpeBRepDS_traceDS::SetHDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
  myHDS = HDS;
  myne = 0;
  myhe.Nullify();
  Allocate();
}

void TopOpeBRepDS_traceDS::Allocate()
{
  Standard_Integer n = Nelem();
  Standard_Boolean all = (myhe.IsNull()) || (n > myne);
  if (all) {
    if (n == 0) n = 1000;
    myhe = new TColStd_HArray1OfBoolean(0,n);
    myhe->Init(Standard_False);
  }
  if (n) myne = n;
}

Standard_Integer TopOpeBRepDS_traceDS::Nelem() const 
{ 
  return 0;
}

const Handle(TopOpeBRepDS_HDataStructure)& TopOpeBRepDS_traceDS::GetHDS() const 
{
  return myHDS;
}

void TopOpeBRepDS_traceDS::Set(const Standard_Integer ie, const Standard_Boolean b)
{
  Allocate();
  if (!(ie>=1 && ie<=myne)) return;
  myhe->SetValue(ie,b); 
}

void TopOpeBRepDS_traceDS::Set(const Standard_Boolean b, Standard_Integer na, char** a)
{
  Allocate();
  Standard_Integer ia;
  if (!na) myhe->Init(b);
  else for (ia=0; ia<na; ia++) Set(atoi(a[ia]),b);
}

Standard_Boolean TopOpeBRepDS_traceDS::GetI(const Standard_Integer ie) const
{
  if (myhe.IsNull()) return Standard_False;
  if (!(ie>=1 && ie<=myne)) return Standard_False;
  return myhe->Value(ie);
}

//////////////////////////////////////////////////////////////

TopOpeBRepDS_traceCURVE::TopOpeBRepDS_traceCURVE(){}
Standard_Integer TopOpeBRepDS_traceCURVE::Nelem() const
{
  if (myHDS.IsNull()) return 0;
  else return myHDS->NbCurves();
}

//////////////////////////////////////////////////////////////

#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>

TopOpeBRepDS_traceSHAPE::TopOpeBRepDS_traceSHAPE() {myns = 0;}
void TopOpeBRepDS_traceSHAPE::SetSS(const TopoDS_Shape& s1,const TopoDS_Shape& s2)
{
  TopTools_IndexedMapOfShape M;
  M.Clear();
  //JMB s1 ou s2 peut etre nul (voir ChFi3d chez lvt)
  if (!s1.IsNull()) {
    TopExp::MapShapes(s1,M);
  }
  Standard_Integer n1 = M.Extent();
  M.Clear();
  if (!s2.IsNull()) {
    TopExp::MapShapes(s2,M);
  }
  Standard_Integer n2 = M.Extent();
  myns = n1+n2;
}

void TopOpeBRepDS_traceSHAPE::SetSSHDS(const TopoDS_Shape& s1,const TopoDS_Shape& s2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{
  SetSS(s1,s2);
  SetHDS(HDS);
}

Standard_Integer TopOpeBRepDS_traceSHAPE::Nelem() const
{
  return myns;
}

Standard_Integer TopOpeBRepDS_traceSHAPE::Index(const TopoDS_Shape& S) const
{
  if (myHDS.IsNull()) return 0;
  Standard_Integer i = myHDS->Shape(S);
  return i;
}

Standard_Boolean TopOpeBRepDS_traceSHAPE::GetS(const TopoDS_Shape& S) const
{
  if (myHDS.IsNull()) return Standard_False;
  Standard_Integer is = myHDS->Shape(S);
  Standard_Boolean b = GetI(is);
  return b;
}

//////////////////////////////////////////////////////////////
static TopOpeBRepDS_traceCURVE VCX;
Standard_EXPORT void TopOpeBRepDS_SettraceCX(const Standard_Boolean b,Standard_Integer n,char** a) { VCX.Set(b,n,a); }
Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceCX(const Standard_Integer i) { return VCX.GetI(i); }

//////////////////////////////////////////////////////////////
static TopOpeBRepDS_traceSHAPE VSPSX;
static TopOpeBRepDS_traceSHAPE VSPSXX;

Standard_EXPORT void TopOpeBRepDS_SettraceSPSX(const Standard_Boolean b,Standard_Integer n,char** a) { VSPSX.Set(b,n,a); }
Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer i) { return VSPSX.GetI(i); }
Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const TopoDS_Shape& S) { return VSPSX.GetS(S); }
Standard_EXPORT Standard_Integer TopOpeBRepDS_GetindexSPSX(const TopoDS_Shape& S) { return VSPSX.Index(S); }
Standard_EXPORT void TopOpeBRepDS_SettraceSPSX(const Standard_Integer i,const Standard_Boolean b) { VSPSX.Set(i,b); }
Standard_EXPORT void TopOpeBRepDS_SettraceSPSXX(const Standard_Boolean b, Standard_Integer n, char** a) { VSPSXX.Set(b,n,a);}
Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSXX(const Standard_Integer i1,const Standard_Integer i2)
{ Standard_Boolean b1 = VSPSXX.GetI(i1); Standard_Boolean b2 = VSPSXX.GetI(i2); return (b1 && b2); }
Standard_EXPORT void TopOpeBRepDS_SettraceSPSX_SS(const TopoDS_Shape& S1,const TopoDS_Shape& S2) 
{ VSPSX.SetSS(S1,S2); VSPSXX.SetSS(S1,S2); }
Standard_EXPORT void TopOpeBRepDS_SettraceSPSX_HDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{ VSPSX.SetHDS(HDS); VSPSXX.SetHDS(HDS); }
Standard_EXPORT void TopOpeBRepDS_SettraceSPSX_SSHDS
(const TopoDS_Shape& a,const TopoDS_Shape& b,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
{ VSPSX.SetSSHDS(a,b,HDS); VSPSXX.SetSSHDS(a,b,HDS); }

#endif