7 #include "imstkAbstractCellMesh.h" 18 for (
auto i : m_cellAttributes)
23 m_activeCellNormals =
"";
24 m_activeCellTangents =
"";
25 m_activeCellScalars =
"";
33 LOG(INFO) <<
"Number of cells: " << getNumCells();
34 LOG(INFO) <<
"Active Cell Normals: " << m_activeCellNormals;
35 LOG(INFO) <<
"Active Cell Tangents: " << m_activeCellTangents;
36 LOG(INFO) <<
"Active Cell Scalars: " << m_activeCellScalars;
39 const std::vector<int>
57 AbstractCellMesh::setCellActiveAttribute(std::string& activeAttributeName, std::string attributeName,
58 const int expectedNumComponents,
const ScalarTypeId expectedScalarType)
60 std::shared_ptr<AbstractDataArray> attribute = m_cellAttributes[attributeName];
61 if (attribute->getNumberOfComponents() != expectedNumComponents)
63 LOG(WARNING) <<
"Failed to set cell attribute on Mesh " +
getName() +
" with " 64 << attribute->getNumberOfComponents() <<
" components. Expected " <<
65 expectedNumComponents <<
" components.";
68 else if (attribute->getScalarType() != expectedScalarType)
70 LOG(INFO) <<
"Tried to set cell attribute on Mesh " +
getName() +
" with scalar type " 71 <<
static_cast<int>(attribute->getScalarType()) <<
". Casting to " 72 << static_cast<int>(expectedScalarType) <<
" scalar type";
73 m_cellAttributes[attributeName] = attribute->cast(expectedScalarType);
75 activeAttributeName = attributeName;
81 m_activeCellScalars = arrayName;
82 m_cellAttributes[arrayName] = scalars;
90 m_activeCellScalars = arrayName;
94 std::shared_ptr<AbstractDataArray>
95 AbstractCellMesh::getCellScalars()
const 99 return m_cellAttributes.at(m_activeCellScalars);
110 m_activeCellNormals = arrayName;
111 m_cellAttributes[arrayName] = normals;
119 setCellActiveAttribute(m_activeCellNormals, arrayName, 3, IMSTK_DOUBLE);
123 std::shared_ptr<VecDataArray<double, 3>>
124 AbstractCellMesh::getCellNormals()
const 139 m_activeCellTangents = arrayName;
140 m_cellAttributes[arrayName] = tangents;
148 setCellActiveAttribute(m_activeCellTangents, arrayName, 3, IMSTK_DOUBLE);
152 std::shared_ptr<VecDataArray<double, 3>>
153 AbstractCellMesh::getCellTangents()
const void setCellNormals(const std::string &arrayName, std::shared_ptr< VecDataArray< double, 3 >> normals)
Get/Set the active normals.
virtual void print() const override
Print the mesh info.
void print() const override
Print the surface mesh.
std::vector< std::unordered_set< int > > m_vertexToNeighborVertex
Map of vertices to neighbor vertices.
void clear() override
Clears all the mesh data.
const std::vector< int > getCellsForVertex(const int vertexId)
Returns cells that contain the vertex, will calculate vertex cells if necessary.
virtual void computeVertexToCellMap()
Computes neighboring cells for all vertices.
std::vector< std::unordered_set< int > > m_vertexToCells
Map of vertices to neighbor cells.
void setCellTangents(const std::string &arrayName, std::shared_ptr< VecDataArray< double, 3 >> tangents)
Get/Set the active tangents.
const std::string & getName() const
Get the name of the geometry.
virtual void clear()
Clears all the mesh data.
bool hasCellAttribute(const std::string &arrayName) const
Check if a specific data array exists.
int getNumVertices() const
Returns the number of total vertices in the mesh.
void setCellScalars(const std::string &arrayName, std::shared_ptr< AbstractDataArray > scalars)
Get/Set the active scalars.