From: Jonathan S. <jjs...@us...> - 2007-01-27 22:50:43
|
Update of /cvsroot/octaviz/octaviz/Scripts In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24964 Modified Files: vtk_polycut.m vtk_trimesh.m vtk_trisurf.m vtk_update.m Log Message: a few bug fixes and adjustments Index: vtk_update.m =================================================================== RCS file: /cvsroot/octaviz/octaviz/Scripts/vtk_update.m,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- vtk_update.m 1 Jun 2005 19:40:40 -0000 1.3 +++ vtk_update.m 27 Jan 2007 22:50:38 -0000 1.4 @@ -27,6 +27,7 @@ f.outline_actor.VisibilityOff(); f.axes.VisibilityOff(); + if ( f.axes_on ) b = f.renderer.ComputeVisiblePropBounds(); f.outline.SetBounds( b(1), b(2), b(3), b(4), b(5), b(6) ); @@ -39,3 +40,14 @@ f.window.Render(); endfunction + +## 'f.axes_on' is reverting to 1 after being set to 0, effectively making the if statement above of no effect +## to be solved later; JJS 1/24/07 +## for example, do: +##(make a figure with axes, e.g. vtk_sombsurf) +##f = vtk_figure(0); +##f.axes_on = 0 +##vtk_update (f); +##clear f +##f = vtk_figure (0); +##f.axes_on Index: vtk_polycut.m =================================================================== RCS file: /cvsroot/octaviz/octaviz/Scripts/vtk_polycut.m,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- vtk_polycut.m 27 Oct 2004 05:34:45 -0000 1.1 +++ vtk_polycut.m 27 Jan 2007 22:50:38 -0000 1.2 @@ -15,7 +15,7 @@ ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{f} =} vtk_polycut(@var{t},@var{x},@var{y},@var{z},@var{c},@var{p0},@var{n}) +## @deftypefn {Function File} vtk_polycut(@var{t},@var{x},@var{y},@var{z},@var{c},@var{p0},@var{n}) ## This function cuts a polygon surface at a plane, leaving only the ## line plot of the surface in that plane. The plane is defined by the ## point @var{p0} and the normal @var{n}. @@ -57,12 +57,14 @@ pts = [x y z]'; coords.SetArray( pts(:), 3*length(x), 0 ); points.SetData(coords); - - colors = vtkUnsignedCharArray; - colors.SetNumberOfTuples( length(x) ); - colors.SetNumberOfComponents(3); - c = c'*255; - colors.SetArray( c(:), 3*length(x), 0 ); + + ## difficult to see the lines with this color scheme; + ## just use default white for now; JJS 1/24/07 + ##colors = vtkUnsignedCharArray; + ##colors.SetNumberOfTuples( length(x) ); + ##colors.SetNumberOfComponents(3); + ##c = c'*255; + ##colors.SetArray( c(:), 3*length(x), 0 ); %% for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]); [nr nc] = size(t); @@ -82,7 +84,7 @@ %% We now assign the pieces to the vtkPolyData. surface.SetPoints(points); surface.SetPolys(polys); - surface.GetPointData().SetScalars(colors); + ##surface.GetPointData().SetScalars(colors); %% We clip with an implicit function. Here we use a plane positioned near; Index: vtk_trisurf.m =================================================================== RCS file: /cvsroot/octaviz/octaviz/Scripts/vtk_trisurf.m,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- vtk_trisurf.m 25 Dec 2006 20:12:50 -0000 1.10 +++ vtk_trisurf.m 27 Jan 2007 22:50:38 -0000 1.11 @@ -146,7 +146,24 @@ endif no_tris = length(t); - t = [ones(no_tris,1)*3 t-1]'; + ## check whether t has invalid indices (prevent segfaults), JJS 1/22/07 + npts = length(x); + tmin = min(t(:)); + tmax = max(t(:)); + if ( tmin < 0 ) + error ("negative value indices detected") + elseif ( tmin==0 ) + if ( tmax>npts-1 ) + error ("maximum index value is larger than the number of points") + endif + t = [ones(no_tris,1)*3 t]'; + warning ("using zero value indices") + else + if ( tmax>npts ) + error ("maximum index value is larger than the number of points") + endif + t = [ones(no_tris,1)*3 t-1]'; + endif ptids = vtkIdTypeArray; ptids.SetArray( t(:), no_tris*4, 0 ); polys.SetCells( no_tris, ptids ); Index: vtk_trimesh.m =================================================================== RCS file: /cvsroot/octaviz/octaviz/Scripts/vtk_trimesh.m,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- vtk_trimesh.m 25 Dec 2006 20:12:50 -0000 1.8 +++ vtk_trimesh.m 27 Jan 2007 22:50:38 -0000 1.9 @@ -174,7 +174,24 @@ endif no_tris = length(t); - t = [ones(no_tris,1)*3 t-1]'; + ## check whether t has invalid indices (prevent segfaults), JJS 1/22/07 + npts = length(x); + tmin = min(t(:)); + tmax = max(t(:)); + if ( tmin < 0 ) + error ("negative value indices detected") + elseif ( tmin==0 ) + if ( tmax>npts-1 ) + error ("maximum index value is larger than the number of points") + endif + t = [ones(no_tris,1)*3 t]'; + warning ("using zero value indices") + else + if ( tmax>npts ) + error ("maximum index value is larger than the number of points") + endif + t = [ones(no_tris,1)*3 t-1]'; + endif ptids = vtkIdTypeArray; ptids.SetArray( t(:), no_tris*4, 0 ); polys.SetCells( no_tris, ptids ); |