I'm pretty new to C++ so I'm not sure I'm going about this problem in the right way. I'm dealing with a 3D array of voxel data and I would like to create a parallel data structure to store isosurface normal vectors. Memory efficiency is an issue so I thought to use a 2D array of maps, which are indexed by an integer and contain a 3D vector.
The idea being the 2D array indexes every x and y coordinate and the maps index only the z coordinates containing a value (typically between 0 and 3 values dispersed along each row of the z axis).
Question 1: how do I create a 2D array of maps like std::map<int, Vector3f> surfaceNormals;
?
Question 2: My idea is declare the 2D array global then to populate it with a function which deals with it by pointer and creates a map for each array cell, is the code below on the right track? the ?????'s indicate where i'm not sure what to put given my uncertainty about Question 1.
In particular am I managing pointers/references/values correctly such as to actually end up storing all the data I need?
????? isoSurfaces1 [256][100];
????? *extractIS(float Threshold, ????? *pointy){
????? *surfacePointer = pointy;
for loop over x and y {
std::map<int, Vector3f> surfaceNormals;
for loop over z {
[ ... find surface voxels and their normal vectors ... ]
Vector3f newNormalVector(x,y,z);
surfaceNormals[zi] = newNormalVector;
}
surfacePointer[x][y] = surfaceNormals;
}
return surfacePointer;
}
extractIS(0.45, isoSurfaces1);