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 "vtkCommonExecutionModelModule.h" // For export macro 00044 #include "vtkObject.h" 00045 00046 class vtkAbstractArray; 00047 class vtkAlgorithmInternals; 00048 class vtkAlgorithmOutput; 00049 class vtkCollection; 00050 class vtkDataArray; 00051 class vtkDataObject; 00052 class vtkExecutive; 00053 class vtkInformation; 00054 class vtkInformationInformationVectorKey; 00055 class vtkInformationIntegerKey; 00056 class vtkInformationStringKey; 00057 class vtkInformationStringVectorKey; 00058 class vtkInformationVector; 00059 00060 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject 00061 { 00062 public: 00063 static vtkAlgorithm *New(); 00064 vtkTypeMacro(vtkAlgorithm,vtkObject); 00065 void PrintSelf(ostream& os, vtkIndent indent); 00066 00068 00075 enum DesiredOutputPrecision 00076 { 00077 SINGLE_PRECISION, 00078 DOUBLE_PRECISION, 00079 DEFAULT_PRECISION 00080 }; 00082 00085 int HasExecutive(); 00086 00089 vtkExecutive* GetExecutive(); 00090 00094 virtual void SetExecutive(vtkExecutive* executive); 00095 00097 00111 virtual int ProcessRequest(vtkInformation* request, 00112 vtkInformationVector** inInfo, 00113 vtkInformationVector* outInfo); 00115 00117 00119 int ProcessRequest(vtkInformation* request, 00120 vtkCollection* inInfo, 00121 vtkInformationVector* outInfo); 00123 00125 00128 virtual int 00129 ComputePipelineMTime(vtkInformation* request, 00130 vtkInformationVector** inInfoVec, 00131 vtkInformationVector* outInfoVec, 00132 int requestFromOutputPort, 00133 unsigned long* mtime); 00135 00141 virtual int ModifyRequest(vtkInformation* request, int when); 00142 00147 vtkInformation* GetInputPortInformation(int port); 00148 00153 vtkInformation* GetOutputPortInformation(int port); 00154 00156 00157 vtkGetObjectMacro(Information, vtkInformation); 00158 virtual void SetInformation(vtkInformation*); 00160 00162 int GetNumberOfInputPorts(); 00163 00165 int GetNumberOfOutputPorts(); 00166 00168 00169 virtual void Register(vtkObjectBase* o); 00170 virtual void UnRegister(vtkObjectBase* o); 00172 00174 00176 vtkSetMacro(AbortExecute,int); 00177 vtkGetMacro(AbortExecute,int); 00178 vtkBooleanMacro(AbortExecute,int); 00180 00182 00183 vtkSetClampMacro(Progress,double,0.0,1.0); 00184 vtkGetMacro(Progress,double); 00186 00190 void UpdateProgress(double amount); 00191 00193 00198 void SetProgressText(const char* ptext); 00199 vtkGetStringMacro(ProgressText); 00201 00203 00205 vtkGetMacro( ErrorCode, unsigned long ); 00207 00208 // left public for performance since it is used in inner loops 00209 int AbortExecute; 00210 00212 00213 static vtkInformationIntegerKey* INPUT_IS_OPTIONAL(); 00214 static vtkInformationIntegerKey* INPUT_IS_REPEATABLE(); 00215 static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS(); 00216 static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE(); 00217 static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS(); 00218 static vtkInformationIntegerKey* INPUT_PORT(); 00219 static vtkInformationIntegerKey* INPUT_CONNECTION(); 00221 00222 00224 00230 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00231 int fieldAssociation, 00232 const char *name); 00233 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00234 int fieldAssociation, 00235 int fieldAttributeType); 00236 virtual void SetInputArrayToProcess(int idx, vtkInformation *info); 00238 00240 00254 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00255 const char* fieldAssociation, 00256 const char* attributeTypeorName); 00258 00260 vtkInformation *GetInputArrayInformation(int idx); 00261 00262 // from here down are convenience methods that really are executive methods 00263 00264 00265 00267 void RemoveAllInputs(); 00268 00271 vtkDataObject* GetOutputDataObject(int port); 00272 00274 00276 vtkDataObject *GetInputDataObject(int port, 00277 int connection); 00279 00281 00290 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input); 00291 virtual void SetInputConnection(vtkAlgorithmOutput* input); 00293 00295 00300 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input); 00301 virtual void AddInputConnection(vtkAlgorithmOutput* input); 00303 00310 virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input); 00311 00313 virtual void RemoveInputConnection(int port, int idx); 00314 00316 virtual void RemoveAllInputConnections(int port); 00317 00319 00326 virtual void SetInputDataObject(int port, vtkDataObject* data); 00327 virtual void SetInputDataObject(vtkDataObject* data) 00328 { this->SetInputDataObject(0, data); } 00330 00332 00335 virtual void AddInputDataObject(int port, vtkDataObject* data); 00336 virtual void AddInputDataObject(vtkDataObject* data) 00337 { this->AddInputDataObject(0, data); } 00339 00341 00345 vtkAlgorithmOutput* GetOutputPort(int index); 00346 vtkAlgorithmOutput* GetOutputPort() { 00347 return this->GetOutputPort(0); } 00349 00351 int GetNumberOfInputConnections(int port); 00352 00354 int GetTotalNumberOfInputConnections(); 00355 00357 vtkAlgorithmOutput* GetInputConnection(int port, int index); 00358 00361 vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort); 00362 00364 vtkAlgorithm* GetInputAlgorithm(int port, int index); 00365 00367 00368 vtkAlgorithm* GetInputAlgorithm() 00369 { 00370 return this->GetInputAlgorithm(0, 0); 00371 } 00373 00375 vtkExecutive* GetInputExecutive(int port, int index); 00376 00378 00379 vtkExecutive* GetInputExecutive() 00380 { 00381 return this->GetInputExecutive(0, 0); 00382 } 00384 00391 vtkInformation* GetInputInformation(int port, int index); 00392 00394 00395 vtkInformation* GetInputInformation() 00396 { 00397 return this->GetInputInformation(0, 0); 00398 } 00400 00405 vtkInformation* GetOutputInformation(int port); 00406 00408 00409 virtual void Update(int port); 00410 virtual void Update(); 00412 00413 00415 virtual void UpdateInformation(); 00416 00418 virtual void PropagateUpdateExtent(); 00419 00421 virtual void UpdateWholeExtent(); 00422 00425 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn); 00426 00427 //====================================================================== 00428 //The following block of code is to support old style VTK applications. If 00429 //you are using these calls there are better ways to do it in the new 00430 //pipeline 00431 //====================================================================== 00432 00434 00435 virtual void SetReleaseDataFlag(int); 00436 virtual int GetReleaseDataFlag(); 00437 void ReleaseDataFlagOn(); 00438 void ReleaseDataFlagOff(); 00440 00441 //======================================================================== 00442 00444 00448 int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output); 00449 int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType); 00451 00454 static void SetDefaultExecutivePrototype(vtkExecutive* proto); 00455 00459 virtual double ComputePriority(); 00460 00462 00464 static vtkInformationIntegerKey* PRESERVES_DATASET(); 00465 static vtkInformationIntegerKey* PRESERVES_GEOMETRY(); 00466 static vtkInformationIntegerKey* PRESERVES_BOUNDS(); 00467 static vtkInformationIntegerKey* PRESERVES_TOPOLOGY(); 00468 static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES(); 00469 static vtkInformationIntegerKey* PRESERVES_RANGES(); 00470 static vtkInformationIntegerKey* MANAGES_METAINFORMATION(); 00472 00477 int SetUpdateExtentToWholeExtent(int port); 00478 00482 int SetUpdateExtentToWholeExtent(); 00483 00485 00486 void SetUpdateExtent(int port, 00487 int piece,int numPieces, int ghostLevel); 00489 00491 00493 void SetUpdateExtent(int piece,int numPieces, int ghostLevel) 00494 { 00495 this->SetUpdateExtent(0, piece, numPieces, ghostLevel); 00496 } 00498 00500 void SetUpdateExtent(int port, int extent[6]); 00501 00503 00504 void SetUpdateExtent(int extent[6]) 00505 { 00506 this->SetUpdateExtent(0, extent); 00507 } 00509 00511 00513 int* GetUpdateExtent() 00514 { 00515 return this->GetUpdateExtent(0); 00516 } 00517 int* GetUpdateExtent(int port); 00518 void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, 00519 int& z0, int& z1) 00520 { 00521 this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1); 00522 } 00523 void GetUpdateExtent(int port, 00524 int& x0, int& x1, int& y0, int& y1, 00525 int& z0, int& z1); 00526 void GetUpdateExtent(int extent[6]) 00527 { 00528 this->GetUpdateExtent(0, extent); 00529 } 00530 void GetUpdateExtent(int port, int extent[6]); 00532 00534 00536 int GetUpdatePiece() 00537 { 00538 return this->GetUpdatePiece(0); 00539 } 00540 int GetUpdatePiece(int port); 00541 int GetUpdateNumberOfPieces() 00542 { 00543 return this->GetUpdateNumberOfPieces(0); 00544 } 00545 int GetUpdateNumberOfPieces(int port); 00546 int GetUpdateGhostLevel() 00547 { 00548 return this->GetUpdateGhostLevel(0); 00549 } 00550 int GetUpdateGhostLevel(int port); 00552 00553 protected: 00554 vtkAlgorithm(); 00555 ~vtkAlgorithm(); 00556 00557 // Keys used to indicate that input/output port information has been 00558 // filled. 00559 static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED(); 00560 00561 // Arbitrary extra information associated with this algorithm 00562 vtkInformation* Information; 00563 00567 virtual int FillInputPortInformation(int port, vtkInformation* info); 00568 00572 virtual int FillOutputPortInformation(int port, vtkInformation* info); 00573 00575 virtual void SetNumberOfInputPorts(int n); 00576 00578 virtual void SetNumberOfOutputPorts(int n); 00579 00580 // Helper methods to check input/output port index ranges. 00581 int InputPortIndexInRange(int index, const char* action); 00582 int OutputPortIndexInRange(int index, const char* action); 00583 00587 int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector); 00588 00590 00596 int GetInputArrayAssociation(int idx, int connection, 00597 vtkInformationVector **inputVector); 00598 int GetInputArrayAssociation(int idx, vtkDataObject* input); 00600 00601 00603 00605 vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector); 00606 vtkDataArray *GetInputArrayToProcess(int idx, 00607 vtkInformationVector **inputVector, 00608 int& association); 00610 00612 00618 vtkDataArray *GetInputArrayToProcess(int idx, 00619 int connection, 00620 vtkInformationVector **inputVector); 00621 vtkDataArray *GetInputArrayToProcess(int idx, 00622 int connection, 00623 vtkInformationVector **inputVector, 00624 int& association); 00625 vtkDataArray *GetInputArrayToProcess(int idx, 00626 vtkDataObject* input); 00627 vtkDataArray *GetInputArrayToProcess(int idx, 00628 vtkDataObject* input, 00629 int& association); 00631 00632 00634 00636 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector); 00637 vtkAbstractArray *GetInputAbstractArrayToProcess 00638 (int idx, vtkInformationVector **inputVector, int& association); 00640 00642 00648 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00649 int connection, 00650 vtkInformationVector **inputVector); 00651 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00652 int connection, 00653 vtkInformationVector **inputVector, 00654 int& association); 00655 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00656 vtkDataObject* input); 00657 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00658 vtkDataObject* input, 00659 int& association); 00661 00662 00663 00665 00670 vtkInformation *GetInputArrayFieldInformation(int idx, 00671 vtkInformationVector **inputVector); 00673 00674 00679 virtual vtkExecutive* CreateDefaultExecutive(); 00680 00682 00684 vtkSetMacro( ErrorCode, unsigned long ); 00685 unsigned long ErrorCode; 00687 00688 // Progress/Update handling 00689 double Progress; 00690 char *ProgressText; 00691 00692 // Garbage collection support. 00693 virtual void ReportReferences(vtkGarbageCollector*); 00694 00695 // executive methods below 00696 00698 00702 virtual void SetNthInputConnection(int port, int index, 00703 vtkAlgorithmOutput* input); 00705 00710 virtual void SetNumberOfInputConnections(int port, int n); 00711 00712 static vtkExecutive* DefaultExecutivePrototype; 00713 00715 00719 void SetInputDataInternal(int port, vtkDataObject *input) 00720 { this->SetInputDataObject(port, input); } 00721 void AddInputDataInternal(int port, vtkDataObject *input) 00722 { this->AddInputDataObject(port, input); } 00724 00725 private: 00726 vtkExecutive* Executive; 00727 vtkInformationVector* InputPortInformation; 00728 vtkInformationVector* OutputPortInformation; 00729 vtkAlgorithmInternals* AlgorithmInternal; 00730 static void ConnectionAdd(vtkAlgorithm* producer, int producerPort, 00731 vtkAlgorithm* consumer, int consumerPort); 00732 static void ConnectionRemove(vtkAlgorithm* producer, int producerPort, 00733 vtkAlgorithm* consumer, int consumerPort); 00734 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port); 00735 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port); 00736 00737 private: 00738 vtkAlgorithm(const vtkAlgorithm&); // Not implemented. 00739 void operator=(const vtkAlgorithm&); // Not implemented. 00740 }; 00741 00742 #endif