summaryrefslogtreecommitdiff
path: root/src/IntPolyh/IntPolyh_ArrayOfCouples.cxx
blob: 7c60f8eb3c47a2f14d145457060283191eee9446 (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
// File:	IntPolyh_ArrayOfCouples.cxx
// Created:	Thu Apr  8 1999
// Author:	Fabrice SERVANT
//		<fst@cleox.paris1.matra-dtv.fr>


#include <IntPolyh_ArrayOfCouples.ixx>
#include <stdio.h>

#include <Standard_Stream.hxx>

IntPolyh_ArrayOfCouples::IntPolyh_ArrayOfCouples() : n(0),eoa(0),ptr(0){
}

IntPolyh_ArrayOfCouples::IntPolyh_ArrayOfCouples(const Standard_Integer N) :  n(N),eoa(0){ 
  Init(N);
}

void IntPolyh_ArrayOfCouples::Init(const Standard_Integer N) { 
  Destroy();
  ptr = (void *) (new IntPolyh_Couple [N]);
  n=N;
}

Standard_Integer IntPolyh_ArrayOfCouples::NbCouples() const { 
  return(eoa); 
}

void IntPolyh_ArrayOfCouples::SetNbCouples(const Standard_Integer fint) {
  eoa=fint;
}

void IntPolyh_ArrayOfCouples::IncNbCouples() {
  eoa++;
}

# ifdef DEB
  #define BORNES 1
# endif

const IntPolyh_Couple& IntPolyh_ArrayOfCouples::Value(const Standard_Integer Index) const { 
  IntPolyh_Couple* ptrCouple = (IntPolyh_Couple*) ptr; 
#if BORNES
  if(Index<0 || Index>=n) { 
    cerr<<" Erreur4 "<<endl; 
    printf("Value() from IntPolyh_ArrayOfCouples : value out of array\n");
  }
#endif
  return(ptrCouple[Index]); 
}

IntPolyh_Couple& IntPolyh_ArrayOfCouples::ChangeValue(const Standard_Integer Index) { 
  IntPolyh_Couple* ptrCouple = (IntPolyh_Couple*) ptr; 
#if BORNES
  if(Index<0 || Index>=n) { 
    cerr<<" Erreur4"<<endl;
    printf("ChangeValue() from IntPolyh_ArrayOfCouples : value out of array\n");
  }
#endif
  return(ptrCouple[Index]);
}

void IntPolyh_ArrayOfCouples::Destroy() { 
  if(n) { 
    if(ptr) { 
      IntPolyh_Couple* ptrCouple = (IntPolyh_Couple*) ptr; 
      delete [] ptrCouple;
      ptrCouple=0;
      ptr=0;
      n=0;
    }
  }
}

void IntPolyh_ArrayOfCouples::Dump() const{ 
  printf("\n ArrayOfCouples 0-> %d",n-1);
    for(Standard_Integer i=0;i<n;i++) { 
      (*this)[i].Dump(i);
    }
    printf("\n");
}