Some general suggestions:
1) Add a default constructor for Vector3f which sets each member to zero. (Actually, you must already have some kind of default constructor if you're storing these things in standard library containers :) ) Then you can rely on...
2) std::map::operator[] automatically adds not-found entries, associating a default-constructed value with the key. This means you don't need to go through and initialize things first.
3) 'calculateNormal_2' is a somewhat strange-looking function.
a) It seems to be used to initialize a Vector3f; why not return one instead, and make it a static member of the class (factory pattern)? (Making it a constructor would be a little strange too :) )
b) Why '_2'? And for that matter, it's a little strange to have words like 'calculate' in the names of functions that return a value (see (a) again) - of course they are performing a calculation :)
4) Instead of accumulating the corresponding "initial" normals and then inserting them into the map, it makes sense to just insert (add) them directly on the first pass. Similarly, we can normalise the results in the same breath that we collect them.
5) There's an (IMHO :) ) slightly neater way to do the initial iteration.
6) You seem to be relying on the output vertNormals to be empty to start out with. It's cleaner (possibly slower, but modern compilers should be able to do the necessary NRVO work here) to just return your return values.
7) Const correctness :)
typedef vector<Vector3f> vertContainer;vertContainer addNormals(const vertContainer& verts) { map<Vector3f, Vector3f, bool(*)(Vector3f, Vector3f)> myMap(vect3fCompare); typedef vertContainer::const_iterator iterator; iterator v1 = verts.begin(); iterator v2 = v1 + 1; iterator v3 = v1 + 2; for (; v1 != verts.end(); v1 += 3, v2 += 3, v3 += 3) { Vector3f temp = Vector3f::faceNormal(*v1, *v2, *v3); myMap[*v1] += temp; myMap[*v2] += temp; myMap[*v3] += temp; } vertContainer result(verts.size()); for (v1 = verts.begin(); v1 != verts.end(); ++v1) { result.push_back(myMap[*v1].normalise()); } return result;}
(EDIT: typedefs added to show some of the benefit of using iterators. Also, *proper* const-correctness, assuming I'm thinking straight.)