geometry-central icon indicating copy to clipboard operation
geometry-central copied to clipboard

Data arrays with no mesh reference

Open keenancrane opened this issue 6 years ago • 1 comments

It's easy to introduce the following bug:

VertexData<double> x;
x[v] = 1.23;

Two possible resolutions:

  • Don't allow a data array to be declared without a reference to a mesh (i.e., don't provide an empty constructor).
  • Include assertions in debug mode that check for a mesh reference.

keenancrane avatar Aug 25 '19 14:08 keenancrane

Agreed that it's an easy bug! Done it many times myself.

Don't allow a data array to be declared without a reference to a mesh (i.e., don't provide an empty constructor).

Perhaps it would encourage better coding habits if we forced initialization, but I'd push back initially on this one. I find it super useful for these to be default-constructible so they can be used as value members in classes without initialization, or left as empty when unused in function calls.

Include assertions in debug mode that check for a mesh reference.

These assertions already exist! Perhaps something is up with the build system if those assertions aren't firing for you?

nmwsharp avatar Aug 25 '19 18:08 nmwsharp