📄 dgnhelp.cpp
字号:
/****************************************************************************** * $Id: dgnhelp.cpp,v 1.24 2004/09/15 16:06:19 fwarmerdam Exp $ * * Project: Microstation DGN Access Library * Purpose: Application visible helper functions for parsing DGN information. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 2002, Avenza Systems Inc, http://www.avenza.com/ * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * $Log: dgnhelp.cpp,v $ * Revision 1.24 2004/09/15 16:06:19 fwarmerdam * Report 3D Cell header better. * * Revision 1.23 2004/09/15 16:00:47 fwarmerdam * Report 3D values for Cell Header range and origin. * * Revision 1.22 2004/09/15 14:06:25 fwarmerdam * added dumping of cone in DGNDumpElement() * A bunch of changes related to quaternion handling... not sure if it all * is working or not. Contributed by user. * * Revision 1.21 2003/12/01 16:58:13 warmerda * Replaced DGNRad50ToAscii() with new implementation from Armin Berg. * This one correctly decodes values with embedded spaces, though I am * not certain it always trims spaces (assuming that is desirable). * * Revision 1.20 2003/09/11 20:00:28 warmerda * avoid casting warning in Quat to Matrix func * * Revision 1.19 2003/08/19 20:16:14 warmerda * Added support for CONE and 3D solid/surface header. * Implemented DGNQuaternionToMatrix function. * Marius Kintel * * Revision 1.18 2003/06/27 14:38:26 warmerda * avoid warnings * * Revision 1.17 2003/05/21 03:42:01 warmerda * Expanded tabs * * Revision 1.16 2003/05/15 14:47:23 warmerda * implement quaternion support on write * * Revision 1.15 2003/05/12 18:48:57 warmerda * added preliminary 3D write support * * Revision 1.14 2003/01/20 20:05:01 warmerda * added DGNAsciiToRad50() * * Revision 1.13 2003/01/09 14:59:47 warmerda * fixed DGNGetLinkage() test for DMRS linkages as provided by Henk Jan Priester * * Revision 1.12 2002/11/13 21:26:32 warmerda * added more documentation * * Revision 1.11 2002/11/12 19:44:17 warmerda * added view display * * Revision 1.10 2002/10/07 13:14:18 warmerda * added association id support * * Revision 1.9 2002/05/31 03:40:22 warmerda * added improved support for parsing attribute linkages * * Revision 1.8 2002/05/30 19:24:38 warmerda * add partial support for tag type 5 * * Revision 1.7 2002/04/22 20:44:41 warmerda * added (partial) cell library support * * Revision 1.6 2002/04/16 17:56:07 warmerda * Initialize ch. * * Revision 1.5 2002/03/14 21:38:05 warmerda * removed DGN_DEBUG macro * * Revision 1.4 2002/03/12 17:07:26 warmerda * added tagset and tag value element support * * Revision 1.3 2002/02/22 22:18:10 warmerda * ensure that multi-part attributes supported for fill info * * Revision 1.2 2002/01/15 06:42:30 warmerda * remove stub statement * * Revision 1.1 2002/01/15 06:38:02 warmerda * New * */#include "dgnlibp.h"CPL_CVSID("$Id: dgnhelp.cpp,v 1.24 2004/09/15 16:06:19 fwarmerdam Exp $");static unsigned char abyDefaultPCT[256][3] = { {255,255,255}, {0,0,255}, {0,255,0}, {255,0,0}, {255,255,0}, {255,0,255}, {255,127,0}, {0,255,255}, {64,64,64}, {192,192,192}, {254,0,96}, {160,224,0}, {0,254,160}, {128,0,160}, {176,176,176}, {0,240,240}, {240,240,240}, {0,0,240}, {0,240,0}, {240,0,0}, {240,240,0}, {240,0,240}, {240,122,0}, {0,240,240}, {240,240,240}, {0,0,240}, {0,240,0}, {240,0,0}, {240,240,0}, {240,0,240}, {240,122,0}, {0,225,225}, {225,225,225}, {0,0,225}, {0,225,0}, {225,0,0}, {225,225,0}, {225,0,225}, {225,117,0}, {0,225,225}, {225,225,225}, {0,0,225}, {0,225,0}, {225,0,0}, {225,225,0}, {225,0,225}, {225,117,0}, {0,210,210}, {210,210,210}, {0,0,210}, {0,210,0}, {210,0,0}, {210,210,0}, {210,0,210}, {210,112,0}, {0,210,210}, {210,210,210}, {0,0,210}, {0,210,0}, {210,0,0}, {210,210,0}, {210,0,210}, {210,112,0}, {0,195,195}, {195,195,195}, {0,0,195}, {0,195,0}, {195,0,0}, {195,195,0}, {195,0,195}, {195,107,0}, {0,195,195}, {195,195,195}, {0,0,195}, {0,195,0}, {195,0,0}, {195,195,0}, {195,0,195}, {195,107,0}, {0,180,180}, {180,180,180}, {0,0,180}, {0,180,0}, {180,0,0}, {180,180,0}, {180,0,180}, {180,102,0}, {0,180,180}, {180,180,180}, {0,0,180}, {0,180,0}, {180,0,0}, {180,180,0}, {180,0,180}, {180,102,0}, {0,165,165}, {165,165,165}, {0,0,165}, {0,165,0}, {165,0,0}, {165,165,0}, {165,0,165}, {165,97,0}, {0,165,165}, {165,165,165}, {0,0,165}, {0,165,0}, {165,0,0}, {165,165,0}, {165,0,165}, {165,97,0}, {0,150,150}, {150,150,150}, {0,0,150}, {0,150,0}, {150,0,0}, {150,150,0}, {150,0,150}, {150,92,0}, {0,150,150}, {150,150,150}, {0,0,150}, {0,150,0}, {150,0,0}, {150,150,0}, {150,0,150}, {150,92,0}, {0,135,135}, {135,135,135}, {0,0,135}, {0,135,0}, {135,0,0}, {135,135,0}, {135,0,135}, {135,87,0}, {0,135,135}, {135,135,135}, {0,0,135}, {0,135,0}, {135,0,0}, {135,135,0}, {135,0,135}, {135,87,0}, {0,120,120}, {120,120,120}, {0,0,120}, {0,120,0}, {120,0,0}, {120,120,0}, {120,0,120}, {120,82,0}, {0,120,120}, {120,120,120}, {0,0,120}, {0,120,0}, {120,0,0}, {120,120,0}, {120,0,120}, {120,82,0}, {0,105,105}, {105,105,105}, {0,0,105}, {0,105,0}, {105,0,0}, {105,105,0}, {105,0,105}, {105,77,0}, {0,105,105}, {105,105,105}, {0,0,105}, {0,105,0}, {105,0,0}, {105,105,0}, {105,0,105}, {105,77,0}, {0,90,90}, {90,90,90}, {0,0,90}, {0,90,0}, {90,0,0}, {90,90,0}, {90,0,90}, {90,72,0}, {0,90,90}, {90,90,90}, {0,0,90}, {0,90,0}, {90,0,0}, {90,90,0}, {90,0,90}, {90,72,0}, {0,75,75}, {75,75,75}, {0,0,75}, {0,75,0}, {75,0,0}, {75,75,0}, {75,0,75}, {75,67,0}, {0,75,75}, {75,75,75}, {0,0,75}, {0,75,0}, {75,0,0}, {75,75,0}, {75,0,75}, {75,67,0}, {0,60,60}, {60,60,60}, {0,0,60}, {0,60,0}, {60,0,0}, {60,60,0}, {60,0,60}, {60,62,0}, {0,60,60}, {60,60,60}, {0,0,60}, {0,60,0}, {60,0,0}, {60,60,0}, {60,0,60}, {60,62,0}, {0,45,45}, {45,45,45}, {0,0,45}, {0,45,0}, {45,0,0}, {45,45,0}, {45,0,45}, {45,57,0}, {0,45,45}, {45,45,45}, {0,0,45}, {0,45,0}, {45,0,0}, {45,45,0}, {45,0,45}, {45,57,0}, {0,30,30}, {30,30,30}, {0,0,30}, {0,30,0}, {30,0,0}, {30,30,0}, {30,0,30}, {30,52,0}, {0,30,30}, {30,30,30}, {0,0,30}, {0,30,0}, {30,0,0}, {30,30,0}, {30,0,30}, {192,192,192}, {28,0,100}};/************************************************************************//* DGNLookupColor() *//************************************************************************//** * Translate color index into RGB values. * * If no color table has yet been encountered in the file a hard-coded * "default" color table will be used. This seems to be what Microstation * uses as a color table when there isn't one in a DGN file but I am not * absolutely convinced it is appropriate. * * @param hDGN the file. * @param color_index the color index to lookup. * @param red location to put red component. * @param green location to put green component. * @param blue location to put blue component. * * @return TRUE on success or FALSE on failure. May fail if color_index is * out of range. */int DGNLookupColor( DGNHandle hDGN, int color_index, int * red, int * green, int * blue ){ DGNInfo *psDGN = (DGNInfo *) hDGN; if( color_index < 0 || color_index > 255 ) return FALSE; 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,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -