9.5.2. Interface Definition

9.5.2.1. Common Interface

The user must define certain data structures and functions to make a UserIO module. The code sample below shows the minimum requirements. The UserImport and UserExport functions are both empty. This interface is defined in the bgUserIO.h file.

// bgUserIO_Blank.cpp

#include "StdAfx.h"

#include "bgUserIO.h"

//---------------------------------------------------
// Error message enumeration
//
enum {
		SuccessMsg,
		nMsg
};

//---------------------------------------------------

// Error message strings
//
const char *pszErrMsg[nMsg] = {
		"Success",
};

//---------------------------------------------------
// Required Data Structures
//
const int						g_iOrder = 10;										// specifies the location in menu
const FileType				g_eImport = NoFile;						// specifies the file type for import
const FileType				g_eExport = NoFile;						// specifies the file type for export
const char						g_szFileDesc[64] = "UserIO";		// specifies the text for the menu and file type

const char						g_szFileType[16] = "usr";				// specifies the file extension
const int						g_nErrorMsg = nMsg;						// specifies the number of error strings
const char**				g_ppszErrorMsg = pszErrMsg;		// specifes the error strings defined above

//---------------------------------------------------
// UserImport function
//
int UserImport( const char *pszUserPath, BgModel &Model )
{
		return -1;		// Return -1 to indicate that function is not supported

}

//---------------------------------------------------
// UserExport function
//
int UserExport( const char *pszUserPath, const char *pszBladeGenFileName, BgModel &Model )
{
		return -1;		// Return -1 to indicate that function is not supported
}

9.5.2.2. Export Interface

When the export interface is enabled (by setting g_eExport) this function can be called by main. However, it must always be defined. If unused, return -1.

int UserExport( const char *pszUserPath, const char *pszBladeGenFileName, BgModel &Model );

The parameter pszUserPath will contain the name of the user file specified on the command line. The parameter Model will contain the model from the BladeGen file specified on the command line and all access to the model is provided by the BgModel class.

As is common practice for C++, all indices (blade and layer) are zero based. These functions are accessed using the supplied Model parameter, as below.

int nBladeSets = Model.NumBladeSets();
int nBlades    = Model.NumBlades();
int nLayers    = Model.NumLayers();

BgMLDatArr DatArr;
if ( !Model.BladeLayerData( 0, 0, BgModel::LeaveSquare, DatArr ) ) {
		return DataCreationError;
}

Available BgModel Member Functions for Exporting Data

Basic information about the number of blade sets, blades, and layers are provided by these functions.

int NumBladeSets();
int NumBlades();
int NumLayers();

The export of mean line data is provided by these functions. Mean line data is created for the specified blade and layer using the specified flags to control leading and trailing edge creation. The data is returned in the supplied DatArr. The value returned indicates if the operation was completed successfully. Use the BgModel::AddType enum values to specify the uiFlags parameter.

bool PeriodicLayerData( int nLayer, BgMLDatArr &DatArr );
bool BladeLayerData( int nBlade, int nLayer, uint uiFlags, BgMLDatArr &DatArr );
bool ExBladeLayerData( int nBlade, int nLayer, uint uiFlags, BgMLDatArr &DatArr );

Rough information about the location of a layer can be obtained with this functions.

double MidLenSpanFraction( int nLayer ) const;

Some blade information is provided by these functions.

bool AreaProps( int nBlade, int nLayer, BgMLDat &mldCentroid, double &dArea );
double PitchFraction( int nBlade ) const;

These functions provide information on the type of leading and trailing edge for the specified blade. See the definition of EndType in the header for BgModel.

EndType BladeLeEndType( int nBlade ) const;
EndType BladeTeEndType( int nBlade ) const;

These functions provide information on how many points are located in the leading and trailing edges for the specified blade. Setting bExtended to true provides the number of points with the extension, if it was defined in the model.

int NumLePoints( int nBlade, bool bExtended=false ) const;
int NumTePoints( int nBlade, bool bExtended=false ) const;

These two functions provide conversions between Meridional Position (U,V) and Meridional Coordinates (Z,R). The return value indicates whether the requested operation was successful.

bool PntAt( const double &dU, const double &dV, double &dZ, double &dR );
bool CoordAt( const double &dZ, const double &dR, double &dU, double &dV );

9.5.2.3. Import Interface

When the import interface is enabled (by setting g_eImport) this function can be called by main. However, it must always be defined. If unused, return -1.

int UserImport( const char *pszUserPath, BgModel &Model );

The parameter pszUserPath will contain the name of the user file specified on the command line. The parameter Model is provided to allow construction of the BladeGen model. When this function returns a zero value, the file specified on the command line will be written. Details on the model creation functions are available from the BgModel class.

The functions are laid out below in the order they should be used. The user must first create the Design Meridional Definition, then add the blades, then create the Trim Meridional Definition (if required).

These functions are accessed using the supplied Model parameter.

Available BgModel Member Functions for Importing Data

These functions create the Design Meridional Definition from various forms of mean line data.

bool CreateDsgnMerDef( int nBladeSets, const BgBladeArr &BladeArr, bool bSafeCurveTypes=true, bool bBezierExtensions=false );
bool CreateDsgnMerDef( int nBladeSets, const BgMLDatArrArrArr &MeanArrArrArr, bool bSafeCurveTypes=true, bool bBezierExtensions=false );
bool CreateDsgnMerDef( int nBladeSets, const BgMLDatArrArr &MeanArrArr, bool bSafeCurveTypes=true, bool bBezierExtensions=false );

This function creates a Design Control Curve at the specified location.

bool CreateDsgnCtrlCrv( const BgMLDatArr &Ctrl, const double &dEstS );

These functions create blades, either all at once or one at a time.

bool CreateBlades( const BgBladeArr &BladeArr );
bool CreateBlade( const BgBlade &Blade );

This function creates the Trim Meridional Definition from the hub and shroud curves. If the user specifies NULL for one or both, the corresponding curve from the Design Meridional Definition is used.

bool CreateTrimMerDef( int nLayers, BgMLDatArr *pHub=NULL, BgMLDatArr *pShr=NULL );

This function creates a Trim Control Curve at the specified location.

bool CreateTrimCtrlCrv( const BgMLDatArr &Ctrl, const double &dEstS );