[cig-commits] r9054 - cs/benchmark/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Mon Jan 14 21:28:31 PST 2008


Author: luis
Date: 2008-01-14 21:28:31 -0800 (Mon, 14 Jan 2008)
New Revision: 9054

Added:
   cs/benchmark/cigma/trunk/src/vtkls.cpp
Modified:
   cs/benchmark/cigma/trunk/src/Makefile
Log:
Utility for examining structure of vtk files


Modified: cs/benchmark/cigma/trunk/src/Makefile
===================================================================
--- cs/benchmark/cigma/trunk/src/Makefile	2008-01-15 05:28:30 UTC (rev 9053)
+++ cs/benchmark/cigma/trunk/src/Makefile	2008-01-15 05:28:31 UTC (rev 9054)
@@ -29,6 +29,7 @@
 	Field.o \
 	FE_Field.o \
 	ExternalField.o \
+	Reader.o \
 	TextReader.o \
 	HdfReader.o \
 	VtkUgReader.o \
@@ -48,7 +49,7 @@
 	Misc.o \
 
 
-default: testlib cigma tests
+default: testlib cigma vtkls tests
 
 %.o: %.cpp
 	$(CXX) $(FLAGS) -c $^
@@ -66,11 +67,14 @@
 cigma: cigma.o $(TESTLIB)
 	$(CXX) $(LDFLAGS) $^ -o $@
 
+vtkls: vtkls.o $(TESTLIB)
+	$(CXX) $(LDFLAGS) $^ -o $@
+
 tests: $(TESTLIB)
 	cd tests/ && make
 
 clean:
-	rm -f $(OBJS) cigma.o
+	rm -f $(OBJS) cigma.o vtkls.o
 
 purge: clean
 	rm -f $(TESTLIB)

Added: cs/benchmark/cigma/trunk/src/vtkls.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/vtkls.cpp	2008-01-15 05:28:30 UTC (rev 9053)
+++ cs/benchmark/cigma/trunk/src/vtkls.cpp	2008-01-15 05:28:31 UTC (rev 9054)
@@ -0,0 +1,119 @@
+#include <iostream>
+#include <cstdlib>
+#include <cassert>
+
+#include "AnyOption.h"
+//#include "VtkUgReader.h"
+
+#include <vtkDataSetReader.h>
+#include <vtkDataSet.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
+
+
+using namespace std;
+
+
+
+// ---------------------------------------------------------------------------
+int main(int argc, char *argv[])
+{
+    AnyOption *opt = new AnyOption();
+
+    if (argc != 2)
+    {
+        cerr << "Usage: " << argv[0] << " " << "file.vtk" << endl;
+        exit(1);
+    }
+    cout << "Reading " << argv[1] << endl;
+
+    // ------------------------------------------------------
+    cout << "<< Creating vtkDataSetReader" << endl;
+    vtkDataSetReader *reader = vtkDataSetReader::New();
+    reader->SetFileName(argv[1]);
+
+    bool is_pd = reader->IsFilePolyData();
+    cout << "Is file poly data? " << is_pd << endl;
+    bool is_sp = reader->IsFileStructuredPoints();
+    cout << "Is file structured points? " << is_sp << endl;
+    bool is_sg = reader->IsFileStructuredGrid();
+    cout << "Is file structured grid? " << is_sg << endl;
+    bool is_ug = reader->IsFileUnstructuredGrid();
+    cout << "Is file unstructured grid? " << is_ug << endl;
+    bool is_rg = reader->IsFileRectilinearGrid();
+    cout << "Is file rectilinear grid? " << is_rg << endl;
+    bool is_valid = is_pd || is_sp || is_sg || is_ug || is_rg;
+    assert(is_valid);
+
+
+    //cout << reader->GetHeader() << endl;
+    
+
+    reader->Update();
+    //reader->PrintSelf(cout, 0);
+
+
+    
+
+    int i,n;
+
+    n = reader->GetNumberOfFieldDataInFile();
+    cout << "Number of field data = " << n << endl;
+    for (i = 0; i < n; i++)
+    {
+        const char *name = reader->GetFieldDataNameInFile(i);
+        cout << "\t" << name << endl;
+    }
+
+    n = reader->GetNumberOfScalarsInFile();
+    cout << "Number of scalars = " << n << endl;
+    for (i = 0; i < n; i++)
+    {
+        const char *name = reader->GetScalarsNameInFile(i);
+        cout << "\t" << name << endl;
+    }
+
+    n = reader->GetNumberOfVectorsInFile();
+    cout << "Number of vectors = " << n << endl;
+    for (i = 0; i < n; i++)
+    {
+        const char *name = reader->GetVectorsNameInFile(i);
+        cout << "\t" << name << endl;
+    }
+
+    n = reader->GetNumberOfTensorsInFile();
+    cout << "Number of tensors = " << n << endl;
+    for (i = 0; i < n; i++)
+    {
+        const char *name = reader->GetTensorsNameInFile(i);
+        cout << "\t" << name << endl;
+    }
+
+    // ------------------------------------------------------
+    cout << "<< Creating vtkDataSet" << endl;
+    vtkDataSet *dataset = reader->GetOutput();
+    //dataset->PrintSelf(cout, 0);
+
+    int nno,nel;
+    nno = dataset->GetNumberOfPoints();
+    nel = dataset->GetNumberOfCells();
+    cout << "Number of points = " << nno << endl;
+    cout << "Number of cells = " << nel << endl;
+
+
+    // ------------------------------------------------------
+    cout << "<< Creating vtkPointData" << endl;
+    vtkPointData *pointData = dataset->GetPointData();
+    //pointData->PrintSelf(cout, 0);
+
+    // ------------------------------------------------------
+    cout << "<< Creating vtkCellData" << endl;
+    vtkCellData *cellData = dataset->GetCellData();
+    //cellData->PrintSelf(cout, 0);
+
+    // ------------------------------------------------------
+    cout << "<< Sleeping..." << endl;
+    sleep(100);
+
+    return 0;
+}



More information about the cig-commits mailing list