Changeset 246 for trunk/src/mesh
- Timestamp:
- Mar 1, 2006 11:59:54 AM (18 years ago)
- Location:
- trunk/src/mesh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mesh/mesh.cc
r241 r246 85 85 { 86 86 if (m_nodeIndex < m_numNodes) { 87 m_nodeList[m_nodeIndex].id(m_nodeIndex); 87 88 m_nodeList[m_nodeIndex++].set(nodeVal); 88 89 return RP_SUCCESS; … … 110 111 111 112 if (m_elemIndex < m_numElements) { 113 (*m_elemList)[m_elemIndex].id(m_elemIndex); 112 114 (*m_elemList)[m_elemIndex++].addNodes(nodes, numNodes); 115 113 116 return RP_SUCCESS; 114 117 } … … 148 151 int numNodes = (*m_elemList)[0].numNodes(); 149 152 for (int i=0; i < m_numElements; i++) { 153 (*m_elemList)[i].id(i); 150 154 (*m_elemList)[i].addNodes(&(elemArray[i*numNodes]), numNodes); 151 155 } … … 182 186 // 183 187 RP_ERROR 184 RpMesh3d::getNodesList(int * nodesList, int& numNodes)188 RpMesh3d::getNodesList(int& numNodes, int* nodesList) 185 189 { 186 190 if (nodesList == NULL) … … 198 202 } 199 203 204 // 205 // Returns the nodes in element in outList 206 // 207 RP_ERROR 208 RpMesh3d::getElement(int seqnum, int* outList) 209 { 210 if (outList == NULL) 211 return RP_ERR_NULL_PTR; 212 213 if (seqnum > m_numElements) 214 return RP_ERR_INVALID_INDEX; 215 216 int nn = (*m_elemList)[seqnum].numNodes(); 217 (*m_elemList)[seqnum].getNodeIdList(outList, nn); 218 219 return RP_SUCCESS; 220 } 221 222 // 223 // Returns all elements in a mesh and store in an int array 224 // 225 // 226 RP_ERROR 227 RpMesh3d::getAllElements(int numElements, int* outList) 228 { 229 if (outList == NULL) 230 return RP_ERR_NULL_PTR; 231 232 if (numElements > m_numElements) 233 return RP_ERR_INVALID_INDEX; 234 235 // get number of nodes in each element 236 int numNodes = (*m_elemList)[0].numNodes(); 237 238 for (int i=0; i < m_numElements; i++) { 239 getElement(i, &(outList[i*numNodes])); 240 } 241 242 return RP_SUCCESS; 243 } 244 245 200 246 RpElement 201 RpMesh3d::getElement(int elemSeqNum) 202 { 203 return RP_SUCCESS; 204 } 205 206 RP_ERROR 207 RpMesh3d::getElement(int elemSeqNum, int* nodesBuf) 208 { 209 return RP_SUCCESS; 247 RpMesh3d::getElement(int seqnum) 248 { 249 if (seqnum > m_numElements) 250 return RP_ERR_INVALID_INDEX; 251 252 return (*m_elemList)[seqnum]; 210 253 } 211 254 … … 233 276 RpMesh3d::xmlString(std::string& textString) 234 277 { 278 if (!m_numNodes) 279 return; 280 235 281 // temp char string 236 282 char cstr[256]; … … 266 312 } 267 313 314 void 315 RpMesh3d::erase() 316 { 317 int i; 318 319 m_id.erase(); 320 m_numNodes = m_numElements = m_nodeIndex = m_elemIndex = 0; 321 322 // zero out element list 323 for (i=0; i < m_numElements; i++) 324 (*m_elemList)[i].erase(); 325 326 // zero out nodes list 327 for (i=0; i < m_numNodes; i++) 328 m_nodeList[i].erase(); 329 } 330 268 331 RpMesh3d::~RpMesh3d() 269 332 { 270 delete []m_elemList;271 } 272 333 delete m_elemList; 334 } 335 -
trunk/src/mesh/mesh.h
r241 r246 16 16 int numNodes() { return m_numNodes; }; 17 17 int numElements() { return m_numElements; }; 18 int elementSize() { return (*m_elemList)[0].numNodes(); }; 18 19 const char* id() { return m_id.c_str(); }; 19 20 … … 38 39 void getNode(int nodeSeqNum, int* x, int* y, int* z); 39 40 RP_ERROR getNode(int nodeSeqNum, RpNode3d& node); 40 RP_ERROR getNodesList(int * nodesList, int& num);41 RP_ERROR getNodesList(int& num, int* nodesList); 41 42 42 43 RpElement getElement(int elemSeqNum); 43 44 RP_ERROR getElement(int elemSeqNum, int* nodesBuf); 45 RP_ERROR getAllElements(int num, int* buf); 44 46 45 47 // serialization … … 50 52 void xmlString(std::string& str); 51 53 void print(); 54 55 // erase all nodes and elements, capacity not changed. 56 void erase(); 52 57 53 58 virtual ~RpMesh3d();
Note: See TracChangeset
for help on using the changeset viewer.