Commit 5ff9d3e9 authored by Ken Martin's avatar Ken Martin
Browse files

merges from the main tree

parent 658ca683
......@@ -356,7 +356,6 @@ protected:
char* Name;
private:
double Range[2];
// We can have arbitrary number of components, but 11 should
......@@ -369,6 +368,7 @@ private:
ComponentRangeComputeTime[VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES];
double ComponentRange[VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES][2];
private:
double* GetTupleN(vtkIdType i, int n);
private:
......
......@@ -149,6 +149,9 @@ public:
void SetVoidArray(void* array, vtkIdType size, int save)
{ this->SetArray(static_cast<T*>(array), size, save); }
// Description:
// Do not call. Use GetRange.
virtual void ComputeRange(int comp);
protected:
vtkDataArrayTemplate(vtkIdType numComp);
~vtkDataArrayTemplate();
......@@ -161,6 +164,8 @@ protected:
int SaveUserArray;
void ComputeScalarRange(int comp);
void ComputeVectorRange();
private:
vtkDataArrayTemplate(const vtkDataArrayTemplate&); // Not implemented.
void operator=(const vtkDataArrayTemplate&); // Not implemented.
......
......@@ -483,4 +483,120 @@ vtkIdType vtkDataArrayTemplate<T>::InsertNextValue(T f)
return this->MaxId;
}
//----------------------------------------------------------------------------
template <class T>
void vtkDataArrayTemplate<T>::ComputeRange(int comp)
{
// If we got component -1 on a vector array, compute vector magnitude.
if(comp < 0 && this->NumberOfComponents == 1)
{
comp = 0;
}
// Choose index into component range cache.
int index = (comp<0)? this->NumberOfComponents : comp;
if(index >= VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES ||
(this->GetMTime() > this->ComponentRangeComputeTime[index]))
{
// We need to compute the range.
this->Range[0] = VTK_DOUBLE_MAX;
this->Range[1] = VTK_DOUBLE_MIN;
if(comp >= 0)
{
this->ComputeScalarRange(comp);
}
else
{
this->ComputeVectorRange();
}
// Store the result in the range cache if there is room.
if(index < VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES)
{
this->ComponentRangeComputeTime[index].Modified();
this->ComponentRange[index][0] = this->Range[0];
this->ComponentRange[index][1] = this->Range[1];
}
}
else
{
// Copy value from range cache entry for this component.
this->Range[0] = this->ComponentRange[index][0];
this->Range[1] = this->ComponentRange[index][1];
}
}
//----------------------------------------------------------------------------
template <class T>
void vtkDataArrayTemplate<T>::ComputeScalarRange(int comp)
{
// Compute range only if there are data.
T* begin = this->Array+comp;
T* end = this->Array+comp+this->MaxId+1;
if(begin == end)
{
return;
}
// Compute the range of scalar values.
int numComp = this->NumberOfComponents;
T range[2] = {*begin, *begin};
for(T* i = begin+numComp; i != end; i += numComp)
{
T s = *i;
if(s < range[0])
{
range[0] = s;
}
else if(s > range[1])
{
range[1] = s;
}
}
// Store the range.
this->Range[0] = range[0];
this->Range[1] = range[1];
}
//----------------------------------------------------------------------------
template <class T>
void vtkDataArrayTemplate<T>::ComputeVectorRange()
{
// Compute range only if there are data.
T* begin = this->Array;
T* end = this->Array+this->MaxId+1;
if(begin == end)
{
return;
}
// Compute the range of vector magnitude squared.
int numComp = this->NumberOfComponents;
double range[2] = {VTK_DOUBLE_MAX, VTK_DOUBLE_MIN};
for(T* i = begin; i != end; i += numComp)
{
double s = 0.0;
for(int j=0; j < numComp; ++j)
{
double t = i[j];
s += t*t;
}
if(s < range[0])
{
range[0] = s;
}
else if(s > range[1])
{
range[1] = s;
}
}
// Store the range of vector magnitude.
this->Range[0] = sqrt(range[0]);
this->Range[1] = sqrt(range[1]);
}
#endif
......@@ -16,7 +16,7 @@
#include "vtkDEMReader.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkDEMReader, "1.32");
vtkCxxRevisionMacro(vtkDEMReader, "1.32.6.1");
vtkStandardNewMacro(vtkDEMReader);
#define VTK_SW 0
......@@ -323,9 +323,6 @@ void vtkDEMReader::ComputeExtentOriginAndSpacing (int extent[6],
origin[0] = this->GroundCoords[VTK_SW][0];
origin[1] = this->GroundCoords[VTK_SW][1];
origin[2] = this->ElevationBounds[0];
origin[0] = 0;
origin[1] = 0;
origin[2] = 0;
spacing[0] = this->SpatialResolution[0] * planeConversion;
spacing[1] = this->SpatialResolution[1] * planeConversion;
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkDICOMImageReader.cxx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
......@@ -29,7 +25,7 @@
#include <vtkstd/vector>
#include <vtkstd/string>
vtkCxxRevisionMacro(vtkDICOMImageReader, "1.24");
vtkCxxRevisionMacro(vtkDICOMImageReader, "1.24.2.1");
vtkStandardNewMacro(vtkDICOMImageReader);
class vtkDICOMImageReaderVector : public vtkstd::vector<vtkstd::string>
......
......@@ -36,7 +36,7 @@
#include "vtkUnsignedLongArray.h"
#include "vtkUnsignedShortArray.h"
vtkCxxRevisionMacro(vtkDataWriter, "1.103.6.1");
vtkCxxRevisionMacro(vtkDataWriter, "1.103.6.2");
vtkStandardNewMacro(vtkDataWriter);
// this undef is required on the hp. vtkMutexLock ends up including
......@@ -504,7 +504,7 @@ int vtkDataWriter::WriteArray(ostream *fp, int dataType, vtkDataArray *data,
{
sprintf (str, format, "char"); *fp << str;
char *s=((vtkCharArray *)data)->GetPointer(0);
vtkWriteDataArray(fp, s, this->FileType, "%i ", num, numComp);
vtkWriteDataArray(fp, s, this->FileType, "%hhd ", num, numComp);
}
break;
......@@ -512,7 +512,7 @@ int vtkDataWriter::WriteArray(ostream *fp, int dataType, vtkDataArray *data,
{
sprintf (str, format, "unsigned_char"); *fp << str;
unsigned char *s=((vtkUnsignedCharArray *)data)->GetPointer(0);
vtkWriteDataArray(fp, s, this->FileType, "%i ", num, numComp);
vtkWriteDataArray(fp, s, this->FileType, "%hhu ", num, numComp);
}
break;
......@@ -544,7 +544,7 @@ int vtkDataWriter::WriteArray(ostream *fp, int dataType, vtkDataArray *data,
{
sprintf (str, format, "unsigned_int"); *fp << str;
unsigned int *s=((vtkUnsignedIntArray *)data)->GetPointer(0);
vtkWriteDataArray(fp, s, this->FileType, "%d ", num, numComp);
vtkWriteDataArray(fp, s, this->FileType, "%u ", num, numComp);
}
break;
......@@ -552,7 +552,7 @@ int vtkDataWriter::WriteArray(ostream *fp, int dataType, vtkDataArray *data,
{
sprintf (str, format, "long"); *fp << str;
long *s=((vtkLongArray *)data)->GetPointer(0);
vtkWriteDataArray(fp, s, this->FileType, "%d ", num, numComp);
vtkWriteDataArray(fp, s, this->FileType, "%ld ", num, numComp);
}
break;
......@@ -560,7 +560,7 @@ int vtkDataWriter::WriteArray(ostream *fp, int dataType, vtkDataArray *data,
{
sprintf (str, format, "unsigned_long"); *fp << str;
unsigned long *s=((vtkUnsignedLongArray *)data)->GetPointer(0);
vtkWriteDataArray(fp, s, this->FileType, "%d ", num, numComp);
vtkWriteDataArray(fp, s, this->FileType, "%lu ", num, numComp);
}
break;
......@@ -576,7 +576,7 @@ int vtkDataWriter::WriteArray(ostream *fp, int dataType, vtkDataArray *data,
{
sprintf (str, format, "double"); *fp << str;
double *s=((vtkDoubleArray *)data)->GetPointer(0);
vtkWriteDataArray(fp, s, this->FileType, "%g ", num, numComp);
vtkWriteDataArray(fp, s, this->FileType, "%lg ", num, numComp);
}
break;
......@@ -974,7 +974,7 @@ int vtkDataWriter::WriteFieldData(ostream *fp, vtkFieldData *f)
// in theory there could be array name consisting of only
// weird symbols.
char* buffer;
if(strlen(array->GetName()) == 0)
if( !array->GetName() || strlen(array->GetName()) == 0)
{
buffer = strcpy(new char[strlen("unknown")+1], "unknown");
}
......@@ -1006,6 +1006,11 @@ int vtkDataWriter::WriteFieldData(ostream *fp, vtkFieldData *f)
int vtkDataWriter::WriteCells(ostream *fp, vtkCellArray *cells, const char *label)
{
if ( ! cells )
{
return 1;
}
int ncells=cells->GetNumberOfCells();
int size=cells->GetNumberOfConnectivityEntries();
......
......@@ -24,7 +24,7 @@
#include <stddef.h>
vtkCxxRevisionMacro(vtkPLYWriter, "1.18");
vtkCxxRevisionMacro(vtkPLYWriter, "1.18.6.1");
vtkStandardNewMacro(vtkPLYWriter);
vtkCxxSetObjectMacro(vtkPLYWriter,LookupTable,vtkScalarsToColors);
......@@ -78,11 +78,11 @@ void vtkPLYWriter::WriteData()
float version;
static const char *elemNames[] = { "vertex", "face" };
static PlyProperty vertProps[] = { // property information for a vertex
{"x", PLY_FLOAT, PLY_FLOAT, static_cast<int>(offsetof(plyVertex,x[0])),
{"x", PLY_FLOAT, PLY_FLOAT, static_cast<int>(offsetof(plyVertex,x)),
0, 0, 0, 0},
{"y", PLY_FLOAT, PLY_FLOAT, static_cast<int>(offsetof(plyVertex,x[1])),
{"y", PLY_FLOAT, PLY_FLOAT, static_cast<int>(offsetof(plyVertex,x)+sizeof(float)),
0, 0, 0, 0},
{"z", PLY_FLOAT, PLY_FLOAT, static_cast<int>(offsetof(plyVertex,x[2])),
{"z", PLY_FLOAT, PLY_FLOAT, static_cast<int>(offsetof(plyVertex,x)+sizeof(float)+sizeof(float)),
0, 0, 0, 0},
{"red", PLY_UCHAR, PLY_UCHAR, static_cast<int>(offsetof(plyVertex,red)),
0, 0, 0, 0},
......
......@@ -25,7 +25,7 @@
# include <io.h> /* unlink */
#endif
vtkCxxRevisionMacro(vtkUnstructuredGridWriter, "1.40");
vtkCxxRevisionMacro(vtkUnstructuredGridWriter, "1.40.6.1");
vtkStandardNewMacro(vtkUnstructuredGridWriter);
//----------------------------------------------------------------------------
......@@ -98,6 +98,8 @@ void vtkUnstructuredGridWriter::WriteData()
//
// Cell types are a little more work
//
if ( input->GetCells() )
{
ncells = input->GetCells()->GetNumberOfCells();
types = new int[ncells];
for (cellId=0; cellId < ncells; cellId++)
......@@ -120,6 +122,7 @@ void vtkUnstructuredGridWriter::WriteData()
}
*fp << "\n";
delete [] types;
}
if (!this->WriteCellData(fp, input))
{
......
......@@ -20,7 +20,7 @@
#include "vtkTransform.h"
#include "vtkUnsignedShortArray.h"
vtkCxxRevisionMacro(vtkVolume16Reader, "1.51");
vtkCxxRevisionMacro(vtkVolume16Reader, "1.51.6.1");
vtkStandardNewMacro(vtkVolume16Reader);
vtkCxxSetObjectMacro(vtkVolume16Reader,Transform,vtkTransform);
......@@ -364,12 +364,12 @@ int vtkVolume16Reader:: Read16BitImage (FILE *fp, unsigned short *pixels, int xs
}
shortPtr = pixels;
shortPtr = shortPtr + xsize*(ysize - 1);
for (int j=0; j<ysize; j++, shortPtr = shortPtr - xsize)
shortPtr += xsize*(ysize - 1);
for (int j=0; j<ysize; j++, shortPtr -= xsize)
{
if ( ! fread(shortPtr,sizeof (unsigned short),xsize,fp) )
{
vtkErrorMacro(<<"Error reaading raw pgm data!");
vtkErrorMacro(<<"Error reading raw pgm data!");
return 0;
}
}
......
......@@ -33,7 +33,7 @@
# include <io.h> /* unlink */
#endif
vtkCxxRevisionMacro(vtkXMLWriter, "1.32");
vtkCxxRevisionMacro(vtkXMLWriter, "1.32.2.1");
vtkCxxSetObjectMacro(vtkXMLWriter, Compressor, vtkDataCompressor);
//----------------------------------------------------------------------------
......@@ -1284,6 +1284,7 @@ int vtkXMLWriter::WriteAsciiData(void* data, int numWords, int wordType,
void* b = data;
int nw = numWords;
vtkIndent i = indent;
this->Stream->precision(11);
ostream& os = *(this->Stream);
switch(wordType)
{
......
......@@ -17,7 +17,7 @@
#include "vtkObjectFactory.h"
#include "vtkRenderWindowInteractor.h"
vtkCxxRevisionMacro(vtkInteractorEventRecorder, "1.7");
vtkCxxRevisionMacro(vtkInteractorEventRecorder, "1.7.4.1");
vtkStandardNewMacro(vtkInteractorEventRecorder);
float vtkInteractorEventRecorder::StreamVersion = 1.0;
......@@ -44,6 +44,8 @@ vtkInteractorEventRecorder::vtkInteractorEventRecorder()
vtkInteractorEventRecorder::~vtkInteractorEventRecorder()
{
this->SetInteractor(0);
if ( this->FileName )
{
delete [] this->FileName;
......@@ -295,8 +297,8 @@ void vtkInteractorEventRecorder::ProcessCharEvent(vtkObject* object,
switch(event)
{
case vtkCommand::DeleteEvent:
//self->Interactor = NULL; //its going bye bye
//self->Enabled = 0; //can't write to a deleted object
// if the interactor is being deleted then remove the event handlers
self->SetInteractor(0);
break;
case vtkCommand::CharEvent:
......
......@@ -20,7 +20,7 @@
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
vtkCxxRevisionMacro(vtkInteractorObserver, "1.28");
vtkCxxRevisionMacro(vtkInteractorObserver, "1.28.6.1");
vtkCxxSetObjectMacro(vtkInteractorObserver,DefaultRenderer,vtkRenderer);
......@@ -46,6 +46,9 @@ vtkInteractorObserver::vtkInteractorObserver()
this->KeyPressActivation = 1;
this->KeyPressActivationValue = 'i';
this->CharObserverTag = 0;
this->DeleteObserverTag = 0;
}
vtkInteractorObserver::~vtkInteractorObserver()
......@@ -55,6 +58,7 @@ vtkInteractorObserver::~vtkInteractorObserver()
this->SetDefaultRenderer(NULL);
this->EventCallbackCommand->Delete();
this->KeyPressCallbackCommand->Delete();
this->SetInteractor(0);
}
//----------------------------------------------------------------------------
......@@ -114,7 +118,10 @@ void vtkInteractorObserver::SetInteractor(vtkRenderWindowInteractor* i)
if (this->Interactor)
{
this->SetEnabled(0); //disable the old interactor
this->Interactor->RemoveObserver(this->KeyPressCallbackCommand);
this->Interactor->RemoveObserver(this->CharObserverTag);
this->CharObserverTag = 0;
this->Interactor->RemoveObserver(this->DeleteObserverTag);
this->DeleteObserverTag = 0;
}
this->Interactor = i;
......@@ -122,11 +129,10 @@ void vtkInteractorObserver::SetInteractor(vtkRenderWindowInteractor* i)
// add observers for each of the events handled in ProcessEvents
if (i)
{
i->AddObserver(vtkCommand::CharEvent,
this->CharObserverTag = i->AddObserver(vtkCommand::CharEvent,
this->KeyPressCallbackCommand,
this->Priority);
i->AddObserver(vtkCommand::DeleteEvent,
this->DeleteObserverTag = i->AddObserver(vtkCommand::DeleteEvent,
this->KeyPressCallbackCommand,
this->Priority);
}
......@@ -139,19 +145,27 @@ void vtkInteractorObserver::ProcessEvents(vtkObject* vtkNotUsed(object),
void* clientdata,
void* vtkNotUsed(calldata))
{
if (event == vtkCommand::CharEvent ||
event == vtkCommand::DeleteEvent)
{
vtkObject *vobj = reinterpret_cast<vtkObject *>( clientdata );
vtkInteractorObserver* self
= reinterpret_cast<vtkInteractorObserver *>( clientdata );
//look for char and delete events
switch(event)
= vtkInteractorObserver::SafeDownCast(vobj);
if (self)
{
if (event == vtkCommand::CharEvent)
{
case vtkCommand::CharEvent:
self->OnChar();
break;
case vtkCommand::DeleteEvent:
//self->Interactor = NULL; //commented out, can't write to a
//self->Enabled = 0; //deleted object
break;
}
else // delete event
{
self->SetInteractor(0);
}
}
else
{
vtkGenericWarningMacro("Process Events received a bad client data. The client data class name was " << vobj->GetClassName());
}
}
}
......
......@@ -178,6 +178,9 @@ protected:
vtkRenderer *CurrentRenderer;
vtkRenderer *DefaultRenderer;
unsigned long CharObserverTag;
unsigned long DeleteObserverTag;
private:
vtkInteractorObserver(const vtkInteractorObserver&); // Not implemented.
void operator=(const vtkInteractorObserver&); // Not implemented.
......
......@@ -32,7 +32,7 @@
#include "vtkRenderer.h"
#include "vtkTextProperty.h"
vtkCxxRevisionMacro(vtkInteractorStyle, "1.95");
vtkCxxRevisionMacro(vtkInteractorStyle, "1.95.2.1");
vtkStandardNewMacro(vtkInteractorStyle);
//----------------------------------------------------------------------------
......@@ -1084,7 +1084,7 @@ void vtkInteractorStyle::ProcessEvents(vtkObject* vtkNotUsed(object),
break;
case vtkCommand::DeleteEvent:
self->Interactor = 0;
self->SetInteractor(0);
break;
}
}
......
......@@ -21,7 +21,7 @@
#include "vtkRenderWindowInteractor.h"
#include "vtkUnsignedCharArray.h"
vtkCxxRevisionMacro(vtkInteractorStyleRubberBandZoom, "1.5");
vtkCxxRevisionMacro(vtkInteractorStyleRubberBandZoom, "1.5.6.1");
vtkStandardNewMacro(vtkInteractorStyleRubberBandZoom);
vtkInteractorStyleRubberBandZoom::vtkInteractorStyleRubberBandZoom()
......@@ -156,14 +156,14 @@ void vtkInteractorStyleRubberBandZoom::Zoom()
double invw;
double worldRBCenter[4];
this->CurrentRenderer->GetWorldPoint(worldRBCenter);
invw = 1.0f/worldRBCenter[3];
invw = 1.0/worldRBCenter[3];
worldRBCenter[0] *= invw;
worldRBCenter[1] *= invw;
worldRBCenter[2] *= invw;
double winCenter[3];
winCenter[0] = origin[0] + 0.5f*size[0];
winCenter[1] = origin[1] + 0.5f*size[1];
winCenter[0] = origin[0] + 0.5*size[0];
winCenter[1] = origin[1] + 0.5*size[1];
winCenter[2] = 0;
this->CurrentRenderer->SetDisplayPoint(winCenter);
......@@ -172,7 +172,7 @@ void vtkInteractorStyleRubberBandZoom::Zoom()
double worldWinCenter[4];
this->CurrentRenderer->GetWorldPoint(worldWinCenter);
invw = 1.0f/worldWinCenter[3];
invw = 1.0/worldWinCenter[3];
worldWinCenter[0] *= invw;
worldWinCenter[1] *= invw;
worldWinCenter[2] *= invw;
......
......@@ -43,7 +43,7 @@
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkOpenGLPolyDataMapper, "1.93");
vtkCxxRevisionMacro(vtkOpenGLPolyDataMapper, "1.93.2.1");
vtkStandardNewMacro(vtkOpenGLPolyDataMapper);
#endif
......@@ -483,25 +483,21 @@ static void vtkOpenGLBeginPolyTriangleOrQuad(GLenum aGlFunction,
} \
}
#define vtkDrawStripLinesMacro(ptype,ntype,ttype,prim,glPFunc,glNFunc,glCFunc,glTFunc,glFlatNFunc,glNInit,glTInit) \
#define vtkDrawStripLinesMacro(ptype,ntype,ttype,prim,glVertFuncs,glCellFuncs,glInitFuncs) \
{ \
vtkIdType nPts = 0; \
ptype *points = (ptype *)voidPoints; \
vtkIdType *savedPtIds = ptIds; \
glNInit \
glTInit \
glInitFuncs \
while (ptIds < endPtIds) \
{ \
glBegin(prim); \
nPts = *ptIds; \
++ptIds; \
glFlatNFunc \
glCellFuncs \
while (nPts > 0) \
{ \
glTFunc \
glCFunc \
glNFunc \
glPFunc \
glVertFuncs \
ptIds += 2; \
nPts -= 2; \
} \
......@@ -514,15 +510,12 @@ static void vtkOpenGLBeginPolyTriangleOrQuad(GLenum aGlFunction,
glBegin(prim); \
nPts = *ptIds; \
++ptIds; \
glFlatNFunc \
glCellFuncs \
++ptIds; \
--nPts; \
while (nPts > 0) \
{ \
glTFunc \
glCFunc \
glNFunc \
glPFunc \
glVertFuncs \
ptIds += 2; \
nPts -= 2; \
} \
......@@ -1247,58 +1240,57 @@ void vtkOpenGLPolyDataMapperDrawTStripLines(int idx,
{
case VTK_PDM_POINT_TYPE_FLOAT:
vtkDrawStripLinesMacro(float, float, float, rep,
glVertex3fv(points + 3**ptIds);, TStripNormal,;,;,
TStripNormalStart,;,;);
TStripNormal; glVertex3fv(points + 3**ptIds);,