/*========================================================================= Library: iMSTK Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, & Imaging in Medicine, Rensselaer Polytechnic Institute. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =========================================================================*/ #pragma once #include "imstkVTKPolyDataRenderDelegate.h" class vtkCellArray; class vtkDataArray; class vtkDoubleArray; class vtkFloatArray; class vtkPolyData; namespace imstk { class AbstractDataArray; class SurfaceMesh; template class VecDataArray; /// /// \class VTKSurfaceMeshRenderDelegate /// /// \brief Surface mesh render delegate with VTK backend /// class VTKSurfaceMeshRenderDelegate : public VTKPolyDataRenderDelegate { public: VTKSurfaceMeshRenderDelegate(std::shared_ptr visualModel); virtual ~VTKSurfaceMeshRenderDelegate() override = default; /// /// \brief Event handler /// void processEvents() override; /// /// \brief Initialize textures /// void initializeTextures(); // Callbacks for modifications, when an element changes the user or API must post the modified event // to inform that this happened, if the actual buffer on the geometry is swapped then geometry // modified would instead be called protected: /// /// \brief Callback for when vertex values are modified /// void vertexDataModified(Event* e); void indexDataModified(Event* e); void normalDataModified(Event* e); void vertexScalarsModified(Event* e); void cellScalarsModified(Event* e); void textureCoordinatesModified(Event* e); /// /// \brief Callback for when geometry is modified /// void geometryModified(Event* e); /// /// \brief Callback for when RenderMaterial textures are modified /// void texturesModified(Event* e); protected: void setVertexBuffer(std::shared_ptr> vertices); void setNormalBuffer(std::shared_ptr> normals); void setIndexBuffer(std::shared_ptr> indices); void setVertexScalarBuffer(std::shared_ptr scalars); void setCellScalarBuffer(std::shared_ptr scalars); void setTextureCoordinateBuffer(std::shared_ptr textureCoordinates); protected: std::shared_ptr m_geometry; std::shared_ptr> m_vertices; std::shared_ptr> m_normals; std::shared_ptr> m_indices; std::shared_ptr m_vertexScalars; std::shared_ptr m_cellScalars; std::shared_ptr m_textureCoordinates; vtkSmartPointer m_polydata; vtkSmartPointer m_mappedVertexArray; ///> Mapped array of vertices vtkSmartPointer m_mappedNormalArray; ///> Mapped array of normals vtkSmartPointer m_mappedTangentArray; ///> Mapped array of tangents vtkSmartPointer m_mappedTCoordsArray; ///> Mapped array of tcoords vtkSmartPointer m_mappedVertexScalarArray; ///> Mapped array of scalars vtkSmartPointer m_mappedCellScalarArray; ///> Mapped array of scalars vtkSmartPointer m_cellArray; ///> Array of cells }; }