/******************************************************************************\**  MODULE:      DLLFuns.C**  PURPOSE:     To provide a Demo function PIE. **  FUNCTIONS:  **  COMMENTS:   \******************************************************************************/#include <math.h>#include "FunctionPIE.h"#include "ANECB.h"#pragma lib_export onextern "C" void GetANEFunctions(long* numNames, struct ANEPIEDesc*** descriptors);#pragma lib_export off//==============================================================================// PIE Function definition//==============================================================================//------------------------------------------------------------------------------// GPIEAbs://------------------------------------------------------------------------------// Function definition:// 	Define an abs function that (surprise!) return the abs value of// its parameter////------------------------------------------------------------------------------static voidGPIEAbsMMFun(const ANE_DOUBLE&				refPtX,				const ANE_DOUBLE&			refPtY,				ANE_INT16				numParams,				const ANE_PTR*		parameters,				ANE_PTR				myHandle,				ANE_PTR				reply ){	ANE_DOUBLE param1 = *(ANE_DOUBLE*)(parameters[0]);		*(ANE_DOUBLE*)reply = fabs(param1);} // GRunPTCMMFun// GPIEF2C://------------------------------------------------------------------------------// Function definition:// 	Define a conversion function (Farenheit->Celsius)//------------------------------------------------------------------------------static voidGPIEF2CMMFun(const ANE_DOUBLE&				refPtX,				const ANE_DOUBLE&			refPtY,				ANE_INT16				numParams,				const ANE_PTR*		parameters,				ANE_PTR				myHandle,				ANE_PTR		reply ){	ANE_DOUBLE param1 = *(ANE_DOUBLE*)(parameters[0]);		*(ANE_DOUBLE*)reply = (param1-32)/1.8;} // GPIEF2CMMFun// GPIEC2F://------------------------------------------------------------------------------// Function definition:// 	Define an a conversion function (Celsius->Faranheit)//------------------------------------------------------------------------------static voidGPIEC2FMMFun(const ANE_DOUBLE&				refPtX,				const ANE_DOUBLE&			refPtY,				ANE_INT16					numParams,				const ANE_PTR*		parameters,				ANE_PTR		myHandle,				ANE_PTR		reply ){	ANE_DOUBLE param1 = *(ANE_DOUBLE*)(parameters[0]);		*(ANE_DOUBLE*)reply = param1*1.8+32;} // GPIEC2FMMFun// GPIEMi2Km://------------------------------------------------------------------------------// Function definition:// 	Define aconversion function (Miles->Kilometers)//------------------------------------------------------------------------------static voidGPIEMi2KmMMFun(const ANE_DOUBLE&				refPtX,				const ANE_DOUBLE&			refPtY,				ANE_INT16					numParams,				const ANE_PTR*		parameters,				ANE_PTR		myHandle,				ANE_PTR		reply ){	ANE_DOUBLE param1 = *(ANE_DOUBLE*)(parameters[0]);		*(ANE_DOUBLE*)reply = param1*1.609344;} // GPIEMi2KmMMFun// GPIEKm2Mi://------------------------------------------------------------------------------// Function definition:// 	Define a conversion function (Kilometers -> Miles)//------------------------------------------------------------------------------static voidGPIEKm2MiMMFun(const ANE_DOUBLE&				refPtX,				const ANE_DOUBLE&			refPtY,				ANE_INT16					numParams,				const ANE_PTR*		parameters,				ANE_PTR				myHandle,				ANE_PTR		reply ){	ANE_DOUBLE param1 = *(ANE_DOUBLE*)(parameters[0]);		*(ANE_DOUBLE*)reply = param1/1.609344;} // GPIEMi2KmMMFun// GPIEPolarR://------------------------------------------------------------------------------// Function definition:// 	Define a conversion from (x,y) verctor to polar notation, return R part//------------------------------------------------------------------------------static voidGPIEPolarRMMFun(const ANE_DOUBLE&				refPtX,				const ANE_DOUBLE&			refPtY,				ANE_INT16					numParams,				const ANE_PTR*		parameters,				ANE_PTR				myHandle,				ANE_PTR		reply ){	ANE_DOUBLE x = *(ANE_DOUBLE*)(parameters[0]);	ANE_DOUBLE y = *(ANE_DOUBLE*)(parameters[1]);		*(ANE_DOUBLE*)reply = sqrt(x*x+y*y);} // GPIEPolarRMMFun// GPIEPolarTheta://------------------------------------------------------------------------------// Function definition:// 	Define a conversion from (x,y) verctor to polar notation, return Theta part//------------------------------------------------------------------------------static voidGPIEPolarThetaMMFun(const ANE_DOUBLE&				refPtX,				const ANE_DOUBLE&			refPtY,				ANE_INT16					numParams,				const ANE_PTR*		parameters,				ANE_PTR		myHandle,				ANE_PTR		reply ){	ANE_DOUBLE x = *(ANE_DOUBLE*)(parameters[0]);	ANE_DOUBLE y = *(ANE_DOUBLE*)(parameters[1]);		*(ANE_DOUBLE*)reply = atan2(y,x);} // GPIEPolarThetaMMFun//=================================================================//	PIE handling functions and declerations//=================================================================struct ANEPIEDesc* gFunDesc[20];								// list of PIE descriptors for all parts//// "PIE_RunPTC" function partstruct ANEPIEDesc					gPIEAbsDesc;				// PIE defcriptorstruct FunctionPIEDesc			gPIEAbsFDesc;				// Function descriptorchar* gpnNumber[2] = {"Number", 0};										// list of  parameters names list for functionenum EPIENumberType	gOneFloatTypes[2] = {kPIEFloat, (EPIENumberType)0};	// list of  parameters types list for function//struct ANEPIEDesc					gPIEF2CDesc;				// PIE defcriptorstruct FunctionPIEDesc			gPIEF2CFDesc;				// Function descriptorchar* gpnFarenheit[2] = {"Farenheit Degrees", 0};			// list of  parameters names list for function//struct ANEPIEDesc					gPIEC2FDesc;				// PIE defcriptorstruct FunctionPIEDesc			gPIEC2FFDesc;				// Function descriptorchar* gpnCelsius[2] = {"Celsius Degrees", 0};				// list of parameters names list for function//struct ANEPIEDesc					gPIEMi2KmDesc;				// PIE defcriptorstruct FunctionPIEDesc			gPIEMi2KmFDesc;				// Function descriptorchar* gpnMiles[2] = {"Miles", 0};							// list of  parameters names list for function//struct ANEPIEDesc					gPIEKm2MiDesc;				// PIE defcriptorstruct FunctionPIEDesc			gPIEKm2MiFDesc;				// Function descriptorchar* gpnKilometers[2] = {"kilometers", 0};							// list of  parameters names list for function//struct ANEPIEDesc					gPIEPolarRDesc;				// PIE defcriptorstruct FunctionPIEDesc			gPIEPolarRFDesc;				// Function descriptorchar* gpnCartesian[3] = {"X Coordinate", "Y Coordinate", 0};							// list of  parameters names list for functionenum EPIENumberType	gTwoFloatTypes[3] = {kPIEFloat, kPIEFloat, (EPIENumberType)0};	// list of  parameters types list for function//struct ANEPIEDesc					gPIEPolarThetaDesc;				// PIE defcriptorstruct FunctionPIEDesc			gPIEPolarThetaFDesc;				// Function descriptor//voidGetANEFunctions(long* numNames, struct ANEPIEDesc*** descriptors){ 	*numNames = 0;	//	// prepare FUNCTION descriptor for "PIE_Abs" function	gPIEAbsFDesc.name = "PIE_Abs";						// name of function	gPIEAbsFDesc.address = GPIEAbsMMFun;					// function address	gPIEAbsFDesc.returnType = kPIEFloat;						// return value type	gPIEAbsFDesc.numParams =  1;							// number of parameters	gPIEAbsFDesc.numOptParams = 0;							// number of optional parameters	gPIEAbsFDesc.paramNames = gpnNumber;						// pointer to parameter names list	gPIEAbsFDesc.paramTypes = gOneFloatTypes;				// pointer to parameters types list	gPIEAbsDesc.name  = "PIE_Abs";						// name of PIE	gPIEAbsDesc.type =  kFunctionPIE;						// PIE type: PIE function	gPIEAbsDesc.descriptor = &gPIEAbsFDesc;					// pointer to descriptor		gFunDesc[(*numNames)++] = &gPIEAbsDesc;					// add descriptor to list	//	// prepare FUNCTION descriptor for "PIE_Far2Cel" function	gPIEF2CFDesc.name = "PIE_Far2Cel";						// name of function	gPIEF2CFDesc.address = GPIEF2CMMFun;					// function address	gPIEF2CFDesc.returnType = kPIEFloat;						// return value type	gPIEF2CFDesc.numParams =  1;							// number of parameters	gPIEF2CFDesc.numOptParams = 0;							// number of optional parameters	gPIEF2CFDesc.paramNames = gpnFarenheit;						// pointer to parameter names list	gPIEF2CFDesc.paramTypes = gOneFloatTypes;				// pointer to parameters types list	gPIEF2CDesc.name  = "PIE_Far2Cel";						// name of PIE	gPIEF2CDesc.type =  kFunctionPIE;						// PIE type: PIE function	gPIEF2CDesc.descriptor = &gPIEF2CFDesc;					// pointer to descriptor		gFunDesc[(*numNames)++] = &gPIEF2CDesc;					// add descriptor to list	//	// prepare FUNCTION descriptor for "PIE_Cel2Far" function	gPIEC2FFDesc.name = "PIE_Cel2Far";						// name of function	gPIEC2FFDesc.address = GPIEC2FMMFun;					// function address	gPIEC2FFDesc.returnType = kPIEFloat;						// return value type	gPIEC2FFDesc.numParams =  1;							// number of parameters	gPIEC2FFDesc.numOptParams = 0;							// number of optional parameters	gPIEC2FFDesc.paramNames = gpnCelsius;						// pointer to parameter names list	gPIEC2FFDesc.paramTypes = gOneFloatTypes;				// pointer to parameters types list	gPIEC2FDesc.name  = "PIE_Cel2Far";						// name of PIE	gPIEC2FDesc.type =  kFunctionPIE;						// PIE type: PIE function	gPIEC2FDesc.descriptor = &gPIEC2FFDesc;					// pointer to descriptor		gFunDesc[(*numNames)++] = &gPIEC2FDesc;					// add descriptor to list	//	// prepare FUNCTION descriptor for "PIE_Mi2Km" function	gPIEMi2KmFDesc.name = "PIE_Miles2Km";						// name of function	gPIEMi2KmFDesc.address = GPIEMi2KmMMFun;					// function address	gPIEMi2KmFDesc.returnType = kPIEFloat;						// return value type	gPIEMi2KmFDesc.numParams =  1;							// number of parameters	gPIEMi2KmFDesc.numOptParams = 0;							// number of optional parameters	gPIEMi2KmFDesc.paramNames = gpnMiles;						// pointer to parameter names list	gPIEMi2KmFDesc.paramTypes = gOneFloatTypes;				// pointer to parameters types list	gPIEMi2KmDesc.name  = "PIE_Miles2Km";						// name of PIE	gPIEMi2KmDesc.type =  kFunctionPIE;						// PIE type: PIE function	gPIEMi2KmDesc.descriptor = &gPIEMi2KmFDesc;					// pointer to descriptor		gFunDesc[(*numNames)++] = &gPIEMi2KmDesc;					// add descriptor to list	//	// prepare FUNCTION descriptor for "PIE_Km2Mi" function	gPIEKm2MiFDesc.name = "PIE_Km2Miles";						// name of function	gPIEKm2MiFDesc.address = GPIEKm2MiMMFun;					// function address	gPIEKm2MiFDesc.returnType = kPIEFloat;						// return value type	gPIEKm2MiFDesc.numParams =  1;							// number of parameters	gPIEKm2MiFDesc.numOptParams = 0;							// number of optional parameters	gPIEKm2MiFDesc.paramNames = gpnKilometers;						// pointer to parameter names list	gPIEKm2MiFDesc.paramTypes = gOneFloatTypes;				// pointer to parameters types list	gPIEKm2MiDesc.name  = "PIE_Km2Miles";						// name of PIE	gPIEKm2MiDesc.type =  kFunctionPIE;						// PIE type: PIE function	gPIEKm2MiDesc.descriptor = &gPIEKm2MiFDesc;					// pointer to descriptor		gFunDesc[(*numNames)++] = &gPIEKm2MiDesc;					// add descriptor to list	//	// prepare FUNCTION descriptor for "PIE_PolarR" function	gPIEPolarRFDesc.name = "PIE_PolarR";						// name of function	gPIEPolarRFDesc.address = GPIEPolarRMMFun;					// function address	gPIEPolarRFDesc.returnType = kPIEFloat;						// return value type	gPIEPolarRFDesc.numParams =  2;							// number of parameters	gPIEPolarRFDesc.numOptParams = 0;							// number of optional parameters	gPIEPolarRFDesc.paramNames = gpnCartesian;						// pointer to parameter names list	gPIEPolarRFDesc.paramTypes = gOneFloatTypes;				// pointer to parameters types list	gPIEPolarRDesc.name  = "PIE_PolarR";						// name of PIE	gPIEPolarRDesc.type =  kFunctionPIE;						// PIE type: PIE function	gPIEPolarRDesc.descriptor = &gPIEPolarRFDesc;					// pointer to descriptor		gFunDesc[(*numNames)++] = &gPIEPolarRDesc;					// add descriptor to list	//	// prepare FUNCTION descriptor for "PIE_PolarTheta" function	gPIEPolarThetaFDesc.name = "PIE_PolarTheta";						// name of function	gPIEPolarThetaFDesc.address = GPIEPolarThetaMMFun;					// function address	gPIEPolarThetaFDesc.returnType = kPIEFloat;						// return value type	gPIEPolarThetaFDesc.numParams =  2;							// number of parameters	gPIEPolarThetaFDesc.numOptParams = 0;							// number of optional parameters	gPIEPolarThetaFDesc.paramNames = gpnCartesian;						// pointer to parameter names list	gPIEPolarThetaFDesc.paramTypes = gOneFloatTypes;				// pointer to parameters types list	gPIEPolarThetaDesc.name  = "PIE_PolarTheta";						// name of PIE	gPIEPolarThetaDesc.type =  kFunctionPIE;						// PIE type: PIE function	gPIEPolarThetaDesc.descriptor = &gPIEPolarThetaFDesc;					// pointer to descriptor		gFunDesc[(*numNames)++] = &gPIEPolarThetaDesc;					// add descriptor to list	*descriptors = gFunDesc;} 
