예제 #1
0
//!----------------------------------------------------------------------------------------------------
//!
//! \brief GuidewareTrackingWindow::startNaigation
//!
void GuidewareTrackingWindow::startNaigation(){
    //! -----------------------------------------------------------------------
    collaborativeState = "on"; //on/off
    collaborativeName = this->patientHandling->getName();
    collaborativeType = "navi"; //standby/normal/reconstruct/reconstructed
    collaborativePath = this->patientHandling->getCTImagePath() + "navi";

    QFile f(this->configuratonFilePath);
    if(!f.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        cout << "Open failed." << endl;
    }

    QTextStream txtOutput(&f);
    QString s1(collaborativeState);
    QString s2(collaborativeName);
    QString s3(collaborativeType);
    QString s4(collaborativePath);

    txtOutput << "state:" << s1 << endl;
    txtOutput << "name:" << s2 << endl;
    txtOutput << "type:" << s3 << endl;
    txtOutput << "path:" << s4 << endl;

    f.close();
    //! -----------------------------------------------------------------------
}
예제 #2
0
bool capacity_test( )
{
  bool rc = true;

  std::string s1;
  std::string s2("Hello, World!");

  if( s1.capacity( ) == 0) FAIL
  if( s2.size( ) > s2.capacity( ) ) FAIL
  if( s1.empty( )    == false ) FAIL
  if( s2.empty( )    == true  ) FAIL

  s2.clear( );
  if( s2.empty( ) == false ) FAIL

  std::string s3("Hello");
  s3.resize( 2 );
  if( s3.size( ) != 2 || s3 != "He" ) FAIL

  s3.resize( 5, 'x' );
  if( s3.size( ) != 5 || s3 != "Hexxx" ) FAIL

  s3.resize( 40, 'y' );
  if( s3.size( ) != 40 ||
      s3 != "Hexxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" ) FAIL

  std::string s4("Hello");
  std::string::size_type new_s4capacity = ( 7 * s4.capacity( ) ) / 2;
  s4.reserve( new_s4capacity );
  if( s4.capacity( ) < new_s4capacity || s4.size( ) != 5 || s4 != "Hello" ) {
    FAIL
  }
  return( rc );
}
예제 #3
0
bool erase_test( )
{
  bool rc = true;

  std::string s1( "Hello, World!" );
  s1.erase( );
  if( s1 != "" || s1.size( ) != 0 || INSANE( s1 ) ) FAIL

  std::string s2( "Hello, World!" );
  s2.erase( 2, 3 );
  if( s2 != "He, World!" || s2.size( ) != 10 || INSANE( s2 ) ) FAIL

  std::string s3( "Hello, World!" );
  s3.erase( 7, 6 );
  if( s3 != "Hello, " || s3.size( ) != 7 || INSANE( s3 ) ) FAIL

  std::string s4( "Hello, World!" );
  s4.erase( s4.begin( ) );
  if( s4 != "ello, World!" || s4.size( ) != 12 || INSANE( s4 ) ) FAIL

  std::string s5( "Hello, World!" );
  s5.erase( s5.begin( ) + 2, s5.begin( ) + 5 );
  if( s5 != "He, World!" || s5.size( ) != 10 || INSANE( s5 ) ) FAIL

  return( rc );
}
예제 #4
0
//===========================================================================
int main ()
{
    // Define, output default constructed value
    string s1("blah");
    std::cout << "string 1: ";
    std::cout << s1;
    std::cout << "\n";

    // Define, output 1 digit number
    string s2("pooltable");
    std::cout << "string 2: ";
    std::cout << s2;
    std::cout << "\n";

    // Define, output 3 digit number
    string s3("crazy man");
    std::cout << "string 2: ";
    std::cout << s3;
    std::cout << "\n";

    // Define, output 90 digit number
    string s4("this project is really hard to understand, as a cs major i have no life.");
    std::cout << "string 3: ";
    std::cout << s4;
    std::cout << "\n";

}
예제 #5
0
//!----------------------------------------------------------------------------------------------------
//!
//! \brief GuidewareTrackingWindow::changeStateToReconstruct
//!
void GuidewareTrackingWindow::changeStateToReconstruct(){
    collaborativeState = "on";
    collaborativeName = this->patientHandling->getName();
    collaborativeType = "reconstruct";
    collaborativePath = this->patientHandling->getCTImagePath() + "reconstruct";

    QFile f(this->configuratonFilePath);
    if(!f.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        cout << "Open failed." << endl;
    }

    QTextStream txtOutput(&f);
    QString s1(collaborativeState);
    QString s2(collaborativeName);
    QString s3(collaborativeType);
    QString s4(collaborativePath);

    txtOutput << "state:" << s1 << endl;
    txtOutput << "name:" << s2 << endl;
    txtOutput << "type:" << s3 << endl;
    txtOutput << "path:" << s4 << endl;

    f.close();
}
예제 #6
0
TEST(functor_call_traits, non_const_this_ref_functor) {
  member_op f;
  member_op const &cf = f;

  functor_call_traits functor;

  EXPECT_THROW(functor(f, 0l, 0.0, 0, ""), std::exception);

  EXPECT_EQ(3.1415926, functor_call_traits::call(cf));
  functor_call_traits::call(f);
  EXPECT_EQ(5.6, functor_call_traits::call(cf));

  std::string s1("hello");
  char const *s2 = ", ";
  std::string const s3("world");
  std::string s4("!");
  std::string out("some test string");

  EXPECT_EQ(17, functor(f, 17));

  EXPECT_EQ(
    s1.size() + std::strlen(s2) + s3.size() + s4.size(),
    (functor(f, s1, s2, s3, s4, out))
  );
  EXPECT_EQ("hello, world!", out);

  typedef std::integral_constant<int, functor(f, 2, 3, 5)> c;

  EXPECT_EQ(2 + 3 + 5, c::value);

  EXPECT_EQ(57, functor(f, 57, true));
  EXPECT_EQ(-57, functor(f, 57, false));
}
예제 #7
0
TEST(call_traits_static_member, call_static_member) {
  EXPECT_THROW(
    sm_traits::static_member<static_fn>::call(0l, 0.0, 0, ""),
    std::exception
  );

  std::string s1("hello");
  char const *s2 = ", ";
  std::string const s3("world");
  std::string s4("!");
  std::string out("some test string");

  EXPECT_EQ(17, sm_traits::static_member<static_fn>::call(17));

  EXPECT_EQ(
    s1.size() + std::strlen(s2) + s3.size() + s4.size(),
    sm_traits::static_member<static_fn>::call(s1, s2, s3, s4, out)
  );
  EXPECT_EQ("hello, world!", out);

  typedef std::integral_constant<
    int, sm_traits::static_member<static_fn>::call(2, 3, 5)
  > c;

  EXPECT_EQ(2 + 3 + 5, c::value);

  EXPECT_EQ(57, sm_traits::static_member<static_fn>::call(57, true));
  EXPECT_EQ(-57, sm_traits::static_member<static_fn>::call(57, false));
}
예제 #8
0
TEST(call_traits_free_function, functor_free_function) {
  ff_traits::free_function functor;

  EXPECT_THROW(functor(0l, 0.0, 0, ""), std::exception);

  std::string s1("hello");
  char const *s2 = ", ";
  std::string const s3("world");
  std::string s4("!");
  std::string out("some test string");

  EXPECT_EQ(17, functor(17));

  EXPECT_EQ(
    s1.size() + std::strlen(s2) + s3.size() + s4.size(),
    functor(s1, s2, s3, s4, out)
  );
  EXPECT_EQ("hello, world!", out);

  typedef std::integral_constant<int, functor(2, 3, 5)> c;

  EXPECT_EQ(2 + 3 + 5, c::value);

  EXPECT_EQ(57, functor(57, true));
  EXPECT_EQ(-57, functor(57, false));
}
예제 #9
0
void StdStringTestCase::StdConstructors()
{
    wxString s1(wxT("abcdefgh")),
             s2(wxT("abcdefghijklm"), 8),
             s3(wxT("abcdefghijklm")),
             s4(8, wxT('a'));
    wxString s5(s1),
             s6(s3, 0, 8),
             s7(s3.begin(), s3.begin() + 8);
    wxString s8(s1, 4, 8);

    CPPUNIT_ASSERT_EQUAL( wxT("abcdefgh"), s1 );
    CPPUNIT_ASSERT_EQUAL( s1, s2 );
    CPPUNIT_ASSERT_EQUAL( wxT("aaaaaaaa"), s4 );
    CPPUNIT_ASSERT_EQUAL( wxT("abcdefgh"), s5 );
    CPPUNIT_ASSERT_EQUAL( s1, s6 );
    CPPUNIT_ASSERT_EQUAL( s1, s7 );
    CPPUNIT_ASSERT_EQUAL( wxT("efgh"), s8 );

    const char *pc = s1.c_str();
    CPPUNIT_ASSERT_EQUAL( "bcd", wxString(pc + 1, pc + 4) );

    const wchar_t *pw = s2.c_str();
    CPPUNIT_ASSERT_EQUAL( "a", wxString(pw, pw + 1) );
}
예제 #10
0
void StdStringTestCase::StdConversion()
{
    std::string strStd("std::string value");
    wxStdWideString strStdWide(L"std::wstring value");

    wxString s1(strStd);
    CPPUNIT_ASSERT_EQUAL( "std::string value", s1 );

    wxString s2(strStdWide);
    CPPUNIT_ASSERT_EQUAL( "std::wstring value", s2 );

    wxString s3;
    s3 = strStd;
    CPPUNIT_ASSERT_EQUAL( "std::string value", s3 );
    s3 = strStdWide;
    CPPUNIT_ASSERT_EQUAL( "std::wstring value", s3 );

    wxString s4("hello");

    // wxString -> std::string conversion is only available in wxUSE_STL case,
    // because it conflicts with conversion to const char*/wchar_t*:
#if wxUSE_STL
    std::string s5 = s4;
    CPPUNIT_ASSERT_EQUAL( "hello", s5 );

    wxStdWideString s6 = s4;
    CPPUNIT_ASSERT_EQUAL( "hello", s6 );
#endif

    std::string s7(s4);
    CPPUNIT_ASSERT( s7 == "hello" );

    wxStdWideString s8(s4);
    CPPUNIT_ASSERT( s8 == "hello" );
}
예제 #11
0
파일: main.cpp 프로젝트: mitko100/CPlusPlus
std::vector<Student> createStudents()
{
	Student s1("Dimitar",
		"Radenkov",
		28,
		"08889793457",
		"*****@*****.**",
		std::vector < int > {1, 2, 3, 5});

	Student s2("Ralica",
		"Vaskova",
		32,
		"088998899889",
		"*****@*****.**",
		std::vector < int > {4, 2, 3, 4});

	Student s3("Nikol",
		"Georgieva",
		18,
		"08989898989",
		"*****@*****.**",
		std::vector < int > {2, 2, 2, 2});

	Student s4("Alexander",
		"Radenkov",
		19,
		"08989898989",
		"*****@*****.**",
		std::vector < int > {6, 6, 6, 6});

	std::vector<Student> students{ s1, s2, s3, s4 };

	return students;
}
예제 #12
0
void insert()
{
/*       MemStat memStat("insert");    */
    String s1("1234", 5), s2("1234");
    String s3("1235", 4), s4("1232");
    String s5;

    insert2();
    cout << "insert" << endl;
    s1.insert(1, s1.cStr());
    assert(s1.length() ==  9);
    s2.insert(1, s2);
    assert(s2.length() ==  8 && s2 == "11234234");
    s5.insert(0, s3);
    assert(s3 == s5);
    s5.insert(2, "abcdef", 4);
    assert(s5 == "12abcd35");
    s3.insert(s3.length(), "abcd");
    assert(s3 == ((String)("1235") + "abcd"));
    s3 = "1234";
    s3.insert(0, 'x', 5);
    assert(s3 == "xxxxx1234");
    s3 = "1234";
    s3.insert(2, 'x', 5);
    assert(s3 == "12xxxxx34");
    s3 = "1234";
    s3.insert(s3.length(), 'x', 5);
    assert(s3 == "1234xxxxx");
}
예제 #13
0
void TestVariant()
{
  bool b1 = is_base_of<nuiObject, nuiWidget>::value;
  bool b2 = is_base_of<nuiWidget, nuiObject>::value;
  bool b3 = is_base_of<nuiObject*, nuiWidget*>::value;
  bool b4 = is_base_of<nuiWidget*, nuiObject*>::value;
  bool b5 = is_base_of<nuiObject, nuiObject>::value;
  bool b6 = is_base_of<nuiWidget, nuiWidget>::value;

  nuiVariant s1(12);
  nuiVariant s2(12.34);
  nuiVariant s3(-10);
  nuiVariant s4(nglString(_T("ProutString")));
  nuiVariant s5(new nuiObject());
  nuiVariant s6(new nuiWidget());

  int r = s1;
  nglString r0 = s3;
  nglString r1 = s4;
  nuiObject* pObj1 = s5;
  nuiObject* pObj2 = s6;
  nuiWidget* pW1 = s5;
  nuiWidget* pW2 = s6;

  NGL_OUT(_T("sizeof nuiVariant: %d\n"), sizeof(nuiVariant));
}
예제 #14
0
파일: test1.c 프로젝트: jkkm/latrace
int main(void)
{
	static const struct st3 a = {1, 2, 3, 4, 5, 6};

	l1(100);
	l2(100, 200);
	l3(100, 200, 300);
	l4(100, 200, 300, 400);
	l5(100, 200, 300, 400, 500);
	l6(100, 200, 300, 400, 500, 600);
	l7(100, 200, 300, 400, 500, 600, 700);
	l8(100, 200, 300, 400, 500, 600, 700, 800);

	d1();
	d2(43);
	d3(100, 200);
	d4(a);
	d5('a', 43, a);
	d6('a', 1);

	c1(44);
	c2(100, 'a', 3.4);
	c3(200, 2.777, 'q');
	c4(200, 1);
	c5(1.1, 2.2);
	c6(1.23, 45.6);
	c7('z', 0x200);

	a1('a');
	a2(10);
	a3(20);
	a4(102030405060LL);

	b1('a', 20);
	b2(30, 'b');
	b3(10, 20, 30, 40, 50, 60);

	s1(sx);
	s1p(&sx);
	s2(sy);
	s3(sz);
	s4(sq);
	s5(sa);
	s6(sb);

	r1();
	r3();
	r4();

	q1(200, sx);
	q2(300, 't', sx);
	q3(400, 410, sy);
	q4(500, 510, sq);
	q5(600, 610, 'z', 'q', sq);

	real1("fresh air");
	real2();

	return 0;
}
예제 #15
0
void compare()
{
/*       MemStat memStat("compare");    */
    String s1("1234", 5), s2("1234");
    String s3("1235", 5), s4("1232");
    String s5;

    cout << "compare" << endl;
    assert(s1.compare(s2) != 0);
    assert(compare(s1,s2) != 0);
    assert(s2.compare(s2) == 0);
    assert(s2.compare("12345", 4) == 0);
    assert(s1.compare(s3) < 0);
    assert(compare(s2, s3) < 0);
    assert(compare(s2, "1235") < 0);
    assert(compare("1235", s2) > 0);
    assert(s1.compare(s4) > 0);
    assert(s2.compare(s5) > 0);
    assert(s5.length() == 0);
    assert(s5.compare("") == 0);
    assert(compare(s5,"") == 0);
    assert(compare("",s5) == 0);
    assert(s1 != "1234");
    assert(s2 == "1234");
    assert("1234" == s2);
    assert("1234" != s1);
}
예제 #16
0
파일: 13.48.cpp 프로젝트: ceye1992/learn
int main()
{
    char text[] = "world";

    String s0;
    String s1("hello");
    String s2(s0);
    String s3 = s1;
    String s4(text);
    s2 = s1;

    foo(s1);
    bar(s1);
    foo("temporary");
    bar("temporary");
    String s5 = baz();

    std::vector<String> svec;
    svec.reserve(8);
    svec.push_back(s0);
    svec.push_back(s1);
    svec.push_back(s2);
    svec.push_back(s3);
    svec.push_back(s4);
    svec.push_back(s5);
    svec.push_back(baz());
    svec.push_back("good job");

    for (const auto &s : svec) {
        std::cout << s.c_str() << std::endl;
    }
}
void ReadFilterData(bool reload)
{
	static bool loaded = false;
	if (!loaded || reload)
	{
		loaded = true;

		QFile f1("berichten/forbidden_sentences.txt");
		QFile f2("berichten/forbidden_start.txt");
		QFile f3("berichten/forbidden_sentences_ai.txt");
		QFile f4("berichten/forbidden_start_ai.txt");

		f1.open(QIODevice::ReadOnly | QIODevice::Text);
		f2.open(QIODevice::ReadOnly | QIODevice::Text);
		f3.open(QIODevice::ReadOnly | QIODevice::Text);
		f4.open(QIODevice::ReadOnly | QIODevice::Text);

		QTextStream s1(&f1);
		QTextStream s2(&f2);
		QTextStream s3(&f3);
		QTextStream s4(&f4);

		disallowed_contents = s1.readAll().split('\n');
		disallowed_begins = s2.readAll().split('\n');
		disallowed_contents_ai = s3.readAll().split('\n');
		disallowed_begins_ai = s4.readAll().split('\n');
	}
}
예제 #18
0
void test() {

    Pboom boom;

    StringMetBits s1("alfa");
    StringMetBits s2("beta");
    StringMetBits s3("delt");
    StringMetBits s4("jaja");
    StringMetBits s5("baby");

    boom.insert(s1);
    boom.insert(s1);

    boom.insert(s2);
    boom.insert(s2);
    boom.insert(s2);

    boom.insert(s3);

    boom.insert(s4);

    boom.insert(s5);
    boom.insert(s5);

    std::cout << s1 << ": " << boom.get(s1) << std::endl;
    std::cout << s2 << ": " << boom.get(s2) << std::endl;
    std::cout << s3 << ": " << boom.get(s3) << std::endl;
    std::cout << s4 << ": " << boom.get(s4) << std::endl;
    std::cout << s5 << ": " << boom.get(s5) << std::endl;
}
예제 #19
0
TEST(ArrayTest, getNumRows) {
	TwoDArray<int> i4(10, 5, 42);
	TwoDArray<double> d4(2, 9, 9.9);
	TwoDArray<std::string> s4(6, 8, "e");
  EXPECT_EQ(10, i4.access(8,2));
  EXPECT_EQ(2, d4.access(0,0));
  EXPECT_EQ(6, s4.access(5,7));	
}
예제 #20
0
bool insert_test( )
{
  bool rc = true;

  std::string s0( "INSERTED" );
  std::string s1( "Hello, World!" );
  s1.insert( 2, s0 );
  if( s1 != "HeINSERTEDllo, World!" || s1.size( ) != 21 || INSANE( s1 ) ) {
    FAIL
  }

  std::string s2( "Hello, World!" );
  s2.insert( 0, s0 );
  if( s2 != "INSERTEDHello, World!" || s2.size( ) != 21 || INSANE( s2 ) ) {
    FAIL
  }

  std::string s3( "Hello, World!" );
  s3.insert( 13, s0 );
  if( s3 != "Hello, World!INSERTED" || s3.size( ) != 21 || INSANE( s3 ) ) {
    FAIL
  }

  std::string s4( "Hello, World!" );
  s4.insert( 0, s0, 2, 2 );
  if( s4 != "SEHello, World!" || s4.size( ) != 15 || INSANE( s4 ) ) {
    FAIL
  }

  std::string s5( "Hello, World!" );
  s5.insert( 0, s0, 2, 128 );
  if( s5 != "SERTEDHello, World!" || s5.size( ) != 19 || INSANE( s5 ) ) {
    FAIL
  }

  // Do multiple insertions to verify reallocations.
  // This should probably also be done for the other insert methods as well.
  std::string s6( "Hello" );
  char input = 'a';
  for( int i = 0; i < 10; ++i ) {
      std::string::iterator p = s6.insert( s6.begin( ), input );
      if( *p != input ) FAIL;
      if( s6.size( ) != 6 + i ) FAIL;
      if( INSANE( s6 ) ) FAIL;
      ++input;
  }
  if( s6 != "jihgfedcbaHello" ) FAIL;

  std::string s7( "Hello, World!" );
  s7.insert( s7.end( ), 3, 'z' );
  if( s7 != "Hello, World!zzz" || s7.size( ) != 16 || INSANE( s7 ) ) {
    FAIL
  }

  // Need to test other insert methods.

  return( rc );
}
예제 #21
0
bool assign_test( )
{
  bool rc = true;
  std::string s1( 5, 'x' );
  const char *shrt_string = "Shorty";
  const char *long_string = "This string is longer than 8 characters";
  const std::string s2( shrt_string );
  const std::string s3( long_string );
  std::string s4( 5, 'x' );
  std::string s5( 5, 'x' );
  std::string s6( 5, 'x' );
  std::string s7( 5, 'x' );
  std::string s8( 5, 'x' );
  std::string s9( 5, 'x' );
  const char *raw = "This is a very, very long string";

  s1 = s2;
  if( s1.size( ) !=  6 || s1 != shrt_string || INSANE( s1 ) ) FAIL

  s1 = s3;
  if( s1.size( ) != 39 || s1 != long_string || INSANE( s1 ) ) FAIL

  s4 = shrt_string;
  if( s4.size( ) !=  6 || s4 != shrt_string || INSANE( s4 ) ) FAIL

  s4 = long_string;
  if( s4.size( ) != 39 || s4 != long_string || INSANE( s4 ) ) FAIL

  s5 = 'y';
  if( s5.size( ) !=  1 || s5 != "y" || INSANE( s5 ) ) FAIL

  s6.assign( s3, 35, 5 );
  if( s6.size( ) !=  4 || s6 != "ters" || INSANE( s6 ) ) FAIL

  s6.assign( s3, 5, 16 );
  if( s6.size( ) != 16 || s6 != "string is longer" || INSANE( s6 ) ) FAIL

  s7.assign( raw, 4 );
  if( s7.size( ) !=  4 || s7 != "This" || INSANE( s7 ) ) FAIL

  s7.assign( raw, 10 );
  if( s7.size( ) != 10 || s7 != "This is a " || INSANE( s7 ) ) FAIL

  s8.assign( "Shorty" );
  if( s8.size( ) !=  6 || s8 != "Shorty" || INSANE( s8 ) ) FAIL

  s8.assign( long_string );
  if( s8.size( ) != 39 || s8 != long_string || INSANE( s8 ) ) FAIL

  s9.assign( 7, 'x' );
  if( s9.size( ) !=  7 || s9 != "xxxxxxx" || INSANE( s9 ) ) FAIL

  s9.assign( 8, 'y' );
  if( s9.size( ) !=  8 || s9 != "yyyyyyyy" || INSANE( s9 ) ) FAIL

  return( rc );
}
예제 #22
0
bool TestExtString::test_stringdata() {
  // None of these should assert.
  StackStringData s1;
  String s2(StringData::MaxSmallSize / 2, ReserveString);
  String s3(StringData::MaxSmallSize * 2, ReserveString);
  String s4(StringData::MaxSmallSize * 2, ReserveString);
  s4.mutableSlice().ptr[0] = 'a';
  return Count(true);
}
예제 #23
0
int main()
{
  // Step(a) - construct a triangular face.
  Arrangement_2   arr;

  Segment_2       s1(Point_2(667, 1000), Point_2(4000, 5000));
  Segment_2       s2(Point_2(4000, 0), Point_2(4000, 5000));
  Segment_2       s3(Point_2(667, 1000), Point_2(4000, 0));

  Halfedge_handle e1 = arr.insert_in_face_interior(s1, arr.unbounded_face());
  Vertex_handle   v1 = e1->source();
  Vertex_handle   v2 = e1->target();
  Halfedge_handle e2 = arr.insert_from_right_vertex(s2, v2);
  Vertex_handle   v3 = e2->target();
  arr.insert_at_vertices(s3, v3, v1);

  // Step (b) - create additional two faces inside the triangle.
  Point_2         p1(4000, 3666), p2(4000, 1000);
  Segment_2       s4(Point_2(4000, 5000), p1);
  Segment_2       s5(p1, p2);
  Segment_2       s6(Point_2(4000, 0), p2);

  Halfedge_handle e4 = arr.split_edge(e2, s4, Segment_2(Point_2(4000, 0), p1));
  Vertex_handle   w1 = e4->target();
  Halfedge_handle e5 = arr.split_edge(e4->next(), s5, s6);
  Vertex_handle   w2 = e5->target();
  Halfedge_handle e6 = e5->next();

  Segment_2       s7(p1, Point_2(3000, 2666));
  Segment_2       s8(p2, Point_2(3000, 1333));
  Segment_2       s9(Point_2(3000, 2666), Point_2(2000, 1666));
  Segment_2       s10(Point_2(3000, 1333), Point_2(2000, 1666));
  Segment_2       s11(Point_2(3000, 1333), Point_2(3000, 2666));

  Halfedge_handle e7 = arr.insert_from_right_vertex(s7, w1);
  Vertex_handle   v4 = e7->target();
  Halfedge_handle e8 = arr.insert_from_right_vertex(s8, w2);
  Vertex_handle   v5 = e8->target();
  Vertex_handle   v6 =
    arr.insert_in_face_interior(Point_2(2000, 1666), e8->face());

  arr.insert_at_vertices(s9, v4, v6);
  arr.insert_at_vertices(s10, v5, v6);
  arr.insert_at_vertices(s11, v4, v5);

  // Step(c) - remove and merge faces to form a single hole in the traingle.
  arr.remove_edge(e7);
  arr.remove_edge(e8);

  e5 = arr.merge_edge(e5, e6, Segment_2(e5->source()->point(),
                                        e6->target()->point()));
  e2 = arr.merge_edge(e4, e5, s2);

  print_arrangement(arr);
  return 0;
}
예제 #24
0
 void SendAudioFrame(const unsigned char* audbuf, unsigned framesize)
 {
     CheckBegin();
     
     //fprintf(stderr, "Writing 01wb of %u bytes\n", framesize);
     
     const unsigned char header[] = { s4("01wb"), u32(framesize) };
     FlushWrite(avifp, header, sizeof(header));
     FlushWrite(avifp, audbuf, framesize);
 }
