root/OpenSceneGraph/trunk/src/osgPlugins/dxf/dxfSection.cpp @ 13041

Revision 13041, 2.6 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* dxfReader for OpenSceneGraph  Copyright (C) 2005 by GraphArchitecture ( grapharchitecture.com )
2 * Programmed by Paul de Repentigny <pdr@grapharchitecture.com>
3 *
4 * OpenSceneGraph is (C) 2004 Robert Osfield
5 *
6 * This library is provided as-is, without support of any kind.
7 *
8 * Read DXF docs or OSG docs for any related questions.
9 *
10 * You may contact the author if you have suggestions/corrections/enhancements.
11 */
12
13#include "dxfSection.h"
14#include "dxfEntity.h"
15#include "dxfBlock.h"
16
17void dxfHeader::assign(dxfFile*, codeValue& cv)
18{
19    if (cv._groupCode == 9) {
20        _inVariable = true;
21        VariableList var;
22        _variables[cv._string] = var;
23        _currentVariable = cv._string;
24    } else if (_inVariable) {
25        VariableList& var = getVariable(_currentVariable);
26        var.push_back(cv);
27    }
28}
29
30void dxfTables::assign(dxfFile* dxf, codeValue& cv)
31{
32    if (cv._groupCode == 0 && cv._string == "TABLE") {
33        _currentTable = NULL;
34    } else if (cv._groupCode == 2 && !_currentTable.get()) {
35        // treat layer table as a special case
36        if (cv._string == "LAYER") {
37            _layerTable = new dxfLayerTable;
38            _currentTable = _layerTable.get();
39        } else {
40            _currentTable = new dxfTable;
41            _others.push_back(_currentTable.get());
42        }
43    } else if (_currentTable.get()) {
44        _currentTable->assign(dxf, cv);
45    }
46}
47
48void dxfBlocks::assign(dxfFile* dxf, codeValue& cv)
49{
50    if (cv._groupCode == 0 && cv._string == std::string("BLOCK")) {
51        _currentBlock = new dxfBlock;
52        _blockList.push_back(_currentBlock);
53    } else if (cv._groupCode == 0 && cv._string == std::string("ENDBLK") && _currentBlock) {
54        std::string bn = _currentBlock->getName();
55        _blockNameList[bn] = _currentBlock;
56    } else if (_currentBlock) {
57        _currentBlock->assign(dxf, cv);
58    }
59}
60
61void dxfEntities::assign(dxfFile* dxf, codeValue& cv)
62{
63    if (cv._groupCode == 0) {
64        if (_currentEntity && _currentEntity->done()) {
65            _currentEntity = new dxfEntity(cv._string);
66            _entityList.push_back(_currentEntity);
67        } else if (_currentEntity) {
68            _currentEntity->assign(dxf, cv);
69        } else {
70            _currentEntity = new dxfEntity(cv._string);
71            _entityList.push_back(_currentEntity);
72        }
73    } else if (_currentEntity) {
74        _currentEntity->assign(dxf, cv);
75    }
76}
77
78void
79dxfEntities::drawScene(scene* sc)
80{
81    for (EntityList::iterator itr = _entityList.begin();
82        itr != _entityList.end(); ++itr)
83        (*itr)->drawScene(sc);
84}
85dxfBlock*
86dxfBlocks::findBlock(std::string s) { return _blockNameList[s]; }
Note: See TracBrowser for help on using the browser.