[vtkusers] cutting through unstructured grid

Philippe Guerville philippe.guerville at free.fr
Thu Dec 7 15:25:30 EST 2000


Simon:

vtkCutter ask each cell to compute the intersection with the plane using the
marching cubes algorithm (The Visualization ToolKit 2nd Edition, p 161). The 256
intersection cases are described using triangles (file
common/vtkMarchingCubeCases.h triCases array). What I've done is to recombine
triangles into polys and to change the function vtkHexahedron::Contour (file
common/vtkHexahedron.cxx line 398).

Change the file accordingly and recompile libVTKcommon.a

typedef struct {
       EDGE_LIST edges[16];
} POLY_CASES;

// number of edges, edges list, number of edges, edges list, ..., end (-1)
static POLY_CASES polyCases[] = {
{{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  0
{{ 3, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  1
{{ 3, 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  2
{{ 4, 1, 3, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  3
{{ 3, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  4
{{ 3, 0, 3, 8, 3, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  5
{{ 4, 9, 11, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  6
{{ 5, 2, 3, 8, 9, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  7
{{ 3, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  8
{{ 4, 0, 2, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  9
{{ 3, 1, 0, 9, 3, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  10
{{ 5, 1, 2, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  11
{{ 4, 3, 1, 11, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  12
{{ 5, 0, 1, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  13
{{ 5, 3, 0, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  14
{{ 4, 9, 11, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  15
{{ 3, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  16
{{ 4, 4, 0, 3, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  17
{{ 3, 0, 9, 1, 3, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  18
{{ 5, 4, 9, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  19
{{ 3, 1, 11, 2, 3, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  20
{{ 4, 3, 7, 4, 0, 3, 1, 11, 2, -1, -1, -1, -1, -1, -1, -1 }}, //  21
{{ 4, 9, 11, 2, 0, 3, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1 }}, //  22
{{ 6, 2, 3, 7, 4, 9, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  23
{{ 3, 8, 7, 4, 3, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  24
{{ 5, 10, 7, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  25
{{ 3, 9, 1, 0, 3, 8, 7, 4, 3, 2, 10, 3, -1, -1, -1, -1 }}, //  26
{{ 6, 4, 9, 1, 2, 10, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  27
{{ 4, 3, 1, 11, 10, 3, 7, 4, 8, -1, -1, -1, -1, -1, -1, -1 }}, //  28
{{ 6, 1, 11, 10, 7, 4, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  29
{{ 3, 4, 8, 7, 5, 9, 11, 10, 3, 0, -1, -1, -1, -1, -1, -1 }}, //  30
{{ 5, 4, 9, 11, 10, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  31
{{ 3, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  32
{{ 3, 9, 4, 5, 3, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  33
{{ 4, 0, 4, 5, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  34
{{ 5, 8, 4, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  35
{{ 3, 1, 11, 2, 3, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  36
{{ 3, 3, 8, 0, 3, 1, 11, 2, 3, 4, 5, 9, -1, -1, -1, -1 }}, //  37
{{ 5, 5, 11, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  38
{{ 6, 2, 3, 8, 4, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  39
{{ 3, 9, 4, 5, 3, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  40
{{ 4, 0, 2, 10, 8, 3, 4, 5, 9, -1, -1, -1, -1, -1, -1, -1 }}, //  41
{{ 4, 0, 4, 5, 1, 3, 2, 10, 3, -1, -1, -1, -1, -1, -1, -1 }}, //  42
{{ 6, 2, 10, 8, 4, 5, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  43
{{ 4, 11, 10, 3, 1, 3, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1 }}, //  44
{{ 3, 4, 5, 9, 5, 0, 1, 11, 10, 8, -1, -1, -1, -1, -1, -1 }}, //  45
{{ 6, 5, 11, 10, 3, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  46
{{ 5, 5, 11, 10, 8, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  47
{{ 4, 9, 8, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  48
{{ 5, 9, 0, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  49
{{ 5, 0, 8, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  50
{{ 4, 1, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  51
{{ 4, 9, 8, 7, 5, 3, 11, 2, 1, -1, -1, -1, -1, -1, -1, -1 }}, //  52
{{ 3, 11, 2, 1, 5, 9, 0, 3, 7, 5, -1, -1, -1, -1, -1, -1 }}, //  53
{{ 6, 8, 7, 5, 11, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  54
{{ 5, 2, 3, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  55
{{ 4, 7, 5, 9, 8, 3, 3, 2, 10, -1, -1, -1, -1, -1, -1, -1 }}, //  56
{{ 6, 9, 0, 2, 10, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  57
{{ 3, 2, 10, 3, 5, 0, 8, 7, 5, 1, -1, -1, -1, -1, -1, -1 }}, //  58
{{ 5, 10, 7, 5, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  59
{{ 4, 9, 8, 7, 5, 4, 11, 10, 3, 1, -1, -1, -1, -1, -1, -1 }}, //  60
{{ 6, 5, 9, 0, 11, 10, 7, 3, 1, 11, 0, -1, -1, -1, -1, -1 }}, //  61
{{ 6, 10, 3, 0, 7, 5, 11, 3, 8, 7, 0, -1, -1, -1, -1, -1 }}, //  62
{{ 4, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  63
{{ 3, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  64
{{ 3, 0, 3, 8, 3, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  65
{{ 3, 9, 1, 0, 3, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  66
{{ 4, 1, 3, 8, 9, 3, 5, 6, 11, -1, -1, -1, -1, -1, -1, -1 }}, //  67
{{ 4, 1, 5, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  68
{{ 4, 1, 5, 6, 2, 3, 3, 8, 0, -1, -1, -1, -1, -1, -1, -1 }}, //  69
{{ 5, 9, 5, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  70
{{ 6, 5, 6, 2, 3, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  71
{{ 3, 2, 10, 3, 3, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  72
{{ 4, 10, 8, 0, 2, 3, 11, 5, 6, -1, -1, -1, -1, -1, -1, -1 }}, //  73
{{ 3, 0, 9, 1, 3, 2, 10, 3, 3, 5, 6, 11, -1, -1, -1, -1 }}, //  74
{{ 3, 5, 6, 11, 5, 1, 2, 10, 8, 9, -1, -1, -1, -1, -1, -1 }}, //  75
{{ 5, 6, 10, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  76
{{ 6, 0, 1, 5, 6, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  77
{{ 6, 3, 0, 9, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  78
{{ 5, 6, 10, 8, 9, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  79
{{ 3, 5, 6, 11, 3, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  80
{{ 4, 4, 0, 3, 7, 3, 6, 11, 5, -1, -1, -1, -1, -1, -1, -1 }}, //  81
{{ 3, 1, 0, 9, 3, 5, 6, 11, 3, 8, 7, 4, -1, -1, -1, -1 }}, //  82
{{ 3, 11, 5, 6, 5, 1, 3, 7, 4, 9, -1, -1, -1, -1, -1, -1 }}, //  83
{{ 4, 6, 2, 1, 5, 3, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1 }}, //  84
{{ 4, 1, 5, 6, 2, 4, 3, 7, 4, 0, -1, -1, -1, -1, -1, -1 }}, //  85
{{ 3, 8, 7, 4, 5, 9, 5, 6, 2, 0, -1, -1, -1, -1, -1, -1 }}, //  86
{{ 6, 7, 4, 9, 6, 2, 3, 3, 5, 6, 9, -1, -1, -1, -1, -1 }}, //  87
{{ 3, 3, 2, 10, 3, 7, 4, 8, 3, 11, 5, 6, -1, -1, -1, -1 }}, //  88
{{ 3, 5, 6, 11, 5, 4, 0, 2, 10, 7, -1, -1, -1, -1, -1, -1 }}, //  89
{{ 3, 0, 9, 1, 3, 4, 8, 7, 3, 2, 10, 3, 3, 5, 6, 11 }}, //  90
{{ 6, 9, 1, 2, 10, 7, 4, 3, 5, 6, 11, -1, -1, -1, -1, -1 }}, //  91
{{ 3, 8, 7, 4, 5, 3, 1, 5, 6, 10, -1, -1, -1, -1, -1, -1 }}, //  92
{{ 6, 5, 6, 10, 4, 0, 1, 3, 7, 4, 10, -1, -1, -1, -1, -1 }}, //  93
{{ 6, 0, 9, 5, 6, 10, 3, 3, 8, 7, 4, -1, -1, -1, -1, -1 }}, //  94
{{ 5, 6, 10, 7, 9, 5, 3, 4, 9, 7, -1, -1, -1, -1, -1, -1 }}, //  95
{{ 4, 11, 9, 4, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  96
{{ 4, 4, 6, 11, 9, 3, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1 }}, //  97
{{ 5, 11, 1, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  98
{{ 6, 8, 4, 6, 11, 1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  99
{{ 5, 1, 9, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  100
{{ 3, 3, 8, 0, 5, 1, 9, 4, 6, 2, -1, -1, -1, -1, -1, -1 }}, //  101
{{ 4, 0, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  102
{{ 5, 8, 4, 6, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  103
{{ 4, 11, 9, 4, 6, 3, 10, 3, 2, -1, -1, -1, -1, -1, -1, -1 }}, //  104
{{ 4, 0, 2, 10, 8, 4, 4, 6, 11, 9, -1, -1, -1, -1, -1, -1 }}, //  105
{{ 3, 3, 2, 10, 5, 0, 4, 6, 11, 1, -1, -1, -1, -1, -1, -1 }}, //  106
{{ 6, 6, 11, 1, 10, 8, 4, 3, 2, 10, 1, -1, -1, -1, -1, -1 }}, //  107
{{ 6, 9, 4, 6, 10, 3, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  108
{{ 6, 8, 0, 1, 4, 6, 10, 3, 9, 4, 1, -1, -1, -1, -1, -1 }}, //  109
{{ 5, 3, 0, 4, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  110
{{ 4, 6, 10, 8, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  111
{{ 5, 7, 6, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  112
{{ 6, 0, 3, 7, 6, 11, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  113
{{ 6, 11, 1, 0, 8, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  114
{{ 5, 11, 1, 3, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  115
{{ 6, 1, 9, 8, 7, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  116
{{ 6, 2, 1, 9, 3, 7, 6, 3, 0, 3, 9, -1, -1, -1, -1, -1 }}, //  117
{{ 5, 7, 6, 2, 0, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  118
{{ 4, 7, 6, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  119
{{ 3, 2, 10, 3, 5, 11, 9, 8, 7, 6, -1, -1, -1, -1, -1, -1 }}, //  120
{{ 6, 2, 10, 7, 11, 9, 0, 3, 6, 11, 7, -1, -1, -1, -1, -1 }}, //  121
{{ 6, 1, 0, 8, 7, 6, 11, 3, 2, 10, 3, -1, -1, -1, -1, -1 }}, //  122
{{ 5, 10, 7, 6, 1, 2, 3, 11, 1, 6, -1, -1, -1, -1, -1, -1 }}, //  123
{{ 6, 8, 7, 6, 3, 1, 9, 3, 10, 3, 6, -1, -1, -1, -1, -1 }}, //  124
{{ 3, 0, 1, 9, 3, 10, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  125
{{ 5, 7, 6, 10, 0, 8, 3, 3, 0, 10, -1, -1, -1, -1, -1, -1 }}, //  126
{{ 3, 7, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  127
{{ 3, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  128
{{ 3, 3, 8, 0, 3, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  129
{{ 3, 0, 9, 1, 3, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  130
{{ 4, 8, 9, 1, 3, 3, 10, 6, 7, -1, -1, -1, -1, -1, -1, -1 }}, //  131
{{ 3, 11, 2, 1, 3, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  132
{{ 3, 1, 11, 2, 3, 3, 8, 0, 3, 6, 7, 10, -1, -1, -1, -1 }}, //  133
{{ 4, 2, 0, 9, 11, 3, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1 }}, //  134
{{ 3, 6, 7, 10, 5, 2, 3, 8, 9, 11, -1, -1, -1, -1, -1, -1 }}, //  135
{{ 4, 7, 3, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  136
{{ 5, 7, 8, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  137
{{ 4, 2, 6, 7, 3, 3, 0, 9, 1, -1, -1, -1, -1, -1, -1, -1 }}, //  138
{{ 6, 1, 2, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  139
{{ 5, 11, 6, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  140
{{ 6, 11, 6, 7, 8, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  141
{{ 6, 0, 9, 11, 6, 7, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  142
{{ 5, 7, 8, 9, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  143
{{ 4, 6, 4, 8, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  144
{{ 5, 3, 10, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  145
{{ 4, 8, 10, 6, 4, 3, 9, 1, 0, -1, -1, -1, -1, -1, -1, -1 }}, //  146
{{ 6, 9, 1, 3, 10, 6, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  147
{{ 4, 6, 4, 8, 10, 3, 2, 1, 11, -1, -1, -1, -1, -1, -1, -1 }}, //  148
{{ 3, 1, 11, 2, 5, 3, 10, 6, 4, 0, -1, -1, -1, -1, -1, -1 }}, //  149
{{ 4, 4, 8, 10, 6, 4, 0, 9, 11, 2, -1, -1, -1, -1, -1, -1 }}, //  150
{{ 6, 11, 2, 3, 6, 4, 9, 3, 10, 6, 3, -1, -1, -1, -1, -1 }}, //  151
{{ 5, 8, 3, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  152
{{ 4, 0, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  153
{{ 3, 1, 0, 9, 5, 2, 6, 4, 8, 3, -1, -1, -1, -1, -1, -1 }}, //  154
{{ 5, 1, 2, 6, 4, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  155
{{ 6, 8, 3, 1, 11, 6, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  156
{{ 5, 11, 6, 4, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  157
{{ 6, 4, 8, 3, 9, 11, 6, 3, 0, 9, 3, -1, -1, -1, -1, -1 }}, //  158
{{ 4, 11, 6, 4, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  159
{{ 3, 4, 5, 9, 3, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  160
{{ 3, 0, 3, 8, 3, 4, 5, 9, 3, 10, 6, 7, -1, -1, -1, -1 }}, //  161
{{ 4, 5, 1, 0, 4, 3, 7, 10, 6, -1, -1, -1, -1, -1, -1, -1 }}, //  162
{{ 3, 10, 6, 7, 5, 8, 4, 5, 1, 3, -1, -1, -1, -1, -1, -1 }}, //  163
{{ 3, 9, 4, 5, 3, 11, 2, 1, 3, 7, 10, 6, -1, -1, -1, -1 }}, //  164
{{ 3, 6, 7, 10, 3, 1, 11, 2, 3, 0, 3, 8, 3, 4, 5, 9 }}, //  165
{{ 3, 7, 10, 6, 5, 5, 11, 2, 0, 4, -1, -1, -1, -1, -1, -1 }}, //  166
{{ 6, 3, 8, 4, 5, 11, 2, 3, 10, 6, 7, -1, -1, -1, -1, -1 }}, //  167
{{ 4, 7, 3, 2, 6, 3, 5, 9, 4, -1, -1, -1, -1, -1, -1, -1 }}, //  168
{{ 3, 9, 4, 5, 5, 0, 2, 6, 7, 8, -1, -1, -1, -1, -1, -1 }}, //  169
{{ 4, 3, 2, 6, 7, 4, 1, 0, 4, 5, -1, -1, -1, -1, -1, -1 }}, //  170
{{ 6, 6, 7, 8, 5, 1, 2, 3, 4, 5, 8, -1, -1, -1, -1, -1 }}, //  171
{{ 3, 9, 4, 5, 5, 11, 6, 7, 3, 1, -1, -1, -1, -1, -1, -1 }}, //  172
{{ 6, 1, 11, 6, 7, 8, 0, 3, 9, 4, 5, -1, -1, -1, -1, -1 }}, //  173
{{ 6, 4, 5, 11, 7, 3, 0, 3, 6, 7, 11, -1, -1, -1, -1, -1 }}, //  174
{{ 5, 7, 8, 4, 11, 6, 3, 5, 11, 4, -1, -1, -1, -1, -1, -1 }}, //  175
{{ 5, 6, 5, 9, 8, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  176
{{ 6, 3, 10, 6, 5, 9, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  177
{{ 6, 0, 8, 10, 6, 5, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  178
{{ 5, 6, 5, 1, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  179
{{ 3, 1, 11, 2, 5, 9, 8, 10, 6, 5, -1, -1, -1, -1, -1, -1 }}, //  180
{{ 6, 0, 3, 10, 6, 5, 9, 3, 1, 11, 2, -1, -1, -1, -1, -1 }}, //  181
{{ 6, 10, 6, 5, 2, 0, 8, 3, 11, 2, 5, -1, -1, -1, -1, -1 }}, //  182
{{ 5, 6, 5, 11, 3, 10, 3, 2, 3, 11, -1, -1, -1, -1, -1, -1 }}, //  183
{{ 6, 5, 9, 8, 3, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  184
{{ 5, 9, 0, 2, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  185
{{ 6, 1, 0, 8, 2, 6, 5, 3, 3, 2, 8, -1, -1, -1, -1, -1 }}, //  186
{{ 4, 1, 2, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  187
{{ 6, 1, 11, 6, 9, 8, 3, 3, 5, 9, 6, -1, -1, -1, -1, -1 }}, //  188
{{ 5, 11, 6, 5, 0, 1, 3, 9, 0, 5, -1, -1, -1, -1, -1, -1 }}, //  189
{{ 3, 0, 8, 3, 3, 5, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  190
{{ 3, 11, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  191
{{ 4, 10, 11, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  192
{{ 4, 10, 11, 5, 7, 3, 8, 0, 3, -1, -1, -1, -1, -1, -1, -1 }}, //  193
{{ 4, 5, 7, 10, 11, 3, 1, 0, 9, -1, -1, -1, -1, -1, -1, -1 }}, //  194
{{ 4, 11, 5, 7, 10, 4, 9, 1, 3, 8, -1, -1, -1, -1, -1, -1 }}, //  195
{{ 5, 10, 2, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  196
{{ 3, 0, 3, 8, 5, 1, 5, 7, 10, 2, -1, -1, -1, -1, -1, -1 }}, //  197
{{ 6, 9, 5, 7, 10, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  198
{{ 6, 7, 10, 2, 8, 9, 5, 3, 3, 8, 2, -1, -1, -1, -1, -1 }}, //  199
{{ 5, 2, 11, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  200
{{ 6, 8, 0, 2, 11, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  201
{{ 3, 9, 1, 0, 5, 5, 7, 3, 2, 11, -1, -1, -1, -1, -1, -1 }}, //  202
{{ 6, 9, 1, 2, 5, 7, 8, 3, 11, 5, 2, -1, -1, -1, -1, -1 }}, //  203
{{ 4, 1, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  204
{{ 5, 0, 1, 5, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  205
{{ 5, 9, 5, 7, 3, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  206
{{ 4, 9, 5, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  207
{{ 5, 5, 4, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  208
{{ 6, 5, 4, 0, 3, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  209
{{ 3, 0, 9, 1, 5, 8, 10, 11, 5, 4, -1, -1, -1, -1, -1, -1 }}, //  210
{{ 6, 11, 5, 4, 1, 3, 10, 3, 9, 1, 4, -1, -1, -1, -1, -1 }}, //  211
{{ 6, 2, 1, 5, 4, 8, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  212
{{ 6, 0, 3, 10, 1, 5, 4, 3, 2, 1, 10, -1, -1, -1, -1, -1 }}, //  213
{{ 6, 0, 9, 5, 8, 10, 2, 3, 4, 8, 5, -1, -1, -1, -1, -1 }}, //  214
{{ 3, 9, 5, 4, 3, 2, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  215
{{ 6, 2, 11, 5, 4, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  216
{{ 5, 5, 4, 0, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  217
{{ 6, 3, 2, 11, 5, 4, 8, 3, 0, 9, 1, -1, -1, -1, -1, -1 }}, //  218
{{ 5, 5, 4, 9, 2, 11, 3, 1, 2, 9, -1, -1, -1, -1, -1, -1 }}, //  219
{{ 5, 8, 3, 1, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  220
{{ 4, 0, 1, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  221
{{ 5, 8, 3, 0, 5, 4, 3, 9, 5, 0, -1, -1, -1, -1, -1, -1 }}, //  222
{{ 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  223
{{ 5, 4, 7, 10, 11, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  224
{{ 3, 0, 3, 8, 5, 4, 7, 10, 11, 9, -1, -1, -1, -1, -1, -1 }}, //  225
{{ 6, 1, 0, 4, 7, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  226
{{ 6, 3, 8, 4, 10, 11, 1, 3, 7, 10, 4, -1, -1, -1, -1, -1 }}, //  227
{{ 6, 4, 7, 10, 2, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  228
{{ 6, 9, 4, 7, 10, 2, 1, 3, 0, 3, 8, -1, -1, -1, -1, -1 }}, //  229
{{ 5, 10, 2, 0, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  230
{{ 5, 10, 2, 3, 4, 7, 3, 8, 4, 3, -1, -1, -1, -1, -1, -1 }}, //  231
{{ 6, 2, 11, 9, 4, 7, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  232
{{ 6, 9, 4, 7, 0, 2, 11, 3, 8, 0, 7, -1, -1, -1, -1, -1 }}, //  233
{{ 6, 3, 2, 11, 0, 4, 7, 3, 1, 0, 11, -1, -1, -1, -1, -1 }}, //  234
{{ 3, 1, 2, 11, 3, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  235
{{ 5, 4, 7, 3, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  236
{{ 5, 4, 7, 8, 1, 9, 3, 0, 1, 8, -1, -1, -1, -1, -1, -1 }}, //  237
{{ 4, 4, 7, 3, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  238
{{ 3, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  239
{{ 4, 9, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  240
{{ 5, 3, 10, 11, 9, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  241
{{ 5, 0, 8, 10, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  242
{{ 4, 3, 10, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  243
{{ 5, 1, 9, 8, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  244
{{ 5, 3, 10, 2, 9, 0, 3, 1, 9, 2, -1, -1, -1, -1, -1, -1 }}, //  245
{{ 4, 0, 8, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  246
{{ 3, 3, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  247
{{ 5, 2, 11, 9, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  248
{{ 4, 9, 0, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  249
{{ 5, 2, 11, 1, 8, 3, 3, 0, 8, 1, -1, -1, -1, -1, -1, -1 }}, //  250
{{ 3, 1, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  251
{{ 4, 1, 9, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  252
{{ 3, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  253
{{ 3, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}, //  254
{{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }}}; //
255


// New version using polys instead of triangles.
void vtkHexahedron::Contour(float value, vtkScalars *cellScalars,
                            vtkPointLocator *locator,
                            vtkCellArray *vtkNotUsed(verts),
                            vtkCellArray *vtkNotUsed(lines),
                            vtkCellArray *polys,
                            vtkPointData *inPd, vtkPointData *outPd,
                            vtkCellData *inCd, int cellId, vtkCellData *outCd)
{
  static int CASE_MASK[8] = {1,2,4,8,16,32,64,128};
  POLY_CASES *polyCase;
  EDGE_LIST  *edge;
  int i, j, index, *vert;
  int e1, e2, newCellId;
  int pts[6]; //   Max hexagon
  float t, x1[3], x2[3], x[3], deltaScalar;

  //   Build the case table
  for ( i=0, index = 0; i < 8; i++)
    {
    if (cellScalars->GetScalar(i) >= value)
      {
      index |= CASE_MASK[i];
      }
    }

  polyCase = polyCases + index;
  edge = polyCase->edges;

  while(edge[0] > -1){
    int nb = *edge++;
    int p=0;
    for (i=0; i<nb; i++) //   insert poly
      {
      vert = edges[edge[i]];
      //   calculate a preferred interpolation direction
      deltaScalar = (cellScalars->GetScalar(vert[1]) -
                     cellScalars->GetScalar(vert[0]));
      if (deltaScalar > 0)
        {
        e1 = vert[0]; e2 = vert[1];
        }
      else
        {
        e1 = vert[1]; e2 = vert[0];
        deltaScalar = -deltaScalar;
        }

      //   linear interpolation
      if (deltaScalar == 0.0)
        {
        t = 0.0;
        }
      else
        {
        t = (value - cellScalars->GetScalar(e1)) / deltaScalar;
        }

      this->Points->GetPoint(e1, x1);
      this->Points->GetPoint(e2, x2);

      for (j=0; j<3; j++)
        {
        x[j] = x1[j] + t * (x2[j] - x1[j]);
        }
      if ( locator->InsertUniquePoint(x, pts[p]) )
        {
        if ( outPd )
          {
          int p1 = this->PointIds->GetId(e1);
          int p2 = this->PointIds->GetId(e2);
          outPd->InterpolateEdge(inPd,pts[p],p1,p2,t);
          }
        }
      //   check for degenerate poly
      if(p==0)
        p++;
      else if(pts[p] !=  pts[p-1])
        p++;
      }

    //   check for degenerate poly
    if(pts[0] ==  pts[p-1])
      p--;
    if(p>2){
      newCellId = polys->InsertNextCell(p,pts);
      outCd->CopyData(inCd,cellId,newCellId);
    }

    edge += nb;
  }
}

If you are interested, I've done the same for wedge, pyramide and tetra.

    Philippe Guerville
    philippe.guerville at cea.fr










More information about the vtkusers mailing list