void CAngularSpectralProperties::calculateAngularProperties(
      std::shared_ptr<CSpectralSample> const & t_SpectralSample, MaterialType const t_Type)
    {
        assert(t_SpectralSample != nullptr);

        auto aMeasuredData = t_SpectralSample->getMeasuredData();

        if(m_Angle != 0)
        {
            auto aSourceData = t_SpectralSample->getSourceData();

            auto aWavelengths = aMeasuredData->getWavelengths();
            auto aT = aMeasuredData->properties(SampleData::T);
            assert(aT->size() == aWavelengths.size());

            auto aRf = aMeasuredData->properties(SampleData::Rf);
            assert(aRf->size() == aWavelengths.size());

            auto aRb = aMeasuredData->properties(SampleData::Rb);
            assert(aRb->size() == aWavelengths.size());

            auto lowLambda = 0.3;
            auto highLambda = 2.5;

            // TODO: Only one side is measured and it is considered that front properties are equal
            // to back properties
            auto aTSolNorm =
              t_SpectralSample->getProperty(lowLambda, highLambda, Property::T, Side::Front);

            for(size_t i = 0; i < aWavelengths.size(); ++i)
            {
                auto ww = aWavelengths[i] * 1e-6;
                auto T = (*aT)[i].value();
                auto Rf = (*aRf)[i].value();
                auto Rb = (*aRb)[i].value();

                auto aSurfaceType = coatingType.at(t_Type);

                auto aFrontFactory = CAngularPropertiesFactory(T, Rf, m_Thickness, aTSolNorm);
                auto aBackFactory = CAngularPropertiesFactory(T, Rb, m_Thickness, aTSolNorm);

                auto aFrontProperties = aFrontFactory.getAngularProperties(aSurfaceType);
                auto aBackProperties = aBackFactory.getAngularProperties(aSurfaceType);

                auto Tangle = aFrontProperties->transmittance(m_Angle, ww);
                auto Rfangle = aFrontProperties->reflectance(m_Angle, ww);
                auto Rbangle = aBackProperties->reflectance(m_Angle, ww);

                m_AngularData->addRecord(ww * 1e6, Tangle, Rfangle, Rbangle);
            }
        }
        else
        {
            m_AngularData = aMeasuredData;
        }
    }
Ejemplo n.º 2
0
//#TPT-Directive ElementHeader Element_FILT static int interactWavelengths(Particle* cpart, int origWl)
// Returns the wavelengths in a particle after FILT interacts with it (e.g. a photon)
// cpart is the FILT particle, origWl the original wavelengths in the interacting particle
int Element_FILT::interactWavelengths(Particle* cpart, int origWl)
{
	const int mask = 0x3FFFFFFF;
	int filtWl = getWavelengths(cpart);
	switch (cpart->tmp)
	{
		case 0:
			return filtWl; //Assign Colour
		case 1:
			return origWl & filtWl; //Filter Colour
		case 2:
			return origWl | filtWl; //Add Colour
		case 3:
			return origWl & (~filtWl); //Subtract colour of filt from colour of photon
		case 4:
			{
				int shift = int((cpart->temp-273.0f)*0.025f);
				if (shift<=0) shift = 1;
				return (origWl << shift) & mask; // red shift
			}
		case 5:
			{
				int shift = int((cpart->temp-273.0f)*0.025f);
				if (shift<=0) shift = 1;
				return (origWl >> shift) & mask; // blue shift
			}
		case 6:
			return origWl; // No change
		case 7:
			return origWl ^ filtWl; // XOR colours
		case 8:
			return (~origWl) & mask; // Invert colours
		case 9:
		{
			int t1 = (origWl & 0x0000FF)+(rand()%5)-2;
			int t2 = ((origWl & 0x00FF00)>>8)+(rand()%5)-2;
			int t3 = ((origWl & 0xFF0000)>>16)+(rand()%5)-2;
			return (origWl & 0xFF000000) | (t3<<16) | (t2<<8) | t1;
		}
		default:
			return filtWl;
	}
}