Adding your source code to the code generated by BladeSmith
About this task
For each of the support routine types you selected in
the New Opaque Type wizard, BladeSmith generates the following functions
for the Pnt and Circ data types in the Pnt.c and Circ.c source
code files.
| Support routine category | Routines for Pnt | Routines for Circ |
|---|---|---|
| Text input and output functions | PntInput(), PntOutput() | CircInput(), CircOutput() |
| Binary send and receive functions | PntSend(), PntReceive() | CircSend(), CircReceive() |
| Type compare functions | PntCompare(), PntEqual(), PntNotEqual() | CircCompare(), CircEqual(), CircNotEqual() |
Look at the source code for each of these routines. You can see them in Visual C++ under the Source Files node in the File view. You do not need to modify these routines. BladeSmith creates complete support routines to manipulate the data types that compose the Pnt and Circ opaque types.
You must implement the following functions for the Circle module,
which you can see under the Globals node in
the Class view:
- Distance()
- Contains()
These functions are in the udr.c source code file.
To implement the Distance() and Contains() functions:
Procedure
- Double-click Distance() in the Class view and scroll to the beginning of the udr.c file.
- Add the following statement to the #include statements
at the beginning of the udr.c file to include
the C math library:
#include <math.h>Because the Contains() function calls the Distance() function, you must have a definition of the Distance() function in the udr.c file before the code for the Contains() function.
- Add the following Distance() function
prototype directly after the #include statements in udr.c:
UDREXPORT mi_double_precision *Distance ( Pnt * Pnt1, Pnt * Pnt2, MI_FPARAM * Gen_fparam ); - Implement the Distance() function:
- Implement the Contains() function:
- Check your source code against the final version of udr.c.
- Save the changes to udr.c.