Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccTagXmlSparseMatrixArray Class Reference

#include <IccTagXml.h>

+ Inheritance diagram for CIccTagXmlSparseMatrixArray:
+ Collaboration diagram for CIccTagXmlSparseMatrixArray:

Public Member Functions

virtual const char * GetClassName () const
 
virtual IIccExtensionTagGetExtension ()
 
virtual bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
virtual bool ToXml (std::string &xml, std::string blanks="")
 
virtual ~CIccTagXmlSparseMatrixArray ()
 
- Public Member Functions inherited from CIccTagSparseMatrixArray
 CIccTagSparseMatrixArray (const CIccTagSparseMatrixArray &ITSMA)
 Name: CIccTagSparseMatrixArray::CIccTagSparseMatrixArray.
 
 CIccTagSparseMatrixArray (int nNumMatrices=1, int nChannelsPerMatrix=4)
 Name: CIccTagSparseMatrixArray::CIccTagSparseMatrixArray.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagSparseMatrixArray::Describe.
 
icUInt32Number GetBytesPerMatrix () const
 
icUInt32Number GetChannelsPerMatrix () const
 
icSparseMatrixType GetMatrixType () const
 
icUInt32Number GetNumMatrices () const
 Returns the number of matrices in the array.
 
virtual icUInt32Number GetNumValues () const
 
bool GetSparseMatrix (CIccSparseMatrix &mtx, int nIndex, bool bInitFromData=true)
 Name: CIccTagSparseMatrixArray::GetValues.
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
virtual bool GetValues (icFloatNumber *DstVector, icUInt32Number nStart=0, icUInt32Number nVectorSize=1) const
 
virtual bool Interpolate (icFloatNumber *DstVector, icFloatNumber val, icUInt32Number nVectorSize=1, icFloatNumber *zeroVals=NULL) const
 Name: CIccTagSparseMatrixArray::Interpolate.
 
virtual bool IsArrayType ()
 
virtual bool IsMatrixArray () const
 
virtual bool IsNumArrayType () const
 
virtual CIccTagNewCopy ()
 
CIccTagSparseMatrixArrayoperator= (const CIccTagSparseMatrixArray &ITSMA)
 Name: CIccTagSparseMatrixArray::operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagSparseMatrixArray::Read.
 
bool Reset (icUInt32Number nNumMatrices, icUInt16Number nChannelsPerMatrix)
 Name: CIccTagSparseMatrixArray::Reset.
 
void SetMatrixType (icSparseMatrixType nType)
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagSparseMatrixArray::Validate.
 
virtual bool ValuePos (icFloatNumber &DstPos, icFloatNumber val, bool &bNoZero) const
 Name: CIccTagSparseMatrixArray::ValuePos.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagSparseMatrixArray::Write.
 
virtual ~CIccTagSparseMatrixArray ()
 Name: CIccTagSparseMatrixArray::~CIccTagSparseMatrixArray.
 
- Public Member Functions inherited from CIccTag
 CIccTag ()
 Name: CIccTag::CIccTag.
 
virtual void DetachIO ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual icArraySignature GetTagArrayType () const
 
virtual icStructSignature GetTagStructType () const
 
virtual bool IsMBBType ()
 
virtual bool IsSupported ()
 Function: IsSupported(size, pIO) - Check if tag fully supported for apply purposes.
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO, CIccProfile *pProfile)
 Function: Read(size, pIO) - Read tag from file.
 
virtual bool ReadAll ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual ~CIccTag ()
 Name: CIccTag::CIccTag.
 
- Public Member Functions inherited from CIccTagXml
virtual const char * GetExtClassName () const
 
virtual const char * GetExtDerivedClassName () const
 
virtual ~CIccTagXml (void)
 

Additional Inherited Members

- Static Public Member Functions inherited from CIccTag
static CIccTagCreate (icTagTypeSignature sig)
 Name: CIccTag::Create.
 
- Public Attributes inherited from CIccTag
icUInt32Number m_nReserved
 
- Protected Attributes inherited from CIccTagSparseMatrixArray
bool m_bNonZeroPadding
 
