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
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
VTK_MOLECULE
#define VTK_MOLECULE
Definition: vtkType.h:124
vtkPlane
perform various plane computations
Definition: vtkPlane.h:37
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:54
vtkGraph::GetEdgeData
virtual vtkDataSetAttributes * GetEdgeData()
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:42
vtkGraph::Initialize
void Initialize() override
Initialize to an empty graph.
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:59
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkUndirectedGraph.h
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:41
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:483
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:54
vtkBond
convenience proxy for vtkMolecule
Definition: vtkBond.h:33
vtkMatrix3x3
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:36
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:34
vtkMolecule::AppendBond
vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2, unsigned short order=1)
Definition: vtkMolecule.h:149
vtkMolecule::GetBondData
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:416
vtkMolecule::GetAtomData
vtkDataSetAttributes * GetAtomData()
Return the VertexData of the underlying graph.
Definition: vtkMolecule.h:408
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:386
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:33
vtkVector3f
Definition: vtkVector.h:452
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:39
vtkSmartPointer.h
vtkMolecule::LatticeOrigin
vtkVector3d LatticeOrigin
Definition: vtkMolecule.h:477
vtkMolecule
class describing a molecule
Definition: vtkMolecule.h:94
vtkMolecule::BondGhostArray
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:480
vtkX3D::order
Definition: vtkX3D.h:440
vtkBond.h
vtkMolecule::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkMolecule.h:105
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkMolecule::AtomicNumberArrayName
char * AtomicNumberArrayName
Definition: vtkMolecule.h:482
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:476
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:41
vtkMolecule::SetBondListDirty
void SetBondListDirty()
Definition: vtkMolecule.h:467
vtkMolecule::AppendAtom
vtkAtom AppendAtom()
Add new atom with atomic number 0 (dummy atom) at origin.
Definition: vtkMolecule.h:111
vtkGraph
Base class for graph data types.
Definition: vtkGraph.h:287
vtkAtom::Id
vtkIdType Id
Definition: vtkAtom.h:75
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkMolecule::ElectronicData
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:475
vtkBond::vtkMolecule
friend class vtkMolecule
Definition: vtkBond.h:81
vtkUndirectedGraph::New
static vtkUndirectedGraph * New()
vtkVector3d
Definition: vtkVector.h:462
vtkAtom.h