<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'><br><br><hr id="zwchr"><blockquote id="DWT9701" style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;">Hi all,<br>I have a request regarding the get_coord() interface function.<br><br>Would it be possible to add a method like the following<br><br>ErrorCode get_coords( const EntityHandle* entity_handles,<br> const int num_entities,<br> double* x_coords,<br> double* y_coords,<br> double* z_coords )<br><br>This would allow me to get the coords in contiguous chunks for a set of ordered entity handles.<br>Have I missed an obvious way to do such a thing using the actual interface?<br><br>Clearly I can call<br><br>ErrorCode get_coords( const EntityHandle* entity_handles,<br> const int num_entities,<br> double* coords)<br><br>and then reorganize the coords as I like... but the addition would allow me to save some time. <br><br>Hope not to have bothered you with such a subtle request. <br>Thanks for help.<br><br>Lorenzo</blockquote>Hello,<br>If your entities are contiguous, you can try using this:<br><br> //! get pointers to coordinate data<br> /** BEWARE, THIS GIVES ACCESS TO MOAB'S INTERNAL STORAGE, USE WITH CAUTION!<br> * This function returns pointers to MOAB's internal storage for vertex coordinates.<br> * Access is similar to tag_iterate, see documentation for that function for details<br> * about arguments and a coding example.<br> */<br> virtual ErrorCode coords_iterate(Range::const_iterator iter,<br> /**< Iterator to first entity you want coordinates for */<br> Range::const_iterator end,<br> /**< Iterator to last entity you want coordinates for */<br> double*& xcoords_ptr,<br> /**< Pointer to x coordinate storage for these entities */<br> double*& ycoords_ptr,<br> /**< Pointer to y coordinate storage for these entities */<br> double*& zcoords_ptr,<br> /**< Pointer to z coordinate storage for these entities */<br> int& count<br> /**< Number of entities for which returned pointers are valid/contiguous */<br> ) = 0;<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"></blockquote><br>It gives access to moab internal data (actually, vertex coordinates are stored in blocked format, internally, not interleaved)<br>if your returned count and size of range you pass in is the same, you are done, you have a pointer to the coordinates in block format (of course, do not modify them!!)<br><br>Also, you can use this, if you need all vertices.<br>//! Get blocked vertex coordinates for all vertices<br>
/** Blocked = all x, then all y, etc. <br>
<br>
Example: \code<br>
std::vector<double> coords;<br>
get_vertex_coordinates(coords);<br>
double xavg = 0;<br>
for (int i = 0; i < coords.size()/3; i++) xavg += coords[i]; \endcode<br>
*/<br>
virtual ErrorCode get_vertex_coordinates(std::vector<double> &coords) const =0;<br><br>If your vertices are not contiguous, then you should do what imesh is doing:<br><br>if (storage_order == iBase_INTERLEAVED) {<br>...<br>}<br>else { // iBase_BLOCKED<br> std::vector<double> dum_coords(3*vertex_handles_size);<br> result = MOABI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles),<br> vertex_handles_size,<br> &dum_coords[0]);<br> CHKERR(result,"iMesh_getVtxArrCoords: problem getting vertex coords");<br><br> for (int i = 0; i < vertex_handles_size; i++) {<br> for (int j = 0; j < geom_dim; j++)<br> (*coords)[i + vertex_handles_size*j] = dum_coords[3*i + j];<br> }<br> }<br></div></body></html>