VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkAlgorithm.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 =========================================================================*/ 00037 #ifndef __vtkAlgorithm_h 00038 #define __vtkAlgorithm_h 00039 00040 #include "vtkObject.h" 00041 00042 class vtkAbstractArray; 00043 class vtkAlgorithmInternals; 00044 class vtkAlgorithmOutput; 00045 class vtkDataArray; 00046 class vtkDataObject; 00047 class vtkExecutive; 00048 class vtkInformation; 00049 class vtkInformationInformationVectorKey; 00050 class vtkInformationIntegerKey; 00051 class vtkInformationStringKey; 00052 class vtkInformationStringVectorKey; 00053 class vtkInformationVector; 00054 00055 class VTK_FILTERING_EXPORT vtkAlgorithm : public vtkObject 00056 { 00057 public: 00058 static vtkAlgorithm *New(); 00059 vtkTypeRevisionMacro(vtkAlgorithm,vtkObject); 00060 void PrintSelf(ostream& os, vtkIndent indent); 00061 00064 int HasExecutive(); 00065 00068 vtkExecutive* GetExecutive(); 00069 00073 virtual void SetExecutive(vtkExecutive* executive); 00074 00076 00090 virtual int ProcessRequest(vtkInformation* request, 00091 vtkInformationVector** inInfo, 00092 vtkInformationVector* outInfo); 00094 00096 00099 virtual int 00100 ComputePipelineMTime(vtkInformation* request, 00101 vtkInformationVector** inInfoVec, 00102 vtkInformationVector* outInfoVec, 00103 int requestFromOutputPort, 00104 unsigned long* mtime); 00106 00112 virtual int ModifyRequest(vtkInformation* request, int when); 00113 00118 vtkInformation* GetInputPortInformation(int port); 00119 00124 vtkInformation* GetOutputPortInformation(int port); 00125 00127 00128 vtkGetObjectMacro(Information, vtkInformation); 00129 virtual void SetInformation(vtkInformation*); 00131 00133 int GetNumberOfInputPorts(); 00134 00136 int GetNumberOfOutputPorts(); 00137 00139 00140 virtual void Register(vtkObjectBase* o); 00141 virtual void UnRegister(vtkObjectBase* o); 00143 00145 00147 vtkSetMacro(AbortExecute,int); 00148 vtkGetMacro(AbortExecute,int); 00149 vtkBooleanMacro(AbortExecute,int); 00151 00153 00154 vtkSetClampMacro(Progress,double,0.0,1.0); 00155 vtkGetMacro(Progress,double); 00157 00161 void UpdateProgress(double amount); 00162 00164 00169 void SetProgressText(const char* ptext); 00170 vtkGetStringMacro(ProgressText); 00172 00174 00176 vtkGetMacro( ErrorCode, unsigned long ); 00178 00179 // left public for performance since it is used in inner loops 00180 int AbortExecute; 00181 00183 00184 static vtkInformationIntegerKey* INPUT_IS_OPTIONAL(); 00185 static vtkInformationIntegerKey* INPUT_IS_REPEATABLE(); 00186 static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS(); 00187 static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE(); 00188 static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS(); 00189 static vtkInformationIntegerKey* INPUT_PORT(); 00190 static vtkInformationIntegerKey* INPUT_CONNECTION(); 00192 00193 00195 00201 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00202 int fieldAssociation, 00203 const char *name); 00204 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00205 int fieldAssociation, 00206 int fieldAttributeType); 00207 virtual void SetInputArrayToProcess(int idx, vtkInformation *info); 00209 00211 00225 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00226 const char* fieldAssociation, 00227 const char* attributeTypeorName); 00229 00231 vtkInformation *GetInputArrayInformation(int idx); 00232 00233 // from here down are convenience methods that really are executive methods 00234 00235 00236 00238 void RemoveAllInputs(); 00239 00242 vtkDataObject* GetOutputDataObject(int port); 00243 00245 00247 vtkDataObject *GetInputDataObject(int port, 00248 int connection); 00250 00252 00261 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input); 00262 virtual void SetInputConnection(vtkAlgorithmOutput* input); 00264 00266 00271 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input); 00272 virtual void AddInputConnection(vtkAlgorithmOutput* input); 00274 00281 virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input); 00282 00284 00288 vtkAlgorithmOutput* GetOutputPort(int index); 00289 vtkAlgorithmOutput* GetOutputPort() { 00290 return this->GetOutputPort(0); } 00292 00294 int GetNumberOfInputConnections(int port); 00295 00297 int GetTotalNumberOfInputConnections(); 00298 00300 vtkAlgorithmOutput* GetInputConnection(int port, int index); 00301 00303 virtual void Update(); 00304 00307 virtual void UpdateInformation(); 00308 00310 virtual void UpdateWholeExtent(); 00311 00314 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn); 00315 00316 //====================================================================== 00317 //The following block of code is to support old style VTK applications. If 00318 //you are using these calls there are better ways to do it in the new 00319 //pipeline 00320 //====================================================================== 00321 00323 00324 virtual void SetReleaseDataFlag(int); 00325 virtual int GetReleaseDataFlag(); 00326 void ReleaseDataFlagOn(); 00327 void ReleaseDataFlagOff(); 00329 00330 //======================================================================== 00331 00333 00337 int UpdateExtentIsEmpty(vtkDataObject *output); 00338 int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType); 00340 00343 static void SetDefaultExecutivePrototype(vtkExecutive* proto); 00344 00348 virtual double ComputePriority(); 00349 00351 00353 static vtkInformationIntegerKey* PRESERVES_DATASET(); 00354 static vtkInformationIntegerKey* PRESERVES_GEOMETRY(); 00355 static vtkInformationIntegerKey* PRESERVES_BOUNDS(); 00356 static vtkInformationIntegerKey* PRESERVES_TOPOLOGY(); 00357 static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES(); 00358 static vtkInformationIntegerKey* PRESERVES_RANGES(); 00360 00361 protected: 00362 vtkAlgorithm(); 00363 ~vtkAlgorithm(); 00364 00365 // Keys used to indicate that input/output port information has been 00366 // filled. 00367 static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED(); 00368 00369 // Arbitrary extra information associated with this algorithm 00370 vtkInformation* Information; 00371 00375 virtual int FillInputPortInformation(int port, vtkInformation* info); 00376 00380 virtual int FillOutputPortInformation(int port, vtkInformation* info); 00381 00383 virtual void SetNumberOfInputPorts(int n); 00384 00386 virtual void SetNumberOfOutputPorts(int n); 00387 00388 // Helper methods to check input/output port index ranges. 00389 int InputPortIndexInRange(int index, const char* action); 00390 int OutputPortIndexInRange(int index, const char* action); 00391 00394 vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector); 00395 00397 00403 vtkDataArray *GetInputArrayToProcess(int idx, 00404 int connection, 00405 vtkInformationVector **inputVector); 00406 vtkDataArray *GetInputArrayToProcess(int idx, 00407 vtkDataObject* input); 00409 00410 00413 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector); 00414 00416 00422 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00423 int connection, 00424 vtkInformationVector **inputVector); 00425 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00426 vtkDataObject* input); 00428 00429 00430 00432 00437 vtkInformation *GetInputArrayFieldInformation(int idx, 00438 vtkInformationVector **inputVector); 00440 00441 00446 virtual vtkExecutive* CreateDefaultExecutive(); 00447 00449 00451 vtkSetMacro( ErrorCode, unsigned long ); 00452 unsigned long ErrorCode; 00454 00455 // Progress/Update handling 00456 double Progress; 00457 char *ProgressText; 00458 00459 // Garbage collection support. 00460 virtual void ReportReferences(vtkGarbageCollector*); 00461 00462 // executive methods below 00463 00465 00469 virtual void SetNthInputConnection(int port, int index, 00470 vtkAlgorithmOutput* input); 00472 00477 virtual void SetNumberOfInputConnections(int port, int n); 00478 00479 static vtkExecutive* DefaultExecutivePrototype; 00480 00481 private: 00482 vtkExecutive* Executive; 00483 vtkInformationVector* InputPortInformation; 00484 vtkInformationVector* OutputPortInformation; 00485 vtkAlgorithmInternals* AlgorithmInternal; 00486 static void ConnectionAdd(vtkAlgorithm* producer, int producerPort, 00487 vtkAlgorithm* consumer, int consumerPort); 00488 static void ConnectionRemove(vtkAlgorithm* producer, int producerPort, 00489 vtkAlgorithm* consumer, int consumerPort); 00490 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port); 00491 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port); 00492 00493 private: 00494 vtkAlgorithm(const vtkAlgorithm&); // Not implemented. 00495 void operator=(const vtkAlgorithm&); // Not implemented. 00496 }; 00497 00498 #endif