ex_meas

<< Click to Display Table of Contents >>

Navigation:  User DLLs > Writing DLLs > Samples >

ex_meas

The sample ex_meas.dsp is a Visual C++ project file that provides a simple example of a user-written measurement routine. By building the DLL module for this project and loading the resulting DLL file into 3DCS, the User-DLL Measure GUI will show the loaded routine in the user-routines pulldown. The code from the file userfunc.cpp for this project is shown below. The name that will appear in the pulldown for the User-DLL Measure GUI's user-routines will be "Example Measure" as defined in the code below. The routine utilizes the wpMEASCAL_s (from dcs_ufnc.h) structure to read the model data and subsequently calculate a point-to-point measurement along an input direction vector.

 

// 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);

}