In making a more elegant solution, I determined it would probably be useful to use classes for certain data storage, retrieval, and comparisons. While I'm still not convinced of the best way to do this, the following are some ideas on how to organize things. It is expected that this will be modified, added to, and probably mostly different by the time I finish any of this.

Bounds Class

The bounds class should provide details and comparisons for a set of Cartesian boundaries for a rectangular prism. The obvious required (probably private) data members are

  • int minCoords[3]
  • int maxCoords[3]

Upon instantiation, it will probably be useful to calculate things such as

  • x size
  • y size
  • z size
  • offsets (in each direction)?

This class doesn't actually refer to any data. Just the boundaries of the data. The important most important routine, as of now, is to calculate the intercepting coordinates of two data sets. For example, if I have one Bounds from 0, 0, 0 to 63, 63, 63 and another Bounds from 0, 0, 0 to 127, 127, 15, the intercepting set of data is the Bounds from 0, 0, 0 to 63, 63, 15.

Other Classes

These next two classes would also use coordinates and intersection information from the Bounds class above. They would either be subclasses or have an object of type Bounds (which might be better).

Chunk Class

The chunk class should actually store some data. I expect it will be useful to either point to some data already present (like the data passed to VDCWrite() initially) or to allocate the memory for whatever data is needed. I expect it could be a subclass of the Bounds class or just have an object of type Bounds in it. The constructor will either provide a pointer to the data and bounds or just the bounds. If only bounds are provided, the memory should be allocated.

Important data members are:

  • bool columnMajor // if true, we treat the array as column-major; otherwise, assume row-major.
  • bool myMemory // am I managing the memory, or did we get a pointer to somebody elses array?
  • float* data // pointer to the data

Important functions might be:

  • copy function (to copy data in range of positions to the same range of positiosn for the new node)
  • overloaded () operator, to reference the data by (x,y,z) where (x,y,z) is a description of a position in the overall dataset.
  • a third constructor that takes Bounds and another Chunk object--it would construct the object over the Bounds given using data from the Chunk passed.

Since this class handles dynamically allocated memory, it will be important to carefully deallocate the memory in the destructor (unless the memory is not ours).

NodeBounds Class?

This is essentially an addition to the Bounds class with the additional information of which node the data referenced by Bounds is located. It will be used to determine where to send and receive data. It will likely be subclass of bounds with the additional data member detailing the node. Additional member functions may provide utilities to determine what data to send and/or receive from a particular node.

Since this really only has some boundaries and a node number, it might be best to just make it a simple struct with those two things publicly accessible.

  • No labels