Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Larry Price
gmsh
Commits
06b42de4
Commit
06b42de4
authored
14 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
fix orientation of STL mesh
parent
875922ce
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Geo/OCCFace.cpp
+35
-3
35 additions, 3 deletions
Geo/OCCFace.cpp
with
35 additions
and
3 deletions
Geo/OCCFace.cpp
+
35
−
3
View file @
06b42de4
...
@@ -366,14 +366,46 @@ bool OCCFace::buildSTLTriangulation(bool force)
...
@@ -366,14 +366,46 @@ bool OCCFace::buildSTLTriangulation(bool force)
stl_vertices
.
push_back
(
SPoint2
(
p
.
X
(),
p
.
Y
()));
stl_vertices
.
push_back
(
SPoint2
(
p
.
X
(),
p
.
Y
()));
}
}
bool
revert
=
false
;
for
(
int
i
=
1
;
i
<=
triangulation
->
NbTriangles
();
i
++
){
for
(
int
i
=
1
;
i
<=
triangulation
->
NbTriangles
();
i
++
){
Poly_Triangle
triangle
=
(
triangulation
->
Triangles
())(
i
);
Poly_Triangle
triangle
=
(
triangulation
->
Triangles
())(
i
);
int
p1
,
p2
,
p3
;
int
p1
,
p2
,
p3
;
triangle
.
Get
(
p1
,
p2
,
p3
);
triangle
.
Get
(
p1
,
p2
,
p3
);
// orient STL mesh to get normal right
if
(
i
==
1
){
gp_Pnt2d
gp1
=
(
triangulation
->
UVNodes
())(
p1
);
gp_Pnt2d
gp2
=
(
triangulation
->
UVNodes
())(
p2
);
gp_Pnt2d
gp3
=
(
triangulation
->
UVNodes
())(
p3
);
SPoint2
b
=
SPoint2
(
gp1
.
X
(),
gp1
.
Y
())
+
SPoint2
(
gp2
.
X
(),
gp2
.
Y
())
+
SPoint2
(
gp3
.
X
(),
gp3
.
Y
());
b
*=
1.
/
3.
;
SVector3
nf
=
normal
(
b
);
GPoint
sp1
=
point
(
gp1
.
X
(),
gp1
.
Y
());
GPoint
sp2
=
point
(
gp2
.
X
(),
gp2
.
Y
());
GPoint
sp3
=
point
(
gp3
.
X
(),
gp3
.
Y
());
double
n
[
3
];
normal3points
(
sp1
.
x
(),
sp1
.
y
(),
sp1
.
z
(),
sp2
.
x
(),
sp2
.
y
(),
sp2
.
z
(),
sp3
.
x
(),
sp3
.
y
(),
sp3
.
z
(),
n
);
SVector3
ne
(
n
[
0
],
n
[
1
],
n
[
2
]);
if
(
dot
(
ne
,
nf
)
<
0
){
Msg
::
Debug
(
"Reverting orientation of STL mesh in face %d"
,
tag
());
revert
=
true
;
}
}
if
(
!
revert
){
stl_triangles
.
push_back
(
p1
-
1
);
stl_triangles
.
push_back
(
p1
-
1
);
stl_triangles
.
push_back
(
p2
-
1
);
stl_triangles
.
push_back
(
p2
-
1
);
stl_triangles
.
push_back
(
p3
-
1
);
stl_triangles
.
push_back
(
p3
-
1
);
}
}
else
{
stl_triangles
.
push_back
(
p1
-
1
);
stl_triangles
.
push_back
(
p3
-
1
);
stl_triangles
.
push_back
(
p2
-
1
);
}
}
return
true
;
return
true
;
}
}
...
...
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