📄 dgnhelp.cpp
字号:
NULL, NULL, &nLinkSize ); if( pabyData == NULL ) return FALSE; if( nLinkType == DGNLT_SHAPE_FILL && nLinkSize >= 7 ) { *pnColor = pabyData[8]; return TRUE; } }}/************************************************************************//* DGNGetAssocID() *//************************************************************************//** * Fetch association id for an element. * * This method will check if an element has an association id, and if so * returns it, otherwise returning -1. Association ids are kept as a * user attribute linkage where present. * * @param hDGN the file. * @param psElem the element. * * @return The id or -1 on failure. */int DGNGetAssocID( DGNHandle hDGN, DGNElemCore *psElem ){ int iLink; for( iLink = 0; TRUE; iLink++ ) { int nLinkType, nLinkSize; unsigned char *pabyData; pabyData = DGNGetLinkage( hDGN, psElem, iLink, &nLinkType, NULL, NULL, &nLinkSize ); if( pabyData == NULL ) return -1; if( nLinkType == DGNLT_ASSOC_ID && nLinkSize >= 8 ) { return pabyData[4] + pabyData[5] * 256 + pabyData[6]*256*256 + pabyData[7] * 256*256*256; } }}/************************************************************************//* DGNRad50ToAscii() *//* *//* Convert one 16-bits Radix-50 to ASCII (3 chars). *//************************************************************************/void DGNRad50ToAscii(unsigned short sRad50, char *str ){ unsigned short sValue; char ch = '\0'; unsigned short saQuots[3] = {1600,40,1}; int i; for ( i=0; i<3; i++) { sValue = sRad50; sValue /= saQuots[i]; /* Map 0..39 to ASCII */ if (sValue==0) ch = ' '; /* space */ else if (sValue >= 1 && sValue <= 26) ch = (char) (sValue-1+'A');/* printable alpha A..Z */ else if (sValue == 27) ch = '$'; /* dollar */ else if (sValue == 28) ch = '.'; /* period */ else if (sValue == 29) ch = ' '; /* unused char, emit a space instead */ else if (sValue >= 30 && sValue <= 39) ch = (char) (sValue-30+'0'); /* digit 0..9 */ *str = ch; str++; sRad50-=(sValue*saQuots[i]); } /* Do zero-terminate */ *str = '\0';}/************************************************************************//* DGNAsciiToRad50() *//************************************************************************/void DGNAsciiToRad50( const char *str, unsigned short *pRad50 ){ unsigned short rad50 = 0; int i; for( i = 0; i < 3; i++ ) { unsigned short value; if( i >= (int) strlen(str) ) { 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_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_COMPLEX_HEADER: { DGNElemComplexHeader *psHdr = (DGNElemComplexHeader *) psElement; fprintf( fp, " totlength=%d, numelems=%d\n", psHdr->totlength, psHdr->numelems ); } 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++ ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -