[Paraview] Application using Paraview library in C++

Adebayo Olowoyeye aolowoye at umail.iu.edu
Tue Jan 26 02:38:20 EST 2010


Hi all,
  I am attempting to use paraview's library to visualize medical volumes in
an application I am building from scratch.  The program is written in C++.
I am having a hard time finding adequate documentation (forums and examples)
that shows how to build an application that uses paraview's library in C++.
I have ran the example program BasicApp.cxx and it works, but it uses a
SphereSource.  I am loading dicom images or .vtk images.  When I edit the
code for BasicApp.cxx to load .vtk files I get an error after setting the
representation to volume.  From reading similar problems on forums, I think
the problem pertains to colormaps and scalars, but I cannot find
documentation on how to fix this in C++.  I'm including my code below.  I
may be over complicating this, but any help is appreciated.
Thanks for your time!

using namespace std;

// our main window
class MainWindow : public QMainWindow
{
public:
  MainWindow()
  {
    // automatically make a server connection
    pqApplicationCore* core = pqApplicationCore::instance();
    pqObjectBuilder* ob = core->getObjectBuilder();
    pqServer* server = ob->createServer(
pqServerResource("builtin:"));

    // create a graphics window and put it in our main window
    this->RenderView =
qobject_cast<pqRenderView*>(ob->createView(pqRenderView::renderViewType(),
server));
    this->setCentralWidget(this->RenderView->getWidget());

    // create source and elevation filter
    pqPipelineSource* source;
    pqPipelineSource* elevation;

    source = ob->createSource("sources", "SphereSource", server);
    // updating source so that when elevation filter is created, the
defaults
    // are setup correctly using the correct data bounds etc.
    vtkSMSourceProxy::SafeDownCast(source->getProxy())->UpdatePipeline();

    QStringList files;
    files.push_back("../brain.vtk");

    pqPipelineSource *reader;
    pqObjectBuilder *builder = core->getObjectBuilder();
    reader = builder->createReader(QString("internal_sources"),
QString("legacyreader"), files, server);


    pqDataRepresentation *repr =
ob->createDataRepresentation(reader->getOutputPort(0), this->RenderView);

    if(repr){

        vtkSMPropertyHelper(repr->getProxy(),
"Representation").Set(vtkSMPVRepresentationProxy::VOLUME);

        pqDisplayPolicy pqDisplayP = core->getDisplayPolicy();
        repr->getProxy()->UpdateVTKObjects();

    }

    //elevation = ob->createFilter("filters", "ElevationFilter", source);

    // put the elevation in the window
    //ob->createDataRepresentation(elevation->getOutputPort(0),
this->RenderView);

    // zoom to sphere
    this->RenderView->resetCamera();
    // make sure we update
    this->RenderView->render();
  }

  QPointer<pqRenderView> RenderView;

};
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100125/edf6ce80/attachment.htm>


More information about the ParaView mailing list