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

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

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

Sky77
Hey guys,

i have a problem with an example. Its name is Compute Gaussian, Mean, Min and Max Curvatures. Instead of using a vtp file as input, i use the following code to create a sphere and use the sphere as input:

/* Create a sphere */
vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
sphereSource->SetCenter(0.0, 0.0, 0.0);
sphereSource->SetRadius(1.0);
sphereSource->SetThetaResolution(50);
sphereSource->SetPhiResolution(50);

I also changed the following line

curvaturesFilter->SetInputConnection(reader->GetOutputPort());

to

curvaturesFilter->SetInputConnection(sphereSource ->GetOutputPort());

so that the algorithm works on the sphere.

Here you can see the output. What did i do wrong?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Bill Lorensen
Please post the entire C++ code.

Thanks,

Bill

On Mon, Aug 25, 2014 at 2:54 PM, Sky77 <[hidden email]> wrote:

> Hey guys,
>
> i have a problem with an example. Its name is  Compute Gaussian, Mean, Min
> and Max Curvatures
> <http://vtk.org/Wiki/VTK/Examples/Cxx/PolyData/Curvatures>  . Instead of
> using a vtp file as input, i use the following code to create a sphere and
> use the sphere as input:
>
> /* Create a sphere */
> vtkSmartPointer<vtkSphereSource> sphereSource =
> vtkSmartPointer<vtkSphereSource>::New();
> sphereSource->SetCenter(0.0, 0.0, 0.0);
> sphereSource->SetRadius(1.0);
> sphereSource->SetThetaResolution(50);
> sphereSource->SetPhiResolution(50);
>
> I also changed the following line
>
> curvaturesFilter->SetInputConnection(reader->GetOutputPort());
>
> to
>
> curvaturesFilter->SetInputConnection(sphereSource ->GetOutputPort());
>
> so that the algorithm works on the sphere.
>
> Here <http://vtk.1045678.n5.nabble.com/file/n5728377/result.png>   you can
> see the output. What did i do wrong?
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Problem-with-Compute-Gaussian-Mean-Minm-and-Max-Curvatures-example-tp5728377.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Sky77
Here is the adapted example:

#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 <vtkSphereSource.h>

int main(int argc, char *argv[])
{
    /* Create a sphere */
    vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
    sphereSource->SetCenter(0.0, 0.0, 0.0);
    sphereSource->SetRadius(1.0);
    sphereSource->SetThetaResolution(50);
    sphereSource->SetPhiResolution(50);

    vtkSmartPointer<vtkCurvatures> curvaturesFilter = vtkSmartPointer<vtkCurvatures>::New();
    curvaturesFilter->SetInputConnection(sphereSource->GetOutputPort());
    curvaturesFilter->SetCurvatureTypeToMinimum();
    curvaturesFilter->SetCurvatureTypeToMaximum();
    curvaturesFilter->SetCurvatureTypeToGaussian();
    curvaturesFilter->SetCurvatureTypeToMean();
    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;
}
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Jott
Sky77

I'm not sure what you expect the output to be.

The example computes the curve in the image, but your input is a sphere which has a constant curvature.

from the documenation: vtkCurvatures takes a polydata input and computes the curvature of the mesh at each point.

From the description I would expect that the results from a sphere would would be a constant value, pretty much what your results showed.

To test this you can try to modify one point on the sphere, this will change the curvature around that point and should show up in your results.

HTH
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Sky77
Hey HTH.

You're right. The sphere alone is an unsuitable example to show that something isn't working when we are looking at the curvature. Therefore I have adapted the code. Now we are looking at the Gaussian curvature of two overlapping spheres. It is clear that the viusalization should show positive curvature everywhere execpt the area where they overlap. There it should be negative curvature. My resulting visualization has not changed (see here).

#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 <vtkSphereSource.h>

