26 o <<
"***************" << std::endl;
27 o <<
"a_unit_system:" << std::endl;
28 o <<
"***************" << std::endl;
29 o <<
"This is a 'a_unit_system' class" << std::endl;
31 o <<
"Create a unit system:" << std::endl;
32 o <<
"a_unit_system s" << std::endl;
34 o <<
"Commands:" << std::endl;
35 o <<
"name _name: set name of system of units" << std::endl;
36 o <<
"name: get name of system of units" << std::endl;
37 o <<
"decimals1 _val: set number of decimals in 1D" << std::endl;
38 o <<
"decimals1: get number of decimals in 1D" << std::endl;
39 o <<
"decimals2 _val: set number of decimals in 2D" << std::endl;
40 o <<
"decimals2: get number of decimals in 2D" << std::endl;
41 o <<
"addlevel1 _unit: add a unit to 1D unit set" << std::endl;
42 o <<
"addlevel2 _unit: add a unit to 2D unit set" << std::endl;
43 o <<
"level1: get pointer to a unit of the 1D unit set" << std::endl;
44 o <<
"level2: get pointer to a unit of the 2D unit set" << std::endl;
45 o <<
"dim1 _val: format a 1D measure" << std::endl;
46 o <<
"dim1_det _val: format a 1D measure (+ system name)" << std::endl;
47 o <<
"dim2 _val: format a 2D measure" << std::endl;
48 o <<
"dim2_det _val: format a 2D measure (+ system name)" << std::endl;
49 o <<
"dim1 _point: format a point" << std::endl;
50 o <<
"print: set parameters" << std::endl;
51 o <<
"read _file: read parameters from file" << std::endl;
52 o <<
"write _file: write parameters to file" << std::endl;
64 for (
int i=0; i<n; i++)
72 for (
int i=0; i<n; i++)
83 o << this->
name() << std::endl;
86 for (
int i=0; i<n1; i++)
87 o <<
level1(i) << std::endl;
91 for (
int i=0; i<n2; i++)
92 o <<
level2(i) << std::endl;
98 for (std::deque<a_unit *>::iterator u =
levels1_.begin(); u <
levels1_.end(); u++)
101 for (std::deque<a_unit *>::iterator u =
levels2_.begin(); u <
levels2_.end(); u++)
121 for (
int tel = 0; tel < u.
levels1(); tel++)
127 for (
int tel = 0; tel < u.
levels2(); tel++)
141 double r = u.
ratio();
142 for (std::deque<a_unit *>::iterator it=
levels1_.begin(); it<
levels1_.end(); it++)
144 if ((*it)->ratio()>r)
155 double r = u.
ratio();
156 for (std::deque<a_unit *>::iterator it=
levels2_.begin(); it<
levels2_.end(); it++)
158 if ((*it)->ratio()>r)
169 double rem = fabs(v);
170 std::ostringstream s;
173 for (
int tel = 0; tel < num; tel++)
178 v1 = rem*unit->
ratio();
180 rem -= v0/unit->
ratio();
181 if ((v0 != 0)||(tel == num-1))
185 s << std::fixed << std::setprecision(
decimals1_);
186 s << v0+rem*unit->
ratio();
198 std::ostringstream s;
199 s << this->
dim1(p.
x()) <<
" " << this->
dim1(p.
y()) <<
" " << this->
dim1(p.
z());
205 std::string s0 =
dim1(v);
206 std::ostringstream s;
207 s <<
"[" << this->
name() <<
"]";
213 double rem = fabs(v);
214 std::ostringstream s;
217 for (
int tel = 0; tel < num; tel++)
222 v1 = rem*unit->
ratio();
224 rem -= v0/unit->
ratio();
225 if ((v0 != 0)||(tel == num-1))
229 s << std::fixed << std::setprecision(
decimals2_);
230 s << v0+rem*unit->
ratio();
242 std::string s0 =
dim2(v);
243 std::ostringstream s;
244 s <<
"[" << this->
name() <<
"]";
static const std::string help()
virtual void write(std::ostream &o) const
std::string dim2_det(const double v)
void addlevel2(a_unit &u)
void decimals1(const int val)
a_unit * level1(int n) const
std::deque< a_unit * > levels1_
static const std::string help()
std::string dim1_det(const double v)
std::string dim1(const double v)
void addlevel1(a_unit &u)
std::deque< a_unit * > levels2_
void name(const std::string name)
virtual void read(std::istream &i)
void decimals2(const int val)
std::string dim2(const double v)
a_unit * level2(int n) const
std::string short_name() const
std::cin getline(buf, 256)