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 vtkDataArray; 00049 class vtkDataObject; 00050 class vtkExecutive; 00051 class vtkInformation; 00052 class vtkInformationInformationVectorKey; 00053 class vtkInformationIntegerKey; 00054 class vtkInformationStringKey; 00055 class vtkInformationStringVectorKey; 00056 class vtkInformationVector; 00057 00058 class VTK_FILTERING_EXPORT vtkAlgorithm : public vtkObject 00059 { 00060 public: 00061 static vtkAlgorithm *New(); 00062 vtkTypeMacro(vtkAlgorithm,vtkObject); 00063 void PrintSelf(ostream& os, vtkIndent indent); 00064 00067 int HasExecutive(); 00068 00071 vtkExecutive* GetExecutive(); 00072 00076 virtual void SetExecutive(vtkExecutive* executive); 00077 00079 00093 virtual int ProcessRequest(vtkInformation* request, 00094 vtkInformationVector** inInfo, 00095 vtkInformationVector* outInfo); 00097 00099 00102 virtual int 00103 ComputePipelineMTime(vtkInformation* request, 00104 vtkInformationVector** inInfoVec, 00105 vtkInformationVector* outInfoVec, 00106 int requestFromOutputPort, 00107 unsigned long* mtime); 00109 00115 virtual int ModifyRequest(vtkInformation* request, int when); 00116 00121 vtkInformation* GetInputPortInformation(int port); 00122 00127 vtkInformation* GetOutputPortInformation(int port); 00128 00130 00131 vtkGetObjectMacro(Information, vtkInformation); 00132 virtual void SetInformation(vtkInformation*); 00134 00136 int GetNumberOfInputPorts(); 00137 00139 int GetNumberOfOutputPorts(); 00140 00142 00143 virtual void Register(vtkObjectBase* o); 00144 virtual void UnRegister(vtkObjectBase* o); 00146 00148 00150 vtkSetMacro(AbortExecute,int); 00151 vtkGetMacro(AbortExecute,int); 00152 vtkBooleanMacro(AbortExecute,int); 00154 00156 00157 vtkSetClampMacro(Progress,double,0.0,1.0); 00158 vtkGetMacro(Progress,double); 00160 00164 void UpdateProgress(double amount); 00165 00167 00172 void SetProgressText(const char* ptext); 00173 vtkGetStringMacro(ProgressText); 00175 00177 00179 vtkGetMacro( ErrorCode, unsigned long ); 00181 00182 // left public for performance since it is used in inner loops 00183 int AbortExecute; 00184 00186 00187 static vtkInformationIntegerKey* INPUT_IS_OPTIONAL(); 00188 static vtkInformationIntegerKey* INPUT_IS_REPEATABLE(); 00189 static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS(); 00190 static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE(); 00191 static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS(); 00192 static vtkInformationIntegerKey* INPUT_PORT(); 00193 static vtkInformationIntegerKey* INPUT_CONNECTION(); 00195 00196 00198 00204 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00205 int fieldAssociation, 00206 const char *name); 00207 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00208 int fieldAssociation, 00209 int fieldAttributeType); 00210 virtual void SetInputArrayToProcess(int idx, vtkInformation *info); 00212 00214 00228 virtual void SetInputArrayToProcess(int idx, int port, int connection, 00229 const char* fieldAssociation, 00230 const char* attributeTypeorName); 00232 00234 vtkInformation *GetInputArrayInformation(int idx); 00235 00236 // from here down are convenience methods that really are executive methods 00237 00238 00239 00241 void RemoveAllInputs(); 00242 00245 vtkDataObject* GetOutputDataObject(int port); 00246 00248 00250 vtkDataObject *GetInputDataObject(int port, 00251 int connection); 00253 00255 00264 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input); 00265 virtual void SetInputConnection(vtkAlgorithmOutput* input); 00267 00269 00274 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input); 00275 virtual void AddInputConnection(vtkAlgorithmOutput* input); 00277 00284 virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input); 00285 00287 00291 vtkAlgorithmOutput* GetOutputPort(int index); 00292 vtkAlgorithmOutput* GetOutputPort() { 00293 return this->GetOutputPort(0); } 00295 00297 int GetNumberOfInputConnections(int port); 00298 00300 int GetTotalNumberOfInputConnections(); 00301 00303 vtkAlgorithmOutput* GetInputConnection(int port, int index); 00304 00306 virtual void Update(); 00307 00310 virtual void UpdateInformation(); 00311 00313 virtual void UpdateWholeExtent(); 00314 00317 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn); 00318 00319 //====================================================================== 00320 //The following block of code is to support old style VTK applications. If 00321 //you are using these calls there are better ways to do it in the new 00322 //pipeline 00323 //====================================================================== 00324 00326 00327 virtual void SetReleaseDataFlag(int); 00328 virtual int GetReleaseDataFlag(); 00329 void ReleaseDataFlagOn(); 00330 void ReleaseDataFlagOff(); 00332 00333 //======================================================================== 00334 00336 00340 int UpdateExtentIsEmpty(vtkDataObject *output); 00341 int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType); 00343 00346 static void SetDefaultExecutivePrototype(vtkExecutive* proto); 00347 00351 virtual double ComputePriority(); 00352 00354 00356 static vtkInformationIntegerKey* PRESERVES_DATASET(); 00357 static vtkInformationIntegerKey* PRESERVES_GEOMETRY(); 00358 static vtkInformationIntegerKey* PRESERVES_BOUNDS(); 00359 static vtkInformationIntegerKey* PRESERVES_TOPOLOGY(); 00360 static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES(); 00361 static vtkInformationIntegerKey* PRESERVES_RANGES(); 00363 00364 protected: 00365 vtkAlgorithm(); 00366 ~vtkAlgorithm(); 00367 00368 // Keys used to indicate that input/output port information has been 00369 // filled. 00370 static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED(); 00371 00372 // Arbitrary extra information associated with this algorithm 00373 vtkInformation* Information; 00374 00378 virtual int FillInputPortInformation(int port, vtkInformation* info); 00379 00383 virtual int FillOutputPortInformation(int port, vtkInformation* info); 00384 00386 virtual void SetNumberOfInputPorts(int n); 00387 00389 virtual void SetNumberOfOutputPorts(int n); 00390 00391 // Helper methods to check input/output port index ranges. 00392 int InputPortIndexInRange(int index, const char* action); 00393 int OutputPortIndexInRange(int index, const char* action); 00394 00397 vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector); 00398 00400 00406 vtkDataArray *GetInputArrayToProcess(int idx, 00407 int connection, 00408 vtkInformationVector **inputVector); 00409 vtkDataArray *GetInputArrayToProcess(int idx, 00410 vtkDataObject* input); 00412 00413 00416 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector); 00417 00419 00425 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00426 int connection, 00427 vtkInformationVector **inputVector); 00428 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx, 00429 vtkDataObject* input); 00431 00432 00433 00435 00440 vtkInformation *GetInputArrayFieldInformation(int idx, 00441 vtkInformationVector **inputVector); 00443 00444 00449 virtual vtkExecutive* CreateDefaultExecutive(); 00450 00452 00454 vtkSetMacro( ErrorCode, unsigned long ); 00455 unsigned long ErrorCode; 00457 00458 // Progress/Update handling 00459 double Progress; 00460 char *ProgressText; 00461 00462 // Garbage collection support. 00463 virtual void ReportReferences(vtkGarbageCollector*); 00464 00465 // executive methods below 00466 00468 00472 virtual void SetNthInputConnection(int port, int index, 00473 vtkAlgorithmOutput* input); 00475 00480 virtual void SetNumberOfInputConnections(int port, int n); 00481 00482 static vtkExecutive* DefaultExecutivePrototype; 00483 00484 private: 00485 vtkExecutive* Executive; 00486 vtkInformationVector* InputPortInformation; 00487 vtkInformationVector* OutputPortInformation; 00488 vtkAlgorithmInternals* AlgorithmInternal; 00489 static void ConnectionAdd(vtkAlgorithm* producer, int producerPort, 00490 vtkAlgorithm* consumer, int consumerPort); 00491 static void ConnectionRemove(vtkAlgorithm* producer, int producerPort, 00492 vtkAlgorithm* consumer, int consumerPort); 00493 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port); 00494 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port); 00495 00496 private: 00497 vtkAlgorithm(const vtkAlgorithm&); // Not implemented. 00498 void operator=(const vtkAlgorithm&); // Not implemented. 00499 }; 00500 00501 #endif