/* * Some older servers (old samba) prefer to talk older * dialects but if given no choice they will talk the * more modern ones, so we don't give them the choice. */ int CIFSnegotiate(Session *s, long *svrtime, char *domain, int domlen, char *cname, int cnamlen) { int d, i; char *ispeak = "NT LM 0.12"; static char *dialects[] = { // { "PC NETWORK PROGRAM 1.0"}, // { "MICROSOFT NETWORKS 1.03"}, // { "MICROSOFT NETWORKS 3.0"}, // { "LANMAN1.0"}, // { "LM1.2X002"}, // { "NT LANMAN 1.0"}, { "NT LM 0.12" }, }; Pkt *p; /* * This should not be necessary, however the XP seems to use * Unicode strings in its Negoiate response, but not set the * Flags2 UNICODE flag. * * It does however echo back the FL_UNICODE flag we set in the * flags2 negoiate request. * * The bodge is to force FL_UNICODE for this single request, * clearing it after. Later we set FL2_UNICODE if the server * agrees to CAP_UNICODE as it "should" be done. */ s->flags2 |= FL2_UNICODE; p = cifshdr(s, nil, SMB_COM_NEGOTIATE); s->flags2 &= ~FL2_UNICODE; pbytes(p); for(i = 0; i < nelem(dialects); i++){ p8(p, STR_DIALECT); pascii(p, dialects[i]); } if(cifsrpc(p) == -1){ free(p); return -1; } d = gl16(p); if(d < 0 || d > nelem(dialects)){ werrstr("no CIFS dialect in common"); free(p); return -1; } if(strcmp(dialects[d], ispeak) != 0){ werrstr("%s dialect unsupported", dialects[d]); free(p); return -1; } s->secmode = g8(p); /* Security mode */ gl16(p); /* Max outstanding requests */ gl16(p); /* Max VCs */ s->mtu = gl32(p); /* Max buffer size */ gl32(p); /* Max raw buffer size (depricated) */ gl32(p); /* Session key */ s->caps = gl32(p); /* Server capabilities */ *svrtime = gvtime(p); /* fileserver time */ s->tz = (short)gl16(p) * 60; /* TZ in mins, is signed (SNIA doc is wrong) */ s->challen = g8(p); /* Encryption key length */ gl16(p); gmem(p, s->chal, s->challen); /* Get the challenge */ gstr(p, domain, domlen); /* source domain */ { /* NetApp Filer seem not to report its called name */ char *cn = emalloc9p(cnamlen); gstr(p, cn, cnamlen); /* their name */ if(strlen(cn) > 0) memcpy(cname, cn, cnamlen); free(cn); } if(s->caps & CAP_UNICODE) s->flags2 |= FL2_UNICODE; free(p); return 0; }
static int dc_add_single_kf(dc_pass *pass, wchar_t *path) { kf_ctx *k_ctx; HANDLE h_file; int resl, i; int succs; u32 bytes; h_file = NULL; k_ctx = NULL; do { if ( (k_ctx = secure_alloc(sizeof(kf_ctx))) == NULL ) { resl = ST_NOMEM; break; } h_file = CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (h_file == INVALID_HANDLE_VALUE) { h_file = NULL; resl = ST_ACCESS_DENIED; break; } /* initialize sha512 for hashing keyfile */ sha512_init(&k_ctx->sha); do { succs = ReadFile(h_file, k_ctx->kf_block, KF_BLOCK_SIZE, &bytes, NULL); if ( (succs == 0) || (bytes == 0) ) { break; } sha512_hash(&k_ctx->sha, k_ctx->kf_block, bytes); } while (1); /* done hasing */ sha512_done(&k_ctx->sha, k_ctx->hash); /* zero unused password buffer bytes */ zeromem( p8(pass->pass) + pass->size, (MAX_PASSWORD*2) - pass->size); /* mix the keyfile hash and password */ for (i = 0; i < (SHA512_DIGEST_SIZE / sizeof(u32)); i++) { p32(pass->pass)[i] += p32(k_ctx->hash)[i]; } pass->size = max(pass->size, SHA512_DIGEST_SIZE); resl = ST_OK; } while (0); if (h_file != NULL) { CloseHandle(h_file); } if (k_ctx != NULL) { secure_free(k_ctx); } return resl; }
TEST(FloatRectTest, SquaredDistanceToTest) { // // O--x // | // y // // FloatRect.x() FloatRect.maxX() // | | // 1 | 2 | 3 // ======+==========+====== --FloatRect.y() // 4 | 5(in) | 6 // ======+==========+====== --FloatRect.maxY() // 7 | 8 | 9 // FloatRect r1(100, 100, 250, 150); // `1` case FloatPoint p1(80, 80); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p1), 800.f); FloatPoint p2(-10, -10); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p2), 24200.f); FloatPoint p3(80, -10); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p3), 12500.f); // `2` case FloatPoint p4(110, 80); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p4), 400.f); FloatPoint p5(150, 0); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p5), 10000.f); FloatPoint p6(180, -10); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p6), 12100.f); // `3` case FloatPoint p7(400, 80); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p7), 2900.f); FloatPoint p8(360, -10); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p8), 12200.f); // `4` case FloatPoint p9(80, 110); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p9), 400.f); FloatPoint p10(-10, 180); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p10), 12100.f); // `5`(& In) case FloatPoint p11(100, 100); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p11), 0.f); FloatPoint p12(150, 100); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p12), 0.f); FloatPoint p13(350, 100); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p13), 0.f); FloatPoint p14(350, 150); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p14), 0.f); FloatPoint p15(350, 250); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p15), 0.f); FloatPoint p16(150, 250); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p16), 0.f); FloatPoint p17(100, 250); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p17), 0.f); FloatPoint p18(100, 150); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p18), 0.f); FloatPoint p19(150, 150); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p19), 0.f); // `6` case FloatPoint p20(380, 150); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p20), 900.f); // `7` case FloatPoint p21(80, 280); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p21), 1300.f); FloatPoint p22(-10, 300); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p22), 14600.f); // `8` case FloatPoint p23(180, 300); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p23), 2500.f); // `9` case FloatPoint p24(450, 450); EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p24), 50000.f); }
int main(int argc, const char * argv[]) { // insert code here... double coeff[13];//array of coefficients for taylor polynomial of cos(x) bool neg=false;//if coefficient is supposed to be negative, then true for (int i=0.0; i<13; i++) {//assigns coefficients to array if(i%2==0) {if(!neg) { coeff[i]=(double)(1.0/factorial(i)); neg=true; } else { coeff[i]=(double)(-1.0/factorial(i)); neg=false; } } else{ coeff[i]=0; } } Matrix z=Linspace(-3, 3, 601);//creates matrix with 601 evenly div numbers between -3 and 3 Matrix p4coeff(1,5,coeff);//matrix with first 4 taylor coefficients Matrix p4(1,601);//matrix with result for 4th degree polynomial evaluated at z for (int i=0;i<601;i++) { p4(i)=nest(p4coeff,z(i)); } p4.Write("p4.txt");//wriete results to text file //same as above for 8th degree polynomial Matrix p8coeff(1,9,coeff); Matrix p8(1,601); for (int i=0;i<601;i++) { p8(i)=nest(p8coeff,z(i)); } p8.Write("p8.txt"); //same as above for 12th degree polynomial Matrix p12coeff(1,13,coeff); Matrix p12(1,601); for (int i=0;i<601;i++) { p12(i)=nest(p12coeff,z(i)); } p12.Write("p12.txt"); // all points are evaluated at cos(x) Matrix f(1,601); for (int i=0;i<601;i++) { f(i)=cos(z(i)); } f.Write("f.txt"); //calculate relative error for the three taylor polynomials Matrix err4(1,601); for (int i=0;i<601;i++) { err4(i)=cos(z(i))-p4(i); } err4.Abs(); err4.Write("err4.txt"); Matrix err8(1,601); for (int i=0;i<601;i++) { err8(i)=cos(z(i))-p8(i); } err8.Abs(); err8.Write("err8.txt"); Matrix err12(1,601); for (int i=0;i<601;i++) { err12(i)=cos(z(i))-p12(i); } err12.Abs(); err12.Write("err12.txt"); z.Write("z.txt"); }
void test01() { CIMParamValue pv; PEGASUS_TEST_ASSERT(pv.isUninitialized()); String p1("message"); CIMValue v1(String("argument_Test")); CIMParamValue a1(p1, v1); // Test call to CIMParamValue::setValue(CIMValue& value) // this test uses the above values for a1, p1 and v1. CIMParamValue a7(p1, v1); CIMValue v7(String("argument_Test7")); a7.setValue( v7); PEGASUS_TEST_ASSERT(a1.getValue().toString() != a7.getValue().toString()); PEGASUS_TEST_ASSERT(a1.getParameterName() == a7.getParameterName()); // Test call to CIMParamValue::setParameterName(String& parameterName) // this test uses the above values for a1, p1 and v1. CIMParamValue a8(p1, v1); String p8("message8"); a8.setParameterName( p8); PEGASUS_TEST_ASSERT(a1.getValue().toString() == a8.getValue().toString()); PEGASUS_TEST_ASSERT(a1.getParameterName() != a8.getParameterName()); PEGASUS_TEST_ASSERT(a8.isTyped()); a8.setIsTyped(false); PEGASUS_TEST_ASSERT(!a8.isTyped()); String p2("message2"); CIMValue v2(String("argument_Test2")); CIMParamValue a2(p2, v2); String p3("message3"); CIMValue v3(String("argument_Test3")); CIMParamValue a3(p3, v3); String p4("message4"); CIMValue v4(String("argument_Test4")); CIMParamValue a4(p4, v4); CIMParamValue a5 = a4; String p6("message6"); CIMValue v6(String("argument_Test6")); CIMParamValue a6(p6, v6); Array<CIMParamValue> aa; aa.append(a1); aa.append(a2); aa.append(CIMParamValue("message3", CIMValue(200000))); aa.append(CIMParamValue("message4", CIMValue(String("test4")))); // // clone // CIMParamValue a4clone = a4.clone(); aa.append(a4clone); if (verbose) { for (Uint32 i=0; i< aa.size(); i++) { XmlWriter::printParamValueElement(aa[i], cout); } } // // toXml // Buffer xmlOut; XmlWriter::appendParamValueElement(xmlOut, a4clone); }
virtual void on_draw() { pixfmt pf(rbuf_window()); renderer_base ren_base(pf); ren_base.clear(agg::rgba(1.0, 1.0, 0.95)); renderer_scanline ren(ren_base); rasterizer_scanline ras; scanline sl; // Pattern source. Must have an interface: // width() const // height() const // pixel(int x, int y) const // Any agg::renderer_base<> or derived // is good for the use as a source. //----------------------------------- pattern_src_brightness_to_alpha p1(rbuf_img(0)); pattern_src_brightness_to_alpha p2(rbuf_img(1)); pattern_src_brightness_to_alpha p3(rbuf_img(2)); pattern_src_brightness_to_alpha p4(rbuf_img(3)); pattern_src_brightness_to_alpha p5(rbuf_img(4)); pattern_src_brightness_to_alpha p6(rbuf_img(5)); pattern_src_brightness_to_alpha p7(rbuf_img(6)); pattern_src_brightness_to_alpha p8(rbuf_img(7)); pattern_src_brightness_to_alpha p9(rbuf_img(8)); agg::pattern_filter_bilinear_rgba<color_type> fltr; // Filtering functor // agg::line_image_pattern is the main container for the patterns. It creates // a copy of the patterns extended according to the needs of the filter. // agg::line_image_pattern can operate with arbitrary image width, but if the // width of the pattern is power of 2, it's better to use the modified // version agg::line_image_pattern_pow2 because it works about 15-25 percent // faster than agg::line_image_pattern (because of using simple masking instead // of expensive '%' operation). typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba<color_type> > pattern_type; typedef agg::renderer_base<pixfmt> base_ren_type; typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_type; typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type; //-- Create with specifying the source //pattern_type patt(fltr, src); //-- Create uninitialized and set the source pattern_type patt(fltr); renderer_type ren_img(ren_base, patt); rasterizer_type ras_img(ren_img); draw_curve(patt, ras_img, ren_img, p1, m_curve1.curve()); draw_curve(patt, ras_img, ren_img, p2, m_curve2.curve()); draw_curve(patt, ras_img, ren_img, p3, m_curve3.curve()); draw_curve(patt, ras_img, ren_img, p4, m_curve4.curve()); draw_curve(patt, ras_img, ren_img, p5, m_curve5.curve()); draw_curve(patt, ras_img, ren_img, p6, m_curve6.curve()); draw_curve(patt, ras_img, ren_img, p7, m_curve7.curve()); draw_curve(patt, ras_img, ren_img, p8, m_curve8.curve()); draw_curve(patt, ras_img, ren_img, p9, m_curve9.curve()); agg::render_ctrl(ras, sl, ren_base, m_curve1); agg::render_ctrl(ras, sl, ren_base, m_curve2); agg::render_ctrl(ras, sl, ren_base, m_curve3); agg::render_ctrl(ras, sl, ren_base, m_curve4); agg::render_ctrl(ras, sl, ren_base, m_curve5); agg::render_ctrl(ras, sl, ren_base, m_curve6); agg::render_ctrl(ras, sl, ren_base, m_curve7); agg::render_ctrl(ras, sl, ren_base, m_curve8); agg::render_ctrl(ras, sl, ren_base, m_curve9); agg::render_ctrl(ras, sl, ren_base, m_scale_x); agg::render_ctrl(ras, sl, ren_base, m_start_x); }
int main( int argc, char* argv[]) { // create some points in the plane Point p1(1,2), p2(4,2); Point p3(2,1), p4(4,3); Point p5(2,2), p6(6,2); Point p7(1,4), p8(2,3); Point p9(3,2), p10(5,0); // create some segments Segment s1(p1, p2); Segment s2(p3, p4); Segment s3(p5, p6); Segment s4(p7, p8); Segment s5(p9, p10); // test with predicate functions echo("*****************************************************************"); echo("Segment 1 and 2, they should intersect at point (3,2)"); printSegments(s1, s2); testForIntersectionAndPrint(s1, s2); doIntersectionAndPrint(s1, s2); newline(); echo("Segment 1 and 3, they should intersect at segment (2,2), (4,2)"); printSegments(s1, s3); testForIntersectionAndPrint(s1, s3); doIntersectionAndPrint(s1, s3); newline(); echo("Segment 1 and 4, they should not intersect"); printSegments(s1, s4); testForIntersectionAndPrint(s1, s4); doIntersectionAndPrint(s1, s4); newline(); echo("Segment 2 and 5, they should intersect at point (3,2)"); printSegments(s2, s5); testForIntersectionAndPrint(s2, s5); doIntersectionAndPrint(s2, s5); newline(); echo("Segment 2 and 2, they should intersect at segment (2,1), (4,3)"); printSegments(s2, s2); testForIntersectionAndPrint(s2, s2); doIntersectionAndPrint(s2, s2); newline(); // test with non-predicate functions echo("*****************************************************************"); echo("Segment 1 and 2, they should intersect at point (3,2)"); printSegments(s1, s2); testForIntersectionAndPrint2(s1, s2); doIntersectionAndPrint2(s1, s2); newline(); echo("Segment 1 and 3, they should intersect at segment (2,2), (4,2)"); printSegments(s1, s3); testForIntersectionAndPrint2(s1, s3); doIntersectionAndPrint2(s1, s3); newline(); echo("Segment 1 and 4, they should not intersect"); printSegments(s1, s4); testForIntersectionAndPrint2(s1, s4); doIntersectionAndPrint2(s1, s4); newline(); echo("Segment 2 and 5, they should intersect at point (3,2)"); printSegments(s2, s5); testForIntersectionAndPrint2(s2, s5); doIntersectionAndPrint2(s2, s5); newline(); echo("Segment 2 and 2, they should intersect at segment (2,1), (4,3)"); printSegments(s2, s2); testForIntersectionAndPrint2(s2, s2); doIntersectionAndPrint2(s2, s2); newline(); return 0; }
int main() { Point p1(-253.357, -123.36); Point p2(-190.03, 216.606); Point p3(-343.349, 286.6); Point p4(141.604, 279.934); Point p5(276.591, -46.7012); Point p6(251.593, -263.347); Point p7(-3.38184, -343.339); Point p8(-380.012, -173.355); Point p9(-98.3726, 39.957); Point p10(133.271, 124.949); Point p11(289.923, 301.598); Point p12(421.577, 23.292); Point p13(79.9434, -93.3633); Point p14(-40.0449, 366.592); Point p15(311.587, 374.924); Point p16(431.576, 214.94); Point p17(426.576, -131.693); Point p18(-265.023, -285.011); Point p19(369.915, 89.9521); Point p20(368.249, -15.0376); Point p21(484.904, 18.2925); Point p22(-411.675, 283.267); Point p23(-250.024, 124.949); Point p24(-80.041, -78.3647); Point p25(-360.014, 31.6245); Point p26(-305.019, 356.593); // built Delaunay triangulation PS.insert(p1); PS.insert(p2); PS.insert(p3); PS.insert(p4); PS.insert(p5); PS.insert(p6); PS.insert(p7); PS.insert(p8); PS.insert(p9); PS.insert(p10); PS.insert(p11); PS.insert(p12); PS.insert(p13); PS.insert(p14); PS.insert(p15); PS.insert(p16); PS.insert(p17); PS.insert(p18); PS.insert(p19); PS.insert(p20); PS.insert(p21); PS.insert(p22); PS.insert(p23); PS.insert(p24); PS.insert(p25); PS.insert(p26); std::list<Vertex_handle> LV; bool correct = true; // circle emptiness check Circle cs1(Point(-23.3799, 108.284), 1124.78); check_empty checker(cs1); CGAL::range_search(PS,cs1,std::back_inserter(LV),checker,true); if (checker.get_result()) { std::cout << "circle not empty !\n"; std::cout << "this is an error !\n"; correct=false; } else std::cout << "circle was empty !\n"; Circle cs2(Point(-255.024, -100.029), 23551); check_empty checker2(cs2); CGAL::range_search(PS,cs2,std::back_inserter(LV),checker2,true); if (checker2.get_result()) std::cout << "circle not empty !\n"; else { std::cout << "circle was empty !\n"; std::cout << "this is an error !\n"; correct=false; } // triangle check Triangle t1(Point(-21.7134, -123.36), Point(84.9429, 74.9536), Point(209.931, -161.69)); Triangle t2(Point(-61.7095, 164.945), Point(-88.3735, 101.618), Point(49.9463, 101.618)); check_empty_triangle tchecker1(t1); CGAL::range_search(PS,t1.vertex(0),t1.vertex(1),t1.vertex(2),std::back_inserter(LV),tchecker1,true); if (tchecker1.get_result()) std::cout << "triangle not empty !\n"; else { std::cout << "triangle was empty !\n"; std::cout << "this is an error !\n"; correct=false; } check_empty_triangle tchecker2(t2); CGAL::range_search(PS,t2.vertex(0),t2.vertex(1),t2.vertex(2),std::back_inserter(LV),tchecker2,true); if (tchecker2.get_result()) { std::cout << "triangle not empty !\n"; std::cout << "this is an error !\n"; correct=false; } else std::cout << "triangle was empty !\n"; // rectangle check Rectangle_2 r1(-290.021, -175.022, -125.037, -35.0356); Rectangle_2 r2(-48.3774, 136.614, -23.3799, 251.603); check_empty_rectangle rchecker1(r1); CGAL::range_search(PS,r1.vertex(0),r1.vertex(1),r1.vertex(2),r1.vertex(3),std::back_inserter(LV),rchecker1,true); if (rchecker1.get_result()) std::cout << "rectangle not empty !\n"; else { std::cout << "rectangle was empty !\n"; std::cout << "this is an error !\n"; correct=false; } check_empty_rectangle rchecker2(r2); CGAL::range_search(PS,r2.vertex(0),r2.vertex(1),r2.vertex(2),r2.vertex(3),std::back_inserter(LV),rchecker2,true); if (rchecker2.get_result()) { std::cout << "rectangle not empty !\n"; std::cout << "this is an error !\n"; correct=false; } else std::cout << "rectangle was empty !\n"; if (correct) return 0; return 1; }
void cubeD_D::draw() { glPushMatrix(); orient_body_in_opengl(boxBody_m); glColor3f(r_m/255, g_m/255, b_m/255); tex1.activate(); // THIS IS WHERE THE DRAWING HAPPENS! // The front face :) glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1); p5(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1); p8(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0); p7(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0); p6(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Right face tex2.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1);p8(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1);p4(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0);p3(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0);p7(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Left face tex3.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1);p5(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1);p6(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0);p2(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0);p1(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Top face tex4.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1);p6(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1);p7(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0);p3(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0);p2(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Bottom face tex5.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1); p4(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1); p8(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0); p5(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0); p1(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Back face tex6.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1); p1(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1); p2(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0); p3(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0); p4(0,0,0,h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. glPopMatrix(); }
void CContainers::prepareMemBuffers() { memout=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p("!data",memout); memmap.insert(p); memout_words=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p2("!!!words",memout_words); memmap.insert(p2); memout_letters=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p3("!!letters",memout_letters); memmap.insert(p3); memout_num=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p4("!num",memout_num); memmap.insert(p4); memout_year=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p5("!year",memout_year); memmap.insert(p5); memout_date=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p6("!date",memout_date); memmap.insert(p6); memout_words2=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p7("!!!words2",memout_words2); memmap.insert(p7); memout_words3=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p8("!!!words3",memout_words3); memmap.insert(p8); memout_words4=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p9("!!!words4",memout_words4); memmap.insert(p9); memout_pages=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p10("!pages",memout_pages); memmap.insert(p10); memout_num2=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p11("!num2",memout_num2); memmap.insert(p11); memout_num3=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p12("!num3",memout_num3); memmap.insert(p12); memout_num4=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p13("!num4",memout_num4); memmap.insert(p13); memout_remain=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p14("!remain",memout_remain); memmap.insert(p14); memout_date2=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p15("!date2",memout_date2); memmap.insert(p15); memout_date3=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p16("!date3",memout_date3); memmap.insert(p16); memout_num2b=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p17("!num2b",memout_num2b); memmap.insert(p17); memout_num3b=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p18("!num3b",memout_num3b); memmap.insert(p18); memout_num4b=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p19("!num4b",memout_num4b); memmap.insert(p19); memout_numb=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p20("!numb",memout_numb); memmap.insert(p20); memout_num2c=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p21("!num2c",memout_num2c); memmap.insert(p21); memout_num3c=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p22("!num3c",memout_num3c); memmap.insert(p22); memout_num4c=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p23("!num4c",memout_num4c); memmap.insert(p23); memout_numc=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p24("!numc",memout_numc); memmap.insert(p24); memout_time=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p25("!time",memout_time); memmap.insert(p25); memout_remain2=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p26("!remain2",memout_remain2); memmap.insert(p26); memout_ip=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p27("!ip",memout_ip); memmap.insert(p27); memout_hm=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p28("!hm",memout_hm); memmap.insert(p28); memout_hms=new CMemoryBuffer(); std::pair<std::string,CMemoryBuffer*> p29("!hms",memout_hms); memmap.insert(p29); }
// Create mesh void Chunk::CreateMesh() { if (m_pMesh == NULL) { m_pMesh = m_pRenderer->CreateMesh(OGLMeshType_Textured); } int *l_merged; l_merged = new int[CHUNK_SIZE_CUBED]; for (unsigned int j = 0; j < CHUNK_SIZE_CUBED; j++) { l_merged[j] = MergedSide_None; } float r = 1.0f; float g = 1.0f; float b = 1.0f; float a = 1.0f; for (int x = 0; x < CHUNK_SIZE; x++) { for (int y = 0; y < CHUNK_SIZE; y++) { for (int z = 0; z < CHUNK_SIZE; z++) { if (GetActive(x, y, z) == false) { continue; } else { GetColour(x, y, z, &r, &g, &b, &a); a = 1.0f; vec3 p1(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); vec3 p2(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); vec3 p3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); vec3 p4(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); vec3 p5(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); vec3 p6(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); vec3 p7(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); vec3 p8(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); vec3 n1; unsigned int v1, v2, v3, v4; unsigned int t1, t2, t3, t4; bool doXPositive = (IsMergedXPositive(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE) == false); bool doXNegative = (IsMergedXNegative(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE) == false); bool doYPositive = (IsMergedYPositive(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE) == false); bool doYNegative = (IsMergedYNegative(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE) == false); bool doZPositive = (IsMergedZPositive(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE) == false); bool doZNegative = (IsMergedZNegative(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE) == false); // Front if (doZPositive && ((z == CHUNK_SIZE - 1) || z < CHUNK_SIZE - 1 && GetActive(x, y, z + 1) == false)) { bool addSide = true; if ((z == CHUNK_SIZE - 1)) { Chunk* pChunk = m_pChunkManager->GetChunk(m_gridX, m_gridY, m_gridZ + 1); if (pChunk == NULL || pChunk->IsSetup()) { addSide = pChunk != NULL && (pChunk->GetActive(x, y, 0) == false); } } if (addSide) { int endX = (x / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; int endY = (y / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; if (m_pChunkManager->GetFaceMerging()) { UpdateMergedSide(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE, &p1, &p2, &p3, &p4, x, y, endX, endY, true, true, false, false); } n1 = vec3(0.0f, 0.0f, 1.0f); v1 = m_pRenderer->AddVertexToMesh(p1, n1, r, g, b, a, m_pMesh); t1 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 0.0f, m_pMesh); v2 = m_pRenderer->AddVertexToMesh(p2, n1, r, g, b, a, m_pMesh); t2 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 0.0f, m_pMesh); v3 = m_pRenderer->AddVertexToMesh(p3, n1, r, g, b, a, m_pMesh); t3 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 1.0f, m_pMesh); v4 = m_pRenderer->AddVertexToMesh(p4, n1, r, g, b, a, m_pMesh); t4 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 1.0f, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v2, v3, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v3, v4, m_pMesh); } } p1 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p2 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p3 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p4 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p5 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p6 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p7 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p8 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); // Back if (doZNegative && ((z == 0) || (z > 0 && GetActive(x, y, z - 1) == false))) { bool addSide = true; if ((z == 0)) { Chunk* pChunk = m_pChunkManager->GetChunk(m_gridX, m_gridY, m_gridZ - 1); if (pChunk == NULL || pChunk->IsSetup()) { addSide = pChunk != NULL && (pChunk->GetActive(x, y, CHUNK_SIZE - 1) == false); } } if (addSide) { int endX = (x / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; int endY = (y / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; if (m_pChunkManager->GetFaceMerging()) { UpdateMergedSide(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE, &p6, &p5, &p8, &p7, x, y, endX, endY, false, true, false, false); } n1 = vec3(0.0f, 0.0f, -1.0f); v1 = m_pRenderer->AddVertexToMesh(p5, n1, r, g, b, a, m_pMesh); t1 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 0.0f, m_pMesh); v2 = m_pRenderer->AddVertexToMesh(p6, n1, r, g, b, a, m_pMesh); t2 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 0.0f, m_pMesh); v3 = m_pRenderer->AddVertexToMesh(p7, n1, r, g, b, a, m_pMesh); t3 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 1.0f, m_pMesh); v4 = m_pRenderer->AddVertexToMesh(p8, n1, r, g, b, a, m_pMesh); t4 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 1.0f, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v2, v3, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v3, v4, m_pMesh); } } p1 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p2 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p3 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p4 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p5 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p6 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p7 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p8 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); // Right if (doXPositive && ((x == CHUNK_SIZE - 1) || (x < CHUNK_SIZE - 1 && GetActive(x + 1, y, z) == false))) { bool addSide = true; if ((x == CHUNK_SIZE - 1)) { Chunk* pChunk = m_pChunkManager->GetChunk(m_gridX + 1, m_gridY, m_gridZ); if (pChunk == NULL || pChunk->IsSetup()) { addSide = pChunk != NULL && (pChunk->GetActive(0, y, z) == false); } } if (addSide) { int endX = (z / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; int endY = (y / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; if (m_pChunkManager->GetFaceMerging()) { UpdateMergedSide(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE, &p5, &p2, &p3, &p8, z, y, endX, endY, true, false, true, false); } n1 = vec3(1.0f, 0.0f, 0.0f); v1 = m_pRenderer->AddVertexToMesh(p2, n1, r, g, b, a, m_pMesh); t1 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 0.0f, m_pMesh); v2 = m_pRenderer->AddVertexToMesh(p5, n1, r, g, b, a, m_pMesh); t2 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 0.0f, m_pMesh); v3 = m_pRenderer->AddVertexToMesh(p8, n1, r, g, b, a, m_pMesh); t3 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 1.0f, m_pMesh); v4 = m_pRenderer->AddVertexToMesh(p3, n1, r, g, b, a, m_pMesh); t4 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 1.0f, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v2, v3, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v3, v4, m_pMesh); } } p1 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p2 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p3 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p4 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p5 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p6 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p7 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p8 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); // Left if (doXNegative && ((x == 0) || (x > 0 && GetActive(x - 1, y, z) == false))) { bool addSide = true; if ((x == 0)) { Chunk* pChunk = m_pChunkManager->GetChunk(m_gridX - 1, m_gridY, m_gridZ); if (pChunk == NULL || pChunk->IsSetup()) { addSide = pChunk != NULL && (pChunk->GetActive(CHUNK_SIZE - 1, y, z) == false); } } if (addSide) { int endX = (z / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; int endY = (y / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; if (m_pChunkManager->GetFaceMerging()) { UpdateMergedSide(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE, &p6, &p1, &p4, &p7, z, y, endX, endY, false, false, true, false); } n1 = vec3(-1.0f, 0.0f, 0.0f); v1 = m_pRenderer->AddVertexToMesh(p6, n1, r, g, b, a, m_pMesh); t1 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 0.0f, m_pMesh); v2 = m_pRenderer->AddVertexToMesh(p1, n1, r, g, b, a, m_pMesh); t2 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 0.0f, m_pMesh); v3 = m_pRenderer->AddVertexToMesh(p4, n1, r, g, b, a, m_pMesh); t3 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 1.0f, m_pMesh); v4 = m_pRenderer->AddVertexToMesh(p7, n1, r, g, b, a, m_pMesh); t4 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 1.0f, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v2, v3, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v3, v4, m_pMesh); } } p1 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p2 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p3 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p4 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p5 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p6 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p7 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p8 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); // Top if (doYPositive && ((y == CHUNK_SIZE - 1) || (y < CHUNK_SIZE - 1 && GetActive(x, y + 1, z) == false))) { bool addSide = true; if ((y == CHUNK_SIZE - 1)) { Chunk* pChunk = m_pChunkManager->GetChunk(m_gridX, m_gridY + 1, m_gridZ); if (pChunk == NULL || pChunk->IsSetup()) { addSide = pChunk != NULL && (pChunk->GetActive(x, 0, z) == false); } } if (addSide) { int endX = (x / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; int endY = (z / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; if (m_pChunkManager->GetFaceMerging()) { UpdateMergedSide(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE, &p7, &p8, &p3, &p4, x, z, endX, endY, true, false, false, true); } n1 = vec3(0.0f, 1.0f, 0.0f); v1 = m_pRenderer->AddVertexToMesh(p4, n1, r, g, b, a, m_pMesh); t1 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 0.0f, m_pMesh); v2 = m_pRenderer->AddVertexToMesh(p3, n1, r, g, b, a, m_pMesh); t2 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 0.0f, m_pMesh); v3 = m_pRenderer->AddVertexToMesh(p8, n1, r, g, b, a, m_pMesh); t3 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 1.0f, m_pMesh); v4 = m_pRenderer->AddVertexToMesh(p7, n1, r, g, b, a, m_pMesh); t4 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 1.0f, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v2, v3, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v3, v4, m_pMesh); } } p1 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p2 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p3 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p4 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); p5 = vec3(x + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p6 = vec3(x - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p7 = vec3(x - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); p8 = vec3(x + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); // Bottom if (doYNegative && ((y == 0) || (y > 0 && GetActive(x, y - 1, z) == false))) { bool addSide = true; if ((y == 0)) { Chunk* pChunk = m_pChunkManager->GetChunk(m_gridX, m_gridY - 1, m_gridZ); if (pChunk == NULL || pChunk->IsSetup()) { addSide = pChunk != NULL && (pChunk->GetActive(x, CHUNK_SIZE - 1, z) == false); } } if (addSide) { int endX = (x / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; int endY = (z / CHUNK_SIZE) * CHUNK_SIZE + CHUNK_SIZE; if (m_pChunkManager->GetFaceMerging()) { UpdateMergedSide(l_merged, x, y, z, CHUNK_SIZE, CHUNK_SIZE, &p6, &p5, &p2, &p1, x, z, endX, endY, false, false, false, true); } n1 = vec3(0.0f, -1.0f, 0.0f); v1 = m_pRenderer->AddVertexToMesh(p6, n1, r, g, b, a, m_pMesh); t1 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 0.0f, m_pMesh); v2 = m_pRenderer->AddVertexToMesh(p5, n1, r, g, b, a, m_pMesh); t2 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 0.0f, m_pMesh); v3 = m_pRenderer->AddVertexToMesh(p2, n1, r, g, b, a, m_pMesh); t3 = m_pRenderer->AddTextureCoordinatesToMesh(1.0f, 1.0f, m_pMesh); v4 = m_pRenderer->AddVertexToMesh(p1, n1, r, g, b, a, m_pMesh); t4 = m_pRenderer->AddTextureCoordinatesToMesh(0.0f, 1.0f, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v2, v3, m_pMesh); m_pRenderer->AddTriangleToMesh(v1, v3, v4, m_pMesh); } } } } } } // Delete the merged array delete l_merged; }
void test_RT() { typedef RT Cls; // _test_cls_regular_3( Cls() ); typedef traits::Bare_point Point; typedef traits::Weighted_point Weighted_point; typedef typename Cls::Vertex_handle Vertex_handle; typedef typename Cls::Cell_handle Cell_handle; typedef typename Cls::Facet Facet; typedef typename Cls::Edge Edge; typedef std::list<Weighted_point> list_point; typedef typename Cls::Finite_cells_iterator Finite_cells_iterator; // temporary version int n, m; int count = 0; // For dimension 0, we need to check that the point of highest weight is the // one that finally ends up in the vertex. std::cout << " test dimension 0 " << std::endl; Cls T0; T0.insert(Weighted_point( Point (0,0,0), 0) ); T0.insert(Weighted_point( Point (0,0,0), 1) ); T0.insert(Weighted_point( Point (0,0,0), -1) ); assert(T0.dimension() == 0); assert(T0.number_of_vertices() == 1); assert(T0.finite_vertices_begin()->point().weight() == 1); std::cout << " test dimension 1 " << std::endl; Cls T1; std::cout << " number of inserted points : " ; Weighted_point p[5]; for ( m=0; m<5; m++) { if ( (m%2)== 0 ) p[m] = Weighted_point( Point( 2*m,0,0 ), 2 ); else p[m] = Weighted_point( Point( -2*m+1,0,0 ), 2 ); T1.insert( p[m] ); count++; if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } assert( T1.is_valid() ); std::cout << std::endl << " number of vertices : " << T1.number_of_vertices() << std::endl; std::cout << " number of inserted points : " ; Weighted_point q[5]; for ( m=0; m<5; m++) { if ( (m%2)== 0 ) q[m] = Weighted_point( Point( 2*m+1,0,0 ), 5 ); else q[m] = Weighted_point( Point( -2*m+1,0,0 ), 5 ); T1.insert( q[m] ); count++; if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } assert( T1.is_valid() ); std::cout << std::endl << " number of vertices : " << T1.number_of_vertices() << std::endl; std::cout << " number of inserted points : " ; Weighted_point r[10]; for ( m=0; m<10; m++) { if ( (m%2)== 0 ) r[m] = Weighted_point( Point( m,0,0 ), 1 ); else r[m] = Weighted_point( Point( -m,0,0 ), 1 ); T1.insert( r[m] ); count++; if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } assert( T1.is_valid() ); std::cout << std::endl << " number of vertices : " << T1.number_of_vertices() << std::endl; assert( T1.dimension()==1 ); // The following is distilled from a bug report by Wulue Zhao // ([email protected]), a student of Tamal Dey. Point pt0(0,0,0); Point pt1( 1,0,0), pt2(2,0,0), pt3(3,0,0); Point pt4(-1,0,0), pt5(-2,0,0), pt6(-3,0,0); Weighted_point wp0(pt0,10.0); Weighted_point wp1(pt1,0.0), wp2(pt2,0.0), wp3(pt3,0.0); Weighted_point wp4(pt4,0.0), wp5(pt5,0.0), wp6(pt6,0.0); Cls T11; T11.insert(wp0); T11.insert(wp1); T11.insert(wp2); T11.insert(wp3); T11.insert(wp4); T11.insert(wp5); T11.insert(wp6); assert(T11.is_valid()); // And another distilled bug report from the same guy. { Point p1(-0.07, 0.04, 0.04); Point p2(0.09, 0.04, 0.04); Point p3(0.09, -0.05, 0.04); Point p4(0.05, -0.05, 0.04); Point p5(0.05, 0.0, 0.04); Point p6(-0.07, 0.0, 0.04); Point p7(-0.07, 0.04, -0.04); Point p8(0.09, 0.04, -0.04); Point p9(0.09, -0.05, -0.04); Point p10(0.05, -0.05, -0.04); Point p11(0.05, 0.0, -0.04); Point p12(-0.07, 0.0, -0.04); Weighted_point wp1(p1,0); Weighted_point wp2(p2,0); Weighted_point wp3(p3,0); Weighted_point wp4(p4,0); Weighted_point wp5(p5,0); Weighted_point wp6(p6,0); Weighted_point wp7(p7,0); Weighted_point wp8(p8,0); Weighted_point wp9(p9,0); Weighted_point wp10(p10,0); Weighted_point wp11(p11,0); Weighted_point wp12(p12,0); Weighted_point wp13(p3,0.3); // wp13 has the same coordinates with wp3 Cls T111; T111.insert(wp1); T111.insert(wp2); T111.insert(wp3); T111.insert(wp13); // it doesnot work inserting wp13 here T111.insert(wp4); T111.insert(wp5); T111.insert(wp6); T111.insert(wp7); T111.insert(wp8); T111.insert(wp9); T111.insert(wp10); T111.insert(wp11); T111.insert(wp12); assert(T111.is_valid()); } std::cout << " test dimension 2 " << std::endl; std::cout << " number of inserted points : " ; Cls T2; count = 0 ; int px=1, py=1; int qx=-1, qy=2; Weighted_point s[400]; for (m=0; m<10; m++) for (n=0; n<10; n++) { s[m+20*n] = Weighted_point( Point(m*px+n*qx, m*py+n*qy, 0), 1 ); T2.insert( s[m+20*n] ); count++; if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } for (m=10; m<20; m++) for (n=0; n<10; n++) { s[m+20*n] = Weighted_point( Point(m*px+n*qx, m*py+n*qy, 0), -1 ); T2.insert( s[m+20*n] ); count++; if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } for (m=0; m<10; m++) for (n=10; n<20; n++) { s[m+20*n] = Weighted_point( Point(m*px+n*qx, m*py+n*qy, 0), -2 ); T2.insert( s[m+20*n] ); count++; if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } for (m=10; m<20; m++) for (n=10; n<20; n++) { s[m+20*n] = Weighted_point( Point(m*px+n*qx, m*py+n*qy, 0), 5 ); T2.insert( s[m+20*n] ); count++; if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else std::cout << count << '\b' << '\b' << '\b' ; std::cout.flush(); } std::cout << std::endl << " number of vertices : " << T2.number_of_vertices() << std::endl; assert( T2.dimension()==2 ); assert( T2.is_valid() ); // dimension 3 std::cout << " test dimension 3" << std::endl; Cls T; list_point lp; int a, b, d; for (a=0;a!=10;a++) // for (b=0;b!=10;b++) for (b=0;b!=5;b++) // for (d=0;d!=10;d++) for (d=0;d!=5;d++) lp.push_back(Weighted_point( Point(a*b-d*a + (a-b)*10 +a , a-b+d +5*b, a*a-d*d+b), a*b-a*d) ); list_point::iterator it; count = 0 ; std::cout << " number of inserted points : " ; for (it=lp.begin(); it!=lp.end(); ++it){ count++; T.insert(*it); if (count <10) std::cout << count << '\b' ; else if (count < 100) std::cout << count << '\b' << '\b' ; else if (count < 1000) std::cout << count << '\b' << '\b' << '\b' ; else std::cout << count << std::endl; std::cout.flush(); } std::cout << std::endl; std::cout << " number of vertices : " << T.number_of_vertices() << std::endl; assert(T.is_valid()); assert(T.dimension()==3); T.clear(); std::cout << " test iterator range insert" << std::endl; T.insert (lp.begin(), lp.end()); std::cout << " number of vertices : " << T.number_of_vertices() << std::endl; assert(T.is_valid()); assert(T.dimension()==3); //test nearest_power_vertex std::cout << " test nearest_power_vertex " << std::endl; Point pp1(0.0, 0.0, 0.0); Point pp2(1.0, 0.0, 0.0); Point pp3(0.0, 1.0, 0.0); Point pp4(0.0, 0.0, 1.0); Point pp5(1.0, 1.0, 0.0); Point pp6(0.0, 1.0, 1.0); Point pp7(1.0, 0.0, 1.0); Point pp8(1.0, 1.0, 1.0); Weighted_point wpp1(pp1, 1.0); Weighted_point wpp2(pp2, 2.0); Weighted_point wpp3(pp3, 1.0); Weighted_point wpp4(pp4, 4.0); Weighted_point wpp5(pp5, 1.0); Weighted_point wpp6(pp6, 1.0); Weighted_point wpp7(pp7, 1.0); Weighted_point wpp8(pp8, 8.0); Cls T3; T3.insert(wpp1); Vertex_handle v2 = T3.insert(wpp2); assert( T3.nearest_power_vertex(Point(0.5,0.5,0.5)) == v2); T3.insert(wpp3); Vertex_handle v4 = T3.insert(wpp4); assert( T3.nearest_power_vertex(Point(0.5,0.5,0.5)) == v4); T3.insert(wpp5); T3.insert(wpp6); T3.insert(wpp7); // Avoid inserting the same point twice, now that hidden points are handled, // insert (existing_point) returns Vertex_handle(). // T3.insert(wpp8); Vertex_handle v8 = T3.insert(wpp8); Point query(0.5,0.5,0.5); assert(T3.nearest_power_vertex(query) == v8); assert(T3.nearest_power_vertex(Weighted_point(query,1.0)) == v8 ); assert(T3.nearest_power_vertex_in_cell(query ,v8->cell()) == v8); // test dual std::cout << " test dual member functions" << std::endl; Finite_cells_iterator fcit = T3.finite_cells_begin(); for( ; fcit != T3.finite_cells_end(); ++fcit) { Point cc = T3.dual(fcit); Vertex_handle ncc = T3.nearest_power_vertex(cc); assert(fcit->has_vertex(ncc)); } // test Gabriel std::cout << " test is_Gabriel " << std::endl; Point q0(0.,0.,0.); Point q1(2.,0.,0.); Point q2(0.,2.,0.); Point q3(0.,0.,2.); Weighted_point wq0(q0,0.); Weighted_point wq1(q1,0.); Weighted_point wq2(q2,0.); Weighted_point wq3(q3,0.); Weighted_point wq01(q0,2.); Cls T4; Vertex_handle v0 = T4.insert(wq0); Vertex_handle v1 = T4.insert(wq1); v2 = T4.insert(wq2); Vertex_handle v3 = T4.insert(wq3); Cell_handle c; int i,j,k,l; assert(T4.is_facet(v0,v1,v2,c,j,k,l)); i = 6 - (j+k+l); Facet f = std::make_pair(c,i); assert(T4.is_Gabriel(c,i)); assert(T4.is_Gabriel(f)); assert(T4.is_facet(v1,v2,v3,c,j,k,l)); i = 6 - (j+k+l); assert(!T4.is_Gabriel(c,i)); assert(T4.is_edge(v0,v1,c,i,j)); assert(T4.is_Gabriel(c,i,j)); Edge e = make_triple(c,i,j); assert(T4.is_Gabriel(e)); assert(T4.is_edge(v2,v3,c,i,j)); assert(T4.is_Gabriel(c,i,j)); Vertex_handle v01 = T4.insert(wq01); (void) v01; // kill warning assert(T4.is_edge(v2,v3,c,i,j)); assert(!T4.is_Gabriel(c,i,j)); Weighted_point wwq0(q0,0.); Weighted_point wwq1(q1,0.); Weighted_point wwq2(q2,0.); Weighted_point wwq3(q3,5.); Cls T5; v0 = T5.insert(wwq0); v1 = T5.insert(wwq1); v2 = T5.insert(wwq2); v3 = T5.insert(wwq3); assert(T5.nearest_power_vertex(v3->point().point()) == v3); assert(T5.nearest_power_vertex(v0->point().point()) == v3); assert(T5.is_Gabriel(v3)); assert(!T5.is_Gabriel(v0)); }
void boot_main() { list_entry *entry; hdd_inf *hdd; prt_inf *prt, *active; char *error; int login, i; int n_mount; active = NULL; error = NULL; login = 0; n_mount = 0; /* init crypto */ dc_init_crypto(conf.options & OP_HW_CRYPTO); /* prepare MBR copy buffer */ autocpy(conf.save_mbr + 432, p8(0x7C00) + 432, 80); if (dc_scan_partitions() == 0) { error = "partitions not found\n"; goto error; } if (hdd = find_hdd(boot_dsk)) { /* find active partition on boot disk */ entry = hdd->part_head.flink; while (entry != &hdd->part_head) { prt = contain_record(entry, prt_inf, entry_hdd); entry = entry->flink; if (prt->active != 0) { active = prt; break; } } } retry_auth:; if (conf.logon_type & LT_GET_PASS) { login = dc_get_password(); if ( (conf.options & OP_NOPASS_ERROR) && (login == 0) ) { dc_password_error(active); if (conf.error_type & ET_RETRY) { goto retry_auth; } else { /* halt system */ __halt(); } } } /* add embedded keyfile to password buffer */ if (conf.logon_type & LT_EMBED_KEY) { sha512_ctx sha; u8 hash[SHA512_DIGEST_SIZE]; sha512_init(&sha); sha512_hash(&sha, conf.emb_key, sizeof(conf.emb_key)); sha512_done(&sha, hash); /* mix the keyfile hash and password */ for (i = 0; i < (SHA512_DIGEST_SIZE / sizeof(u32)); i++) { p32(bd_dat->password.pass)[i] += p32(hash)[i]; } bd_dat->password.size = max(bd_dat->password.size, SHA512_DIGEST_SIZE); /* prevent leaks */ zeroauto(hash, sizeof(hash)); zeroauto(&sha, sizeof(sha)); } if (bd_dat->password.size != 0) { if (n_mount = dc_mount_parts()) { /* hook BIOS interrupts */ bios_hook_ints(); } else { /* clean password buffer to prevent leaks */ zeroauto(&bd_dat->password, sizeof(dc_pass)); } } if ( (n_mount == 0) && (login != 0) ) { dc_password_error(active); if (conf.error_type & ET_RETRY) { goto retry_auth; } else { /* halt system */ __halt(); } } switch (conf.boot_type) { case BT_MBR_BOOT: { if (hdd == NULL) { error = "boot disk not found\n"; goto error; } boot_from_mbr(hdd, n_mount); } break; case BT_MBR_FIRST: { if ( (hdd = find_bootable_hdd()) == NULL ) { error = "boot disk not found\n"; goto error; } boot_from_mbr(hdd, n_mount); } break; case BT_ACTIVE: { if (active == NULL) { error = "active partition not found\n"; goto error; } else { boot_from_partition(active, n_mount); } } break; case BT_AP_PASSWORD: { /* find first partition with appropriate password */ entry = prt_head.flink; while (entry != &prt_head) { prt = contain_record(entry, prt_inf, entry_glb); entry = entry->flink; if ( (prt->extend == 0) && (prt->mnt_ok != 0) ) { boot_from_partition(prt, n_mount); } } error = "bootable partition not mounted\n"; goto error; } break; case BT_DISK_ID: { /* find partition by disk_id */ entry = prt_head.flink; while (entry != &prt_head) { prt = contain_record(entry, prt_inf, entry_glb); entry = entry->flink; if ( (prt->extend == 0) && (prt->mnt_ok != 0) && (prt->disk_id == conf.disk_id) ) { boot_from_partition(prt, n_mount); } } error = "disk_id equal partition not found\n"; goto error; } break; } error:; if (error != NULL) { puts(error); } while (1); }
void BlockType::drawBlock(TriangleCollector *collector, const Block &block) const { collector->setCurrentBlock(block); int type = block.getType(); if (blockTypeSpec[type].type == Type_Cube) { const Tile &tile = blockTypeSpec[type].tile; /* |y * | * 1----------2 * /| /| * / | / | * / | / | * 3---+------4 | * | 5------+---6------x * | / | / * | / | / * |/ |/ * 7----------8 * / * /z */ float3 p1(0, 1, 0); float3 p2(1, 1, 0); float3 p3(0, 1, 1); float3 p4(1, 1, 1); float3 p5(0, 0, 0); float3 p6(1, 0, 0); float3 p7(0, 0, 1); float3 p8(1, 0, 1); Block b[3][3][3]; for (int x = -1; x <= 1; x++) for (int y = -1; y <= 1; y++) for (int z = -1; z <= 1; z++) b[x + 1][y + 1][z + 1] = block.getNeighbour(x, y, z); drawFace(collector, tile, p4, p2, p8, p6, b[2][2][2], b[2][2][1], b[2][2][0], b[2][1][2], b[2][1][1], b[2][1][0], b[2][0][2], b[2][0][1], b[2][0][0], float3(1, 0, 0)); drawFace(collector, tile, p1, p3, p5, p7, b[0][2][0], b[0][2][1], b[0][2][2], b[0][1][0], b[0][1][1], b[0][1][2], b[0][0][0], b[0][0][1], b[0][0][2], float3(-1, 0, 0)); drawFace(collector, tile, p1, p2, p3, p4, b[0][2][0], b[1][2][0], b[2][2][0], b[0][2][1], b[1][2][1], b[2][2][1], b[0][2][2], b[1][2][2], b[2][2][2], float3(0, 1, 0)); drawFace(collector, tile, p7, p8, p5, p6, b[0][0][2], b[1][0][2], b[2][0][2], b[0][0][1], b[1][0][1], b[2][0][1], b[0][0][0], b[1][0][0], b[2][0][0], float3(0, -1, 0)); drawFace(collector, tile, p3, p4, p7, p8, b[0][2][2], b[1][2][2], b[2][2][2], b[0][1][2], b[1][1][2], b[2][1][2], b[0][0][2], b[1][0][2], b[2][0][2], float3(0, 0, 1)); drawFace(collector, tile, p2, p1, p6, p5, b[2][2][0], b[1][2][0], b[0][2][0], b[2][1][0], b[1][1][0], b[0][1][0], b[2][0][0], b[1][0][0], b[0][0][0], float3(0, 0, -1)); } }
int CIFSsession(Session *s) { char os[64], *q; Rune r; Pkt *p; enum { mycaps = CAP_UNICODE | CAP_LARGE_FILES | CAP_NT_SMBS | CAP_NT_FIND | CAP_STATUS32, }; s->seqrun = 1; /* activate the sequence number generation/checking */ p = cifshdr(s, nil, SMB_COM_SESSION_SETUP_ANDX); p8(p, 0xFF); /* No secondary command */ p8(p, 0); /* Reserved (must be zero) */ pl16(p, 0); /* Offset to next command */ pl16(p, MTU); /* my max buffer size */ pl16(p, 1); /* my max multiplexed pending requests */ pl16(p, 0); /* Virtual connection # */ pl32(p, 0); /* Session key (if vc != 0) */ if((s->secmode & SECMODE_PW_ENCRYPT) == 0) { pl16(p, utflen(Sess->auth->resp[0])*2 + 2); /* passwd size */ pl16(p, utflen(Sess->auth->resp[0])*2 + 2); /* passwd size (UPPER CASE) */ pl32(p, 0); /* Reserved */ pl32(p, mycaps); pbytes(p); for(q = Sess->auth->resp[0]; *q; ){ q += chartorune(&r, q); pl16(p, toupperrune(r)); } pl16(p, 0); for(q = Sess->auth->resp[0]; *q; ){ q += chartorune(&r, q); pl16(p, r); } pl16(p, 0); }else{ pl16(p, Sess->auth->len[0]); /* LM passwd size */ pl16(p, Sess->auth->len[1]); /* NTLM passwd size */ pl32(p, 0); /* Reserved */ pl32(p, mycaps); pbytes(p); pmem(p, Sess->auth->resp[0], Sess->auth->len[0]); pmem(p, Sess->auth->resp[1], Sess->auth->len[1]); } pstr(p, Sess->auth->user); /* Account name */ pstr(p, Sess->auth->windom); /* Primary domain */ pstr(p, "plan9"); /* Client OS */ pstr(p, argv0); /* Client LAN Manager type */ if(cifsrpc(p) == -1){ free(p); return -1; } g8(p); /* Reserved (0) */ gl16(p); /* Offset to next command wordcount */ Sess->isguest = gl16(p) & 1; /* logged in as guest */ gl16(p); gl16(p); /* no security blob here - we don't understand extended security anyway */ gstr(p, os, sizeof os); s->remos = estrdup9p(os); free(p); return 0; }
void BGcubeD_D::BGdraw() { glPushMatrix(); const dReal* pos = dGeomGetPosition(boxGeom_m); glColor3f(r_m/255, g_m/255, b_m/255); tex1.activate(); // THIS IS WHERE THE DRAWING HAPPENS! // The front face :) glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1); p5(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1); p8(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0); p7(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0); p6(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Right face tex2.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1);p8(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1);p4(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0);p3(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0);p7(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Left face tex3.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1);p5(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1);p6(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0);p2(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0);p1(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Top face tex4.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1);p6(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1);p7(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0);p3(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0);p2(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Bottom face tex5.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1); p4(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1); p8(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0); p5(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0); p1(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. // Back face tex6.activate(); glBegin(GL_QUADS); // All OpenGL drawing begins with a glBegin. glTexCoord2f(0, 1); p1(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 1); p2(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(1, 0); p3(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glTexCoord2f(0, 0); p4(pos[0],pos[1],pos[2],h_m,w_m,d_m,r_m,g_m,b_m); glEnd(); // All OpenGL drawing ends with a glEnd. glPopMatrix(); }
bool test(bool is_kernel_exact = true) { // types typedef typename K::FT FT; typedef typename K::Line_3 Line; typedef typename K::Point_3 Point; typedef typename K::Segment_3 Segment; typedef typename K::Ray_3 Ray; typedef typename K::Line_3 Line; typedef typename K::Triangle_3 Triangle; /* ------------------------------------- // Test data is something like that (in t supporting plane) // Triangle is (p1,p2,p3) // // +E +1 // / \ // +C 6+ +8 +4 +B // / 9++7 \ // 3+-------+5--+2 // // +F +A ------------------------------------- */ Point p1(FT(1.), FT(0.), FT(0.)); Point p2(FT(0.), FT(1.), FT(0.)); Point p3(FT(0.), FT(0.), FT(1.)); Triangle t(p1,p2,p3); // Edges of t Segment s12(p1,p2); Segment s21(p2,p1); Segment s13(p1,p3); Segment s23(p2,p3); Segment s32(p3,p2); Segment s31(p3,p1); bool b = test_aux(is_kernel_exact,t,s12,"t-s12",s12); b &= test_aux(is_kernel_exact,t,s21,"t-s21",s21); b &= test_aux(is_kernel_exact,t,s13,"t-s13",s13); b &= test_aux(is_kernel_exact,t,s23,"t-s23",s23); // Inside points Point p4(FT(0.5), FT(0.5), FT(0.)); Point p5(FT(0.), FT(0.75), FT(0.25)); Point p6(FT(0.5), FT(0.), FT(0.5)); Point p7(FT(0.25), FT(0.625), FT(0.125)); Point p8(FT(0.5), FT(0.25), FT(0.25)); Segment s14(p1,p4); Segment s41(p4,p1); Segment s24(p2,p4); Segment s42(p4,p2); Segment s15(p1,p5); Segment s25(p2,p5); Segment s34(p3,p4); Segment s35(p3,p5); Segment s36(p3,p6); Segment s45(p4,p5); Segment s16(p1,p6); Segment s26(p2,p6); Segment s62(p6,p2); Segment s46(p4,p6); Segment s48(p4,p8); Segment s56(p5,p6); Segment s65(p6,p5); Segment s64(p6,p4); Segment s17(p1,p7); Segment s67(p6,p7); Segment s68(p6,p8); Segment s86(p8,p6); Segment s78(p7,p8); Segment s87(p8,p7); b &= test_aux(is_kernel_exact,t,s14,"t-s14",s14); b &= test_aux(is_kernel_exact,t,s41,"t-s41",s41); b &= test_aux(is_kernel_exact,t,s24,"t-s24",s24); b &= test_aux(is_kernel_exact,t,s42,"t-s42",s42); b &= test_aux(is_kernel_exact,t,s15,"t-s15",s15); b &= test_aux(is_kernel_exact,t,s25,"t-s25",s25); b &= test_aux(is_kernel_exact,t,s34,"t-s34",s34); b &= test_aux(is_kernel_exact,t,s35,"t-s35",s35); b &= test_aux(is_kernel_exact,t,s36,"t-s36",s36); b &= test_aux(is_kernel_exact,t,s45,"t-s45",s45); b &= test_aux(is_kernel_exact,t,s16,"t-s16",s16); b &= test_aux(is_kernel_exact,t,s26,"t-s26",s26); b &= test_aux(is_kernel_exact,t,s62,"t-s62",s62); b &= test_aux(is_kernel_exact,t,s46,"t-s46",s46); b &= test_aux(is_kernel_exact,t,s65,"t-s65",s65); b &= test_aux(is_kernel_exact,t,s64,"t-s64",s64); b &= test_aux(is_kernel_exact,t,s48,"t-s48",s48); b &= test_aux(is_kernel_exact,t,s56,"t-s56",s56); b &= test_aux(is_kernel_exact,t,s17,"t-t17",s17); b &= test_aux(is_kernel_exact,t,s67,"t-t67",s67); b &= test_aux(is_kernel_exact,t,s68,"t-s68",s68); b &= test_aux(is_kernel_exact,t,s86,"t-s86",s86); b &= test_aux(is_kernel_exact,t,s78,"t-t78",s78); b &= test_aux(is_kernel_exact,t,s87,"t-t87",s87); // Outside points (in triangle plane) Point pA(FT(-0.5), FT(1.), FT(0.5)); Point pB(FT(0.5), FT(1.), FT(-0.5)); Point pC(FT(0.5), FT(-0.5), FT(1.)); Point pE(FT(1.), FT(-1.), FT(1.)); Point pF(FT(-1.), FT(0.), FT(2.)); Segment sAB(pA,pB); Segment sBC(pB,pC); Segment s2E(p2,pE); Segment sE2(pE,p2); Segment s2A(p2,pA); Segment s6E(p6,pE); Segment sB8(pB,p8); Segment sC8(pC,p8); Segment s8C(p8,pC); Segment s1F(p1,pF); Segment sF6(pF,p6); b &= test_aux(is_kernel_exact,t,sAB,"t-sAB",p2); b &= test_aux(is_kernel_exact,t,sBC,"t-sBC",s46); b &= test_aux(is_kernel_exact,t,s2E,"t-s2E",s26); b &= test_aux(is_kernel_exact,t,sE2,"t-sE2",s62); b &= test_aux(is_kernel_exact,t,s2A,"t-s2A",p2); b &= test_aux(is_kernel_exact,t,s6E,"t-s6E",p6); b &= test_aux(is_kernel_exact,t,sB8,"t-sB8",s48); b &= test_aux(is_kernel_exact,t,sC8,"t-sC8",s68); b &= test_aux(is_kernel_exact,t,s8C,"t-s8C",s86); b &= test_aux(is_kernel_exact,t,s1F,"t-s1F",s13); b &= test_aux(is_kernel_exact,t,sF6,"t-sF6",s36); // Outside triangle plane Point pa(FT(0.), FT(0.), FT(0.)); Point pb(FT(2.), FT(0.), FT(0.)); Point pc(FT(1.), FT(0.), FT(1.)); Point pe(FT(1.), FT(0.5), FT(0.5)); Segment sab(pa,pb); Segment sac(pa,pc); Segment sae(pa,pe); Segment sa8(pa,p8); Segment sb2(pb,p2); b &= test_aux(is_kernel_exact,t,sab,"t-sab",p1); b &= test_aux(is_kernel_exact,t,sac,"t-sac",p6); b &= test_aux(is_kernel_exact,t,sae,"t-sae",p8); b &= test_aux(is_kernel_exact,t,sa8,"t-sa8",p8); b &= test_aux(is_kernel_exact,t,sb2,"t-sb2",p2); // ----------------------------------- // ray queries // ----------------------------------- // Edges of t Ray r12(p1,p2); Ray r21(p2,p1); Ray r13(p1,p3); Ray r23(p2,p3); b &= test_aux(is_kernel_exact,t,r12,"t-r12",s12); b &= test_aux(is_kernel_exact,t,r21,"t-r21",s21); b &= test_aux(is_kernel_exact,t,r13,"t-r13",s13); b &= test_aux(is_kernel_exact,t,r23,"t-r23",s23); // In triangle Point p9_(FT(0.), FT(0.5), FT(0.5)); Point p9(FT(0.25), FT(0.375), FT(0.375)); Ray r14(p1,p4); Ray r41(p4,p1); Ray r24(p2,p4); Ray r42(p4,p2); Ray r15(p1,p5); Ray r25(p2,p5); Ray r34(p3,p4); Ray r35(p3,p5); Ray r36(p3,p6); Ray r45(p4,p5); Ray r16(p1,p6); Ray r26(p2,p6); Ray r62(p6,p2); Ray r46(p4,p6); Ray r48(p4,p8); Ray r56(p5,p6); Ray r47(p4,p7); Ray r89(p8,p9); Ray r86(p8,p6); Ray r68(p6,p8); Segment r89_res(p8,p9_); b &= test_aux(is_kernel_exact,t,r14,"t-r14",s12); b &= test_aux(is_kernel_exact,t,r41,"t-r41",s41); b &= test_aux(is_kernel_exact,t,r24,"t-r24",s21); b &= test_aux(is_kernel_exact,t,r42,"t-r42",s42); b &= test_aux(is_kernel_exact,t,r15,"t-r15",s15); b &= test_aux(is_kernel_exact,t,r25,"t-r25",s23); b &= test_aux(is_kernel_exact,t,r34,"t-r34",s34); b &= test_aux(is_kernel_exact,t,r35,"t-r35",s32); b &= test_aux(is_kernel_exact,t,r36,"t-r36",s31); b &= test_aux(is_kernel_exact,t,r45,"t-r45",s45); b &= test_aux(is_kernel_exact,t,r16,"t-r16",s13); b &= test_aux(is_kernel_exact,t,r26,"t-r26",s26); b &= test_aux(is_kernel_exact,t,r62,"t-r62",s62); b &= test_aux(is_kernel_exact,t,r46,"t-r46",s46); b &= test_aux(is_kernel_exact,t,r48,"t-r48",s46); b &= test_aux(is_kernel_exact,t,r56,"t-r56",s56); b &= test_aux(is_kernel_exact,t,r47,"t-r47",s45); b &= test_aux(is_kernel_exact,t,r89,"t-t89",r89_res); b &= test_aux(is_kernel_exact,t,r68,"t-r68",s64); b &= test_aux(is_kernel_exact,t,r86,"t-r86",s86); // Outside points (in triangre prane) Ray rAB(pA,pB); Ray rBC(pB,pC); Ray r2E(p2,pE); Ray rE2(pE,p2); Ray r2A(p2,pA); Ray r6E(p6,pE); Ray rB8(pB,p8); Ray rC8(pC,p8); Ray r8C(p8,pC); Ray r1F(p1,pF); Ray rF6(pF,p6); b &= test_aux(is_kernel_exact,t,rAB,"t-rAB",p2); b &= test_aux(is_kernel_exact,t,rBC,"t-rBC",s46); b &= test_aux(is_kernel_exact,t,r2E,"t-r2E",s26); b &= test_aux(is_kernel_exact,t,rE2,"t-rE2",s62); b &= test_aux(is_kernel_exact,t,r2A,"t-r2A",p2); b &= test_aux(is_kernel_exact,t,r6E,"t-r6E",p6); b &= test_aux(is_kernel_exact,t,rB8,"t-rB8",s46); b &= test_aux(is_kernel_exact,t,rC8,"t-rC8",s64); b &= test_aux(is_kernel_exact,t,r8C,"t-r8C",s86); b &= test_aux(is_kernel_exact,t,r1F,"t-r1F",s13); b &= test_aux(is_kernel_exact,t,rF6,"t-rF6",s31); // Outside triangle plane Ray rab(pa,pb); Ray rac(pa,pc); Ray rae(pa,pe); Ray ra8(pa,p8); Ray rb2(pb,p2); b &= test_aux(is_kernel_exact,t,rab,"t-rab",p1); b &= test_aux(is_kernel_exact,t,rac,"t-rac",p6); b &= test_aux(is_kernel_exact,t,rae,"t-rae",p8); b &= test_aux(is_kernel_exact,t,ra8,"t-ra8",p8); b &= test_aux(is_kernel_exact,t,rb2,"t-rb2",p2); // ----------------------------------- // Line queries // ----------------------------------- // Edges of t Line l12(p1,p2); Line l21(p2,p1); Line l13(p1,p3); Line l23(p2,p3); b &= test_aux(is_kernel_exact,t,l12,"t-l12",s12); b &= test_aux(is_kernel_exact,t,l21,"t-l21",s21); b &= test_aux(is_kernel_exact,t,l13,"t-l13",s13); b &= test_aux(is_kernel_exact,t,l23,"t-l23",s23); // In triangle Line l14(p1,p4); Line l41(p4,p1); Line l24(p2,p4); Line l42(p4,p2); Line l15(p1,p5); Line l25(p2,p5); Line l34(p3,p4); Line l35(p3,p5); Line l36(p3,p6); Line l45(p4,p5); Line l16(p1,p6); Line l26(p2,p6); Line l62(p6,p2); Line l46(p4,p6); Line l48(p4,p8); Line l56(p5,p6); Line l47(p4,p7); Line l89(p8,p9); Line l86(p8,p6); Line l68(p6,p8); Segment l89_res(p1,p9_); b &= test_aux(is_kernel_exact,t,l14,"t-l14",s12); b &= test_aux(is_kernel_exact,t,l41,"t-l41",s21); b &= test_aux(is_kernel_exact,t,l24,"t-l24",s21); b &= test_aux(is_kernel_exact,t,l42,"t-l42",s12); b &= test_aux(is_kernel_exact,t,l15,"t-l15",s15); b &= test_aux(is_kernel_exact,t,l25,"t-l25",s23); b &= test_aux(is_kernel_exact,t,l34,"t-l34",s34); b &= test_aux(is_kernel_exact,t,l35,"t-l35",s32); b &= test_aux(is_kernel_exact,t,l36,"t-l36",s31); b &= test_aux(is_kernel_exact,t,l45,"t-l45",s45); b &= test_aux(is_kernel_exact,t,l16,"t-l16",s13); b &= test_aux(is_kernel_exact,t,l26,"t-l26",s26); b &= test_aux(is_kernel_exact,t,l62,"t-l62",s62); b &= test_aux(is_kernel_exact,t,l46,"t-l46",s46); b &= test_aux(is_kernel_exact,t,l48,"t-l48",s46); b &= test_aux(is_kernel_exact,t,l56,"t-l56",s56); b &= test_aux(is_kernel_exact,t,l47,"t-l47",s45); b &= test_aux(is_kernel_exact,t,l89,"t-t89",l89_res); b &= test_aux(is_kernel_exact,t,l68,"t-l68",s64); b &= test_aux(is_kernel_exact,t,l86,"t-l86",s46); // Outside points (in triangle plane) Line lAB(pA,pB); Line lBC(pB,pC); Line l2E(p2,pE); Line lE2(pE,p2); Line l2A(p2,pA); Line l6E(p6,pE); Line lB8(pB,p8); Line lC8(pC,p8); Line l8C(p8,pC); Line l1F(p1,pF); Line lF6(pF,p6); b &= test_aux(is_kernel_exact,t,lAB,"t-lAB",p2); b &= test_aux(is_kernel_exact,t,lBC,"t-lBC",s46); b &= test_aux(is_kernel_exact,t,l2E,"t-l2E",s26); b &= test_aux(is_kernel_exact,t,lE2,"t-lE2",s62); b &= test_aux(is_kernel_exact,t,l2A,"t-l2A",p2); b &= test_aux(is_kernel_exact,t,l6E,"t-l6E",s26); b &= test_aux(is_kernel_exact,t,lB8,"t-lB8",s46); b &= test_aux(is_kernel_exact,t,lC8,"t-lC8",s64); b &= test_aux(is_kernel_exact,t,l8C,"t-l8C",s46); b &= test_aux(is_kernel_exact,t,l1F,"t-l1F",s13); b &= test_aux(is_kernel_exact,t,lF6,"t-lF6",s31); // Outside triangle plane Line lab(pa,pb); Line lac(pa,pc); Line lae(pa,pe); Line la8(pa,p8); Line lb2(pb,p2); b &= test_aux(is_kernel_exact,t,lab,"t-lab",p1); b &= test_aux(is_kernel_exact,t,lac,"t-lac",p6); b &= test_aux(is_kernel_exact,t,lae,"t-lae",p8); b &= test_aux(is_kernel_exact,t,la8,"t-la8",p8); b &= test_aux(is_kernel_exact,t,lb2,"t-lb2",p2); return b; }
/** @SYMTestCaseID SYSLIB-SQL-CT-1628 @SYMTestCaseDesc GetFirstSqlStmt() test Tests the GetFirstSqlStmt() behaviour with a set of various SQL statements. @SYMTestPriority High @SYMTestActions GetFirstSqlStmt() test @SYMTestExpectedResults Test must not fail @SYMREQ REQ5792 REQ5793 */ void TestGetFirstSqlStmt() { TPtrC res; TBuf<1> b2; b2.Append(TChar(0)); TPtr p2(PTR_ARG(b2)); res.Set(GetFirstSqlStmt(p2)); //Expected result: res = "\x0", p2 is NULL TEST(res == b2); TEST(!p2.Ptr()); TBuf<2> b3; b3.Append(TChar(' ')); b3.Append(TChar(0)); TPtr p3(PTR_ARG(b3)); res.Set(GetFirstSqlStmt(p3)); //Expected result: res = " \x0", p3 is NULL TEST(res == b3); TEST(!p3.Ptr()); TBuf<7> b4(_L(";; ; ")); b4.Append(TChar(0)); TPtr p4(PTR_ARG(b4)); res.Set(GetFirstSqlStmt(p4)); //Expected result: res = "\x0", p4 = "; ; \x0" TEST(res.Length() == 1 && (TInt)res[0] == 0); TInt accLen = res.Length(); TEST(p4 == b4.Right(b4.Length() - accLen)); res.Set(GetFirstSqlStmt(p4)); //Expected result: res = "\x0", p4 = " ; \x0" TEST(res.Length() == 1 && (TInt)res[0] == 0); accLen += res.Length(); TEST(p4 == b4.Right(b4.Length() - accLen)); res.Set(GetFirstSqlStmt(p4)); //Expected result: res = " \x0", p4 = " \x0" TEST((TInt)res[0] == (TInt)TChar(' ') && (TInt)res[1] == 0); accLen += res.Length(); TEST(p4 == b4.Right(b4.Length() - accLen)); res.Set(GetFirstSqlStmt(p4)); //Expected result: res = " \x0", p4 is NULL TEST((TInt)res[0] == (TInt)TChar(' ') && (TInt)res[1] == (TInt)TChar(' ') && (TInt)res[2] == 0); TEST(!p4.Ptr()); TBuf<20> b5(_L("SELECT * FROM A")); b5.Append(TChar(0)); TPtr p5(PTR_ARG(b5)); res.Set(GetFirstSqlStmt(p5)); //Expected result: res = "SELECT * FROM A\x0", p5 is NULL TEST(res == b5); TEST(!p5.Ptr()); TBuf<20> b6(_L("SELECT * FROM A;")); b6.Append(TChar(0)); TPtr p6(PTR_ARG(b6)); res.Set(GetFirstSqlStmt(p6)); //Expected result: res = "SELECT * FROM A\x0", p6 = "\x0" TEST(res == b6.Left(b6.Length() - 1)); TEST(p6.Length() == 1 && p6[0] == 0); TBuf<40> b7(_L("/** Comment */ SELECT * FROM A;")); b7.Append(TChar(0)); TPtr p7(PTR_ARG(b7)); res.Set(GetFirstSqlStmt(p7)); //Expected result: res = "/** Comment */ SELECT * FROM A\x0", p7 = "\x0" TEST(res == b7.Left(b7.Length() - 1)); TEST(p7.Length() == 1 && p7[0] == 0); TBuf<40> b8(_L(" SELECT * FROM --Comment \r\n A;")); b8.Append(TChar(0)); TPtr p8(PTR_ARG(b8)); res.Set(GetFirstSqlStmt(p8)); //Expected result: res = " SELECT * FROM --Comment \r\n A\x0", p8 = "\x0" TEST(res == b8.Left(b8.Length() - 1)); TEST(p8.Length() == 1 && p8[0] == 0); TBuf<40> b9(_L("SELECT * FROM A; SELECT * FROM B")); b9.Append(TChar(0)); TPtr p9(PTR_ARG(b9)); res.Set(GetFirstSqlStmt(p9)); //Expected result: res = "SELECT * FROM A\x0", p9 = " SELECT * FROM B\x0" TEST(res.Left(res.Length() - 1) == b9.Left(res.Length() - 1) && (TInt)res[res.Length() - 1] == 0); accLen = res.Length(); TEST(p9 == b9.Right(b9.Length() - accLen)); res.Set(GetFirstSqlStmt(p9)); //Expected result: res = " SELECT * FROM B\x0", p9 is NULL TEST(res == b9.Right(b9.Length() - accLen)); TEST(!p9.Ptr()); //Defect INC113060 TBuf<255> b10(_L("UPDATE Playlist SET Name=';',Time='2007-09-20 12:31:33' WHERE UniqueId=640397473")); TPtr p10(PTR_ARG(b10)); res.Set(GetFirstSqlStmt(p10)); //Expected results: res= original string TEST(res.Compare(b10)==0); TEST(!p10.Ptr()); TBuf<255> firstStmt(_L("SELECT * FROM PlayList"));firstStmt.Append(TChar(0)); TBuf<255> b11(_L("SELECT * FROM PlayList;UPDATE Playlist SET Name=';',Time='2007-09-20 12:31:33' WHERE UniqueId=640397473")); TPtr p11(PTR_ARG(b11)); res.Set(GetFirstSqlStmt(p11)); TEST(res.Compare(firstStmt)==0); TEST(p11.Compare(b10)==0); }
void update_mission_brief_point( interfaceItemType *dataItem, long whichBriefPoint, const Scenario* scenario, coordPointType *corner, long scale, Rect *bounds, vector<inlinePictType>& inlinePict, Rect& highlight_rect, vector<pair<Point, Point> >& lines, String& text) { if (whichBriefPoint < kMissionBriefPointOffset) { // No longer handled here. return; } whichBriefPoint -= kMissionBriefPointOffset; Rect hiliteBounds; long headerID, headerNumber, contentID; BriefPoint_Data_Get(whichBriefPoint, scenario, &headerID, &headerNumber, &contentID, &hiliteBounds, corner, scale, 16, 32, bounds); hiliteBounds.offset(bounds->left, bounds->top); // TODO(sfiera): catch exception. Resource rsrc("text", "txt", contentID); text.assign(macroman::decode(rsrc.data())); short textHeight = GetInterfaceTextHeightFromWidth(text, dataItem->style, kMissionDataWidth); if (hiliteBounds.left == hiliteBounds.right) { dataItem->bounds.left = (bounds->right - bounds->left) / 2 - (kMissionDataWidth / 2) + bounds->left; dataItem->bounds.right = dataItem->bounds.left + kMissionDataWidth; dataItem->bounds.top = (bounds->bottom - bounds->top) / 2 - (textHeight / 2) + bounds->top; dataItem->bounds.bottom = dataItem->bounds.top + textHeight; } else { if ((hiliteBounds.left + (hiliteBounds.right - hiliteBounds.left) / 2) > (bounds->left + (bounds->right - bounds->left) / 2)) { dataItem->bounds.right = hiliteBounds.left - kMissionDataHBuffer; dataItem->bounds.left = dataItem->bounds.right - kMissionDataWidth; } else { dataItem->bounds.left = hiliteBounds.right + kMissionDataHBuffer; dataItem->bounds.right = dataItem->bounds.left + kMissionDataWidth; } dataItem->bounds.top = hiliteBounds.top + (hiliteBounds.bottom - hiliteBounds.top) / 2 - textHeight / 2; dataItem->bounds.bottom = dataItem->bounds.top + textHeight; if (dataItem->bounds.top < (bounds->top + kMissionDataTopBuffer)) { dataItem->bounds.top = bounds->top + kMissionDataTopBuffer; dataItem->bounds.bottom = dataItem->bounds.top + textHeight; } if (dataItem->bounds.bottom > (bounds->bottom - kMissionDataBottomBuffer)) { dataItem->bounds.bottom = bounds->bottom - kMissionDataBottomBuffer; dataItem->bounds.top = dataItem->bounds.bottom - textHeight; } if (dataItem->bounds.left < (bounds->left + kMissionDataVBuffer)) { dataItem->bounds.left = bounds->left + kMissionDataVBuffer; dataItem->bounds.right = dataItem->bounds.left + kMissionDataWidth; } if (dataItem->bounds.right > (bounds->right - kMissionDataVBuffer)) { dataItem->bounds.right = bounds->right - kMissionDataVBuffer; dataItem->bounds.left = dataItem->bounds.right - kMissionDataWidth; } hiliteBounds.right++; hiliteBounds.bottom++; highlight_rect = hiliteBounds; Rect newRect; GetAnyInterfaceItemGraphicBounds(*dataItem, &newRect); lines.clear(); if (dataItem->bounds.right < hiliteBounds.left) { Point p1(hiliteBounds.left, hiliteBounds.top); Point p2(newRect.right + kMissionLineHJog, hiliteBounds.top); Point p3(newRect.right + kMissionLineHJog, newRect.top); Point p4(newRect.right + 2, newRect.top); lines.push_back(make_pair(p1, p2)); lines.push_back(make_pair(p2, p3)); lines.push_back(make_pair(p3, p4)); Point p5(hiliteBounds.left, hiliteBounds.bottom - 1); Point p6(newRect.right + kMissionLineHJog, hiliteBounds.bottom - 1); Point p7(newRect.right + kMissionLineHJog, newRect.bottom - 1); Point p8(newRect.right + 2, newRect.bottom - 1); lines.push_back(make_pair(p5, p6)); lines.push_back(make_pair(p6, p7)); lines.push_back(make_pair(p7, p8)); } else { Point p1(hiliteBounds.right, hiliteBounds.top); Point p2(newRect.left - kMissionLineHJog, hiliteBounds.top); Point p3(newRect.left - kMissionLineHJog, newRect.top); Point p4(newRect.left - 3, newRect.top); lines.push_back(make_pair(p1, p2)); lines.push_back(make_pair(p2, p3)); lines.push_back(make_pair(p3, p4)); Point p5(hiliteBounds.right, hiliteBounds.bottom - 1); Point p6(newRect.left - kMissionLineHJog, hiliteBounds.bottom - 1); Point p7(newRect.left - kMissionLineHJog, newRect.bottom - 1); Point p8(newRect.left - 3, newRect.bottom - 1); lines.push_back(make_pair(p5, p6)); lines.push_back(make_pair(p6, p7)); lines.push_back(make_pair(p7, p8)); } } dataItem->item.labeledRect.label.stringID = headerID; dataItem->item.labeledRect.label.stringNumber = headerNumber; Rect newRect; GetAnyInterfaceItemGraphicBounds(*dataItem, &newRect); populate_inline_picts(dataItem->bounds, text, dataItem->style, inlinePict); }
void BuildTreeDoubleYShape(Node *node[], Tree &tree) { const KDL::Vector unitx(1,0,0); const KDL::Vector unity(0,1,0); const KDL::Vector unitz(0,0,1); const KDL::Vector unit1(sqrt(14.0)/8.0, 1.0/8.0, 7.0/8.0); const KDL::Vector zero = KDL::Vector::Zero(); KDL::Vector p0(0.0f, -1.5f, 0.0f); KDL::Vector p1(0.0f, -1.0f, 0.0f); KDL::Vector p2(0.0f, -0.5f, 0.0f); KDL::Vector p3(0.5f*Root2Inv, -0.5+0.5*Root2Inv, 0.0f); KDL::Vector p4(0.5f*Root2Inv+0.5f*HalfRoot3, -0.5+0.5*Root2Inv+0.5f*0.5, 0.0f); KDL::Vector p5(0.5f*Root2Inv+1.0f*HalfRoot3, -0.5+0.5*Root2Inv+1.0f*0.5, 0.0f); KDL::Vector p6(0.5f*Root2Inv+1.5f*HalfRoot3, -0.5+0.5*Root2Inv+1.5f*0.5, 0.0f); KDL::Vector p7(0.5f*Root2Inv+0.5f*HalfRoot3, -0.5+0.5*Root2Inv+0.5f*HalfRoot3, 0.0f); KDL::Vector p8(0.5f*Root2Inv+1.0f*HalfRoot3, -0.5+0.5*Root2Inv+1.0f*HalfRoot3, 0.0f); KDL::Vector p9(0.5f*Root2Inv+1.5f*HalfRoot3, -0.5+0.5*Root2Inv+1.5f*HalfRoot3, 0.0f); KDL::Vector p10(-0.5f*Root2Inv, -0.5+0.5*Root2Inv, 0.0f); KDL::Vector p11(-0.5f*Root2Inv-0.5f*HalfRoot3, -0.5+0.5*Root2Inv+0.5f*HalfRoot3, 0.0f); KDL::Vector p12(-0.5f*Root2Inv-1.0f*HalfRoot3, -0.5+0.5*Root2Inv+1.0f*HalfRoot3, 0.0f); KDL::Vector p13(-0.5f*Root2Inv-1.5f*HalfRoot3, -0.5+0.5*Root2Inv+1.5f*HalfRoot3, 0.0f); KDL::Vector p14(-0.5f*Root2Inv-0.5f*HalfRoot3, -0.5+0.5*Root2Inv+0.5f*0.5, 0.0f); KDL::Vector p15(-0.5f*Root2Inv-1.0f*HalfRoot3, -0.5+0.5*Root2Inv+1.0f*0.5, 0.0f); KDL::Vector p16(-0.5f*Root2Inv-1.5f*HalfRoot3, -0.5+0.5*Root2Inv+1.5f*0.5, 0.0f); node[0] = new Node(p0, unit1, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertRoot(node[0]); node[1] = new Node(p1, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[0], node[1]); node[2] = new Node(p1, unitz, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[1], node[2]); node[3] = new Node(p2, unitz, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[2], node[3]); node[4] = new Node(p2, unitz, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertRightSibling(node[3], node[4]); node[5] = new Node(p3, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[3], node[5]); node[6] = new Node(p3, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertRightSibling(node[5], node[6]); node[7] = new Node(p3, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[5], node[7]); node[8] = new Node(p4, unitz, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[7], node[8]); node[9] = new Node(p5, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[8], node[9]); node[10] = new Node(p5, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[9], node[10]); node[11] = new Node(p6, zero, 0.08, EFFECTOR); tree.InsertLeftChild(node[10], node[11]); node[12] = new Node(p3, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[6], node[12]); node[13] = new Node(p7, unitz, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[12], node[13]); node[14] = new Node(p8, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[13], node[14]); node[15] = new Node(p8, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[14], node[15]); node[16] = new Node(p9, zero, 0.08, EFFECTOR); tree.InsertLeftChild(node[15], node[16]); node[17] = new Node(p10, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[4], node[17]); node[18] = new Node(p10, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[17], node[18]); node[19] = new Node(p10, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertRightSibling(node[17], node[19]); node[20] = new Node(p11, unitz, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[18], node[20]); node[21] = new Node(p12, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[20], node[21]); node[22] = new Node(p12, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[21], node[22]); node[23] = new Node(p13, zero, 0.08, EFFECTOR); tree.InsertLeftChild(node[22], node[23]); node[24] = new Node(p10, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[19], node[24]); node[25] = new Node(p14, unitz, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[24], node[25]); node[26] = new Node(p15, unitx, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[25], node[26]); node[27] = new Node(p15, unity, 0.08, JOINT, RADIAN(-180.), RADIAN(180.), RADIAN(30.)); tree.InsertLeftChild(node[26], node[27]); node[28] = new Node(p16, zero, 0.08, EFFECTOR); tree.InsertLeftChild(node[27], node[28]); }