/* the spheres came about originaly as quick way to test the directional lighting/normals */ static void buildBlock(ModeInfo *mi) { int i,c; int wire = MI_IS_WIREFRAME(mi); topBlockSTATE *tb = &tbs[MI_SCREEN(mi)]; tb->block=glGenLists(1); /* only one */ glNewList(tb->block,GL_COMPILE); tb->block_polys=0; glPushMatrix(); /* save state */ glRotatef(90, 0.0f, 1.0f, 0.0f); /* base */ polygonPlane(wire, 0,3,2,1,0); tb->block_polys++; polygonPlane(wire, 2,3,7,6,1); tb->block_polys++; polygonPlane(wire, 1,2,6,5,2); tb->block_polys++; polygonPlane(wire, 4,5,6,7,3); tb->block_polys++; polygonPlane(wire, 0,1,5,4,4); tb->block_polys++; if (drawNipples) { /* nipples */ /* draw 8 cylinders each with a disk cap */ glRotatef(90, 0.0f, 1.0f, 0.0f); /* 'aim' the pointer ready for the cylinder */ glTranslatef(0.5f,0.5f,0.99f); /* move to the cylinder center */ for (c=0;c<2;c++) { for (i=0;i<4;i++) { tb->block_polys += tube(0, 0, 0, 0, 0, 0.25, cylSize, 0, resolution, True, True, wire); glTranslatef(0.0f,0.0f,0.25f); /* move to the cylinder cap */ glTranslatef(0.0f,0.0f,-0.25f); /* move back from the cylinder cap */ if (c==0) { glTranslatef(0.0f,-1.0f,0.0f); /* move to the next cylinder center (forward) */ } else { glTranslatef(0.0f,1.0f,0.0f); /* move to the next cylinder center (backward) */ } } glTranslatef(-1.0f,1.0f,0.0f); /* move to the cylinder center */ } /* udders */ /* 3 cylinders on the underside */ glTranslatef(1.5f,-2.5f,-1.5f); /* move to the center, under the top of the brick */ if (! wire) for (c=0;c<3;c++) { tb->block_polys += tube(0, 0, 0.1, 0, 0, 1.4, uddSize, 0, resolution, True, True, wire); glTranslatef(0.0f,-1.0f,0.0f); /* move to the center */ } } glPopMatrix(); /* restore state */ glEndList(); }
int main(int argc, char *argv[]) { GC_find_leak = 1; tube(); CHECK_LEAKS(); return(0); }
TEST(Queue, Beanstalk) { std::string tube("lt_"); tube += std::to_string(time(NULL)); comm::library::QueueClient client("10.0.1.27", 11300, tube); ASSERT_GT(client.EnQueue("hello, world", 2048, 0, 60), 0); ASSERT_GT(client.EnQueue("hello, world, 11", 1024, 0, 60), 0); std::string msg; int64_t id1 = client.Front(0, msg); EXPECT_EQ(id1 > 0, true); EXPECT_EQ(msg, "hello, world, 11"); int64_t id2 = client.Front(0, msg); EXPECT_GT(id2, 0); EXPECT_EQ(msg, "hello, world"); EXPECT_EQ(0, client.Delete(id1)); EXPECT_EQ(0, client.Release(id2, 2048, 0)); id1 = client.Front(0, msg); EXPECT_EQ(id1, id2); EXPECT_EQ(msg, "hello, world"); EXPECT_EQ(0, client.Delete(id1)); }
static int ctube (GLfloat diameter, GLfloat width, Bool wire) { tube (0, 0, width/2, 0, 0, -width/2, diameter, 0, 32, True, True, wire); return 0; /* #### */ }
static void hokuyoCase(void) { glPushMatrix(); glColor3f(0, 0, 0); glRotated(-90, 0, 1, 0); glTranslated(-0.016, 0, 0); tube(0.02,0.029); glColor3f(0, 1, 0); glBegin(GL_TRIANGLES); glNormal3f(1, 0, 0); glVertex3f(0.0295,0,-0.005); glVertex3f(0.0295,0.02,0); glVertex3f(0.0295,0,0.005); glEnd(); glColor3f(1, 1, 1); glBegin(GL_QUAD_STRIP); glNormal3f(0, 0, 1); glVertex3f(-0.041, -0.025, 0.025); glVertex3f(0, -0.025, 0.025); glVertex3f(-0.041, 0.025, 0.025); glVertex3f(0, 0.025, 0.025); glNormal3f(0, 1, 0); glVertex3f(-0.041, 0.025, -0.025); glVertex3f(0, 0.025, -0.025); glNormal3f(0, 0, -1); glVertex3f(-0.041, -0.025, -0.025); glVertex3f(0, -0.025, -0.025); glNormal3f(0, -1, 0); glVertex3f(-0.041, -0.025, 0.025); glVertex3f(0, -0.025, 0.025); glEnd(); glBegin(GL_QUADS); glNormal3f(1, 0, 0); glVertex3f(0,-0.025,0.025); glVertex3f(0,-0.025,-0.025); glVertex3f(0,0.025,-0.025); glVertex3f(0,0.025,0.025); glNormal3f(-1, 0, 0); glVertex3f(-0.041,-0.025,0.025); glVertex3f(-0.041,0.025,0.025); glVertex3f(-0.041,0.025,-0.025); glVertex3f(-0.041,-0.025,-0.025); glEnd(); glPopMatrix(); }
CelledBaseChunkReader::CelledBaseChunkReader( const Metadata& m, PointPool& pool, const arbiter::Endpoint& endpoint) : BaseChunkReader(m, pool) { DimList dims; dims.push_back(DimInfo("TubeId", "unsigned", 8)); dims.insert(dims.end(), m.schema().dims().begin(), m.schema().dims().end()); const Schema celledSchema(dims); PointPool celledPool(celledSchema, m.delta()); auto tubedCells(m.storage().deserialize(endpoint, celledPool, m_id)); Data::PooledStack tubedData(celledPool.dataPool()); auto dataNodes(m_pool.dataPool().acquire(tubedCells.size())); m_cells = m_pool.cellPool().acquire(tubedCells.size()); const std::size_t celledPointSize(celledSchema.pointSize()); const std::size_t tubeIdSize(sizeof(uint64_t)); uint64_t tube(0); char* tPos(reinterpret_cast<char*>(&tube)); BinaryPointTable table(m.schema()); pdal::PointRef pointRef(table, 0); for (auto& cell : m_cells) { auto tubedCell(tubedCells.popOne()); const char* src(tubedCell->uniqueData()); Data::PooledNode data(dataNodes.popOne()); std::copy(src, src + tubeIdSize, tPos); std::copy(src + tubeIdSize, src + celledPointSize, *data); table.setPoint(*data); cell.set(pointRef, std::move(data)); m_points.at(tube).emplace_back(cell.point(), cell.uniqueData()); tubedData.push(tubedCell->acquire()); } }
/** draws cylindermodel */ static int draw_model(int chunks, const GLfloat model[][3], int r) { int i = 0; int polys = 0; glPushMatrix(); glRotatef(-90.0, 1.0, 0.0, 0.0); for(i = 0; i < chunks; ++i) { if(model[i][0] > EPSILON || model[i][1] > EPSILON) { polys += tube (0, 0, 0, 0, 0, model[i][1], model[i][0], 0, r, False, False, False); /* gluCylinder(quadric, model[i][0], model[i][1], model[i][2], r, 1); polys += r;*/ } glTranslatef(0.0, 0.0, model[i][2]); } glPopMatrix(); return polys; }
static void make_ladder (logo_configuration *dc, int facetted, int wire) { GLfloat th; GLfloat max_th = dc->turns * M_PI * 2; GLfloat max_z = dc->turns * dc->turn_spacing; GLfloat z_inc = dc->bar_spacing; GLfloat th_inc = M_PI * 2 * (dc->bar_spacing / dc->turn_spacing); GLfloat x, y, z; /* skip forward to center the bars in the helix... */ int i; GLfloat usable_th = max_th - dc->wall_taper; GLfloat usable_z = max_z / (max_th / usable_th); int nbars = usable_z / dc->bar_spacing; GLfloat used_z = (nbars - 1) * dc->bar_spacing; GLfloat pad_z = max_z - used_z; GLfloat pad_ratio = pad_z / max_z; th = (max_th * pad_ratio/2); z = -(max_z / 2) + (max_z * pad_ratio/2); if (!dc->clockwise) z = -z, z_inc = -z_inc; for (i = 0; i < nbars; i++) { int facets = dc->tube_facets / (facetted ? 14 : 1); if (facets <= 3) facets = 3; x = cos (th) * (1 - dc->wall_thickness); y = sin (th) * (1 - dc->wall_thickness); tube ( x, y, z, -x, -y, z, dc->tube_thickness, 0, facets, True, True, wire); z += z_inc; th += th_inc; } }
/* Constructs the GL shapes of the current molecule */ static void build_molecule (ModeInfo *mi, Bool transparent_p) { molecule_configuration *mc = &mcs[MI_SCREEN(mi)]; int wire = MI_IS_WIREFRAME(mi); int i; GLfloat alpha = transparent_p ? shell_alpha : 1.0; int polys = 0; molecule *m = &mc->molecules[mc->which]; if (wire) { glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); glDisable(GL_DEPTH_TEST); glDisable(GL_NORMALIZE); glDisable(GL_CULL_FACE); } else { glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); } if (!wire) set_atom_color (mi, 0, False, alpha); if (do_bonds) for (i = 0; i < m->nbonds; i++) { const molecule_bond *b = &m->bonds[i]; const molecule_atom *from = get_atom (m->atoms, m->natoms, b->from); const molecule_atom *to = get_atom (m->atoms, m->natoms, b->to); if (wire) { glBegin(GL_LINES); glVertex3f(from->x, from->y, from->z); glVertex3f(to->x, to->y, to->z); glEnd(); polys++; } else { int faces = (mc->scale_down ? TUBE_FACES_2 : TUBE_FACES); # ifdef SMOOTH_TUBE int smooth = True; # else int smooth = False; # endif GLfloat thickness = 0.07 * b->strength; GLfloat cap_size = 0.03; if (thickness > 0.3) thickness = 0.3; polys += tube (from->x, from->y, from->z, to->x, to->y, to->z, thickness, cap_size, faces, smooth, (!do_atoms || do_shells), wire); } } if (!wire && do_atoms) for (i = 0; i < m->natoms; i++) { const molecule_atom *a = &m->atoms[i]; GLfloat size = atom_size (a); set_atom_color (mi, a, False, alpha); polys += sphere (mc, a->x, a->y, a->z, size, wire); } if (do_bbox && !transparent_p) { draw_bounding_box (mi); polys += 4; } mc->polygon_count += polys; }
static void make_knot (ModeInfo *mi) { int wire = MI_IS_WIREFRAME(mi); GLfloat diam = (4 * thickness); int faces = (wire ? 3 : 6); unsigned int i; double x, y, z, ox=0, oy=0, oz=0; double mu; double p[9]; Bool blobby_p = (0 == (random() % 5)); Bool type = (random() % 2); for (i = 0; i < countof(p); i++) { p[i] = 1 + (random() % 4); if (! (random() % 3)) p[i] += (random() % 5); } if (type == 1) { p[0] += 4; p[1] *= ((p[0] + p[0]) / 10); blobby_p = False; } mi->polygon_count = 0; for (i = 0; i <= segments; i++) { if (type == 0) { mu = i * (M_PI * 2) / segments; x = 10 * (cos(mu) + cos(p[0]*mu)) + cos(p[1]*mu) + cos(p[2]*mu); y = 6 * sin(mu) + 10 * sin(p[3]*mu); z = 16 * sin(p[4]*mu) * sin(p[5]*mu/2) + p[6]*sin(p[7]*mu) - 2 * sin(p[8]*mu); } else if (type == 1) { mu = i * (M_PI * 2) * p[0] / (double) segments; x = 10 * cos(mu) * (1 + cos(p[1] * mu/ p[0]) / 2.0); y = 25 * sin(p[1] * mu / p[0]) / 2.0; z = 10 * sin(mu) * (1 + cos(p[1] * mu/ p[0]) / 2.0); } else abort(); if (i != 0) { GLfloat dist = sqrt ((x-ox)*(x-ox) + (y-oy)*(y-oy) + (z-oz)*(z-oz)); GLfloat di; if (!blobby_p) di = diam; else { di = dist * (segments / 500.0); di = (di * di * 3); } mi->polygon_count += tube (ox, oy, oz, x, y, z, di, dist/3, faces, True, wire, wire); } ox = x; oy = y; oz = z; } }
/* Constructs the GL shapes of the current molecule */ static void build_molecule (ModeInfo *mi) { molecule_configuration *mc = &mcs[MI_SCREEN(mi)]; int wire = cur_wire; int i; molecule *m = &mc->molecules[mc->which]; if (wire) { glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); glDisable(GL_DEPTH_TEST); glDisable(GL_NORMALIZE); glDisable(GL_CULL_FACE); } else { glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); } if (!wire) set_atom_color (mi, 0, False); if (do_bonds) for (i = 0; i < m->nbonds; i++) { molecule_bond *b = &m->bonds[i]; molecule_atom *from = get_atom(m->atoms, m->natoms, b->from, MI_IS_VERBOSE(mi)); molecule_atom *to = get_atom(m->atoms, m->natoms, b->to, MI_IS_VERBOSE(mi)); if (wire) { glBegin(GL_LINES); glVertex3f(from->x, from->y, from->z); glVertex3f(to->x, to->y, to->z); glEnd(); } else { int faces = (scale_down ? TUBE_FACES_2 : TUBE_FACES); # ifdef SMOOTH_TUBE int smooth = True; # else int smooth = False; # endif GLfloat thickness = 0.07 * b->strength; GLfloat cap_size = 0.03; if (thickness > 0.3) thickness = 0.3; tube (from->x, from->y, from->z, to->x, to->y, to->z, thickness, cap_size, faces, smooth, !do_atoms, wire); } } for (i = 0; i < m->natoms; i++) { molecule_atom *a = &m->atoms[i]; int i; if (!wire && do_atoms) { GLfloat size = atom_size (a); set_atom_color (mi, a, False); sphere (a->x, a->y, a->z, size, wire); } if (do_labels) { glPushAttrib (GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT); glDisable (GL_LIGHTING); glDisable (GL_DEPTH_TEST); if (!wire) set_atom_color (mi, a, True); glRasterPos3f (a->x, a->y, a->z); { GLdouble mm[17], pm[17]; GLint vp[5]; GLdouble wx=-1, wy=-1, wz=-1; glGetDoublev (GL_MODELVIEW_MATRIX, mm); glGetDoublev (GL_PROJECTION_MATRIX, pm); glGetIntegerv (GL_VIEWPORT, vp); /* Convert 3D coordinates to window coordinates */ gluProject (a->x, a->y, a->z, mm, pm, vp, &wx, &wy, &wz); /* Fudge the window coordinates to center the string */ wx -= string_width (mc->xfont1, a->label) / 2; wy -= mc->xfont1->descent; /* Convert new window coordinates back to 3D coordinates */ gluUnProject (wx, wy, wz, mm, pm, vp, &wx, &wy, &wz); glRasterPos3f (wx, wy, wz); } for (i = 0; i < (int) strlen(a->label); i++) glCallList (mc->font1_dlist + (int)(a->label[i])); glPopAttrib(); } } if (do_bbox) draw_bounding_box (mi); if (do_titles && m->label && *m->label) print_title_string (mi, m->label, 10, MI_HEIGHT(mi) - 10, mc->xfont2->ascent + mc->xfont2->descent); }
/* called at init this creates the 'carpet' display list item */ static void buildCarpet(ModeInfo *mi) { int i,c,x,y; GLfloat color[4]; int wire = MI_IS_WIREFRAME(mi); topBlockSTATE *tb = &tbs[MI_SCREEN(mi)]; color[0] = 0.0f; color[1] = 1.0f; color[2] = 0.0f; color[3] = 1.0f; tb->carpet=glGenLists(1); /* only one */ glNewList(tb->carpet,GL_COMPILE); tb->carpet_polys=0; glPushMatrix(); /* save state */ x=tb->carpetWidth; y=tb->carpetLength; if (wire) { glColor3fv(color); } else { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); } /* draw carpet plane */ glBegin( wire ? GL_LINE_LOOP : GL_QUADS ); /* draw top */ glNormal3f( 0, 0, -1 ); glVertex3f(0.0,0.0,0.0); glVertex3f(x,0.0,0.0); glVertex3f(x,y,0.0); glVertex3f(0.0,y,0.0); tb->carpet_polys++; if (!wire) { /* add edge pieces */ /* side 1 */ glNormal3f( 0, -1, 0 ); glVertex3f(0.0,0.0,0.0); glVertex3f(x,0.0,0.0); glVertex3f(x,0,singleThick); glVertex3f(0.0,0,singleThick); tb->carpet_polys++; /* side 2 */ glNormal3f( -1, 0, 0 ); glVertex3f(0.0,0.0,0.0); glVertex3f(0,y,0.0); glVertex3f(0,y,singleThick); glVertex3f(0.0,0,singleThick); tb->carpet_polys++; /* side 3 */ glNormal3f( 1, 0, 0 ); glVertex3f(x,0.0,0.0); glVertex3f(x,y,0.0); glVertex3f(x,y,singleThick); glVertex3f(x,0,singleThick); tb->carpet_polys++; /* side 4 */ glNormal3f( 0, 1, 0 ); glVertex3f(0,y,0.0); glVertex3f(x,y,0.0); glVertex3f(x,y,singleThick); glVertex3f(0,y,singleThick); tb->carpet_polys++; } glEnd(); /* nipples */ if (drawNipples) { glTranslatef(0.5f,0.5f,-.25); /* move to the cylinder center */ for (c=0;c<x;c++) { glPushMatrix(); /* save state */ for (i=0;i<y;i++) { tb->carpet_polys += tube(0, 0, -0.1, 0, 0, 0.26, cylSize, 0, resolution, True, True, wire); glRotatef(180, 0.0f, 1.0f, 0.0f); /* they are upside down */ glRotatef(180, 0.0f, 1.0f, 0.0f); /* recover */ glTranslatef(0.0f,1.0f,0.0f); /* move to the next cylinder center (backward) */ } glPopMatrix(); /* save state */ glTranslatef(1.0f,0.0f,0.0f); /* reset */ } } glPopMatrix(); /* restore state */ glEndList(); }