MStatus StrandLengthCount::doIt(const MArgList & args) { std::list<MObject> targets; MStatus status = ArgList_GetModelObjects(args, syntax(), "-b", targets); if (status != MStatus::kNotFound && status != MStatus::kSuccess) { HMEVALUATE_RETURN_DESCRIPTION("ArgList_GetModelObjects", status); } clearResult(); if (!targets.empty()) { for (std::list<MObject>::const_iterator it(targets.begin()); it != targets.end(); ++it) { Model::Base base(*it); Model::Strand strand(base); HPRINT("Calling with base: %s", base.getDagPath(status).fullPathName().asChar()); appendToResult(int(m_operation.length(strand))); } } else { MObjectArray objects; HMEVALUATE_RETURN(status = Model::Base::AllSelected(objects), status); for (unsigned int i = 0; i < objects.length(); ++i) { Model::Base base(objects[i]); Model::Strand strand(base); HPRINT("Calling with base: %s", base.getDagPath(status).fullPathName().asChar()); appendToResult(int(m_operation.length(strand))); } } return MStatus::kSuccess; }
//---- // function to display PMT pulse (flash-ADC array arr[]) : // void ANTI2DBc::displ_a(char comm[], int id, int mf, const geant arr[]){ integer i; geant tm,a(0.); geant tb,tbi; char name[80], buf[10]; sprintf(buf, "%4d\n",id); strcpy(name,comm); strcat(name,buf); tb=geant(mf)*ANTI2DBc::fadcbw(); tbi=ANTI2DBc::fadcbw(); HBOOK1(2638,name,100,0.,100*tb,0.); for(i=1;i<=ANTI2C::ANFADC;i++){ if(i%mf==0){ a+=arr[i-1]; tm=i*tbi-0.5*tb; HF1(2638,tm,a/geant(mf)); a=0.; } else{ a+=arr[i-1]; } } HPRINT(2638); HDELET(2638); return ; }
/** * Calculates the bounding Right Parallel Piped (RPP) of the NURB * surface, and returns the minimum and maximum points of the surface. */ int rt_nurb_s_bound(struct face_g_snurb *srf, fastf_t *bmin, fastf_t *bmax) { register fastf_t *p_ptr; /* Mesh pointer */ register int coords; /* Elements per vector */ int i; int rat; VSETALL(bmin, INFINITY); VSETALL(bmax, -INFINITY); if (srf == (struct face_g_snurb *)0) { bu_log("nurb_s_bound: NULL surface\n"); return -1; /* BAD */ } p_ptr = srf->ctl_points; coords = RT_NURB_EXTRACT_COORDS(srf->pt_type); rat = RT_NURB_IS_PT_RATIONAL(srf->pt_type); for (i = (srf->s_size[RT_NURB_SPLIT_ROW] * srf->s_size[RT_NURB_SPLIT_COL]); i > 0; i--) { if (!rat) { VMINMAX(bmin, bmax, p_ptr); } else if (rat) { point_t tmp_pt; if (ZERO(p_ptr[H])) { HPRINT("mesh point", p_ptr); bu_log("nurb_s_bound: H too small\n"); } else { HDIVIDE(tmp_pt, p_ptr); VMINMAX(bmin, bmax, tmp_pt); } } p_ptr += coords; } return 0; /* OK */ }
/* * This routine is called (at prep time) * once for each region which uses this shader. * Any shader-specific initialization should be done here. * * Returns: * 1 success * 0 success, but delete region * -1 failure */ HIDDEN int bbd_setup(struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip) { register struct bbd_specific *bbd_sp; struct rt_db_internal intern; struct rt_tgc_internal *tgc; int s; mat_t mat; struct bbd_img *bi; double angle; vect_t vtmp; int img_num; vect_t vv; /* check the arguments */ RT_CHECK_RTI(rtip); BU_CK_VLS(matparm); RT_CK_REGION(rp); if (rdebug&RDEBUG_SHADE) bu_log("bbd_setup(%s)\n", rp->reg_name); RT_CK_TREE(rp->reg_treetop); if (rp->reg_treetop->tr_a.tu_op != OP_SOLID) { bu_log("--- Warning: Region %s shader %s", rp->reg_name, mfp->mf_name); bu_bomb("Shader should be used on region of single (rec/rcc) primitive\n"); } RT_CK_SOLTAB(rp->reg_treetop->tr_a.tu_stp); if (rp->reg_treetop->tr_a.tu_stp->st_id != ID_REC) { bu_log("--- Warning: Region %s shader %s", rp->reg_name, mfp->mf_name); bu_log("Shader should be used on region of single REC/RCC primitive %d\n", rp->reg_treetop->tr_a.tu_stp->st_id); bu_bomb("oops\n"); } /* Get memory for the shader parameters and shader-specific data */ BU_GET(bbd_sp, struct bbd_specific); *dpp = bbd_sp; /* initialize the default values for the shader */ memcpy(bbd_sp, &bbd_defaults, sizeof(struct bbd_specific)); bu_vls_init(&bbd_sp->img_filename); BU_LIST_INIT(&bbd_sp->imgs); bbd_sp->rtip = rtip; /* because new_image() needs this */ bbd_sp->img_count = 0; /* parse the user's arguments for this use of the shader. */ if (bu_struct_parse(matparm, bbd_parse_tab, (char *)bbd_sp, NULL) < 0) return -1; if (bbd_sp->img_count > MAX_IMAGES) { bu_log("too many images (%zu) in shader for %s sb < %d\n", bbd_sp->img_count, rp->reg_name, MAX_IMAGES); bu_bomb("excessive image count\n"); } MAT_IDN(mat); RT_DB_INTERNAL_INIT(&intern); s = rt_db_get_internal(&intern, rp->reg_treetop->tr_a.tu_stp->st_dp, rtip->rti_dbip, mat, &rt_uniresource); if (intern.idb_minor_type != ID_TGC && intern.idb_minor_type != ID_REC) { bu_log("What did I get? %d\n", intern.idb_minor_type); } if (s < 0) { bu_log("%s:%d didn't get internal", __FILE__, __LINE__); bu_bomb(""); } tgc = (struct rt_tgc_internal *)intern.idb_ptr; RT_TGC_CK_MAGIC(tgc); angle = M_PI / (double)bbd_sp->img_count; img_num = 0; VMOVE(vv, tgc->h); VUNITIZE(vv); for (BU_LIST_FOR(bi, bbd_img, &bbd_sp->imgs)) { static const point_t o = VINIT_ZERO; bn_mat_arb_rot(mat, o, vv, angle*img_num); /* compute plane equation */ MAT4X3VEC(bi->img_plane, mat, tgc->a); VUNITIZE(bi->img_plane); bi->img_plane[H] = VDOT(tgc->v, bi->img_plane); MAT4X3VEC(vtmp, mat, tgc->b); VADD2(bi->img_origin, tgc->v, vtmp); /* image origin in 3d space */ /* calculate image u vector */ VREVERSE(bi->img_x, vtmp); VUNITIZE(bi->img_x); bi->img_xlen = MAGNITUDE(vtmp) * 2; /* calculate image v vector */ VMOVE(bi->img_y, tgc->h); VUNITIZE(bi->img_y); bi->img_ylen = MAGNITUDE(tgc->h); if (rdebug&RDEBUG_SHADE) { HPRINT("\nimg_plane", bi->img_plane); VPRINT("vtmp", vtmp); VPRINT("img_origin", bi->img_origin); bu_log("img_xlen:%g ", bi->img_xlen); VPRINT("img_x", bi->img_x); bu_log("img_ylen:%g ", bi->img_ylen); VPRINT("img_y", bi->img_y); } img_num++; } rt_db_free_internal(&intern); if (rdebug&RDEBUG_SHADE) { bu_struct_print(" Parameters:", bbd_print_tab, (char *)bbd_sp); } return 1; }