233 for (
int copyIndex = 0; copyIndex < commonSize; ++copyIndex){
234 BaseClass::SetElement(copyIndex, vector[copyIndex]);
237 for (
int resetIndex = commonSize; resetIndex < Size; ++resetIndex){
238 BaseClass::SetElement(resetIndex, 0.0);
246 return GetDistance(color) <= tolerance;
253 for (
int i = 0; i < Size; ++i){
254 double component = BaseClass::GetElement(i);
256 if ((component < 0) || (component > 1)){
270 for (
int i = 0; i < Size; ++i){
271 retVal[i] = BaseClass::GetElement(i) + color[i];
283 for (
int i = 0; i < Size; ++i){
284 retVal[i] = BaseClass::GetElement(i) - color[i];
296 for (
int i = 0; i < Size; ++i){
297 retVal[i] = BaseClass::GetElement(i) * color[i];
309 for (
int i = 0; i < Size; ++i){
310 retVal[i] = BaseClass::GetElement(i) / color[i];
322 for (
int i = 0; i < Size; ++i){
323 retVal[i] = BaseClass::GetElement(i) * value;
335 for (
int i = 0; i < Size; ++i){
336 retVal[i] = BaseClass::GetElement(i) / value;
346 for (
int i = 0; i < Size; ++i){
347 BaseClass::SetElement(i, color[i]);
357 std::memset(&BaseClass::GetElementsRef()[0], 0.0,
sizeof(
double) * Size);
359 BaseClass::SetElement(0, colorValue);
368 BaseClass::operator+=(color);
377 BaseClass::operator-=(color);
386 Elements& elements = BaseClass::GetElementsRef();
388 for (
int index = 0; index < Size; ++index){
389 elements[index] *= color[index];
399 Elements& elements = BaseClass::GetElementsRef();
401 for (
int index = 0; index < Size; ++index){
402 elements[index] /= color[index];
412 BaseClass::operator*=(value);
421 BaseClass::operator/=(value);
432 for (
int i = 0; i < Size; ++i){
433 result[i] = manipulator.
GetRounded(BaseClass::GetElement(i));
441 for (
int i = 0; i < Size; ++i){
442 if (!manipulator.
AreValuesEqual(BaseClass::GetElement(i), color[i])){
454 Elements& elements = BaseClass::GetElementsRef();
456 for (
int i = 0; i < Size; ++i){
457 if (elements[i] < 0.0){
461 if (elements[i] > 1.0){
490 int elementsCount = BaseClass::GetElementsCount();
492 retVal = retVal && archive.
BeginMultiTag(colorComponentsTag, componentTag, elementsCount);
494 if ((!retVal) || (!archive.
IsStoring() && (elementsCount != Size))){
498 for (
int i = 0; i < elementsCount; ++i){
499 retVal = retVal && archive.
BeginTag(componentTag);
500 retVal = retVal && archive.
Process(BaseClass::GetElementRef(i));
501 retVal = retVal && archive.
EndTag(componentTag);
504 retVal = retVal && archive.
EndTag(colorComponentsTag);
515 quint64 retVal = seed;
524 for (
int i = 0; i < elementsCount; ++i){
525 element.value = color[i];
527 retVal = (retVal >> 1) ^ (element.raw + 1);
Generic fixed-size color implementation template.
TComposedColor< Size > operator*(const TComposedColor< Size > &color) const
const TComposedColor< Size > & operator=(const TComposedColor< Size > &color)
TComposedColor< Size > operator/(double value) const
const TComposedColor< Size > & operator=(double colorValue)
const TComposedColor< Size > & operator+=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator-=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator*=(const TComposedColor< Size > &color)
TComposedColor(const BaseClass &value)
const TComposedColor< Size > & operator*=(double value)
TComposedColor(const TComposedColor< Size > &color)=default
const TComposedColor< Size > & operator/=(double value)
bool IsRoundedEqual(const TComposedColor< Size > &color, const imath::IDoubleManip &manipulator) const
Check if two values are equal after rounding.
bool IsSimilar(const TComposedColor< Size > &color, double tolerance=I_BIG_EPSILON) const
Allows to compare two colors with tolerance.
void GetRounded(const imath::IDoubleManip &manipulator, TComposedColor< Size > &result)
Get color after components value rounding with specified precision.
TComposedColor< Size > operator*(double value) const
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
BaseClass::Elements Elements
const TComposedColor< Size > & operator/=(const TComposedColor< Size > &color)
imath::TVector< Size > BaseClass
TComposedColor(const imath::CVarVector &vector)
void GetNormalized(TComposedColor< Size > &result) const
Get normalized color.
void Normalize()
Make this color to be normalized.
TComposedColor< Size > operator+(const TComposedColor< Size > &color) const
bool IsNormalized() const
Check if this color value is normalized.
TComposedColor< Size > operator-(const TComposedColor< Size > &color) const
TComposedColor< Size > operator/(const TComposedColor< Size > &color) const
Implementation of variable-size mathematical vector with double precision elements.
int GetElementsCount() const
Get number of elements.
Interface for all manipulation using values represent as double.
virtual bool AreValuesEqual(const ValueType &value1, const ValueType &value2) const =0
Compare two values and check, if there are equal.
virtual ValueType GetRounded(const ValueType &value) const =0
Get the nearest value rounded used this arithmetik.
Implementation of fixed-size mathematical vector with specified type of elements.
static int GetElementsCount()
Get number of elements.
TVector< Size, Element > operator-() const
Process tag used to group data in archive stream.
@ TT_LEAF
Leaf tag, it can contain only one primitive element.
@ TT_MULTIPLE
Multiple tag containing variable number of child tags.
Represents an input/output persistence archive for object serialization.
virtual bool Process(bool &value)=0
Processes (reads or writes) a boolean value.
virtual bool EndTag(const CArchiveTag &tag)=0
Ends a tagged section in the archive.
virtual bool BeginMultiTag(const CArchiveTag &tag, const CArchiveTag &subTag, int &count)=0
Begins a tagged section containing multiple elements of the same type.
virtual bool IsStoring() const =0
Checks if this archive is in storing (writing) or loading (reading) mode.
virtual bool BeginTag(const CArchiveTag &tag)=0
Begins a tagged section in the archive.
Common class for all classes which objects can be archived or restored from archive.
Help class which provides the automatic update mechanism of the model.
static const double I_BIG_EPSILON
Contains color management classes.
uint qHash(const CFastColor &color, uint seed=0)