vtkVolumeFromVolume.h 10.2 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2012, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
5
* LLNL-CODE-442911
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
// ************************************************************************* //
//                            vtkVolumeFromVolume.h                          //
// ************************************************************************* //

#ifndef VTK_VOLUME_FROM_VOLUME_H
#define VTK_VOLUME_FROM_VOLUME_H

bonnell's avatar
bonnell committed
46
#include <visit_vtk_exports.h>
hrchilds's avatar
hrchilds committed
47
#include <vtkDataSetFromVolume.h>
hrchilds's avatar
hrchilds committed
48
#include <vtkCellType.h>
hrchilds's avatar
hrchilds committed
49 50 51 52 53

#include <vector>


class vtkCellData;
54
class vtkDataArray;
hrchilds's avatar
hrchilds committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
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
75 76 77
//    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
78
//
hrchilds's avatar
hrchilds committed
79 80 81 82
//    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
83 84 85
//    Jeremy Meredith, Tue Aug 29 14:33:30 EDT 2006
//    Added support for lines and vertices.
//
86 87 88 89
//    Jeremy Meredith, Fri Feb 26 14:00:07 EST 2010
//    Made internal class definitions protected instead of private so
//    we could usefully subclass this.
//
90 91 92
//    Jeremy Meredith, Thu Oct 28 10:26:45 EDT 2010
//    Added external visibility macro to nested classes.
//
93 94 95
//    Brad Whitlock, Thu Mar 22 14:01:17 PDT 2012
//    Adapted the code to use vtkIdType. Added double coordinate support.
//
96 97 98 99
//    Eric Brugger, Wed Jul 25 11:04:21 PDT 2012
//    Added a clear method to CentroidPointList and added a version of
//    ShapeList::GetList where none of its arguments had const qualifiers.
//
hrchilds's avatar
hrchilds committed
100 101
// ****************************************************************************

