scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | List of all members
scifir::size_3d< float > Class Reference

Specialization class of size_3d<T> that allows to store and calculate size in 3D, with width, height and depth as float types. Initialization string example: "1 * 2 * 4". More...

#include <size_3d.hpp>

Public Member Functions

 size_3d ()
 Default constructor. Initializes width, height and depth to 0.
 
 size_3d (const size_3d< float > &x)
 Copy constructor. The width, height and depth are copied from the size_3d<float> x.
 
 size_3d (size_3d< float > &&x)
 Move constructor. The width, height and depth are moved from the size_3d<float> x.
 
 size_3d (const float &new_width, const float &new_height, const float &new_depth)
 Constructor. width is new_width, height is new_height and depth is new_depth.
 
 size_3d (const string &new_width, const string &new_height, const string &new_depth)
 Constructor. width is new_width, height is new_height and depth is new_depth, they are initialized by string.
 
 size_3d (const string &init_size_3d)
 Constructor. The member-variables are initialized by the initialization string init_size_3d specialized for float.
 
size_3d< float > & operator= (const size_3d< float > &x)
 Copy assignment. The width, height and depth are copied from the size_3d<float> x.
 
size_3d< float > & operator= (size_3d< float > &&x)
 Move assignment. The width, height and depth are moved from the size_3d<float> x.
 
size_3d< float > & operator= (const string &init_size_3d)
 Assignment. The member-variables are initialized by the initialization string init_size_3d specialized for float.
 
size_3d< floatoperator+ (const size_3d< float > &x) const
 Creates a new size_3d<float> by the addition of two size_3d<float> classes. The width, height and depth are the result of the addition of the two width, height and depth of the size_3d<float> classes, respectively.
 
size_3d< floatoperator- (const size_3d< float > &x) const
 Creates a new size_3d<float> by the difference of two size_3d<float> classes. The width, height and depth are the result of the difference of the width, height and depth of the size_3d<float> classes, respectively.
 
void operator+= (const size_3d< float > &x)
 Sums the width of size_3d<float> x to the width, sums the height of size_3d<float> x to the height and sums the depth of size_3d<float> x to the depth.
 
void operator-= (const size_3d< float > &x)
 Substracts the width of size_3d<float> x to the width, substracts the height of size_3d<float> x to the height and substracts the depth of size_3d<float> x to the depth.
 
float get_volume () const
 Calculates the volume as the multiplication of the width, height and depth.
 
string display () const
 Returns a string representation of size_3d<float>, with his width, height and depth.
 

Public Attributes

float width
 Width, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes less, the disadvantage is the lack of dimensions.
 
float height
 Height, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes less, the disadvantage is the lack of dimensions.
 
float depth
 Depth, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes less, the disadvantage is the lack of dimensions.
 

Private Member Functions

void initialize_from_string (const string &init_size_3d)
 Internal function. Initializes the member-variables with an initialization string of size_3d<float>.
 

Detailed Description

Specialization class of size_3d<T> that allows to store and calculate size in 3D, with width, height and depth as float types. Initialization string example: "1 * 2 * 4".

Definition at line 123 of file size_3d.hpp.

Constructor & Destructor Documentation

◆ size_3d() [1/6]

scifir::size_3d< float >::size_3d ( )
inline

Default constructor. Initializes width, height and depth to 0.

Definition at line 126 of file size_3d.hpp.

126 : width(),height(),depth()
127 {}
float depth
Depth, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes le...
Definition size_3d.hpp:206
float height
Height, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes l...
Definition size_3d.hpp:205
float width
Width, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes le...
Definition size_3d.hpp:204

◆ size_3d() [2/6]

scifir::size_3d< float >::size_3d ( const size_3d< float > &  x)
inline

Copy constructor. The width, height and depth are copied from the size_3d<float> x.

Definition at line 129 of file size_3d.hpp.

129 : width(x.width),height(x.height),depth(x.depth)
130 {}

◆ size_3d() [3/6]

scifir::size_3d< float >::size_3d ( size_3d< float > &&  x)
inline

Move constructor. The width, height and depth are moved from the size_3d<float> x.

Definition at line 132 of file size_3d.hpp.

132 : width(std::move(x.width)),height(std::move(x.height)),depth(std::move(x.depth))
133 {}

◆ size_3d() [4/6]

scifir::size_3d< float >::size_3d ( const float new_width,
const float new_height,
const float new_depth 
)
inlineexplicit

Constructor. width is new_width, height is new_height and depth is new_depth.

Definition at line 135 of file size_3d.hpp.

135 : width(new_width),height(new_height),depth(new_depth)
136 {}

◆ size_3d() [5/6]

scifir::size_3d< float >::size_3d ( const string new_width,
const string new_height,
const string new_depth 
)
inlineexplicit

Constructor. width is new_width, height is new_height and depth is new_depth, they are initialized by string.

Definition at line 138 of file size_3d.hpp.

138 : width(stof(new_width)),height(stof(new_height)),depth(stof(new_depth))
139 {}

◆ size_3d() [6/6]

scifir::size_3d< float >::size_3d ( const string init_size_3d)
inlineexplicit

