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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
C-Fu
OpenGL
Commits
4f1ff65f
Commit
4f1ff65f
authored
8 years ago
by
Anakin
Browse files
Options
Downloads
Patches
Plain Diff
first try to get all MODL and their sub chunks,
parent
443675ae
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
MshViewer/Header/Object.h
+3
-2
3 additions, 2 deletions
MshViewer/Header/Object.h
MshViewer/Source/Object.cpp
+26
-8
26 additions, 8 deletions
MshViewer/Source/Object.cpp
with
29 additions
and
10 deletions
MshViewer/Header/Object.h
+
3
−
2
View file @
4f1ff65f
...
@@ -17,12 +17,13 @@ public:
...
@@ -17,12 +17,13 @@ public:
private:
private:
std
::
list
<
chunkHeader
*>
lChunk
;
std
::
list
<
chunkHeader
*>
lChunkMsh2
;
std
::
list
<
chunkHeader
*>
lChunkModl
;
std
::
fstream
fsMesh
;
std
::
fstream
fsMesh
;
private:
private:
void
re
adChunks
();
void
lo
adChunks
(
std
::
list
<
chunkHeader
*>
&
destination
,
std
::
streampos
start
,
const
char
end
[
5
]
);
public:
public:
...
...
This diff is collapsed.
Click to expand it.
MshViewer/Source/Object.cpp
+
26
−
8
View file @
4f1ff65f
...
@@ -14,8 +14,24 @@ Object::Object(const char* path)
...
@@ -14,8 +14,24 @@ Object::Object(const char* path)
if
(
!
fsMesh
.
is_open
())
if
(
!
fsMesh
.
is_open
())
throw
std
::
invalid_argument
(
std
::
string
(
"file not found: "
)
+=
path
);
throw
std
::
invalid_argument
(
std
::
string
(
"file not found: "
)
+=
path
);
// get Chunks
fsMesh
.
seekg
(
8
);
readChunks
();
char
tempChunkName
[
5
]
=
{
0
};
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempChunkName
[
0
]),
sizeof
(
tempChunkName
)
-
1
);
if
(
strcmp
(
tempChunkName
,
"MSH2"
))
throw
std
::
invalid_argument
(
std
::
string
(
"corrupted file MSH2 expected instead of "
)
+=
tempChunkName
);
fsMesh
.
seekg
(
4
,
std
::
ios_base
::
cur
);
loadChunks
(
lChunkMsh2
,
fsMesh
.
tellg
(),
"CL1L"
);
for
(
std
::
list
<
chunkHeader
*>::
iterator
it
=
lChunkMsh2
.
begin
();
it
!=
lChunkMsh2
.
end
();
it
++
)
{
if
(
!
strcmp
(
"MODL"
,
(
*
it
)
->
name
))
{
loadChunks
(
lChunkModl
,
(
*
it
)
->
position
,
"CL1L"
);
}
}
// close file
// close file
fsMesh
.
close
();
fsMesh
.
close
();
...
@@ -27,13 +43,14 @@ Object::~Object()
...
@@ -27,13 +43,14 @@ Object::~Object()
}
}
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// private functions
// private functions
void
Object
::
re
adChunks
()
void
Object
::
lo
adChunks
(
std
::
list
<
chunkHeader
*>&
destination
,
std
::
streampos
start
,
const
char
end
[
5
]
)
{
{
// Jump into Mesh2
// Jump into Mesh2
fsMesh
.
seekg
(
16
,
std
::
ios_base
::
cur
);
fsMesh
.
seekg
(
start
);
do
do
{
{
...
@@ -43,15 +60,16 @@ void Object::readChunks()
...
@@ -43,15 +60,16 @@ void Object::readChunks()
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempHeader
->
size
),
sizeof
(
tempHeader
->
size
));
fsMesh
.
read
(
reinterpret_cast
<
char
*>
(
&
tempHeader
->
size
),
sizeof
(
tempHeader
->
size
));
tempHeader
->
position
=
fsMesh
.
tellg
();
tempHeader
->
position
=
fsMesh
.
tellg
();
lChunk
.
push_back
(
tempHeader
);
destination
.
push_back
(
tempHeader
);
fsMesh
.
seekg
(
tempHeader
->
size
,
std
::
ios_base
::
cur
);
fsMesh
.
seekg
(
tempHeader
->
size
,
std
::
ios_base
::
cur
);
if
(
!
std
::
strcmp
(
tempHeader
->
name
,
"CL1L"
))
if
(
!
std
::
strcmp
(
tempHeader
->
name
,
end
))
break
;
break
;
}
while
(
!
fsMesh
.
eof
());
}
while
(
fsMesh
.
good
());
std
::
cout
<<
"got all chunks, totaly found: "
<<
destination
.
size
()
<<
std
::
endl
;
std
::
cout
<<
"got all chunks, totaly found: "
<<
lChunk
.
size
()
<<
std
::
endl
;
}
}
...
...
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