bonnell's avatar
bonnell committed
102
class VISIT_VTK_API vtkVolumeFromVolume : public vtkDataSetFromVolume
hrchilds's avatar
hrchilds committed
103
{
104 105 106 107 108 109 110 111 112 113 114 115 116
public:
struct CentroidPointEntry
{
    vtkIdType     nPts;
    vtkIdType     ptIds[8];
};

class VISIT_VTK_API CentroidPointList
{
  public:
                   CentroidPointList();
    virtual       ~CentroidPointList();
 
117 118
    void           Clear();

119 120 121 122 123 124 125 126 127 128 129 130 131 132
    vtkIdType            AddPoint(vtkIdType, const vtkIdType*);
 
    vtkIdType            GetTotalNumberOfPoints(void) const;
    vtkIdType            GetNumberOfLists(void) const;
    vtkIdType            GetList(vtkIdType, const CentroidPointEntry *&) const;
 
  protected:
    CentroidPointEntry   **list;
    vtkIdType              currentList;
    vtkIdType              currentPoint;
    vtkIdType              listSize;
    vtkIdType              pointsPerList;
};

hrchilds's avatar
hrchilds committed
133 134 135
class ShapeList
{
  public:
136
                   ShapeList(vtkIdType size);
hrchilds's avatar
hrchilds committed
137
    virtual       ~ShapeList();
hrchilds's avatar
hrchilds committed
138 139
    virtual int    GetVTKType(void) const = 0;
    int            GetShapeSize(void) const { return shapeSize; };
140 141 142
    vtkIdType      GetTotalNumberOfShapes(void) const;
    vtkIdType      GetNumberOfLists(void) const;
    vtkIdType      GetList(vtkIdType, const vtkIdType *&) const;
143
    vtkIdType      GetList(vtkIdType, vtkIdType *&) const;
hrchilds's avatar
hrchilds committed
144
  protected:
145 146 147 148 149
    vtkIdType    **list;
    vtkIdType      currentList;
    vtkIdType      currentShape;
    vtkIdType      listSize;
    vtkIdType      shapesPerList;
hrchilds's avatar
hrchilds committed
150 151 152
    int            shapeSize;
};

153
class VISIT_VTK_API  HexList : public ShapeList
hrchilds's avatar
hrchilds committed
154 155 156 157
{
  public:
                   HexList();
    virtual       ~HexList();
hrchilds's avatar
hrchilds committed
158
    virtual int    GetVTKType(void) const { return VTK_HEXAHEDRON; };
159
    void           AddHex(vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
160 161
};

162
class VISIT_VTK_API WedgeList : public ShapeList
hrchilds's avatar
hrchilds committed
163 164 165 166
{
  public:
                   WedgeList();
    virtual       ~WedgeList();
hrchilds's avatar
hrchilds committed
167
    virtual int    GetVTKType(void) const { return VTK_WEDGE; };
168
    void           AddWedge(vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
169 170
};

171
class VISIT_VTK_API PyramidList : public ShapeList
hrchilds's avatar
hrchilds committed
172 173 174 175
{
  public:
                   PyramidList();
    virtual       ~PyramidList();
hrchilds's avatar
hrchilds committed
176
    virtual int    GetVTKType(void) const { return VTK_PYRAMID; };
177
    void           AddPyramid(vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
178 179
};

180
class VISIT_VTK_API TetList : public ShapeList
hrchilds's avatar
hrchilds committed
181 182 183 184
{
  public:
                   TetList();
    virtual       ~TetList();
hrchilds's avatar
hrchilds committed
185
    virtual int    GetVTKType(void) const { return VTK_TETRA; };
186
    void           AddTet(vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
187 188
};

189
class VISIT_VTK_API QuadList : public ShapeList
hrchilds's avatar
hrchilds committed
190 191 192 193
{
  public:
                   QuadList();
    virtual       ~QuadList();
hrchilds's avatar
hrchilds committed
194
    virtual int    GetVTKType(void) const { return VTK_QUAD; };
195
    void           AddQuad(vtkIdType, vtkIdType, vtkIdType, vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
196 197
};

198
class VISIT_VTK_API TriList : public ShapeList
hrchilds's avatar
hrchilds committed
199 200 201 202
{
  public:
                   TriList();
    virtual       ~TriList();
hrchilds's avatar
hrchilds committed
203
    virtual int    GetVTKType(void) const { return VTK_TRIANGLE; };
204
    void           AddTri(vtkIdType, vtkIdType, vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
205 206
};

207
class VISIT_VTK_API LineList : public ShapeList
hrchilds's avatar
hrchilds committed
208 209 210 211 212
{
  public:
                   LineList();
    virtual       ~LineList();
    virtual int    GetVTKType(void) const { return VTK_LINE; };
213
    void           AddLine(vtkIdType, vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
214 215
};

216
class VISIT_VTK_API VertexList : public ShapeList
hrchilds's avatar
hrchilds committed
217 218 219 220 221
{
  public:
                   VertexList();
    virtual       ~VertexList();
    virtual int    GetVTKType(void) const { return VTK_VERTEX; };
222
    void           AddVertex(vtkIdType, vtkIdType);
hrchilds's avatar
hrchilds committed
223 224 225
};

  public:
226
                      vtkVolumeFromVolume(vtkIdType nPts, vtkIdType ptSizeGuess);
hrchilds's avatar
hrchilds committed
227 228 229
    virtual          ~vtkVolumeFromVolume() { ; };

    void              ConstructDataSet(vtkPointData *, vtkCellData *,
230
                                       vtkUnstructuredGrid *, vtkPoints *);
hrchilds's avatar
hrchilds committed
231
    void              ConstructDataSet(vtkPointData *, vtkCellData *,
232 233
                                       vtkUnstructuredGrid *, const int *, vtkDataArray *,
                                       vtkDataArray *,vtkDataArray *);
hrchilds's avatar
hrchilds committed
234

235
    int            AddCentroidPoint(vtkIdType n, const vtkIdType *p)
hrchilds's avatar
hrchilds committed
236 237
                        { return -1 - centroid_list.AddPoint(n, p); }

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

  protected:
    CentroidPointList  centroid_list;
    HexList            hexes;
    WedgeList          wedges;
    PyramidList        pyramids;
    TetList            tets;
hrchilds's avatar
hrchilds committed
263 264
    QuadList           quads;
    TriList            tris;
hrchilds's avatar
hrchilds committed
265 266
    LineList           lines;
    VertexList         vertices;
hrchilds's avatar
hrchilds committed
267

hrchilds's avatar
hrchilds committed
268
    ShapeList         *shapes[8];
hrchilds's avatar
hrchilds committed
269
    const int          nshapes;
hrchilds's avatar
hrchilds committed
270 271 272 273 274 275
};


#endif