[vtkusers] Trying to display vectors

Thanos Kousis thkousis at hotmail.com
Tue Oct 28 07:33:33 EDT 2008


Hi everyone,
I am  trying to learn how to use vtk. I tried a sample code found in the book "The Visualisation Toolkit" for displaying vectors. The code is the following. I included all header files. When I run it there are no errors. However the only thing I see is the window "Press any key to continue" and then nothing. Do you know what I should do?
Thanks in advance.
 
 
#include "vtkVectors.h"#include "vtkFloatVectors.h"#include "vtkIdList.h"#include "vtkMath.h"
vtkVectors::vtkVectors(){  this->MaxNorm = 0.0;}
void vtkVectors::GetVector(int id, float v[3]){  float *vp = this->GetVector(id);  for (int i=0; i<3; i++) v[i] = vp[i];}
// Description:// Insert vector into position indicated.void vtkVectors::InsertVector(int id, float vx, float vy, float vz){  float v[3];
  v[0] = vx;  v[1] = vy;  v[2] = vz;  this->InsertVector(id,v);}
// Description:// Insert vector into position indicated.int vtkVectors::InsertNextVector(float vx, float vy, float vz){  float v[3];
  v[0] = vx;  v[1] = vy;  v[2] = vz;  return this->InsertNextVector(v);}
// Description:// Given a list of pt ids, return an array of vectors.void vtkVectors::GetVectors(vtkIdList& ptId, vtkFloatVectors& fp){  for (int i=0; i<ptId.GetNumberOfIds(); i++)    {    fp.InsertVector(i,this->GetVector(ptId.GetId(i)));    }}
// Description:// Compute the largest norm for these vectors.void vtkVectors::ComputeMaxNorm(){  int i;  float *v, norm;
  if ( this->GetMTime() > this->ComputeTime )    {    this->MaxNorm = 0.0;    for (i=0; i<this->GetNumberOfVectors(); i++)      {      v = this->GetVector(i);      norm = vtkMath::Norm(v);      if ( norm > this->MaxNorm ) this->MaxNorm = norm;      }
    this->ComputeTime.Modified();    }}
// Description:// Return the maximum norm for these vectors.float vtkVectors::GetMaxNorm(){  this->ComputeMaxNorm();  return this->MaxNorm;}
void vtkVectors::PrintSelf(ostream& os, vtkIndent indent){  vtkReferenceCount::PrintSelf(os,indent);
  os << indent << "Number Of Vectors: " << this->GetNumberOfVectors() << "\n";  os << indent << "Maximum Euclidean Norm: " << this->GetMaxNorm() << "\n";}
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081028/3f6f2260/attachment.htm>


More information about the vtkusers mailing list