OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimMatrixProperty Class Reference

#include <ossimMatrixProperty.h>

Inheritance diagram for ossimMatrixProperty:
ossimProperty ossimObject ossimReferenced

Public Member Functions

 ossimMatrixProperty (const ossimString &name=ossimString(""), const std::vector< double > &values=std::vector< double >(), int numberOfRows=0, int numberOfColumns=0)
 
 ossimMatrixProperty (const ossimMatrixProperty &rhs)
 
virtual ~ossimMatrixProperty ()
 
virtual ossimObjectdup () const
 
virtual const ossimPropertyassign (const ossimProperty &rhs)
 
virtual bool setValue (const ossimString &value)
 
virtual void valueToString (ossimString &valueResult) const
 
void resize (int numberOfRows, int numberOfColumns)
 
double & operator() (int rowIdx, int colIdx)
 
const double & operator() (int rowIdx, int colIdx) const
 
int getNumberOfRows () const
 
int getNumberOfCols () const
 
void clearConstraints ()
 
void setColConstraints (int minNumberOfColumns, int maxNumberOfColumns)
 
void setRowConstraints (int minNumberOfRows, int maxNumberOfRows)
 
void getColConstraints (int &minNumberOfColumns, int &maxNumberOfColumns) const
 
void getRowConstraints (int &minNumberOfRows, int &maxNumberOfRows) const
 
void normalize ()
 
void zero ()
 
- Public Member Functions inherited from ossimProperty
 ossimProperty (const ossimString &name=ossimString(""))
 
 ossimProperty (const ossimProperty &rhs)
 
const ossimPropertyoperator= (const ossimProperty &rhs)
 
const ossimStringgetName () const
 
void setName (const ossimString &name)
 
virtual ossimString valueToString () const
 
virtual const ossimContainerPropertyasContainer () const
 
virtual ossimContainerPropertyasContainer ()
 
bool isChangeTypeSet (int type) const
 
void clearChangeType ()
 
void setChangeType (int type, bool on=true)
 
void setFullRefreshBit ()
 
void setCacheRefreshBit ()
 
ossimPropertyChangeType getChangeType () const
 
bool isFullRefresh () const
 
bool isCacheRefresh () const
 
bool isChangeTypeSpecified () const
 
bool affectsOthers () const
 
virtual void setReadOnlyFlag (bool flag)
 
bool getReadOnlyFlag () const
 
bool isReadOnly () const
 
void setModifiedFlag (bool flag)
 
bool getModifiedFlag () const
 
bool isModified () const
 
void clearModifiedFlag ()
 
void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual ossimRefPtr< ossimXmlNodetoXml () const
 
virtual void saveState (ossimKeywordlist &kwl, const ossimString &prefix="") const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

double density () const
 
- Protected Member Functions inherited from ossimProperty
virtual ~ossimProperty ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

std::vector< std::vector< double > > theValueArray
 
int theMinNumberOfCols
 
int theMaxNumberOfCols
 
int theMinNumberOfRows
 
int theMaxNumberOfRows
 
- Protected Attributes inherited from ossimProperty
ossimString theName
 
ossimString theDescription
 
bool theReadOnlyFlag
 
ossimPropertyChangeType theChangeType
 
bool theModifiedFlag
 

Additional Inherited Members

- Public Types inherited from ossimProperty
enum  ossimPropertyChangeType {
  ossimPropertyChangeType_NOTSPECIFIED = 0, ossimPropertyChangeType_CACHE_REFRESH = 1, ossimPropertyChangeType_FULL_REFRESH = 2, ossimPropertyChangeType_AFFECTS_OTHERS = 4,
  ossimPropertyChangeType_ALL = (ossimPropertyChangeType_CACHE_REFRESH|ossimPropertyChangeType_FULL_REFRESH|ossimPropertyChangeType_AFFECTS_OTHERS)
}
 

Detailed Description

Definition at line 15 of file ossimMatrixProperty.h.

Constructor & Destructor Documentation

◆ ossimMatrixProperty() [1/2]

ossimMatrixProperty::ossimMatrixProperty ( const ossimString name = ossimString(""),
const std::vector< double > &  values = std::vector<double>(),
int  numberOfRows = 0,
int  numberOfColumns = 0 
)

Definition at line 15 of file ossimMatrixProperty.cpp.

References getNumberOfCols(), getNumberOfRows(), resize(), and theValueArray.

Referenced by dup().

