bool test_cell_on_cell_iterator(G const& g, ::std::ostream & out, GT)
{
  typedef GT gt;
  typedef typename gt::CellIterator        CellIterator;
  typedef typename gt::CellOnCellIterator  CellOnCellIterator;

  for(CellIterator c(g); ! c.IsDone(); ++c) {
    int v_cnt = 0;
    for(CellOnCellIterator vc(*c); ! vc.IsDone(); ++vc, ++v_cnt) {
      ;
    }
    REQUIRE_ALWAYS(v_cnt == (int)(*c).NumOfCells(), 
                   "v_cnt = " << v_cnt << " != c.NumOfCells() = " 
                   << (*c).NumOfCells() << '\n',1);

    CellOnCellIterator v;
    v = (*c).FirstCell();
    CellOnCellIterator w = v;
    for( ; !v.IsDone(); ++v, ++w) {
      REQUIRE_ALWAYS( ( v ==  w), "Iterators differ!\n",1);
      REQUIRE_ALWAYS( (*v == *w), "Iterator values differ!\n",1);
    }
    REQUIRE_ALWAYS( (w.IsDone()), "", 1);
    REQUIRE_ALWAYS( (v == w), "Past-the-end iterators differ!\n", 1);
  
    if((*c).NumOfCells() > 0) {
      v = (*c).FirstCell();
      w = v;
      ++v;
      for( ; !v.IsDone(); ++v, ++w) 
        REQUIRE_ALWAYS( (*v != *w), "Iterators point to same cell!\n",1);
    }
  }
  return true;
}
Exemplo n.º 2
0
void test_none()
{
//  Note: The literal values here are tested against directly, careful if you change them:
    int some_numbers[] = { 1, 5, 0, 18, 1 };
    std::vector<int> vi(some_numbers, some_numbers + 5);
    std::list<int>   li(vi.begin(), vi.end ());
    
    int some_letters[] = { 'a', 'q', 'n', 'y', 'n' };
    std::vector<char> vc(some_letters, some_letters + 5);
    
    BOOST_CHECK ( ba::none_of_equal ( vi,                                  100 ));
    BOOST_CHECK ( ba::none_of       ( vi,                       is_<int> ( 100 )));
    BOOST_CHECK ( ba::none_of_equal ( vi.begin(),     vi.end(),            100 ));
    BOOST_CHECK ( ba::none_of       ( vi.begin(),     vi.end(), is_<int> ( 100 )));

    BOOST_CHECK (!ba::none_of_equal ( vi,                                    1 ));
    BOOST_CHECK (!ba::none_of       ( vi,                       is_<int> (   1 )));
    BOOST_CHECK (!ba::none_of_equal ( vi.begin(),     vi.end(),              1 ));
    BOOST_CHECK (!ba::none_of       ( vi.begin(),     vi.end(), is_<int> (   1 )));

    BOOST_CHECK ( ba::none_of_equal ( vi.end(),       vi.end(),              0 ));
    BOOST_CHECK ( ba::none_of       ( vi.end(),       vi.end(), is_<int> (   0 )));

//   5 is not in { 0, 18, 1 }, but 1 is
    BOOST_CHECK ( ba::none_of_equal ( vi.begin() + 2, vi.end(),              5 ));
    BOOST_CHECK ( ba::none_of       ( vi.begin() + 2, vi.end(), is_<int> (   5 )));
    BOOST_CHECK (!ba::none_of_equal ( vi.begin() + 2, vi.end(),              1 ));
    BOOST_CHECK (!ba::none_of       ( vi.begin() + 2, vi.end(), is_<int> (   1 )));

//  18 is not in { 1, 5, 0 }, but 5 is
    BOOST_CHECK ( ba::none_of_equal ( vi.begin(),     vi.begin() + 3,            18 ));
    BOOST_CHECK ( ba::none_of       ( vi.begin(),     vi.begin() + 3, is_<int> ( 18 )));
    BOOST_CHECK (!ba::none_of_equal ( vi.begin(),     vi.begin() + 3,             5 ));
    BOOST_CHECK (!ba::none_of       ( vi.begin(),     vi.begin() + 3, is_<int> (  5 )));
    
    BOOST_CHECK ( ba::none_of_equal ( vc,             'z' ));
    BOOST_CHECK ( ba::none_of       ( vc, is_<char> ( 'z' )));

    BOOST_CHECK (!ba::none_of_equal ( vc,             'a' ));
    BOOST_CHECK (!ba::none_of       ( vc, is_<char> ( 'a' )));

    BOOST_CHECK (!ba::none_of_equal ( vc,             'n' ));
    BOOST_CHECK (!ba::none_of       ( vc, is_<char> ( 'n' )));

    BOOST_CHECK ( ba::none_of_equal ( vi.begin(), vi.begin(),   1 ));
    BOOST_CHECK ( ba::none_of_equal ( vc.begin(), vc.begin(), 'a' ));
    BOOST_CHECK ( ba::none_of       ( vi.begin(), vi.begin(), is_<int>  (   1 )));
    BOOST_CHECK ( ba::none_of       ( vc.begin(), vc.begin(), is_<char> ( 'a' )));

    BOOST_CHECK ( ba::none_of_equal ( li,                                  100 ));
    BOOST_CHECK ( ba::none_of       ( li,                       is_<int> ( 100 )));
    BOOST_CHECK ( ba::none_of_equal ( li.begin(),     li.end(),            100 ));
    BOOST_CHECK ( ba::none_of       ( li.begin(),     li.end(), is_<int> ( 100 )));
    
    std::list<int>::iterator l_iter = li.begin ();
    l_iter++; l_iter++; l_iter++;
    BOOST_CHECK ( ba::none_of_equal ( li.begin(), l_iter,            18 ));
    BOOST_CHECK ( ba::none_of       ( li.begin(), l_iter, is_<int> ( 18 )));
    BOOST_CHECK (!ba::none_of       ( li.begin(), l_iter, is_<int> (  5 )));
}
Exemplo n.º 3
0
/** [Example] */
int main(int argc, char *argv[]) 
{  
  // Start server
  ib::fast_server< ib::image > is;
  is.set_max_pending_outbound(100);
  is.startup("tcp://127.0.0.1:6000");
   
  // Open video device
  cv::VideoCapture vc(0);
  if (!vc.isOpened()) {
    std::cerr << "Failed to open capture device" << std::endl;
  }
  
  cv::Mat cv_img;

  // While more images are available ...
  while (vc.grab() && vc.retrieve(cv_img)) 
  {
    // Convert image
    ib::image ib_img;
    ib::cvt_image(cv_img, ib_img, ib::copy_mem());

    // Publish to all connected clients
    is.publish(ib_img);
  }
  
  return 0;
}
Exemplo n.º 4
0
/**
 *
 * Points are in world coordinates
 */
