Ejemplo n.º 1
0
void Delaunay::init(PointVec& points)
{
    total_points_count = (int)points.size();
    mesh.clear();
    for(int i = 0; i < points.size(); i++)
    {
        mesh.add_vertex(points[i]);
    }

    // add properties
    mesh.add_property(FaceToVertices);
    mesh.add_property(VertexToFace);
    mesh.add_property(VertexToHEdge);

    // add infinite vertices
    VHandle vhs[3];
    vhs[0] = mesh.add_vertex(Point(-INF, -INF, 0));
    vhs[1] = mesh.add_vertex(Point(INF, -INF, 0));
    vhs[2] = mesh.add_vertex(Point(0, INF, 0));

    // add the initial triangle
    FHandle fh = mesh.add_face(vhs, 3);

    // link vertex and face
    for(auto& vhi : mesh.vertices())
    {
        mesh.property(FaceToVertices, fh).push_back(vhi);
        mesh.property(VertexToFace, vhi) = fh;
    }
}
Ejemplo n.º 2
0
    bool DelPoint() {
        if (vertex_.size() == Settings::MinPoints)
            return false;

        int idx = RangeRand(vertex_.size());
        PointIt it = vertex_.begin();
        std::advance(it, idx);
        vertex_.erase(it);

        return true;
    }
Ejemplo n.º 3
0
    bool AddPoint() {
        if (vertex_.size() == Settings::MaxPoints)
            return false;

        int idx = RangeRand(vertex_.size());
        PointIt it = vertex_.begin();
        std::advance(it, idx);
        vertex_.insert(it, DnaPoint(RangeRand(Settings::ScreenWidth), 
                                    RangeRand(Settings::ScreenHeight)));

        return true;
    }
Ejemplo n.º 4
0
void Delaunay::addVertices(PointVec& points)
{
    //mesh.clear();
    //for(auto& p : points)
    //    mesh.add_vertex(p);
    mesh.clear();
    for(int i = 0; i < points.size(); i++)
    {
        mesh.add_vertex(points[i]);
    }
}
Ejemplo n.º 5
0
    void Render(Image &dest) const {
        int points = vertex_.size(); 
        Sint16 x[points];
        Sint16 y[points];
        int i = 0;

        for ( PointVec::const_iterator it = vertex_.begin(); 
              it != vertex_.end(); ++it, ++i) {
            x[i] = it->X();
            y[i] = it->Y();
        }

        dest.Polygon(x, y, points, color_);
    }
Ejemplo n.º 6
0
	void RenderEngine::renderPath( Path& path , PointVec& points)
	{
		if ( !points.empty() )
			RenderRT::draw< RenderRT::eXYZ >( GL_LINE_STRIP , &points[0] , points.size() , sizeof( Vec3f ) );
	}