19  :ossimProperty(name),
24 {
25  resize(numberOfRows, numberOfCols);
26 
27  if((int)values.size() == numberOfRows*numberOfCols)
28  {
29  int rowIdx = 0;
30  int colIdx = 0;
31  int linearIdx = 0;
32  for(rowIdx = 0; rowIdx < getNumberOfRows(); ++rowIdx)
33  {
34  for(colIdx = 0; colIdx < getNumberOfCols(); ++colIdx)
35  {
36  theValueArray[rowIdx][colIdx] = values[linearIdx];
37  ++linearIdx;
38  }
39  }
40  }
41 }
ossimProperty(const ossimString &name=ossimString(""))
void resize(int numberOfRows, int numberOfColumns)
std::vector< std::vector< double > > theValueArray

◆ ossimMatrixProperty() [2/2]

ossimMatrixProperty::ossimMatrixProperty ( const ossimMatrixProperty rhs)

Definition at line 44 of file ossimMatrixProperty.cpp.

◆ ~ossimMatrixProperty()

ossimMatrixProperty::~ossimMatrixProperty ( )
virtual

Definition at line 54 of file ossimMatrixProperty.cpp.

55 {
56 
57 }

Member Function Documentation

◆ assign()

const ossimProperty & ossimMatrixProperty::assign ( const ossimProperty rhs)
virtual

Reimplemented from ossimProperty.

Definition at line 65 of file ossimMatrixProperty.cpp.

References ossimProperty::assign(), theMaxNumberOfCols, theMaxNumberOfRows, theMinNumberOfCols, theMinNumberOfRows, and theValueArray.

66 {
67  const ossimMatrixProperty* rhsPtr = dynamic_cast<const ossimMatrixProperty*>(&rhs);
68  if(rhsPtr)
69  {
70  theValueArray = rhsPtr->theValueArray;
75  }
76 
77  return ossimProperty::assign(rhs);
78 }
virtual const ossimProperty & assign(const ossimProperty &rhs)
std::vector< std::vector< double > > theValueArray

◆ clearConstraints()

void ossimMatrixProperty::clearConstraints ( )

◆ density()

double ossimMatrixProperty::density ( ) const
protected

Definition at line 296 of file ossimMatrixProperty.cpp.

References getNumberOfCols(), getNumberOfRows(), size, and theValueArray.

Referenced by normalize().

297 {
298  double result = 0.0;
299 
300  if((getNumberOfRows() > 0)&&
301  (getNumberOfCols() > 0))
302  {
303  int rowIdx = 0;
304  int colIdx = 0;
305 
306  for(rowIdx = 0 ; rowIdx < (int)theValueArray.size(); ++rowIdx)
307  {
308  for(colIdx = 0 ; colIdx < (int)theValueArray[rowIdx].size(); ++colIdx)
309  {
310  result += theValueArray[rowIdx][colIdx];
311  }
312  }
313  }
314 
315  return result;
316 }
std::vector< std::vector< double > > theValueArray
yy_size_t size

◆ dup()

ossimObject * ossimMatrixProperty::dup ( ) const
virtual

Reimplemented from ossimObject.

Definition at line 59 of file ossimMatrixProperty.cpp.

References ossimMatrixProperty().

60 {
61  return new ossimMatrixProperty(*this);
62 }
ossimMatrixProperty(const ossimString &name=ossimString(""), const std::vector< double > &values=std::vector< double >(), int numberOfRows=0, int numberOfColumns=0)

◆ getColConstraints()

void ossimMatrixProperty::getColConstraints ( int &  minNumberOfColumns,
int &  maxNumberOfColumns 
) const

Definition at line 249 of file ossimMatrixProperty.cpp.

References theMaxNumberOfCols, and theMinNumberOfCols.

251 {
252  minNumberOfCols = theMinNumberOfCols;
253  maxNumberOfCols = theMaxNumberOfCols;
254 }

◆ getNumberOfCols()

int ossimMatrixProperty::getNumberOfCols ( ) const

Definition at line 217 of file ossimMatrixProperty.cpp.

References getNumberOfRows(), and theValueArray.

Referenced by density(), ossimMatrixProperty(), resize(), ossimConvolutionFilter1D::setProperty(), setValue(), and valueToString().

218 {
219  if(getNumberOfRows())
220  {
221  return (int)theValueArray[0].size();
222  }
223 
224  return 0;
225 }
std::vector< std::vector< double > > theValueArray

◆ getNumberOfRows()

int ossimMatrixProperty::getNumberOfRows ( ) const

Definition at line 212 of file ossimMatrixProperty.cpp.

References theValueArray.

Referenced by density(), getNumberOfCols(), ossimMatrixProperty(), resize(), setValue(), and valueToString().

213 {
214  return (int)theValueArray.size();
215 }
std::vector< std::vector< double > > theValueArray

◆ getRowConstraints()

