<DIV id=RTEContent>  <DIV id=RTEContent>  <DIV id=RTEContent>hello,</DIV>  <DIV>&nbsp;</DIV>  <DIV><STRONG>Problem I am trying to solve:</STRONG></DIV>  <DIV>&nbsp;</DIV>  <DIV>I am trying to get the volume enclosed between a hemisphere like surface and a plane like surface which lies at the base of the hemispherical surface.</DIV>  <DIV>&nbsp;</DIV>  <DIV>These surfaces are extracted from the mesh of a human body.</DIV>  <DIV>&nbsp;</DIV>  <DIV>I want to use the z-buffer difference to estimate the enclosed volume, since it is more quick compared to vtkMassProperties. At the end i will compare with vtkMassProperties estimate.</DIV>  <DIV>&nbsp;</DIV>  <DIV><STRONG>Approach i am following: </STRONG></DIV>  <DIV>&nbsp;</DIV>  <DIV>To simplify my problem, here are the steps i am following</DIV>  <DIV>&nbsp;</DIV>  <OL>  <LI>I&nbsp;first created a hemisphere actor using vtkSphereSource   <LI>Next i create a square Plane&nbsp;actor which represents the base of the hemispherical surface.  
 <LI>Now i create an off screen render window using <STRONG>vtkWin32OpenGLRenderWindow. </STRONG>  <LI>I make the renderer to use OrthographicProjection using vtkRenderer::ParallelProjectionOn.   <LI>Then i first render both actors to the renderer.   <LI>I get the z-buffer data of the render window using vtkRenderWindow::GetZBufferData with the hemisphere and cache it.   <LI>Then i hide the hemipherical actor using vtkActor::VisibilityOff.   <LI>Then i get the z-buffer data of the plane actor.   <LI>Now i compute the difference which is an estimate of the volume.</LI></OL>  <DIV><STRONG>Difficulty:</STRONG></DIV>  <DIV>&nbsp;</DIV>  <DIV>I rendered the off screen render window for both actors to a disk image using vtkWindowToImageFilter and both the images come perfectly as expected. The images are attached to the message if you want to take a look.</DIV>  <DIV>&nbsp;</DIV>  <DIV><STRONG><EM>Now the difficulty is, i am getting a negative cumulative difference.</EM></STRONG></DIV> 
 <DIV><EM></EM>&nbsp;</DIV>  <DIV><STRONG><EM>Also this estimate of the volume is relative to the graphic world i created.</EM></STRONG></DIV>  <DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>  <DIV><STRONG><EM>How do i convert it to an estimate of the real volume ? which factor or scales should i multiply the z-buffer differnce with to get the volume ?</EM></STRONG></DIV>  <DIV>&nbsp;</DIV>  <DIV>Below is the code i used..............</DIV>  <DIV>&nbsp;</DIV>  <DIV>Can Anyone tell me whats going wrong ?</DIV>  <DIV>&nbsp;</DIV>  <DIV>What do those z-values mean ??</DIV>  <DIV>&nbsp;</DIV>  <DIV>Thanks in Advance.</DIV>  <DIV>&nbsp;</DIV>  <DIV>Regards,</DIV>  <DIV>&nbsp;</DIV>  <DIV>Deepak</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp;</DIV>  <DIV>*************************************************************************************************</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp;</DIV><FONT color=#008000 size=2>  <DIV>// create Sphere actor first</DIV></FONT><FONT size=2>  <DIV>vtkSphereSource
 *pSphere = vtkSphereSource::New();</DIV>  <DIV>pSphere-&gt;SetCenter( 0.0 , 0.0 , 0.0 );</DIV>  <DIV>pSphere-&gt;SetRadius( 8.0 );</DIV>  <DIV>pSphere-&gt;SetStartTheta( 0.0 );</DIV>  <DIV>pSphere-&gt;SetEndTheta( 360.0 );</DIV>  <DIV>pSphere-&gt;SetThetaResolution( 30.0 );</DIV>  <DIV>pSphere-&gt;SetStartPhi( 0.0 );</DIV>  <DIV>pSphere-&gt;SetEndPhi( 90.0 );</DIV>  <DIV>pSphere-&gt;SetPhiResolution( 30.0 );</DIV>  <DIV>&nbsp;</DIV>  <DIV>vtkPolyDataMapper *pSphereMapper = vtkPolyDataMapper::New();</DIV>  <DIV>pSphereMapper-&gt;SetInput( pSphere-&gt;GetOutput() );</DIV>  <DIV>pSphereMapper-&gt;Update();</DIV>  <DIV>&nbsp;</DIV>  <DIV>vtkOpenGLActor *pSphereActor = vtkOpenGLActor::New();</DIV>  <DIV>pSphereActor-&gt;SetMapper( pSphereMapper );</DIV>  <DIV>pSphereActor-&gt;GetProperty()-&gt;SetColor( 1.0 , 0.0 , 0.0 );</DIV>  <DIV></FONT><FONT color=#0000ff size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#0000ff size=2>float</FONT><FONT size=2> sphereBounds[6];</DIV> 
 <DIV>pSphereActor-&gt;GetBounds( sphereBounds );</DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// build&nbsp;coons plane actor</DIV></FONT><FONT size=2>  <DIV>vtkPolyData *pCoonsPlane = vtkPolyData::New();</DIV>  <DIV>vtkPoints *pMeshPoints;</DIV>  <DIV>vtkCellArray *pMeshCells;</DIV>  <DIV>&nbsp;</DIV>  <DIV></DIV>  <DIV></FONT><FONT color=#008000 size=2>// allocate space for points</DIV></FONT><FONT size=2>  <DIV>pMeshPoints = vtkPoints::New();</DIV>  <DIV>pMeshPoints-&gt;Allocate( 4 );</DIV>  <DIV>pMeshPoints-&gt;InsertNextPoint( sphereBounds[0] , sphereBounds[2] , 0.0 );</DIV>  <DIV>pMeshPoints-&gt;InsertNextPoint( sphereBounds[0] , sphereBounds[3] , 0.0 );</DIV>  <DIV>pMeshPoints-&gt;InsertNextPoint( sphereBounds[1] , sphereBounds[3] , 0.0 );</DIV>  <DIV>pMeshPoints-&gt;InsertNextPoint( sphereBounds[1] , sphereBounds[2] , 0.0 );</DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000
 size=2>// allocate space for cells</DIV></FONT><FONT size=2>  <DIV>pMeshCells = vtkCellArray::New();</DIV>  <DIV>pMeshCells-&gt;Allocate( pMeshCells-&gt;EstimateSize( 1 , 4 ) );</DIV>  <DIV>vtkIdType pts[4];</DIV>  <DIV></DIV>  <DIV>pts[0] = 0;</DIV>  <DIV>pts[1] = 1;</DIV>  <DIV>pts[2] = 2;</DIV>  <DIV>pts[3] = 3;</DIV>  <DIV>pMeshCells-&gt;InsertNextCell( 4 , pts ); </DIV>  <DIV></DIV>  <DIV>&nbsp;</DIV>  <DIV>pCoonsPlane-&gt;SetPoints( pMeshPoints );</DIV>  <DIV>pCoonsPlane-&gt;SetPolys( pMeshCells );</DIV>  <DIV>&nbsp;</DIV>  <DIV>pMeshPoints-&gt;Delete();</DIV>  <DIV>pMeshCells-&gt;Delete();</DIV>  <DIV>&nbsp;</DIV>  <DIV>vtkPolyDataMapper *pCoonsMapper = vtkPolyDataMapper::New();</DIV>  <DIV>pCoonsMapper-&gt;SetInput( pCoonsPlane );</DIV>  <DIV>pCoonsMapper-&gt;Update();</DIV>  <DIV>&nbsp;</DIV>  <DIV>vtkOpenGLActor *pCoonsActor = vtkOpenGLActor::New();</DIV>  <DIV>pCoonsActor-&gt;SetMapper( pCoonsMapper );</DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV> 
 <DIV><FONT color=#008000 size=2>// setup rendering</DIV></FONT><FONT size=2>  <DIV>vtkOpenGLRenderer *pOffScreenRenderer = vtkOpenGLRenderer::New();</DIV>  <DIV></DIV>  <DIV></FONT><FONT color=#0000ff size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#0000ff size=2>double</FONT><FONT size=2> wx, wy;</DIV>  <DIV>wx = 500;</DIV>  <DIV>wy = 500;</DIV>  <DIV>&nbsp;</DIV>  <DIV>vtkWin32OpenGLRenderWindow *pOffScreenRenderWindow = vtkWin32OpenGLRenderWindow::New();</DIV>  <DIV>pOffScreenRenderWindow-&gt;OffScreenRenderingOn();</DIV>  <DIV>pOffScreenRenderWindow-&gt;AddRenderer( pOffScreenRenderer );</DIV>  <DIV>pOffScreenRenderWindow-&gt;Start();</DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// add actors</DIV></FONT><FONT size=2>  <DIV>pOffScreenRenderer-&gt;AddActor( pSphereActor );</DIV>  <DIV>pOffScreenRenderer-&gt;AddActor( pCoonsActor );</DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000
 size=2>// set up projection attributes</DIV></FONT><FONT size=2>  <DIV>pOffScreenRenderer-&gt;GetActiveCamera()-&gt;ParallelProjectionOn();</DIV>  <DIV>pOffScreenRenderWindow-&gt;SetSize( wx , wy );</DIV>  <DIV>pOffScreenRenderer-&gt;ResetCamera();</DIV>  <DIV></DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// show sphere and coons plane actor first</DIV></FONT><FONT size=2>  <DIV>pOffScreenRenderer-&gt;Render();</DIV>  <DIV></DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// write window to disk image</DIV></FONT><FONT size=2>  <DIV>vtkWindowToImageFilter *pSphereWindowImageFilter = vtkWindowToImageFilter::New();</DIV>  <DIV>pSphereWindowImageFilter-&gt;SetInput( pOffScreenRenderWindow );</DIV>  <DIV>vtkJPEGWriter *pSphereImageWriter = vtkJPEGWriter::New();</DIV>  <DIV>pSphereImageWriter-&gt;SetInput( pSphereWindowImageFilter-&gt;GetOutput() );</DIV> 
 <DIV>pSphereImageWriter-&gt;SetQuality( 100.0 );</DIV>  <DIV>pSphereImageWriter-&gt;SetFileName( "Sphere_image.jpg" );</DIV>  <DIV>pSphereImageWriter-&gt;ProgressiveOff();</DIV>  <DIV>pSphereImageWriter-&gt;Write();</DIV>  <DIV>pSphereImageWriter-&gt;Delete();</DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// get Sphere zbuffer </DIV></FONT><FONT size=2>  <DIV></FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2> *pSphereZBuffer = pOffScreenRenderWindow-&gt;GetZbufferData( 0 , 0 , wx , wy );</DIV>  <DIV></DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// show only coons actor</DIV></FONT><FONT size=2>  <DIV>pSphereActor-&gt;VisibilityOff();</DIV>  <DIV>pOffScreenRenderer-&gt;Render();</DIV>  <DIV></DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// write window to disk image</DIV></FONT><FONT size=2> 
 <DIV>vtkWindowToImageFilter *pCoonsWindowImageFilter = vtkWindowToImageFilter::New();</DIV>  <DIV>pCoonsWindowImageFilter-&gt;SetInput( pOffScreenRenderWindow );</DIV>  <DIV>vtkJPEGWriter *pCoonsImageWriter = vtkJPEGWriter::New();</DIV>  <DIV>pCoonsImageWriter-&gt;SetInput( pCoonsWindowImageFilter-&gt;GetOutput() );</DIV>  <DIV>pCoonsImageWriter-&gt;SetQuality( 100.0 );</DIV>  <DIV>pCoonsImageWriter-&gt;SetFileName( "coons_image.jpg" );</DIV>  <DIV>pCoonsImageWriter-&gt;ProgressiveOff();</DIV>  <DIV>pCoonsImageWriter-&gt;Write();</DIV>  <DIV>pCoonsImageWriter-&gt;Delete();</DIV>  <DIV></FONT><FONT color=#008000 size=2></FONT>&nbsp;</DIV>  <DIV><FONT color=#008000 size=2>// get Sphere zbuffer </DIV></FONT><FONT size=2>  <DIV></FONT><FONT color=#0000ff size=2>float</FONT><FONT size=2> *pCoonsZBuffer = pOffScreenRenderWindow-&gt;GetZbufferData( 0 , 0 , wx , wy );</DIV>  <DIV>&nbsp;</DIV><FONT color=#008000 size=2>  <DIV>// compute diffrence</DIV></FONT></FONT><FONT color=#0000ff
 size=2></FONT>  <DIV><FONT color=#0000ff size=2>double</FONT><FONT size=2> dblSphereVolume = 0.0;</DIV>  <DIV></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>( </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> i = 0 ; i &lt; wx ; i++ )</DIV>  <DIV>{</DIV>  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">  <DIV></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>( </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> j = 0 ; j &lt; wy ; j++ )</DIV>  <DIV>{</DIV>  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">  <DIV></FONT><FONT color=#0000ff size=2>long</FONT><FONT size=2> index = i * j;</DIV>  <DIV></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> coons_depth, Sphere_depth;</DIV>  <DIV>Sphere_depth = pSphereZBuffer[index];</DIV>  <DIV></DIV></BLOCKQUOTE></BLOCKQUOTE></FONT>  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">  <DIV><FONT color=#008000 size=2></DIV></FONT><FONT size=2>  <DIV></DIV> 
 <DIV>coons_depth = pCoonsZBuffer[index];</DIV>  <DIV></DIV>  <DIV></FONT>  <DIV><FONT color=#008000 size=2></DIV></FONT><FONT size=2>  <DIV></DIV></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> diff = ( Sphere_depth - coons_depth );</DIV></FONT><FONT size=2>  <DIV>dblSphereVolume += diff;</DIV></BLOCKQUOTE>  <DIV>}</DIV></BLOCKQUOTE>  <DIV>}</DIV>  <DIV>&nbsp;</DIV>  <DIV>printf( "\ncomputed Sphere volume = %lf\n" , dblSphereVolume );</DIV>  <DIV>getch();</DIV></FONT>  <DIV>&nbsp;</DIV></DIV></DIV><p>
        
                <hr size=1>Yahoo! Shopping<br> 
Find Great Deals on Gifts at <a href="http://shopping.yahoo.com/;_ylc=X3oDMTE2bzVzaHJtBF9TAzk1OTQ5NjM2BHNlYwNtYWlsdGFnBHNsawNob2xpZGF5LTA1 
">Yahoo! Shopping</a>