X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlugins%2FTableReader%2FTableTo3DFilter%2FvtkTableTo3D.cxx;h=3a3e0da3ee0b8a4f4b3313a9ec3b0c2902360dd3;hb=5b130b79009fb8c054f777569fbc7c609f92e266;hp=77c99585d54d2c8bdf092f88817a8a5bdcd186ee;hpb=f284847a1f9ec2519639285396adf10a84903eea;p=modules%2Fparavis.git diff --git a/src/Plugins/TableReader/TableTo3DFilter/vtkTableTo3D.cxx b/src/Plugins/TableReader/TableTo3DFilter/vtkTableTo3D.cxx index 77c99585..3a3e0da3 100644 --- a/src/Plugins/TableReader/TableTo3DFilter/vtkTableTo3D.cxx +++ b/src/Plugins/TableReader/TableTo3DFilter/vtkTableTo3D.cxx @@ -50,152 +50,152 @@ vtkTableTo3D::~vtkTableTo3D() } int vtkTableTo3D::FillInputPortInformation( - int vtkNotUsed(port), vtkInformation* info) + int vtkNotUsed(port), vtkInformation* info) { info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkTable"); return 1; } int vtkTableTo3D::RequestData(vtkInformation* vtkNotUsed(request), - vtkInformationVector** inputVector, vtkInformationVector* outputVector) + vtkInformationVector** inputVector, vtkInformationVector* outputVector) { vtkTable* input = vtkTable::GetData(inputVector[0], 0); vtkPolyData* output = vtkPolyData::GetData(outputVector, 0); if (input->GetNumberOfRows() == 0 ||input->GetNumberOfColumns() < 2) - { - return 1; - } - + { + return 1; + } + vtkIdType xSize = input->GetNumberOfRows(); vtkIdType ySize = input->GetNumberOfColumns() - 1; vtkIdType nbPoints = xSize * ySize; vtkDataArray* xAxis = vtkDataArray::SafeDownCast(input->GetColumn(0)); if (!xAxis) - { - vtkErrorMacro("The first column is not numeric."); - return 1; - } - + { + vtkErrorMacro("The first column is not numeric."); + return 1; + } + double xRange = xAxis->GetTuple1(xSize - 1) - xAxis->GetTuple1(0); double yDelta = xRange / ySize; - + vtkSmartPointer yAxis = - vtkSmartPointer::New(); + vtkSmartPointer::New(); yAxis->SetNumberOfValues(ySize); for (vtkIdType i = 0; i < ySize; i++ ) - { - yAxis->SetValue(i, i*yDelta); - } + { + yAxis->SetValue(i, i*yDelta); + } vtkSmartPointer points = - vtkSmartPointer::New(); + vtkSmartPointer::New(); points->SetNumberOfPoints(nbPoints); vtkSmartPointer pointsIdMapper = - vtkSmartPointer::New(); + vtkSmartPointer::New(); pointsIdMapper->SetName("POINTS_ID_MAPPER"); pointsIdMapper->SetNumberOfComponents(2); pointsIdMapper->SetNumberOfTuples(nbPoints); int *pointsIdMapperPtr = pointsIdMapper->GetPointer(0); for (vtkIdType i = 0, pntId = 0; i < ySize; i++) + { + for (vtkIdType j = 0; j < xSize; j++, pntId++) { - for (vtkIdType j = 0; j < xSize; j++, pntId++) - { - points->SetPoint(pntId, xAxis->GetTuple1(j), - yAxis->GetValue(i), - 0.0); - - *pointsIdMapperPtr++ = pntId; - *pointsIdMapperPtr++ = 0; - } + points->SetPoint(pntId, xAxis->GetTuple1(j), + yAxis->GetValue(i), + 0.0); + + *pointsIdMapperPtr++ = pntId; + *pointsIdMapperPtr++ = 0; } + } vtkSmartPointer scalars = - vtkSmartPointer::New(); + vtkSmartPointer::New(); scalars->SetNumberOfComponents(1); scalars->SetNumberOfTuples(nbPoints); double *scalarsPtr = scalars->GetPointer(0); for (vtkIdType i = 0; i < ySize; i++) + { + vtkDataArray* col = + vtkDataArray::SafeDownCast(input->GetColumn(i + 1)); + + if (!col) + { + vtkErrorMacro("Column "<< i <<"is not numeric."); + return 1; + } + + for ( vtkIdType j = 0; j < xSize; j++ ) { - vtkDataArray* col = - vtkDataArray::SafeDownCast(input->GetColumn(i + 1)); - - if (!col) - { - vtkErrorMacro("Column "<< i <<"is not numeric."); - return 1; - } - - for ( vtkIdType j = 0; j < xSize; j++ ) - { - double value = col->GetTuple1(j); - *scalarsPtr++ = value; - } + double value = col->GetTuple1(j); + *scalarsPtr++ = value; } + } vtkSmartPointer structuredGrid = - vtkSmartPointer::New(); + vtkSmartPointer::New(); structuredGrid->SetPoints(points); structuredGrid->SetDimensions(xSize, ySize, 1); // structuredGrid->GetPointData()->AddArray(pointsIdMapper); if (input->GetInformation()->Has(vtkDataObject::FIELD_NAME())) - { - scalars->SetName(input->GetInformation()->Get(vtkDataObject::FIELD_NAME())); - } + { + scalars->SetName(input->GetInformation()->Get(vtkDataObject::FIELD_NAME())); + } else - { - scalars->SetName("Table"); - } + { + scalars->SetName("Table"); + } structuredGrid->GetPointData()->SetScalars(scalars); vtkSmartPointer geomFilter = - vtkSmartPointer::New(); + vtkSmartPointer::New(); geomFilter->SetInputData(structuredGrid); geomFilter->Update(); - + vtkSmartPointer warpScalar = - vtkSmartPointer::New(); - + vtkSmartPointer::New(); + double scaleFactor = this->ScaleFactor; if (this->UseOptimusScale) + { + double range[2]; + geomFilter->GetOutput()->GetScalarRange(range); + double length = geomFilter->GetOutput()->GetLength(); + if (range[1] > 0) { - double range[2]; - geomFilter->GetOutput()->GetScalarRange(range); - double length = geomFilter->GetOutput()->GetLength(); - if (range[1] > 0) - { - scaleFactor = length / range[1] * 0.3; - } - else - { - scaleFactor = 0; - } + scaleFactor = length / range[1] * 0.3; } - - if (this->PresentationType == TABLETO3D_SURFACE) + else { - warpScalar->SetInputConnection(geomFilter->GetOutputPort(0)); - warpScalar->SetScaleFactor(scaleFactor); + scaleFactor = 0; } + } + + if (this->PresentationType == TABLETO3D_SURFACE) + { + warpScalar->SetInputConnection(geomFilter->GetOutputPort(0)); + warpScalar->SetScaleFactor(scaleFactor); + } else - { - vtkSmartPointer contourFilter = - vtkSmartPointer::New(); - contourFilter->SetInputConnection(geomFilter->GetOutputPort(0)); - contourFilter->GenerateValues(this->NumberOfContours, - geomFilter->GetOutput()->GetScalarRange()); - warpScalar->SetInputConnection(contourFilter->GetOutputPort(0)); - warpScalar->SetScaleFactor(scaleFactor); - } + { + vtkSmartPointer contourFilter = + vtkSmartPointer::New(); + contourFilter->SetInputConnection(geomFilter->GetOutputPort(0)); + contourFilter->GenerateValues(this->NumberOfContours, + geomFilter->GetOutput()->GetScalarRange()); + warpScalar->SetInputConnection(contourFilter->GetOutputPort(0)); + warpScalar->SetScaleFactor(scaleFactor); + } warpScalar->Update(); output->ShallowCopy(warpScalar->GetPolyDataOutput()); - + return 1; } @@ -206,9 +206,9 @@ void vtkTableTo3D::PrintSelf(ostream& os, vtkIndent indent) os << indent << "ScaleFactor: " << this->ScaleFactor << endl; os << indent << "UseOptimusScale: " - << (this->UseOptimusScale? "true" : "false") << endl; + << (this->UseOptimusScale? "true" : "false") << endl; os << indent << "PresentationType: " - << ((this->PresentationType == TABLETO3D_SURFACE)? "Surface" : "Contour") - << endl; + << ((this->PresentationType == TABLETO3D_SURFACE)? "Surface" : "Contour") + << endl; os << indent << "NumberOfContours: " << this->NumberOfContours << endl; }