Logo Search packages:      
Sourcecode: octaviz version File versions  Download package

vtk_demo_old_syntax.m

## Copyright (C) 2004  Dragan Tubic
## 
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
## 
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details. 
## 
## You should have received a copy of the GNU General Public License
## along with this file.  If not, write to the Free Software Foundation,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
      
      vtk_init;   
  
      x   = ;
  pts = ;
  
  % We'll create the building blocks of polydata including data attributes.
  % vtkPolyData *cube = vtkPolyData::New();
      cube    = vtkPolyData("New");
  % vtkPoints *points = vtkPoints::New();
  points  = vtkPoints("New");
  % vtkCellArray *polys = vtkCellArray::New();
  polys   = vtkCellArray("New");
  % vtkFloatArray *scalars = vtkFloatArray::New();
  scalars = vtkFloatArray("New");

  % Load the point, cell, and data attributes.
  % for (i=0; i<8; i++) points->InsertPoint(i,x[i]);
      for i=1:8
            vtkPoints(points,"InsertPoint",i-1,x(i,1),x(i,2),x(i,3));
      end
  
      % for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]);
      for i=1:6
            vtkCellArray( polys, "InsertNextCell", 4 );
            vtkCellArray( polys, "InsertCellPoint", pts(i,1) );
            vtkCellArray( polys, "InsertCellPoint", pts(i,2) );
            vtkCellArray( polys, "InsertCellPoint", pts(i,3) );
            vtkCellArray( polys, "InsertCellPoint", pts(i,4) );
      end
  % for (i=0; i<8; i++) scalars->InsertValue(i,i);
      for i=1:8
            vtkFloatArray(scalars,"InsertValue",i-1,i-1);
      end
  % We now assign the pieces to the vtkPolyData.
      % cube->SetPoints(points);
  vtkPolyData(cube,"SetPoints",points);
  
      %cube->SetPolys(polys);
  vtkPolyData(cube,"SetPolys",polys);
  
      %cube->GetPointData()->SetScalars(scalars);
      pointData = vtkPolyData(cube,"GetPointData" );
        vtkPointData(pointData,"SetScalars",scalars);

  % Now we'll look at it.
  %vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();
  cubeMapper = vtkPolyDataMapper("New");
      % cubeMapper->SetInput(cube);
      vtkPolyDataMapper(cubeMapper,"SetInput",cube);
      % cubeMapper->SetScalarRange(0,7);
      vtkPolyDataMapper(cubeMapper,"SetScalarRange",0,7);
  
      % vtkActor *cubeActor = vtkActor::New();
  cubeActor = vtkActor("New");
      % cubeActor->SetMapper(cubeMapper);
      vtkActor(cubeActor,"SetMapper",cubeMapper);

  % vtkRenderer *renderer = vtkRenderer::New();
      renderer = vtkRenderer("New");
  % vtkRenderWindow *renWin = vtkRenderWindow::New();
      renWin = vtkRenderWindow("New");
    % renWin->AddRenderer(renderer);
            vtkRenderWindow(renWin,"AddRenderer",renderer);

  % vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
      iren = vtkRenderWindowInteractor("New");
    % iren->SetRenderWindow(renWin);
            vtkRenderWindowInteractor(iren,"SetRenderWindow",renWin);

  % renderer->AddActor(cubeActor);
  vtkRenderer(renderer,"AddActor",cubeActor);
      % renderer->SetActiveCamera(camera);
      % renderer->ResetCamera();
      %vtkRenderer(renderer,"SetBackground",1,1,1);
  
  % renWin->SetSize(300,300);
  % vtkRenderWindow(renWin,"SetSize",500,500);

  % interact with data
      vtkInitializeInteractor(iren);
  % renWin->Render();
  % vtkRenderWindow(renWin,"Render");
  % iren->Start();
      % vtkRenderWindowInteractor(iren,"Start");

      

Generated by  Doxygen 1.6.0   Back to index