Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OpenGL
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
C-Fu
OpenGL
Commits
443675ae
Commit
443675ae
authored
8 years ago
by
Anakin
Browse files
Options
Downloads
Patches
Plain Diff
save name, size and position of every chunk under MSH2
parent
05b6e4f9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MshViewer/Header/Object.h
+14
-1
14 additions, 1 deletion
MshViewer/Header/Object.h
MshViewer/Source/Object.cpp
+25
-30
25 additions, 30 deletions
MshViewer/Source/Object.cpp
with
39 additions
and
31 deletions
MshViewer/Header/Object.h
+
14
−
1
View file @
443675ae
#pragma once
#include
<vector>
#include
<list>
#include
<fstream>
struct
chunkHeader
{
char
name
[
5
];
int
size
;
std
::
streampos
position
;
};
class
Object
{
...
...
@@ -9,7 +16,13 @@ public:
~
Object
();
private:
std
::
list
<
chunkHeader
*>
lChunk
;
std
::
fstream
fsMesh
;
private:
void
readChunks
();
public:
...
...
This diff is collapsed.
Click to expand it.
MshViewer/Source/Object.cpp
+
25
−
30
View file @
443675ae
#include
"Object.h"
#include
<fstream>
#include
<iostream>
...
...
@@ -10,56 +9,52 @@
Object
::
Object
(
const
char
*
path
)
{
// open file
std
::
fstream
fsMesh
(
path
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
fsMesh
.
open
(
path
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
fsMesh
.
is_open
())
throw
std
::
invalid_argument
(
std
::
string
(
"file not found: "
)
+=
path
);
std
::
uint8_t
ui8x4Header
[
5
]
=
{
0
};
// get Chunks
readChunks
();
fsMesh
.
seekg
(
4
,
std
::
ios_base
::
cur
);
std
::
uint32_t
ui32FileSize
;
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
ui32FileSize
),
sizeof
(
ui32FileSize
));
// close file
fsMesh
.
close
();
}
Object
::~
Object
()
{
//delete Chunk list;
}
fsMesh
.
seekg
(
4
,
std
::
ios_base
::
cur
);
std
::
uint32_t
ui32MshSize
;
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
ui32MshSize
),
sizeof
(
ui32MshSize
));
std
::
cout
<<
"Hedr "
<<
ui32FileSize
<<
std
::
endl
;
std
::
cout
<<
"Msh "
<<
ui32MshSize
<<
std
::
endl
;
/////////////////////////////////////////////////////////////////////////
// private functions
void
Object
::
readChunks
()
{
// Jump into Mesh2
fsMesh
.
seekg
(
16
,
std
::
ios_base
::
cur
);
do
{
chunkHeader
*
tempHeader
=
new
chunkHeader
();
char
tempChunkName
[
5
]
=
{
0
};
std
::
uint32_t
tempChunkSize
=
0
;
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempChunkName
[
0
]),
sizeof
(
tempChunkName
)
-
1
);
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempChunkSize
),
sizeof
(
tempChunkSize
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempHeader
->
name
[
0
]),
sizeof
(
tempHeader
->
name
)
-
1
);
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempHeader
->
size
),
sizeof
(
tempHeader
->
size
));
tempHeader
->
position
=
fsMesh
.
tellg
();
std
::
cout
<<
tempChunkName
<<
" "
<<
tempChunkSize
<<
std
::
endl
;
lChunk
.
push_back
(
tempHeader
)
;
fsMesh
.
seekg
(
temp
ChunkS
ize
,
std
::
ios_base
::
cur
);
fsMesh
.
seekg
(
temp
Header
->
s
ize
,
std
::
ios_base
::
cur
);
if
(
!
std
::
strcmp
(
temp
ChunkN
ame
,
"CL1L"
))
if
(
!
std
::
strcmp
(
temp
Header
->
n
ame
,
"CL1L"
))
break
;
}
while
(
!
fsMesh
.
eof
());
fsMesh
.
close
();
}
Object
::~
Object
()
{
std
::
cout
<<
"got all chunks, totaly found: "
<<
lChunk
.
size
()
<<
std
::
endl
;
}
/////////////////////////////////////////////////////////////////////////
// private functions
/////////////////////////////////////////////////////////////////////////
// public getter
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment