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 vtkMatrix3x3;
86 class vtkPlane;
87 class vtkPoints;
89 
90 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
91 {
92 public:
93  static vtkMolecule *New();
95  void PrintSelf(ostream &os, vtkIndent indent) override;
96  void Initialize() override;
97 
101  int GetDataObjectType() override {return VTK_MOLECULE;}
102 
108  {
109  return this->AppendAtom(0, vtkVector3f(0, 0, 0));
110  }
111 
116  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos);
117 
122  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
123  {
124  return this->AppendAtom(atomicNumber, vtkVector3f(x, y, z));
125  }
126 
130  vtkAtom GetAtom(vtkIdType atomId);
131 
135  vtkIdType GetNumberOfAtoms();
136 
138 
143  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2,
144  unsigned short order = 1);
145  vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2,
146  unsigned short order = 1)
147  {
148  return this->AppendBond(atom1.Id, atom2.Id, order);
149  }
151 
155  vtkBond GetBond(vtkIdType bondId);
156 
160  vtkIdType GetNumberOfBonds();
161 
165  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
166 
170  void SetAtomAtomicNumber(vtkIdType atomId,
171  unsigned short atomicNum);
172 
174 
177  void SetAtomPosition(vtkIdType atomId, const vtkVector3f &pos);
178  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
180 
182 
185  vtkVector3f GetAtomPosition(vtkIdType atomId);
186  void GetAtomPosition(vtkIdType atomId, float pos[3]);
188 
190 
193  void SetBondOrder(vtkIdType bondId, unsigned short order);
194  unsigned short GetBondOrder(vtkIdType bondId);
196 
206  double GetBondLength(vtkIdType bondId);
207 
209 
212  vtkPoints * GetAtomicPositionArray();
213  vtkUnsignedShortArray * GetAtomicNumberArray();
215 
217 
220  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
221  virtual void SetElectronicData(vtkAbstractElectronicData*);
223 
229  bool CheckedShallowCopy(vtkGraph *g) override;
230 
236  bool CheckedDeepCopy(vtkGraph *g) override;
237 
241  void ShallowCopy(vtkDataObject *obj) override;
242 
246  void DeepCopy(vtkDataObject *obj) override;
247 
251  virtual void ShallowCopyStructure(vtkMolecule *m);
252 
256  virtual void DeepCopyStructure(vtkMolecule *m);
257 
262  virtual void ShallowCopyAttributes(vtkMolecule *m);
263 
268  virtual void DeepCopyAttributes(vtkMolecule *m);
269 
271 
298  static bool GetPlaneFromBond(const vtkBond &bond, const vtkVector3f &normal,
299  vtkPlane *plane);
300  static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2,
301  const vtkVector3f &normal, vtkPlane *plane);
303 
307  bool HasLattice();
308 
312  void ClearLattice();
313 
315 
319  void SetLattice(vtkMatrix3x3 *matrix);
320  void SetLattice(const vtkVector3d &a,
321  const vtkVector3d &b,
322  const vtkVector3d &c);
324 
331  vtkMatrix3x3* GetLattice();
332 
334 
337  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c);
338  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c,
339  vtkVector3d &origin);
341 
343 
346  vtkGetMacro(LatticeOrigin, vtkVector3d)
347  vtkSetMacro(LatticeOrigin, vtkVector3d)
349 
350  protected:
351  vtkMolecule();
352  ~vtkMolecule() override;
353 
357  virtual void CopyStructureInternal(vtkMolecule *m, bool deep);
358 
362  virtual void CopyAttributesInternal(vtkMolecule *m, bool deep);
363 
365 
372  void SetBondListDirty() {this->BondListIsDirty = true;}
373  void UpdateBondList();
374  vtkIdTypeArray* GetBondList();
376 
377  friend class vtkAtom;
378  friend class vtkBond;
379 
383 
384 private:
385  vtkMolecule(const vtkMolecule&) = delete;
386  void operator=(const vtkMolecule&) = delete;
387 };
388 
389 #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:75
class describing a molecule
Definition: vtkMolecule.h:90
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:145
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:287
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:371
perform various plane computations
Definition: vtkPlane.h:37
friend class vtkMolecule
Definition: vtkBond.h:81
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:101
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:382
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:372
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...
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:107
convenience proxy for vtkMolecule
Definition: vtkBond.h:33
#define VTK_MOLECULE
Definition: vtkType.h:124
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:122
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:381
general representation of visualization data
Definition: vtkDataObject.h:64
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:380
dynamic, self-adjusting array of unsigned short