vtkVolumeFromVolume.h 9.09 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
5
* LLNL-CODE-400142
hrchilds's avatar
hrchilds committed
6 7
* All rights reserved.
*
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9 10 11 12 13 14 15 16 17 18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
19 20 21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22 23 24 25 26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
27 28 29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30 31 32 33 34 35 36 37 38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

hrchilds's avatar
hrchilds committed
39 40 41 42 43 44 45 46
// ************************************************************************* //
//                            vtkVolumeFromVolume.h                          //
// ************************************************************************* //

#ifndef VTK_VOLUME_FROM_VOLUME_H
#define VTK_VOLUME_FROM_VOLUME_H

#include <vtkDataSetFromVolume.h>
hrchilds's avatar
hrchilds committed
47
#include <vtkCellType.h>
hrchilds's avatar
hrchilds committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

#include <vector>


class vtkCellData;
class vtkPointData;
class vtkPolyData;
class vtkUnstructuredGrid;


// ****************************************************************************
//  Class: vtkVolumeFromVolume
//
//  Purpose:
//      This class is a data object.  It is much like vtkSurfaceFromVolume,
//      except instead of generating new surfaces (e.g. from contours or
//      slicing), it generates new volumes (e.g. from clipping or isovolumes).
//      It also extends it to allow points based on the unweighted
//      interpolation of up-to-eight other points, and it uses negative
//      indices for these "centroid" points.
//
//  Programmer: Jeremy Meredith
//  Creation:   August  7, 2003
//
//  Modifications:
hrchilds's avatar
hrchilds committed
73 74 75
//    Jeremy Meredith, Mon Feb 16 18:01:29 PST 2004
//    Added 2D shape support.  This might seem weird, but there may be 
//    some 2D shapes in a volumetric setting.
hrchilds's avatar
hrchilds committed
76
//
hrchilds's avatar
hrchilds committed
77 78 79 80
//    Hank Childs, Thu Oct 21 07:23:55 PDT 2004
//    Added new data members shapes and nshapes.  Also added 
//    GetNumberOfPointsPerShape method to ShapeList.
//
hrchilds's avatar
hrchilds committed
81 82 83
//    Jeremy Meredith, Tue Aug 29 14:33:30 EDT 2006
//    Added support for lines and vertices.
//
hrchilds's avatar
hrchilds committed
84 85 86 87 88 89 90 91 92 93
// ****************************************************************************

class vtkVolumeFromVolume : public vtkDataSetFromVolume
{

class ShapeList
{
  public:
                   ShapeList(int size);
    virtual       ~ShapeList();
hrchilds's avatar
hrchilds committed
94 95
    virtual int    GetVTKType(void) const = 0;
    int            GetShapeSize(void) const { return shapeSize; };
hrchilds's avatar
hrchilds committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
    int            GetTotalNumberOfShapes(void) const;
    int            GetNumberOfLists(void) const;
    int            GetList(int, const int *&) const;
  protected:
    int          **list;
    int            currentList;
    int            currentShape;
    int            listSize;
    int            shapesPerList;
    int            shapeSize;
};

class HexList : public ShapeList
{
  public:
                   HexList();
    virtual       ~HexList();
hrchilds's avatar
hrchilds committed
113
    virtual int    GetVTKType(void) const { return VTK_HEXAHEDRON; };
hrchilds's avatar
hrchilds committed
114 115 116 117 118 119 120 121
    void           AddHex(int, int, int, int, int, int, int, int, int);
};

class WedgeList : public ShapeList
{
  public:
                   WedgeList();
    virtual       ~WedgeList();
hrchilds's avatar
hrchilds committed
122
    virtual int    GetVTKType(void) const { return VTK_WEDGE; };
hrchilds's avatar
hrchilds committed
123 124 125 126 127 128 129 130
    void           AddWedge(int, int, int, int, int, int, int);
};

class PyramidList : public ShapeList
{
  public:
                   PyramidList();
    virtual       ~PyramidList();
hrchilds's avatar
hrchilds committed
131
    virtual int    GetVTKType(void) const { return VTK_PYRAMID; };
hrchilds's avatar
hrchilds committed
132 133 134 135 136 137 138 139
    void           AddPyramid(int, int, int, int, int, int);
};

class TetList : public ShapeList
{
  public:
                   TetList();
    virtual       ~TetList();
hrchilds's avatar
hrchilds committed
140
    virtual int    GetVTKType(void) const { return VTK_TETRA; };
hrchilds's avatar
hrchilds committed
141 142 143
    void           AddTet(int, int, int, int, int);
};

hrchilds's avatar
hrchilds committed
144 145 146 147 148
class QuadList : public ShapeList
{
  public:
                   QuadList();
    virtual       ~QuadList();
hrchilds's avatar
hrchilds committed
149
    virtual int    GetVTKType(void) const { return VTK_QUAD; };
hrchilds's avatar
hrchilds committed
150 151 152 153 154 155 156 157
    void           AddQuad(int, int, int, int, int);
};

class TriList : public ShapeList
{
  public:
                   TriList();
    virtual       ~TriList();
hrchilds's avatar
hrchilds committed
158
    virtual int    GetVTKType(void) const { return VTK_TRIANGLE; };
hrchilds's avatar
hrchilds committed
159 160 161
    void           AddTri(int, int, int, int);
};

hrchilds's avatar
hrchilds committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
class LineList : public ShapeList
{
  public:
                   LineList();
    virtual       ~LineList();
    virtual int    GetVTKType(void) const { return VTK_LINE; };
    void           AddLine(int, int, int);
};

class VertexList : public ShapeList
{
  public:
                   VertexList();
    virtual       ~VertexList();
    virtual int    GetVTKType(void) const { return VTK_VERTEX; };
    void           AddVertex(int, int);
};

hrchilds's avatar
hrchilds committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
struct CentroidPointEntry
{
    int     nPts;
    int     ptIds[8];
};


class CentroidPointList
{
  public:
                   CentroidPointList();
    virtual       ~CentroidPointList();
 
