Skip to content

Commit

Permalink
Cleaned up code. Inserted doxygen comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoSterbentz committed Jun 21, 2019
1 parent cf6f5f7 commit 36bb5a3
Show file tree
Hide file tree
Showing 16 changed files with 1,115 additions and 555 deletions.
49 changes: 24 additions & 25 deletions src/axom/mir/CellData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,67 +26,66 @@ namespace mir

//--------------------------------------------------------------------------------

/// Merges the cell data from the given cell into this cell
void CellData::mergeCell(CellData cellToMerge)
void CellData::mergeCell(const CellData& cellToMerge)
{
// Initialize index offsets
int evBeginsOffset = topology.evInds.size();
int veBeginsOffset = topology.veInds.size();
int evBeginsOffset = m_topology.m_evInds.size();
int veBeginsOffset = m_topology.m_veInds.size();

int vertexIndexOffset = numVerts;
int elementIndexOffset = numElems;
int vertexIndexOffset = m_numVerts;
int elementIndexOffset = m_numElems;

// Merge the cell topology information
for (unsigned long i = 0; i < cellToMerge.topology.evInds.size(); ++i)
for (unsigned long i = 0; i < cellToMerge.m_topology.m_evInds.size(); ++i)
{
topology.evInds.push_back(cellToMerge.topology.evInds[i] + vertexIndexOffset);
m_topology.m_evInds.push_back(cellToMerge.m_topology.m_evInds[i] + vertexIndexOffset);
}

for (unsigned long i = 1; i < cellToMerge.topology.evBegins.size(); ++i)
for (unsigned long i = 1; i < cellToMerge.m_topology.m_evBegins.size(); ++i)
{
topology.evBegins.push_back(cellToMerge.topology.evBegins[i] + evBeginsOffset);
m_topology.m_evBegins.push_back(cellToMerge.m_topology.m_evBegins[i] + evBeginsOffset);
}

for (unsigned long i = 0; i < cellToMerge.topology.veInds.size(); ++i)
for (unsigned long i = 0; i < cellToMerge.m_topology.m_veInds.size(); ++i)
{
topology.veInds.push_back(cellToMerge.topology.veInds[i] + elementIndexOffset);
m_topology.m_veInds.push_back(cellToMerge.m_topology.m_veInds[i] + elementIndexOffset);
}

for (unsigned long i = 1; i < cellToMerge.topology.veBegins.size(); ++i)
for (unsigned long i = 1; i < cellToMerge.m_topology.m_veBegins.size(); ++i)
{
topology.veBegins.push_back(cellToMerge.topology.veBegins[i] + veBeginsOffset);
m_topology.m_veBegins.push_back(cellToMerge.m_topology.m_veBegins[i] + veBeginsOffset);
}

// Merge the vertex positions
for (unsigned long i = 0; i < cellToMerge.mapData.vertexPositions.size(); ++i)
for (unsigned long i = 0; i < cellToMerge.m_mapData.m_vertexPositions.size(); ++i)
{
mapData.vertexPositions.push_back(cellToMerge.mapData.vertexPositions[i]);
m_mapData.m_vertexPositions.push_back(cellToMerge.m_mapData.m_vertexPositions[i]);
}

// Merge the vertex volume fractions
for (unsigned long matID = 0; matID < mapData.vertexVolumeFractions.size(); ++matID)
for (unsigned long matID = 0; matID < m_mapData.m_vertexVolumeFractions.size(); ++matID)
{
for (unsigned long vID = 0; vID < cellToMerge.mapData.vertexVolumeFractions[matID].size(); ++vID)
for (unsigned long vID = 0; vID < cellToMerge.m_mapData.m_vertexVolumeFractions[matID].size(); ++vID)
{
mapData.vertexVolumeFractions[matID].push_back(cellToMerge.mapData.vertexVolumeFractions[matID][vID]);
m_mapData.m_vertexVolumeFractions[matID].push_back(cellToMerge.m_mapData.m_vertexVolumeFractions[matID][vID]);
}
}

// Merge the elements' dominant materials
for (unsigned long i = 0; i < cellToMerge.mapData.elementDominantMaterials.size(); ++i)
for (unsigned long i = 0; i < cellToMerge.m_mapData.m_elementDominantMaterials.size(); ++i)
{
mapData.elementDominantMaterials.push_back(cellToMerge.mapData.elementDominantMaterials[i]);
m_mapData.m_elementDominantMaterials.push_back(cellToMerge.m_mapData.m_elementDominantMaterials[i]);
}

// Merge the elements' parent ids
for (unsigned long i = 0; i < cellToMerge.mapData.elementParents.size(); ++i)
for (unsigned long i = 0; i < cellToMerge.m_mapData.m_elementParents.size(); ++i)
{
mapData.elementParents.push_back(cellToMerge.mapData.elementParents[i]);
m_mapData.m_elementParents.push_back(cellToMerge.m_mapData.m_elementParents[i]);
}

// Merge the total number of verts and elems in the resulting cell
numVerts += cellToMerge.numVerts;
numElems += cellToMerge.numElems;
m_numVerts += cellToMerge.m_numVerts;
m_numElems += cellToMerge.m_numElems;
}

