ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccScalarField Class Reference

A scalar field associated to display-related parameters. More...

#include <ecvScalarField.h>

Inheritance diagram for ccScalarField:
Collaboration diagram for ccScalarField:

Classes

struct  Histogram
 Simple histogram structure. More...
 
class  Range
 Scalar field range structure. More...
 

Public Member Functions

 ccScalarField (const char *name=nullptr)
 Default constructor. More...
 
 ccScalarField (const ccScalarField &sf)
 Copy constructor. More...
 
const RangedisplayRange () const
 Access to the range of displayed values. More...
 
const RangesaturationRange () const
 Access to the range of saturation values. More...
 
const RangelogSaturationRange () const
 Access to the range of log scale saturation values. More...
 
void setMinDisplayed (ScalarType val)
 Sets the minimum displayed value. More...
 
void setMaxDisplayed (ScalarType val)
 Sets the maximum displayed value. More...
 
void setSaturationStart (ScalarType val)
 Sets the value at which to start color gradient. More...
 
void setSaturationStop (ScalarType val)
 Sets the value at which to stop color gradient. More...
 
const ecvColor::RgbgetColor (ScalarType value) const
 
const ecvColor::RgbgetValueColor (unsigned index) const
 Shortcut to getColor. More...
 
void showNaNValuesInGrey (bool state)
 
bool areNaNValuesShownInGrey () const
 Returns whether NaN values are displayed in gray or hidden. More...
 
void alwaysShowZero (bool state)
 Sets whether 0 should always appear in associated color ramp or not. More...
 
bool isZeroAlwaysShown () const
 Returns whether 0 should always appear in associated color ramp or not. More...
 
void setSymmetricalScale (bool state)
 Sets whether the color scale should be symmetrical or not. More...
 
bool symmetricalScale () const
 Returns whether the color scale s symmetrical or not. More...
 
void setLogScale (bool state)
 Sets whether scale is logarithmic or not. More...
 
bool logScale () const
 Returns whether scalar field is logarithmic or not. More...
 
void computeMinAndMax () override
 Determines the min and max values. More...
 
const ccColorScale::SharedgetColorScale () const
 Returns associated color scale. More...
 
void setColorScale (ccColorScale::Shared scale)
 Sets associated color scale. More...
 
unsigned getColorRampSteps () const
 Returns number of color ramp steps. More...
 
void setColorRampSteps (unsigned steps)
 Sets number of color ramp steps used for display. More...
 
const HistogramgetHistogram () const
 Returns associated histogram values (for display) More...
 
bool mayHaveHiddenValues () const
 
void setModificationFlag (bool state)
 Sets modification flag state. More...
 
bool getModificationFlag () const
 Returns modification flag state. More...
 
void importParametersFrom (const ccScalarField *sf)
 Imports the parameters from another scalar field. More...
 
bool isSerializable () const override
 Returns whether object is serializable of not. More...
 
bool toFile (QFile &out, short dataVersion) const override
 Saves data to binary stream. More...
 
short minimumFileVersion () const override
 Returns the minimum file version required to save this instance. More...
 
bool fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
 Loads data from binary stream. More...
 
double getGlobalShift () const
 Returns the global shift (if any) More...
 
void setGlobalShift (double shift)
 Sets the global shift. More...
 
- Public Member Functions inherited from cloudViewer::ScalarField
 ScalarField (const char *name=nullptr)
 Default constructor. More...
 
 ScalarField (const ScalarField &sf)
 Copy constructor. More...
 
void setName (const char *name)
 Sets scalar field name. More...
 
const char * getName () const
 Returns scalar field name. More...
 
void computeMeanAndVariance (ScalarType &mean, ScalarType *variance=nullptr) const
 
void flagValueAsInvalid (std::size_t index)
 Sets the value as 'invalid' (i.e. NAN_VALUE) More...
 
std::size_t countValidValues () const
 Returns the number of valid values in this scalar field. More...
 
ScalarType getMin () const
 Returns the minimum value. More...
 
ScalarType getMax () const
 Returns the maximum value. More...
 
