[vtk-developers] Bug in vtkCompositeDataPipeline?
Jeff Lee
jeff at cdnorthamerica.com
Fri May 26 10:32:14 EDT 2006
Bill McGrory wrote:
> I'm not sure I understand what you're saying.
> I understand that vtkStructuredGridOutlineFilter only accepts
> vtkStructuredGrid as input.
>
>
> It is my understanding that vtkMultiGroupDataGeometryFilter handles the
> the case of a simple filter, and sends the children of a
> multigroupdataset one at a time. I don't think the problem is with the
> pipeline after the dataset, but with the pipeline getting the data from
> a source.
>
I guess I got confused, does this all work when you manually create the
sgrids, and fails when you try to use the source? I thought that
neither way would work because you are setting the input of the
StructuredGridOutlineFilter which doesn't handle MultiBlockDataSets at all.
-J
> I'm attaching my test code.
> there is a #if loop on line 113 used to switch back and forth.
>
>
> On Fri, 2006-05-26 at 08:45 -0400, Jeff Lee wrote:
>
>> So is this right, you are setting the input of the
>> vtkStructuredGridOutlineFilter with a vtkMultiBlockDataSet? If not,
>> can you post a prototype pipeline? vtkStructuredGridOutlineFilter
>> doesn't accept any input other than vtkStructuredGrid.
>> FillInputPortInformation could take a dataset and do the appropriate
>> thing for a multiblock dataset consisting of structured grids, or just
>> process the structured grids. But this should probably be another
>> filter along the lines of vtkMultiGroupDataGeometryFilter...
>> -Jeff
>>
>> Bill McGrory wrote:
>>
>>> Yes, that is correct.
>>> I have two datasets constructed from two custom sources.
>>> I put these two datasets into a multiblock dataset.
>>>
>>> multiblock dataset is then fed to a structuredgridoutline filter.
>>>
>>> this is fed to a vtkMultiGroupDataGeometry filter and mapped.
>>>
>>> Before adding the patches listed below, the vtkStructuredGridSource
>>> never receives a ExecuteData call.
>>>
>>> If I fill the two datasets by hand, before adding them to the multiblock
>>> dataset then everything works as expected.
>>>
>>> Likewise, if I simply feed the vtkStructuredGridSource->GetOutput()
>>> directly to the Outline filter (bypass the multiblock dataset) then the
>>> source correctly gets the ExecuteData call as well.
>>>
>>> Regards
>>> Bill
>>>
>>> On Thu, 2006-05-25 at 16:55 -0400, Berk Geveci wrote:
>>>
>>>
>>>> I am not sure I understand. You have a few datasets, you add these to
>>>> a multiblock dataset, you process this multiblock dataset with a
>>>> filter. Is that right?
>>>>
>>>> On 5/25/06, Bill McGrory <mcgrory at aerosft.com> wrote:
>>>> I've been trying to get a
>>>> vtkMultiBlockDataSet to work properly with vtkStructuredGrid's
>>>> which are
>>>> output from a vtkStructuredGridSource
>>>>
>>>> >From what I can tell, it appears that the
>>>> the vtkCompositeDataPipeline
>>>> is unaware of child vtkDataObject->Source, so none of the data
>>>> ever gets
>>>> loaded.
>>>>
>>>> I have constructed a work-around which appears (superficially
>>>> at least)
>>>> to work for my particular case, which is basically, if a
>>>> Source exists
>>>> for the original vtkDataObject in the *ForBlock() routines,
>>>> call the
>>>> relevant Update's before performing the ShallowCopy
>>>>
>>>> patch is as follows
>>>>
>>>> Index: vtkCompositeDataPipeline.cxx
>>>> ===================================================================
>>>> RCS
>>>> file: /cvsroot/VTK/VTK/Filtering/vtkCompositeDataPipeline.cxx,v
>>>> retrieving revision 1.34
>>>> diff -u -r1.34 vtkCompositeDataPipeline.cxx
>>>> --- vtkCompositeDataPipeline.cxx 7 Dec 2005 16:21:29
>>>> -0000 1.34
>>>> +++ vtkCompositeDataPipeline.cxx 25 May 2006 19:48:48
>>>> -0000
>>>> @@ -35,6 +35,8 @@
>>>> #include "vtkStructuredGrid.h"
>>>> #include "vtkUniformGrid.h"
>>>>
>>>> +#include "vtkSource.h"
>>>> +
>>>> vtkCxxRevisionMacro(vtkCompositeDataPipeline, "$Revision: 1.34
>>>> $");
>>>> vtkStandardNewMacro(vtkCompositeDataPipeline);
>>>>
>>>> @@ -46,6 +48,28 @@
>>>>
>>>> vtkInformationKeyMacro(vtkCompositeDataPipeline,INPUT_REQUIRED_COMPOSITE_DATA_TYPE, String);
>>>> vtkInformationKeyMacro(vtkCompositeDataPipeline,UPDATE_BLOCKS,
>>>> ObjectBase);
>>>>
>>>> +class vtkCompositeDataPipelineToDataObjectFriendship
>>>> +{
>>>> +public:
>>>> + static void UpdateDataObject(vtkDataObject* obj)
>>>> + {
>>>> + if(obj->Source)
>>>> + {
>>>> + obj->Source->Update();
>>>> + }
>>>> +
>>>> + }
>>>> +
>>>> + static void UpdateInformation(vtkDataObject* obj)
>>>> + {
>>>> + if(obj->Source)
>>>> + {
>>>> + obj->Source->UpdateInformation();
>>>> + }
>>>> +
>>>> + }
>>>> +};
>>>> +
>>>> //----------------------------------------------------------------------------
>>>> vtkCompositeDataPipeline::vtkCompositeDataPipeline()
>>>> {
>>>> @@ -490,6 +514,7 @@
>>>> info->Get(vtkDataObject::DATA_OBJECT());
>>>> if (dobj && dobjCopy)
>>>> {
>>>> +
>>>> vtkCompositeDataPipelineToDataObjectFriendship::UpdateInformation(dobj);
>>>> dobjCopy->ShallowCopy(dobj);
>>>> dobjCopy->CopyInformation(dobj);
>>>> }
>>>> @@ -1089,6 +1114,7 @@
>>>>
>>>> if (dobj && dobjCopy)
>>>> {
>>>> +
>>>> vtkCompositeDataPipelineToDataObjectFriendship::UpdateDataObject(dobj);
>>>> dobjCopy->ShallowCopy(dobj);
>>>> }
>>>> }
>>>>
>>>>
>>>> Is this really a bug, and is this an appropriate fix?
>>>> Or am I doing something wrong up the pipeline, such that I
>>>> shouldn't
>>>> need to do this?
>>>>
>>>> Regards
>>>> Bill
>>>> _______________________________________________
>>>> vtk-developers mailing list
>>>> vtk-developers at vtk.org
>>>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> vtk-developers mailing list
>>> vtk-developers at vtk.org
>>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>>
>>>
>>>
>>>
>
>
> ------------------------------------------------------------------------
>
> /*=========================================================================
>
> Program: Visualization Toolkit
> Module: $RCSfile: SGrid.cxx,v $
>
> 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.
>
> =========================================================================*/
> // This example shows how to manually create a structured grid.
> // The basic idea is to instantiate vtkStructuredGrid, set its dimensions,
> // and then assign points defining the grid coordinate. The number of
> // points must equal the number of points implicit in the dimensions
> // (i.e., dimX*dimY*dimZ). Also, data attributes (either point or cell)
> // can be added to the dataset.
> //
> //
> #include "vtkActor.h"
> #include "vtkCamera.h"
> #include "vtkCommand.h"
> #include "vtkFloatArray.h"
> #include "vtkHedgeHog.h"
> #include "vtkImageActor.h"
> #include "vtkImageMapToColors.h"
> #include "vtkInteractorStyleTrackballCamera.h"
> #include "vtkMath.h"
> #include "vtkPoints.h"
> #include "vtkPointData.h"
> #include "vtkPolyData.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkPolyDataNormals.h"
> #include "vtkProperty.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkStructuredGrid.h"
> #include "vtkStructuredGridGeometryFilter.h"
> #include "vtkStructuredGridOutlineFilter.h"
> #include "vtkMultiBlockDataSet.h"
> #include "vtkMultiGroupDataGeometryFilter.h"
>
> #include "vtkStructuredGridSource.h"
> #include "vtkObjectFactory.h"
> #include "vtkInformation.h"
> #include "vtkInformationVector.h"
> #include "vtkDemandDrivenPipeline.h"
> #include "vtkStreamingDemandDrivenPipeline.h"
> #include "vtkSource.h"
>
> // Define callbacks
>
>
> void AllocGrid(vtkStructuredGrid *sgrid, float myoffset);
>
> class MyStructuredGridSource
> : public vtkStructuredGridSource
> {
>
> public:
>
> vtkTypeRevisionMacro(MyStructuredGridSource,vtkStructuredGridSource);
>
> void PrintSelf(ostream& os, vtkIndent indent);
>
> static MyStructuredGridSource *New();
>
> virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector);
>
> int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector);
>
> public:
>
> float myoffset;
>
> protected:
>
>
> MyStructuredGridSource();
> ~MyStructuredGridSource();
>
> virtual void ExecuteData (vtkDataObject *output);
>
> private:
>
> MyStructuredGridSource(const MyStructuredGridSource&); // Not implemented.
> void operator=(const MyStructuredGridSource&); // Not implemented.
>
> };
>
> int
> main( int argc, char *argv[] )
> {
> // Create a renderer.
>
> vtkRenderer *ren = vtkRenderer::New();
> ren->SetBackground(1,1,1);
> ren->TwoSidedLightingOn();
> ren->LightFollowCameraOn();
> ren->GetActiveCamera()->Elevation(30.0);
> ren->GetActiveCamera()->Azimuth(30.0);
> ren->GetActiveCamera()->Zoom(10.0);
>
> // Load two vtkStructuredGrid's into a multi-block dataset
>
> vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::New();
>
>
> #if 0
>
> // First way is to get the vtkStructureGrid from a custom vtkStructuredGridSource
>
> MyStructuredGridSource *sgridsrc0 = MyStructuredGridSource::New();
> MyStructuredGridSource *sgridsrc1 = MyStructuredGridSource::New();
>
> sgridsrc0->myoffset = 0.;
> sgridsrc1->myoffset = 3.;
>
> vtkStructuredGrid *sgrid0 = sgridsrc0->GetOutput();
> vtkStructuredGrid *sgrid1 = sgridsrc1->GetOutput();
>
> #else
>
> // Second way is to simply create the sgrid's by hand
>
> vtkStructuredGrid *sgrid0 = vtkStructuredGrid::New();
> vtkStructuredGrid *sgrid1 = vtkStructuredGrid::New();
>
> AllocGrid(sgrid0, 0.);
> AllocGrid(sgrid1, 3.);
>
> #endif
>
> mb->SetDataSet(0, 0, sgrid0);
> mb->SetDataSet(1, 0, sgrid1);
>
> // Now put the sgrid's into a vtkStructuredGridOutlineFilter
>
> vtkStructuredGridOutlineFilter *oFilter = vtkStructuredGridOutlineFilter::New();
> vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
>
> oFilter->SetInput(mb);
>
> vtkMultiGroupDataGeometryFilter *filter = vtkMultiGroupDataGeometryFilter::New();
> filter->SetInputConnection(0, oFilter->GetOutputPort(0));
> oFilter->Delete();
>
> mapper->SetInputConnection(0, filter->GetOutputPort(0));
> filter->Delete();
>
> vtkActor* actor = vtkActor::New();
> actor->SetMapper(mapper);
> actor->GetProperty()->SetColor(0,0,0);
>
> ren->AddActor(actor);
>
> mapper->Delete();
> actor->Delete();
>
> // Define the render window
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren);
> renWin->SetSize(600,600);
>
> // Define a window interactor to move the scene around
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
> // Set the interactor style to a trackball camera.
> vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
> iren->SetInteractorStyle(style);
>
> // Interact with data
>
> renWin->Render();
>
>
> iren->Initialize();
> iren->Start();
>
> ren->Delete();
> renWin->Delete();
> iren->Delete();
> style->Delete();
>
> return 0;
>
> }
>
>
> vtkCxxRevisionMacro(MyStructuredGridSource, "$Revision: 0.1 $");
>
> vtkStandardNewMacro(MyStructuredGridSource);
>
> MyStructuredGridSource::MyStructuredGridSource()
> : vtkStructuredGridSource()
> {
> }
>
> MyStructuredGridSource::~MyStructuredGridSource()
> {
> }
>
> void
> MyStructuredGridSource::PrintSelf(ostream& os, vtkIndent indent)
> {
> this->Superclass::PrintSelf(os, indent);
> }
>
>
> int
> MyStructuredGridSource::ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
> {
> if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) {
>
> return this->RequestInformation(request, inputVector, outputVector);
>
> }
>
> return this->Superclass::ProcessRequest(request, inputVector, outputVector);
> }
>
> int
> MyStructuredGridSource::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
> {
>
> vtkInformation *outInfo = outputVector->GetInformationObject(0);
>
> int ext[6];
>
> ext[0] = 0;
> ext[1] = 13;
> ext[2] = 0;
> ext[3] = 11;
> ext[4] = 0;
> ext[5] = 11;
>
> --ext[1];
> --ext[3];
> --ext[5];
>
> outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
> ext, 6);
>
> return 1;
> }
>
>
>
> void
> MyStructuredGridSource::ExecuteData(vtkDataObject *output)
> {
>
> vtkStructuredGrid *sgrid = vtkStructuredGrid::SafeDownCast(output);
>
> AllocGrid(sgrid,myoffset);
>
> }
>
>
> void
> AllocGrid(vtkStructuredGrid *sgrid, float myoffset)
> {
> int i, j, k, kOffset, jOffset, offset;
> float x[3];
>
> int dims[3]={13,11,11};
>
>
> float radius, rMin=0.5, rMax=1.0, deltaRad;
> float theta, deltaZ;
>
>
> sgrid->SetWholeExtent(0,dims[0]-1,0,dims[1]-1,0,dims[2]-1);
> sgrid->SetDimensions(dims);
>
> // A 1-D array of grid points (r cos, r sin, z) where theta(i), r(j), z(k)
>
> vtkPoints *points = vtkPoints::New();
> points->Allocate(dims[0]*dims[1]*dims[2]);
>
> // Create a hemi-cylindrical grid
>
> deltaZ = 2.0 / (dims[2]-1);
> deltaRad = (rMax-rMin) / (dims[1]-1);
>
> for (k=0; k<dims[2]; k++) {
>
> x[2] = myoffset -1.0 + k*deltaZ;
> kOffset = k * dims[0] * dims[1];
>
> for (j=0; j<dims[1]; j++) {
>
> radius = rMin + j*deltaRad;
> jOffset = j * dims[0];
>
> for (i=0; i<dims[0]; i++) {
>
> theta = i * 15.0 * vtkMath::DegreesToRadians();
>
> x[0] = radius * cos(theta);
> x[1] = radius * sin(theta);
>
> offset = i + jOffset + kOffset;
>
> points->InsertPoint(offset,x);
>
> }
> }
> }
>
> // Set the grid points
> sgrid->SetPoints(points);
> points->Delete();
>
> }
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
More information about the vtk-developers
mailing list