当前位置: 首页>>代码示例>>C++>>正文


C++ Quantity::getValueAs方法代码示例

本文整理汇总了C++中base::Quantity::getValueAs方法的典型用法代码示例。如果您正苦于以下问题:C++ Quantity::getValueAs方法的具体用法?C++ Quantity::getValueAs怎么用?C++ Quantity::getValueAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在base::Quantity的用法示例。


在下文中一共展示了Quantity::getValueAs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_cflux

double TaskFemConstraintTemperature::get_cflux() const{
    Base::Quantity cflux =  ui->if_temperature->getQuantity();
    double cflux_in_watt = cflux.getValueAs(Base::Quantity::Watt);
    return cflux_in_watt;
}
开发者ID:SparkyCola,项目名称:FreeCAD,代码行数:5,代码来源:TaskFemConstraintTemperature.cpp

示例2: get_temperature

double TaskFemConstraintTemperature::get_temperature() const{
    Base::Quantity temperature =  ui->if_temperature->getQuantity();
    double temperature_in_kelvin = temperature.getValueAs(Base::Quantity::Kelvin);
    return temperature_in_kelvin;
}
开发者ID:SparkyCola,项目名称:FreeCAD,代码行数:5,代码来源:TaskFemConstraintTemperature.cpp

示例3: getPressure

double TaskFemConstraintPressure::getPressure(void) const
{
    Base::Quantity pressure =  ui->if_pressure->getQuantity();
    double pressure_in_MPa = pressure.getValueAs(Base::Quantity::MegaPascal);
    return pressure_in_MPa;
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:6,代码来源:TaskFemConstraintPressure.cpp

示例4: PyInit

// constructor method
int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
    if (PyArg_ParseTuple(args, "")) {
        return 0;
    }

    PyErr_Clear();

    char *ConstraintType;
    int  FirstIndex = Constraint::GeoUndef;
    int  FirstPos   = none;
    int  SecondIndex= Constraint::GeoUndef;
    int  SecondPos  = none;
    int  ThirdIndex = Constraint::GeoUndef;
    int  ThirdPos   = none;
    double Value    = 0;
    int intArg1, intArg2, intArg3, intArg4, intArg5;
    // Note: In Python 2.x PyArg_ParseTuple prints a warning if a float is given but an integer is expected.
    // This means we must use a PyObject and check afterwards if it's a float or integer.
    PyObject* index_or_value;
    PyObject* oNumArg4;
    PyObject* oNumArg5;
    int any_index;

    // ConstraintType, GeoIndex
    if (PyArg_ParseTuple(args, "si", &ConstraintType, &FirstIndex)) {
        if (strcmp("Horizontal",ConstraintType) == 0) {
            this->getConstraintPtr()->Type = Horizontal;
            this->getConstraintPtr()->First = FirstIndex;
            return 0;
        }
        else if (strcmp("Vertical",ConstraintType) == 0) {
            this->getConstraintPtr()->Type = Vertical;
            this->getConstraintPtr()->First = FirstIndex;
            return 0;
        }
    }
    PyErr_Clear();

    if (PyArg_ParseTuple(args, "siO", &ConstraintType, &FirstIndex, &index_or_value)) {
        // ConstraintType, GeoIndex1, GeoIndex2
        if (PyInt_Check(index_or_value)) {
            SecondIndex = PyInt_AsLong(index_or_value);
            bool valid = false;
            if (strcmp("Tangent",ConstraintType) == 0) {
                this->getConstraintPtr()->Type = Tangent;
                valid = true;
            }
            else if (strcmp("Parallel",ConstraintType) == 0) {
                this->getConstraintPtr()->Type = Parallel;
                valid = true;
            }
            else if (strcmp("Perpendicular",ConstraintType) == 0) {
                this->getConstraintPtr()->Type = Perpendicular;
                valid = true;
            }
            else if (strcmp("Equal",ConstraintType) == 0) {
                this->getConstraintPtr()->Type = Equal;
                valid = true;
            }
            else if (strstr(ConstraintType,"InternalAlignment") != NULL) {
                this->getConstraintPtr()->Type = InternalAlignment;
                
                valid = true;
                if(strstr(ConstraintType,"EllipseMajorDiameter") != NULL)
                    this->getConstraintPtr()->AlignmentType=EllipseMajorDiameter;
                else if(strstr(ConstraintType,"EllipseMinorDiameter") != NULL)
                    this->getConstraintPtr()->AlignmentType=EllipseMinorDiameter;                    
                else {
                    this->getConstraintPtr()->AlignmentType=Undef;
                    valid = false;
                }
            }
            
            if (valid) {
                this->getConstraintPtr()->First = FirstIndex;
                this->getConstraintPtr()->Second = SecondIndex;
                return 0;
            }
        }
        // ConstraintType, GeoIndex, Value
        if (PyNumber_Check(index_or_value)) { // can be float or int
            Value = PyFloat_AsDouble(index_or_value);
            bool valid = false;
            if (strcmp("Distance",ConstraintType) == 0 ) {
                this->getConstraintPtr()->Type = Distance;
                valid = true;
            }
            else if (strcmp("Angle",ConstraintType) == 0 ) {
                if (PyObject_TypeCheck(index_or_value, &(Base::QuantityPy::Type))) {
                    Base::Quantity q = *(static_cast<Base::QuantityPy*>(index_or_value)->getQuantityPtr());
                    if (q.getUnit() == Base::Unit::Angle)
                        Value = q.getValueAs(Base::Quantity::Radian);
                }
                this->getConstraintPtr()->Type = Angle;
                valid = true;
            }
            else if (strcmp("DistanceX",ConstraintType) == 0) {
                this->getConstraintPtr()->Type = DistanceX;
//.........这里部分代码省略.........
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:101,代码来源:ConstraintPyImp.cpp

示例5: onPressureChanged

void TaskFemConstraintPressure::onPressureChanged(const Base::Quantity& f)
{
    Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
    double val = f.getValueAs(Base::Quantity::MegaPascal);
    pcConstraint->Pressure.setValue(val);
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:6,代码来源:TaskFemConstraintPressure.cpp


注:本文中的base::Quantity::getValueAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。