20 if (!cloud || !resultSFName) {
31 const char* resultSFName,
34 if (!cloud || !resultSFName) {
58 if (generatedScalarFields) {
60 generatedScalarFields->
push(cloud, newSF, behavior);
76 s =
static_cast<ScalarType
>(s1 - s2);
79 s =
static_cast<ScalarType
>(s1 + s2);
82 if (
std::abs(s2) > std::numeric_limits<ScalarType>::epsilon())
83 s =
static_cast<ScalarType
>(s1 / s2);
86 s =
static_cast<ScalarType
>(s1 * s2);
98 if (!sf1 || !sf2 || sf1->size() != sf2->size() ||
105 for (
unsigned i = 0; i < sf1->size(); ++i) {
120 if (!outSF || sf1.
size() != sf2.
size() || sf1.
size() != outSF->size() ||
127 for (
unsigned i = 0; i < sf1.
size(); ++i) {
140 if (!file.open(QFile::WriteOnly | QFile::Text)) {
145 QTextStream stream(&file);
147 for (
const Source& s : sources) {
156 if (!file.open(QFile::ReadOnly | QFile::Text)) {
161 QTextStream stream(&file);
162 QString header = stream.readLine();
163 if (!header.startsWith(
"#Features_SF")) {
169 QString line = stream.readLine();
170 if (line.isNull())
break;
171 if (line.isEmpty())
continue;
172 QStringList tokens = line.split(
':');
173 if (tokens.size() != 2) {
180 int sourceType = tokens[0].toInt(&ok);
187 src.
name = tokens[1];
189 sources.push_back(src);
198 sources.reserve(features.size());
199 }
catch (
const std::bad_alloc&) {
205 sources.push_back(f->source);
constexpr ScalarType NAN_VALUE
NaN as a ScalarType value.
virtual void release()
Decrease counter and deletes object when 0.
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
virtual size_t size() const =0
virtual double pointValue(unsigned index) const =0
void push(ccPointCloud *cloud, cloudViewer::ScalarField *sf, Behavior behavior)
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
A scalar field associated to display-related parameters.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
unsigned size() const override
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 & getValue(std::size_t index)
void setValue(std::size_t index, ScalarType value)
bool resizeSafe(std::size_t count, bool initNewElements=false, ScalarType valueForNewElements=0)
Resizes memory (no exception thrown)
__host__ __device__ int2 abs(int2 v)
QTextStream & endl(QTextStream &stream)
Sources of values for this feature.
std::vector< Source > Set
static bool CheckSFExistence(ccPointCloud *cloud, const char *resultSFName)
static bool ExtractSources(const Set &features, Source::Set &sources)
Extracts the set of 'sources' from a set of features.
static bool SaveSources(const Source::Set &sources, QString filename)
Saves a set of 'sources' to a file.
std::vector< Shared > Set
Set of features.
static bool LoadSources(Source::Set &sources, QString filename)
Loads a set of 'sources' from a file.
QSharedPointer< Feature > Shared
Shared type.
static ScalarType PerformMathOp(double s1, double s2, Operation op)
Performs a mathematical operation between two scalars.
static cloudViewer::ScalarField * PrepareSF(ccPointCloud *cloud, const char *resultSFName, SFCollector *generatedScalarFields, SFCollector::Behavior behavior)