Commit 0342427f authored by Ken Martin's avatar Ken Martin
Browse files

ENH: merge from main tree to add mpeg plus fix for big data exceeding int cells

parent 3aa1613a
......@@ -33,6 +33,8 @@ SET(ParaViewServer_SRCS ${ParaViewServer_SRCS}
)
SET( ParaViewClientNotWrapped_SRCS
vtkKWGenericMovieWriter.cxx
vtkMPEG2Writer.cxx
vtkPVAnimationBatchHelper.cxx
vtkPVAxesActor.cxx
vtkPVAxesWidget.cxx
......@@ -165,6 +167,7 @@ INCLUDE_DIRECTORIES(
${VTKCLIENTSERVER_INCLUDE_DIR}
${VTK_INCLUDE_DIR}
${XDMF_INCLUDE_DIRS}
${VTKMPEG2_INCLUDE_DIRS}
)
IF(VTK_USE_MPI)
INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
......@@ -191,6 +194,7 @@ SET_SOURCE_FILES_PROPERTIES(
)
SET_SOURCE_FILES_PROPERTIES(
vtkKWGenericMovieWriter.cxx
vtkPV3DWidget
vtkPVJoystickFly
vtkPVObjectWidget
......@@ -234,7 +238,8 @@ ADD_LIBRARY(vtkKWParaView ${ParaViewTCL_SRCS} ${PVInstantiator_SRCS}
${ParaViewServerNonWrapped_SRCS}
${ParaViewSharedNotWrapped_SRCS}
${ParaView_SRCS})
TARGET_LINK_LIBRARIES(vtkKWParaView vtkKWWidgetsTCL vtkPVServerManagerTCL)
TARGET_LINK_LIBRARIES(vtkKWParaView
vtkKWWidgetsTCL vtkPVServerManagerTCL vtkMPEG2Encode)
IF(PARAVIEW_PLUS_BUILD)
INCLUDE_DIRECTORIES(${PARAVIEW_PLUS_INCLUDE_DIRS})
......
/*=========================================================================
Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway,
Clifton Park, NY, 12065, USA.
All rights reserved. No part of this software may be reproduced, distributed,
or modified, in any form or by any means, without permission in writing from
Kitware Inc.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
#include "vtkKWGenericMovieWriter.h"
#include "vtkImageData.h"
vtkCxxRevisionMacro(vtkKWGenericMovieWriter, "1.1.2.1");
//---------------------------------------------------------------------------
vtkKWGenericMovieWriter::vtkKWGenericMovieWriter()
{
this->FileName = NULL;
this->Error = 0;
}
//---------------------------------------------------------------------------
vtkKWGenericMovieWriter::~vtkKWGenericMovieWriter()
{
this->SetFileName(0);
this->SetInput(0);
}
//----------------------------------------------------------------------------
void vtkKWGenericMovieWriter::SetInput(vtkImageData *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
vtkImageData *vtkKWGenericMovieWriter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return (vtkImageData *)(this->Inputs[0]);
}
void vtkKWGenericMovieWriter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "FileName: " << this->FileName << endl;
os << indent << "Error: " << this->Error << endl;
}
/*=========================================================================
Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway,
Clifton Park, NY, 12065, USA.
All rights reserved. No part of this software may be reproduced, distributed,
or modified, in any form or by any means, without permission in writing from
Kitware Inc.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
// .NAME vtkKWGenericMovieWriter - Writes Windows Movie files.
// .SECTION Description
// vtkKWGenericMovieWriter writes Movie files. The data type
// of the file is unsigned char regardless of the input type.
// .SECTION See Also
// vtkMovieReader
#ifndef __vtkKWGenericMovieWriter_h
#define __vtkKWGenericMovieWriter_h
#include "vtkProcessObject.h"
class vtkImageData;
class vtkKWGenericMovieWriterInternal;
class VTK_EXPORT vtkKWGenericMovieWriter : public vtkProcessObject
{
public:
vtkTypeRevisionMacro(vtkKWGenericMovieWriter,vtkProcessObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set/Get the input object from the image pipeline.
virtual void SetInput(vtkImageData *input);
virtual vtkImageData *GetInput();
// Description:
// Specify file name of avi file.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// These methods start writing an Movie file, write a frame to the file
// and then end the writing process.
virtual void Start() =0;
virtual void Write() =0;
virtual void End() =0;
// Description:
// Was there an error on the last read performed?
vtkGetMacro(Error,int);
protected:
vtkKWGenericMovieWriter();
~vtkKWGenericMovieWriter();
char *FileName;
int Error;
long Time;
private:
vtkKWGenericMovieWriter(const vtkKWGenericMovieWriter&); // Not implemented
void operator=(const vtkKWGenericMovieWriter&); // Not implemented
};
#endif
/*=========================================================================
Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway,
Clifton Park, NY, 12065, USA.
All rights reserved. No part of this software may be reproduced, distributed,
or modified, in any form or by any means, without permission in writing from
Kitware Inc.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
#include "vtkMPEG2Writer.h"
#include "vtkImageData.h"
#include "vtkMPEG2WriterHelper.h"
#include "vtkObjectFactory.h"
#include "vtkSmartPointer.h"
//---------------------------------------------------------------------------
vtkStandardNewMacro(vtkMPEG2Writer);
vtkCxxRevisionMacro(vtkMPEG2Writer, "1.1.2.1");
//---------------------------------------------------------------------------
vtkMPEG2Writer::vtkMPEG2Writer()
{
this->MPEG2WriterHelper = vtkMPEG2WriterHelper::New();
}
//---------------------------------------------------------------------------
vtkMPEG2Writer::~vtkMPEG2Writer()
{
this->MPEG2WriterHelper->Delete();
}
//---------------------------------------------------------------------------
void vtkMPEG2Writer::Start()
{
this->MPEG2WriterHelper->SetFileName(this->FileName);
this->MPEG2WriterHelper->Start();
}
//---------------------------------------------------------------------------
void vtkMPEG2Writer::Write()
{
this->MPEG2WriterHelper->Write();
}
//---------------------------------------------------------------------------
void vtkMPEG2Writer::End()
{
this->MPEG2WriterHelper->End();
}
//----------------------------------------------------------------------------
void vtkMPEG2Writer::SetInput(vtkImageData *input)
{
this->Superclass::SetInput(input);
this->MPEG2WriterHelper->SetInput(input);
}
//----------------------------------------------------------------------------
vtkImageData *vtkMPEG2Writer::GetInput()
{
return this->MPEG2WriterHelper->GetInput();
}
//---------------------------------------------------------------------------
void vtkMPEG2Writer::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Copyright (c) 1998-2003 Kitware Inc. 469 Clifton Corporate Parkway,
Clifton Park, NY, 12065, USA.
All rights reserved. No part of this software may be reproduced, distributed,
or modified, in any form or by any means, without permission in writing from
Kitware Inc.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
=========================================================================*/
// .NAME vtkMPEG2Writer - Writes Windows Movie files.
// .SECTION Description
// vtkMPEG2Writer writes Movie files. The data type
// of the file is unsigned char regardless of the input type.
// .SECTION See Also
// vtkMovieReader
#ifndef __vtkMPEG2Writer_h
#define __vtkMPEG2Writer_h
#include "vtkKWGenericMovieWriter.h"
class vtkMPEG2WriterHelper;
class VTK_EXPORT vtkMPEG2Writer : public vtkKWGenericMovieWriter
{
public:
static vtkMPEG2Writer *New();
vtkTypeRevisionMacro(vtkMPEG2Writer,vtkKWGenericMovieWriter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// These methods start writing an Movie file, write a frame to the file
// and then end the writing process.
void Start();
void Write();
void End();
// Description:
// Set/Get the input object from the image pipeline.
virtual void SetInput(vtkImageData *input);
virtual vtkImageData *GetInput();
protected:
vtkMPEG2Writer();
~vtkMPEG2Writer();
vtkMPEG2WriterHelper *MPEG2WriterHelper;
private:
vtkMPEG2Writer(const vtkMPEG2Writer&); // Not implemented
void operator=(const vtkMPEG2Writer&); // Not implemented
};
#endif
......@@ -30,6 +30,7 @@
#include "vtkKWScale.h"
#include "vtkKWText.h"
#include "vtkKWView.h"
#include "vtkMPEG2Writer.h"
#include "vtkObjectFactory.h"
#include "vtkPVAnimationBatchHelper.h"
#include "vtkPVApplication.h"
......@@ -63,15 +64,6 @@
#include "vtkKWEvent.h"
#include "vtkPVConfig.h"
#ifdef PARAVIEW_PLUS_BUILD
# ifdef _WIN32
# include "vtkAVIWriter.h"
# else
//# include "vtkMPEG2Writer.h"
# include "vtkMovieWriter.h"
# endif
#endif
#ifndef _WIN32
# include <unistd.h>
#endif
......@@ -185,7 +177,7 @@ public:
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPVAnimationInterface);
vtkCxxRevisionMacro(vtkPVAnimationInterface, "1.161");
vtkCxxRevisionMacro(vtkPVAnimationInterface, "1.161.2.1");
vtkCxxSetObjectMacro(vtkPVAnimationInterface,ControlledWidget, vtkPVWidget);
......@@ -1221,13 +1213,8 @@ void vtkPVAnimationInterface::SaveImagesCallback()
saveDialog->SetTitle("Save Animation Images");
ostrstream ostr;
ostr << "{{JPEG Images} {.jpg}} {{TIFF Images} {.tif}} {{PNG Images} {.png}}";
#ifdef PARAVIEW_PLUS_BUILD
# ifdef _WIN32
ostr << " {{AVI movie file} {.avi}}";
# else
ostr << " {{MPEG movie file} {.mpg}}";
# endif
#endif
ostr << " {{MPEG2 movie file} {.mp2}}";
ostr << ends;
saveDialog->SetFileTypes(ostr.str());
......@@ -1272,22 +1259,23 @@ void vtkPVAnimationInterface::SaveImagesCallback()
dlg->SetMasterWindow(this->Window);
dlg->Create(this->GetApplication(), "");
int isMPEG = (!strcmp(ext, "mpg") || !strcmp(ext, "mpeg") ||
!strcmp(ext, "MPG") || !strcmp(ext, "MPEG"));
!strcmp(ext, "MPG") || !strcmp(ext, "MPEG") ||
!strcmp(ext, "MP2") || !strcmp(ext, "mp2"));
if (isMPEG)
{
dlg->SetText(
"Specify the width and aspect ratio of the images to be saved from "
"this animation. The images will be scaled so that they are no larger "
"than the size of the display area.");
"Specify the width and height of the mpeg to be saved from this "
"animation. Each dimension must be a multiple of 32. Each will be "
"resized to the next smallest multiple of 32 if it does not meet this "
"criterion.");
}
else
{
dlg->SetText(
"Specify the width and height of the images to be saved from this "
"animation. Each dimension must be a multiple of 4. Each will be "
"resized to the next smallest multiple of 4 if it does not meet this "
"criterion. The images will also be scaled so that they are no "
"larger than the size of the display area.");
"animation. Each dimension must be a multiple of 32. Each will be "
"resized to the next smallest multiple of 32 if it does not meet this "
"criterion.");
}
vtkKWWidget *frame = vtkKWWidget::New();
frame->SetParent(dlg->GetTopFrame());
......@@ -1308,62 +1296,15 @@ void vtkPVAnimationInterface::SaveImagesCallback()
heightEntry->Create(this->GetApplication(), "");
heightEntry->GetEntry()->SetValue(origHeight);
vtkKWLabeledOptionMenu *aspectRatioMenu = vtkKWLabeledOptionMenu::New();
aspectRatioMenu->SetLabel("Aspect Ratio:");
aspectRatioMenu->SetParent(frame);
aspectRatioMenu->Create(this->GetApplication(), "");
aspectRatioMenu->GetOptionMenu()->AddEntry("1:1");
aspectRatioMenu->GetOptionMenu()->AddEntry("4:3");
aspectRatioMenu->GetOptionMenu()->AddEntry("16:9");
aspectRatioMenu->GetOptionMenu()->AddEntry("2.21:1");
aspectRatioMenu->GetOptionMenu()->SetValue("1:1");
if (isMPEG)
{
this->Script("pack %s %s -side left -fill both -expand t",
widthEntry->GetWidgetName(),
aspectRatioMenu->GetWidgetName());
}
else
{
this->Script("pack %s %s -side left -fill both -expand t",
widthEntry->GetWidgetName(), heightEntry->GetWidgetName());
}
this->Script("pack %s -side top -pady 5", frame->GetWidgetName());
dlg->Invoke();
int width = widthEntry->GetEntry()->GetValueAsInt();
int height = origHeight;
int aspectRatio = 0;
if (isMPEG)
{
const char *aspect = aspectRatioMenu->GetOptionMenu()->GetValue();
if (!strcmp(aspect, "1:1"))
{
height = width;
aspectRatio = 1;
}
else if (!strcmp(aspect, "4:3"))
{
height = static_cast<int>(width / 4.0 * 3);
aspectRatio = 2;
}
else if (!strcmp(aspect, "16:9"))
{
height = static_cast<int>(width / 16.0 * 9);
aspectRatio = 3;
}
else if (!strcmp(aspect, "2.21:1"))
{
height = static_cast<int>(width / 2.21);
aspectRatio = 4;
}
}
else
{
height = heightEntry->GetEntry()->GetValueAsInt();
}
// For now, the image size for the animations cannot be larger than
// the size of the render window. The problem is that tiling doesn't
......@@ -1385,6 +1326,19 @@ void vtkPVAnimationInterface::SaveImagesCallback()
}
}
if (isMPEG)
{
if ((width % 32) > 0)
{
width -= width % 32;
}
if ((height % 32) > 0)
{
height -= height % 32;
}
}
else
{
if ((width % 4) > 0)
{
width -= width % 4;
......@@ -1393,14 +1347,14 @@ void vtkPVAnimationInterface::SaveImagesCallback()
{
height -= height % 4;
}
}
widthEntry->Delete();
heightEntry->Delete();
aspectRatioMenu->Delete();
frame->Delete();
dlg->Delete();
this->SaveImages(fileRoot, ext, width, height, aspectRatio);
this->SaveImages(fileRoot, ext, width, height, 0);
this->View->SetRenderWindowSize(origWidth, origHeight);
delete [] fileRoot;
......@@ -1415,16 +1369,15 @@ void vtkPVAnimationInterface::SaveImagesCallback()
//-----------------------------------------------------------------------------
void vtkPVAnimationInterface::SaveImages(const char* fileRoot,
const char* ext,
int width, int height, int vtkNotUsed(aspectRatio) /* = 0 */)
int width, int height,
int vtkNotUsed(aspectRatio) /* = 0 */)
{
this->SavingData = 1;
this->GetWindow()->UpdateEnableState();
this->StopButton->SetEnabled(1);
vtkWindowToImageFilter* winToImage;
vtkImageWriter* writer = 0;
#ifdef PARAVIEW_PLUS_BUILD
vtkKWGenericMovieWriter* awriter = 0;
#endif
char *fileName;
int fileCount;
int t;
......@@ -1459,26 +1412,14 @@ void vtkPVAnimationInterface::SaveImages(const char* fileRoot,
{
writer = vtkPNGWriter::New();
}
#ifdef PARAVIEW_PLUS_BUILD
# ifdef _WIN32
else if (strcmp(ext,"avi") == 0 )
else if (strcmp(ext, "mp2") == 0)
{
awriter = vtkAVIWriter::New();
}
# else
else if (strcmp(ext, "mpg") == 0)
{
//awriter = vtkMPEG2Writer::New();
awriter = vtkMovieWriter::New();
/*
if ( aspectRatio > 0 && aspectRatio <= 4 )
{
vtkMPEG2Writer::SafeDownCast(awriter)->SetAspectRatio(aspectRatio);
awriter = vtkMPEG2Writer::New();
// if ( aspectRatio > 0 && aspectRatio <= 4 )
// {
// vtkMPEG2Writer::SafeDownCast(awriter)->SetAspectRatio(aspectRatio);
// }
}
*/
}
# endif
#endif
else
{
vtkErrorMacro("Unknown extension " << ext << ", try: jpg, tif or png.");
......@@ -1493,7 +1434,6 @@ void vtkPVAnimationInterface::SaveImages(const char* fileRoot,
{
writer->SetInput(winToImage->GetOutput());
}
#ifdef PARAVIEW_PLUS_BUILD
else if ( awriter )
{
awriter->SetInput(winToImage->GetOutput());
......@@ -1501,7 +1441,6 @@ void vtkPVAnimationInterface::SaveImages(const char* fileRoot,
awriter->SetFileName(fileName);
awriter->Start();
}
#endif
// Loop through all of the time steps.
t = this->GetGlobalStart();
......@@ -1525,13 +1464,11 @@ void vtkPVAnimationInterface::SaveImages(const char* fileRoot,
writer->Write();
errcode = writer->GetErrorCode();
}
#ifdef PARAVIEW_PLUS_BUILD
else if ( awriter )
{
awriter->Write();
errcode = awriter->GetErrorCode() + awriter->GetError();
}
#endif
if ( errcode == vtkErrorCode::OutOfDiskSpaceError)
{
if ( writer )
......@@ -1562,14 +1499,13 @@ void vtkPVAnimationInterface::SaveImages(const char* fileRoot,
writer->Delete();
writer = NULL;
}
#ifdef PARAVIEW_PLUS_BUILD
else if ( awriter )
{
awriter->End();
awriter->SetInput(0);
awriter->Delete();
awriter = 0;
}
#endif
delete [] fileName;
fileName = NULL;
......
<
......@@ -24,6 +24,7 @@
#define __vtkPVDataInformation_h
#include "vtkPVInformation.h"
#include "vtkTypeFromNative.h" // This is required to get the 64 bit int definition.
class vtkCollection;
class vtkCompositeDataSet;
......@@ -60,8 +61,8 @@ public:
vtkGetMacro(DataSetType, int);
const char *GetDataSetTypeAsString();
int DataSetTypeIsA(const char* type);
vtkGetMacro(NumberOfPoints, vtkIdType);
vtkGetMacro(NumberOfCells, vtkIdType);
vtkGetMacro(NumberOfPoints, vtkTypeInt64);
vtkGetMacro(NumberOfCells, vtkTypeInt64);
vtkGetMacro(MemorySize, int);