#include <vtkVersion.h>
#include <vtkPolyData.h>
#include <vtkCleanPolyData.h>
#include <vtkAppendPolyData.h>

int main(int argc, char *argv[])
{
    vtkSmartPointer<vtkPolyData> input1 = vtkSmartPointer<vtkPolyData>::New();
    vtkSmartPointer<vtkPolyData> input2 = vtkSmartPointer<vtkPolyData>::New();

    vtkSmartPointer<vtkSphereSource> sphereSource1 = vtkSmartPointer<vtkSphereSource>::New();
    sphereSource1->SetRadius(5);
    sphereSource1->SetCenter(-2,0,0);
    sphereSource1->SetPhiResolution(15);
    sphereSource1->SetThetaResolution(15);
    sphereSource1->Update();
    input1->ShallowCopy(sphereSource1->GetOutput());

    vtkSmartPointer<vtkSphereSource> sphereSource2 = vtkSmartPointer<vtkSphereSource>::New();
    sphereSource2->SetRadius(5);
    sphereSource2->SetCenter(2,0,0);
    sphereSource2->SetPhiResolution(15);
    sphereSource2->SetThetaResolution(15);
    sphereSource2->Update();
    input2->ShallowCopy(sphereSource2->GetOutput());

    //Append the two meshes
    vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
    appendFilter->AddInputConnection(input1->GetProducerPort());
    appendFilter->AddInputConnection(input2->GetProducerPort());
    appendFilter->Update();

    // Remove any duplicate points.
    vtkSmartPointer<vtkCleanPolyData> cleanFilter = vtkSmartPointer<vtkCleanPolyData>::New();
    cleanFilter->SetInputConnection(appendFilter->GetOutputPort());
    cleanFilter->Update();

    vtkSmartPointer<vtkCurvatures> curvaturesFilter = vtkSmartPointer<vtkCurvatures>::New();
    curvaturesFilter->SetInputConnection(cleanFilter->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;
}
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

David Doria-2-3
On Tue, Aug 26, 2014 at 5:42 AM, Sky77 <[hidden email]> wrote:
Hey HTH.

You're right. The sphere alone is an unsuitable example to show that
something isn't working when we are looking at the curvature. Therefore I
have adapted the code. Now we are looking at the Gaussian curvature of two
overlapping spheres. It is clear that the viusalization should show positive
curvature everywhere execpt the area where they overlap. There it should be
negative curvature. My resulting visualization has not changed (see  here
<http://vtk.1045678.n5.nabble.com/file/n5728392/result.png>  ).

It works for me. I had to change

appendFilter->AddInputConnection(input1->GetProducerPort());
appendFilter->AddInputConnection(input2->GetProducerPort());

to
  
appendFilter->AddInputData(input1);
appendFilter->AddInputData(input2);

for VTK6 compatibility, but then I get the attached output.

David

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers

curvature.jpg (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Sky77
Hey David,

i get the same result as you when i comment the following line out:

// mapper->SetLookupTable(lut);

It is not nice that the Gaussian curvature fall off to 0.0316. Also there should be an area with negative Gaussian curvature, which is missing completely. Maybe i did something wrong when i merge the two spheres?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

David Doria-2-3
On Tue, Aug 26, 2014 at 9:00 AM, Sky77 <[hidden email]> wrote:
Hey David,

i get the same result as you when i comment the following line out:

// mapper->SetLookupTable(lut);

It is not nice that the Gaussian curvature fall off to 0.0316. Also there
should be an area with negative Gaussian curvature, which is missing
completely. Maybe i did something wrong when i merge the two spheres?

The way you have "merged" the two spheres leaves pieces of the spheres inside of the surface that we can see. Try merging them using one of the capabilities of this filter:

http://www.vtk.org/doc/nightly/html/classvtkBooleanOperationPolyDataFilter.html
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/BooleanOperationPolyDataFilter

David

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Sky77
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 

Here 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;

}
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Jott
In reply to this post by Sky77
Sky77

I reviewed your code again and saw that you use a color scheme of 16. What version of VTK are you using?

I currently am using 5.10 and a color scheme of 16 creates a custom scheme with only one color, which would explain your one color image.

Try changing the color scheme to 0 (vtkColorSeries::SPECTRUM). I ran your code with color scheme 16 and got the same result you did. I change the color scheme to 0 and the results changed to what you would expect.

Since I haven't used vtkCurvatures before I was mistaken in that a sphere would be flat

HTH,

Jott

ps: HTH = hope this helps

Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Sky77
Hey Jott.

Sorry, I thought that "HTH" is your nickname. I was reading to quickly. :-).

Currently I'm using VTK 5.8. Your note also worked for me. Now the colormap is visible on the sphere.

Do you also have an idea why the function doesn't compute negative Gaussian curvature for the torus? It seems strange. The function of VTK should really compute negative curvature on the inside of the torus (like it is shown here).
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Bill Lorensen
Please provide the wikipedia link that points to that image.


On Tue, Aug 26, 2014 at 2:42 PM, Sky77 <[hidden email]> wrote:

> Hey Jott.
>
> Sorry, I thought that "HTH" is your nickname. I was reading to quickly. :-).
>
> Currently I'm using VTK 5.8. Your note also worked for me. Now the colormap
> is visible on the sphere.
>
> Do you also have an idea why the function doesn't compute negative Gaussian
> curvature for the torus? It seems strange. The function of VTK should really
> compute negative curvature on the inside of the torus (like it is shown
> here
> <http://upload.wikimedia.org/wikipedia/commons/3/38/Torus_Positive_and_negative_curvature.png>
> ).
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Problem-with-Compute-Gaussian-Mean-Minm-and-Max-Curvatures-example-tp5728377p5728405.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Sky77
Unfortunately i haven't the wikipedia link. I searched with google for an appropriate visualization of the torus. But i have found something likely. You can find a similar visualization on page 2 of this pdf file.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Bill Lorensen
That is a good reference. So it seems the gaussian curvature in VTK
may have a problem.


