55 ScalarType& mean, ScalarType* variance =
nullptr)
const;
62 return std::isfinite(value);
77 inline void fill(ScalarType fillValue = 0) {
79 resize(capacity(), fillValue);
81 std::fill(begin(), end(), fillValue);
88 bool initNewElements =
false,
89 ScalarType valueForNewElements = 0);
92 inline ScalarType&
getValue(std::size_t index) {
return at(index); }
93 inline const ScalarType&
getValue(std::size_t index)
const {
96 inline void setValue(std::size_t index, ScalarType value) {
99 inline void addElement(ScalarType value) { push_back(value); }
101 return static_cast<unsigned>(
size());
103 inline void swap(std::size_t i1, std::size_t i2) {
124 ScalarType minVal = 0.0f;
125 ScalarType maxVal = 0.0f;
127 bool minMaxInitialized =
false;
128 for (std::size_t i = 0; i <
size(); ++i) {
129 const ScalarType& val =
at(i);
131 if (minMaxInitialized) {
134 else if (val > maxVal)
138 minVal = maxVal = val;
139 minMaxInitialized =
true;
144 if (minMaxInitialized) {
constexpr ScalarType NAN_VALUE
NaN as a ScalarType value.
A simple scalar field (to be associated to a point cloud)
void fill(ScalarType fillValue=0)
Fills the array with a particular value.
virtual void computeMinAndMax()
Determines the min and max values.
ScalarType getMin() const
Returns the minimum value.
std::size_t countValidValues() const
Returns the number of valid values in this scalar field.
~ScalarField() override=default
Default destructor.
void addElement(ScalarType value)
static ScalarType NaN()
Returns the specific NaN value.
ScalarType & getValue(std::size_t index)
void computeMeanAndVariance(ScalarType &mean, ScalarType *variance=nullptr) const
void setValue(std::size_t index, ScalarType value)
void flagValueAsInvalid(std::size_t index)
Sets the value as 'invalid' (i.e. NAN_VALUE)
const char * getName() const
Returns scalar field name.
char m_name[256]
Scalar field name.
bool reserveSafe(std::size_t count)
Reserves memory (no exception thrown)
ScalarField(const char *name=nullptr)
Default constructor.
void setName(const char *name)
Sets scalar field name.
bool resizeSafe(std::size_t count, bool initNewElements=false, ScalarType valueForNewElements=0)
Resizes memory (no exception thrown)
ScalarType m_maxVal
Maximum value.
static bool ValidValue(ScalarType value)
Returns whether a scalar value is valid or not.
void swap(std::size_t i1, std::size_t i2)
unsigned currentSize() const
ScalarType m_minVal
Minimum value.
ScalarType getMax() const
Returns the maximum value.
const ScalarType & getValue(std::size_t index) const
Generic file read and write utility for python interface.
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.