9 #include "imstkGeometry.h" 10 #include "imstkTypes.h" 12 #include <unordered_map> 16 class AbstractDataArray;
17 template<
typename T,
int N>
class VecDataArray;
46 virtual void print()
const override;
51 virtual void computeBoundingBox(Vec3d& lowerCorner, Vec3d& upperCorner,
const double paddingPercent = 0.0)
override;
100 void setVertexAttribute(
const std::string& arrayName, std::shared_ptr<AbstractDataArray> arr);
105 std::shared_ptr<AbstractDataArray>
getVertexAttribute(
const std::string& arrayName)
const;
115 void setVertexAttributes(std::unordered_map<std::string, std::shared_ptr<AbstractDataArray>> attributes) { m_vertexAttributes = attributes; }
120 const std::unordered_map<std::string, std::shared_ptr<AbstractDataArray>>&
getVertexAttributes()
const {
return m_vertexAttributes; }
125 void setVertexScalars(
const std::string& arrayName, std::shared_ptr<AbstractDataArray> scalars);
127 std::string getActiveVertexScalars()
const {
return m_activeVertexScalars; }
128 std::shared_ptr<AbstractDataArray> getVertexScalars()
const;
136 std::string getActiveVertexNormals()
const {
return m_activeVertexNormals; }
137 std::shared_ptr<VecDataArray<double, 3>> getVertexNormals()
const;
145 std::string getActiveVertexTangents()
const {
return m_activeVertexTangents; }
146 std::shared_ptr<VecDataArray<float, 3>> getVertexTangents()
const;
154 std::string getActiveVertexTCoords()
const {
return m_activeVertexTCoords; }
155 std::shared_ptr<VecDataArray<float, 2>> getVertexTCoords()
const;
169 return std::unique_ptr<PointSet>(cloneImplementation());
183 const int expectedNumComponents,
const ScalarTypeId expectedScalarType);
185 std::shared_ptr<VecDataArray<double, 3>> m_initialVertexPositions;
186 std::shared_ptr<VecDataArray<double, 3>> m_vertexPositions;
188 std::unordered_map<std::string, std::shared_ptr<AbstractDataArray>> m_vertexAttributes;
189 std::string m_activeVertexNormals =
"";
190 std::string m_activeVertexScalars =
"";
191 std::string m_activeVertexTangents =
"";
192 std::string m_activeVertexTCoords =
"";
198 PointSet* cloneImplementation()
const;
void initialize(std::shared_ptr< VecDataArray< double, 3 >> positions)
Initializes the data structure given vertex positions.
void setVertexNormals(const std::string &arrayName, std::shared_ptr< VecDataArray< double, 3 >> normals)
Get/Set the active normals.
Base class for all geometries represented by discrete points and elements The pointsets follow a pipe...
void setVertexTangents(const std::string &arrayName, std::shared_ptr< VecDataArray< float, 3 >> tangents)
Get/Set the active tangents.
std::unique_ptr< PointSet > clone()
Polymorphic clone, hides the declaration in superclass return own type.
std::shared_ptr< AbstractDataArray > getVertexAttribute(const std::string &arrayName) const
Get a specific data array. If the array name cannot be found, nullptr is returned.
void applyTransform(const Mat4d &m) override
Applies transformation m directly the initial and post transform data.
void setVertexAttributes(std::unordered_map< std::string, std::shared_ptr< AbstractDataArray >> attributes)
Set the vertex attributes map.
virtual void print() const override
Print the mesh info.
bool hasVertexAttribute(const std::string &arrayName) const
Check if a specific data array exists.
const std::unordered_map< std::string, std::shared_ptr< AbstractDataArray > > & getVertexAttributes() const
Get the vertex attributes map.
void setVertexTCoords(const std::string &arrayName, std::shared_ptr< VecDataArray< float, 2 >> tcoords)
Get/Set the active tcoords.
virtual void computeBoundingBox(Vec3d &lowerCorner, Vec3d &upperCorner, const double paddingPercent=0.0) override
Compute the bounding box for the entire mesh.
void setVertexAttribute(const std::string &arrayName, std::shared_ptr< AbstractDataArray > arr)
Set a data array holding some per vertex data.
void updatePostTransformData() const override
Applies the geometries member transform to produce currPositions.
Base class for any geometrical representation.
void setVertexScalars(const std::string &arrayName, std::shared_ptr< AbstractDataArray > scalars)
Get/Set the active scalars.
void setActiveVertexAttribute(std::string &activeAttributeName, const std::string attributeName, const int expectedNumComponents, const ScalarTypeId expectedScalarType)
Sets the active vertex attribute name as long as the # components is satisfied. Throws message and ca...
const Vec3d & getVertexPosition(const size_t vertNum, DataType type=DataType::PostTransform) const
Returns the position of a vertex given its index.
void setVertexPosition(const size_t vertNum, const Vec3d &pos)
Set the current position of a vertex given its index to certain position (this is not a thread-safe m...
void setInitialVertexPositions(std::shared_ptr< VecDataArray< double, 3 >> vertices)
Sets initial positions from an array.
std::shared_ptr< VecDataArray< double, 3 > > getVertexPositions(DataType type=DataType::PostTransform) const
Returns the vector of current positions of the mesh vertices.
virtual void clear()
Clears all the mesh data.
void setVertexPositions(std::shared_ptr< VecDataArray< double, 3 >> positions)
Sets current vertex positions of the mesh.
Vec3d & getInitialVertexPosition(const size_t vertNum)
Returns the initial position of a vertex given its index.
int getNumVertices() const
Returns the number of total vertices in the mesh.
std::shared_ptr< VecDataArray< double, 3 > > getInitialVertexPositions() const
Returns the vector of initial positions of the mesh vertices.
DataType
Enumeration for the data to retrieve PreTransform for data where transform matrix is not applied Po...