[vtkusers] vtkTextureMapToSphere - PreventSeamOn also prevents correct scale

John Davis gcubed.developer at yahoo.com
Mon Sep 3 15:15:22 EDT 2007


There is at least one numerical error in vtkTextureMapToSphere.cxx.  People have been complaining about this or vtkTextureMapToCylinder since 1999, so it must be too hard for the VTK team to handle! 

I have a Bandaid fix that works for a structured sphere source, but I don't know how to handle the general case.  The polar regions are still distorted, and PreventSeamOn still ruins the scale of the entire map, but now at least there is no jumbled band of colors from North Pole to South Pole along longitude 0 degrees.  

To see my two-line fix, see the insertion in my original message below.



John Davis <gcubed.developer at yahoo.com> wrote: I have a complete working VTK 5.0.3/C++ application that includes these lines:

    vtkTextureMapToSphere *textureMapper = vtkTextureMapToSphere::New();
    textureMapper->SetInput(globeOverlay->GetOutput());
    textureMapper->PreventSeamOff(); 

The application displays a rotating 3D globe with earth geography mapped from an 2D image to a 2D texture.  The 2D image is rectangular and linear in X and Y with the prime meridian in the center, 180 longitude on the right edge, and, -180 longitude on the left edge.  From vtkTransformTextureCoords I use

 ->AddPosition(0.5,0.0,0.0) 
 ->FlipROn()

My application does exactly what it is supposed to do except that the prime meridian is a jumbled narrow band of colors and there is a visible seam in the Pacific at 180.

If I change only this line:

    textureMapper->PreventSeamOn();  

the prime meridan closes, but the entire geography is compressed and duplicated in both the eastern and western hemispheres.

No amount of experimenting with vtkTransformTextureCoords scaling, positioning, and flipping has restored the correct geography.

I'm beginning to believe that this code from vtkTextureMapToSphere.cxx is causing the problem, but it looks logical.  What am I missing?

    if ( this->PreventSeam )
      {
      tc[0] = thetaX / vtkMath::Pi();
      }
    else
      {
      tc[0] = thetaX / (2.0*vtkMath::Pi());
      if ( fabs(thetaY) < 0.002)
         thetaY = -thetaY;
      if ( thetaY < 0.0 )
        {
        tc[0] = 1.0 - tc[0];
         }
      }

 

...

       
---------------------------------
Pinpoint customers who are looking for what you sell. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070903/a8d5834f/attachment.htm>


More information about the vtkusers mailing list