int main () { SuccessorTest (); ItrTest (); CL_BitSet set1 = CL_BitSet (25) + 1 + 3 + 15 + 21 + 7; CL_BitSet set2; set2 = set2 + 2 + 3 + 1 + 15; TestBigSet (); CL_String strg = set2.AsString(); cout << "set2: " << strg << endl; strg = set1.AsString (); cout << "set1: " << strg << endl; CL_BitSet set5 (5, 15, 30); cout << "Set5: " << set5 << endl; cout << "Complement of set5: " << ~set5 << endl; CL_BitSet set3; set3 = set1 * set2; CL_IntegerSet set = set1.AsSet (); cout << "Set1:" << endl; short i; for (i = 0; i < set.Size(); i++) cout << " " << set.ItemWithRank (i); cout << endl; long r = 3; cout << "Element of rank " << r << " in set2 is " << set2.ItemWithRank(r) << endl; cout << "Set2:" << endl; for (i = 0; i < set2.Size(); i++) cout << " " << set2.ItemWithRank(i); cout << endl; set = set3.AsSet (); cout << "Set3:" << endl; CL_BitSetIterator itr1 (set3); for (i = 0; i < set.Size(); i++) cout << " " << itr1.Next(); cout << endl; CL_BitSetIterator itr (set1); cout << "set1 via iterator:" << endl; for (itr.Reset(); (i = itr.Next()) >= 0; ) { cout << "i = " << i << endl; } cout << endl << "set3: smallest " << set3.Smallest() << " largest " << set3.Largest() << endl; cout << endl; cout << "set1: smallest " << set1.Smallest() << " largest " << set1.Largest() << endl; cout << "set5: smallest " << set5.Smallest() << " largest " << set5.Largest() << endl; return(0); }
int main(int argc, char *argv[]) { /* sets to be used for testing */ char s[5] = {'1','2','3','4','\0'}; char t[4] = {'1','2','3','\0'}; char u[1] = {'\0'}; char v[4] = {'x','y','z','\0'}; /* sets to contain results */ char a[SIZE]; char b[SIZE]; char c[SIZE]; char d[SIZE]; /* SetTypes for testing */ SetType set1(s); SetType set2(t); SetType set3(u); /* test of is_empty. Should output "Set is empty" followed by "Set is not empty */ set3.is_empty() ? cout << "Set is empty\n" : cout << "Set is not empty\n"; set1.is_empty() ? cout << "Set is empty\n" : cout << "Set is not empty\n"; /* test of is_equal. Should output "s is equal" followed by "t is not equal" */ set1.is_equal(s) ? cout << "s is equal\n" : cout << "s is not equal\n"; set1.is_equal(t) ? cout << "t is equal\n" : cout << "t is not equal\n"; /* test of is_member. Should output "4 is a member" followed by "8 is not a member */ set1.is_member('4') ? cout << "4 is a member\n" : cout << "4 is not a member\n"; set1.is_member('8') ? cout << "8 is a member\n" : cout << "8 is not a member\n"; /* test of is_subset. Should output "t is a subset" followed by "v is not a subset */ set1.is_subset(t) ? cout << "t is a subset\n" : cout << "t is not a subset\n"; set1.is_subset(v) ? cout << "v is a subset\n" : cout << "v is not a subset\n"; /* test of setunion. Should output all elements from s and v. Implicitly tests the write function. */ set1.setunion(v, a); SetType set4(a); set4.write(); /* test of intersection. Should output all elements in both t and s. */ set1.intersection(t, b); SetType set5(b); set5.write(); /* test of difference. Should output all elements only in t or only in s */ set1.difference(t, d); SetType set7(d); set7.write(); /* return success */ return 0; }
// 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(); }
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); }