implementing Element reading
This commit is contained in:
parent
1ca23c33c7
commit
ade02b5643
40
src/Mod/JtReader/App/FcLodHandler.cpp
Normal file
40
src/Mod/JtReader/App/FcLodHandler.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2014 *
|
||||
* *
|
||||
* 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 <Base/Console.h>
|
||||
|
||||
#include "FcLodHandler.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void FcLodHandler::startLod()
|
||||
{
|
||||
Base::Console().Log("FcLodHandler::startLod()");
|
||||
}
|
44
src/Mod/JtReader/App/FcLodHandler.h
Normal file
44
src/Mod/JtReader/App/FcLodHandler.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2014 *
|
||||
* *
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef FcLodHandler_HEADER
|
||||
#define FcLodHandler_HEADER
|
||||
|
||||
#include "JrJt/LodHandler.h"
|
||||
|
||||
class FcLodHandler: public LodHandler
|
||||
{
|
||||
public:
|
||||
virtual void startLod();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
75
src/Mod/JtReader/App/JrJt/Element_Header.h
Normal file
75
src/Mod/JtReader/App/JrJt/Element_Header.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2014 *
|
||||
* *
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef Element_Header_HEADER
|
||||
#define Element_Header_HEADER
|
||||
|
||||
#include <istream>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Context.h"
|
||||
#include "GUID.h"
|
||||
#include "UChar.h"
|
||||
#include "I32.h"
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
struct Element_Header
|
||||
{
|
||||
Element_Header(){};
|
||||
|
||||
Element_Header(Context& cont, bool zLib=false)
|
||||
{
|
||||
read(cont, zLib);
|
||||
};
|
||||
|
||||
inline void read(Context& cont ,bool zLib=false)
|
||||
{
|
||||
// only zip less implemented so far...
|
||||
assert(zLib == false);
|
||||
|
||||
Element_Lenght.read(cont);
|
||||
Object_Type_ID.read(cont);
|
||||
Object_Base_Type.read(cont);
|
||||
};
|
||||
|
||||
I32 Element_Lenght;
|
||||
GUID Object_Type_ID;
|
||||
UChar Object_Base_Type;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -41,11 +41,34 @@ struct GUID
|
|||
{
|
||||
GUID(){};
|
||||
|
||||
GUID(uint32_t a1, uint16_t b1, uint16_t b2, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, uint8_t c6, uint8_t c7, uint8_t c8)
|
||||
:_A1(a1), _B1(b1), _B2(b2), _C1(c1), _C2(c2), _C3(c3), _C4(c4), _C5(c5), _C6(c6), _C7(c7), _C8(c8)
|
||||
{}
|
||||
|
||||
GUID(Context& cont)
|
||||
{
|
||||
read(cont);
|
||||
}
|
||||
|
||||
bool operator!=(const GUID& other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
||||
bool operator==(const GUID& other) const {
|
||||
return
|
||||
_A1 == other._A1
|
||||
&& _B1 == other._B1
|
||||
&& _B2 == other._B2
|
||||
&& _C1 == other._C1
|
||||
&& _C2 == other._C2
|
||||
&& _C3 == other._C3
|
||||
&& _C4 == other._C4
|
||||
&& _C5 == other._C5
|
||||
&& _C6 == other._C6
|
||||
&& _C7 == other._C7
|
||||
&& _C8 == other._C8;
|
||||
}
|
||||
|
||||
inline void read(Context& cont)
|
||||
{
|
||||
_A1.read(cont);
|
||||
|
|
|
@ -3,19 +3,25 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TOC_Entry.h"
|
||||
#include "GUID.h"
|
||||
#include "UChar.h"
|
||||
#include "I32.h"
|
||||
#include "TOC_Entry.h"
|
||||
#include "LodHandler.h"
|
||||
#include "Segment_Header.h"
|
||||
#include "Element_Header.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const GUID JtReader::TriStripSetShapeLODElement_ID(0x10dd10ab, 0x2ac8, 0x11d1, 0x9b, 0x6b, 0x0, 0x80, 0xc7, 0xbb, 0x59, 0x97);
|
||||
|
||||
JtReader::JtReader()
|
||||
{
|
||||
}
|
||||
|
@ -63,4 +69,32 @@ const std::vector<TOC_Entry>& JtReader::readToc()
|
|||
|
||||
return TocEntries;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void JtReader::readLodSegment(const TOC_Entry& toc, LodHandler& handler)
|
||||
{
|
||||
std::ifstream strm;
|
||||
strm.open(_fileName, ios::binary);
|
||||
|
||||
if (!strm) throw "cannot open file";
|
||||
|
||||
strm.seekg((int32_t)toc.Segment_Offset);
|
||||
|
||||
Context cont(strm);
|
||||
|
||||
|
||||
// check if called with the right Toc
|
||||
assert(toc.getSegmentType() == 7);
|
||||
|
||||
// read the segment header
|
||||
Segment_Header header(cont);
|
||||
|
||||
// read the non zip Element header
|
||||
Element_Header eHeader(cont, false);
|
||||
|
||||
if ( eHeader.Object_Type_ID != TriStripSetShapeLODElement_ID)
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include <vector>
|
||||
#include "TOC_Entry.h"
|
||||
|
||||
class LodHandler;
|
||||
|
||||
|
||||
|
||||
class JtReader
|
||||
{
|
||||
|
@ -17,7 +20,9 @@ public:
|
|||
|
||||
void readSegment(int tocIndex);
|
||||
|
||||
|
||||
void readLodSegment(const TOC_Entry&, LodHandler&);
|
||||
|
||||
static const GUID TriStripSetShapeLODElement_ID;
|
||||
|
||||
|
||||
protected:
|
||||
|
|
41
src/Mod/JtReader/App/JrJt/LodHandler.h
Normal file
41
src/Mod/JtReader/App/JrJt/LodHandler.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2014 *
|
||||
* *
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef LodHandler_HEADER
|
||||
#define LodHandler_HEADER
|
||||
|
||||
|
||||
|
||||
class LodHandler
|
||||
{
|
||||
public:
|
||||
virtual void startLod(){};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
68
src/Mod/JtReader/App/JrJt/Segment_Header.h
Normal file
68
src/Mod/JtReader/App/JrJt/Segment_Header.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) Juergen Riegel (juergen.riegel@web.de) 2014 *
|
||||
* *
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef Segment_Header_HEADER
|
||||
#define Segment_Header_HEADER
|
||||
|
||||
#include <istream>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Context.h"
|
||||
#include "GUID.h"
|
||||
#include "U16.h"
|
||||
#include "U32.h"
|
||||
#include "I32.h"
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
struct Segment_Header
|
||||
{
|
||||
Segment_Header(){};
|
||||
|
||||
Segment_Header(Context& cont)
|
||||
{
|
||||
read(cont);
|
||||
};
|
||||
|
||||
inline void read(Context& cont)
|
||||
{
|
||||
Segment_ID.read(cont);
|
||||
Segment_Type.read(cont);
|
||||
Segment_Length.read(cont);
|
||||
};
|
||||
|
||||
GUID Segment_ID;
|
||||
I32 Segment_Type;
|
||||
I32 Segment_Length;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ struct TOC_Entry
|
|||
|
||||
uint8_t getSegmentType()const
|
||||
{
|
||||
return Segment_Attributes << 24;
|
||||
return Segment_Attributes >> 24;
|
||||
}
|
||||
|
||||
std::string toString()const{
|
||||
|
|
|
@ -32,6 +32,8 @@ struct U16
|
|||
{
|
||||
U16(){};
|
||||
|
||||
U16(uint16_t ui) :_U16(ui){}
|
||||
|
||||
U16(Context& cont)
|
||||
{
|
||||
read(cont);
|
||||
|
|
|
@ -32,6 +32,8 @@ struct U32
|
|||
{
|
||||
U32(){};
|
||||
|
||||
U32(uint32_t ui) :_U32(ui){}
|
||||
|
||||
U32(Context& cont)
|
||||
{
|
||||
read(cont);
|
||||
|
|
|
@ -33,6 +33,8 @@ struct U8
|
|||
{
|
||||
U8(){};
|
||||
|
||||
U8(uint8_t ui) :_U8(ui){}
|
||||
|
||||
U8(Context& cont)
|
||||
{
|
||||
read(cont);
|
||||
|
|
|
@ -25,12 +25,14 @@
|
|||
#endif
|
||||
|
||||
|
||||
#include <Python.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/FileInfo.h>
|
||||
|
||||
#include "TestJtReader.h"
|
||||
#include "FcLodHandler.h"
|
||||
|
||||
|
||||
TestJtReader::TestJtReader()
|
||||
|
@ -49,6 +51,15 @@ void TestJtReader::read(void)
|
|||
for (std::vector<TOC_Entry>::const_iterator i = TocEntries.begin(); i != TocEntries.end(); ++i){
|
||||
int segType = i->getSegmentType();
|
||||
|
||||
if (segType == 7){
|
||||
FcLodHandler handler;
|
||||
|
||||
readLodSegment(*i, handler);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Base::Console().Log(i->toString().c_str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user