From 81b4bcd4afb1c9d8a1fb282e7ba8395878ac2a74 Mon Sep 17 00:00:00 2001 From: jriegel Date: Sat, 13 Dec 2014 11:58:58 +0100 Subject: [PATCH] further implementing --- src/Mod/JtReader/App/AppJtReaderPy.cpp | 2 +- src/Mod/JtReader/App/JrJt/GUID.h | 9 +++++- src/Mod/JtReader/App/JrJt/JtReader.cpp | 10 +++---- src/Mod/JtReader/App/JrJt/JtReader.h | 9 +++++- src/Mod/JtReader/App/JrJt/TOC_Entry.h | 12 ++++++++ src/Mod/JtReader/App/TestJtReader.cpp | 40 +++++++++++++++++++++++++- src/Mod/JtReader/App/TestJtReader.h | 2 +- 7 files changed, 74 insertions(+), 10 deletions(-) diff --git a/src/Mod/JtReader/App/AppJtReaderPy.cpp b/src/Mod/JtReader/App/AppJtReaderPy.cpp index 05387a4d9..c497a5edf 100644 --- a/src/Mod/JtReader/App/AppJtReaderPy.cpp +++ b/src/Mod/JtReader/App/AppJtReaderPy.cpp @@ -109,7 +109,7 @@ open(PyObject *self, PyObject *args) reader.setFile(EncodedName.c_str()); - reader.readToc(); + reader.read(); // create new document and add Import feature diff --git a/src/Mod/JtReader/App/JrJt/GUID.h b/src/Mod/JtReader/App/JrJt/GUID.h index 93b007cb4..2e4571f51 100644 --- a/src/Mod/JtReader/App/JrJt/GUID.h +++ b/src/Mod/JtReader/App/JrJt/GUID.h @@ -23,7 +23,8 @@ #ifndef GUID_HEADER #define GUID_HEADER -#include +#include +#include #include #include "U8.h" @@ -62,6 +63,12 @@ struct GUID _C8.read(cont); } + std::string toString()const{ + std::stringstream strm; + strm << "{" << std::hex << _A1 << "-" << _B1 << _B2 << "-" << _C1 << _C2 << _C3 << _C4 << _C5 << _C6 << _C7 << _C8 << "}"; + return strm.str(); + } + U32 _A1; U16 _B1; diff --git a/src/Mod/JtReader/App/JrJt/JtReader.cpp b/src/Mod/JtReader/App/JrJt/JtReader.cpp index 87b490c70..34a0b03a9 100644 --- a/src/Mod/JtReader/App/JrJt/JtReader.cpp +++ b/src/Mod/JtReader/App/JrJt/JtReader.cpp @@ -30,7 +30,7 @@ void JtReader::setFile(const std::string fileName) this->_fileName = fileName; } -void JtReader::readToc() +const std::vector& JtReader::readToc() { ifstream strm; @@ -56,11 +56,11 @@ void JtReader::readToc() I32 Entry_Count(cont); - vector TocEntries(Entry_Count); - - - + TocEntries.resize(Entry_Count); + for (std::vector::iterator i = TocEntries.begin(); i != TocEntries.end(); ++i) + i->read(cont); + return TocEntries; } diff --git a/src/Mod/JtReader/App/JrJt/JtReader.h b/src/Mod/JtReader/App/JrJt/JtReader.h index 23ecbf63b..a0310a1d4 100644 --- a/src/Mod/JtReader/App/JrJt/JtReader.h +++ b/src/Mod/JtReader/App/JrJt/JtReader.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include "TOC_Entry.h" class JtReader @@ -11,11 +13,16 @@ public: void setFile(const std::string fileName); - void readToc(); + const std::vector& readToc(); + + void readSegment(int tocIndex); + + protected: std::string _fileName; + vector TocEntries; }; diff --git a/src/Mod/JtReader/App/JrJt/TOC_Entry.h b/src/Mod/JtReader/App/JrJt/TOC_Entry.h index f2c5d8cae..2c530c5fb 100644 --- a/src/Mod/JtReader/App/JrJt/TOC_Entry.h +++ b/src/Mod/JtReader/App/JrJt/TOC_Entry.h @@ -54,6 +54,18 @@ struct TOC_Entry Segment_Attributes.read(cont); }; + uint8_t getSegmentType()const + { + return Segment_Attributes << 24; + } + + std::string toString()const{ + stringstream strm; + strm << getSegmentType() << ":" << Segment_Offset << ":" << Segment_Length << ":" << Segment_ID.toString(); + + return strm.str(); + } + GUID Segment_ID; I32 Segment_Offset; I32 Segment_Length; diff --git a/src/Mod/JtReader/App/TestJtReader.cpp b/src/Mod/JtReader/App/TestJtReader.cpp index 2e9cc2df5..f6fb8f8f4 100644 --- a/src/Mod/JtReader/App/TestJtReader.cpp +++ b/src/Mod/JtReader/App/TestJtReader.cpp @@ -1,3 +1,35 @@ +/*************************************************************************** +* Copyright (c) Juergen Riegel * +* * +* This file is part of the FreeCAD CAx development system. * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of the GNU Library General Public * +* License as published by the Free Software Foundation; either * +* version 2 of the License, or (at your option) any later version. * +* * +* This library is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Library General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this library; see the file COPYING.LIB. If not, * +* write to the Free Software Foundation, Inc., 59 Temple Place, * +* Suite 330, Boston, MA 02111-1307, USA * +* * +***************************************************************************/ + +#include "PreCompiled.h" +#ifndef _PreComp_ +#endif + + +#include + +#include +#include + #include "TestJtReader.h" @@ -12,7 +44,13 @@ TestJtReader::~TestJtReader() void TestJtReader::read(void) { - readToc(); + const std::vector& toc = readToc(); + + for (std::vector::const_iterator i = TocEntries.begin(); i != TocEntries.end(); ++i){ + int segType = i->getSegmentType(); + + Base::Console().Log(i->toString().c_str()); + } diff --git a/src/Mod/JtReader/App/TestJtReader.h b/src/Mod/JtReader/App/TestJtReader.h index 701e75150..da510e8b3 100644 --- a/src/Mod/JtReader/App/TestJtReader.h +++ b/src/Mod/JtReader/App/TestJtReader.h @@ -1,4 +1,4 @@ -#pragma once + #include "JrJt/JtReader.h"