I have a base class called "ModelFile" which I derive several types of 3D model file classes from.
Many of these types of files are just a set of points, so in the base class I have a vector<Point> member. Some of the derived file classes also have vector<Triangle> members. The problem is, in a class with triangles, if I move the points, I need to update the triangles (even if the triangles have their 3 points stored as the address of the points, I still need to recalculate normals). I thought of two solutions:
1) put the vector<Triangle> in the base class so I can call an UpdateTriangles() function every time a MovePoints() function is called (which is in the base class). The vector<Triangle> would just be empty for derived classes without triangles and therefore the update triangle function would have nothing to do in those cases.
2) is there a way to somehow flag/trigger something to happen in particular derived classes? ie when MovePoints() is called, at the end of the function say "if the current class is a derived class with triangles, do soemthing"?
Any suggestions are appreciated!
Thanks,
Dave