Commit 1c28f019 authored by Arne Graf's avatar Arne Graf

fixed memory leaks of debug vars

parent 41514689
...@@ -84,17 +84,17 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd"> ...@@ -84,17 +84,17 @@ xsi:noNamespaceSchemaLocation="http://134.94.2.137/jps_ini_core.xsd">
<exit_crossing_strategy>6</exit_crossing_strategy> <exit_crossing_strategy>6</exit_crossing_strategy>
<floorfield delta_h="0.0625" wall_avoid_distance="0.4" use_wall_avoidance="true" /> <floorfield delta_h="0.0625" wall_avoid_distance="0.4" use_wall_avoidance="true" />
<linkedcells enabled="true" cell_size="4.2" /> <linkedcells enabled="true" cell_size="4.2" />
<force_ped nu="3" b="1.0" c="3.0" /> <force_ped nu="15" b="0.30" c="3.0" />
<force_wall nu="1" b="0.70" c="3.0" /> <force_wall nu="1" b="0.70" c="3.0" />
<anti_clipping slow_down_distance=".5" /> <anti_clipping slow_down_distance=".5" />
</model_parameters> </model_parameters>
<agent_parameters agent_parameter_id="0"> <agent_parameters agent_parameter_id="0">
<v0 mu="1.5" sigma="0.0" /> <v0 mu="1.5" sigma="0.0" />
<bmax mu="0.25" sigma="0.001" /> <bmax mu="0.15" sigma="0.00" />
<bmin mu="0.20" sigma="0.001" /> <bmin mu="0.15" sigma="0.00" />
<amin mu="0.18" sigma="0.001" /> <amin mu="0.15" sigma="0.00" />
<tau mu="0.5" sigma="0.001" /> <tau mu="0.5" sigma="0.001" />
<atau mu="0.23" sigma="0.001" /> <atau mu="0.0" sigma="0.00" />
</agent_parameters> </agent_parameters>
</model> </model>
......
...@@ -86,7 +86,11 @@ GradientModel::GradientModel(DirectionStrategy* dir, double nuped, double aped, ...@@ -86,7 +86,11 @@ GradientModel::GradientModel(DirectionStrategy* dir, double nuped, double aped,
GradientModel::~GradientModel() GradientModel::~GradientModel()
{ {
delete over;
delete under;
delete redircnt;
delete slowcnt;
delete overlapcnt;
} }
bool GradientModel::Init (Building* building) bool GradientModel::Init (Building* building)
...@@ -314,11 +318,11 @@ Point GradientModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const ...@@ -314,11 +318,11 @@ Point GradientModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const
Point F_rep(0.0, 0.0); Point F_rep(0.0, 0.0);
// x- and y-coordinate of the distance between p1 and p2 // x- and y-coordinate of the distance between p1 and p2
Point distp12 = ped2->GetPos() - ped1->GetPos(); Point distp12 = ped2->GetPos() - ped1->GetPos();
const Point& vp1 = ped1->GetV(); // v Ped1 //const Point& vp1 = ped1->GetV(); // v Ped1
const Point& vp2 = ped2->GetV(); // v Ped2 //const Point& vp2 = ped2->GetV(); // v Ped2
Point ep12; // x- and y-coordinate of the normalized vector between p1 and p2 Point ep12; // x- and y-coordinate of the normalized vector between p1 and p2
//double K_ij; //double K_ij;
double B_ij, f, tmp; double B_ij, f; // tmp2;
const JEllipse& E1 = ped1->GetEllipse(); const JEllipse& E1 = ped1->GetEllipse();
const JEllipse& E2 = ped2->GetEllipse(); const JEllipse& E2 = ped2->GetEllipse();
Point AP1inE1 = E1.GetCenter(); Point AP1inE1 = E1.GetCenter();
...@@ -367,8 +371,8 @@ Point GradientModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const ...@@ -367,8 +371,8 @@ Point GradientModel::ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const
// return ep12 * (-5); // return ep12 * (-5);
// } // }
//--------------------------check speed diff //--------------------------check speed diff
// tmp = (vp1 - vp2).ScalarProduct(ep12); // < v_ij , e_ij > // tmp2 = (vp1 - vp2).ScalarProduct(ep12); // < v_ij , e_ij >
// if (tmp < 0) { // if (tmp2 < 0) {
// return F_rep; // ignore ped2 // return F_rep; // ignore ped2
// } // }
......
...@@ -49,7 +49,7 @@ FloorfieldViaFM::~FloorfieldViaFM() ...@@ -49,7 +49,7 @@ FloorfieldViaFM::~FloorfieldViaFM()
if (modifiedspeed) delete[] modifiedspeed; if (modifiedspeed) delete[] modifiedspeed;
if (cost) delete[] cost; if (cost) delete[] cost;
if (neggrad) delete[] neggrad; if (neggrad) delete[] neggrad;
if (dist2Wall) delete[] dist2Wall; if (dirToWall) delete[] dirToWall;
if (trialfield) delete[] trialfield; if (trialfield) delete[] trialfield;
} }
...@@ -64,13 +64,6 @@ FloorfieldViaFM::FloorfieldViaFM(const Building* const buildingArg, const double ...@@ -64,13 +64,6 @@ FloorfieldViaFM::FloorfieldViaFM(const Building* const buildingArg, const double
//parse building and create list of walls/obstacles (find xmin xmax, ymin, ymax, and add border?) //parse building and create list of walls/obstacles (find xmin xmax, ymin, ymax, and add border?)
parseBuilding(buildingArg, hxArg, hyArg); parseBuilding(buildingArg, hxArg, hyArg);
//create rectgrid (grid->createGrid()) <- DONE in parseBuilding
//'grid->GetnPoints()' and create all data fields: cost, neggradient, speed, dis2wall, flag, secondaryKey <- DONE in parseBuilding
//call fkt: linescan und set Distance2Wall mit 0 fuer alle Wandpunkte, speed mit lowspeed <- DONE in parseBuilding
//this step includes Linescanalgorithmus? (maybe included in parsing above)
//testoutput("AALineScan.vtk", "AALineScan.txt", dist2Wall); //testoutput("AALineScan.vtk", "AALineScan.txt", dist2Wall);
prepareForDistanceFieldCalculation(wall, numOfExits); prepareForDistanceFieldCalculation(wall, numOfExits);
...@@ -206,10 +199,10 @@ FloorfieldViaFM::FloorfieldViaFM(const std::string& filename) { ...@@ -206,10 +199,10 @@ FloorfieldViaFM::FloorfieldViaFM(const std::string& filename) {
file.close(); file.close();
} }
FloorfieldViaFM::FloorfieldViaFM(const FloorfieldViaFM& other) //FloorfieldViaFM::FloorfieldViaFM(const FloorfieldViaFM& other)
{ //{
//copy ctor // //copy ctor
} //}
//FloorfieldViaFM& FloorfieldViaFM::operator=(const FloorfieldViaFM& rhs) //FloorfieldViaFM& FloorfieldViaFM::operator=(const FloorfieldViaFM& rhs)
//{ //{
...@@ -326,17 +319,6 @@ void FloorfieldViaFM::parseBuilding(const Building* const buildingArg, const dou ...@@ -326,17 +319,6 @@ void FloorfieldViaFM::parseBuilding(const Building* const buildingArg, const dou
drawLinesOnGrid(wall, dist2Wall, 0.); drawLinesOnGrid(wall, dist2Wall, 0.);
} }
//void FloorfieldViaFM::resetGoalAndCosts(const Goal* const goalArg) {
/* this fkt shall set all Costdata to unknown and the goal points to 0
we have to watch how to calc indices as goal only knows coords from input file
*/
// set all cost data to "unknown" (remember to change flag accordingly)
// get lines/walls from goals
// use linescan to ititialize cost grid
//}
//this function must only be used BEFORE calculateDistanceField(), because we set trialfield[].cost = dist2Wall AND we init dist2Wall with "-3" //this function must only be used BEFORE calculateDistanceField(), because we set trialfield[].cost = dist2Wall AND we init dist2Wall with "-3"
void FloorfieldViaFM::prepareForDistanceFieldCalculation(std::vector<Wall>& wallArg, int numOfExits) { void FloorfieldViaFM::prepareForDistanceFieldCalculation(std::vector<Wall>& wallArg, int numOfExits) {
std::vector<Wall> exits(wallArg.begin(), wallArg.begin()+numOfExits); std::vector<Wall> exits(wallArg.begin(), wallArg.begin()+numOfExits);
...@@ -362,15 +344,31 @@ void FloorfieldViaFM::prepareForDistanceFieldCalculation(std::vector<Wall>& wall ...@@ -362,15 +344,31 @@ void FloorfieldViaFM::prepareForDistanceFieldCalculation(std::vector<Wall>& wall
} }
drawLinesOnGrid(exits, cost, 0.); //already mark targets/exits in cost array (for floorfieldcalc) drawLinesOnGrid(exits, cost, 0.); //already mark targets/exits in cost array (for floorfieldcalc)
for (long int i=0; i < grid->GetnPoints(); ++i) { for (long int i=0; i < grid->GetnPoints(); ++i) {
if (cost[i] == 0.) { if (cost[i] == 0.) { //here we use cost, neggrad directly
neggrad[i].SetX(0.); neggrad[i].SetX(0.); //must be changed to costarray/neggradarray?
neggrad[i].SetY(0.); neggrad[i].SetY(0.); //we can leave it, if we agree on cost/neggrad being
dirToWall[i].SetX(0.); dirToWall[i].SetX(0.); //default floorfield using all exits and have the
dirToWall[i].SetY(0.); dirToWall[i].SetY(0.); //array mechanic on top
}
}
}
void FloorfieldViaFM::clearAndPrepareForFloorfieldReCalc(double* costarray) {
for (long int i = 0; i < grid->GetnPoints(); ++i) {
if (dist2Wall[i] == 0.) { //wall
costarray[i] = -7.; //this is done in calculateFloorfield again
flag[i] = -7; // meaning wall
} else { //inside
costarray[i] = -2.;
flag[i] = 0; // meaning unknown
} }
} }
} }
void FloorfieldViaFM::setNewGoalAfterTheClear(double* costarray, std::vector<Wall>& GoalWallArg) {
drawLinesOnGrid(GoalWallArg, costarray, 0.);
}
void FloorfieldViaFM::lineScan(std::vector<Wall>& wallArg, double* const target, const double outside, const double inside) { void FloorfieldViaFM::lineScan(std::vector<Wall>& wallArg, double* const target, const double outside, const double inside) {
// use RectGrid to go thru lines and check intersection with any wall // use RectGrid to go thru lines and check intersection with any wall
...@@ -584,13 +582,9 @@ void FloorfieldViaFM::calculateFloorfield(double* costarray, Point* neggradarray ...@@ -584,13 +582,9 @@ void FloorfieldViaFM::calculateFloorfield(double* costarray, Point* neggradarray
//re-init memory //re-init memory
for (long int i = 0; i < grid->GetnPoints(); ++i) { for (long int i = 0; i < grid->GetnPoints(); ++i) {
if (dist2Wall[i] == 0.) { //outside if (dist2Wall[i] == 0.) { //wall
//speedInitial[i] = .001; flag[i] = -7; // -7 => wall
//cost[i] = -7.; // @todo: ar.graf
flag[i] = -7; // -7 => outside
} else { //inside } else { //inside
//speedInitial[i] = 1.;
//cost[i] = -2.;
flag[i] = 0; flag[i] = 0;
} }
//set Trialptr to fieldelements //set Trialptr to fieldelements
...@@ -625,7 +619,6 @@ void FloorfieldViaFM::calculateFloorfield(double* costarray, Point* neggradarray ...@@ -625,7 +619,6 @@ void FloorfieldViaFM::calculateFloorfield(double* costarray, Point* neggradarray
trialfield[keyOfSmallest].removecurr(smallest, biggest, trialfield+keyOfSmallest); trialfield[keyOfSmallest].removecurr(smallest, biggest, trialfield+keyOfSmallest);
checkNeighborsAndAddToNarrowband(smallest, biggest, keyOfSmallest, [&] (const long int key) { this->checkNeighborsAndCalcFloorfield(key);} ); checkNeighborsAndAddToNarrowband(smallest, biggest, keyOfSmallest, [&] (const long int key) { this->checkNeighborsAndCalcFloorfield(key);} );
} }
delete[] modifiedspeed;
} }
void FloorfieldViaFM::calculateDistanceField(const double thresholdArg) { //if threshold negative, then ignore it void FloorfieldViaFM::calculateDistanceField(const double thresholdArg) { //if threshold negative, then ignore it
......
...@@ -62,11 +62,12 @@ class FloorfieldViaFM ...@@ -62,11 +62,12 @@ class FloorfieldViaFM
double getDistance2WallAt(const Point& position); double getDistance2WallAt(const Point& position);
void parseBuilding(const Building* const buildingArg, const double stepSizeX, const double stepSizeY); void parseBuilding(const Building* const buildingArg, const double stepSizeX, const double stepSizeY);
//void resetGoalAndCosts(const Goal* const goalArg);
void prepareForDistanceFieldCalculation(std::vector<Wall>& wallArg, int numOfExits); void prepareForDistanceFieldCalculation(std::vector<Wall>& wallArg, int numOfExits);
void lineScan(std::vector<Wall>& wallArg, double* const target, const double outside, const double inside); void lineScan(std::vector<Wall>& wallArg, double* const target, const double outside, const double inside);
void drawLinesOnGrid(std::vector<Wall>& wallArg, double* const target, const double outside); void drawLinesOnGrid(std::vector<Wall>& wallArg, double* const target, const double outside);
void setSpeed(bool useDistance2Wall); void setSpeed(bool useDistance2Wall);
void clearAndPrepareForFloorfieldReCalc(double* costarray);
void setNewGoalAfterTheClear(double* costarray, std::vector<Wall>& GoalWallArg);
void calculateFloorfield(double* costarray, Point* neggradarray); //make private void calculateFloorfield(double* costarray, Point* neggradarray); //make private
void calculateDistanceField(const double thresholdArg); //make private void calculateDistanceField(const double thresholdArg); //make private
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment