http://www.cplusplus.com/forum/articles/7459/
2x1
std::vector
2x3
std::vector
2x3x4
std::vector
int rows = 2, columns = 3, planes = 4;
array3d.resize(rows);
for (int i = 0; i < rows; i++) {
array3d[i].resize(columns);
for (int j = 0; j < columns; j++) {
array3d[i][j].resize(planes);
}
}
and using structures
struct VoxelProperties {
// Contains:
int NumInVoxel; // Num points in each voxel
std::vector
};
std::vector Voxels(2);
Voxels[0].NumInVoxel = 1;
Voxels[0].NodeIndex.push_back(13);
std::cout << Voxels[0].NumInVoxel << std::endl;
std::cout << Voxels[0].NodeIndex[0] << std::endl;
std::vector > Voxels(2,std::vector(3));
Voxels[0][0].NumInVoxel = 1;
Voxels[0][0].NodeIndex.push_back(13);
Voxels[1][1].NumInVoxel = 11;
Voxels[1][2].NodeIndex.push_back(15);
std::cout << Voxels[0][0].NumInVoxel << std::endl;
std::cout << Voxels[0][0].NodeIndex[0] << std::endl;
std::cout << Voxels[1][1].NumInVoxel << std::endl;
std::cout << Voxels[1][2].NodeIndex[0] << std::endl;
std::vector > > Voxels(2,std::vector(3));
std::vector > > Voxels(2,std::vector(2) >(3));
std::vector > > Voxels;
int rows = 2, columns = 3, planes = 4;
Voxels.resize(rows);
for (int i = 0; i < rows; i++) {
Voxels[i].resize(columns);
for (int j = 0; j < columns; j++) {
Voxels[i][j].resize(planes);
}
}
Voxels[0][0][0].NumInVoxel = 1;
Voxels[0][0][1].NodeIndex.push_back(13);
Voxels[1][1][2].NumInVoxel = 11;
Voxels[1][2][2].NodeIndex.push_back(15);
Voxels[1][2][2].NodeIndex.push_back(16);
std::cout << Voxels[0][0][0].NumInVoxel << std::endl;
std::cout << Voxels[0][0][1].NodeIndex[0] << std::endl;
std::cout << Voxels[1][1][2].NumInVoxel << std::endl;
std::cout << Voxels[1][2][2].NodeIndex[0] << std::endl;
std::cout << Voxels[1][2][2].NodeIndex[1] << std::endl;
No comments:
Post a Comment