Woolz Image Processing Version 1.4.0
AlcVector

Data Structures

struct  _AlcVector
 An extensible 1D array. Typedef: AlcVector. More...

Files

file  AlcVector.c
 

A general purpose 1D vector (extensible array).


Functions

AlcVectorAlcVectorNew (size_t elmCnt, size_t elmSz, size_t blkSz, AlcErrno *dstErr)
 Creates a new 1D vector (extensible array) with the required element size and initial number of elements. Vector elements are initialised by setting all bytes to zero.
AlcErrno AlcVectorFree (AlcVector *vec)
 Free's the given vector.
AlcErrno AlcVectorExtend (AlcVector *vec, size_t elmCnt)
 Extend the vector for at least the given number of elements.
void * AlcVectorItemGet (AlcVector *vec, size_t idx)
 Gets a pointer to the vector item with the given index.
void * AlcVectorExtendAndGet (AlcVector *vec, size_t idx)
 Extends the vector and gets the vector item with the given index.
size_t AlcVectorCount (AlcVector *vec)
 Gets the number of elements that the vector can hold before it needs to be extended.
void AlcVectorSetArray1D (AlcVector *vec, size_t fIdx, size_t lIdx, void *aM)
 Copies elements from the vector into a 1 dimensional array.
void * AlcVectorToArray1D (AlcVector *vec, size_t fIdx, size_t lIdx, AlcErrno *dstErr)
 Creates a 1 dimensional array which contains a copy of the vectors elements.
void ** AlcVectorToArray2D (AlcVector *vec, size_t nR, size_t nC, AlcErrno *dstErr)
 Creates a 2 dimensional array which contains a copy of the vectors elements.
AlcVectorAlcVecReadDouble1Asci (FILE *fP, const char *fSep, size_t recMax, size_t *dstNV, AlcErrno *dstErr)
 Reads a 1D double array from the given numeric ASCI file. Each value should be on a seperate line.
AlcVectorAlcVecReadDouble2Asci (FILE *fP, const char *fSep, size_t recMax, size_t *dstNR, size_t *dstNC, AlcErrno *dstErr)
 Reads a 2D double array from the given numeric ASCI file into an extensible vector. The number of fields per record must be the same for all records.

Function Documentation

AlcVector* AlcVectorNew ( size_t  elmCnt,
size_t  elmSz,
size_t  blkSz,
AlcErrno dstErr 
)

Creates a new 1D vector (extensible array) with the required element size and initial number of elements. Vector elements are initialised by setting all bytes to zero.

Returns:
New vector, or NULL on error.
Parameters:
elmCntInitial number of elements.
elmSzSize of elements.
blkSzNumber of elements per block, also minimum initial number of blocks allocated. If blkSz <= 0 then a default a defualt value is used.
dstErrDestination pointer for error code, may be NULL.

References ALC_ER_ALLOC, ALC_ER_NONE, ALC_ER_PARAM, AlcCalloc(), AlcFree(), AlcFreeStackPush(), _AlcVector::blkCnt, _AlcVector::blkSz, _AlcVector::blkUse, _AlcVector::blocks, _AlcVector::elmSz, and _AlcVector::freeStack.

Referenced by AlcVecReadDouble1Asci(), AlcVecReadDouble2Asci(), WlzCMeshCopy2D(), WlzCMeshCopy2D5(), WlzCMeshCopy3D(), WlzCMeshNew2D(), WlzCMeshNew2D5(), WlzCMeshNew3D(), WlzEffReadObjObj(), WlzGeoModelGridWSpSet3D(), WlzGMModelFindNMEdges(), WlzGMModelNew(), and WlzMakeIndexedValues().

AlcErrno AlcVectorExtend ( AlcVector vec,
size_t  elmCnt 
)

Extend the vector for at least the given number of elements.

Returns:
Error code.
Parameters:
vecVector to extend.
elmCntRequired number of elements.

References ALC_ER_ALLOC, ALC_ER_NONE, AlcCalloc(), AlcFree(), AlcFreeStackPush(), _AlcVector::blkCnt, _AlcVector::blkSz, _AlcVector::blkUse, _AlcVector::blocks, _AlcVector::elmSz, and _AlcVector::freeStack.

Referenced by AlcVectorExtendAndGet(), WlzCMeshCopy2D(), WlzCMeshCopy2D5(), WlzCMeshCopy3D(), and WlzCMeshIntersect2Mesh2D().

void* AlcVectorItemGet ( AlcVector vec,
size_t  idx 
)

Gets a pointer to the vector item with the given index.

