More raw double arrays to vectors

This commit is contained in:
Nyall Dawson 2019-11-29 13:15:03 +10:00
parent fe9dcf1f33
commit 499f240ca7
5 changed files with 13 additions and 21 deletions

View File

@ -476,7 +476,7 @@ bool LabelPosition::countFullOverlapCallback( LabelPosition *lp, void *ctx )
LabelPosition *lp2 = context->lp;
double *cost = context->cost;
int *nbOv = context->nbOv;
double *inactiveCost = context->inactiveCost;
std::vector< double > &inactiveCost = *context->inactiveCost;
if ( lp2->isInConflict( lp ) )
{
( *nbOv ) ++;

View File

@ -281,8 +281,7 @@ namespace pal
LabelPosition *lp = nullptr;
int *nbOv = nullptr;
double *cost = nullptr;
double *inactiveCost = nullptr;
//int *feat;
std::vector< double > *inactiveCost = nullptr;
};
/*

View File

@ -325,9 +325,9 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
prob->mFeatureCount = features.size();
prob->mTotalCandidates = 0;
prob->mFeatNbLp = new int [prob->mFeatureCount];
prob->mFeatStartId = new int [prob->mFeatureCount];
prob->mInactiveCost = new double[prob->mFeatureCount];
prob->mFeatNbLp.resize( prob->mFeatureCount );
prob->mFeatStartId.resize( prob->mFeatureCount );
prob->mInactiveCost.resize( prob->mFeatureCount );
if ( !features.empty() )
{

View File

@ -57,13 +57,7 @@ inline void delete_chain( Chain *chain )
Problem::Problem() = default;
Problem::~Problem()
{
delete[] mFeatStartId;
delete[] mFeatNbLp;
delete[] mInactiveCost;
}
Problem::~Problem() = default;
void Problem::reduce()
{
@ -302,7 +296,7 @@ struct ChainContext
QLinkedList<ElemTrans *> *currentChain;
QLinkedList<int> *conflicts;
double *delta_tmp = nullptr;
double *inactiveCost = nullptr;
std::vector< double > *inactiveCost = nullptr;
} ;
@ -346,7 +340,7 @@ bool chainCallback( LabelPosition *lp, void *context )
if ( !ctx->conflicts->contains( feat ) )
{
ctx->conflicts->append( feat );
*ctx->delta_tmp += lp->cost() + ctx->inactiveCost[rfeat];
*ctx->delta_tmp += lp->cost() + ( * ctx->inactiveCost )[rfeat];
}
}
return true;
@ -386,7 +380,7 @@ inline Chain *Problem::chain( int seed )
context.featWrap = nullptr;
context.borderSize = 0;
context.tmpsol = &tmpsol;
context.inactiveCost = mInactiveCost;
context.inactiveCost = &mInactiveCost;
context.feat = nullptr;
context.currentChain = &currentChain;
context.conflicts = &conflicts;
@ -786,7 +780,7 @@ void Problem::solution_cost()
int nbOv;
LabelPosition::CountContext context;
context.inactiveCost = mInactiveCost;
context.inactiveCost = &mInactiveCost;
context.nbOv = &nbOv;
context.cost = &mSol.totalCost;
double amin[2];

View File

@ -183,10 +183,9 @@ namespace pal
std::vector< std::unique_ptr< LabelPosition > > mPositionsWithNoCandidates;
//int *feat; // [nblp]
int *mFeatStartId = nullptr; // [nbft]
int *mFeatNbLp = nullptr; // [nbft]
double *mInactiveCost = nullptr; //
std::vector< int > mFeatStartId;
std::vector< int > mFeatNbLp;
std::vector< double > mInactiveCost;
class Sol
{