Commit ad5b329b authored by Marcus D. Hanwell's avatar Marcus D. Hanwell
Browse files

ENH: Simplify the vtkAtom API.

The underlying storage is float, and the Cast method can be used if a
double precision vector is required.

Change-Id: I46db3aae9dc365a7bcbf7517fde570e2ff54cddb
parent 33b7ffea
......@@ -39,8 +39,8 @@ bool MoleculeExampleCode1()
vtkBond b = mol->AppendBond(h1, h2, 1);
TEST(fabs(b.GetBondLength() - 1.0) < 1e-8);
TEST(h1.GetPositionAsVector3d().Compare(vtkVector3d(0.0, 0.0,-0.5), 1e-8));
TEST(h2.GetPositionAsVector3d().Compare(vtkVector3d(0.0, 0.0, 0.5), 1e-8));
TEST(h1.GetPosition().Compare(vtkVector3f(0.0, 0.0,-0.5), 1e-8));
TEST(h2.GetPosition().Compare(vtkVector3f(0.0, 0.0, 0.5), 1e-8));
TEST(h1.GetAtomicNumber() == 1);
TEST(h2.GetAtomicNumber() == 1);
......@@ -61,14 +61,14 @@ bool MoleculeExampleCode2()
vtkAtom h2 = mol->AppendAtom();
h2.SetAtomicNumber(1);
vtkVector3d displacement (0.0, 0.0, 1.0);
h2.SetPosition(h1.GetPositionAsVector3d() + displacement);
vtkVector3f displacement(0.0, 0.0, 1.0);
h2.SetPosition(h1.GetPosition() + displacement);
vtkBond b = mol->AppendBond(h1, h2, 1);
TEST(fabs(b.GetBondLength() - 1.0) < 1e-8);
TEST(h1.GetPositionAsVector3d().Compare(vtkVector3d(0.0, 0.0,-0.5), 1e-8));
TEST(h2.GetPositionAsVector3d().Compare(vtkVector3d(0.0, 0.0, 0.5), 1e-8));
TEST(h1.GetPosition().Compare(vtkVector3f(0.0, 0.0,-0.5), 1e-8));
TEST(h2.GetPosition().Compare(vtkVector3f(0.0, 0.0, 0.5), 1e-8));
TEST(h1.GetAtomicNumber() == 1);
TEST(h2.GetAtomicNumber() == 1);
......
......@@ -38,7 +38,7 @@ void vtkAtom::PrintSelf(ostream &os, vtkIndent indent)
os << indent << "Molecule: " << this->Molecule
<< " Id: " << this->Id
<< " Element: " << this->GetAtomicNumber()
<< " Position: " << this->GetPositionAsVector3f() << endl;
<< " Position: " << this->GetPosition() << endl;
}
//----------------------------------------------------------------------------
......@@ -84,7 +84,7 @@ void vtkAtom::SetPosition(float x, float y, float z)
}
//----------------------------------------------------------------------------
vtkVector3f vtkAtom::GetPositionAsVector3f()
vtkVector3f vtkAtom::GetPosition()
{
return this->Molecule->GetAtomPositionAsVector3f(this->Id);
}
......@@ -94,15 +94,3 @@ void vtkAtom::SetPosition(const vtkVector3f &pos)
{
this->Molecule->SetAtomPosition(this->Id, pos);
}
//----------------------------------------------------------------------------
vtkVector3d vtkAtom::GetPositionAsVector3d()
{
return this->Molecule->GetAtomPositionAsVector3d(this->Id);
}
//----------------------------------------------------------------------------
void vtkAtom::SetPosition(const vtkVector3d &pos)
{
this->Molecule->SetAtomPosition(this->Id, pos);
}
......@@ -57,10 +57,8 @@ class VTK_FILTERING_EXPORT vtkAtom
void GetPosition(float pos[3]);
void SetPosition(const float pos[3]);
void SetPosition(float x, float y, float z);
vtkVector3f GetPositionAsVector3f();
vtkVector3f GetPosition();
void SetPosition(const vtkVector3f &pos);
vtkVector3d GetPositionAsVector3d();
void SetPosition(const vtkVector3d &pos);
protected:
friend class vtkMolecule;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment