VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAlgorithm.h 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 =========================================================================*/ 00040 #ifndef __vtkAlgorithm_h 00041 #define __vtkAlgorithm_h 00042 00043 #include "vtkObject.h" 00044 00045 class vtkAbstractArray; 00046 class vtkAlgorithmInternals; 00047 class vtkAlgorithmOutput; 00048 class vtkCollection; 00049 class vtkDataArray; 00050 class vtkDataObject; 00051 class vtkExecutive; 00052 class vtkInformation; 00053 class vtkInformationInformationVectorKey; 00054 class vtkInformationIntegerKey; 00055 class vtkInformationStringKey; 00056 class vtkInformationStringVectorKey; 00057 class vtkInformationVector; 00058 00059 class VTK_FILTERING_EXPORT vtkAlgorithm : public vtkObject 00060 { 00061 public: 00062 static vtkAlgorithm *New(); 00063 vtkTypeMacro(vtkAlgorithm,vtkObject); 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00068 int HasExecutive(); 00069 00072 vtkExecutive* GetExecutive(); 00073 00077 virtual void SetExecutive(vtkExecutive* executive); 00078 00080 00094 virtual int ProcessRequest(vtkInformation* request, 00095 vtkInformationVector** inInfo, 00096 vtkInformationVector* outInfo); 00098 00100 00102 int ProcessRequest(vtkInformation* request, 00103 vtkCollection* inInfo, 00104 vtkInformationVector* outInfo); 00106 00108 00111 virtual int 00112 ComputePipelineMTime(vtkInformation* request, 00113 vtkInformationVector** inInfoVec, 00114 vtkInformationVector* outInfoVec, 00115 int requestFromOutputPort, 00116 unsigned long* mtime); 00118 00124 virtual int ModifyRequest(vtkInformation* request, int when); 00125 00130 vtkInformation* GetInputPortInformation(int port); 00131 00136 vtkInformation* GetOutputPortInformation(int port); 00137 00139 00140 vtkGetObjectMacro(Information, vtkInformation); 00141 virtual void SetInformation(vtkInformation*); 00143 00145 int GetNumberOfInputPorts(); 00146 00148 int GetNumberOfOutputPorts(); 00149 00151 00152 virtual void Register(vtkObjectBase* o); 00153 virtual void UnRegister(vtkObjectBase* o); 00155 00157 00159 vtkSetMacro(AbortExecute,int); 00160 vtkGetMacro(AbortExecute,int); 00161 vtkBooleanMacro(AbortExecute,int); 00163 00165 00166 vtkSetClampMacro(Progress,double,0.0,1.0); 00167 vtkGetMacro(Progress,double); 00169 00173 void UpdateProgress(double amount); 00174 00176 00181 void SetProgressText(const char* ptext); 00182 vtkGetStringMacro(ProgressText); 00184 00186 00188 vtkGetMacro( ErrorCode, unsigned long ); 00190 00191 // left public for performance since it is used in inner loops 00192 int AbortExecute; 00193 00195 00196 static vtkInformationIntegerKey* INPUT_IS_OPTIONAL(); 00197 static vtkInformationIntegerKey* INPUT_IS_REPEATABLE(); 00198 static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS(); 00199 static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE(); 00200 static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS(); 00201 static vtkInformationIntegerKey* INPUT_PORT(); 00202 static vtkInformationIntegerKey* INPUT_CONNECTION(); 00204 00205 00207 00213 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00214 int fieldAssociation, 00215 const char *name); 00216 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00217 int fieldAssociation, 00218 int fieldAttributeType); 00219 virtual void SetInputArrayToProcess(int idx, vtkInformation *info); 00221 00223 00237 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00238 const char* fieldAssociation, 00239 const char* attributeTypeorName); 00241 00243 vtkInformation *GetInputArrayInformation(int idx); 00244 00245 // from here down are convenience methods that really are executive methods 00246 00247 00248 00250 void RemoveAllInputs(); 00251 00254 vtkDataObject* GetOutputDataObject(int port); 00255 00257 00259 vtkDataObject *GetInputDataObject(int port, 00260 int connection); 00262 00264 00273 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input); 00274 virtual void SetInputConnection(vtkAlgorithmOutput* input); 00276 00278 00283 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input); 00284 virtual void AddInputConnection(vtkAlgorithmOutput* input); 00286 00293 virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input); 00294 00296 00300 vtkAlgorithmOutput* GetOutputPort(int index); 00301 vtkAlgorithmOutput* GetOutputPort() { 00302 return this->GetOutputPort(0); } 00304 00306 int GetNumberOfInputConnections(int port); 00307 00309 int GetTotalNumberOfInputConnections(); 00310 00312 vtkAlgorithmOutput* GetInputConnection(int port, int index); 00313 00315 virtual void Update(); 00316 00319 virtual void UpdateInformation(); 00320 00322 virtual void UpdateWholeExtent(); 00323 00326 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn); 00327 00328 //====================================================================== 00329 //The following block of code is to support old style VTK applications. If 00330 //you are using these calls there are better ways to do it in the new 00331 //pipeline 00332 //====================================================================== 00333 00335 00336 virtual void SetReleaseDataFlag(int); 00337 virtual int GetReleaseDataFlag(); 00338 void ReleaseDataFlagOn(); 00339 void ReleaseDataFlagOff(); 00341 00342 //======================================================================== 00343 00345 00349 int UpdateExtentIsEmpty(vtkDataObject *output); 00350 int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType); 00352 00355 static void SetDefaultExecutivePrototype(vtkExecutive* proto); 00356 00360 virtual double ComputePriority(); 00361 00363 00365 static vtkInformationIntegerKey* PRESERVES_DATASET(); 00366 static vtkInformationIntegerKey* PRESERVES_GEOMETRY(); 00367 static vtkInformationIntegerKey* PRESERVES_BOUNDS(); 00368 static vtkInformationIntegerKey* PRESERVES_TOPOLOGY(); 00369 static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES(); 00370 static vtkInformationIntegerKey* PRESERVES_RANGES(); 00372 00373 protected: 00374 vtkAlgorithm(); 00375 ~vtkAlgorithm(); 00376 00377 // Keys used to indicate that input/output port information has been 00378 // filled. 00379 static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED(); 00380 00381 // Arbitrary extra information associated with this algorithm 00382 vtkInformation* Information; 00383 00387 virtual int FillInputPortInformation(int port, vtkInformation* info); 00388 00392 virtual int FillOutputPortInformation(int port, vtkInformation* info); 00393 00395 virtual void SetNumberOfInputPorts(int n); 00396 00398 virtual void SetNumberOfOutputPorts(int n); 00399 00400 // Helper methods to check input/output port index ranges. 00401 int InputPortIndexInRange(int index, const char* action); 00402 int OutputPortIndexInRange(int index, const char* action); 00403 00407 int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector); 00408 00410 00416 int GetInputArrayAssociation(int idx, int connection, 00417 vtkInformationVector **inputVector); 00418 int GetInputArrayAssociation(int idx, vtkDataObject* input); 00420 00421 00423 00425 vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector); 00426 vtkDataArray *GetInputArrayToProcess(int idx, 00427 vtkInformationVector **inputVector, 00428 int& association); 00430 00432 00438 vtkDataArray *GetInputArrayToProcess(int idx, 00439 int connection, 00440 vtkInformationVector **inputVector); 00441 vtkDataArray *GetInputArrayToProcess(int idx, 00442 int connection, 00443 vtkInformationVector **inputVector, 00444 int& association); 00445 vtkDataArray *GetInputArrayToProcess(int idx, 00446 vtkDataObject* input); 00447 vtkDataArray *GetInputArrayToProcess(int idx, 00448 vtkDataObject* input, 00449 int& association); 00451 00452 00454 00456 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector); 00457 vtkAbstractArray *GetInputAbstractArrayToProcess 00458 (int idx, vtkInformationVector **inputVector, int& association); 00460 00462 00468 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00469 int connection, 00470 vtkInformationVector **inputVector); 00471 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00472 int connection, 00473 vtkInformationVector **inputVector, 00474 int& association); 00475 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00476 vtkDataObject* input); 00477 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00478 vtkDataObject* input, 00479 int& association); 00481 00482 00483 00485 00490 vtkInformation *GetInputArrayFieldInformation(int idx, 00491 vtkInformationVector **inputVector); 00493 00494 00499 virtual vtkExecutive* CreateDefaultExecutive(); 00500 00502 00504 vtkSetMacro( ErrorCode, unsigned long ); 00505 unsigned long ErrorCode; 00507 00508 // Progress/Update handling 00509 double Progress; 00510 char *ProgressText; 00511 00512 // Garbage collection support. 00513 virtual void ReportReferences(vtkGarbageCollector*); 00514 00515 // executive methods below 00516 00518 00522 virtual void SetNthInputConnection(int port, int index, 00523 vtkAlgorithmOutput* input); 00525 00530 virtual void SetNumberOfInputConnections(int port, int n); 00531 00532 static vtkExecutive* DefaultExecutivePrototype; 00533 00534 private: 00535 vtkExecutive* Executive; 00536 vtkInformationVector* InputPortInformation; 00537 vtkInformationVector* OutputPortInformation; 00538 vtkAlgorithmInternals* AlgorithmInternal; 00539 static void ConnectionAdd(vtkAlgorithm* producer, int producerPort, 00540 vtkAlgorithm* consumer, int consumerPort); 00541 static void ConnectionRemove(vtkAlgorithm* producer, int producerPort, 00542 vtkAlgorithm* consumer, int consumerPort); 00543 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port); 00544 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port); 00545 00546 private: 00547 vtkAlgorithm(const vtkAlgorithm&); // Not implemented. 00548 void operator=(const vtkAlgorithm&); // Not implemented. 00549 }; 00550 00551 #endif