void Gouraud_Shading(face *f, object_copy *obj,
		vector<light> *lights, camera *camera, int xres, int yres, color **grid,
		float **depth_grid, MatrixXd *perspective, MatrixXd *inv_cam) {
	point *a = &(obj->points[f->vertices.index1-1]);
	color colora = lighting(a,
				&(obj->normals[f->normals.index1-1]),
				obj, lights, camera);

	point *b = &(obj->points[f->vertices.index2-1]);
	color colorb = lighting(b,
				&(obj->normals[f->normals.index2-1]),
				obj, lights, camera);

	point *c = &(obj->points[f->vertices.index3-1]);
	color colorc = lighting(c,
				&(obj->normals[f->normals.index3-1]),
				obj, lights, camera);

	point ndca = to_NDC(a, perspective, inv_cam);
	point ndcb = to_NDC(b, perspective, inv_cam);
	point ndcc = to_NDC(c, perspective, inv_cam);

	Vector3d va(ndca.x, ndca.y, ndca.z);
	Vector3d vb(ndcb.x, ndcb.y, ndcb.z);
	Vector3d vc(ndcc.x, ndcc.y, ndcc.z);
	Vector3d cross = (vc - vb).cross(va - vb);

	// ignore if pointing away from camera or if face is outside NDC box
	if (cross(2) >= 0 && is_in_box(&ndca) && is_in_box(&ndcb) && is_in_box(&ndcc))
		raster_triangle(&ndca, &ndcb, &ndcc, colora, colorb, colorc, xres, yres, grid, depth_grid);
}
Exemplo n.º 5
0
Arquivo: main.cpp Projeto: CCJY/coliru
 void test16(void)
 {
     vector<string> vc(2);
     vc.front() = "hi";
     
     cout << vc.front() << '|' << vc.back() << endl;
 }
