📄 dgnhelp.cpp
字号:
if( !psDGN->got_color_table ) { *red = abyDefaultPCT[color_index][0]; *green = abyDefaultPCT[color_index][1]; *blue = abyDefaultPCT[color_index][2]; } else { *red = psDGN->color_table[color_index][0]; *green = psDGN->color_table[color_index][1]; *blue = psDGN->color_table[color_index][2]; } return TRUE;}/************************************************************************//* DGNGetShapeFillInfo() *//************************************************************************//** * Fetch fill color for a shape. * * This method will check for a 0x0041 user attribute linkaged with fill * color information for the element. If found the function returns TRUE, * and places the fill color in *pnColor, otherwise FALSE is returned and * *pnColor is not updated. * * @param hDGN the file. * @param psElem the element. * @param pnColor the location to return the fill color. * * @return TRUE on success or FALSE on failure. */int DGNGetShapeFillInfo( DGNHandle hDGN, DGNElemCore *psElem, int *pnColor ){ 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 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 rad50, char *str ){ unsigned char cTimes; unsigned short value; unsigned short temp; char ch = '\0'; while (rad50 > 0) { value = rad50; cTimes = 0; while (value >= 40) { value /= 40; cTimes ++; } /* Map 0..39 to ASCII */ if (value==0) ch = ' '; /* space */ else if (value >= 1 && value <= 26) ch = value-1+'A';/* printable alpha A..Z */ else if (value == 27) ch = '$'; /* dollar */ else if (value == 28) ch = '.'; /* period */ else if (value == 29) ch = ' '; /* unused char, emit a space instead */ else if (value >= 30 && value <= 39) ch = value-30+'0'; /* digit 0..9 */ *str = ch; str++; temp = 1; while (cTimes-- > 0) temp *= 40; rad50-=value*temp; } /* Do zero-terminate */ *str = '\0';}/************************************************************************//* 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 ){ 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), rnghigh=(%.5f,%.5f)\n", psCell->rnglow.x, psCell->rnglow.y, psCell->rnghigh.x, psCell->rnghigh.y ); fprintf( fp, " origin=(%.5f,%.5f)\n", psCell->origin.x, psCell->origin.y ); fprintf( fp, " xscale=%g, yscale=%g, rotation=%g\n", psCell->xscale, psCell->yscale, psCell->rotation ); } 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; fprintf( fp, " origin=(%.5f,%.5f), rotation=%f\n" " axes=(%.5f,%.5f), start angle=%f, sweep=%f\n", psArc->origin.x, psArc->origin.y, psArc->rotation, 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -