[MOAB-dev] r4430 - MOAB/trunk/itaps/imesh

Iulian Grindeanu iulian at mcs.anl.gov
Thu Jan 13 18:56:36 CST 2011


Hello,
I have a problem now;
I was doing some dynamic casting in meshkit, moab::Interface <-> iMesh instance
These will not work anymore. What should be the preferred way to get it now?

mb = reinterpret_cast<MBInterface *> (m_mesh);

(So how do I get now moab::Interface from iMesh instance?)

I see that in iMesh_MOAB we do something like
static inline MBiMesh* MBI_cast( iMesh_Instance i )  
  { return reinterpret_cast<MBiMesh*>(i); }         
#define MBI MBI_cast(instance)->mbImpl

Which would be 'reinterpret_cast<MBiMesh*>(instance)->mbImpl'

This also assumes the MBiMesh is included (defined) in the code

Is there a better way? 

maybe define a macro somewhere, too?

Thanks,
Iulian

----- Original Message -----
> Author: tautges
> Date: 2011-01-11 11:54:19 -0600 (Tue, 11 Jan 2011)
> New Revision: 4430
> 
> Added:
> MOAB/trunk/itaps/imesh/MBiMesh.hpp
> Modified:
> MOAB/trunk/itaps/imesh/MOAB_iMesh_unit_tests.cpp
> MOAB/trunk/itaps/imesh/Makefile.am
> MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
> MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp
> Log:
> Change initialization of iMesh so the resulting class object (MBiMesh)
> hasA moab::Interface * instead of isA moab::Core*. Makes it possible
> to
> initialize iMesh with an existing moab::Interface object.
> 
> 
> 
> 
> Added: MOAB/trunk/itaps/imesh/MBiMesh.hpp
> ===================================================================
> --- MOAB/trunk/itaps/imesh/MBiMesh.hpp (rev 0)
> +++ MOAB/trunk/itaps/imesh/MBiMesh.hpp 2011-01-11 17:54:19 UTC (rev
> 4430)
> @@ -0,0 +1,73 @@
> +#ifndef MBIMESH_HPP
> +#define MBIMESH_HPP
> +
> +#include "moab/Core.hpp"
> +using namespace moab;
> +
> +class MBiMesh
> +{
> +private:
> + bool haveDeletedEntities;
> + bool iCreatedInterface;
> +public:
> + MBiMesh(moab::Interface *mbImpl = NULL);
> +
> + virtual ~MBiMesh();
> + bool have_deleted_ents( bool reset ) {
> + bool result = haveDeletedEntities;
> + if (reset)
> + haveDeletedEntities = false;
> + return result;
> + }
> +
> + virtual ErrorCode delete_mesh();
> + virtual ErrorCode delete_entities( const EntityHandle*, const int );
> + virtual ErrorCode delete_entities( const Range& );
> + int AdjTable[16];
> + moab::Interface *mbImpl;
> +};
> +
> +#define MBimesh reinterpret_cast<MBiMesh*>(instance)
> +
> +inline MBiMesh::MBiMesh(Interface *impl)
> + : haveDeletedEntities(false), iCreatedInterface(false), mbImpl(impl)
> +{
> + int tmp_table[] = {
> + 1, 1, 1, 1,
> + 1, 0, 2, 2,
> + 1, 2, 0, 2,
> + 1, 2, 2, 1
> + };
> + memcpy(AdjTable, tmp_table, 16*sizeof(int));
> +
> + if (!mbImpl) {
> + mbImpl = new Core();
> + iCreatedInterface = true;
> + }


More information about the moab-dev mailing list