icUInt16Number m_nChannelsPerMatrix
 
icSparseMatrixType m_nMatrixType
 
icUInt32Number m_nSize
 
icUInt8Numberm_RawData
 

Detailed Description

Definition at line 269 of file IccTagXml.h.

Constructor & Destructor Documentation

◆ ~CIccTagXmlSparseMatrixArray()

virtual CIccTagXmlSparseMatrixArray::~CIccTagXmlSparseMatrixArray ( )
inlinevirtual

Definition at line 272 of file IccTagXml.h.

272{}

Member Function Documentation

◆ GetClassName()

virtual const char * CIccTagXmlSparseMatrixArray::GetClassName ( ) const
inlinevirtual

Reimplemented from CIccTagSparseMatrixArray.

Definition at line 274 of file IccTagXml.h.

274{return "CIccTagXmlSparseMatrixArray"; }

◆ GetExtension()

virtual IIccExtensionTag * CIccTagXmlSparseMatrixArray::GetExtension ( )
inlinevirtual

Reimplemented from CIccTag.

Definition at line 276 of file IccTagXml.h.

276{return this; }

◆ ParseXml()

bool CIccTagXmlSparseMatrixArray::ParseXml ( xmlNode * pNode,
std::string & parseStr )
virtual

Implements CIccTagXml.

Definition at line 1070 of file IccTagXml.cpp.

