Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Thompson
SMTK
Commits
25b9664a
Commit
25b9664a
authored
Feb 18, 2016
by
David Thompson
Browse files
Looks like "force create face" works with edges.
parent
69a41638
Changes
1
Hide whitespace changes
Inline
Side-by-side
smtk/bridge/polygon/testing/python/polygonForceCreateFace.py
View file @
25b9664a
...
...
@@ -39,65 +39,7 @@ class TestPolygonCreation(smtk.testing.TestCase):
#opnames = sess.operatorNames()
#print opnames
def
checkModel
(
self
,
mod
,
origin
,
x_axis
,
y_axis
,
normal
,
feature_size
,
model_scale
):
self
.
assertEqual
(
mod
.
floatProperty
(
'origin'
),
origin
,
'Bad origin'
)
[
self
.
assertAlmostEqual
(
mod
.
floatProperty
(
'x axis'
)[
i
],
x_axis
[
i
],
'Bad x axis'
)
for
i
in
range
(
3
)]
self
.
assertEqual
(
mod
.
floatProperty
(
'y axis'
),
y_axis
,
'Bad y axis'
)
self
.
assertEqual
(
mod
.
floatProperty
(
'normal'
),
normal
,
'Bad normal'
)
self
.
assertEqual
(
mod
.
floatProperty
(
'feature size'
),
[
feature_size
,],
'Bad feature size'
)
self
.
assertEqual
(
mod
.
integerProperty
(
'model scale'
),
[
int
(
model_scale
/
feature_size
),],
'Bad model scale'
)
#print smtk.io.ExportJSON.fromModelManager(self.mgr, smtk.io.JSON_DEFAULT)
# Print a summary of the model:
print
'Model '
,
mod
.
entity
()
print
' x axis '
,
(
' {:.3g}'
*
3
).
format
(
*
mod
.
floatProperty
(
'x axis'
))
print
' y axis '
,
(
' {:.3g}'
*
3
).
format
(
*
mod
.
floatProperty
(
'y axis'
))
print
' normal '
,
(
' {:.3g}'
*
3
).
format
(
*
mod
.
floatProperty
(
'normal'
))
print
' feature size {:14.3g}'
.
format
(
mod
.
floatProperty
(
'feature size'
)[
0
])
print
' model scale {:14d}'
.
format
(
mod
.
integerProperty
(
'model scale'
)[
0
])
# Square pierced by edges
weirdVerts
=
[
\
0.0
,
0.0
,
5.0
,
0.0
,
5.0
,
5.0
,
0.0
,
5.0
,
\
0.0
,
0.0
,
\
\
1.0
,
1.0
,
2.0
,
1.0
,
2.0
,
4.0
,
1.0
,
4.0
,
\
1.5
,
2.5
,
1.0
,
1.0
,
\
\
3.0
,
2.0
,
4.0
,
2.0
,
3.7
,
2.5
,
4.0
,
3.0
,
\
3.0
,
3.0
,
2.7
,
2.5
,
3.0
,
2.0
,
\
]
weirdCounts
=
[
5
,
2
,
6
,
7
]
fop
=
GetActiveSession
().
op
(
'force create face'
)
fop
.
associateEntity
(
mod
)
fop
.
findAsInt
(
'construction method'
).
setDiscreteIndex
(
0
)
SetVectorValue
(
fop
.
findAsInt
(
'counts'
),
weirdCounts
)
SetVectorValue
(
fop
.
findAsDouble
(
'points'
),
weirdVerts
)
fop
.
findAsInt
(
'coordinates'
).
setValue
(
0
,
2
)
res
=
fop
.
operate
()
PrintResultLog
(
res
)
self
.
mgr
.
assignDefaultNames
()
smtk
.
io
.
ExportJSON
.
fromModelManagerToFile
(
self
.
mgr
,
'/tmp/forcepoly.json'
)
def
testCreation
(
self
):
mod
=
CreateModel
()
self
.
checkModel
(
mod
,
[
0
,
0
,
0
],
[
1
,
0
,
0
],
[
0
,
1
,
0
],
[
0
,
0
,
1
],
1e-8
,
231000
)
#mod = CreateModel(x_axis=[1,0,0], y_axis=[0,1,0], model_scale=231000)
#self.checkModel(mod, [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], 1, 231000)
#mod = CreateModel(x_axis=[1,0,0], y_axis=[0,1,0], feature_size=1e-8)
#self.checkModel(mod, [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], 1e-8, 231000)
#mod = CreateModel(x_axis=[1,0,0], normal=[0,0,1], feature_size=1e-8)
#self.checkModel(mod, [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], 1e-8, 231000)
#mod = CreateModel(x_axis=[1,0,0], normal=[0,0,1], model_scale=1182720)
#self.checkModel(mod, [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], 1, 1182720)
def
renderTestModel
(
self
,
mod
,
baselinePath
):
if
self
.
haveVTK
()
and
self
.
haveVTKExtension
():
...
...
@@ -115,12 +57,15 @@ class TestPolygonCreation(smtk.testing.TestCase):
cam
.
SetViewUp
(
0
,
1
,
0
)
self
.
renderer
.
ResetCamera
()
self
.
renderWindow
.
Render
()
# Uncomment for debugging before the image test fails:
#smtk.testing.INTERACTIVE = True
#self.interact()
# Skip the image match if we don't have a baseline.
# This allows the test to succeed even on systems without the test
# data but requires a match on systems with the test data.
self
.
assertImageMatchIfFileExists
(
[
'
baseline
s'
,
'polygon'
,
'forceCreateFaces.png'
]
)
self
.
assertImageMatchIfFileExists
(
baseline
Path
)
self
.
interact
()
else
:
...
...
@@ -128,6 +73,71 @@ class TestPolygonCreation(smtk.testing.TestCase):
self
.
haveVTKExtension
(),
'Could not import vtk. Python path is {pp}'
.
format
(
pp
=
sys
.
path
))
def
testCreationFromPoints
(
self
):
print
'testCreationFromPoints'
# Create a default model (in the x-y plane)
mod
=
CreateModel
()
weirdPoints
=
[
\
0.0
,
0.0
,
5.0
,
0.0
,
5.0
,
5.0
,
0.0
,
5.0
,
\
0.0
,
0.0
,
\
\
1.0
,
1.0
,
2.0
,
1.0
,
2.0
,
4.0
,
1.0
,
4.0
,
\
1.5
,
2.5
,
1.0
,
1.0
,
\
\
3.0
,
2.0
,
4.0
,
2.0
,
3.7
,
2.5
,
4.0
,
3.0
,
\
3.0
,
3.0
,
2.7
,
2.5
,
3.0
,
2.0
,
\
]
weirdCounts
=
[
5
,
2
,
6
,
7
]
fop
=
GetActiveSession
().
op
(
'force create face'
)
fop
.
associateEntity
(
mod
)
fop
.
findAsInt
(
'construction method'
).
setDiscreteIndex
(
0
)
SetVectorValue
(
fop
.
findAsInt
(
'counts'
),
weirdCounts
)
SetVectorValue
(
fop
.
findAsDouble
(
'points'
),
weirdPoints
)
fop
.
findAsInt
(
'coordinates'
).
setValue
(
0
,
2
)
res
=
fop
.
operate
()
PrintResultLog
(
res
)
self
.
mgr
.
assignDefaultNames
()
smtk
.
io
.
ExportJSON
.
fromModelManagerToFile
(
self
.
mgr
,
'/tmp/forcepoly.json'
)
self
.
renderTestModel
(
mod
,
[
'baselines'
,
'polygon'
,
'forceCreateFaces.png'
])
def
testCreationFromEdges
(
self
):
print
'testCreationFromEdges'
# Create a default model (in the x-y plane)
mod
=
CreateModel
()
# Create edges that will compose face:
weirdPoints
=
[
\
# Outer
[
0.0
,
0.0
],
[
5.0
,
0.0
],
\
[
5.0
,
5.0
],
[
5.0
,
0.0
],
\
[
5.0
,
5.0
],
[
0.0
,
5.0
],
[
0.0
,
0.0
],
\
\
# Inner
[
1.0
,
1.0
],
[
1.5
,
2.5
],
[
1.0
,
4.0
],
[
2.0
,
4.0
],
[
2.0
,
1.0
],
[
1.0
,
1.0
],
\
[
3.0
,
2.0
],
[
2.7
,
2.5
],
[
3.0
,
3.0
],
[
4.0
,
3.0
],
[
3.7
,
2.5
],
[
4.0
,
2.0
],
[
3.0
,
2.0
],
\
]
weirdOffsets
=
[
0
,
2
,
4
,
7
,
13
,]
elist
=
CreateEdge
(
weirdPoints
,
offsets
=
weirdOffsets
,
model
=
mod
)
# Create the face from edges we specify
fop
=
GetActiveSession
().
op
(
'force create face'
)
for
e
in
elist
:
fop
.
associateEntity
(
e
)
fop
.
findAsInt
(
'construction method'
).
setDiscreteIndex
(
1
)
SetVectorValue
(
fop
.
findAsInt
(
'counts'
),
[
3
,
2
,
1
,
1
])
SetVectorValue
(
fop
.
findAsInt
(
'orientations'
),
[
+
1
,
-
1
,
+
1
,
+
1
,
+
1
])
res
=
fop
.
operate
()
PrintResultLog
(
res
)
self
.
mgr
.
assignDefaultNames
()
smtk
.
io
.
ExportJSON
.
fromModelManagerToFile
(
self
.
mgr
,
'/tmp/forcepoly2.json'
)
self
.
renderTestModel
(
mod
,
[
'baselines'
,
'polygon'
,
'forceCreateFaces.png'
])
if
__name__
==
'__main__'
:
smtk
.
testing
.
process_arguments
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment