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

◆ ccScalarField() [2/2]

ccScalarField::ccScalarField ( const ccScalarField sf)

Copy constructor.

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

◆ ~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.

Referenced by sfEditDlg::alwaysShow0Changed(), define_ccScalarField(), and cloudViewer::utility::pybind_scalarfield().

◆ areNaNValuesShownInGrey()

bool ccScalarField::areNaNValuesShownInGrey ( ) const
inline

Returns whether NaN values are displayed in gray or hidden.

Definition at line 156 of file ecvScalarField.h.

Referenced by define_ccScalarField(), ccSNECloud::drawMeOnly(), sfEditDlg::fillDialogWith(), sfEditDlg::nanInGrayChanged(), and cloudViewer::utility::pybind_scalarfield().

◆ computeMinAndMax()

◆ 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(), cloudViewer::utility::pybind_scalarfield(), ccHistogramWindow::refresh(), and ecvFilterByLabelDlg::setInputEntity().

◆ 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.

◆ 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(), and normalize().

Referenced by ccRasterizeTool::addNewContour(), define_ccScalarField(), ccSNECloud::drawMeOnly(), ccHistogramWindow::refresh(), and ccHistogramWindow::refreshBars().

◆ getColorRampSteps()

unsigned ccScalarField::getColorRampSteps ( ) const
inline

◆ getColorScale()

◆ getGlobalShift()

double ccScalarField::getGlobalShift ( ) const
inline

◆ 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(), and sfEditDlg::fillDialogWith().

◆ getModificationFlag()

bool ccScalarField::getModificationFlag ( ) const
inline

Returns modification flag state.

Definition at line 219 of file ecvScalarField.h.

Referenced by define_ccScalarField(), and cloudViewer::utility::pybind_scalarfield().

◆ getValueColor()

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

Shortcut to getColor.

Definition at line 147 of file ecvScalarField.h.

References cloudViewer::ScalarField::getValue().

Referenced by define_ccScalarField().

◆ importParametersFrom()

void ccScalarField::importParametersFrom ( const ccScalarField sf)

Imports the parameters from another scalar field.

Referenced by ccCropTool::Crop(), and define_ccScalarField().

◆ isSerializable()

bool ccScalarField::isSerializable ( ) const
inlineoverridevirtual

Returns whether object is serializable of not.

Reimplemented from ccSerializableObject.

Definition at line 225 of file ecvScalarField.h.

Referenced by cloudViewer::utility::pybind_scalarfield().

◆ 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(), and cloudViewer::utility::pybind_scalarfield().

◆ 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(), and cloudViewer::utility::pybind_scalarfield().

◆ 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(), sfEditDlg::logScaleChanged(), and cloudViewer::utility::pybind_scalarfield().

◆ 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).

Referenced by define_ccScalarField(), and cloudViewer::utility::pybind_scalarfield().

◆ 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.

◆ 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

◆ 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(), cloudViewer::utility::pybind_scalarfield(), and ccHistogramWindow::refresh().

◆ setColorRampSteps()

void ccScalarField::setColorRampSteps ( unsigned  steps)

◆ setColorScale()

◆ setGlobalShift()

void ccScalarField::setGlobalShift ( double  shift)
inline

Sets the global shift.

Definition at line 236 of file ecvScalarField.h.

Referenced by define_ccScalarField(), SimpleBinFilter::loadFile(), and cloudViewer::utility::pybind_scalarfield().

◆ setLogScale()

void ccScalarField::setLogScale ( bool  state)

Sets whether scale is logarithmic or not.

Referenced by define_ccScalarField(), sfEditDlg::logScaleChanged(), and cloudViewer::utility::pybind_scalarfield().

◆ 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(), and cloudViewer::utility::pybind_scalarfield().

◆ setSaturationStart()

◆ setSaturationStop()

void ccScalarField::setSaturationStop ( ScalarType  val)

◆ setSymmetricalScale()

◆ showNaNValuesInGrey()

void ccScalarField::showNaNValuesInGrey ( bool  state)

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

Referenced by define_ccScalarField(), qPoissonRecon::doAction(), sfEditDlg::nanInGrayChanged(), and cloudViewer::utility::pybind_scalarfield().

◆ 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(), cloudViewer::utility::pybind_scalarfield(), ccHistogramWindow::refresh(), and sfEditDlg::symmetricalScaleChanged().

◆ 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.

◆ updateSaturationBounds()

void ccScalarField::updateSaturationBounds ( )
protected

Updates saturation values.

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.

◆ m_colorRampSteps

unsigned ccScalarField::m_colorRampSteps
protected

Number of color ramps steps (for display)

Definition at line 286 of file ecvScalarField.h.

◆ m_colorScale

ccColorScale::Shared ccScalarField::m_colorScale
protected

Active color ramp (for display)

Definition at line 283 of file ecvScalarField.h.

◆ m_displayRange

Range ccScalarField::m_displayRange
protected

Displayed values range.

Definition at line 256 of file ecvScalarField.h.

◆ 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.

◆ 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.

◆ m_logScale

bool ccScalarField::m_logScale
protected

Whether scale is logarithmic or not.

Definition at line 277 of file ecvScalarField.h.

◆ 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.

◆ m_saturationRange

Range ccScalarField::m_saturationRange
protected

Saturation values range.

For color mapping with relative scales.

Definition at line 261 of file ecvScalarField.h.

◆ 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.

◆ 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.


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