/* MINMAX -- Format the minimum and maximum values of a parameter, if any. */ char * minmax ( register struct param *pp ) { static char message[SZ_LINE]; /* Show the ranges if they are defined and this is a parameter * type that has ranges. */ if (range_check (pp)) { char str[SZ_LINE]; struct operand o; o.o_type = pp->p_type & OT_BASIC; sprintf (message, " (minimum="); if (!(pp->p_flags & (P_IMIN|P_UMIN))) { o.o_val = pp->p_min; sprop (str, &o); strcat (message, str); } strcat (message, ": maximum="); if (!(pp->p_flags & (P_IMAX|P_UMAX))) { o.o_val = pp->p_max; sprop (str, &o); strcat(message, str); } strcat (message, ")"); } else message[0] = EOS; return (message); }
/* SHOW_PARAM -- Print the name and value of a parameter on the output file * in the format `task.param = value'. */ void show_param (struct ltask *ltp, struct param *pp, FILE *fp) { char buf[SZ_LINE+1]; int isstr; if (ltp) fprintf (fp, "%s.%s", ltp->lt_lname, pp->p_name); else fputs (pp->p_name, fp); fputs (" = ", fp); if (!(pp->p_valo.o_type & OT_UNDEF)) { sprop (buf, &pp->p_valo); isstr = ((pp->p_type & OT_BASIC) == OT_STRING && *buf != PF_INDIRECT); if (isstr) fputc ('"', fp); fputs (buf, fp); if (isstr) fputc ('"', fp); } fputc ('\n', fp); }
ReflectionComponent Animation::Reflection(Animation* val) { ReflectionComponent refcomp; Property sprop(Property::STRING); (refcomp.properties["Animation Name"] = sprop).Set<std::string>(val->animation_name); refcomp.properties["Animation Name"].update_func = [val] (Property& prop) { val->animation_name = prop.Get<std::string>(); }; Property iprop(Property::INTEGER); (refcomp.properties["Current Frame"] = sprop).Set<int>(val->current_frame_index); refcomp.properties["Current Frame"].update_func = [val] (Property& prop) { val->current_frame_index = prop.Get<int>(); }; return std::move(refcomp); }
void write() { Abc::OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(), "HasAMaterial.abc" ); Abc::OObject root(archive, Abc::kTop); //BEGIN Manually create and test schemas and compounds { Abc::OObject obj(root, "an_object"); Mat::OMaterialSchema mat(Mat::OMaterialSchema(obj.getProperties(), ".byanyothername")); mat.setShader("prman", "surface", "ambocc"); { Abc::OCompoundProperty compound(obj.getProperties(), "butnotbythisone"); Abc::OStringProperty sprop(compound, "value"); sprop.set("hello"); } { //add a .material but not created with the schema Abc::OCompoundProperty compound(obj.getProperties(), ".material"); Abc::OStringProperty sprop(compound, "value"); sprop.set("world"); } //END Manually create and test schemas and compounds } //BEGIN Test assignment and has-a mechanisms { { Abc::OObject anotherObj(root, "another_object"); Mat::addMaterialAssignment(anotherObj, "/some/material"); Mat::OMaterialSchema mat = Mat::addMaterial(anotherObj); mat.setShader("prman", "surface", "carpet"); } //END Test assignment and has-a mechanisms } }
/* ENUMIN -- Format the enumeration string for a parameter. */ char * enumin ( register struct param *pp ) { static char message[SZ_LINE]; if (!(pp->p_flags & (P_IMIN|P_UMIN))) { char str[SZ_LINE]; struct operand o; sprintf (message, " choose: "); o.o_type = pp->p_type & OT_BASIC; o.o_val = pp->p_min; sprop (str, &o); strcat (message, str); } else message[0] = EOS; return (message); }
/* MK_STARTUPMSG -- Format the command to be sent to the interpreter in the * IRAF Main in the child to execute the indicated logical task. The format * of this command is * * taskname redir_args paramset_args * * where "redir_args" are used to either inform the task that a stream has * been redirected by the CL (file "$") or to actually redirect a stream, * and where "paramset_args" are assignments of the form "param=value". * For example, "4 > $" tells the task that its standard output (4 = integer * value of STDOUT) has been redirected. Only parameters with static values, * i.e., with predefined values that are not expected to change during task * execution (no queries) may be passed on the command line. */ void mk_startupmsg ( struct task *tp, /* task being executed */ char *cmd, /* receives formatted command */ int maxch /* max chars out */ ) { register char *ip, *op, *cp; struct pfile *pfp; struct operand o; struct param *pp; char redir[20]; /* Start with the task name. * Task names which begin with an underscore are used to implement * "invisible" commands which are not intended to be part of the * user interface. The distinction between these and regular * commands is restricted to the CL, hence the leading underscore * is stripped from the task name sent to the process. */ ip = tp->t_ltp->lt_lname; while (*ip == CH_INVIS) ip++; strcpy (cmd, ip); /* Add redirection information. We can omit the pseudofile stream * codes for the standard input and output as the iraf main will * assume those streams if no stream code is given, though we must * be explicit for stderr and the graphics streams. */ if (tp->t_flags & (T_MYIN|T_MYOUT|T_MYERR)) { if (tp->t_flags & T_MYIN) strcat (cmd, " < $"); if (tp->t_flags & T_MYOUT) strcat (cmd, " > $"); if (tp->t_flags & T_MYERR) { sprintf (redir, " %d> $", STDERR); strcat (cmd, redir); } } if (tp->t_flags & (T_MYSTDGRAPH|T_MYSTDIMAGE|T_MYSTDPLOT)) { if (tp->t_flags & T_MYSTDGRAPH) { sprintf (redir, " %d> $", STDGRAPH); strcat (cmd, redir); } if (tp->t_flags & T_MYSTDIMAGE) { sprintf (redir, " %d> $", STDIMAGE); strcat (cmd, redir); } if (tp->t_flags & T_MYSTDPLOT) { sprintf (redir, " %d> $", STDPLOT); strcat (cmd, redir); } } for (cp=cmd; *cp; cp++) --maxch; /* Add parameter assignments for all non list-structured parameters * whose access would not cause a query, i.e., those parameters which * already have a legal value and which are either hidden or were set * on the command line. Passing the values of these parameters on the * command line speeds task startup by reducing the number of parameter * requests that must be processed by handshaking over the IPC. */ for (pfp = tp->t_pfp; pfp; pfp = pfp->pf_npset) { for (pp = pfp->pf_pp; pp != NULL; pp = pp->p_np) { o = pp->p_valo; /* Do not cache parameters which have an undefined value or * for which the value is indirect to another parameter. * Also, array parameters can not be cached currently. */ if (o.o_type & OT_UNDEF) continue; if ((o.o_type & OT_BASIC) == OT_STRING && (o.o_val.v_s[0] == PF_INDIRECT)) continue; if (pp->p_type & PT_ARRAY) continue; if (!(pp->p_type & PT_LIST) && !(effmode(pp) & M_QUERY)) { char buf[SZ_LINE+1]; char val[SZ_LINE+1]; /* First format the param=value string in buf. */ /* Start with "param=" if main pfile, or "pset.param=" if * pset-param pfile. */ if (pfp->pf_psetp != NULL) { ip = pfp->pf_psetp->p_name; for (op=buf; (*op = *ip++); op++) ; *op++ = '.'; } else op = buf; for (ip=pp->p_name; (*op = *ip++); op++) ; *op++ = '='; /* Add "value". If the parameter is string valued enclose * the string in quotes and convert any newlines into \n. */ sprop (val, &pp->p_valo); if ((pp->p_type & OT_BASIC) == OT_STRING) *op++ = '"'; for (ip=val; (*op = *ip++); op++) if (*op == '\n') { *op++ = '\\'; *op = 'n'; } else if (*op == '"') { *op++ = '\\'; *op = '"'; } if ((pp->p_type & OT_BASIC) == OT_STRING) *op++ = '"'; *op = EOS; /* Now check to see if there is room in the output buffer. * If not we can just quit, as the task will automatically * query for any parameters not set on the command line. * If there is room break the current line by appending \\n * (an escaped newline) and append the new line. */ maxch -= (strlen(buf) + 2); if (maxch <= 0) break; *cp++ = '\\'; *cp++ = '\n'; for (ip=buf; (*cp = *ip++); cp++) ; } } } /* Terminate the command line by appending an unescaped newline. */ *cp++ = '\n'; *cp = EOS; if (cldebug) eprintf ("CALL %s", cmd); }
inline short int generator(short int ilruch,short int ildod) { bool kon,tmp; short int licz=0,wnios; short int odl,ostkier; bool tab[wieltab[0]][wieltab[1]]; for (int i=0;i<wieltab[0];i++) { for (int j=0;j<wieltab[1];j++) { tab[i][j]=false; pozkal[i][j]=false; } } tab[0][0]=true; x=0; y=0; kier=nic; kon=true; for (int i=0;i<ilruch;i++) { licz=0; while (1==1) { if (kon) ostkier=kier; licz++; if (licz>50) return 1; kier=(Kierunek)(rand()%4+1); kon=false; if ((kier==gora&&y==0)||(kier==lewo&&x==0)||(kier==prawo&&x==(wieltab[0]-1))||(kier==dol&&y==(wieltab[1]-1))) continue; if (ostkier==kier) continue; switch (kier) { case dol: { if (ostkier==gora) continue; odl=rand()%(wieltab[1]-y-1)+1; kon=false; for (int j=1;j<=odl;j++) { if (pozkal[x][y+j]) { kon=true; break; } } if (kon) { kon=false; continue; } kon=false; if (tab[x][y+odl]) continue; if (y+odl+1<wieltab[1]) { if (tab[x][y+odl+1]) continue; tmp=pozkal[x][y+odl+1]; pozkal[x][y+odl+1]=true; } wnios=sprop(x,y+odl); if (!wnios) return 1; if (wnios==2) { if (y+odl+1<wieltab[1]) pozkal[x][y+odl+1]=tmp; continue; } for (int j=1;j<=odl;j++) { tab[x][y+j]=true; } kon=true; y+=odl; break; } case gora: { if (ostkier==dol) continue; odl=rand()%y+1; kon=false; for (int j=1;j<=odl;j++) { if (pozkal[x][y-j]) { kon=true; break; } } if (kon) { kon=false; continue; } kon=false; if (tab[x][y-odl]) continue; if (y-odl>0) { if (tab[x][y-odl-1]) continue; tmp=pozkal[x][y-odl-1]; pozkal[x][y-odl-1]=true; } wnios=sprop(x,y-odl); if (!wnios) return 1; if (wnios==2) { if (y-odl>0) pozkal[x][y-odl-1]=tmp; continue; } for (int j=1;j<=odl;j++) { tab[x][y-j]=true; } kon=true; y-=odl; break; } case prawo: { if (ostkier==lewo) continue; odl=rand()%(wieltab[0]-x-1)+1; kon=false; for (int j=1;j<=odl;j++) { if (pozkal[x+j][y]) { kon=true; break; } } if (kon) { kon=false; continue; } kon=false; if (tab[x+odl][y]) continue; if (x+odl+1<wieltab[0]) { if (tab[x+odl+1][y]) continue; tmp=pozkal[x+odl+1][y]; pozkal[x+odl+1][y]=true; } wnios=sprop(x+odl,y); if (!wnios) return 1; if (wnios==2) { if (x+odl+1<wieltab[0]) pozkal[x+odl+1][y]=tmp; continue; } for (int j=1;j<=odl;j++) { tab[x+j][y]=true; } kon=true; x+=odl; break; } case lewo: { if (ostkier==prawo) continue; odl=rand()%x+1; kon=false; for (int j=1;j<=odl;j++) { if (pozkal[x-j][y]) { kon=true; break; } } if (kon) { kon=false; continue; } kon=false; if (tab[x-odl][y]) continue; if (x-odl>0) { if (tab[x-odl-1][y]) continue; tmp=pozkal[x-odl-1][y]; pozkal[x-odl-1][y]=true; } wnios=sprop(x-odl,y); if (!wnios) return 1; if (wnios==2) { if (x-odl>0) pozkal[x-odl-1][y]=tmp; continue; } for (int j=1;j<=odl;j++) { tab[x-j][y]=true; } x-=odl; kon=true; break; } } if (kon) break; } } celpozx=x; celpozy=y; licz=0; for (int i=0;i<ildod;i++) { licz=0; while (true) { licz++; if (licz>50) return 1; x=rand()%wieltab[0]; y=rand()%wieltab[1]; if (tab[x][y]||pozkal[x][y]) continue; pozkal[x][y]=true; wnios=sprop(celpozx,celpozy); if (!wnios) return 1; if (wnios>=2) { pozkal[x][y]=false; continue; } break; } } return 0; }
/* PRETTY_PARAM -- Pretty print the name, value, and prompt string of * a parameter on the output file. Put parens around the name=value string * if a hidden parameter. */ void pretty_param (struct param *pp, FILE *fp) { register char ch, *p; char buf[SZ_LINE]; int nchars, maxch; /* Get terminal dimensions from the environment. */ maxch = c_envgeti ("ttyncols") - 1; p = buf; /* name = */ if (pp->p_mode & M_HIDDEN) *p++ = '('; sprintf (p, "%0.12s = ", pp->p_name); nchars = strlen (buf); while (nchars < 16) { fputc (' ', fp); nchars++; } fputs (buf, fp); /* For arrays print the index list. */ if (pp->p_type & PT_ARRAY) { int dim, d, amin, amax; short *len, *off; char ibuf[15]; /* Maximum length of an index range should * be 13 e.g. -DDDDD:-DDDDD, plus one for the * terminator, and one for good luck. */ buf[0]= '['; buf[1] = '\0'; dim = pp->p_val.v_a->a_dim; len = &(pp->p_val.v_a->a_len); off = &(pp->p_val.v_a->a_off); for (d=0; d<dim; d++) { amin = *(off + 2*d); amax = amin + *(len + 2*d) - 1; if (amin != 1) sprintf (ibuf, "%d:%d", amin, amax); else sprintf (ibuf, "%d", amax); strcat (buf, ibuf); if (d+1<dim) strcat (buf, ","); if (strlen (buf) > SZ_LINE-14) break; } strcat (buf, "]"); fputs (buf, fp); nchars += strlen (buf); } else if (!(pp->p_valo.o_type & OT_UNDEF)) { /* For scalars print the value if available. */ sprop (buf, &pp->p_valo); if ((pp->p_type & OT_BASIC) == OT_STRING && *buf != PF_INDIRECT) { fputc ('"', fp); nchars++; } fputs (buf, fp); nchars += strlen (buf); if ((pp->p_type & OT_BASIC) == OT_STRING && *buf != PF_INDIRECT) { fputc ('"', fp); nchars++; } } if (pp->p_mode & M_HIDDEN) { fputc (')', fp); nchars++; } fputc (' ', fp); nchars++; /* Advance to next field. */ while (nchars < 32) { fputc (' ', fp); nchars++; } /* prompt */ for (p=pp->p_prompt; (ch = *p++) != '\0' && nchars < maxch; nchars++) switch (ch) { case '\t': fputs ("\\t", fp); nchars++; break; case '\n': fputs ("\\n", fp); nchars++; break; case '\r': fputs ("\\r", fp); nchars++; break; case '\f': fputs ("\\f", fp); nchars++; break; default: fputc (ch, fp); } fputc ('\n', fp); }