[cig-commits] r11484 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Mar 19 12:00:26 PDT 2008
Author: luis
Date: 2008-03-19 12:00:25 -0700 (Wed, 19 Mar 2008)
New Revision: 11484
Modified:
cs/benchmark/cigma/trunk/src/CommandSet.cpp
cs/benchmark/cigma/trunk/src/CubeCmd.cpp
cs/benchmark/cigma/trunk/src/ListCmd.cpp
cs/benchmark/cigma/trunk/src/VtkList.cpp
cs/benchmark/cigma/trunk/src/VtkList.h
Log:
Started to fix the commands. Restricting to list & cube to see
if the readers and writers still work.
Modified: cs/benchmark/cigma/trunk/src/CommandSet.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/CommandSet.cpp 2008-03-19 19:00:23 UTC (rev 11483)
+++ cs/benchmark/cigma/trunk/src/CommandSet.cpp 2008-03-19 19:00:25 UTC (rev 11484)
@@ -4,11 +4,11 @@
#include "CommandSet.h"
#include "SkelCmd.h"
#include "HelpCmd.h"
-#include "CompareCmd.h"
#include "ListCmd.h"
-#include "ExtractCmd.h"
+#include "CubeCmd.h"
+//#include "CompareCmd.h"
+//#include "ExtractCmd.h"
//#include "EvalCmd.h"
-#include "CubeCmd.h"
cigma::CommandSet::CommandSet()
{
@@ -31,10 +31,10 @@
/* assemble set of commands */
addCommand(help);
- addCommand(new CompareCmd());
+ //addCommand(new CompareCmd());
addCommand(new ListCmd());
addCommand(new CubeCmd());
- addCommand(new ExtractCmd());
+ //addCommand(new ExtractCmd());
//addCommand(new EvalCmd());
//addCommand(new SkelCmd());
Modified: cs/benchmark/cigma/trunk/src/CubeCmd.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/CubeCmd.cpp 2008-03-19 19:00:23 UTC (rev 11483)
+++ cs/benchmark/cigma/trunk/src/CubeCmd.cpp 2008-03-19 19:00:25 UTC (rev 11484)
@@ -130,7 +130,7 @@
// determine the extension and instantiate appropriate writer object
string root, ext;
path_splitext(output_filename, root, ext);
- new_writer(&writer, ext);
+ writer = NewWriter(ext.c_str());
if (writer == 0)
{
cerr << "cube: File with bad extension (" << ext << ")" << endl;
@@ -247,7 +247,7 @@
if (writer->getType() == Writer::HDF_WRITER)
{
HdfWriter *hdfWriter = static_cast<HdfWriter*>(writer);
- ierr = hdfWriter->open(output_filename);
+ ierr = hdfWriter->open(output_filename.c_str());
if (ierr < 0)
{
cerr << "Error: Could not open (or create) the HDF5 file " << output_filename << endl;
@@ -270,24 +270,24 @@
hdfWriter->close();
}
- else if (writer->getType() == Writer::TXT_WRITER)
+ else if (writer->getType() == Writer::TEXT_WRITER)
{
- TextWriter *txtWriter = static_cast<TextWriter*>(writer);
- ierr = txtWriter->open(output_filename);
+ TextWriter *textWriter = static_cast<TextWriter*>(writer);
+ ierr = textWriter->open(output_filename.c_str());
if (ierr < 0)
{
cerr << "Error: Could not create output text file " << output_filename << endl;
exit(1);
}
- txtWriter->write_coordinates(mesh->coords, mesh->nno, mesh->nsd);
- txtWriter->write_connectivity(mesh->connect, mesh->nel, mesh->ndofs);
- txtWriter->close();
+ textWriter->write_coordinates(mesh->coords, mesh->nno, mesh->nsd);
+ textWriter->write_connectivity(mesh->connect, mesh->nel, mesh->ndofs);
+ textWriter->close();
}
else if (writer->getType() == Writer::VTK_WRITER)
{
VtkWriter *vtkWriter = static_cast<VtkWriter*>(writer);
- ierr = vtkWriter->open(output_filename);
+ ierr = vtkWriter->open(output_filename.c_str());
if (ierr < 0)
{
cerr << "Error: Could not create output VTK file " << output_filename << endl;
Modified: cs/benchmark/cigma/trunk/src/ListCmd.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/ListCmd.cpp 2008-03-19 19:00:23 UTC (rev 11483)
+++ cs/benchmark/cigma/trunk/src/ListCmd.cpp 2008-03-19 19:00:25 UTC (rev 11484)
@@ -2,6 +2,7 @@
#include <cstdlib>
#include <cassert>
#include <string>
+
#include "ListCmd.h"
#include "VtkList.h"
#include "StringUtils.h"
@@ -84,14 +85,10 @@
ret = system(cmd.c_str());
return ret;
}
- else if (extension == ".vtk")
+ else if ((extension == ".vtk") || (extension == ".vts"))
{
- list_vtk(filename.c_str());
+ vtk_list(filename.c_str());
}
- else if (extension == ".vts")
- {
- list_vts(filename.c_str());
- }
else
{
cerr << "list: File extensions must be HDF5(.h5) or VTK(.vtk, .vts)"
Modified: cs/benchmark/cigma/trunk/src/VtkList.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/VtkList.cpp 2008-03-19 19:00:23 UTC (rev 11483)
+++ cs/benchmark/cigma/trunk/src/VtkList.cpp 2008-03-19 19:00:25 UTC (rev 11484)
@@ -1,61 +1,20 @@
#include <cassert>
+#include <cstdlib>
+
#include "VtkList.h"
+#include "VtkReader.h"
-#include "vtkDataSetReader.h"
-#include "vtkXMLStructuredGridReader.h"
-
#include "vtkDataSet.h"
-#include "vtkStructuredGrid.h"
-
#include "vtkPointData.h"
#include "vtkCellData.h"
-#include "vtkDataArray.h"
-
using namespace std;
+using namespace cigma;
-
// ---------------------------------------------------------------------------
-/*
-VtkFileType getFileType(vtkDataSetReader *reader)
+static void list_data(vtkDataSet *dataset)
{
- // XXX: are these mutually exclusive?
- if (reader->IsFilePolyData())
- return VTK_FILE_POLYDATA;
- if (reader->IsFileStructuredPoints())
- return VTK_FILE_STRUCTURED_POINTS;
- if (reader->IsFileStructuredGrid())
- return VTK_FILE_STRUCTURED_GRID;
- if (reader->IsFileUnstructuredGrid())
- return VTK_FILE_UNSTRUCTURED_GRID;
- if (reader->IsFileRectilinearGrid())
- return VTK_FILE_RECTILINEAR_GRID;
- return VTK_FILE_NONE;
-
-} // */
-
-
-const char *getFileTypeName(VtkFileType fileType)
-{
- if (fileType == VTK_FILE_POLYDATA)
- return "polydata";
- if (fileType == VTK_FILE_STRUCTURED_POINTS)
- return "structured points";
- if (fileType == VTK_FILE_STRUCTURED_GRID)
- return "structured grid";
- if (fileType == VTK_FILE_UNSTRUCTURED_GRID)
- return "unstructured grid";
- if (fileType == VTK_FILE_RECTILINEAR_GRID)
- return "rectilinear grid";
- return "none";
-}
-
-
-// ---------------------------------------------------------------------------
-
-void vtkls(vtkDataSet *dataset)
-{
assert(dataset != 0);
vtkPointData *pointData = dataset->GetPointData();
@@ -123,128 +82,20 @@
return;
}
-
// ---------------------------------------------------------------------------
-void list_vtk(const char *filename)
+void vtk_list(const char *filename)
{
- int outputType;
- vtkDataSetReader *reader = vtkDataSetReader::New();
+ VtkReader vtkreader;
+ vtkreader.open(filename);
- reader->SetFileName(filename);
- cout << "Reading " << filename << endl;
-
- int ierr = -1;
-
- ierr = reader->OpenVTKFile(); // does file exist?
- if (ierr == 0)
+ if (vtkreader.dataset != 0)
{
- cerr << "Could not open " << filename << endl;
- exit(1);
+ list_data(vtkreader.dataset);
}
-
- ierr = reader->ReadHeader(); // is the vtk header present?
- if (ierr == 0)
+ else
{
- cerr << "Unrecognized file " << filename << endl;
- exit(1);
- }
-
- outputType = reader->ReadOutputType();
- if (outputType < 0)
- {
- cerr << "Invalid VTK file? " << filename << endl;
- exit(1);
- }
-
-
- // ---------------------------------------------------
- reader->Update();
- //reader->PrintSelf(cout, 0);
-
- vtkDataSet *dataset = reader->GetOutput();
- //dataset->PrintSelf(cout, 0);
-
- const bool group_by_arrays = true;
- const bool group_by_class = false;
-
- if (group_by_arrays)
- {
- vtkls(dataset);
- }
-
- if (group_by_class)
- {
- int n, i;
-
- n = reader->GetNumberOfFieldDataInFile();
- for (i = 0; i < n; i++)
- {
- const char *name = reader->GetFieldDataNameInFile(i);
- //cout << "Number of field data = " << n << endl;
- cout << "FieldData[" << i << "] = " << name;
- cout << endl;
- }
-
- n = reader->GetNumberOfScalarsInFile();
- //cout << "Number of scalars = " << n << endl;
- for (i = 0; i < n; i++)
- {
- const char *name = reader->GetScalarsNameInFile(i);
- cout << "Scalars[" << i << "] = " << name;
- cout << endl;
- }
-
- n = reader->GetNumberOfVectorsInFile();
- //cout << "Number of vectors = " << n << endl;
- for (i = 0; i < n; i++)
- {
- const char *name = reader->GetVectorsNameInFile(i);
- cout << "Vectors[" << i << "] = " << name;
- cout << endl;
- }
-
- n = reader->GetNumberOfTensorsInFile();
- //cout << "Number of tensors = " << n << endl;
- for (i = 0; i < n; i++)
- {
- const char *name = reader->GetTensorsNameInFile(i);
- cout << "Tensors[" << i << "] = " << name;
- cout << endl;
- }
- }
-
- reader->Delete();
-
- return;
-}
-
-
-void list_vts(const char *filename)
-{
- vtkXMLStructuredGridReader *reader = vtkXMLStructuredGridReader::New();
-
- int canReadFile = 0;
- canReadFile = reader->CanReadFile(filename);
-
- if (!canReadFile)
- {
cerr << "Could not read " << filename << endl;
exit(1);
}
-
- reader->SetFileName(filename);
- cout << "Reading " << filename << endl;
-
- reader->Update();
- //reader->PrintSelf(cout, 0);
-
- vtkStructuredGrid *sgrid = reader->GetOutput();
- vtkDataSet *dataset = static_cast<vtkDataSet*>(sgrid);
-
- vtkls(dataset);
-
- reader->Delete();
}
-
-// ---------------------------------------------------------------------------
Modified: cs/benchmark/cigma/trunk/src/VtkList.h
===================================================================
--- cs/benchmark/cigma/trunk/src/VtkList.h 2008-03-19 19:00:23 UTC (rev 11483)
+++ cs/benchmark/cigma/trunk/src/VtkList.h 2008-03-19 19:00:25 UTC (rev 11484)
@@ -1,21 +1,6 @@
#ifndef __VTK_LIST_H__
#define __VTK_LIST_H__
+void vtk_list(const char *filename);
-typedef enum {
- VTK_FILE_NONE,
- VTK_FILE_POLYDATA,
- VTK_FILE_STRUCTURED_POINTS,
- VTK_FILE_STRUCTURED_GRID,
- VTK_FILE_UNSTRUCTURED_GRID,
- VTK_FILE_RECTILINEAR_GRID
-} VtkFileType;
-
-//VtkFileType getFileType(vtkDataSetReader *reader);
-const char *getFileTypeName(VtkFileType fileType);
-
-void list_vtk(const char *filename);
-void list_vts(const char *filename);
-
-
#endif
More information about the cig-commits
mailing list