//--------------------------------------------------------- bool CSG_Formula::Set_Formula(const SG_Char *Formula) { if( Formula ) { m_sFormula = Formula; if( m_Formula.code ) { SG_Free(m_Formula.code); m_Formula.code = NULL; } if( m_Formula.ctable ) { SG_Free(m_Formula.ctable); m_Formula.ctable = NULL; } m_Formula = _Translate(Formula, SG_T("abcdefghijklmnopqrstxyz"), &m_Length, &m_Error_Position); return( m_Formula.code != NULL ); } return( false ); }
//--------------------------------------------------------- void CSG_Shapes_Search::Destroy(void) { if( m_nPoints > 0 ) { SG_Free(m_Pos); } m_Pos = NULL; m_Idx .Destroy(); //----------------------------------------------------- if( m_bDestroy && m_pPoints ) { delete(m_pPoints); } m_pPoints = NULL; m_nPoints = 0; m_bDestroy = false; //----------------------------------------------------- if( m_Selected ) { SG_Free(m_Selected); SG_Free(m_Selected_Dst); } m_Selected = NULL; m_Selected_Dst = NULL; m_nSelected = 0; m_Selected_Buf = 0; m_Selected_Idx .Destroy(); }
//--------------------------------------------------------- double CSG_Table_DBase::asDouble(int iField) { char *s; double Result = 0; if( bOpen && iField >= 0 && iField < nFields ) { if( FieldDesc[iField].Type == DBF_FT_NUMERIC ) { s = (char *)SG_Calloc(FieldDesc[iField].Width + 1, sizeof(char)); memcpy(s, Record + FieldOffset[iField], FieldDesc[iField].Width); Result = atof(s); SG_Free(s); } else if( FieldDesc[iField].Type == DBF_FT_DATE ) { s = (char *)SG_Calloc(FieldDesc[iField].Width + 1, sizeof(char)); memcpy(s, Record + FieldOffset[iField], FieldDesc[iField].Width); int d = atoi(s + 6); s[6] = '\0'; if( d < 1 ) d = 1; else if( d > 31 ) d = 31; int m = atoi(s + 4); s[4] = '\0'; if( m < 1 ) m = 1; else if( m > 12 ) m = 12; int y = atoi(s); Result = 10000 * y + 100 * m + 1 * d; SG_Free(s); } } return( Result ); }
//--------------------------------------------------------- // Closes DBase-File if one was opened... void CSG_Table_DBase::Close(void) { //----------------------------------------------------- if( bOpen ) { Flush_Record(); Header_Write(); bOpen = false; fclose(hFile); hFile = NULL; } //----------------------------------------------------- if( Record ) { SG_Free(Record); Record = NULL; } if( FieldOffset ) { SG_Free(FieldOffset); FieldOffset = NULL; } if( FieldDesc ) { SG_Free(FieldDesc); FieldDesc = NULL; } nFields = 0; if( Result_String ) { SG_Free(Result_String); Result_String = NULL; } //----------------------------------------------------- bModified = false; bRecModified = false; //----------------------------------------------------- FileType = 0; nRecords = 0; nHeaderBytes = 0; nRecordBytes = 0; Transaction = 0; bEncrypted = 0; ProductionIdx = 0; LanguageDrvID = 0; nFileBytes = 0; memset(LastUpdate, 0, 3 * sizeof(char)); }
void CPointsEx::Clear(void) { if( m_Points ) { SG_Free(m_Points); SG_Free(m_ClosestPts); } m_nPoints = 0; m_Points = NULL; m_ClosestPts = NULL; }
//--------------------------------------------------------- CSG_Formula::~CSG_Formula(void) { if( m_Formula.code ) { SG_Free(m_Formula.code); m_Formula.code = NULL; } if( m_Formula.ctable ) { SG_Free(m_Formula.ctable); m_Formula.ctable = NULL; } }
//--------------------------------------------------------- void CSG_Regression::Destroy(void) { if( m_nBuffer > 0 ) { SG_Free(m_x); SG_Free(m_y); m_nBuffer = 0; } m_nValues = 0; m_x = NULL; m_y = NULL; }
//--------------------------------------------------------- int CSG_PointCloud::Del_Selection(void) { if( m_nSelected <= 0 ) { return( 0 ); } //----------------------------------------------------- int i, n; m_Array_Selected.Set_Array(0, (void **)&m_Selected); m_nSelected = 0; m_Cursor = NULL; for(i=0, n=0; i<m_nRecords; i++) { if( (m_Points[i][0] & SG_TABLE_REC_FLAG_Selected) != 0 ) { SG_Free(m_Points[i]); } else { if( n < i ) { m_Points[n] = m_Points[i]; } n++; } } m_Array_Points.Set_Array(m_nRecords = n, (void **)&m_Points); return( n ); }
//--------------------------------------------------------- bool CSG_Points_Z::Del(int Index) { if( Index >= 0 && Index < m_nPoints ) { m_nPoints--; if( m_nPoints > 0 ) { for(TSG_Point_Z *A=m_Points+Index, *B=m_Points+Index+1; Index<m_nPoints; Index++, A++, B++) { *A = *B; } m_Points = (TSG_Point_Z *)SG_Realloc(m_Points, m_nPoints * sizeof(TSG_Point_Z)); } else { SG_Free(m_Points); } return( true ); } return( false ); }
//--------------------------------------------------------- CVIEW_Table_Control::~CVIEW_Table_Control(void) { if( m_pRecords ) { SG_Free(m_pRecords); } }
//--------------------------------------------------------- void CCandidates::Destroy(void) { m_nCandidates = 0; if( m_Candidates ) { SG_Free(m_Candidates); m_Candidates = NULL; } if( m_pLow ) { delete(m_pLow); m_pLow = NULL; } if( m_pHigh ) { delete(m_pHigh); m_pHigh = NULL; } }
//--------------------------------------------------------- int CSG_PointCloud::Del_Selection(void) { int n = 0; if( Get_Selection_Count() > 0 ) { m_Selection.Set_Array(0); m_Cursor = NULL; for(int i=0; i<m_nRecords; i++) { if( (m_Points[i][0] & SG_TABLE_REC_FLAG_Selected) != 0 ) { SG_Free(m_Points[i]); } else { if( n < i ) { m_Points[n] = m_Points[i]; } n++; } } m_Array_Points.Set_Array(m_nRecords = n, (void **)&m_Points); } return( n ); }
bool CSG_Matrix::Destroy(void) { if( m_z ) { if( m_z[0] ) { SG_Free(m_z[0]); } SG_Free(m_z); } m_z = NULL; m_nx = 0; m_ny = 0; return( true ); }
//--------------------------------------------------------- void CFlow_RecursiveUp::On_Destroy(void) { int y; if( Flow ) { SG_Free(Flow[0][0]); for(y=0; y<Get_NY(); y++) { SG_Free(Flow[y]); } SG_Free(Flow); Flow = NULL; } }
//--------------------------------------------------------- void CSG_Points_Z::Clear(void) { if( m_Points ) { SG_Free(m_Points); } m_nBuffer = 0; m_nPoints = 0; m_Points = NULL; }
//--------------------------------------------------------- void CGrid_3D_Image::_Set_Grid(void) { T3DPoint *a, *b, *c, *d, p[3]; //----------------------------------------------------- a = (T3DPoint *)SG_Malloc(sizeof(T3DPoint) * Get_NX()); b = (T3DPoint *)SG_Malloc(sizeof(T3DPoint) * Get_NX()); c = (T3DPoint *)SG_Malloc(sizeof(T3DPoint) * (Get_NX() - 1)); //----------------------------------------------------- _Get_Line(0, b); for(int y=1; y<Get_NY() && Set_Progress(y); y++) { d = a; a = b; b = d; _Get_Line(y, b); _Get_Line(a, b, c); for(int ax=0, bx=1; bx<Get_NX(); ax++, bx++) { DRAW_TRIANGLE(a[ax], a[bx], c[ax]); DRAW_TRIANGLE(b[ax], b[bx], c[ax]); DRAW_TRIANGLE(a[ax], b[ax], c[ax]); DRAW_TRIANGLE(a[bx], b[bx], c[ax]); } } //----------------------------------------------------- SG_Free(a); SG_Free(b); SG_Free(c); //----------------------------------------------------- DataObject_Add(m_pRGB_Z); DataObject_Add(m_pRGB); DataObject_Set_Colors(m_pRGB, 100, SG_COLORS_BLACK_WHITE); }
//--------------------------------------------------------- void CSG_Grid_Radius::Destroy(void) { if( m_Points ) { SG_Free(m_Points); } if( m_nPoints_R ) { SG_Free(m_nPoints_R); } if( m_Points_R ) { SG_Free(m_Points_R); } m_maxRadius = 0; m_nPoints = 0; m_Points = NULL; m_nPoints_R = NULL; m_Points_R = NULL; }
size_t CSG_File::Read(CSG_String &Buffer, size_t Size) const { if( m_pStream ) { char *b = (char *)SG_Calloc(Size + 1, sizeof(char)); int i = fread(b, sizeof(char), Size, m_pStream); Buffer = b; SG_Free(b); return( i ); } return( 0 ); }
//--------------------------------------------------------- bool CSG_Matrix::Set_Inverse(bool bSilent, int nSubSquare) { bool bResult = false; int n = 0; //----------------------------------------------------- if( nSubSquare > 0 ) { if( nSubSquare <= m_nx && nSubSquare <= m_ny ) { n = nSubSquare; } } else if( is_Square() ) { n = m_nx; } //----------------------------------------------------- if( n > 0 ) { CSG_Matrix m(*this); int *Permutation = (int *)SG_Malloc(n * sizeof(int)); if( SG_Matrix_LU_Decomposition(n, Permutation, m.Get_Data(), bSilent) ) { CSG_Vector v(n); for(int j=0; j<n && (bSilent || SG_UI_Process_Set_Progress(j, n)); j++) { v.Set_Zero(); v[j] = 1.0; SG_Matrix_LU_Solve(n, Permutation, m, v.Get_Data(), true); for(int i=0; i<n; i++) { m_z[i][j] = v[i]; } } bResult = true; } SG_Free(Permutation); } return( bResult ); }
//--------------------------------------------------------- bool CSG_PointCloud::_Dec_Array(void) { if( m_nRecords > 0 ) { m_nRecords --; m_Cursor = NULL; SG_Free(m_Points[m_nRecords]); m_Array_Points.Set_Array(m_nRecords, (void **)&m_Points); } return( true ); }
//--------------------------------------------------------- void CSG_Strings::Clear(void) { if( m_Strings ) { for(int i=0; i<m_nStrings; i++) { delete(m_Strings[i]); } SG_Free(m_Strings); m_nStrings = 0; m_Strings = NULL; } }
//--------------------------------------------------------- void CSG_Translator::Destroy(void) { if( m_Translations ) { for(int i=0; i<m_nTranslations; i++) { delete(m_Translations[i]); } SG_Free(m_Translations); m_nTranslations = 0; m_Translations = NULL; } }
bool CSG_PointCloud::Destroy(void) { Del_Points(); if( m_nFields > 0 ) { for(int i=0; i<m_nFields; i++) { delete(m_Field_Name [i]); delete(m_Field_Stats[i]); } SG_Free(m_Field_Name); SG_Free(m_Field_Type); SG_Free(m_Field_Stats); SG_Free(m_Field_Offset); _On_Construction(); } CSG_Data_Object::Destroy(); return( true ); }
//--------------------------------------------------------- void CSG_Rects::Clear(void) { if( m_Rects ) { for(int i=0; i<m_nRects; i++) { delete(m_Rects[i]); } SG_Free(m_Rects); } m_nRects = 0; m_Rects = NULL; }
//--------------------------------------------------------- bool CWKSP_Data_Buttons::_Del_Items(void) { if( m_nItems > 0 ) { for(int i=0; i<m_nItems; i++) { delete(m_Items[i]); } SG_Free(m_Items); } m_Items = NULL; m_nItems = 0; return( true ); }
//--------------------------------------------------------- bool CSG_PointCloud::Del_Points(void) { for(int iPoint=0; iPoint<m_nRecords; iPoint++) { SG_Free(m_Points[iPoint]); } m_Array_Points.Destroy(); m_nRecords = 0; m_Points = NULL; m_Cursor = NULL; m_Selection.Set_Array(0); return( true ); }
//--------------------------------------------------------- bool CSG_Grid_Pyramid::Destroy(void) { if( m_pLevels ) { for(int i=0; i<m_nLevels; i++) { delete(m_pLevels[i]); } SG_Free(m_pLevels); m_nLevels = 0; m_pLevels = NULL; m_pGrid = NULL; } return( true ); }
//--------------------------------------------------------- int CSG_Table_DBase::asInt(int iField) { char *s; int Result = 0; if( bOpen && iField >= 0 && iField < nFields ) { if( FieldDesc[iField].Type == DBF_FT_NUMERIC ) { s = (char *)SG_Calloc(FieldDesc[iField].Width + 1, sizeof(char)); memcpy(s, Record + FieldOffset[iField], FieldDesc[iField].Width); Result = atoi(s); SG_Free(s); } } return( Result ); }
//--------------------------------------------------------- void CTIN_Flow_Parallel::Let_it_flow_multiple(CSG_TIN_Node *pPoint) { int i; double d, dzSum, *dz, Area; Area = pPoint->Get_Polygon_Area(); pPoint->Set_Value(m_iArea, Area); pPoint->Add_Value(m_iFlow, Area); if( pPoint->Get_Neighbor_Count() > 0 ) { dz = (double *)SG_Malloc(pPoint->Get_Neighbor_Count() * sizeof(double)); for(i=0, dzSum=0.0; i<pPoint->Get_Neighbor_Count(); i++) { if( (d = pPoint->Get_Gradient(i, m_iHeight)) > 0.0 ) { dzSum += (dz[i] = d); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { d = pPoint->asDouble(m_iFlow); for(i=0; i<pPoint->Get_Neighbor_Count(); i++) { if( dz[i] > 0.0 ) { pPoint->Get_Neighbor(i)->Add_Value( m_iFlow, d * dz[i] / dzSum); } } } SG_Free(dz); } pPoint->Set_Value(m_iSpecific, Area > 0.0 ? 1.0 / Area : -1.0); }
//--------------------------------------------------------- void CCandidates::Add(int x, int y, int Segment, double Similarity) { if( m_Candidates && m_nCandidates < m_nMax ) { int iInsert = _Find(Similarity); memmove(m_Candidates + iInsert + 1, m_Candidates + iInsert, sizeof(TCandidate) * (m_nCandidates - iInsert)); m_Candidates[iInsert].x = x; m_Candidates[iInsert].y = y; m_Candidates[iInsert].Segment = Segment; m_Candidates[iInsert].Similarity = Similarity; } else { if( !m_pLow ) { int iDivide = m_nMax / 2; m_pLow = new CCandidates(m_nMax); m_pHigh = new CCandidates(m_nMax); m_pLow ->m_nCandidates = iDivide; m_pHigh->m_nCandidates = m_nMax - iDivide; memcpy(m_pLow ->m_Candidates, m_Candidates , m_pLow ->m_nCandidates * sizeof(TCandidate)); memcpy(m_pHigh->m_Candidates, m_Candidates + m_pLow->m_nCandidates, m_pHigh->m_nCandidates * sizeof(TCandidate)); SG_Free(m_Candidates); m_Candidates = NULL; } if( Similarity > m_pHigh->Get_Minimum() ) { m_pHigh->Add(x, y, Segment, Similarity); } else { m_pLow ->Add(x, y, Segment, Similarity); } } m_nCandidates++; }