Replaced tabs with spaces.

This commit is contained in:
Robert Osfield
2005-11-17 15:03:51 +00:00
parent 0e16b64665
commit d3541b96ed
116 changed files with 6866 additions and 6855 deletions

View File

@@ -22,52 +22,52 @@
using namespace std;
bool
bool
dxfFile::parseFile()
{
if (_fileName == "") return false;
_reader = new dxfReader;
if (_reader->openFile(_fileName)) {
codeValue cv;
while(_reader->nextGroupCode(cv)) {
short result = assign(cv);
if (result < 0)
return false;
else if (result == 0) {
return true;
}
}
// we did not reach 0 EOF
return false;
} else {
return false;
}
if (_fileName == "") return false;
_reader = new dxfReader;
if (_reader->openFile(_fileName)) {
codeValue cv;
while(_reader->nextGroupCode(cv)) {
short result = assign(cv);
if (result < 0)
return false;
else if (result == 0) {
return true;
}
}
// we did not reach 0 EOF
return false;
} else {
return false;
}
}
osg::Group*
dxfFile::dxf2osg()
{
if (!_entities) return NULL;
if (!_tables) { // a dxfTable is needed to create undefined layers
_tables = new dxfTables;
}
osg::ref_ptr<dxfLayerTable> layerTable = _tables->getOrCreateLayerTable();
// to do: should be more general and pass a pointer to ourselves
// which in turn should be able to feed any information
// the scene might need
_scene = new scene(layerTable.get());
_entities->drawScene(_scene.get());
osg::Group* g = _scene->scene2osg();
return g;
if (!_entities) return NULL;
if (!_tables) { // a dxfTable is needed to create undefined layers
_tables = new dxfTables;
}
osg::ref_ptr<dxfLayerTable> layerTable = _tables->getOrCreateLayerTable();
// to do: should be more general and pass a pointer to ourselves
// which in turn should be able to feed any information
// the scene might need
_scene = new scene(layerTable.get());
_entities->drawScene(_scene.get());
osg::Group* g = _scene->scene2osg();
return g;
}
dxfBlock*
dxfBlock*
dxfFile::findBlock(std::string name)
{
if (_blocks.get())
return _blocks->findBlock(name);
return NULL;
if (_blocks.get())
return _blocks->findBlock(name);
return NULL;
}
/// not used. if you want to know what a header variable
@@ -76,45 +76,45 @@ dxfFile::findBlock(std::string name)
VariableList
dxfFile::getVariable(std::string var)
{
return _header->getVariable(var);
return _header->getVariable(var);
}
/// parse the dxf sections
short
dxfFile::assign(codeValue& cv)
{
std::string s = cv._string;
if (cv._groupCode == 0 && s == std::string("ENDSEC")) {
_isNewSection = false;
_current = _unknown.get();
} else if (cv._groupCode == 0 && s == std::string("SECTION")) {
_isNewSection = true;
} else if (cv._groupCode == 0 && s == std::string("EOF")) {
return 0;
} else if (cv._groupCode == 2 && _isNewSection) {
_isNewSection = false;
// std::cout << "Reading section " << s << std::endl;
if (s =="HEADER") {
_header = new dxfHeader;
_current = _header.get();
} else if (s =="TABLES") {
_tables = new dxfTables;
_current = _tables.get();
} else if (s =="BLOCKS") {
_blocks = new dxfBlocks;
_current = _blocks.get();
} else if (s =="ENTITIES") {
_entities = new dxfEntities;
_current = _entities.get();
} else {
_current = _unknown.get();
}
} else if (_isNewSection) {
// problem. a 0/SECTION should be followed by a 2/SECTION_NAME
std::cout << "No groupcode for changing section " << cv._groupCode << " value: " << s << std::endl;
return -1;
} else if (_current.get()) {
_current->assign(this, cv);
}
return 1;
std::string s = cv._string;
if (cv._groupCode == 0 && s == std::string("ENDSEC")) {
_isNewSection = false;
_current = _unknown.get();
} else if (cv._groupCode == 0 && s == std::string("SECTION")) {
_isNewSection = true;
} else if (cv._groupCode == 0 && s == std::string("EOF")) {
return 0;
} else if (cv._groupCode == 2 && _isNewSection) {
_isNewSection = false;
// std::cout << "Reading section " << s << std::endl;
if (s =="HEADER") {
_header = new dxfHeader;
_current = _header.get();
} else if (s =="TABLES") {
_tables = new dxfTables;
_current = _tables.get();
} else if (s =="BLOCKS") {
_blocks = new dxfBlocks;
_current = _blocks.get();
} else if (s =="ENTITIES") {
_entities = new dxfEntities;
_current = _entities.get();
} else {
_current = _unknown.get();
}
} else if (_isNewSection) {
// problem. a 0/SECTION should be followed by a 2/SECTION_NAME
std::cout << "No groupcode for changing section " << cv._groupCode << " value: " << s << std::endl;
return -1;
} else if (_current.get()) {
_current->assign(this, cv);
}
return 1;
}