// Return the fragment of text after an offset. QString QsciAccessibleScintillaBase::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const { QsciScintillaBase *sb = sciWidget(); // Initialise in case of errors. *startOffset = *endOffset = -1; int position = validPosition(offset); if (position < 0) return QString(); int start_position, end_position; if (!boundaries(sb, position, boundaryType, &start_position, &end_position)) return QString(); if (end_position >= sb->SendScintilla(QsciScintillaBase::SCI_GETTEXTLENGTH)) return QString(); if (!boundaries(sb, end_position, boundaryType, &start_position, &end_position)) return QString(); positionRangeAsOffsetRange(sb, start_position, end_position, startOffset, endOffset); return textRange(sb, start_position, end_position); }
// Accessor methods void mgrid::BoundaryConditions::set(BoundaryFlag bFlag, const Boundary& referent) { // Check lengths before assignment if (boundaries(bFlag).extent(0) != referent.extent(0)) { throw InvalidBoundaryCondition(); } else { Boundary::iterator boundIter = boundaries(bFlag).begin(); for (Boundary::const_iterator refIter = referent.begin(); refIter != referent.end(); refIter++, boundIter++) { boundIter->value = refIter->value; boundIter->conditionType = refIter->conditionType; } } }
void RA_addNote_FloatPlace( int blocknum, int tracknum, float start, int notenum, float volume, float end) { struct Blocks *block=SWIG_getBlock(blocknum); struct Tracks *track=SWIG_getTrack(blocknum,tracknum); struct Notes *note; Place p2; if(track==NULL) return; note=NewNote(); Float2Placement(start,¬e->l.p); Float2Placement(end,¬e->end); PlaceSetLastPos(block,&p2); if(PlaceGreaterOrEqual(¬e->l.p,&p2)) return; if(PlaceGreaterOrEqual(¬e->end,&p2)){ PlaceCopy(¬e->end,&p2); } note->note=notenum; note->velocity=boundaries( volume*(*track->instrument->getMaxVelocity)(track), 0, (*track->instrument->getMaxVelocity)(track) ); ListAddElement3(&track->notes,¬e->l); }
int main() { initialize(); boundaries(); gaussSeidel(); printToFile(); }
LayoutRect AbstractInlineTextBox::bounds() const { if (!m_inlineTextBox || !m_lineLayoutItem) return LayoutRect(); FloatRect boundaries(m_inlineTextBox->calculateBoundaries()); return LayoutRect(m_lineLayoutItem.localToAbsoluteQuad(boundaries).enclosingBoundingBox()); }
BoundedVolume3d BoundedVolume3d::transformedBy(const TTransformation& transformation) const { return BoundedVolume3d( SpatialSet<ParametricSurface3d>( boundaries().map( [&transformation] (const ParametricSurface3d& boundarySurface) { return boundarySurface.transformedBy(transformation); } ) ) ); }
//Initializes the KDTree void KDTree::Init( float width, float depth, int aMaxDepth ) { //cleanup any old resources Cleanup(); //record the maximum depth of the tree maxDepth = aMaxDepth; //store the boundaries AABB boundaries( Vector3D ( 0, 0, 0 ), Vector3D ( width, 0, depth ) ); //build the tree root = new KDNode( this, NULL ); root->BuildTree( this, 0, boundaries, 0 ); }
void LensConfig::interpolate(LensConfig &prev, LensConfig &next, int64_t prev_frame, int64_t next_frame, int64_t current_frame) { double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame); double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame); for(int i = 0; i < FOV_CHANNELS; i++) fov[i] = prev.fov[i] * prev_scale + next.fov[i] * next_scale; aspect = prev.aspect * prev_scale + next.aspect * next_scale; radius = prev.radius * prev_scale + next.radius * next_scale; center_x = prev.center_x * prev_scale + next.center_x * next_scale; center_y = prev.center_y * prev_scale + next.center_y * next_scale; mode = prev.mode; draw_guides = prev.draw_guides; boundaries(); }
/** * This is the main() method which is called from the command-line. * Return code 0 means success. Any other values means some sort of error occurred. */ int main(const int argc, const char **argv) { // Assume no extra digits (unless overridden later. int extraDigits = 0; // If XYZ is added to -b, -r or -g, print x, y, z coordinates int useXYZ = 0; // Provide usage message if no arguments specified. const char *appName = argv[0]; selfCheckEnabled = (strstr(appName, "debug") != 0); if (selfCheckEnabled) { fprintf(stderr, "(debug mode: self checking enabled)\n"); } if (argc < 2) { usage(appName); return NORMAL_ERROR; } // First argument: command. const char *cmd = argv[1]; if ((strcmp(cmd, "-d") == 0) || (strcmp(cmd, "--decode") == 0)) { // ------------------------------------------------------------------ // Decode: [-d | --decode] <default-territory> <mapcode> [<mapcode> ...] // ------------------------------------------------------------------ if (argc < 4) { fprintf(stderr, "error: incorrect number of arguments\n\n"); usage(appName); return NORMAL_ERROR; } const char *defaultTerritory = argv[2]; double lat; double lon; // Get the territory context. int context = convertTerritoryIsoNameToCode(defaultTerritory, 0); // Decode every Mapcode. for (int i = 3; i < argc; ++i) { // Decode the Mapcode to a lat/lon. const char *mapcode = argv[i]; int err = decodeMapcodeToLatLon(&lat, &lon, mapcode, context); if (err != 0) { fprintf(stderr, "error: cannot decode '%s %s'\n", defaultTerritory, mapcode); return NORMAL_ERROR; } // Output the decoded lat/lon. printf("%.12g %.12g\n", lat, lon); // Self-checking code to see if encoder produces this Mapcode for the lat/lon. if (selfCheckEnabled) { const char *suffix = strstr(mapcode, "-"); extraDigits = 0; if (suffix != 0) { extraDigits = (int) (strlen(suffix) - 1); } selfCheckLatLonToMapcode(lat, lon, defaultTerritory, mapcode, extraDigits); } } } else if ((strcmp(cmd, "-e") == 0) || (strcmp(cmd, "-e0") == 0) || (strcmp(cmd, "-e1") == 0) || (strcmp(cmd, "-e2") == 0) || (strcmp(cmd, "-e3") == 0) || (strcmp(cmd, "-e4") == 0) || (strcmp(cmd, "-e5") == 0) || (strcmp(cmd, "-e6") == 0) || (strcmp(cmd, "-e7") == 0) || (strcmp(cmd, "-e8") == 0) || (strcmp(cmd, "--encode") == 0) || (strcmp(cmd, "--encode0") == 0) || (strcmp(cmd, "--encode1") == 0) || (strcmp(cmd, "--encode2") == 0) || (strcmp(cmd, "--encode3") == 0) || (strcmp(cmd, "--encode4") == 0) || (strcmp(cmd, "--encode5") == 0) || (strcmp(cmd, "--encode5") == 0) || (strcmp(cmd, "--encode7") == 0) || (strcmp(cmd, "--encode8") == 0)) { // ------------------------------------------------------------------ // Encode: [-e[0-8] | --encode[0-8]] <lat:-90..90> <lon:-180..180> [territory]> // ------------------------------------------------------------------ if ((argc != 4) && (argc != 5)) { fprintf(stderr, "error: incorrect number of arguments\n\n"); usage(appName); return NORMAL_ERROR; } if ((!isdigit(*argv[2]) && (*argv[2] != '-')) || (!isdigit(*argv[3]) && (*argv[3] != '-'))) { fprintf(stderr, "error: latitude and longitude must be numeric\n"); usage(appName); return NORMAL_ERROR; } const double lat = atof(argv[2]); const double lon = atof(argv[3]); if (strstr(cmd, "-e1") || strstr(cmd, "--encode1")) { extraDigits = 1; } else if (strstr(cmd, "-e2") || strstr(cmd, "--encode2")) { extraDigits = 2; } else if (strstr(cmd, "-e3") || strstr(cmd, "--encode3")) { extraDigits = 3; } else if (strstr(cmd, "-e4") || strstr(cmd, "--encode4")) { extraDigits = 4; } else if (strstr(cmd, "-e5") || strstr(cmd, "--encode5")) { extraDigits = 5; } else if (strstr(cmd, "-e6") || strstr(cmd, "--encode6")) { extraDigits = 6; } else if (strstr(cmd, "-e7") || strstr(cmd, "--encode7")) { extraDigits = 7; } else if (strstr(cmd, "-e8") || strstr(cmd, "--encode8")) { extraDigits = 8; } else { extraDigits = 0; } // Get territory context. int context = 0; const char *defaultTerritory = "AAA"; if (argc == 5) { context = convertTerritoryIsoNameToCode(argv[4], 0); defaultTerritory = argv[4]; } // Encode the lat/lon to a set of Mapcodes. char *results[2 * MAX_NR_OF_MAPCODE_RESULTS]; const int nrResults = encodeLatLonToMapcodes_Deprecated(results, lat, lon, context, extraDigits); if (nrResults <= 0) { fprintf(stderr, "error: cannot encode lat=%.12g, lon=%.12g (default territory=%s)\n", lat, lon, defaultTerritory); return NORMAL_ERROR; } // Output the Mapcode. for (int i = 0; i < nrResults; ++i) { const char *foundMapcode = results[(i * 2)]; const char *foundTerritory = results[(i * 2) + 1]; printf("%s %s\n", foundTerritory, foundMapcode); // Self-checking code to see if decoder produces the lat/lon for all of these Mapcodes. if (selfCheckEnabled) { selfCheckMapcodeToLatLon(foundTerritory, foundMapcode, lat, lon); } } } else if ((strcmp(cmd, "-b") == 0) || (strcmp(cmd, "-bXYZ") == 0) || (strcmp(cmd, "--boundaries") == 0) || (strcmp(cmd, "--boundariesXYZ") == 0)) { // ------------------------------------------------------------------ // Generate a test set based on the Mapcode boundaries. // ------------------------------------------------------------------ if ((argc < 2) || (argc > 3)) { fprintf(stderr, "error: incorrect number of arguments\n\n"); usage(appName); return NORMAL_ERROR; } if (argc == 3) { extraDigits = atoi(argv[2]); if ((extraDigits < 0) || (extraDigits > 8)) { fprintf(stderr, "error: parameter extraDigits must be in [0..8]\n\n"); usage(appName); return NORMAL_ERROR; } } useXYZ = (strstr(cmd, "XYZ") != 0); resetStatistics(NR_BOUNDARY_RECS); for (int i = 0; i < totalNrOfPoints; ++i) { double minLon; double maxLon; double minLat; double maxLat; double lat; double lon; const mminforec *mm = boundaries(i); minLon = ((double) mm->minx) / 1.0E6; maxLon = ((double) mm->maxx) / 1.0E6; minLat = ((double) mm->miny) / 1.0E6; maxLat = ((double) mm->maxy) / 1.0E6; // Try center. lat = (maxLat - minLat) / 2.0; lon = (maxLon - minLon) / 2.0; generateAndOutputMapcodes(lat, lon, 0, extraDigits, useXYZ); // Try corners. generateAndOutputMapcodes(minLat, minLon, 0, extraDigits, useXYZ); generateAndOutputMapcodes(minLat, maxLon, 0, extraDigits, useXYZ); generateAndOutputMapcodes(maxLat, minLon, 0, extraDigits, useXYZ); generateAndOutputMapcodes(maxLat, maxLon, 0, extraDigits, useXYZ); // Try JUST inside. const double d = 0.000001; generateAndOutputMapcodes(minLat + d, minLon + d, 0, extraDigits, useXYZ); generateAndOutputMapcodes(minLat + d, maxLon - d, 0, extraDigits, useXYZ); generateAndOutputMapcodes(maxLat - d, minLon + d, 0, extraDigits, useXYZ); generateAndOutputMapcodes(maxLat - d, maxLon - d, 0, extraDigits, useXYZ); // Try JUST outside. generateAndOutputMapcodes(minLat - d, minLon - d, 0, extraDigits, useXYZ); generateAndOutputMapcodes(minLat - d, maxLon + d, 0, extraDigits, useXYZ); generateAndOutputMapcodes(maxLat + d, minLon - d, 0, extraDigits, useXYZ); generateAndOutputMapcodes(maxLat + d, maxLon + d, 0, extraDigits, useXYZ); if ((i % SHOW_PROGRESS) == 0) { showProgress(i); } } outputStatistics(); } else if ((strcmp(cmd, "-g") == 0) || (strcmp(cmd, "-gXYZ") == 0) || (strcmp(cmd, "--grid") == 0) || (strcmp(cmd, "--gridXYZ") == 0) || (strcmp(cmd, "-r") == 0) || (strcmp(cmd, "-rXYZ") == 0) || (strcmp(cmd, "--random") == 0) || (strcmp(cmd, "--randomXYZ") == 0)) { // ------------------------------------------------------------------ // Generate grid test set: [-g | --grid] <nrOfPoints> [<extradigits>] // Generate uniform test set: [-r | --random] <nrOfPoints> [<seed>] // ------------------------------------------------------------------ if ((argc < 3) || (argc > 5)) { fprintf(stderr, "error: incorrect number of arguments\n\n"); usage(appName); return NORMAL_ERROR; } int nrOfPoints = atoi(argv[2]); if (nrOfPoints < 1) { fprintf(stderr, "error: total number of points to generate must be >= 1\n\n"); usage(appName); return NORMAL_ERROR; } if (argc >= 4) { extraDigits = atoi(argv[3]); if ((extraDigits < 0) || (extraDigits > 8)) { fprintf(stderr, "error: parameter extraDigits must be in [0..8]\n\n"); usage(appName); return NORMAL_ERROR; } } int random = (strcmp(cmd, "-r") == 0) || (strcmp(cmd, "--random") == 0); if (random) { if (argc == 5) { const int seed = atoi(argv[4]); srand((unsigned int) seed); } else { srand((unsigned int) time(0)); } } useXYZ = (strstr(cmd, "XYZ") != 0); // Statistics. resetStatistics(nrOfPoints); int gridX = 0; int gridY = 0; int line = my_round(sqrt((double) totalNrOfPoints)); for (int i = 0; i < totalNrOfPoints; ++i) { double lat; double lon; double unit1; double unit2; if (random) { unit1 = ((double) rand()) / RAND_MAX; unit2 = ((double) rand()) / RAND_MAX; } else { unit1 = ((double) gridX) / line; unit2 = ((double) gridY) / line; if (gridX < line) { ++gridX; } else { gridX = 0; ++gridY; } } unitToLatLonDeg(unit1, unit2, &lat, &lon); generateAndOutputMapcodes(lat, lon, 1, extraDigits, useXYZ); if ((i % SHOW_PROGRESS) == 0) { showProgress(i); } } outputStatistics(); } else { // ------------------------------------------------------------------ // Usage. // ------------------------------------------------------------------ usage(appName); return NORMAL_ERROR; } return 0; }
inline Box3d BoundedVolume3d::bounds() const { return boundaries().bounds(); }
int EDLSession::load_defaults(BC_Hash *defaults) { char string[BCTEXTLEN]; // Default channel positions for(int i = 0; i < MAXCHANNELS; i++) { sprintf(string, "ACHANNEL_ANGLE_%d", i); int default_position = i * 30; if(i == 0) default_position = 180; else if(i == 1) default_position = 0; else if(default_position == 90) default_position = 300; else if(default_position == 0) default_position = 330; achannel_positions[i] = defaults->get(string, default_position); } aconfig_duplex->load_defaults(defaults); aconfig_in->load_defaults(defaults); assetlist_format = defaults->get("ASSETLIST_FORMAT", ASSETS_ICONS); aspect_w = defaults->get("ASPECTW", (float)4); aspect_h = defaults->get("ASPECTH", (float)3); for(int i = 0; i < ASSET_COLUMNS; i++) { sprintf(string, "ASSET_COLUMN%d", i); asset_columns[i] = defaults->get(string, 100); } audio_channels = defaults->get("ACHANNELS", 2); audio_tracks = defaults->get("ATRACKS", 2); auto_conf->load_defaults(defaults); autos_follow_edits = defaults->get("AUTOS_FOLLOW_EDITS", 1); brender_start = defaults->get("BRENDER_START", brender_start); cmodel_to_text(string, BC_RGBA8888); color_model = cmodel_from_text(defaults->get("COLOR_MODEL", string)); eyedrop_radius = defaults->get("EYEDROP_RADIUS", 0); crop_x1 = defaults->get("CROP_X1", 0); crop_x2 = defaults->get("CROP_X2", 320); crop_y1 = defaults->get("CROP_Y1", 0); crop_y2 = defaults->get("CROP_Y2", 240); ruler_x1 = defaults->get("RULER_X1", 0.0); ruler_x2 = defaults->get("RULER_X2", 0.0); ruler_y1 = defaults->get("RULER_Y1", 0.0); ruler_y2 = defaults->get("RULER_Y2", 0.0); sprintf(current_folder, MEDIA_FOLDER); defaults->get("CURRENT_FOLDER", current_folder); cursor_on_frames = defaults->get("CURSOR_ON_FRAMES", 0); typeless_keyframes = defaults->get("TYPELESS_KEYFRAMES", 0); cwindow_dest = defaults->get("CWINDOW_DEST", 0); cwindow_mask = defaults->get("CWINDOW_MASK", 0); cwindow_meter = defaults->get("CWINDOW_METER", 1); cwindow_operation = defaults->get("CWINDOW_OPERATION", 0); cwindow_scrollbars = defaults->get("CWINDOW_SCROLLBARS", 1); cwindow_xscroll = defaults->get("CWINDOW_XSCROLL", 0); cwindow_yscroll = defaults->get("CWINDOW_YSCROLL", 0); cwindow_zoom = defaults->get("CWINDOW_ZOOM", (float)1); sprintf(default_atransition, "Crossfade"); defaults->get("DEFAULT_ATRANSITION", default_atransition); sprintf(default_vtransition, "Dissolve"); defaults->get("DEFAULT_VTRANSITION", default_vtransition); default_transition_length = defaults->get("DEFAULT_TRANSITION_LENGTH", (double)1); edit_handle_mode[0] = defaults->get("EDIT_HANDLE_MODE0", MOVE_ALL_EDITS); edit_handle_mode[1] = defaults->get("EDIT_HANDLE_MODE1", MOVE_ONE_EDIT); edit_handle_mode[2] = defaults->get("EDIT_HANDLE_MODE2", MOVE_NO_EDITS); editing_mode = defaults->get("EDITING_MODE", EDITING_IBEAM); enable_duplex = defaults->get("ENABLE_DUPLEX", 1); folderlist_format = defaults->get("FOLDERLIST_FORMAT", FOLDERS_ICONS); frame_rate = defaults->get("FRAMERATE", (double)30000.0/1001); frames_per_foot = defaults->get("FRAMES_PER_FOOT", (float)16); interpolation_type = defaults->get("INTERPOLATION_TYPE", interpolation_type); interpolate_raw = defaults->get("INTERPOLATE_RAW", interpolate_raw); white_balance_raw = defaults->get("WHITE_BALANCE_RAW", white_balance_raw); labels_follow_edits = defaults->get("LABELS_FOLLOW_EDITS", 1); plugins_follow_edits = defaults->get("PLUGINS_FOLLOW_EDITS", 1); single_standalone = defaults->get("SINGLE_STANDALONE", 1); auto_keyframes = defaults->get("AUTO_KEYFRAMES", 0); meter_format = defaults->get("METER_FORMAT", METER_DB); min_meter_db = defaults->get("MIN_METER_DB", -85); max_meter_db = defaults->get("MAX_METER_DB", 6); mpeg4_deblock = defaults->get("MPEG4_DEBLOCK", mpeg4_deblock); output_w = defaults->get("OUTPUTW", 720); output_h = defaults->get("OUTPUTH", 480); playback_buffer = defaults->get("PLAYBACK_BUFFER", 4096); playback_preload = defaults->get("PLAYBACK_PRELOAD", 0); playback_software_position = defaults->get("PLAYBACK_SOFTWARE_POSITION", 0); delete playback_config; playback_config = new PlaybackConfig; playback_config->load_defaults(defaults); real_time_playback = defaults->get("PLAYBACK_REALTIME", 0); real_time_record = defaults->get("REALTIME_RECORD", 0); record_software_position = defaults->get("RECORD_SOFTWARE_POSITION", 1); record_sync_drives = defaults->get("RECORD_SYNC_DRIVES", 0); // record_speed = defaults->get("RECORD_SPEED", 24); record_fragment_size = defaults->get("RECORD_FRAGMENT_SIZE", 2048); record_write_length = defaults->get("RECORD_WRITE_LENGTH", 131072); recording_format->load_defaults(defaults, "RECORD_", 1, 1, 1, 1, 1); safe_regions = defaults->get("SAFE_REGIONS", 1); sample_rate = defaults->get("SAMPLERATE", 48000); scrub_speed = defaults->get("SCRUB_SPEED", (float)2); show_assets = defaults->get("SHOW_ASSETS", 1); show_titles = defaults->get("SHOW_TITLES", 1); // test_playback_edits = defaults->get("TEST_PLAYBACK_EDITS", 1); time_format = defaults->get("TIME_FORMAT", TIME_HMS); nudge_seconds = defaults->get("NUDGE_FORMAT", 1); tool_window = defaults->get("TOOL_WINDOW", 0); vconfig_in->load_defaults(defaults); for(int i = 0; i < MAXCHANNELS; i++) { int default_position = i * output_w; sprintf(string, "VCHANNEL_X_%d", i); vchannel_x[i] = defaults->get(string, default_position); sprintf(string, "VCHANNEL_Y_%d", i); vchannel_y[i] = defaults->get(string, 0); } video_channels = defaults->get("VCHANNELS", 1); video_every_frame = defaults->get("VIDEO_EVERY_FRAME", 1); video_asynchronous = defaults->get("VIDEO_ASYNCHRONOUS", 0); video_tracks = defaults->get("VTRACKS", 1); video_write_length = defaults->get("VIDEO_WRITE_LENGTH", 30); view_follows_playback = defaults->get("VIEW_FOLLOWS_PLAYBACK", 1); vwindow_meter = defaults->get("VWINDOW_METER", 1); decode_subtitles = defaults->get("DECODE_SUBTITLES", decode_subtitles); subtitle_number = defaults->get("SUBTITLE_NUMBER", subtitle_number); vwindow_zoom = defaults->get("VWINDOW_ZOOM", (float)1); boundaries(); return 0; }
/* troche brzydkiego kodu ;) częsciowo skopiowanego z modułu history-migration*/ void ImportFromGG::run() { //kodowanie historii QTextCodec::setCodecForCStrings(QTextCodec::codecForName("cp1250")); if (cancel) return; /* przesuń się na index */ arch->seek(gg_header.index_off); /* oblicz ilość sekcji w indeksie */ int index_entries=gg_header.index_size/sizeof(gg_index); /* odczytaj kolejne sekcje */ for (int i=0;i<index_entries;i++) { arch->read(reinterpret_cast<char*>(&gg_index), sizeof(gg_index)); if (i!=1) continue; //pierwsza sekcja (0) zawiera smieci, druga(1) wiadomosci, inne nas nie interesują /* zapamiętaj pozycje w pliku, bo zaraz bedziemy po nim jeździć */ qint64 pos=arch->pos(); /* offset bloku danych liczony względem sekcji danych (data_off w strukturze nagłówka) */ /* przesuń się na pierwszy blok */ arch->seek(gg_header.data_off + gg_index.first_block_off); emit boundaries(gg_index.first_block_off,gg_index.last_block_off); //ustaw progress bar /* analizuj kolejne bloki */ do { arch->read(reinterpret_cast<char*>(&gg_block), sizeof(gg_block)); //wczytaj nagłówek bloku /* odczytaj wszystkie nagłówki wiadomości znajdujące się za nagłówkiem */ int msg_entries=gg_block.block_size/sizeof(struct msg_header); //liczba wiadomości gg_msg_header=new struct msg_header[msg_entries]; arch->read(reinterpret_cast<char*>(gg_msg_header), sizeof(struct msg_header) *msg_entries); for (int j=0;j<msg_entries;j++) { arch->seek(gg_header.data_off + gg_msg_header[j].msg_off); /* odczytaj nagłówek wiadomości */ arch->read(reinterpret_cast<char*>(&gg_message), sizeof(gg_message)); Message message=Message::create(); /* na podstawie message.recivers rozsądź czy wiadomość przychodząca czy wychodząca */ /* jeśli message.recivers==0 to wiadomość przychodząca */ /* jeśli message.recivers>0 i uin inny niż w nagłówku to przychodząca konferencja */ /* jeśli message.recivers>0 i uin jak w nagłówku to wychodząca (może również to być konferencja) */ if (gg_message.recivers==0) //przychodząca { /* doczytaj ciąg dalszy wiadomości */ arch->read(reinterpret_cast<char*>(&gg_rcv_msg), sizeof(gg_rcv_msg)); /* odczytaj treść wiadomości */ QByteArray msg=arch->read(gg_rcv_msg.len); int uin = gg_message.sender_uin; UinsList uinsList; uinsList << uin; Chat chat=chatFromUinsList(uinsList); Contact user=ContactManager::instance()->byId(account, QString::number(uin), ActionCreateAndAdd); message.setMessageChat(chat); message.setMessageSender(user); message.setContent(decode(msg, user)); message.setSendDate(QDateTime::fromTime_t (gg_message.send_time)); message.setReceiveDate(QDateTime::fromTime_t (gg_rcv_msg.rcv_time)); message.setType(MessageTypeReceived); History::instance()->currentStorage()->appendMessage(message); //1. argument (osoba/by z którymi gadamy) 2. ten kto pisał czyli w tym wypadku dwa razy to samo //History::instance()->currentStorage()->appendMessage(uins, gg_message.sender_uin, decode ( msg,uins[0] ),false,gg_message.send_time,true,gg_rcv_msg.rcv_time ); } else //wychodząca (konferencja) lub przychodząca konferencja { /* w pliku kolejno: 0x0C [n] * 4 bajty numerki odbiorców 0x0C + [n] * 4 4 bajty prawdopodobnie czas dostarczenia wiadomości do odbiorcy 0x10 + [n] * 4 4 bajty długość wiadomości (len) 0x14 + [n] * 4 [len] bajtów wiadomość */ quint32* us= new quint32[gg_message.recivers]; quint32 time; quint32 len; arch->read(reinterpret_cast<char*>(us), sizeof(quint32) *gg_message.recivers); arch->read(reinterpret_cast<char*>(&time), sizeof(quint32)); arch->read(reinterpret_cast<char*>(&len), sizeof(quint32)); /* odczytaj treść wiadomości */ QByteArray msg=arch->read(len); UinsList uins; bool outgoing= owner_uin==gg_message.sender_uin; if (outgoing==false) //konferencja lub wiadomość przychodząca uins << gg_message.sender_uin; //dopisz tego co przysyła też do listy odbiorców for (int k=0; k<gg_message.recivers; k++) if (us[k]!=owner_uin) uins << us[k]; //stare gg (chyba <6.0) traktuje zwykle rozmowy jak konferencje dodając osobe wysylającą (własciciela) do listy odbiorców, wyrzuć go Contact user=outgoing? account.accountContact() :ContactManager::instance()->byId(account, QString::number(gg_message.sender_uin), ActionCreateAndAdd); message.setMessageChat(chatFromUinsList(uins)); message.setMessageSender(user); message.setContent(decode(msg, user)); // message.setContent(decode(msg, uins[0])); //1. uin ? nie pamięta skąd to sie wzięło, widocznie tak jest ;) message.setSendDate(QDateTime::fromTime_t (gg_message.send_time)); message.setReceiveDate(QDateTime::fromTime_t (gg_rcv_msg.rcv_time)); message.setType(outgoing ? MessageTypeSent : MessageTypeReceived); History::instance()->currentStorage()->appendMessage(message); } } /* przesuń się do kolejnego bloku */ delete [] gg_msg_header; if (gg_block.next_block!=0) arch->seek(gg_header.data_off + gg_block.next_block); position=gg_block.next_block; } while (gg_block.next_block!=0 && !cancel); //pracuj dopóki cancel==false /* powrót do sekcji */ arch->seek(pos); } arch->close(); return; }
int MainSession::load_defaults(BC_Hash *defaults) { // Setup main windows default_window_positions(); vwindow_x = defaults->get("VWINDOW_X", vwindow_x); vwindow_y = defaults->get("VWINDOW_Y", vwindow_y); vwindow_w = defaults->get("VWINDOW_W", vwindow_w); vwindow_h = defaults->get("VWINDOW_H", vwindow_h); cwindow_x = defaults->get("CWINDOW_X", cwindow_x); cwindow_y = defaults->get("CWINDOW_Y", cwindow_y); cwindow_w = defaults->get("CWINDOW_W", cwindow_w); cwindow_h = defaults->get("CWINDOW_H", cwindow_h); ctool_x = defaults->get("CTOOL_X", ctool_x); ctool_y = defaults->get("CTOOL_Y", ctool_y); gwindow_x = defaults->get("GWINDOW_X", gwindow_x); gwindow_y = defaults->get("GWINDOW_Y", gwindow_y); mwindow_x = defaults->get("MWINDOW_X", mwindow_x); mwindow_y = defaults->get("MWINDOW_Y", mwindow_y); mwindow_w = defaults->get("MWINDOW_W", mwindow_w); mwindow_h = defaults->get("MWINDOW_H", mwindow_h); lwindow_x = defaults->get("LWINDOW_X", lwindow_x); lwindow_y = defaults->get("LWINDOW_Y", lwindow_y); lwindow_w = defaults->get("LWINDOW_W", lwindow_w); lwindow_h = defaults->get("LWINDOW_H", lwindow_h); awindow_x = defaults->get("AWINDOW_X", awindow_x); awindow_y = defaults->get("AWINDOW_Y", awindow_y); awindow_w = defaults->get("AWINDOW_W", awindow_w); awindow_h = defaults->get("AWINDOW_H", awindow_h); ewindow_w = defaults->get("EWINDOW_W", ewindow_w); ewindow_h = defaults->get("EWINDOW_H", ewindow_h); channels_x = defaults->get("CHANNELS_X", channels_x); channels_y = defaults->get("CHANNELS_Y", channels_y); picture_x = defaults->get("PICTURE_X", picture_x); picture_y = defaults->get("PICTURE_Y", picture_y); scope_x = defaults->get("SCOPE_X", scope_x); scope_y = defaults->get("SCOPE_Y", scope_y); scope_w = defaults->get("SCOPE_W", scope_w); scope_h = defaults->get("SCOPE_H", scope_h); histogram_x = defaults->get("HISTOGRAM_X", histogram_x); histogram_y = defaults->get("HISTOGRAM_Y", histogram_y); histogram_w = defaults->get("HISTOGRAM_W", histogram_w); histogram_h = defaults->get("HISTOGRAM_H", histogram_h); record_scope = defaults->get("RECORD_SCOPE", record_scope); use_hist = defaults->get("USE_HIST", use_hist); use_wave = defaults->get("USE_WAVE", use_wave); use_vector = defaults->get("USE_VECTOR", use_vector); use_hist_parade = defaults->get("USE_HIST_PARADE", use_hist_parade); use_wave_parade = defaults->get("USE_WAVE_PARADE", use_wave_parade); //printf("MainSession::load_defaults 1\n"); // Other windows afolders_w = defaults->get("ABINS_W", 100); rwindow_x = defaults->get("RWINDOW_X", rwindow_x); rwindow_y = defaults->get("RWINDOW_Y", rwindow_y); rwindow_w = defaults->get("RWINDOW_W", rwindow_w); rwindow_h = defaults->get("RWINDOW_H", rwindow_h); rmonitor_x = defaults->get("RMONITOR_X", rmonitor_x); rmonitor_y = defaults->get("RMONITOR_Y", rmonitor_y); rmonitor_w = defaults->get("RMONITOR_W", rmonitor_w); rmonitor_h = defaults->get("RMONITOR_H", rmonitor_h); batchrender_x = defaults->get("BATCHRENDER_X", batchrender_x); batchrender_y = defaults->get("BATCHRENDER_Y", batchrender_y); batchrender_w = defaults->get("BATCHRENDER_W", batchrender_w); batchrender_h = defaults->get("BATCHRENDER_H", batchrender_h); show_vwindow = defaults->get("SHOW_VWINDOW", 1); show_awindow = defaults->get("SHOW_AWINDOW", 1); show_cwindow = defaults->get("SHOW_CWINDOW", 1); show_lwindow = defaults->get("SHOW_LWINDOW", 0); show_gwindow = defaults->get("SHOW_GWINDOW", 0); cwindow_controls = defaults->get("CWINDOW_CONTROLS", cwindow_controls); plugindialog_w = defaults->get("PLUGINDIALOG_W", 510); plugindialog_h = defaults->get("PLUGINDIALOG_H", 415); presetdialog_w = defaults->get("PRESETDIALOG_W", 510); presetdialog_h = defaults->get("PRESETDIALOG_H", 415); keyframedialog_w = defaults->get("KEYFRAMEDIALOG_W", 510); keyframedialog_h = defaults->get("KEYFRAMEDIALOG_H", 415); keyframedialog_column1 = defaults->get("KEYFRAMEDIALOG_COLUMN1", 150); keyframedialog_column2 = defaults->get("KEYFRAMEDIALOG_COLUMN2", 100); keyframedialog_all = defaults->get("KEYFRAMEDIALOG_ALL", 0); menueffect_w = defaults->get("MENUEFFECT_W", 580); menueffect_h = defaults->get("MENUEFFECT_H", 350); transitiondialog_w = defaults->get("TRANSITIONDIALOG_W", 320); transitiondialog_h = defaults->get("TRANSITIONDIALOG_H", 512); current_tip = defaults->get("CURRENT_TIP", current_tip); actual_frame_rate = defaults->get("ACTUAL_FRAME_RATE", (float)-1); boundaries(); return 0; }
bool PrimitiveShapeClassifier::estimate(const pcl::PointCloud<PointT>::Ptr& cloud, const pcl::PointCloud<pcl::Normal>::Ptr& normal, const pcl::ModelCoefficients::Ptr& plane, pcl::PointIndices::Ptr& boundary_indices, pcl::PointCloud<PointT>::Ptr& projected_cloud, float& circle_likelihood, float& box_likelihood) { // estimate boundaries pcl::PointCloud<pcl::Boundary>::Ptr boundaries(new pcl::PointCloud<pcl::Boundary>); pcl::BoundaryEstimation<PointT, pcl::Normal, pcl::Boundary> b; b.setInputCloud(cloud); b.setInputNormals(normal); b.setSearchMethod(typename pcl::search::KdTree<PointT>::Ptr(new pcl::search::KdTree<PointT>)); b.setAngleThreshold(DEG2RAD(70)); b.setRadiusSearch(0.03); b.compute(*boundaries); // set boundaries as indices for (size_t i = 0; i < boundaries->points.size(); ++i) if ((int)boundaries->points[i].boundary_point) boundary_indices->indices.push_back(i); // extract boundaries pcl::PointCloud<PointT>::Ptr boundary_cloud(new pcl::PointCloud<PointT>); pcl::ExtractIndices<PointT> ext; ext.setInputCloud(cloud); ext.setIndices(boundary_indices); ext.filter(*boundary_cloud); // thresholding with min points num if (boundary_indices->indices.size() < min_points_num_) return false; // project to supporting plane pcl::ProjectInliers<PointT> proj; proj.setModelType(pcl::SACMODEL_PLANE); proj.setInputCloud(boundary_cloud); proj.setModelCoefficients(plane); proj.filter(*projected_cloud); // estimate circles pcl::PointIndices::Ptr circle_inliers(new pcl::PointIndices); pcl::ModelCoefficients::Ptr circle_coeffs(new pcl::ModelCoefficients); pcl::PointIndices::Ptr line_inliers(new pcl::PointIndices); pcl::ModelCoefficients::Ptr line_coeffs(new pcl::ModelCoefficients); pcl::SACSegmentation<PointT> seg; seg.setInputCloud(projected_cloud); seg.setOptimizeCoefficients(true); seg.setMethodType(pcl::SAC_RANSAC); seg.setMaxIterations(sac_max_iterations_); seg.setModelType(pcl::SACMODEL_CIRCLE3D); seg.setDistanceThreshold(sac_distance_threshold_); seg.setRadiusLimits(sac_radius_limit_min_, sac_radius_limit_max_); seg.segment(*circle_inliers, *circle_coeffs); seg.setOptimizeCoefficients(true); seg.setMethodType(pcl::SAC_RANSAC); seg.setMaxIterations(sac_max_iterations_); seg.setModelType(pcl::SACMODEL_LINE); seg.setDistanceThreshold(sac_distance_threshold_); seg.segment(*line_inliers, *line_coeffs); // compute likelihood circle_likelihood = 1.0f * circle_inliers->indices.size() / projected_cloud->points.size(); box_likelihood = 1.0f * line_inliers->indices.size() / projected_cloud->points.size(); NODELET_DEBUG_STREAM("Projected cloud has " << projected_cloud->points.size() << " points"); NODELET_DEBUG_STREAM(circle_inliers->indices.size() << " circle inliers found"); NODELET_DEBUG_STREAM("circle confidence: " << circle_likelihood); NODELET_DEBUG_STREAM(line_inliers->indices.size() << " line inliers found"); NODELET_DEBUG_STREAM("box confidence: " << box_likelihood); return true; }
int Asset::read(FileXML *file, int expand_relative) { int result = 0; // Check for relative path. if(expand_relative) { char new_path[BCTEXTLEN]; char asset_directory[BCTEXTLEN]; char input_directory[BCTEXTLEN]; FileSystem fs; strcpy(new_path, path); fs.set_current_dir(""); fs.extract_dir(asset_directory, path); // No path in asset. // Take path of XML file. if(!asset_directory[0]) { fs.extract_dir(input_directory, file->filename); // Input file has a path if(input_directory[0]) { fs.join_names(path, input_directory, new_path); } } } while(!result) { result = file->read_tag(); if(!result) { if(file->tag.title_is("/ASSET")) { result = 1; } else if(file->tag.title_is("AUDIO")) { read_audio(file); } else if(file->tag.title_is("AUDIO_OMIT")) { read_audio(file); } else if(file->tag.title_is("FORMAT")) { const char *string = file->tag.get_property("TYPE"); format = File::strtoformat(string); use_header = file->tag.get_property("USE_HEADER", use_header); file->tag.get_property("FFORMAT", fformat); } else if(file->tag.title_is("FOLDER")) { strcpy(folder, file->read_text()); } else if(file->tag.title_is("VIDEO")) { read_video(file); } else if(file->tag.title_is("VIDEO_OMIT")) { read_video(file); } else if(file->tag.title_is("INDEX")) { read_index(file); } } } boundaries(); //printf("Asset::read 2\n"); return 0; }
void Asset::load_defaults(BC_Hash *defaults, const char *prefix, int do_format, int do_compression, int do_path, int do_data_types, int do_bits) { char string[BCTEXTLEN]; // Can't save codec here because it's specific to render, record, and effect. // The codec has to be UNKNOWN for file probing to work. if(do_path) { GET_DEFAULT("PATH", path); } if(do_compression) { GET_DEFAULT("AUDIO_CODEC", acodec); GET_DEFAULT("VIDEO_CODEC", vcodec); } if(do_format) { format = GET_DEFAULT("FORMAT", format); use_header = GET_DEFAULT("USE_HEADER", use_header); GET_DEFAULT("FFORMAT", fformat); } if(do_data_types) { audio_data = GET_DEFAULT("AUDIO", 1); video_data = GET_DEFAULT("VIDEO", 1); } if(do_bits) { bits = GET_DEFAULT("BITS", 16); dither = GET_DEFAULT("DITHER", 0); signed_ = GET_DEFAULT("SIGNED", 1); byte_order = GET_DEFAULT("BYTE_ORDER", 1); // Used by filefork channels = GET_DEFAULT("CHANNELS", 2); if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 44100); header = GET_DEFAULT("HEADER", 0); audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0); height = GET_DEFAULT("HEIGHT", height); width = GET_DEFAULT("WIDTH", width); actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height); actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width); program = GET_DEFAULT("PROGRAM", program); layers = GET_DEFAULT("LAYERS", layers); if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate); video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0); } ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate); ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative); vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr); vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate); vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate); vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate); theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate); theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate); theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality); theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness); theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency); theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency); GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options); ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate); GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options); ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate); ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality); mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate); mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate); mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual); jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality); aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio); // MPEG format information vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance); vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance); vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive); vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise); vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate); vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative); vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization); vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel); vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate); vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes); vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset); vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order); h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate); h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer); h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate); divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate); divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period); divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio); divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period); divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval); divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer); divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer); divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer); divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality); divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate); divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking); ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate); ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance); ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced); ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization); ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size); ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate); ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate); png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha); exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha); exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression); tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel); tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression); boundaries(); }
void mgrid::BoundaryConditions::set(BoundaryFlag bFlag, const BoundaryPoint& pt) { boundaries(bFlag) = pt; }
void PlaneSupportedCuboidEstimator::estimate( const sensor_msgs::PointCloud2::ConstPtr& msg) { // Update polygons_ vector polygons_.clear(); for (size_t i = 0; i < latest_polygon_msg_->polygons.size(); i++) { Polygon::Ptr polygon = Polygon::fromROSMsgPtr(latest_polygon_msg_->polygons[i].polygon); polygon->decomposeToTriangles(); polygons_.push_back(polygon); } try { // viewpoint tf::StampedTransform transform = lookupTransformWithDuration(tf_, sensor_frame_, msg->header.frame_id, ros::Time(0.0), ros::Duration(0.0)); tf::vectorTFToEigen(transform.getOrigin(), viewpoint_); if (!tracker_) { NODELET_INFO("initTracker"); pcl::PointCloud<pcl::tracking::ParticleCuboid>::Ptr particles = initParticles(); tracker_.reset(new pcl::tracking::ROSCollaborativeParticleFilterTracker<pcl::PointXYZ, pcl::tracking::ParticleCuboid>); tracker_->setCustomSampleFunc(boost::bind(&PlaneSupportedCuboidEstimator::sample, this, _1)); tracker_->setLikelihoodFunc(boost::bind(&PlaneSupportedCuboidEstimator::likelihood, this, _1, _2)); tracker_->setParticles(particles); tracker_->setParticleNum(particle_num_); } else { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); pcl::fromROSMsg(*msg, *cloud); tracker_->setInputCloud(cloud); // Before call compute() method, we prepare candidate_cloud_ for // weight phase. candidate_cloud_.reset(new pcl::PointCloud<pcl::PointXYZ>); std::set<int> all_indices; for (size_t i = 0; i < latest_polygon_msg_->polygons.size(); i++) { Polygon::Ptr polygon = Polygon::fromROSMsgPtr(latest_polygon_msg_->polygons[i].polygon); pcl::ExtractPolygonalPrismData<pcl::PointXYZ> prism_extract; pcl::PointCloud<pcl::PointXYZ>::Ptr boundaries (new pcl::PointCloud<pcl::PointXYZ>); polygon->boundariesToPointCloud<pcl::PointXYZ>(*boundaries); boundaries->points.push_back(boundaries->points[0]); prism_extract.setInputCloud(cloud); prism_extract.setViewPoint(viewpoint_[0], viewpoint_[1], viewpoint_[2]); prism_extract.setHeightLimits(init_local_position_z_min_, init_local_position_z_max_); prism_extract.setInputPlanarHull(boundaries); pcl::PointIndices output_indices; prism_extract.segment(output_indices); for (size_t i = 0; i < output_indices.indices.size(); i++) { all_indices.insert(output_indices.indices[i]); } } pcl::ExtractIndices<pcl::PointXYZ> ex; ex.setInputCloud(cloud); pcl::PointIndices::Ptr indices (new pcl::PointIndices); indices->indices = std::vector<int>(all_indices.begin(), all_indices.end()); ex.setIndices(indices); ex.filter(*candidate_cloud_); sensor_msgs::PointCloud2 ros_candidate_cloud; pcl::toROSMsg(*candidate_cloud_, ros_candidate_cloud); ros_candidate_cloud.header = msg->header; pub_candidate_cloud_.publish(ros_candidate_cloud); // check the number of candidate points if (candidate_cloud_->points.size() == 0) { JSK_NODELET_ERROR("No candidate cloud"); return; } tree_.setInputCloud(candidate_cloud_); if (support_plane_updated_) { // Compute assignment between particles and polygons NODELET_INFO("polygon updated"); updateParticlePolygonRelationship(tracker_->getParticles()); } ROS_INFO("start tracker_->compute()"); tracker_->compute(); ROS_INFO("done tracker_->compute()"); Particle result = tracker_->getResult(); jsk_recognition_msgs::BoundingBoxArray box_array; box_array.header = msg->header; box_array.boxes.push_back(result.toBoundingBox()); box_array.boxes[0].header = msg->header; pub_result_.publish(box_array); } support_plane_updated_ = false; ParticleCloud::Ptr particles = tracker_->getParticles(); // Publish histograms publishHistogram(particles, 0, pub_histogram_global_x_, msg->header); publishHistogram(particles, 1, pub_histogram_global_y_, msg->header); publishHistogram(particles, 2, pub_histogram_global_z_, msg->header); publishHistogram(particles, 3, pub_histogram_global_roll_, msg->header); publishHistogram(particles, 4, pub_histogram_global_pitch_, msg->header); publishHistogram(particles, 5, pub_histogram_global_yaw_, msg->header); publishHistogram(particles, 6, pub_histogram_dx_, msg->header); publishHistogram(particles, 7, pub_histogram_dy_, msg->header); publishHistogram(particles, 8, pub_histogram_dz_, msg->header); // Publish particles sensor_msgs::PointCloud2 ros_particles; pcl::toROSMsg(*particles, ros_particles); ros_particles.header = msg->header; pub_particles_.publish(ros_particles); } catch (tf2::TransformException& e) { JSK_ROS_ERROR("tf exception"); } }
// Reference another set of BoundaryConditions void mgrid::BoundaryConditions::reference(const BoundaryConditions& referent) { foreach(BoundaryFlag boundaryFlag, allBoundaryFlags) boundaries(boundaryFlag).reference(referent.boundaries(boundaryFlag)); }
int EDL::load_xml(FileXML *file, uint32_t load_flags) { int result = 0; // Track numbering offset for replacing undo data. int track_offset = 0; // Clear objects folders.remove_all_objects(); if((load_flags & LOAD_ALL) == LOAD_ALL) { remove_vwindow_edls(); } // Search for start of master EDL. // The parent_edl test caused clip creation to fail since those XML files // contained an EDL tag. // The parent_edl test is required to make EDL loading work because // when loading an EDL the EDL tag is already read by the parent. if(!parent_edl) { do{ result = file->read_tag(); }while(!result && !file->tag.title_is("XML") && !file->tag.title_is("EDL")); } if(!result) { // Get path for backups // path[0] = 0; file->tag.get_property("path", path); // Erase everything if((load_flags & LOAD_ALL) == LOAD_ALL || (load_flags & LOAD_EDITS) == LOAD_EDITS) { while(tracks->last) delete tracks->last; } if((load_flags & LOAD_ALL) == LOAD_ALL) { for(int i = 0; i < clips.size(); i++) clips.get(i)->Garbage::remove_user(); clips.remove_all(); } if(load_flags & LOAD_TIMEBAR) { while(labels->last) delete labels->last; local_session->unset_inpoint(); local_session->unset_outpoint(); } // This was originally in LocalSession::load_xml if(load_flags & LOAD_SESSION) { local_session->clipboard_length = 0; } do{ result = file->read_tag(); if(!result) { if(file->tag.title_is("/XML") || file->tag.title_is("/EDL") || file->tag.title_is("/CLIP_EDL") || file->tag.title_is("/VWINDOW_EDL")) { result = 1; } else if(file->tag.title_is("CLIPBOARD")) { local_session->clipboard_length = file->tag.get_property("LENGTH", (double)0); } else if(file->tag.title_is("VIDEO")) { if((load_flags & LOAD_VCONFIG) && (load_flags & LOAD_SESSION)) session->load_video_config(file, 0, load_flags); } else if(file->tag.title_is("AUDIO")) { if((load_flags & LOAD_ACONFIG) && (load_flags & LOAD_SESSION)) session->load_audio_config(file, 0, load_flags); } else if(file->tag.title_is("FOLDER")) { char folder[BCTEXTLEN]; strcpy(folder, file->read_text()); new_folder(folder); } else if(file->tag.title_is("ASSETS")) { if(load_flags & LOAD_ASSETS) assets->load(file, load_flags); } else if(file->tag.title_is(labels->xml_tag)) { if(load_flags & LOAD_TIMEBAR) labels->load(file, load_flags); } else if(file->tag.title_is("LOCALSESSION")) { if((load_flags & LOAD_SESSION) || (load_flags & LOAD_TIMEBAR)) local_session->load_xml(file, load_flags); } else if(file->tag.title_is("SESSION")) { if((load_flags & LOAD_SESSION) && !parent_edl) session->load_xml(file, 0, load_flags); } else if(file->tag.title_is("TRACK")) { tracks->load(file, track_offset, load_flags); } else // Sub EDL. // Causes clip creation to fail because that involves an opening EDL tag. if(file->tag.title_is("CLIP_EDL") && !parent_edl) { EDL *new_edl = new EDL(this); new_edl->create_objects(); new_edl->load_xml(file, LOAD_ALL); if((load_flags & LOAD_ALL) == LOAD_ALL) clips.append(new_edl); else new_edl->Garbage::remove_user(); } else if(file->tag.title_is("VWINDOW_EDL") && !parent_edl) { EDL *new_edl = new EDL(this); new_edl->create_objects(); new_edl->load_xml(file, LOAD_ALL); if((load_flags & LOAD_ALL) == LOAD_ALL) { // if(vwindow_edl && !vwindow_edl_shared) // vwindow_edl->Garbage::remove_user(); // vwindow_edl_shared = 0; // vwindow_edl = new_edl; append_vwindow_edl(new_edl, 0); } else // Discard if not replacing EDL { new_edl->Garbage::remove_user(); new_edl = 0; } } } }while(!result); } boundaries(); //dump(); return 0; }
int EDL::load_xml(ArrayList<PluginServer*> *plugindb, FileXML *file, uint32_t load_flags) { int result = 0; // Track numbering offset for replacing undo data. int track_offset = 0; // Search for start of master EDL. // The parent_edl test caused clip creation to fail since those XML files // contained an EDL tag. // The parent_edl test is required to make EDL loading work because // when loading an EDL the EDL tag is already read by the parent. if(!parent_edl) { do{ result = file->read_tag(); }while(!result && !file->tag.title_is("XML") && !file->tag.title_is("EDL")); } if(!result) { // Get path for backups project_path[0] = 0; file->tag.get_property("PROJECT_PATH", project_path); // Erase everything if((load_flags & LOAD_ALL) == LOAD_ALL || (load_flags & LOAD_EDITS) == LOAD_EDITS) { while(tracks->last) delete tracks->last; } if((load_flags & LOAD_ALL) == LOAD_ALL) { clips.remove_all_objects(); } if(load_flags & LOAD_TIMEBAR) { while(labels->last) delete labels->last; local_session->unset_inpoint(); local_session->unset_outpoint(); } do{ result = file->read_tag(); if(!result) { if(file->tag.title_is("/XML") || file->tag.title_is("/EDL") || file->tag.title_is("/CLIP_EDL") || file->tag.title_is("/VWINDOW_EDL")) { result = 1; } else if(file->tag.title_is("CLIPBOARD")) { local_session->clipboard_length = file->tag.get_property("LENGTH", 0); } else if(file->tag.title_is("VIDEO")) { if((load_flags & LOAD_VCONFIG) && (load_flags & LOAD_SESSION)) session->load_video_config(file, 0, load_flags); } else if(file->tag.title_is("AUDIO")) { if((load_flags & LOAD_ACONFIG) && (load_flags & LOAD_SESSION)) session->load_audio_config(file, 0, load_flags); } else if(file->tag.title_is("ASSETS")) { if(load_flags & LOAD_ASSETS) assets->load(plugindb, file, load_flags); } else if(file->tag.title_is(labels->xml_tag)) { if(load_flags & LOAD_TIMEBAR) labels->load(file, load_flags); } else if(file->tag.title_is("LOCALSESSION")) { if((load_flags & LOAD_SESSION) || (load_flags & LOAD_TIMEBAR)) local_session->load_xml(file, load_flags); } else if(file->tag.title_is("SESSION")) { if((load_flags & LOAD_SESSION) && !parent_edl) session->load_xml(file, 0, load_flags); } else if(file->tag.title_is("TRACK")) { tracks->load(file, track_offset, load_flags); } else // Sub EDL. // Causes clip creation to fail because that involves an opening EDL tag. if(file->tag.title_is("CLIP_EDL") && !parent_edl) { EDL *new_edl = new EDL(this); new_edl->create_objects(); new_edl->load_xml(plugindb, file, LOAD_ALL); if((load_flags & LOAD_ALL) == LOAD_ALL) clips.append(new_edl); else delete new_edl; } else if(file->tag.title_is("VWINDOW_EDL") && !parent_edl) { EDL *new_edl = new EDL(this); new_edl->create_objects(); new_edl->load_xml(plugindb, file, LOAD_ALL); if((load_flags & LOAD_ALL) == LOAD_ALL) { if(vwindow_edl && !vwindow_edl_shared) delete vwindow_edl; vwindow_edl = new_edl; vwindow_edl_shared = 0; } else { delete new_edl; new_edl = 0; } } } }while(!result); } boundaries(); //dump(); return 0; }
// inteface to various superpixel helpers void mexFunction( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { int f; char action[1024]; f=mxGetString(pr[0],action,1024); nr--; pr++; uint *S = (uint*) mxGetData(pr[0]); int h = (int) mxGetM(pr[0]); int w = (int) mxGetN(pr[0]); if(f) { mexErrMsgTxt("Failed to get action."); } else if(!strcmp(action,"sticky")) { // S = sticky( S, I, E, prm ) float *I = (float*) mxGetData(pr[1]); float *E = (float*) mxGetData(pr[2]); double *prm = (double*) mxGetData(pr[3]); pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL); uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint)); sticky(T,h,w,I,E,prm); relabel(T,h,w); } else if(!strcmp(action,"boundaries")) { // S = boundaries( S, E, add, nThreads ) float *E = (float*) mxGetData(pr[1]); bool add = mxGetScalar(pr[2])>0; uint nThreads = (uint) mxGetScalar(pr[3]); pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL); uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint)); boundaries(T,h,w,E,add,nThreads); } else if(!strcmp(action,"merge")) { // S = merge( S, E, thr ); float *E = (float*) mxGetData(pr[1]); float thr = (float) mxGetScalar(pr[2]); pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL); uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint)); merge(T,h,w,E,thr); } else if(!strcmp(action,"visualize")) { // V = visualize( S, I, hasBnds ) float *I = (float*) mxGetData(pr[1]); bool hasBnds = mxGetScalar(pr[2])>0; const int dims[3] = {h,w,3}; pl[0] = mxCreateNumericArray(3,dims,mxSINGLE_CLASS,mxREAL); float* V = (float*) mxGetData(pl[0]); visualize(V,S,h,w,I,hasBnds); } else if(!strcmp(action,"affinities")) { // A = affinities( S, E, segs, nThreads ) float *E = (float*) mxGetData(pr[1]); uint8 *segs = (uint8*) mxGetData(pr[2]); uint nThreads = (uint) mxGetScalar(pr[3]); if( mxGetNumberOfDimensions(pr[2])!=5 ) mexErrMsgTxt("invalid input"); uint *dims = (uint*) mxGetDimensions(pr[2]); uint m=0; for( uint x=0; x<w*h; x++ ) m=S[x]>m ? S[x] : m; pl[0] = mxCreateNumericMatrix(m,m,mxSINGLE_CLASS,mxREAL); float *A = (float*) mxGetData(pl[0]); affinities(A,S,h,w,E,segs,dims,nThreads); } else if(!strcmp(action,"edges")) { // E = edges(S,A); float* A = (float*) mxGetData(pr[1]); pl[0] = mxCreateNumericMatrix(h,w,mxSINGLE_CLASS,mxREAL); float *E = (float*) mxGetData(pl[0]); edges(E,S,h,w,A); } else mexErrMsgTxt("Invalid action."); }
template <class T> void FastStatsHist<T>::actuate(Lng32 numEHIntervals) { //cbf_->printfreq(group_->colNames->data()); Int32 numEWIntervals = 4 * numEHIntervals; T width = (max_ - min_ + (numEWIntervals - 1)) / numEWIntervals; if (width == 0) // range of values (e.g., _SALT_) may be less than # intervals width = 1; // Average height of intervals in equi-width histogram. This is passed to the // histogram ctor below when creating the equi-width histogram, and is used as // the initial number of elements in the NAArray underlying the interval (an // array of value/frequency pairs). Int32 keysPerEWInterval = cbf_->getAllKeys().entries() / numEWIntervals; // FSHistogram* equiWidthHist = // new(STMTHEAP) FSHistogram(STMTHEAP, numEWIntervals, keysPerEWInterval); FSHistogram<T> equiWidthHist(STMTHEAP, numEWIntervals, keysPerEWInterval); // Now compute the equi-width histogram. const NAList<simple_cbf_key>& keys = cbf_->getAllKeys(); CollIndex intvlInx; UInt64 freq; T keyVal; // Iterate over each distinct value found and add it to the correct interval // of the equi-width histogram. for (CollIndex i=0; i<keys.entries(); i++ ) { const simple_cbf_key& key = keys[i]; // Look up the key in the CBF and find its frequency of occurrence. if (!cbf_->contain(key.getKey(), key.getKeyLen(), &freq)) continue; // why would the key not be found in CBF? // compute the interval index for the key keyVal = *((T*)key.getKey()); intvlInx = (CollIndex)((keyVal - min_) / width); if (intvlInx == numEWIntervals) intvlInx--; if (intvlInx < 0) continue; // shouldn't happen if min/max maintained correctly // Insert the encoded value and freq pair into the interval. KeyFreqPair<T> vf(keyVal, (UInt32)freq); equiWidthHist[intvlInx].append(vf); } //equiWidthHist.display(cout, "Equi-width histogram:"); // Now convert the equi-width histogram into equal height one //float skRatio = 0.05; float skRatio = 1.00; // Set the target interval height to the total frequency divided by the // desired number of intervals. Int32 height = totalFreq_ / numEHIntervals; // This is an estimate of the number of distinct values that will be // represented in each interval of the equi-height histogram. It will // only be exactly correct when each distinct value has the same // frequency. It is only used as an arg to the ctor to construct the // equi-height histogram, saying what the initial number of elements in // the NAArray of intervals should be. Int32 keysPerEHInterval = keys.entries() / numEHIntervals; FSHistogram<T> equiHeightHist(STMTHEAP, numEHIntervals, keysPerEHInterval); // First allocate 'numEHIntervals' intervals. May require more. NAList<T> boundaries(STMTHEAP, numEHIntervals); equiWidthHist.convertToEQHistogram(height, equiHeightHist, boundaries); //equiHeightHist.display(cout, "Equa-height Histogram"); equiHeightHist.estimateRowsAndUecs(FastStatsHist::SAMPLE_RATE, skRatio); //equaHeightHistogram.displayRowsAndUecs(cout, "========== Computed UECs ==========="); }
int EDLSession::load_xml(FileXML *file, int append_mode, uint32_t load_flags) { char string[BCTEXTLEN]; if(append_mode) { } else { assetlist_format = file->tag.get_property("ASSETLIST_FORMAT", assetlist_format); for(int i = 0; i < ASSET_COLUMNS; i++) { sprintf(string, "ASSET_COLUMN%d", i); asset_columns[i] = file->tag.get_property(string, asset_columns[i]); } auto_conf->load_xml(file); auto_keyframes = file->tag.get_property("AUTO_KEYFRAMES", auto_keyframes); autos_follow_edits = file->tag.get_property("AUTOS_FOLLOW_EDITS", autos_follow_edits); brender_start = file->tag.get_property("BRENDER_START", brender_start); eyedrop_radius = file->tag.get_property("EYEDROP_RADIUS", eyedrop_radius); crop_x1 = file->tag.get_property("CROP_X1", crop_x1); crop_y1 = file->tag.get_property("CROP_Y1", crop_y1); crop_x2 = file->tag.get_property("CROP_X2", crop_x2); crop_y2 = file->tag.get_property("CROP_Y2", crop_y2); ruler_x1 = file->tag.get_property("RULER_X1", ruler_x1); ruler_y1 = file->tag.get_property("RULER_Y1", ruler_y1); ruler_x2 = file->tag.get_property("RULER_X2", ruler_x2); ruler_y2 = file->tag.get_property("RULER_Y2", ruler_y2); file->tag.get_property("CURRENT_FOLDER", current_folder); cursor_on_frames = file->tag.get_property("CURSOR_ON_FRAMES", cursor_on_frames); typeless_keyframes = file->tag.get_property("TYPELESS_KEYFRAMES", typeless_keyframes); cwindow_dest = file->tag.get_property("CWINDOW_DEST", cwindow_dest); cwindow_mask = file->tag.get_property("CWINDOW_MASK", cwindow_mask); cwindow_meter = file->tag.get_property("CWINDOW_METER", cwindow_meter); cwindow_operation = file->tag.get_property("CWINDOW_OPERATION", cwindow_operation); cwindow_scrollbars = file->tag.get_property("CWINDOW_SCROLLBARS", cwindow_scrollbars); cwindow_xscroll = file->tag.get_property("CWINDOW_XSCROLL", cwindow_xscroll); cwindow_yscroll = file->tag.get_property("CWINDOW_YSCROLL", cwindow_yscroll); cwindow_zoom = file->tag.get_property("CWINDOW_ZOOM", cwindow_zoom); editing_mode = file->tag.get_property("EDITING_MODE", editing_mode); folderlist_format = file->tag.get_property("FOLDERLIST_FORMAT", folderlist_format); highlighted_track = file->tag.get_property("HIGHLIGHTED_TRACK", 0); labels_follow_edits = file->tag.get_property("LABELS_FOLLOW_EDITS", labels_follow_edits); mpeg4_deblock = file->tag.get_property("MPEG4_DEBLOCK", mpeg4_deblock); plugins_follow_edits = file->tag.get_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits); single_standalone = file->tag.get_property("SINGLE_STANDALONE", single_standalone); playback_preload = file->tag.get_property("PLAYBACK_PRELOAD", playback_preload); safe_regions = file->tag.get_property("SAFE_REGIONS", safe_regions); show_assets = file->tag.get_property("SHOW_ASSETS", 1); show_titles = file->tag.get_property("SHOW_TITLES", 1); // test_playback_edits = file->tag.get_property("TEST_PLAYBACK_EDITS", test_playback_edits); time_format = file->tag.get_property("TIME_FORMAT", time_format); nudge_seconds = file->tag.get_property("NUDGE_FORMAT", nudge_seconds); tool_window = file->tag.get_property("TOOL_WINDOW", tool_window); vwindow_meter = file->tag.get_property("VWINDOW_METER", vwindow_meter); vwindow_zoom = file->tag.get_property("VWINDOW_ZOOM", vwindow_zoom); decode_subtitles = file->tag.get_property("DECODE_SUBTITLES", decode_subtitles); subtitle_number = file->tag.get_property("subtitle_number", subtitle_number); boundaries(); } return 0; }
inline bool BoundedVolume3d::isEmpty() const { return boundaries().isEmpty(); }