1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*=========================================================================
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"
#include "vtkVectorOperators.h"
#include <cassert>
//----------------------------------------------------------------------------
vtkAtom::vtkAtom(vtkMolecule *parent, vtkIdType id)
: Molecule(parent), Id(id)
{
assert(parent != 0);
assert(id < parent->GetNumberOfAtoms());
}
//----------------------------------------------------------------------------
void vtkAtom::PrintSelf(ostream &os, vtkIndent indent)
{
os << indent << "Molecule: " << this->Molecule
<< " Id: " << this->Id
<< " Element: " << this->GetAtomicNumber()
<< " Position: " << this->GetPosition() << endl;
}
//----------------------------------------------------------------------------
unsigned short vtkAtom::GetAtomicNumber() const
{
return this->Molecule->GetAtomAtomicNumber(this->Id);
}
//----------------------------------------------------------------------------
void vtkAtom::SetAtomicNumber(unsigned short atomicNum)
{
this->Molecule->SetAtomAtomicNumber(this->Id, atomicNum);
}
//----------------------------------------------------------------------------
void vtkAtom::GetPosition(float pos[3]) const
{
this->Molecule->GetAtomPosition(this->Id, pos);
}
//----------------------------------------------------------------------------
void vtkAtom::GetPosition(double pos[3]) const
{
vtkVector3f position = this->GetPosition();
pos[0] = position.GetX();
pos[1] = position.GetY();
pos[2] = position.GetZ();
}
//----------------------------------------------------------------------------
void vtkAtom::SetPosition(const float pos[3])
{
this->Molecule->SetAtomPosition(this->Id, vtkVector3f(pos));
}
//----------------------------------------------------------------------------
void vtkAtom::SetPosition(float x, float y, float z)
{
this->Molecule->SetAtomPosition(this->Id, x, y, z);
}
//----------------------------------------------------------------------------
vtkVector3f vtkAtom::GetPosition() const
{
return this->Molecule->GetAtomPosition(this->Id);
}
//----------------------------------------------------------------------------
void vtkAtom::SetPosition(const vtkVector3f &pos)
{
this->Molecule->SetAtomPosition(this->Id, pos);
}
|