|
Prisms Development Toolkit Documentation
Side Effects Software Inc. 1997
|
Custom SOPs
Example 3: A simple merge SOP
This demonstrates accepting multiple inputs and collecting them
together into a single new polydetail. This is the Prisms Merge
SOP, stripped of any pattern specification or transform object
technology. The heart of this SOP is the
PolyJoin command.
#include <custom.h>
typedef struct sop_data {
/* there are no input parameters */
} SOP_DATA;
#define NSOURCES 6
static SOP_PARMS sopParms[] = {
/* so there are no specifiers here */
{ NULL },
};
static char *sopHelp[] = {
"This SOP merges polygons from up to six\
source SOPs. It doesn't do anything else.",
" ",
0,
};
static void
sopScan(SOP *sop, int argc, char *argv[])
{
SOP_DATA *sb;
int i;
/* this sop takes no input */
sb = (SOP_DATA *)sop->special;
}
static void
sopPrint(FILE *fp, SOP *sop)
{
SOP_DATA *sb;
char option[3];
int i;
/* this sop has no arguments to output */
sb = (SOP_DATA *)sop->special;
}
static void
sopCook(SOP *sop)
{
int i;
PolyDetail *pdp[6], *opdp;
SOP_DATA *sb;
OBJECT *magic;
sb = (SOP_DATA *)sop->special;
/* read in all the source geometry - pdp[i] is set to NULL
if there is no geometry associated with that input */
for (i=0; i<6; i++)
{
pdp[i] = SopGetSource(sop, i);
}
if (sop->pdp) FreePolyDetail(sop->pdp);
/* allocate a new polydetail, and initialize it */
sop->pdp = (PolyDetail *)PolyAlloc(POLYDETAIL);
InitPolyDetail(sop->pdp);
/* join them all together into one object */
for (i=0; i<6; i++)
{
if (!pdp[i]) continue;
PolyJoin(sop->pdp, pdp[i]);
}
PolyNum(sop->pdp);
CLEARSOPNML(sop)
}
static void
sopDefaults(SOP *sop) /* Put in default values */
{
SOP_DATA *sb;
int i;
if (sop->special) free(sop->special);
sb = (SOP_DATA *)Calloc(sizeof(SOP_DATA), "SOPMergeDefaults");
sop->special = (char *)sb;
sop->nsources = 6;
}
static void
sopClean(SOP *sop)
{
int i;
SOP_DATA *sb;
FreeSopExpr((SOP_EXPR *)sop->special, sopParms);
if (sop->pdp) FreePolyDetail(sop->pdp);
sop->pdp = NULL;
free(sop->special);
sop->special = NULL;
}
static char *srclabels[] = {
"Source 1",
"Source 2",
"Source 3",
"Source 4",
"Source 5",
"Source 6",
};
GETSOPPARMS
static void
sopGPMake(UI_DBOX *dbp, SOP *sop)
{
InitSopParms(sop);
BuildCommonSopGadgets(sop, NSOURCES, sopParms,
sopHelp, dbp, srclabels);
}
#define SOPUSAGE \
"smmerge"
SOP_FUNC MmergeSopRef = {
"mmerge",
"",
sopScan, sopPrint, sopCook, sopDefaults, sopClean, sopGPMake,
sopGetParms,
SOPUSAGE,
};
Tookit Overview
Expression Functions |
User Functions |
Custom SOPs
Prisms Internal Format |
Programmer's Reference
Compiling SOPs |
Using sopbuild |
SOP Routine Reference
Dynamic SOPs |
Prisms Types |
Macros
Math Routines |
Data Routines |
Polygon Routines |
Winged-edge Routines
Copyright © 1997 Side Effects Software Inc.
477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7