View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0012985 | VTK | (No Category) | public | 2012-03-09 10:37 | 2016-08-12 09:55 | ||||
Reporter | Dominic Plourde | ||||||||
Assigned To | Dave DeMarle | ||||||||
Priority | normal | Severity | minor | Reproducibility | have not tried | ||||
Status | closed | Resolution | moved | ||||||
Platform | OS | OS Version | |||||||
Product Version | 5.8.0 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0012985: vtkDataObjectToTable don't transfere points | ||||||||
Description | I made a patch for create 3 news columns(X, Y, Z) in the vtkTable output when the option IsTransferPoints is set to On. Diff: /*========================================================================= Program: Visualization Toolkit Module: vtkDataObjectToTable.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm [^] for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /*------------------------------------------------------------------------- Copyright 2008 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. -------------------------------------------------------------------------*/ // .NAME vtkDataObjectToTable - extract field data as a table // // .SECTION Description // This filter is used to extract either the field, cell or point data of // any data object as a table. #ifndef __vtkDataObjectToTable_h #define __vtkDataObjectToTable_h #include "vtkTableAlgorithm.h" class VTK_INFOVIS_EXPORT vtkDataObjectToTable : public vtkTableAlgorithm { public: static vtkDataObjectToTable* New(); vtkTypeMacro(vtkDataObjectToTable,vtkTableAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); //BTX enum { FIELD_DATA = 0, POINT_DATA = 1, CELL_DATA = 2, VERTEX_DATA = 3, EDGE_DATA = 4 }; //ETX // Description: // The field type to copy into the output table. // Should be one of FIELD_DATA, POINT_DATA, CELL_DATA, VERTEX_DATA, EDGE_DATA. vtkGetMacro(FieldType, int); vtkSetClampMacro(FieldType, int, 0, 4); + // Description: + // Turn on/off the transfere of points to the output. + vtkGetMacro(IsTransferPoints, bool); + vtkSetMacro(IsTransferPoints, bool); + vtkBooleanMacro(IsTransferPoints, bool); protected: vtkDataObjectToTable(); ~vtkDataObjectToTable(); int FillInputPortInformation(int port, vtkInformation* info); + void AddPointsColumn(vtkTable *output, vtkDataObject *input); int RequestData( vtkInformation*, vtkInformationVector**, vtkInformationVector*); int FieldType; + bool IsTransferPoints; private: vtkDataObjectToTable(const vtkDataObjectToTable&); // Not implemented void operator=(const vtkDataObjectToTable&); // Not implemented }; #endif /*========================================================================= Program: Visualization Toolkit Module: vtkDataObjectToTable.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm [^] for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /*------------------------------------------------------------------------- Copyright 2008 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. -------------------------------------------------------------------------*/ #include "vtkDataObjectToTable.h" #include "vtkCellData.h" #include "vtkDataObject.h" #include "vtkDataSet.h" #include "vtkDataSetAttributes.h" #include "vtkGraph.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" + #include "vtkPointSet.h" #include "vtkTable.h" + #include "vtkPoints.h" + #include "vtkDoubleArray.h" vtkStandardNewMacro(vtkDataObjectToTable); //--------------------------------------------------------------------------- vtkDataObjectToTable::vtkDataObjectToTable() { this->FieldType = POINT_DATA; } //--------------------------------------------------------------------------- vtkDataObjectToTable::~vtkDataObjectToTable() { } //--------------------------------------------------------------------------- int vtkDataObjectToTable::FillInputPortInformation( int vtkNotUsed(port), vtkInformation* info) { info->Remove(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE()); info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet"); info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkGraph"); info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkTable"); return 1; } //--------------------------------------------------------------------------- int vtkDataObjectToTable::RequestData( vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { // Get input data vtkInformation* inputInfo = inputVector[0]->GetInformationObject(0); vtkDataObject* input = inputInfo->Get(vtkDataObject::DATA_OBJECT()); // Get output table vtkInformation* outputInfo = outputVector->GetInformationObject(0); vtkTable* output = vtkTable::SafeDownCast( outputInfo->Get(vtkDataObject::DATA_OBJECT())); // If the input is a table, just copy it into the output. if (vtkTable::SafeDownCast(input)) { output->ShallowCopy(input); return 1; } vtkDataSetAttributes* data = vtkDataSetAttributes::New(); switch(this->FieldType) { case FIELD_DATA: if(input->GetFieldData()) { data->ShallowCopy(input->GetFieldData()); } break; case POINT_DATA: if(vtkDataSet* const dataset = vtkDataSet::SafeDownCast(input)) { if(dataset->GetPointData()) { data->ShallowCopy(dataset->GetPointData()); } } break; case CELL_DATA: if(vtkDataSet* const dataset = vtkDataSet::SafeDownCast(input)) { if(dataset->GetCellData()) { data->ShallowCopy(dataset->GetCellData()); } } break; case VERTEX_DATA: if(vtkGraph* const graph = vtkGraph::SafeDownCast(input)) { if(graph->GetVertexData()) { data->ShallowCopy(graph->GetVertexData()); } } break; case EDGE_DATA: if(vtkGraph* const graph = vtkGraph::SafeDownCast(input)) { if(graph->GetEdgeData()) { data->ShallowCopy(graph->GetEdgeData()); } } break; } output->SetRowData(data); + if(GetIsTransferPoints()) + AddPointsColumn(output, input); data->Delete(); return 1; } + +//--------------------------------------------------------------------------- +void vtkDataObjectToTable::AddPointsColumn(vtkTable* output, vtkDataObject* input) +{ + if(vtkPointSet* const pointsSet = vtkPointSet::SafeDownCast(input)) + { + vtkPoints* points = pointsSet->GetPoints(); + + if(points->GetNumberOfPoints() > 0) + { + vtkDoubleArray* xArray = vtkDoubleArray::New(); + vtkDoubleArray* yArray = vtkDoubleArray::New(); + vtkDoubleArray* zArray = vtkDoubleArray::New(); + + xArray->SetName("X"); + yArray->SetName("Y"); + zArray->SetName("Z"); + + for(int i=0; i<points->GetNumberOfPoints(); ++i) + { + double* currentPoint = points->GetPoint(i); + xArray->InsertNextValue(currentPoint[0]); + yArray->InsertNextValue(currentPoint[1]); + zArray->InsertNextValue(currentPoint[2]); + } + output->AddColumn(xArray); + output->AddColumn(yArray); + output->AddColumn(zArray); + } + } +} //--------------------------------------------------------------------------- void vtkDataObjectToTable::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "FieldType: " << this->FieldType << endl; } | ||||||||
Tags | No tags attached. | ||||||||
Project | TBD | ||||||||
Type | incorrect functionality | ||||||||
Attached Files | ![]() | ||||||||
Relationships | |
Relationships |
Notes | |
(0031172) Dave DeMarle (administrator) 2013-07-22 16:41 |
If this is still an issue in VTK 6, please reopen the bug, and if possible submit the patch via Gerrit where we can review it. Step by step instructions are here: http://www.vtk.org/Wiki/VTK/Git/Develop [^] |
(0037269) Kitware Robot (administrator) 2016-08-12 09:55 |
Resolving issue as `moved`. This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2012-03-09 10:37 | Dominic Plourde | New Issue | |
2012-03-09 10:37 | Dominic Plourde | File Added: vtkDataObjectToTable.zip | |
2013-07-22 16:41 | Dave DeMarle | Note Added: 0031172 | |
2013-07-22 16:41 | Dave DeMarle | Status | backlog => expired |
2013-07-22 16:41 | Dave DeMarle | Assigned To | => Dave DeMarle |
2016-08-12 09:55 | Kitware Robot | Note Added: 0037269 | |
2016-08-12 09:55 | Kitware Robot | Status | expired => closed |
2016-08-12 09:55 | Kitware Robot | Resolution | open => moved |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |