Skip to content
Snippets Groups Projects
Commit c91700b0 authored by Ricardo Ortiz's avatar Ricardo Ortiz
Browse files

Add unit test for the vtk map array.

parent 0d45fe2f
No related branches found
No related tags found
No related merge requests found
......@@ -116,7 +116,7 @@ private:
void operator=(const MeshNodalCoordinates &); // Not implemented.
vtkIdType Lookup(const Scalar &val, vtkIdType startIndex);
std::array<double,3> TempDoubleArray;
core::Vec3d TempDoubleArray;
};
#include "MeshNodalCoordinates.txx"
......
......@@ -61,7 +61,7 @@ template <class Scalar> void MeshNodalCoordinates<Scalar>
os, indent);
os << indent << "vertexArray : " << this->vertexArray << std::endl;
os << "TempDoubleArray : " << &this->TempDoubleArray << std::endl;
os << "TempDoubleArray : " << this->TempDoubleArray << std::endl;
}
//------------------------------------------------------------------------------
......@@ -183,7 +183,7 @@ template <class Scalar> void MeshNodalCoordinates<Scalar>
template <class Scalar> double* MeshNodalCoordinates<Scalar>
::GetTuple(vtkIdType i)
{
this->GetTuple(i, this->TempDoubleArray.data());
this->TempDoubleArray = (*this->vertexArray)[i];
return this->TempDoubleArray.data();
}
......@@ -191,9 +191,9 @@ template <class Scalar> double* MeshNodalCoordinates<Scalar>
template <class Scalar> void MeshNodalCoordinates<Scalar>
::GetTuple(vtkIdType i, double *tuple)
{
tuple[0] = static_cast<double>((*this->vertexArray)[i](0));
tuple[1] = static_cast<double>((*this->vertexArray)[i](1));
tuple[2] = static_cast<double>((*this->vertexArray)[i](2));
tuple[0] = static_cast<double>((*this->vertexArray)[i][0]);
tuple[1] = static_cast<double>((*this->vertexArray)[i][1]);
tuple[2] = static_cast<double>((*this->vertexArray)[i][2]);
}
//------------------------------------------------------------------------------
......@@ -507,3 +507,4 @@ template <class Scalar> vtkIdType MeshNodalCoordinates<Scalar>
}
return -1;
}
......@@ -26,6 +26,7 @@
// VTK includes
#include <vtkNew.h>
#include <vtkSmartPointer.h>
#include <vtkPoints.h>
// SimMedTK includes
#include "../MeshNodalCoordinates.h"
......@@ -40,6 +41,51 @@ go_bandit([](){
vtkNew<MeshNodalCoordinates<double>> meshMapper;
AssertThat(meshMapper.GetPointer() != nullptr, IsTrue());
});
it("initializes", []() {
vtkNew<MeshNodalCoordinates<double>> meshMapper;
meshMapper->Initialize();
AssertThat(meshMapper->GetMaxId() == -1, IsTrue());
AssertThat(meshMapper->GetSize() == 0, IsTrue());
AssertThat(meshMapper->GetNumberOfComponents() == 1, IsTrue());
});
it("wraps data", []() {
vtkNew<MeshNodalCoordinates<double>> meshMapper;
std::vector<core::Vec3d> vertices;
vertices.emplace_back(0,1,0);
vertices.emplace_back(1,0,0);
vertices.emplace_back(0,0,1);
vertices.emplace_back(0,1,1);
meshMapper->SetVertexArray(vertices);
AssertThat(meshMapper->GetMaxId() == 11, IsTrue());
AssertThat(meshMapper->GetSize() == 12, IsTrue());
AssertThat(meshMapper->GetNumberOfComponents() == 3, IsTrue());
});
it("is used by vtkPoints", []() {
vtkNew<MeshNodalCoordinates<double>> meshMapper;
std::vector<core::Vec3d> vertices;
vertices.emplace_back(0,1,0);
vertices.emplace_back(1,0,0);
vertices.emplace_back(0,0,1);
vertices.emplace_back(0,1,1);
meshMapper->SetVertexArray(vertices);
vtkNew<vtkPoints> points;
points->SetData(meshMapper.GetPointer());
points->Modified();
AssertThat(points->GetNumberOfPoints() == 4, IsTrue());
AssertThat(points->GetPoint(0)[1] == 1, IsTrue());
AssertThat(points->GetPoint(1)[0] == 1, IsTrue());
AssertThat(points->GetPoint(2)[2] == 1, IsTrue());
AssertThat(points->GetPoint(3)[1] == 1, IsTrue());
});
});
});
......@@ -88,7 +88,7 @@ MeshRenderDelegate::MeshRenderDelegate()
}
vertices->SetNumberOfPoints(mesh->getVertices().size());
vertices->SetData(mappedData.Get());
vertices->SetData(mappedData.GetPointer());
unstructuredMesh->SetPoints(vertices.GetPointer());
unstructuredMesh->SetCells(VTK_TRIANGLE,triangles.GetPointer());
......
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