您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ENSURE函数代码示例

51自学网 2021-06-01 20:32:48
  C++
这篇教程C++ ENSURE函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ENSURE函数的典型用法代码示例。如果您正苦于以下问题:C++ ENSURE函数的具体用法?C++ ENSURE怎么用?C++ ENSURE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ENSURE函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: return

BOOL OperationHistory::ReduceSize(UINT32 MaxHistorySize, BOOL ExcludeLastUndo, BOOL DeleteWhatYouCan /*= FALSE*/){    // If the Current size of the operation history is less than or equal to MaxHistorySize then    // there is no need to do anything.    if ((CurrentSize <= MaxHistorySize))        return (TRUE);    // If The NowPtr is NULL then there are no undo operations to be deleted so return FALSE    if (NowPtr == NULL)        return (FALSE);    // Calculate how many bytes we need to reduce the size of the Operation history by    UINT32 Reduction = (CurrentSize - MaxHistorySize);    //-------------------------------------------------------------------------------    // Check if the operation history can be reduced to MaxHistorySize bytes or less    // The OpSize total is the count of the number of bytes we can reduce the Operation    // history by.    UINT32 OpSizeTotal = 0;    // We know that the NowPtr is not NULL so the oldest undo operation will be found at    // the head of the OpHistoryList.    ListItem* pOp = OpHistoryList.GetHead();    // We are allowed to delete all operations from the head of the list    // upto and excluding StopOp. StopOp is the last undo operation if the    // ExcludeLastUndo flag is TRUE, else it is the first redo operation.    ListItem* StopOp = (ExcludeLastUndo) ? NowPtr: OpHistoryList.GetNext(NowPtr);    // Loop until we either hit StopOp or we have found enough operations to delete    while ((pOp != StopOp) && (OpSizeTotal < Reduction))    {        // In a sane world this should always be true        ENSURE(	pOp != NULL,                "OperationHistory::ReduceSize: Pointer OperationHistory is NULL");        // Increase the OpSizeTotal by the number of bytes of the current operation        OpSizeTotal += ((Operation*)pOp)->GetSize();        // Get the next operation        pOp = OpHistoryList.GetNext(pOp);    };    //-------------------------------------------------------------------------------    // Now if we can,  reduce the operation history size    if ((OpSizeTotal >= Reduction) || (DeleteWhatYouCan && (OpSizeTotal != 0))) // The size can be reduced    {        // Start at the head of the OpHistoryList        ListItem* pDeleteOp = OpHistoryList.GetHead();#ifdef _DEBUG        UINT32 TotalChk = 0;#endif        while (pDeleteOp != pOp)        {            DecSize(((Operation*)pDeleteOp)->GetSize());  // Reduce history size#ifdef _DEBUG            TotalChk += ((Operation*)pDeleteOp)->GetSize();#endif            ListItem* pNextDeleteOp = OpHistoryList.GetNext(pDeleteOp);            // If the operation which is about to be deleted is the operation pointed to by the NowPtr            // then it is the last undo operation, so set NowPtr to NULL.            if (NowPtr == pDeleteOp)                NowPtr = NULL;            delete(OpHistoryList.RemoveItem(pDeleteOp));         // Delete the operation            pDeleteOp = pNextDeleteOp;        }        // Defensive programming#ifdef _DEBUG                       // Required because of TotalChk variable        ENSURE(	OpSizeTotal == TotalChk,                "OperationHistory::ReduceSize: OpSizeTotal != TotalChk");#endif        Reduced = TRUE;        return (TRUE);    }    else        return (FALSE); // Cannot reduce size of history to MaxHistorySize bytes or less}
开发者ID:vata,项目名称:xarino,代码行数:89,


示例2: switch

VfsPath CColladaManager::GetLoadablePath(const VfsPath& pathnameNoExtension, FileType type){	std::wstring extn;	switch (type)	{	case PMD: extn = L".pmd"; break;	case PSA: extn = L".psa"; break;		// no other alternatives	}	/*	Algorithm:	* Calculate hash of skeletons.xml and converter version.	* Use CCacheLoader to check for archived or loose cached .pmd/psa.	* If cached version exists:		* Return pathname of cached .pmd/psa.	* Else, if source .dae for this model exists:		* Convert it to cached .pmd/psa.		* If converter succeeded:			* Return pathname of cached .pmd/psa.		* Else, fail (return empty path).	* Else, if uncached .pmd/psa exists:		* Return pathname of uncached .pmd/psa.	* Else, fail (return empty path).	Since we use CCacheLoader which automatically hashes file size and mtime,	and handles archived files and loose cache, when preparing the cache key	we add converter version number (so updates of the converter cause	regeneration of the .pmd/psa) and the global skeletons.xml file size and	mtime, as modelers frequently change the contents of skeletons.xml and get	perplexed if the in-game models haven't updated as expected (we don't know	which models were affected by the skeletons.xml change, if any, so we just	regenerate all of them)	TODO (maybe): The .dae -> .pmd/psa conversion may fail (e.g. if the .dae is	invalid or unsupported), but it may take a long time to start the conversion	then realise it's not going to work. That will delay the loading of the game	every time, which is annoying, so maybe it should cache the error message	until the .dae is updated and fixed. (Alternatively, avoid having that many	broken .daes in the game.)	*/	// Now we're looking for cached files	CCacheLoader cacheLoader(m_VFS, extn);	MD5 hash;	u32 version;	m->PrepareCacheKey(hash, version);	VfsPath cachePath;	VfsPath sourcePath = pathnameNoExtension.ChangeExtension(L".dae");	Status ret = cacheLoader.TryLoadingCached(sourcePath, hash, version, cachePath);	if (ret == INFO::OK)		// Found a valid cached version		return cachePath;	// No valid cached version, check if we have a source .dae	if (ret != INFO::SKIPPED)	{		// No valid cached version was found, and no source .dae exists		ENSURE(ret < 0);		// Check if source (uncached) .pmd/psa exists		sourcePath = pathnameNoExtension.ChangeExtension(extn);		if (m_VFS->GetFileInfo(sourcePath, NULL) != INFO::OK)		{			// Broken reference, the caller will need to handle this			return L"";		}		else		{			return sourcePath;		}	}	// No valid cached version was found - but source .dae exists	// We'll try converting it	// We have a source .dae and invalid cached version, so regenerate cached version	if (! m->Convert(sourcePath, cachePath, type))	{		// The COLLADA converter failed for some reason, this will need to be handled		//	by the caller		return L"";	}	return cachePath;}
开发者ID:2asoft,项目名称:0ad,代码行数:90,


示例3: AfxGetModuleThreadState

void CControlBar::OnTimer(UINT_PTR nIDEvent){	if (GetKeyState(VK_LBUTTON) < 0)		return;	AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();	// get current mouse position for hit test	CPoint point; GetCursorPos(&point);	ScreenToClient(&point);	INT_PTR nHit = OnToolHitTest(point, NULL);	if (nHit >= 0)	{		CWnd *pParent=GetTopLevelParent();		// determine if status bar help should go away        if(!IsTopParentActive())        {            nHit=-1;        }        else        {			ENSURE(pParent);		    if(!pParent->IsWindowEnabled())            {			    nHit = -1;            }        }		// remove status help if capture is set		HWND hWndTip = pModuleThreadState->m_pToolTip->GetSafeHwnd();		CWnd* pCapture = GetCapture();		if (pCapture != this && pCapture->GetSafeHwnd() != hWndTip &&			pCapture->GetTopLevelParent() == pParent)		{			nHit = -1;		}	}	else	{		pModuleThreadState->m_nLastStatus = static_cast<INT_PTR>(-1);	}	// make sure it isn't over some other app's window	if (nHit >= 0)	{		ClientToScreen(&point);		HWND hWnd = ::WindowFromPoint(point);		if (hWnd == NULL || (hWnd != m_hWnd && !::IsChild(m_hWnd, hWnd) &&			pModuleThreadState->m_pToolTip->GetSafeHwnd() != hWnd))		{			nHit = -1;			pModuleThreadState->m_nLastStatus = static_cast<INT_PTR>(-1);		}	}	// handle the result	if (nHit < 0)	{		if (pModuleThreadState->m_nLastStatus == static_cast<INT_PTR>(-1))			KillTimer(ID_TIMER_CHECK);		SetStatusText(static_cast<INT_PTR>(-1));	}	// set status text after initial timeout	if (nIDEvent == ID_TIMER_WAIT)	{		KillTimer(ID_TIMER_WAIT);		if (nHit >= 0)			SetStatusText(nHit);	}}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:71,


示例4: while

BOOL OutputDIB::WriteBlock( UINT32 YPos, UINT32 Height, LPBYTE BlockStart, UINT32 InputBPP,							INT32 ProgressOffset){	FNPTR_SCANLINE ConvertFn = NULL;	LPBYTE Buffer = NULL;	size_t BufSize = 0L;	size_t ChunkHeight = 1;	DIBConvert *DoConvert = NULL;	// Set up the size and other information for the dib block that we require. This is	// dependent on the export depth or bpp required.	if ( !SetUpBlock( &BufSize, &ChunkHeight, &DoConvert, &ConvertFn ) )		return FALSE;			// Error details already set up	if (BufSize)	{		Buffer = (LPBYTE)CCMalloc( BufSize );		if (Buffer==NULL)			return FALSE;	}	if ( DoConvert )	{		// use new classes to do it		// 8bpp, 4bpp and 1bpp conversion		INT32 h = Height;		INT32 count = 0;		LPBYTE Data = BlockStart;		const size_t SourceWidth = DIBUtil::ScanlineSize( BitmapInfo.biWidth, InputBPP ) * ChunkHeight;		const size_t DestWidth   = DIBUtil::ScanlineSize( BitmapInfo.biWidth, BitmapInfo.biBitCount );		while (h)		{			ENSURE(h >= 0, "bad looping");			const size_t ThisBit = min( h, (INT32)ChunkHeight );			if (!DoConvert->Convert( Data, Buffer, ThisBit, IsFirstStrip ))				break;								// stop if conversion failed			IsFirstStrip = FALSE;			OutputFile->write( Buffer, ThisBit * DestWidth );			if (OutputFile->bad())				break;								// stop if file errored			Data += SourceWidth;			h -= ThisBit;			// now update the progress display, started with CurrentExportSize			// CurrentExport size is now the point to go from in the export			count++;			ContinueSlowJob( (INT32)( ProgressOffset + count ));			//ContinueSlowJob( (INT32)(100*count/(Height)) );		}	}	// now the bytes (this is crying out for a virtual function or two)	else if ( ConvertFn && Buffer )	{		// Write via conversion function		// 24 bpp convert		UINT32 h = Height;		INT32 count = 0;		LPBYTE Data = BlockStart;		const size_t SourceWidth = DIBUtil::ScanlineSize( BitmapInfo.biWidth, InputBPP );		while (h)		{			ConvertFn( BitmapInfo.biWidth, Data, Buffer );			OutputFile->write( Buffer, BufSize );			if (OutputFile->bad())				break;								// stop if file errored			Data += SourceWidth;			h -= ChunkHeight;			// now update the progress display, started with CurrentExportSize			// ProgressOffset size is now the point to go from in the export			count++;			ContinueSlowJob( (INT32)( ProgressOffset + count ));			//ContinueSlowJob( (INT32)((CurrentExportSize * count)/Height) );		}	}	else	{		// Write it all out in one go		//OutputFile->write( BlockStart, BitmapInfo.biSizeImage );		// Write the actual bytes out to file. Used to do it in one go but we really		// require some progress bar indication so we will do it in chunks.		DWORD BitsSize = BitmapInfo.biSizeImage; 		if (BitsSize > 0)		{			if (BitsSize < 1024)			{				// File very small or no progress bar required, so load in one go				OutputFile->write( BlockStart, BitsSize);			}			else			{				// Load in chunks, for present split into 100 chunks				DWORD ChunkSize = BitsSize/100;				DWORD Position = 0;				LPBYTE pBitInfo = BlockStart;//.........这里部分代码省略.........
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:101,


示例5: GetClientRect

void CInformErrorDialog::GetDialogInfo(){	// Skip this if we've already done it.	if (ValidInfo)		return;	// Find out how bug the dialog is by default.	CRect DlgRect;	GetClientRect(&DlgRect);	DialogSize.cx = DlgRect.Width();	DialogSize.cy = DlgRect.Height();	// Find out the button spacing/sizes etc.	CWnd *pCtrl1 = GetDlgItem(ButtonID[0]);	CWnd *pCtrl2 = GetDlgItem(ButtonID[1]);	ENSURE((pCtrl1 != NULL) && (pCtrl2 != NULL), 		   "Can't find control in CInformErrorDialog::OnInitDialog()");	// Safety check.	if ((pCtrl1 == NULL) || (pCtrl2 == NULL))		return;	// Get width of buttons, and the spacing between the buttons and the edge of the dialog.	WINDOWPLACEMENT Placement;	Placement.length = sizeof(WINDOWPLACEMENT);	pCtrl1->GetWindowPlacement(&Placement);	DefTopOfButton = Placement.rcNormalPosition.top;	DefButtonSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;	DefButtonSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;	EdgeSpacing = Placement.rcNormalPosition.left;	// Get space between adjacent buttons.	Placement.length = sizeof(WINDOWPLACEMENT);	pCtrl2->GetWindowPlacement(&Placement);	ButtonSpacing = Placement.rcNormalPosition.left - (EdgeSpacing + DefButtonSize.cx);	// Find the position of the icon.	CWnd *pIconCtrl = GetDlgItem(_R(IDC_ERRORBOX_ICON));	ENSURE(pIconCtrl != NULL, "Can't find Icon control in CInformErrorDialog::GetDialogInfo()");	// Safety check.	if (pIconCtrl == NULL)		return;	Placement.length = sizeof(WINDOWPLACEMENT);	pIconCtrl->GetWindowPlacement(&Placement);		DefIconPos.x = Placement.rcNormalPosition.left;	DefIconPos.y = Placement.rcNormalPosition.top;	// Find the position of the message text area.	CWnd *pMsgCtrl = GetDlgItem(_R(IDC_ERRORBOX_TEXT));	ENSURE(pMsgCtrl != NULL, "Can't find Text control in CInformErrorDialog::GetDialogInfo()");	// Safety check.	if (pMsgCtrl == NULL)		return;	Placement.length = sizeof(WINDOWPLACEMENT);	pMsgCtrl->GetWindowPlacement(&Placement);	DefMsgSize.cx = Placement.rcNormalPosition.right - Placement.rcNormalPosition.left;	DefMsgSize.cy = Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top;	// The static variables now contain valid information.	ValidInfo = TRUE;}
开发者ID:UIKit0,项目名称:xara-xtreme,代码行数:69,


示例6: GetDlgItem

BOOL CInformErrorDialog::SetupButtons(HDC hDC, INT32 NumButtons){	// Set the default button in the dialog.	CWnd *pDefCtrl = GetDlgItem(ButtonID[m_OK - 1]);	ENSURE(pDefCtrl != NULL, "Can't get handle to default control in CInformErrorDialog");	// If we can't get at this button then ooer...bit of a fatal error	if (pDefCtrl == NULL)	{		ENSURE(FALSE, "Can't get default button in error box!");		return FALSE;	}	// Set the keyboard focus to the default button, and give it a 'default' border.	pDefCtrl->SetFocus();	SendMessage(DM_SETDEFID, ButtonID[m_OK - 1], 0);	// Read in the button texts, and find which is the widest string.	INT32 ButtonWidth = DefButtonSize.cx;	INT32 i;	for (i = 0; i < NumButtons; i++)	{		// Try to load text for this button		if (!ButtonText[i].Load(m_ButtonStr[i], m_OwnerModule))		{			ENSURE(FALSE, "Unable to load button text for error box!");			return FALSE;		}		// Try to read the size of this button text.		SIZE TextSize;		if (!GetTextExtentPoint(hDC, (TCHAR *) ButtonText[i], ButtonText[i].Length(),						   	    &TextSize))		{			// Error reading text size			ENSURE(FALSE, "Unable to read button text size for error box!");			return FALSE;		}		if (TextSize.cx > ButtonWidth)			ButtonWidth = TextSize.cx + 8;	}	// Allow for space on either side in the button	ButtonWidth += 8;	// Find out how big the buttons can be at the most.	INT32 MaxWidth = DialogSize.cx - 				   (2 * EdgeSpacing) - 				   ((NumButtons - 1) * ButtonSpacing);	// NumButtons cannot be 0 if we get to here...but just in case :-)	if (NumButtons == 0)	{		ENSURE(FALSE, "NumButtons is zero in error box!");		return FALSE;	}	// Safe to do a divide now!	MaxWidth /= NumButtons;	// The width of the dialog may change.	INT32 NewWidth = DialogSize.cx;	// Find out if we need to make the dialog bigger to accomodate the buttons.	if (ButtonWidth > MaxWidth)	{		// Yes - find out if the buttons actually fit on screen - if not, make them		// smaller and truncate the button text (this shouldn't happen too often!)		// Get required dialog width		NewWidth = (EdgeSpacing * 2) +				   (NumButtons * ButtonWidth) +				   ((NumButtons - 1) * ButtonSpacing);		// Does this actually fit on screen?		INT32 ScreenWidth = GetSystemMetrics(SM_CXSCREEN);		if (ScreenWidth < NewWidth)		{			// They don't fit - downsize the buttons to fit.			ButtonWidth = ScreenWidth - 					      (2 * EdgeSpacing) - 					      ((NumButtons - 1) * ButtonSpacing);			ButtonWidth /= NumButtons;			NewWidth = ScreenWidth;		}		// Ok - buttons are now correct size - resize the dialog.		SIZE BorderSize;		BorderSize.cx = 2 * ::GetSystemMetrics(SM_CXDLGFRAME);		BorderSize.cy = ::GetSystemMetrics(SM_CYDLGFRAME) + 						::GetSystemMetrics(SM_CYCAPTION);		if (!SetWindowPos(NULL, 0, 0, 					 	  NewWidth + BorderSize.cx, DialogSize.cy + BorderSize.cy,					      SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW))		{			ENSURE(FALSE, "Unable to resize the error box!");//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:xara-xtreme,代码行数:101,


示例7: ENSURE

u32 CNetServerTurnManager::GetSavedTurnLength(u32 turn){	ENSURE(turn <= m_ReadyTurn);	return m_SavedTurnLengths.at(turn);}
开发者ID:Epidilius,项目名称:0ad,代码行数:5,


示例8: ENSURE

void OpLayerChange::Do(OpDescriptor*){   	ENSURE(FALSE,"This shouldn't have been called");/*	Spread* pSpread = Document::GetCurrent()->GetLayerMgr().GetCurrentSpread(); 	// Find the first layer on the spread. All siblings of the first layer node should	// be layer nodes	Node* CurrentTreeLayer = pSpread->FindFirstLayer(); // skips over page nodes 	ENSURE(CurrentTreeLayer->GetRuntimeClass() == CC_RUNTIME_CLASS(Layer), 			"A next sibling of a layer node is not a layer"); 	// Get the first layer details record 	LyrDetails* CurLyrDet = (LyrDetails*)		(Document::GetCurrent()->GetLayerMgr()).LyrDetList.GetHead(); 		BOOL InvalidateLayersRgn; // Flag used to decide if we should invalidate							  // a layers region	BOOL RemoveSelections; 	  // Flag used to indicate if we should remove all							  // selections from the layer     // loop while there are more changes to be made 	while (CurLyrDet != NULL) 	{		InvalidateLayersRgn = FALSE;		RemoveSelections = FALSE; 		// We can ignore all new layers which have been deleted 		if (!((CurLyrDet->New) && (CurLyrDet->Deleted)))		{			// Is the layer a new layer ? 			if (CurLyrDet->New)			{				// Attempt to create a new layer node 				Layer* NewLyr; 				ALLOC_WITH_FAIL(NewLyr, (new Layer()), this); 	      				if (NewLyr == NULL)				{					goto EndOperation; // We were unable to create a new layer so 									   // abort the operation 				}				// Set the new layer's status  				NewLyr->SetLayerStatus(CurLyrDet->Status); 		   			    // Create a hide node action to hide the new node when we undo/redo			    HideNodeAction* UndoHideNodeAction; 			    // ** Change !!!    				if (!HideNodeAction::Init(this,                    							 			  &UndoActions,										  NewLyr, 										  TRUE, 							  			  ( Action**)(&UndoHideNodeAction))      							  			  != AC_FAIL)				{					delete NewLyr;     // We won't be needing this 					goto EndOperation; 						}				// All is well 				if (CurrentTreeLayer != NULL)				{					// Add the new layer to the tree as a previous sibling of 					// the CurrentTreeLayer 					NewLyr->AttachNode(CurrentTreeLayer, PREV); 				}				else 				{					// Add the new layer as a last child of the spread 					NewLyr->AttachNode(Document::GetCurrent()->						GetLayerMgr().GetCurrentSpread(), LASTCHILD); 				}			}			// Has the layer been deleted 			else if (CurLyrDet->Deleted)			{				if ( CurLyrDet->Layer == CurrentTreeLayer )				{					// We are about to hide the CurrentTreeLayer so we need to find the 					// next layer before we do this 					CurrentTreeLayer = ((Layer*)CurrentTreeLayer)->FindNextLayer(); 				}								// If a layer has been deleted then we ignore all attribute changes 				// which may have been made prior to the layer being deleted. 				// Change 				if (!DoHideNode(CurLyrDet->Layer, 								TRUE				// Include subtree size 								)) // Hide the node 					goto EndOperation; 				InvalidateLayersRgn = TRUE; // We will need to invalidate the hidden 											// layers bounding region. 				RemoveSelections = TRUE;    			}			else 			{				// Have the attributes of the layer changed 				if ( !(CurLyrDet->Status == CurLyrDet->Layer->GetLayerStatus()) )					{		//.........这里部分代码省略.........
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:101,


示例9: bar

void bar(void) {    ENSURE(1 == 2);}
开发者ID:hudsonsferreira,项目名称:thc,代码行数:3,


示例10: foo

void foo(void) {    ENSURE(1 == 1);}
开发者ID:hudsonsferreira,项目名称:thc,代码行数:3,


示例11: test_functional_columns

    void test_functional_columns(smt_params fparams, params_ref& params) {        ast_manager m;        register_engine re;        context ctx(m, re, fparams);        rel_context_base& rctx = *ctx.get_rel_context();        ctx.updt_params(params);        relation_manager & rmgr(rctx.get_rmanager());        sparse_table_plugin & plugin =             static_cast<sparse_table_plugin &>(*rctx.get_rmanager().get_table_plugin(symbol("sparse")));        ENSURE(&plugin);        table_signature sig2;        sig2.push_back(2);        sig2.push_back(2);        sig2.set_functional_columns(1);        ENSURE(plugin.can_handle_signature(sig2));                table_fact f00;        f00.push_back(0);        f00.push_back(0);        table_fact f01;        f01.push_back(0);        f01.push_back(1);        table_fact f11;        f11.push_back(1);        f11.push_back(1);        {            table_aptr t0 = plugin.mk_empty(sig2);            ENSURE(t0->empty());            t0->add_fact(f00);            ENSURE(!t0->empty());            ENSURE(t0->get_size_estimate_rows()==1);            t0->add_fact(f01);            ENSURE(t0->get_size_estimate_rows()==1);            t0->add_fact(f11);            ENSURE(t0->get_size_estimate_rows()==2);            unsigned rem_cols0[]={0};            scoped_ptr<table_transformer_fn> project0 = rmgr.mk_project_fn(*t0, 1, rem_cols0);            table_aptr t1 = (*project0)(*t0);            ENSURE(t1->get_size_estimate_rows()==2);            ENSURE(t1->get_signature().functional_columns()==0); //project on non-functional column cancels functional            unsigned rem_cols1[]={1};            scoped_ptr<table_transformer_fn> project1 = rmgr.mk_project_fn(*t0, 1, rem_cols1);            table_aptr t2 = (*project1)(*t0);            ENSURE(t2->get_size_estimate_rows()==2);            idx_set acc;            collector_of_reduced * reducer = alloc(collector_of_reduced, acc);            scoped_ptr<table_transformer_fn> rproject = rmgr.mk_project_with_reduce_fn(*t0, 1, rem_cols0, reducer);            table_aptr rt = (*rproject)(*t0);            ENSURE(acc.num_elems()==1);            ENSURE(rt->get_size_estimate_rows()==1);        }        {            table_aptr t0 = plugin.mk_empty(sig2);            t0->add_fact(f01);            unsigned join_cols[]={1};            scoped_ptr<table_join_fn> join0 = rmgr.mk_join_fn(*t0, *t0, 1, join_cols, join_cols);            table_aptr t1 = (*join0)(*t0, *t0);            ENSURE(t1->get_signature().size()==4);            ENSURE(t1->get_signature().functional_columns()==2);            table_fact f0011;            f0011.push_back(0);            f0011.push_back(0);            f0011.push_back(1);            f0011.push_back(1);            ENSURE(t1->contains_fact(f0011));            table_fact f0111 = f0011;            f0111[1] = 1;            ENSURE(!t1->contains_fact(f0111));        }        {            table_aptr t0 = plugin.mk_empty(sig2);            t0->display(std::cout<<"0:");            ENSURE(t0->get_signature().functional_columns()==1);                        table_fact aux_fact;            aux_fact = f01;            TRUSTME( t0->suggest_fact(aux_fact) );            t0->display(std::cout<<"1:");            ENSURE(t0->contains_fact(f01));            ENSURE(aux_fact[1]==1);            aux_fact = f00;            TRUSTME( !t0->suggest_fact(aux_fact) );            t0->display(std::cout<<"2:");            ENSURE(t0->contains_fact(f01));            ENSURE(!t0->contains_fact(f00));            ENSURE(aux_fact[1]==1);            t0->ensure_fact(f00);            t0->display(std::cout<<"3:");            ENSURE(t0->contains_fact(f00));//.........这里部分代码省略.........
开发者ID:NikolajBjorner,项目名称:z3,代码行数:101,


示例12: ENSURE

 const NPb::FieldDescriptor* TProtoSerial::GetFieldDescr(int protoField) {     const auto* fd = Descr->FindFieldByNumber(protoField);     ENSURE(fd, "Can't find field number " << protoField << " in message " << Message.GetTypeName());     return fd; }
开发者ID:alexeyche,项目名称:ground,代码行数:5,


示例13: _R

BOOL CInformErrorDialog::OnInitDialog(){	CDialog::OnInitDialog();		String_64 BoxTitle;	BoxTitle = _R(IDS_ERROR_BOX_SERIOUS_ERROR);	// "Serious error"	String_256 VerySeriousError;	VerySeriousError = _R(IDS_ERROR_BOX_VERY_SERIOUS_ERROR); // "A very serious error has occured - please consult your technical support."	// Andy Hills, 22-11-00	// Store the help context.	// We need to do this here, because the global help context variable	// nNextMessageHelpContext may change before the user clicks the 'Help'	// button. This fixes bug 6359.	m_nHelpContext = Error::GetErrorNumber();	if (! m_nHelpContext) m_nHelpContext = GetNextMsgHelpContext();	// Find out how many buttons there are.	for (INT32 NumButtons = ERRORDLG_MAXBUTTONS; NumButtons > 0; NumButtons--)	{		if (m_ButtonStr[NumButtons - 1] != 0) break;	}	// Adjust the OK and Cancel fields if necessary	if (m_OK > (UINT32) NumButtons)	{		if (IsUserName("Tim"))		{			TRACE( _T("OK out of range, OK=%u, NumButtons=%d/n"), m_OK, NumButtons);		}		// Default to first button		m_OK = 1;	}	if (m_Cancel > (UINT32) NumButtons)	{		if (IsUserName("Tim"))		{			TRACE( _T("Cancel out of range, Cancel=%u, NumButtons=%d/n"), m_Cancel, NumButtons);		}		// Default to be the same as OK (this means a box with a single OK box will		// respond to Enter and Esc without the user having to specify a Cancel ID).		m_Cancel = m_OK;	}	if (m_Help > (UINT32) NumButtons)	{		TRACEUSER( "JustinF", _T("Help button (%d) out of range (%d)/n"),									(INT32) m_Help, (INT32) NumButtons);				// The only really safe thing we can do is drop the help button.		m_Help = 0;	}			// Make sure we have correct dialog information	GetDialogInfo();	if (!ValidInfo)	{		// Serious error - fall back to to MessageBox().		goto SevereError;	}	// Get icon position	IconPos = DefIconPos;	// Get a DC for this dialog, so we can find out the size of text strings.	// We'll also need to select in our font or else it'll base the width upon the	// System font rather than the font we're using (MS Sans Serif at last check)	CDC *pDC;	CFont *OldFont;	pDC = GetDC();	ENSURE(pDC != NULL, "Can't get DC for error box dialog");	// Check the DC	if (pDC == NULL)		goto SevereError;	OldFont = pDC->SelectObject(GetFont());	// Set buttons text and move/resize buttons according to the number of them,	// and their contents.	BOOL Success;	Success = SetupButtons(pDC->m_hDC, NumButtons);	// Size the error message control, and put the message in it.	Success = Success && SetupMessage(pDC->m_hDC);	if (OldFont != NULL)		pDC->SelectObject(OldFont);	// We've finished with this DC now.	ReleaseDC(pDC);	// Check for failure in button/message setup.	if (!Success)//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:xara-xtreme,代码行数:101,


示例14: switch

BOOL OutputDIB::SetUpBlock( size_t *pBufSize, size_t *pChunkHeight, DIBConvert **pDoConvert,							FNPTR_SCANLINE *pConvertFn ){	BOOL Problems = FALSE;	switch (SourceBitmapDepth)	{		case 32:		{			switch (BitmapInfo.biBitCount)			{				case 32:					{						// real 32-bit BMPs here						// our 'filter' zeros the transparency bits						*pConvertFn = DIBUtil::Convert32to32;						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 32 );					}					break;				case 24:					{						// convert 32-bit BMPs to 24-bit ones so things can read them						*pConvertFn = DIBUtil::Convert32to24;	  						// 32->24						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 24 );	// size of 24-bit scanline					}					break;				case 8:					{						// 32->8 we do in bigger chunks because of dithering						*pDoConvert = DIBConvert::Create( SourceBitmapDepth, 8, BitmapInfo.biWidth, OutputPalette, Dither );						if (*pDoConvert==NULL)						{							ENSURE(FALSE, "DIBConvert::Create returned NULL");							return FALSE;						}						*pChunkHeight = 16;						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 8 ) * (*pChunkHeight);					}					break;				case 4:					{						// 32->4 we do in bigger chunks because of dithering						*pDoConvert = DIBConvert::Create( SourceBitmapDepth, 4, BitmapInfo.biWidth, OutputPalette, Dither );						if (*pDoConvert==NULL)						{							ENSURE(FALSE, "DIBConvert::Create returned NULL");							return FALSE;						}						*pChunkHeight = 16;						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 4 ) * (*pChunkHeight);					}					break;				case 1:					{						// 32->1 we do in bigger chunks because of dithering						*pDoConvert = DIBConvert::Create( SourceBitmapDepth, 1, BitmapInfo.biWidth, OutputPalette, Dither );						if (*pDoConvert==NULL)						{							ENSURE(FALSE, "DIBConvert::Create returned NULL");							return FALSE;						}						*pChunkHeight = 16;						*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 1 ) * (*pChunkHeight);					}					break;				default:					Problems = TRUE;					break;			}			break;		}		case 8:			if (BitmapInfo.biBitCount==8)			{				// real 8-bit BMPs here				// we basically just do a memory copy from source to dest				*pConvertFn = DIBUtil::Convert8to8;				*pBufSize = DIBUtil::ScanlineSize( BitmapInfo.biWidth, 8 );				break;			}			Problems = TRUE;			break;		default:			Problems = TRUE;			break;	}	if(Problems)	{		Error::SetError( _R(IDE_FORMATNOTSUPPORTED) );		return FALSE;	}	return TRUE;}
开发者ID:Amadiro,项目名称:xara-cairo,代码行数:97,


示例15: Init

	virtual void Init(const CParamNode& paramNode)	{		// The minimum obstruction size is the navcell size * sqrt(2)		// This is enforced in the schema as a minimum of 1.5		fixed minObstruction = (Pathfinding::NAVCELL_SIZE.Square() * 2).Sqrt();		m_TemplateFlags = 0;		if (paramNode.GetChild("BlockMovement").ToBool())			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;		if (paramNode.GetChild("BlockPathfinding").ToBool())			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;		if (paramNode.GetChild("BlockFoundation").ToBool())			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_FOUNDATION;		if (paramNode.GetChild("BlockConstruction").ToBool())			m_TemplateFlags |= ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION;		m_Flags = m_TemplateFlags;		if (paramNode.GetChild("DisableBlockMovement").ToBool())			m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT);		if (paramNode.GetChild("DisableBlockPathfinding").ToBool())			m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING);		if (paramNode.GetChild("Unit").IsOk())		{			m_Type = UNIT;			CmpPtr<ICmpUnitMotion> cmpUnitMotion(GetEntityHandle());			if (cmpUnitMotion)				m_Clearance = cmpUnitMotion->GetUnitClearance();		}		else if (paramNode.GetChild("Static").IsOk())		{			m_Type = STATIC;			m_Size0 = paramNode.GetChild("Static").GetChild("@width").ToFixed();			m_Size1 = paramNode.GetChild("Static").GetChild("@depth").ToFixed();			ENSURE(m_Size0 > minObstruction);			ENSURE(m_Size1 > minObstruction);		}		else		{			m_Type = CLUSTER;			CFixedVector2D max = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0));			CFixedVector2D min = CFixedVector2D(fixed::FromInt(0), fixed::FromInt(0));			const CParamNode::ChildrenMap& clusterMap = paramNode.GetChild("Obstructions").GetChildren();			for(CParamNode::ChildrenMap::const_iterator it = clusterMap.begin(); it != clusterMap.end(); ++it)			{				Shape b;				b.size0 = it->second.GetChild("@width").ToFixed();				b.size1 = it->second.GetChild("@depth").ToFixed();				ENSURE(b.size0 > minObstruction);				ENSURE(b.size1 > minObstruction);				b.dx = it->second.GetChild("@x").ToFixed();				b.dz = it->second.GetChild("@z").ToFixed();				b.da = entity_angle_t::FromInt(0);				b.flags = m_Flags;				m_Shapes.push_back(b);				max.X = MAX(max.X, b.dx + b.size0/2);				max.Y = MAX(max.Y, b.dz + b.size1/2);				min.X = MIN(min.X, b.dx - b.size0/2);				min.Y = MIN(min.Y, b.dz - b.size1/2);			}			m_Size0 = fixed::FromInt(2).Multiply(MAX(max.X, -min.X));			m_Size1 = fixed::FromInt(2).Multiply(MAX(max.Y, -min.Y));		}		m_Active = paramNode.GetChild("Active").ToBool();		m_ControlPersist = paramNode.GetChild("ControlPersist").IsOk();		m_Tag = tag_t();		if (m_Type == CLUSTER)			m_ClusterTags.clear();		m_Moving = false;		m_ControlGroup = GetEntityId();		m_ControlGroup2 = INVALID_ENTITY;	}
开发者ID:Rektosauros,项目名称:0ad,代码行数:74,


示例16: ENSURE

void GUITooltip::ShowTooltip(IGUIObject* obj, CPos pos, const CStr& style, CGUI* gui){	ENSURE(obj);	// Ignore attempts to use tooltip ""	if (style.empty())		return;	// Get the object referenced by 'tooltip_style'	IGUIObject* tooltipobj = gui->FindObjectByName("__tooltip_"+style);	if (! tooltipobj)	{		LOGERROR(L"Cannot find tooltip named '%hs'", style.c_str());		return;	}	IGUIObject* usedobj = tooltipobj; // object actually used to display the tooltip in	CStr usedObjectName;	if (GUI<CStr>::GetSetting(tooltipobj, "use_object", usedObjectName) == PSRETURN_OK		&& !usedObjectName.empty())	{		usedobj = gui->FindObjectByName(usedObjectName);		if (! usedobj)		{			LOGERROR(L"Cannot find object named '%hs' used by tooltip '%hs'", usedObjectName.c_str(), style.c_str());			return;		}		// Unhide the object. (If it had use_object and hide_object="true",		// still unhide it, because the used object might be hidden by default)		GUI<bool>::SetSetting(usedobj, "hidden", false);	}	else	{		// Unhide the object		GUI<bool>::SetSetting(usedobj, "hidden", false);		// Store mouse position inside the CTooltip		if (GUI<CPos>::SetSetting(usedobj, "_mousepos", pos) != PSRETURN_OK)			debug_warn(L"Failed to set tooltip mouse position");	}	// Retrieve object's 'tooltip' setting	CStrW text;	if (m_IsIconTooltip)	{		// Use icon tooltip property		if (GUI<CStrW>::GetSetting(obj, "_icon_tooltip", text) != PSRETURN_OK)			debug_warn(L"Failed to retrieve icon tooltip text"); // shouldn't fail	}	else	{		// Use normal tooltip property		if (GUI<CStrW>::GetSetting(obj, "tooltip", text) != PSRETURN_OK)			debug_warn(L"Failed to retrieve tooltip text"); // shouldn't fail	}	// Do some minimal processing ("/n" -> newline, etc)	text = text.UnescapeBackslashes();	// Set tooltip's caption	if (usedobj->SetSetting("caption", text) != PSRETURN_OK)		debug_warn(L"Failed to set tooltip caption"); // shouldn't fail	// Make the tooltip object regenerate its text	SGUIMessage msg(GUIM_SETTINGS_UPDATED, "caption");	usedobj->HandleMessage(msg);}
开发者ID:Marlinc,项目名称:0ad,代码行数:69,


示例17: tst1

static void tst1() {  map<char const *, int, str_hash_proc, str_eq_proc> str2int;  str2int.insert("foo", 35);  ENSURE(str2int.contains("foo"));  ENSURE(str2int.find_iterator("foo") != str2int.end());  ENSURE((*(str2int.find_iterator("foo"))).m_value == 35);  ENSURE(str2int.size() == 1);  str2int.insert("boo", 32);  ENSURE(str2int.contains("foo"));  ENSURE(str2int.find_iterator("foo") != str2int.end());  ENSURE((*(str2int.find_iterator("foo"))).m_value == 35);  ENSURE(str2int.contains("boo"));  ENSURE(str2int.find_iterator("boo") != str2int.end());  ENSURE((*(str2int.find_iterator("boo"))).m_value == 32);  ENSURE(str2int.size() == 2);  str2int.remove("boo");  ENSURE(str2int.size() == 1);  ENSURE(!str2int.contains("boo"));  ENSURE(str2int.contains("foo"));}
开发者ID:NikolajBjorner,项目名称:z3,代码行数:20,


示例18: ENSURE

JS::Value ScriptInterface::GetCachedValue(CACHED_VAL valueIdentifier){	std::map<ScriptInterface::CACHED_VAL, JS::PersistentRootedValue>::iterator it = m->m_ScriptValCache.find(valueIdentifier);	ENSURE(it != m->m_ScriptValCache.end());	return it->second.get();}
开发者ID:2asoft,项目名称:0ad,代码行数:6,


示例19: _start

void_start (void){  // debugging  /*  volatile char xxx = 0;  while (xxx == 0)    asm volatile ("pause" ::: "memory");  //*/  // clear BSS:  memset (&_section_bss_start[0], 0,          &_section_bss_end[0] - &_section_bss_start[0]);  videoram_cls (COLOR_NORMAL);  // some welcoming information:  videoram_printf ("/n  Welcome to /e%c chaOS! /n/n", COLOR_ERROR);  put_cpu_info ();  put_memory_map ();  if (!nx_bit_present ())    {      videoram_puts (" Your CPU does not support the NX bit! /n", COLOR_ERROR);      khalt ();    }  init_subsystem ("interrupt handling", &interrupts_init, NULL);  videoram_puts ("Running a syscall test: ", COLOR_NORMAL);  if (syscall_test ())    videoram_put_right (" ok ", COLOR_INFO);  else    {      videoram_put_right (" FAIL ", COLOR_ERROR);      khalt ();    }  init_subsystem ("PIC", &pic_init, NULL);  pit_set_handler (pic_handler_fun);  pic_mask (~PIC_MASK_PIT);  videoram_puts ("Setting CPU standards", COLOR_NORMAL);  cr0_set_reset (CR0_WP|CR0_NE, CR0_MP|CR0_EM|CR0_NE|CR0_AM|CR0_CD|CR0_NW);  msr_set_reset (MSR_EFER, EFER_NXE, 0);  videoram_put_right (" ok ", COLOR_INFO);  init_subsystem ("paging", &paging_init, NULL);  videoram_puts ("Enabling interrupts", COLOR_NORMAL);  asm volatile ("sti");  videoram_put_right (" ok ", COLOR_INFO);  init_subsystem ("real-time clock", &rtc_init, NULL);  init_subsystem ("timeout handler", &timeout_init, NULL);  init_subsystem ("random number generator", &random_init, NULL);  init_subsystem ("frame allocator", &frame_allocator_init, NULL);  init_subsystem ("Interrupt timer (33Hz)", &pit_init_33hz, NULL);  pic_mask (~0);  init_subsystem ("PS/2 keyboard", &keyboard_init, NULL);  init_subsystem ("PS/2 mouse", &mouse_init, NULL);  init_subsystem ("keypress handler", &keypress_handler_init, NULL);  ENSURE (keypress_handler_set_keymap (KEYMAP_QWERTZ_DE_DE));  // TODO: initialize more subsystems  put_welcoming_message ();  // TODO: do something  for (;;)    {      int c = keypress_handler_getc ();      if (!c)        break;      if (c < 128 && c != 127)        videoram_printf ("C: <%c>/n", c);    }    khalt ();}
开发者ID:Kijewski,项目名称:chaOS,代码行数:83,


示例20: test_finite_product_relation

    void test_finite_product_relation(smt_params fparams, params_ref& params) {        ast_manager m;        register_engine re;        context ctx(m, re, fparams);        ctx.updt_params(params);        dl_decl_util dl_util(m);        relation_manager & rmgr = ctx.get_rel_context()->get_rmanager();        relation_plugin & rel_plugin = *rmgr.get_relation_plugin(params.get_sym("default_relation", symbol("sparse")));        ENSURE(&rel_plugin);        finite_product_relation_plugin plg(rel_plugin, rmgr);        sort_ref byte_srt_ref(dl_util.mk_sort(symbol("BYTE"), 256), m);        relation_sort byte_srt = byte_srt_ref;        relation_signature sig2;        sig2.push_back(byte_srt);        sig2.push_back(byte_srt);        relation_signature sig3(sig2);        sig3.push_back(byte_srt);        relation_signature sig4(sig3);        sig4.push_back(byte_srt);        app_ref seven_ref(dl_util.mk_numeral(7, byte_srt), m);        app_ref nine_ref(dl_util.mk_numeral(9, byte_srt), m);        relation_element seven = seven_ref;        relation_element nine = nine_ref;        relation_fact f7(m);        f7.push_back(seven);        relation_fact f9(m);        f9.push_back(nine);        relation_fact f77(f7);        f77.push_back(seven);        relation_fact f79(f7);        f79.push_back(nine);        relation_fact f97(f9);        f97.push_back(seven);        relation_fact f99(f9);        f99.push_back(nine);        relation_fact f779(f77);        f779.push_back(nine);        relation_fact f799(f79);        f799.push_back(nine);        relation_fact f977(f97);        f977.push_back(seven);        relation_fact f7797(f779);        f7797.push_back(seven);        relation_fact f7997(f799);        f7997.push_back(seven);        bool table_cols2[] = { true, false };        bool table_cols3[] = { true, false, false };        bool table_cols4[] = { true, true, false, false };        scoped_rel<relation_base> r1 = plg.mk_empty(sig2, table_cols2);        scoped_rel<relation_base> r2 = r1->clone();        scoped_rel<relation_base> r3 = r2->clone();        ENSURE(!r1->contains_fact(f77));        r1->add_fact(f77);        ENSURE(r1->contains_fact(f77));        r2->add_fact(f79);        r3->add_fact(f99);        r2->display( std::cout << "r2 0/n");        scoped_rel<relation_base> r4 = r2->clone();        r2->display( std::cout << "r2 1/n");        r4->display( std::cout << "r4 0/n");        ENSURE(!r4->contains_fact(f77));        ENSURE(r4->contains_fact(f79));        r4->add_fact(f77);        r4->display( std::cout << "r4 1/n");        ENSURE(r4->contains_fact(f77));        ENSURE(r4->contains_fact(f79));        r4->add_fact(f99);        r4->display( std::cout << "r4 2/n");        ENSURE(r4->contains_fact(f99));        std::cout << "------ testing union ------/n";        r2->display( std::cout << "r2/n");        scoped_ptr<relation_union_fn> union_op = rmgr.mk_union_fn(*r1, *r2, r3.get());        ENSURE(union_op);        (*union_op)(*r1, *r2, r3.get());        r1->display( std::cout << "r1/n");        r2->display( std::cout << "r2/n");        r3->display( std::cout << "r3/n");        ENSURE(r1->contains_fact(f77));        ENSURE(r1->contains_fact(f79));        ENSURE(!r1->contains_fact(f99));//.........这里部分代码省略.........
开发者ID:NikolajBjorner,项目名称:z3,代码行数:101,


示例21: PROFILE

void SimRender::InterpolatePointsRNS(std::vector<CVector2D>& points, bool closed, float offset, int segmentSamples /* = 4 */){	PROFILE("InterpolatePointsRNS");	ENSURE(segmentSamples > 0);	std::vector<CVector2D> newPoints;	// (This does some redundant computations for adjacent vertices,	// but it's fairly fast (<1ms typically) so we don't worry about it yet)	// TODO: Instead of doing a fixed number of line segments between each	// control point, it should probably be somewhat adaptive to get a nicer	// curve with fewer points	size_t n = points.size();	if (closed)	{		if (n < 1)			return; // we need at least a single point to not crash	}	else	{		if (n < 2)			return; // in non-closed mode, we need at least n=2 to not crash	}	size_t imax = closed ? n : n-1;	newPoints.reserve(imax*segmentSamples);	// these are primarily used inside the loop, but for open paths we need them outside the loop once to compute the last point	CVector2D a0;	CVector2D a1;	CVector2D a2;	CVector2D a3;	for (size_t i = 0; i < imax; ++i)	{		// Get the relevant points for this spline segment; each step interpolates the segment between p1 and p2; p0 and p3 are the points		// before p1 and after p2, respectively; they're needed to compute tangents and whatnot.		CVector2D p0; // normally points[(i-1+n)%n], but it's a bit more complicated due to open/closed paths -- see below		CVector2D p1 = points[i];		CVector2D p2 = points[(i+1)%n];		CVector2D p3; // normally points[(i+2)%n], but it's a bit more complicated due to open/closed paths -- see below		if (!closed && (i == 0))			// p0's point index is out of bounds, and we can't wrap around because we're in non-closed mode -- create an artificial point			// that extends p1 -> p0 (i.e. the first segment's direction)			p0 = points[0] + (points[0] - points[1]);		else			// standard wrap-around case			p0 = points[(i-1+n)%n]; // careful; don't use (i-1)%n here, as the result is machine-dependent for negative operands (e.g. if i==0, the result could be either -1 or n-1)		if (!closed && (i == n-2))			// p3's point index is out of bounds; create an artificial point that extends p_(n-2) -> p_(n-1) (i.e. the last segment's direction)			// (note that p2's index should not be out of bounds, because in non-closed mode imax is reduced by 1)			p3 = points[n-1] + (points[n-1] - points[n-2]);		else			// standard wrap-around case			p3 = points[(i+2)%n];		// Do the RNS computation (based on GPG4 "Nonuniform Splines")		float l1 = (p2 - p1).Length(); // length of spline segment (i)..(i+1)		CVector2D s0 = (p1 - p0).Normalized(); // unit vector of spline segment (i-1)..(i)		CVector2D s1 = (p2 - p1).Normalized(); // unit vector of spline segment (i)..(i+1)		CVector2D s2 = (p3 - p2).Normalized(); // unit vector of spline segment (i+1)..(i+2)		CVector2D v1 = (s0 + s1).Normalized() * l1; // spline velocity at i		CVector2D v2 = (s1 + s2).Normalized() * l1; // spline velocity at i+1		// Compute standard cubic spline parameters		a0 = p1*2 + p2*-2 + v1 + v2;		a1 = p1*-3 + p2*3 + v1*-2 + v2*-1;		a2 = v1;		a3 = p1;		// Interpolate at regular points across the interval		for (int sample = 0; sample < segmentSamples; sample++)			newPoints.push_back(EvaluateSpline(sample/((float) segmentSamples), a0, a1, a2, a3, offset));	}	if (!closed)		// if the path is open, we should take care to include the last control point		// NOTE: we can't just do push_back(points[n-1]) here because that ignores the offset		newPoints.push_back(EvaluateSpline(1.f, a0, a1, a2, a3, offset));	points.swap(newPoints);}
开发者ID:2asoft,项目名称:0ad,代码行数:90,


示例22: GetTilesPerSide

	virtual u16 GetTilesPerSide()	{		ssize_t tiles = m_Terrain->GetTilesPerSide();		ENSURE(1 <= tiles && tiles <= 65535);		return (u16)tiles;	}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:6,



注:本文中的ENSURE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ENSURES函数代码示例
C++ ENQUEUE函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。