Exemplo n.º 6
0
QVector<QVector3D> SurfaceItem::vertices() const
{
    QSize size = surface()->size();

    qreal w = (m_height * size.width()) / size.height();
    qreal h = m_height;

    QVector3D pos = m_pos + m_normal * m_depthOffset;

    QVector2D center(pos.x(), pos.z());

    QVector3D perp = QVector3D::crossProduct(QVector3D(0, 1, 0), m_normal);
    QVector2D delta = w * QVector2D(perp.x(), perp.z()).normalized() / 2;

    qreal scale = qMin(1.0, m_time.elapsed() * 0.002);

    qreal top = m_pos.y() + h * 0.5 * scale;
    qreal bottom = m_pos.y() - h * 0.5 * scale;

    QVector2D left = center - delta * scale;
    QVector2D right = center + delta * scale;

    QVector3D va(left.x(), top, left.y());
    QVector3D vb(right.x(), top, right.y());
    QVector3D vc(right.x(), bottom, right.y());
    QVector3D vd(left.x(), bottom, left.y());

    QVector<QVector3D> result;
    result << va << vb << vc << vd;
    return result;
}
Exemplo n.º 7
0
// runs the raytrace over all tests and saves the corresponding images
int main(int argc, char** argv) {
    
    // test that glfw and glew are linked properly
    uiloop();
    message("GLFW and GLEW seem to work\n\n");
    
    // test max_component function
    vec3f v(1,2,-3);
    float max_val = max_component(v);
    message("Result of max_component: %f\n", max_val);
    
    // test sum of three vectors
    vec3f va(1,0,0);
    vec3f vb(0,4,0);
    vec3f vc(0,0,2);
    vec3f vabc = sum_three(va, vb, vc);
    message("Result of sum_three: %s\n", tostring(vabc).c_str());
    
    // test sum of vectors
    vector<vec3f> vs = {
        {3.14,1.5,2.7},
        {2.71,8.2,8.2},
        {1.61,8.0,3.4},
        {1.41,4.2,1.4},
    };
    vec3f vsum = sum_many(vs);
    message("Result of sum_many: %s\n", tostring(vsum).c_str());

    message("\nThis message indicates a successful build!\n\n");

    return 0;
}
Exemplo n.º 8
0
T0* ci(int id, T0* o, se_position position) {
  /*
    Check Id for reference target.
  */
  if ( vc(o,position) != NULL) {
    if ( id == (o->id) ) {
      return o;
    }
    else {
#ifdef SE_EXCEPTIONS
      internal_exception_handler(System_level_type_error);
#else
      int l = se_position2line(position);
      int c = se_position2column(position);
      int f = se_position2path_id(position);

      se_print_bad_target(SE_ERR,id,o,l,c,f);
      se_print_run_time_stack();
      se_print_bad_target(SE_ERR,id,o,l,c,f);
#ifdef SE_SEDB
      sedb_break(se_dst,0);
#else
      exit(EXIT_FAILURE);
#endif
#endif
    }
  }
  return o;
}
Exemplo n.º 9
0
void drawTexturedPolyhedron(carve::mesh::MeshSet<3> *poly,
                            carve::interpolate::FaceVertexAttr<tex_t> &fv_tex,
                            carve::interpolate::FaceAttr<GLuint> &f_tex_num) {
  glEnable(GL_TEXTURE_2D);

  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

  GLUtesselator *tess = gluNewTess();

  gluTessCallback(tess, GLU_TESS_BEGIN, (GLUTessCallback)glBegin);
  gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (GLUTessCallback)tess_vertex);
  gluTessCallback(tess,  GLU_TESS_END, (GLUTessCallback)glEnd);

  for (carve::mesh::MeshSet<3>::face_iter i = poly->faceBegin(); i != poly->faceEnd(); ++i) {
    carve::mesh::MeshSet<3>::face_t *f = *i;
    std::vector<vt_t> vc(f->nVertices());

    bool textured = true;
    for (carve::mesh::MeshSet<3>::face_t::edge_iter_t e = f->begin(); e != f->end(); ++e) {
      vc[e.idx()].x = g_scale * (e->vert->v.x + g_translation.x);
      vc[e.idx()].y = g_scale * (e->vert->v.y + g_translation.y);
      vc[e.idx()].z = g_scale * (e->vert->v.z + g_translation.z);

      if (fv_tex.hasAttribute(f, e.idx())) {
        tex_t t = fv_tex.getAttribute(f, e.idx());
        vc[e.idx()].u = t.u;
        vc[e.idx()].v = t.v;
      } else {
        textured = false;
      }
    }

    if (textured) {
      GLuint tex_num = f_tex_num.getAttribute(f, 0);
      glEnable(GL_TEXTURE_2D);
      glBindTexture(GL_TEXTURE_2D, tex_num);
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
      glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    } else {
      glColor4f(0.5f, 0.6f, 0.7f, 1.0f);
    }

    glNormal3dv(f->plane.N.v);

    gluTessBeginPolygon(tess, (void *)&textured);
    gluTessBeginContour(tess);

    for (size_t j = 0; j != vc.size(); ++j) {
      gluTessVertex(tess, (GLdouble *)&vc[j], (GLvoid *)&vc[j]);
    }

    gluTessEndContour(tess);
    gluTessEndPolygon(tess);

  }

  gluDeleteTess(tess);

  glDisable(GL_TEXTURE_2D);
}
Exemplo n.º 10
0
void test_offset_curve(double const &offset) {
    const double dx = 0.01;
    const double r = (1.0 + offset);

    std::vector<double> pos, off_pos;
    const size_t max_i = 1000;
    for (size_t i = 0; i <= max_i; ++i) {
        double x = M_PI * double(i) / max_i;
        pos.push_back(-std::cos(x)); pos.push_back(std::sin(x));
        off_pos.push_back(-r * std::cos(x)); off_pos.push_back(r * std::sin(x));
    }

    fake_path path(pos), off_path(off_pos);
    mapnik::vertex_cache vc(path), off_vc(off_path);

    vc.reset(); vc.next_subpath();
    off_vc.reset(); off_vc.next_subpath();

    while (vc.move(dx)) {
        double mpos = vc.linear_position();
        double moff_pos = off_vc.position_closest_to(vc.current_position());
        {
            mapnik::vertex_cache::scoped_state s(off_vc);
            off_vc.move(moff_pos);
            auto eps = (1.001 * offset);
            auto actual = dist(vc.current_position(), off_vc.current_position());
            REQUIRE(actual < eps);
        }
        REQUIRE(std::abs((mpos / vc.length()) - (moff_pos / off_vc.length())) < 1.0e-3);
    }
}
Exemplo n.º 11
0
    void step()
    {
        boost::scoped_ptr<
            typename multi_particle_container_type::transaction_type>
                tx(pc_.create_transaction());
        typedef typename multi_particle_container_type::transaction_type::particle_id_pair_generator particle_id_pair_generator;
        typedef typename multi_particle_container_type::transaction_type::particle_id_pair_and_distance_list particle_id_pair_and_distance_list;
        last_reaction_setter rs(*this);
        volume_clearer vc(*this);
        BDPropagator<traits_type> ppg(
            *tx, *main_.network_rules(), main_.rng(),
            base_type::dt_,
            1 /* FIXME: dissociation_retry_moves */, &rs, &vc,
            make_select_first_range(pc_.get_particles_range()));

        last_event_ = NONE;

        while (ppg())
        {
            if (last_reaction_)
            {
                last_event_ = REACTION;
                break;
            }
        }
    }
