void CCPACSWingCellPositionChordwise::ReadCPACS(TixiDocumentHandle tixiHandle,  const std::string& xpath)
{
    Reset();

    // Get subelement "xsi1, xsi2" or Spar Uid (choice)
    const std::string sparUIdString  = xpath + "/sparUID";
    const std::string xsi1String     = xpath + "/xsi1";

    if (tixiCheckElement(tixiHandle, xsi1String.c_str()) == SUCCESS) {
        m_inputType = Xsi;
        if (tixiGetDoubleElement(tixiHandle, xsi1String.c_str(), &m_xsi1) != SUCCESS) {
            LOG(ERROR) << "Error during read of <xsi1>";
            throw CTiglError("Error: Error during read of <xsi1> in CCPACSWingCellPositionChordwise::ReadCPACS!", TIGL_XML_ERROR);
        }
        if (tixiGetDoubleElement(tixiHandle, (xpath + "/xsi2").c_str(), &m_xsi2) != SUCCESS) {
            LOG(ERROR) << "Error during read of <xsi2>";
            throw CTiglError("Error: Error during read of <xsi2> in CCPACSWingCellPositionChordwise::ReadCPACS!", TIGL_XML_ERROR);
        }
    }
    else if (tixiCheckElement(tixiHandle, sparUIdString.c_str()) == SUCCESS) {
        m_inputType = Spar;
        char* ptrSUId = NULL;
        if (tixiGetTextElement(tixiHandle, sparUIdString.c_str(), &ptrSUId) != SUCCESS) {
            LOG(ERROR) << "Error during read of <sparUID>";
            throw CTiglError("Error: Error during read of <sparUID> in CCPACSWingCellPositionChordwise::ReadCPACS!", TIGL_XML_ERROR);
        }
        m_sparUID = ptrSUId;

    }
    else {
        LOG(ERROR) << "Missing element <xsi1> or <sparUID>";
        throw CTiglError("Error: Missing element <xsi1> or <sparUID> in CCPACSWingCellPositionChordwise::ReadCPACS!", TIGL_XML_ERROR);
    }
}
void CCPACSControlSurfaceDeviceAirfoil::ReadCPACS(TixiDocumentHandle tixiHandle, const std::string& xpath)
{
    char* tmp = NULL;

    if (tixiGetTextElement(tixiHandle, (xpath + "/airfoilUID").c_str(), &tmp) == SUCCESS) {
        _airfoilUID = tmp;

        // check if airfoil exists by query
        _config->GetWingProfile(_airfoilUID);
    }
    else {
        throw CTiglError("Missing airfoilUID element in path: " + xpath + "!", TIGL_OPEN_FAILED);
    }

    _rotX = 90.0;
    if (tixiCheckElement(tixiHandle, (xpath + "/rotX").c_str()) == SUCCESS) {
        tixiGetDoubleElement(tixiHandle, (xpath + "/rotX").c_str(), &_rotX);
    }

    // check, if yscale != 1. If yes, we show a warning
    double scalY;
    if (tixiCheckElement(tixiHandle, (xpath + "/scalY").c_str()) == SUCCESS) {
        tixiGetDoubleElement(tixiHandle, (xpath + "/scalY").c_str(), &scalY);
        if (fabs(scalY - 1.0) > 1e-10) {
            LOG(WARNING) << "Y scaling in \"" << xpath << "\" ignored. Only 2D profiles supported.";
        }
    }

    _scalZ = 1.0;
    if (tixiCheckElement(tixiHandle, (xpath + "/scalZ").c_str()) == SUCCESS) {
        tixiGetDoubleElement(tixiHandle, (xpath + "/scalZ").c_str(), &_scalZ);
    }
}
void CCPACSWingRibExplicitPositioning::ReadCPACS(TixiDocumentHandle tixiHandle, const std::string& explicitRibPosXPath)
{
    Cleanup();

    // Get subelement "startReference"
    char* ptrStartReference = NULL;
    if (tixiGetTextElement(tixiHandle, (explicitRibPosXPath + "/startReference").c_str(), &ptrStartReference) != SUCCESS) {
        LOG(ERROR) << "Missing startReference";
        throw CTiglError("Error: Missing startReference in CCPACSWingRibExplicitPositioning::ReadCPACS!", TIGL_XML_ERROR);
    }
    startReference = ptrStartReference;

    // Get subelement "etaStart"
    ReturnCode tixiRet = tixiGetDoubleElement(tixiHandle, (explicitRibPosXPath + "/etaStart").c_str(), &startEta);
    if (tixiRet != SUCCESS) {
        LOG(ERROR) << "Missing etaStart";
        throw CTiglError("Error: Missing etaStart in CCPACSWingRibExplicitPositioning::ReadCPACS!", TIGL_XML_ERROR);
    }

    // Get subelement "endReference"
    char* ptrEndReference = NULL;
    if (tixiGetTextElement(tixiHandle, (explicitRibPosXPath + "/endReference").c_str(), &ptrEndReference) != SUCCESS) {
        LOG(ERROR) << "Missing endReference";
        throw CTiglError("Error: Missing endReference in CCPACSWingRibExplicitPositioning::ReadCPACS!", TIGL_XML_ERROR);
    }
    endReference = ptrEndReference;

    // Get subelement "etaEnd"
    tixiRet = tixiGetDoubleElement(tixiHandle, (explicitRibPosXPath + "/etaEnd").c_str(), &endEta);
    if (tixiRet != SUCCESS) {
        LOG(ERROR) << "Missing etaEnd";
        throw CTiglError("Error: Missing etaEnd in CCPACSWingRibExplicitPositioning::ReadCPACS!", TIGL_XML_ERROR);
    }
}
Ejemplo n.º 4
0
void CCPACSMaterial::ReadCPACS(TixiDocumentHandle tixiHandle, const std::string &materialXPath)
{
    Cleanup();
    
    // check path
    if ( tixiCheckElement(tixiHandle, materialXPath.c_str()) != SUCCESS) {
        LOG(ERROR) << "Material definition" << materialXPath << " not found in CPACS file!" << std::endl;
        return;
    }
    
    // test whether composite or normal material
    std::string tempstring = materialXPath + "/materialUID";
    char * matUID = NULL;
    if (tixiGetTextElement(tixiHandle, tempstring.c_str(), &matUID) == SUCCESS){
        uid = matUID;
        is_composite = false;
    }
    else if (tixiGetTextElement(tixiHandle, std::string(materialXPath + "/compositeUID").c_str(), &matUID) == SUCCESS){
        uid = matUID;
        is_composite = true;
    }
    else {
        throw CTiglError("Neither Material UID nor Composite UID  specified in " + materialXPath, TIGL_ERROR);
    }
    
    // get thickness (not mandatory)
    tempstring = materialXPath + "/thickness";
    if (tixiCheckElement(tixiHandle, tempstring.c_str())== SUCCESS) {
       if (tixiGetDoubleElement(tixiHandle, tempstring.c_str(), &thickness) != SUCCESS) {
           LOG(ERROR) << "Invalid material thickness in " << materialXPath;
       }
    }
    else if (tixiCheckElement(tixiHandle, std::string(materialXPath + "/thicknessScaling").c_str())== SUCCESS) {
       if (tixiGetDoubleElement(tixiHandle, std::string(materialXPath + "/thicknessScaling").c_str(), &thicknessScaling) != SUCCESS) {
           LOG(ERROR) << "Invalid composite thickness scaling in " << materialXPath;
       }
    }
    else {
        if (!isComposite()) {
            LOG(INFO) << "Thickness of Material " << materialXPath << " not set.";
        }
        else {
            LOG(INFO) << "Thickness scaling of Composite Material " << materialXPath << " not set.";
        }
    }
    
    isvalid = true;
}
Ejemplo n.º 5
0
// Read CPACS segment elements
void CCPACSFuselagePositioning::ReadCPACS(TixiDocumentHandle tixiHandle, const std::string& positioningXPath)
{
    Cleanup();

    char*       elementPath;
    std::string tempString;

    // Get subelement "length"
    tempString  = positioningXPath + "/length";
    elementPath = const_cast<char*>(tempString.c_str());
    tixiGetDoubleElement(tixiHandle, elementPath, &length);

    // Get subelement "sweepAngle"
    tempString  = positioningXPath + "/sweepAngle";
    elementPath = const_cast<char*>(tempString.c_str());
    tixiGetDoubleElement(tixiHandle, elementPath, &sweepangle);

    // Get subelement "dihedralAngle"
    tempString  = positioningXPath + "/dihedralAngle";
    elementPath = const_cast<char*>(tempString.c_str());
    tixiGetDoubleElement(tixiHandle, elementPath, &dihedralangle);

    // Get subelement "toSectionUID"
    char*         ptrOuterSection = NULL;
    tempString  = positioningXPath + "/toSectionUID";
    elementPath = const_cast<char*>(tempString.c_str());
    if (tixiGetTextElement(tixiHandle, elementPath, &ptrOuterSection) != SUCCESS){
        std::stringstream stream;
        stream << "Error: Can't read element" << tempString << "in CCPACSFuselagePositioning:ReadCPACS";
        throw CTiglError(stream.str(), TIGL_XML_ERROR);
    }
    endSection = ptrOuterSection;

    // Get subelement "fromSectionUID"
    char*         ptrInnerSection = NULL;
    tempString  = positioningXPath + "/fromSectionUID";
    elementPath = const_cast<char*>(tempString.c_str());
    if (tixiCheckElement(tixiHandle, elementPath) == SUCCESS &&
        tixiGetTextElement(tixiHandle, elementPath, &ptrInnerSection) == SUCCESS ) {

        startSection = ptrInnerSection;
    }
    else {
        startSection = "";
    }

    Update();
}
Ejemplo n.º 6
0
TEST_F(UpdateElementTests, updateDoubleElement_success)
{
    const char* parentPath = "/rootElement/double";
    double val = 666.666;
    double val2 = 0.0;

    ASSERT_TRUE( tixiUpdateDoubleElement( documentHandle, parentPath, val, formatDbl ) == SUCCESS );
    ASSERT_TRUE( tixiGetDoubleElement( documentHandle, parentPath, &val2 ) == SUCCESS );
    ASSERT_TRUE( val == val2 );
}