void fill (ScalarType fillValue=0)
 Fills the array with a particular value. More...
 
bool reserveSafe (std::size_t count)
 Reserves memory (no exception thrown) More...
 
bool resizeSafe (std::size_t count, bool initNewElements=false, ScalarType valueForNewElements=0)
 Resizes memory (no exception thrown) More...
 
ScalarType & getValue (std::size_t index)
 
const ScalarType & getValue (std::size_t index) const
 
void setValue (std::size_t index, ScalarType value)
 
void addElement (ScalarType value)
 
unsigned currentSize () const
 
void swap (std::size_t i1, std::size_t i2)
 
 ~ScalarField () override=default
 Default destructor. More...
 
- Public Member Functions inherited from CCShareable
 CCShareable ()
 Default constructor. More...
 
virtual void link ()
 Increase counter. More...
 
virtual void release ()
 Decrease counter and deletes object when 0. More...
 
virtual unsigned getLinkCount () const
 Returns the current link count. More...
 
- Public Member Functions inherited from ccSerializableObject
virtual ~ccSerializableObject ()=default
 Destructor. More...
 

Protected Member Functions

 ~ccScalarField () override=default
 Default destructor. More...
 
void updateSaturationBounds ()
 Updates saturation values. More...
 
ScalarType normalize (ScalarType val) const
 Normalizes a scalar value between 0 and 1 (wrt to current parameters) More...
 
- Protected Member Functions inherited from CCShareable
virtual ~CCShareable ()
 Destructor. More...
 

Protected Attributes

Range m_displayRange
 Displayed values range. More...
 
Range m_saturationRange
 Saturation values range. More...
 
Range m_logSaturationRange
 saturation values range (log scale mode) More...
 
bool m_showNaNValuesInGrey
 Whether NaN values are shown in grey or are hidden. More...
 
bool m_symmetricalScale
 Whether color scale is symmetrical or not. More...
 
bool m_logScale
 Whether scale is logarithmic or not. More...
 
bool m_alwaysShowZero
 Whether 0 should always appear in associated color ramp. More...
 
ccColorScale::Shared m_colorScale
 Active color ramp (for display) More...
 
unsigned m_colorRampSteps
 Number of color ramps steps (for display) More...
 
Histogram m_histogram
 Associated histogram values (for display) More...
 
bool m_modified
 Modification flag. More...
 
double m_globalShift
 Global shift. More...
 
- Protected Attributes inherited from cloudViewer::ScalarField
char m_name [256]
 Scalar field name. More...
 
ScalarType m_minVal
 Minimum value. More...
 
ScalarType m_maxVal
 Maximum value. More...
 
- Protected Attributes inherited from CCShareable
unsigned m_linkCount
 Links counter. More...
 

Additional Inherited Members

- Public Types inherited from ccSerializableObject
enum  DeserializationFlags { DF_POINT_COORDS_64_BITS , DF_SCALAR_VAL_32_BITS = 2 }
 Deserialization flags (bit-field) More...
 
typedef QMultiMap< unsigned, unsigned > LoadedIDMap
 Map of loaded unique IDs (old ID --> new ID) More...
 
- Static Public Member Functions inherited from cloudViewer::ScalarField
static ScalarType NaN ()
 Returns the specific NaN value. More...
 
static bool ValidValue (ScalarType value)
 Returns whether a scalar value is valid or not. More...
 
- Static Public Member Functions inherited from ccSerializableObject
static bool WriteError ()
 Sends a custom error message (write error) and returns 'false'. More...
 
static bool ReadError ()
 Sends a custom error message (read error) and returns 'false'. More...
 
static bool MemoryError ()
 Sends a custom error message (not enough memory) and returns 'false'. More...
 
static bool CorruptError ()
 Sends a custom error message (corrupted file) and returns 'false'. More...
 

Detailed Description

A scalar field associated to display-related parameters.

Extends the cloudViewer::ScalarField object.

Definition at line 19 of file ecvScalarField.h.

Constructor & Destructor Documentation

