VTK
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 =========================================================================*/
72 #ifndef vtkMolecule_h
73 #define vtkMolecule_h
74 
75 #include "vtkCommonDataModelModule.h" // For export macro
76 #include "vtkUndirectedGraph.h"
77 #include "vtkSmartPointer.h" // For vtkSmartPointer
78 
79 #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
80 #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
81 
82 #include "vtkVector.h" // Small templated vector convenience class
83 
85 class vtkDataArray;
86 class vtkInformation;
88 class vtkMatrix3x3;
89 class vtkPlane;
90 class vtkPoints;
93 
94 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
95 {
96 public:
97  static vtkMolecule *New();
99  void PrintSelf(ostream &os, vtkIndent indent) override;
100  void Initialize() override;
101 
105  int GetDataObjectType() override {return VTK_MOLECULE;}
106 
112  {
113  return this->AppendAtom(0, vtkVector3f(0, 0, 0));
114  }
115 
120  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos);
121 
126  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
127  {
128  return this->AppendAtom(atomicNumber, vtkVector3f(x, y, z));
129  }
130 
135 
140 
142 
148  unsigned short order = 1);
149  vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2,
150  unsigned short order = 1)
151  {
152  return this->AppendBond(atom1.Id, atom2.Id, order);
153  }
155 
160 
165 
169  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
170 
175  unsigned short atomicNum);
176 
178 
181  void SetAtomPosition(vtkIdType atomId, const vtkVector3f &pos);
182  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
184 
186 
190  void GetAtomPosition(vtkIdType atomId, float pos[3]);
192 
194 
197  void SetBondOrder(vtkIdType bondId, unsigned short order);
198  unsigned short GetBondOrder(vtkIdType bondId);
200 
210  double GetBondLength(vtkIdType bondId);
211 
213 
220 
222 
225  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
228 
234  bool CheckedShallowCopy(vtkGraph *g) override;
235 
241  bool CheckedDeepCopy(vtkGraph *g) override;
242 
246  void ShallowCopy(vtkDataObject *obj) override;
247 
251  void DeepCopy(vtkDataObject *obj) override;
252 
257 
261  virtual void DeepCopyStructure(vtkMolecule *m);
262 
268 
273  virtual void DeepCopyAttributes(vtkMolecule *m);
274 
276 
303  static bool GetPlaneFromBond(const vtkBond &bond, const vtkVector3f &normal,
304  vtkPlane *plane);
305  static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2,
306  const vtkVector3f &normal, vtkPlane *plane);
308 
312  bool HasLattice();
313 
317  void ClearLattice();
318 
320 
324  void SetLattice(vtkMatrix3x3 *matrix);
325  void SetLattice(const vtkVector3d &a,
326  const vtkVector3d &b,
327  const vtkVector3d &c);
329 
337 
339 
344  vtkVector3d &origin);
346 
348 
351  vtkGetMacro(LatticeOrigin, vtkVector3d)
352  vtkSetMacro(LatticeOrigin, vtkVector3d)
354 
358  vtkUnsignedCharArray* GetAtomGhostArray();
359 
363  void AllocateAtomGhostArray();
364 
368  vtkUnsignedCharArray* GetBondGhostArray();
369 
373  void AllocateBondGhostArray();
374 
379  int Initialize(vtkPoints* atomPositions,
380  vtkDataArray* atomicNumberArray,
381  vtkDataSetAttributes* atomData);
382 
386  int Initialize(vtkPoints* atomPositions,
387  vtkDataSetAttributes* atomData)
388  {
389  return this->Initialize(atomPositions, nullptr, atomData);
390  }
391 
395  int Initialize(vtkMolecule* molecule);
396 
398 
404 
409  {
410  return this->GetVertexData();
411  }
412 
417  {
418  return this->GetEdgeData();
419  }
420 
425  {
426  return this->GetEdgeId(a, b);
427  }
428 
430 
433  vtkSetStringMacro(AtomicNumberArrayName);
434  vtkGetStringMacro(AtomicNumberArrayName);
436 
438 
441  vtkSetStringMacro(BondOrdersArrayName);
442  vtkGetStringMacro(BondOrdersArrayName);
444 
445  protected:
447  ~vtkMolecule() override;
448 
452  virtual void CopyStructureInternal(vtkMolecule *m, bool deep);
453 
457  virtual void CopyAttributesInternal(vtkMolecule *m, bool deep);
458 
460 
467  void SetBondListDirty() {this->BondListIsDirty = true;}
471 
472  friend class vtkAtom;
473  friend class vtkBond;
474 
478 
481 
484 
485 private:
486  vtkMolecule(const vtkMolecule&) = delete;
487  void operator=(const vtkMolecule&) = delete;
488 };
489 
490 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:40
vtkMolecule::GetAtomicPositionArray
vtkPoints * GetAtomicPositionArray()
Access the raw arrays used in this vtkMolecule instance.
VTK_MOLECULE
#define VTK_MOLECULE
Definition: vtkType.h:124
vtkPlane
perform various plane computations
Definition: vtkPlane.h:38
vtkMolecule::AppendAtom
vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
Convenience methods to append a new atom with the specified atomic number and position.
Definition: vtkMolecule.h:126
vtkUndirectedGraph
An undirected graph.
Definition: vtkUndirectedGraph.h:55
vtkMolecule::GetBondList
vtkIdTypeArray * GetBondList()
vtkMolecule::~vtkMolecule
~vtkMolecule() override
vtkMolecule::AppendAtom
vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos)
Add new atom with the specified atomic number and position.
vtkGraph::GetEdgeData
virtual vtkDataSetAttributes * GetEdgeData()
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:43
vtkGraph::Initialize
void Initialize() override
Initialize to an empty graph.
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:60
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:42
vtkUndirectedGraph.h
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:42
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)
vtkMolecule::GetAtomPosition
void GetAtomPosition(vtkIdType atomId, float pos[3])
vtkSmartPointer< vtkMatrix3x3 >
vtkVector.h
vtkMolecule::BondOrdersArrayName
char * BondOrdersArrayName
Definition: vtkMolecule.h:483
vtkMolecule::GetNumberOfBonds
vtkIdType GetNumberOfBonds()
Return the number of bonds in the molecule.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
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:34
vtkMatrix3x3
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:37
vtkMolecule::SetLattice
void SetLattice(const vtkVector3d &a, const vtkVector3d &b, const vtkVector3d &c)
vtkMolecule::GetBondId
vtkIdType GetBondId(vtkIdType a, vtkIdType b)
Return the edge id from the underlying graph.
Definition: vtkMolecule.h:424
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:466
vtkMolecule::AtomGhostArray
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:479
vtkAtom
convenience proxy for vtkMolecule
Definition: vtkAtom.h:35
vtkMolecule::GetBondOrdersArray
vtkUnsignedShortArray * GetBondOrdersArray()
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)
Definition: vtkMolecule.h:149
vtkMolecule::SetElectronicData
virtual void SetElectronicData(vtkAbstractElectronicData *)
vtkMolecule::GetBondData
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:416
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:408
vtkMolecule::UpdateBondList
void UpdateBondList()
vtkMolecule::SetLattice
void SetLattice(vtkMatrix3x3 *matrix)
The unit cell vectors.
vtkMolecule::ShallowCopyAttributes
virtual void ShallowCopyAttributes(vtkMolecule *m)
Shallow copies attributes (i.e.
vtkAbstractElectronicData
Provides access to and storage of chemical electronic data.
Definition: vtkAbstractElectronicData.h:34
vtkVector3f
Definition: vtkVector.h:453
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:40
vtkMolecule::CopyAttributesInternal
virtual void CopyAttributesInternal(vtkMolecule *m, bool deep)
Copy everything but bonds and 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)
vtkMolecule::LatticeOrigin
vtkVector3d LatticeOrigin
Definition: vtkMolecule.h:477
vtkMolecule::GetPlaneFromBond
static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2, const vtkVector3f &normal, vtkPlane *plane)
vtkMolecule
class describing a molecule
Definition: vtkMolecule.h:95
vtkMolecule::GetLattice
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c, vtkVector3d &origin)
vtkMolecule::BondGhostArray
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:480
vtkX3D::order
@ order
Definition: vtkX3D.h:440
vtkBond.h
vtkMolecule::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:105
vtkMolecule::GetBondOrder
unsigned short GetBondOrder(vtkIdType bondId)
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:87
vtkMolecule::DeepCopyStructure
virtual void DeepCopyStructure(vtkMolecule *m)
Deep copies the atoms and bonds from m into this.
vtkMolecule::AtomicNumberArrayName
char * AtomicNumberArrayName
Definition: vtkMolecule.h:482
vtkMolecule::GetBond
vtkBond GetBond(vtkIdType bondId)
Return a vtkAtom that refers to the bond with the specified id.
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkMolecule::Initialize
void Initialize() override
Initialize to an empty graph.
vtkMolecule::GetAtomicNumberArray
vtkUnsignedShortArray * GetAtomicNumberArray()
vtkMolecule::Lattice
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:476
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:42
vtkMolecule::vtkMolecule
vtkMolecule()
vtkMolecule::GetAtomPosition
vtkVector3f GetAtomPosition(vtkIdType atomId)
Get the position of the atom with the specified id.
vtkMolecule::SetBondListDirty
void SetBondListDirty()
Definition: vtkMolecule.h:467
vtkMolecule::SetBondOrder
void SetBondOrder(vtkIdType bondId, unsigned short order)
Get/Set the bond order of the bond with the specified id.
vtkMolecule::AppendAtom
vtkAtom AppendAtom()
Add new atom with atomic number 0 (dummy atom) at origin.
Definition: vtkMolecule.h:111
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:288
vtkAtom::Id
vtkIdType Id
Definition: vtkAtom.h:75
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:65
vtkMolecule::ElectronicData
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:475
vtkBond::vtkMolecule
friend class vtkMolecule
Definition: vtkBond.h:81
vtkMolecule::GetAtom
vtkAtom GetAtom(vtkIdType atomId)
Return a vtkAtom that refers to the atom with the specified id.
vtkVector3d
Definition: vtkVector.h:463
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).