Skip to content

Commit

Permalink
[insitu] Removed VtkMappedPropertyVectorTemplate.
Browse files Browse the repository at this point in the history
This introduces a possible problem as the Vtk array wrapper around
properties is not const and therefore the properties can be modified
by using this wrapper.
  • Loading branch information
bilke committed Mar 23, 2017
1 parent 6fac49a commit ec155c9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 659 deletions.
2 changes: 2 additions & 0 deletions MeshLib/Vtk/VtkMappedMeshSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <vtkSmartPointer.h>
#include <vtkStreamingDemandDrivenPipeline.h>

#include "MeshLib/Elements/Element.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/VtkOGSEnum.h"
#include "VtkMeshNodalCoordinatesTemplate.h"

Expand Down
22 changes: 14 additions & 8 deletions MeshLib/Vtk/VtkMappedMeshSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <string>

#include <vtkAOSDataArrayTemplate.h>
#include <vtkCellData.h>
#include <vtkFieldData.h>
#include <vtkNew.h>
Expand All @@ -34,10 +35,12 @@
#include "MeshLib/Properties.h"
#include "MeshLib/PropertyVector.h"

#include "VtkMappedPropertyVectorTemplate.h"


namespace MeshLib {

class Mesh;

/// Adapter which maps a MeshLib::Mesh to a vtkUnstructuredGridAlgorithm.
/// Allows for zero-copy access of the mesh from the visualization side.
class VtkMappedMeshSource final : public vtkUnstructuredGridAlgorithm
Expand Down Expand Up @@ -67,21 +70,24 @@ class VtkMappedMeshSource final : public vtkUnstructuredGridAlgorithm
VtkMappedMeshSource(const VtkMappedMeshSource &); // Not implemented.
void operator=(const VtkMappedMeshSource &); // Not implemented.

/// Adds a zero-copy array (MeshLib::VtkMappedPropertyVectorTemplate) as
/// either point or cell data to the mesh.
/// Adds a zero-copy vtk array wrapper.
/// \param properties MeshLib::Properties object
/// \param prop_name The name of the property vector to be mapped from
/// vtk-mesh to ogs-mesh
/// \param prop_name The name of the property vector to be mapped
template <typename T>
bool addProperty(MeshLib::Properties const& properties,
std::string const& prop_name) const
{
if (!properties.existsPropertyVector<T>(prop_name))
return false;
auto* const propertyVector = properties.getPropertyVector<T>(prop_name);
// TODO: Hack removing const
auto* propertyVector = const_cast<MeshLib::PropertyVector<T> *>(
properties.getPropertyVector<T>(prop_name));
if(!propertyVector)
return false;

vtkNew<VtkMappedPropertyVectorTemplate<T> > dataArray;
dataArray->SetPropertyVector(const_cast<MeshLib::PropertyVector<T> &>(*propertyVector));
vtkNew<vtkAOSDataArrayTemplate<T> > dataArray;
dataArray->SetArray(propertyVector->data(),
static_cast<vtkIdType>(propertyVector->size()), 1);
dataArray->SetName(prop_name.c_str());

if(propertyVector->getMeshItemType() == MeshLib::MeshItemType::Node)
Expand Down
Loading

0 comments on commit ec155c9

Please sign in to comment.