void _Mesh_Algorithms_Update( void* algorithms ) {
    Mesh_Algorithms*	self = (Mesh_Algorithms*)algorithms;
    int nDims, d_i;

    assert( self );

#if 0
    if( !self->mesh ) {
        if( self->tree )
            SpatialTree_Clear( self->tree );
        return;
    }

    if( !self->tree )
        self->tree = SpatialTree_New();
    SpatialTree_SetMesh( self->tree, self->mesh );
    SpatialTree_Rebuild( self->tree );
    self->search = Mesh_Algorithms_SearchWithTree;
#endif

    if( Mesh_HasIncidence( self->mesh, MT_VERTEX, MT_VERTEX ) )
    {
        self->nearestVertex = Mesh_Algorithms_NearestVertexWithNeighbours;
    }
    else
        self->nearestVertex = Mesh_Algorithms_NearestVertexGeneral;

    nDims = Mesh_GetDimSize( self->mesh );
    for( d_i = 0; d_i < nDims; d_i++ ) {
        if( (!Mesh_GetGlobalSize( self->mesh, d_i ) || !Mesh_HasIncidence( self->mesh, nDims, d_i )) )
        {
            break;
        }
    }
    if( d_i == nDims )
        self->search = Mesh_Algorithms_SearchWithFullIncidence;
    else if( Mesh_HasIncidence( self->mesh, MT_VERTEX, Mesh_GetDimSize( self->mesh ) ) )
        self->search = Mesh_Algorithms_SearchWithMinIncidence;
    else
        self->search = Mesh_Algorithms_SearchGeneral;
}
void _ElementCellLayout_Build( void *elementCellLayout, void *data ){
	ElementCellLayout*	self = (ElementCellLayout*)elementCellLayout;

	Stg_Component_Build( self->mesh, NULL, False );

	if( !Mesh_HasIncidence( self->mesh, Mesh_GetDimSize( self->mesh ), MT_VERTEX ) ) {
		Stream* elementCellLayoutStream = Journal_Register( ErrorStream_Type, (Name)self->type  );
		Journal_Printf( elementCellLayoutStream, "Warning: Mesh not configured to build element node table. "
			"Activating it now.\n" );
		abort();
	}

	ElementCellLayout_BuildShadowInfo( self );
}
Bool _Mesh_Algorithms_SearchElements( void* algorithms, double* point,
                                      unsigned* elInd )
{
    Mesh_Algorithms*	self = (Mesh_Algorithms*)algorithms;
    Mesh*			mesh;
    unsigned		dim, ind;

    assert( self );
    assert( self->mesh );
    assert( elInd );

    mesh = self->mesh;
    if( Mesh_Algorithms_Search( self, point, &dim, &ind ) ) {
        unsigned	nDims;

        nDims = Mesh_GetDimSize( mesh );
        if( dim != nDims ) {
            unsigned	nInc, *inc;
            unsigned	lowest;
            unsigned	global;
            unsigned	inc_i;

            /* Must have required incidence for this to work. */
            assert( Mesh_HasIncidence( mesh, dim, nDims ) );

            Mesh_GetIncidence( mesh, dim, ind, nDims, self->incArray );
            nInc = IArray_GetSize( self->incArray );
            inc = (unsigned*)IArray_GetPtr( self->incArray );
            assert( nInc );
            lowest = Mesh_DomainToGlobal( mesh, nDims, inc[0] );
            for( inc_i = 1; inc_i < nInc; inc_i++ ) {
                global = Mesh_DomainToGlobal( mesh, nDims, inc[inc_i] );
                if( global < lowest )
                    lowest = global;
            }

            insist( Mesh_GlobalToDomain( mesh, nDims, lowest, elInd), == True );
        }