1071{
1072 pNode = icXmlFindNode(pNode, "SparseMatrixArray");
1073
1074 if (pNode) {
1075 xmlAttr *outputChan = icXmlFindAttr(pNode, "outputChannels");
1076 xmlAttr *matrixType = icXmlFindAttr(pNode, "matrixType");
1077
1078 if (outputChan && matrixType) {
1079 icUInt32Number nChannelsPerMatrix = atoi(icXmlAttrValue(outputChan));
1080 icSparseMatrixType nMatrixType = (icSparseMatrixType)atoi(icXmlAttrValue(matrixType));
1081
1082 xmlNode *pChild;
1083
1084 int n=0;
1085 for (pChild = pNode->children; pChild; pChild=pChild->next) {
1086 if (pChild->type == XML_ELEMENT_NODE &&
1087 (!icXmlStrCmp(pChild->name, "SparseMatrix") || !icXmlStrCmp(pChild->name, "FullMatrix")))
1088 n++;
1089
1090 }
1091 Reset(n, (icUInt16Number)nChannelsPerMatrix);
1092 m_nMatrixType = (icSparseMatrixType)nMatrixType;
1093
1094 icUInt32Number bytesPerMatrix = GetBytesPerMatrix();
1095 CIccSparseMatrix mtx;
1096 int i=0;
1097 for (pChild = pNode->children; pChild; pChild=pChild->next) {
1098 if (pChild->type == XML_ELEMENT_NODE) {
1099 if (!icXmlStrCmp(pChild->name, "SparseMatrix")) {
1100 mtx.Reset(m_RawData + i*bytesPerMatrix, bytesPerMatrix, icSparseMatrixFloatNum, false);
1101
1102 xmlAttr *rows = icXmlFindAttr(pChild, "rows");
1103 xmlAttr *cols = icXmlFindAttr(pChild, "cols");
1104
1105 if (rows && cols) {
1106 icUInt16Number nRows, nCols;
1107
1108 nRows = atoi(icXmlAttrValue(rows));
1109 nCols = atoi(icXmlAttrValue(cols));
1110
1111 mtx.Init(nRows, nCols, true);
1112
1113 icUInt16Number *rowstart = mtx.GetRowStart();
1114 icUInt32Number nMaxEntries = mtx.GetMaxEntries();
1115 xmlNode *pRow;
1116 int iRow=0;
1117 icUInt32Number pos = 0;
1118 for (pRow=pChild->children; pRow; pRow=pRow->next) {
1119 if (pRow->type == XML_ELEMENT_NODE && !icXmlStrCmp(pRow->name, "SparseRow")) {
1120 xmlNode *pIdx = icXmlFindNode(pRow->children, "ColIndices");
1121 xmlNode *pData = icXmlFindNode(pRow->children, "ColData");
1122
1123 if (pIdx && pData) {
1124 CIccUInt16Array idx;
1125 CIccFloatArray data;
1126
1127 if (!idx.ParseTextArray(pIdx) || !data.ParseTextArray(pData)) {
1128 parseStr += "Unable to parse SparseRow index or data values\n";
1129 return false;
1130 }
1131 if (idx.GetSize() != data.GetSize()) {
1132 parseStr += "Mismatch between SparseRow index and data lengths\n";
1133 return false;
1134 }
1135 if (pos+idx.GetSize() > nMaxEntries) {
1136 parseStr += "Exceeded maximum number of sparse matrix entries\n";
1137 return false;
1138 }
1139 rowstart[iRow] = (icUInt16Number)pos;
1140 memcpy(mtx.GetColumnsForRow(iRow), idx.GetBuf(), idx.GetSize()*sizeof(icUInt16Number));
1141 memcpy(mtx.GetData()->getPtr(pos), data.GetBuf(), data.GetSize()*sizeof(icFloatNumber));
1142 pos += idx.GetSize();
1143 }
1144 iRow++;
1145 }
1146 }
1147 while(iRow<nRows) {
1148 rowstart[iRow] = (icUInt16Number)pos;
1149 iRow++;
1150 }
1151 rowstart[iRow] = (icUInt16Number)pos;
1152 }
1153 else {
1154 parseStr += "Cannot find SparseMatrix rows and cols\n";
1155 return false;
1156 }
1157
1158 i++;
1159 }
1160 else if (!icXmlStrCmp(pChild->name, "FullMatrix")) {
1161 mtx.Reset(m_RawData + i*bytesPerMatrix, bytesPerMatrix, icSparseMatrixFloatNum, false);
1162
1163 xmlAttr *rows = icXmlFindAttr(pChild, "rows");
1164 xmlAttr *cols = icXmlFindAttr(pChild, "cols");
1165
1166 if (rows && cols) {
1167 icUInt16Number nRows, nCols;
1168
1169 nRows = atoi(icXmlAttrValue(rows));
1170 nCols = atoi(icXmlAttrValue(cols));
1171
1172 mtx.Init(nRows, nCols, true);
1173
1174 CIccFloatArray data;
1175 data.ParseTextArray(pChild);
1176 if (data.GetSize()==nRows*nCols) {
1177 if (!mtx.FillFromFullMatrix(data.GetBuf()))
1178 parseStr += "Exceeded maximum number of sparse matrix entries\n";
1179 }
1180 else {
1181 parseStr += "Invalid FullMatrix data dimensions\n";
1182 return false;
1183 }
1184 }
1185 else {
1186 parseStr += "Cannot find FullMatrix rows and cols\n";
1187 return false;
1188 }
1189 i++;
1190 }
1191 }
1192 }
1193 return true;
1194 }
1195 else {
1196 parseStr += "Cannot find outputChannels and matrixType members\n";
1197 }
1198 }
1199 else {
1200 parseStr += "Cannot find SparseMatrixArray node\n";
1201 }
1202
1203 return false;
1204}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
unsigned int icUInt32Number
bool FillFromFullMatrix(icFloatNumber *pData)
icUInt16Number * GetColumnsForRow(icUInt16Number nRow=0) const
IIccSparseMatrixEntry * GetData() const
icUInt32Number GetMaxEntries()
void Reset(void *pMatrix, icUInt32Number nSize, icSparseMatrixType nType, bool bInitFromData=true)
icUInt16Number * GetRowStart() const
bool Init(icUInt16Number nRows, icUInt16Number nCols, bool bSetData=false)
icUInt8Number * m_RawData
bool Reset(icUInt32Number nNumMatrices, icUInt16Number nChannelsPerMatrix)
Name: CIccTagSparseMatrixArray::Reset.
icUInt32Number GetBytesPerMatrix() const
icSparseMatrixType m_nMatrixType
bool ParseTextArray(const char *szText)
icUInt32Number GetSize()
Definition IccUtilXml.h:166
virtual icUInt8Number * getPtr(int index=0) const =0
icSparseMatrixType
unsigned short icUInt16Number
#define icSparseMatrixFloatNum
Convenience Enum Definition - Not defined in ICC specification.

