VTK
vtkStructuredVisibilityConstraint.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStructuredVisibilityConstraint.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
28 #ifndef __vtkStructuredVisibilityConstraint_h
29 #define __vtkStructuredVisibilityConstraint_h
30 
31 #include "vtkObject.h"
32 
33 #include "vtkUnsignedCharArray.h" // Needed for inline methods.
34 
36 {
37 public:
39 
41  void PrintSelf(ostream& os, vtkIndent indent);
42 
44  unsigned char IsVisible(vtkIdType id);
45 
49  void Blank(vtkIdType id);
50 
52  void UnBlank(vtkIdType id);
53 
55 
56  vtkGetVectorMacro(Dimensions,int,3);
58 
61  void Initialize(int dims[3]);
62 
64 
65  void SetVisibilityById(vtkUnsignedCharArray* vis);
66  vtkGetObjectMacro(VisibilityById, vtkUnsignedCharArray);
68 
71  void ShallowCopy(vtkStructuredVisibilityConstraint* src);
72 
74  void DeepCopy(vtkStructuredVisibilityConstraint* src);
75 
77 
79  unsigned char IsConstrained()
80  {
81  return this->VisibilityById ? 1 : 0;
82  }
84 
85 protected:
88 
90  int Dimensions[3];
92  unsigned char Initialized;
93 
94 private:
96  void operator=(const vtkStructuredVisibilityConstraint&); // Not implemented.
97 };
98 
99 //----------------------------------------------------------------------------
100 // These methods are inline for efficiency.
101 
102 //----------------------------------------------------------------------------
104  vtkIdType id)
105 {
107  return vis ? vis->GetValue(id) : 1;
108 }
109 
110 //----------------------------------------------------------------------------
112 {
114  if (!vis)
115  {
117  vis = this->VisibilityById;
119  for (int i=0; i<this->NumberOfIds; ++i)
120  {
121  this->VisibilityById->SetValue(i, 1);
122  }
123  }
124  vis->SetValue(id, 0);
125 }
126 
127 //----------------------------------------------------------------------------
129 {
131  if (!vis)
132  {
133  return;
134  }
135  vis->SetValue(id, 1);
136 }
137 
138 //----------------------------------------------------------------------------
140 {
141  if (this->Initialized)
142  {
143  return;
144  }
145  for (int i=0; i<3; i++)
146  {
147  this->Dimensions[i] = dims[i];
148  }
149  this->NumberOfIds = static_cast<vtkIdType>(dims[0])*
150  static_cast<vtkIdType>(dims[1])*
151  static_cast<vtkIdType>(dims[2]);
152  this->Initialized = 1;
153 }
154 
155 #endif
156 
abstract base class for most VTK objects
Definition: vtkObject.h:60
virtual void SetNumberOfTuples(vtkIdType number)=0
int vtkIdType
Definition: vtkType.h:255
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
unsigned char GetValue(vtkIdType id)
#define VTK_COMMON_EXPORT
dynamic, self-adjusting array of unsigned char
static vtkUnsignedCharArray * New()
static vtkObject * New()
helper object to manage the visibility of points and cells
void SetValue(vtkIdType id, unsigned char value)