dgnhelp.cpp

来自「支持各种栅格图像和矢量图像读取的库」· C++ 代码 · 共 1,438 行 · 第 1/3 页

CPP
1,438
字号
        {            rad50 = rad50 * 40;            continue;        }        if( str[i] == '$' )            value = 27;        else if( str[i] == '.' )            value = 28;        else if( str[i] == ' ' )            value = 29;        else if( str[i] >= '0' && str[i] <= '9' )            value = str[i] - '0' + 30;        else if( str[i] >= 'a' && str[i] <= 'z' )            value = str[i] - 'a' + 1;        else if( str[i] >= 'A' && str[i] <= 'Z' )            value = str[i] - 'A' + 1;        else            value = 0;        rad50 = rad50 * 40 + value;    }    *pRad50 = rad50;}/************************************************************************//*                        DGNGetLineStyleName()                         *//*                                                                      *//*      Read the line style name from symbol table.                     *//*      The got name is stored in psLine.                               *//************************************************************************/int DGNGetLineStyleName(DGNInfo *psDGN, DGNElemMultiPoint *psLine,                        char szLineStyle[65] ){    if (psLine->core.attr_bytes > 0 &&        psLine->core.attr_data[1] == 0x10 &&        psLine->core.attr_data[2] == 0xf9 &&        psLine->core.attr_data[3] == 0x79)    {#ifdef notdef        for (int i=0;i<SYMBOL_TABLE_SIZE;i++)        {            if (*((unsigned char*)psDGN->buffer + 0x21e5 + i) == psLine->core.attr_data[4] &&                *((unsigned char*)psDGN->buffer + 0x21e6 + i) == psLine->core.attr_data[5] &&                *((unsigned char*)psDGN->buffer + 0x21e7 + i) == psLine->core.attr_data[6] &&                *((unsigned char*)psDGN->buffer + 0x21e8 + i) == psLine->core.attr_data[7])            {                memcpy( szLineStyle,                         (unsigned char*)psDGN->buffer + 0x21e9 + i, 64 );                szLineStyle[64] = '\0';                return TRUE;            }        }#endif        return FALSE;    }    else    {        szLineStyle[0] = '\0';        return FALSE;    }}/************************************************************************//*                           DGNDumpElement()                           *//************************************************************************//** * Emit textual report of an element. * * This function exists primarily for debugging, and will produce a textual * report about any element type to the designated file.  * * @param hDGN the file from which the element originated. * @param psElement the element to report on. * @param fp the file (such as stdout) to report the element information to. */void DGNDumpElement( DGNHandle hDGN, DGNElemCore *psElement, FILE *fp ){    DGNInfo *psInfo = (DGNInfo *) hDGN;    fprintf( fp, "\n" );    fprintf( fp, "Element:%-12s Level:%2d id:%-6d ",             DGNTypeToName( psElement->type ),             psElement->level,              psElement->element_id );    if( psElement->complex )        fprintf( fp, "(Complex) " );    if( psElement->deleted )        fprintf( fp, "(DELETED) " );    fprintf( fp, "\n" );    fprintf( fp, "  offset=%d  size=%d bytes\n",              psElement->offset, psElement->size );    fprintf( fp,              "  graphic_group:%-3d color:%d weight:%d style:%d\n",              psElement->graphic_group,             psElement->color,             psElement->weight,             psElement->style );    if( psElement->properties != 0 )    {        int     nClass;        fprintf( fp, "  properties=%d", psElement->properties );        if( psElement->properties & DGNPF_HOLE )            fprintf( fp, ",HOLE" );        if( psElement->properties & DGNPF_SNAPPABLE )            fprintf( fp, ",SNAPPABLE" );        if( psElement->properties & DGNPF_PLANAR )            fprintf( fp, ",PLANAR" );        if( psElement->properties & DGNPF_ORIENTATION )            fprintf( fp, ",ORIENTATION" );        if( psElement->properties & DGNPF_ATTRIBUTES )            fprintf( fp, ",ATTRIBUTES" );        if( psElement->properties & DGNPF_MODIFIED )            fprintf( fp, ",MODIFIED" );        if( psElement->properties & DGNPF_NEW )            fprintf( fp, ",NEW" );        if( psElement->properties & DGNPF_LOCKED )            fprintf( fp, ",LOCKED" );        nClass = psElement->properties & DGNPF_CLASS;        if( nClass == DGNC_PATTERN_COMPONENT )            fprintf( fp, ",PATTERN_COMPONENT" );        else if( nClass == DGNC_CONSTRUCTION_ELEMENT )            fprintf( fp, ",CONSTRUCTION ELEMENT" );        else if( nClass == DGNC_DIMENSION_ELEMENT )            fprintf( fp, ",DIMENSION ELEMENT" );        else if( nClass == DGNC_PRIMARY_RULE_ELEMENT )            fprintf( fp, ",PRIMARY RULE ELEMENT" );        else if( nClass == DGNC_LINEAR_PATTERNED_ELEMENT )            fprintf( fp, ",LINEAR PATTERNED ELEMENT" );        else if( nClass == DGNC_CONSTRUCTION_RULE_ELEMENT )            fprintf( fp, ",CONSTRUCTION_RULE_ELEMENT" );                    fprintf( fp, "\n" );    }    switch( psElement->stype )    {      case DGNST_MULTIPOINT:      {          DGNElemMultiPoint     *psLine = (DGNElemMultiPoint *) psElement;          int                   i;                    for( i=0; i < psLine->num_vertices; i++ )              fprintf( fp, "  (%.6f,%.6f,%.6f)\n",                        psLine->vertices[i].x,                        psLine->vertices[i].y,                        psLine->vertices[i].z );      }      break;      case DGNST_CELL_HEADER:      {          DGNElemCellHeader     *psCell = (DGNElemCellHeader*) psElement;          fprintf( fp, "  totlength=%d, name=%s, class=%x, levels=%02x%02x%02x%02x\n",                   psCell->totlength, psCell->name, psCell->cclass,                   psCell->levels[0], psCell->levels[1], psCell->levels[2],                   psCell->levels[3] );          fprintf( fp, "  rnglow=(%.5f,%.5f,%.5f)\n"                       "  rnghigh=(%.5f,%.5f,%.5f)\n",                   psCell->rnglow.x, psCell->rnglow.y, psCell->rnglow.z,                   psCell->rnghigh.x, psCell->rnghigh.y, psCell->rnghigh.z );          fprintf( fp, "  origin=(%.5f,%.5f,%.5f)\n",                   psCell->origin.x, psCell->origin.y, psCell->origin.z);                    if( psInfo->dimension == 2 )              fprintf( fp, "  xscale=%g, yscale=%g, rotation=%g\n",                       psCell->xscale, psCell->yscale, psCell->rotation );          else              fprintf( fp, "  trans=%g,%g,%g,%g,%g,%g,%g,%g,%g\n",                       psCell->trans[0],                       psCell->trans[1],                       psCell->trans[2],                       psCell->trans[3],                       psCell->trans[4],                       psCell->trans[5],                       psCell->trans[6],                       psCell->trans[7],                       psCell->trans[8] );      }      break;      case DGNST_CELL_LIBRARY:      {          DGNElemCellLibrary    *psCell = (DGNElemCellLibrary*) psElement;          fprintf( fp,                    "  name=%s, class=%x, levels=%02x%02x%02x%02x, numwords=%d\n",                    psCell->name, psCell->cclass,                    psCell->levels[0], psCell->levels[1], psCell->levels[2],                    psCell->levels[3], psCell->numwords );          fprintf( fp, "  dispsymb=%d, description=%s\n",                    psCell->dispsymb, psCell->description );      }      break;      case DGNST_SHARED_CELL_DEFN:      {          DGNElemSharedCellDefn *psShared = (DGNElemSharedCellDefn *) psElement;          fprintf( fp, "  totlength=%d\n", psShared->totlength);      }      break;      case DGNST_ARC:      {          DGNElemArc    *psArc = (DGNElemArc *) psElement;          if( psInfo->dimension == 2 )              fprintf( fp, "  origin=(%.5f,%.5f), rotation=%f\n",                       psArc->origin.x,                        psArc->origin.y,                        psArc->rotation );          else              fprintf( fp, "  origin=(%.5f,%.5f,%.5f), quat=%d,%d,%d,%d\n",                       psArc->origin.x,                        psArc->origin.y,                        psArc->origin.z,                        psArc->quat[0],                        psArc->quat[1],                        psArc->quat[2],                        psArc->quat[3] );          fprintf( fp, "  axes=(%.5f,%.5f), start angle=%f, sweep=%f\n",                    psArc->primary_axis,                   psArc->secondary_axis,                   psArc->startang,                   psArc->sweepang );                         }      break;      case DGNST_TEXT:      {          DGNElemText   *psText = (DGNElemText *) psElement;          fprintf( fp,                    "  origin=(%.5f,%.5f), rotation=%f\n"                   "  font=%d, just=%d, length_mult=%g, height_mult=%g\n"                   "  string = \"%s\"\n",                   psText->origin.x,                    psText->origin.y,                    psText->rotation,                   psText->font_id,                   psText->justification,                   psText->length_mult,                   psText->height_mult,                   psText->string );      }      break;      case DGNST_TEXT_NODE:      {          DGNElemTextNode *psNode = (DGNElemTextNode *) psElement;          fprintf( fp,                    "  totlength=%d, num_texts=%d\n",                   psNode->totlength,                   psNode->numelems );          fprintf( fp,                    "  origin=(%.5f,%.5f), rotation=%f\n"                   "  font=%d, just=%d, length_mult=%g, height_mult=%g\n",                   psNode->origin.x,                    psNode->origin.y,                    psNode->rotation,                   psNode->font_id,                   psNode->justification,                   psNode->length_mult,                   psNode->height_mult );          fprintf( fp, 		   "  max_length=%d, used=%d,",		   psNode->max_length, 		   psNode->max_used );          fprintf( fp, 		   "  node_number=%d\n", 		   psNode->node_number );      }      break;      case DGNST_COMPLEX_HEADER:      {          DGNElemComplexHeader  *psHdr = (DGNElemComplexHeader *) psElement;          fprintf( fp,                    "  totlength=%d, numelems=%d\n",                   psHdr->totlength,                   psHdr->numelems );          if (psElement->type  == DGNT_3DSOLID_HEADER ||              psElement->type  == DGNT_3DSURFACE_HEADER) {            fprintf( fp,                      "  surftype=%d, boundelms=%d\n",                      psHdr->surftype, psHdr->boundelms );          }      }      break;      case DGNST_COLORTABLE:      {          DGNElemColorTable *psCT = (DGNElemColorTable *) psElement;          int                   i;          fprintf( fp, "  screen_flag: %d\n", psCT->screen_flag );          for( i = 0; i < 256; i++ )          {              fprintf( fp, "  %3d: (%3d,%3d,%3d)\n",                       i,                        psCT->color_info[i][0],                        psCT->color_info[i][1],                        psCT->color_info[i][2] );          }      }      break;      case DGNST_TCB:      {          DGNElemTCB *psTCB = (DGNElemTCB *) psElement;          int iView;          fprintf( fp, "  dimension = %d\n", psTCB->dimension );          fprintf( fp, "  uor_per_subunit = %ld, subunits = `%s'\n",                   psTCB->uor_per_subunit, psTCB->sub_units );          fprintf( fp, "  subunits_per_master = %ld, master units = `%s'\n",                   psTCB->subunits_per_master, psTCB->master_units );          fprintf( fp, "  origin = (%.5f,%.5f,%.5f)\n",                    psTCB->origin_x,                   psTCB->origin_y,                   psTCB->origin_z );          for( iView = 0; iView < 8; iView++ )          {              DGNViewInfo *psView = psTCB->views + iView;                            fprintf(fp,                       "  View%d: flags=%04X, levels=%02X%02X%02X%02X%02X%02X%02X%02X\n",                      iView,                      psView->flags,                       psView->levels[0],                      psView->levels[1],                      psView->levels[2],                      psView->levels[3],                      psView->levels[4],                      psView->levels[5],                      psView->levels[6],                      psView->levels[7] );              fprintf(fp,                       "        origin=(%g,%g,%g)\n        delta=(%g,%g,%g)\n",                       psView->origin.x, psView->origin.y, psView->origin.z,                      psView->delta.x, psView->delta.y, psView->delta.z );              fprintf(fp,                       "       trans=(%g,%g,%g,%g,%g,%g,%g,%g,%g)\n",                      psView->transmatrx[0],                      psView->transmatrx[1],                      psView->transmatrx[2],                      psView->transmatrx[3],                      psView->transmatrx[4],                      psView->transmatrx[5],                      psView->transmatrx[6],                      psView->transmatrx[7],                      psView->transmatrx[8] );          }      }      break;      case DGNST_TAG_SET:      {          DGNElemTagSet *psTagSet = (DGNElemTagSet*) psElement;          int            iTag;          fprintf( fp, "  tagSetName=%s, tagSet=%d, tagCount=%d, flags=%d\n",                    psTagSet->tagSetName, psTagSet->tagSet,                    psTagSet->tagCount, psTagSet->flags );          for( iTag = 0; iTag < psTagSet->tagCount; iTag++ )          {              DGNTagDef *psTagDef = psTagSet->tagList + iTag;              fprintf( fp, "    %d: name=%s, type=%d, prompt=%s",                        psTagDef->id, psTagDef->name, psTagDef->type,                        psTagDef->prompt );              if( psTagDef->type == 1 )                  fprintf( fp, ", default=%s\n",                            psTagDef->defaultValue.string );              else if( psTagDef->type == 3 || psTagDef->type == 5 )                  fprintf( fp, ", default=%d\n",                            psTagDef->defaultValue.integer );              else if( psTagDef->type == 4 )                  fprintf( fp, ", default=%g\n",                            psTagDef->defaultValue.real );              else                  fprintf( fp, ", default=<unknown>\n" );          }      }      break;      case DGNST_TAG_VALUE:      {          DGNElemTagValue *psTag = (DGNElemTagValue*) psElement;          fprintf( fp, "  tagType=%d, tagSet=%d, tagIndex=%d, tagLength=%d\n",                    psTag->tagType, psTag->tagSet, psTag->tagIndex,                    psTag->tagLength );          if( psTag->tagType == 1 )              fprintf( fp, "  value=%s\n", psTag->tagValue.string );          else if( psTag->tagType == 3 )              fprintf( fp, "  value=%d\n", psTag->tagValue.integer );          else if( psTag->tagType == 4 )              fprintf( fp, "  value=%g\n", psTag->tagValue.real );      }      break;      case DGNST_CONE:      {          DGNElemCone *psCone = (DGNElemCone *) psElement;          fprintf( fp,                    "  center_1=(%g,%g,%g) radius=%g\n"                   "  center_2=(%g,%g,%g) radius=%g\n"                   "  quat=%d,%d,%d,%d unknown=%d\n",                    psCone->center_1.x, psCone->center_1.y, psCone->center_1.z,                   psCone->radius_1,                    psCone->center_2.x, psCone->center_2.y, psCone->center_2.z,                   psCone->radius_2,                    psCone->quat[0], psCone->quat[1],                   psCone->quat[2], psCone->quat[3],                   psCone->unknown );      }      break;      case DGNST_BSPLINE_SURFACE_HEADER:      {          DGNElemBSplineSurfaceHeader *psSpline =            (DGNElemBSplineSurfaceHeader *) psElement;          fprintf( fp, "  desc_words=%ld, curve type=%d\n",                   psSpline->desc_words, psSpline->curve_type);          fprintf( fp, "  U: properties=%02x",                   psSpline->u_properties);          if (psSpline->u_properties != 0) {            if (psSpline->u_properties & DGNBSC_CURVE_DISPLAY) {              fprintf(fp, ",CURVE_DISPLAY");            }            if (psSpline->u_properties & DGNBSC_POLY_DISPLAY) {              fprintf(fp, ",POLY_DISPLAY");            }            if (psSpline->u_properties & DGNBSC_RATIONAL) {              fprintf(fp, ",RATIONAL");            }            if (psSpline->u_properties & DGNBSC_CLOSED) {              fprintf(fp, ",CLOSED");            }          }          fprintf(fp, "\n");          fprintf( fp, "     order=%d\n  %d poles, %d knots, %d rule lines\n",                   psSpline->u_order, psSpline->num_poles_u,                    psSpline->num_knots_u, psSpline->rule_lines_u);          fprintf( fp, "  V: properties=%02x",                   psSpline->v_properties);          if (psSpline->v_properties != 0) {            if (psSpline->v_properties & DGNBSS_ARC_SPACING) {              fprintf(fp, ",ARC_SPACING");            }            if (psSpline->v_properties & DGNBSS_CLOSED) {              fprintf(fp, ",CLOSED");            }          }          fprintf(fp, "\n");          fprintf( fp, "     order=%d\n  %d poles, %d knots, %d rule lines\n",

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?