[vtkusers] I need help!

Randy Heiland heiland at ncsa.uiuc.edu
Fri Jul 21 09:52:45 EDT 2000


Naoko,

1) It would help to submit an example pgm that at least compiles

2) Why are you declaring your SP to be 100^3 and then in your nested do loops
(which don't compile), fill up only 5^3?

3) It seems your example is very similar to Lorenz.cxx

--Randy


--------------------------------------------------------
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  *
*********************************************





More information about the vtkusers mailing list