<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>  <LI>Next i create a square Plane&nbsp;actor which represents the base of the hemispherical surface.</LI>  <LI>Now i create an off screen
 render window using <STRONG>vtkWin32OpenGLRenderWindow. </STRONG></LI>  <LI>I make the renderer to use OrthographicProjection using vtkRenderer::ParallelProjectionOn.</LI>  <LI>Then i first render both actors to the renderer.</LI>  <LI>I get the z-buffer data of the render window using vtkRenderWindow::GetZBufferData with the hemisphere and cache it.</LI>  <LI>Then i hide the hemipherical actor using vtkActor::VisibilityOff.</LI>  <LI>Then i get the z-buffer data of the plane actor.</LI>  <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>*************************************************************************************************</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>&nbsp;</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp;</DIV>  <DIV>&nbsp;</DIV><p>
                <hr size=1> <B>Yahoo! Personals</B><BR> 
Skip the bars and set-ups and <a href="http://us.rd.yahoo.com/evt=36107/*http://personals.yahoo.com/us/reg/free7days 
">start using Yahoo! Personals for free</a>