VTK  9.2.20230527
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 =========================================================================*/
91 #ifndef vtkMolecule_h
92 #define vtkMolecule_h
93 
94 #include "vtkCommonDataModelModule.h" // For export macro
95 #include "vtkSmartPointer.h" // For vtkSmartPointer
96 #include "vtkUndirectedGraph.h"
97 
98 #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
99 #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
100 
101 #include "vtkVector.h" // Small templated vector convenience class
102 
103 VTK_ABI_NAMESPACE_BEGIN
105 class vtkDataArray;
106 class vtkInformation;
108 class vtkMatrix3x3;
109 class vtkPlane;
110 class vtkPoints;
113 
114 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
115 {
116 public:
117  static vtkMolecule* New();
119  void PrintSelf(ostream& os, vtkIndent indent) override;
120  void Initialize() override;
121 
125  int GetDataObjectType() override { return VTK_MOLECULE; }
126 
131  vtkAtom AppendAtom() { return this->AppendAtom(0, 0., 0., 0.); }
132 
134 
138  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z);
139  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f& pos)
140  {
141  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
142  }
143 
144  vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
145  {
146  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
147  }
149 
154 
159 
161 
166  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2, unsigned short order = 1);
167  vtkBond AppendBond(const vtkAtom& atom1, const vtkAtom& atom2, unsigned short order = 1)
168  {
169  return this->AppendBond(atom1.Id, atom2.Id, order);
170  }
172 
177 
182 
186  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
187 
191  void SetAtomAtomicNumber(vtkIdType atomId, unsigned short atomicNum);
192 
194 
197  void SetAtomPosition(vtkIdType atomId, const vtkVector3f& pos);
198  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
199  void SetAtomPosition(vtkIdType atomId, double pos[3])
200  {
201  this->SetAtomPosition(atomId, pos[0], pos[1], pos[2]);
202  }
204 
206 
210  void GetAtomPosition(vtkIdType atomId, float pos[3]);
211  void GetAtomPosition(vtkIdType atomId, double pos[3]);
213 
215 
218  void SetBondOrder(vtkIdType bondId, unsigned short order);
219  unsigned short GetBondOrder(vtkIdType bondId);
221 
231  double GetBondLength(vtkIdType bondId);
232 
234 
241 
243 
246  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
249 
255  bool CheckedShallowCopy(vtkGraph* g) override;
256 
262  bool CheckedDeepCopy(vtkGraph* g) override;
263 
267  void ShallowCopy(vtkDataObject* obj) override;
268 
272  void DeepCopy(vtkDataObject* obj) override;
273 
278 
282  virtual void DeepCopyStructure(vtkMolecule* m);
283 
289 
294  virtual void DeepCopyAttributes(vtkMolecule* m);
295 
297 
324  static bool GetPlaneFromBond(const vtkBond& bond, const vtkVector3f& normal, vtkPlane* plane);
325  static bool GetPlaneFromBond(
326  const vtkAtom& atom1, const vtkAtom& atom2, const vtkVector3f& normal, vtkPlane* plane);
328 
332  bool HasLattice();
333 
337  void ClearLattice();
338 
340 
344  void SetLattice(vtkMatrix3x3* matrix);
345  void SetLattice(const vtkVector3d& a, const vtkVector3d& b, const vtkVector3d& c);
347 
355 
357 
363 
365 
368  vtkGetMacro(LatticeOrigin, vtkVector3d);
369  vtkSetMacro(LatticeOrigin, vtkVector3d);
371 
376 
381 
386 
391 
397  vtkPoints* atomPositions, vtkDataArray* atomicNumberArray, vtkDataSetAttributes* atomData);
398 
402  int Initialize(vtkPoints* atomPositions, vtkDataSetAttributes* atomData)
403  {
404  return this->Initialize(atomPositions, nullptr, atomData);
405  }
406 
410  int Initialize(vtkMolecule* molecule);
411 
413 
417  static vtkMolecule* GetData(vtkInformationVector* v, int i = 0);
419 
424 
429 
433  vtkIdType GetBondId(vtkIdType a, vtkIdType b) { return this->GetEdgeId(a, b); }
434 
436 
439  vtkSetStringMacro(AtomicNumberArrayName);
440  vtkGetStringMacro(AtomicNumberArrayName);
442 
444 
447  vtkSetStringMacro(BondOrdersArrayName);
448  vtkGetStringMacro(BondOrdersArrayName);
450 
458  unsigned long GetActualMemorySize() override;
459 
460 protected:
462  ~vtkMolecule() override;
463 
467  virtual void CopyStructureInternal(vtkMolecule* m, bool deep);
468 
472  virtual void CopyAttributesInternal(vtkMolecule* m, bool deep);
473 
475 
482  void SetBondListDirty() { this->BondListIsDirty = true; }
486 
487  friend class vtkAtom;
488  friend class vtkBond;
489 
493 
496 
499 
500 private:
501  vtkMolecule(const vtkMolecule&) = delete;
502  void operator=(const vtkMolecule&) = delete;
503 };
504 
505 VTK_ABI_NAMESPACE_END
506 #endif
Provides access to and storage of chemical electronic data.
convenience proxy for vtkMolecule
Definition: vtkAtom.h:36
vtkIdType Id
Definition: vtkAtom.h:76
convenience proxy for vtkMolecule
Definition: vtkBond.h:35
friend class vtkMolecule
Definition: vtkBond.h:82
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:166
general representation of visualization data
represent and manipulate attribute data in a dataset
Base class for graph data types.
Definition: vtkGraph.h:346
virtual vtkDataSetAttributes * GetEdgeData()
Get the vertex or edge data.
void Initialize() override
Initialize to an empty graph.
virtual vtkDataSetAttributes * GetVertexData()
Get the vertex or edge data.
vtkIdType GetEdgeId(vtkIdType a, vtkIdType b)
Returns the Id of the edge between vertex a and vertex b.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:120
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:67
class describing a molecule
Definition: vtkMolecule.h:115
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:490
void GetAtomPosition(vtkIdType atomId, float pos[3])
Get the position of the atom with the specified id.
vtkAtom AppendAtom()
Add new atom with atomic number 0 (dummy atom) at origin.
Definition: vtkMolecule.h:131
vtkVector3f GetAtomPosition(vtkIdType atomId)
Get the position of the atom with the specified id.
vtkIdTypeArray * GetBondList()
The graph superclass does not provide fast random access to the edge (bond) data.
void SetLattice(vtkMatrix3x3 *matrix)
The unit cell vectors.
vtkDataSetAttributes * GetAtomData()
Return the VertexData of the underlying graph.
Definition: vtkMolecule.h:423
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int Initialize(vtkPoints *atomPositions, vtkDataArray *atomicNumberArray, vtkDataSetAttributes *atomData)
Initialize a molecule with an atom per input point.
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:167
void SetBondOrder(vtkIdType bondId, unsigned short order)
Get/Set the bond order of the bond with the specified id.
vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
Add new atom with the specified atomic number and position.
vtkAtom GetAtom(vtkIdType atomId)
Return a vtkAtom that refers to the atom with the specified id.
virtual void DeepCopyStructure(vtkMolecule *m)
Deep copies the atoms and bonds from m into this.
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c, vtkVector3d &origin)
Get the unit cell lattice vectors, and optionally, the origin.
void Initialize() override
Initialize to an empty graph.
void ClearLattice()
Remove any unit cell lattice information from the molecule.
vtkUnsignedCharArray * GetAtomGhostArray()
Get the array that defines the ghost type of each atom.
virtual void ShallowCopyAttributes(vtkMolecule *m)
Shallow copies attributes (i.e.
void SetAtomAtomicNumber(vtkIdType atomId, unsigned short atomicNum)
Set the atomic number of the atom with the specified id.
virtual void ShallowCopyStructure(vtkMolecule *m)
Shallow copies the atoms and bonds from m into this.
void GetAtomPosition(vtkIdType atomId, double pos[3])
Get the position of the atom with the specified id.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
double GetBondLength(vtkIdType bondId)
Get the bond length of the bond with the specified id.
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:491
virtual void DeepCopyAttributes(vtkMolecule *m)
Deep copies attributes (i.e.
static bool GetPlaneFromBond(const vtkBond &bond, const vtkVector3f &normal, vtkPlane *plane)
Obtain the plane that passes through the indicated bond with the given normal.
int Initialize(vtkPoints *atomPositions, vtkDataSetAttributes *atomData)
Overloads Initialize method.
Definition: vtkMolecule.h:402
void ShallowCopy(vtkDataObject *obj) override
Shallow copies the data object into this molecule.
vtkPoints * GetAtomicPositionArray()
Access the raw arrays used in this vtkMolecule instance.
void SetBondListDirty()
The graph superclass does not provide fast random access to the edge (bond) data.
Definition: vtkMolecule.h:482
vtkIdType GetBondId(vtkIdType a, vtkIdType b)
Return the edge id from the underlying graph.
Definition: vtkMolecule.h:433
vtkUnsignedShortArray * GetAtomicNumberArray()
Access the raw arrays used in this vtkMolecule instance.
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:494
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c)
Get the unit cell lattice vectors, and optionally, the origin.
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:495
void SetAtomPosition(vtkIdType atomId, double x, double y, double z)
Set the position of the atom with the specified id.
void UpdateBondList()
The graph superclass does not provide fast random access to the edge (bond) data.
virtual void CopyAttributesInternal(vtkMolecule *m, bool deep)
Copy everything but bonds and atoms.
void DeepCopy(vtkDataObject *obj) override
Deep copies the data object into this molecule.
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:125
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.
void AllocateAtomGhostArray()
Allocate ghost array for atoms.
void SetAtomPosition(vtkIdType atomId, const vtkVector3f &pos)
Set the position of the atom with the specified id.
virtual void SetElectronicData(vtkAbstractElectronicData *)
Set/Get the AbstractElectronicData-subclassed object for this molecule.
unsigned short GetAtomAtomicNumber(vtkIdType atomId)
Return the atomic number of the atom with the specified id.
vtkIdType GetNumberOfBonds()
Return the number of bonds in the molecule.
char * BondOrdersArrayName
Definition: vtkMolecule.h:498
bool HasLattice()
Return true if a unit cell lattice is defined.
~vtkMolecule() override
vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2, unsigned short order=1)
Add a bond between the specified atoms, optionally setting the bond order (default: 1).
void SetLattice(const vtkVector3d &a, const vtkVector3d &b, const vtkVector3d &c)
The unit cell vectors.
unsigned short GetBondOrder(vtkIdType bondId)
Get/Set the bond order of the bond with the specified id.
vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos)
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:139
bool BondListIsDirty
The graph superclass does not provide fast random access to the edge (bond) data.
Definition: vtkMolecule.h:481
vtkBond GetBond(vtkIdType bondId)
Return a vtkAtom that refers to the bond with the specified id.
static vtkMolecule * GetData(vtkInformationVector *v, int i=0)
Retrieve a molecule from an information vector.
int Initialize(vtkMolecule *molecule)
Use input molecule points, atomic number and atomic data to initialize the new molecule.
char * AtomicNumberArrayName
Definition: vtkMolecule.h:497
void AllocateBondGhostArray()
Allocate ghost array for bonds.
vtkUnsignedShortArray * GetBondOrdersArray()
Access the raw arrays used in this vtkMolecule instance.
virtual void CopyStructureInternal(vtkMolecule *m, bool deep)
Copy bonds and atoms.
static vtkMolecule * New()
static vtkMolecule * GetData(vtkInformation *info)
Retrieve a molecule from an information vector.
vtkUnsignedCharArray * GetBondGhostArray()
Get the array that defines the ghost type of each bond.
void SetAtomPosition(vtkIdType atomId, double pos[3])
Set the position of the atom with the specified id.
Definition: vtkMolecule.h:199
vtkIdType GetNumberOfAtoms()
Return the number of atoms in the molecule.
vtkVector3d LatticeOrigin
Definition: vtkMolecule.h:492
bool CheckedShallowCopy(vtkGraph *g) override
Performs the same operation as ShallowCopy(), but instead of reporting an error for an incompatible g...
bool CheckedDeepCopy(vtkGraph *g) override
Performs the same operation as DeepCopy(), but instead of reporting an error for an incompatible grap...
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:428
vtkMatrix3x3 * GetLattice()
Get the unit cell lattice vectors.
vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:144
perform various plane computations
Definition: vtkPlane.h:147
represent and manipulate 3D points
Definition: vtkPoints.h:150
An undirected graph.
dynamic, self-adjusting array of unsigned char
dynamic, self-adjusting array of unsigned short
@ order
Definition: vtkX3D.h:452
@ info
Definition: vtkX3D.h:388
int vtkIdType
Definition: vtkType.h:327
#define VTK_MOLECULE
Definition: vtkType.h:110