Changeset 334 for trunk/src


Ignore:
Timestamp:
Mar 12, 2006 8:29:56 PM (18 years ago)
Author:
cxsong
Message:

added linkage to mesh and handling, addValue etc.

Location:
trunk/src/mesh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mesh/field.cc

    r327 r334  
    55#include "field.h"
    66
    7 void RpField::setMesh(const char* meshId)
    8 {
    9         m_meshName.assign(meshId);
     7RP_ERROR RpField::setMeshObj(RpSerializable* mesh)
     8{
     9        if (mesh) {
     10                m_mesh = mesh;
     11                return RP_SUCCESS;
     12        }
     13        else {
     14                return RP_ERR_NULL_PTR;
     15        }
    1016}
    1117
  • trunk/src/mesh/field.h

    r327 r334  
    33
    44//
    5 // class for field values
     5// Class for field object
     6//
     7// Example usage:
     8//      mesh = new RpGrid2d;
     9//      mesh->addAllPoints(x,y);
     10//      field = new RpField;
     11//      field->addValues(val);
     12//
    613//
    714
     
    1320public:
    1421        // constructors
    15         RpField() { };
     22        RpField() { m_mesh = NULL; };
    1623
    17         RpField(int size) : RpGrid1d(size) { };
     24        RpField(int size) : RpGrid1d(size) { m_mesh = NULL; };
    1825
    19         RpField(const char* name, int size=0) : RpGrid1d(name,size) { };
     26        RpField(const char* name, int size=0) : RpGrid1d(name,size)
     27                { m_mesh = NULL; };
    2028
    21         // set mesh link
    22         void setMesh(const char* meshId);
     29        // set name of mesh object used in field
     30        void setMeshId(const char* meshId) { m_meshName.assign(meshId); };
     31
     32        // set name of mesh object used in field
     33        RP_ERROR setMeshObj(RpSerializable* meshPtr);
     34
     35        // remove mesh - only erase name and remove ptr (not free memory as serializer manages the object memory)
     36        void removeMesh();
     37
     38        const char* getMeshId() { return m_meshName.c_str(); };
     39        RpSerializable* getMeshObj() { return m_mesh; };
    2340
    2441        // return number of bytes needed for serialization
     
    2744        // return object type as a char string
    2845        virtual const char* objectType();
     46
     47        virtual RP_ERROR addAllValues(double* val, int nitems) {
     48                return RpGrid1d::addAllPoints(val, nitems);
     49        };
     50
     51        virtual void addValue(double val) {
     52                RpGrid1d::addPoint(val);
     53        };
    2954
    3055        // serialize data
     
    5782private:
    5883        std::string m_meshName; // mesh
     84        RpSerializable* m_mesh; // pointer to mesh object
    5985};
    6086
Note: See TracChangeset for help on using the changeset viewer.