7fd59977 |
1 | #include <Standard_OutOfRange.hxx> |
2 | #include <Standard_DimensionMismatch.hxx> |
3 | #include <Standard_RangeError.hxx> |
4 | #include <Standard_OutOfMemory.hxx> |
5 | |
6 | #ifdef TRACE |
7 | static int GPixelFieldCount = 0 ; |
8 | #endif |
9 | |
10 | //======================================================================= |
11 | //function : Image_GPixelField |
12 | //purpose : |
13 | //======================================================================= |
14 | |
15 | Image_GPixelField::Image_GPixelField (const Standard_Integer Width, |
16 | const Standard_Integer Height) : |
17 | myWidth(Width), |
18 | myHeight(Height), |
19 | myDeletable(Standard_True) |
20 | { |
21 | |
22 | Standard_Integer Size = myWidth * myHeight; |
23 | |
24 | Standard_RangeError_Raise_if(( myWidth <= 0 || myHeight <= 0 ), |
25 | "Image_GPixelField::Create"); |
26 | |
27 | #ifdef TRACE |
28 | cout << form("\tCreate a new GPixelField ( Count : %d )\n",++GPixelFieldCount) |
29 | << flush ; |
30 | #endif |
31 | |
32 | myData = new Item [Size]; |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : Image_GPixelField |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | Image_GPixelField::Image_GPixelField (const Standard_Integer Width, |
41 | const Standard_Integer Height, |
42 | const Item& V) : |
43 | myWidth(Width), |
44 | myHeight(Height), |
45 | myDeletable(Standard_True) |
46 | { |
47 | |
48 | Standard_Integer Size = myWidth * myHeight; |
49 | |
50 | Standard_RangeError_Raise_if(( myWidth <= 0 || myHeight <= 0 ), |
51 | "Image_GPixelField::Create"); |
52 | |
53 | #ifdef TRACE |
54 | cout << form("\tCreate a new GPixelField ( Count : %d )\n",++GPixelFieldCount) |
55 | << flush ; |
56 | #endif |
57 | |
58 | myData = new Item [Size]; |
59 | |
60 | for (Standard_Integer I = 0; I < Size ; I++) ((Item *)myData)[I] = V; |
61 | } |
62 | |
63 | //======================================================================= |
64 | //function : Destroy |
65 | //purpose : |
66 | //======================================================================= |
67 | |
68 | void Image_GPixelField::Destroy () |
69 | { |
70 | #ifdef TRACE |
71 | cout << form("\t\tDelete a GPixelField ( Count : %d )\n", --GPixelFieldCount ) |
72 | << flush ; |
73 | #endif |
74 | |
75 | if(myDeletable) { |
76 | delete [] (Item *) myData; |
77 | } |
78 | } |
79 | |