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 
134  vtkAtom GetAtom(vtkIdType atomId);
135 
139  vtkIdType GetNumberOfAtoms();
140 
142 
147  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2,
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 
159  vtkBond GetBond(vtkIdType bondId);
160 
164  vtkIdType GetNumberOfBonds();
165 
169  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
170 
174  void SetAtomAtomicNumber(vtkIdType atomId,
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 
189  vtkVector3f GetAtomPosition(vtkIdType atomId);
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 
216  vtkPoints * GetAtomicPositionArray();
217  vtkUnsignedShortArray * GetAtomicNumberArray();
218  vtkUnsignedShortArray * GetBondOrdersArray();
220 
222 
225  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
226  virtual void SetElectronicData(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 
256  virtual void ShallowCopyStructure(vtkMolecule *m);
257 
261  virtual void DeepCopyStructure(vtkMolecule *m);
262 
267  virtual void ShallowCopyAttributes(vtkMolecule *m);
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 
336  vtkMatrix3x3* GetLattice();
337 
339 
342  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c);
343  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c,
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 
402  static vtkMolecule* GetData(vtkInformationVector *v, int i=0);
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:
446  vtkMolecule();
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;}
468  void UpdateBondList();
469  vtkIdTypeArray* GetBondList();
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
static vtkUndirectedGraph * GetData(vtkInformation *info)
Retrieve a graph from an information vector.
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:75
Store vtkAlgorithm input/output information.
class describing a molecule
Definition: vtkMolecule.h:94
vtkIdType GetBondId(vtkIdType a, vtkIdType b)
Return the edge id from the underlying graph.
Definition: vtkMolecule.h:424
char * BondOrdersArrayName
Definition: vtkMolecule.h:483
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:149
An undirected graph.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:347
static vtkUndirectedGraph * New()
Provides access to and storage of chemical electronic data.
Base class for graph data types.
Definition: vtkGraph.h:287
int Initialize(vtkPoints *atomPositions, vtkDataSetAttributes *atomData)
Overloads Initialize method.
Definition: vtkMolecule.h:386
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:479
vtkDataSetAttributes * GetAtomData()
Return the VertexData of the underlying graph.
Definition: vtkMolecule.h:408
a simple class to control print indentation
Definition: vtkIndent.h:39
bool BondListIsDirty
The graph superclass does not provide fast random access to the edge (bond) data. ...
Definition: vtkMolecule.h:466
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
perform various plane computations
Definition: vtkPlane.h:37
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:416
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:480
represent and manipulate attribute data in a dataset
friend class vtkMolecule
Definition: vtkBond.h:81
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:105
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:477
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:467
convenience proxy for vtkMolecule
Definition: vtkAtom.h:34
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:482
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:111
Store zero or more vtkInformation instances.
convenience proxy for vtkMolecule
Definition: vtkBond.h:33
#define VTK_MOLECULE
Definition: vtkType.h:124
virtual vtkDataSetAttributes * GetVertexData()
Get the vertex or edge data.
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:36
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
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:476
general representation of visualization data
Definition: vtkDataObject.h:64
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:475
dynamic, self-adjusting array of unsigned short