[Paraview] Application using Paraview library in C++

Eric E. Monson emonson at cs.duke.edu
Wed Jan 27 09:11:36 EST 2010


Hello Adebayo,

Sorry I'm not going to address your question directly (because I don't know the answer), but I wanted to make sure you know about other options that are available to you for building applications based on ParaView. Maybe you've thought all of this through  already -- in that case please excuse me.

If you want or need the capabilities of ParaView to deal with large data sets, or if you want to just build upon other nice existing elements of ParaView, but you don't need all of its functionality, there is now a much easier way to build a simplified / customized version of ParaView through "branding". This wiki page describes the process:

http://www.paraview.org/Wiki/Writing_Custom_Applications

There are also six examples in {PVsource}/Examples/CustomApplications.

This way it is not difficult to get ParaView's basic functionality, and then add your own custom readers, filters, widgets, etc, through plugins. 

If you don't need to scale your application to very large data sets, then personally I find it easier to build a custom application directly using VTK rather than building upon ParaView's libraries.

Take care,
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Jan 26, 2010, at 8:24 PM, pat marion wrote:

> Hi,
> 
> You should include the exact error message you are getting so that people can help.
> 
> I'm not very familiar with building custom apps using paraview so I won't be able to answer your question exactly... but to change the representation to volume you must create proxy objects for a lookup table and a piecewise function, then assign them to the representation's proxy properties LookupTable and ScalarOpacityFunction.  
> 
> The best example I have is in python- a image-data source is created and the representation is set to volume, the scalar value 37 is set to the color red with an opacity value of 0, and scalar value 270 is set to the color blue with opacity value 0.5:
> 
> Wavelet()
> rep = Show()
> rep.ColorArrayName = "RTData"
> rep.Representation = "Volume"
> 
> lut = CreateLookupTable()
> lut.RGBPoints = [37, 1, 0, 0, 270, 0, 0, 1]
> rep.LookupTable = lut
> 
> func = CreatePiecewiseFunction()
> func.Points = [37, 0, 270, 0.5]
> rep.ScalarOpacityFunction = func
> 
> Render()
> 
> 
> Goodluck!
> 
> Pat
> 
> On Tue, Jan 26, 2010 at 2:38 AM, Adebayo Olowoyeye <aolowoye at umail.iu.edu> wrote:
> 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;
> 
> };
> ...
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
> 
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
> 
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100127/d152cafb/attachment-0001.htm>


More information about the ParaView mailing list