예제 #25
0
 void SendVideoFrame(const unsigned char* vidbuf, unsigned framesize)
 {
     CheckBegin();
     
     //fprintf(stderr, "Writing 00dc of %u bytes\n", framesize);
     
     const unsigned char header[] = { s4("00dc"), u32(framesize) };
     FlushWrite(avifp, header, sizeof(header));
     FlushWrite(avifp, vidbuf, framesize);
 }
예제 #26
0
int main(int argc, char *argv[])
{
   QApplication a(argc, argv);
   std::random_device rd;
   random_engine gen(rd());

   int imageSize = 300;
   QList<QImage> images;
   for (int n = 0; n < 28; ++n) images << randomImage(imageSize, gen);
   std::uniform_int_distribution<> dImage(0, images.size()-1);

   QStackedWidget display;
   QPushButton ready("I'm Ready!");
   QLabel label, labelHidden;
   display.addWidget(&ready);
   display.addWidget(&label);
   display.addWidget(&labelHidden);

   QTimer splashTimer;
   QStateMachine machine;
   QState s1(&machine), s2(&machine), s3(&machine), s4(&machine);
   splashTimer.setSingleShot(true);

   QObject::connect(&s1, &QState::entered, [&]{
      display.setCurrentWidget(&ready);
      ready.setDefault(true);
      ready.setFocus();
   });
   s1.addTransition(&ready, "clicked()", &s2);

   QObject::connect(&s2, &QState::entered, [&]{
      label.setPixmap(QPixmap::fromImage(images.at(dImage(gen))));
      display.setCurrentWidget(&label);
      splashTimer.start(250 + std::uniform_int_distribution<>(1500, 3000)(gen));
   });
   s2.addTransition(&splashTimer, "timeout()", &s3);

   QObject::connect(&s3, &QState::entered, [&]{
      display.setCurrentWidget(&labelHidden);
      splashTimer.start(2000);
   });
   s3.addTransition(&splashTimer, "timeout()", &s4);

   QObject::connect(&s4, &QState::entered, [&]{
      display.setCurrentWidget(&label);
      splashTimer.start(3000);
   });
   s4.addTransition(&splashTimer, "timeout()", &s1);

   machine.setInitialState(&s1);
   machine.start();
   display.show();

   return a.exec();
}
예제 #27
0
void Engine::LoadScores()
{
	iHiScore[0]= 10000;
	iHiScore[1]= 9000;
	iHiScore[2]= 8000;
	iHiScore[3]= 7000;
	iHiScore[4]= 6000;
	iHiScore[5]= 5000;
	iHiScore[6]= 4000;
	iHiScore[7]= 3000;
	iHiScore[8]= 2000;
	iHiScore[9]= 1000;
	string s1("HOLD");
	string s2("DOWN");
	string s3("KEYS");
	string s4("MARY");
	string s5("ON");
	string s6("MAIN");
	string s7("PAGE");
	string s8("FOR");
	string s9("CHEAT");
	string s10("*****");

	gSerializer.ReadVariable("score.dat","1a",iHiScore[0]);
	gSerializer.ReadVariable("score.dat","1b",s1);
	gSerializer.ReadVariable("score.dat","2a",iHiScore[1]);
	gSerializer.ReadVariable("score.dat","2b",s2);
	gSerializer.ReadVariable("score.dat","3a",iHiScore[2]);
	gSerializer.ReadVariable("score.dat","3b",s3);
	gSerializer.ReadVariable("score.dat","4a",iHiScore[3]);
	gSerializer.ReadVariable("score.dat","4b",s4);
	gSerializer.ReadVariable("score.dat","5a",iHiScore[4]);
	gSerializer.ReadVariable("score.dat","5b",s5);
	gSerializer.ReadVariable("score.dat","6a",iHiScore[5]);
	gSerializer.ReadVariable("score.dat","6b",s6);
	gSerializer.ReadVariable("score.dat","7a",iHiScore[6]);
	gSerializer.ReadVariable("score.dat","7b",s7);
	gSerializer.ReadVariable("score.dat","8a",iHiScore[7]);
	gSerializer.ReadVariable("score.dat","8b",s8);
	gSerializer.ReadVariable("score.dat","9a",iHiScore[8]);
	gSerializer.ReadVariable("score.dat","9b",s9);
	gSerializer.ReadVariable("score.dat","10a",iHiScore[9]);
	gSerializer.ReadVariable("score.dat","10b",s10);
	strcpy(szHiScore[0],s1.c_str());
	strcpy(szHiScore[1],s2.c_str());
	strcpy(szHiScore[2],s3.c_str());
	strcpy(szHiScore[3],s4.c_str());
	strcpy(szHiScore[4],s5.c_str());
	strcpy(szHiScore[5],s6.c_str());
	strcpy(szHiScore[6],s7.c_str());
	strcpy(szHiScore[7],s8.c_str());
	strcpy(szHiScore[8],s9.c_str());
	strcpy(szHiScore[9],s10.c_str());
}
예제 #28
0
void TestDelegatingConstructor()
{
	std::cout << "*****s1's constructor*****" << std::endl;
	Sales_data s1("978-7-121-15535-2", 0, 0);
	std::cout << "*****s2's constructor*****" << std::endl;
	Sales_data s2;
	std::cout << "*****s3's constructor*****" << std::endl;
	Sales_data s3("978-7-121-15535-2");
	std::cout << "*****s4's constructor*****" << std::endl;
	Sales_data s4(std::cin);
}
예제 #29
0
Stream<int> test1()
{
    Stream<int> s0;
    Stream<int> s1(1, s0);
    lazyPrint(s1);
    Stream<int> s2(2, s1);
    Stream<int> s3(3, s2);
    Stream<int> s4(4, s3);
    std::cout << s1.get() << std::endl;
    lazyPrint(s4);
    return s4;
}
예제 #30
0
TQSize KJanusWidget::minimumSizeHint() const
{
  if( mFace == TreeList || mFace == IconList )
  {
    TQSize s1( KDialog::spacingHint(), KDialog::spacingHint()*2 );
    TQSize s2(0,0);
    TQSize s3(0,0);
    TQSize s4( mPageStack->sizeHint() );

    if( mFace == TreeList )
    {
      s1.rwidth() += style().pixelMetric( TQStyle::PM_SplitterWidth );
      s2 = mTreeList->minimumSize();
    }
    else
    {
      mIconList->updateMinimumHeight();
      mIconList->updateWidth();
      s2 = mIconList->minimumSize();
    }

    if( mTitleLabel->isVisible() )
    {
      s3 += mTitleLabel->sizeHint();
      s3.rheight() += mTitleSep->minimumSize().height();
    }

    //
    // Select the tallest item. It has only effect in IconList mode
    //
    int h1 = s1.rheight() + s3.rheight() + s4.height();
    int h2 = TQMAX( h1, s2.rheight() );

    return TQSize( s1.width()+s2.width()+TQMAX(s3.width(),s4.width()), h2 );
  }
  else if( mFace == Tabbed )
  {
    return mTabControl->sizeHint();
  }
  else if( mFace == Swallow )
  {
    return mSwallowPage->minimumSize();
  }
  else if( mFace == Plain )
  {
    return mPlainPage->sizeHint();
  }
  else
  {
    return TQSize( 100, 100 ); // Should never happen though.
  }

}