<< Click to Display Table of Contents >> Navigation: User DLLs > Writing DLLs > Samples > ex_meas |
// dcs headers
#include "dcs_defn.h"
#include "dcs_ufnc.h"
#include "userfunc.h"
/****************************************************************************/
/* Implement your measurement routines here */
/****************************************************************************/
// This is an example measurement .dll function that measures the deviation
// of a point in the direction perpendicular to two non-parallel input direction vectors.
char dcsMeasName1[] = "Example Measure";
char* dcsGetMeasFuncName1() { return dcsMeasName1;}
void userMeasFunc1(dcsDataPtr* pDataPtr)
{
wpMEASCAL_s* pMeasPtr = (wpMEASCAL_s*)pDataPtr; // measurement object pointer
if (pMeasPtr == wpNULL)
{
dcsApiLogWrite("Example Measure Error: **** NULL input\n");
return;
}
// determine input number of points
int ptNum = pMeasPtr->m_PtList1Num + pMeasPtr->m_PtList2Num;
if (ptNum < 1)
{
dcsApiLogWrite("Example Measure Error: **** Not enough points\n");
return;
}
// determine number of input directions
int dirNum = pMeasPtr->m_NumDirVec;
if (dirNum < 1)
{
dcsApiLogWrite("Example Measure Error: **** Not enough directions\n");
return;
}
wpVEC3D_s measVec = msGlbGetDirVec(pMeasPtr, 0);
// 6/7/02 use new dcs_ufnc interface
// compute measurement
wpVEC3D_s vec1;
if (pMeasPtr->m_PtList1Num > 0) // obtain from list1
vec1 = msGlbGetPtList1VecAt(pMeasPtr, 0);
else // obtain from list2
vec1 = msGlbGetPtList2VecAt(pMeasPtr, 0);
wpVEC3D_s vec2 = msGlbGetNominalVec(pMeasPtr); // nominal location of point
wpGlbSubtractVec3D(&vec1, vec2);
double measure = wpGlbDotProductOfVec3D(vec1, measVec);
msGlbSetMeasVal(pMeasPtr, measure);
}