<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
If you need a 3d volume of bitmaps that are all the same x,y size, just
do the same thing, but add an iteration over the z-dimension. The
vtkImageData object supports 3 dimensions. Then, for each distinct
value of z, you'll be jamming a separate bitmap into a given z-slice of
the vtkImageData.<br>
<br>
In the example, change the SetDimensions call to include more than one
z value:<br>
&nbsp; imageData-&gt;SetDimensions(16, 16, <b>16</b>);<br>
<br>
Then add another loop to fill in the z data:<br>
&nbsp; int k = 0;<br>
&nbsp; for (k= 0; k&lt;16; ++k) // as outer loop; i and j loops in here;
conecptually, first slice filled is z=0, next z=1 and so on...<br>
<br>
Then simply use the imageData object as the input to your algorithm,
just like you would have used the output of the BMP reader...<br>
<br>
<br>
David<br>
<br>
<br>
med ali wrote:
<blockquote
 cite="mid20050609174215.91108.qmail@web26403.mail.ukl.yahoo.com"
 type="cite">
  <div>hi David,</div>
  <div>&nbsp;</div>
  <div>thanks for this example </div>
  <div>&nbsp;</div>
  <div>this example work for one array but i want&nbsp; do that for many
arrays of bmp images&nbsp; </div>
  <div>because after&nbsp; i will pass the output to&nbsp; the <font size="2">vtkImageMarchingCubes
.</font></div>
  <div>&nbsp;</div>
  <div>how can i do this without using vtkBMPReader.</div>
  <div>&nbsp;</div>
  <div>regards </div>
  <div>dali</div>
  <div>&nbsp;</div>
  <div><font size="2">
  <p>&nbsp;</p>
  <p>/////////////////////////////////////////////////////// the code&nbsp;
///////////////////////////////////////////</p>
  <p><font color="#ff007f">vtkBMPReader *bmpreader=vtkBMPReader ::New();</font></p>
  <p><font color="#ff007f">bmpreader-&gt;SetFilePrefix (prefix);</font></p>
  <p><font color="#ff007f">bmpreader-&gt;SetFileNameSliceOffset(1);</font></p>
  <p><font color="#ff007f">bmpreader-&gt;SetFilePattern("%s%d.bmp");</font></p>
  <p><font color="#ff007f">bmpreader-&gt;SetDataExtent(0,width,
0,height, 0, 31); </font></p>
  <p><font color="#ff007f">//319 -( width-1, 239 - (height-1), 10 - (no
of bitmaps-1)</font></p>
  <p><font color="#ff007f">bmpreader-&gt;SetDataSpacing(1,1,interslices);</font></p>
  <p>&nbsp;</p>
  <p>//marchingcubes</p>
  <p>vtkImageMarchingCubes *MC=vtkImageMarchingCubes ::New();</p>
  <p>MC-&gt;SetInput(bmpreader-&gt;GetOutput());</p>
  <p>MC-&gt;SetValue(0,iso-value);</p>
  <p>MC-&gt;GetOutput()-&gt;Update();</p>
  <p>&nbsp;</p>
  <p>////////////////////////////////&nbsp;
///////////////////////////////////////////////////////</p>
  </font><br>
  <br>
  <b><i>David Cole <a class="moz-txt-link-rfc2396E" href="mailto:david.cole@kitware.com">&lt;david.cole@kitware.com&gt;</a></i></b> a &eacute;crit :</div>
  <blockquote class="replbq"
 style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">Please
keep questions/replies on the list in case somebody else has time to
respond sooner. (Next time, keep cc'ing <a
 class="moz-txt-link-abbreviated" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>...)<br>
    <br>
Here's a small example that builds a vtkImageData from raw r,g,b values
and shows it in a render window. It's an adaptation and reduction of
VTK/Examples/Tutorial/Step6/Cxx/Cone6.cxx. I've eliminated the cone
source/mapper/actor and added a vtkImageData and vtkImageActor.<br>
    <br>
The important pieces of the puzzle are SetScalarTypeToUnsignedChar and
SetNumberOfScalarComponents(3). Then you can fill in the r,g,b values
to your liking in a loop after allocating the scalars. If you already
have a bitmap allocated and filled in, there's probably a way for you
to set that data in as the scalar data here as long as it is laid out
properly: r, g, b sequentially for each pixe! l as shown here. I'll let
somebody else who's done that before chime in if you need more help. :-)<br>
    <br>
//====================&lt;SampleCode&gt;====================<br>
#include "vtkImageActor.h"<br>
#include "vtkImageData.h"<br>
#include "vtkInteractorStyleTrackballCamera.h"<br>
#include "vtkRenderer.h"<br>
#include "vtkRenderWindow.h"<br>
#include "vtkRenderWindowInteractor.h"<br>
    <br>
int main()<br>
{<br>
&nbsp; vtkImageData *imageData = vtkImageData::New();<br>
&nbsp; imageData-&gt;SetScalarTypeToUnsignedChar();<br>
&nbsp; imageData-&gt;SetNumberOfScalarComponents(3);<br>
&nbsp; imageData-&gt;SetDimensions(16, 16, 1);<br>
&nbsp; imageData-&gt;AllocateScalars();<br>
    <br>
&nbsp; int i = 0;<br>
&nbsp; int j = 0;<br>
&nbsp; unsigned char r = 0;<br>
&nbsp; unsigned char g = 0;<br>
&nbsp; unsigned char b = 0;<br>
&nbsp; unsigned char *data = (unsigned char *)
imageData-&gt;GetScalarPointer();<br>
&nbsp; for (i= 0; i&lt;16; ++i)<br>
&nbsp; for (j= 0; j&lt;16; ++j)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp; Checkerboard test pattern with red, green, blue and black
quadrants:<br>
&nbsp;&nbsp;&nbsp; if ((j+i) % 2)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r= g= b= 0;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i&gt;7 &amp;&amp; j&gt;7)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r= 255;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (i&gt;7)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b= 255;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (j&gt;7)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g= 255;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; White on the "other" part of the checkerboard:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r= g= b= 255;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Grayscale ramp:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //r= g= b= 16*i + j;<br>
&nbsp;&nbsp;&nbsp; }<br>
    <br>
