Skip to content

Commit

Permalink
Making methods const where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Sep 14, 2023
1 parent 0c4ae4c commit 8741c61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/dagmc/DagMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,11 @@ ErrorCode DagMC::next_vol(EntityHandle surface, EntityHandle old_volume,

/* SECTION III: Indexing & Cross-referencing */

EntityHandle DagMC::entity_by_id(int dimension, int id) {
EntityHandle DagMC::entity_by_id(int dimension, int id) const {
return GTT->entity_by_id(dimension, id);
}

int DagMC::id_by_index(int dimension, int index) {
int DagMC::id_by_index(int dimension, int index) const {
EntityHandle h = entity_by_index(dimension, index);
if (!h) return 0;

Expand All @@ -883,7 +883,7 @@ int DagMC::id_by_index(int dimension, int index) {
return result;
}

int DagMC::get_entity_id(EntityHandle this_ent) {
int DagMC::get_entity_id(EntityHandle this_ent) const {
return GTT->global_id(this_ent);
}

Expand Down
18 changes: 9 additions & 9 deletions src/dagmc/DagMC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,16 @@ class DagMC {
*/

/** map from dimension & global ID to EntityHandle */
EntityHandle entity_by_id(int dimension, int id);
EntityHandle entity_by_id(int dimension, int id) const;
/** map from dimension & base-1 ordinal index to EntityHandle */
EntityHandle entity_by_index(int dimension, int index);
EntityHandle entity_by_index(int dimension, int index) const;
/** map from dimension & base-1 ordinal index to global ID */
int id_by_index(int dimension, int index);
int id_by_index(int dimension, int index) const;
/** PPHW: Missing dim & global ID ==> base-1 ordinal index */
/** map from EntityHandle to base-1 ordinal index */
int index_by_handle(EntityHandle handle);
int index_by_handle(EntityHandle handle) const;
/** map from EntityHandle to global ID */
int get_entity_id(EntityHandle this_ent);
int get_entity_id(EntityHandle this_ent) const;

/**\brief get number of geometric sets corresponding to geometry of specified
*dimension
Expand All @@ -282,7 +282,7 @@ class DagMC {
*the dimensionality of the entities in question \return integer number of
*entities of that dimension
*/
unsigned int num_entities(int dimension);
unsigned int num_entities(int dimension) const;

private:
/** get all group sets on the model */
Expand Down Expand Up @@ -564,18 +564,18 @@ class DagMC {

}; // end DagMC

inline EntityHandle DagMC::entity_by_index(int dimension, int index) {
inline EntityHandle DagMC::entity_by_index(int dimension, int index) const {
assert(2 <= dimension && 3 >= dimension &&
(unsigned)index < entHandles[dimension].size());
return entHandles[dimension][index];
}

inline int DagMC::index_by_handle(EntityHandle handle) {
inline int DagMC::index_by_handle(EntityHandle handle) const {
assert(handle - setOffset < entIndices.size());
return entIndices[handle - setOffset];
}

inline unsigned int DagMC::num_entities(int dimension) {
inline unsigned int DagMC::num_entities(int dimension) const {
assert(vertex_handle_idx <= dimension && groups_handle_idx >= dimension);
return entHandles[dimension].size() - 1;
}
Expand Down

0 comments on commit 8741c61

Please sign in to comment.