home *** CD-ROM | disk | FTP | other *** search
- #include "ooglutil.h"
- #include "geom.h"
- #include "instP.h"
- #include "pointlistP.h"
-
- void *inst_PointList_get(int sel, Geom *geom, va_list args);
- void *inst_PointList_fillin(int sel, Geom *geom, va_list args);
- void *inst_PointList_set(int sel, Geom *geom, va_list args);
- void *inst_PointList_length(int sel, Geom *geom, va_list args);
-
- #define MAX_METHODS 4
-
- static SpecFunc methods[] = {
- "PointList_get", inst_PointList_get,
- "PointList_fillin", inst_PointList_fillin,
- "PointList_set", inst_PointList_set,
- "PointList_length", inst_PointList_length
- };
-
- static char msg[] = "ptlInst.c";
-
- ptlInst_init() {
- pointlist_initspec(methods, MAX_METHODS, GeomClassLookup("inst"));
- }
-
- void *inst_PointList_get(int sel, Geom *geom, va_list args) {
- Inst *i = (Inst *)geom;
- HPoint3 *plist;
- int n_points;
- float **t;
- int coordsys;
-
- n_points = (int)GeomCall(GeomMethodSel("PointList_length"), geom);
- plist = OOGLNewNE(HPoint3, n_points, msg);
-
- t = va_arg(args, float **);
- coordsys = va_arg(args, int);
-
- return GeomCall(GeomMethodSel("PointList_fillin"), geom, t,
- coordsys, plist);
-
- }
-
- void *inst_PointList_fillin(int sel, Geom *geom, va_list args) {
- Inst *inst = (Inst *)geom;
- HPoint3 *plist;
- int coordsys;
- GeomIter *it;
- Transform Tnew;
- int i, n_points;
- float **t;
-
- t = va_arg(args, float **);
- coordsys = va_arg(args, int);
- plist = va_arg(args, HPoint3 *);
-
- n_points = (int)GeomCall(GeomMethodSel("PointList_length"), inst->geom);
-
- it = GeomIterate(geom, DEEP);
- for (i = 0; NextTransform(it, Tnew); i += n_points)
- if (coordsys == POINTLIST_SELF) {
- TmConcat(Tnew, t, Tnew);
- GeomCall(GeomMethodSel("PointList_fillin"), inst->geom, &Tnew[0][0],
- coordsys, &plist[i]);
- } else if (coordsys == POINTLIST_PRIMITIVE)
- GeomCall(GeomMethodSel("PointList_fillin"), inst->geom, t, coordsys,
- &plist[i]);
- else {
- OOGLError(1, "Unrecognized coordinate system in inst_PointList_fillin");
- return NULL;
- }
-
- return plist;
-
- }
-
-
- void *inst_PointList_set(int sel, Geom *geom, va_list args) {
- Inst *inst = (Inst *)geom;
- HPoint3 *plist;
- Transform T, TInv;
- int coordsys;
- GeomIter *it;
-
- coordsys = va_arg(args, int);
- plist = va_arg(args, HPoint3 *);
-
- /* If the point list has more than one copy of the points
- * of the geom in it, just use the first set */
- it = GeomIterate(geom, DEEP);
- if (NextTransform(it, T) && coordsys == POINTLIST_SELF) {
- Tm3Invert(T, TInv);
- HPt3TransformN(TInv, plist, plist,
- GeomCall(GeomMethodSel("PointList_length"), inst->geom));
- }
- GeomCall(GeomMethodSel("PointList_set"), inst->geom, coordsys, plist);
- return NULL;
-
- }
-
-
- void *inst_PointList_length(int sel, Geom *geom, va_list args) {
- Inst *inst = (Inst *)geom;
- int i, n_points;
- Transform T;
- GeomIter *it;
-
- n_points =
- (int)GeomCall(GeomMethodSel("PointList_length"), inst->geom);
- it = GeomIterate(geom, DEEP);
- for (i = 0; NextTransform(it, T); i += n_points);
- return (void *)i;
-
- }
-