Skip to content
Snippets Groups Projects
Commit 0393b61d authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

use stl::list for a better memory management

parent 6a76fe8d
No related branches found
No related tags found
No related merge requests found
......@@ -61,12 +61,12 @@ static void printInterpLc(const char *name)
fclose(f);
}
static void buildInterpLc(List_T *lcPoints)
static void buildInterpLc(const std::vector<IntPoint> &lcPoints)
{
IntPoint p;
interpLc.clear();
for(int i = 0; i < List_Nbr(lcPoints); i++){
List_Read(lcPoints, i, &p);
for(int i = 0; i < lcPoints.size(); i++){
p=lcPoints[i];
interpLc.push_back(xi2lc( p.t, p.lc));
}
}
......@@ -197,7 +197,7 @@ static double trapezoidal(IntPoint * P1, IntPoint * P2)
}
static void RecursiveIntegration(GEdge *ge, IntPoint * from, IntPoint * to,
double (*f) (GEdge *e, double X), List_T * pPoints,
double (*f) (GEdge *e, double X), std::vector<IntPoint> &Points,
double Prec, int *depth)
{
IntPoint P, p1;
......@@ -213,17 +213,18 @@ static void RecursiveIntegration(GEdge *ge, IntPoint * from, IntPoint * to,
double err = fabs(val1 - val2 - val3);
if(((err < Prec) && (*depth > 1)) || (*depth > 25)) {
List_Read(pPoints, List_Nbr(pPoints) - 1, &p1);
p1=Points.back();
P.p = p1.p + val2;
List_Add(pPoints, &P);
Points.push_back(P);
List_Read(pPoints, List_Nbr(pPoints) - 1, &p1);
//List_Read(pPoints, List_Nbr(pPoints) - 1, &p1);
to->p=P.p+val3;
to->p = p1.p + val3;
List_Add(pPoints, to);
Points.push_back(*to);
}
else {
RecursiveIntegration(ge, from, &P, f, pPoints, Prec, depth);
RecursiveIntegration(ge, &P, to, f, pPoints, Prec, depth);
RecursiveIntegration(ge, from, &P, f, Points, Prec, depth);
RecursiveIntegration(ge, &P, to, f, Points, Prec, depth);
}
(*depth)--;
......@@ -231,7 +232,7 @@ static void RecursiveIntegration(GEdge *ge, IntPoint * from, IntPoint * to,
static double Integration(GEdge *ge, double t1, double t2,
double (*f) (GEdge *e, double X),
List_T * pPoints, double Prec)
std::vector<IntPoint>&Points, double Prec)
{
IntPoint from, to;
......@@ -240,14 +241,13 @@ static double Integration(GEdge *ge, double t1, double t2,
from.t = t1;
from.lc = f(ge, from.t);
from.p = 0.0;
List_Add(pPoints, &from);
Points.push_back(from);
to.t = t2;
to.lc = f(ge, to.t);
RecursiveIntegration(ge, &from, &to, f, pPoints, Prec, &depth);
RecursiveIntegration(ge, &from, &to, f, Points, Prec, &depth);
List_Read(pPoints, List_Nbr(pPoints) - 1, &to);
return to.p;
return Points.back().p;
}
void deMeshGEdge::operator() (GEdge *ge)
......@@ -281,9 +281,7 @@ void meshGEdge::operator() (GEdge *ge)
Msg::Info("Meshing curve %d (%s)", ge->tag(), ge->getTypeString().c_str());
// Create a list of integration points
List_T *Points = List_Create(10, 10, sizeof(IntPoint));
// Create a list of points for interpolating the LC Field
List_T *lcPoints = List_Create(10, 10, sizeof(IntPoint));
std::vector<IntPoint> Points,lcPoints;
// compute bounds
Range<double> bounds = ge->parBounds(0);
......@@ -296,8 +294,7 @@ void meshGEdge::operator() (GEdge *ge)
if(length == 0.0)
Msg::Debug("Curve %d has a zero length", ge->tag());
List_Reset(Points);
Points.resize(0);
// Integrate detJ/lc du
double a;
......@@ -351,8 +348,8 @@ void meshGEdge::operator() (GEdge *ge)
IntPoint P1, P2;
ge->mesh_vertices.resize(N - 2);
while(NUMP < N - 1) {
List_Read(Points, count - 1, &P1);
List_Read(Points, count, &P2);
P1=Points[count-1];
P2=Points[count];
const double d = (double)NUMP * b;
if((fabs(P2.p) >= fabs(d)) && (fabs(P1.p) < fabs(d))) {
double dt = P2.t - P1.t;
......@@ -373,8 +370,6 @@ void meshGEdge::operator() (GEdge *ge)
}
ge->mesh_vertices.resize(NUMP - 1);
}
List_Delete(Points);
List_Delete(lcPoints);
for(unsigned int i = 0; i < ge->mesh_vertices.size() + 1; i++){
MVertex *v0 = (i == 0) ?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment