Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
taglut
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
Container Registry
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jean-Marie Favreau
taglut
Commits
c703fb08
Commit
c703fb08
authored
14 years ago
by
Jean-Marie Favreau
Browse files
Options
Downloads
Patches
Plain Diff
Add a script to test PLCut tools
parent
39d5ae25
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
python/meshPLCutter.py
+131
-0
131 additions, 0 deletions
python/meshPLCutter.py
with
131 additions
and
0 deletions
python/meshPLCutter.py
0 → 100755
+
131
−
0
View file @
c703fb08
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Taglut : Topological And Geometrical Library - a Useful Toolkit
# Copyright (C) 2011 Jean-Marie Favreau <J-Marie.Favreau@u-clermont1.fr>
# ISIT, Université d'Auvergne
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License 2
# as published by the Free Software Foundation.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
Usage: meshPLCutter [options] INPUT
Options:
-n, --name Object name
-1, --first-vertex=V1 First vertex of the path
-2, --second-vertex=V2 Seconf vertex of the path
-d, --display Display the final mesh
-i, --infos Display information about final mesh
-o, --output=FILE Save the mesh using the file FILE
-x, --x=X 3d window size (x)
-y, --y=Y 3d window size (y)
-h, --help Print this message and exit.
INPUT is a mesh file (available formats: VRML, PLY)
"""
import
taglut
import
getopt
import
sys
try
:
my_getopt
=
getopt
.
gnu_getopt
except
AttributeError
:
my_getopt
=
getopt
.
getopt
def
usage
():
print
__doc__
sys
.
exit
(
0
)
def
main
():
try
:
opts
,
args
=
my_getopt
(
sys
.
argv
[
1
:],
"
nhx:y:do:1:2:i
"
,
[
"
name
"
,
"
help
"
,
"
x=
"
,
"
y=
"
,
"
display
"
,
"
output=
"
,
"
first-vertex=
"
,
"
second-vertex=
"
,
"
infos
"
])
except
getopt
.
GetoptError
,
msg
:
# print help information and exit:
print
"
Error:
"
,
msg
usage
()
sys
.
exit
(
2
)
display
=
False
outputFile
=
""
sizex
=
600
sizey
=
600
firstVertex
=
0
secondVertex
=
-
1
infos
=
False
for
o
,
a
in
opts
:
if
o
in
(
"
-i
"
,
"
--infos
"
):
infos
=
True
if
o
in
(
"
-1
"
,
"
--first-vertex
"
):
firstVertex
=
a
if
o
in
(
"
-2
"
,
"
--second-vertex
"
):
secondVertex
=
a
if
o
in
(
"
-n
"
,
"
--name
"
):
name
=
a
if
o
in
(
"
-x
"
,
"
--x
"
):
sizex
=
int
(
a
)
if
o
in
(
"
-y
"
,
"
--y
"
):
sizey
=
int
(
a
)
if
o
in
(
"
-d
"
,
"
--display
"
):
display
=
True
if
o
in
(
"
-o
"
,
"
--output
"
):
outputFile
=
a
if
o
in
(
"
-h
"
,
"
--help
"
):
usage
()
sys
.
exit
()
try
:
inputFile
=
args
[
0
]
except
IndexError
:
print
"
Error: Input file not defined
"
usage
()
sys
.
exit
()
try
:
print
"
Loading mesh...
"
m
=
taglut
.
Mesh
(
inputFile
)
print
"
Create path...
"
if
firstVertex
<
0
or
firstVertex
>=
m
.
getNbPoints
():
print
"
Bad value for the first point. Value selected: 0
"
firstVertex
=
0
print
"
First point:
"
,
firstVertex
if
secondVertex
<
0
or
secondVertex
>=
m
.
getNbPoints
():
mManip
=
taglut
.
MeshManipulator
(
m
)
secondVertex
=
mManip
.
getOppositePoint
(
firstVertex
)
print
"
Init second point using the opposite point:
"
,
secondVertex
else
:
print
"
Second point:
"
,
secondVertex
gDist
=
taglut
.
FastMarching
()
path
=
gDist
.
getShortestPath
(
m
,
firstVertex
,
secondVertex
)
print
"
Cut mesh...
"
plCut
=
taglut
.
MeshPLCut
()
m2
=
plCut
.
cutMesh
(
m
,
path
)
if
(
infos
):
print
m2
.
getInfos
()
if
(
display
):
print
"
Display...
"
taglut
.
Display3D
.
displayMesh
(
sizex
,
sizey
,
"
Display
"
,
m2
,
False
,
True
)
if
(
outputFile
!=
""
):
print
"
Save mesh (
"
+
outputFile
+
"
)...
"
m2
.
save
(
outputFile
)
except
taglut
.
Exception
,
msg
:
print
"
Error:
"
,
msg
.
getMessage
()
sys
.
exit
()
if
__name__
==
"
__main__
"
:
main
()
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