Woolz Image Processing  Version 1.8.3
AlcVector

Files

file  AlcVector.c
 A general purpose 1D vector (extensible array).
 

Data Structures

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

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. More...
 
AlcErrno AlcVectorFree (AlcVector *vec)
 Free's the given vector. More...
 
AlcErrno AlcVectorExtend (AlcVector *vec, size_t elmCnt)
 Extend the vector for at least the given number of elements. More...
 
void * AlcVectorItemGet (AlcVector *vec, size_t idx)
 Gets a pointer to the vector item with the given index. More...
 
void * AlcVectorExtendAndGet (AlcVector *vec, size_t idx)
 Extends the vector and gets the vector item with the given index. More...
 
size_t AlcVectorCount (AlcVector *vec)
 Gets the number of elements that the vector can hold before it needs to be extended. More...
 
void AlcVectorSetArray1D (AlcVector *vec, size_t fIdx, size_t lIdx, void *aM)
 Copies elements from the vector into a 1 dimensional array. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Function Documentation

◆ AlcVectorNew()

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(), WlzCopyIndexedValues(), WlzEffReadObjObj(), WlzGeoModelGridWSpSet3D(), WlzGMModelFindNMEdges(), WlzGMModelNew(), WlzMakeIndexedValues(), and WlzPointsFromDomObj().

◆ AlcVectorFree()

◆ AlcVectorExtend()

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(), WlzCMeshIntersect2Mesh2D(), WlzExtendIndexedValues(), and WlzPointsFromDomObj().

◆ AlcVectorItemGet()

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(), WlzCMeshCompSurfMapToDomain(), WlzCMeshComputeCurvaturesFromNodNorm(), WlzCMeshComputeNormalsElm(), WlzCMeshComputeNormalsIxv2D5(), WlzCMeshComputeNormalsNod(), WlzCMeshCopy2D(), WlzCMeshCopy2D5(), WlzCMeshCopy3D(), WlzCMeshCountBoundNodes2D(), WlzCMeshCountBoundNodes2D5(), WlzCMeshCountBoundNodes3D(), WlzCMeshCurvToImage(), WlzCMeshDbgOutVTK2D(), WlzCMeshDbgOutVTK3D(), WlzCMeshDelUnusedNodes2D(), WlzCMeshDelUnusedNodes2D5(), WlzCMeshDelUnusedNodes3D(), WlzCMeshDispToField(), WlzCMeshExtract2D(), WlzCMeshFixNegativeElms2D(), WlzCMeshFixNegativeElms3D(), WlzCMeshFlatten2D5(), WlzCMeshFromGM(), WlzCMeshGetBoundNodes2D(), WlzCMeshGetBoundNodes2D5(), WlzCMeshGetBoundNodes3D(), WlzCMeshGetNodesAndEdges(), WlzCMeshIntersect2Mesh2D(), WlzCMeshIntersectDom2D5(), WlzCMeshLaplacianSmooth2D(), WlzCMeshLaplacianSmooth3D(), WlzCMeshMeshMeshProduct(), WlzCMeshNextElm2D(), WlzCMeshNextElm3D(), WlzCMeshNextNod2D(), WlzCMeshNextNod3D(), WlzCMeshSetBoundElmFlags2D(), WlzCMeshSetBoundElmFlags3D(), WlzCMeshSetBoundNodFlags2D(), WlzCMeshSetBoundNodFlags2D5(), WlzCMeshSetBoundNodFlags3D(), WlzCMeshSetDispFromField(), WlzCMeshSetElmIdxTbl2D(), WlzCMeshSetElmIdxTbl2D5(), WlzCMeshSetElmIdxTbl3D(), WlzCMeshSetNodFlags2D(), WlzCMeshSetNodFlags3D(), WlzCMeshSetNodIdxTbl2D(), WlzCMeshSetNodIdxTbl2D5(), WlzCMeshSetNodIdxTbl3D(), WlzCMeshSetVertices2D(), WlzCMeshSetVertices3D(), WlzCMeshTransformGetBBox2D(), WlzCMeshTransformGetBBox3D(), WlzCMeshTrRegSM3D(), WlzCMeshUpdateBBox2D(), WlzCMeshUpdateBBox2D5(), WlzCMeshUpdateBBox3D(), WlzCMeshUpdateMaxSqEdgLen2D(), WlzCMeshUpdateMaxSqEdgLen2D5(), WlzCMeshUpdateMaxSqEdgLen3D(), WlzCMeshVerify2D(), WlzCMeshVerify3D(), WlzEffWriteObjEMT(), WlzEffWriteObjMesh(), WlzEffWriteObjNodeEle(), WlzEffWriteObjVMesh(), WlzGeoModelGridWSpSet3D(), WlzGMFilterFlipOrient(), WlzGMModelCopy(), WlzGMModelFindNMEdges(), WlzGMModelRehashVHT(), WlzGMModelResIdx(), WlzGMModelSetSG(), WlzGMModelSpxStats(), WlzIndexedValueGet(), WlzIndexedValuesSet(), and WlzPointsFromDomObj().

◆ AlcVectorExtendAndGet()

◆ AlcVectorCount()

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.

Referenced by WlzCopyIndexedValues().

◆ AlcVectorSetArray1D()

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().

◆ AlcVectorToArray1D()

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().

◆ AlcVectorToArray2D()

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().

◆ AlcVecReadDouble1Asci()

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
fPFile pointer.
fSepField 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().

◆ AlcVecReadDouble2Asci()

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
fPFile pointer.
fSepField 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().