[cig-commits] r13753 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Dec 17 02:33:10 PST 2008


Author: luis
Date: 2008-12-17 02:33:10 -0800 (Wed, 17 Dec 2008)
New Revision: 13753

Modified:
   cs/cigma/trunk/src/io_vtk_reader.cpp
   cs/cigma/trunk/src/io_vtk_reader.h
Log:
Return objects directly from the reader class

Modified: cs/cigma/trunk/src/io_vtk_reader.cpp
===================================================================
--- cs/cigma/trunk/src/io_vtk_reader.cpp	2008-12-17 10:33:08 UTC (rev 13752)
+++ cs/cigma/trunk/src/io_vtk_reader.cpp	2008-12-17 10:33:10 UTC (rev 13753)
@@ -5,10 +5,13 @@
 #ifdef HAVE_VTK
 
 //
+// This is the implementation of VtkReader when the preprocessor
+// variable HAVE_VTK has been defined.
 //
-//
 
 #include "Filesystem.h"
+#include "nc_array.h"
+#include "eb_array.h"
 
 #include "vtkUnstructuredGridReader.h"
 #include "vtkStructuredGridReader.h"
@@ -34,6 +37,7 @@
 
 
 using namespace std;
+using namespace boost;
 using namespace cigma;
 
 
@@ -143,6 +147,7 @@
     return vtk_read_coordinates<double>(this->dataset, loc, coordinates, nno, nsd);
 }
 
+
 int VtkReader::getConnectivity(const char *loc, int **connectivity, int *nel, int *ndofs)
 {
     TRI_LOG_STR("VtkReader::getConnectivity()");
@@ -181,6 +186,85 @@
 }
 
 
+shared_ptr<MeshPart> VtkReader::getMesh()
+{
+    TRI_LOG_STR("VtkReader::getMesh()");
+
+    shared_ptr<MeshPart> mesh;
+    int status;
+
+    int npts, ndim;
+    double *coords = 0;
+    status = this->getCoordinates("", &coords, &npts, &ndim);
+    if (status < 0)
+    {
+        if (coords) { delete [] coords; }
+        return mesh;
+    }
+    shared_ptr<nc_array> nc(new nc_array);
+    nc->nno = npts;
+    nc->nsd = ndim;
+    nc->coords = coords;
+
+    int nel, ndofs;
+    int *connect = 0;
+    status = this->getConnectivity("", &connect, &nel, &ndofs);
+    if (status < 0)
+    {
+        if (connect) { delete [] connect; }
+        return mesh;
+    }
+    shared_ptr<eb_array> eb(new eb_array);
+    eb->nel = nel;
+    eb->ndofs = ndofs;
+    eb->connect = connect;
+
+
+    mesh = shared_ptr<MeshPart>(new MeshPart);
+    mesh->coords = nc;
+    mesh->connect = eb;
+    mesh->cell_type = this->getCellType(0);
+
+    return mesh;
+}
+
+
+shared_ptr<FE> VtkReader::getFE()
+{
+    TRI_LOG_STR("VtkReader::getFE()");
+    Cell::type celltype = this->getCellType(0);
+    TRI_LOG(Cell::type2string(celltype));
+    shared_ptr<FE> fe(new FE(celltype));
+    return fe;
+}
+
+
+shared_ptr<DofHandler> VtkReader::getDofs(const char *loc)
+{
+    TRI_LOG_STR("VtkReader::getDofs()");
+    TRI_LOG(loc);
+
+    shared_ptr<DofHandler> dofs;
+    int status;
+
+    int nno, rank;
+    double *data = 0;
+    status = this->getDataset(loc, &data, &nno, &rank);
+    if (status < 0)
+    {
+        if (data) { delete [] data; }
+        return dofs;
+    }
+
+    dofs = shared_ptr<DofHandler>(new DofHandler);
+    dofs->nno = nno;
+    dofs->rank = rank;
+    dofs->dofs = data;
+
+    return dofs;
+}
+
+
 int vtk_print_contents(const char *filename)
 {
     TRI_LOG_STR("vtk_print_contents()");
@@ -255,12 +339,11 @@
 #else
 
 //
+// Default implementation
 //
-//
 
 
-#include "Cell.h"
-
+using namespace boost;
 using namespace cigma;
 
 
@@ -304,6 +387,24 @@
     return Cell::NONE;
 }
 
+shared_ptr<MeshPart> VtkReader::getMesh()
+{
+    shared_ptr<MeshPart> mesh;
+    return mesh;
+}
+
+shared_ptr<FE> VtkReader::getFE()
+{
+    shared_ptr<FE> fe;
+    return fe;
+}
+
+shared_ptr<DofHandler> VtkReader::getDofs(const char *loc)
+{
+    shared_ptr<DofHandler> dofs;
+    return dofs;
+}
+
 int vtk_print_contents(const char *filename)
 {
     throw cigma::Exception("vtk_print_contents", "Error: Cigma not configured with VTK library", 1);

Modified: cs/cigma/trunk/src/io_vtk_reader.h
===================================================================
--- cs/cigma/trunk/src/io_vtk_reader.h	2008-12-17 10:33:08 UTC (rev 13752)
+++ cs/cigma/trunk/src/io_vtk_reader.h	2008-12-17 10:33:10 UTC (rev 13753)
@@ -1,12 +1,18 @@
 #ifndef __CIGMA_VTK_READER_H__
 #define __CIGMA_VTK_READER_H__
 
-#include "Common.h"
 #include "io_file_reader.h"
 #include "io_vtk.h" // for GridType enum
+
+#include <boost/shared_ptr.hpp>
+#include "Common.h"
 #include "Cell.h"
+#include "MeshPart.h"
+#include "FE.h"
+#include "DofHandler.h"
 
 #ifdef HAVE_VTK
+#include "vtkDataSet.h"
 #include "vtkDataSetReader.h"
 #include "vtkXMLDataReader.h"
 #endif
@@ -35,6 +41,10 @@
 
     Cell::type getCellType(int id) const;
 
+    boost::shared_ptr<MeshPart>     getMesh();
+    boost::shared_ptr<FE>           getFE();
+    boost::shared_ptr<DofHandler>   getDofs(const char *loc);
+
 #ifdef HAVE_VTK
 public:
     vtkGridType gridType;



More information about the CIG-COMMITS mailing list