Hi folks!
I'm working on an Wavefront OBJ loader written entirely in C++ and try to figure out the best design choices for the involved classes.
Specifically, I'm currently thinking about the following designs:
1) nested structs in a class. consider the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
class GeometricObject
{
public:
enum polygon_type
{
TRIANGLE,
QUAD
};
struct vector
{
float x, y, z;
};
struct face
{
polygon_type polyType;
std::vector<int> vertexIndices;
std::vector<int> normalIndices;
};
};
| |
What this class obviously does is define some data structures to describe points/vectors in 3D space and faces made of vertices and corresponding vertex normals. In addition there is a polygon type, either quads or triangles can be stored.
What do you think about the nested structs and the members of the structs? Is it wise to avoid a seperate class to describe simple floating point values, if their mere function is to bundle three float values and not provide any functionality? Since the number of vertex and normal indices can vary, is the overhead of choosing a std::vector justified in the struct face?
2) A class holding only static methods and no data meant as a conversion class.
My loader is supported by a class StringProcessor which handles conversion of strings to numbers and vice versa, trimming a.s.o., to avoid the necessity to use a bigger library like Boost just because I need some helper functions (have you seen the dependencies of boost::lexical_cast?!).
The aim is a class containing only static methods and templates designed for specific tasks. Copying and explicit construction are disabled. I've read one should avoid defining a class if there is no data and there are no methods to be encapsulated, but simply defining methods on the namespace level seems to break any OOP considerations.
What do you think?
Thank you all!