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 vtkDataArray;
83 class vtkInformation;
85 class vtkMatrix3x3;
86 class vtkPlane;
87 class vtkPoints;
90 
91 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
92 {
93 public:
94  static vtkMolecule *New();
96  void PrintSelf(ostream &os, vtkIndent indent) override;
97  void Initialize() override;
98 
102  int GetDataObjectType() override {return VTK_MOLECULE;}
103 
109  {
110  return this->AppendAtom(0, vtkVector3f(0, 0, 0));
111  }
112 
117  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos);
118 
123  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
124  {
125  return this->AppendAtom(atomicNumber, vtkVector3f(x, y, z));
126  }
127 
131  vtkAtom GetAtom(vtkIdType atomId);
132 
136  vtkIdType GetNumberOfAtoms();
137 
139 
144  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2,
145  unsigned short order = 1);
146  vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2,
147  unsigned short order = 1)
148  {
149  return this->AppendBond(atom1.Id, atom2.Id, order);
150  }
152 
156  vtkBond GetBond(vtkIdType bondId);
157 
161  vtkIdType GetNumberOfBonds();
162 
166  unsigned short GetAtomAtomicNumber(vtkIdType atomId);
167 
171  void SetAtomAtomicNumber(vtkIdType atomId,
172  unsigned short atomicNum);
173 
175 
178  void SetAtomPosition(vtkIdType atomId, const vtkVector3f &pos);
179  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
181 
183 
186  vtkVector3f GetAtomPosition(vtkIdType atomId);
187  void GetAtomPosition(vtkIdType atomId, float pos[3]);
189 
191 
194  void SetBondOrder(vtkIdType bondId, unsigned short order);
195  unsigned short GetBondOrder(vtkIdType bondId);
197 
207  double GetBondLength(vtkIdType bondId);
208 
210 
213  vtkPoints * GetAtomicPositionArray();
214  vtkUnsignedShortArray * GetAtomicNumberArray();
215  vtkUnsignedShortArray * GetBondOrdersArray();
217 
219 
222  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
223  virtual void SetElectronicData(vtkAbstractElectronicData*);
225 
231  bool CheckedShallowCopy(vtkGraph *g) override;
232 
238  bool CheckedDeepCopy(vtkGraph *g) override;
239 
243  void ShallowCopy(vtkDataObject *obj) override;
244 
248  void DeepCopy(vtkDataObject *obj) override;
249 
253  virtual void ShallowCopyStructure(vtkMolecule *m);
254 
258  virtual void DeepCopyStructure(vtkMolecule *m);
259 
264  virtual void ShallowCopyAttributes(vtkMolecule *m);
265 
270  virtual void DeepCopyAttributes(vtkMolecule *m);
271 
273 
300  static bool GetPlaneFromBond(const vtkBond &bond, const vtkVector3f &normal,
301  vtkPlane *plane);
302  static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2,
303  const vtkVector3f &normal, vtkPlane *plane);
305 
309  bool HasLattice();
310 
314  void ClearLattice();
315 
317 
321  void SetLattice(vtkMatrix3x3 *matrix);
322  void SetLattice(const vtkVector3d &a,
323  const vtkVector3d &b,
324  const vtkVector3d &c);
326 
333  vtkMatrix3x3* GetLattice();
334 
336 
339  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c);
340  void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c,
341  vtkVector3d &origin);
343 
345 
348  vtkGetMacro(LatticeOrigin, vtkVector3d)
349  vtkSetMacro(LatticeOrigin, vtkVector3d)
351 
355  vtkUnsignedCharArray* GetAtomGhostArray();
356 
360  void AllocateAtomGhostArray();
361 
365  vtkUnsignedCharArray* GetBondGhostArray();
366 
370  void AllocateBondGhostArray();
371 
376  int Initialize(vtkPoints* atomPositions,
377  vtkDataArray* atomicNumberArray,
378  vtkDataSetAttributes* atomData);
379 
383  int Initialize(vtkPoints* atomPositions,
384  vtkDataSetAttributes* atomData)
385  {
386  return this->Initialize(atomPositions, nullptr, atomData);
387  }
388 
392  int Initialize(vtkMolecule* molecule);
393 
395 
399  static vtkMolecule* GetData(vtkInformationVector *v, int i=0);
401 
406  {
407  return this->GetVertexData();
408  }
409 
414  {
415  return this->GetEdgeData();
416  }
417 
422  {
423  return this->GetEdgeId(a, b);
424  }
425 
427 
430  vtkSetStringMacro(AtomicNumberArrayName);
431  vtkGetStringMacro(AtomicNumberArrayName);
433 
435 
438  vtkSetStringMacro(BondOrdersArrayName);
439  vtkGetStringMacro(BondOrdersArrayName);
441 
442  protected:
443  vtkMolecule();
444  ~vtkMolecule() override;
445 
449  virtual void CopyStructureInternal(vtkMolecule *m, bool deep);
450 
454  virtual void CopyAttributesInternal(vtkMolecule *m, bool deep);
455 
457 
464  void SetBondListDirty() {this->BondListIsDirty = true;}
465  void UpdateBondList();
466  vtkIdTypeArray* GetBondList();
468 
469  friend class vtkAtom;
470  friend class vtkBond;
471 
475 
478 
481 
482 private:
483  vtkMolecule(const vtkMolecule&) = delete;
484  void operator=(const vtkMolecule&) = delete;
485 };
486 
487 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
VTK_MOLECULE
#define VTK_MOLECULE
Definition: vtkType.h:124
vtkPlane
perform various plane computations
Definition: vtkPlane.h:31
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:123
vtkUndirectedGraph
An undirected graph.
Definition: vtkUndirectedGraph.h:48
vtkGraph::GetEdgeData
virtual vtkDataSetAttributes * GetEdgeData()
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:39
vtkGraph::Initialize
void Initialize() override
Initialize to an empty graph.
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:53
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkUndirectedGraph.h
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkGraph::DeepCopy
void DeepCopy(vtkDataObject *obj) override
Deep copies the data object into this graph.
vtkSmartPointer< vtkMatrix3x3 >
vtkVector.h
vtkMolecule::BondOrdersArrayName
char * BondOrdersArrayName
Definition: vtkMolecule.h:480
vtkUndirectedGraph::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkBond
convenience proxy for vtkMolecule
Definition: vtkBond.h:30
vtkMatrix3x3
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:33
vtkMolecule::GetBondId
vtkIdType GetBondId(vtkIdType a, vtkIdType b)
Return the edge id from the underlying graph.
Definition: vtkMolecule.h:421
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:463
vtkMolecule::AtomGhostArray
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:476
vtkAtom
convenience proxy for vtkMolecule
Definition: vtkAtom.h:31
vtkMolecule::AppendBond
vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2, unsigned short order=1)
Definition: vtkMolecule.h:146
vtkMolecule::GetBondData
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:413
vtkMolecule::GetAtomData
vtkDataSetAttributes * GetAtomData()
Return the VertexData of the underlying graph.
Definition: vtkMolecule.h:405
vtkGraph::CheckedDeepCopy
virtual bool CheckedDeepCopy(vtkGraph *g)
Performs the same operation as DeepCopy(), but instead of reporting an error for an incompatible grap...
vtkMolecule::Initialize
int Initialize(vtkPoints *atomPositions, vtkDataSetAttributes *atomData)
Overloads Initialize method.
Definition: vtkMolecule.h:383
vtkGraph::CheckedShallowCopy
virtual bool CheckedShallowCopy(vtkGraph *g)
Performs the same operation as ShallowCopy(), but instead of reporting an error for an incompatible g...
vtkAbstractElectronicData
Provides access to and storage of chemical electronic data.
Definition: vtkAbstractElectronicData.h:30
vtkVector3f
Definition: vtkVector.h:449
vtkUndirectedGraph::GetData
static vtkUndirectedGraph * GetData(vtkInformation *info)
Retrieve a graph from an information vector.
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:33
vtkSmartPointer.h
vtkMolecule::LatticeOrigin
vtkVector3d LatticeOrigin
Definition: vtkMolecule.h:474
vtkMolecule
class describing a molecule
Definition: vtkMolecule.h:91
vtkMolecule::BondGhostArray
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:477
vtkX3D::order
Definition: vtkX3D.h:440
vtkBond.h
vtkMolecule::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:102
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkMolecule::AtomicNumberArrayName
char * AtomicNumberArrayName
Definition: vtkMolecule.h:479
vtkX3D::info
Definition: vtkX3D.h:376
vtkGraph::ShallowCopy
void ShallowCopy(vtkDataObject *obj) override
Shallow copies the data object into this graph.
vtkMolecule::Lattice
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:473
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:35
vtkMolecule::SetBondListDirty
void SetBondListDirty()
Definition: vtkMolecule.h:464
vtkMolecule::AppendAtom
vtkAtom AppendAtom()
Add new atom with atomic number 0 (dummy atom) at origin.
Definition: vtkMolecule.h:108
vtkGraph
Base class for graph data types.
Definition: vtkGraph.h:281
vtkAtom::Id
vtkIdType Id
Definition: vtkAtom.h:72
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkMolecule::ElectronicData
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:472
vtkBond::vtkMolecule
friend class vtkMolecule
Definition: vtkBond.h:78
vtkUndirectedGraph::New
static vtkUndirectedGraph * New()
vtkVector3d
Definition: vtkVector.h:459
vtkAtom.h