Skip to content

Commit

Permalink
Merge commit 'bd241202c9daf787fe8c4bfdb990e43ace95c765'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jan 10, 2025
2 parents 00bfeb6 + bd24120 commit eb9106f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
38 changes: 21 additions & 17 deletions agrolib/interpolation/interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,43 +850,47 @@ float shepardSearchNeighbour(vector <Crit3DInterpolationDataPoint> &inputPoints,
Crit3DInterpolationSettings* settings,
vector <Crit3DInterpolationDataPoint> &outputPoints)
{
std::vector <Crit3DInterpolationDataPoint> shepardNeighbourPoints;

float radius;
unsigned int nrValid = 0;
float shepardInitialRadius = computeShepardInitialRadius(settings->getPointsBoundingBoxArea(),
unsigned(inputPoints.size()), SHEPARD_AVG_NRPOINTS);

// define a first neighborhood inside initial radius
std::vector <Crit3DInterpolationDataPoint> shepardNeighbourPoints;
for (unsigned int i=0; i < inputPoints.size(); i++)
{
if (inputPoints[i].distance <= shepardInitialRadius &&
inputPoints[i].distance > 0 &&
inputPoints[i].index != settings->getIndexPointCV())
{
shepardNeighbourPoints.push_back(inputPoints[i]);
nrValid++;
}
}

if (shepardNeighbourPoints.size() <= SHEPARD_MIN_NRPOINTS)
// If the points are too few, double the check radius
if (shepardNeighbourPoints.size() < SHEPARD_MIN_NRPOINTS)
{
nrValid = sortPointsByDistance(SHEPARD_MIN_NRPOINTS + 1, inputPoints, outputPoints);
if (nrValid > SHEPARD_MIN_NRPOINTS)
{
radius = outputPoints[SHEPARD_MIN_NRPOINTS].distance;
outputPoints.pop_back();
}
else
float doubleRadius = shepardInitialRadius * 2;
for (unsigned int i=0; i < inputPoints.size(); i++)
{
radius = outputPoints[nrValid-1].distance + float(EPSILON);
if (inputPoints[i].distance <= doubleRadius &&
inputPoints[i].distance > shepardInitialRadius &&
inputPoints[i].index != settings->getIndexPointCV())
{
shepardNeighbourPoints.push_back(inputPoints[i]);
}
}
shepardInitialRadius = doubleRadius;
}

float radius;
if (shepardNeighbourPoints.size() < SHEPARD_MIN_NRPOINTS)
{
int nrPoints = sortPointsByDistance(SHEPARD_MIN_NRPOINTS, inputPoints, outputPoints);
radius = outputPoints[nrPoints-1].distance + float(EPSILON);
}
else if (shepardNeighbourPoints.size() > SHEPARD_MAX_NRPOINTS)
{
nrValid = sortPointsByDistance(SHEPARD_MAX_NRPOINTS + 1, shepardNeighbourPoints, outputPoints);
radius = outputPoints[SHEPARD_MAX_NRPOINTS].distance;
outputPoints.pop_back();
int nrPoints = sortPointsByDistance(SHEPARD_MAX_NRPOINTS, shepardNeighbourPoints, outputPoints);
radius = outputPoints[nrPoints-1].distance + float(EPSILON);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions agrolib/interpolation/interpolationConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#define MIN_REGRESSION_POINTS 5
#define PEARSONSTANDARDTHRESHOLD 0.1
#define SHEPARD_MIN_NRPOINTS 4
#define SHEPARD_AVG_NRPOINTS 7
#define SHEPARD_MIN_NRPOINTS 5
#define SHEPARD_AVG_NRPOINTS 8
#define SHEPARD_MAX_NRPOINTS 10

#ifndef _STRING_
Expand Down
2 changes: 1 addition & 1 deletion agrolib/pragaProject/pragaShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ int pragaBatch(PragaProject* myProject, QString scriptFileName)
attachOutputToConsole();
#endif

myProject->logInfo("\nPRAGA v1.8.3");
myProject->logInfo("\nPRAGA v2.0.0");
myProject->logInfo("Execute script: " + scriptFileName);

if (scriptFileName == "")
Expand Down

0 comments on commit eb9106f

Please sign in to comment.