программа должна создавать stl файл, в которой должна происходить триангуляция цилиндрической поверхности заданной уравнениями
но капилятор выдает следующее
помогите разобраться в чем причина
#сам код
#include <iostream>
#include <fstream>
#define M_PI 3.1415926
#include<math.h>
using namespace std;
int n = 30;
int m = 10;
double H = 7;
double rho(double O) {
return 5;
}
int surfacesavetostl(double* X, double* Y, double* Z, int** T, int N);
int surfacesavetostl(double* X, double* Y, double* Z, int** T, int N)
{
int k = 0, ia, ib, ic;
double v, x1, y1, z1, x2, y2, z2, nx, ny, nz;
fstream TRstl;
remove("triangulation.stl");
TRstl.open("triangulation.stl", ios::out | ios::app);
TRstl << "solid <Triangulation>\n";
for (k = 0; k < N; k++)
{
ia = T[k][0];
ib = T[k][1];
ic = T[k][2];
x1 = X[ib] - X[ia];
y1 = Y[ib] - Y[ia];
z1 = Z[ib] - Z[ia];
x2 = X[ic] - X[ia];
y2 = Y[ic] - Y[ia];
z2 = Z[ic] - Z[ia];
nx = (y1 * z2 - y2 * z1);
ny = (z1 * x2 - x1 * z2);
nz = (x1 * y2 - x2 * y1);
v = sqrt(nx * nx + ny * ny + nz * nz);
nx = nx / v;
ny = ny / v;
nz = nz / v;
TRstl << "facet normal " << nx << " " << ny << " " << nz << "\n";
TRstl << "outer loop\n";
TRstl << "vertex ";
TRstl << X[ia] << " " << Y[ia] << " " << Z[ia] << "\n";
TRstl << "vertex ";
TRstl << X[ib] << " " << Y[ib] << " " << Z[ib] << "\n";
TRstl << "vertex ";
TRstl << X[ic] << " " << Y[ic] << " " << Z[ic] << "\n";
TRstl << "endloop\n";
TRstl << "endfacet\n";
}
TRstl << "endsolid";
TRstl.close();
return 0;
}
int main()
{
double* On = new double[n + 1];
double* Hn = new double[m + 1];
for (int i = 0; i <= n; i++) {
On[i] = (double)i * 2 * M_PI / n;
}
for (int i = 0; i <= n; i++) {
Hn[i] = (double)i * H / m;
}
int p = n * (m + 1);
double* X = new double[p];
double* Y = new double[p];
double* Z = new double[p];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m + 1; j++) {
X[(m + 1) * i + j] = rho(On[i]) * cos(On[i]);
Y[(m + 1) * i + j] = rho(On[i]) * sin(On[i]);
Z[(m + 1) * i + j] = Hn[j];
}
}
int N = 2 * n * m;
int** T = new int* [N];
for (int i = 0; i < N; i++) {
T[i] = new int[3];
}
int k = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < m; j++) {
T[k][0] = (m + 1) * (i)+j;
T[k][1] = (m + 1) * (i + 1) + j;
T[k][2] = (m + 1) * (i)+j + 1;
k++;
T[k][0] = (m + 1) * (i)+j + 1;
T[k][1] = (m + 1) * (i + 1) + j;
T[k][2] = (m + 1) * (i + 1) + j + 1;
k++;
}
}
int i = n - 1;
for (int j = 0; j < m; j++) {
T[k][0] = (m + 1) * (i)+j;
T[k][1] = j;
T[k][2] = (m + 1) * (i)+j + 1;
k++;
T[k][0] = (m + 1) * (i)+j + 1;
T[k][1] = j;
T[k][2] = j + 1;
k++;
}
surfacesavetostl(X, Y, Z, T, N);
}