//--------------------------------------------------------------------------------
Expand Down
70 changes: 53 additions & 17 deletions src/axom/mir/CellData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
//
// SPDX-License-Identifier: (BSD-3-Clause)

/**
* \file CellData.hpp
*
* \brief Contains the specifications for the CellData class
* and CellTopologyData and CellMapData structs.
*/

#ifndef __CELL_DATA_H__
#define __CELL_DATA_H__

Expand All @@ -19,40 +26,69 @@ namespace axom
namespace mir
{

// Struct for collecting data that specifies a mesh or cell's connectivity/topology.
/**
* \struct CellTopologyData
*
* \brief Struct for collecting data that specifies a mesh or cell's connectivity/topology.
*/
struct CellTopologyData
{
std::vector<PosType> evInds;
std::vector<PosType> evBegins;
std::vector<PosType> veInds;
std::vector<PosType> veBegins;
std::vector<PosType> m_evInds;
std::vector<PosType> m_evBegins;
std::vector<PosType> m_veInds;
std::vector<PosType> m_veBegins;
};

// Struct for collecting the data that will populate a mesh's map data structures.
/**
* \struct CellMapData
*
* \brief Struct for collecting the data that will populate a mesh's map data structures.
*/
struct CellMapData
{
std::vector<mir::Point2> vertexPositions; // Data that goes into MIRMesh's vertexPositions PointMap
std::vector<std::vector<axom::float64> > vertexVolumeFractions; // Data that goes into MIRMesh's materialVolumeFractionsVertex ScalarMap
std::vector<int> elementDominantMaterials; // Data that goes into MIRMesh's elementDominantColors IntMap
std::vector<int> elementParents; // Data that goes into MIRMesh's elementParentIDs IntMap
std::vector<mir::Point2> m_vertexPositions; // Data that goes into MIRMesh's vertexPositions PointMap
std::vector<std::vector<axom::float64> > m_vertexVolumeFractions; // Data that goes into MIRMesh's materialVolumeFractionsVertex ScalarMap
std::vector<int> m_elementDominantMaterials; // Data that goes into MIRMesh's elementDominantColors IntMap
std::vector<int> m_elementParents; // Data that goes into MIRMesh's elementParentIDs IntMap
};

/// Represents an arbitrary number of cells that are within the same local coordinate system (i.e. share a set of vertices and elements).
/// Intended to be used as a helper class to hold intermediate data while processing a mesh, and to be used as input to the MIRMesh class to fully initialize it.
/**
* \class CellData
*
* \brief The CellData class represents an arbitrary number of cells that are
* within the same local coordinate system (i.e. share a set of vertices
* and elements).
*
* \detail This class is intended to be used as a helper class to hold intermediate
* data while processing a mesh, and to be used as input to the MIRMesh class
* to fully initialize it.
*/
class CellData
{
public:
/**
* \brief Default constructor.
*/
CellData();

/**
* \brief Default destructor.
*/
~CellData();

void mergeCell(CellData cellToMerge);
/**
* \brief Merges the cell data from the given cell into this cell.
*
* \param cellToMerge The cell whose data will be taken and merged in.
*/
void mergeCell(const CellData& cellToMerge);

public:
int numVerts;
int numElems;
int m_numVerts;
int m_numElems;

CellTopologyData topology;
CellMapData mapData;
CellTopologyData m_topology;
CellMapData m_mapData;
};
}
}
Expand Down
Loading

0 comments on commit 36bb5a3

Please sign in to comment.