Constructor. The member-variables are initialized by the initialization string init_size_3d specialized for float.

Definition at line 141 of file size_3d.hpp.

141 : size_3d()
142 {
143 initialize_from_string(init_size_3d);
144 }
size_3d()
Default constructor. Initializes width, height and depth to 0.
Definition size_3d.hpp:126
void initialize_from_string(const string &init_size_3d)
Internal function. Initializes the member-variables with an initialization string of size_3d<float>.
Definition size_3d.hpp:209

Member Function Documentation

◆ display()

string scifir::size_3d< float >::display ( ) const
inline

Returns a string representation of size_3d<float>, with his width, height and depth.

Definition at line 197 of file size_3d.hpp.

198 {
199 ostringstream output;
200 output << display_float(width,2) << " * " << display_float(height,2) << " * " << display_float(depth,2);
201 return output.str();
202 }
string display_float(const float &value, int number_of_decimals)
Definition types.cpp:36

◆ get_volume()

float scifir::size_3d< float >::get_volume ( ) const
inline

Calculates the volume as the multiplication of the width, height and depth.

Definition at line 192 of file size_3d.hpp.

193 {
194 return width * height * depth;
195 }

◆ initialize_from_string()

void scifir::size_3d< float >::initialize_from_string ( const string init_size_3d)
inlineprivate

Internal function. Initializes the member-variables with an initialization string of size_3d<float>.

Definition at line 209 of file size_3d.hpp.

210 {
211 vector<string> widths;
212 boost::split(widths,init_size_3d,boost::is_any_of("*"));
213 if (widths.size() == 3)
214 {
215 boost::trim(widths[0]);
216 boost::trim(widths[1]);
217 boost::trim(widths[2]);
218 width = stof(widths[0]);
219 height = stof(widths[1]);
220 depth = stof(widths[2]);
221 }
222 }

◆ operator+()

size_3d< float > scifir::size_3d< float >::operator+ ( const size_3d< float > &  x) const
inline

Creates a new size_3d<float> by the addition of two size_3d<float> classes. The width, height and depth are the result of the addition of the two width, height and depth of the size_3d<float> classes, respectively.

Definition at line 168 of file size_3d.hpp.

169 {
170 return size_3d<float>(width + x.width,height + x.height,depth + x.depth);
171 }

◆ operator+=()

void scifir::size_3d< float >::operator+= ( const size_3d< float > &  x)
inline

Sums the width of size_3d<float> x to the width, sums the height of size_3d<float> x to the height and sums the depth of size_3d<float> x to the depth.

Definition at line 178 of file size_3d.hpp.

179 {
180 width += x.width;
181 height += x.height;
182 depth += x.depth;
183 }

◆ operator-()

size_3d< float > scifir::size_3d< float >::operator- ( const size_3d< float > &  x) const
inline

Creates a new size_3d<float> by the difference of two size_3d<float> classes. The width, height and depth are the result of the difference of the width, height and depth of the size_3d<float> classes, respectively.

Definition at line 173 of file size_3d.hpp.

174 {
175 return size_3d<float>(width - x.width,height - x.height,depth - x.depth);
176 }

◆ operator-=()

void scifir::size_3d< float >::operator-= ( const size_3d< float > &  x)
inline

Substracts the width of size_3d<float> x to the width, substracts the height of size_3d<float> x to the height and substracts the depth of size_3d<float> x to the depth.

Definition at line 185 of file size_3d.hpp.

186 {
187 width -= x.width;
188 height -= x.height;
189 depth -= x.depth;
190 }

◆ operator=() [1/3]

size_3d< float > & scifir::size_3d< float >::operator= ( const size_3d< float > &  x)
inline

Copy assignment. The width, height and depth are copied from the size_3d<float> x.

Definition at line 146 of file size_3d.hpp.

147 {
148 width = x.width;
149 height = x.height;
150 depth = x.depth;
151 return *this;
152 }

◆ operator=() [2/3]

size_3d< float > & scifir::size_3d< float >::operator= ( const string init_size_3d)
inline

Assignment. The member-variables are initialized by the initialization string init_size_3d specialized for float.

Definition at line 162 of file size_3d.hpp.

163 {
164 initialize_from_string(init_size_3d);
165 return *this;
166 }

◆ operator=() [3/3]

size_3d< float > & scifir::size_3d< float >::operator= ( size_3d< float > &&  x)
inline

Move assignment. The width, height and depth are moved from the size_3d<float> x.

Definition at line 154 of file size_3d.hpp.

155 {
156 width = std::move(x.width);
157 height = std::move(x.height);
158 depth = std::move(x.depth);
159 return *this;
160 }

Member Data Documentation

◆ depth

Depth, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes less, the disadvantage is the lack of dimensions.

Definition at line 206 of file size_3d.hpp.

◆ height

Height, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes less, the disadvantage is the lack of dimensions.

Definition at line 205 of file size_3d.hpp.

◆ width

Width, stored as a float. The advantage related to size_3d<float> over size_3d<T> is that it sizes less, the disadvantage is the lack of dimensions.

Definition at line 204 of file size_3d.hpp.


The documentation for this class was generated from the following files: