23 return _num_channels != 0 && (_x_size * _y_size * _num_channels <= (int)_table.size());
58 return _has_point(
this, x, y);
69 nassertr(x >= 0 && x < _x_size &&
70 y >= 0 && y < _y_size &&
71 c >= 0 && c < _num_channels, 0.0f);
72 return _table[(y * _x_size + x) * _num_channels + c];
83 nassertv(x >= 0 && x < _x_size &&
84 y >= 0 && y < _y_size &&
85 c >= 0 && c < _num_channels);
86 _table[(y * _x_size + x) * _num_channels + c] = value;
97 nassertr(x >= 0 && x < _x_size &&
98 y >= 0 && y < _y_size, 0.0);
99 return _table[(y * _x_size + x) * _num_channels];
110 nassertv(!cnan(point));
111 nassertv(x >= 0 && x < _x_size &&
112 y >= 0 && y < _y_size);
113 _table[(y * _x_size + x) * _num_channels] = point;
125 nassertr(x >= 0 && x < _x_size &&
127 return *(
LPoint2f *)&_table[(y * _x_size + x) * _num_channels];
139 nassertv(!point.
is_nan());
140 nassertv(x >= 0 && x < _x_size &&
141 y >= 0 && y < _y_size);
142 switch (_num_channels) {
144 _table[(y * _x_size + x)] = point[0];
148 *(
LPoint2f *)&_table[(y * _x_size + x) * _num_channels] = point;
152 (*(
LPoint3f *)&_table[(y * _x_size + x) * _num_channels]).
set(point[0], point[1], 0.0);
156 (*(
LPoint4f *)&_table[(y * _x_size + x) * _num_channels]).
set(point[0], point[1], 0.0, 0.0);
183 nassertr(x >= 0 && x < _x_size &&
184 y >= 0 && y < _y_size, dummy_value);
187 return *(
LPoint2f *)&_table[(y * _x_size + x) * _num_channels];
246 nassertr(x >= 0 && x < _x_size &&
248 return *(
LPoint3f *)&_table[(y * _x_size + x) * _num_channels];
260 nassertv(!point.
is_nan());
261 nassertv(x >= 0 && x < _x_size &&
262 y >= 0 && y < _y_size);
263 switch (_num_channels) {
265 _table[(y * _x_size + x)] = point[0];
269 (*(
LPoint2f *)&_table[(y * _x_size + x) * _num_channels]).
set(point[0], point[1]);
273 *(
LPoint3f *)&_table[(y * _x_size + x) * _num_channels] = point;
277 (*(
LPoint4f *)&_table[(y * _x_size + x) * _num_channels]).
set(point[0], point[1], 0.0f, 0.0f);
304 nassertr(x >= 0 && x < _x_size &&
305 y >= 0 && y < _y_size, dummy_value);
308 return *(
LPoint3f *)&_table[(y * _x_size + x) * _num_channels];
320 nassertr(x >= 0 && x < _x_size &&
322 return *(
LPoint4f *)&_table[(y * _x_size + x) * _num_channels];
334 nassertv(!point.
is_nan());
335 nassertv(x >= 0 && x < _x_size &&
336 y >= 0 && y < _y_size);
337 switch (_num_channels) {
339 _table[(y * _x_size + x)] = point[0];
343 (*(
LPoint2f *)&_table[(y * _x_size + x) * _num_channels]).
set(point[0], point[1]);
347 (*(
LPoint3f *)&_table[(y * _x_size + x) * _num_channels]).
set(point[0], point[1], point[2]);
351 *(
LPoint4f *)&_table[(y * _x_size + x) * _num_channels] = point;
378 nassertr(x >= 0 && x < _x_size &&
379 y >= 0 && y < _y_size, dummy_value);
382 return *(
LPoint4f *)&_table[(y * _x_size + x) * _num_channels];
426 int x_begin, x_end, y_begin, y_end;
428 range.set(x_begin, x_end, y_begin, y_end);
443 int x_begin, x_end, y_begin, y_end;
445 range.set(x_begin, x_end, y_begin, y_end);
479 if (chan4 && _num_channels == 4) {
480 _has_no_data_value =
true;
481 _has_no_data_threshold =
false;
482 _no_data_value.set(0.0, 0.0, 0.0, -1.0);
483 _has_point = has_point_chan4;
521 _has_no_data_value =
false;
522 _has_no_data_threshold =
false;
524 _has_point = has_point_noop;
535 return _has_no_data_value;
546 return _has_no_data_threshold;
558 return _no_data_value;
569 xform(LCAST(PN_float32, transform));
592 compute_planar_bounds(
const LPoint2d ¢er, PN_float32 point_dist, PN_float32 sample_radius,
bool points_only)
const {
593 return compute_planar_bounds(LCAST(PN_float32, center), point_dist, sample_radius, points_only);
604 INLINE
const vector_float &PfmFile::
619 swap_table(vector_float &table) {
630 INLINE
void PfmFile::
631 setup_sub_image(
const PfmFile ©,
int &xto,
int &yto,
632 int &xfrom,
int &yfrom,
int &x_size,
int &y_size,
633 int &xmin,
int &ymin,
int &xmax,
int &ymax) {
663 x_size = min(x_size, copy.
get_x_size() - xfrom);
664 y_size = min(y_size, copy.
get_y_size() - yfrom);
This is the base class for all three-component vectors and points.
bool has_point(int x, int y) const
Returns true if there is a valid point at x, y.
This is a 4-by-4 transform matrix.
This is the base class for all two-component vectors and points.
void set_point4(int x, int y, const LVecBase4f &point)
Replaces the 4-component point value at the indicated point.
This is a four-component point in space.
const LPoint3f & get_point(int x, int y) const
Returns the 3-component point value at the indicated point.
static const LPoint3f & zero()
Returns a zero-length point.
This is the base class for all three-component vectors and points.
This is a two-component point in space.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
void set_no_data_chan4(bool chan4)
Sets the no_data_chan4 flag.
void set_point2(int x, int y, const LVecBase2f &point)
Replaces the 2-component point value at the indicated point.
const LPoint4f & get_point4(int x, int y) const
Returns the 4-component point value at the indicated point.
void set_point3(int x, int y, const LVecBase3f &point)
Replaces the 3-component point value at the indicated point.
static const LPoint4f & zero()
Returns a zero-length point.
const LPoint3f & get_point3(int x, int y) const
Returns the 3-component point value at the indicated point.
const LPoint2f & get_point2(int x, int y) const
Returns the 2-component point value at the indicated point.
LPoint4f & modify_point4(int x, int y)
Returns a modifiable 4-component point value at the indicated point.
void set_scale(PN_float32 scale)
The "scale" is reported in the pfm header and is probably meaningless.
PN_float32 get_point1(int x, int y) const
Returns the 1-component point value at the indicated point.
void set_point1(int x, int y, PN_float32 point)
Replaces the 1-component point value at the indicated point.
LPoint3f & modify_point3(int x, int y)
Returns a modifiable 3-component point value at the indicated point.
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
PN_float32 get_channel(int x, int y, int c) const
Returns the cth channel of the point value at the indicated point.
bool has_no_data_value() const
Returns whether a "no data" value has been established by set_no_data_value().
This is the base class for all two-component vectors and points.
void fill(PN_float32 value)
Fills the table with all of the same value.
This is the base class for all three-component vectors and points.
void set_point(int x, int y, const LVecBase3f &point)
Replaces the 3-component point value at the indicated point.
static const LPoint2f & zero()
Returns a zero-length point.
PN_float32 get_scale() const
The "scale" is reported in the pfm header and is probably meaningless.
void set_channel(int x, int y, int c, PN_float32 value)
Replaces the cth channel of the point value at the indicated point.
This is the base class for all three-component vectors and points.
bool has_no_data_threshold() const
Returns whether a "no data" threshold value has been established by set_no_data_threshold().
void xform(const LMatrix4f &transform)
Applies the indicated transform matrix to all points in-place.
This is a four-component point in space.
LPoint3f & modify_point(int x, int y)
Returns a modifiable 3-component point value at the indicated point.
void set_zero_special(bool zero_special)
Sets the zero_special flag.
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
void clear_no_data_value()
Removes the special value that means "no data" when it appears in the pfm file.
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
This is a two-component point in space.
void set_no_data_threshold(const LPoint4f &no_data_value)
Sets the special threshold value.
LPoint2f & modify_point2(int x, int y)
Returns a modifiable 2-component point value at the indicated point.
bool calc_autocrop(int &x_begin, int &x_end, int &y_begin, int &y_end) const
Computes the minimum range of x and y across the PFM file that include all points.
This defines a bounding convex hexahedron.
const LPoint4f & get_no_data_value() const
If has_no_data_value() returns true, this returns the particular "no data" value. ...
void set_no_data_value(const LPoint4f &no_data_value)
Sets the special value that means "no data" when it appears in the pfm file.