VTK  9.2.6
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 "vtkSmartPointer.h" // For vtkSmartPointer
77 #include "vtkUndirectedGraph.h"
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 
111  vtkAtom AppendAtom() { return this->AppendAtom(0, 0., 0., 0.); }
112 
114 
118  vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z);
119  vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f& pos)
120  {
121  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
122  }
123 
124  vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
125  {
126  return this->AppendAtom(atomicNumber, pos[0], pos[1], pos[2]);
127  }
129 
133  vtkAtom GetAtom(vtkIdType atomId);
134 
138  vtkIdType GetNumberOfAtoms();
139 
141 
146  vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2, unsigned short order = 1);
147  vtkBond AppendBond(const vtkAtom& atom1, const vtkAtom& atom2, 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, unsigned short atomicNum);
172 
174 
177  void SetAtomPosition(vtkIdType atomId, const vtkVector3f& pos);
178  void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
179  void SetAtomPosition(vtkIdType atomId, double pos[3])
180  {
181  this->SetAtomPosition(atomId, pos[0], pos[1], pos[2]);
182  }
184 
186 
189  vtkVector3f GetAtomPosition(vtkIdType atomId);
190  void GetAtomPosition(vtkIdType atomId, float pos[3]);
191  void GetAtomPosition(vtkIdType atomId, double pos[3]);
193 
195 
198  void SetBondOrder(vtkIdType bondId, unsigned short order);
199  unsigned short GetBondOrder(vtkIdType bondId);
201 
211  double GetBondLength(vtkIdType bondId);
212 
214 
217  vtkPoints* GetAtomicPositionArray();
218  vtkUnsignedShortArray* GetAtomicNumberArray();
219  vtkUnsignedShortArray* GetBondOrdersArray();
221 
223 
226  vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
227  virtual void SetElectronicData(vtkAbstractElectronicData*);
229 
235  bool CheckedShallowCopy(vtkGraph* g) override;
236 
242  bool CheckedDeepCopy(vtkGraph* g) override;
243 
247  void ShallowCopy(vtkDataObject* obj) override;
248 
252  void DeepCopy(vtkDataObject* obj) override;
253 
257  virtual void ShallowCopyStructure(vtkMolecule* m);
258 
262  virtual void DeepCopyStructure(vtkMolecule* m);
263 
268  virtual void ShallowCopyAttributes(vtkMolecule* m);
269 
274  virtual void DeepCopyAttributes(vtkMolecule* m);
275 
277 
304  static bool GetPlaneFromBond(const vtkBond& bond, const vtkVector3f& normal, vtkPlane* plane);
305  static bool GetPlaneFromBond(
306  const vtkAtom& atom1, const vtkAtom& atom2, 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, const vtkVector3d& b, const vtkVector3d& c);
327 
334  vtkMatrix3x3* GetLattice();
335 
337 
340  void GetLattice(vtkVector3d& a, vtkVector3d& b, vtkVector3d& c);
341  void GetLattice(vtkVector3d& a, vtkVector3d& b, vtkVector3d& c, 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(
377  vtkPoints* atomPositions, vtkDataArray* atomicNumberArray, vtkDataSetAttributes* atomData);
378 
382  int Initialize(vtkPoints* atomPositions, vtkDataSetAttributes* atomData)
383  {
384  return this->Initialize(atomPositions, nullptr, atomData);
385  }
386 
390  int Initialize(vtkMolecule* molecule);
391 
393 
397  static vtkMolecule* GetData(vtkInformationVector* v, int i = 0);
399 
404 
409 
413  vtkIdType GetBondId(vtkIdType a, vtkIdType b) { return this->GetEdgeId(a, b); }
414 
416 
419  vtkSetStringMacro(AtomicNumberArrayName);
420  vtkGetStringMacro(AtomicNumberArrayName);
422 
424 
427  vtkSetStringMacro(BondOrdersArrayName);
428  vtkGetStringMacro(BondOrdersArrayName);
430 
438  unsigned long GetActualMemorySize() override;
439 
440 protected:
441  vtkMolecule();
442  ~vtkMolecule() override;
443 
447  virtual void CopyStructureInternal(vtkMolecule* m, bool deep);
448 
452  virtual void CopyAttributesInternal(vtkMolecule* m, bool deep);
453 
455 
462  void SetBondListDirty() { this->BondListIsDirty = true; }
463  void UpdateBondList();
464  vtkIdTypeArray* GetBondList();
466 
467  friend class vtkAtom;
468  friend class vtkBond;
469 
473 
476 
479 
480 private:
481  vtkMolecule(const vtkMolecule&) = delete;
482  void operator=(const vtkMolecule&) = delete;
483 };
484 
485 #endif
static vtkUndirectedGraph * GetData(vtkInformation *info)
Retrieve a graph from an information vector.
vtkAtom AppendAtom(unsigned short atomicNumber, double pos[3])
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:124
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:413
char * BondOrdersArrayName
Definition: vtkMolecule.h:478
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:147
An undirected graph.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:332
static vtkUndirectedGraph * New()
Provides access to and storage of chemical electronic data.
Base class for graph data types.
Definition: vtkGraph.h:295
int Initialize(vtkPoints *atomPositions, vtkDataSetAttributes *atomData)
Overloads Initialize method.
Definition: vtkMolecule.h:382
vtkUnsignedCharArray * AtomGhostArray
Definition: vtkMolecule.h:474
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkDataSetAttributes * GetAtomData()
Return the VertexData of the underlying graph.
Definition: vtkMolecule.h:403
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:461
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
perform various plane computations
Definition: vtkPlane.h:36
vtkDataSetAttributes * GetBondData()
Return the EdgeData of the underlying graph.
Definition: vtkMolecule.h:408
vtkUnsignedCharArray * BondGhostArray
Definition: vtkMolecule.h:475
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:472
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:462
convenience proxy for vtkMolecule
Definition: vtkAtom.h:34
void SetAtomPosition(vtkIdType atomId, double pos[3])
Set the position of the atom with the specified id.
Definition: vtkMolecule.h:179
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:477
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:110
virtual vtkDataSetAttributes * GetVertexData()
Get the vertex or edge data.
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:36
vtkSmartPointer< vtkMatrix3x3 > Lattice
Definition: vtkMolecule.h:471
general representation of visualization data
Definition: vtkDataObject.h:65
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkAbstractElectronicData * ElectronicData
Definition: vtkMolecule.h:470
vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos)
Add new atom with the specified atomic number and position.
Definition: vtkMolecule.h:119
dynamic, self-adjusting array of unsigned short