Exemplo n.º 1
0
gp_Pnt getSectionElementChordlinePoint(const CCPACSWingComponentSegment& cs, const std::string& sectionElementUID, double xsi)
{
    gp_Pnt chordlinePoint;
    CCPACSWing& wing = cs.GetWing();
    // find section element
    const CCPACSWingSegment& segment = static_cast<const CCPACSWingSegment&>(wing.GetSegment(1));
    if (sectionElementUID == segment.GetInnerSectionElementUID()) {
        // convert into wing coordinate system
        CTiglTransformation wingTrans = wing.GetTransformation();
        chordlinePoint = wingTrans.Inverted().Transform(segment.GetChordPoint(0, xsi));
    }
    else {
        int i;
        for (i = 1; i <= wing.GetSegmentCount(); ++i) {
            const CCPACSWingSegment& segment = static_cast<const CCPACSWingSegment&>(wing.GetSegment(i));
            if (sectionElementUID == segment.GetOuterSectionElementUID()) {
                // convert into wing coordinate system
                CTiglTransformation wingTrans = wing.GetTransformation();
                chordlinePoint = wingTrans.Inverted().Transform(segment.GetChordPoint(1, xsi));
                break;
            }
        }
        if (i > wing.GetSegmentCount()) {
            throw CTiglError("Error in getSectionElementChordlinePoint: section element not found!");
        }
    }
    return chordlinePoint;
}
Exemplo n.º 2
0
// Build outer transformation matrix for the positioning
void CCPACSFuselagePositioning::BuildMatrix(void)
{
    // Compose the transformation for the tip section reference point.
    // The positioning transformation is basically a translation in two steps:
    // 1. from the fuselage origin to the startPoint (= endPoint of previous positioning)
    // 2. from the innerPoint to the endPoint with coordinates given
    //    in a "spherical" coordinate system (length, sweepAngle, dihedralAngle).
    // The original section is neither rotated by sweepAngle nor by dihedralAngle.

    // Calculate the cartesian translation components for step two from "spherical" input coordinates
    CTiglTransformation tempTransformation;
    tempTransformation.SetIdentity();
    tempTransformation.AddRotationZ(-sweepangle);
    tempTransformation.AddRotationX(dihedralangle);
    gp_Pnt tempPnt = tempTransformation.Transform(gp_Pnt(0.0, length, 0.0));

    // Setup transformation combining both steps
    endTransformation.SetIdentity();
    endTransformation.AddTranslation( startPoint.x + tempPnt.X() , 
                                        startPoint.y + tempPnt.Y() , 
                                        startPoint.z + tempPnt.Z() );

    // calculate outer section point by transforming origin
    tempPnt = endTransformation.Transform(gp_Pnt(0.0, 0.0, 0.0));
    endPoint.x = tempPnt.X();
    endPoint.y = tempPnt.Y();
    endPoint.z = tempPnt.Z();
}
Exemplo n.º 3
0
// Adds projection an yz plane by setting the x coordinate to 0
void CTiglTransformation::AddProjectionOnYZPlane(void)
{
    // Matrix is:
    //
    // (      0       0       0        0 )
    // (      0       1       0        0 )
    // (      0       0       1        0 )
    // (      0       0       0        1 )

    CTiglTransformation trans;
    trans.SetValue(0, 0, 0.0);

    PreMultiply(trans);
}
Exemplo n.º 4
0
// Adds mirroring at yz plane
void CTiglTransformation::AddMirroringAtYZPlane(void)
{
    // Matrix is:
    //
    // (      -1      0       0        0 )
    // (      0       1       0        0 )
    // (      0       0       1        0 )
    // (      0       0       0        1 )

    CTiglTransformation trans;
    trans.SetValue(0, 0, -1.0);

    PreMultiply(trans);
}
Exemplo n.º 5
0
// Returns the positioning matrix for a given section index
CTiglTransformation CCPACSWingPositionings::GetPositioningTransformation(std::string sectionIndex)
{
    Update();
    CCPACSWingPositioningIterator iter = positionings.find(sectionIndex);
        
    // check, if section has positioning definition, if not
    // return Zero-Transformation
    if (iter == positionings.end()){
        CTiglTransformation zeroTrans;
        zeroTrans.SetIdentity();
        return zeroTrans;
    }
       
    return iter->second->GetOuterTransformation();
}
Exemplo n.º 6
0
// Save a sequence of shapes in IGES Format
void CTiglExportIges::ExportShapes(const ListPNamedShape& shapes, const std::string& filename) const
{
    IGESControl_Controller::Init();

    if ( filename.empty()) {
       LOG(ERROR) << "Error: Empty filename in ExportShapes.";
       return;
    }

    ListPNamedShape::const_iterator it;
    // scale all shapes to mm
    ListPNamedShape shapeScaled;
    for (it = shapes.begin(); it != shapes.end(); ++it) {
        PNamedShape pshape = *it;
        if (pshape) {
            CTiglTransformation trafo;
            trafo.AddScaling(1000,1000,1000);
            PNamedShape pScaledShape(new CNamedShape(*pshape));
            pScaledShape->SetShape(trafo.Transform(pshape->Shape()));
            shapeScaled.push_back(pScaledShape);
        }
    }
    
    ListPNamedShape list;
    for (it = shapeScaled.begin(); it != shapeScaled.end(); ++it) {
        ListPNamedShape templist = GroupFaces(*it, _groupMode);
        for (ListPNamedShape::iterator it2 = templist.begin(); it2 != templist.end(); ++it2) {
            list.push_back(*it2);
        }
    }
    
    SetTranslationParameters();

    IGESControl_Writer igesWriter("MM", 0);
    igesWriter.Model()->ApplyStatic();

    int level = 0;
    for (it = list.begin(); it != list.end(); ++it) {
        PNamedShape pshape = *it;
        AddToIges(pshape, igesWriter, level++);
    }

    igesWriter.ComputeModel();

    if (igesWriter.Write(const_cast<char*>(filename.c_str())) != Standard_True) {
        throw CTiglError("Error: Export of shapes to IGES file failed in CCPACSImportExport::SaveIGES", TIGL_ERROR);
    }
}
Exemplo n.º 7
0
void CTiglTransformation::AddScaling(double sx, double sy, double sz)
{
    // Matrix is:
    //
    // (     sx       0       0        0 )
    // (      0      sy       0        0 )
    // (      0       0       sz       0 )
    // (      0       0       0        1 )

    CTiglTransformation trans;
    trans.SetValue(0, 0, sx);
    trans.SetValue(1, 1, sy);
    trans.SetValue(2, 2, sz);

    PreMultiply(trans);
}
Exemplo n.º 8
0
// Adds a translation to this transformation. Translation part
// is stored in the last column of the transformation matrix.
void CTiglTransformation::AddTranslation(double tx, double ty, double tz)
{
    // Matrix is:
    //
    // (      1       0       0       tx )
    // (      0       1       0       ty )
    // (      0       0       1       tz )
    // (      0       0       0        1 )

    CTiglTransformation trans;
    trans.SetValue(0, 3, tx);
    trans.SetValue(1, 3, ty);
    trans.SetValue(2, 3, tz);

    PreMultiply(trans);
}
TopoDS_Wire CCPACSControlSurfaceDeviceAirfoil::GetWire(CTiglControlSurfaceBorderCoordinateSystem& coords)
{
    CCPACSWingProfile& profile =_config->GetWingProfile(_airfoilUID);
    TopoDS_Wire w = profile.GetWire();

    // scale
    CTiglTransformation scale;
    scale.AddScaling(coords.getLe().Distance(coords.getTe()), 1, _scalZ);

    // bring the wire into the coordinate system of
    // the airfoil by swapping z with y
    gp_Trsf trafo;
    trafo.SetTransformation(gp_Ax3(gp_Pnt(0,0,0), gp_Vec(0,-1,0), gp_Vec(1,0,0)));
    CTiglTransformation flipZY(trafo);

    // put the airfoil to the correct place
    CTiglTransformation position(coords.globalTransform());

    // compute the total transform
    CTiglTransformation total;
    total.PreMultiply(scale);
    total.PreMultiply(flipZY);
    total.PreMultiply(position);
    w = TopoDS::Wire(total.Transform(w));
    return w;
}
Exemplo n.º 10
0
void CTiglTransformation::AddRotationZ(double degreeZ)
{
    double radianZ = DegreeToRadian(degreeZ);
    double sinVal  = sin(radianZ);
    double cosVal  = cos(radianZ);

    // Matrix is:
    //
    // ( cosVal -sinVal       0        0 )
    // ( sinVal  cosVal       0        0 )
    // (      0       0       1        0 )
    // (      0       0       0        1 )

    CTiglTransformation trans;
    trans.SetValue(0, 0, cosVal);
    trans.SetValue(0, 1, -sinVal);
    trans.SetValue(1, 0, sinVal);
    trans.SetValue(1, 1, cosVal);

    PreMultiply(trans);
}
Exemplo n.º 11
0
void CTiglTransformation::AddRotationY(double degreeY)
{
    double radianY = DegreeToRadian(degreeY);
    double sinVal  = sin(radianY);
    double cosVal  = cos(radianY);

    // Matrix is:
    //
    // ( cosVal       0  sinVal        0 )
    // (      0       1       0        0 )
    // (-sinVal       0  cosVal        0 )
    // (      0       0       0        1 )

    CTiglTransformation trans;
    trans.SetValue(0, 0, cosVal);
    trans.SetValue(0, 2, sinVal);
    trans.SetValue(2, 0, -sinVal);
    trans.SetValue(2, 2, cosVal);

    PreMultiply(trans);
}
Exemplo n.º 12
0
void CTiglTransformation::AddRotationX(double degreeX)
{
    double radianX = DegreeToRadian(degreeX);
    double sinVal  = sin(radianX);
    double cosVal  = cos(radianX);

    // Matrix is:
    //
    // (      1       0       0        0 )
    // (      0  cosVal -sinVal        0 )
    // (      0  sinVal  cosVal        0 )
    // (      0       0       0        1 )

    CTiglTransformation trans;
    trans.SetValue(1, 1, cosVal);
    trans.SetValue(1, 2, -sinVal);
    trans.SetValue(2, 1, sinVal);
    trans.SetValue(2, 2, cosVal);

    PreMultiply(trans);
}