<div dir="ltr">I was one of the original authors of this class.<div><br><div>Some points to remember are:</div><div>1) Curvatures are calculated on a triangulated surface using the vertices of the triangles.</div><div>2) The ideal case would be a large number of small triangles across the surface.</div>
<div>3) If the surface is planar then the edges of the plane may have large values - especially at the corners so it is best to use a clip function after applying the filter.</div><div>4) If the surface is a deformed plane e.g. vtkParametricRandomHills then most of the gaussian curvatures will lie in the range -1 to 0.2 (say) with a few large values say 20 to 40 at the peaks of the hills. You may need to tailor your lookup table</div>
<div>to account for this.</div><div><br></div><div><br></div><div>Here is a beautiful example (in my opinion) I made using <a href="http://www.vtk.org/Wiki/VTK/Examples/Python/CurvaturesDemo">http://www.vtk.org/Wiki/VTK/Examples/Python/CurvaturesDemo</a> and <a href="http://www.vtk.org/Wiki/VTK/Examples/Python/Visualization/ElevationBandsWithGlyphs">http://www.vtk.org/Wiki/VTK/Examples/Python/Visualization/ElevationBandsWithGlyphs</a></div>
<div>It uses a torus and a banded polydata contour filter, I have also added normal glyphs to the surface.</div><div><br></div><div>I will most likely add a C++ and Python example similar to this.</div><div><br></div><div>
<br><div class="gmail_extra">Regards</div><div class="gmail_extra"> Andrew<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
---------- Forwarded message ----------<br>From: Sky77 <<a href="mailto:Joan.Hensen@outlook.de">Joan.Hensen@outlook.de</a>><br>To: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>Cc: <br>Date: Tue, 26 Aug 2014 07:35:48 -0700 (PDT)<br>
Subject: Re: [vtkusers] Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example<br>It seems that my version of VTK is to old. The header file<br>
vtkBooleanOperationPolyDataFilter.h can't be found. For this purpose, i have<br>
try something else to get an object with negative Gaussian curvature. A<br>
torus have positive Gaussian curvature on the outside and negative Gaussian<br>
curvature on the inside. I have created one with blender and import it as<br>
obj file.<br>
<br>
This ist the input file: torus.obj<br>
<<a href="http://vtk.1045678.n5.nabble.com/file/n5728401/torus.obj" target="_blank">http://vtk.1045678.n5.nabble.com/file/n5728401/torus.obj</a>><br>
<br>
Here <<a href="http://vtk.1045678.n5.nabble.com/file/n5728401/result.png" target="_blank">http://vtk.1045678.n5.nabble.com/file/n5728401/result.png</a>> you can<br>
see my result. Also in this case no negative curvature is computed.<br>
<br>
Has someone of you experience with the curvature computation with vtk? I<br>
mean has someone used this functionality with success?<br>
<br>
#include <vtkSmartPointer.h><br>
#include <vtkCurvatures.h><br>
#include <vtkXMLPolyDataReader.h><br>
#include <vtkLookupTable.h><br>
#include <vtkColorTransferFunction.h><br>
#include <vtkColorSeries.h><br>
#include <vtkPointData.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkActor.h><br>
#include <vtkScalarBarActor.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkOBJReader.h><br>
#include <vtkUnstructuredGrid.h><br>
#include <vtkCell.h><br>
#include <vtkCellArray.h><br>
#include <vtkIdList.h><br>
#include <vtkUnsignedCharArray.h><br>
#include <string><br>
<br>
int main(int argc, char *argv[])<br>
{<br>
// Parse command line arguments<br>
if(argc != 2)<br>
{<br>
std::cout << "Usage: " << argv[0] << " Filename(.obj)" << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
std::string filename = argv[1];<br>
vtkSmartPointer<vtkOBJReader> reader =<br>
vtkSmartPointer<vtkOBJReader>::New();<br>
reader->SetFileName(filename.c_str());<br>
reader->Update();<br>
<br>
vtkSmartPointer<vtkCurvatures> curvaturesFilter =<br>
vtkSmartPointer<vtkCurvatures>::New();<br>
curvaturesFilter->SetInputConnection(reader->GetOutputPort());<br>
curvaturesFilter->SetCurvatureTypeToGaussian();<br>
curvaturesFilter->Update();<br>
<br>
// Get scalar range from command line if present, otherwise use<br>
// range of computed curvature<br>
double scalarRange[2];<br>
if (argc >= 4)<br>
{<br>
scalarRange[0] = atof(argv[2]);<br>
scalarRange[1] = atof(argv[3]);<br>
}<br>
else<br>
{<br>
curvaturesFilter->GetOutput()->GetScalarRange(scalarRange);<br>
}<br>
<br>
int scheme = 16;<br>
if (argc >= 5)<br>
{<br>
scheme = atoi(argv[4]);<br>
}<br>
<br>
// Build a lookup table<br>
vtkSmartPointer<vtkColorSeries> colorSeries =<br>
vtkSmartPointer<vtkColorSeries>::New();<br>
colorSeries->SetColorScheme(scheme);<br>
<br>
vtkSmartPointer<vtkColorTransferFunction> lut =<br>
vtkSmartPointer<vtkColorTransferFunction>::New();<br>
lut->SetColorSpaceToHSV();<br>
<br>
// Use a color series to create a transfer function<br>
int numColors = colorSeries->GetNumberOfColors();<br>
for (int i = 0; i < numColors; i++)<br>
{<br>
vtkColor3ub color = colorSeries->GetColor(i);<br>
double dColor[3];<br>
dColor[0] = static_cast<double> (color[0]) / 255.0;<br>
dColor[1] = static_cast<double> (color[1]) / 255.0;<br>
dColor[2] = static_cast<double> (color[2]) / 255.0;<br>
double t = scalarRange[0] + (scalarRange[1] - scalarRange[0]) /<br>
(numColors - 1) * i;<br>
lut->AddRGBPoint(t, dColor[0], dColor[1], dColor[2]);<br>
}<br>
<br>
// Create a mapper and actor<br>
vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
mapper->SetInputConnection(curvaturesFilter->GetOutputPort());<br>
// mapper->SetLookupTable(lut);<br>
mapper->SetScalarRange(scalarRange);<br>
<br>
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br>
actor->SetMapper(mapper);<br>
<br>
// Create a scalar bar<br>
vtkSmartPointer<vtkScalarBarActor> scalarBar =<br>
vtkSmartPointer<vtkScalarBarActor>::New();<br>
scalarBar->SetLookupTable(mapper->GetLookupTable());<br>
<br>
scalarBar->SetTitle(curvaturesFilter->GetOutput()->GetPointData()->GetScalars()->GetName());<br>
scalarBar->SetNumberOfLabels(5);<br>
<br>
// Create a renderer, render window, and interactor<br>
vtkSmartPointer<vtkRenderer> renderer =<br>
vtkSmartPointer<vtkRenderer>::New();<br>
vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
vtkSmartPointer<vtkRenderWindow>::New();<br>
renderWindow->AddRenderer(renderer);<br>
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
renderWindowInteractor->SetRenderWindow(renderWindow);<br>
<br>
// Add the actors to the scene<br>
renderer->AddActor(actor);<br>
renderer->AddActor2D(scalarBar);<br>
<br>
renderer->SetBackground(.1, .2, .3); // Background color blue<br>
<br>
// Render and interact<br>
renderWindow->Render();<br>
renderWindowInteractor->Start();<br>
<br>
return EXIT_SUCCESS;<br>
<br>
}<br> -- <br></blockquote></div>___________________________________________<br>Andrew J. P. Maclean<br><br>___________________________________________
</div></div></div></div>