vtkAMRCutPlane.h 5.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*=========================================================================

 Program:   Visualization Toolkit
 Module:    vtkAMRCutPlane.h

 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
 All rights reserved.
 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notice for more information.

 =========================================================================*/
// .NAME vtkAMRCutPlane.h -- Cuts an AMR dataset
//
// .SECTION Description
18
19
20
//  A concrete instance of vtkMultiBlockDataSet that provides functionality for
// cutting an AMR dataset (an instance of vtkOverlappingAMR) with user supplied
// implicit plane function defined by a normal and center.
21
22
23
24
25
26

#ifndef VTKAMRCUTPLANE_H_
#define VTKAMRCUTPLANE_H_

#include "vtkMultiBlockDataSetAlgorithm.h"

27
#include <vector> // For STL vector
28
#include <map> // For STL map
29
30

class vtkMultiBlockDataSet;
31
class vtkOverlappingAMR;
32
33
34
35
36
class vtkMultiProcessController;
class vtkInformation;
class vtkInformationVector;
class vtkIndent;
class vtkPlane;
37
38
39
40
class vtkUniformGrid;
class vtkCell;
class vtkPoints;
class vtkCellArray;
41
42
class vtkPointData;
class vtkCellData;
43

44
45
46
47
48
class VTK_AMR_EXPORT vtkAMRCutPlane : public vtkMultiBlockDataSetAlgorithm
{
  public:
    static vtkAMRCutPlane *New();
    vtkTypeMacro(vtkAMRCutPlane, vtkMultiBlockDataSetAlgorithm);
49
    void PrintSelf(ostream &oss, vtkIndent indent );
50
51
52
53
54
55
56
57
58
59
60
61

    // Description:
    // Sets the center
    vtkSetVector3Macro(Center, double);

    // Description:
    // Sets the normal
    vtkSetVector3Macro(Normal, double);

    // Description:
    // Sets the level of resolution
    vtkSetMacro(LevelOfResolution, int);
62
63
64
65
66
67
68
69
70
    vtkGetMacro(LevelOfResolution, int);

    // Description:
    //
    vtkSetMacro(UseNativeCutter, int);
    vtkGetMacro(UseNativeCutter, int);
    vtkBooleanMacro(UseNativeCutter,int);

    // Description:
71
    // Set/Get a multiprocess controller for parallel processing.
72
    // By default this parameter is set to NULL by the constructor.
73
74
    vtkSetMacro(Controller, vtkMultiProcessController*);
    vtkGetMacro(Controller, vtkMultiProcessController*);
75
76
77

    // Standard pipeline routines

78
79
80
81
82
83
    virtual int RequestData(
         vtkInformation*,vtkInformationVector**,vtkInformationVector*);
    virtual int FillInputPortInformation(int port, vtkInformation *info);
    virtual int FillOutputPortInformation(int port, vtkInformation *info);


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
    // Description:
    // Gets the metadata from upstream module and determines which blocks
    // should be loaded by this instance.
    virtual int RequestInformation(
        vtkInformation *rqst,
        vtkInformationVector **inputVector,
        vtkInformationVector *outputVector );

    // Description:
    // Performs upstream requests to the reader
    virtual int RequestUpdateExtent(
        vtkInformation*, vtkInformationVector**, vtkInformationVector* );

  protected:
    vtkAMRCutPlane();
    virtual ~vtkAMRCutPlane();

101
102
103
    // Description:
    // Returns the cut-plane defined by a vtkCutPlane instance based on the
    // user-supplied center and normal.
104
    vtkPlane* GetCutPlane( vtkOverlappingAMR *metadata );
105

106
107
108
    // Description:
    // Extracts cell
    void ExtractCellFromGrid(
109
110
111
        vtkUniformGrid *grid, vtkCell* cell,
        std::map<vtkIdType,vtkIdType>& gridPntMapping,
        vtkPoints *nodes,
112
        vtkCellArray *cells );
113

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    // Description:
    // Given the grid and a subset ID pair, grid IDs mapping to the extracted
    // grid IDs, extract the point data.
    void ExtractPointDataFromGrid(
        vtkUniformGrid *grid,
        std::map<vtkIdType,vtkIdType>& gridPntMapping,
        vtkIdType NumNodes,
        vtkPointData *PD );

    // Description:
    // Given the grid and the list of cells that are extracted, extract the
    // corresponding cell data.
    void ExtractCellDataFromGrid(
        vtkUniformGrid *grid,
        std::vector<vtkIdType>& cellIdxList,
        vtkCellData *CD);

131
132
133
134
135
    // Description:
    // Given a cut-plane, p, and the metadata, m, this method computes which
    // blocks need to be loaded. The corresponding block IDs are stored in
    // the internal STL vector, blocksToLoad, which is then propagated upstream
    // in the RequestUpdateExtent.
136
    void ComputeAMRBlocksToLoad( vtkPlane* p, vtkOverlappingAMR* m);
137
138
139
140
141
142
143

    // Descriription:
    // Initializes the cut-plane center given the min/max bounds.
    void InitializeCenter( double min[3], double max[3] );

    // Description:
    // Determines if a plane intersects with an AMR box
144
    bool PlaneIntersectsAMRBox( vtkPlane* pl, double bounds[6] );
145
146
    bool PlaneIntersectsAMRBox( double plane[4], double bounds[6] );

147
148
    // Description:
    // Determines if a plane intersects with a grid cell
149
    bool PlaneIntersectsCell( vtkPlane *pl, vtkCell *cell );
150

151
152
    // Description:
    // A utility function that checks if the input AMR data is 2-D.
153
    bool IsAMRData2D( vtkOverlappingAMR *input );
154

155
156
    // Description:
    // Applies cutting to an AMR block
157
    void CutAMRBlock(
158
        vtkPlane *cutPlane,
159
160
        unsigned int blockIdx,
        vtkUniformGrid *grid, vtkMultiBlockDataSet *dataSet );
161

162
163
164
    int    LevelOfResolution;
    double Center[3];
    double Normal[3];
165
166
167
    bool initialRequest;
    bool UseNativeCutter;
    vtkMultiProcessController *Controller;
168

169
// BTX
170
    std::vector<int> blocksToLoad;
171
// ETX
172
173
174
175
176
177
178

  private:
    vtkAMRCutPlane(const vtkAMRCutPlane& ); // Not implemented
    void operator=(const vtkAMRCutPlane& ); // Not implemented
};

#endif /* VTKAMRCUTPLANE_H_ */