Exemplo n.º 12
0
int Font::write(unsigned int dx, const std::string& text, float r, float g, float b, float a) {
    FontEntry& e = entries[dx];
    if(e.num_vertices) {
        vertices.erase(vertices.begin()+e.start_dx, vertices.begin()+(e.start_dx+e.num_vertices));
    }
    e.col[0] = r, e.col[1] = g, e.col[2] = b, e.col[3] = a;

    // Create vertices
    e.w = 0;
    e.start_dx = vertices.size();
    float x = 0;
    float y = 0;
    for(int i = 0; i < text.size(); ++i) {
        char c = text[i];
        stbtt_aligned_quad q;
        stbtt_GetBakedQuad(cdata, w, h, c-32, &x, &y, &q, 1);
        CharVertex va(q.x0, q.y1, q.s0, q.t1, e.col);
        CharVertex vb(q.x1, q.y1, q.s1, q.t1, e.col);
        CharVertex vc(q.x1, q.y0, q.s1, q.t0, e.col);
        CharVertex vd(q.x0, q.y0, q.s0, q.t0, e.col);
        CHAR_TRI(va, vb, vc);
        CHAR_TRI(va, vc, vd);

        if(q.x1 > e.w) {
            e.w = q.x1;
        }
    }
    e.needs_update = true;
    e.num_vertices = vertices.size() - e.start_dx;
    flagChanged();
    return e.num_vertices;
}
Exemplo n.º 13
0
void test_s_shaped_curve(double const &offset) {
    const double dx = 0.01;
    const double r = (1.0 + offset);
    const double r2 = (1.0 - offset);

    std::vector<double> pos, off_pos;
    const size_t max_i = 1000;
    for (size_t i = 0; i <= max_i; ++i) {
        double x = M_PI * double(i) / max_i;
        pos.push_back(-std::cos(x) - 1); pos.push_back(std::sin(x));
        off_pos.push_back(-r * std::cos(x) - 1); off_pos.push_back(r * std::sin(x));
    }
    for (size_t i = 0; i <= max_i; ++i) {
        double x = M_PI * double(i) / max_i;
        pos.push_back(-std::cos(x) + 1); pos.push_back(-std::sin(x));
        off_pos.push_back(-r2 * std::cos(x) + 1); off_pos.push_back(-r2 * std::sin(x));
    }

    fake_path path(pos), off_path(off_pos);
    mapnik::vertex_cache vc(path), off_vc(off_path);

    vc.reset(); vc.next_subpath();
    off_vc.reset(); off_vc.next_subpath();

    while (vc.move(dx)) {
        double moff_pos = off_vc.position_closest_to(vc.current_position());
        {
            mapnik::vertex_cache::scoped_state s(off_vc);
            off_vc.move(moff_pos);
            REQUIRE(dist(vc.current_position(), off_vc.current_position()) < (1.002 * offset));
        }
    }
}
Exemplo n.º 14
0
VoxelCube HeightNoise::noise(int dim, int offset[3], int octaves, float frequency, float amplitude, int seed)
{
	VoxelCube vc(dim);
	m_perlin = new Perlin(octaves, frequency, amplitude, seed);
	
	for(int i = 0; i < dim; i++)
	{
		for(int j = 0; j < dim; j++)
		{
			float value = m_perlin->Get((i+offset[0])/(float)dim, (j+offset[2])/(float)dim);
			value +=      m_perlin->Get((i+offset[0])/(float)dim*2, (j+offset[2])/(float)dim*2) * 0.5;
			value +=      m_perlin->Get((i+offset[0])/(float)dim*4, (j+offset[2])/(float)dim*4) * 0.5 * 0.5;
			value +=      m_perlin->Get((i+offset[0])/(float)dim*8, (j+offset[2])/(float)dim*8) * 0.5 * 0.5 * 0.5;
			
			value = value * 0.5 + 0.5;
			
			if(value > 1.0)
				value = 1.0;
			else if(value < 0.0)
				value = 0.0;
			
			for(int k = 0; k < dim*value; k++)
			{
				vc.set(i, k, j, 255);
			}
			
			for(int k = dim*value; k < dim; k++)
			{
				vc.set(i, k, j, 0);
			}
		}
	}
	
	return vc;
}
Exemplo n.º 15
0
void Phong_Shading(face *f, object_copy *obj,
	vector<light> *lights, camera *camera, int xres, int yres, color **grid,
	float **depth_grid, MatrixXd *perspective, MatrixXd *inv_cam) {
	// TODO: implement
	point *a = &(obj->points[f->vertices.index1-1]);
	point *normal_a = &(obj->normals[f->normals.index1-1]);

	point *b = &(obj->points[f->vertices.index2-1]);
	point *normal_b = &(obj->normals[f->normals.index2-1]);

	point *c = &(obj->points[f->vertices.index3-1]);
	point *normal_c = &(obj->normals[f->normals.index3-1]);

	point ndca = to_NDC(a, perspective, inv_cam);
	point ndcb = to_NDC(b, perspective, inv_cam);
	point ndcc = to_NDC(c, perspective, inv_cam);

	Vector3d va(ndca.x, ndca.y, ndca.z);
	Vector3d vb(ndcb.x, ndcb.y, ndcb.z);
	Vector3d vc(ndcc.x, ndcc.y, ndcc.z);
	Vector3d cross = (vc - vb).cross(va - vb);

	// ignore if pointing away from camera or if face is outside NDC box
	if (cross(2) >= 0) // && is_in_box(&ndca) && is_in_box(&ndcb) && is_in_box(&ndcc))
		raster_triangle_Phong(&ndca, &ndcb, &ndcc, a, b, c, normal_a, normal_b,
				normal_c, obj, lights, camera, xres, yres, grid, depth_grid, perspective, inv_cam);
}
Exemplo n.º 16
0
void
OcclusionQueryVisitor::addOQN( osg::Node& node )
{
    VertexCounter vc( _occluderThreshold );
    node.accept( vc );
    if (vc.exceeded())
    {
        // Insert OQN(s) above this node.
        unsigned int np = node.getNumParents();
        while (np--)
        {
            osg::Group* parent = dynamic_cast<osg::Group*>( node.getParent( np ) );
            if (parent != NULL)
            {
                osg::ref_ptr<osg::OcclusionQueryNode> oqn = new osg::OcclusionQueryNode();
                oqn->addChild( &node );
                parent->replaceChild( &node, oqn.get() );

                oqn->setName( getNextOQNName() );
                // Set all OQNs to use the same query StateSets (instead of multiple copies
                //   of the same StateSet) for efficiency.
                oqn->setQueryStateSet( _state.get() );
                oqn->setDebugStateSet( _debugState.get() );
            }
        }
    }
}
Exemplo n.º 17
0
// 텍스트 레이아웃 기능이 없는 단순 출력루틴
float XFontDatFTGL::DrawString( float x, float y, LPCTSTR szString, XCOLOR color, xFONT::xtStyle style )
{
	if( XBREAK(m_font == NULL) )
		return 0;
	if( XE::IsEmpty( szString ) )
		return 0;
	y += GetFontHeight();		// FTGL은 좌표계가 글자의 아랫부분이므로 편의상 글자위 좌상귀가 좌표가 되도록 바꿈
	// 프리타입 폰트는 독자적인 좌표계를 씀. 아래쪽이 0임
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	if( GRAPHICS->GetScreenWidth() > GRAPHICS->GetScreenHeight() )
		glOrthof(0.0f, 1024, 0.0f, 768, -1.0f, 1.0f);
	else
		glOrthof(0.0f, 768, 0.0f, 1024, -1.0f, 1.0f);
	glMatrixMode(GL_MODELVIEW);
	
	XE::VEC2 vc( x, y );	// virtual coodinate
	// 480x320좌표계를 1024x768좌표계로 바꿈
	// 그리고 y좌표를 뒤집음
	To1024Cood( &vc );
//	vc.x = x * (1024.0f / GRAPHICS->GetScreenWidth());	// ex: 1024/480
//	vc.y = 768.0f - (y * (768.0f / GRAPHICS->GetScreenHeight()));	// ex: 768/320
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);	// SprObj쪽에서 이걸 썼을것이므로 해제해줘야 함
	glBindBuffer(GL_ARRAY_BUFFER, 0);

    if( style == xFONT::xSTYLE_SHADOW )
    {
        glPushMatrix();
        glLoadIdentity();
        glTranslatef(vc.x+1.0f, vc.y+1.0f, 0.0f);
        if( color == XCOLOR_BLACK )
            glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        else
            glColor4f(0.0f, 0.0f, 0.0f, 1.0f);

        m_font->Render(szString);
        glPopMatrix();
    }
	float r, g, b, a;
	r = XCOLOR_RGB_R(color) / 255.0f;
	g = XCOLOR_RGB_G(color) / 255.0f;
	b = XCOLOR_RGB_B(color) / 255.f;
	a = XCOLOR_RGB_A(color) / 255.f;
	glColor4f(r, g, b, a);
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(vc.x, vc.y, 0.0f);
	m_font->Render(szString);
	glPopMatrix();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	
	// 좌표계를 원래대로 되돌림
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrthof(0, GRAPHICS->GetScreenWidth(), GRAPHICS->GetScreenHeight(), 0, -1.0f, 1.0f);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	return 0;
}
Exemplo n.º 18
0
void RS_Painter::createEllipse(QPointArray& pa,
                             const RS_Vector& cp,
                             double radius1, double radius2,
                             double angle,
                             double angle1, double angle2,
                             bool reversed)
{


    double aStep;         // Angle Step (rad)
    double a;             // Current Angle (rad)

    aStep=0.01;

    RS_Vector vp;
    RS_Vector vc(cp.x, cp.y);
    vp.set(cp.x+cos(angle1)*radius1,
           cp.y-sin(angle1)*radius2);
    vp.rotate(vc, -angle);

    int i=0;
    pa.resize(i+1);
    pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));

    if(!reversed) {
        // Arc Counterclockwise:
        if(angle1>angle2-RS_TOLERANCE) {
            angle2+=2*M_PI;
        }
        for(a=angle1+aStep; a<=angle2; a+=aStep) {
            vp.set(cp.x+cos(a)*radius1,
                   cp.y-sin(a)*radius2);
            vp.rotate(vc, -angle);

	    pa.resize(i+1);
            pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));
        }
    } else {
        // Arc Clockwise:
        if(angle1<angle2+RS_TOLERANCE) {
            angle2-=2*M_PI;
        }
        for(a=angle1-aStep; a>=angle2; a-=aStep) {
            vp.set(cp.x+cos(a)*radius1,
                   cp.y-sin(a)*radius2);
            vp.rotate(vc, -angle);

	    pa.resize(i+1);
            pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));
        }
    }
    vp.set(cp.x+cos(angle2)*radius1,
           cp.y-sin(angle2)*radius2);
    vp.rotate(vc, -angle);

    pa.resize(i+1);
    pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));

}
Exemplo n.º 19
0
main()
{
 char a[30];
 printf("enter a string: ");
 scanf("%s",a);

   vc(a);
}
Exemplo n.º 20
0
void test_all ()
{
//  Note: The literal values here are tested against directly, careful if you change them:
    BOOST_CXX14_CONSTEXPR int some_numbers[] = { 1, 1, 1, 18, 10 };
    std::vector<int> vi(some_numbers, some_numbers + 5);
    std::list<int>   li(vi.begin(), vi.end ());
    
    int some_letters[] = { 'a', 'q', 'n', 'y', 'n' };
    std::vector<char> vc(some_letters, some_letters + 5);
    
    
    BOOST_CHECK (!ba::all_of_equal ( vi,                                  1 ));
    BOOST_CHECK (!ba::all_of       ( vi,                       is_<int> ( 1 )));
    BOOST_CHECK (!ba::all_of_equal ( vi.begin(),     vi.end(),            1 ));
    BOOST_CHECK (!ba::all_of       ( vi.begin(),     vi.end(), is_<int> ( 1 )));
    
    BOOST_CHECK (!ba::all_of_equal ( vi,                                  0 ));
    BOOST_CHECK (!ba::all_of       ( vi,                       is_<int> ( 0 )));
    BOOST_CHECK (!ba::all_of_equal ( vi.begin(),     vi.end(),            0 ));
    BOOST_CHECK (!ba::all_of       ( vi.begin(),     vi.end(), is_<int> ( 0 )));

    BOOST_CHECK ( ba::all_of_equal ( vi.end(),       vi.end(),            0 ));
    BOOST_CHECK ( ba::all_of       ( vi.end(),       vi.end(), is_<int> ( 0 )));

    BOOST_CHECK ( ba::all_of_equal ( vi.begin(), vi.begin () + 3,            1 ));
    BOOST_CHECK ( ba::all_of       ( vi.begin(), vi.begin () + 3, is_<int> ( 1 )));
    
    BOOST_CHECK ( ba::all_of_equal ( vc.begin() + 1, vc.begin() + 2,             'q' ));
    BOOST_CHECK ( ba::all_of       ( vc.begin() + 1, vc.begin() + 2, is_<char> ( 'q' )));

    BOOST_CHECK (!ba::all_of_equal ( vc,             '!' ));
    BOOST_CHECK (!ba::all_of       ( vc, is_<char> ( '!' )));

    BOOST_CHECK ( ba::all_of_equal ( vi.begin(), vi.begin(),   1 ));
    BOOST_CHECK ( ba::all_of_equal ( vc.begin(), vc.begin(), 'a' ));
    BOOST_CHECK ( ba::all_of       ( vi.begin(), vi.begin(), is_<int>  (   1 )));
    BOOST_CHECK ( ba::all_of       ( vc.begin(), vc.begin(), is_<char> ( 'a' )));

    BOOST_CHECK (!ba::all_of_equal ( li,                                  1 ));
    BOOST_CHECK (!ba::all_of       ( li,                       is_<int> ( 1 )));
    BOOST_CHECK (!ba::all_of_equal ( li.begin(),     li.end(),            1 ));
    BOOST_CHECK (!ba::all_of       ( li.begin(),     li.end(), is_<int> ( 1 )));
    
    std::list<int>::iterator l_iter = li.begin ();
    l_iter++; l_iter++; l_iter++;
    BOOST_CHECK ( ba::all_of_equal ( li.begin(), l_iter,            1 ));
    BOOST_CHECK ( ba::all_of       ( li.begin(), l_iter, is_<int> ( 1 )));

    BOOST_CXX14_CONSTEXPR bool constexpr_res =
        !ba::all_of_equal ( some_numbers, 1 )                               &&
        !ba::all_of       ( some_numbers, is_<int> ( 1 ))                   &&
         ba::all_of_equal ( some_numbers, some_numbers + 3,            1 )  &&
         ba::all_of       ( some_numbers, some_numbers + 3, is_<int> ( 1 )) &&
        true;

    BOOST_CHECK ( constexpr_res );
}
Exemplo n.º 21
0
/**
 * Exports an ellipse with the current attributes.
 * \todo switch from line based interpolation to arcs.
 */
