openModeller
Version 1.5.0
Main Page
Modules
Classes
Files
File List
File Members
EnvCell.cpp
Go to the documentation of this file.
1
/* **************************************
2
* GARP Modeling Package
3
*
4
* **************************************
5
*
6
* Copyright (c), The Center for Research, University of Kansas, 2385 Irving Hill Road, Lawrence, KS 66044-4755, USA.
7
* Copyright (C), David R.B. Stockwell of Symbiotik Pty. Ltd.
8
*
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the license that is distributed with the software.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* license.txt file included with this software for more details.
16
*/
17
18
// EnvCell.cpp: implementation of the EnvCell class.
19
//
21
22
#include "
EnvCell.h
"
23
#include "
Utilities.h
"
24
25
#include <stdio.h>
26
27
// ============================================================================
28
EnvCell::EnvCell
()
29
{
30
intCount
= 0;
31
values
= NULL;
32
33
intPos
= -1;
34
x
=
y
= 0.0;
35
}
36
37
// ============================================================================
38
EnvCell::EnvCell
(
int
ct,
BYTE
* val)
39
{
40
intCount
= ct;
41
values
= val;
42
43
intPos
= -1;
44
x
=
y
= 0.0;
45
}
46
47
// ============================================================================
48
EnvCell::EnvCell
(
int
ct,
BYTE
* val,
int
pos,
double
px,
double
py)
49
{
50
intCount
= ct;
51
values
= val;
52
53
intPos
= pos;
54
x
= px;
55
y
= py;
56
}
57
58
// ============================================================================
59
EnvCell::~EnvCell
()
60
{
61
}
62
63
// ============================================================================
64
void
EnvCell::setSize
(
int
newSize)
65
{
66
intCount
= newSize;
67
}
68
69
// ============================================================================
70
int
EnvCell::size
()
71
{
72
return
intCount
;
73
}
74
75
// ============================================================================
76
void
EnvCell::setValues
(
BYTE
* newValues)
77
{
78
values
= newValues;
79
}
80
81
// ============================================================================
82
BYTE
*
EnvCell::getValues
()
83
{
84
return
values
;
85
}
86
87
// ============================================================================
88
bool
EnvCell::operator==
(
EnvCell
oCell)
89
{
90
int
i;
91
92
// if the sizes are different than they are not equal
93
if
(
intCount
!= oCell.
intCount
)
94
return
false
;
95
96
// check if the values in both cells are identical
97
i = 0;
98
while
((
values
[i] == oCell.
values
[i]) && (i <
intCount
))
99
i++;
100
101
// if (i == intCount) then all values are equal
102
// otherwise, the values at index [i] are the first difference found
103
return
(i ==
intCount
);
104
}
105
106
// ============================================================================
107
bool
EnvCell::operator!=
(
EnvCell
oCell)
108
{
109
return
!(
operator==
(oCell));
110
}
111
112
// ============================================================================
113
char
*
EnvCell::toXML
()
114
{
115
const
int
iStringSize = 1024;
116
117
char
* strXML =
new
char
[iStringSize];
118
char
strAux[256];
119
120
sprintf(strXML,
"<EnvCell Pos=\"%d\" X=\"%f\" Y=\"%f\">"
,
intPos
,
x
,
y
);
121
122
for
(
int
i = 0; i <
intCount
; i++)
123
{
124
sprintf(strAux,
"%d "
,
values
[i]);
125
strcat(strXML, strAux);
126
}
127
128
strcat(strXML,
"</EnvCell>\n"
);
129
130
if
(strlen(strXML) > static_cast<int> (iStringSize))
131
throw
GarpException
(82,
"String size exceeded in EnvCell::toXML()"
);
132
133
return
strXML;
134
}
135
136
// ============================================================================
137
// ============================================================================
EnvCell::EnvCell
EnvCell()
Definition:
EnvCell.cpp:28
EnvCell::toXML
char * toXML()
Definition:
EnvCell.cpp:113
EnvCell::values
BYTE * values
Definition:
EnvCell.h:32
GarpException
Definition:
Utilities.h:110
EnvCell::setSize
void setSize(int newSize)
Definition:
EnvCell.cpp:64
EnvCell::operator!=
bool operator!=(EnvCell oCell)
Definition:
EnvCell.cpp:107
BYTE
unsigned char BYTE
Definition:
Utilities.h:36
EnvCell::intCount
int intCount
Definition:
EnvCell.h:31
EnvCell.h
EnvCell::intPos
int intPos
Definition:
EnvCell.h:35
EnvCell
Definition:
EnvCell.h:28
EnvCell::getValues
BYTE * getValues()
Definition:
EnvCell.cpp:82
Utilities.h
EnvCell::~EnvCell
virtual ~EnvCell()
Definition:
EnvCell.cpp:59
EnvCell::x
double x
Definition:
EnvCell.h:36
EnvCell::y
double y
Definition:
EnvCell.h:36
EnvCell::operator==
bool operator==(EnvCell oCell)
Definition:
EnvCell.cpp:88
EnvCell::setValues
void setValues(BYTE *newValues)
Definition:
EnvCell.cpp:76
EnvCell::size
int size()
Definition:
EnvCell.cpp:70
src
algorithms
dg_garp
EnvCell.cpp
Generated on Thu Jan 8 2015 17:05:09 for openModeller by
1.8.6