[vtkusers] Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Andrew Maclean andrew.amaclean at gmail.com
Tue Aug 26 19:37:47 EDT 2014


Just to clarify, there is a picture and python code atttached to the
previous message (reattached here).

Andrew

On Wed, Aug 27, 2014 at 9:26 AM, Andrew Maclean <andrew.amaclean at gmail.com>
wrote:

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



-- 
___________________________________________
Andrew J. P. Maclean

___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140827/1e2b80c4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CurvatureBandsWithGlyphs.png
Type: image/png
Size: 104633 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140827/1e2b80c4/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CurvatureBandsWithGlyphs.zip
Type: application/zip
Size: 5384 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140827/1e2b80c4/attachment.zip>


More information about the vtkusers mailing list