VTK  9.0.1
vtkMolecule.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMolecule.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 =========================================================================*/
69 #ifndef vtkMolecule_h
70 #define vtkMolecule_h
71 
72 #include "vtkCommonDataModelModule.h" // For export macro
73 #include "vtkSmartPointer.h" // For vtkSmartPointer
74 #include "vtkUndirectedGraph.h"
75 
76 #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
77 #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
78 
79 #include "vtkVector.h" // Small templated vector convenience class
80 
82 class vtkDataArray;
83 class vtkInformation;
85 class vtkMatrix3x3;
86 class vtkPlane;
87 class vtkPoints;
90 
91 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
92 {
93 public:
94  static vtkMolecule* New();
96  void PrintSelf(ostream& os, vtkIndent indent) override;
97  void Initialize() override;
98 
102  int GetDataObjectType() override { return VTK_MOLECULE; }
103 
108  vtkAtom AppendAtom() { return this->AppendAtom(0, 0., 0., 0.); }
109 
111 
115  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z);
116  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f& pos)
117  {
118  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
119  }
120 
121  vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
122  {
123  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
124  }
126 
130  vtkAtom GetAtom(vtkIdType atomId);
131 
135  vtkIdType GetNumberOfAtoms();
136 
138 
143  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2, unsigned short order = 1);
144  vtkBond AppendBond(const vtkAtom& atom1, const vtkAtom& atom2, unsigned short order = 1)
145  {
146  return this->AppendBond(atom1.Id, atom2.Id, order);
147  }
149 
153  vtkBond GetBond(vtkIdType bondId);
154 
158  vtkIdType GetNumberOfBonds();
159 
163  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
164 
168  void SetAtomAtomicNumber(vtkIdType atomId, unsigned short atomicNum);
169 
171 
174  void SetAtomPosition(vtkIdType atomId, const vtkVector3f& pos);
175  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
176  void SetAtomPosition(vtkIdType atomId, double pos[3])
177  {
178  this->SetAtomPosition(atomId, pos[0], pos[1], pos[2]);
179  }
181 
183 
186  vtkVector3f GetAtomPosition(vtkIdType atomId);
187  void GetAtomPosition(vtkIdType atomId, float pos[3]);
188  void GetAtomPosition(vtkIdType atomId, double pos[3]);
190 
192 
195  void SetBondOrder(vtkIdType bondId, unsigned short order);
196  unsigned short GetBondOrder(vtkIdType bondId);
198 
208  double GetBondLength(vtkIdType bondId);
209 
211 
214  vtkPoints* GetAtomicPositionArray();
215  vtkUnsignedShortArray* GetAtomicNumberArray();
216  vtkUnsignedShortArray* GetBondOrdersArray();
218 
220 
223  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
224  virtual void SetElectronicData(vtkAbstractElectronicData*);
226 
232  bool CheckedShallowCopy(vtkGraph* g) override;
233 
239  bool CheckedDeepCopy(vtkGraph* g) override;
240 
244  void ShallowCopy(vtkDataObject* obj) override;
245 
249  void DeepCopy(vtkDataObject* obj) override;
250 
254  virtual void ShallowCopyStructure(vtkMolecule* m);
255 
259  virtual void DeepCopyStructure(vtkMolecule* m);
260 
265  virtual void ShallowCopyAttributes(vtkMolecule* m);
266 
271  virtual void DeepCopyAttributes(vtkMolecule* m);
272 
274 
301  static bool GetPlaneFromBond(const vtkBond& bond, const vtkVector3f& normal, vtkPlane* plane);
302  static bool GetPlaneFromBond(
303  const vtkAtom& atom1, const vtkAtom& atom2, const vtkVector3f& normal, vtkPlane* plane);
305 
309  bool HasLattice();
310 
314  void ClearLattice();
315 
317 
321  void SetLattice(vtkMatrix3x3* matrix);
322  void SetLattice(const vtkVector3d& a, const vtkVector3d& b, const vtkVector3d& c);
324 
331  vtkMatrix3x3* GetLattice();
332 
334 
337  void GetLattice(vtkVector3d& a, vtkVector3d& b, vtkVector3d& c);
338  void GetLattice(vtkVector3d& a, vtkVector3d& b, vtkVector3d& c, vtkVector3d& origin);
340 
342 
345  vtkGetMacro(LatticeOrigin, vtkVector3d);
346  vtkSetMacro(LatticeOrigin, vtkVector3d);
348 
352  vtkUnsignedCharArray* GetAtomGhostArray();
353 
357  void AllocateAtomGhostArray();
358 
362  vtkUnsignedCharArray* GetBondGhostArray();
363 
367  void AllocateBondGhostArray();
368 
373  int Initialize(
374  vtkPoints* atomPositions, vtkDataArray* atomicNumberArray, vtkDataSetAttributes* atomData);
375 
379  int Initialize(vtkPoints* atomPositions, vtkDataSetAttributes* atomData)
380  {
381  return this->Initialize(atomPositions, nullptr, atomData);
382  }
383 
387  int Initialize(vtkMolecule* molecule);
388 
390 
394  static vtkMolecule* GetData(vtkInformationVector* v, int i = 0);
396 
401 
406 
410  vtkIdType GetBondId(vtkIdType a, vtkIdType b) { return this->GetEdgeId(a, b); }
411 
413 
416  vtkSetStringMacro(AtomicNumberArrayName);
417  vtkGetStringMacro(AtomicNumberArrayName);
419 
421 
424  vtkSetStringMacro(BondOrdersArrayName);
425  vtkGetStringMacro(BondOrdersArrayName);
427 
435  unsigned long GetActualMemorySize() override;
436 
437 protected:
438  vtkMolecule();
439  ~vtkMolecule() override;
440 
444  virtual void CopyStructureInternal(vtkMolecule* m, bool deep);
445 
449  virtual void CopyAttributesInternal(vtkMolecule* m, bool deep);
450 
452 
459  void SetBondListDirty() { this->BondListIsDirty = true; }
460  void UpdateBondList();
461  vtkIdTypeArray* GetBondList();
463 
464  friend class vtkAtom;
465  friend class vtkBond;
466 
470 
473 
476 
477 private:
478  vtkMolecule(const vtkMolecule&) = delete;
479  void operator=(const vtkMolecule&) = delete;
480 };
481 
482 #endif
static vtkUndirectedGraph * GetData(vtkInformation *info)
Retrieve a graph from an information vector.
vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:121
virtual bool CheckedDeepCopy(vtkGraph *g)
Performs the same operation as DeepCopy(), but instead of reporting an error for an incompatible grap...
vtkIdType Id
Definition: vtkAtom.h:72
Store vtkAlgorithm input/output information.
class describing a molecule
Definition: vtkMolecule.h:91
vtkIdType GetBondId(vtkIdType a, vtkIdType b)
Return the edge id from the underlying graph.
Definition: vtkMolecule.h:410
char * BondOrdersArrayName
Definition: vtkMolecule.h:475
vtkIdType GetEdgeId(vtkIdType a, vtkIdType b)
Returns the Id of the edge between vertex a and vertex b.
vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2, unsigned short order=1)
Add a bond between the specified atoms, optionally setting the bond order (default: 1)...
Definition: vtkMolecule.h:144
An undirected graph.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:338
static vtkUndirectedGraph * New()
Provides access to and storage of chemical electronic data.
Base class for graph data types.
Definition: vtkGraph.h:289
int Initialize(vtkPoints *atomPositions, vtkDataSetAttributes *atomData)
Overloads Initialize method.
Definition: vtkMolecule.h:379
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:471
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkDataSetAttributes * GetAtomData()
Return the VertexData of the underlying graph.
Definition: vtkMolecule.h:400
a simple class to control print indentation
Definition: vtkIndent.h:33
bool BondListIsDirty
The graph superclass does not provide fast random access to the edge (bond) data. ...
Definition: vtkMolecule.h:458
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
perform various plane computations
Definition: vtkPlane.h:31
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:405
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:472
represent and manipulate attribute data in a dataset
friend class vtkMolecule
Definition: vtkBond.h:78
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:102
void DeepCopy(vtkDataObject *obj) override
Deep copies the data object into this graph.
void ShallowCopy(vtkDataObject *obj) override
Shallow copies the data object into this graph.
vtkVector3d LatticeOrigin
Definition: vtkMolecule.h:469
dynamic, self-adjusting array of unsigned char
void SetBondListDirty()
The graph superclass does not provide fast random access to the edge (bond) data. ...
Definition: vtkMolecule.h:459
convenience proxy for vtkMolecule
Definition: vtkAtom.h:31
void SetAtomPosition(vtkIdType atomId, double pos[3])
Set the position of the atom with the specified id.
Definition: vtkMolecule.h:176
virtual bool CheckedShallowCopy(vtkGraph *g)
Performs the same operation as ShallowCopy(), but instead of reporting an error for an incompatible g...
char * AtomicNumberArrayName
Definition: vtkMolecule.h:474
virtual vtkDataSetAttributes * GetEdgeData()
Get the vertex or edge data.
void Initialize() override
Initialize to an empty graph.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAtom AppendAtom()
Add new atom with atomic number 0 (dummy atom) at origin.
Definition: vtkMolecule.h:108
Store zero or more vtkInformation instances.
convenience proxy for vtkMolecule
Definition: vtkBond.h:30
#define VTK_MOLECULE
Definition: vtkType.h:118
virtual vtkDataSetAttributes * GetVertexData()
Get the vertex or edge data.
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:33
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:468
general representation of visualization data
Definition: vtkDataObject.h:59
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:467
vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos)
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:116
dynamic, self-adjusting array of unsigned short