    int            AddPoint(int, int*);
 
    int            GetTotalNumberOfPoints(void) const;
    int            GetNumberOfLists(void) const;
    int            GetList(int, const CentroidPointEntry *&) const;
 
  protected:
    CentroidPointEntry   **list;
    int                    currentList;
    int                    currentPoint;
    int                    listSize;
    int                    pointsPerList;
};

hrchilds's avatar
hrchilds committed
207 208 209 210 211 212 213 214 215
typedef struct
{
   bool   hasPtsList;
   float *pts_ptr;
   int   *dims;
   float *X;
   float *Y;
   float *Z;
} CommonPointsStructure;
hrchilds's avatar
hrchilds committed
216 217 218


  public:
hrchilds's avatar
hrchilds committed
219
                      vtkVolumeFromVolume(int nPts, int ptSizeGuess);
hrchilds's avatar
hrchilds committed
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
    virtual          ~vtkVolumeFromVolume() { ; };

    void              ConstructDataSet(vtkPointData *, vtkCellData *,
                                       vtkUnstructuredGrid *, float *);
    void              ConstructDataSet(vtkPointData *, vtkCellData *,
                                       vtkUnstructuredGrid *, int *, float *,
                                       float *,float *);

    int            AddCentroidPoint(int n, int *p)
                        { return -1 - centroid_list.AddPoint(n, p); }

    void           AddHex(int z, int v0, int v1, int v2, int v3,
                          int v4, int v5, int v6, int v7)
                        { hexes.AddHex(z, v0, v1, v2, v3, v4, v5, v6, v7); }
        
    void           AddWedge(int z,int v0,int v1,int v2,int v3,int v4,int v5)
                        { wedges.AddWedge(z, v0, v1, v2, v3, v4, v5); }
    void           AddPyramid(int z, int v0, int v1, int v2, int v3, int v4)
                        { pyramids.AddPyramid(z, v0, v1, v2, v3, v4); }
    void           AddTet(int z, int v0, int v1, int v2, int v3)
                        { tets.AddTet(z, v0, v1, v2, v3); }
hrchilds's avatar
hrchilds committed
241 242 243 244
    void           AddQuad(int z, int v0, int v1, int v2, int v3)
                        { quads.AddQuad(z, v0, v1, v2, v3); }
    void           AddTri(int z, int v0, int v1, int v2)
                        { tris.AddTri(z, v0, v1, v2); }
hrchilds's avatar
hrchilds committed
245 246 247 248
    void           AddLine(int z, int v0, int v1)
                        { lines.AddLine(z, v0, v1); }
    void           AddVertex(int z, int v0)
                        { vertices.AddVertex(z, v0); }
hrchilds's avatar
hrchilds committed
249 250 251 252 253 254 255

  protected:
    CentroidPointList  centroid_list;
    HexList            hexes;
    WedgeList          wedges;
    PyramidList        pyramids;
    TetList            tets;
hrchilds's avatar
hrchilds committed
256 257
    QuadList           quads;
    TriList            tris;
hrchilds's avatar
hrchilds committed
258 259
    LineList           lines;
    VertexList         vertices;
hrchilds's avatar
hrchilds committed
260

hrchilds's avatar
hrchilds committed
261
    ShapeList         *shapes[8];
hrchilds's avatar
hrchilds committed
262 263 264 265 266
    const int          nshapes;

    void               ConstructDataSet(vtkPointData *, vtkCellData *,
                                        vtkUnstructuredGrid *, 
                                        CommonPointsStructure &);
hrchilds's avatar
hrchilds committed
267 268 269 270 271 272
};


#endif