Skip to content

Instantly share code, notes, and snippets.

@dgobbi
dgobbi / bracefix.py
Created July 3, 2016 19:31
Modernize VTK brace style, optionally convert to my own K&R-based style
#! /usr/bin/env python
"""
Usage: python bracefix.py [--test] <file1> [<file2> ...]
This script takes old-style "Whitesmiths" indented VTK source files as
input, and re-indents the braces according to the new VTK style.
Only the brace indentation is modified.
If called with the --test option, then it will print an error message
for each file that it would modify, but it will not actually modify the
// Clip a line segment defined by endpoints at p1[3], p2[3] by a
// collection of n planes defined by the equation ax+by+cz+d=0.
// The parametric coordinates t1,t2 of new endpoints are returned,
// as well as the indices i1,i2 of the entry and exit planes for the line.
// Result values of -1 for i1 or i2 signify that the line was not clipped
// at the p1 end or the p2 end respectively. The function return value
// will be 0 if the whole line segment lies outside, or 1 if the line
// segment lies fully or partially inside the planes.
int clipLineWithPlanes(const double p1[3], const double p2[3],
"""
This is a simple class that can catch errors from VTK objects.
"""
import vtk
class ErrorObserver:
def __init__(self):
self.__ErrorOccurred = False
!!ARBfp1.0
# This is a short fragment program for bicubic texture interpolation.
# It takes one parameter, a vector that gives the texture size as
# (xsize, ysize, 1.0/xsize, 1.0/ysize). The cubic interpolation weights
# are computed by the shader, so it is not necessary to supply an
# interpolation kernel texture.
# width, height, xspacing, yspacing
#include <stdio.h>
#include <stdlib.h>
// This is a program for converting a binary image (little-endian)
// into a set of integers that indicate the position where the bit
// value changes. It is much faster than going through bit-by-bit.
int main(int argc, char *argv[])
{
static const int debruijn[32] =
@dgobbi
dgobbi / ImageStreaming.cxx
Last active November 9, 2015 20:32
An example of using a writer that automatically streams image data through VTK.
//
// A simple example of image streaming, using a reader that can stream
// from a file and a writer than can stream to a file.
//
// Currently, the only image writer in VTK that streams from its input
// is the vtkMINCImageWriter.
//
// Please send any comments to david.gobbi@gmail.com
//