void RExporter::exportEllipse(const REllipse& ellipse, double offset) {
    if (ellipse.getMajorRadius()<RS::PointTolerance ||
            ellipse.getMinorRadius()<RS::PointTolerance) {
        return;
    }

    RPolyline polyline;

    RVector cp = ellipse.getCenter();
    double radius1 = ellipse.getMajorRadius();
    double radius2 = ellipse.getMinorRadius();
    double angle = ellipse.getAngle();
    double a1 = ellipse.getStartParam();
    double a2 = ellipse.getEndParam();
    bool reversed = ellipse.isReversed();

    double aStep;         // Angle Step (rad)
    double a;             // Current Angle (rad)

    aStep=0.05;
    RVector vp;
    RVector vc(cp.x, cp.y);
    vp.set(cp.x+cos(a1)*radius1,
           cp.y+sin(a1)*radius2);
    vp.rotate(angle, vc);
    polyline.appendVertex(vp);
    if (!reversed) {
        // Arc Counterclockwise:
        if (a1>a2-RS::AngleTolerance) {
            a2+=2*M_PI;
        }
        for(a=a1+aStep; a<=a2; a+=aStep) {
            vp.set(cp.x+cos(a)*radius1,
                   cp.y+sin(a)*radius2);
            vp.rotate(angle, vc);
            polyline.appendVertex(vp);
        }
    } else {
        // Arc Clockwise:
        if (a1<a2+RS::AngleTolerance) {
            a2-=2*M_PI;
        }
        for(a=a1-aStep; a>=a2; a-=aStep) {
            vp.set(cp.x+cos(a)*radius1,
                   cp.y+sin(a)*radius2);
            vp.rotate(angle, vc);
            polyline.appendVertex(vp);
        }
    }
    vp.set(cp.x+cos(a2)*radius1,
           cp.y+sin(a2)*radius2);
    vp.rotate(angle, vc);
    polyline.appendVertex(vp);

    exportPolyline(polyline, offset);
}
Exemplo n.º 22
0
void TransferFunctionEditor::loadColorMaps() {

	std::vector< ColorMap > cmaps = ColorMap::load_colormap_directory();

  for (std::vector< ColorMap >::iterator it = cmaps.begin(); it != cmaps.end(); ++it)
	{
		VColorMap vc(*it);
		colorMaps.push_back(vc);
	}
}
Exemplo n.º 23
0
// -------------------------------------------------------------------------
double ctkQImageView::positionValue( void )
{
  Q_D( ctkQImageView );
  if( d->SliceNumber >= 0 && d->SliceNumber < d->ImageList.size() )
    {
    QColor vc( d->ImageList[ d->SliceNumber ].pixel( d->PositionX,
      d->PositionY ) );
    return vc.value();
    }
  return 0;
}
Exemplo n.º 24
0
Components::Components(int _ix_bin, DescFile& desc_file) {
	ix_bin=_ix_bin;

	int in_components; string str_line; stringstream ss;
	
	str_line=desc_file.getline();ss.str(str_line);ss>>in_components;
	members=vc(in_components);
	FORix(in_components) {
		members.at(ix)=new Component(desc_file);
	}
}
Exemplo n.º 25
0
void g() {
    Vector_container vc(10);
    //Container *pc = &vc;
    //use(*pc);
#if 0
    for (int i = 0; i != vc.size(); ++i)
        vc[i] = 'a' + i;
    for (int i = 0; i != vc.size(); ++i)
        std::cout << vc[i] << std::endl;
#endif
}
Exemplo n.º 26
0
/*----------------------------------------------------------------------------------------------
	This constructor uses a UnicodeConverter class method to convert a string from UTF-32 to
	to UTF-8. A char vector is used to receive the result of the conversion. (This is
	considered the safest way to work with the C API, u_strToUTF8(), within
	UnicodeConverter::Convert.)

	Assumptions:
		None

	Exit conditions:
		<text>

	Parameters:
		<text>
----------------------------------------------------------------------------------------------*/
UnicodeString8::UnicodeString8(const wchar_t* source, int sourceLen)
{
	std::vector<char> vc(std::max(sourceLen, 1));

	vc.resize(UnicodeConverter::Convert(source, sourceLen, &vc[0], vc.size()));

	if (vc.size() > std::max(sourceLen, 1))  // was original buffer too small?
		UnicodeConverter::Convert(source, sourceLen, &vc[0], vc.size());

	assign(vc.begin(), vc.begin() + vc.size());
}
Exemplo n.º 27
0
void util::renameProperty(Deserializer& d, std::initializer_list<std::pair<const Property*, std::string>> rules) {
    NodeVersionConverter vc([&rules](TxElement* node) {
        for (auto rule : rules) {
            TxElement* p = util::xmlGetElement(node, "Properties/Property&type=" +
                                               rule.first->getClassIdentifier() +
                                               "&identifier=" + rule.second);
            if (p) p->SetAttribute("identifier", rule.first->getIdentifier());
        }
        return true;
    });
    d.convertVersion(&vc);
}
Exemplo n.º 28
0
GvNode *GvColorGradient::Apply(GTraversal &state, GvNode * node)

