[vtkusers] Simple Question

Randy Heiland heiland at ncsa.uiuc.edu
Tue Jun 27 06:47:07 EDT 2000


On Jun 27, 12:20pm, Takaya Naoko wrote:
> Subject: [vtkusers] Simple Question
> To Vtk Users
>
> I'm very very new to vtk and am just trying out the sample
> programms. I'm in chapter 3 and I tried to do the program on rotations
> and WalkCow but these are written in tcl as you know. I don't know tcl and
> am using c++ and my computer can only compile c++ and not tcl.
> Are there rotation.tcl and WalkCow.tcl programs in C++?
> I tried to rewrite it in C++ since tcl seems to be very similar
> to C++ but I couldn't. I didn't know what proc means and so on and
> am not used to tcl at all.

If you can pgm C++, you can pgm Tcl (but better yet, use Python :).  "proc" is
Tcl's way of defining procedures.

Here's some code to get you started down the cow path...

#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkBYUReader.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkCamera.h"

#include "SaveImage.h"

vtkActor *cowActor;
vtkRenderer *ren1;
vtkRenderWindow *renWin;

void walk4 ()
{
  cowActor-> SetOrientation(0, 0, 0);
  ren1-> ResetCameraClippingRange();
  renWin-> Render();
  renWin->Render();
  renWin-> EraseOff();
  cowActor-> SetOrigin(6.11414, 1.27386, .015175);
  cowActor-> SetOrigin(0, 0, 0);
  cowActor-> SetPosition(0, 0, 0);
  vtkTransform *cowTransform = vtkTransform::New();
  cowTransform-> Identity();
//  cowActor-> SetUserMatrix(cowTransform-> GetMatrix());
  for (int idx=1; idx<=6; idx++)  {
//    cowActor-> RotateWXYZ(60,2.19574,-1.42455,-.0331036);
    cowActor-> RotateY(60);
    renWin-> Render();
  }
//  renWin-> EraseOn();
}

void main( int argc, char *argv[] )
{
  ren1 = vtkRenderer::New();
  renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);

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

  vtkBYUReader *cow = vtkBYUReader::New();
  cow->SetGeometryFileName("../../../vtkdata/Viewpoint/cow.g");
    cow->Update();

  vtkPolyDataMapper *cowMapper = vtkPolyDataMapper::New();
    cowMapper->SetInput(cow->GetOutput());
    cowMapper->ScalarVisibilityOff();

  cowActor = vtkActor::New();
    cowActor->SetMapper(cowMapper);
    cowActor->GetProperty()->SetColor(0.9608, 0.8706, 0.7020);

  ren1->AddActor(cowActor);

  renWin->SetSize(300,300);
  renWin->Render();

  renWin-> EraseOff();

  walk4();

  // interact with data
  iren->Start();

  // Clean up...
}




More information about the vtkusers mailing list