Exemplo n.º 1
0
/**********************************************************************************************************************
	CConvertibleEnum::Register_Entry -- registers a string and integer value pair as convertible

		entry_name -- corresponding string value
		value -- integer to convert to/from

**********************************************************************************************************************/
void CConvertibleEnum::Register_Entry( const std::string &entry_name, uint64 value )
{
	std::string upper_entry_name;
	NStringUtils::To_Upper_Case( entry_name, upper_entry_name );

	auto name_iter = NameToValueTable.find( upper_entry_name );
	FATAL_ASSERT( name_iter == NameToValueTable.end() );

	auto value_iter = ValueToNameTable.find( value );
	FATAL_ASSERT( value_iter == ValueToNameTable.end() );

	NameToValueTable[ upper_entry_name ] = value;
	ValueToNameTable[ value ] = upper_entry_name;
}
Exemplo n.º 2
0
	virtual void ProcessingMaterial(GLMmodel* model, KScene& scene, const stdext::hash_map<UINT32, UINT32>& nodeToMtl)
	{
		// Create material
		KMaterialLibrary* pML = KMaterialLibrary::GetInstance();
		for (UINT32 mi = 0; mi < model->nummaterials; ++mi) {
			ISurfaceShader* pSurfShader = pML->CreateMaterial("simple_phong_default.template", model->materials[mi].name);
			pSurfShader->SetParam("diffuse_color", model->materials[mi].diffuse, sizeof(float)*3);
			if (model->materials[mi].shininess > 3.0f) {
				pSurfShader->SetParam("specular_color", model->materials[mi].specular, sizeof(float)*3);
				pSurfShader->SetParam("power", &model->materials[mi].shininess, sizeof(float));
			}
			else {
				float specular[3] = {0,0,0};
				float pow = 0;
				pSurfShader->SetParam("specular_color", specular, sizeof(float)*3);
				pSurfShader->SetParam("power", &pow, sizeof(float));
			}

			pSurfShader->SetParam("opacity", model->materials[mi].transparency, sizeof(float)*3);

			if (mUseTexMap && model->materials[mi].diffuse_map) {
				pSurfShader->SetParam("diffuse_map", model->materials[mi].diffuse_map, 0);
			}
		}

		for (UINT32 i = 0; i < scene.GetNodeCnt(); ++i) {
			KNode* pNode = scene.GetNode(i);
			stdext::hash_map<UINT32, UINT32>::const_iterator it = nodeToMtl.find(i);
			assert(it != nodeToMtl.end());
			pNode->mpSurfShader = pML->OpenMaterial(model->materials[it->second].name);
		}

	}
		void PeakMatchingResults::GetMatches(std::vector<int> &vectFeatureIndices, std::vector<int> &vectMassTagIndices, 
			std::vector<int> &vectProteinIndices , const std::vector<MultiAlignEngine::MassTags::Protein>* &vectProteins, 
			const std::vector<MultiAlignEngine::MassTags::MassTag>* &vectMasstags) const
		{
			// The mass tag database has stored in it all the proteins and mass tags corresponding to the matches.
			// So thats where we need to get all the data from. 
			int numMatches = (int) mvectPeakMatches.size(); 
			std::set <int> massTagID; 

			stdext::hash_map <int, int > massTagSeen;
			// first get all mass tags in the matches into the set of mass tags. 
			for (int matchNum = 0; matchNum < numMatches; matchNum++)
			{
				PeakMatch match = mvectPeakMatches[matchNum]; 
				massTagSeen.insert(std::pair<int,int>(match.mintMasstagID, matchNum)); 
			}

			// copy hash to mass tag vector
			std::vector<int> vectMassTagIDs; 
			vectMassTagIDs.reserve(massTagSeen.size()); 
			for (stdext::hash_map <int, int >::iterator massTagIter = massTagSeen.begin();
				massTagIter != massTagSeen.end(); massTagIter++)
			{
				vectMassTagIDs.push_back((*massTagIter).first); 
			}


			vectMasstags = mobjMasstagDB.GetMassTagVector(); 
			vectProteins = mobjMasstagDB.GetProteinVector(); 
			const std::multimap<int,int> mapMassTagId2ProteinIndex = mobjMasstagDB.GetMassTagId2ProteinIndexMap(); 
			const stdext::hash_map <int, int > hashMapMassTagId2Index  = mobjMasstagDB.GetMassTagId2IndexHash();

			// now the relevant mass tags are copied, their ids are copied, the protein names are copied. 
			// So lets create the table of matches using the three vectors vectFeatureIndices, vectMassTagIndices and 
			// vectProteinIndices. Basically, vectFeatureIndices will have the index of the ms feature in a peak match.
			// the vectMassTagIndices will have the corresponding massTagID, and vectProteinIndices will have the corresponding
			// parent protein. 
			for (std::multimap<int,int>::const_iterator featureIter = mmapFeatureIndex2PeakMatch.begin(); featureIter != mmapFeatureIndex2PeakMatch.end(); 
				featureIter++)
			{
				int featureIndex = (*featureIter).first; 
				int peakMatchIndex = (*featureIter).second; 
				PeakMatch pkMatch = mvectPeakMatches[peakMatchIndex]; 
				int massTagID = pkMatch.mintMasstagID; 
				stdext::hash_map <int, int>::const_iterator massTagIterHash = hashMapMassTagId2Index.find(massTagID); 
				int massTagIndex = (*massTagIterHash).second; 
				// now go through each of the parent proteins of this massTagID and push the triplet into their 
				// corresponding vectors
				for (std::multimap<int,int>::const_iterator massTagIter = mapMassTagId2ProteinIndex.find(massTagID); 
					massTagIter != mapMassTagId2ProteinIndex.end(); 
					massTagIter++)
				{
					if ((*massTagIter).first != massTagID)
						break; 
					vectFeatureIndices.push_back(featureIndex); 
					vectMassTagIndices.push_back(massTagIndex); 
					vectProteinIndices.push_back((*massTagIter).second); 
				}
			}
		}