◆ ccScalarField() [1/2]

ccScalarField::ccScalarField ( const char *  name = nullptr)
explicit

Default constructor.

Parameters
namescalar field name

Definition at line 24 of file ecvScalarField.cpp.

References ccColorScalesManager::BGYR, ccColorScale::DEFAULT_STEPS, ccColorScalesManager::GetUniqueInstance(), setColorRampSteps(), and setColorScale().

◆ ccScalarField() [2/2]

ccScalarField::ccScalarField ( const ccScalarField sf)

Copy constructor.

Parameters
sfscalar field to copy
Warning
May throw a std::bad_alloc exception

Definition at line 39 of file ecvScalarField.cpp.

References computeMinAndMax().

◆ ~ccScalarField()

ccScalarField::~ccScalarField ( )
overrideprotecteddefault

Default destructor.

Call release instead

Member Function Documentation

◆ alwaysShowZero()

void ccScalarField::alwaysShowZero ( bool  state)

Sets whether 0 should always appear in associated color ramp or not.

Definition at line 628 of file ecvScalarField.cpp.

References m_alwaysShowZero, and m_modified.

Referenced by sfEditDlg::alwaysShow0Changed(), define_ccScalarField(), and importParametersFrom().

◆ areNaNValuesShownInGrey()

bool ccScalarField::areNaNValuesShownInGrey ( ) const
inline

◆ computeMinAndMax()

void ccScalarField::computeMinAndMax ( )
overridevirtual

Determines the min and max values.

Reimplemented from cloudViewer::ScalarField.

Definition at line 145 of file ecvScalarField.cpp.

References cloudViewer::utility::ceil(), count, cloudViewer::ScalarField::currentSize(), cloudViewer::utility::floor(), cloudViewer::ScalarField::getValue(), m_displayRange, m_histogram, cloudViewer::ScalarField::m_maxVal, cloudViewer::ScalarField::m_minVal, m_modified, MAX_HISTOGRAM_SIZE, ccScalarField::Range::maxRange(), ccScalarField::Histogram::maxValue, ccScalarField::Range::min(), ccScalarField::Range::setBounds(), updateSaturationBounds(), and CVLog::Warning().

Referenced by ccPointCloud::append(), ccScalarField(), masc::Classifier::classify(), qM3C2Process::Compute(), qVoxFallProcess::Compute(), DistanceMapGenerationTool::ComputeRadialDist(), DistanceMapGenerationTool::ConvertMapToCloud(), ccPointCloud::convertNormalToDipDirSFs(), ccRasterGrid::convertToCloud(), vtk2cc::ConvertToPointCloud(), pcl2cc::CopyScalarField(), copyScalarFields(), ccMeasurementDevice::createScalarFieldForCloud(), qPCV::doAction(), qPoissonRecon::doAction(), ccDBRoot::editLabelScalarValue(), ccCompass::estimateStrain(), masc::Classifier::evaluate(), ccPointCloud::From(), ccRasterizeTool::generateHillshade(), LoadCloud(), PTXFilter::loadFile(), VTKFilter::loadFile(), LoadScan(), ccFastMarchingForNormsDirection::OrientNormals(), ccPointCloud::partialClone(), CommandStatTest::process(), PCVCommand::Process(), ccPointCloud::RemoveNonFinitePoints(), ResolveNormalsWithMST(), ccPointCloud::SelectByIndex(), ccEntityAction::statisticalTest(), and DistanceMapGenerationDlg::update().

◆ displayRange()

const Range& ccScalarField::displayRange ( ) const
inline

Access to the range of displayed values.

Values outside of the [start;stop] intervale will either be grey or invisible (see showNaNValuesInGrey).

Definition at line 108 of file ecvScalarField.h.

Referenced by ccRasterizeTool::activeLayerChanged(), ccColorFromScalarDlg::ccColorFromScalarDlg(), define_ccScalarField(), ccSNECloud::drawMeOnly(), sfEditDlg::fillDialogWith(), ccHistogramWindow::fromSF(), importParametersFrom(), ccHistogramWindow::refresh(), ecvFilterByLabelDlg::setInputEntity(), and PclTools::UpdateScalarBar().

