Exemple #1
0
double CSSPrimitiveValue::computeLengthFloat(RenderStyle *style, bool applyZoomFactor)
{
    unsigned short type = primitiveType();

    // We always assume 96 CSS pixels in a CSS inch. This is the cold hard truth of the Web.
    // At high DPI, we may scale a CSS pixel, but the ratio of the CSS pixel to the so-called
    // "absolute" CSS length units like inch and pt is always fixed and never changes.
    double cssPixelsPerInch = 96.;

    double factor = 1.;
    switch(type) {
    case CSS_EMS:
        factor = applyZoomFactor ?
          style->fontDescription().computedSize() :
          style->fontDescription().specifiedSize();
        break;
    case CSS_EXS: {
        // FIXME: We have a bug right now where the zoom will be applied multiple times to EX units.
        // We really need to compute EX using fontMetrics for the original specifiedSize and not use
        // our actual constructed rendering font.
        factor = style->font().xHeight();
        break;
    }
    case CSS_PX:
        break;
    case CSS_CM:
        factor = cssPixelsPerInch/2.54; // (2.54 cm/in)
        break;
    case CSS_MM:
        factor = cssPixelsPerInch/25.4;
        break;
    case CSS_IN:
        factor = cssPixelsPerInch;
        break;
    case CSS_PT:
        factor = cssPixelsPerInch/72.;
        break;
    case CSS_PC:
        // 1 pc == 12 pt
        factor = cssPixelsPerInch*12./72.;
        break;
    default:
        return -1;
    }

    return getFloatValue() * factor;
}
Exemple #2
0
PASManager* ObjectManager::getPASManager(){
	assert(getIfAdditive() == true);
	if (pasManager_ == NULL) {
		std::cout << "Creating PASManager" << std::endl;
		std::string tmp =  params_->getParamWoSpaces("ALGORITHM");
		if (tmp == "TAPAS") {
			pasManager_ = new PASManager(*getShPath(), getFloatValue("DIR_TOLERANCE"), getNet()->getNbLinks(), 
						getFloatValue("MU"), getFloatValue("V"), 
						getFloatValue("ZERO_FLOW"));
		} else if (tmp == "TAPASstep") {
			pasManager_ = new PASManagerWithStep(*getShPath(), getFloatValue("DIR_TOLERANCE"), getNet()->getNbLinks(), 
						getFloatValue("MU"), getFloatValue("V"), getNet()->getNbLinks(),
						getLineSearch(), getFloatValue("ZERO_FLOW"));
		} else {
			throw Error("Unexpected algorithm type. Possible values are TAPAS or TAPASwithStep");
		}
		std::cout << "PASManager created" << std::endl;
	}
	return pasManager_;
};
Exemple #3
0
// Create random values for keys
static void initKeyValues(const KeyDesc* key)
{
	// Don't create values for missing keys
	if (key->mMissing)
		return;

	short arrayCount = 1;		// Default to 1 value
	switch (key->mType) {
		case kIntArray:
			// Get number of values in array
			arrayCount = getArrayCount();
			// Fall into...
		case kInt: {
			// Allocate memory for array
			key->mpValue = new int[arrayCount];
			key->mValueCount = arrayCount;
			// Add values to array
			while (arrayCount > 0) {
				--arrayCount;
				static_cast<int*>(key->mpValue)[arrayCount] = getIntValue();
			}
		} break;
		case kFloatArray:
			// Get number of values in array
			arrayCount = getArrayCount();
			// Fall into...
		case kFloat: {
			// Allocate memory for array
			key->mpValue = new float[arrayCount];
			key->mValueCount = arrayCount;
			// Add values to array
			while (arrayCount > 0) {
				--arrayCount;
				static_cast<float*>(key->mpValue)[arrayCount] = getFloatValue();
			}
		} break;
		case kString: {
			// Get the string
			key->mValueCount = 1;
			key->mpValue = getStringValue();
		}
	}
}
void StageObjectOverlay::draw()
{
    
    ofSetColor(255, 255, 255, 255);
    
	glEnable(GL_DEPTH_TEST);
    
    
    ofPushMatrix();
    float scale = getFloatValue(4);
    glScalef(scale, scale, scale);

    glRotatef (getFloatValue(5),getFloatValue(6), getFloatValue(7),getFloatValue(8));
    glTranslatef(getFloatValue(1), getFloatValue(2), getFloatValue(3));
    if (getBoolValue(9))
        model->drawWireframe();
    else
        model->drawFaces();
    //mesh.drawFaces();
    ofPopMatrix();    
}
Exemple #5
0
OriginSet* ObjectManager::getOriginSet(){
	assert(getIfAdditive() == true);
	if (originSet_ == NULL) {
		std::cout << "Creating origin set" << std::endl;
		std::string tmp =  params_->getParamWoSpaces("ALGORITHM");
		
		if (tmp == "B") {

			std::string steps =  params_->getParamWoSpaces("NEWTON_STEPS");
			bool useMulti = true;
			if (steps == "SINGLE") {
				useMulti = false;
			} else if (steps == "MULTI") {
				useMulti = true;
			} else {
				throw Error("Unexpected value of parameter <NEWTON_STEPS>");
			} 

			originSet_ = OriginSet::createOriginSetB(getODMatrix(), getNet(), 
					getFloatValue("ZERO_FLOW"), getFloatValue("DIR_TOLERANCE"), useMulti, 
					getLabelCorrectingAlgo());
		} else if (tmp == "Bstep"){
			originSet_ = OriginSet::createOriginSetBWithStep(getODMatrix(), getNet(), 
					getFloatValue("ZERO_FLOW"), getFloatValue("DIR_TOLERANCE"), 
					getLineSearch(), getLabelCorrectingAlgo());
		} else if (tmp == "LUCE") {
			originSet_ = OriginSet::createOriginSetLUCE(getODMatrix(), getNet(), getFloatValue("ZERO_FLOW"), 
						getFloatValue("DIR_TOLERANCE"), getLineSearch(), getLabelCorrectingAlgo());
		} else if (tmp == "TAPAS" || tmp == "TAPASstep") {
			originSet_ = OriginSet::createOriginSetTAPAS(getODMatrix(), getNet(), getFloatValue("ZERO_FLOW"), 
						getFloatValue("DIR_TOLERANCE"), getPASManager(), getLabelCorrectingAlgo());
		} else {
			throw Error("Unexpected algorithm value");
		}
		std::cout << "origin set created" << std::endl;
	}
	return originSet_;
};
Exemple #6
0
ShortestPath* ObjectManager::getShPath(){
	if (shPath_ == NULL) {
		std::cout << "Creating shortest path" << std::endl;
		std::string algo =  params_->getParamWoSpaces("ShPathAlgo");
	    if( algo == "LC"){
	    	assert(getIfAdditive() == true);
	       	LCShortestPath_ = new LabelCorrectingAl(getNet());
	       	shPath_ = LCShortestPath_;
	    } else if( algo == "Astar"){
	    	assert(getIfAdditive() == true);
        	aStar_ = new Astar(getNet(), getODMatrix());
        	aStar_->initializeBounds(getODMatrix());
        	shPath_ = aStar_;
        } else if (algo == "NonAdd" || algo == "LazyNonAdd" || algo == "NonAddWithAstar") {
        	assert(getIfAdditive() == false);
        	nonAddShPath_ = getNonAddShPath();
        } else if (algo == "LazySP") {
        	assert(getIfAdditive() == true);
        	shPath_ = new LazyShortestPath(new LabelCorrectingAl(getNet()));
        } else {
        	throw Error("Unexpected parameter for <ShPathAlgo>. Possible values are LC, Astar.");
        }
       
	    if (nonAddShPath_ == NULL && ! params_->getParamWoSpaces("UseP2PShPathWithRandomReturn").empty()) {
			std::cout << " params_->getParamWoSpaces(UseP2PShPathWithRandomReturn) = " <<
       	 	 params_->getParamWoSpaces("UseP2PShPathWithRandomReturn") << std::endl;
       	 	if (! params_->getParamWoSpaces("FIXED_PROBABILITY").empty()) {
       	 		FPType probability = getFloatValue("FIXED_PROBABILITY");
       	 		if (probability <= 0 || probability > 1) throw Error("Unexpected value of parameter <FIXED_PROBABILITY>");
       	 		shPath_ = new ShortestPathWithRandomReturnWithFixedProbability(shPath_, probability);
       	 	} else {
				shPath_ = new ShortestPathWithRandomReturn(shPath_);
			}
		}
	    std::cout << "Shortest path created" << std::endl;
	}
	return shPath_;
};
Exemple #7
0
bool MLProperty::operator== (const MLProperty& b) const
{
	bool r = false;
	if(mType == b.getType())
	{
		switch(mType)
		{
			case kUndefinedProperty:
				r = true;
				break;
			case kFloatProperty:
				r = (getFloatValue() == b.getFloatValue());
				break;
			case kStringProperty:
				r = (getStringValue() == b.getStringValue());
				break;
			case kSignalProperty:
				r = (getSignalValue() == b.getSignalValue());
				break;
		}
	}
	return r;
}
    double FloatValue::NearlyEqual(double another) const {

        const double a = getFloatValue();
        const double b = another;

        const double absA = std::abs(a);
        const double absB = std::abs(b);
        const double diff = std::abs(a - b);

        const double epsilon = std::numeric_limits<double>::epsilon();

        if (a == b) {
            // shortcut, handles infinities
            return true;
        }
        else if (a == 0 || b == 0 || diff < std::numeric_limits<double>::min()) {
            // a or b is zero or both are extremely close to it
            // relative error is less meaningful here
            return diff < (epsilon * std::numeric_limits<double>::min());
        }
        else { // use relative error
            return diff / std::min((absA + absB), std::numeric_limits<double>::max()) < epsilon;
        }
    }