On Tue, Aug 26, 2014 at 3:37 PM, Sky77 <[hidden email]> wrote:

> Unfortunately i haven't the wikipedia link. I searched with google for an
> appropriate visualization of the torus. But i have found something likely.
> You can find a similar visualization on page 2 of  this pdf file
> <http://www.win.tue.nl/~rvhassel/Onderwijs/Tensor-ConTeX-Bib/Examples-diff-geom/Torus-diff-geom/curv-torus.pdf>
> .
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Problem-with-Compute-Gaussian-Mean-Minm-and-Max-Curvatures-example-tp5728377p5728409.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Bill Lorensen
Try this. It uses a parametric torus. Something strange is going on
with your torus:

#include <vtkSmartPointer.h>

#include <vtkCurvatures.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 <vtkParametricFunctionSource.h>
#include <vtkParametricTorus.h>

int main(int argc, char *argv[])
{
   vtkSmartPointer<vtkParametricTorus> parametricObject =
vtkSmartPointer<vtkParametricTorus>::New();
  parametricObject->SetRingRadius(0.5);
  parametricObject->SetCrossSectionRadius(.25);

  vtkSmartPointer<vtkParametricFunctionSource> parametricFunctionSource =
    vtkSmartPointer<vtkParametricFunctionSource>::New();
  parametricFunctionSource->SetParametricFunction(parametricObject);
  parametricFunctionSource->Update();

 // Create a polydata
  vtkSmartPointer<vtkCurvatures> curvaturesFilter =
    vtkSmartPointer<vtkCurvatures>::New();
  curvaturesFilter->SetInputConnection(parametricFunctionSource->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);
  std::cout << "Using color scheme #: "
            << colorSeries->GetColorScheme() << " is "
            << colorSeries->GetColorSchemeName() << std::endl;

  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;
}

