VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
36 class VTKCOMMONDATAMODEL_EXPORT vtkStructuredVisibilityConstraint : public vtkObject
37 {
38 public:
40 
41  vtkTypeMacro(vtkStructuredVisibilityConstraint,vtkObject);
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 
79  void DeepCopy(vtkStructuredVisibilityConstraint* src);
80 
82 
84  unsigned char IsConstrained()
85  {
86  return this->VisibilityById ? 1 : 0;
87  }
89 
90 protected:
93 
94  vtkUnsignedCharArray* VisibilityById;
95  int Dimensions[3];
96  vtkIdType NumberOfIds;
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  {
112  this->VisibilityById = vtkUnsignedCharArray::New();
113  this->VisibilityById->SetNumberOfTuples( this->NumberOfIds );
114  for( int i=0; i < this->NumberOfIds; ++i )
115  {
116  this->VisibilityById->SetValue( i, 1 );
117  }
118  }
119 }
120 //----------------------------------------------------------------------------
122  vtkIdType id)
123 {
124  vtkUnsignedCharArray* vis = this->VisibilityById;
125  return vis ? vis->GetValue(id) : 1;
126 }
127 
128 //----------------------------------------------------------------------------
130 {
131  vtkUnsignedCharArray* vis = this->VisibilityById;
132  if (!vis)
133  {
134  this->VisibilityById = vtkUnsignedCharArray::New();
135  vis = this->VisibilityById;
136  this->VisibilityById->SetNumberOfTuples(this->NumberOfIds);
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 {
148  vtkUnsignedCharArray* vis = this->VisibilityById;
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 
helper object to manage the visibility of points and cells