References CIccSparseMatrix::FillFromFullMatrix(), CIccXmlArrayType< T, Tsig >::GetBuf(), CIccSparseMatrix::GetColumnsForRow(), CIccSparseMatrix::GetData(), CIccSparseMatrix::GetMaxEntries(), IIccSparseMatrixEntry::getPtr(), CIccSparseMatrix::GetRowStart(), CIccXmlArrayType< T, Tsig >::GetSize(), icSparseMatrixFloatNum, icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), icXmlStrCmp, CIccSparseMatrix::Init(), CIccXmlArrayType< T, Tsig >::ParseTextArray(), and CIccSparseMatrix::Reset().

+ Here is the call graph for this function:

◆ ToXml()

bool CIccTagXmlSparseMatrixArray::ToXml ( std::string & xml,
std::string blanks = "" )
virtual

Implements CIccTagXml.

Definition at line 1030 of file IccTagXml.cpp.

1031{
1032 char buf[256];
1033 int i, j, n;
1034
1035 sprintf(buf, "<SparseMatrixArray outputChannels=\"%d\" matrixType=\"%d\">\n", m_nChannelsPerMatrix, m_nMatrixType);
1036 xml += blanks + buf;
1037
1038 CIccSparseMatrix mtx;
1039 icUInt32Number bytesPerMatrix = GetBytesPerMatrix();
1040
1041 for (i=0; i<(int)m_nSize; i++) {
1042 mtx.Reset(m_RawData+i*bytesPerMatrix, bytesPerMatrix, icSparseMatrixFloatNum, true);
1043 sprintf(buf, " <SparseMatrix rows=\"%d\" cols=\"%d\">\n", mtx.Rows(), mtx.Cols());
1044 xml += blanks + buf;
1045
1046 for (j=0; j<(int)mtx.Rows(); j++) {
1047 xml += blanks + " <SparseRow>\n";
1048
1049 n=mtx.GetNumRowColumns(j);
1050
1051 xml += blanks + " <ColIndices>\n";
1052 CIccUInt16Array::DumpArray(xml, blanks+" ", mtx.GetColumnsForRow(j), n, icConvert16Bit, 8);
1053 xml += blanks + " </ColIndices>\n";
1054
1055 xml += blanks + " <ColData>\n";
1056 CIccFloatArray::DumpArray(xml, blanks+" ", (icFloatNumber*)(mtx.GetData()->getPtr(mtx.GetRowOffset(j))), n, icConvertFloat, 8);
1057 xml += blanks + " </ColData>\n";
1058
1059 xml += blanks + " </SparseRow>\n";
1060 }
1061 xml += blanks + " </SparseMatrix>\n";
1062 }
1063
1064 xml += blanks + "</SparseMatrixArray>\n";
1065
1066 return true;
1067}
@ icConvertFloat
@ icConvert16Bit
icUInt16Number GetNumRowColumns(icUInt16Number nRow) const
icUInt16Number GetRowOffset(icUInt16Number nRow=0)
icUInt16Number Cols() const
icUInt16Number Rows() const
icUInt16Number m_nChannelsPerMatrix
static bool DumpArray(std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize, icConvertType nType, icUInt8Number nColumns)

References CIccSparseMatrix::Cols(), CIccXmlArrayType< T, Tsig >::DumpArray(), CIccSparseMatrix::GetColumnsForRow(), CIccSparseMatrix::GetData(), CIccSparseMatrix::GetNumRowColumns(), IIccSparseMatrixEntry::getPtr(), CIccSparseMatrix::GetRowOffset(), icConvert16Bit, icConvertFloat, icSparseMatrixFloatNum, CIccSparseMatrix::Reset(), and CIccSparseMatrix::Rows().

+ Here is the call graph for this function:

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