[MOAB-dev] Equality of `Interface`s

Whitney, Ben whitneybe at ornl.gov
Thu Mar 19 11:59:44 CDT 2020


> What are you trying to do ?
> Why would you need to compare different moab instances?

Here are the steps that lead me to the problem:

1. I start with a class `Mesh` that represents meshes. The class has data members of type `moab::Interface &` (the underlying MOAB instance) and `moab::Range` (the vertices of the mesh).
2. I would like to iterate over the vertices, so I add an iterator class. This iterator class has data members of type `const Mesh &` (the underlying mesh) and `moab::Range::iterator` (the position in the vertex set). (I need the new class – I can't just use `moab::Range::iterator` – because I want the iterator to dereference to the vertex handle plus some additional information about the vertex, computed from the mesh.)
3. In order to know when I've reached the end of the vertex set (when the 'current' iterator equals the 'end' iterator), I overload `operator==` in the iterator class.
4. The definition of `operator==` compares both the `const Mesh &` and `moab::Range::iterator` data members, because I want to make sure that I'm in the same location in the vertex range and that the handles in that range correspond to the same mesh.
5. So, `Mesh` needs to overload `operator==`, and that definition compares the `moab::Range` and `moab::Interface &` data members. The second comparison is not defined.

(The actual situation is more complicated; hopefully I haven't lost anything in the simplification.) In practice, I, like you, have always just had a single `moab::Interface` shared between all the `Mesh`es. So, I've worked around the problem by comparing the addresses of the `moab::Interface`s.

-- 
Ben Whitney


More information about the moab-dev mailing list