Commit dbae27c5 authored by David Lonie's avatar David Lonie Committed by Kitware Robot
Browse files

Merge topic 'VASP-animate-reader'

01d22529 Make internal dependency private for Domains/Chemistry -> vtksys.
4ab52591 Update baselines.
7b1dc68d Update PDB+Shadows+DOF+SSAA test.
69bb2b15 Allow vtkMoleculeMapper's color array to be changed.
3cc2b845 Add vtkCountFaces filter.
af47eacd Extend vtkCellIterator::GetNumberOfFaces for non-polyhedra.
2b788633 Add VASPTessellationReader for NPT_Z_TESSELLATE.out files.
9838dcfa

 Add VASPAnimationReader to read NPT_Z_ANIMATE.out files.
...
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1874
parents 62ab1089 01d22529
Pipeline #23853 failed with stage
in 0 seconds
...@@ -115,7 +115,8 @@ public: ...@@ -115,7 +115,8 @@ public:
vtkPoints *GetPoints(); vtkPoints *GetPoints();
// Description: // Description:
// Get the faces for a polyhedral cell. // Get the faces for a polyhedral cell. This is only valid when CellType
// is VTK_POLYHEDRON.
vtkIdList *GetFaces(); vtkIdList *GetFaces();
// Description: // Description:
...@@ -130,7 +131,7 @@ public: ...@@ -130,7 +131,7 @@ public:
vtkIdType GetNumberOfPoints(); vtkIdType GetNumberOfPoints();
// Description: // Description:
// Return the number of faces in the current polyhedral cell. // Return the number of faces in the current cell.
// This should only be called when IsDoneWithTraversal() returns false. // This should only be called when IsDoneWithTraversal() returns false.
vtkIdType GetNumberOfFaces(); vtkIdType GetNumberOfFaces();
...@@ -277,12 +278,82 @@ inline vtkIdType vtkCellIterator::GetNumberOfPoints() ...@@ -277,12 +278,82 @@ inline vtkIdType vtkCellIterator::GetNumberOfPoints()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
inline vtkIdType vtkCellIterator::GetNumberOfFaces() inline vtkIdType vtkCellIterator::GetNumberOfFaces()
{ {
if (!this->CheckCache(FacesFlag)) switch (this->GetCellType())
{ {
this->FetchFaces(); case VTK_EMPTY_CELL:
this->SetCache(FacesFlag); case VTK_VERTEX:
case VTK_POLY_VERTEX:
case VTK_LINE:
case VTK_POLY_LINE:
case VTK_TRIANGLE:
case VTK_TRIANGLE_STRIP:
case VTK_POLYGON:
case VTK_PIXEL:
case VTK_QUAD:
case VTK_QUADRATIC_EDGE:
case VTK_QUADRATIC_TRIANGLE:
case VTK_QUADRATIC_QUAD:
case VTK_QUADRATIC_POLYGON:
case VTK_BIQUADRATIC_QUAD:
case VTK_QUADRATIC_LINEAR_QUAD:
case VTK_BIQUADRATIC_TRIANGLE:
case VTK_CUBIC_LINE:
case VTK_CONVEX_POINT_SET:
case VTK_PARAMETRIC_CURVE:
case VTK_PARAMETRIC_SURFACE:
case VTK_PARAMETRIC_TRI_SURFACE:
case VTK_PARAMETRIC_QUAD_SURFACE:
case VTK_HIGHER_ORDER_EDGE:
case VTK_HIGHER_ORDER_TRIANGLE:
case VTK_HIGHER_ORDER_QUAD:
case VTK_HIGHER_ORDER_POLYGON:
return 0;
case VTK_TETRA:
case VTK_QUADRATIC_TETRA:
case VTK_PARAMETRIC_TETRA_REGION:
case VTK_HIGHER_ORDER_TETRAHEDRON:
return 4;
case VTK_PYRAMID:
case VTK_QUADRATIC_PYRAMID:
case VTK_HIGHER_ORDER_PYRAMID:
case VTK_WEDGE:
case VTK_QUADRATIC_WEDGE:
case VTK_QUADRATIC_LINEAR_WEDGE:
case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
case VTK_HIGHER_ORDER_WEDGE:
return 5;
case VTK_VOXEL:
case VTK_HEXAHEDRON:
case VTK_QUADRATIC_HEXAHEDRON:
case VTK_TRIQUADRATIC_HEXAHEDRON:
case VTK_HIGHER_ORDER_HEXAHEDRON:
case VTK_PARAMETRIC_HEX_REGION:
case VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON:
return 6;
case VTK_PENTAGONAL_PRISM:
return 7;
case VTK_HEXAGONAL_PRISM:
return 8;
case VTK_POLYHEDRON: // Need to look these up
if (!this->CheckCache(FacesFlag))
{
this->FetchFaces();
this->SetCache(FacesFlag);
}
return this->Faces->GetNumberOfIds() != 0 ? this->Faces->GetId(0) : 0;
default:
vtkGenericWarningMacro("Unknown cell type: " << this->CellType);
break;
} }
return this->Faces->GetNumberOfIds() != 0 ? this->Faces->GetId(0) : 0;
return 0;
} }
#endif //vtkCellIterator_h #endif //vtkCellIterator_h
...@@ -17,6 +17,7 @@ PURPOSE. See the above copyright notice for more information. ...@@ -17,6 +17,7 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkDataSetAttributes.h" #include "vtkDataSetAttributes.h"
#include "vtkEdgeListIterator.h" #include "vtkEdgeListIterator.h"
#include "vtkIdTypeArray.h" #include "vtkIdTypeArray.h"
#include "vtkMatrix3x3.h"
#include "vtkNew.h" #include "vtkNew.h"
#include "vtkObjectFactory.h" #include "vtkObjectFactory.h"
#include "vtkPlane.h" #include "vtkPlane.h"
...@@ -33,10 +34,10 @@ vtkStandardNewMacro(vtkMolecule); ...@@ -33,10 +34,10 @@ vtkStandardNewMacro(vtkMolecule);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
vtkMolecule::vtkMolecule() vtkMolecule::vtkMolecule()
: ElectronicData(NULL),
Lattice(NULL),
LatticeOrigin(0., 0., 0.)
{ {
vtkPoints *points = vtkPoints::New();
this->SetPoints(points);
points->Delete();
this->Initialize(); this->Initialize();
} }
...@@ -57,7 +58,9 @@ void vtkMolecule::Initialize() ...@@ -57,7 +58,9 @@ void vtkMolecule::Initialize()
vertData->SetScalars(atomicNums.GetPointer()); vertData->SetScalars(atomicNums.GetPointer());
// Nuclear coordinates // Nuclear coordinates
this->Points->Initialize(); vtkPoints *points = vtkPoints::New();
this->SetPoints(points);
points->Delete();
// Setup edge data // Setup edge data
vtkDataSetAttributes *edgeData = this->GetEdgeData(); vtkDataSetAttributes *edgeData = this->GetEdgeData();
...@@ -71,7 +74,7 @@ void vtkMolecule::Initialize() ...@@ -71,7 +74,7 @@ void vtkMolecule::Initialize()
this->UpdateBondList(); this->UpdateBondList();
// Electronic data // Electronic data
this->ElectronicData = NULL; this->SetElectronicData(NULL);
this->Modified(); this->Modified();
} }
...@@ -102,6 +105,19 @@ void vtkMolecule::PrintSelf(ostream &os, vtkIndent indent) ...@@ -102,6 +105,19 @@ void vtkMolecule::PrintSelf(ostream &os, vtkIndent indent)
this->GetBond(i).PrintSelf(os, subIndent); this->GetBond(i).PrintSelf(os, subIndent);
} }
os << indent << "Lattice:\n";
if (this->HasLattice())
{
double *m = this->Lattice->GetData();
os << subIndent << "a: " << m[0] << " " << m[3] << " " << m[6] << "\n";
os << subIndent << "b: " << m[1] << " " << m[4] << " " << m[7] << "\n";
os << subIndent << "c: " << m[2] << " " << m[5] << " " << m[8] << "\n";
os << subIndent << "origin: "
<< this->LatticeOrigin[0] << " "
<< this->LatticeOrigin[1] << " "
<< this->LatticeOrigin[2] << "\n";
}
os << indent << "Electronic Data:\n"; os << indent << "Electronic Data:\n";
if (this->ElectronicData) if (this->ElectronicData)
{ {
...@@ -388,6 +404,26 @@ void vtkMolecule::CopyStructureInternal(vtkMolecule *m, bool deep) ...@@ -388,6 +404,26 @@ void vtkMolecule::CopyStructureInternal(vtkMolecule *m, bool deep)
{ {
this->Superclass::ShallowCopy(m); this->Superclass::ShallowCopy(m);
} }
if (!m->HasLattice())
{
this->ClearLattice();
}
else
{
if (deep)
{
vtkNew<vtkMatrix3x3> newLattice;
newLattice->DeepCopy(m->Lattice);
this->SetLattice(newLattice.Get());
}
else
{
this->SetLattice(m->Lattice);
}
this->LatticeOrigin = m->LatticeOrigin;
}
this->BondListIsDirty = true; this->BondListIsDirty = true;
} }
...@@ -472,3 +508,115 @@ bool vtkMolecule::GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2, ...@@ -472,3 +508,115 @@ bool vtkMolecule::GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2,
plane->SetNormal(realNormal.Cast<double>().GetData()); plane->SetNormal(realNormal.Cast<double>().GetData());
return true; return true;
} }
//------------------------------------------------------------------------------
bool vtkMolecule::HasLattice()
{
return this->Lattice.Get() != NULL;
}
//------------------------------------------------------------------------------
void vtkMolecule::ClearLattice()
{
this->SetLattice(NULL);
}
//------------------------------------------------------------------------------
void vtkMolecule::SetLattice(vtkMatrix3x3 *matrix)
{
if (!matrix)
{
if (this->Lattice)
{
// If we're clearing a matrix, zero out the origin:
this->LatticeOrigin = vtkVector3d(0., 0., 0.);
this->Lattice = NULL;
this->Modified();
}
}
else if (this->Lattice != matrix)
{
this->Lattice = matrix;
this->Modified();
}
}
//------------------------------------------------------------------------------
void vtkMolecule::SetLattice(const vtkVector3d &a, const vtkVector3d &b,
const vtkVector3d &c)
{
if (this->Lattice.Get() == NULL)
{
this->Lattice.TakeReference(vtkMatrix3x3::New());
this->Modified();
}
double *mat = this->Lattice->GetData();
if (mat[0] != a[0] || mat[1] != b[0] || mat[2] != c[0] ||
mat[3] != a[1] || mat[4] != b[1] || mat[5] != c[1] ||
mat[6] != a[2] || mat[7] != b[2] || mat[8] != c[2])
{
mat[0] = a[0];
mat[1] = b[0];
mat[2] = c[0];
mat[3] = a[1];
mat[4] = b[1];
mat[5] = c[1];
mat[6] = a[2];
mat[7] = b[2];
mat[8] = c[2];
this->Modified();
}
}
//------------------------------------------------------------------------------
vtkMatrix3x3 *vtkMolecule::GetLattice()
{
return this->Lattice.Get();
}
//------------------------------------------------------------------------------
void vtkMolecule::GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c)
{
if (this->Lattice)
{
double *mat = this->Lattice->GetData();
a[0] = mat[0];
a[1] = mat[3];
a[2] = mat[6];
b[0] = mat[1];
b[1] = mat[4];
b[2] = mat[7];
c[0] = mat[2];
c[1] = mat[5];
c[2] = mat[8];
}
else
{
a = b = c = vtkVector3d(0., 0., 0.);
}
}
//------------------------------------------------------------------------------
void vtkMolecule::GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c,
vtkVector3d &origin)
{
if (this->Lattice)
{
double *mat = this->Lattice->GetData();
a[0] = mat[0];
a[1] = mat[3];
a[2] = mat[6];
b[0] = mat[1];
b[1] = mat[4];
b[2] = mat[7];
c[0] = mat[2];
c[1] = mat[5];
c[2] = mat[8];
origin = this->LatticeOrigin;
}
else
{
a = b = c = origin = vtkVector3d(0., 0., 0.);
}
}
...@@ -68,14 +68,16 @@ ...@@ -68,14 +68,16 @@
#include "vtkCommonDataModelModule.h" // For export macro #include "vtkCommonDataModelModule.h" // For export macro
#include "vtkUndirectedGraph.h" #include "vtkUndirectedGraph.h"
#include "vtkSmartPointer.h" // For vtkSmartPointer
#include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule #include "vtkAtom.h" // Simple proxy class dependent on vtkMolecule
#include "vtkBond.h" // Simple proxy class dependent on vtkMolecule #include "vtkBond.h" // Simple proxy class dependent on vtkMolecule
#include "vtkVector.h" // Small templated vector convenience class #include "vtkVector.h" // Small templated vector convenience class
class vtkPlane;
class vtkAbstractElectronicData; class vtkAbstractElectronicData;
class vtkMatrix3x3;
class vtkPlane;
class vtkPoints; class vtkPoints;
class vtkUnsignedShortArray; class vtkUnsignedShortArray;
...@@ -253,6 +255,40 @@ public: ...@@ -253,6 +255,40 @@ public:
static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2, static bool GetPlaneFromBond(const vtkAtom &atom1, const vtkAtom &atom2,
const vtkVector3f &normal, vtkPlane *plane); const vtkVector3f &normal, vtkPlane *plane);
// Description:
// Return true if a unit cell lattice is defined.
bool HasLattice();
// Description:
// Remove any unit cell lattice information from the molecule.
void ClearLattice();
// Description:
// The unit cell vectors. The matrix is stored using a row-major layout, with
// the vectors encoded as columns.
void SetLattice(vtkMatrix3x3 *matrix);
void SetLattice(const vtkVector3d &a,
const vtkVector3d &b,
const vtkVector3d &c);
// Description:
// Get the unit cell lattice vectors. The matrix is stored using a row-major
// layout, with the vectors encoded as columns. Will return NULL if no
// unit cell information is available.
// @sa GetLatticeOrigin
vtkMatrix3x3* GetLattice();
// Description:
// Get the unit cell lattice vectors, and optionally, the origin.
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c);
void GetLattice(vtkVector3d &a, vtkVector3d &b, vtkVector3d &c,
vtkVector3d &origin);
// Description:
// Get the unit cell origin (for rendering purposes).
vtkGetMacro(LatticeOrigin, vtkVector3d)
vtkSetMacro(LatticeOrigin, vtkVector3d)
protected: protected:
vtkMolecule(); vtkMolecule();
~vtkMolecule(); ~vtkMolecule();
...@@ -279,6 +315,8 @@ public: ...@@ -279,6 +315,8 @@ public:
friend class vtkBond; friend class vtkBond;
vtkAbstractElectronicData *ElectronicData; vtkAbstractElectronicData *ElectronicData;
vtkSmartPointer<vtkMatrix3x3> Lattice;
vtkVector3d LatticeOrigin;
private: private:
vtkMolecule(const vtkMolecule&) VTK_DELETE_FUNCTION; vtkMolecule(const vtkMolecule&) VTK_DELETE_FUNCTION;
......
...@@ -24,7 +24,13 @@ ...@@ -24,7 +24,13 @@
#include "vtkTimerLog.h" #include "vtkTimerLog.h"
#include "vtkMath.h"
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <stdarg.h> // Needed for ... #include <stdarg.h> // Needed for ...
#include <vector>
#ifndef _WIN32 #ifndef _WIN32
#include <climits> // for CLK_TCK #include <climits> // for CLK_TCK
...@@ -412,6 +418,104 @@ void vtkTimerLog::DumpLogWithIndents(ostream *os, double threshold) ...@@ -412,6 +418,104 @@ void vtkTimerLog::DumpLogWithIndents(ostream *os, double threshold)
#endif #endif
} }
//----------------------------------------------------------------------------
void vtkTimerLog::DumpLogWithIndentsAndPercentages(std::ostream *os)
{
assert(os);
// Use indents to pair start/end events. Indents work like this:
// Indent | Event
// ------ | -----
// 0 | Event 1 Start
// 1 | SubEvent 1 Start
// 2 | SubEvent 1 End
// 1 | SubEvent 2 Start
// 2 | SubSubEvent 1 Start
// 3 | SubSubEvent 1 End
// 2 | SubEvent 2 End
// 1 | Event 1 End
// If we've wrapped the entry buffer, the indent information will be
// nonsensical. I don't trust the parsing logic below to not do bizarre,
// possibly crashy things in this case, so let's just error out and let the
// dev know how to fix the issue.
if (vtkTimerLog::WrapFlag)
{
*os << "Error: Event log has exceeded vtkTimerLog::MaxEntries.\n"
"Call vtkTimerLog::SetMaxEntries to increase the log buffer size.\n"
"Current vtkTimerLog::MaxEntries: " << vtkTimerLog::MaxEntries
<< ".\n";
return;
}
// Store previous 'scopes' in a LIFO buffer
typedef std::pair<int, double> IndentTime;
std::vector<IndentTime> parentInfo;
// Find the longest event string:
int numEvents = vtkTimerLog::GetNumberOfEvents();
int longestString = 0;
for (int i = 0; i < numEvents; ++i)
{
longestString = std::max(longestString, static_cast<int>(
strlen(vtkTimerLog::GetEventString(i))));
}
// Loop to numEvents - 1, since the last event must be an end event.
for (int startIdx = 0; startIdx < numEvents - 1; ++startIdx)
{
int curIndent = vtkTimerLog::GetEventIndent(startIdx);
// Skip this event if it is an end event:
if (startIdx > 0 && // first event cannot be end
// end events are always followed by a smaller indent:
curIndent > vtkTimerLog::GetEventIndent(startIdx + 1))
{
assert(!parentInfo.empty());
parentInfo.pop_back();
continue;
}
// Find the event that follows the end event:
int endIdx = startIdx + 1;
for (; endIdx < numEvents; ++endIdx)
{
if (vtkTimerLog::GetEventIndent(endIdx) == curIndent)
{
break;
}
}
// Move back one event to get our end event (also works when we've reached
// the end of the event log).
endIdx--;
// Get the current event time:
double elapsedTime = (vtkTimerLog::GetEventWallTime(endIdx) -
vtkTimerLog::GetEventWallTime(startIdx));
// The total time the parent took to execute. If empty, this is the first
// event, and just set to 100%.
IndentTime parent = parentInfo.empty() ? IndentTime(-1, elapsedTime)
: parentInfo.back();
// Percentage of parent exec time, rounded to a single decimal:
float percentage =
vtkMath::Round(elapsedTime / parent.second * 1000.) / 10.f;
*os << std::setw(8) << std::setprecision(6) << std::fixed
<< elapsedTime
<< std::setw(0) << "s"
<< std::setw(curIndent * 2) << " "
<< std::setprecision(1) << std::setw(5) << std::right << percentage
<< std::setw(0) << std::left << "% "
<< std::setw(longestString) << vtkTimerLog::GetEventString(startIdx)
<< "\n";
// Add our parent info:
parentInfo.push_back(IndentTime(curIndent, elapsedTime));
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Write the timing table out to a file. Calculate some helpful // Write the timing table out to a file. Calculate some helpful
// statistics (deltas and percentages) in the process. // statistics (deltas and percentages) in the process.
......
...@@ -107,6 +107,7 @@ public: ...@@ -107,6 +107,7 @@ public:
static void MarkEndEvent(const char *EventString); static void MarkEndEvent(const char *EventString);
static void DumpLogWithIndents(ostream *os, double threshold); static void DumpLogWithIndents(ostream *os, double threshold);
static void DumpLogWithIndentsAndPercentages(ostream *os);
// Description: // Description:
// Programatic access to events. Indexed from 0 to num-1. // Programatic access to events. Indexed from 0 to num-1.
......
...@@ -12,6 +12,8 @@ set(Module_SRCS ...@@ -12,6 +12,8 @@ set(Module_SRCS
vtkProgrammableElectronicData.cxx vtkProgrammableElectronicData.cxx
vtkProteinRibbonFilter.cxx vtkProteinRibbonFilter.cxx
vtkSimpleBondPerceiver.cxx vtkSimpleBondPerceiver.cxx
vtkVASPAnimationReader.cxx
vtkVASPTessellationReader.cxx
vtkXYZMolReader2.cxx vtkXYZMolReader2.cxx
) )
......
set(TestVASPAnimationReader_ARGS DATA{../Data/VASP/NPT_Z_ANIMATE.out})
set(TestVASPTessellationReader_ARGS DATA{../Data/VASP/NPT_Z_TESSELLATE.out})
vtk_add_test_cxx(${vtk-module}CxxTests tests vtk_add_test_cxx(${vtk-module}CxxTests tests
TestBallAndStick.cxx TestBallAndStick.cxx
TestPDBBallAndStick.cxx