1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAtom.cxx
5 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6 All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13 =========================================================================*/
14 #include "vtkAtom.h"
15
16 #include "vtkMolecule.h"
17 #include "vtkVector.h"
18 #include "vtkVectorOperators.h"
19
20 #include <cassert>
21
22 //----------------------------------------------------------------------------
vtkAtom(vtkMolecule * parent,vtkIdType id)23 vtkAtom::vtkAtom(vtkMolecule *parent, vtkIdType id)
24 : Molecule(parent), Id(id)
25 {
26 assert(parent != nullptr);
27 assert(id < parent->GetNumberOfAtoms());
28 }
29
30 //----------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)31 void vtkAtom::PrintSelf(ostream &os, vtkIndent indent)
32 {
33 os << indent << "Molecule: " << this->Molecule
34 << " Id: " << this->Id
35 << " Element: " << this->GetAtomicNumber()
36 << " Position: " << this->GetPosition() << endl;
37 }
38
39 //----------------------------------------------------------------------------
GetAtomicNumber() const40 unsigned short vtkAtom::GetAtomicNumber() const
41 {
42 return this->Molecule->GetAtomAtomicNumber(this->Id);
43 }
44
45 //----------------------------------------------------------------------------
SetAtomicNumber(unsigned short atomicNum)46 void vtkAtom::SetAtomicNumber(unsigned short atomicNum)
47 {
48 this->Molecule->SetAtomAtomicNumber(this->Id, atomicNum);
49 }
50
51 //----------------------------------------------------------------------------
GetPosition(float pos[3]) const52 void vtkAtom::GetPosition(float pos[3]) const
53 {
54 this->Molecule->GetAtomPosition(this->Id, pos);
55 }
56
57 //----------------------------------------------------------------------------
GetPosition(double pos[3]) const58 void vtkAtom::GetPosition(double pos[3]) const
59 {
60 vtkVector3f position = this->GetPosition();
61 pos[0] = position.GetX();
62 pos[1] = position.GetY();
63 pos[2] = position.GetZ();
64 }
65
66 //----------------------------------------------------------------------------
SetPosition(const float pos[3])67 void vtkAtom::SetPosition(const float pos[3])
68 {
69 this->Molecule->SetAtomPosition(this->Id, vtkVector3f(pos));
70 }
71
72 //----------------------------------------------------------------------------
SetPosition(float x,float y,float z)73 void vtkAtom::SetPosition(float x, float y, float z)
74 {
75 this->Molecule->SetAtomPosition(this->Id, x, y, z);
76 }
77
78 //----------------------------------------------------------------------------
GetPosition() const79 vtkVector3f vtkAtom::GetPosition() const
80 {
81 return this->Molecule->GetAtomPosition(this->Id);
82 }
83
84 //----------------------------------------------------------------------------
SetPosition(const vtkVector3f & pos)85 void vtkAtom::SetPosition(const vtkVector3f &pos)
86 {
87 this->Molecule->SetAtomPosition(this->Id, pos);
88 }
89