1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkAssemblyPath.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkAssemblyPath 17 * @brief a list of nodes that form an assembly path 18 * 19 * vtkAssemblyPath represents an ordered list of assembly nodes that 20 * represent a fully evaluated assembly path. This class is used primarily 21 * for picking. Note that the use of this class is to add one or more 22 * assembly nodes to form the path. (An assembly node consists of an instance 23 * of vtkProp and vtkMatrix4x4, the matrix may be NULL.) As each node is 24 * added, the matrices are concatenated to create a final, evaluated matrix. 25 * 26 * @sa 27 * vtkAssemblyNode vtkAssembly vtkActor vtkMatrix4x4 vtkProp vtkAbstractPicker 28 */ 29 30 #ifndef vtkAssemblyPath_h 31 #define vtkAssemblyPath_h 32 33 #include "vtkRenderingCoreModule.h" // For export macro 34 #include "vtkCollection.h" 35 #include "vtkAssemblyNode.h" // used for inlines 36 37 class vtkMatrix4x4; 38 class vtkTransform; 39 class vtkProp; 40 41 class VTKRENDERINGCORE_EXPORT vtkAssemblyPath : public vtkCollection 42 { 43 public: 44 vtkTypeMacro(vtkAssemblyPath, vtkCollection); 45 void PrintSelf(ostream& os, vtkIndent indent) override; 46 47 /** 48 * Instantiate empty path with identify matrix. 49 */ 50 static vtkAssemblyPath *New(); 51 52 /** 53 * Convenience method adds a prop and matrix together, 54 * creating an assembly node transparently. The matrix 55 * pointer m may be NULL. Note: that matrix is the one, 56 * if any, associated with the prop. 57 */ 58 void AddNode(vtkProp *p, vtkMatrix4x4 *m); 59 60 /** 61 * Get the next assembly node in the list. The node returned 62 * contains a pointer to a prop and a 4x4 matrix. The matrix 63 * is evaluated based on the preceding assembly hierarchy 64 * (i.e., the matrix is not necessarily as the same as the 65 * one that was added with AddNode() because of the 66 * concatenation of matrices in the assembly hierarchy). 67 */ 68 vtkAssemblyNode *GetNextNode(); 69 70 /** 71 * Get the first assembly node in the list. See the comments for 72 * GetNextNode() regarding the contents of the returned node. (Note: This 73 * node corresponds to the vtkProp associated with the vtkRenderer. 74 */ 75 vtkAssemblyNode *GetFirstNode(); 76 77 /** 78 * Get the last assembly node in the list. See the comments 79 * for GetNextNode() regarding the contents of the returned node. 80 */ 81 vtkAssemblyNode *GetLastNode(); 82 83 /** 84 * Delete the last assembly node in the list. This is like 85 * a stack pop. 86 */ 87 void DeleteLastNode(); 88 89 /** 90 * Perform a shallow copy (reference counted) on the 91 * incoming path. 92 */ 93 void ShallowCopy(vtkAssemblyPath *path); 94 95 /** 96 * Override the standard GetMTime() to check for the modified times 97 * of the nodes in this path. 98 */ 99 vtkMTimeType GetMTime() override; 100 101 /** 102 * Reentrant safe way to get an object in a collection. Just pass the 103 * same cookie back and forth. 104 */ GetNextNode(vtkCollectionSimpleIterator & cookie)105 vtkAssemblyNode *GetNextNode(vtkCollectionSimpleIterator &cookie) 106 { return static_cast<vtkAssemblyNode *>(this->GetNextItemAsObject(cookie)); } 107 108 protected: 109 vtkAssemblyPath(); 110 ~vtkAssemblyPath() override; 111 112 void AddNode(vtkAssemblyNode *n); //Internal method adds assembly node 113 vtkTransform *Transform; //Used to perform matrix concatenation 114 vtkProp *TransformedProp; //A transformed prop used to do the rendering 115 116 private: 117 // hide the standard AddItem from the user and the compiler. AddItem(vtkObject * o)118 void AddItem(vtkObject *o) 119 { this->vtkCollection::AddItem(o); } 120 121 private: 122 vtkAssemblyPath(const vtkAssemblyPath&) = delete; 123 void operator=(const vtkAssemblyPath&) = delete; 124 }; 125 126 #endif 127