void Cmerkle_tree::set(int i, const_memory_range v) { assert(i >= 0); assert(i < m_size); set0(i, v); int a = 0; int b = m_size; while (b - a >= 2) { int j = i ^ 1; if (a + j < b && !*d(a + j)) break; if (i > j) std::swap(i, j); int c = a; a = b; i >>= 1; if (*d(a + i)) break; *d(a + i) = true; if (c + j < b) set0(a + i, internal_hash(get0(c + j - 1), get0(c + j))); else set0(a + i, get0(c + j - 1)); b += b - c + 1 >> 1; } }
void handle(event me[2]) { if(is1(flag,0)&&is1(me[1].b,0)) { if(me[1].x>=x&&me[1].x<(x+w)&&me[1].y>=y&&me[1].y<(y+h)) set1(flag,1); else set0(flag,1); } if(is1(flag,1)) {if(me[1].key==1) { if(me[1].ch==8){if(no>0){no--;st[no]=0;}} else if(me[1].ch==13){set1(flag,2);} else if(no<num&&isalnum(me[1].ch)) {st[no]=me[1].ch; no++; st[no]=0; } } if(me[1].key==2) {if(me[1].ch==72)set1(flag,3); else if(me[1].ch==80)set1(flag,4); } setfillstyle(SOLID_FILL,ACOL); bar(x,y-2,x+w+1,y+h+2); } setfillstyle(SOLID_FILL,8); bar(x+w1,y,x+w,y+h); setcolor(color); outtextxy(x+1,y+3,str); setcolor(15); outtextxy(x+1+w1,y+3,st); }
Tools_toolbar::Tools_toolbar(CGAL::Qt_widget *w, QMainWindow *mw) : QToolBar(mw, "NT") { //when it is created, the toolbar has 0 buttons nr_of_buttons = 0; //set the widget widget = w; widget->attach(&getpolybut); getpolybut.deactivate(); QIconSet set0(QPixmap( (const char**)arrow_small_xpm ), QPixmap( (const char**)arrow_xpm )); QIconSet set1(QPixmap( (const char**)polygon_small_xpm ), QPixmap( (const char**)polygon_xpm )); but[0] = new QToolButton(this, "deactivate layer"); but[0]->setIconSet(set0); but[0]->setTextLabel("Deactivate Layer"); but[1] = new QToolButton(this, "polygon"); but[1]->setIconSet(set1); but[1]->setTextLabel("Input Polygon"); button_group = new QButtonGroup(0, "exclusive_group"); button_group->insert(but[0]); button_group->insert(but[1]); button_group->setExclusive(true); but[0]->setToggleButton(true); but[1]->setToggleButton(true); connect(but[1], SIGNAL(stateChanged(int)), &getpolybut, SLOT(stateChanged(int))); nr_of_buttons = 2; }
int main (int argc, char** argv) { static bitfield a; bitfield b = bfi1 (a); bitfield c = bfi2 (b); bitfield d = movk (c); if (d.eight != 3) abort (); if (d.five != 7) abort (); if (d.sixteen != 7531) abort (); d = set1 (d); if (d.five != 0x1f) abort (); d = set0 (d); if (d.five != 0) abort (); return 0; }
int main() { scanf("%d",&n); set0(g); set0(ne); set0(vis); set0(ans); min = n; for(int i=1; i<=n; i++) for(int j=1; j<=n; j++){ scanf("%d",&g[i][j]); ne[i]++; } dfs(1,0); for(int i=1; i<=n; i++) printf("%d ",best[i]); printf("\n%d\n",min); return 0; }
TEST(TSet, can_use_sum_for_three_sets) { const int size = 10; TSet set0(size), set1(size), set2(size), set3(size), expSet(size); set0.InsElem(1); set1.InsElem(3); set2.InsElem(5); set3 = set0 + set1 + set2; expSet.InsElem(1); expSet.InsElem(3); expSet.InsElem(5); EXPECT_EQ(expSet, set3); }
void handle(event me[2]) {if(is1(flag,0)) {if(is1(flag,1)) {if(me[1].x>=x+w1-2&&me[1].y>y&&me[1].x<x+w1+charheight+2&&me[1].y<y+charheight+8) {setfillstyle(SOLID_FILL,ACOL);bar(x+w1-2,y,x+w1+charheight+2,y+charheight+8); if((me[1].b&1)==1){set1(flag,3);set0(flag,1);set1(flag,2);} } } if(is1(flag,2)) {if(me[1].x>x+w/2+w2+1&&me[1].y>y&&me[1].x<x+w/2+w2+charheight+9&&me[1].y<y+charheight+8) {setfillstyle(SOLID_FILL,ACOL);bar(x+w/2+w2+1,y,x+w/2+w2+charheight+9,y+charheight+8); if((me[1].b&1)==1){set1(flag,4);set0(flag,2);set1(flag,1);} } } } if(is1(flag,1)&&is1(flag,0))setcolor(1);else setcolor(8); outtextxy(x+1,y+4," PLAY : "); setcolor(0); setfillstyle(SOLID_FILL,1); int pol[8]; pol[0]=x+w1+2;pol[1]=y+1; pol[2]=x+w1+2;pol[3]=y+charheight+7; pol[4]=x+w1+(charheight+6)/sqrt(2);pol[5]=y+(charheight+6)/2+1; pol[6]=x+w1+2;pol[7]=y+1; fillpoly(4,pol); setcolor(9); drawpoly(4,pol); if(is1(flag,2)&&is1(flag,0))setcolor(2);else setcolor(8); outtextxy(x+1+w/2,y+4," PAUSE : "); setcolor(0); setfillstyle(SOLID_FILL,2); bar(x+w/2+w2+3,y+2,x+w/2+w2+charheight+7,y+charheight+6); setcolor(11); rectangle(x+w/2+w2+3,y+2,x+w/2+w2+charheight+7,y+charheight+6); line(x+w/2+7+w2,y+5,x+w/2+7+w2,y+charheight+3); line(x+w/2+11+w2,y+5,x+w/2+11+w2,y+charheight+3); }
Tools_toolbar::Tools_toolbar(CGAL::Qt_widget *w, QMainWindow *mw) : QToolBar(mw, "NT") { w->attach(&input_point); input_point.deactivate(); w->attach(&input_line); input_line.deactivate(); w->attach(&input_polygon); input_polygon.deactivate(); //set the widget widget = w; QIconSet set0(QPixmap( (const char**)arrow_small_xpm ), QPixmap( (const char**)arrow_xpm )); QIconSet set1(QPixmap( (const char**)point_small_xpm ), QPixmap( (const char**)point_xpm )); QIconSet set2(QPixmap( (const char**)line_small_xpm ), QPixmap( (const char**)line_xpm )); QIconSet set3(QPixmap( (const char**)polygon_small_xpm ), QPixmap( (const char**)polygon_xpm )); but[0] = new QToolButton(this, "Deactivate Layer"); but[0]->setIconSet(set0); but[0]->setTextLabel("Deactivate Layer"); but[1] = new QToolButton(this, "pointinput layer"); but[1]->setIconSet(set1); but[1]->setTextLabel("Input Point"); but[2] = new QToolButton(this, "lineinput layer"); but[2]->setIconSet(set2); but[2]->setTextLabel("Input Line"); but[3] = new QToolButton(this, "polygoninput layer"); but[3]->setIconSet(set3); but[3]->setTextLabel("Input Simple Polygon"); nr_of_buttons = 4; button_group = new QButtonGroup(0, "My_group"); for(int i = 0; i<nr_of_buttons; i++) { button_group->insert(but[i]); but[i]->setToggleButton(true); } button_group->setExclusive(true); connect(but[1], SIGNAL(stateChanged(int)), &input_point, SLOT(stateChanged(int))); connect(but[2], SIGNAL(stateChanged(int)), &input_line, SLOT(stateChanged(int))); connect(but[3], SIGNAL(stateChanged(int)), &input_polygon, SLOT(stateChanged(int))); }
void Cmerkle_tree::set(int i, const_memory_range v, const_memory_range w) { assert(i >= 0); assert(i < m_size); int a = 0; int b = m_size; unsigned int z = 0; set0(a + i, v); while (b - a >= 2 && z + 20 <= w.size()) { int j = i ^ 1; if (a + j < b) { if (*d(a + j)) return; set0(a + j, w.sub_range(z, 20)); z += 20; } int c = a; a = b; b += b - c + 1 >> 1; i >>= 1; } }
static void _serial_init(int bord_rate, int data, int parity, int stop) { setval(GPHCON, 0xa, 4, 4 + 4 * UART_NR); setbit(GPHUP, 0x3, 2 + 2 * UART_NR); switch(data) { case 5: clrbit(ULCON, 0x3, 0); break; case 6: setval(ULCON, 0x1, 2, 0); break; case 7: setval(ULCON, 0x2, 2, 0); break; case 8: default: setbit(ULCON, 0x3, 0); } switch(parity) { case 1: setval(ULCON, 0x4, 3, 3); break; case 2: setval(ULCON, 0x5, 3, 3); break; case 0: default: clrbit(ULCON, 0x7, 3); } switch(stop) { case 2: set1(ULCON, 2); break; case 1: default: set0(ULCON, 2); } setval(UCON, 0x5, 4, 0); UBRDIV = get_pclk() / (bord_rate * 16) - 1; }
static void test_dataset(skiatest::Reporter* reporter) { SkDataSet set0(NULL, 0); SkDataSet set1("hello", SkTUnref<SkData>(SkData::NewWithCString("world"))); const SkDataSet::Pair pairs[] = { { "one", SkData::NewWithCString("1") }, { "two", SkData::NewWithCString("2") }, { "three", SkData::NewWithCString("3") }, }; SkDataSet set3(pairs, 3); unrefAll(pairs, 3); test_dataset(reporter, set0, 0); test_dataset(reporter, set1, 1); test_dataset(reporter, set3, 3); }
Tools_toolbar::Tools_toolbar(CGAL::Qt_widget *w, QMainWindow *mw, std::list<Point_2> *l1) : QToolBar(mw, "NT") { w->attach(&move_deletebut); w->attach(&pointbut); move_deletebut.deactivate(); pointbut.deactivate(); move_deletebut.pass_the_structure(l1); //set the widget widget = w; QIconSet set0(QPixmap( (const char**)arrow_small_xpm ), QPixmap( (const char**)arrow_xpm )); QIconSet set1(QPixmap( (const char**)point_small_xpm ), QPixmap( (const char**)point_xpm )); QIconSet set2(QPixmap( (const char**)movepoint_small_xpm ), QPixmap( (const char**)movepoint_xpm )); but[0] = new QToolButton(this, "deactivate layer"); but[0]->setIconSet(set0); but[0]->setTextLabel("Deactivate Layer"); but[1] = new QToolButton(this, "pointtool"); but[1]->setIconSet(set1); but[1]->setTextLabel("Input Point"); but[2] = new QToolButton(this, "move/delete tool"); but[2]->setIconSet(set2); but[2]->setTextLabel("Move/Delete Point"); nr_of_buttons = 3; button_group = new QButtonGroup(0, "My_group"); for(int i = 0; i<nr_of_buttons; i++) { button_group->insert(but[i]); but[i]->setToggleButton(true); } button_group->setExclusive(true); connect(but[1], SIGNAL(stateChanged(int)), &pointbut, SLOT(stateChanged(int))); connect(but[2], SIGNAL(stateChanged(int)), &move_deletebut, SLOT(stateChanged(int))); }
/* Wiggle plot subroutine for vertical plotting */ void wigplot(float *dataptr, int nt, int ntr) { float scalet; /* time axis scale */ float scalex; /* trace axis scale */ float sizet; /* length of t-axis (inches) */ float sizex; /* length of x-axis (inches) */ float zerot; /* base of plot to bot. of screen */ float zerox; /* left of plot to left of screen */ int fill; /* fill flag */ float overlap; /* maximum trace overlap */ int plotfat; /* line thickness of traces */ register int i; /* counter */ /* Get parameters */ if (!igetpar("fill", &fill)) fill = FILL; if (!fgetpar("overlap", &overlap)) overlap = OVERLAP; if (!fgetpar("zerot", &zerot)) zerot = ZEROT; if (!fgetpar("zerox", &zerox)) zerox = ZEROX; if (!fgetpar("sizet", &sizet)) sizet = SIZET; if (!fgetpar("sizex", &sizex)) sizex = SIZEX; scalet = -sizet/nt; scalex = sizex/MAX(ntr, 8); if (!igetpar("plotfat", &plotfat)) plotfat = PLOTFAT; setscl(scalex, scalet); set0(zerox, zerot + sizet); /* Draw wiggle traces */ setcol(RED); setfat(plotfat); setscl(scalex*overlap, scalet); for (i = 0; i < ntr; i++) { setu0(-(float) i / overlap, 0.0); vertwig(dataptr + nt*i, nt, fill); } }
void handle(event me[2]) {if(is1(flag,0)) {if((me[1].b&3)==1) { if((me[2].b&3)==0&&me[1].x>=x+x1+11&&me[1].x<=x+x1+15&&me[1].y>=y-5&&me[1].y<=y+5) set1(flag,2); else if(is1(flag,2)&&me[1].x-x-13>=0&&me[1].x-x-13<w-5) x1=me[1].x-x-13; } else set0(flag,2); } setcolor(7); outtextxy(x+3,y-8-charheight,"Speed of time :"); setcolor(0); line(x+10,y,x+10+w,y); for(int i=0;i<=5;i++) line(x+10+i*w/5,y-2,x+10+i*w/5,y+2); setcolor(0); setfillstyle(SOLID_FILL,1); bar(x+x1+11,y-5,x+x1+15,y+5); }
void ft_print_comb2(void) { char nb11; char nb12; char nb21; char nb22; set0 (&nb11, &nb12, &nb21, &nb22); while (nb11 <= '9') { while (nb12 <= '9') { boucle(&nb11, &nb12, &nb21, &nb22); nb12++; nb21 = '0'; nb22 = '0'; } nb11++; set02(&nb12, &nb21, &nb22); } }
TEST(TSet, product_of_sets) { const int size = 10; TSet set0(size), set1(size), set2(size), set3(size), expSet(size); set0.InsElem(0); set0.InsElem(1); set0.InsElem(3); set0.InsElem(5); set1.InsElem(0); set1.InsElem(3); set1.InsElem(4); set1.InsElem(5); set2.InsElem(0); set2.InsElem(1); set2.InsElem(5); set2.InsElem(6); set2.InsElem(7); set3 = set0 * set1 * set2; expSet.InsElem(0); expSet.InsElem(5); EXPECT_EQ(expSet, set3); }
T set(size_type i, T x) { set0(i, x); return x; }
Tools_toolbar::Tools_toolbar(CGAL::Qt_widget *w, QMainWindow *mw, std::vector<Point_2> *l1) : QToolBar(mw, "NT") { w->attach(&edit_layer); w->attach(&point_layer); w->attach(&iso_r_layer); w->attach(&circle_layer); edit_layer.deactivate(); point_layer.deactivate(); iso_r_layer.deactivate(); circle_layer.deactivate(); edit_layer.pass_the_structure(l1); //set the widget widget = w; QIconSet set0(QPixmap( (const char**)arrow_small_xpm ), QPixmap( (const char**)arrow_xpm )); QIconSet set1(QPixmap( (const char**)point_small_xpm ), QPixmap( (const char**)point_xpm )); QIconSet set2(QPixmap( (const char**)iso_rectangle_small_xpm ), QPixmap( (const char**)iso_rectangle_xpm )); QIconSet set3(QPixmap( (const char**)circle_small_xpm ), QPixmap( (const char**)circle_xpm )); QIconSet set4(QPixmap( (const char**)movepoint_small_xpm ), QPixmap( (const char**)movepoint_xpm )); but[0] = new QToolButton(this, "deactivate layer"); but[0]->setIconSet(set0); but[0]->setTextLabel("Deactivate Layer"); but[1] = new QToolButton(this, "pointtool"); but[1]->setIconSet(set1); but[1]->setTextLabel("Input Point"); but[2] = new QToolButton(this, "iso_rectangle"); but[2]->setIconSet(set2); but[2]->setTextLabel("Input Iso_rectangle"); but[3] = new QToolButton(this, "iso_rectangle"); but[3]->setIconSet(set3); but[3]->setTextLabel("Input Circle"); but[4] = new QToolButton(this, "move/delete tool"); but[4]->setIconSet(set4); but[4]->setTextLabel("Move/Delete Point"); nr_of_buttons = 5; button_group = new QButtonGroup(0, "My_group"); for(int i = 0; i<nr_of_buttons; i++) { button_group->insert(but[i]); but[i]->setToggleButton(true); } button_group->setExclusive(true); connect(but[1], SIGNAL(stateChanged(int)), &point_layer, SLOT(stateChanged(int))); connect(but[2], SIGNAL(stateChanged(int)), &iso_r_layer, SLOT(stateChanged(int))); connect(but[3], SIGNAL(stateChanged(int)), &circle_layer, SLOT(stateChanged(int))); connect(but[4], SIGNAL(stateChanged(int)), &edit_layer, SLOT(stateChanged(int))); but[1]->toggle(); }
void* scan_nodes(void* threadid) { int i, j, k; long tid; unsigned int min_nbr_height; Edge nbr_edge, min_height_edge; long d; long local_e; long local_c; int max_flow; int isInQ; int height_before_lift; int node_push_times = 0, node_lift_times = 0; int op_times = 0; tid = (long)threadid; Node* cur_node; ThreadEnv* thisThread; thisThread = threadEnv + tid; #if 0 if (tid == 0) global_relabel(tid); #endif pthread_barrier_wait(&start_barrier); while (!flow_done()) { cur_node = thisThread->Q[0]; while (cur_node != NoNode) { #ifdef GR if (op_times > gr_threshold) { op_times = 0; if (pthread_mutex_trylock(&gr_mutex) == 0) { global_relabel(tid); pthread_mutex_unlock(&gr_mutex); } } #endif while (cur_node->excess > 0) { #ifdef DEBUG fprintf(stderr, "%d h=%d, e=%ld\n", cur_node - g_node, cur_node->height, cur_node->excess); fflush(stderr); #endif min_nbr_height = UINT_MAX; for (nbr_edge = cur_node->adj_list; nbr_edge < (cur_node + 1)->adj_list; nbr_edge++) { if (nbr_edge->capacity > 0 && (nbr_edge->endpoint)->height < min_nbr_height) { min_nbr_height = (nbr_edge->endpoint)->height; min_height_edge = nbr_edge; } } #ifdef DEBUG fprintf(stderr, "work on %d\n", cur_node - g_node); fflush(stderr); #endif if (cur_node->height > min_nbr_height) { local_e = cur_node->excess; local_c = min_height_edge->capacity; d = MIN(local_e, local_c); if (min_height_edge->endpoint->wave == cur_node->wave && cur_node->height > min_height_edge->endpoint->height) { node_push_times++; op_times++; atomic_add(d, &(min_height_edge->mateedge->capacity)); atomic_sub(d, &(min_height_edge->capacity)); atomic_add(d, &((min_height_edge->endpoint)->excess)); atomic_sub(d, &(cur_node->excess)); #if defined(PUSH) || defined(DEBUG) fprintf(stderr, "[%ld] %ld(%ld) -> %ld -> %ld(%ld) \n", tid, cur_node - g_node, cur_node->excess, d, min_height_edge->endpoint - g_node, (min_height_edge->endpoint)->excess); fflush(stderr); #endif // add min_nbr to local queue isInQ = cmpxchg(&(min_height_edge->endpoint->inQ), 0, tid + 1); if (isInQ == 0) enQ(thisThread, min_height_edge->endpoint); } } else { // if we cannot push to any nodes, then we must be able to lift node_lift_times++; op_times++; pthread_mutex_lock(&(node_mutex[cur_node - g_node])); if (cur_node->height < min_nbr_height + 1) cur_node->height = min_nbr_height + 1; pthread_mutex_unlock(&(node_mutex[cur_node - g_node])); #if defined(LIFT) || defined(DEBUG) fprintf(stderr, "%ld ^ %d, ref %ld(%d)\n", cur_node - g_node, cur_node->height, min_height_edge->endpoint - g_node, min_height_edge->endpoint->height); fflush(stderr); #endif } } // while( g_node[i].excess > 0 ) set0(&(cur_node->inQ)); if (cur_node->excess > 0) { isInQ = cmpxchg(&(cur_node->inQ), 0, tid + 1); if (isInQ == 0) { reenQ(thisThread, cur_node); } else { deQ(thisThread); } } else { deQ(thisThread); } #ifdef HELP if (thisThread->request < MAX_THRD) send_work(tid); #endif cur_node = thisThread->Q[thisThread->head]; } // while (i != -1) #ifdef HELP // Q is empty, find something to do; request_work(tid); #else break; #endif } // while(!flow_done()) atomic_add(node_push_times, &(totalPushes)); atomic_add(node_lift_times, &(totalLifts)); } // scan_node
// constructor MyWindow::MyWindow(int w, int h) : red_active(false), red_set(*(new Polygon_set)), blue_set(*(new Polygon_set)), res_set(*(new Polygon_set)) { widget = new CGAL::Qt_widget(this); //Constructs a widget which is a child of this window /* Sets the central widget for this main window to w. * The central widget is surrounded by the left, top, right and bottom dock areas. * The menu bar is above the top dock area */ setCentralWidget(widget); file_name= QString::null; //create a timer for checking if somthing changed QTimer *timer = new QTimer( this ); // constructs a timer whose parent is this window connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); // connects the timer to the window timer->start( 200, FALSE ); // Starts the timer with a msec milliseconds timeout // file menu QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( "&File", file ); file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); file->insertSeparator(); file->insertItem("&Open Linear Polygon file", this, SLOT(open_linear_polygon_file()),CTRL+Key_O); file->insertItem("&Open DXF file", this, SLOT(open_dxf_file()),CTRL+Key_D); file->insertSeparator(); //file->insertItem("&Save",this ,SLOT(save_file()),CTRL+Key_S); //file->insertItem("&Save as",this ,SLOT(save_file_as())); file->insertSeparator(); file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); file->insertSeparator(); file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); // help menu QPopupMenu * help = new QPopupMenu( this ); menuBar()->insertItem( "&Help", help ); help->insertItem("How To", this, SLOT(howto()), Key_F1); help->insertSeparator(); help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); help->insertItem("About &Qt", this, SLOT(aboutQt()) ); //the standard toolbar stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); radiotoolbar = new QToolBar(this, "polygon type"); blue_pgn = new QRadioButton ("Blue", radiotoolbar); blue_pgn->toggle(); red_pgn = new QRadioButton("Red", radiotoolbar); radio_group = new QVButtonGroup(this,"Radios"); radio_group->insert(blue_pgn); radio_group->insert(red_pgn); radio_group->setRadioButtonExclusive(true); connect(blue_pgn, SIGNAL(toggled (bool)), this, SLOT(radio_selected())); connect(red_pgn, SIGNAL(toggled (bool)), this, SLOT(radio_selected())); //layers //widget->attach(&testlayer); //the new tools toolbar newtoolbar = new Tools_toolbar(widget, this); // voronoi toolbar bops_toolbar = new QToolBar(this, "Boolean operations"); QIconSet set0(QPixmap( (const char**)intersection_xpm ), QPixmap( (const char**)intersection_xpm )); intersection_but = new QToolButton(bops_toolbar, "Boolean operations"); intersection_but->setAutoRaise(TRUE); intersection_but->setIconSet(set0); intersection_but->setTextLabel("Intersection "); connect(intersection_but,SIGNAL(pressed()), this, SLOT(perform_intersection())); QIconSet set1(QPixmap( (const char**)union_xpm ), QPixmap( (const char**)union_xpm )); bops_toolbar->addSeparator(); union_but = new QToolButton(bops_toolbar, "Boolean operations"); union_but->setAutoRaise(TRUE); union_but->setIconSet(set1); union_but->setTextLabel("Union "); connect(union_but,SIGNAL(pressed()), this, SLOT(perform_union())); QIconSet set2(QPixmap( (const char**)diff_PQ_xpm ), QPixmap( (const char**)diff_PQ_xpm )); bops_toolbar->addSeparator(); diff_but2 = new QToolButton(bops_toolbar, "Boolean operations"); diff_but2->setAutoRaise(TRUE); diff_but2->setIconSet(set2); diff_but2->setTextLabel("Difference between Blue and Red"); connect(diff_but2, SIGNAL(pressed()), this, SLOT(perform_diff2())); QIconSet set3(QPixmap( (const char**)diff_QP_xpm ), QPixmap( (const char**)diff_QP_xpm )); bops_toolbar->addSeparator(); diff_but = new QToolButton(bops_toolbar, "Boolean operations"); diff_but->setAutoRaise(TRUE); diff_but->setIconSet(set3); diff_but->setTextLabel("Difference between Red and Blue"); connect(diff_but, SIGNAL(pressed()), this, SLOT(perform_diff())); QIconSet set4(QPixmap( (const char**)symm_diff_xpm ), QPixmap( (const char**)symm_diff_xpm )); bops_toolbar->addSeparator(); symm_diff_but = new QToolButton(bops_toolbar, "Boolean operations"); symm_diff_but->setAutoRaise(TRUE); symm_diff_but->setIconSet(set4); symm_diff_but->setTextLabel("Symmetric Difference "); connect(symm_diff_but, SIGNAL(pressed()), this, SLOT(perform_symm_diff())); QIconSet set12(QPixmap( (const char**)mink_sum_xpm ), QPixmap( (const char**)mink_sum_xpm )); bops_toolbar->addSeparator(); mink_sum_but = new QToolButton(bops_toolbar, "Boolean operations"); mink_sum_but->setAutoRaise(TRUE); mink_sum_but->setIconSet(set12); mink_sum_but->setTextLabel("Minkowski Sum "); connect(mink_sum_but, SIGNAL(pressed()), this, SLOT(perform_mink_sum())); QIconSet set5(QPixmap( (const char**)comp_P_xpm ), QPixmap( (const char**)comp_P_xpm )); bops_toolbar->addSeparator(); blue_complement_but = new QToolButton(bops_toolbar, "Boolean operations"); blue_complement_but->setAutoRaise(TRUE); blue_complement_but->setIconSet(set5); blue_complement_but->setTextLabel("Blue Complement "); connect(blue_complement_but, SIGNAL(pressed()), this, SLOT(perform_blue_complement())); QIconSet set6(QPixmap( (const char**)comp_Q_xpm ), QPixmap( (const char**)comp_Q_xpm )); bops_toolbar->addSeparator(); red_complement_but = new QToolButton(bops_toolbar, "Boolean operations"); red_complement_but->setAutoRaise(TRUE); red_complement_but->setIconSet(set6); red_complement_but->setTextLabel("Red Complement "); connect(red_complement_but, SIGNAL(pressed()), this, SLOT(perform_red_complement())); QIconSet set7(QPixmap( (const char**)make_P_xpm ), QPixmap( (const char**)make_P_xpm )); bops_toolbar->addSeparator(); make_res_blue_but = new QToolButton(bops_toolbar, "Boolean operations"); make_res_blue_but->setAutoRaise(TRUE); make_res_blue_but->setIconSet(set7); make_res_blue_but->setTextLabel("Make Result Blue"); connect(make_res_blue_but,SIGNAL(pressed()), this, SLOT(make_res_blue())); QIconSet set8(QPixmap( (const char**)make_Q_xpm ), QPixmap( (const char**)make_Q_xpm )); bops_toolbar->addSeparator(); make_res_red_but = new QToolButton(bops_toolbar, "Boolean operations"); make_res_red_but->setAutoRaise(TRUE); make_res_red_but->setIconSet(set8); make_res_red_but->setTextLabel("Make Result Red"); connect(make_res_red_but,SIGNAL(pressed()), this, SLOT(make_res_red())); QIconSet set9(QPixmap( (const char**)refresh_xpm ), QPixmap( (const char**)refresh_xpm )); bops_toolbar->addSeparator(); refresh_but = new QToolButton(bops_toolbar, "Boolean operations"); refresh_but->setAutoRaise(TRUE); refresh_but->setIconSet(set9); refresh_but->setTextLabel("Refresh "); connect(refresh_but,SIGNAL(pressed()), this, SLOT(refresh())); QIconSet set10(QPixmap( (const char**)del_P_xpm ), QPixmap( (const char**)del_P_xpm )); bops_toolbar->addSeparator(); delete_blue_but = new QToolButton(bops_toolbar, "Boolean operations"); delete_blue_but->setAutoRaise(TRUE); delete_blue_but->setIconSet(set10); delete_blue_but->setTextLabel("Delete Blue Polygons"); connect(delete_blue_but,SIGNAL(pressed()), this, SLOT(delete_blue_polygons())); QIconSet set11(QPixmap( (const char**)del_Q_xpm ), QPixmap( (const char**)del_Q_xpm )); bops_toolbar->addSeparator(); delete_red_but = new QToolButton(bops_toolbar, "Boolean operations"); delete_red_but->setAutoRaise(TRUE); delete_red_but->setIconSet(set11); delete_red_but->setTextLabel("Delete Red Polygons"); connect(delete_red_but,SIGNAL(pressed()), this, SLOT(delete_red_polygons())); *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor (CGAL::BLACK); resize(w,h); widget->set_window(-1, 1, -1, 1); widget->setMouseTracking(TRUE); //connect the widget to the main function that receives the objects connect(widget, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_new_object(CGAL::Object))); //application flag stuff old_state = 0; current_state = 1; red_active = false; red_set.clear(); blue_set.clear(); res_set.clear(); }
void Cmerkle_tree::root(const_memory_range v) { set0(m_d.size() / 21 - 1, v); }
void handle(event mev) {int f=0; me[2]=me[1]; me[1]=mev; if(is1(sc.flag,15)) {if(me[1].key==1)endprogram(); else status("Press any key to exit"); } if(me[1].key==1&&me[1].ch==27) {set0(sc.flag,0); set0(sc.flag,1); set1(sc.flag,15); status("Press any key to exit"); } t1.handle(me); t2.handle(me); t3.handle(me); sc.handle(me); e1.handle(me); e2.handle(me); e3.handle(me);e3.st[0]=0; e4.handle(me);e4.st[0]=0; e5.handle(me);e5.st[0]=0; e6.handle(me);e6.st[0]=0; b.handle(me); rb1.handle(me); rb2.handle(me); scrbar.handle(me); if(is1(sc.flag,15))return; sc.dt=(0.5*scrbar.x1)/scrbar.w; if(is1(e1.flag,2)||is1(e1.flag,4)) {set0(e1.flag,1);set0(e1.flag,2);set0(e1.flag,4);set1(e2.flag,1); } if(is1(e2.flag,2)) {set0(e2.flag,1);set0(e2.flag,2); } if(is1(e2.flag,3)) {set0(e2.flag,3);set0(e2.flag,1);set1(e1.flag,1); } if(e1.st[0]!=0) { set1(f,2);for(int i=0;e1.st[i]!=0;i++)if(!isdigit(e1.st[i])){set1(f,0);break;} } if(e2.st[0]!=0) { set1(f,3);for(int i=0;e2.st[i]!=0;i++)if(!isdigit(e2.st[i])){set1(f,1);break;} } switch(f&3) {case 1:status("Invalid Mass 1");break; case 2:status("Invalid Mass 2");break; case 3:status("Invalid Mass 1 and Mass 2"); }; if((f&3)!=0||(f>>2)!=3) { set0(sc.flag,0); set0(b.flag,0); set0(rb1.flag,0); set0(rb2.flag,0); } if(is0(sc.flag,0)&&(f&3)==0&&is0(sc.flag,1))status("Enter Mass 1 and Mass 2"); if(is1(sc.flag,0))status("Use Mouse to set position and direction of velocity of both masses"); if((f&3)==0&&(f>>2)==3&&is0(sc.flag,1)) {set1(sc.flag,0); long lm1,lm2; sscanf(e1.st,"%ld",&lm1); sscanf(e2.st,"%ld",&lm2); sc.m1=lm1; sc.m2=lm2; set1(b.flag,0); set1(rb1.flag,0); set1(rb2.flag,0); } if(is1(b.flag,3)) //play {set0(b.flag,3); set0(e1.flag,0); set0(e2.flag,0); set0(sc.flag,0); set1(sc.flag,1); set0(rb1.flag,0); set0(rb2.flag,0); } if(is1(b.flag,4)) //pause {set0(b.flag,4); set1(e1.flag,0); set1(e2.flag,0); set1(sc.flag,0); set0(sc.flag,1); set1(rb1.flag,0); set1(rb2.flag,0); } if(is1(sc.flag,0)&&(f&3)==0) {sprintf(e3.st,"%f",sc.r1.x); sprintf(e4.st,"%f",sc.r1.y); sprintf(e5.st,"%f",sc.r2.x); sprintf(e6.st,"%f",sc.r2.y); } if(is1(sc.flag,1)&&(f&3)==0) {sprintf(e3.st,"%f",sc.d1.x); sprintf(e4.st,"%f",sc.d1.y); sprintf(e5.st,"%f",sc.d2.x); sprintf(e6.st,"%f",sc.d2.y); } if(is1(rb1.flag,2)) {set0(rb1.flag,2); set1(rb1.flag,1); set0(rb2.flag,1); set0(sc.flag,13); } if(is1(rb2.flag,2)) {set0(rb2.flag,2); set1(rb2.flag,1); set0(rb1.flag,1); set1(sc.flag,13); } }
void handle(event me[2]) {setviewport(5,5,5+440,5+height,1); clearviewport(); if(is1(flag,0)) {rad1=pow(m1/500,0.33333333); rad2=pow(m2/500,0.33333333); // if(is1(flag,12)) {delete tms; set0(flag,12); if(is1(flag,7)) {delete array[0];delete array[1];delete array[2];delete array[3]; set0(flag,7); } if(is1(flag,6)) {delete array[0];delete array[1];delete array[2];delete array[3]; set0(flag,6); } if(is1(flag,5)) {delete array[0];delete array[1];delete array[2];delete array[3]; set0(flag,5); } } // if((me[1].b&1)==1) {vector vm2(me[2].x-5-220,height/2-me[2].y+5), vm1(me[1].x-5-220,height/2-me[1].y+5); if((me[2].b&1)==0) { if((r1+v1-vm1).mod()<=5) set1(flag,8); else if((r2+v2-vm1).mod()<=5) set1(flag,9); else if((r1-vm1).mod()<=rad1) set1(flag,10); else if((r2-vm1).mod()<=rad2) set1(flag,11); } else if(me[1].x>5&&me[1].x<445&&me[1].y>5&&me[1].y<(5+height)) { if(is1(flag,8)) v1=vm1-r1; else if(is1(flag,9)) v2=vm1-r2; else if(is1(flag,10)) r1=vm1; else if(is1(flag,11)) r2=vm1; } } else {set0(flag,8);set0(flag,9);set0(flag,10);set0(flag,11); } setcolor(COL1); setfillstyle(SOLID_FILL,COL1); fillellipse(r1.x+220,height/2-r1.y,rad1*10./9,rad1); setcolor(14); setfillstyle(SOLID_FILL,14); fillellipse(r2.x+220,height/2-r2.y,rad2*10./9,rad2); // setcolor(1); line(220+r1.x,height/2-r1.y,220+r1.x+v1.x,height/2-r1.y-v1.y); double ang=angle(v1.x,-v1.y); int pol[8]; setfillstyle(SOLID_FILL,1); pol[0]=220+r1.x+v1.x;pol[1]=height/2-r1.y-v1.y; pol[2]=220+r1.x+v1.x+4*cos(ang+2.5);pol[3]=height/2-r1.y-v1.y+4*sin(ang+2.5); pol[4]=220+r1.x+v1.x+4*cos(ang-2.5);pol[5]=height/2-r1.y-v1.y+4*sin(ang-2.5); pol[6]=220+r1.x+v1.x;pol[7]=height/2-r1.y-v1.y; fillpoly(4,pol); // setcolor(2); line(220+r2.x,height/2-r2.y,220+r2.x+v2.x,height/2-r2.y-v2.y); ang=angle(v2.x,-v2.y); setfillstyle(SOLID_FILL,2); pol[0]=220+r2.x+v2.x;pol[1]=height/2-r2.y-v2.y; pol[2]=220+r2.x+v2.x+4*cos(ang+2.5);pol[3]=height/2-r2.y-v2.y+4*sin(ang+2.5); pol[4]=220+r2.x+v2.x+4*cos(ang-2.5);pol[5]=height/2-r2.y-v2.y+4*sin(ang-2.5); pol[6]=220+r2.x+v2.x;pol[7]=height/2-r2.y-v2.y; fillpoly(4,pol); } if(is1(flag,1)) {if(is0(flag,12)) {set1(flag,12); tms=new Two_Mass_System(m1,m2,r1,r2,v1,v2); if(is1(flag,13)) { setviewport(0,0,639,349,1); active setfillstyle(SOLID_FILL,7); bar(0,349-charheight-1,639,349); status("Wait..."); active setviewport(5,5,5+440,5+height,1); if((tms->s->flag==2||tms->s->flag==3)&&tms->s->T*2/0.05<2000) {array[0]=new double[tms->s->T*2/0.05+25]; array[1]=new double[tms->s->T*2/0.05+25]; array[2]=new double[tms->s->T*2/0.05+25]; array[3]=new double[tms->s->T*2/0.05+25]; long i=0; for(double q=0;q<=tms->s->T*2+0.6;q+=0.05,i++) {tms->position_wrt_cm(q,w1,w2); array[0][i]=w1.x; array[1][i]=w1.y; array[2][i]=w2.x; array[3][i]=w2.y; } set1(flag,7); } if(tms->s->flag==1||tms->s->flag==4) {array[0]=new double[20/0.05+25]; array[1]=new double[20/0.05+25]; array[2]=new double[20/0.05+25]; array[3]=new double[20/0.05+25]; long i=0; for(double q=0;q<=20+0.5;q+=0.05,i++) {tms->position_wrt_cm(q,w1,w2); array[0][i]=w1.x; array[1][i]=w1.y; array[2][i]=w2.x; array[3][i]=w2.y; } set1(flag,6); } if(tms->s->flag==2&&tms->s->T*2/0.05>=2000) {array[0]=new double[40/0.05+25]; array[1]=new double[40/0.05+25]; array[2]=new double[40/0.05+25]; array[3]=new double[40/0.05+25]; long i=0; for(double q=-20-0.5;q<=20+0.5;q+=0.05,i++) {tms->position_wrt_cm(q,w1,w2); array[0][i]=w1.x; array[1][i]=w1.y; array[2][i]=w2.x; array[3][i]=w2.y; } set1(flag,5); } } t=0; } if(is1(flag,7)) {setcolor(8); for(long i=2;i<t/0.05&&i*0.05<=tms->s->T*2+0.5;i++) {line(220+array[0][i],height/2-array[1][i]*0.9,220+array[0][i+1],height/2-array[1][i+1]*0.9); line(220+array[2][i],height/2-array[3][i]*0.9,220+array[2][i+1],height/2-array[3][i+1]*0.9); } } if(is1(flag,6)) {setcolor(8); for(long i=2;i<t/0.05&&i*0.05<=20;i++) {line(220+array[0][i],height/2-array[1][i]*0.9,220+array[0][i+1],height/2-array[1][i+1]*0.9); line(220+array[2][i],height/2-array[3][i]*0.9,220+array[2][i+1],height/2-array[3][i+1]*0.9); } } if(is1(flag,5)) {setcolor(8); for(long i=(20+0.5)/0.05;i*0.05-(20+0.5)<t&&i*0.05-(20+0.5)<=20;i++) {line(220+array[0][i],height/2-array[1][i]*0.9,220+array[0][i+1],height/2-array[1][i+1]*0.9); line(220+array[2][i],height/2-array[3][i]*0.9,220+array[2][i+1],height/2-array[3][i+1]*0.9); } for(i=0.5/0.05;i*0.05<(20+0.5)+t-tms->s->T*2&&i*0.05<=(20+0.5);i++) {line(220+array[0][i],height/2-array[1][i]*0.9,220+array[0][i+1],height/2-array[1][i+1]*0.9); line(220+array[2][i],height/2-array[3][i]*0.9,220+array[2][i+1],height/2-array[3][i+1]*0.9); } } if(is1(flag,13)) { tms->position_wrt_cm(t,d1,d2); setviewport(0,0,639,349,1); if(tms->s->flag==1)status("Moving in Parabolic path"); if(tms->s->flag==2)status("Moving in Elliptical path"); if(tms->s->flag==3)status("Moving in Circular path"); if(tms->s->flag==4)status("Moving in Hyperbolic path"); setviewport(5,5,5+440,5+height,1); } else tms->position(t,d1,d2); setcolor(COL1); setfillstyle(SOLID_FILL,COL1); fillellipse(d1.x+220,height/2-d1.y*0.9,rad1*10./9,rad1); setcolor(COL2); setfillstyle(SOLID_FILL,COL2); fillellipse(d2.x+220,height/2-d2.y*0.9,rad2*10./9,rad2); t+=dt; } if(is1(flag,15)) {setcolor(15); char str[100]="An Application by "; char ma[13]; for(int i=0;i<13;i++) ma[i]=char(~st_[i]); strcat(str,ma); strcat(str," to obserb how a Mass "); outtextxy(5,5, str ); outtextxy(5,5+charheight+5, "Body is affected in the Gravitational Feild developed" ); outtextxy(5,5+2*(charheight+5),"by anoher Mass Body. ( Written in CPP )"); } setviewport(0,0,639,349,1); setcolor(8); line(445,6,445,5+height); line(444,7,444,5+height); line(443,8,443,5+height); line(6,5+height,445,5+height); line(7,5+height-1,445,5+height-1); line(8,5+height-2,445,5+height-2); }
int main(int argc, char* argv[]) { //BEGIN: initialization struct sockaddr_in sin_server; int sfd_client, x; size_t size_sockaddr = sizeof(struct sockaddr), size_packet = sizeof(struct packet); short int connection_id; struct packet* chp = (struct packet*) malloc(size_packet); // client host packet set0(chp); struct packet* data; // network packet if((x = sfd_client = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) er("socket()", x); memset((char*) &sin_server, 0, sizeof(struct sockaddr_in)); sin_server.sin_family = AF_INET; sin_server.sin_addr.s_addr = inet_addr(IPSERVER); sin_server.sin_port = htons(PORTSERVER); if((x = connect(sfd_client, (struct sockaddr*) &sin_server, size_sockaddr)) < 0) er("connect()", x); printf(ID "FTP Client started up. Attempting communication with server @ %s:%d...\n\n", IPSERVER, PORTSERVER); //END: initialization struct command* cmd; char lpwd[LENBUFFER], pwd[LENBUFFER]; //用作本地和FTP server端的当前工作区间名的缓冲区 char userinput[LENUSERINPUT]; while(1) { printf("\t> "); fgets(userinput, LENUSERINPUT, stdin); /* in order to give a filename with spaces, put ':' instead of ' '. If a command needs x paths, and y (y > x) paths are provided, y - x paths will be ignored. */ cmd = userinputtocommand(userinput); if(!cmd) continue; //printcommand(cmd); switch(cmd->id) { case GET: if(cmd->npaths) command_get(chp, data, sfd_client, *cmd->paths); else fprintf(stderr, "No path to file given.\n"); break; case PUT: if(cmd->npaths) command_put(chp, data, sfd_client, *cmd->paths); else fprintf(stderr, "No path to file given.\n"); break; case MGET: if(cmd->npaths) command_mget(chp, data, sfd_client, cmd->npaths, cmd->paths); else fprintf(stderr, "No path to file given.\n"); break; case MPUT: if(cmd->npaths) command_mput(chp, data, sfd_client, cmd->npaths, cmd->paths); else fprintf(stderr, "No path to file given.\n"); break; case MGETWILD: command_mgetwild(chp, data, sfd_client); break; case MPUTWILD: if(!getcwd(lpwd, sizeof lpwd)) er("getcwd()", 0); command_mputwild(chp, data, sfd_client, lpwd); break; case CD: if(cmd->npaths) command_cd(chp, data, sfd_client, *cmd->paths); else fprintf(stderr, "No path given.\n"); break; case LCD: // 改变local 工作区间 if(cmd->npaths) command_lcd(*cmd->paths); else fprintf(stderr, "No path given.\n"); break; case PWD: command_pwd(chp, data, sfd_client); break; case LPWD: // local pwd if(!getcwd(lpwd, sizeof lpwd)) er("getcwd()", 0); printf("\t%s\n", lpwd); break; case DIR_: case LS: command_ls(chp, data, sfd_client); break; case LDIR: case LLS: if(!getcwd(lpwd, sizeof lpwd)) er("getcwd()", 0); command_lls(lpwd); break; case MKDIR: if(cmd->npaths) command_mkdir(chp, data, sfd_client, *cmd->paths); else fprintf(stderr, "No path to directory given.\n"); break; case LMKDIR: if(cmd->npaths) command_lmkdir(*cmd->paths); else fprintf(stderr, "No path to directory given.\n"); break; case RGET: if(!getcwd(lpwd, sizeof lpwd)) er("getcwd()", 0); command_rget(chp, data, sfd_client); if((x = chdir(lpwd)) == -1) fprintf(stderr, "Wrong path.\n"); break; case RPUT: if(!getcwd(lpwd, sizeof lpwd)) er("getcwd()", 0); command_rput(chp, data, sfd_client); if((x = chdir(lpwd)) == -1) fprintf(stderr, "Wrong path.\n"); break; case EXIT: goto outside_client_command_loop; default: // display error break; } } outside_client_command_loop: /* chp->type = REQU; chp->conid = -1; strcpy(path, argv[1]); strcpy(chp->buffer, argv[1]); //printpacket(chp, HP); data = htonp(chp); if((x = send(sfd_client, data, size_packet, 0)) != size_packet) er("send()", x); set0(data); do { if((x = recv(sfd_client, data, size_packet, 0)) <= 0) er("recv()", x); chp = htonp(data); if(chp->type == INFO) printf(ID "Server says: %s\n", chp->buffer); else if(chp->type == DATA) { //printpacket(chp, HP); receive_file(extract_filename(path), sfd_client, chp); } } while(chp->type != TERM); fprintf(stderr, "TERM received; exiting...\n"); */ close(sfd_client); printf(ID "Done.\n"); fflush(stdout); return 0; }
Layers_toolbar::Layers_toolbar(CGAL::Qt_widget* w ,QMainWindow* mw ,demo::Regions const& in ,demo::SSkelPtr const& sskel ,demo::Regions const& out ) : QToolBar(mw, "LT"), nr_of_buttons(0) { showI = new Qt_layer_show_regions <demo::Regions> (this,"Input",in,CGAL::RED); showSSkel = new Qt_layer_show_skeleton<demo::SSkel> (this,"Skeleton",sskel); showO = new Qt_layer_show_regions <demo::Regions> (this,"Offset",out,CGAL::BLACK); progress = new Qt_layer_show_progress (this,"Progress"); //set the widget widget = w; window = mw; widget->attach(showI); widget->attach(progress); widget->attach(showSSkel); widget->attach(showO); QIconSet set0(QPixmap( (const char**)show_polygon_small_xpm ), QPixmap( (const char**)show_polygon_xpm )); QIconSet set1(QPixmap( (const char**)voronoi_small_xpm ), QPixmap( (const char**)voronoi_xpm )); QIconSet set2(QPixmap( (const char**)polygon_small_xpm ), QPixmap( (const char**)polygon_xpm )); QIconSet set3(QPixmap( (const char**)polygon_small_xpm ), QPixmap( (const char**)polygon_xpm )); but[0] = new QToolButton(this, "polygon"); but[0]->setIconSet(set0); but[0]->setTextLabel("Show Simple Polygon"); but[1] = new QToolButton(this, "straight_skeleton"); but[1]->setIconSet(set1); but[1]->setTextLabel("Show Straight Skeleton"); but[2] = new QToolButton(this, "offset"); but[2]->setIconSet(set2); but[2]->setTextLabel("Show Polygon Offset"); but[3] = new QToolButton(this, "progress"); but[3]->setIconSet(set3); but[3]->setTextLabel("Show Progress"); nr_of_buttons = 4; button_group = new QButtonGroup(0, "nonexclusive"); for(int i =0; i<nr_of_buttons; i++){ but[i]->setToggleButton(true); but[i]->toggle(); button_group->insert(but[i]); } //but[1]->toggle(); connect(but[0], SIGNAL(stateChanged(int)), showI, SLOT(stateChanged(int))); connect(but[1], SIGNAL(stateChanged(int)), showSSkel, SLOT(stateChanged(int))); connect(but[2], SIGNAL(stateChanged(int)), showO, SLOT(stateChanged(int))); connect(but[3], SIGNAL(stateChanged(int)), progress, SLOT(stateChanged(int))); }
static void TestBitSet(skiatest::Reporter* reporter) { SkBitSet set0(65536); REPORTER_ASSERT(reporter, set0.isBitSet(0) == false); REPORTER_ASSERT(reporter, set0.isBitSet(32767) == false); REPORTER_ASSERT(reporter, set0.isBitSet(65535) == false); SkBitSet set1(65536); REPORTER_ASSERT(reporter, set0 == set1); set0.setBit(22, true); REPORTER_ASSERT(reporter, set0.isBitSet(22) == true); set0.setBit(24, true); REPORTER_ASSERT(reporter, set0.isBitSet(24) == true); set0.setBit(35, true); // on a different DWORD REPORTER_ASSERT(reporter, set0.isBitSet(35) == true); set0.setBit(22, false); REPORTER_ASSERT(reporter, set0.isBitSet(22) == false); REPORTER_ASSERT(reporter, set0.isBitSet(24) == true); REPORTER_ASSERT(reporter, set0.isBitSet(35) == true); SkTDArray<unsigned int> data; set0.exportTo(&data); REPORTER_ASSERT(reporter, data.count() == 2); REPORTER_ASSERT(reporter, data[0] == 24); REPORTER_ASSERT(reporter, data[1] == 35); set1.setBit(12345, true); set1.orBits(set0); REPORTER_ASSERT(reporter, set0.isBitSet(12345) == false); REPORTER_ASSERT(reporter, set1.isBitSet(12345) == true); REPORTER_ASSERT(reporter, set1.isBitSet(22) == false); REPORTER_ASSERT(reporter, set1.isBitSet(24) == true); REPORTER_ASSERT(reporter, set0.isBitSet(35) == true); REPORTER_ASSERT(reporter, set1 != set0); set1.clearAll(); REPORTER_ASSERT(reporter, set0.isBitSet(12345) == false); REPORTER_ASSERT(reporter, set1.isBitSet(12345) == false); REPORTER_ASSERT(reporter, set1.isBitSet(22) == false); REPORTER_ASSERT(reporter, set1.isBitSet(24) == false); REPORTER_ASSERT(reporter, set1.isBitSet(35) == false); set1.orBits(set0); REPORTER_ASSERT(reporter, set1 == set0); SkBitSet set2(1); SkBitSet set3(1); SkBitSet set4(4); SkBitSet set5(33); REPORTER_ASSERT(reporter, set2 == set3); REPORTER_ASSERT(reporter, set2 != set4); REPORTER_ASSERT(reporter, set2 != set5); set2.setBit(0, true); REPORTER_ASSERT(reporter, set2 != set5); set5.setBit(0, true); REPORTER_ASSERT(reporter, set2 != set5); REPORTER_ASSERT(reporter, set2 != set3); set3.setBit(0, true); REPORTER_ASSERT(reporter, set2 == set3); set3.clearAll(); set3 = set2; set2 = set2; REPORTER_ASSERT(reporter, set2 == set3); }
void subplot(float *data, int nt, int nx, string title, string label1, string label2, float truemax, float max) { int i,plotfat,axisfat,dtict,ntict,nticx; float sizet,sizex,scalet,scalex,zerot,zerox,margint,marginx,dticx; float dash,gap,truedticx,xmin,dx; int titlsz,lablsz,ticsz,hcopy,dashflag; char tval[8]; /* tic value string */ zerot = 0.5; fgetpar("zerox",&zerot); zerox = 1.0; fgetpar("zeroy",&zerox); sizet = 8.0; fgetpar("sizex",&sizet); sizex = 5.0; fgetpar("sizey",&sizex); dashflag = 0; igetpar("dash",&dashflag); nticx = 1; igetpar("nticy",&nticx); ntict = 5; fgetpar("nticx",&ntict); dtict = nt/ntict; if (dtict>10) dtict -= dtict%10; igetpar("dticx",&dtict); margint = 0.01; fgetpar("marginx",&margint); marginx = 0.04; fgetpar("marginy",&marginx); ticsz = 3; igetpar("ticsz",&ticsz); hcopy = 0; igetpar("hcopy",&hcopy); if ( hcopy == 1 ) { sizet=4.5; sizex=3.5; ticsz=2; } scalet = sizet/nt; scalex = 0.5*sizex; setscl(scalet,scalex); set0(zerot, zerox + 0.5*sizex ); setfat(axisfat); /* ZERO LINE*/ setcol(3); umove( 0.0, 0.0 ); udraw( (float)nt, 0.0 ); /* Amplitude tics */ dticx = max/nticx; truedticx = truemax/nticx; for ( i = -nticx ; i <= nticx ; i++ ) { umove( (float)nt , i*dticx / max ); udraw( (1.0 + margint) * nt, i*dticx / max ); sprintf( tval, "%.3g", i*truedticx ); utext( (1.0 + 2*margint) * nt, i*dticx / max , ticsz, 0, tval); } /* DRAW N2 WIGGLE TRACES */ for ( i = 0 ; i < nx ; i++ ) { if ( dashflag ) { dash = ( i % 6 ) * .05; gap = dash; if ( dash ) { setdash(dash,gap,dash,gap); } } setcol(6 - i % 6); wgl1( data + nt*i, nt); } }