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;
}
Esempio n. 2
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);
    }
}