[vtkusers] help needed setting up the colormap/lookuptable/mapperin C++
David, John
john.david at uconn.edu
Wed Aug 15 09:55:20 EDT 2007
You were right. I was missing the include "vtkPointData.h" in the original code, but I had it added in the minimal test case which I cleaned up for posting... Boy I feel stupid for missing that one.
Sorry for the waste of time.
EBo --
-----Original Message-----
From: vtkusers-bounces+john.david=uconn.edu at vtk.org on behalf of David, John
Sent: Tue 8/14/2007 2:14 PM
To: Eduardo K. Saldanha; vtkusers at vtk.org
Subject: RE: [vtkusers] help needed setting up the colormap/lookuptable/mapperin C++
I found that my original problem appears to be cause by the order I include the headers in the original code. I'll try to take some time out and track that down.
In the end, your fix to the minimal code worked, but when I cut and pasted that back into the original code it still gives the posted errors. So, I was looking in the wrong place.
More later,
EBo --
-----Original Message-----
From: eduardoks at gmail.com on behalf of Eduardo K. Saldanha
Sent: Mon 8/13/2007 9:16 PM
To: David, John; vtkusers at vtk.org
Subject: Re: [vtkusers] help needed setting up the colormap/lookuptable/mapper in C++
I only found the member setScalarRange in mappers, so i changed to the
setScalars as I had told
#include <cstdlib>
#include <ctime>
#include <iostream>
#include "vtkCellArray.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkPolyDataWriter.h"
#include "vtkDoubleArray.h"
#include "vtkPointData.h"
using namespace std;
int main(int argc, char** argv)
{
int i;
int num_points = 100;
double x,y,z; // data points
double rnd_min=1.0, rnd_max=-1.0; // cache the range for SetScalarRange
vtkPoints *points = vtkPoints::New();
vtkDoubleArray *scalars = vtkDoubleArray::New();
srand48((unsigned)time(NULL));
for (i=0; i<num_points; i++)
{
// the original code read in XYZ triplets, but for testing
// just randomly create XY and set the Z to be on a slanted
// plane
x = drand48();
y = drand48();
z = (x+y)/2.0;
if (z < rnd_min) rnd_min = z;
if (z > rnd_max) rnd_max = z;
points->InsertPoint(i, x, y, z);
scalars->InsertNextValue(z);
}
vtkCellArray *polys = vtkCellArray::New();
polys->InsertNextCell(points->GetNumberOfPoints());
for (i=0; i<points->GetNumberOfPoints(); i++)
{
polys->InsertCellPoint(i);
}
vtkPolyData *polyData = vtkPolyData::New();
polyData->SetPoints(points);
polyData->SetPolys(polys);
polyData->GetPointData()->SetScalars(scalars);
polyData->Update();
vtkPolyDataWriter* writer1 = vtkPolyDataWriter::New();
writer1->SetInput(polyData);
writer1->SetFileName( "tst_points.vtk" );
writer1->Update();
writer1->Delete();
return 0;
}
2007/8/13, David, John <john.david at uconn.edu>:
>
> > put the header
> > #include "vtkPointData.h"
>
> it is already in there...
>
> Hmmm... tell you what. At the end you will find a minimal case (but with full source) to reproduce this problem.
>
>
> EBo --
>
> ps: I've appended the code instead of attaching it to the email just in case the server strips attachments by default.
>
> ===============================================
>
>
> #include <cstdlib>
> #include <ctime>
> #include <iostream>
>
> #include "vtkCellArray.h"
>
> #include "vtkPoints.h"
> #include "vtkPolyData.h"
>
> #include "vtkPolyDataWriter.h"
>
> #include "vtkDoubleArray.h"
>
>
> using namespace std;
>
>
> int
> main(int argc, char** argv)
> {
> int i;
> int num_points = 100;
>
> double x,y,z; // data points
> double rnd_min=1.0, rnd_max=-1.0; // cache the range for SetScalarRange
>
> vtkPoints *points = vtkPoints::New();
> vtkDoubleArray *scalars = vtkDoubleArray::New();
>
> srand48((unsigned)time(NULL));
>
> for (i=0; i<num_points; i++)
> {
> // the original code read in XYZ triplets, but for testing
> // just randomly create XY and set the Z to be on a slanted
> // plane
>
> x = drand48();
> y = drand48();
> z = (x+y)/2.0;
>
> if (z < rnd_min) rnd_min = z;
> if (z > rnd_max) rnd_max = z;
>
> points->InsertPoint(i, x, y, z);
>
> scalars->InsertNextValue(z);
> }
>
>
> vtkCellArray *polys = vtkCellArray::New();
>
> polys->InsertNextCell(points->GetNumberOfPoints());
> for (i=0; i<points->GetNumberOfPoints(); i++)
> {
> polys->InsertCellPoint(i);
> }
>
>
> vtkPolyData *polyData = vtkPolyData::New();
> polyData->SetPoints(points);
> polyData->SetPolys(polys);
>
> // problem line
> polyData->GetPointData()->SetScalarRange( rnd_min, rnd_max );
>
> polyData->Update();
>
>
> vtkPolyDataWriter* writer1 = vtkPolyDataWriter::New();
>
> writer1->SetInput(polyData);
> writer1->SetFileName( "tst_points.vtk" );
> writer1->Update();
>
> writer1->Delete();
>
> return 0;
> }
>
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list