コード例 #1
0
ファイル: nbt.cpp プロジェクト: tvolpes/MCMapper3
CTag* CTagParent::getChildPath( std::string path, boost::int8_t type )
{
	std::vector<std::string> tokens;
	CTag *pNextTag;
	CTagParent *pCurrentParent;

	// Split into tokens
	boost::split( tokens, path, boost::is_any_of( "." ) );
	pCurrentParent = this;
	for( auto it = tokens.begin(); it != tokens.end(); it++ )
	{
		// Search for
		pNextTag = pCurrentParent->getChildName( (*it) );
		if( !pNextTag ) {
			std::cout << "Could not find tag \'" << path.c_str() << "\'" << std::endl;
			return 0;
		}
		// Check if we're at the end
		if( it == tokens.end()-1 ) {
			if( pNextTag->getId() == type )
				return pNextTag;
			else {
				std::cout << "Invalid type for tag specified by path \'" << path.c_str() << "\'" << std::endl;
				return 0;
			}
		}
		else if( pNextTag->isParent() )
			pCurrentParent = reinterpret_cast<CTagParent*>(pNextTag);
		else {
			std::cout << "Invalid path \'" << path.c_str() << "\'" << std::endl;
		}
	}

	return 0;
}
コード例 #2
0
ファイル: Friend.cpp プロジェクト: BackupTheBerlios/nextemf
void CFriend::LoadFromFile(CFileDataIO* file)
{
	file->ReadHash16(m_abyUserhash);
	m_dwHasHash = md4cmp(m_abyUserhash, sm_abyNullHash) ? 1 : 0;
	m_dwLastUsedIP = file->ReadUInt32();
	m_nLastUsedPort = file->ReadUInt16();
	m_dwLastSeen = file->ReadUInt32();
	m_dwLastChatted = file->ReadUInt32();

	UINT tagcount = file->ReadUInt32();
	for (UINT j = 0; j < tagcount; j++){
		CTag* newtag = new CTag(file, false);
		switch (newtag->GetNameID()){
			case FF_NAME:{
				ASSERT( newtag->IsStr() );
				if (newtag->IsStr()){
					if (m_strName.IsEmpty())
						m_strName = newtag->GetStr();
				}
				break;
			}
		}
		delete newtag;
	}
}
コード例 #3
0
ファイル: CTagIterator.cpp プロジェクト: north0808/haina
EXPORT_C gint32 CTagIterator::Current(CDbEntity ** ppEntity)
	{
	if (ppEntity == NULL)
		return ERROR(ESide_Client, EModule_Db, ECode_Invalid_Param);
	
	*ppEntity = NULL;
	if (m_dbQuery->eof())
		return ERROR(ESide_Client, EModule_Db, ECode_Not_Exist);
	
	 /* fill cgroup table fields */
	*ppEntity = new CTag(m_pEntityDb);
	if (NULL == *ppEntity)
		{
		return ERROR(ESide_Client, EModule_Db, ECode_No_Memory);
		}
	
	CTag * pTag = (CTag*)(*ppEntity);
	for (int i=0; i<TagField_EndFlag; i++)
		{
		GString * fieldValue = g_string_new(m_dbQuery->fieldValue(i));
		pTag->SetFieldValue(i, fieldValue);	
		g_string_free(fieldValue, TRUE);
		}
	
	return 0;
	}
