Commit 315230de authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED move the first access to data array in MeshComponent

parent 889adb90
......@@ -525,6 +525,16 @@ void MeshComponent::removeSelectedSelections() {
}
}
// -------------------- getNumberOfDataArray --------------------
int MeshComponent::getNumberOfDataArray() {
if (getPointSet() == NULL) {
return 0;
}
else {
return getPointSet()->GetCellData()->GetNumberOfArrays() + getPointSet()->GetPointData()->GetNumberOfArrays();
}
}
// -------------------- getDataArray --------------------
vtkSmartPointer<vtkDataArray> MeshComponent::getDataArray(MeshDataModel::FieldType fieldType, const QString& arrayName) {
vtkSmartPointer< vtkFieldData > dataField;
......
......@@ -224,6 +224,9 @@ public:
* @{
*/
/// Get the total number of point and cell data arrays (not taking intou account the field arrays), returns -1 if there is none
int getNumberOfDataArray();
/**
* @brief Get the data array of specified field type and name.
*
......@@ -253,7 +256,6 @@ public:
*/
void addDataArray ( MeshDataModel::FieldType fieldType, const QString& name, vtkSmartPointer<vtkDataArray> data );
/**
* @brief Remove a data array.
*
......
......@@ -45,11 +45,12 @@ MeshDataModel::MeshDataModel(MeshComponent* meshComp) :
// -------------------- rowCount --------------------
int MeshDataModel::rowCount(const QModelIndex& parent) const {
if (meshComponent == NULL || meshComponent->getPointSet() == NULL) {
if (meshComponent == NULL) {
return 0;
}
return meshComponent->getPointSet()->GetCellData()->GetNumberOfArrays() + meshComponent->getPointSet()->GetPointData()->GetNumberOfArrays();
else {
return meshComponent->getNumberOfDataArray();
}
}
// -------------------- columnCount --------------------
......@@ -88,6 +89,7 @@ QVariant MeshDataModel::data(const QModelIndex& index, int role) const {
int dataIndex;
FieldType fieldType = getFieldTypeOfRow(row, &dataIndex);
// TODO use only MeshComponent methods
vtkSmartPointer<vtkFieldData> data = meshComponent->getFieldData(fieldType);
vtkSmartPointer<vtkDataArray> dataArray = data->GetArray(dataIndex);
DataType type = getDataType(dataArray);
......
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