Commit 2c7e9bc4 authored by David Thompson's avatar David Thompson
Browse files

Handle some degenerate inputs...

... where point coordinates are repeated (by skipping the
copies). Also, make holes in the test face concave.
parent 56f320fb
......@@ -93,6 +93,10 @@ smtk::model::OperatorResult ForceCreateFace::operateInternal()
for (cit = pointsItem->begin(); cit != pointsItem->end(); cit += numCoordsPerPt)
{
internal::Point pt = pmodel->projectPoint(cit, cit + numCoordsPerPt);
if (!polypts.empty() && polypts.back() == pt)
{
continue;
}
polypts.push_back(pt);
}
......@@ -105,10 +109,10 @@ smtk::model::OperatorResult ForceCreateFace::operateInternal()
{
++oidx;
offset = (oidx == numOffsets) ?
pointsItem->numberOfValues() / numCoordsPerPt :
polypts.size() :
offsetsItem->value(oidx);
}
if (offset <= 3 || offset >= static_cast<int>(polypts.size()))
if (offset <= 3 || offset > static_cast<int>(polypts.size()))
{
smtkErrorMacro(this->log(), "Invalid offset (" << offset << ") or too few points (" << polypts.size() << ").");
return this->createResult(smtk::model::OPERATION_FAILED);
......
......@@ -62,12 +62,14 @@ class TestPolygonCreation(smtk.testing.TestCase):
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.0,1.0, \
3.0,2.0, 4.0,2.0, 4.0,3.0, 3.0,3.0, \
3.0,2.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, \
]
weirdOffsets = [0, 5, 10]
weirdOffsets = [0, 5, 11]
fop = GetActiveSession().op('force create face')
fop.associateEntity(mod)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment