Creating Libraries for Multiple Programming Languages
by Ken Martin, William Hoffmanm, Berk Geveci 

Example 1: 

// C++
vtkPolyDataReader* skinReader = vtkPolyDataReader::New();
skinReader->SetFileName("/vtkdata/skin.vtk");

// Visual Basic
Dim skinReader As vtkPolyDataReader
Set skinReader = New vtkPolyDataReader
skinReader.SetFileName "/vtkdata/skin.vtk"

// Java
vtkPolyDataReader skinReader = new vtkPolyDataReader();
skinReader.SetFileName("/vtkdata/skin.vtk");

// Python
skinReader = vtkPolyDataReader()
skinReader.SetFileName("/vtkdata/skin.vtk")

// Tcl
vtkPolyDataReader skinReader
skinReader SetFileName "/vtkdata/skin.vtk"


Listing One
extern "C" JNIEXPORT void* vtkCell_Typecast(void *me,char *dType)
{
  void* res;
  if (!strcmp("vtkCell",dType)) { return me; }
  if ((res= vtkObject_Typecast(me,dType)) != NULL) { return res; }
  return NULL;
}


Listing Two
class vtkTclCommand : public vtkCommand
{
public:
  vtkTclCommand();
  ~vtkTclCommand();   void SetStringCommand(char *arg) 
{ this->StringCommand = arg; };
  void SetInterp(Tcl_Interp *interp) 
{ this->Interp = interp; };
  void Execute(vtkObject *, unsigned long, void *);
private:
  char *StringCommand;
  Tcl_Interp *Interp;
};


Listing Three
class vtkComCommand : public vtkCommand
{
public:
  vtkComCommand(T* o, unsigned long id)
    {
      this->Object = o;
      this->EventId = id;
    }
  virtual void Execute(vtkObject *caller, unsigned  long, void *callData)
    {
      this->Object->Fire_VTKEvent(this->EventId);
    }
  T* Object;
  unsigned long EventId;
}


Listing Four
vtkRenderer renderer
    renderer SetStartRenderMethod start 
proc start{}  {
   puts "Start Render"
}


Listing Five
Dim WithEvents renderer As vtkRenderer
Private Sub renderer_StartEvent()
MsgBox "Start Render"
End Sub

Listing Six
HRESULT GetClassName ([out, retval] BSTR *arg20); //IDL
virtual const char *GetClassName(); // C++ 





2