void ossimMatrixProperty::getRowConstraints ( int &  minNumberOfRows,
int &  maxNumberOfRows 
) const

Definition at line 256 of file ossimMatrixProperty.cpp.

References theMaxNumberOfRows, and theMinNumberOfRows.

258 {
259  minNumberOfRows = theMinNumberOfRows;
260  maxNumberOfRows = theMaxNumberOfRows;
261 }

◆ normalize()

void ossimMatrixProperty::normalize ( )

Definition at line 263 of file ossimMatrixProperty.cpp.

References DBL_EPSILON, density(), size, and theValueArray.

264 {
265  double densityValue = density();
266 
267  if(fabs(densityValue) <= DBL_EPSILON)
268  {
269  return;
270  }
271  int rowIdx = 0;
272  int colIdx = 0;
273  for(rowIdx = 0 ; rowIdx < (int)theValueArray.size(); ++rowIdx)
274  {
275  for(colIdx = 0 ; colIdx < (int)theValueArray[rowIdx].size(); ++colIdx)
276  {
277  theValueArray[rowIdx][colIdx]/=densityValue;
278  }
279  }
280 
281 }
std::vector< std::vector< double > > theValueArray
yy_size_t size
#define DBL_EPSILON

◆ operator()() [1/2]

double & ossimMatrixProperty::operator() ( int  rowIdx,
int  colIdx 
)

Definition at line 200 of file ossimMatrixProperty.cpp.

References theValueArray.

202 {
203  return theValueArray[rowIdx][colIdx];
204 }
std::vector< std::vector< double > > theValueArray

◆ operator()() [2/2]

const double & ossimMatrixProperty::operator() ( int  rowIdx,
int  colIdx 
) const

Definition at line 206 of file ossimMatrixProperty.cpp.

References theValueArray.

208 {
209  return theValueArray[rowIdx][colIdx];
210 }
std::vector< std::vector< double > > theValueArray

◆ resize()

void ossimMatrixProperty::resize ( int  numberOfRows,
int  numberOfColumns 
)

Definition at line 134 of file ossimMatrixProperty.cpp.

References getNumberOfCols(), getNumberOfRows(), ossim::min(), theMaxNumberOfCols, theMaxNumberOfRows, theMinNumberOfCols, theMinNumberOfRows, and theValueArray.

Referenced by ossimMatrixProperty(), and setValue().

136 {
137  int tempNumberOfRows = numberOfRows;
138  int tempNumberOfCols = numberOfCols;
139 
140  if(theMinNumberOfCols > 0)
141  {
142  if(tempNumberOfCols < theMinNumberOfCols)
143  {
144  tempNumberOfCols = theMinNumberOfCols;
145  }
146  }
147  if(theMinNumberOfRows > 0)
148  {
149  if(tempNumberOfRows < theMinNumberOfRows)
150  {
151  tempNumberOfRows = theMinNumberOfRows;
152  }
153  }
154  if(theMaxNumberOfCols > 0)
155  {
156  if(tempNumberOfCols > theMaxNumberOfCols)
157  {
158  tempNumberOfCols = theMaxNumberOfCols;
159  }
160  }
161  if(theMaxNumberOfRows > 0)
162  {
163  if(tempNumberOfRows > theMaxNumberOfRows)
164  {
165  tempNumberOfRows = theMaxNumberOfRows;
166  }
167  }
168 
169  int currentNumberOfRows = getNumberOfRows();
170  int currentNumberOfCols = getNumberOfCols();
171 
172  if((currentNumberOfRows != tempNumberOfRows) ||
173  (currentNumberOfCols != tempNumberOfCols))
174  {
175  std::vector< std::vector<double> > tempValue = theValueArray;
176 
177  theValueArray.resize(tempNumberOfRows);
178 
179  int minCols = ossim::min((int)currentNumberOfCols,
180  (int)tempNumberOfCols);
181  int rowIdx = 0;
182  int colIdx = 0;
183 
184  for(rowIdx = 0 ; rowIdx < tempNumberOfRows; ++rowIdx)
185  {
186  theValueArray[rowIdx].resize(tempNumberOfCols);
187  std::fill(theValueArray[rowIdx].begin(), theValueArray[rowIdx].end(), 0);
188 
189  if(tempNumberOfRows < currentNumberOfRows)
190  {
191  for(colIdx = 0 ; colIdx < minCols; ++colIdx)
192  {
193  theValueArray[rowIdx][colIdx] = tempValue[rowIdx][colIdx];
194  }
195  }
196  }
197  }
198 }
std::vector< std::vector< double > > theValueArray
T min(T a, T b)
Definition: ossimCommon.h:203

◆ setColConstraints()

