MCell - Interface (abstract) class for all the cell shapes.
More...
#include <MCell.h>
|
double | MCellVolume {} |
| MCellVolume - stores the volume of the cell, can not be set by accessors. More...
|
|
double | MCellWeight {} |
| MCellWeight - stores the weight of the cell, can not be set by accessors.
|
|
const long int | MCellID |
| MCellDensity - stores the density of the cell, , can not be set by accessors.
|
|
std::vector< std::shared_ptr< MVector > > | MCellVertices |
| holds a vector of MVectors defining the vertex of the cell More...
|
|
std::vector< unsigned int > | vertexIDs |
| holds a list of all the vertices IDs, populated on construction More...
|
|
std::shared_ptr< MMaterial > | MCellMaterial |
| holds a the material of the cell
|
|
std::shared_ptr< MVector > | MCellCOG |
| holds the Centre Of Gravity of the cell as a shared pointer MVector More...
|
|
MCellType_TypeDef | MCellType |
| MCellType - holds the type of the current cell.
|
|
|
std::ostream & | operator<< (std::ostream &os, const MCell &mCell) |
| Unsure if useful. should perform deep (not shallow) copy to avoid accidental freeing. More...
|
|
std::ofstream & | operator<< (std::ofstream &os, const MCell &mCell) |
| classic friend overloaded ofstream operator<< declaration - prints MCell properties to file in Model Loader parser format More...
|
|
MCell - Interface (abstract) class for all the cell shapes.
MCell::MCell |
( |
std::vector< std::shared_ptr< MVector >> |
vertices, |
|
|
std::shared_ptr< MMaterial > |
material, |
|
|
long int |
id |
|
) |
| |
|
explicitprotected |
MCell constructor.
- Parameters
-
vertices | - the vertex defining the cell |
material | - material of the cell |
id | - unique cell identifier |
- Note
- Protected accessibility because MCell is an abstract class. Explicit because Derived class should not be able to hardcode ID - it should come straight from the data file
default constructor - deleted
- Note
- No such thing as anonymous (ID - less) cells should exist
virtual std::shared_ptr<MVector> MCell::calcCentreOfGrav |
( |
| ) |
const |
|
protectedpure virtual |
calculates centre of gravity of the cell
- Returns
- shared pointer to anonymous (ID - less) 3D MVector
This should probably return weak_ptr - shared_ptr has more overhead. We dont care about the freeing differences as calc* functions are only called internally so at least one instance will exist if the method was called
virtual double MCell::calcVolume |
( |
| ) |
const |
|
protectedpure virtual |
calculates volume of the cell
- Returns
- scalar volume of the cell in same unit as cell vectors
- Note
- requires shape specific knowledge is to be implemented by derived classes (Pure Virtual)
virtual double MCell::calcWeight |
( |
| ) |
const |
|
protectedpure virtual |
calculates weight of the cell
- Returns
- scalar weight of the cell - unit dependant on volume and density
: This one does NOT need to be virtual.
std::shared_ptr< MVector > MCell::getCentreOfGrav |
( |
| ) |
const |
get MCellCOG (accessor)
- Returns
- shared pointer to anonymous (ID - less) 3D MVector instance
double MCell::getCount |
( |
| ) |
|
|
static |
get MCellInstanceCount (accessor)
- Returns
- MCellInstanceCount copy
double MCell::getID |
( |
| ) |
const |
get MCellID (accessor)
- Returns
- MCellID copy
std::shared_ptr< MMaterial > MCell::getMaterial |
( |
| ) |
const |
get MCellMaterial (accessor)
- Returns
- shared pointer to Material instance
std::vector< std::string > MCell::getType |
( |
| ) |
const |
get MCellType (accessor)
- Returns
- Vector of two strings, first element in file format, second in human readable format
: Implement Compile Time Evaluated mapping, maybe use constexpr array.
const std::vector< unsigned int > & MCell::getVertexIndices |
( |
| ) |
|
getVertexIndices (accessor)
- Returns
- const reference to vector of unsigned int vector indices
- Note
- : const - Returning a mutable reference bypasses protected visibility (Dangerous)
std::vector< std::shared_ptr< MVector > > MCell::getVertices |
( |
| ) |
const |
get MCellVertices (accessor)
- Returns
- vector of shared pointer to ID represented MVectors
double MCell::getVolume |
( |
| ) |
const |
get MCellVolume (accessor)
- Returns
- MCellVolume copy
double MCell::getWeight |
( |
| ) |
const |
get MCellWeight (accessor)
- Returns
- MCellWeight copy
void MCell::setMaterial |
( |
std::shared_ptr< MMaterial > |
material | ) |
|
set MCellMaterial accesor
: Do we really need these? - These setters are meant to be used to apply transforms on the object (MColor change, rotation, etc), it is unclear at the moment if they are actually needed, as the transformer - the gpu or some other function could access the memory directly through getVectors(). It probably makes more sense for this class to remain as visualization oriented as possible.
See reverted commit b0e030c for a reference on implementing const methods.
- Parameters
-
material | - a shared pointer to Material of the cell |
void MCell::setVertices |
( |
std::vector< std::shared_ptr< MVector >> |
vertices | ) |
|
set MCellMaterial accesor
- Parameters
-
vertices | - a vector a shared pointer to vertex of the cell |
std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const MCell & |
mCell |
|
) |
| |
|
friend |
Unsure if useful. should perform deep (not shallow) copy to avoid accidental freeing.
classic friend overloaded ostream operator<< declaration - prints MCell properties to stdout in human friendly format
- Parameters
-
os | - lhs element [ a.operator<<(b) ], might be std::cout or see return |
mCell | - MCell instance |
- Returns
- os reference for cascading <<
std::ofstream& operator<< |
( |
std::ofstream & |
os, |
|
|
const MCell & |
mCell |
|
) |
| |
|
friend |
classic friend overloaded ofstream operator<< declaration - prints MCell properties to file in Model Loader parser format
- Parameters
-
os | - lhs element [ a.operator<<(b) ], might be std::cout or see return |
mCell | |
- Returns
- os reference for cascading <<
std::shared_ptr<MVector> MCell::MCellCOG |
|
mutableprotected |
holds the Centre Of Gravity of the cell as a shared pointer MVector
- Note
- shared_ptr because Overlapping Cells might share Centre of Gravity
std::vector<std::shared_ptr<MVector> > MCell::MCellVertices |
|
protected |
holds a vector of MVectors defining the vertex of the cell
color? - check with Material. Should be shared_ptr, likely implemented as char array and likely very shared.
double MCell::MCellVolume {} |
|
mutableprotected |
MCellVolume - stores the volume of the cell, can not be set by accessors.
- Note
- Data Members Volume, Weight, Density use default ctors as they are initialized in the derived class immediately and its cleaner syntax to do it here rather than in the Member Initializer List in some ctor.
Mutable as they might need to be updated on the background and I want the accessor interface consistently const to not hint on internals
std::vector<unsigned int> MCell::vertexIDs |
|
protected |
holds a list of all the vertices IDs, populated on construction
- Note
- std::vector<T> reserves space for two elements by default. On push_back(), a new larger (+1) memory space is reserved if the pushed element doesnt fit. This makes push_back() extremely inefficient if enough space is not reserved from the beginning (eg. 100 push_backs on a default constructed std::vector will run 100 malloc and 100 memmove - they are copied to the new memory space after reserving it ).
-
The base constructor however does not know how many elements the vertexIDs vector is going to hold because the base class does not know what cell type is being initialized (although the derived class could pass it a flag) the best approach then is to reserve space in the derived constructor. Note, however, that the derived class constructor body runs after the base class constructor is done - and hence the std::vector is allocating memory twice, once in the base class constructor (space for 2) and once in the derived constructor (space for n). Not ideal, but way better than not reserving, and it keeps code simple by not passing flags to the base ctor.
The documentation for this class was generated from the following files:
- /home/travis/build/KurusView/2020_GROUP_21/include/MCell.h
- /home/travis/build/KurusView/2020_GROUP_21/lib/MCell.cpp