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 /
18 rasdaman 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 {
227 public:
229  using AreaType = r_Area;
231 
233  r_Minterval(const r_Point &low, const r_Point &high);
235  explicit r_Minterval(r_Dimension);
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 
265  const r_Sinterval &operator[](r_Dimension) const;
266 
268  const r_Sinterval &at(r_Dimension) const;
269 
272 
275 
276  const r_Sinterval &at_unsafe(r_Dimension dim) const;
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 
304  r_Dimension dimension() const;
305 
307  bool is_scalar() const noexcept;
308 
311  r_Point get_origin() const;
312 
315  r_Point get_high() const;
316 
319  r_Point get_extent() const;
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 
341  void set_axis_names(const r_Minterval &o);
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:
375 
380 
384  r_Minterval &translate(const r_Point &);
385 
389  r_Minterval create_translation(const r_Point &) const;
391 
392  // Methods for scaling:
394  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  r_Minterval &union_of(const r_Minterval &, const r_Minterval &);
413  r_Minterval &operator+=(const r_Minterval &);
415  r_Minterval create_union(const r_Minterval &) const;
417  r_Minterval operator+(const r_Minterval &) const;
419 
420  // Methods/Operators for the difference operation:
427  r_Minterval &operator-=(const r_Minterval &);
431  r_Minterval operator-(const r_Minterval &) const;
433 
434  // Methods/Operators for the intersection operation:
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  r_Minterval &closure_of(const r_Minterval &, const r_Minterval &);
459  r_Minterval create_closure(const r_Minterval &) const;
462  std::vector<r_Minterval> extension_of(const r_Minterval &big) const;
464 
465  // Methods/Operators for dimension-specific operations involving projections:
467  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 
479  char *get_string_representation() const;
480 
482  std::string to_string() const;
483 
484  // Methods for internal use only:
486  r_Area cell_count() const;
489  r_Area cell_offset(const r_Point &) const;
491  r_Area cell_offset_unsafe(const r_Point &) const;
493  r_Point cell_point(r_Area) const;
494 
496  void add_dimension();
502  void delete_non_trims(const std::vector<bool> &trims);
504  void delete_slices();
507  void append_axes(const r_Minterval &mint);
510  void append_axes(const r_Point &pnt);
512  bool is_point() const noexcept;
513 
515  r_Bytes get_storage_size() const;
516 
519  r_Dimension get_trim_count() const;
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 
533 protected:
535  std::vector<r_Sinterval> intervals;
536 
542 
544  void constructorinit(char *);
545 };
546 
547 //@ManMemo: Module: {\bf raslib}
551 extern std::ostream &operator<<(std::ostream &s, const r_Minterval &d);
552 extern std::ostream &operator<<(std::ostream &s, const std::vector<r_Minterval> &d);
553 extern std::ostream &operator<<(std::ostream &s, const std::vector<double> &doubleVec);
554 
555 #endif
r_Minterval::get_origin
r_Point get_origin() const
Returns a point with the minimum coordinates in all dimensions.
mddtypes.hh
r_Minterval::create_intersection
r_Minterval create_intersection(const r_Minterval &) const
Same as intersection_with but return a new minterval instead of modifying this one.
r_Dimension
std::uint32_t r_Dimension
number of dimensions in r_Point and r_Minterval.
Definition: mddtypes.hh:56
r_Minterval::validateDomainExtents
void validateDomainExtents(const r_Minterval &b) const
throw error if domains differ in the extents of any axis.
r_Minterval::OffsetType
r_Sinterval::OffsetType OffsetType
Definition: minterval.hh:230
r_Minterval::is_fixed
bool is_fixed() const noexcept
Returns true if all intervals are fixed.
r_Minterval::set_axis_names
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_Minterval::union_with
r_Minterval & union_with(const r_Minterval &)
Union of argument with this minterval.
r_Minterval::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...
r_Minterval::operator[]
const r_Sinterval & operator[](r_Dimension) const
read access the i-th interval
r_Minterval::split_equal
std::vector< r_Minterval > split_equal(int n)
Split into n smaller mintervals.
point.hh
r_Minterval::project_along_dims
r_Minterval project_along_dims(const std::vector< r_Dimension > &) const
the vector of projection dimensions can have more values than this->dimensionality
r_Minterval::equal_extents
bool equal_extents(const r_Minterval &other) const
Return true if the extents of each dimension are equal, otherwise false.
r_Minterval::is_mergeable
bool is_mergeable(const r_Minterval &other) const
This method checks if two r_Mintervals are "mergeable" side by side.
r_Minterval::get_axis_names
std::vector< std::string > get_axis_names() const
r_Minterval::get_high
r_Point get_high() const
Returns a point with the maximum coordinates in all dimensions.
r_Minterval::intervals
std::vector< r_Sinterval > intervals
axis intervals, intervals.size() == dimension()
Definition: minterval.hh:535
r_Minterval::get_string_representation
char * get_string_representation() const
Returns a string representation of this minterval as a pointer that should eventually be deallocated ...
r_Minterval::has_slices
bool has_slices() const
r_Minterval::cell_offset
r_Area cell_offset(const r_Point &) const
calculate offset in cells for one dimensional access (dimension ordering is high first)
r_Sinterval::OffsetType
size_t OffsetType
Definition: sinterval.hh:217
r_Minterval::add_dimension
void add_dimension()
add dimension with open bounds
r_Bytes
size_t r_Bytes
number of bytes in an tile or mdd or type.
Definition: mddtypes.hh:43
r_Minterval::create_union
r_Minterval create_union(const r_Minterval &) const
Same as union_with but return a new minterval instead of modifying this one.
r_Minterval::operator!=
bool operator!=(const r_Minterval &) const
non equal operator - negation of equal operator
r_Minterval::is_scalar
bool is_scalar() const noexcept
r_Minterval::cell_point
r_Point cell_point(r_Area) const
calculate point index out of offset
r_Minterval::difference_of
r_Minterval & difference_of(const r_Minterval &, const r_Minterval &)
Return new minterval as difference of the argument mintervals.
r_Minterval::DimType
r_Dimension DimType
Definition: minterval.hh:228
r_Minterval::~r_Minterval
~r_Minterval()=default
default destructor
r_Minterval::fromPoint
static r_Minterval fromPoint(const r_Point &p)
construct minterval of slices from the given point p
r_Minterval::scale_of
std::vector< double > scale_of(const r_Minterval &op) const
r_Minterval::is_point
bool is_point() const noexcept
r_Point
Class r_Point represents an n-dimensional point vector.
Definition: point.hh:42
r_Minterval::AreaType
r_Area AreaType
Definition: minterval.hh:229
r_Minterval::scale
r_Minterval & scale(const double &)
Scales all extents by factor.
r_Range
std::int64_t r_Range
for axis indexing, e.g.
Definition: mddtypes.hh:53
r_Minterval::inside_of
bool inside_of(const r_Minterval &) const
Check whether one interval is within another.
r_Minterval::compareDomainExtents
bool compareDomainExtents(const r_Minterval &b) const
r_Minterval::at_unsafe
const r_Sinterval & at_unsafe(r_Dimension dim) const
r_Minterval::at
const r_Sinterval & at(r_Dimension) const
read access the i-th interval with bound checking
r_Minterval::cell_offset_unsafe
r_Area cell_offset_unsafe(const r_Point &) const
as above, but without error checking, for performance
r_Minterval::create_difference
r_Minterval create_difference(const r_Minterval &) const
Same as difference_with but return a new minterval instead of modifying this one.
r_Minterval::r_Minterval
r_Minterval()=default
default constructor
r_Minterval::get_storage_size
r_Bytes get_storage_size() const
calculate the size of the storage space occupied
r_Minterval::is_origin_fixed
bool is_origin_fixed() const noexcept
Returns true if all lower bounds are fixed, otherwise false.
r_Minterval::touches
bool touches(const r_Minterval &o) const
Determines if this minterval touches given minterval.
r_Minterval::intersects_with
bool intersects_with(const r_Minterval &) const
Determines if the self minterval intersects with the argument one.
r_Minterval::print_status
void print_status(std::ostream &s) const
Serialize the object to the specified stream.
r_Minterval::get_trim_count
r_Dimension get_trim_count() const
r_Minterval::create_scale
r_Minterval create_scale(const double &) const
Returns new interval as scaled from this by factor.
r_Minterval::extension_of
std::vector< r_Minterval > extension_of(const r_Minterval &big) const
r_Minterval::axis_names_match
bool axis_names_match(const r_Minterval &o) const
operator<<
std::ostream & operator<<(std::ostream &s, const r_Minterval &d)
Output stream operator for objects of type const r_Minterval.
r_Minterval::to_string
std::string to_string() const
Returns a string representation of this minterval as a string object.
r_Minterval::cell_count
r_Area cell_count() const
calculate number of cells
r_Minterval::create_translation
r_Minterval create_translation(const r_Point &) const
Returns new interval as translation of this by a point.
r_Minterval::create_reverse_translation
r_Minterval create_reverse_translation(const r_Point &) const
Returns new interval as translation of this by a point.
r_Minterval::streamInitCnt
r_Dimension streamInitCnt
The minterval can be initialized in all dimensions as follows: minterval << sinterval1 << sinterval2 ...
Definition: minterval.hh:541
r_Minterval::operator<<
r_Minterval & operator<<(const r_Sinterval &)
for stream initializing with intervals
r_Minterval::create_closure
r_Minterval create_closure(const r_Minterval &) const
Same as closure_with but return a new minterval instead of modifying this one.
r_Minterval::trim_along_slice
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_Minterval::covers
bool covers(const r_Point &pnt) const
Does this interval cover the given point.
r_Minterval::get_extent
r_Point get_extent() const
Get size of minterval as point.
r_Minterval::closure_of
r_Minterval & closure_of(const r_Minterval &, const r_Minterval &)
Return new minterval as closure of the argument mintervals.
r_Minterval::constructorinit
void constructorinit(char *)
initialization for constructors which take chars
r_Minterval::difference_with
r_Minterval & difference_with(const r_Minterval &)
Difference of argument with this minterval.
r_Minterval::operator=
r_Minterval & operator=(r_Minterval &&other)=default
move assignment
r_Minterval::computeDomainOfResult
r_Minterval computeDomainOfResult(const r_Minterval &b) const
r_Minterval
The spatial domain of an MDD is represented by an object of class r_Minterval.
Definition: minterval.hh:225
r_Minterval::union_of
r_Minterval & union_of(const r_Minterval &, const r_Minterval &)
Return new minterval as union of the argument mintervals.
r_Minterval::delete_dimension
void delete_dimension(r_Dimension)
delete the specified dimension
r_Minterval::dimension
r_Dimension dimension() const
get dimensionality
r_Minterval::append_axes
void append_axes(const r_Minterval &mint)
append mint's intervals to the end of this minterval, resulting in [ ..., mint[0],...
r_Area
std::uint64_t r_Area
number of cells in an mdd object or tile.
Definition: mddtypes.hh:49
r_Minterval::intersection_with
r_Minterval & intersection_with(const r_Minterval &)
Intersection of argument with this minterval.
r_Minterval::delete_non_trims
void delete_non_trims(const std::vector< bool > &trims)
delete slices (false values in trims); does nothing if trims size != dimension
r_Minterval::has_axis_names
bool has_axis_names() const
r_Minterval::intersection_of
r_Minterval & intersection_of(const r_Minterval &, const r_Minterval &)
Return new minterval as intersection of the argument mintervals.
r_Minterval::is_high_fixed
bool is_high_fixed() const noexcept
Returns true if all upper bounds are fixed, otherwise false.
r_Sinterval
The class represents an interval with lower and upper bound.
Definition: sinterval.hh:213
sinterval.hh
r_Minterval::reverse_translate
r_Minterval & reverse_translate(const r_Point &)
Subtracts respective coordinate of a point to the lower bounds of an interval.
r_Minterval::translate
r_Minterval & translate(const r_Point &)
Translates this by a point.
r_Minterval::closure_with
r_Minterval & closure_with(const r_Minterval &)
Closure of argument with this minterval.
r_Minterval::delete_slices
void delete_slices()
delete intervals which are slices (i.e. interval.is_slice() is true)
r_Minterval::swap_dimensions
void swap_dimensions(r_Dimension d1, r_Dimension d2)
swap dimensions