inline
void
SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::initStructure(
	void)
	{
	/* Initialize vertex stride array: */
	for(int i=0;i<dimension;++i)
		vertexStrides[i]=numVertices.calcIncrement(i);
	
	/* 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=Vertex(this,vertexIndex);
	vertexIndex[0]=numVertices[0];
	lastVertex=Vertex(this,vertexIndex);
	
	/* Initialize cell list bounds: */
	Index cellIndex(0);
	firstCell=Cell(this,cellIndex);
	cellIndex[0]=numCells[0];
	lastCell=Cell(this,cellIndex);
	}
inline
SlicedCurvilinear<ScalarParam,dimensionParam,ValueScalarParam>::SlicedCurvilinear(
	void)
	:numVertices(0),
	 numSlices(0),slices(0),
	 numCells(0),
	 domainBox(Box::empty),
	 locatorEpsilon(Scalar(1.0e-4))
	{
	/* 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)
		{
		/* Vertex indices are, as usual, bit masks of a vertex' position in cell coordinates: */
		vertexOffsets[i]=0;
		}
	
	/* Initialize vertex list bounds: */
	Index vertexIndex(0);
	firstVertex=Vertex(this,vertexIndex);
	lastVertex=Vertex(this,vertexIndex);
	
	/* Initialize cell list bounds: */
	Index cellIndex(0);
	firstCell=Cell(this,cellIndex);
	lastCell=Cell(this,cellIndex);
	}
Exemplo n.º 3
0
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);
	}
Exemplo n.º 4
0
void Mesh::quadBoundary(int iLeft, int jLower, Point3 p[4])
//
// possible helper: returns (in p[]) the four points bounding the two
// faces of the quad in CCW order. It takes account of wrapping in
// both the i and j directions.
//
{
    int iRight, jUpper;

    //
    // It is a bug to request the boundary of the "rightmost
    // rectangles" (i.e. those whose lower left corner is
    // `iLower` = `nI`-1) *unless* we're wrapping in i (i.e.
    // `wrapI` is true).
    //
    assert(0 <= iLeft && iLeft < nI - 1 + wrapI);
    //
    // Likewise for the "topmost" rectangle, `jLower`, `nI`, and
    // `wrapJ`, respectively.
    //
    assert(0 <= jLower && jLower < nJ - 1 + wrapJ);

    //
    // When wrapI is true, the iLeft = 0 vertices form the boundary of
    // the rightmost rectangles.
    //
    if (wrapI && iLeft == nI-1)
        iRight = 0;
    else
        iRight = iLeft+1;

    //
    // Likewise when wrapJ is true for the topmost rectangles.
    //
    if (wrapJ && jLower == nJ-1)
        jUpper = 0;
    else
        jUpper = jLower+1;

    p[0] = vertices[vertexIndex(iLeft,  jLower)];
    p[1] = vertices[vertexIndex(iRight, jLower)];
    p[2] = vertices[vertexIndex(iRight, jUpper)];
    p[3] = vertices[vertexIndex(iLeft,  jUpper)];
}
Exemplo n.º 5
0
void Mesh::createVertexIndices(void)
{
    int nIndicesPerTriangleStrip = 2 * (nI + wrapI);
    int nTriangleStrips = nJ - 1 + wrapJ;
    nVertexIndices = nIndicesPerTriangleStrip * nTriangleStrips;
    vertexIndices = new unsigned int [nVertexIndices];
    int iVertexIndices = 0;
    for (int j = 0; j < nJ - 1 + wrapJ; j++) {
        int jTop = j + 1;
        if (jTop >= nJ) {
            assert(jTop == nJ && wrapJ); // should be the only time this happens
            jTop = 0;
        }
        for (int i = 0; i < nI; i++) {
            vertexIndices[iVertexIndices++] = vertexIndex(i, jTop);
            vertexIndices[iVertexIndices++] = vertexIndex(i, j);
        }
        if (wrapI) {
            vertexIndices[iVertexIndices++] = vertexIndex(0, jTop);
            vertexIndices[iVertexIndices++] = vertexIndex(0, j);
        }
    }
    assert(iVertexIndices == nVertexIndices);
}
Exemplo n.º 6
0
	void SpriteBatch::CreateSpriteQuad(const std::vector<SpriteInfo>& spriteQueue)
	{	
		//for every sprite that has to be drawn, push back all vertices 
		//(12 per sprite) into the vertexbuffer and all uvcoords (8 per
		//sprite) into the uvbuffer

		int32 vertexIndex(0);
		int32 uvIndex(0);

		for(auto& sprite : spriteQueue)
		{
			for(auto& vertex : sprite.vertices)
			{
				m_VertexBuffer.push_back(vertex);
			}

			for(auto& uvCoord : sprite.uvCoords)
			{
				m_UvCoordBuffer.push_back(uvCoord);
			}
		}
	}
Exemplo n.º 7
0
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;
			}
		}
	}