◆ fromFile()

bool ccScalarField::fromFile ( QFile &  in,
short  dataVersion,
int  flags,
LoadedIDMap oldToNewIDMap 
)
overridevirtual

Loads data from binary stream.

Parameters
ininput file (already opened)
dataVersionfile version (for version-specific deserialization)
flagsdeserialization flags (see ccSerializableObject::DeserializationFlags)
oldToNewIDMapmap to link old IDs with new IDs
Returns
success
Note: When implementing, use dataVersion checks to handle different
versions:
  • if (dataVersion >= X) { read new field } else { use default value } This ensures forward compatibility with older file formats.

Reimplemented from ccSerializableObject.

Definition at line 390 of file ecvScalarField.cpp.

◆ getColor()

const ecvColor::Rgb* ccScalarField::getColor ( ScalarType  value) const
inline

Returns the color corresponding to a given value (wrt to the current display parameters) Warning: must no be called if the SF is not associated to a color scale!

Definition at line 139 of file ecvScalarField.h.

References ecvColor::lightGrey().

Referenced by ccRasterizeTool::addNewContour(), define_ccScalarField(), ccSNECloud::drawMeOnly(), ccPointCloud::getScalarValueColor(), ccGenericPointCloud::pointPicking(), ccOctree::pointPicking(), ccHistogramWindow::refresh(), ccHistogramWindow::refreshBars(), and PclTools::UpdateScalarBar().

◆ getColorRampSteps()

unsigned ccScalarField::getColorRampSteps ( ) const
inline

Returns number of color ramp steps.

Definition at line 194 of file ecvScalarField.h.

Referenced by define_ccScalarField(), importParametersFrom(), ccHistogramWindow::refresh(), and ccPropertiesTreeDelegate::setEditorData().

◆ getColorScale()

◆ getGlobalShift()

◆ getHistogram()

const Histogram& ccScalarField::getHistogram ( ) const
inline

Returns associated histogram values (for display)

Definition at line 206 of file ecvScalarField.h.

Referenced by ccHistogramWindow::computeBinArrayFromSF(), define_ccScalarField(), sfEditDlg::fillDialogWith(), and PclTools::UpdateScalarBar().

◆ getModificationFlag()

bool ccScalarField::getModificationFlag ( ) const
inline

Returns modification flag state.

Definition at line 219 of file ecvScalarField.h.

Referenced by define_ccScalarField().

◆ getValueColor()

const ecvColor::Rgb* ccScalarField::getValueColor ( unsigned  index) const
inline

◆ importParametersFrom()

◆ isSerializable()

bool ccScalarField::isSerializable ( ) const
inlineoverridevirtual

Returns whether object is serializable of not.

Reimplemented from ccSerializableObject.

Definition at line 225 of file ecvScalarField.h.

◆ isZeroAlwaysShown()

bool ccScalarField::isZeroAlwaysShown ( ) const
inline

Returns whether 0 should always appear in associated color ramp or not.

Definition at line 164 of file ecvScalarField.h.

Referenced by sfEditDlg::alwaysShow0Changed(), define_ccScalarField(), sfEditDlg::fillDialogWith(), importParametersFrom(), and PclTools::UpdateScalarBar().

◆ logSaturationRange()

const Range& ccScalarField::logSaturationRange ( ) const
inline

Access to the range of log scale saturation values.

Relative color scales will only be applied to values inside the [start;stop] intervale.

Definition at line 122 of file ecvScalarField.h.

Referenced by define_ccScalarField().

◆ logScale()

bool ccScalarField::logScale ( ) const
inline

Returns whether scalar field is logarithmic or not.

Definition at line 180 of file ecvScalarField.h.

Referenced by define_ccScalarField(), sfEditDlg::fillDialogWith(), importParametersFrom(), sfEditDlg::logScaleChanged(), and PclTools::UpdateScalarBar().

◆ mayHaveHiddenValues()

