source: src/base/index.cpp@ 66f24d

Last change on this file since 66f24d was 48b662, checked in by Olaf Lenz <olenz@…>, 14 years ago

Moved files in scafacos_fcs one level up.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@847 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 * @file index.cpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Mon Apr 18 12:19:16 2011
5 *
6 */
7
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
12#include "base/index.hpp"
13#include "base/stencil.hpp"
14#include "base/vector.hpp"
15
16using namespace VMG;
17
18Index::Index(const Vector& vec)
19{
20 i[0] = static_cast<int>(vec.X());
21 i[1] = static_cast<int>(vec.Y());
22 i[2] = static_cast<int>(vec.Z());
23}
24
25Index::Index(const Stencil::iterator& iter)
26{
27 i[0] = iter->m;
28 i[1] = iter->n;
29 i[2] = iter->o;
30}
31
32const Vector Index::operator+(const Vector& rhs) const
33{
34 return Vector(*this) += rhs;
35}
36
37const Vector Index::operator-(const Vector& rhs) const
38{
39 return Vector(*this) -= rhs;
40}
41
42const Vector Index::operator*(const Vector& rhs) const
43{
44 return Vector(*this) *= rhs;
45}
46
47const Vector Index::operator/(const Vector& rhs) const
48{
49 return Vector(*this) /= rhs;
50}
51
52const Vector Index::operator+(const vmg_float& rhs) const
53{
54 return Vector(*this) += rhs;
55}
56
57const Vector Index::operator-(const vmg_float& rhs) const
58{
59 return Vector(*this) -= rhs;
60}
61
62const Vector Index::operator*(const vmg_float& rhs) const
63{
64 return Vector(*this) *= rhs;
65}
66
67const Vector Index::operator/(const vmg_float& rhs) const
68{
69 return Vector(*this) /= rhs;
70}
71
72bool operator<(const Index& lhs, const Index& rhs)
73{
74 if (lhs.X() < rhs.X())
75 return true;
76 else if (lhs.X() > rhs.X())
77 return false;
78
79 if (lhs.Y() < rhs.Y())
80 return true;
81 else if (lhs.Y() > rhs.Y())
82 return false;
83
84 if (lhs.Z() < rhs.Z())
85 return true;
86 else
87 return false;
88}
89
90const Index Max(const Index& index1, const Index& index2)
91{
92 return Index(std::max(index1.X(), index2.X()), std::max(index1.Y(), index2.Y()), std::max(index1.Z(), index2.Z()));
93}
94
95std::ostream& operator<<(std::ostream& out, const Index& base)
96{
97 return out << "{" << base.X() << " " << base.Y() << " " << base.Z() << "}";
98}
Note: See TracBrowser for help on using the repository browser.