summaryrefslogtreecommitdiff
path: root/inc/Image_GPixelField.gxx
blob: 2e533be63a4c8e4d38ea40cb83ed1182e57e9d1e (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
#include <Standard_OutOfRange.hxx>
#include <Standard_DimensionMismatch.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_OutOfMemory.hxx>

#ifdef TRACE
static int GPixelFieldCount = 0 ;
#endif

//=======================================================================
//function : Image_GPixelField
//purpose  : 
//=======================================================================

Image_GPixelField::Image_GPixelField (const Standard_Integer Width,
				      const Standard_Integer Height) :
	myWidth(Width),
	myHeight(Height),
	myDeletable(Standard_True)
{

  Standard_Integer Size = myWidth * myHeight;
 
  Standard_RangeError_Raise_if(( myWidth <= 0  || myHeight <= 0 ),
			       "Image_GPixelField::Create");

#ifdef TRACE
  cout << form("\tCreate a new GPixelField ( Count : %d )\n",++GPixelFieldCount)
       << flush ;
#endif

  myData = new Item [Size];
}

//=======================================================================
//function : Image_GPixelField
//purpose  : 
//=======================================================================

Image_GPixelField::Image_GPixelField (const Standard_Integer Width,
				      const Standard_Integer Height,
					const Item& V) :
	myWidth(Width),
	myHeight(Height),
	myDeletable(Standard_True)
{

  Standard_Integer Size = myWidth * myHeight;
 
  Standard_RangeError_Raise_if(( myWidth <= 0  || myHeight <= 0 ),
			       "Image_GPixelField::Create");

#ifdef TRACE
  cout << form("\tCreate a new GPixelField ( Count : %d )\n",++GPixelFieldCount)
       << flush ;
#endif

  myData = new Item [Size];
  
  for (Standard_Integer I = 0; I < Size ; I++) ((Item *)myData)[I] = V;
}

//=======================================================================
//function : Destroy
//purpose  : 
//=======================================================================

void Image_GPixelField::Destroy () 
{
#ifdef TRACE
  cout << form("\t\tDelete a GPixelField ( Count : %d )\n", --GPixelFieldCount )
       << flush ;
#endif

  if(myDeletable) {
    delete [] (Item *) myData;
  }
}