00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkStructuredVisibilityConstraint.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00038 #ifndef __vtkStructuredVisibilityConstraint_h 00039 #define __vtkStructuredVisibilityConstraint_h 00040 00041 #include "vtkObject.h" 00042 00043 #include "vtkUnsignedCharArray.h" // Needed for inline methods. 00044 00045 class VTK_COMMON_EXPORT vtkStructuredVisibilityConstraint : public vtkObject 00046 { 00047 public: 00048 static vtkStructuredVisibilityConstraint *New(); 00049 00050 vtkTypeRevisionMacro(vtkStructuredVisibilityConstraint,vtkObject); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00052 00054 unsigned char IsVisible(vtkIdType id); 00055 00059 void Blank(vtkIdType id); 00060 00062 void UnBlank(vtkIdType id); 00063 00065 00066 vtkGetVectorMacro(Dimensions,int,3); 00068 00071 void Initialize(int dims[3]); 00072 00074 00075 void SetVisibilityById(vtkUnsignedCharArray* vis); 00076 vtkGetObjectMacro(VisibilityById, vtkUnsignedCharArray); 00078 00081 void ShallowCopy(vtkStructuredVisibilityConstraint* src); 00082 00084 void DeepCopy(vtkStructuredVisibilityConstraint* src); 00085 00087 00089 unsigned char IsConstrained() 00090 { 00091 return this->VisibilityById ? 1 : 0; 00092 } 00094 00095 protected: 00096 vtkStructuredVisibilityConstraint(); 00097 ~vtkStructuredVisibilityConstraint(); 00098 00099 vtkUnsignedCharArray* VisibilityById; 00100 int Dimensions[3]; 00101 vtkIdType NumberOfIds; 00102 unsigned char Initialized; 00103 00104 private: 00105 vtkStructuredVisibilityConstraint(const vtkStructuredVisibilityConstraint&); // Not implemented. 00106 void operator=(const vtkStructuredVisibilityConstraint&); // Not implemented. 00107 }; 00108 00109 //---------------------------------------------------------------------------- 00110 // These methods are inline for efficiency. 00111 00112 //---------------------------------------------------------------------------- 00113 inline unsigned char vtkStructuredVisibilityConstraint::IsVisible( 00114 vtkIdType id) 00115 { 00116 vtkUnsignedCharArray* vis = this->VisibilityById; 00117 return vis ? vis->GetValue(id) : 1; 00118 } 00119 00120 //---------------------------------------------------------------------------- 00121 inline void vtkStructuredVisibilityConstraint::Blank(vtkIdType id) 00122 { 00123 vtkUnsignedCharArray* vis = this->VisibilityById; 00124 if (!vis) 00125 { 00126 this->VisibilityById = vtkUnsignedCharArray::New(); 00127 vis = this->VisibilityById; 00128 this->VisibilityById->Allocate(this->NumberOfIds); 00129 for (int i=0; i<this->NumberOfIds; ++i) 00130 { 00131 this->VisibilityById->SetValue(i, 1); 00132 } 00133 } 00134 vis->SetValue(id, 0); 00135 } 00136 00137 //---------------------------------------------------------------------------- 00138 inline void vtkStructuredVisibilityConstraint::UnBlank(vtkIdType id) 00139 { 00140 vtkUnsignedCharArray* vis = this->VisibilityById; 00141 if (!vis) 00142 { 00143 return; 00144 } 00145 vis->SetValue(id, 1); 00146 } 00147 00148 //---------------------------------------------------------------------------- 00149 inline void vtkStructuredVisibilityConstraint::Initialize(int dims[3]) 00150 { 00151 if (this->Initialized) 00152 { 00153 return; 00154 } 00155 for (int i=0; i<3; i++) 00156 { 00157 this->Dimensions[i] = dims[i]; 00158 } 00159 this->NumberOfIds = dims[0]*dims[1]*dims[2]; 00160 this->Initialized = 1; 00161 } 00162 00163 00164 #endif