const map<ArpString,int>& ArpDebugLevel(void) { map<ArpString,int>* level = level_map(); ArpASSERT(level != NULL); (*level)["core"] = corelevel; return *level; }
int ArpDebugLevel(const char* module) { ArpASSERT(module != NULL); if( module == 0 ) return 0; if( strcmp(module,"core") == 0 ) return corelevel; map<ArpString,int>* level = level_map(); if( level == 0 ) return 0; const ArpString modName(ArpDebugName(module)); if( corelevel > 4 ) { cdb << ADH << "Name to get module '" << module << "' is '" << modName << "'" << endl; } map<ArpString, int>::iterator item = level->find(modName); if( item == level->end() ) { if( corelevel >= 1 ) { cdb << ADH << "First access of module " << modName << "; setting to level 0" << endl; } (*level)[modName] = 0; } return (*level)[modName]; }
const short* select_bundle(ODFModel* odf_model,short* position, float angle,float fa_threshold,unsigned int& count) { float cos_angle = std::cos(angle); image::basic_image<char,3> level_map(odf_model->fib_data.dim); std::deque<image::vector<3,float> > seed_dir; std::deque<image::pixel_index<3> > seed_pos; seed_pos.push_back(image::pixel_index<3>(position[0],position[1],position[2],odf_model->fib_data.dim)); seed_pos.push_back(image::pixel_index<3>(position[0],position[1],position[2],odf_model->fib_data.dim)); seed_dir.push_back(odf_model->fib_data.fib.getDir(seed_pos.back().index(),0)); seed_dir.push_back(-odf_model->fib_data.fib.getDir(seed_pos.back().index(),0)); level_map[seed_pos.back().index()] = 1; while (!seed_pos.empty()) { std::vector<image::pixel_index<3> > neighbors; image::get_neighbors(seed_pos.front(),odf_model->fib_data.dim,neighbors); image::vector<3,float> center(seed_pos.front()); for (unsigned int index = 0;index < neighbors.size();++index) { // select front if (level_map[neighbors[index].index()]) continue; image::vector<3,float> displace(neighbors[index]); displace -= center; if (displace*seed_dir.front() < 0.2) continue; image::vector<3,float> new_dir; if (!odf_model->fib_data.get_nearest_dir(neighbors[index].index(),seed_dir.front(),new_dir,fa_threshold,cos_angle)) continue; if (std::abs(new_dir*seed_dir.front()) < cos_angle) continue; if (new_dir*seed_dir.front() < 0) new_dir = -new_dir; seed_pos.push_back(neighbors[index]); seed_dir.push_back(new_dir); level_map[neighbors[index].index()] = 1; } seed_pos.pop_front(); seed_dir.pop_front(); } //image::morphology_smoothing(level_map); static std::vector<short> sel_regions; sel_regions.clear(); for (image::pixel_index<3> index;index.valid(odf_model->fib_data.dim);index.next(odf_model->fib_data.dim)) if (level_map[index.index()]) { sel_regions.push_back(index.x()); sel_regions.push_back(index.y()); sel_regions.push_back(index.z()); } count = sel_regions.size(); return &*sel_regions.begin(); }
int main(int argc, char **argv) { struct stat st; char *slash; int fd; int ch; const char *tag; int log_flags = 0; int level = MSG_INFO; /* * Fingerprint executables and core dumps. */ MAIL_VERSION_STAMP_ALLOCATE; /* * Be consistent with file permissions. */ umask(022); /* * To minimize confusion, make sure that the standard file descriptors * are open before opening anything else. XXX Work around for 44BSD where * fstat can return EBADF on an open file descriptor. */ for (fd = 0; fd < 3; fd++) if (fstat(fd, &st) == -1 && (close(fd), open("/dev/null", O_RDWR, 0)) != fd) msg_fatal("open /dev/null: %m"); /* * Set up diagnostics. */ if ((slash = strrchr(argv[0], '/')) != 0 && slash[1]) tag = mail_task(slash + 1); else tag = mail_task(argv[0]); if (isatty(STDERR_FILENO)) msg_vstream_init(tag, VSTREAM_ERR); msg_syslog_init(tag, LOG_PID, LOG_FACILITY); /* * Check the Postfix library version as soon as we enable logging. */ MAIL_VERSION_CHECK; /* * Parse switches. */ while ((ch = GETOPT(argc, argv, "c:ip:t:v")) > 0) { switch (ch) { default: msg_fatal("usage: %s [-c config_dir] [-i] [-p priority] [-t tag] [-v] [text]", tag); break; case 'c': if (setenv(CONF_ENV_PATH, optarg, 1) < 0) msg_fatal("out of memory"); break; case 'i': log_flags |= LOG_PID; break; case 'p': level = level_map(optarg); break; case 't': tag = optarg; break; case 'v': msg_verbose++; break; } } /* * Process the main.cf file. This overrides any logging facility that was * specified with msg_syslog_init(); */ mail_conf_read(); if (tag == 0 && strcmp(var_syslog_name, DEF_SYSLOG_NAME) != 0) { if ((slash = strrchr(argv[0], '/')) != 0 && slash[1]) tag = mail_task(slash + 1); else tag = mail_task(argv[0]); } /* * Re-initialize the logging, this time with the tag specified in main.cf * or on the command line. */ if (tag != 0) { if (isatty(STDERR_FILENO)) msg_vstream_init(tag, VSTREAM_ERR); msg_syslog_init(tag, LOG_PID, LOG_FACILITY); } /* * Log the command line or log lines from standard input. */ if (argc > optind) { log_argv(level, argv + optind); } else { log_stream(level, VSTREAM_IN); } exit(0); }