コード例 #1
0
 void circle::makeCurrentCircle() {
      // Make the figure represent the current circle.
      
        removeAllComponents();
        insertArc(currentX, currentY, currentR, 0.0, 360.0);
      
 }
コード例 #2
0
void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& aData )
{
    // Currently, Pcbnew does not know polylines, for boards.
    // So we have to convert a polyline to a set of segments.
    // The import is a simplified import: the width of segment is
    // (obviously constant and is the width of the DRW_LWPolyline.
    // the variable width of each vertex (when exists) is not used.
    wxRealPoint seg_start;
    wxRealPoint poly_start;
    double bulge = 0.0;
    int lineWidth = mapDim( aData.thickness == 0 ? m_defaultThickness
                            : aData.thickness );

    for( unsigned ii = 0; ii < aData.vertlist.size(); ii++ )
    {
        DRW_Vertex2D* vertex = aData.vertlist[ii];

        if( ii == 0 )
        {
            seg_start.x = m_xOffset + vertex->x * m_DXF2mm;
            seg_start.y = m_yOffset - vertex->y * m_DXF2mm;
            bulge = vertex->bulge;
            poly_start = seg_start;
            continue;
        }

        wxRealPoint seg_end( m_xOffset + vertex->x * m_DXF2mm, m_yOffset - vertex->y * m_DXF2mm );

        if( std::abs( bulge ) < MIN_BULGE )
            insertLine( seg_start, seg_end, lineWidth );
        else
            insertArc( seg_start, seg_end, bulge, lineWidth );

        bulge = vertex->bulge;
        seg_start = seg_end;
    }

    // LWPolyline flags bit 0 indicates closed (1) or open (0) polyline
    if( aData.flags & 1 )
    {
        if( std::abs( bulge ) < MIN_BULGE )
            insertLine( seg_start, poly_start, lineWidth );
        else
            insertArc( seg_start, poly_start, bulge, lineWidth );
    }
}
コード例 #3
0
ファイル: Random_Dijkstra.cpp プロジェクト: crispyrusk/ivp
void ArcWeightedDiGraph::constructGraphFromArcs(std::string graph) {
  auto itMover = graph.begin();
  while (itMover != graph.end()) {
    auto openBraceIt = std::find(itMover, graph.end(), '(');
    auto closeBraceIt = std::find(itMover, graph.end(), ')');
    if (openBraceIt == graph.end() || closeBraceIt == graph.end()) { return; }
    assert(openBraceIt + 1 != graph.end());
    auto posOpenBracePlusOne = std::distance(graph.begin(), openBraceIt + 1);
    auto len = std::distance(openBraceIt + 1, closeBraceIt);
    insertArc(graph.substr(posOpenBracePlusOne, len));
    itMover = closeBraceIt + 1;
  }
}
コード例 #4
0
ファイル: PROCS.C プロジェクト: 8l/dcc
boolT insertCallGraph (PCALL_GRAPH pcallGraph, PPROC caller, PPROC callee)
/* Inserts a (caller, callee) arc in the call graph tree. */
{ Int i;

    if (pcallGraph->proc == caller)
    {
        insertArc (pcallGraph, callee);
        return (TRUE);
    }
    else
    {
        for (i = 0; i < pcallGraph->numOutEdges; i++)
            if (insertCallGraph (pcallGraph->outEdges[i], caller, callee))
                return (TRUE);
        return (FALSE);
    }
}
コード例 #5
0
ファイル: graph.cpp プロジェクト: alonsovb/datos-grafos2
bool graph::processArc(string line) {
    try {
        int last = 0;
        for (unsigned int i = 0; i < line.length(); i++) {
            if (line.at(i) == ';') {
                string sub = line.substr(last, i - last + 1);

                int dist; vert *start, *end;
                int slast = 0, type = 0;
                for (unsigned int j = 0; j < sub.length(); j++) {
                    if (sub.at(j) == ',' || sub.at(j) == ';' || j == sub.length() - 1) {
                        switch (type) {
                        case 0:
                            dist = atoi(sub.substr(slast, j - slast).c_str());
                            break;
                        case 1:
                            start = findVert(atoi(sub.substr(slast, j - slast).c_str()));
                            break;
                        case 2:
                            end = findVert(atoi(sub.substr(slast, j - slast).c_str()));
                            break;
                        default:
                            break;
                        }
                        slast = j + 1;
                        type++;
                    }
                }
                if (start != NULL && end != NULL) {
                    arc *narc = new arc(arcc++, dist, start, end);
                    insertArc(narc);
                    start->insArc(narc);
                    end->insArc(narc);
                }
                last = i + 1;
            }
        }
        return true;
    } catch (exception e) {
        return false;
    }
}
コード例 #6
0
ファイル: test2.c プロジェクト: lubing521/wifi-bus-app
int main(int argc, char*argv[]){
 
 ALGraph G;
 ALGraph* GPt = &G;
 initALGraph(GPt,1000);
 #if 0
 initALGraph(GPt,6);

 insertArc(GPt,0,1,7);
 
 insertArc(GPt,0,2,9);
 insertArc(GPt,0,5,14);
 insertArc(GPt,1,2,10);
 insertArc(GPt,1,3,15);
 insertArc(GPt,2,5,2);
 insertArc(GPt,2,3,10);
 insertArc(GPt,5,4,9);
 insertArc(GPt,3,4,6);
 insertArc(GPt,4,3,6);
#endif 
 #if 1
   sqlite3 *db;
    char *zErrMsg = 0;
    int rc, ret = 0, j,i, row_count = 0;
    printf("sqlite3 info:\n libversion:%s\n souceid:%s\n vesion_num:%d\n",sqlite3_libversion(), sqlite3_sourceid(),
      sqlite3_libversion_number());
  sqlite3_stmt *pStmt = NULL;
  
    if( argc < 3 ){
      fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
      return(1);
    }
    rc = sqlite3_open(argv[1], &db);
    if( rc ){
      fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
      sqlite3_close(db);
      return(1);
    }

    rc = sqlite3_prepare(db, argv[2], strlen(argv[2]), &pStmt, NULL);
    printf("rc =%d\n", rc);
  if(rc != SQLITE_OK){
    fprintf(stderr, "SQL error1: %s\n", zErrMsg);
    sqlite3_free(zErrMsg);
    return 1;
  }
  
  printf("pStmt=%p\n",pStmt);
  ret = sqlite3_column_count(pStmt);
  printf("BEFORE STEP col count= %d, rc = %d\n", ret, rc);
   printf("pStmt22=%p\n",pStmt);
  i = 0;
  //´òÓ¡colÃû³Æ
  while(i < ret){
    printf("%20s \t %d \t %20s \t %d\n",
      sqlite3_column_name(pStmt, i),
      sqlite3_column_type(pStmt, i),
      sqlite3_column_decltype(pStmt, i),
      sqlite3_column_bytes(pStmt, i));
    i++;
  }
  printf("pStmt23=%p\n",pStmt);
 

 
  printf("\n------ ------ ------ ------ ------------ ------ ------ ------\n");
  printf("pStmt2=%p\n",pStmt);
  rc = sqlite3_step(pStmt);
   printf("pStmt3=%p\n",pStmt);
    STRACE
  if(rc != SQLITE_ROW){
          fprintf(stderr, "SQL error2: %s,rc =%d\n", zErrMsg, rc);
          sqlite3_free(zErrMsg);
    return 1;
  }
  STRACE
  //¿ªÊ¼¶ÁȡÿһÐÐ
  while(rc == SQLITE_ROW){
    //STRACE
    i = 0;row_count++;
    // for(j=0;j< ret;j++){
    //   printf("%s ", sqlite3_column_text(pStmt,j));
    // }
    //printf("%d -> %d w:%d\n", sqlite3_column_int(pStmt,1), sqlite3_column_int(pStmt,2), sqlite3_column_int(pStmt,4));
    insertArc(GPt,sqlite3_column_int(pStmt,1), sqlite3_column_int(pStmt,2), sqlite3_column_int(pStmt,4));
    #if 0
    printf("%d, %s, %s, %s\n",
      sqlite3_column_int(pStmt, 0),
      sqlite3_column_text(pStmt, 1),
      sqlite3_column_text(pStmt, 2),
      sqlite3_column_text(pStmt, 3));
    #endif
    rc = sqlite3_step(pStmt);
  }
  STRACE
  printf("row_count=%d\n ", row_count);
  sqlite3_finalize(pStmt);

    sqlite3_close(db);
#endif
 G.vexnum = row_count;
 printf("显示出此构造的图:\n");
 //displayGraph(G);
 printf("\n");
 
 int d[MAX_VERTEX_NUM];
 int pi[MAX_VERTEX_NUM];
 int Q[MAX_VERTEX_NUM+1]; 
        //Q[]的第一个元素只保存堆的大小,不保存元素。所以定义长度时+1

 dijkstra(G,1,d,pi,Q);
STRACE
    i= atoi(argv[3]);
    printf("从源点1到点%d的最短路径信息:\n",i);
    printf("长度为%d\n",d[i]);
    printf("路径为: %d ", i);
    for(j=i;j>1;){
     printf("%d ",pi[j]);
     j=pi[j];
    }
    printf("\n");

 // for(i=1;i<G.vexnum;i++){
  
 //  printf("从源点1到点%d的最短路径信息:\n",i);
 //  printf("长度为%d\n",d[i]);
 //  printf("路径为: %d ", i);
 //  for(j=i;j>0;){
 //  	printf("%d ",pi[j]);
 //  	j=pi[j];
 //  }
 
 //}
 return 0; 
}