/*------------------------------------------------------------------------- * Function: ptr_bind * * Purpose: Binds array dimensions to numeric values. * * Return: Success: SELF * * Failure: NIL * * Programmer: Robb Matzke * [email protected] * Jan 13 1997 * * Modifications: * *------------------------------------------------------------------------- */ static obj_t ptr_bind (obj_t _self, void *mem) { obj_ptr_t *self = MYCLASS(_self); obj_t name=NIL, val=NIL, x=NIL; int i; if (C_STR==self->sub->pub.cls) { name = obj_new (C_SYM, obj_name(self->sub)); x = sym_vboundp (name); name = obj_dest (name); val = obj_copy (x, DEEP); /*so we can modify it*/ x = obj_dest (x); /* * We're being tricky here. By assigning a new value to the `sub' * field we're modifying all the expressions that share this cell. * We must insure that the correct reference count is imparted * to the new subtype. */ for (i=1; i<self->pub.ref; i++) { x = obj_copy (val, SHALLOW); assert (x==val); } if (val) self->sub = val; } return obj_bind (self->sub, mem ? *((void**)mem) : NULL); }
//-------------------------------------------------------------------------- // Function: H5Object::getObjName ///\brief Returns the name of this object as an \a H5std_string. ///\return Name of the object ///\exception H5::Exception // Programmer Binh-Minh Ribler - Mar, 2014 // Modification //-------------------------------------------------------------------------- H5std_string H5Object::getObjName() const { H5std_string obj_name(""); // object name to return // Preliminary call to get the size of the object name ssize_t name_size = H5Iget_name(getId(), NULL, static_cast<size_t>(0)); // If H5Iget_name failed, throw exception if (name_size < 0) { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } else if (name_size == 0) { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Object's name exists, retrieve it else if (name_size > 0) { char* name_C = new char[name_size+1]; // temporary C-string HDmemset(name_C, 0, name_size+1); // clear buffer // Use overloaded function name_size = getObjName(name_C, name_size+1); // Convert the C object name to return obj_name = name_C; // Clean up resource delete []name_C; } // Return object's name return(obj_name); }
int vpm(int argc, char **argv) { if( argc < 2 ) throw std::runtime_error("Provide model name as second argument"); std::string obj_name(argv[1]); std::string vision_module_dir( ros::package::getPath("vision_module") ); std::string tree_vps_path( vision_module_dir + "/data/tree_vps.txt"); std::string views_path( vision_module_dir + "/../database/cloud_data/" + obj_name + "_views" ); // Read the tree vps file Eigen::MatrixXd tree_vps; io_utils::file2matrix( tree_vps_path, tree_vps, 3 ); int num_vps = tree_vps.rows(); pcl::PointCloud<pcl::PointXYZ>::Ptr pcd_model_ptr( new pcl::PointCloud<pcl::PointXYZ>); for(int vp = 0; vp < num_vps; ++vp) { // load the view pcl::PointCloud<pcl::PointXYZ>::Ptr view_ptr( new pcl::PointCloud<pcl::PointXYZ>); std::string view_path( views_path + "/" + obj_name + "_" + boost::lexical_cast<std::string>(vp) +".pcd" ); pcl::io::loadPCDFile<pcl::PointXYZ> ( view_path, *view_ptr ); // rotate to world frame Eigen::Vector3d camera_position = tree_vps.row(vp).transpose(); Eigen::Vector4d camera_orientation = misc::target2quat( camera_position, Eigen::Vector3d(0,0,0) ); tf::Transform map_T_snsr; map_T_snsr.setOrigin( tf::Vector3(camera_position.x(), camera_position.y(), camera_position.z()) ); map_T_snsr.setRotation( tf::Quaternion( camera_orientation.x(), camera_orientation.y(), camera_orientation.z(), camera_orientation.w()) ); tf::Transform snsr_T_optical; snsr_T_optical.setOrigin( tf::Vector3( 0.0, 0.0, 0.0 ) ); snsr_T_optical.setRotation( tf::Quaternion( -0.5, 0.5, -0.5, 0.5 ) ); tf::Transform map_T_optical = map_T_snsr * snsr_T_optical; pcl_ros::transformPointCloud( *view_ptr, *view_ptr, map_T_optical); // add to pcd_model *pcd_model_ptr += *view_ptr; } // Save pcl::PCDWriter writer; writer.writeASCII( vision_module_dir + "../database/pcd_models/" + obj_name + "_complete.pcd", *pcd_model_ptr ); return 0; }
/*------------------------------------------------------------------------- * Function: sym_eval * * Purpose: Returns the variable value of a symbol if it has one. * * Return: Success: Ptr to a copy of the variable value. * * Failure: NIL * * Programmer: Robb Matzke * [email protected] * Dec 4 1996 * * Modifications: * Robb Matzke, 4 Feb 1997 * Fixed the arguments for the obj_deref() call. * * Robb Matzke, 2000-07-03 * The symbol `$*' evaluates to a list of all $N files for * consecutive N beginning at 1. *------------------------------------------------------------------------- */ static obj_t sym_eval (obj_t _self) { obj_t name_1=NIL, file_1=NIL, retval=NIL; obj_sym_t *self = MYCLASS(_self); /* If the symbol has a variable value then return it. */ if (MYCLASS(_self)->sym->var) { return obj_copy (MYCLASS(_self)->sym->var, SHALLOW); } /* The symbol `$*' evaluates to a list of the first consecutive files * bound to the $N symbols. */ if (!strcmp(self->sym->name, "$*")) { obj_t opands[1024], retval; int nopands, i; for (nopands=0; nopands<NELMTS(opands); nopands++) { obj_t symbol; char tmp[32]; sprintf(tmp, "$%d", nopands+1); symbol = obj_new(C_SYM, tmp); opands[nopands] = sym_vboundp(symbol); obj_dest(symbol); if (!opands[nopands] || C_FILE!=opands[nopands]->pub.cls) { /* We reached the last file or something isn't a file */ obj_dest(opands[nopands]); break; } } retval = V_make_list(nopands, opands); for (i=0; i<nopands; i++) { obj_dest(opands[i]); } return retval; } /* If the symbol exists in the first data file, then return * that SDO. */ name_1 = obj_new (C_SYM, "$1"); file_1 = MYCLASS(name_1)->sym->var; name_1 = obj_dest (name_1); if (file_1 && C_FILE==file_1->pub.cls) { retval = obj_deref (file_1, 1, &_self); return retval; } /* Symbol has no value. */ out_errorn ("eval: variable `%s' has no value", obj_name(_self)); return NIL; }
static gchar * _mdh_name( t_obj * mdh_obj) /* * The 'name' of the MIDI hook is in fact the name of the trigger it calls */ { if(!mdh_obj) return NULL; if(!MDH(mdh_obj)->trg_obj) return NULL; return obj_name(MDH(mdh_obj)->trg_obj); } /* _mdh_name() */
const char* findKeyWord(const char* msg) { android::String8 obj_name(msg); obj_name.toLower(); const char* OBJ_NAME = obj_name.string(); // NOTE: keep these keywords in sync with MOF android::String8 keyword("timeline_"); if (strstr(OBJ_NAME, "surfaceflinger")) { keyword.append("SurfaceFlinger"); } else if (strstr(OBJ_NAME, "ovl_timeline")) { keyword.append("ovl_timeline"); } else if (strstr(OBJ_NAME, "mali")) { keyword.append("mali"); } return keyword.string(); }
/*--------------------------------------------------------------------------- * Purpose: Return the string value of a builtin symbol. * * Return: Copy of the string value or NULL * * Programmer: Robb Matzke * Friday, June 2, 2000 * * Modifications: *--------------------------------------------------------------------------- */ char * sym_bi_gets(const char *name) { char fullname[1024], *retval; obj_t var, val; /* Add built-in prefix */ if (*name!='$') { fullname[0] = '$'; strcpy(fullname+1, name); name = fullname; } var = obj_new(C_SYM, name); val = sym_vboundp(var); var = obj_dest(var); retval = safe_strdup(obj_name(val)); obj_dest(val); return retval; }
void makePlots(char * file, char * suffix) { //Get rid of stat-box gROOT->GetStyle("Plain")->SetOptStat(0); // AXIS LABELS STYLE gROOT->GetStyle("Plain")->SetLabelColor(kBlack, "XYZ"); gROOT->GetStyle("Plain")->SetLabelFont(43, "XYZ"); gROOT->GetStyle("Plain")->SetLabelSize(20, "XYZ"); gROOT->SetStyle("Plain"); gROOT->ForceStyle(kTRUE); const char * folder = "demo"; const char * to_plot[] = {"TrackerClusterMap", "TrackerClusterOntrackMap", "TrackerSameClusterOntrackMap", "TrackerOccupancyOntrackMap", "TrackerOccupancySameClusterOntrackMap", 0}; TFile * f = new TFile(file); TCanvas * c = new TCanvas("C", "C", 1024, 1024); for (const char **profile = to_plot; *profile; ++profile) { TString obj_name(folder); obj_name.Append("/").Append(*profile); TProfile * p = (TProfile*)f->Get(obj_name.Data()); p->Draw("colz"); TString filename(*profile); filename.Append("_").Append(suffix).Append(".png"); c->SaveAs(filename.Data()); } }
int main(int argc, char **argv) { FILE *nl; char *stub; fint nerror = (fint)0; int n_badvals = 0; real f; if( argc < 2 ) { fprintf(stderr, "Usage: %s stub\n", argv[0]); return 1; } // Read objectives and first derivative information. if( !(asl = ASL_alloc(ASL_read_fg)) ) exit(1); stub = getstub(&argv, &Oinfo); nl = jac0dim(stub, (fint)strlen(stub)); // Get command-line options. if (getopts(argv, &Oinfo)) exit(1); // Check command-line options. if( showgrad < 0 || showgrad > 1 ) { Printf("Invalid value for showgrad: %d\n", showgrad); n_badvals++; } if( showname < 0 || showname > 1 ) { Printf("Invalid value for showname: %d\n", showname); n_badvals++; } if(n_badvals) { Printf("Found %d errors in command-line options.\n", n_badvals); exit(1); } // Allocate memory for problem data. // The variables below must have precisely THESE names. X0 = (real*)Malloc(n_var * sizeof(real)); // Initial guess pi0 = (real*)Malloc(n_con * sizeof(real)); // Initial multipliers LUv = (real*)Malloc(n_var * sizeof(real)); // Lower bounds on variables Uvx = (real*)Malloc(n_var * sizeof(real)); // Upper bounds on variables LUrhs = (real*)Malloc(n_con * sizeof(real)); // Lower bounds on constraints Urhsx = (real*)Malloc(n_con * sizeof(real)); // Upper bounds on constraints want_xpi0 = 3; // Read in ASL structure - trap read errors if( fg_read(nl, 0) ) { fprintf(stderr, "Error fg-reading nl file\n"); goto bailout; } if(showname) { // Display objective name if requested. Printf("Objective name: %s\n", obj_name(0)); } // This "solver" outputs the objective function value at X0. f = objval(0, X0, &nerror); if(nerror) { fprintf(stderr, "Error while evaluating objective.\n"); goto bailout; } Printf("f(x0) = %21.15e\n", f); // Optionally also output objective gradient at X0. if(showgrad) { real *g = (real*)malloc(n_var * sizeof(real)); objgrd(0, X0, g, &nerror); Printf("g(x0) = [ "); for(int i=0; i<n_var; i++) Printf("%8.1e ", g[i]); Printf("]\n"); free(g); } // Write solution to file. Here we just write the initial guess. Oinfo.wantsol = 9; // Suppress message echo. Force .sol writing write_sol(CHR"And the winner is", X0, pi0, &Oinfo); bailout: // Free data structure. DO NOT use free() on X0, pi0, etc. ASL_free((ASL**)(&asl)); return 0; }