&nbsp;&nbsp;&nbsp; *data++ = r;<br>
&nbsp;&nbsp;&nbsp; *data++ = g;<br>
&nbsp;&nbsp;&nbsp; *data++ = b;<br>
&nbsp; }<br>
    <br>
&nbsp; vtkImageActor *imageActor = vtkImageActor::New();<br>
&nbsp; imageActor-&gt;SetInput(imageData);<br>
&nbsp; imageActor-&gt;InterpolateOff();<br>
    <br>
&nbsp; vtkRenderer *ren1= vtkRenderer::New();<br>
&nbsp; ren1-&gt;AddActor( imageActor );<br>
&nbsp; ren1-&gt;SetBackground( 0.1, 0.2, 0.4 );<br>
    <br>
&nbsp; vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
&nbsp; renWin-&gt;AddRenderer( ren1 );<br>
&nbsp; renWin-&gt;SetSize( 300, 300 );<br>
    <br>
&nbsp; vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
&nbsp; iren-&gt;SetRenderWindow(renWin);<br>
    <br>
&nbsp; vtkInteractorStyleTrackballCamera *style =
vtkInteractorStyleTrackballCamera::New();<br>
&nbsp; iren-&gt;SetInteractorStyle(style);<br>
    <br>
&nbsp; iren-&gt;Initialize();<br>
&nbsp; iren-&gt;Start();<br>
    <br>
&nbsp; imageActor-&gt;Delete();<br>
&nbsp; imageData-&gt;Delete();<br>
&nbsp; ren1-&gt;Delete();<br>
&nbsp; renWin-&gt;Delete();<br>
&nbsp; iren-&gt;Delete();<br>
&nbsp; style-&gt;Delete();<br>
    <br>
&nbsp; return 0;<br>
}<br>
//====================&lt;/SampleCode&gt;====================<br>
    <br>
    <br>
Hope this helps you get a little further,<br>
David<br>
    <br>
    <br>
    <br>
med ali wrote:
    <blockquote
 cite="mid20050607153402.74432.qmail@web26407.mail.ukl.yahoo.com"
 type="cite">
      <div>Hi,</div>
      <div>&nbsp;</div>
      <div>thanks you,</div>
      <div>but i 'am begginer in vtk </div>
      <div>can you give me a short example that i can begin with .</div>
      <div>&nbsp;</div>
      <div>thanks,</div>
      <div>&nbsp;</div>
      <div>dali<br>
      <br>
      <b><i>David Cole <a class="moz-txt-link-rfc2396E"
 href="mailto:david.cole@kitware.com">&lt;david.cole@kitware.com&gt;</a></i></b>
a &eacute;crit :</div>
      <blockquote class="replbq"
 style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">The
output of vtkBMPReader (which is derived from vtkImageAlgorithm) is a
vtkImageData. Just construct a vtkImageData directly from your data
with the correct dimensions, scalar type and underlying data rather
than using vtkBMPReader.<br>
        <br>
med ali wrote:
        <blockquote
 cite="mid20050607144554.60708.qmail@web26407.mail.ukl.yahoo.com"
 type="cite">
          <div>
          <p>Hi all,</p>
          <p>&nbsp;</p>
          <p>i want use vtkBMPReader&nbsp; but&nbsp; not directly on the files </p>
          <p>&nbsp;instead of passing the prefix of slices&nbsp; can i pass the
array data&nbsp; of pixels&nbsp; to vtkBMPReader</p>
          <font size="2"><font size="2">
          <p>/* </p>
          <p>bmp= vtkBMPReader::New();</p>
          </font></font>
          <p><font size="2">bmp-&gt;SetFilePrefix (prefix);</font></p>
          <p><font size="2">bmp-&gt;SetFileNameSliceOffset(1);</font></p>
          <p><font size="2">bmp-&gt;SetFilePattern("%s%d.bmp");</font></p>
          <p><font size="2">*/</font></p>
          </div>
          <hr size="1">
D&eacute;couvrez le nouveau Yahoo! Mail : <font color="red">1 Go d'espace</font>
de stockage pour vos mails, photos et vid&eacute;os !<br>
          <a
 href="http://us.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_1go/default/*http://fr.promotions.yahoo.com/mail/creer28.html"
 target="_blank">Cr&eacute;ez votre Yahoo! Mail</a>
          <pre wrap=""><hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: <a
 class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext"
 href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
  </pre>
        </blockquote>
      </blockquote>
      <hr size="1">
D&eacute;couvrez le nouveau Yahoo! Mail : <font color="red">1 Go d'espace</font>
de stockage pour vos mails, photos et vid&eacute;os !<br>
      <a
 href="http://us.rd.yahoo.com/mail_fr/mail_campaigns/splash/taglines_1go/default/*http://fr.promotions.yahoo.com/mail/creer28.html"
 target="_blank">Cr&eacute;ez votre Yahoo! Mail</a> </blockquote>
  </blockquote>
  <p> </p>
  <hr size="1"> <b><font color="#ff0000">Appel audio GRATUIT</font>
partout dans le monde</b> avec le nouveau Yahoo! Messenger<br>
  <a
 href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com">T&eacute;l&eacute;chargez
le ici !</a> </blockquote>
</body>
</html>