<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi Ricky,<br>
    <br>
    I guess that's what I need to do. Thanks a lot all. And if it does
    work, I'll check what I can do for vtk :)<br>
    <br>
    Cheers and have a nice week end!<br>
    <br>
    Adrien<br>
    <br>
    <div class="moz-cite-prefix">Le 30/05/2014 19:46, Ricky Singla a
      écrit :<br>
    </div>
    <blockquote
cite="mid:CAPEEyN6dMdvJP16ANvwyMmA=u79_gw+N8XRiL+-GjiFBRxw6vw@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Adrien,
        <div><br>
        </div>
        <div>Have you considered using a non-VTK based STL writer? For
          example: <a moz-do-not-send="true"
            href="http://code.activestate.com/recipes/578246-stl-writer/">http://code.activestate.com/recipes/578246-stl-writer/</a></div>
        <div><br>
        </div>
        <div>Shows how you could write your own in Python. That being
          said, you could always contribute some changes to improve the
          STL writer in VTK. </div>
        <div><br>
        </div>
        <div>Hope this helps.</div>
        <div><br>
        </div>
        <div>Cheers,</div>
        <div class="gmail_extra"><br clear="all">
          <div>
            <div dir="ltr">Ricky Singla <br>
            </div>
          </div>
          <br>
          <br>
          <div class="gmail_quote">On Fri, May 30, 2014 at 10:43 AM,
            David Gobbi <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              Hi Adrien,<br>
              <br>
              I'm fond of python, too, but why do you think this problem<br>
              is specific to python?  It would be the same in any
              language.<br>
              <br>
                David<br>
              <br>
              On Fri, May 30, 2014 at 11:31 AM, Adrien Brunet <<a
                moz-do-not-send="true"
                href="mailto:brunet.adrien@gmail.com">brunet.adrien@gmail.com</a>>
              wrote:<br>
              > Hi,<br>
              ><br>
              > thanks a ton for this so quick answer!<br>
              > I guess I need to change my tools then, do you have
              any advice? I'm fond of<br>
              > python but I'm ok with any other language...<br>
              ><br>
              > Cheers,<br>
              ><br>
              > Adrien<br>
              ><br>
              ><br>
              > Le 30/05/2014 19:26, David Gobbi a écrit :<br>
              <div class="HOEnZb">
                <div class="h5">><br>
                  >> Hi Adrien,<br>
                  >><br>
                  >> This is the first time that I've heard this
                  question.  The answer is that<br>
                  >> the<br>
                  >> vtkSTLWriter is not sophisticated enough to
                  write files with multiple<br>
                  >> solids.<br>
                  >> This is a bit strange, because the
                  vtkSTLReader is capable of labeling the<br>
                  >> solids when it reads them.<br>
                  >><br>
                  >>    David<br>
                  >><br>
                  >><br>
                  >> On Fri, May 30, 2014 at 11:06 AM, Adrien
                  Brunet <<a moz-do-not-send="true"
                    href="mailto:brunet.adrien@gmail.com">brunet.adrien@gmail.com</a>><br>
                  >> wrote:<br>
                  >>><br>
                  >>> Hi guys,<br>
                  >>><br>
                  >>> I hope this has not been already asked
                  but the archives are not really<br>
                  >>> handy<br>
                  >>> to explore...<br>
                  >>><br>
                  >>> I'm converting stl files from ascii to
                  binary and from binary to ascii<br>
                  >>> with<br>
                  >>> vtk. I use the following code:<br>
                  >>><br>
                  >>> #!/usr/bin/env python<br>
                  >>><br>
                  >>> import vtk<br>
                  >>><br>
                  >>><br>
                  >>> def convert_stl2ascii(path):<br>
                  >>>      reader = vtk.vtkSTLReader()<br>
                  >>><br>
                  >>>      reader.SetFileName(path)<br>
                  >>>      reader.Update()<br>
                  >>>      write = vtk.vtkSTLWriter()<br>
                  >>>      write.SetFileTypeToASCII()<br>
                  >>><br>
                  >>>      write.SetInput(reader.GetOutput())<br>
                  >>>      write.SetFileName(path)<br>
                  >>>      write.Write()<br>
                  >>><br>
                  >>><br>
                  >>> def convert_stl2binary(path):<br>
                  >>>      reader = vtk.vtkSTLReader()<br>
                  >>><br>
                  >>>      reader.SetFileName(path)<br>
                  >>>      reader.Update()<br>
                  >>>      write = vtk.vtkSTLWriter()<br>
                  >>>      write.SetFileTypeToBinary()<br>
                  >>><br>
                  >>>    
                   write.SetFileName('_binary.stl'.join(path.split('.stl')))<br>
                  >>>      write.SetInput(reader.GetOutput())<br>
                  >>>      write.Write()<br>
                  >>><br>
                  >>><br>
                  >>><br>
                  >>> It does work BUT, Let's say I have a
                  ascii stl file like this:<br>
                  >>><br>
                  >>> solid first_name<br>
                  >>>      [...]<br>
                  >>> endsolid<br>
                  >>> solid second_name<br>
                  >>>      [...]<br>
                  >>> endsolid<br>
                  >>><br>
                  >>> I can convert it to a binary file but
                  when I try to convert it back to<br>
                  >>> ascii, I get something like:<br>
                  >>><br>
                  >>> solid ascii<br>
                  >>>      [...]<br>
                  >>> endsolid<br>
                  >>><br>
                  >>> What should I do to keep the Region name
                  first_name and second_name and<br>
                  >>> to<br>
                  >>> avoid that several different regions to
                  be merged in only one region?<br>
                  >>><br>
                  >>> Cheers !!<br>
                  ><br>
                  ><br>
                  _______________________________________________<br>
                  Powered by <a moz-do-not-send="true"
                    href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
                  <br>
                  Visit other Kitware open-source projects at <a
                    moz-do-not-send="true"
                    href="http://www.kitware.com/opensource/opensource.html"
                    target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
                  <br>
                  Please keep messages on-topic and check the VTK FAQ
                  at: <a moz-do-not-send="true"
                    href="http://www.vtk.org/Wiki/VTK_FAQ"
                    target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
                  <br>
                  Follow this link to subscribe/unsubscribe:<br>
                  <a moz-do-not-send="true"
                    href="http://www.vtk.org/mailman/listinfo/vtkusers"
                    target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>