Example #1
0
void Game::Draw3dLab()
{
	db3D.clear();
	db3D.setBgColor(WHITE);
	db3D.setTxtColor(BLACK);
	db3DP.clear();
	db3DP.setBgColor(WHITE);
	db3DP.setTxtColor(BLACK);

	int wall_num = 0, middle_wall_type=0;
	int leftWalls[8], rightWalls[8];
	pixel tmpPx = {0,0,0};
	getProjection(middle_wall_type,wall_num, leftWalls, rightWalls);
	drawEdge(0, &db3D);
	drawEdge(0, &db3DP);
	for (int i = 0; i < wall_num; i++) {
		if (leftWalls[i] == BLOCK_EMPTY){
			if (leftWalls[i + 1]!=BLOCK_EMPTY){
			fillWall(i + 1, true, Game::block_types[leftWalls[i + 1]], &db3D);
			drawTopEdge(i + 1, true, &db3D);
			drawBottomEdge(i + 1, true, &db3D);
			}
		}
		else {
			fillWall(i + 1, false, Game::block_types[leftWalls[i]], &db3D);
			drawTopEdge(i+1, false, &db3D);
			drawBottomEdge(i+1, false, &db3D);
		}
		drawEdge(i+1, &db3D);

		if (rightWalls[i] == BLOCK_EMPTY) {
			if (rightWalls[i + 1]!=BLOCK_EMPTY){
			fillWall(i + 1, true, Game::block_types[rightWalls[i + 1]], &db3DP);
			drawTopEdge(i + 1, true, &db3DP);
			drawBottomEdge(i + 1, true, &db3DP);
			}
		}
		else {
			fillWall(i + 1, false, Game::block_types[rightWalls[i]], &db3DP);
			drawTopEdge(i + 1, false, &db3DP);
			drawBottomEdge(i + 1, false, &db3DP);
		}
		drawEdge(i + 1, &db3DP);
	}
    db3DP.flip();
	db3D.paintFrom(db3DP);
	drawFrontWall(wall_num, middle_wall_type);
}
void COverlappedWindow::drawEdges(HDC paintDC, const RECT& rect) {
	if (isGameStarted) {
		for (Edge e : game.getEdges()) {
			drawEdge(paintDC, rect, e);
		}
	}
}
Example #3
0
void drawAllNodesEdges()
{
	for(int i = 0 ; i < edgeCount; i++)
		drawEdge(&edgeList[i], edgeList[i].color, edgeList[i].weight);
	for(ADJ_LIST *header = adjListBeg; header != NULL; header = header->down)
		drawNode(header->node);
}
Example #4
0
void GraphDrawer::drawEdges(const EdgeDrawParamsMap &edges)
{
    for (auto &p : edges)
    {
        drawEdge(p.first->from, p.first->to, p.second.color, p.second.width);
    }
}
void MaxFlowVisualizer::showEdges(QPainter &painter) {
    for (VertexIndex vertex = 0; vertex < relabelToFrontAlgo.getNetwork().getVerticesNumber(); ++vertex) {
        auto adjacentEdgesList = relabelToFrontAlgo.getNetwork().getEdgesListFromVertex(vertex);
        for (Edge edge : adjacentEdgesList) {
            if (edge.getCapacity() != 0) {
                drawEdge(edge, painter);
            }
        }
    }
}
Example #6
0
/*
 * Traverse the graph and draw all the elements. The order of edges vs nodes
 * doesn't matter here since the groups are already in the correct order.
 */
