2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
#pragma once
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief Class gathering stroke creation algorithms
|
2012-12-28 20:21:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string>
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
#include "AdvancedFunctions1D.h"
|
|
|
|
|
#include "Predicates1D.h"
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
#include "../view_map/Interface1D.h"
|
2008-04-30 15:41:54 +00:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Predicates definitions
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2008-04-30 15:41:54 +00:00
|
|
|
namespace Predicates1D {
|
|
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
// DensityLowerThanUP1D
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Returns true if the density evaluated for the
|
2016-07-02 10:02:04 +10:00
|
|
|
* Interface1D is less than a user-defined density value.
|
|
|
|
|
*/
|
2012-12-28 20:21:05 +00:00
|
|
|
class DensityLowerThanUP1D : public UnaryPredicate1D {
|
|
|
|
|
public:
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Builds the functor.
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param threshold:
|
2012-12-28 20:21:05 +00:00
|
|
|
* The value of the threshold density.
|
|
|
|
|
* Any Interface1D having a density lower than this threshold will match.
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param sigma:
|
2012-12-28 20:21:05 +00:00
|
|
|
* The sigma value defining the density evaluation window size used in the DensityF0D functor.
|
|
|
|
|
*/
|
|
|
|
|
DensityLowerThanUP1D(double threshold, double sigma = 2)
|
|
|
|
|
{
|
|
|
|
|
_threshold = threshold;
|
|
|
|
|
_sigma = sigma;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Returns the string "DensityLowerThanUP1D" */
|
2012-12-28 20:21:05 +00:00
|
|
|
string getName() const
|
|
|
|
|
{
|
|
|
|
|
return "DensityLowerThanUP1D";
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** The () operator. */
|
2012-12-28 20:21:05 +00:00
|
|
|
int operator()(Interface1D &inter)
|
|
|
|
|
{
|
|
|
|
|
Functions1D::DensityF1D fun(_sigma);
|
2019-05-31 22:51:19 +10:00
|
|
|
if (fun(inter) < 0) {
|
2012-12-28 20:21:05 +00:00
|
|
|
return -1;
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2012-12-28 20:21:05 +00:00
|
|
|
result = (fun.result < _threshold);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
double _sigma;
|
|
|
|
|
double _threshold;
|
|
|
|
|
};
|
2008-04-30 15:41:54 +00:00
|
|
|
|
|
|
|
|
} // end of namespace Predicates1D
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|