[vtkusers] I need help!

Naoko Takaya takaya at cv.cs.ritsumei.ac.jp
Fri Jul 21 08:44:42 EDT 2000


Hi vtkusers!

I have been trying to work this out for quite a long time now, but I can't
go any further. I need help!
 
The thing I'm trying to do is clear but doing it is not so clear to me. So,
I need help. 
Note: I'm very new to vtk:)

I want to do the following;

     for (z=-2; z<2; z++)
        for (y=-2; y<2; y++)
          for (x=-2; x<2; x++)
              {
               p=255/92;
               q=255/2;
               r=x+y+1;
               s=p*(x*x*x+y*y*y+1.5*z*z*r-3*x*y)+q;
              }
with following conditions;
|x,y,z|<=2 and volume of 100*100*100.

I want to represent volume of s. 

The program that I wrote is as follows. This doesn’t work… 
What’s wrong? How can I fix this?

main ()
{
  int i, j, k, kOffset, jOffset, offset;
  float x, y, z, s, sp,p,q,r;
  
  vtkRenderer *renderer = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(renderer);
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

  vtkStructuredPoints *vol = vtkStructuredPoints::New();
      vol->SetDimensions(100,100,100);
	  vol->SetOrigin(-2.0,-.2.0,-2.0);


  vtkFloatScalars *scalars = vtkFloatScalars::New();
	s = scalars -> WritePointer(0,100*100*100);

  for (z=-2; z<2; z++)
    for (y=-2; y<2; y++) 
      for (x=-2; x<2; x++) 
        {
	p = 255/92;
		q = 255/2;
		r = x+y+1;
		s = p*(x*x*x+y*y*y+1.5*z*z*r-3*x*y)+q;

		}
      }
    }
  vol->GetPointData()->SetScalars(scalars);
  scalars->Delete();
  
  vtkContourFilter *contour = vtkContourFilter::New();
      contour->SetInput(vol);
      contour->SetValue(0,0.0);

  vtkPolyDataMapper *volMapper = vtkPolyDataMapper::New();
      volMapper->SetInput(contour->GetOutput());
      volMapper->ScalarVisibilityOff();
  vtkActor *volActor = vtkActor::New();
      volActor->SetMapper(volMapper);

  renderer->AddActor(volActor);
      renderer->SetBackground(1,1,1);
  renWin->SetSize(450,450);

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

  // Clean up
  renderer->Delete();
  renWin->Delete();
  iren->Delete();
  vol->Delete();
  scalars->Delete();
  contour->Delete();
  volActor->Delete();
}


**********************************************
*     Naoko Takaya from Japan            *
* e-mail: takaya at cv.cs.ritsumei.ac.jp  *
*********************************************

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 2776 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20000721/b5e11577/attachment-0001.bin>


More information about the vtkusers mailing list