{

	if (!RTISA(node,GShell)) return(node);

   float time = 0.0;

   if (cycle) {
         GTimeStack  *ts = (GTimeStack*) state.Get(GTimeStack::attrId);
	      if (ts && ts->time.On()) 
	      	time=ts->time.t;
   }

	GShell *s = (GShell *) node;

	int n= s->v.Length();
	int ax = axis.value;


	PointArray vc(n);

	for(int i=0; i<n; i++) 
	{
		const Point &p =  s->v[i];
		float t;
      // apply mapping 
      switch (ax) {
      case X:  t = p[ax];         break;
      case Y:  t = p[ax];         break;
      case Z:  t = p[ax];         break;
      case RADIAL2:  t = sqrt(sqr(p.x) + sqr(p.y)); break;
      case RADIAL:  t = sqrt(sqr(p.x) + sqr(p.y) + sqr(p.z)); break;
      case SINXY:  t = sin(p.x * TWOPI) * sin(p.y*TWOPI); break;
      default:
               t = p.x;
               break;
      }
      
      t += time;

		t *= scaleFactor;
		vc[i]= Get(t);
    }

	s->SetVC(vc);

	// destory

	return(s);

}
Exemplo n.º 29
0
int main(int argc, char *argv[]) {

	char tab [10] = {'A', 'B', 'C', 'E', 'G', 'I', 'M', 'O', 'P', 'Y'};
	std::vector<char> vi(tab, tab+10);
	std::vector<char> vc(tab, tab+4);

	do
	{
		show_collection(vc);
	} 
	while(next_combination(vi.begin(), vi.end(), vc.begin(), vc.end()));

	return 0; //Huge success!
}
Exemplo n.º 30
0
/*Call functions from threded function*/
void *cnf(void *v)
{
	int r,n;
	int *v1 = (int *)v;
	n=*v1;	
	r=vc(n);
	
	clock_gettime(cid1, &ts1);
	t1 = ts1.tv_sec +ts1.tv_nsec/ 1000000000.0;
	
        pthread_exit (NULL);
	//return NULL;
	
}