⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dgnwritetest.c

📁 在Linux环境下读写DGN文件
💻 C
字号:
/****************************************************************************** * $Id: dgnwritetest.c,v 1.1 2002/11/11 20:40:33 warmerda Exp $ * * Project:  Microstation DGN Access Library * Purpose:  Test program for use of write api. * Author:   Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.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: dgnwritetest.c,v $ * Revision 1.1  2002/11/11 20:40:33  warmerda * New * */#include "dgnlib.h"CPL_CVSID("$Id: dgnwritetest.c,v 1.1 2002/11/11 20:40:33 warmerda Exp $");/************************************************************************//*                                main()                                *//************************************************************************/int main( int argc, char ** argv ){    DGNHandle hNewDGN;/* -------------------------------------------------------------------- *//*      Create new DGN file.                                            *//* -------------------------------------------------------------------- */    hNewDGN = DGNCreate( "out.dgn", "seed.dgn",                          DGNCF_USE_SEED_UNITS                         | DGNCF_USE_SEED_ORIGIN,                          0.0, 0.0, 0.0, 0, 0, "", "" );/* -------------------------------------------------------------------- *//*      Write one line segment to it.                                   *//* -------------------------------------------------------------------- */    DGNPoint   asPoints[10];    DGNElemCore *psLine;    memset( &asPoints, 0, sizeof(asPoints) );    asPoints[0].x = 0;    asPoints[0].y = 0;    asPoints[1].x = 10000;    asPoints[1].y = 4000;    psLine = DGNCreateMultiPointElem( hNewDGN, DGNT_LINE, 2, asPoints );    DGNUpdateElemCore( hNewDGN, psLine, 15, 0, 3, 1, 0 );    DGNWriteElement( hNewDGN, psLine );    DGNFreeElement( hNewDGN, psLine );/* -------------------------------------------------------------------- *//*      Write a line string.                                            *//* -------------------------------------------------------------------- */    asPoints[0].x = 0;    asPoints[0].y = 1000;    asPoints[1].x = 6000;    asPoints[1].y = 5000;    asPoints[2].x = 12000;    asPoints[2].y = 6000;    psLine = DGNCreateMultiPointElem( hNewDGN, DGNT_LINE_STRING, 3, asPoints );    DGNUpdateElemCore( hNewDGN, psLine, 15, 0, 3, 1, 0 );    DGNWriteElement( hNewDGN, psLine );    DGNFreeElement( hNewDGN, psLine );/* -------------------------------------------------------------------- *//*      Write an Arc.                                                   *//* -------------------------------------------------------------------- */    psLine = DGNCreateArcElem2D( hNewDGN, DGNT_ARC,                                  2000.0, 3000.0, 2000.0, 1000.0,                                  45.0, 0.0, 270.0 );    DGNUpdateElemCore( hNewDGN, psLine, 15, 0, 3, 1, 0 );    DGNWriteElement( hNewDGN, psLine );    DGNFreeElement( hNewDGN, psLine );/* -------------------------------------------------------------------- *//*      Write an Ellipse with fill info.                                *//* -------------------------------------------------------------------- */    psLine = DGNCreateArcElem2D( hNewDGN, DGNT_ELLIPSE,                                  2000.0, 3000.0, 1000.0, 1000.0,                                  45.0, 0.0, 360.0 );    DGNUpdateElemCore( hNewDGN, psLine, 15, 0, 3, 1, 0 );    DGNWriteElement( hNewDGN, psLine );    DGNFreeElement( hNewDGN, psLine );/* -------------------------------------------------------------------- *//*      Write some text.                                                *//* -------------------------------------------------------------------- */    psLine = DGNCreateTextElem( hNewDGN, "This is a test string",                                 0, DGNJ_CENTER_TOP, 200.0, 200.0, 0.0,                                2000.0, 3000.0, 0.0 );    DGNAddMSLink( hNewDGN, psLine, DGNLT_XBASE, 7, 101 );    DGNAddMSLink( hNewDGN, psLine, DGNLT_DMRS, 7, 101 );    DGNUpdateElemCore( hNewDGN, psLine, 15, 0, 3, 1, 0 );    DGNWriteElement( hNewDGN, psLine );    DGNFreeElement( hNewDGN, psLine );/* -------------------------------------------------------------------- *//*      Write a complex shape consisting of two line strings.           *//* -------------------------------------------------------------------- */    DGNElemCore *psMembers[2];    asPoints[0].x = 8000;    asPoints[0].y = 8000;    asPoints[1].x = 6000;    asPoints[1].y = 8000;    asPoints[2].x = 6000;    asPoints[2].y = 6000;    psMembers[0] = DGNCreateMultiPointElem( hNewDGN, DGNT_LINE_STRING, 3,                                             asPoints );    DGNUpdateElemCore( hNewDGN, psMembers[0], 9, 0, 3, 1, 0 );    asPoints[0].x = 6000;    asPoints[0].y = 6000;    asPoints[1].x = 8000;    asPoints[1].y = 6000;    asPoints[2].x = 8000;    asPoints[2].y = 8000;    psMembers[1] = DGNCreateMultiPointElem( hNewDGN, DGNT_LINE_STRING, 3,                                             asPoints );    DGNUpdateElemCore( hNewDGN, psMembers[1], 9, 0, 3, 1, 0 );    psLine = DGNCreateComplexHeaderFromGroup( hNewDGN,                                               DGNT_COMPLEX_SHAPE_HEADER,                                              2, psMembers );    DGNAddShapeFillInfo( hNewDGN, psLine, 7 );    DGNWriteElement( hNewDGN, psLine );    DGNWriteElement( hNewDGN, psMembers[0] );    DGNWriteElement( hNewDGN, psMembers[1] );    DGNFreeElement( hNewDGN, psLine );    DGNFreeElement( hNewDGN, psMembers[0] );    DGNFreeElement( hNewDGN, psMembers[1] );/* -------------------------------------------------------------------- *//*      Close it.                                                       *//* -------------------------------------------------------------------- */    DGNClose( hNewDGN );    return 0;}

⌨️ 快捷键说明

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