コード例 #4
0
ファイル: AbstractFile.cpp プロジェクト: dalinhuang/dmibox
CTag* CAbstractFile::GetTag(uint8 tagname) const
{
	for (int i = 0; i < taglist.GetSize(); i++){
		CTag* pTag = taglist[i];
		if (pTag->GetNameID()==tagname)
			return pTag;
	}
	return NULL;
}
コード例 #5
0
ファイル: AbstractFile.cpp プロジェクト: dalinhuang/dmibox
CTag* CAbstractFile::GetTag(LPCSTR tagname) const
{
	for (int i = 0; i < taglist.GetSize(); i++){
		CTag* pTag = taglist[i];
		if (pTag->GetNameID()==0 && CmpED2KTagName(pTag->GetName(), tagname)==0)
			return pTag;
	}
	return NULL;
}
コード例 #6
0
ファイル: CGroupTag.cpp プロジェクト: RocketersAlex/LCSource
CGroupTag::CGroupTag(CTag &tag)
{
	//tag
	m_eType = TT_GROUP;
	m_strName = tag.GetName();
	m_fMaxTimeLength = tag.GetMaxTimeLength();
	m_vOffsetPos = tag.GetOffsetPos();
	m_qOffsetRot = tag.GetOffsetRot();
	this->AddNewTagInfo(tag.CurrentTagInfo());
}
コード例 #7
0
ファイル: AbstractFile.cpp プロジェクト: dalinhuang/dmibox
void CAbstractFile::DeleteTag(uint8 tagname)
{
	for (int i = 0; i < taglist.GetSize(); i++){
		CTag* pTag = taglist[i];
		if (pTag->GetNameID()==tagname){
			taglist.RemoveAt(i);
			delete pTag;
			return;
		}
	}
}
コード例 #8
0
ファイル: AbstractFile.cpp プロジェクト: dalinhuang/dmibox
void CAbstractFile::SetStrTagValue(uint8 tagname, LPCTSTR pszValue)
{
	for (int i = 0; i < taglist.GetSize(); i++){
		CTag* pTag = taglist[i];
		if (pTag->GetNameID()==tagname && pTag->IsStr()){
			pTag->SetStr(pszValue);
			return;
		}
	}
	CTag* pTag = new CTag(tagname, pszValue);
	taglist.Add(pTag);
}
コード例 #9
0
ファイル: AbstractFile.cpp プロジェクト: dalinhuang/dmibox
void CAbstractFile::SetInt64TagValue(uint8 tagname, uint64 uValue)
{
	for (int i = 0; i < taglist.GetSize(); i++){
		CTag* pTag = taglist[i];
		if (pTag->GetNameID()==tagname && pTag->IsInt64(true)){
			pTag->SetInt64(uValue);
			return;
		}
	}
	CTag* pTag = new CTag(tagname, uValue);
	taglist.Add(pTag);
}
コード例 #10
0
ファイル: Friend.cpp プロジェクト: HackLinux/eMule-IS-Mod
void CFriend::LoadFromFile(CFileDataIO* file)
{
	file->ReadHash16(m_abyUserhash);
	m_dwLastUsedIP = file->ReadUInt32();
	m_nLastUsedPort = file->ReadUInt16();
	m_dwLastSeen = ConvertFromTime32(file->ReadUInt32());
	m_dwLastChatted = file->ReadUInt32();

	UINT tagcount = file->ReadUInt32();
	for (UINT j = 0; j < tagcount; j++){
		CTag* newtag = new CTag(file, false);
		switch (newtag->GetNameID()){
			case FF_NAME:{
				ASSERT( newtag->IsStr() );
				if (newtag->IsStr()){
					if (m_strName.IsEmpty())
						m_strName = newtag->GetStr();
				}
				break;
			}
			case FF_KADID:{
				ASSERT( newtag->IsHash() );
				if (newtag->IsHash())
					md4cpy(m_abyKadID, newtag->GetHash());
				break;
			}
		}
		delete newtag;
	}
}
コード例 #11
0
CCollectionFile::CCollectionFile(CFileDataIO* in_data)
{
	UINT tagcount = in_data->ReadUInt32();

	for (UINT i = 0; i < tagcount; i++)
	{
		CTag* toadd = new CTag(in_data, true);
		if (toadd)
			taglist.Add(toadd);
	}
	
	CTag* pTagHash = GetTag(FT_FILEHASH);
	if(pTagHash)
		SetFileHash(pTagHash->GetHash());
	else
		ASSERT(0);
	
	// here we have two choices
	//	- if the server/client sent us a filetype, we could use it (though it could be wrong)
	//	- we always trust our filetype list and determine the filetype by the extension of the file
	//
	// if we received a filetype from server, we use it.
	// if we did not receive a filetype, we determine it by examining the file's extension.
	//
	// but, in no case, we will use the receive file type when adding this search result to the download queue, to avoid
	// that we are using 'wrong' file types in part files. (this has to be handled when creating the part files)
	const CString& rstrFileType = GetStrTagValue(FT_FILETYPE);
	SetFileName(GetStrTagValue(FT_FILENAME), false, rstrFileType.IsEmpty());
	SetFileSize(GetIntTagValue(FT_FILESIZE));
	if (!rstrFileType.IsEmpty())
	{
		if (_tcscmp(rstrFileType, _T(ED2KFTSTR_PROGRAM))==0)
		{
			CString strDetailFileType = GetFileTypeByName(GetFileName());
			if (!strDetailFileType.IsEmpty())
				SetFileType(strDetailFileType);
			else
				SetFileType(rstrFileType);
		}
		else
			SetFileType(rstrFileType);
	}

	if(!GetFileSize() || !GetFileName().Compare(_T("")))
		ASSERT(0);
}
コード例 #12
0
ファイル: KnownFile.cpp プロジェクト: dreamerc/amule
void CAbstractFile::AddTagUnique(const CTag &rTag)
{
	ArrayOfCTag::iterator it = m_taglist.begin();
	for (; it != m_taglist.end(); ++it) {
		if ( ( ((*it).GetNameID() != 0 &&
			(*it).GetNameID() == rTag.GetNameID()) ||
		       (!(*it).GetName().IsEmpty() &&
			!rTag.GetName().IsEmpty() &&
			(*it).GetName() == rTag.GetName()) ) &&
		     (*it).GetType() == rTag.GetType()){
			m_taglist.erase(it);
			m_taglist.insert(it, rTag);
			return;
		}
	}
	m_taglist.push_back(rTag);
}
コード例 #13
0
ファイル: SafeFile.cpp プロジェクト: 0vermind/hmule
void CFileDataIO::WriteTag(const CTag& tag)
{
	try
	{
		WriteUInt8(tag.GetType());
		
		if (!tag.GetName().IsEmpty()) {
			WriteString(tag.GetName(),utf8strNone);
		} else {
			WriteUInt16(1);
			WriteUInt8(tag.GetNameID());
		}
		
		switch (tag.GetType())
		{
			case TAGTYPE_HASH16:
				// Do NOT use this to transfer any tags for at least half a year!!
				WriteHash(CMD4Hash(tag.GetHash()));
				break;
			case TAGTYPE_STRING:
				WriteString(tag.GetStr(), utf8strRaw); // Always UTF8
				break;
			case TAGTYPE_UINT64:
				WriteUInt64(tag.GetInt());
				break;
			case TAGTYPE_UINT32:
				WriteUInt32(tag.GetInt());
				break;
			case TAGTYPE_FLOAT32:
				WriteFloat(tag.GetFloat());
				break;
			case TAGTYPE_BSOB:
				WriteBsob(tag.GetBsob(), tag.GetBsobSize());
				break;
			case TAGTYPE_UINT16:
				WriteUInt16(tag.GetInt());
				break;
			case TAGTYPE_UINT8:
				WriteUInt8(tag.GetInt());
				break;
			case TAGTYPE_BLOB:
				// NOTE: This will break backward compatibility with met files for eMule versions prior to 0.44a
				// and any aMule prior to SVN 26/02/2005
				WriteUInt32(tag.GetBlobSize());
				Write(tag.GetBlob(), tag.GetBlobSize());
				break;
			default:
				//TODO: Support more tag types
				// With the if above, this should NEVER happen.
				AddLogLineNS(CFormat(wxT("CFileDataIO::WriteTag: Unknown tag: type=0x%02X")) % tag.GetType());
				wxFAIL;
				break;
		}				
	} catch (...) {
		AddLogLineNS(wxT("Exception in CDataIO:WriteTag"));
		throw;
	}
}
コード例 #14
0
ファイル: nbt.cpp プロジェクト: tvolpes/MCMapper3
CTag* CNBTReader::readTag( InputStream &stream, size_t *pBytesRead, bool fullTag = true )
{
	boost::int8_t tagId;
	CTag *pTag;

	// Read the tag ID
	if( fullTag ) {
		stream.read( reinterpret_cast<char*>(&tagId), sizeof( tagId ) );
		(*pBytesRead) += sizeof( tagId );
	}
	else {
		_ASSERT_EXPR( !m_parentStack.empty(), L"can't create non-full tag when parent stack is empty" );
		_ASSERT_EXPR( m_parentStack.top()->getId() == TAGID_LIST, L"list not at top of parent stack" );
		tagId = reinterpret_cast<CTagList*>(m_parentStack.top())->getChildrenId();
	}

	if( stream.eof() )
		return 0;

	// Create the tag
	pTag = this->createTag( tagId );
	if( !pTag )
		return 0;

	// If it has no parents its a root tag
	if( m_parentStack.empty() )
		m_rootTags.push_back( pTag );
	// If not assign it to parent
	else
		m_parentStack.top()->addChild( pTag );

	// Check if its an end tag
	if( pTag->getId() == TAGID_END ) {
		if( m_parentStack.empty() ) {
			std::cout << "Failed: mismatched end tag" << std::endl;
			delete pTag;
			return 0;
		}
		m_parentStack.pop();
	}
	// Check if its a parent
	if( pTag->isParent() )
		m_parentStack.push( reinterpret_cast<CTagParent*>( pTag ) );

	// Read the tag
	pTag->read( stream, pBytesRead, fullTag );

	// Check if the list is full
	if( !m_parentStack.empty() ) {
		if( m_parentStack.top()->getId() == TAGID_LIST ) {
			if( m_parentStack.top()->getChildren().size() == reinterpret_cast<CTagList*>(m_parentStack.top())->getChildrenCount() )
				m_parentStack.pop(); // pop off the list
		}
	}

	/*if( pTag->isParent() )
		for( unsigned int i = 0; i < m_parentStack.size()-1; i++ )
			std::cout << "\t";
	else
		for( unsigned int i = 0; i < m_parentStack.size(); i++ )
			std::cout << "\t";
	std::cout << (int)pTag->getId() << "(" << pTag->getName().c_str() << ")" << std::endl;*/

	return pTag;
}
コード例 #15
0
ファイル: tagger.cpp プロジェクト: xiangyu/zpar-0.6
SCORE_TYPE CTagger::getLocalScore( const CStringVector * sentence, CStateItem * item , unsigned long index ) {

    static SCORE_TYPE nReturn ;
    static unsigned long int last_start , last_length ;
    static unsigned long int start , end , length ;

    // abstd::cout the words
    start = item->getWordStart( index ) ;
    end = item->getWordEnd( index ) ;
    length = item->getWordLength( index ) ;
    last_start = index > 0 ? item->getWordStart( index-1 ) : 999999 ;
    last_length = index > 0 ? item->getWordLength( index-1 ) : 99999 ;
    const CWord &word = m_WordCache.find( start , end , sentence ) ;
    const CWord &last_word = index > 0 ? m_WordCache.find( last_start , start-1 , sentence ) : g_emptyWord ;

    // abstd::cout the chars
    const CWord &first_char = m_WordCache.find( start , start , sentence ) ;
    const CWord &last_char = m_WordCache.find( end , end , sentence ) ;
    const CWord &first_char_last_word = index > 0 ? m_WordCache.find( last_start , last_start , sentence ) : g_emptyWord ;
    const CWord &last_char_last_word = index > 0 ? m_WordCache.find( start-1 , start-1 , sentence) : g_emptyWord;
    const CWord &first_char_next_word = end+1 < sentence->size() ? m_WordCache.find( end+1 , end+1 , sentence) : g_emptyWord ;
    const CWord &first_twochar = start+1 < sentence->size() ? m_WordCache.find( start , start+1 , sentence ) : g_emptyWord ;
    const CWord &last_twochar_last_word = start>1 ? m_WordCache.find( start-2 , start-1 , sentence ) : g_emptyWord ;
    const CWord &two_char = index > 0 ? m_WordCache.find( start-1 , start, sentence) : g_emptyWord;
    const CWord &lastword_firstchar = index > 0 ? m_WordCache.find( last_start , start , sentence ) : g_emptyWord ;
    const CWord &currentword_lastchar = index > 0 ? m_WordCache.find( start-1 , end , sentence) : g_emptyWord ;
    const CWord &currentword_lasttwochar = start > 1 ? m_WordCache.find( start-2 , end , sentence ) : g_emptyWord ;
    const CWord &lastword_firsttwochar = index > 0 && start+1 < sentence->size() ? m_WordCache.find( last_start , start+1 , sentence ) : g_emptyWord ;
    const CWord &three_char = length == 1 && start > 0 && end < sentence->size()-1 ? m_WordCache.find( start-1 , end+1 , sentence ) : g_emptyWord ;

    CTwoWords two_word;

    // abstd::cout the tags
    const CTag tag = item->getTag(index);
    const CTag last_tag = index>0 ? item->getTag(index-1) : CTag::SENTENCE_BEGIN;
    const CTag second_last_tag = index>1 ? item->getTag(index-2) : CTag::SENTENCE_BEGIN;
    const CTagSet<CTag, 2> tag_bigram(encodeTags(tag, last_tag));
    const CTagSet<CTag, 3> tag_trigram(encodeTags(tag, last_tag, second_last_tag));
    static CTaggedWord<CTag, TAG_SEPARATOR> wt1, wt2;
    static CTwoTaggedWords wt12;

    long int first_char_cat = m_weights->m_mapCharTagDictionary.lookup(first_char) | (1<<tag.code()) ;
    long int last_char_cat = m_weights->m_mapCharTagDictionary.lookup(last_char) | (1<<tag.code()) ;

    nReturn = m_weights->m_mapCurrentTag.getScore( std::make_pair(word, tag) , m_nScoreIndex ) ;
    nReturn += m_weights->m_mapLastTagByTag.getScore( tag_bigram , m_nScoreIndex ) ;
    nReturn += m_weights->m_mapLastTwoTagsByTag.getScore( tag_trigram , m_nScoreIndex ) ;
    if ( start > 0 ) {
        if ( last_length <= 2 ) nReturn += m_weights->m_mapTagByLastWord.getScore( std::make_pair(last_word, tag) , m_nScoreIndex ) ;
        if ( length <= 2 ) nReturn += m_weights->m_mapLastTagByWord.getScore( std::make_pair(word, last_tag) , m_nScoreIndex ) ;
        if ( length <= 2 ) nReturn += m_weights->m_mapTagByWordAndPrevChar.getScore( std::make_pair(currentword_lastchar, tag) , m_nScoreIndex ) ;
        if ( last_length <= 2 ) nReturn += m_weights->m_mapTagByWordAndNextChar.getScore( std::make_pair(lastword_firstchar, last_tag) , m_nScoreIndex) ;

    }
    if ( length == 1 ) {
        if ( start > 0 && end < sentence->size()-1 )
            nReturn += m_weights->m_mapTagOfOneCharWord.getScore( std::make_pair(three_char, tag) , m_nScoreIndex ) ;
    }
    else {
        nReturn += m_weights->m_mapTagByFirstChar.getScore( std::make_pair(first_char, tag) , m_nScoreIndex ) ;
        nReturn += m_weights->m_mapTagByLastChar.getScore( std::make_pair(last_char, tag) , m_nScoreIndex ) ;
        nReturn += m_weights->m_mapTagByFirstCharCat.getScore( std::make_pair(first_char_cat, tag) , m_nScoreIndex ) ;
        nReturn += m_weights->m_mapTagByLastCharCat.getScore( std::make_pair(last_char_cat, tag) , m_nScoreIndex ) ;

        for ( int j = 0 ; j < item->getWordLength( index ) ; ++ j ) {
            if ( j > 0 && j < item->getWordLength( index )-1 )
                nReturn += m_weights->m_mapTagByChar.getScore( std::make_pair(m_WordCache.find(start+j, start+j, sentence), tag) , m_nScoreIndex );
            if ( j > 0 ) {
                wt1.load( m_WordCache.find(start+j, start+j, sentence), tag );
                wt2.load( first_char );
                wt12.refer(&wt1, &wt2);
                nReturn += m_weights->m_mapTaggedCharByFirstChar.getScore( wt12, m_nScoreIndex );
                if ( m_WordCache.find(start+j, start+j, sentence) == m_WordCache.find(start+j-1, start+j-1, sentence))
                    nReturn += m_weights->m_mapRepeatedCharByTag.getScore( std::make_pair(m_WordCache.find(start+j, start+j, sentence), tag) , m_nScoreIndex );
            }
            if ( j < item->getWordLength( index )-1 ) {
                wt1.load( m_WordCache.find(start+j, start+j, sentence), tag );
                wt2.load( last_char );
                wt12.refer(&wt1, &wt2);
                nReturn += m_weights->m_mapTaggedCharByLastChar.getScore( wt12 , m_nScoreIndex );
            }
        }
    }

    return nReturn;
}
コード例 #16
0
ファイル: packets.cpp プロジェクト: BackupTheBerlios/nextemf
CTag::CTag(const CTag& rTag)
{
	m_uType = rTag.m_uType;
	m_uName = rTag.m_uName;
	m_pszName = rTag.m_pszName!=NULL ? nstrdup(rTag.m_pszName) : NULL;
	m_nBlobSize = 0;
	if (rTag.IsStr())
		m_pstrVal = new CString(rTag.GetStr());
	else if (rTag.IsInt())
		m_uVal = rTag.GetInt();
	else if (rTag.IsFloat())
		m_fVal = rTag.GetFloat();
	else if (rTag.IsHash()){
		m_pData = new BYTE[16];
		md4cpy(m_pData, rTag.GetHash());
	}
	else if (rTag.IsBlob()){
		m_nBlobSize = rTag.GetBlobSize();
		m_pData = new BYTE[rTag.GetBlobSize()];
		memcpy(m_pData, rTag.GetBlob(), rTag.GetBlobSize());
	}
	else{
		ASSERT(0);
		m_uVal = 0;
	}
	ASSERT_VALID(this);
}
コード例 #17
0
BOOL CEffectGroup::Process(FLOAT time)
{
	if(!m_bActive) return FALSE;

	// 1/50의 정확도를 갖는다.
	//if( time - m_fLastProcessedTime < 0.02f ) return TRUE;

	FLOAT fProcessedTime = time - m_fStartTime;
	m_fLastProcessedTime = time;

	if(!m_bDirectTag)
	{
		//tag change 처리
		for(INDEX i=0; i<m_vectorTagKey.size(); ++i)
		{
			if(m_vectorTagKey[i].m_fSettingTime * m_fSpeedMul > fProcessedTime) continue;

			//tag를 붙임. 매프레임마다 처리됨. (계속 붙음)
			EffectKey* effectkey = FindEffectKey(m_vectorTagKey[i].m_iEffectKeyValue);
			
			if (effectkey && effectkey->m_pCreatedEffect)
			{
				effectkey->m_pCreatedEffect->AttachToTag(m_vectorTagKey[i].m_ptrReserveTag);
			}
		}
	}
	//effect 처리
	CAnyProjection3D &apr = *m_pProjection;
	BOOL bTestCulling = m_pProjection != NULL && apr.ap_CurrentProjection != NULL;
	BOOL ret = FALSE;
	for(INDEX i=0; i<m_vectorEffectKey.size(); ++i)
	{
		EffectKey &effectKey = m_vectorEffectKey[ i ];

		//시작 시간을 지났으므로 시작한다. 시간은 정해진 시작시간으로 세팅한다.
		if(effectKey.m_pCreatedEffect->GetState() == ES_NOT_STARTED
			&& time >= effectKey.m_fStartTime * m_fSpeedMul + m_fStartTime)
		{
			effectKey.m_pCreatedEffect->Start( m_fStartTime + effectKey.m_fStartTime * m_fSpeedMul );
			if(effectKey.m_pCreatedEffect->GetTag().NotNull()
			&& !effectKey.m_pCreatedEffect->GetTag()->Active()
			&& effectKey.m_pCreatedEffect->Playing())
				effectKey.m_pCreatedEffect->SetNotRenderAtThisFrame();
		}

		//플레이 상태가 아니면 다음으로 넘어감
		if(effectKey.m_pCreatedEffect->Playing() == FALSE)
		{
			if(effectKey.m_pCreatedEffect->GetState() == ES_NOT_STARTED)
			{
				ret |= TRUE;
				continue;
			}
			else if(effectKey.m_pCreatedEffect->GetState() == ES_PLAY_END
				&& effectKey.m_pCreatedEffect->GetRepeatCount() != 0)
			{
				effectKey.m_pCreatedEffect->Start(time);

				if(effectKey.m_pCreatedEffect->Playing() == FALSE)
				{
					if(effectKey.m_pCreatedEffect->GetState() == ES_NOT_STARTED) ret |= TRUE;
					continue;
				}
			}
			else continue;
		}

		if(bTestCulling
			&& effectKey.m_pCreatedEffect->GetType() != ET_SOUND
			&& effectKey.m_pCreatedEffect->GetType() != ET_CAMERA)
		{
			BOOL bNoPassTest = FALSE;

			//거리 테스트, 먼저 한다.
			CTag *pTagTest = NULL;
			if(effectKey.m_pCreatedEffect->GetTag()->GetType() != TT_GROUP)
			{
				pTagTest = effectKey.m_pCreatedEffect->GetTag().GetNative();
			}
			else
			{
				pTagTest = ((CGroupTag*)effectKey.m_pCreatedEffect->GetTag().GetNative())->GetTag(0).GetNative();
			}
			bNoPassTest = (g_fEffectDistance < fabs(apr->GetDistance( pTagTest->CurrentTagInfo().m_vPos )));
			if(!bNoPassTest)
			{
				//Frustum 테스트
				FLOAT fPerspectiveFactor = 1.0f;
				if( apr.IsPerspective())
					fPerspectiveFactor = ((CPerspectiveProjection3D*)&*apr)->ppr_PerspectiveRatios(1);
				// project point to screen
				FLOAT3D vProjected;
				apr->PreClip( pTagTest->CurrentTagInfo().m_vPos, vProjected);
				// skip if too small
				const FLOAT fPixSize = effectKey.m_pCreatedEffect->GetBoundingSphereRadius() * fPerspectiveFactor / vProjected(3);
				if( fPixSize < 0.5f )
					bNoPassTest = TRUE;
				// skip if not in screen
				const INDEX iTested = apr->TestSphereToFrustum( vProjected, effectKey.m_pCreatedEffect->GetBoundingSphereRadius() );
				if( iTested < 0 )
					bNoPassTest = TRUE;
			}

			if(bNoPassTest)
			{
				effectKey.m_pCreatedEffect->SetNotRenderAtThisFrame();
				if(effectKey.m_pCreatedEffect->GetType() == ET_SPLINEBILLBOARD
				|| effectKey.m_pCreatedEffect->GetType() == ET_ORBIT)
				{
					effectKey.m_pCreatedEffect->Stop(0);
				}
			}
		}
		if(!effectKey.m_pCreatedEffect->IsNotRenderAtThisFrame())
		{
			//Processing, 내부적으로 상태가 변할 수 있음.
			BOOL processRet = effectKey.m_pCreatedEffect->Process(time);
			ret = ret || processRet;
		}
		else ret = TRUE;
	}
	return ret;
}
コード例 #18
0
ファイル: Tag.cpp プロジェクト: windreamer/amule-dlp
CTag::CTag(const CTag& rTag)
{
	m_uType = rTag.m_uType;
	m_uName = rTag.m_uName;
	m_Name = rTag.m_Name;
	m_nSize = 0;
	if (rTag.IsStr()) {
		m_pstrVal = new wxString(rTag.GetStr());
	} else if (rTag.IsInt()) {
		m_uVal = rTag.GetInt();
	} else if (rTag.IsFloat()) {
		m_fVal = rTag.GetFloat();
	} else if (rTag.IsHash()) {
		m_hashVal = new CMD4Hash(rTag.GetHash());
	} else if (rTag.IsBlob()) {
		m_nSize = rTag.GetBlobSize();
		m_pData = new unsigned char[rTag.GetBlobSize()];
		memcpy(m_pData, rTag.GetBlob(), rTag.GetBlobSize());
	} else if (rTag.IsBsob()) {
		m_nSize = rTag.GetBsobSize();
		m_pData = new unsigned char[rTag.GetBsobSize()];
		memcpy(m_pData, rTag.GetBsob(), rTag.GetBsobSize());
	} else {
		wxFAIL;
		m_uVal = 0;
	}
}
コード例 #19
0
ファイル: tagger.cpp プロジェクト: xiangyu/zpar-0.6
void CTagger :: updateLocalFeatureVector( SCORE_UPDATE method , const CTwoStringVector * sentence , unsigned long index , unsigned long round ) {
    // abstd::cout words
    CWord word = sentence->at( index ).first ;
    CWord last_word = index > 0 ? sentence->at( index - 1 ).first : g_emptyWord ;
    CWord next_word = index < sentence->size() - 1 ? sentence->at( index + 1 ).first : g_emptyWord ;
    CStringVector chars , last_chars ;
    chars.clear() ;
    getCharactersFromUTF8String( sentence->at(index).first , &chars ) ;
    last_chars.clear() ;
    if ( index > 0 ) getCharactersFromUTF8String( sentence->at( index - 1 ).first , &last_chars ) ;
    // abstd::cout length
    int length = chars.size() ; //if ( length > LENGTH_MAX-1 ) length = LENGTH_MAX-1 ;
    int last_length = last_chars.size() ; //if ( last_length > LENGTH_MAX-1 ) last_length = LENGTH_MAX-1 ;
    // abstd::cout chars
    CWord first_char = chars[ 0 ];
    CWord last_char = chars[ chars.size() - 1 ];
    CWord first_char_last_word = index > 0 ? last_chars[ 0 ] : g_emptyWord;
    CWord last_char_last_word = index > 0 ? last_chars[ last_chars.size() - 1 ] : g_emptyWord;
    CWord first_char_next_word = index + 1 < sentence->size() ? getFirstCharFromUTF8String( sentence->at( index + 1 ).first ) : g_emptyWord ;
    CWord last_twochar_last_word = last_chars.size() > 1 ? last_chars[ last_chars.size() - 2 ] + last_chars[ last_chars.size() - 1]
                                   : ( index > 1 ? getLastCharFromUTF8String(sentence->at(index-2).first) + last_chars[ 0 ] : g_emptyWord );
    CWord first_twochar = chars.size() > 1 ? chars[ 0 ] + chars [ 1 ] : ( index + 1 <sentence->size() ? chars[ 0 ] + getFirstCharFromUTF8String( sentence->at( index + 1 ).first ) : g_emptyWord );
    CWord currentword_lasttwochar = index > 1 ? last_twochar_last_word.str() + word.str() : g_emptyWord ;
    CWord lastword_firsttwochar = index > 0 && index+1 < sentence->size() ? last_word.str() + first_twochar.str() : g_emptyWord ;

    CWord two_char = index > 0 ? last_char_last_word.str() + first_char.str() : g_emptyWord ;
    CWord lastword_firstchar = index > 0 ? last_word.str() + first_char.str() : g_emptyWord ;
    CWord currentword_lastchar = index > 0 ? last_char_last_word.str() + word.str() : g_emptyWord ;
    CWord three_char = length == 1 ? last_char_last_word.str() + word.str() + first_char_next_word.str() : g_emptyWord ;

    CTwoWords two_word ;

    // abstd::cout tags
    const CTag tag( sentence->at(index).second ) ;
    const CTag last_tag = index > 0 ? CTag( sentence->at( index-1 ).second) : CTag::SENTENCE_BEGIN ;
    const CTag second_last_tag = index > 1 ? CTag( sentence->at( index-2 ).second) : CTag::SENTENCE_BEGIN ;
    const CTagSet<CTag, 2> tag_bigram(encodeTags(tag, last_tag));
    const CTagSet<CTag, 3> tag_trigram(encodeTags(tag, last_tag, second_last_tag));
    CTaggedWord<CTag, TAG_SEPARATOR> wt1, wt2;
    CTwoTaggedWords wt12;

    // abstd::cout the char categories
    long int first_char_cat = m_weights->m_mapCharTagDictionary.lookup(first_char) | (1<<tag.code()) ;
    long int last_char_cat = m_weights->m_mapCharTagDictionary.lookup(last_char) | (1<<tag.code()) ;
    SCORE_TYPE amount = method == eAdd ? 1 : -1 ;

    m_weights->m_mapCurrentTag[ std::make_pair(word, tag) ].updateCurrent( amount , round ) ;
    m_weights->m_mapLastTagByTag[ tag_bigram ].updateCurrent( amount , round ) ;
    m_weights->m_mapLastTwoTagsByTag[ tag_trigram ].updateCurrent( amount , round ) ;
    if ( index > 0 ) {
        if ( last_length <= 2 ) m_weights->m_mapTagByLastWord[ std::make_pair(last_word, tag) ].updateCurrent( amount , round ) ;
        if ( length <= 2 ) m_weights->m_mapLastTagByWord[ std::make_pair(word, last_tag) ].updateCurrent( amount , round ) ;
        if ( length <= 2 ) m_weights->m_mapTagByWordAndPrevChar[ std::make_pair(currentword_lastchar, tag) ].updateCurrent( amount , round ) ;
        if ( last_length <= 2 ) m_weights->m_mapTagByWordAndNextChar[ std::make_pair(lastword_firstchar, last_tag) ].updateCurrent( amount , round ) ;
    }
    if ( length == 1 ) {
        if ( index > 0 && index < sentence->size() - 1 )
            m_weights->m_mapTagOfOneCharWord[ std::make_pair(three_char, tag) ].updateCurrent( amount , round ) ;
    }
    else {
        m_weights->m_mapTagByFirstChar[ std::make_pair(first_char, tag) ].updateCurrent( amount , round ) ;
        m_weights->m_mapTagByLastChar[ std::make_pair(last_char, tag) ].updateCurrent( amount , round ) ;                    //
        m_weights->m_mapTagByFirstCharCat[ std::make_pair(first_char_cat, tag) ].updateCurrent( amount , round ) ;
        m_weights->m_mapTagByLastCharCat[ std::make_pair(last_char_cat, tag) ].updateCurrent( amount , round ) ;
        for ( int j = 0 ; j < chars.size() ; ++ j ) {
            if ( j > 0 && j < chars.size() - 1 )
                m_weights->m_mapTagByChar[ std::make_pair(CWord(chars[j]), tag) ].updateCurrent( amount , round ) ;
            if ( j > 0 ) {
                wt1.load(chars[j], tag);
                wt2.load(first_char);
                wt12.allocate(wt1, wt2);
                m_weights->m_mapTaggedCharByFirstChar[ wt12 ].updateCurrent( amount , round ) ;
                if ( chars[j] == chars[j-1] ) m_weights->m_mapRepeatedCharByTag[ std::make_pair(CWord(chars[j]), tag) ].updateCurrent( amount , round ) ; //
            }
            if (j<chars.size()-1) {
                wt1.load(chars[j], tag);
                wt2.load(last_char);
                wt12.allocate(wt1, wt2);
                m_weights->m_mapTaggedCharByLastChar[ wt12 ].updateCurrent(amount, round);
            }
        }
    }

}