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 =========================================================================*/
69 #ifndef vtkMolecule_h
70 #define vtkMolecule_h
71 
72 #include "vtkCommonDataModelModule.h" // For export macro
73 #include "vtkUndirectedGraph.h"
74 #include "vtkSmartPointer.h" // For vtkSmartPointer
75 
76 #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
77 #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
78 
79 #include "vtkVector.h" // Small templated vector convenience class
80 
82 class vtkMatrix3x3;
83 class vtkPlane;
84 class vtkPoints;
86 
87 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
88 {
89 public:
90  static vtkMolecule *New();
92  void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE;
93  void Initialize() VTK_OVERRIDE;
94 
98  int GetDataObjectType() VTK_OVERRIDE {return VTK_MOLECULE;}
99 
105  {
106  return this->AppendAtom(0, vtkVector3f(0, 0, 0));
107  }
108 
113  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos);
114 
119  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
120  {
121  return this->AppendAtom(atomicNumber, vtkVector3f(x, y, z));
122  }
123 
127  vtkAtom GetAtom(vtkIdType atomId);
128 
132  vtkIdType GetNumberOfAtoms();
133 
135 
140  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2,
141  unsigned short order = 1);
142  vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2,
143  unsigned short order = 1)
144  {
145  return this->AppendBond(atom1.Id, atom2.Id, order);
146  }
148 
152  vtkBond GetBond(vtkIdType bondId);
153 
157  vtkIdType GetNumberOfBonds();
158 
162  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
163 
167  void SetAtomAtomicNumber(vtkIdType atomId,
168  unsigned short atomicNum);
169 
171 
174  void SetAtomPosition(vtkIdType atomId, const vtkVector3f &pos);
175  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
177 
179 
182  vtkVector3f GetAtomPosition(vtkIdType atomId);
183  void GetAtomPosition(vtkIdType atomId, float pos[3]);
185 
187 
190  void SetBondOrder(vtkIdType bondId, unsigned short order);
191  unsigned short GetBondOrder(vtkIdType bondId);
193 
203  double GetBondLength(vtkIdType bondId);
204 
206 
209  vtkPoints * GetAtomicPositionArray();
210  vtkUnsignedShortArray * GetAtomicNumberArray();
212 
214 
217  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
218  virtual void SetElectronicData(vtkAbstractElectronicData*);
220 
226  bool CheckedShallowCopy(vtkGraph *g) VTK_OVERRIDE;
227 
233  bool CheckedDeepCopy(vtkGraph *g) VTK_OVERRIDE;
234 
238  void ShallowCopy(vtkDataObject *obj) VTK_OVERRIDE;
239 
243  void DeepCopy(vtkDataObject *obj) VTK_OVERRIDE;
244 
248  virtual void ShallowCopyStructure(vtkMolecule *m);
249 
253  virtual void DeepCopyStructure(vtkMolecule *m);
254 
259  virtual void ShallowCopyAttributes(vtkMolecule *m);
260 
265  virtual void DeepCopyAttributes(vtkMolecule *m);
266 
268 
295  static bool GetPlaneFromBond(const vtkBond &bond, const vtkVector3f &normal,
296  vtkPlane *plane);
297  static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2,
298  const vtkVector3f &normal, vtkPlane *plane);
300 
304  bool HasLattice();
305 
309  void ClearLattice();
310 
312 
316  void SetLattice(vtkMatrix3x3 *matrix);
317  void SetLattice(const vtkVector3d &a,
318  const vtkVector3d &b,
319  const vtkVector3d &c);
321 
328  vtkMatrix3x3* GetLattice();
329 
331 
334  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c);
335  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c,
336  vtkVector3d &origin);
338 
340 
343  vtkGetMacro(LatticeOrigin, vtkVector3d)
344  vtkSetMacro(LatticeOrigin, vtkVector3d)
346 
347  protected:
348  vtkMolecule();
349  ~vtkMolecule() VTK_OVERRIDE;
350 
354  virtual void CopyStructureInternal(vtkMolecule *m, bool deep);
355 
359  virtual void CopyAttributesInternal(vtkMolecule *m, bool deep);
360 
362 
369  void SetBondListDirty() {this->BondListIsDirty = true;}
370  void UpdateBondList();
371  vtkIdTypeArray* GetBondList();
373 
374  friend class vtkAtom;
375  friend class vtkBond;
376 
380 
381 private:
382  vtkMolecule(const vtkMolecule&) VTK_DELETE_FUNCTION;
383  void operator=(const vtkMolecule&) VTK_DELETE_FUNCTION;
384 };
385 
386 #endif
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:72
class describing a molecule
Definition: vtkMolecule.h:87
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:142
An undirected graph.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
static vtkUndirectedGraph * New()
Provides access to and storage of chemical electronic data.
Base class for graph data types.
Definition: vtkGraph.h:281
a simple class to control print indentation
Definition: vtkIndent.h:33
bool BondListIsDirty
The graph superclass does not provide fast random access to the edge (bond) data. ...
Definition: vtkMolecule.h:368
perform various plane computations
Definition: vtkPlane.h:31
friend class vtkMolecule
Definition: vtkBond.h:78
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:379
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetBondListDirty()
The graph superclass does not provide fast random access to the edge (bond) data. ...
Definition: vtkMolecule.h:369
convenience proxy for vtkMolecule
Definition: vtkAtom.h:31
virtual bool CheckedShallowCopy(vtkGraph *g)
Performs the same operation as ShallowCopy(), but instead of reporting an error for an incompatible g...
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:104
convenience proxy for vtkMolecule
Definition: vtkBond.h:30
#define VTK_MOLECULE
Definition: vtkType.h:124
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:33
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:119
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:378
general representation of visualization data
Definition: vtkDataObject.h:58
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:377
dynamic, self-adjusting array of unsigned short