bool ccScalarField::mayHaveHiddenValues ( ) const

Returns whether the scalar field in its current configuration MAY have 'hidden' values or not 'Hidden' values are typically NaN values or values outside of the 'displayed' intervale while those values are not displayed in grey (see ccScalarField::showNaNValuesInGrey).

Definition at line 615 of file ecvScalarField.cpp.

References areNaNValuesShownInGrey(), m_displayRange, ccScalarField::Range::max(), ccScalarField::Range::min(), ccScalarField::Range::start(), and ccScalarField::Range::stop().

Referenced by define_ccScalarField(), ccGenericPointCloud::pointPicking(), and ccOctree::pointPicking().

◆ minimumFileVersion()

short ccScalarField::minimumFileVersion ( ) const
overridevirtual

Returns the minimum file version required to save this instance.

To be overridden by subclasses to indicate their minimum required version. This enables the system to determine:

  • Forward compatibility: newer software can read older files (dataVersion check in fromFile)
  • Backward compatibility: determine minimum version needed to save current data
    Returns
    minimum file version required for this object

Implements ccSerializableObject.

Definition at line 373 of file ecvScalarField.cpp.

References getGlobalShift(), m_colorScale, and cloudViewer::ScalarField::m_name.

◆ normalize()

ScalarType ccScalarField::normalize ( ScalarType  val) const
protected

Normalizes a scalar value between 0 and 1 (wrt to current parameters)

Parameters
valscalar value
Returns
a number between 0 and 1 if inside displayed range or -1 otherwise

ValidValue(d) ||

Definition at line 56 of file ecvScalarField.cpp.

References ccScalarField::Range::isInRange(), m_displayRange, m_logSaturationRange, m_logScale, m_saturationRange, m_symmetricalScale, ccScalarField::Range::range(), ccScalarField::Range::start(), ccScalarField::Range::stop(), and ZERO_TOLERANCE_SCALAR.

◆ saturationRange()

const Range& ccScalarField::saturationRange ( ) const
inline

Access to the range of saturation values.

Relative color scales will only be applied to values inside the [start;stop] intervale.

Definition at line 114 of file ecvScalarField.h.

Referenced by ccColorFromScalarDlg::ccColorFromScalarDlg(), define_ccScalarField(), sfEditDlg::fillDialogWith(), importParametersFrom(), ccHistogramWindow::refresh(), and PclTools::UpdateScalarBar().

◆ setColorRampSteps()

void ccScalarField::setColorRampSteps ( unsigned  steps)

◆ setColorScale()

◆ setGlobalShift()

void ccScalarField::setGlobalShift ( double  shift)
inline

◆ setLogScale()

void ccScalarField::setLogScale ( bool  state)

Sets whether scale is logarithmic or not.

Definition at line 132 of file ecvScalarField.cpp.

References m_logScale, cloudViewer::ScalarField::m_minVal, m_modified, and CVLog::Warning().

Referenced by define_ccScalarField(), importParametersFrom(), and sfEditDlg::logScaleChanged().

◆ setMaxDisplayed()

void ccScalarField::setMaxDisplayed ( ScalarType  val)

◆ setMinDisplayed()

◆ setModificationFlag()

void ccScalarField::setModificationFlag ( bool  state)
inline

Sets modification flag state.

Definition at line 217 of file ecvScalarField.h.

Referenced by define_ccScalarField().

◆ setSaturationStart()

◆ setSaturationStop()

◆ setSymmetricalScale()

◆ showNaNValuesInGrey()

void ccScalarField::showNaNValuesInGrey ( bool  state)

Sets whether NaN/out of displayed range values should be displayed in gray or hidden

Definition at line 623 of file ecvScalarField.cpp.

References m_modified, and m_showNaNValuesInGrey.

Referenced by define_ccScalarField(), qPoissonRecon::doAction(), importParametersFrom(), and sfEditDlg::nanInGrayChanged().

◆ symmetricalScale()

bool ccScalarField::symmetricalScale ( ) const
inline

Returns whether the color scale s symmetrical or not.