Returns:
Vector item, or NULL on error.
Parameters:
vecVector to extend.
idxGiven item index.

References _AlcVector::blkSz, _AlcVector::blkUse, _AlcVector::blocks, and _AlcVector::elmSz.

Referenced by AlgMatrixReadAscii(), WlzAffineTransformGMModel(), WlzBasisFnSetCMesh2D(), WlzBasisFnSetCMesh3D(), WlzBasisFnTransformGMModel(), WlzCMeshAffineTransformMesh2D(), WlzCMeshAffineTransformMesh2D5(), WlzCMeshAffineTransformMesh3D(), WlzCMeshBoundConform2D(), WlzCMeshBoundConform3D(), WlzCMeshClearElmFlags2D(), WlzCMeshClearElmFlags3D(), WlzCMeshClearNodFlags2D(), WlzCMeshClearNodFlags3D(), WlzCMeshClosePointDom2D5(), WlzCMeshCmpElmFeat2D(), WlzCMeshCmpElmFeat3D(), WlzCMeshCompSurfMapIdx(), WlzCMeshCompSurfMapToCircle(), WlzCMeshComputeCurvaturesFromNodNorm(), WlzCMeshComputeNormalsElm(), WlzCMeshComputeNormalsIxv2D5(), WlzCMeshComputeNormalsNod(), WlzCMeshCopy2D(), WlzCMeshCopy2D5(), WlzCMeshCopy3D(), WlzCMeshCountBoundNodes2D(), WlzCMeshCountBoundNodes2D5(), WlzCMeshCountBoundNodes3D(), WlzCMeshCurvToImage(), WlzCMeshDbgOutVTK2D(), WlzCMeshDbgOutVTK3D(), WlzCMeshDelUnusedNodes2D(), WlzCMeshDelUnusedNodes2D5(), WlzCMeshDelUnusedNodes3D(), WlzCMeshExtract2D(), WlzCMeshFixNegativeElms2D(), WlzCMeshFixNegativeElms3D(), WlzCMeshFlatten2D5(), WlzCMeshFMarNodes2D(), WlzCMeshFMarNodes3D(), WlzCMeshFromGM(), WlzCMeshGetBoundNodes2D(), WlzCMeshGetBoundNodes2D5(), WlzCMeshGetBoundNodes3D(), WlzCMeshGetNodesAndEdges(), WlzCMeshIntersect2Mesh2D(), WlzCMeshIntersectDom2D5(), WlzCMeshLaplacianSmooth2D(), WlzCMeshLaplacianSmooth3D(), WlzCMeshMeshMeshProduct(), WlzCMeshNextElm2D(), WlzCMeshNextElm3D(), WlzCMeshNextNod2D(), WlzCMeshNextNod3D(), WlzCMeshReassignGridCells2D(), WlzCMeshReassignGridCells2D5(), WlzCMeshReassignGridCells3D(), WlzCMeshSetBoundElmFlags2D(), WlzCMeshSetBoundElmFlags3D(), WlzCMeshSetBoundNodFlags2D(), WlzCMeshSetBoundNodFlags2D5(), WlzCMeshSetBoundNodFlags3D(), WlzCMeshSetElmIdxTbl2D(), WlzCMeshSetElmIdxTbl2D5(), WlzCMeshSetElmIdxTbl3D(), WlzCMeshSetNodFlags2D(), WlzCMeshSetNodFlags3D(), WlzCMeshSetNodIdxTbl2D(), WlzCMeshSetNodIdxTbl2D5(), WlzCMeshSetNodIdxTbl3D(), WlzCMeshSetVertices2D(), WlzCMeshSetVertices3D(), WlzCMeshTransformGetBBox2D(), WlzCMeshTransformGetBBox3D(), WlzCMeshUpdateBBox2D(), WlzCMeshUpdateBBox2D5(), WlzCMeshUpdateBBox3D(), WlzCMeshUpdateMaxSqEdgLen2D(), WlzCMeshUpdateMaxSqEdgLen2D5(), WlzCMeshUpdateMaxSqEdgLen3D(), WlzCMeshVerify2D(), WlzCMeshVerify3D(), WlzEffReadObjEMT(), WlzEffReadObjMesh(), WlzEffReadObjNodeEle(), WlzEffReadObjObj(), WlzEffReadObjVMesh(), WlzEffWriteObjEMT(), WlzEffWriteObjMesh(), WlzEffWriteObjNodeEle(), WlzEffWriteObjVMesh(), WlzGeoModelGridWSpSet3D(), WlzGMFilterFlipOrient(), WlzGMModelCopy(), WlzGMModelFindNMEdges(), WlzGMModelRehashVHT(), WlzGMModelResIdx(), WlzGMModelSetSG(), WlzGMModelSpxStats(), WlzIndexedValueGet(), and WlzIndexedValuesSet().

