[vtkusers] marching cubes: scalar values equal to isovalue

Eduardo Suarez-Santana esuarez at itccanarias.org
Wed Mar 2 07:51:00 EST 2011


El 01/03/11 17:33, Bill Lorensen escribió:
> Edges are generated on cell faces, triangles are not generated on cell
> faces. So, you will have shared edges, but never shared faces.

You are right. What I meant was that there were two triangles in the
same position.

This is a small python script where, as far as I understand, generates
two triangles in the same position, coincident with the shared face.
These are the triangles which enclose no volume, and I'd like to remove.

---- BEGIN HERE ----
#!/usr/bin/python

import vtk

# three 'ones' in their common face
st = vtk.vtkStructuredPoints()
st.SetDimensions(2,3,2)
st.AllocateScalars()
sc = (st.GetPointData()).GetScalars()
sc.SetValue(  0, 0.0 )
sc.SetValue(  1, 0.0 )
sc.SetValue(  2, 1.0 )
sc.SetValue(  3, 1.0 )
sc.SetValue(  4, 0.0 )
sc.SetValue(  5, 0.0 )
sc.SetValue(  6, 0.0 )
sc.SetValue(  7, 0.0 )
sc.SetValue(  8, 0.0 )
sc.SetValue(  9, 1.0 )
sc.SetValue( 10, 0.0 )
sc.SetValue( 11, 0.0 )

mc = vtk.vtkMarchingCubes()
mc.SetNumberOfContours(1)
mc.SetValue( 0, 1.0 )
mc.SetInput(st)
mc.Update()

pd = mc.GetOutput()
print "Number of Cells: %d\n" % pd.GetNumberOfCells() # return 2L
print pd.GetCell(0) # return a triangle, coincident with the face
print pd.GetCell(1) # return another triangle, in the same position
---- END HERE ----




More information about the vtkusers mailing list