Integration of OCCT 6.5.0 from SVN
[occt.git] / src / IntPolyh / IntPolyh_ArrayOfPoints.cxx
1 // File:        IntPolyh_ArrayOfPoints.cxx
2 // Created:     Mon Mar  8 09:32:00 1999
3 // Author:      Fabrice SERVANT
4 //              <fst@cleox.paris1.matra-dtv.fr>
5
6
7 #include <IntPolyh_ArrayOfPoints.ixx>
8
9 #include <stdio.h>
10
11
12 IntPolyh_ArrayOfPoints::IntPolyh_ArrayOfPoints() : n(0),fintp(0),ptr(0) { }
13
14 IntPolyh_ArrayOfPoints::IntPolyh_ArrayOfPoints(const Standard_Integer N): fintp(0){ 
15   Init(N);
16 }
17
18 void IntPolyh_ArrayOfPoints::Init(const Standard_Integer N) { 
19   Destroy();
20   ptr = (void*) (new IntPolyh_Point [N]);
21   n = N;
22 }
23
24 Standard_Integer IntPolyh_ArrayOfPoints::GetN() const { 
25     return(n); 
26 }
27
28 Standard_Integer IntPolyh_ArrayOfPoints::NbPoints() const { 
29     return(fintp); 
30 }
31
32 void IntPolyh_ArrayOfPoints::IncNbPoints() {
33   fintp++;
34 }
35
36 void IntPolyh_ArrayOfPoints::SetNbPoints(const Standard_Integer endaop) {
37   fintp = endaop;
38 }
39
40 # ifdef DEB
41   #define BORNES 1
42 # endif
43
44 const IntPolyh_Point& IntPolyh_ArrayOfPoints::Value(const Standard_Integer Index) const { 
45   IntPolyh_Point *ptrpoint = (IntPolyh_Point *)ptr;
46 #if BORNES
47   if(Index<0 || Index>=n) { 
48     cerr<<" Erreur1 "<<endl; 
49     printf("Value() from IntPolyh_ArrayOfPoints : ERROR value outside of the array\n");
50   } 
51 #endif
52   return(ptrpoint[Index]); 
53 }
54
55 IntPolyh_Point& IntPolyh_ArrayOfPoints::ChangeValue(const Standard_Integer Index) { 
56   IntPolyh_Point *ptrpoint = (IntPolyh_Point *)ptr;
57 #if BORNES
58     if(Index<0 || Index>=n) { 
59       cerr<<" Erreur1 "<<endl; 
60       printf("ChangeValue() from IntPolyh_ArrayOfPoints : ERROR value outside of the array\n");
61     } 
62 #endif
63     return(ptrpoint[Index]); 
64 }
65   
66 void IntPolyh_ArrayOfPoints::Destroy() { 
67   if(n) { 
68     if(ptr) { 
69       IntPolyh_Point *ptrpoint = (IntPolyh_Point *)ptr;
70       delete [] ptrpoint;
71       ptrpoint=0;
72       ptr=0;
73       n=0;
74       }
75   }
76 }
77   
78 IntPolyh_ArrayOfPoints & IntPolyh_ArrayOfPoints::Copy(const IntPolyh_ArrayOfPoints& Other) { 
79   if(ptr==Other.ptr) return(*this);
80   Destroy();
81   n=Other.n;
82   ptr = (void *) (new IntPolyh_Point[n]);
83   for(Standard_Integer i=0;i<=n;i++) { 
84     (*this)[i]=Other[i];
85   }
86   return(*this);
87 }
88
89 void IntPolyh_ArrayOfPoints::Dump() const{ 
90   printf("\n ArrayOfPoints 0-> %d\n",fintp-1);
91   printf("size %d, room left%d", n, n-fintp);
92   for(Standard_Integer i=0;i<fintp;i++) { 
93     (*this)[i].Dump(i);
94   }
95   printf("\n");
96 }
97
98
99
100
101
102
103