In my program I import a set of millions of 3D points with multiple properties each (RGB values, XYZ values, alpha, etc) from an external file and store it in memory. Rather than storing them as a simple array, I was hoping to store them in a Qt container class like QList so that I could tap into Qt's sorting capabilites. In order to conserve memory, I've written several class-based point data types to choose from—some with XYZ only, others that store XYZ and RGB data, etc—all that inherit from a core data type:
class p3d_core_t {/*variables here*/}
class p3d_0_t : public p3d_core_t {/*variables here*/}
class p3d_1_t : public p3d_core_t {/*variables here*/}
class p3d_2_t : public p3d_core_t {/*variables here*/}
class p3d_core_t {/*variables here*/}
class p3d_0_t : public p3d_core_t {/*variables here*/}
class p3d_1_t : public p3d_core_t {/*variables here*/}
class p3d_2_t : public p3d_core_t {/*variables here*/}
To copy to clipboard, switch view to plain text mode
A given data file specifies in its header which data type it contains (0, 1, 2, ..., N), so I don't know which type to store in my QList until run-time. I have two questions:
- How do I construct a new QList during run-time once I know which data type I'm importing?
- Is it possible to list the data types themselves in a QHash so that I can index them instead of having a series of if-else statements? For example, something like this
int dataTypeIndex = 2;
QHash<int, pointdatatype> hash;
list = new QList<hash.value(dataTypeIndex)>
int dataTypeIndex = 2;
QList* list;
QHash<int, pointdatatype> hash;
list = new QList<hash.value(dataTypeIndex)>
To copy to clipboard, switch view to plain text mode
would create a QList of p3d_2_t data, ready for importing.
I can hardcode this with a huge set of if-else statements, but I have a feeling there's an elegant "Qt way" to do this, especially since the number of point data types changes periodically. I'd rather it be a little more flexible. Because these data sets get huge, even a little memory or speed boost makes a huge difference.
Thanks in advance!
[edit]
I'd also like to add that I'm open to alternatives to QList or QHash that are more appropriate for lists that get into the 10-999 million member range.
[/edit]
Bookmarks