Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Özgür Ozan Sen
ogs
Commits
023a89b5
Commit
023a89b5
authored
10 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[FileIO] Corrected readTIN() and made it more robust.
parent
a56c9179
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
FileIO/TINInterface.cpp
+41
-12
41 additions, 12 deletions
FileIO/TINInterface.cpp
with
41 additions
and
12 deletions
FileIO/TINInterface.cpp
+
41
−
12
View file @
023a89b5
...
...
@@ -34,29 +34,58 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, std::vector<Geo
GeoLib
::
Surface
*
sfc
=
new
GeoLib
::
Surface
(
pnt_vec
);
std
::
size_t
id
;
double
x
,
y
,
z
;
while
(
in
)
double
p0
[
3
],
p1
[
3
],
p2
[
3
]
;
while
(
in
.
good
()
)
{
// read id
in
>>
id
;
// determine size
std
::
size_t
pnt_pos
(
pnt_vec
.
size
());
if
(
!
(
in
>>
id
))
continue
;
// read first point
in
>>
x
>>
y
>>
z
;
pnt_vec
.
push_back
(
new
GeoLib
::
Point
(
x
,
y
,
z
));
if
(
!
(
in
>>
p0
[
0
]
>>
p0
[
1
]
>>
p0
[
2
]))
{
ERR
(
"Could not read coords of 1st point of triangle %d."
,
id
);
if
(
errors
)
errors
->
push_back
(
std
::
string
(
"readTIN error: "
)
+
std
::
string
(
"Could not read coords of 1st point in triangle "
)
+
std
::
to_string
(
id
));
in
.
close
();
delete
sfc
;
return
nullptr
;
}
// read second point
in
>>
x
>>
y
>>
z
;
pnt_vec
.
push_back
(
new
GeoLib
::
Point
(
x
,
y
,
z
));
if
(
!
(
in
>>
p1
[
0
]
>>
p1
[
1
]
>>
p1
[
2
]))
{
ERR
(
"Could not read coords of 2nd point of triangle %d."
,
id
);
if
(
errors
)
errors
->
push_back
(
std
::
string
(
"readTIN error: "
)
+
std
::
string
(
"Could not read coords of 2nd point in triangle "
)
+
std
::
to_string
(
id
));
in
.
close
();
delete
sfc
;
return
nullptr
;
}
// read third point
in
>>
x
>>
y
>>
z
;
pnt_vec
.
push_back
(
new
GeoLib
::
Point
(
x
,
y
,
z
));
if
(
!
(
in
>>
p2
[
0
]
>>
p2
[
1
]
>>
p2
[
2
]))
{
ERR
(
"Could not read coords of 3rd point of triangle %d."
,
id
);
if
(
errors
)
errors
->
push_back
(
std
::
string
(
"readTIN error: "
)
+
std
::
string
(
"Could not read coords of 3rd point in triangle "
)
+
std
::
to_string
(
id
));
in
.
close
();
delete
sfc
;
return
nullptr
;
}
// determine size pnt_vec to insert the correct ids
std
::
size_t
pnt_pos
(
pnt_vec
.
size
());
pnt_vec
.
push_back
(
new
GeoLib
::
Point
(
p0
));
pnt_vec
.
push_back
(
new
GeoLib
::
Point
(
p1
));
pnt_vec
.
push_back
(
new
GeoLib
::
Point
(
p2
));
// create new Triangle
sfc
->
addTriangle
(
pnt_pos
,
pnt_pos
+
1
,
pnt_pos
+
2
);
}
if
(
sfc
->
getNTriangles
()
==
0
)
{
WARN
(
"readTIN(): No triangle found."
,
fname
.
c_str
());
if
(
errors
)
errors
->
push_back
(
"readTIN error because of no triangle found"
);
if
(
errors
)
errors
->
push_back
(
"readTIN error because of no triangle found"
);
delete
sfc
;
return
nullptr
;
}
...
...
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