StringBase& SetData(const wchar_t* lpData, size_t nLength) { if ( !lpData || !nLength ) { FreeData(); SetEmpty(); } else { size_t nSize = Traits::GetUnicodeDataLength(lpData, nLength, m_nEncoding); if ( m_pData && m_pData->Unique() && (nSize < m_pData->GetSize()) ) { Traits::CopyUnicodeData(m_pData->GetData(), nSize, lpData, nLength, m_nEncoding); m_pData->SetLength(nLength); } else { StringData<T>* pNewData = new StringData<T>(nSize+1); Traits::CopyUnicodeData(pNewData->GetData(), nSize, lpData, nLength, m_nEncoding); pNewData->SetLength(nLength); FreeData(); m_pData = pNewData; } } return *this; }
const CDynamicArray & CDynamicArray::operator =(const CDynamicArray &array) { PARRAY_CHAIN pCur,pAdd,pTail=NULL;//The pointer of array chain SetEmpty(); m_nCol=array.m_nCol; m_nRow=array.m_nRow; pCur=array.m_pHead; while(pCur!=NULL) { pAdd=(PARRAY_CHAIN)malloc(sizeof(ARRAY_CHAIN));//malloc a new node memset(pAdd,0,sizeof(ARRAY_CHAIN)); pAdd->col=pCur->col;//get the value pAdd->row=pCur->row; pAdd->value=pCur->value; pAdd->nPOS=pCur->nPOS; pAdd->next=NULL; pAdd->sWord=NULL; if(pCur->nWordLen>=0) { pAdd->nWordLen=pCur->nWordLen; pAdd->sWord=new char[pAdd->nWordLen+1]; strcpy(pAdd->sWord,pCur->sWord); } if(pTail==NULL) m_pHead=pAdd;//The head element else pTail->next=pAdd; pTail=pAdd; pCur=pCur->next; } return *this; }
StringBase& SetData(const char* lpData, size_t nLength, int nCodePage = CP_OEMCP) { m_nEncoding = nCodePage; if ( !lpData || !nLength ) { FreeData(); SetEmpty(); } else { size_t nSize = Traits::GetAnsiDataLength(lpData, nLength, m_nEncoding); if ( m_pData && m_pData->Unique() && (nSize < m_pData->GetSize()) ) { Traits::CopyAnsiData(m_pData->GetData(), nSize, lpData, nLength, m_nEncoding); m_pData->SetLength(nLength); } else { StringData<T>* pNewData = new StringData<T>(nSize+1); Traits::CopyAnsiData(pNewData->GetData(), nSize, lpData, nLength, m_nEncoding); pNewData->SetLength(nLength); FreeData(); m_pData = pNewData; } } return *this; }
AsciiStringBase& SetData(const wchar_t* lpData, size_t nLength) { if ( !lpData || !nLength ) { FreeData(); SetEmpty(); } else { size_t nSize = WideCharToMultiByte(m_nEncoding, 0, lpData, nLength, 0, 0, 0, 0); if ( m_pData && m_pData->Unique() && (nSize < m_pData->GetSize()) ) { WideCharToMultiByte(m_nEncoding, 0, lpData, nLength, m_pData->GetData(), nSize, 0, 0); m_pData->SetLength(nSize); } else { StringData<char>* pNewData = new StringData<char>(nSize+1); WideCharToMultiByte(m_nEncoding, 0, lpData, nLength, pNewData->GetData(), nSize, 0, 0); pNewData->SetLength(nSize); FreeData(); m_pData = pNewData; } } return *this; }
void CLevelsCtrl::CalcLevels() { if (m_View->GetHistogram(m_Sample, m_MaxSamp)) Invalidate(); else SetEmpty(); }
SLS_tpReturnCode SLS_SimpleList :: DeleteCurrentElement( ) { if ( pCurrentElement == NULL ) { return SLS_ReturnCodeNoCurrent ; } /* if */ SLS_ListElement * pTemp = pCurrentElement ; numElements -- ; // Delete towards predecessor if ( pCurrentElement->pPredecessor != NULL ) { pCurrentElement->pPredecessor->pSuccessor = pCurrentElement->pSuccessor ; if ( pCurrentElement->pSuccessor != NULL ) { pCurrentElement->pSuccessor->pPredecessor = pCurrentElement->pPredecessor ; } /* if */ pCurrentElement = pCurrentElement->pPredecessor ; if ( pCurrentElement->pSuccessor == NULL ) { pLastElement = pCurrentElement ; } /* if */ } // end selection: Delete towards predecessor // Delete towards successor else if ( pCurrentElement->pSuccessor != NULL ) { pCurrentElement = pCurrentElement->pSuccessor ; pCurrentElement->pPredecessor = NULL ; pFirstElement = pCurrentElement ; } // end selection: Delete towards successor // Delete single element else { SetEmpty( ) ; } // end selection: Delete single element pTemp->pPredecessor = NULL ; pTemp->pSuccessor = NULL ; delete pTemp ; return SLS_ReturnCodeOK ; } // End of function: SLS !Delete current element
void nsRegion::SimplifyInward (uint32_t aMaxRects) { NS_ASSERTION(aMaxRects >= 1, "Invalid max rect count"); if (GetNumRects() <= aMaxRects) return; SetEmpty(); }
void SIO_SequentialIO :: CloseSequentialFile( ) { if ( pSequentialFile != NULL ) { fclose( pSequentialFile ) ; } /* if */ SetEmpty( ) ; } // End of function: SIO !Close sequential file
void CLevelsCtrl::SetView(CFracticeView *View) { if (View == m_View) return; // nothing to do m_View = View; if (View != NULL) CalcLevels(); else SetEmpty(); }
bool WorkspaceBound::SetIntersection(const WorkspaceBound& a, const WorkspaceBound& b) { //cout<<"Setting intersection of "<<a<<" and "<<b<<endl; if(a.IsEmpty() || b.IsEmpty()) { SetEmpty(); return false; } if(a.balls.empty()) { *this = b; return true; } if(b.balls.empty()) { *this = a; return true; } HollowBall bounda,boundb; a.GetBounds(bounda); b.GetBounds(boundb); HollowBall isect; if(!BoundIntersection(bounda,boundb,isect)) { SetEmpty(); return false; } balls.resize(a.balls.size()+b.balls.size()); copy(a.balls.begin(),a.balls.end(),balls.begin()); copy(b.balls.begin(),b.balls.end(),balls.begin()+a.balls.size()); maxAngle=Max(a.maxAngle,b.maxAngle); RemoveRedundancies(); //cout<<"Result is "<<*this<<endl; return true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- Box3D::Box3D(void) { SetEmpty(); SetDrawFlags(0); m_TranslateMode = modeScale; m_vTranslationFixPoint.Init(); m_TranslateHandle.Init(); m_bEnableHandles = true; SetDrawColors(Options.colors.clrToolHandle, Options.colors.clrToolBlock); }
func Hit() { if(!GBackLiquid()) { for(var i=15; i>0; i--) { var iX=Sin(GetR(), RandomX(4,8)), iY=-Cos(GetR(), RandomX(4,8)), iXDir=GetWind()*30/100, iYDir=-Cos(GetR()+RandomX(-2,2), Random(7)); InsertMaterial(Material("Water"), iX, iY, iXDir, iYDir); } SetEmpty(); } }
//----------------------------------------------------------------------------- // Purpose: Handles the escape key in the 2D or 3D views. //----------------------------------------------------------------------------- void Clipper3D::OnEscape(void) { // If we're clipping, clear it if (!IsEmpty()) { SetEmpty(); m_pDocument->UpdateAllViews(NULL, MAPVIEW_UPDATE_DISPLAY); } else { g_pToolManager->SetTool(TOOL_POINTER); } }
void CppScanner::GetNext() { SetEmpty(); SkipWhitespace(); if (f.Get() == '/') { SkipComment(); SkipWhitespace(); } char ch = f.Get(); if (IsNumber(ch) || (ch == '+') || (ch == '-')) GetNumber(); else if (IsAlpha(ch)) GetName(); else if (ch == '(' || ch == ')' || ch == '<' || ch == '>' || ch == '=' || ch == ',' || ch == ';' || ch == '&') { type = CToken::DELIMITER; delimiter = ch; f.GetNext(); } else throw CPError(CPError::UNKNOWN_CHARACTER); }
inline void IASRect::Intersect(const ADMRect& a) { if (left < a.left) left = a.left; if (top < a.top) top = a.top; if (right > a.right) right = a.right; if (bottom > a.bottom) bottom = a.bottom; if (!Overlaps(a)) SetEmpty(); }
inline void IASRealRectCartesian::Intersect(const AIRealRect &a) { if (left < a.left) left = a.left; if (top > a.top) top = a.top; if (right > a.right) right = a.right; if (bottom < a.bottom) bottom = a.bottom; if (!Overlaps(a)) SetEmpty(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- Marker3D::Marker3D(void) { SetEmpty(); m_vecPos = vec3_origin; m_vecTranslatePos = vec3_origin; m_bLButtonDown = false; if (s_hcurEntity == NULL) { s_hcurEntity = LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDC_ENTITY)); } }
//----------------------------------------------------------------------------- // Purpose: Handles the escape key in the 2D or 3D views. //----------------------------------------------------------------------------- void Marker3D::OnEscape(void) { // // Cancel the object creation tool. // if (!IsEmpty()) { SetEmpty(); m_pDocument->ToolUpdateViews(CMapView2D::updEraseTool); } else { g_pToolManager->SetTool(TOOL_POINTER); } }
void SLS_SimpleList :: EmptyList( ) { SLS_ListElement * pNextElement = NULL ; while ( pFirstElement != NULL ) { pNextElement = pFirstElement->pSuccessor ; delete pFirstElement ; pFirstElement = pNextElement ; } /* while */ SetEmpty( ) ; } // End of function: SLS !Empty list
//----------------------------------------------------------------------------- // Purpose: constructor - initialize the clipper variables //----------------------------------------------------------------------------- Clipper3D::Clipper3D(void) { m_Mode = FRONT; ZeroVector( m_ClipPlane.normal ); m_ClipPlane.dist = 0.0f; ZeroVector( m_ClipPoints[0] ); ZeroVector( m_ClipPoints[1] ); m_ClipPointHit = -1; m_pOrigObjects = NULL; m_bLButtonDown = false; m_bDrawMeasurements = false; SetEmpty(); }
AsciiStringBase& SetData(const char* lpData, size_t nLength, int nSrcEncoding = SAME_ENCODING) { if ( nSrcEncoding == SAME_ENCODING ) nSrcEncoding = m_nEncoding; if ( !lpData || !nLength ) { FreeData(); SetEmpty(); } else { char* pBuffer = nullptr; size_t nBufferSize = 0; bool bConverted = ConvertEncoding(lpData, nLength, &pBuffer, &nBufferSize, nSrcEncoding, m_nEncoding); if ( !bConverted ) { pBuffer = (char*)lpData; nBufferSize = nLength; } if ( m_pData && m_pData->Unique() && (nBufferSize < m_pData->GetSize()) ) { memmove(m_pData->GetData(), pBuffer, nBufferSize); m_pData->SetLength(nBufferSize); } else { StringData<char>* pNewData = new StringData<char>(nBufferSize+1); memmove(pNewData->GetData(), pBuffer, nBufferSize); pNewData->SetLength(nBufferSize); FreeData(); m_pData = pNewData; } if ( bConverted ) delete [] pBuffer; } return *this; }
void WorkspaceBound::SetMinkowskiSum(const WorkspaceBound& a,const WorkspaceBound& b) { if(a.IsEmpty() || b.IsEmpty()) { cerr<<"Warning, minkowski sum is empty"<<endl; SetEmpty(); return; } HollowBall bb; b.GetBounds(bb); balls.resize(a.balls.size()); for(size_t i=0;i<a.balls.size();i++) { Real r = bb.center.norm() + bb.outerRadius; balls[i].center = a.balls[i].center; balls[i].outerRadius = a.balls[i].outerRadius + r; balls[i].innerRadius = a.balls[i].innerRadius - r; } maxAngle = a.maxAngle + b.maxAngle; }
CBoundingBoxOriented::CBoundingBoxOriented(const CBoundingBoxAligned& bound) { if (bound.IsEmpty()) { SetEmpty(); } else { bound.GetCentre(m_Center); // the axes of an AABB are the world-space axes m_Basis[0].X = 1.f; m_Basis[0].Y = 0.f; m_Basis[0].Z = 0.f; m_Basis[1].X = 0.f; m_Basis[1].Y = 1.f; m_Basis[1].Z = 0.f; m_Basis[2].X = 0.f; m_Basis[2].Y = 0.f; m_Basis[2].Z = 1.f; // element-wise division by two to get half sizes (remember, [1] and [0] are the max and min coord points) m_HalfSizes = (bound[1] - bound[0]) * 0.5f; } }
inline void IASRealRectCartesian::Intersect(const AIRealRect &a, const AIRealRect &b) { if (b.left < a.left) left = a.left; else left = b.left; if (b.top > a.top) top = a.top; else top = b.top; if (b.right > a.right) top = a.right; else top = b.right; if (b.bottom < a.bottom) bottom = a.bottom; else bottom = b.bottom; if (!Overlaps(a)) SetEmpty(); }
inline void IASRect::Intersect(const ADMRect& a, const ADMRect& b) { if (b.left < a.left) left = a.left; else left = b.left; if (b.top < a.top) top = a.top; else top = b.top; if (b.right > a.right) right = a.right; else right = b.right; if (b.bottom > a.bottom) bottom = a.bottom; else bottom = b.bottom; if (!Overlaps(a)) SetEmpty(); }
KBBox::KBBox(const KTriVertPos2& tri) { SetEmpty(); for (int i = 0; i < 3; ++i) ContainVert(tri.mVertPos[i]); if (tri.mIsMoving) { for (int i = 0; i < 3; ++i) ContainVert(tri.mVertPos[i] + tri.mVertPos_Delta[i]); } KVec3 diagnal(mMax - mMin); float len = nvmath::length(diagnal); // We need to be carefully to tweak this value to avoid precision issue float epsilon = len * 0.0001f; for (int i = 0; i < 3; ++i) { if (fabs(mMax[i] - mMin[i]) < epsilon) { mMin[i] -= 2*epsilon; mMax[i] += 2*epsilon; break; } } }
bool WorkspaceBound::SetIntersection(const WorkspaceBound& a, const WorkspaceBound& b) { if(a.IsEmpty() || b.IsEmpty()) { SetEmpty(); return false; } Sphere3D sa,sb; Circle3D c; sa.center = a.center; sa.radius = a.outerRadius; sb.center = b.center; sb.radius = b.outerRadius; int res = BallBallIntersection(sa,sb,c); Real solidAngle = Min(a.maxAngle*a.outerRadius,b.maxAngle*b.outerRadius); if(res==2) { //it's a circle Assert(c.radius <= a.outerRadius+Epsilon && c.radius <= b.outerRadius+Epsilon); if(!sa.contains(c.center) || !sb.contains(c.center)) { cout<<"Uh... circle intersection of balls isn't contained in them"<<endl; cout<<sa.center<<" r "<<sa.radius<<endl; cout<<sb.center<<" r "<<sb.radius<<endl; cout<<"Center "<<c.center<<" radius "<<c.radius<<endl; getchar(); } Assert(sa.contains(c.center)); Assert(sb.contains(c.center)); //If a and b lie on opposite sides of c's plane, //use the sphere that contains c. //Otherwise, the smallest circle that contains the intersection //is the smaller of a and b Real offset=c.axis.dot(c.center); if(Sign(c.axis.dot(a.center)-offset) == Sign(c.axis.dot(b.center)-offset)) { //on same side of plane if(b.outerRadius < a.outerRadius) res=4; else res=3; } } switch(res) { case 0: center = Half*(a.center + b.center); outerRadius=0; innerRadius=-(a.center-b.center).norm(); maxAngle=-Inf; break; case 1: //point case 2: //circle center=c.center; outerRadius=c.radius; innerRadius=0; //TODO: find this? //get the maxAngle that gives the right solid angle if(solidAngle >= outerRadius*TwoPi) maxAngle = TwoPi; else maxAngle = solidAngle/outerRadius; break; case 3: //a completely contained within b Assert(a.outerRadius <= b.outerRadius); operator = (a); if(solidAngle < maxAngle*outerRadius) maxAngle = solidAngle / outerRadius; break; case 4: //b contained completely in a Assert(a.outerRadius >= b.outerRadius); operator = (b); if(solidAngle < maxAngle*outerRadius) maxAngle = solidAngle / outerRadius; break; } return true; }
StringBase() { SetEmpty(); }
SLS_SimpleList :: SLS_SimpleList( ) { SetEmpty( ) ; } // End of function: SLS !List constructor
KBBox::KBBox() { SetEmpty(); }