[vtkusers] vtkThreadedController::singleMethodExecute
ban4n
ban4n at online.no
Wed May 7 09:02:47 EDT 2003
Hi all.
I'm using the example ParallelIso.cxx as a template for my program.
I wonder if it's possible to put some of the pipeline in the main-method
instead of MyMain.
I've tried to put the mapper in the main-method and call Update on it, but
nothing happens.
As far as I know, none of the process-objects are deleted, but it seems that
the pipe is broken anyway.
I'd appreciate any help on this.
*-----------------------------------------------*
C O D E
*-----------------------------------------------*
Intro:
The code in "paraPipe" has a pipe which seems to run well, I want to
use the resulting output of this pipe as the input(the Mapper-GetOutput)
for the Actor set up outside the paraPipe method.
When trying to run the code the vizualisation hangs, seems like using the
mapper's
output from the paraPipe method for the Actor doesn't work. Perhaps because
Actor, when asking for the mapper's output, want the mapper to do a update on
it's
pipe to "regenerate" it's output..?
----------------------------------------------------
Mainwindow::fileImport
----------------------------------------------------
void MainWindow::fileImport()
{
Dataset * ds = new Dataset(this, pProgressDialog);
pDatasetList->append(ds);
cout << "ds->initParaPipe();" << endl;
ds->initParaPipe();
cout << "fileImport() finished" << endl;
}
----------------------------------------------------
Dataset::initParaPipe
----------------------------------------------------
void Dataset::initParaPipe()
{
cout << "initParaPipe()" << endl;
//pVtkMultiProcessController = vtkMultiProcessController::New();
int argc = qApp->argc();
char ** argv = qApp->argv();
pVtkMultiProcessController->Initialize(&argc, &argv);
pVtkMultiProcessController->SetSingleMethod(¶Pipe,
reinterpret_cast<void*>(this));
if(pVtkMultiProcessController->IsA("vtkThreadedController"))
{
pVtkMultiProcessController->SetNumberOfProcesses(3);
}
cout << "SingleMethodExecute()" << endl;
pVtkMultiProcessController->SingleMethodExecute();
cout << "Finalize()" << endl;
pVtkMultiProcessController->Finalize();
}
-----------------------------------------------------
Paralell pipe using MultiThread, ThreadedController..
-----------------------------------------------------
void paraPipe(vtkMultiProcessController * controller, void * arg)
{
cout << "paraPipe()" << endl;
Dataset * ds = reinterpret_cast<Dataset *>(arg);
QString pathToFiles = "/home/peteabre/datasett/xykcl1png/kcl1b.png";
int resX = 1460;
int resY = 512;
double dataSpaceX = 1;
double dataSpaceY = 1;
double dataSpaceZ = 1;
int firstPictNr = 0;
int lastPictNr = 15;
int myId, numProcs;
myId = controller->GetLocalProcessId();
cout << "myId = " << myId << endl;
numProcs = controller->GetNumberOfProcesses();
vtkPNGReader * pReader = vtkPNGReader::New();
vtkMarchingCubes * pMCubes = vtkMarchingCubes::New();
StartEvent * pStartEvent = new StartEvent();
showProgress * pShowProgress = new showProgress(myId);
EndEvent * pEndEvent = new EndEvent();
pReader->SetDataOrigin(0.0,0.0,0.0);
pReader->SetFilePrefix(pathToFiles);
pReader->SetDataSpacing(dataSpaceX, dataSpaceY, dataSpaceZ);
pReader->SetDataExtent(0,resX-1,0,resY-1, firstPictNr, lastPictNr);
pMCubes->SetInput(pReader->GetOutput());
pMCubes->SetValue(0,1); //Binarised
picture, thus threshold 1 is enough
pMCubes->ComputeGradientsOff();
pMCubes->ComputeScalarsOff();
pMCubes->ComputeNormalsOn();
if(myId != 0)
{
cout << myId << ": satelite-process" << endl;
vtkOutputPort * upPort = vtkOutputPort::New();
upPort->SetInput(pMCubes->GetOutput());
upPort->SetTag(ds->PORT_TAG);
cout << myId << ": WaitForUpdate()" << endl;
upPort->WaitForUpdate();
}
else
{
cout << myId << ": root-process" << endl;
int i;
vtkInputPort * downPort;
vtkAppendPolyData * app = vtkAppendPolyData::New();
app->AddInput(pMCubes->GetOutput());
app->ParallelStreamingOn();
cout << myId << ": numProcs = " << numProcs << endl;
for(i = 1; i < numProcs; ++i)
{
cout << myId << ": forl�kke: i=" << i << endl;
downPort = vtkInputPort::New();
downPort->SetRemoteProcessId(i);
downPort->SetTag(ds->PORT_TAG);
app->AddInput(downPort->GetPolyDataOutput());
}
ds->setPolyData(app->GetOutput());
cout << myId << ": ds->addMapper();" << endl;
ds->addMapper();
cout << myId << ": ds->getMainWindow()->createView(ds);" <<
endl;
ds->getMainWindow()->createView(ds);
for(i = 1; i < numProcs; ++i)
{
controller->TriggerRMI(i,
vtkMultiProcessController::BREAK_RMI_TAG);//Stopper k�lkoking
}
}
cout << myId << ": end of paraPipe" << endl;
}
------------------------------------------------------------------------------
-----------
MainWindow::createView (this is where I want to use the output from
the paraPipe)
------------------------------------------------------------------------------
------------
void MainWindow::createView(Dataset * pDataset)
{
View * pView = new View(pDataset, pWorkspace , 0, WDestructiveClose);
CHECK_PTR( pView );
pView->createActor(pDataset->getMapper()); //The Critical point
pView->GetRenderer()->ResetCamera();
pDataset->addView(pView);
pView->resize(400,400);
pView->setFocus();
this->setLastActiveView(pView);
pView->saveCameraState();
pView->setCaption(pDataset->getTitle());
pView->setCursor(pWorkspace->cursor());
pViewPanel->addDataset(pDataset->getTitle());
pView->installEventFilter(this);
pView->show();
}
--------------------------------------------------
View::createActor
--------------------------------------------------
void View::createActor(vtkPolyDataMapper * pMapper)
{
pActor = vtkLODActor::New();
pActor->SetMapper(pMapper);
GetRenderer()->AddActor(pActor);
}
More information about the vtkusers
mailing list