Exemplo n.º 4
0
/**********************************************************************************************************************
	CConvertibleEnum::Convert_Internal -- internal function to convert from an integer value to a string

		value -- integer to convert from
		entry_name -- output parameter for the string value 

		Returns: success/failure

**********************************************************************************************************************/
bool CConvertibleEnum::Convert_Internal( uint64 value, std::string &entry_name ) const
{
	auto iter = ValueToNameTable.find( value );
	if ( iter == ValueToNameTable.end() )
	{
		return false;
	}

	entry_name = iter->second;
	return true;
}
Exemplo n.º 5
0
/**********************************************************************************************************************
	CConvertibleEnum::Convert_Internal -- internal function to convert from a string to an integer value

		entry_name -- string value to convert from
		output_value -- output parameter for the integer to convert to

		Returns: success/failure

**********************************************************************************************************************/
bool CConvertibleEnum::Convert_Internal( const std::string &entry_name, uint64 &output_value ) const
{
	std::string upper_entry_name;
	NStringUtils::To_Upper_Case( entry_name, upper_entry_name );

	auto iter = NameToValueTable.find( upper_entry_name );
	if ( iter == NameToValueTable.end() )
	{
		return false;
	}

	output_value = iter->second;
	return true;
}
Exemplo n.º 6
0
HRESULT __wrapper_FilterGetMessage(    
	HANDLE  hPort,    
	PFILTER_MESSAGE_HEADER  lpMessageBuffer,    
	DWORD  dwMessageBufferSize,    
	LPOVERLAPPED  lpOverlapped )
{	
	Chess::SyncVarAccess(GetWin32SyncManager()->GetSyncVarFromHandle(hPorte), SVOP::FLT_RW);
	if(qsize.find(hPorte) == qsize.end())
		qsize[hPorte] = 0;
	if(lpOverlapped != NULL){
		HRESULT ret = Real_FilterGetMessage(hPort, lpMessageBuffer, dwMessageBufferSize, lpOverlapped);
		if(ret == ERROR_IO_PENDING)
			qsize[hPorte]++;
		return ret;
	}

	LPOVERLAPPED myOverlapped;
	OVERLAPPED tempOverlapped;
	memset(&tempOverlapped, 0, sizeof(OVERLAPPED));
	myOverlapped = &tempOverlapped;
	myOverlapped->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

	HRESULT ret = Real_FilterGetMessage(hPort, lpMessageBuffer, dwMessageBufferSize, myOverlapped);
	//if(ret != S_OK || ret != ERROR_IO_PENDING)
	//	return ret;
	
	assert(ret != S_OK);
	qsize[hPorte]++;

	Chess::SyncVarAccess(GetWin32SyncManager()->GetSyncVarFromHandle(hPorte), SVOP::FLT_RW);
	while(true){
		HRESULT retVal = WaitForSingleObject(myOverlapped->hEvent, 0);
		switch(retVal){
			case WAIT_OBJECT_0 :
				CloseHandle(myOverlapped->hEvent);
				return S_OK;

			case WAIT_TIMEOUT :
				Chess::LocalBacktrack();
				break;	
			default:
				fprintf(stderr, "Waiting for event failed in Wrapper FilterGetMessage");
				return retVal;
		}
	}
	assert(false);
	return S_OK;
}
Exemplo n.º 7
0
HRESULT __wrapper_FilterSendMessage( 
				  HANDLE  hPort,    
				  LPVOID  lpInBuffer,    
				  DWORD  dwInBufferSize,    
				  LPVOID  lpOutBuffer,    
				  DWORD  dwOutBufferSize,    
				  LPDWORD  lpBytesReturned    )
{
	Chess::SyncVarAccess(GetWin32SyncManager()->GetSyncVarFromHandle(hPorte), SVOP::FLT_RW);
	if(qsize.find(hPorte) == qsize.end())
		qsize[hPorte] = 0;
	while(qsize[hPorte] == 0){
		Chess::LocalBacktrack();
	}
	qsize[hPorte]--;
	return Real_FilterSendMessage(hPort, lpInBuffer, dwInBufferSize, lpOutBuffer, dwOutBufferSize, lpBytesReturned);
}
Exemplo n.º 8
0
DWORD _stdcall AIGetLastTarget(DWORD source) {
	iter itr=targets.find(source);
	if(itr==targets.end()) return 0;
	else return itr->second;
}
Exemplo n.º 9
0
DWORD _stdcall AIGetLastAttacker(DWORD target) {
	iter itr=sources.find(target);
	if(itr==sources.end()) return 0;
	else return itr->second;
}