Commit 92578832 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED now we can read absolutely every data from the vtk files

Fixed also: only one representation of vector and tensor is possible
at a time.
parent 6d57558d
......@@ -51,6 +51,7 @@ VtkMeshComponent::VtkMeshComponent (const QString& fileName) throw(AbortExcepti
// build the vtk data structure from the file
vtkSmartPointer<vtkPointSet> data = VtkMeshUtil::buildVtkPointSet(myFileName.toStdString().c_str(), whatIsIt);
std::cout << data->GetPointData()->GetNumberOfArrays() << " arrays in pointdata" << std::endl;
// instanciate the Geometry
initRepresentation(data);
}
......
......@@ -71,40 +71,59 @@ vtkSmartPointer<vtkPointSet> VtkMeshUtil::buildVtkPointSet(std::string vtkFileNa
whatIsIt = VtkMeshUtil::typeOf(vtkFileName);
}
if (whatIsIt == VtkMeshUtil::UNKNOWN) {
return nullptr;
}
// create the Geometry depending on the type
vtkSmartPointer<vtkDataReader> vtkPointSetReader;
switch (whatIsIt) {
case VtkMeshUtil::UNSTRUCTURED_GRID: {
vtkSmartPointer<vtkUnstructuredGridReader>uGridReader = vtkSmartPointer<vtkUnstructuredGridReader>::New();
uGridReader->SetFileName(vtkFileName.c_str());
uGridReader->Update();
case VtkMeshUtil::UNSTRUCTURED_GRID:
vtkPointSetReader = vtkSmartPointer<vtkUnstructuredGridReader>::New();
break;
return uGridReader->GetOutput();
case VtkMeshUtil::STRUCTURED_GRID:
vtkPointSetReader = vtkSmartPointer<vtkStructuredGridReader>::New();
break;
}
case VtkMeshUtil::STRUCTURED_GRID: {
vtkSmartPointer<vtkStructuredGridReader>sGridReader = vtkSmartPointer<vtkStructuredGridReader>::New();
sGridReader->SetFileName(vtkFileName.c_str());
sGridReader->Update();
case VtkMeshUtil::POLY_DATA:
vtkPointSetReader = vtkSmartPointer<vtkPolyDataReader>::New();
break;
return sGridReader->GetOutput();
default:
break;
}
case VtkMeshUtil::POLY_DATA: {
vtkSmartPointer<vtkPolyDataReader>polyDataReader = vtkSmartPointer<vtkPolyDataReader>::New();
polyDataReader->SetFileName(vtkFileName.c_str());
polyDataReader->Update();
}
return polyDataReader->GetOutput();
vtkPointSetReader->SetFileName(vtkFileName.c_str());
// read absolutely everything!
vtkPointSetReader->ReadAllFieldsOn();
vtkPointSetReader->ReadAllScalarsOn();
vtkPointSetReader->ReadAllColorScalarsOn();
vtkPointSetReader->ReadAllNormalsOn();
vtkPointSetReader->ReadAllTCoordsOn();
vtkPointSetReader->ReadAllTensorsOn();
vtkPointSetReader->ReadAllVectorsOn();
vtkPointSetReader->Update();
switch (whatIsIt) {
case VtkMeshUtil::UNSTRUCTURED_GRID:
return vtkUnstructuredGridReader::SafeDownCast(vtkPointSetReader)->GetOutput();
break;
}
case VtkMeshUtil::UNKNOWN: {
return NULL;
case VtkMeshUtil::STRUCTURED_GRID:
return vtkStructuredGridReader::SafeDownCast(vtkPointSetReader)->GetOutput();
break;
case VtkMeshUtil::POLY_DATA:
return vtkPolyDataReader::SafeDownCast(vtkPointSetReader)->GetOutput();
break;
}
}
return NULL;
default:
return nullptr;
break;
}
}
// -------------------- saveGeometryToFile --------------------
......@@ -243,12 +262,14 @@ VtkMeshUtil::VtkPointSetType VtkMeshUtil::typeOf(vtkSmartPointer<vtkPointSet> aP
if (aPointSet->IsA("vtkPolyData")) {
whatIsIt = VtkMeshUtil::POLY_DATA;
}
else if (aPointSet->IsA("vtkUnstructuredGrid")) {
whatIsIt = VtkMeshUtil::UNSTRUCTURED_GRID;
}
else if (aPointSet->IsA("vtkStructuredGrid")) {
whatIsIt = VtkMeshUtil::STRUCTURED_GRID;
}
else
if (aPointSet->IsA("vtkUnstructuredGrid")) {
whatIsIt = VtkMeshUtil::UNSTRUCTURED_GRID;
}
else
if (aPointSet->IsA("vtkStructuredGrid")) {
whatIsIt = VtkMeshUtil::STRUCTURED_GRID;
}
return whatIsIt;
}
......
......@@ -270,11 +270,11 @@ void MeshComponent::initSelection() {
// -------------------- initData --------------------
void MeshComponent::initData() {
//-- add loaded data arrays
for(vtkIdType i = 0; i < myGeometry->getPointSet()->GetPointData()->GetNumberOfArrays(); i++) {
addPointData(myGeometry->getPointSet()->GetPointData()->GetArrayName(i) , myGeometry->getPointSet()->GetPointData()->GetArray(i));
for (vtkIdType i = 0; i < myGeometry->getPointSet()->GetPointData()->GetNumberOfArrays(); i++) {
addPointData(myGeometry->getPointSet()->GetPointData()->GetArrayName(i), myGeometry->getPointSet()->GetPointData()->GetArray(i));
}
for(vtkIdType i = 0; i < myGeometry->getPointSet()->GetCellData()->GetNumberOfArrays(); i++) {
addCellData(myGeometry->getPointSet()->GetCellData()->GetArrayName(i) , myGeometry->getPointSet()->GetCellData()->GetArray(i));
for (vtkIdType i = 0; i < myGeometry->getPointSet()->GetCellData()->GetNumberOfArrays(); i++) {
addCellData(myGeometry->getPointSet()->GetCellData()->GetArrayName(i), myGeometry->getPointSet()->GetCellData()->GetArray(i));
}
//-- no active data by default
......@@ -647,7 +647,7 @@ void MeshComponent::createDataRepresentation(FieldType field, const QString& nam
if (vectorPolicy == UNSCALED_ARROW) {
// the best would be to scale to a minimal %age of the bounding radius up to a maximal %age of bounding radius
// unfortunately it not easy to understand the scaling process of vtkGlyph3D
arrowGlyph->SetScaleFactor(getBoundingRadius()/2.0);
arrowGlyph->SetScaleFactor(getBoundingRadius() / 2.0);
arrowGlyph->SetScaleModeToDataScalingOff();
arrowGlyph->ClampingOn();
//arrowGlyph->ScalingOff();
......@@ -916,7 +916,7 @@ void MeshComponent::setDataRepresentationVisibility(FieldType fieldType, const Q
case VECTORS:
if (representation != VECTOR_3D) {
// first remove all other scalar color map (only one possible color at at time
// first remove all other scalar color map (only one possible color at at time)
setDataRepresentationOff(SCALARS);
// create 1D representation (color map)
......@@ -940,6 +940,9 @@ void MeshComponent::setDataRepresentationVisibility(FieldType fieldType, const Q
break; // specific vector representation is finished here
}
else {
// first remove all other vector representation (only one possible color at at time)
setDataRepresentationOff(VECTORS);
// just update the data set state for now (see case TENSORS for the rest)
dataSet->SetActiveVectors(name.toStdString().c_str());
}
......@@ -948,6 +951,10 @@ void MeshComponent::setDataRepresentationVisibility(FieldType fieldType, const Q
case TENSORS: {
// ... which means we still need this test here (not elegant but better than repeating the following lines twice)
if (type == TENSORS) {
// first remove all other vector representation (only one possible color at at time)
setDataRepresentationOff(TENSORS);
// update the data set state
dataSet->SetActiveTensors(name.toStdString().c_str());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment