hi i compile this code but it works but i have as result the error message "Memory is insufficient! "
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <math.h>
#include <nurbsS.h>
#include <nurbsSub.h>
using namespace std;
int i ,j , l , k ,x,y ;
float b;
const int maxElements = 15000;
float **Bt , **Btc ;
float **M , **MC;
string **T , **TC;
int main()
{
using namespace PLib ;
NurbsSurface<float,3> surf ;
ifstream file("visage.txt");
Bt = new float* [maxElements];
T = new string*[maxElements];
string word;
i=0;
while( file >> word)
{
word.size();
T[i]= new string[word.size()];
*(T[i])= word;
i=i+1;
}
for (j=0;j<i;j++)
{ Bt[j] = new float [100];
*Bt[j] = atof((T[j])->c_str());
}
for (j=0;j<i;++j)
delete[] T[j];
delete[] T;
l=0;
x=i/3;
M = new float* [x];
for( j=0 ; j < x ; j++ )
{M[j] = new float [3];}
for (j=0;j<x;j++)
{
M[j][0]=*Bt[l];
M[j][1]=*Bt[l+1];
M[j][2]=*Bt[l+2];
l=l+3;
}
for (j=0;j<i;++j)
delete[] Bt[j];
delete[] Bt;
Matrix<Point_nD<float,3>> Pts(x,3) ;
for (j=0;j<x;++j)
{
Pts(j,0)=M[j][0];
Pts(j,1)=M[j][1];
Pts(j,2)=M[j][2];
}
for (j=0;j<x;++j)
delete[] M[j];
delete[] M;
Btc = new float* [maxElements];
TC = new string*[maxElements];
std::ifstream fileuv("a1.txt");
std::string worduv;
i=0;
while( fileuv >> worduv )
{
worduv.size();
TC[i]= new string[worduv.size()];
*(TC[i])= worduv;
i=i+1;
}
for (j=0;j<i;j++)
{ Btc[j] = new float [100];
*Btc[j] = atof((TC[j])->c_str());
}
for (j=0;j<i;++j)
delete[] TC[j];
delete[] TC;
l=0;
y=i/2;
MC = new float* [y];
for( j=0 ; j < y ; j++ )
{MC[j] = new float [2*sizeof(float)];}
for (j=0;j<y;j++)
{
MC[j][0]=*Btc[l];
MC[j][1]=*Btc[l+1];
l=l+2;
}
for (j=0;j<i;++j)
delete[] Btc[j];
delete[] Btc;
Vector<float> uk(8000) ,vk(8000);
k=0;
for (j=0;j<y;j++)
{
vk[j]=MC[j][1];
uk[j]=MC[j][0];
k=k+1;
}
for (j=0;j<y;++j)
delete[] MC[j];
delete[] MC;
surf.U=uk;
surf.V=vk;
surf.knotU()[1];
try {
surf.leastSquares(Pts, 3, 3, 7120, 7120);
} catch(std::bad_alloc& e) {
std::cout << "Memory is insufficient!" << std::endl;
return 1;
};
return 0;
}
but i think it's not a memory problem how can solve this problem