///////////////////////////////////////////////////////////////////// // ConfMask.cxx // version 0.1 ///////////////////////////////////////////////////////////////////// // // 13/04/04 Version 0.1 (CS) // #include "Config/ConfMask.h" using namespace PixLib; //! Constructor (all entries are set to zero) template ConfMask::ConfMask(int nCol, int nRow, T maxValue) : m_maxValue(maxValue) { // Check column and row numbers if(nCol>0 && nRow>0) { // Create mask m_mask = std::vector< std::vector >(nCol, std::vector(nRow, 0)); } } //! Constructor (all entries are set to defValue) template ConfMask::ConfMask(int nCol, int nRow, T maxValue, T defValue) : m_maxValue(maxValue) { // Check column and row numbers if(nCol>0 && nRow>0) { // Create mask T defaultValue; if(defValue >(nCol, std::vector(nRow, defaultValue)); } } //! Copy constructor template ConfMask::ConfMask(const ConfMask &c) { // Copy mask m_mask = c.m_mask; // Copy max value m_maxValue = c.m_maxValue; } //! Destructor template ConfMask::~ConfMask() { // Clear columns for(unsigned int col=0; col ConfMask& ConfMask::operator = (const ConfMask& c) { // Copy mask m_mask = c.m_mask; // Copy max value m_maxValue = c.m_maxValue; return *this; } //! Set all entries to m_maxValue template void ConfMask::enableAll() { // Enable mask m_mask = std::vector< std::vector >(m_mask.size(), std::vector(m_mask.front().size(), m_maxValue)); } //! Set all entries to zero template void ConfMask::disableAll() { // Disable mask m_mask = std::vector< std::vector >(m_mask.size(), std::vector(m_mask.front().size(), 0)); } //! Set all entries to value template void ConfMask::setAll(T value) { // Set mask T val; if(value >(m_mask.size(), std::vector(m_mask.front().size(), val)); } //! Set an entire column to m_maxValue template void ConfMask::enableCol(int col) { // Check column number if(col<0 || col>=(int)m_mask.size()) return; // Enable column m_mask[col] = std::vector(m_mask.front().size(), m_maxValue); } //! Set an entire column to zero template void ConfMask::disableCol(int col) { // Check column number if(col<0 || col>=(int)m_mask.size()) return; // Disable column m_mask[col] = std::vector(m_mask.front().size(), 0); } //! Set an entire column to value template void ConfMask::setCol(int col, T value) { // Check column number if(col<0 || col>=(int)m_mask.size()) return; // Set column to value T val; if(value(m_mask.front().size(), val); } //! Set an entire row to m_maxValue template void ConfMask::enableRow(int row) { // Check row number if(row<0 || row>=(int)m_mask.front().size()) return; // Enable row for(unsigned int i=0; i void ConfMask::disableRow(int row) { // Check row number if(row<0 || row>=(int)m_mask.front().size()) return; // Disable row for(unsigned int i=0; i void ConfMask::setRow(int row, T value) { // Check row number if(row<0 || row>=(int)m_mask.front().size()) return; // Set row to value T val; if(value void ConfMask::enable(int col, int row) { // Check row and column number if(col<0 || col>=(int)m_mask.size()) return; if(row<0 || row>=(int)m_mask.front().size()) return; // Enable entry m_mask[col][row] = m_maxValue; } //! Set entry to m_maxValue template void ConfMask::disable(int col, int row) { // Check row and column number if(col<0 || col>=(int)m_mask.size()) return; if(row<0 || row>=(int)m_mask.front().size()) return; // Disable entry m_mask[col][row] = 0; } //! Set entry to m_maxValue template void ConfMask::set(int col, int row, T value) { // Check row and column number if(col<0 || col>=(int)m_mask.size()) return; if(row<0 || row>=(int)m_mask.front().size()) return; // Set entry to value T val; if(value void ConfMask::set(std::vector &value) { // Get row and column number unsigned int nCol = m_mask.size(); unsigned int nRow = m_mask.front().size(); unsigned int col=0, row=0; // Set entries for(unsigned int i=0; i void ConfMask::get(std::vector &output) { // Get row and column number unsigned int nCol = m_mask.size(); unsigned int nRow = m_mask.front().size(); // Get entries output.clear(); for(unsigned int row=0; row std::vector< std::vector >& ConfMask::get() { return m_mask; } //! Column accessor method template std::vector& ConfMask::operator[](int col) { return m_mask[col]; } //! Mask accessor method template T& ConfMask::get(int col, int row) { return m_mask[col][row]; }