- // Copy the triangulation vertices
- // This is only the case when normals are defined by node so each
- // node can be shared by several triangles
- if (nNodesTri == nbNodes)
- {
- NCollection_DataMap <int, int>::Iterator anIterN(mapNodeId);
- for (i = 1; anIterN.More(); anIterN.Next()) {
- const int aKey = anIterN.Key();
- const gp_XYZ& aNodePnt = arrNodes[aKey];
- aNodes(i) = gp_Pnt (aNodePnt);
- anIterN.ChangeValue() = i++;
- }
- // Fill the array of triangles
- for (i = 0; i < (int)myNbPolygons; i++) {
- const Standard_Integer * arrIndice;
- if (Polygon(i, arrIndice) == 3)
- if (arrIndice[0] >= 0) // check to avoid previously skipped faces
- aTriangles(++nTri).Set (mapNodeId(arrIndice[0]),
- mapNodeId(arrIndice[1]),
- mapNodeId(arrIndice[2]));
- }
- // Normals should be defined; if they are not, compute them
- if (myNormals.IsNull()) {
- //aTriangulation->ComputeNormals();
- Poly::ComputeNormals(aTriangulation);
- } else {
- // Copy the normals-per-vertex.
- NCollection_DataMap <int, int>::Iterator anIterNN (mapNodeId);
- for (; anIterNN.More(); anIterNN.Next()) {
- const Standard_Integer ind = (anIterNN.Value() - 1) * 3 + 1;
- const gp_XYZ& aNormal = myNormals->Normal(anIterNN.Key());
- aNormals->SetValue(ind + 0, Standard_ShortReal(aNormal.X()));
- aNormals->SetValue(ind + 1, Standard_ShortReal(aNormal.Y()));
- aNormals->SetValue(ind + 2, Standard_ShortReal(aNormal.Z()));
- }
- }