VTK  9.1.0
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 =========================================================================*/
88 #ifndef vtkMolecule_h
89 #define vtkMolecule_h
90 
91 #include "vtkCommonDataModelModule.h" // For export macro
92 #include "vtkSmartPointer.h" // For vtkSmartPointer
93 #include "vtkUndirectedGraph.h"
94 
95 #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
96 #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
97 
98 #include "vtkVector.h" // Small templated vector convenience class
99 
101 class vtkDataArray;
102 class vtkInformation;
104 class vtkMatrix3x3;
105 class vtkPlane;
106 class vtkPoints;
109 
110 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
111 {
112 public:
113  static vtkMolecule* New();
115  void PrintSelf(ostream& os, vtkIndent indent) override;
116  void Initialize() override;
117 
121  int GetDataObjectType() override { return VTK_MOLECULE; }
122 
127  vtkAtom AppendAtom() { return this->AppendAtom(0, 0., 0., 0.); }
128 
130 
134  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z);
135  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f& pos)
136  {
137  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
138  }
139 
140  vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
141  {
142  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
143  }
145 
150 
155 
157 
162  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2, unsigned short order = 1);
163  vtkBond AppendBond(const vtkAtom& atom1, const vtkAtom& atom2, unsigned short order = 1)
164  {
165  return this->AppendBond(atom1.Id, atom2.Id, order);
166  }
168 
173 
178 
182  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
183 
187  void SetAtomAtomicNumber(vtkIdType atomId, unsigned short atomicNum);
188 
190 
193  void SetAtomPosition(vtkIdType atomId, const vtkVector3f& pos);
194  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
195  void SetAtomPosition(vtkIdType atomId, double pos[3])
196  {
197  this->SetAtomPosition(atomId, pos[0], pos[1], pos[2]);
198  }
200 
202 
206  void GetAtomPosition(vtkIdType atomId, float pos[3]);
207  void GetAtomPosition(vtkIdType atomId, double pos[3]);
209 
211 
214  void SetBondOrder(vtkIdType bondId, unsigned short order);
215  unsigned short GetBondOrder(vtkIdType bondId);
217 
227  double GetBondLength(vtkIdType bondId);
228 
230 
237 
239 
242  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
245 
251  bool CheckedShallowCopy(vtkGraph* g) override;
252 
258  bool CheckedDeepCopy(vtkGraph* g) override;
259 
263  void ShallowCopy(vtkDataObject* obj) override;
264 
268  void DeepCopy(vtkDataObject* obj) override;
269 
274 
278  virtual void DeepCopyStructure(vtkMolecule* m);
279 
285 
290  virtual void DeepCopyAttributes(vtkMolecule* m);
291 
293 
320  static bool GetPlaneFromBond(const vtkBond& bond, const vtkVector3f& normal, vtkPlane* plane);
321  static bool GetPlaneFromBond(
322  const vtkAtom& atom1, const vtkAtom& atom2, const vtkVector3f& normal, vtkPlane* plane);
324 
328  bool HasLattice();
329 
333  void ClearLattice();
334 
336 
340  void SetLattice(vtkMatrix3x3* matrix);
341  void SetLattice(const vtkVector3d& a, const vtkVector3d& b, const vtkVector3d& c);
343 
351 
353 
359 
361 
364  vtkGetMacro(LatticeOrigin, vtkVector3d);
365  vtkSetMacro(LatticeOrigin, vtkVector3d);
367 
372 
377 
382 
387 
393  vtkPoints* atomPositions, vtkDataArray* atomicNumberArray, vtkDataSetAttributes* atomData);
394 
398  int Initialize(vtkPoints* atomPositions, vtkDataSetAttributes* atomData)
399  {
400  return this->Initialize(atomPositions, nullptr, atomData);
401  }
402 
406  int Initialize(vtkMolecule* molecule);
407 
409 
413  static vtkMolecule* GetData(vtkInformationVector* v, int i = 0);
415 
420 
425 
429  vtkIdType GetBondId(vtkIdType a, vtkIdType b) { return this->GetEdgeId(a, b); }
430 
432 
435  vtkSetStringMacro(AtomicNumberArrayName);
436  vtkGetStringMacro(AtomicNumberArrayName);
438 
440 
443  vtkSetStringMacro(BondOrdersArrayName);
444  vtkGetStringMacro(BondOrdersArrayName);
446 
454  unsigned long GetActualMemorySize() override;
455 
456 protected:
458  ~vtkMolecule() override;
459 
463  virtual void CopyStructureInternal(vtkMolecule* m, bool deep);
464 
468  virtual void CopyAttributesInternal(vtkMolecule* m, bool deep);
469 
471 
478  void SetBondListDirty() { this->BondListIsDirty = true; }
482 
483  friend class vtkAtom;
484  friend class vtkBond;
485 
489 
492 
495 
496 private:
497  vtkMolecule(const vtkMolecule&) = delete;
498  void operator=(const vtkMolecule&) = delete;
499 };
500 
501 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkMolecule::GetActualMemorySize
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkMolecule::GetAtomicPositionArray
vtkPoints * GetAtomicPositionArray()
Access the raw arrays used in this vtkMolecule instance.
VTK_MOLECULE
#define VTK_MOLECULE
Definition: vtkType.h:110
vtkPlane
perform various plane computations
Definition: vtkPlane.h:143
vtkMolecule::AppendAtom
vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
Add new atom with the specified atomic number and position.
vtkMolecule::GetBondGhostArray
vtkUnsignedCharArray * GetBondGhostArray()
Get the array that defines the ghost type of each bond.
vtkUndirectedGraph
An undirected graph.
Definition: vtkUndirectedGraph.h:88
vtkMolecule::GetBondList
vtkIdTypeArray * GetBondList()
The graph superclass does not provide fast random access to the edge (bond) data.
vtkMolecule::~vtkMolecule
~vtkMolecule() override
vtkMolecule::AppendAtom
vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos)
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:135
vtkGraph::GetEdgeData
virtual vtkDataSetAttributes * GetEdgeData()
Get the vertex or edge data.
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:40
vtkGraph::Initialize
void Initialize() override
Initialize to an empty graph.
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:170
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkMolecule::AppendAtom
vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:140
vtkUndirectedGraph.h
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:145
vtkMolecule::GetAtomAtomicNumber
unsigned short GetAtomAtomicNumber(vtkIdType atomId)
Return the atomic number of the atom with the specified id.
vtkMolecule::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMolecule::HasLattice
bool HasLattice()
Return true if a unit cell lattice is defined.
vtkMolecule::GetData
static vtkMolecule * GetData(vtkInformationVector *v, int i=0)
Retrieve a molecule from an information vector.
vtkMolecule::GetAtomPosition
void GetAtomPosition(vtkIdType atomId, float pos[3])
Get the position of the atom with the specified id.
vtkSmartPointer< vtkMatrix3x3 >
vtkVector.h
vtkMolecule::BondOrdersArrayName
char * BondOrdersArrayName
Definition: vtkMolecule.h:494
vtkMolecule::GetAtomPosition
void GetAtomPosition(vtkIdType atomId, double pos[3])
Get the position of the atom with the specified id.
vtkMolecule::GetNumberOfBonds
vtkIdType GetNumberOfBonds()
Return the number of bonds in the molecule.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkMolecule::CheckedShallowCopy
bool CheckedShallowCopy(vtkGraph *g) override
Performs the same operation as ShallowCopy(), but instead of reporting an error for an incompatible g...
vtkBond
convenience proxy for vtkMolecule
Definition: vtkBond.h:31
vtkMatrix3x3
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:63
vtkMolecule::SetLattice
void SetLattice(const vtkVector3d &a, const vtkVector3d &b, const vtkVector3d &c)
The unit cell vectors.
vtkMolecule::GetBondId
vtkIdType GetBondId(vtkIdType a, vtkIdType b)
Return the edge id from the underlying graph.
Definition: vtkMolecule.h:429
vtkGraph::GetVertexData
virtual vtkDataSetAttributes * GetVertexData()
Get the vertex or edge data.
vtkMolecule::BondListIsDirty
bool BondListIsDirty
The graph superclass does not provide fast random access to the edge (bond) data.
Definition: vtkMolecule.h:477
vtkMolecule::Initialize
int Initialize(vtkPoints *atomPositions, vtkDataArray *atomicNumberArray, vtkDataSetAttributes *atomData)
Initialize a molecule with an atom per input point.
vtkMolecule::AtomGhostArray
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:490
vtkAtom
convenience proxy for vtkMolecule
Definition: vtkAtom.h:32
vtkMolecule::GetBondOrdersArray
vtkUnsignedShortArray * GetBondOrdersArray()
Access the raw arrays used in this vtkMolecule instance.
vtkMolecule::ShallowCopyStructure
virtual void ShallowCopyStructure(vtkMolecule *m)
Shallow copies the atoms and bonds from m into this.
vtkMolecule::AppendBond
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:163
vtkMolecule::SetElectronicData
virtual void SetElectronicData(vtkAbstractElectronicData *)
Set/Get the AbstractElectronicData-subclassed object for this molecule.
vtkMolecule::GetBondData
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:424
vtkMolecule::DeepCopyAttributes
virtual void DeepCopyAttributes(vtkMolecule *m)
Deep copies attributes (i.e.
vtkMolecule::GetAtomData
vtkDataSetAttributes * GetAtomData()
Return the VertexData of the underlying graph.
Definition: vtkMolecule.h:419
vtkMolecule::UpdateBondList
void UpdateBondList()
The graph superclass does not provide fast random access to the edge (bond) data.
vtkMolecule::SetLattice
void SetLattice(vtkMatrix3x3 *matrix)
The unit cell vectors.
vtkMolecule::ShallowCopyAttributes
virtual void ShallowCopyAttributes(vtkMolecule *m)
Shallow copies attributes (i.e.
vtkMolecule::Initialize
int Initialize(vtkPoints *atomPositions, vtkDataSetAttributes *atomData)
Overloads Initialize method.
Definition: vtkMolecule.h:398
vtkAbstractElectronicData
Provides access to and storage of chemical electronic data.
Definition: vtkAbstractElectronicData.h:31
vtkVector3f
Definition: vtkVector.h:534
vtkMolecule::DeepCopy
void DeepCopy(vtkDataObject *obj) override
Deep copies the data object into this molecule.
vtkMolecule::ShallowCopy
void ShallowCopy(vtkDataObject *obj) override
Shallow copies the data object into this molecule.
vtkMolecule::GetLattice
vtkMatrix3x3 * GetLattice()
Get the unit cell lattice vectors.
vtkMolecule::CopyStructureInternal
virtual void CopyStructureInternal(vtkMolecule *m, bool deep)
Copy bonds and atoms.
vtkMolecule::CheckedDeepCopy
bool CheckedDeepCopy(vtkGraph *g) override
Performs the same operation as DeepCopy(), but instead of reporting an error for an incompatible grap...
vtkMolecule::GetPlaneFromBond
static bool GetPlaneFromBond(const vtkBond &bond, const vtkVector3f &normal, vtkPlane *plane)
Obtain the plane that passes through the indicated bond with the given normal.
vtkGraph::GetEdgeId
vtkIdType GetEdgeId(vtkIdType a, vtkIdType b)
Returns the Id of the edge between vertex a and vertex b.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkMolecule::CopyAttributesInternal
virtual void CopyAttributesInternal(vtkMolecule *m, bool deep)
Copy everything but bonds and atoms.
vtkMolecule::AllocateAtomGhostArray
void AllocateAtomGhostArray()
Allocate ghost array for atoms.
vtkMolecule::Initialize
int Initialize(vtkMolecule *molecule)
Use input molecule points, atomic number and atomic data to initialize the new molecule.
vtkMolecule::GetLattice
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c)
Get the unit cell lattice vectors, and optionally, the origin.
vtkSmartPointer.h
vtkMolecule::SetAtomAtomicNumber
void SetAtomAtomicNumber(vtkIdType atomId, unsigned short atomicNum)
Set the atomic number of the atom with the specified id.
vtkMolecule::SetAtomPosition
void SetAtomPosition(vtkIdType atomId, double x, double y, double z)
Set the position of the atom with the specified id.
vtkMolecule::LatticeOrigin
vtkVector3d LatticeOrigin
Definition: vtkMolecule.h:488
vtkMolecule::GetPlaneFromBond
static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2, const vtkVector3f &normal, vtkPlane *plane)
Obtain the plane that passes through the indicated bond with the given normal.
vtkMolecule::GetAtomGhostArray
vtkUnsignedCharArray * GetAtomGhostArray()
Get the array that defines the ghost type of each atom.
vtkMolecule::SetAtomPosition
void SetAtomPosition(vtkIdType atomId, double pos[3])
Set the position of the atom with the specified id.
Definition: vtkMolecule.h:195
vtkMolecule
class describing a molecule
Definition: vtkMolecule.h:111
vtkMolecule::GetLattice
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c, vtkVector3d &origin)
Get the unit cell lattice vectors, and optionally, the origin.
vtkMolecule::BondGhostArray
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:491
vtkX3D::order
@ order
Definition: vtkX3D.h:446
vtkBond.h
vtkMolecule::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:121
vtkMolecule::GetBondOrder
unsigned short GetBondOrder(vtkIdType bondId)
Get/Set the bond order of the bond with the specified id.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkMolecule::DeepCopyStructure
virtual void DeepCopyStructure(vtkMolecule *m)
Deep copies the atoms and bonds from m into this.
vtkMolecule::AtomicNumberArrayName
char * AtomicNumberArrayName
Definition: vtkMolecule.h:493
vtkMolecule::GetBond
vtkBond GetBond(vtkIdType bondId)
Return a vtkAtom that refers to the bond with the specified id.
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkMolecule::Initialize
void Initialize() override
Initialize to an empty graph.
vtkMolecule::GetAtomicNumberArray
vtkUnsignedShortArray * GetAtomicNumberArray()
Access the raw arrays used in this vtkMolecule instance.
vtkMolecule::Lattice
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:487
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:145
vtkMolecule::vtkMolecule
vtkMolecule()
vtkMolecule::GetAtomPosition
vtkVector3f GetAtomPosition(vtkIdType atomId)
Get the position of the atom with the specified id.
vtkMolecule::SetBondListDirty
void SetBondListDirty()
The graph superclass does not provide fast random access to the edge (bond) data.
Definition: vtkMolecule.h:478
vtkMolecule::SetBondOrder
void SetBondOrder(vtkIdType bondId, unsigned short order)
Get/Set the bond order of the bond with the specified id.
vtkMolecule::AllocateBondGhostArray
void AllocateBondGhostArray()
Allocate ghost array for bonds.
vtkMolecule::AppendAtom
vtkAtom AppendAtom()
Add new atom with atomic number 0 (dummy atom) at origin.
Definition: vtkMolecule.h:127
vtkMolecule::SetAtomPosition
void SetAtomPosition(vtkIdType atomId, const vtkVector3f &pos)
Set the position of the atom with the specified id.
vtkGraph
Base class for graph data types.
Definition: vtkGraph.h:339
vtkAtom::Id
vtkIdType Id
Definition: vtkAtom.h:72
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkMolecule::ElectronicData
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:486
vtkBond::vtkMolecule
friend class vtkMolecule
Definition: vtkBond.h:78
vtkMolecule::GetAtom
vtkAtom GetAtom(vtkIdType atomId)
Return a vtkAtom that refers to the atom with the specified id.
vtkVector3d
Definition: vtkVector.h:547
vtkMolecule::GetBondLength
double GetBondLength(vtkIdType bondId)
Get the bond length of the bond with the specified id.
vtkMolecule::New
static vtkMolecule * New()
vtkMolecule::GetNumberOfAtoms
vtkIdType GetNumberOfAtoms()
Return the number of atoms in the molecule.
vtkAtom.h
vtkMolecule::ClearLattice
void ClearLattice()
Remove any unit cell lattice information from the molecule.
vtkMolecule::GetData
static vtkMolecule * GetData(vtkInformation *info)
Retrieve a molecule from an information vector.
vtkMolecule::AppendBond
vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2, unsigned short order=1)
Add a bond between the specified atoms, optionally setting the bond order (default: 1).