<P>
hello everyone,<BR>
Iam working on glyphs.<BR>
I have two scalar arrays , I want one scalar to scale the glyph ie a sphere and the other scalar to colour the glyphs.<BR>
I have written something but it does not work. something is wrong.<BR>
Someone please correct me.<BR>
Thanking you,<BR>
David Michell<BR>
<BR>
<BR>
<BR>
void main()<BR>
{<BR>
int npts=10;<BR>
int i;<BR>
FILE *fp;<BR>
float coord[3];<BR>
<BR>
vtkLookupTable *ltab;<BR>
<BR>
fp=fopen("data.set","r");<BR>
<BR>
vtkPoints *ps=vtkPoints::New();<BR>
vtkCellArray *ca =vtkCellArray::New();<BR>
vtkUnstructuredGrid *ug=vtkUnstructuredGrid::New();<BR>
vtkFloatArray *da=vtkFloatArray::New();<BR>
<BR>
ps->Allocate(npts);<BR>
<BR>
ca->Allocate(ca->EstimateSize(100,100));<BR>
ca->InsertNextCell(npts);<BR>
<BR>
ltab=vtkLookupTable::New();<BR>
ltab->SetNumberOfColors(npts);<BR>
ltab->SetHueRange(0.893,0.021);<BR>
ltab->Build();<BR>
<BR>
<BR>
for (i=0;i<npts,i++)<BR>
{<BR>
fscanf(fp,"%f%f%f",&coord[0],&coord[1],&coord[2]);<BR>
ps->InsertNextPoint(coord);<BR>
ca->InsertCellPoint(i);<BR>
da->InsertValue(i,i); //i want this to be the color scalar<BR>
}<BR>
<BR>
fclose(fp);<BR>
<BR>
ug->Allocate(100,100);<BR>
ug->SetPoints(ps);<BR>
i=1;<BR>
ug->SetCells(&i,ca);<BR>
<BR>
<BR>
<BR>
vtkRenderer *rn=vtkRenderer::New();<BR>
<BR>
vtkRenderWindow *win=vtkRenderWindow::New();<BR>
win->AddRenderer(rn);<BR>
<BR>
vtkRenderWindowInteractor *intr=vtkRenderWindowInteractor::New();<BR>
inter->SetRenderWindow(rn);<BR>
<BR>
<BR>
vtkSphereSource *cst=vtkSphereSource::New();<BR>
cst->SetRadius(0.1);<BR>
cst->SetPhiResolution(6);<BR>
cst->SetThetaResolution(6);<BR>
<BR>
vtkFloatArray *sz =vtkFloatArray::New();//i want this to be the glyph scaling scalar<BR>
<BR>
sz->InsertValue(0,1.0);<BR>
sz->InsertValue(1,2.0);<BR>
sz->InsertValue(2,3.0);<BR>
sz->InsertValue(3,4.0);<BR>
sz->InsertValue(4,5.0);<BR>
sz->InsertValue(5,6.0);<BR>
sz->InsertValue(6,7.0);<BR>
sz->InsertValue(7,8.0);<BR>
sz->InsertValue(8,9.0);<BR>
sz->InsertValue(9,10.0);<BR>
<BR>
<BR>
vtkGlyph3D *g3t=vtkGlyph3D::New();<BR>
g3t->SetInput(ug);<BR>
g3t->SetSource(cst->GetOutput());<BR>
//here iam saying the unstructured grid to use sz as the scalar <BR>
//so that glyph3d can use it for scaling<BR>
ug->GetPointData()->SetScalars(sz);<BR>
g3t->SetScaleModeToScaleByScalar();<BR>
<BR>
vtkPolyDataMapper *g3map=vtkPolyDataMapper::New();<BR>
<BR>
g3map->SetInput(g3t->GetOutput());<BR>
g3map->SetLookupTable(ltab);<BR>
//here iam saying the unstructured grid to use da as the scalar <BR>
//to get the color<BR>
ug->GetPointData()->SetScalars(da);<BR>
<BR>
vtkActor *g3act=vtkActor::New();<BR>
g3act->SetMapper(g3map);<BR>
<BR>
rn->AddActor(g3act);<BR>
<BR>
intr->Initialize();<BR>
rn->Render();<BR>
intr->Start();<BR>
}
</P>
<br><br>
<A target="_blank" HREF="http://clients.rediff.com/signature/track_sig.asp"><IMG SRC="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com/inbox.htm@Bottom" BORDER=0 VSPACE=0 HSPACE=0 HEIGHT=74 WIDTH=496></a>