void SVG_Image::drawGraph(const Graph& g, unsigned int layoutGridSize)
{
    gridSize = layoutGridSize;
    hexWidth = getHexagonWidth(gridSize);
    std::cout << "Drawing a graph, gridsize = " << gridSize << std::endl;
    // Try to come up with good size for nodes and edges.
    nodeRadius = 0.2*hexWidth;
    nodeThickness = 0*nodeRadius;
    edgeThickness = 0.1*nodeRadius;
    init_xml();
    for(auto node : g.nodes) {
        drawNode(node.first);
        for(auto to : node.second) {
            drawEdge(node.first, to);
        }
    }
}
Example #7
0
void DrawGame::CircleSprite::draw()
{
  // 显示圆形	
  ofPushMatrix();	 
  ofTranslate(ofPoint(X,Y)); 
  ofRotate(Rot,0,0,1); 
  ofScale(Size,Size,1.0f);   
  drawFill();  
  drawEdge();  
  ofPopMatrix();

  // 显示表情
  ofPushMatrix();
  ofTranslate(ofPoint(X,Y));
  ofRotate(Rot,0,0,1);	 
  ofScale(Size,Size,1.0f);  
  drawFace();
  ofPopMatrix();
}
void GraphView::paintEvent(QPaintEvent*){
    QPixmap backbuffer;
    backbuffer.convertFromImage (image);
    QPainter paint(&backbuffer);
    if(disc){
        for(int i = 0; i < disc->numEdge; i++){
            int x1,y1,x2,y2;
            getPoint(x1, y1, disc->verts[disc->edges[i].vert1]);
            getPoint(x2, y2, disc->verts[disc->edges[i].vert2]);
            drawEdge(paint,x1,y1,x2,y2);
        }
        for(int i = 0; i < disc->numVert; i++){
            int x,y;
            getPoint(x, y, disc->verts[i]);
            drawCrossHair(paint,x,y);
        }
    }
    paint.end();
    bitBlt(this,0,0,&backbuffer,0,0,width(),height(),CopyROP,FALSE);
}
      static void traceIntersectionGraph(const V2Set &shared_edges,
                                         const FLGroupList & /* a_loops_grouped */,
                                         const FLGroupList & /* b_loops_grouped */,
                                         const carve::csg::detail::LoopEdges &a_edge_map,
                                         const carve::csg::detail::LoopEdges &b_edge_map) {

        carve::csg::detail::VVSMap shared_edge_graph;
        carve::csg::detail::VSet branch_points;

        // first, make the intersection graph.
        for (V2Set::const_iterator i = shared_edges.begin(); i != shared_edges.end(); ++i) {
          const V2Set::key_type &edge = (*i);
          carve::csg::detail::VVSMap::mapped_type &out = (shared_edge_graph[edge.first]);
          out.insert(edge.second);
          if (out.size() == 3) branch_points.insert(edge.first);

#if defined(CARVE_DEBUG) && defined(DEBUG_DRAW_INTERSECTION_LINE)
          HOOK(drawEdge(edge.first, edge.second, 1, 1, 1, 1, 1, 1, 1, 1, 1.0););
#endif
        }
Example #10
0
void GraphDrawer::drawEdges()
{
    if (changed)
    {
        //ci::app::console() << "Redrawing edges" << std::endl;
        ci::gl::ScopedFramebuffer scpFbEdge(edgeFbo);
        ci::gl::ScopedViewport scpVpEdge(edgeFbo->getSize());
        
        ci::gl::pushMatrices();
        ci::gl::setMatricesWindow(edgeFbo->getSize());
        ci::gl::clear(ci::ColorA(0, 0, 0, 0.0f));

        for (int nodeIdx = 0; nodeIdx < g->getNodeCount(); ++nodeIdx)
        {
            auto &node = g->getNode(nodeIdx);
            for (auto &edge : node)
            {
                drawEdge(edge.from, edge.to, colorScheme.edgeColor, settings.edgeWidth);
            }
        }
        ci::gl::popMatrices();
    }
    ci::gl::draw(edgeFbo->getColorTexture());
}
void* edge_event(void* args) {
    ImageDB *imgdb = (ImageDB*)args;
    ImageList *current = imgdb->imglists[imgdb->current_id];

#if ShowEdgeResult
    boost::shared_ptr<pcl::visualization::PCLVisualizer> edge_viewer (new pcl::visualization::PCLVisualizer ("EdgeViewer"));
    edge_viewer->setBackgroundColor (0, 0, 0);
    edge_viewer->addPointCloud (current->cloud, "base cloud");
    drawEdge(current->edge, current->cloud, 1, edge_viewer);
    while (!edge_viewer->wasStopped()) {
        edge_viewer->spinOnce(100);
    }
#else
    drawEdge(current->edge, current->cloud, 1);
#endif

    printf("finished egde detect %d\n", current->id);

    if (imgdb->local_viewer) {
        char final_edge_name[20];
        sprintf(final_edge_name, "cloud_%d", current->id);

        imgdb->local_viewer->removeAllShapes();
        imgdb->local_viewer->removeAllPointClouds();
        imgdb->local_viewer->addPointCloud(current->cloud, final_edge_name);
        //imgdb->local_viewer->spinOnce(100);
        
        for (int i = 0; i < current->edge.size(); i++) {
            vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New ();
            vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New ();
            vtkSmartPointer<vtkPolyLine> polyLine = vtkSmartPointer<vtkPolyLine>::New ();
            for (int j = 0; j < current->edge[i].size()-1; j++) {
                points->InsertNextPoint(current->edge[i][j].data);
                points->InsertNextPoint(current->edge[i][j+1].data);
            }
            points->InsertNextPoint(current->edge[i][current->edge[i].size()-1].data);
            points->InsertNextPoint(current->edge[i][0].data);

            vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New ();
            // Add the points to the dataset
            polyData->SetPoints (points);
            polyLine->GetPointIds  ()->SetNumberOfIds(points->GetNumberOfPoints ());
            for(unsigned int j= 0; j < points->GetNumberOfPoints (); j++)
                polyLine->GetPointIds ()->SetId (j,j);
            cells->InsertNextCell (polyLine);
            // Add the lines to the dataset
            polyData->SetLines (cells);
            sprintf(final_edge_name, "final_edge_%d", i);
            imgdb->local_viewer->addModelFromPolyData (polyData, final_edge_name);
        }
        //while (!imgdb->local_viewer->wasStopped()) 
imgdb->local_viewer->spinOnce(100);
        //imgdb->local_viewer->resetStoppedFlag();
        printf("+========  %d ========\n===============\n", current->id);
    }


    imgdb->edge_thread_in_use = false;
    if (!imgdb->qby_thread_in_use) imgdb->edge_thread_item = current;

    return NULL;
}
 void SimpleDotVisitor::handle(osg::Drawable&, osg::StateSet&, int parentID, int childID ) {
   drawEdge( parentID, childID, "dashed" );
 }
 void SimpleDotVisitor::handle(osg::Group&, osg::Node&, int parentID, int childID ) {
   drawEdge( parentID, childID, "setlinewidth(2)" );
 }
void SimpleDotVisitor::handle(osg::Geode &geode, osg::Drawable &drawable, int parentID, int childID)
{
    drawEdge(parentID, childID, "dashed");
}
void SimpleDotVisitor::handle(osg::Node &node, osg::StateSet &stateset, int parentID, int childID)
{
    drawEdge(parentID, childID, "dashed");
}