VTK
dox/Common/DataModel/vtkMolecule.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMolecule.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00071 #ifndef __vtkMolecule_h
00072 #define __vtkMolecule_h
00073 
00074 #include "vtkCommonDataModelModule.h" // For export macro
00075 #include "vtkUndirectedGraph.h"
00076 
00077 //BTX
00078 #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
00079 #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
00080 //ETX
00081 #include "vtkVector.h" // Small templated vector convenience class
00082 
00083 class vtkPlane;
00084 class vtkAbstractElectronicData;
00085 class vtkPoints;
00086 class vtkUnsignedShortArray;
00087 
00088 class VTKCOMMONDATAMODEL_EXPORT vtkMolecule : public vtkUndirectedGraph
00089 {
00090 public:
00091   static vtkMolecule *New();
00092   vtkTypeMacro(vtkMolecule,vtkUndirectedGraph);
00093   void PrintSelf(ostream &os, vtkIndent indent);
00094   virtual void Initialize();
00095 
00097   virtual int GetDataObjectType() {return VTK_MOLECULE;}
00098 
00099 //BTX
00101 
00103   vtkAtom AppendAtom()
00104   {
00105     return this->AppendAtom(0, vtkVector3f(0, 0, 0));
00106   }
00108 
00111   vtkAtom AppendAtom(unsigned short atomicNumber, const vtkVector3f &pos);
00112 
00114 
00116   vtkAtom AppendAtom(unsigned short atomicNumber, double x, double y, double z)
00117   {
00118     return this->AppendAtom(atomicNumber, vtkVector3f(x, y, z));
00119   }
00121 
00123   vtkAtom GetAtom(vtkIdType atomId);
00124 
00126   vtkIdType GetNumberOfAtoms();
00127 
00129 
00132   vtkBond AppendBond(vtkIdType atom1, vtkIdType atom2,
00133                      unsigned short order = 1);
00134   vtkBond AppendBond(const vtkAtom &atom1, const vtkAtom &atom2,
00135                      unsigned short order = 1)
00136   {
00137     return this->AppendBond(atom1.Id, atom2.Id, order);
00138   }
00140 
00142 
00143   vtkBond GetBond(vtkIdType bondId);
00144 //ETX
00146 
00148   vtkIdType GetNumberOfBonds();
00149 
00151   unsigned short GetAtomAtomicNumber(vtkIdType atomId);
00152 
00154 
00155   void SetAtomAtomicNumber(vtkIdType atomId,
00156                            unsigned short atomicNum);
00158 
00160 
00161   void SetAtomPosition(vtkIdType atomId, const vtkVector3f &pos);
00162   void SetAtomPosition(vtkIdType atomId, double x, double y, double z);
00164 
00166 
00167   vtkVector3f GetAtomPosition(vtkIdType atomId);
00168   void GetAtomPosition(vtkIdType atomId, float pos[3]);
00170 
00172 
00173   void SetBondOrder(vtkIdType bondId, unsigned short order);
00174   unsigned short GetBondOrder(vtkIdType bondId);
00176 
00182   double GetBondLength(vtkIdType bondId);
00183 
00185 
00186   vtkPoints * GetAtomicPositionArray();
00187   vtkUnsignedShortArray * GetAtomicNumberArray();
00189 
00190 //BTX
00192 
00194   vtkGetObjectMacro(ElectronicData, vtkAbstractElectronicData);
00195   virtual void SetElectronicData(vtkAbstractElectronicData*);
00196 //ETX
00198 
00200   virtual void ShallowCopy(vtkDataObject *obj);
00201 
00203   virtual void DeepCopy(vtkDataObject *obj);
00204 
00206   virtual void ShallowCopyStructure(vtkMolecule *m);
00207 
00209   virtual void DeepCopyStructure(vtkMolecule *m);
00210 
00213   virtual void ShallowCopyAttributes(vtkMolecule *m);
00214 
00217   virtual void DeepCopyAttributes(vtkMolecule *m);
00218 
00220 
00233   static bool GetPlaneFromBond(const vtkBond &bond, const vtkVector3f &normal,
00234                                vtkPlane *plane);
00235   static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2,
00236                                const vtkVector3f &normal, vtkPlane *plane);
00238 
00239  protected:
00240   vtkMolecule();
00241   ~vtkMolecule();
00242 
00244   virtual void CopyStructureInternal(vtkMolecule *m, bool deep);
00245 
00247   virtual void CopyAttributesInternal(vtkMolecule *m, bool deep);
00248 
00250 
00254   bool BondListIsDirty;
00255   void SetBondListDirty() {this->BondListIsDirty = true;}
00256   void UpdateBondList();
00258 
00259   friend class vtkAtom;
00260   friend class vtkBond;
00261 
00262   vtkAbstractElectronicData *ElectronicData;
00263 
00264 private:
00265   vtkMolecule(const vtkMolecule&);    // Not implemented.
00266   void operator=(const vtkMolecule&); // Not implemented.
00267 };
00268 
00269 #endif