rasdaman client API 10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
minterval.hh
Go to the documentation of this file.
1/*
2* This file is part of rasdaman community.
3*
4* Rasdaman community is free software: you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation, either version 3 of the License, or
7* (at your option) any later version.
8*
9* Rasdaman community is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16*
17* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18rasdaman GmbH.
19*
20* For more information please see <http://www.rasdaman.org>
21* or contact Peter Baumann via <baumann@rasdaman.com>.
22*/
23
24#ifndef D_MINTERVAL_HH
25#define D_MINTERVAL_HH
26
27#include "raslib/sinterval.hh"
28#include "raslib/point.hh"
29#include "raslib/mddtypes.hh" // for r_Dimension, r_Area, r_Bytes, r_Range
30
31#include <iosfwd> // for ostream, cout
32#include <string> // for string
33#include <vector> // for vector
34
35//@ManMemo: Module: {\bf raslib}
226{
227public:
231
233 r_Minterval(const r_Point &low, const r_Point &high);
237 explicit r_Minterval(const char *);
239 explicit r_Minterval(char *);
241 explicit r_Minterval(std::vector<r_Sinterval> intervals);
247 static r_Minterval fromPoint(const r_Point &p);
248
250 r_Minterval() = default;
252 ~r_Minterval() = default;
253
255 r_Minterval(r_Minterval &&other) = default;
257 r_Minterval &operator=(r_Minterval &&other) = default;
258
260 r_Minterval(const r_Minterval &other) = default;
262 r_Minterval &operator=(const r_Minterval &other) = default;
263
266
269
272
275
278
281 bool operator==(const r_Minterval &) const;
282
284 bool operator!=(const r_Minterval &) const;
285
287 bool equal_extents(const r_Minterval &other) const;
288
291 bool covers(const r_Point &pnt) const;
292
295 bool covers(const r_Minterval &inter) const;
296
298 bool inside_of(const r_Minterval &) const;
299
301 std::vector<r_Minterval> split_equal(int n);
302
305
307 bool is_scalar() const noexcept;
308
312
316
320
322 bool is_origin_fixed() const noexcept;
323
325 bool is_high_fixed() const noexcept;
326
328 bool is_fixed() const noexcept;
329
332 std::vector<std::string> get_axis_names() const;
333
337 void set_axis_names(std::vector<std::string> axis_names);
338
342
345 bool axis_names_match(const r_Minterval &o) const;
346
348 bool has_axis_names() const;
349
368 bool is_mergeable(const r_Minterval &other) const;
369
370 // Methods for translation:
372
375
380
385
391
392 // Methods for scaling:
394
395 r_Minterval &scale(const double &);
397 r_Minterval &scale(const std::vector<double> &);
399 r_Minterval create_scale(const double &) const;
401 r_Minterval create_scale(const std::vector<double> &) const;
403 std::vector<double> scale_of(const r_Minterval &op) const;
405
406 // Methods/Operators for the union operation:
408
413 r_Minterval &operator+=(const r_Minterval &);
417 r_Minterval operator+(const r_Minterval &) const;
419
420 // Methods/Operators for the difference operation:
422
427 r_Minterval &operator-=(const r_Minterval &);
431 r_Minterval operator-(const r_Minterval &) const;
433
434 // Methods/Operators for the intersection operation:
436
441 r_Minterval &operator*=(const r_Minterval &);
445 r_Minterval operator*(const r_Minterval &) const;
447 bool intersects_with(const r_Minterval &) const;
449 bool touches(const r_Minterval &o) const;
451
452 // Methods/Operators for the closure operation:
454
462 std::vector<r_Minterval> extension_of(const r_Minterval &big) const;
464
465 // Methods/Operators for dimension-specific operations involving projections:
467
469 r_Minterval trim_along_slice(const r_Minterval &, const std::vector<r_Dimension> &) const;
471 r_Minterval project_along_dims(const std::vector<r_Dimension> &) const;
473
475 void print_status(std::ostream &s) const;
476
480
482 std::string to_string() const;
483
484 // Methods for internal use only:
486
489 r_Area cell_offset(const r_Point &) const;
494
502 void delete_non_trims(const std::vector<bool> &trims);
507 void append_axes(const r_Minterval &mint);
510 void append_axes(const r_Point &pnt);
512 bool is_point() const noexcept;
513
516
520
522 bool has_slices() const;
523
525 bool compareDomainExtents(const r_Minterval &b) const;
527 void validateDomainExtents(const r_Minterval &b) const;
528
532
533protected:
535 std::vector<r_Sinterval> intervals;
536
542
544 void constructorinit(char *);
545};
546
547//@ManMemo: Module: {\bf raslib}
551extern std::ostream &operator<<(std::ostream &s, const r_Minterval &d);
552extern std::ostream &operator<<(std::ostream &s, const std::vector<r_Minterval> &d);
553extern std::ostream &operator<<(std::ostream &s, const std::vector<double> &doubleVec);
554
555#endif
The spatial domain of an MDD is represented by an object of class r_Minterval.
Definition minterval.hh:226
const r_Sinterval & at_unsafe(r_Dimension dim) const
r_Minterval & operator=(const r_Minterval &other)=default
copy assignment
bool operator!=(const r_Minterval &) const
non equal operator - negation of equal operator
bool operator==(const r_Minterval &) const
Two domains are equal if they have the same number of dimensions and each dimension has the same lowe...
void constructorinit(char *)
initialization for constructors which take chars
r_Area cell_offset(const r_Point &) const
calculate offset in cells for one dimensional access (dimension ordering is high first)
std::string to_string() const
Returns a string representation of this minterval as a string object.
const r_Sinterval & at(r_Dimension) const
read access the i-th interval with bound checking
void delete_dimension(r_Dimension)
delete the specified dimension
r_Minterval project_along_dims(const std::vector< r_Dimension > &) const
the vector of projection dimensions can have more values than this->dimensionality
bool covers(const r_Point &pnt) const
Does this interval cover the given point.
r_Point get_high() const
Returns a point with the maximum coordinates in all dimensions.
bool axis_names_match(const r_Minterval &o) const
std::vector< r_Sinterval > intervals
axis intervals, intervals.size() == dimension()
Definition minterval.hh:535
r_Minterval create_difference(const r_Minterval &) const
Same as difference_with but return a new minterval instead of modifying this one.
r_Minterval & intersection_with(const r_Minterval &)
Intersection of argument with this minterval.
r_Area AreaType
Definition minterval.hh:229
void validateDomainExtents(const r_Minterval &b) const
throw error if domains differ in the extents of any axis.
r_Minterval create_reverse_translation(const r_Point &) const
Returns new interval as translation of this by a point.
bool is_origin_fixed() const noexcept
Returns true if all lower bounds are fixed, otherwise false.
r_Area cell_offset_unsafe(const r_Point &) const
as above, but without error checking, for performance
r_Minterval & closure_with(const r_Minterval &)
Closure of argument with this minterval.
r_Dimension DimType
Definition minterval.hh:228
r_Minterval computeDomainOfResult(const r_Minterval &b) const
bool is_fixed() const noexcept
Returns true if all intervals are fixed.
r_Minterval trim_along_slice(const r_Minterval &, const std::vector< r_Dimension > &) const
the vector of projection dimensions cannot have more values than dimension() this should really be ca...
r_Dimension get_trim_count() const
r_Dimension streamInitCnt
The minterval can be initialized in all dimensions as follows: minterval << sinterval1 << sinterval2 ...
Definition minterval.hh:541
bool is_high_fixed() const noexcept
Returns true if all upper bounds are fixed, otherwise false.
bool intersects_with(const r_Minterval &) const
Determines if the self minterval intersects with the argument one.
r_Minterval & difference_of(const r_Minterval &, const r_Minterval &)
Return new minterval as difference of the argument mintervals.
r_Sinterval::OffsetType OffsetType
Definition minterval.hh:230
bool is_scalar() const noexcept
r_Minterval create_translation(const r_Point &) const
Returns new interval as translation of this by a point.
bool inside_of(const r_Minterval &) const
Check whether one interval is within another.
r_Minterval create_intersection(const r_Minterval &) const
Same as intersection_with but return a new minterval instead of modifying this one.
r_Minterval(r_Dimension)
constructor getting dimensionality for stream initializing
bool is_point() const noexcept
r_Minterval(std::vector< r_Sinterval > intervals)
construct from interval axes
r_Point cell_point(r_Area) const
calculate point index out of offset
bool equal_extents(const r_Minterval &other) const
Return true if the extents of each dimension are equal, otherwise false.
std::vector< r_Minterval > extension_of(const r_Minterval &big) const
r_Minterval & operator<<(r_Range)
for stream initializing with point intervals
bool is_mergeable(const r_Minterval &other) const
This method checks if two r_Mintervals are "mergeable" side by side.
void delete_non_trims(const std::vector< bool > &trims)
delete slices (false values in trims); does nothing if trims size != dimension
r_Minterval & scale(const double &)
Scales all extents by factor.
r_Minterval & intersection_of(const r_Minterval &, const r_Minterval &)
Return new minterval as intersection of the argument mintervals.
r_Sinterval & operator[](r_Dimension)
write access the i-th interval
const r_Sinterval & operator[](r_Dimension) const
read access the i-th interval
r_Bytes get_storage_size() const
calculate the size of the storage space occupied
static r_Minterval fromPoint(const r_Point &p)
construct minterval of slices from the given point p
char * get_string_representation() const
Returns a string representation of this minterval as a pointer that should eventually be deallocated ...
r_Minterval & operator=(r_Minterval &&other)=default
move assignment
bool has_axis_names() const
r_Minterval create_scale(const double &) const
Returns new interval as scaled from this by factor.
bool covers(const r_Minterval &inter) const
Does this interval cover the given interval.
r_Minterval & operator<<(const r_Sinterval &)
for stream initializing with intervals
r_Minterval & union_with(const r_Minterval &)
Union of argument with this minterval.
r_Minterval & union_of(const r_Minterval &, const r_Minterval &)
Return new minterval as union of the argument mintervals.
void delete_slices()
delete intervals which are slices (i.e. interval.is_slice() is true)
std::vector< double > scale_of(const r_Minterval &op) const
r_Minterval create_union(const r_Minterval &) const
Same as union_with but return a new minterval instead of modifying this one.
r_Dimension dimension() const
get dimensionality
bool touches(const r_Minterval &o) const
Determines if this minterval touches given minterval.
void swap_dimensions(r_Dimension d1, r_Dimension d2)
swap dimensions
bool compareDomainExtents(const r_Minterval &b) const
~r_Minterval()=default
default destructor
r_Minterval & translate(const r_Point &)
Translates this by a point.
bool has_slices() const
r_Minterval(const r_Point &low, const r_Point &high)
constructor getting a low, high pair
void add_dimension()
add dimension with open bounds
r_Minterval create_closure(const r_Minterval &) const
Same as closure_with but return a new minterval instead of modifying this one.
std::vector< std::string > get_axis_names() const
r_Point get_extent() const
Get size of minterval as point.
void set_axis_names(std::vector< std::string > axis_names)
set new axis names to the underlying sintervals; the size of the axis_names vector must match the dim...
r_Point get_origin() const
Returns a point with the minimum coordinates in all dimensions.
r_Minterval(const char *)
constructor taking string representation (e.g. [ 1:255, *:200, *:* ])
r_Sinterval & at(r_Dimension)
write access the i-th interval with bound checking
r_Minterval & reverse_translate(const r_Point &)
Subtracts respective coordinate of a point to the lower bounds of an interval.
r_Minterval(char *)
constructor taking string representation (e.g. [ 1:255, *:200, *:* ])
r_Minterval()=default
default constructor
r_Minterval(r_Minterval &&other)=default
move constructor
r_Sinterval & at_unsafe(r_Dimension dim)
r_Minterval & difference_with(const r_Minterval &)
Difference of argument with this minterval.
std::vector< r_Minterval > split_equal(int n)
Split into n smaller mintervals.
void append_axes(const r_Minterval &mint)
append mint's intervals to the end of this minterval, resulting in [ ..., mint[0],...
r_Minterval & closure_of(const r_Minterval &, const r_Minterval &)
Return new minterval as closure of the argument mintervals.
r_Area cell_count() const
calculate number of cells
void print_status(std::ostream &s) const
Serialize the object to the specified stream.
r_Minterval(const r_Minterval &other)=default
copy constructor
Class r_Point represents an n-dimensional point vector.
Definition point.hh:43
The class represents an interval with lower and upper bound.
Definition sinterval.hh:214
size_t OffsetType
Definition sinterval.hh:217
std::int64_t r_Range
for axis indexing, e.g.
Definition mddtypes.hh:53
std::uint32_t r_Dimension
number of dimensions in r_Point and r_Minterval.
Definition mddtypes.hh:56
size_t r_Bytes
number of bytes in an tile or mdd or type.
Definition mddtypes.hh:43
std::uint64_t r_Area
number of cells in an mdd object or tile.
Definition mddtypes.hh:49
std::ostream & operator<<(std::ostream &s, const r_Minterval &d)
Output stream operator for objects of type const r_Minterval.