Example API Function
List of: Discussion Topic
Subjects: Extending ACIS, C++ Interface
Contents: Application Development Manual

Example 8-1 shows the function prototype (from the header file) while Example 8-2 shows most of the source file for the API function api_make_cuboid. The prototype is in the header file <install_dir>/cstr/constrct/kernapi/api/cstrapi.hxx:

C++ Example

DECL_CSTR outcome api_make_cuboid(



double,


// size in x coordinate direction



double,


// size in y coordinate direction



double,


// size in z coordinate direction



BODY *&


// body constructed


);

Example 8-1. Header File for api_make_cuboid

Example 8-2 contains most of the source file, <install_dir>/cstr/constrct/kernapi/api/mkcuboid.cxx:

C++ Example

#include "kernel/acis.hxx"
#include "kernel/dcl_kern.h"
#include "constrct/kernapi/api/cstrapi.hxx"
#include "kernel/kernapi/api/api.hxx"

// {... Documentation code template not shown ...}

// Include files:
#include <stdio.h>
#include "kernel/logical.h"
#include "kernel/kernapi/api/check.hxx"
#include "kernel/kernapi/api/api.err"
#include "constrct/kernbody/primtive/primtive.hxx"
#include "kernel/kerndata/top/body.hxx"
#include "kernel/kernutil/debug/module.hxx"

#define MODULE() api
MODULE_REF(KERN);

// ************************************************************
outcome api_make_cuboid(

double
width,

double
depth,

double
height,

BODY*&
body )
{

DEBUG_LEVEL(DEBUG_CALLS)


fprintf(debug_file_ptr, "calling api_make_cuboid\n");


API_BEGIN



if (api_checking_on)


{



check_pos_length(width, "width");



check_pos_length(depth, "depth");



check_non_neg_length(height, "height");


}



body = make_parallelepiped( width, depth, height );


result = outcome( body == NULL ? API_FAILED : 0 );


API_END


DEBUG_LEVEL(DEBUG_FLOW)


fprintf(debug_file_ptr, "leaving api_make_cuboid: %s\n",


find_err_ident(result.error_number()));


return result;
}

Example 8-2. Source File for api_make_cuboid
PDF/APPDEV/08EXT.PDF
HTM/DATA/ACIS/APPDEV/08EXT/0010.HTM