Пример #1
0
const labelList& tetPointFieldDecomposer::directAddressing() const
{
    if (!directAddressingPtr_)
    {
        calcAddressing();
    }

    return *directAddressingPtr_;
}
const labelListList&
PrimitivePatch<Face, FaceList, PointField, PointType>::faceEdges() const
{
    if (!faceEdgesPtr_)
    {
        calcAddressing();
    }

    return *faceEdgesPtr_;
}
label PrimitivePatch<Face, FaceList, PointField, PointType>::nInternalEdges()
 const
{
    if (!edgesPtr_)
    {
        calcAddressing();
    }

    return nInternalEdges_;
}
const edgeList&
PrimitivePatch<Face, FaceList, PointField, PointType>::edges() const
{
    if (!edgesPtr_)
    {
        calcAddressing();
    }

    return *edgesPtr_;
}
Пример #5
0
const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edgeFaces() const
{
    if (!edgeFacesPtr_)
    {
        calcAddressing();
    }

    return *edgeFacesPtr_;
}
const scalarListList&
MixingPlaneInterpolation<MasterPatch, SlavePatch>::
slaveProfileToPatchWeights() const
{
    if (!slaveProfileToPatchWeightsPtr_)
    {
        calcAddressing();
    }

    return *slaveProfileToPatchWeightsPtr_;
}
const labelListList&
MixingPlaneInterpolation<MasterPatch, SlavePatch>::
slaveProfileToPatchAddr() const
{
    if (!slaveProfileToPatchAddrPtr_)
    {
        calcAddressing();
    }

    return *slaveProfileToPatchAddrPtr_;
}
Пример #8
0
UniPixel tex2D( SamplerData* sampler, const double& su, const double& sv )
{
	UniPixel result;

	double u = su;
	double v = sv;

	if( sampler->mapping == SMM_PERCENT )
	{
		u = su * sampler->samplingImage->width - 0.5;
		v = sv * sampler->samplingImage->height - 0.5;
	}

	size_t imgWidth = sampler->samplingImage->width;
	size_t imgHeight = sampler->samplingImage->height;

	//TODO check mirroring in all states
	if( sampler->filter == SF_POINT )
	{
		//TODO: try add round 

		
		u = floor(u + 0.5);
		v = floor(v + 0.5);

		u = calcAddressing( sampler->samplingU, imgWidth, u );
		v = calcAddressing( sampler->samplingV, imgHeight, v );

		
		assert( !( v < 0.0 || u < 0.0 || u > imgWidth - 1 || v > imgHeight - 1 ) && "Wrong sampling address" );

		unsigned char* srcData = (unsigned char*)sampler->samplingImage->imgData;

		assert( sampler->samplingImage->format->readFn && "No sampling implementation in format" );
		sampler->samplingImage->format->readFn( srcData + (size_t(v) * imgWidth + size_t(u)) * sampler->samplingImage->format->bytesPerPixel, &result );

		return result;
	}else if( sampler->filter == SF_LINEAR )
	{
		double minU = floor(u);
		double minV = floor(v);
		double maxU = ceil(u);
		double maxV = ceil(v);

		double blendCoefU = u - minU;
		double blendCoefV = v - minV;
		
		minU = calcAddressing( sampler->samplingU, imgWidth, minU );
		maxU = calcAddressing( sampler->samplingU, imgWidth, maxU );

		minV = calcAddressing( sampler->samplingV, imgHeight, minV );
		maxV = calcAddressing( sampler->samplingV, imgHeight, maxV );
		
		unsigned char* srcData = (unsigned char*)sampler->samplingImage->imgData;

		UniPixel q0;
		UniPixel q1;

		UniPixel q2;
		UniPixel q3;

		sampler->samplingImage->format->readFn( srcData + (size_t(minV) * imgWidth + size_t(minU)) * sampler->samplingImage->format->bytesPerPixel, &q0 );
		sampler->samplingImage->format->readFn( srcData + (size_t(minV) * imgWidth + size_t(maxU)) * sampler->samplingImage->format->bytesPerPixel, &q1 );

		sampler->samplingImage->format->readFn( srcData + (size_t(maxV) * imgWidth + size_t(minU)) * sampler->samplingImage->format->bytesPerPixel, &q2 );
		sampler->samplingImage->format->readFn( srcData + (size_t(maxV) * imgWidth + size_t(maxU)) * sampler->samplingImage->format->bytesPerPixel, &q3 );

		UniPixel linear0;
		UniPixel linear1;
		
		uniPixelLerp( &linear0, &q0, &q1, blendCoefU );
		uniPixelLerp( &linear1, &q2, &q3, blendCoefU );

		uniPixelLerp( &result, &linear0, &linear1, blendCoefV );
	}

	return result;
}