summaryrefslogtreecommitdiff
path: root/src/BRepClass3d/BRepClass3d_SolidClassifier.cxx
blob: dd819be841e38e788b36af2f619ec86474b71f84 (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// File:	BRepClass3d_SolidClassifier.cxx
// Created:	Wed Mar 30 18:28:29 1994
// Author:	Laurent BUCHARD
//		<lbr@fuegox>
//-Copyright:	 Matra Datavision 1994



#define MARCHEPASSIUNESEULEFACE 0


#ifdef DEB
#define LBRCOMPT 0
#else 
#define LBRCOMPT 0
#endif

#if LBRCOMPT
#include <stdio.h>

class StatistiquesBRepClass3d { 
public:
  long unsigned NbConstrVide;
  long unsigned NbLoad;
  long unsigned NbConstrShape;
  long unsigned NbConstrShapePnt;
  long unsigned NbPerform;
  long unsigned NbPerformRejection;
  long unsigned NbPerformInfinitePoint;
  long unsigned NbDestroy;
public:
  StatistiquesBRepClass3d() { 
    NbConstrVide=NbLoad=NbConstrShape=NbConstrShapePnt=NbPerform=NbPerformInfinitePoint=NbDestroy=0;
  }
  ~StatistiquesBRepClass3d() { 
    printf("\n--- Statistiques BRepClass3d:\n");

    printf("\nConstructeurVide    : %10lu",NbConstrVide);
    printf("\nConstructeur(Shape) : %10lu",NbConstrShape);
    printf("\nLoad(Shape)         : %10lu",NbLoad);
    printf("\nPerform(pnt3d)      : %10lu",NbPerform);
    printf("\nPerform(pnt3d) REJ  : %10lu",NbPerformRejection);
    printf("\nPerformInfinitePoint: %10lu",NbPerformInfinitePoint);
    printf("\nDestroy             : %10lu",NbDestroy             );
  }
};

static StatistiquesBRepClass3d STAT;
#endif



#include <BRepClass3d_SolidClassifier.ixx>

#include <TopoDS_Shape.hxx>

BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier()
{
  aSolidLoaded=isaholeinspace=Standard_False;
#if LBRCOMPT
  STAT.NbConstrVide++;
#endif
}


void BRepClass3d_SolidClassifier::Load(const TopoDS_Shape& S) {

#if LBRCOMPT
  STAT.NbLoad++;
#endif

  if(aSolidLoaded) { 
    explorer.Destroy();
  }
  explorer.InitShape(S);
  aSolidLoaded = Standard_True;


#if MARCHEPASSIUNESEULEFACE
  PerformInfinitePoint(1e-7);
  if(State()==TopAbs_OUT) { 
    isaholeinspace=Standard_False;
  }
  else { 
    isaholeinspace=Standard_True;
  }
#endif  
}

BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S)
:  aSolidLoaded(Standard_True),explorer(S) 
{ 
#if LBRCOMPT
  STAT.NbConstrShape++;
#endif
#if MARCHEPASSIUNESEULEFACE
  PerformInfinitePoint(1e-7);
  if(State()==TopAbs_OUT) { 
    isaholeinspace=Standard_False;
  }
  else { 
    isaholeinspace=Standard_True;
  }
#endif  
}

BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S,
							 const gp_Pnt&       P,
							 const Standard_Real Tol) 
: explorer(S) { 
#if LBRCOMPT
  STAT.NbConstrShapePnt++;
#endif
  aSolidLoaded = Standard_True;
#if MARCHEPASSIUNESEULEFACE  
  PerformInfinitePoint(1e-7);
  if(State()==TopAbs_OUT) { 
    isaholeinspace=Standard_False;
  }
  else { 
    isaholeinspace=Standard_True;
  }
  
  if(isaholeinspace==Standard_False) { 
    if(explorer.Box().IsOut(P)) { 
      ForceOut(); 
    }
    else {
      Perform(P,Tol); 
    }
  }
  else { 
    if(explorer.Box().IsOut(P)) { 
      ForceIn(); 
    }
    else {
      Perform(P,Tol); 
    }
  }
#else 
  Perform(P,Tol); 
#endif
}


void BRepClass3d_SolidClassifier::Perform(const gp_Pnt& P,const Standard_Real Tol) { 
#if LBRCOMPT
  STAT.NbPerform++;
#endif
#if MARCHEPASSIUNESEULEFACE 
  if(aSolidLoaded) { 
    if(isaholeinspace==Standard_False) { 
      if(explorer.Box().IsOut(P)) { 
	ForceOut(); 
#if LBRCOMPT
	STAT.NbPerformRejection++;
#endif
	
      }
      else {
	BRepClass3d_SClassifier::Perform(explorer,P,Tol);
      }
    }
    else { 
      if(explorer.Box().IsOut(P)) { 
	ForceIn(); 
#if LBRCOMPT
	STAT.NbPerformRejection++;
#endif
	
      }
      else {
	BRepClass3d_SClassifier::Perform(explorer,P,Tol);
      }
    }
  }
#else 
  BRepClass3d_SClassifier::Perform(explorer,P,Tol);
#endif
}

void BRepClass3d_SolidClassifier::PerformInfinitePoint(const Standard_Real Tol) { 
#if LBRCOMPT
  STAT.NbPerformInfinitePoint++;
#endif

  if(aSolidLoaded) { 
    BRepClass3d_SClassifier::PerformInfinitePoint(explorer,Tol);
    if(State()==TopAbs_OUT) 
      isaholeinspace=Standard_False;
    else 
      isaholeinspace=Standard_True;
  }
}



void BRepClass3d_SolidClassifier::Destroy() { 
#if LBRCOMPT
  STAT.NbDestroy++;
#endif

  if(aSolidLoaded) { 
    explorer.Destroy();
    aSolidLoaded = Standard_False;
  }
}