# [vtkusers] smoothing errors

Berk Geveci berkgeveci at hotmail.com
Tue Sep 4 18:20:18 EDT 2001

>I use vtkSmoothPolyDataFilter, to smooth a surface. It smoots the surface.
>But, at the end of the smoothing process, I want to display smoothing
>errors. For this purpose I use the   functions GenerateErrorScalars, and
>GrenerateErrorScalarsOn. When I use these functions, in the render window,
>smoothed surface is drawn with various colors. I think, these colors
>correspond to different error values. Here I have the following questions:
>
>1- How is the smoothing error computed? (i.e, what is the error
>measure?Laplacian smoothing is used but error measure?)

Here is the piece of code which calculates the errors

for (i=0; i<numPts; i++)
{
// inPts are the points from the input
// newPts are the output points
// the error measure is simply ||x2 - x1||
inPts->GetPoint(i,x1);
newPts->GetPoint(i,x2);
newScalars->SetComponent(i,0,
sqrt(vtkMath::Distance2BetweenPoints(x1,x2)));
}

If you don't like the error measure, it should be very easy to change it.
just replace
newScalars->SetComponent(i,0,sqrt(vtkMath::Distance2BetweenPoints(x1,x2)));

>2- How can I obtain the numerical values of these errors?

Just get the scalars from the output's point data, for example:
vtkScalars* errors =
smoothFilter->GetOutput()->GetPointData()->GetScalars();

and to get the error at ith point, you can
errors->GetScalar(i);

>3- How can I draw a graphic to legend these error values?

Use vtkScalarBarActor. There are examples in the user's guide.

-Berk

_________________________________________________________________