Moved triangleToMem function to cuda helpers