Пример #1
0
bool FileNode::GetValue(const FileAttributeType eType, int &iValue) const
{
	if (!doesAttributeExist(eType))
		return false;
	iValue = m_mapAttributes.at(eType).m_iValue;
	return true;
}
Пример #2
0
bool FileNode::GetValue(const FileAttributeType eType, std::wstring &strValue) const
{
	if (!doesAttributeExist(eType))
		return false;
	strValue = m_mapAttributes.at(eType).m_strValue;
	return true;
}
Пример #3
0
bool FileNode::SetValue(const FileAttributeType eType, const std::wstring strValue)
{
	if (doesAttributeExist(eType))
	{
		m_mapAttributes.at(eType).m_strValue = strValue;
		return true;
	}
	else
	{
		if (shouldAddAttribute(eType))
		{
			m_mapAttributes.insert(std::pair<FileAttributeType, AttrValue>(eType, AttrValue(strValue)));
			return true;
		}
	}
	return false;
}
Пример #4
0
	/**
	 * @copydoc Model::open()
	 */
	long Adapt3D::open(const std::string& filename)
	{

		this->setBusyStatus(Model::BUSY);
		long status;
		status = GeneralFileReader::open(filename);
		this->progress = 10;
		if (status != FileReader::OK)
		   return status;

		//counts[0] = 1; 									/* set values */
		//intervals[0] = 1;

		   /* get all of the cdf attribute/variable numbers that will be needed *******/
		//if (!this->doesVariableExist(ccmc::strings::variables::coord_))
		{
		//	return FileReader::VARIABLE_DOES_NOT_EXIST;
		}
		long loadStatus = this->loadVariable(ccmc::strings::variables::coord_);
		if (loadStatus != FileReader::OK)
				return loadStatus;
		this->progress = 15;
		loadStatus = this->loadVariableInt(ccmc::strings::variables::intmat_);
		if (status != FileReader::OK)
			return loadStatus;
		this->progress = 20;
		/***  Check the existence of necessary attributes.  Fail if any don't exist ***/
		if (doesAttributeExist(ccmc::strings::variables::grid_reg_no_))
		{
			this->grid_reg_no = (this->getGlobalAttribute(ccmc::strings::variables::grid_reg_no_)).getAttributeInt();
		} else
		{
			std::cerr << "grid_reg_no not found" << std::endl;
			return FileReader::ATTRIBUTE_DOES_NOT_EXIST;
		}
		this->progress = 25;
		if (doesAttributeExist(ccmc::strings::variables::ndimn_))
		{
			this->ndimn = (this->getGlobalAttribute(ccmc::strings::variables::ndimn_)).getAttributeInt();
		} else
		{
			std::cerr << "ndimn not found" << std::endl;
			return FileReader::ATTRIBUTE_DOES_NOT_EXIST;
		}
		//this->progress = 40;
		if (doesAttributeExist(ccmc::strings::variables::npoin_))
		{
			this->npoin = (this->getGlobalAttribute(ccmc::strings::variables::npoin_)).getAttributeInt();
		} else
		{
			std::cerr << "npoin not found" << std::endl;
			return FileReader::ATTRIBUTE_DOES_NOT_EXIST;
		}
		this->progress = 30;
		if (doesAttributeExist(ccmc::strings::variables::nelem_))
		{
			this->nelem = (this->getGlobalAttribute(ccmc::strings::variables::nelem_)).getAttributeInt();
		} else
		{
			std::cerr << "nelem not found" << std::endl;
			return FileReader::ATTRIBUTE_DOES_NOT_EXIST;
		}
		this->progress = 35;
		//create and setup the necessary smart search stuff
		this->nelem = (this->getGlobalAttribute(ccmc::strings::variables::nelem_)).getAttributeInt();

		this->npoin = (this->getGlobalAttribute(ccmc::strings::variables::npoin_)).getAttributeInt();
		this->smartSearchValues.indx = new std::vector<int>(nelem);
		this->smartSearchValues.delauney_search_iteration_profile = new std::vector<int>(DELAUNEY_ITER_MAX);
		if (this->smartSearchValues.facing_elements != NULL)
			delete this->smartSearchValues.facing_elements;
		this->smartSearchValues.facing_elements = new std::vector<int>(this->nelem*4);
		this->smartSearchValues.esup1 = new std::vector<int>(nelem*4);
		for (int i = 0; i < nelem*4; i++)
		{
			this->smartSearchValues.esup1->push_back(0);
		}
		this->smartSearchValues.esup2 = new std::vector<int>(npoin+1);
		for (int i = 0; i < npoin+1; i++)
		{
			this->smartSearchValues.esup2->push_back(0);
		}
		this->progress = 45;
		//this->coord = (this->getVariableFromMap(ccmc::strings::variables::coord_));
		coord_modified = this->getVariableFromMapRW(ccmc::strings::variables::coord_);
#ifdef DEBUG
		std::cout << "this->coord->size(): " << this->coord_modified->size() << std::endl;
#endif
		std::vector<float> * buffer = new std::vector<float>(coord_modified->size());
		for (int i = 0; i < coord_modified->size(); i++)
		{
			(*buffer)[i] = coord_modified->at(i);
		}
		this->progress = 50;
//		float tempc = 0;
		for ( int i=0; i<npoin; i++) {
//			(*coord_modified)[i]=(*buffer)[i*3];
//			(*coord_modified)[i+npoin]=(*buffer)[i*3+1];
//			(*coord_modified)[i+npoin*2]=(*buffer)[i*3+2];
			(*coord_modified)[i*3]=(*buffer)[i];
			(*coord_modified)[i*3+1]=(*buffer)[i+npoin];
			(*coord_modified)[i*3+2]=(*buffer)[i+npoin*2];
			//std::cout << "this->coord_modifed->size(): " << this->coord_modified->size() << " tempc: " << tempc << " [i+npoin*2]: " << (i+npoin*2) <<  " i+npoin " << (i+npoin) << std::endl;
		}

		delete buffer;
		this->progress = 55;
		this->intmat_modified = (this->getIntVariableFromMapRW(ccmc::strings::variables::intmat_));

		//intmat_modified = new std::vector<int>(intmat->size());
		for (int i = 0; i < this->intmat_modified->size(); i++)
		{
			(*intmat_modified)[i] = (*intmat_modified)[i] - 1;
		}
		//this->unloadVariable(ccmc::strings::variables::intmat_);

		this->smartSearchValues.indx_nodes = new std::vector<int>(npoin);
		this->progress = 65;
		this->setupSearchUnstructuredGrid();
		this->progress = 75;
		this->smartSearchSetup();

		//this->setupOctreeGrid();
		this->setBusyStatus(Model::OK);

		return status;

	}