vtkAtom.cxx 2.73 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*=========================================================================

Program:   Visualization Toolkit
Module:    vtkAtom.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkAtom.h"

#include "vtkMolecule.h"
#include "vtkVector.h"
18
#include "vtkVectorOperators.h"
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#include <assert.h>

//----------------------------------------------------------------------------
vtkAtom::vtkAtom(vtkMolecule *parent, vtkIdType id)
  : Molecule(parent), Id(id)
{
  assert(parent != 0);
  assert(id < parent->GetNumberOfAtoms());
}

//----------------------------------------------------------------------------
void vtkAtom::PrintSelf(ostream &os, vtkIndent indent)
{
33
34
35
  os << indent << "Molecule: " << this->Molecule
     << " Id: " << this->Id
     << " Element: " << this->GetAtomicNumber()
36
     << " Position: " << this->GetPosition() << endl;
37
38
39
}

//----------------------------------------------------------------------------
40
unsigned short vtkAtom::GetAtomicNumber() const
41
42
43
44
45
46
47
48
49
50
51
{
  return this->Molecule->GetAtomAtomicNumber(this->Id);
}

//----------------------------------------------------------------------------
void vtkAtom::SetAtomicNumber(unsigned short atomicNum)
{
  this->Molecule->SetAtomAtomicNumber(this->Id, atomicNum);
}

//----------------------------------------------------------------------------
52
void vtkAtom::GetPosition(float pos[3]) const
53
{
54
  this->Molecule->GetAtomPosition(this->Id, pos);
55
56
57
}

//----------------------------------------------------------------------------
58
void vtkAtom::GetPosition(double pos[3]) const
59
{
60
  vtkVector3f position = this->GetPosition();
61
62
63
  pos[0] = position.GetX();
  pos[1] = position.GetY();
  pos[2] = position.GetZ();
64
65
66
67
68
}

//----------------------------------------------------------------------------
void vtkAtom::SetPosition(const float pos[3])
{
69
  this->Molecule->SetAtomPosition(this->Id, vtkVector3f(pos));
70
71
72
73
74
75
76
77
78
}

//----------------------------------------------------------------------------
void vtkAtom::SetPosition(float x, float y, float z)
{
  this->Molecule->SetAtomPosition(this->Id, x, y, z);
}

//----------------------------------------------------------------------------
79
vtkVector3f vtkAtom::GetPosition() const
80
{
81
  return this->Molecule->GetAtomPosition(this->Id);
82
83
84
85
86
87
88
}

//----------------------------------------------------------------------------
void vtkAtom::SetPosition(const vtkVector3f &pos)
{
  this->Molecule->SetAtomPosition(this->Id, pos);
}