void ossimMatrixProperty::setColConstraints ( int  minNumberOfColumns,
int  maxNumberOfColumns 
)

If any of the constraints are set to something < 0 then it means there isn't a constraint for that value. So if you give a min value of -1 and a max value of 10 then the column can grow from 10 downto 0.

Definition at line 235 of file ossimMatrixProperty.cpp.

References theMaxNumberOfCols, and theMinNumberOfCols.

237 {
238  theMinNumberOfCols = minNumberOfCols;
239  theMaxNumberOfCols = maxNumberOfCols;
240 }

◆ setRowConstraints()

void ossimMatrixProperty::setRowConstraints ( int  minNumberOfRows,
int  maxNumberOfRows 
)

If any of the contraints are set to something < 0 then it means there isn't a constraint for that value. So if you give a min value of -1 and a max value of 10 then the row can grow from 10 downto 0.

Definition at line 242 of file ossimMatrixProperty.cpp.

References theMaxNumberOfRows, and theMinNumberOfRows.

244 {
245  theMinNumberOfRows = minNumberOfRows;
246  theMaxNumberOfRows = maxNumberOfRows;
247 }

◆ setValue()

bool ossimMatrixProperty::setValue ( const ossimString value)
virtual

Implements ossimProperty.

Definition at line 80 of file ossimMatrixProperty.cpp.

References getNumberOfCols(), getNumberOfRows(), resize(), theValueArray, and ossimString::toInt32().

81 {
82  std::istringstream in(value);
83 
84  ossimString numberOfRows;
85  ossimString numberOfCols;
86  ossimString tempValue;
87 
88  in>>numberOfRows >> numberOfCols;
89 
90  if(!in.bad())
91  {
92  resize(numberOfRows.toInt32(), numberOfCols.toInt32());
93 
94  int rowIdx = 0;
95  int colIdx = 0;
96  for(rowIdx = 0; ((rowIdx < getNumberOfRows())&&(!in.bad())); ++rowIdx)
97  {
98  for(colIdx = 0; ((colIdx < getNumberOfCols())&&(!in.bad()));++ colIdx)
99  {
100  in >> tempValue;
101 
102  theValueArray[rowIdx][colIdx] = tempValue.toDouble();
103  }
104  }
105  }
106 
107  return !in.bad();
108 }
void resize(int numberOfRows, int numberOfColumns)
std::vector< std::vector< double > > theValueArray
ossim_int32 toInt32() const
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32

◆ valueToString()

void ossimMatrixProperty::valueToString ( ossimString valueResult) const
virtual

Implements ossimProperty.

Definition at line 110 of file ossimMatrixProperty.cpp.

References getNumberOfCols(), getNumberOfRows(), size, theValueArray, and ossimString::toString().

111 {
112  if(theValueArray.size()>0)
113  {
114  if(theValueArray[0].size() > 0)
115  {
116  valueResult = "";
117 
118  int rowIdx = 0;
119  int colIdx = 0;
120  valueResult += ossimString::toString(getNumberOfRows()) + " " +
122  for(rowIdx = 0; rowIdx < getNumberOfRows();++rowIdx)
123  {
124  for(colIdx = 0; colIdx < getNumberOfCols(); ++colIdx)
125  {
126  valueResult += ossimString::toString(theValueArray[rowIdx][colIdx]);
127  valueResult += " ";
128  }
129  }
130  }
131  }
132 }
static ossimString toString(bool aValue)
Numeric to string methods.
std::vector< std::vector< double > > theValueArray
yy_size_t size

◆ zero()

void ossimMatrixProperty::zero ( )

Definition at line 283 of file ossimMatrixProperty.cpp.

References size, and theValueArray.

284 {
285  int rowIdx = 0;
286  int colIdx = 0;
287  for(rowIdx = 0 ; rowIdx < (int)theValueArray.size(); ++rowIdx)
288  {
289  for(colIdx = 0 ; colIdx < (int)theValueArray[rowIdx].size(); ++colIdx)
290  {
291  theValueArray[rowIdx][colIdx] = 0.0;
292  }
293  }
294 }
std::vector< std::vector< double > > theValueArray
yy_size_t size

Member Data Documentation

◆ theMaxNumberOfCols

int ossimMatrixProperty::theMaxNumberOfCols
protected

◆ theMaxNumberOfRows

int ossimMatrixProperty::theMaxNumberOfRows
protected

◆ theMinNumberOfCols

int ossimMatrixProperty::theMinNumberOfCols
protected

◆ theMinNumberOfRows

int ossimMatrixProperty::theMinNumberOfRows
protected

◆ theValueArray

std::vector< std::vector<double> > ossimMatrixProperty::theValueArray
protected

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