For relative color scales only.

Definition at line 174 of file ecvScalarField.h.

Referenced by define_ccScalarField(), sfEditDlg::fillDialogWith(), importParametersFrom(), ccHistogramWindow::refresh(), sfEditDlg::symmetricalScaleChanged(), and PclTools::UpdateScalarBar().

◆ toFile()

bool ccScalarField::toFile ( QFile &  out,
short  dataVersion 
) const
overridevirtual

Saves data to binary stream.

Parameters
outoutput file (already opened)
dataVersiontarget file version (for forward/backward compatibility)
Returns
success

Reimplemented from ccSerializableObject.

Definition at line 295 of file ecvScalarField.cpp.

◆ updateSaturationBounds()

Member Data Documentation

◆ m_alwaysShowZero

bool ccScalarField::m_alwaysShowZero
protected

Whether 0 should always appear in associated color ramp.

Definition at line 280 of file ecvScalarField.h.

Referenced by alwaysShowZero().

◆ m_colorRampSteps

unsigned ccScalarField::m_colorRampSteps
protected

Number of color ramps steps (for display)

Definition at line 286 of file ecvScalarField.h.

Referenced by setColorRampSteps().

◆ m_colorScale

ccColorScale::Shared ccScalarField::m_colorScale
protected

Active color ramp (for display)

Definition at line 283 of file ecvScalarField.h.

Referenced by minimumFileVersion(), setColorScale(), and updateSaturationBounds().

◆ m_displayRange

Range ccScalarField::m_displayRange
protected

Displayed values range.

Definition at line 256 of file ecvScalarField.h.

Referenced by computeMinAndMax(), mayHaveHiddenValues(), normalize(), setMaxDisplayed(), and setMinDisplayed().

◆ m_globalShift

double ccScalarField::m_globalShift
protected

Global shift.

Definition at line 298 of file ecvScalarField.h.

◆ m_histogram

Histogram ccScalarField::m_histogram
protected

Associated histogram values (for display)

Definition at line 289 of file ecvScalarField.h.

Referenced by computeMinAndMax().

◆ m_logSaturationRange

Range ccScalarField::m_logSaturationRange
protected

saturation values range (log scale mode)

For log scale color mapping with relative scales.

Definition at line 266 of file ecvScalarField.h.

Referenced by normalize(), setSaturationStart(), setSaturationStop(), and updateSaturationBounds().

◆ m_logScale

bool ccScalarField::m_logScale
protected

Whether scale is logarithmic or not.

Definition at line 277 of file ecvScalarField.h.

Referenced by normalize(), setLogScale(), setSaturationStart(), and setSaturationStop().

◆ m_modified

bool ccScalarField::m_modified
protected

Modification flag.

Any modification to the scalar field values or parameters will turn this flag on.

Definition at line 295 of file ecvScalarField.h.

Referenced by alwaysShowZero(), computeMinAndMax(), setColorRampSteps(), setColorScale(), setLogScale(), setMaxDisplayed(), setMinDisplayed(), setSaturationStart(), setSaturationStop(), setSymmetricalScale(), showNaNValuesInGrey(), and updateSaturationBounds().

◆ m_saturationRange

Range ccScalarField::m_saturationRange
protected

Saturation values range.

For color mapping with relative scales.

Definition at line 261 of file ecvScalarField.h.

Referenced by normalize(), setSaturationStart(), setSaturationStop(), and updateSaturationBounds().

◆ m_showNaNValuesInGrey

bool ccScalarField::m_showNaNValuesInGrey
protected

Whether NaN values are shown in grey or are hidden.

Definition at line 269 of file ecvScalarField.h.

Referenced by showNaNValuesInGrey().

◆ m_symmetricalScale

bool ccScalarField::m_symmetricalScale
protected

Whether color scale is symmetrical or not.

For relative color scales only.

Definition at line 274 of file ecvScalarField.h.

Referenced by normalize(), setColorScale(), setSymmetricalScale(), and updateSaturationBounds().


The documentation for this class was generated from the following files: