[MOAB-dev] one more get_coord option

Iulian Grindeanu iulian at mcs.anl.gov
Wed Jul 11 12:36:31 CDT 2012


----- Original Message -----
| Hi all,
| I have a request regarding the get_coord() interface function.
| Would it be possible to add a method like the following
| ErrorCode get_coords( const EntityHandle* entity_handles,
| const int num_entities,
| double* x_coords,
| double* y_coords,
| double* z_coords )
| This would allow me to get the coords in contiguous chunks for a set
| of ordered entity handles.
| Have I missed an obvious way to do such a thing using the actual
| interface?
| Clearly I can call
| ErrorCode get_coords( const EntityHandle* entity_handles,
| const int num_entities,
| double* coords)
| and then reorganize the coords as I like... but the addition would
| allow me to save some time.
| Hope not to have bothered you with such a subtle request.
| Thanks for help.
| Lorenzo
Hello, If your entities are contiguous, you can try using this: //! get pointers to coordinate data /** BEWARE, THIS GIVES ACCESS TO MOAB'S INTERNAL STORAGE, USE WITH CAUTION! * This function returns pointers to MOAB's internal storage for vertex coordinates. * Access is similar to tag_iterate, see documentation for that function for details * about arguments and a coding example. */ virtual ErrorCode coords_iterate(Range::const_iterator iter, /**< Iterator to first entity you want coordinates for */ Range::const_iterator end, /**< Iterator to last entity you want coordinates for */ double*& xcoords_ptr, /**< Pointer to x coordinate storage for these entities */ double*& ycoords_ptr, /**< Pointer to y coordinate storage for these entities */ double*& zcoords_ptr, /**< Pointer to z coordinate storage for these entities */ int& count /**< Number of entities for which returned pointers are valid/contiguous */ ) = 0; It gives access to moab internal data (actually, vertex coordinates are stored in blocked format, internally, not interleaved) 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!!) Also, you can use this, if you need all vertices. //! Get blocked vertex coordinates for all vertices /** Blocked = all x, then all y, etc. Example: \code std::vector<double> coords; get_vertex_coordinates(coords); double xavg = 0; for (int i = 0; i < coords.size()/3; i++) xavg += coords[i]; \endcode */ virtual ErrorCode get_vertex_coordinates(std::vector<double> &coords) const =0; If your vertices are not contiguous, then you should do what imesh is doing: if (storage_order == iBase_INTERLEAVED) { ... } else { // iBase_BLOCKED std::vector<double> dum_coords(3*vertex_handles_size); result = MOABI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), vertex_handles_size, &dum_coords[0]); CHKERR(result,"iMesh_getVtxArrCoords: problem getting vertex coords"); for (int i = 0; i < vertex_handles_size; i++) { for (int j = 0; j < geom_dim; j++) (*coords)[i + vertex_handles_size*j] = dum_coords[3*i + j]; } }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20120711/c8f43292/attachment.html>


More information about the moab-dev mailing list