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 "vtkCommonDataModelModule.h" // For export macro
32 #include "vtkObject.h"
33 
34 #include "vtkUnsignedCharArray.h" // Needed for inline methods.
35 
37 {
38 public:
40 
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
45  unsigned char IsVisible(vtkIdType id);
46 
50  void Blank(vtkIdType id);
51 
53  void UnBlank(vtkIdType id);
54 
56 
57  vtkGetVectorMacro(Dimensions,int,3);
59 
62  void Initialize(int dims[3]);
63 
66  void Allocate();
67 
69 
70  void SetVisibilityById(vtkUnsignedCharArray* vis);
71  vtkGetObjectMacro(VisibilityById, vtkUnsignedCharArray);
73 
76  void ShallowCopy(vtkStructuredVisibilityConstraint* src);
77 
80 
82 
84  unsigned char IsConstrained()
85  {
86  return this->VisibilityById ? 1 : 0;
87  }
89 
90 protected:
93 
95  int Dimensions[3];
97  unsigned char Initialized;
98 
99 private:
101  void operator=(const vtkStructuredVisibilityConstraint&); // Not implemented.
102 };
103 
104 //----------------------------------------------------------------------------
105 // These methods are inline for efficiency.
106 
107 //----------------------------------------------------------------------------
109 {
110  if( !this->VisibilityById )
111  {
114  for( int i=0; i < this->NumberOfIds; ++i )
115  {
116  this->VisibilityById->SetValue( i, 1 );
117  }
118  }
119 }
120 //----------------------------------------------------------------------------
122  vtkIdType id)
123 {
125  return vis ? vis->GetValue(id) : 1;
126 }
127 
128 //----------------------------------------------------------------------------
130 {
132  if (!vis)
133  {
135  vis = this->VisibilityById;
137  for (int i=0; i<this->NumberOfIds; ++i)
138  {
139  this->VisibilityById->SetValue(i, 1);
140  }
141  }
142  vis->SetValue(id, 0);
143 }
144 
145 //----------------------------------------------------------------------------
147 {
149  if (!vis)
150  {
151  return;
152  }
153  vis->SetValue(id, 1);
154 }
155 
156 //----------------------------------------------------------------------------
158 {
159  if (this->Initialized)
160  {
161  return;
162  }
163  for (int i=0; i<3; i++)
164  {
165  this->Dimensions[i] = dims[i];
166  }
167  this->NumberOfIds = static_cast<vtkIdType>(dims[0])*
168  static_cast<vtkIdType>(dims[1])*
169  static_cast<vtkIdType>(dims[2]);
170  this->Initialized = 1;
171 }
172 
173 #endif
174 
abstract base class for most VTK objects
Definition: vtkObject.h:61
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
virtual void SetNumberOfTuples(vtkIdType number)=0
int vtkIdType
Definition: vtkType.h:281
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
GLenum src
Definition: vtkgl.h:12525
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
dynamic, self-adjusting array of unsigned char
static vtkUnsignedCharArray * New()
static vtkObject * New()
helper object to manage the visibility of points and cells
#define vtkGetVectorMacro(name, type, count)
Definition: vtkSetGet.h:414
#define VTKCOMMONDATAMODEL_EXPORT