ex_move

<< Click to Display Table of Contents >>

Navigation:  User DLLs > Writing DLLs > Samples >

ex_move

The sample ex_move.dsp is a Visual C++ project file that provides a simple example of a user-written move routine. By building the DLL module for this project and loading the resulting DLL file into 3DCS, the User-DLL Move 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 Move GUI's user-routines will be "Example Move" as defined in the code below. The routine utilizes the wpMOVECAL_s (from dcs_ufnc.h) structure to read the model data and subsequently calculate a 3-point move from the specified object and target points.

 

// dcs headers

#include "dcs_defn.h"

#include "dcs_ufnc.h"

#include "userfunc.h"

 

/****************************************************************************/

/* Implement your move routines here */

/****************************************************************************/

 

// This is a sample move .dll function that performs a three point move.

 

char dcsMoveName1[] = "Example Move";

char* dcsGetMoveFuncName1() { return dcsMoveName1;}

 

void userMoveFunc1(dcsDataPtr* pDataPtr)

{

wpMOVECAL_s* pMovePtr = (wpMOVECAL_s*)pDataPtr;

if (pMovePtr == wpNULL) return;

 

pMovePtr->m_IsMvInfoCal = wpTRUE;

 

int objNum = pMovePtr->m_NumObjVec; // number of object points

int tgtNum = pMovePtr->m_NumTgtVec; // number of target points

 

if (objNum != 3 || tgtNum != 3) return; // enforce move requirements

 

// get move data

int ii;

wpVEC3D_s objVec[3];

wpVEC3D_s tgtVec[3];

wpBOOL retv;

 

for (ii = 0; ii < 3; ii++)

{

objVec[ii] = mvGlbGetObjVec(pMovePtr, ii); // object vectors

tgtVec[ii] = mvGlbGetTgtVec(pMovePtr, ii); // target vectors

}

 

// get three point move parameters

wpVEC3D_s transVec; // translation vector

wpVEC3D_s axis1, axis2; // rotation axes

double angle1, angle2; // rotation angles

 

retv = mvGlbThreePt3Move(objVec[0], objVec[1], objVec[2], // three point move

tgtVec[0], tgtVec[1], tgtVec[2], &transVec, &axis1, &angle1, &axis2, &angle2);

 

if (retv == wpFALSE) pMovePtr->m_IsMvInfoCal = wpFALSE;

 

// pass move information back to 3-Dcs

if (pMovePtr->m_IsMvInfoCal != wpFALSE)

{

wpVEC3D_s rtVec = tgtVec[0]; // rotation point

int pairNum = 2;

 

mvGlbSetMovePairNum(pMovePtr, pairNum); // allocate memory

 

ii = 0;

mvGlbSetMoveTrInfo(pMovePtr, ii, transVec); // pass translation vector

mvGlbSetMoveRtInfo(pMovePtr, ii, rtVec, axis1, angle1); // pass rotation information

 

ii++;

mvGlbSetMoveRtInfo(pMovePtr, ii, rtVec, axis2, angle2); // pass rotation information

}

}