[Ves] Simple example of using Kiwi/VES

Pat Marion james.patrick.marion at gmail.com
Fri Apr 11 11:41:17 EDT 2014


While can use the VES API directly to create arrays of points and
triangles, I'd recommend starting with VTK APIs to generate geometry using
VTK sources, for example, the
vtkSphereSource<http://www.vtk.org/doc/nightly/html/classvtkSphereSource.html>is
used create sphere geometry with custom parameters like radius and
resolution.  Using something like the vtkSphereSource, you'll get an output
object of type vtkPolyData.  If this sounds new to you, then you might want
to start by following some VTK tutorials:

http://www.vtk.org/Wiki/VTK/Tutorials

Anyway, once you have your geometry as a VTK object, you can use this
function to add it to the vesKiwiViewerApp's renderer:

  void vesKiwiViewerApp::addRepresentationsForDataSet(vtkDataSet* dataSet);

Note that this method is protected.  You should derive a new class from
vesKiwiViewerApp.  Then you will have access to all the protected methods.
Example:

class MyApp : public vesKiwiViewerApp
{
public:

vtkSmartPointer<vtkPolyData> mSphereGeometry;

  void addSphere()
  {

    vtkNew<vtkSphereSource> sphereSource;
    sphereSource->SetRadius(2.5);
    sphereSource->Update();
    mSphereGeometry = sphereSource->GetOutput();

   this->addRepresentationsForDataSet(mSphereGeometry);

   // or
  // this->addPolyDataRepresentation(mSphereGoemtry, this->shaderProgram());

 }

};


Then, in your iOS app, create MyApp instead of vesKiwiViewerApp, and call
addSphere().  For more example code, read vesKiwiViewerApp.cpp.  For
examples to create VES data arrays, see methods in
vesKiwiDataConversionTools.cpp.

Hope this helps!

Pat


On Fri, Apr 11, 2014 at 11:15 AM, Zhichao Hong <zhichao.hong at gmail.com>wrote:

> I have played with both KiwiSimple and KiwiViewer.  But I am still looking
> for an iOS and/or Android example that can show how to make simpler task
> happen such as draw a sphere surface using ves directly.  The loadDataset
> is nice.  However, it only supports loading the data from a file (vtk, stl,
> etc).  Is there a way to draw a shape directly from the memory?
>
> Any hint will be appreciated!
>
> Zhichao Hong, CSDP
> zhichao.hong at computer.org
>
> _______________________________________________
> Ves mailing list
> Ves at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/ves
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ves/attachments/20140411/5fa5cb75/attachment-0003.html>


More information about the Ves mailing list