Changeset 188 for trunk


Ignore:
Timestamp:
Feb 17, 2006 8:30:27 AM (18 years ago)
Author:
cxsong
Message:

added sets

Location:
trunk/src/mesh
Files:
2 edited

Legend:

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

    r187 r188  
    44// assign value to coordinate[index]
    55//
    6 RP_ERROR RpNode::set(int val, int index)
     6RP_ERROR
     7RpNode::set(int val, int index)
    78{
    89        RP_ERROR err = RP_SUCCESS;
     
    1011        if (index < m_dim)
    1112                m_node[index] = val;
     13        else {
     14                RpAppendErr("RpNode::set: index out of bound");
     15                RpPrintErr();
     16                err = RP_ERR_OUTOFBOUND_INDEX;
     17        }
     18
     19        return err;
     20}
     21
     22void
     23RpNode::setNode2d(int xval, int yval, const char* id)
     24{
     25        m_node.resize(2);
     26
     27        m_dim = 2;
     28        m_node[0] = xval;
     29        m_node[1] = yval;
     30        m_id = id;
     31}
     32
     33void
     34RpNode::setNode3d(int xval, int yval, int zval, const char* id)
     35{
     36        m_node.resize(3);
     37
     38        m_dim = 3;
     39        m_node[0] = xval;
     40        m_node[1] = yval;
     41        m_node[2] = zval;
     42        m_id = id;
     43}
     44
     45RP_ERROR
     46RpNode::get(int& val, int index)
     47{
     48        RP_ERROR err = RP_SUCCESS;
     49
     50        if (index < m_dim)
     51                val =  m_node[index];
    1252        else {
    1353                RpAppendErr("RpNode::set: index out of bound");
  • trunk/src/mesh/node.h

    r187 r188  
    1010public:
    1111        // constructors (default to 2d node)
    12         RpNode(int dim=2):
    13                 m_dim(dim)
     12        RpNode(int dim=2, const char* id=NULL):
     13                m_dim(dim),
     14                m_id(id)
    1415        {
    1516                m_node.resize(dim);
     
    1819        // assign value to coordinate[index]
    1920        RP_ERROR set(int val, int index);
     21        RP_ERROR get(int& val, int index);
     22
     23        void setNode2d(int x, int y, const char* id);
     24        void setNode3d(int x, int y, int z, const char* id);
     25
     26        const char* id() { return m_id.c_str(); };
     27        void id(const char* id) { m_id = id; };
    2028
    2129        char* serialize();
     
    3038        vector<int> m_node;
    3139        int m_dim;
     40        std::string m_id;
    3241};
    3342
Note: See TracChangeset for help on using the changeset viewer.