size_t AlcVectorCount ( AlcVector vec)

Gets the number of elements that the vector can hold before it needs to be extended.

Returns:
Number of elements in vector.
Parameters:
vecVector to extend.

References _AlcVector::blkSz, and _AlcVector::blkUse.

void AlcVectorSetArray1D ( AlcVector vec,
size_t  fIdx,
size_t  lIdx,
void *  aM 
)

Copies elements from the vector into a 1 dimensional array.

Returns:
void
Parameters:
vecGiven vector.
fIdxIndex of the first element in the vector to copy.
lIdxIndex of the last element in the vector to copy.
aMThe 1 dimensional array.

References _AlcVector::blkSz, _AlcVector::blocks, and _AlcVector::elmSz.

Referenced by AlcVectorToArray1D(), AlcVectorToArray2D(), and AlgMatrixReadAscii().

void* AlcVectorToArray1D ( AlcVector vec,
size_t  fIdx,
size_t  lIdx,
AlcErrno dstErr 
)

Creates a 1 dimensional array which contains a copy of the vectors elements.

Returns:
Array of copied elements.
Parameters:
vecGiven vector.
fIdxIndex of the first element in the vector to copy, becomes the first element of the array.
lIdxIndex of the last element in the vector to copy, becomes the last element of the array.
dstErrDestination pointer for error code, may be NULL.

References ALC_ER_ALLOC, ALC_ER_NONE, ALC_ER_NULLPTR, ALC_ER_PARAM, AlcCalloc(), AlcVectorSetArray1D(), and _AlcVector::elmSz.

Referenced by AlcDouble1ReadAsci().

void** AlcVectorToArray2D ( AlcVector vec,
size_t  nR,
size_t  nC,
AlcErrno dstErr 
)

Creates a 2 dimensional array which contains a copy of the vectors elements.

Returns:
Array of copied elements.
Parameters:
vecGiven vector.
nRNumber of rows (1D arrays).
nCNumber of columns (elements in each 1D array).
dstErrDestination pointer for error code, may be NULL.

References ALC_ER_NONE, ALC_ER_NULLPTR, ALC_ER_PARAM, AlcCalloc(), AlcFree(), AlcMalloc(), AlcVectorSetArray1D(), and _AlcVector::elmSz.

Referenced by AlcDouble2ReadAsci(), and AlgMatrixReadAscii().

AlcVector* AlcVecReadDouble1Asci ( FILE *  fP,
const char *  fSep,
size_t  recMax,
size_t *  dstNV,
AlcErrno dstErr 
)

Reads a 1D double array from the given numeric ASCI file. Each value should be on a seperate line.

Returns:
Extensible vector containing values for a 1D array or NULL on error.
Parameters:
fP,:File pointer.
fsField seperator chracter string. If NULL whitespace assumed.
recMaxMaximum record length.
dstNVDestination pointer for the number of vector values. Must not be NULL.
dstErrDestination error pointer, may be NULL.

References ALC_ER_ALLOC, ALC_ER_NONE, ALC_ER_READ, AlcFree(), AlcMalloc(), AlcVectorExtendAndGet(), AlcVectorFree(), and AlcVectorNew().

Referenced by AlcDouble1ReadAsci().

AlcVector* AlcVecReadDouble2Asci ( FILE *  fP,
const char *  fSep,
size_t  recMax,
size_t *  dstNR,
size_t *  dstNC,
AlcErrno dstErr 
)

Reads a 2D double array from the given numeric ASCI file into an extensible vector. The number of fields per record must be the same for all records.

Returns:
Extensible vector containing values for a 2D array or NULL on error.
Parameters:
fP,:File pointer.
fsField seperator chracter string. If NULL whitespace assumed.
recMaxMaximum record length.
dstNRDestination pointer for the number of rows (records) read. Must not be NULL.
dstNCDestination pointer for the number of columns, ie the number of elements in each 1D array (number of fields per record). Must not be NULL.
dstErrDestination error pointer, may be NULL.

References ALC_ER_ALLOC, ALC_ER_NONE, ALC_ER_READ, AlcFree(), AlcMalloc(), AlcVectorExtendAndGet(), AlcVectorFree(), and AlcVectorNew().

Referenced by AlcDouble2ReadAsci(), and AlgMatrixReadAscii().