int NumericControl::getIntValue( WindowRef window )
{
	return static_cast<int>( getFloatValue( window ) );
}
// -------------------------------------------------------------------
//	Loads the material description
void ObjFileMtlImporter::load()
{
	if ( m_DataIt == m_DataItEnd )
		return;

	while ( m_DataIt != m_DataItEnd )
	{
		switch (*m_DataIt)
		{
		case 'K':
			{
				++m_DataIt;
				if (*m_DataIt == 'a') // Ambient color
				{
					++m_DataIt;
					getColorRGBA( &m_pModel->m_pCurrentMaterial->ambient );
				}
				else if (*m_DataIt == 'd')	// Diffuse color
				{
					++m_DataIt;
					getColorRGBA( &m_pModel->m_pCurrentMaterial->diffuse );
				}
				else if (*m_DataIt == 's')
				{
					++m_DataIt;
					getColorRGBA( &m_pModel->m_pCurrentMaterial->specular );
				}
				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
			}
			break;

		case 'd':	// Alpha value
			{
				++m_DataIt;
				getFloatValue( m_pModel->m_pCurrentMaterial->alpha );
				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
			}
			break;

		case 'N':	// Shineness
			{
				++m_DataIt;
				switch(*m_DataIt) 
				{
				case 's':
					++m_DataIt;
					getFloatValue(m_pModel->m_pCurrentMaterial->shineness);
					break;
				case 'i': //Index Of refraction 
					++m_DataIt;
					getFloatValue(m_pModel->m_pCurrentMaterial->ior);
					break;
				}
				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
				break;
			}
			break;
		

		case 'm':	// Texture
		case 'b':   // quick'n'dirty - for 'bump' sections
			{
				getTexture();
				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
			}
			break;

		case 'n':	// New material name
			{
				createMaterial();
				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
			}
			break;

		case 'i':	// Illumination model
			{
				m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
				getIlluminationModel( m_pModel->m_pCurrentMaterial->illumination_model );
				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
			}
			break;

		default:
			{
				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
			}
			break;
		}
	}
}
Exemple #11
0
DecoratedEqAlgo* ObjectManager::getEqAlgo(const std::string& dirConv, 
							const std::string& dirFlows){
	if (algo_ == NULL) {
		std::cout << "Creating algo" << std::endl;
		std::string tmp =  params_->getParamWoSpaces("ALGORITHM");
		if ((tmp == "FW") || (tmp == "CFW") || (tmp == "BFW")) {
			assert(getIfAdditive() == true);
			if (linkFlows_ == NULL) {
				if (tmp == "CFW") {
					linkFlows_ = new LinkFlowsCFW(getNet(), getODMatrix(), getShPath(), getLineSearch(), 
						getFloatValue("ZERO_FLOW"), getLabelCorrectingAlgo());
				} else if (tmp == "BFW") {
					linkFlows_ = new LinkFlowsBFW(getNet(), getODMatrix(), getShPath(), getLineSearch(),
						getFloatValue("ZERO_FLOW"), getLabelCorrectingAlgo());
				} else {
					linkFlows_ = new LinkFlows(getNet(), getODMatrix(), getShPath(), getLineSearch(),
						getFloatValue("ZERO_FLOW"), getLabelCorrectingAlgo());
				}
	
			}
			algo_ = new FWAlgo(linkFlows_, getAddHook(), getNet(), getConvMeasure(), 
					getFloatValue("TIME_LIMIT")); 
		} else if (getPathAlgoType() != Nothing){
			std::string tmp =  params_->getParamWoSpaces("EQUILIBRATION");
			std::cout << "EQ = " << tmp << std::endl;

			if (tmp == "EQI") {
				
				algo_ = new PathBasedAlgo(getPathSet(), getAddHook(), getConvMeasure(), getNet(),
					getFloatValue("TIME_LIMIT"), getODMatrix()); 
			} else if (tmp == "EQII") {
				algo_ = new PathBasedAlgoEqII(getPathSet(), getAddHook(), getConvMeasure(), getNet(),
					getFloatValue("TIME_LIMIT"), 
					static_cast<int>(getFloatValue("MAX_ITER")), getODMatrix());
			} else {
				throw Error("Unexpected value of parameter <EQUILIBRATION>");
			}
			if (currPathsAdder_ != NULL) currPathsAdder_->setPathSet(getPathSet());
			if (aStar_ != NULL) aStar_->setPathSet(getPathSet());
			if (aStarForNonAdd_ != NULL) aStarForNonAdd_->setPathSet(getPathSet());

		} else if (tmp == "B" || tmp == "Bstep") {
			assert(getIfAdditive() == true);
			std::string tmp =  params_->getParamWoSpaces("EQUILIBRATION");
			std::cout << "EQ = " << tmp << std::endl;
			if (tmp == "EQI") {
				algo_ = new OriginBasedAlgo(getOriginSet(), getNet(), getAddHook(),  
							getConvMeasure(), getFloatValue("TIME_LIMIT"));
			} else if (tmp == "EQII") {
				algo_ = new OriginBasedAlgoEQII(getOriginSet(), getNet(), getAddHook(),
						getConvMeasure(), getFloatValue("TIME_LIMIT"), 
						static_cast<int>(getFloatValue("MAX_ITER")));
			} else {
				throw Error("Unexpected value of parameter <EQUILIBRATION>");
			}
		} else if (tmp == "LUCE") {
			assert(getIfAdditive() == true);
			std::string tmp =  params_->getParamWoSpaces("EQUILIBRATION");
			std::cout << "EQ = " << tmp << std::endl;
			if (tmp == "EQI") {
				algo_ = new OriginBasedAlgo(getOriginSet(), getNet(), getAddHook(),
					getConvMeasure(), getFloatValue("TIME_LIMIT"));
			} else if (tmp == "EQII") {
				algo_ = new OriginBasedAlgoEQII(getOriginSet(), getNet(), getAddHook(),
						getConvMeasure(), getFloatValue("TIME_LIMIT"), 
						static_cast<int>(getFloatValue("MAX_ITER")));
			} else {
				throw Error("Unexpected value of parameter <EQUILIBRATION>");
			}
		} else if (tmp == "TAPAS" || tmp == "TAPASstep") {
			assert(getIfAdditive() == true);
			std::string tmp =  params_->getParamWoSpaces("EQUILIBRATION");
			std::cout << "EQ = " << tmp << std::endl;
			if (tmp == "EQI") {
				algo_ = new OriginBasedAlgoTapas(getOriginSet(), getNet(), getPASManager(), 
					getAddHook(), getConvMeasure(), getFloatValue("TIME_LIMIT"));
			} else if (tmp == "EQII") {
				algo_ = new OriginBasedAlgoTapasEqII(getOriginSet(), getNet(), getPASManager(), 
					getAddHook(), getConvMeasure(), getFloatValue("TIME_LIMIT"),
					static_cast<int>(getFloatValue("MAX_ITER")));
			} else {
				throw Error("Unexpected value of parameter <EQUILIBRATION>");
			}

		} else {
			throw Error("Unexpected value of parameter <ALGORITHM>");
		}
		
		std::cout << "Adding decorations" << std::endl;
		tmp =  params_->getParamWoSpaces("CONVERGENCE");
		if (tmp != "") {
			getAddHook();
			assert(addHookStore_ != NULL);
			if (tmp == "AUTO") {
				tmp =  params_->getAutoFileName() + ".conv";
			}
			algo_ = new AlgoDecorator(algo_, addHookStore_, tmp, dirConv);
		}
		tmp =  params_->getParamWoSpaces("LINK_FLOWS");
		if (tmp != "") {
			if (tmp == "AUTO") {
				tmp =  params_->getAutoFileName() + ".flows";
			}
			algo_ = new AlgoDecoratorWriteLinks(algo_, getNet(), tmp, dirFlows);
		}
		std::cout << "Algo created" << std::endl;
	}
	return algo_;
};
Exemple #12
0
Test::Test(XmlElement *xe,bool &ok, ProductionUnit* unit_) :
	input (-1),
	output (-1),
	num_channels(1),
    glitchThreshold(4.0f),
	unit(unit_),
    requiredTestAdapterProductId(0) // Most tests do not require a specific product ID
{
	XmlElement *temp;

	temp = xe->getFirstChildElement();
    if (temp && temp->isTextElement())
	{
		title = temp->getText();
		title = title.trim();
	}

	if (application->testManager->getNumLoops())
	{
        int currentLoop = application->testManager->currentLoop;
		if (title.isNotEmpty())
		{
			title += String::formatted(" - loop %d/%d", currentLoop + 1, application->testManager->getNumLoops());
		}
	}

	getIntValue(xe, "input", input);
	getIntValue(xe, "output", output);
	getIntValue(xe, "num_channels", num_channels);
	ok = getIntValue(xe, "sample_rate_check", sample_rate_check);
	if (!ok)
		sample_rate_check = 0;
	ok = getIntValue(xe, "sample_rate", sample_rate);
	ok &= getFloatValue(xe, "output_amplitude_db", output_amplitude_db);

	if (sample_rate_check != 0)
	{
		minSampleRate = sample_rate_check * 0.80f;
		maxSampleRate = sample_rate_check * 1.20f;
	}
	else
	{
		minSampleRate = sample_rate * 0.94f;
		maxSampleRate = sample_rate * 1.06f;
	}
	getFloatValue(xe, "min_sample_rate", minSampleRate);
	getFloatValue(xe, "max_sample_rate", maxSampleRate);
    
    getHexValue(xe, "required_test_adapter_product_id", requiredTestAdapterProductId); // Not required
    
    if (ECHOAIO_INTERFACE_MODULE_REV1 == unit_->getAIORevision())
    {
        if (minSampleRate > 144000.0)
            minSampleRate *= 0.5f;
        if (maxSampleRate > 144000.0)
            maxSampleRate *= 0.5f;
        if (sample_rate > 144000.0)
            sample_rate *= 0.5f;
    }

	output_frequency = 1000.0f;
}
float FGPropertyManager::GetFloat (const string &name, float defaultValue )
{
  return getFloatValue(name.c_str(), defaultValue);
}
float FGPropertyNode::GetFloat (const string &name, float defaultValue ) const
{
  return getFloatValue(name.c_str(), defaultValue);
}