iMSTK
Interactive Medical Simulation Toolkit
imstkLineMesh.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkCellMesh.h"
10 
11 namespace imstk
12 {
18 class LineMesh : public CellMesh<2>
19 {
20 public:
21  LineMesh() = default;
22  ~LineMesh() override = default;
23 
24  int getNumLines() const { return getNumCells(); }
25  void setLinesIndices(std::shared_ptr<VecDataArray<int, 2>> indices) { setCells(indices); }
26  std::shared_ptr<VecDataArray<int, 2>> getLinesIndices() const { return getCells(); }
27 
28  IMSTK_TYPE_NAME(LineMesh)
29 
30 
31  std::unique_ptr<LineMesh> clone()
35  {
36  return std::unique_ptr<LineMesh>(cloneImplementation());
37  }
38 
39 private:
40  LineMesh* cloneImplementation() const
41  {
42  // Do shallow copy
43  LineMesh* geom = new LineMesh(*this);
44  // Deal with deep copy members
45  geom->m_indices = std::make_shared<VecDataArray<int, 2>>(*m_indices);
46  for (auto i : m_cellAttributes)
47  {
48  geom->m_cellAttributes[i.first] = i.second->clone();
49  }
50  geom->m_initialVertexPositions = std::make_shared<VecDataArray<double, 3>>(*m_initialVertexPositions);
51  geom->m_vertexPositions = std::make_shared<VecDataArray<double, 3>>(*m_vertexPositions);
52  for (auto i : m_vertexAttributes)
53  {
54  geom->m_vertexAttributes[i.first] = i.second->clone();
55  }
56  return geom;
57  }
58 };
59 } // namespace imstk
Compound Geometry.
std::unique_ptr< LineMesh > clone()
Polymorphic clone, hides the declaration in superclass return own type.
Definition: imstkLineMesh.h:34
int getNumCells() const override
Returns the number of cells.
void setCells(std::shared_ptr< VecDataArray< int, N >> indices)
Get/Set cell connectivity.
Base class for all volume mesh types.
Definition: imstkLineMesh.h:18
Abstract template base class for all meshes that have homogenous cell types. This class allows templa...
Definition: imstkCellMesh.h:23