On Tue, Aug 26, 2014 at 3:46 PM, Bill Lorensen <[hidden email]> wrote:

> That is a good reference. So it seems the gaussian curvature in VTK
> may have a problem.
>
>
> On Tue, Aug 26, 2014 at 3:37 PM, Sky77 <[hidden email]> wrote:
>> Unfortunately i haven't the wikipedia link. I searched with google for an
>> appropriate visualization of the torus. But i have found something likely.
>> You can find a similar visualization on page 2 of  this pdf file
>> <http://www.win.tue.nl/~rvhassel/Onderwijs/Tensor-ConTeX-Bib/Examples-diff-geom/Torus-diff-geom/curv-torus.pdf>
>> .
>>
>>
>>
>>
>> --
>> View this message in context: http://vtk.1045678.n5.nabble.com/Problem-with-Compute-Gaussian-Mean-Minm-and-Max-Curvatures-example-tp5728377p5728409.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com



--
Unpaid intern in BillsBasement at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Meehan, Bernard
In reply to this post by Sky77
I found the image at:
http://commons.wikimedia.org/wiki/Category:Curvature
http://commons.wikimedia.org/wiki/Category:Torus

and couldn't find a Wikipedia page referencing it ...


On 8/26/14 12:15 PM, "Bill Lorensen" <[hidden email]> wrote:

>Please provide the wikipedia link that points to that image.
>
>
>On Tue, Aug 26, 2014 at 2:42 PM, Sky77 <[hidden email]> wrote:
>> Hey Jott.
>>
>> Sorry, I thought that "HTH" is your nickname. I was reading to quickly.
>>:-).
>>
>> Currently I'm using VTK 5.8. Your note also worked for me. Now the
>>colormap
>> is visible on the sphere.
>>
>> Do you also have an idea why the function doesn't compute negative
>>Gaussian
>> curvature for the torus? It seems strange. The function of VTK should
>>really
>> compute negative curvature on the inside of the torus (like it is shown
>> here
>>
>><http://upload.wikimedia.org/wikipedia/commons/3/38/Torus_Positive_and_ne
>>gative_curvature.png>
>> ).
>>
>>
>>
>> --
>> View this message in context:
>>http://vtk.1045678.n5.nabble.com/Problem-with-Compute-Gaussian-Mean-Minm-
>>and-Max-Curvatures-example-tp5728377p5728405.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>>http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>>http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
>--
>Unpaid intern in BillsBasement at noware dot com
>_______________________________________________
>Powered by www.kitware.com
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Please keep messages on-topic and check the VTK FAQ at:
>http://www.vtk.org/Wiki/VTK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Jott
In reply to this post by Sky77
Sky77

I'm glad changing color scheme helped.

I'm not sure why you aren't seeing negative curvatures, but Bill's post using the parametric Torus seems to work.

Unfortunately I don't have any further insight for you.

Jott
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Sky77
In reply to this post by Bill Lorensen
Hey Bill.

With your provided code i get the expected result. Thank you!

I still get an artefact, which you can see in the following image:

torus-artefact
(I created this image with Bill's provided code)

Does someone knows how i can avoid it?

@ Jott: Thank you for your help.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Andrew Maclean-3
In reply to this post by Sky77
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.


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 <[hidden email]>
To: [hidden email]
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

___________________________________________

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers

CurvatureBandsWithGlyphs.zip (7K) Download Attachment
CurvatureBandsWithGlyphs.png (139K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with "Compute Gaussian, Mean, Minm and Max Curvatures" example

Andrew Maclean-3
In reply to this post by Sky77

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 <[hidden email]> 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.


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 <[hidden email]>
To: [hidden email]
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

___________________________________________

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers

CurvatureBandsWithGlyphs.png (139K) Download Attachment
CurvatureBandsWithGlyphs.zip (7K) Download Attachment
12