inline
SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::SlicedCartesian(
	void)
	:numVertices(0),
	 numSlices(0),
	 slices(0),
	 numCells(0),
	 cellSize(Scalar(0)),
	 domainBox(Box::empty)
	{
	/* Initialize vertex stride array: */
	for(int i=0;i<dimension;++i)
		vertexStrides[i]=0;
	
	/* Initialize vertex offset array: */
	for(int i=0;i<CellTopology::numVertices;++i)
		vertexOffsets[i]=0;
	
	/* Initialize vertex list bounds: */
	Index vertexIndex(0);
	firstVertex=VertexIterator(this,vertexIndex);
	lastVertex=VertexIterator(this,vertexIndex);
	
	/* Initialize cell list bounds: */
	Index cellIndex(0);
	firstCell=CellIterator(this,cellIndex);
	lastCell=CellIterator(this,cellIndex);
	}
inline
void
SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::setData(
	const typename SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::Index& sNumVertices,
	int sNumSlices,
	const typename SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::Size& sCellSize,
	const typename SlicedCartesian<ScalarParam,dimensionParam,VScalarParam>::Value* sVertexValues)
	{
	/* Destroy the slice arrays: */
	if(numSlices>0)
		delete[] slices;
	
	/* Re-initialize the slice arrays: */
	numVertices=sNumVertices;
	numSlices=sNumSlices;
	slices=new Array[numSlices];
	for(int slice=0;slice<numSlices;++slice)
		slices[slice].resize(numVertices);
	
	/* Initialize vertex stride array: */
	for(int i=0;i<dimension;++i)
		vertexStrides[i]=slices[0].getIncrement(i);
	
	/* Initialize the cell size: */
	cellSize=sCellSize;
	
	/* Calculate number of cells: */
	for(int i=0;i<dimension;++i)
		numCells[i]=numVertices[i]-1;
	
	/* Initialize vertex offset array: */
	for(int i=0;i<CellTopology::numVertices;++i)
		{
		/* Vertex indices are, as usual, bit masks of a vertex' position in cell coordinates: */
		vertexOffsets[i]=0;
		for(int j=0;j<dimension;++j)
			if(i&(1<<j))
				vertexOffsets[i]+=vertexStrides[j];
		}
	
	/* Initialize vertex list bounds: */
	Index vertexIndex(0);
	firstVertex=VertexIterator(this,vertexIndex);
	vertexIndex[0]=numVertices[0];
	lastVertex=VertexIterator(this,vertexIndex);
	
	/* Initialize cell list bounds: */
	Index cellIndex(0);
	firstCell=CellIterator(this,cellIndex);
	cellIndex[0]=numCells[0];
	lastCell=CellIterator(this,cellIndex);
	
	/* Initialize domain bounding box: */
	Point domainMax;
	for(int i=0;i<dimension;++i)
		domainMax[i]=Scalar(numCells[i])*cellSize[i];
	domainBox=Box(Point::origin,domainMax);
	
	/* Copy source vertex values, if present: */
	if(sVertexValues!=0)
		{
		const VScalar* sPtr=sVertexValues;
		size_t totalNumVertices=slices[slice].getNumElements();
		for(int slice=0;slice<numSlices;++slice)
			{
			/* Copy all slice vertex values: */
			VScalar* vPtr=slices[slice].getArray();
			for(size_t i=0;i<totalNumVertices;++i,++vPtr,++sPtr)
				*vPtr=*sPtr;
			}
		}
	}
Exemple #3
0
CellList::CellIterator CellList::cells(void)const{
    return CellIterator(n_cells_tot_);
}