[Paraview] RAW to STL Script Help?

Eric E. Monson emonson at cs.duke.edu
Wed Oct 13 19:11:25 EDT 2010


Hey Christopher,

Well, I think that page is the best current documentation. Which version of ParaView are you using? (The API has changed quite a bit over various versions, and if you're using an earlier version than 3.8 or 3.9, the Python API has gotten much nicer these days.)

I'm not actually sure how to write the STL file with PV 3.8.1, but with the current development version (3.9) you can load the data and write the STL with something like this (which I used the Python State Trace to figure out the commands -- ask if you don't know how to use this functionality because it's _really_ helpful in writing scripts):

# =====================
try: paraview.simple
except: from paraview.simple import *

noisy_10x100x100_sphere_raw = ImageReader( guiName="noisy_10x100x100_sphere.raw", ScalarArrayName='ImageFile', DataExtent=[0, 10, 0, 100, 0, 100], FilePrefix='/Users/emonson/Programming/ParaView_git/ParaViewData/Data/noisy_10x100x100_sphere.raw', NumberOfScalarComponents=1, FileDimensionality='3', DataByteOrder='LittleEndian', DataOrigin=[0.0, 0.0, 0.0], FilePattern='%s', DataSpacing=[10.0, 1.0, 1.0], DataScalarType='unsigned int', FileLowerLeft=1 )

Contour1 = Contour( guiName="Contour1", Isosurfaces=[1021190000.0, 1043550000.0, 1065900000.0], ComputeNormals=1, ComputeGradients=0, ComputeScalars=0, ContourBy=['POINTS', 'ImageFile'], PointMergeMethod="Uniform Binning" )

Show()

ResetCamera()
Render()

writer= CreateWriter("raw_contours.stl", Contour1)
writer.UpdatePipeline()
# =====================

Note that some of the options that are specified might be defaults that you wouldn't have to include, but I got these from the State Trace. Also, I didn't try to include the loop for varied file names...

Maybe someone else can chime in with the STL writing if you're using 3.8.1.

Hope this points you in the right direction,
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Oct 13, 2010, at 5:06 PM, Christopher Olah wrote:

> Dear All,
> 
> I have a large number of RAW files (unsigned characters in 3
> dimensions of varying size) and I need to extract isosurfaces and save
> them as STLs. I've been using paraview to do this (and it's awesome!),
> but doing it by hand is becoming impractical. Unfortunately, I've been
> having trouble figuring out how to script it.
> 
> In particular, I can't figure out how to load RAW files or how save
> STLs. In fact, the best documentation on the python API I can find is
> http://www.paraview.org/Wiki/ParaView/Python_Scripting ... Could
> someone direct me towards something a bit more comprehensive?
> 
> Thanks in advance,
> 
> Christopher Olah
> 
> PS. I hope this isn't too trivial to write to you about -- I couldn't
> really find anything on what level of question was appropriate for
> this list.
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
> 
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview



More information about the ParaView mailing list