Skip to content
Snippets Groups Projects
Commit 41e28cf4 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MeL] Move private method implementation into cpp.

parent 0cbfc9af
No related branches found
No related tags found
No related merge requests found
...@@ -163,4 +163,34 @@ int VtkMappedMeshSource::RequestInformation(vtkInformation*, ...@@ -163,4 +163,34 @@ int VtkMappedMeshSource::RequestInformation(vtkInformation*,
return 1; return 1;
} }
template <typename T>
bool VtkMappedMeshSource::addProperty(MeshLib::Properties const& properties,
std::string const& prop_name) const
{
if (!properties.existsPropertyVector<T>(prop_name))
return false;
// TODO: Hack removing const
auto* propertyVector = const_cast<MeshLib::PropertyVector<T>*>(
properties.getPropertyVector<T>(prop_name));
if (!propertyVector)
return false;
vtkNew<vtkAOSDataArrayTemplate<T>> dataArray;
const bool hasArrayOwnership = false;
dataArray->SetArray(propertyVector->data(),
static_cast<vtkIdType>(propertyVector->size()),
static_cast<int>(!hasArrayOwnership));
dataArray->SetNumberOfComponents(propertyVector->getNumberOfComponents());
dataArray->SetName(prop_name.c_str());
if (propertyVector->getMeshItemType() == MeshLib::MeshItemType::Node)
this->PointData->AddArray(dataArray.GetPointer());
else if (propertyVector->getMeshItemType() == MeshLib::MeshItemType::Cell)
this->CellData->AddArray(dataArray.GetPointer());
else if (propertyVector->getMeshItemType() ==
MeshLib::MeshItemType::IntegrationPoint)
this->FieldData->AddArray(dataArray.GetPointer());
return true;
}
} // Namespace MeshLib } // Namespace MeshLib
...@@ -79,36 +79,7 @@ private: ...@@ -79,36 +79,7 @@ private:
/// \param prop_name The name of the property vector to be mapped /// \param prop_name The name of the property vector to be mapped
template <typename T> template <typename T>
bool addProperty(MeshLib::Properties const& properties, bool addProperty(MeshLib::Properties const& properties,
std::string const& prop_name) const std::string const& prop_name) const;
{
if (!properties.existsPropertyVector<T>(prop_name))
return false;
// TODO: Hack removing const
auto* propertyVector = const_cast<MeshLib::PropertyVector<T>*>(
properties.getPropertyVector<T>(prop_name));
if (!propertyVector)
return false;
vtkNew<vtkAOSDataArrayTemplate<T>> dataArray;
const bool hasArrayOwnership = false;
dataArray->SetArray(propertyVector->data(),
static_cast<vtkIdType>(propertyVector->size()),
static_cast<int>(!hasArrayOwnership));
dataArray->SetNumberOfComponents(
propertyVector->getNumberOfComponents());
dataArray->SetName(prop_name.c_str());
if (propertyVector->getMeshItemType() == MeshLib::MeshItemType::Node)
this->PointData->AddArray(dataArray.GetPointer());
else if (propertyVector->getMeshItemType() ==
MeshLib::MeshItemType::Cell)
this->CellData->AddArray(dataArray.GetPointer());
else if (propertyVector->getMeshItemType() ==
MeshLib::MeshItemType::IntegrationPoint)
this->FieldData->AddArray(dataArray.GetPointer());
return true;
}
const MeshLib::Mesh* _mesh; const MeshLib::Mesh* _mesh;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment