[vtkusers] colored error bar

samo sandra.moritz at gmx.de
Mon Jul 16 10:17:24 EDT 2007


Hi folks

I have a problem and hope you can help me. I have two surfaces which I want
to compare. These two surfaces should overlap each other. What I am doing
now is visualize the error with the help of the normals of one surface. My
problem is, that I don't get the colored error surface visualized. And I
can't find the error. The normals are calculated correctly and the color as
well. But they are not visualized.


virtScanActor and realScanActor are my two surfaces.

Here is my code:
vtkPolyDataNormals* normals = vtkPolyDataNormals::New();
normals->SetInput((vtkPolyData*)(virtScanActor->GetMapper()->GetInput()));
normals->Update();
vtkPolyData* normalData = normals->GetOutput();
vtkDataArray* normalArray = normalData->GetPointData()->GetNormals();


vtkFloatArray* colorArray = vtkFloatArray::New();
colorArray->SetNumberOfComponents(1);
for (int i = 0; i < normalArray->GetNumberOfTuples(); i++) {
	colorArray->InsertTuple1(i,
(float)i/(float)normalArray->GetNumberOfTuples());
}
normals->GetOutput()->GetPointData()->SetScalars(colorArray);

// Build a locator 
vtkCellLocator *cellLocator = vtkCellLocator::New();
cellLocator->SetDataSet((vtkPolyData*)(realScanActor->GetMapper()->GetInput()));
cellLocator->BuildLocator();


float fact = 2.0;
virtScanActor->GetMapper()->SetScalarRange(-fact,fact);

// Für alle Normalenvektoren
int cnt = normalArray->GetNumberOfTuples();
for (int i = 0; i < normalArray->GetNumberOfTuples(); i++)
{
	double normalVector[3];
	double foot[3];
	double top[3];
	double mintop[3];

	normalArray->GetTuple(i, normalVector);
	normalData->GetPoint(i, foot);
		
	top[0] = foot[0] + fact*normalVector[0];
	top[1] = foot[1] + fact*normalVector[1];
	top[2] = foot[2] + fact*normalVector[2];
	mintop[0] = foot[0] - fact*normalVector[0];
	mintop[1] = foot[1] - fact*normalVector[1];
	mintop[2] = foot[2] - fact*normalVector[2];
		

	// Intersect with line
	double t;
	double pcoords[3];
	double ptline[3];
	int subId;
	bool ptline1Valid = true;
	bool ptline2Valid = true;

	if (cellLocator->IntersectWithLine(mintop, top, 0.001, t, ptline, pcoords,
subId)) 
		colorArray->SetValue(i, 2.0f*fact*(t-0.5f));
	else
		colorArray->SetValue(i, -fact);


}	// Normalen
colorArray->Modified();
normals->Update();

realScanActor->GetProperty()->SetOpacity(0.4);

virtScanActor->Modified();
realScanActor->Modified();
}
-- 
View this message in context: http://www.nabble.com/colored-error-bar-tf4086845.html#a11615940
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list