Commit f91852fe authored by pugmire's avatar pugmire

PLY writer.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@11836 18c085ea-50e0-402c-830e-de6fd14e8384
parent 4b257371
......@@ -56,6 +56,7 @@
#include <vtkOBJWriter.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPLYWriter.h>
#include <vtkRectilinearGrid.h>
#include <vtkVisItSTLWriter.h>
#include <vtkTriangleFilter.h>
......@@ -67,7 +68,6 @@
#include <ColorControlPoint.h>
#include <AtomicProperties.h>
#include <StringHelpers.h>
#include <avtCommonDataFunctions.h>
#include <DebugStream.h>
......@@ -83,7 +83,7 @@
// enumerated in the DatasetFileFormat enum.
const char *avtDatasetFileWriter::extensions[] = { ".curve", ".obj",
".stl", ".vtk", ".ultra",
".pov"};
".pov", ".ply"};
static void SortLineSegments(vtkPolyData *, std::vector< std::vector<int> > &);
static void TakeOffPolyLine(int *, int, std::vector< std::vector<int> > &);
......@@ -164,6 +164,9 @@ avtDatasetFileWriter::~avtDatasetFileWriter()
// Jeremy Meredith, Thu Apr 5 17:23:37 EDT 2007
// Added POVRay file type.
//
// Dave Pugmire, Thu Jul 8 08:30:11 EDT 2010
// Added PLY writer.
//
// ****************************************************************************
void
......@@ -190,6 +193,9 @@ avtDatasetFileWriter::Write(DatasetFileFormat format, const char *filename,
case VTK:
WriteVTKFamily(filename, binary);
break;
case PLY:
WritePLYFile(filename, binary);
break;
default:
// Don't know what type to write out.
......@@ -633,6 +639,49 @@ avtDatasetFileWriter::WriteSTLFile(const char *filename, bool binary)
ds->Delete();
}
// ****************************************************************************
// Method: avtDatasetFileWriter::WritePLYFile
//
// Purpose:
// Writes out the input as a PLY file.
//
// Programmer: Dave Pugmire
// Creation: July 8, 2010
//
// Modifications:
//
// ****************************************************************************
void
avtDatasetFileWriter::WritePLYFile(const char *filename, bool binary)
{
vtkDataSet *ds = GetSingleDataset();
WriteVTKFile(ds, "VTK.vtk", false);
if (ds->GetDataObjectType() != VTK_POLY_DATA)
{
EXCEPTION0(NoInputException);
}
vtkPLYWriter *writer = vtkPLYWriter::New();
if (binary)
writer->SetFileTypeToBinary();
else
writer->SetFileTypeToASCII();
vtkDataArray *arr = ds->GetPointData()->GetScalars();
if (arr == NULL)
arr = ds->GetCellData()->GetScalars();
if (arr)
writer->SetArrayName(arr->GetName());
writer->SetInput(ds);
writer->SetFileName(filename);
writer->Write();
writer->Delete();
ds->Delete();
}
// ****************************************************************************
// Method: avtDatasetFileWriter::WriteCurveFile
......
......@@ -60,7 +60,8 @@ typedef enum
STL, /* 2 */
VTK, /* 3 */
ULTRA, /* 4 */
POVRAY /* 5 */
POVRAY, /* 5 */
PLY /* 6 */
} DatasetFileFormat;
......@@ -94,6 +95,9 @@ typedef enum
// Jeremy Meredith, Thu May 31 11:06:48 EDT 2007
// Added support for POVRay .df3 density files for volume rendering.
//
// Dave Pugmire, Thu Jul 8 08:30:11 EDT 2010
// Added PLY writer.
//
// ****************************************************************************
class AVTFILEWRITER_API avtDatasetFileWriter : public avtTerminatingDatasetSink
......@@ -114,6 +118,8 @@ class AVTFILEWRITER_API avtDatasetFileWriter : public avtTerminatingDatasetSink
void WriteSTLFile(const char *, bool);
void WritePLYFile(const char *, bool);
void WriteCurveFile(const char *);
void WritePOVRayFamily(const char *);
......
......@@ -115,6 +115,9 @@ avtFileWriter::~avtFileWriter()
// Jeremy Meredith, Thu Apr 5 17:23:37 EDT 2007
// Added POVRay data file format.
//
// Dave Pugmire, Thu Jul 8 08:30:11 EDT 2010
// Added PLY writer.
//
// ****************************************************************************
void
......@@ -170,6 +173,11 @@ avtFileWriter::SetFormat(int f)
dsFormat = STL;
isImage = false;
}
else if (f == SaveWindowAttributes::PLY)
{
dsFormat = PLY;
isImage = false;
}
else if (f == SaveWindowAttributes::TIFF)
{
imgFormat = TIFF;
......
......@@ -48,20 +48,20 @@ static const char *FileFormat_strings[] = {
"OBJ", "PNG", "POSTSCRIPT",
"POVRAY", "PPM", "RGB",
"STL", "TIFF", "ULTRA",
"VTK"};
"VTK", "PLY"};
std::string
SaveWindowAttributes::FileFormat_ToString(SaveWindowAttributes::FileFormat t)
{
int index = int(t);
if(index < 0 || index >= 13) index = 0;
if(index < 0 || index >= 14) index = 0;
return FileFormat_strings[index];
}
std::string
SaveWindowAttributes::FileFormat_ToString(int t)
{
int index = (t < 0 || t >= 13) ? 0 : t;
int index = (t < 0 || t >= 14) ? 0 : t;
return FileFormat_strings[index];
}
......@@ -69,7 +69,7 @@ bool
SaveWindowAttributes::FileFormat_FromString(const std::string &s, SaveWindowAttributes::FileFormat &val)
{
val = SaveWindowAttributes::BMP;
for(int i = 0; i < 13; ++i)
for(int i = 0; i < 14; ++i)
{
if(s == FileFormat_strings[i])
{
......@@ -156,14 +156,11 @@ SaveWindowAttributes::ResConstraint_FromString(const std::string &s, SaveWindowA
return false;
}
// Type map format string
const char *SaveWindowAttributes::TypeMapFormatString = "bssbiiibbibbsbibi";
// ****************************************************************************
// Method: SaveWindowAttributes::SaveWindowAttributes
//
// Purpose:
// Constructor for the SaveWindowAttributes class.
// Init utility for the SaveWindowAttributes class.
//
// Note: Autogenerated by xml2atts.
//
......@@ -174,8 +171,7 @@ const char *SaveWindowAttributes::TypeMapFormatString = "bssbiiibbibbsbibi";
//
// ****************************************************************************
SaveWindowAttributes::SaveWindowAttributes() :
AttributeSubject(SaveWindowAttributes::TypeMapFormatString)
void SaveWindowAttributes::Init()
{
#if defined(_WIN32)
outputToCurrentDirectory = false;
......@@ -217,13 +213,15 @@ SaveWindowAttributes::SaveWindowAttributes() :
compression = PackBits;
forceMerge = false;
resConstraint = ScreenProportions;
SaveWindowAttributes::SelectAll();
}
// ****************************************************************************
// Method: SaveWindowAttributes::SaveWindowAttributes
//
// Purpose:
// Copy constructor for the SaveWindowAttributes class.
// Copy utility for the SaveWindowAttributes class.
//
// Note: Autogenerated by xml2atts.
//
......@@ -234,8 +232,7 @@ SaveWindowAttributes::SaveWindowAttributes() :
//
// ****************************************************************************
SaveWindowAttributes::SaveWindowAttributes(const SaveWindowAttributes &obj) :
AttributeSubject(SaveWindowAttributes::TypeMapFormatString)
void SaveWindowAttributes::Copy(const SaveWindowAttributes &obj)
{
outputToCurrentDirectory = obj.outputToCurrentDirectory;
outputDirectory = obj.outputDirectory;
......@@ -255,7 +252,96 @@ SaveWindowAttributes::SaveWindowAttributes(const SaveWindowAttributes &obj) :
forceMerge = obj.forceMerge;
resConstraint = obj.resConstraint;
SelectAll();
SaveWindowAttributes::SelectAll();
}
// Type map format string
const char *SaveWindowAttributes::TypeMapFormatString = SAVEWINDOWATTRIBUTES_TMFS;
const AttributeGroup::private_tmfs_t SaveWindowAttributes::TmfsStruct = {SAVEWINDOWATTRIBUTES_TMFS};
// ****************************************************************************
// Method: SaveWindowAttributes::SaveWindowAttributes
//
// Purpose:
// Default constructor for the SaveWindowAttributes class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
SaveWindowAttributes::SaveWindowAttributes() :
AttributeSubject(SaveWindowAttributes::TypeMapFormatString)
{
SaveWindowAttributes::Init();
}
// ****************************************************************************
// Method: SaveWindowAttributes::SaveWindowAttributes
//
// Purpose:
// Constructor for the derived classes of SaveWindowAttributes class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
SaveWindowAttributes::SaveWindowAttributes(private_tmfs_t tmfs) :
AttributeSubject(tmfs.tmfs)
{
SaveWindowAttributes::Init();
}
// ****************************************************************************
// Method: SaveWindowAttributes::SaveWindowAttributes
//
// Purpose:
// Copy constructor for the SaveWindowAttributes class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
SaveWindowAttributes::SaveWindowAttributes(const SaveWindowAttributes &obj) :
AttributeSubject(SaveWindowAttributes::TypeMapFormatString)
{
SaveWindowAttributes::Copy(obj);
}
// ****************************************************************************
// Method: SaveWindowAttributes::SaveWindowAttributes
//
// Purpose:
// Copy constructor for derived classes of the SaveWindowAttributes class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
SaveWindowAttributes::SaveWindowAttributes(const SaveWindowAttributes &obj, private_tmfs_t tmfs) :
AttributeSubject(tmfs.tmfs)
{
SaveWindowAttributes::Copy(obj);
}
// ****************************************************************************
......@@ -297,25 +383,9 @@ SaveWindowAttributes&
SaveWindowAttributes::operator = (const SaveWindowAttributes &obj)
{
if (this == &obj) return *this;
outputToCurrentDirectory = obj.outputToCurrentDirectory;
outputDirectory = obj.outputDirectory;
fileName = obj.fileName;
family = obj.family;
format = obj.format;
width = obj.width;
height = obj.height;
screenCapture = obj.screenCapture;
saveTiled = obj.saveTiled;
quality = obj.quality;
progressive = obj.progressive;
binary = obj.binary;
lastRealFilename = obj.lastRealFilename;
stereo = obj.stereo;
compression = obj.compression;
forceMerge = obj.forceMerge;
resConstraint = obj.resConstraint;
SelectAll();
SaveWindowAttributes::Copy(obj);
return *this;
}
......@@ -699,7 +769,7 @@ SaveWindowAttributes::SetFromNode(DataNode *parentNode)
if(node->GetNodeType() == INT_NODE)
{
int ival = node->AsInt();
if(ival >= 0 && ival < 13)
if(ival >= 0 && ival < 14)
SetFormat(FileFormat(ival));
}
else if(node->GetNodeType() == STRING_NODE)
......
......@@ -42,6 +42,7 @@
#include <string>
#include <AttributeSubject.h>
// ****************************************************************************
// Class: SaveWindowAttributes
//
......@@ -74,7 +75,8 @@ public:
STL,
TIFF,
ULTRA,
VTK
VTK,
PLY
};
enum CompressionType
{
......@@ -90,13 +92,23 @@ public:
ScreenProportions
};
// These constructors are for objects of this class
SaveWindowAttributes();
SaveWindowAttributes(const SaveWindowAttributes &obj);
protected:
// These constructors are for objects derived from this class
SaveWindowAttributes(private_tmfs_t tmfs);
SaveWindowAttributes(const SaveWindowAttributes &obj, private_tmfs_t tmfs);
public:
virtual ~SaveWindowAttributes();
virtual SaveWindowAttributes& operator = (const SaveWindowAttributes &obj);
virtual bool operator == (const SaveWindowAttributes &obj) const;
virtual bool operator != (const SaveWindowAttributes &obj) const;
private:
void Init();
void Copy(const SaveWindowAttributes &obj);
public:
virtual const std::string TypeName() const;
virtual bool CopyAttributes(const AttributeGroup *);
......@@ -198,7 +210,8 @@ public:
ID_stereo,
ID_compression,
ID_forceMerge,
ID_resConstraint
ID_resConstraint,
ID__LAST
};
private:
......@@ -222,6 +235,8 @@ private:
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define SAVEWINDOWATTRIBUTES_TMFS "bssbiiibbibbsbibi"
#endif
......@@ -14,6 +14,7 @@
TIFF
ULTRA
VTK
PLY
</Enum>
<Enum name="CompressionType">
None
......
......@@ -174,6 +174,9 @@ QvisSaveWindow::~QvisSaveWindow()
// Cyrus Harrison, Tue Jun 24 11:15:28 PDT 2008
// Initial Qt4 Port.
//
// Dave Pugmire, Thu Jul 8 08:30:11 EDT 2010
// Added PLY writer.
//
// ****************************************************************************
void
......@@ -241,6 +244,7 @@ QvisSaveWindow::CreateWindowContents()
fileFormatComboBox->addItem("tiff");
fileFormatComboBox->addItem("ultra");
fileFormatComboBox->addItem("vtk");
fileFormatComboBox->addItem("ply");
connect(fileFormatComboBox, SIGNAL(activated(int)),
this, SLOT(fileFormatChanged(int)));
QLabel *formatLabel = new QLabel(tr("File type"),infoBox);
......@@ -437,6 +441,9 @@ QvisSaveWindow::CreateWindowContents()
// Cyrus Harrison, Tue Jun 24 11:15:28 PDT 2008
// Initial Qt4 Port.
//
// Dave Pugmire, Thu Jul 8 08:30:11 EDT 2010
// Added PLY writer.
//
// ****************************************************************************
void
......@@ -492,7 +499,9 @@ QvisSaveWindow::UpdateWindow(bool doAll)
if (saveWindowAtts->GetFormat()
== SaveWindowAttributes::VTK
|| saveWindowAtts->GetFormat()
== SaveWindowAttributes::STL)
== SaveWindowAttributes::STL
|| saveWindowAtts->GetFormat()
== SaveWindowAttributes::PLY)
{
binaryCheckBox->setEnabled(true);
}
......
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