VTK  9.3.20240302
vtkMolecule.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
60 #ifndef vtkMolecule_h
61 #define vtkMolecule_h
62 
63 #include "vtkCommonDataModelModule.h" // For export macro
64 #include "vtkSmartPointer.h" // For vtkSmartPointer
65 #include "vtkUndirectedGraph.h"
66 
67 #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
68 #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
69 
70 #include "vtkVector.h" // Small templated vector convenience class
71 
72 VTK_ABI_NAMESPACE_BEGIN
74 class vtkDataArray;
75 class vtkInformation;
77 class vtkMatrix3x3;
78 class vtkPlane;
79 class vtkPoints;
82 
83 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
84 {
85 public:
86  static vtkMolecule* New();
88  void PrintSelf(ostream& os, vtkIndent indent) override;
89  void Initialize() override;
90 
94  int GetDataObjectType() override { return VTK_MOLECULE; }
95 
100  vtkAtom AppendAtom() { return this->AppendAtom(0, 0., 0., 0.); }
101 
103 
107  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z);
108  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f& pos)
109  {
110  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
111  }
112 
113  vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
114  {
115  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
116  }
118 
123 
128 
130 
135  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2, unsigned short order = 1);
136  vtkBond AppendBond(const vtkAtom& atom1, const vtkAtom& atom2, unsigned short order = 1)
137  {
138  return this->AppendBond(atom1.Id, atom2.Id, order);
139  }
141 
146 
151 
155  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
156 
160  void SetAtomAtomicNumber(vtkIdType atomId, unsigned short atomicNum);
161 
163 
166  void SetAtomPosition(vtkIdType atomId, const vtkVector3f& pos);
167  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
168  void SetAtomPosition(vtkIdType atomId, double pos[3])
169  {
170  this->SetAtomPosition(atomId, pos[0], pos[1], pos[2]);
171  }
173 
175 
179  void GetAtomPosition(vtkIdType atomId, float pos[3]);
180  void GetAtomPosition(vtkIdType atomId, double pos[3]);
182 
184 
187  void SetBondOrder(vtkIdType bondId, unsigned short order);
188  unsigned short GetBondOrder(vtkIdType bondId);
190 
200  double GetBondLength(vtkIdType bondId);
201 
203 
210 
212 
215  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
218 
224  bool CheckedShallowCopy(vtkGraph* g) override;
225 
231  bool CheckedDeepCopy(vtkGraph* g) override;
232 
236  void ShallowCopy(vtkDataObject* obj) override;
237 
241  void DeepCopy(vtkDataObject* obj) override;
242 
247 
251  virtual void DeepCopyStructure(vtkMolecule* m);
252 
258 
263  virtual void DeepCopyAttributes(vtkMolecule* m);
264 
266 
293  static bool GetPlaneFromBond(const vtkBond& bond, const vtkVector3f& normal, vtkPlane* plane);
294  static bool GetPlaneFromBond(
295  const vtkAtom& atom1, const vtkAtom& atom2, const vtkVector3f& normal, vtkPlane* plane);
297 
301  bool HasLattice();
302 
306  void ClearLattice();
307 
309 
313  void SetLattice(vtkMatrix3x3* matrix);
314  void SetLattice(const vtkVector3d& a, const vtkVector3d& b, const vtkVector3d& c);
316 
324 
326 
332 
334 
337  vtkGetMacro(LatticeOrigin, vtkVector3d);
338  vtkSetMacro(LatticeOrigin, vtkVector3d);
340 
345 
350 
355 
360 
366  vtkPoints* atomPositions, vtkDataArray* atomicNumberArray, vtkDataSetAttributes* atomData);
367 
371  int Initialize(vtkPoints* atomPositions, vtkDataSetAttributes* atomData)
372  {
373  return this->Initialize(atomPositions, nullptr, atomData);
374  }
375 
379  int Initialize(vtkMolecule* molecule);
380 
382 
386  static vtkMolecule* GetData(vtkInformationVector* v, int i = 0);
388 
393 
398 
402  vtkIdType GetBondId(vtkIdType a, vtkIdType b) { return this->GetEdgeId(a, b); }
403 
405 
408  vtkSetStringMacro(AtomicNumberArrayName);
409  vtkGetStringMacro(AtomicNumberArrayName);
411 
413 
416  vtkSetStringMacro(BondOrdersArrayName);
417  vtkGetStringMacro(BondOrdersArrayName);
419 
427  unsigned long GetActualMemorySize() override;
428 
429 protected:
431  ~vtkMolecule() override;
432 
436  virtual void CopyStructureInternal(vtkMolecule* m, bool deep);
437 
441  virtual void CopyAttributesInternal(vtkMolecule* m, bool deep);
442 
444 
451  void SetBondListDirty() { this->BondListIsDirty = true; }
455 
456  friend class vtkAtom;
457  friend class vtkBond;
458 
462 
465 
468 
469 private:
470  vtkMolecule(const vtkMolecule&) = delete;
471  void operator=(const vtkMolecule&) = delete;
472 };
473 
474 VTK_ABI_NAMESPACE_END
475 #endif
Provides access to and storage of chemical electronic data.
convenience proxy for vtkMolecule
Definition: vtkAtom.h:24
vtkIdType Id
Definition: vtkAtom.h:64
convenience proxy for vtkMolecule
Definition: vtkBond.h:23
friend class vtkMolecule
Definition: vtkBond.h:70
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
general representation of visualization data
represent and manipulate attribute data in a dataset
Base class for graph data types.
Definition: vtkGraph.h:340
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:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:55
class describing a molecule
Definition: vtkMolecule.h:84
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:459
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:100
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:392
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:136
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:460
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:371
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:451
vtkIdType GetBondId(vtkIdType a, vtkIdType b)
Return the edge id from the underlying graph.
Definition: vtkMolecule.h:402
vtkUnsignedShortArray * GetAtomicNumberArray()
Access the raw arrays used in this vtkMolecule instance.
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:463
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c)
Get the unit cell lattice vectors, and optionally, the origin.
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:464
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:94
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:467
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:108
bool BondListIsDirty
The graph superclass does not provide fast random access to the edge (bond) data.
Definition: vtkMolecule.h:450
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:466
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:168
vtkIdType GetNumberOfAtoms()
Return the number of atoms in the molecule.
vtkVector3d LatticeOrigin
Definition: vtkMolecule.h:461
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:397
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:113
perform various plane computations
Definition: vtkPlane.h:135
represent and manipulate 3D points
Definition: vtkPoints.h:138
An undirected graph.
dynamic, self-adjusting array of unsigned char
dynamic, self-adjusting array of unsigned short
@ order
Definition: vtkX3D.h:440
@ info
Definition: vtkX3D.h:376
int vtkIdType
Definition: vtkType.h:315
#define VTK_MOLECULE
Definition: vtkType.h:98