Commit e29a8f4c authored by David Thompson's avatar David Thompson
Browse files

Add pedigree IDs to polygon imports.

... and test the import operator. The large image error allowance (50.0)
is because the image is larger and (on Mac OS X 10.11 with current
VTK) edge thickness varies significantly from run to run. Grrr.
parent 4d6bf7ab
...@@ -94,7 +94,7 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh, ...@@ -94,7 +94,7 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh,
smtk::io::Logger& logger) smtk::io::Logger& logger)
{ {
int numEdges = 0; int numEdges = 0;
vtkCellArray *lines = mesh->GetLines(); vtkCellArray* lines = mesh->GetLines();
if (lines) if (lines)
{ {
smtk::model::Operator::Ptr edgeOp = sess->op("create edge"); smtk::model::Operator::Ptr edgeOp = sess->op("create edge");
...@@ -136,9 +136,10 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh, ...@@ -136,9 +136,10 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh,
counts.push_back(0); counts.push_back(0);
// peek at next pedigree id if possible, to see if the pedId is the same, if yes, // peek at next pedigree id if possible, to see if the pedId is the same, if yes,
// the next cell is the inner loop // the next cell is the inner loop
vtkIdType pedId = -1;
if (pedigree && numNewEdges > 0) if (pedigree && numNewEdges > 0)
{ {
vtkIdType pedId = pedigree[pidx]; pedId = pedigree[pidx];
//std::cout << "pedid: " << pedId << std::endl; //std::cout << "pedid: " << pedId << std::endl;
while(pidx < numPedIDs - 1 && pedId == pedigree[pidx + 1]) while(pidx < numPedIDs - 1 && pedId == pedigree[pidx + 1])
{ {
...@@ -171,6 +172,8 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh, ...@@ -171,6 +172,8 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh,
{ {
smtkDebugMacro(logger, "\"force create face\" op failed to creat face with given edges."); smtkDebugMacro(logger, "\"force create face\" op failed to creat face with given edges.");
} }
// Add a pedigree ID (if we have it, or -1 otherwise) to each face:
faceResult->findModelEntity("created")->value(0).setIntegerProperty("pedigree", pedId);
} }
} }
} }
......
...@@ -6,6 +6,7 @@ set(smtkPolygonSessionPythonDataTests ...@@ -6,6 +6,7 @@ set(smtkPolygonSessionPythonDataTests
polygonCreate polygonCreate
polygonCreateFaces polygonCreateFaces
polygonForceCreateFace polygonForceCreateFace
polygonImport
#polygonReadFile #polygonReadFile
) )
......
...@@ -52,7 +52,7 @@ class TestPolygonImport(smtk.testing.TestCase): ...@@ -52,7 +52,7 @@ class TestPolygonImport(smtk.testing.TestCase):
def testImportShapefile(self): def testImportShapefile(self):
iop = GetActiveSession().op('import') iop = GetActiveSession().op('import')
iop.findAsFile('filename').setValue( \ iop.findAsFile('filename').setValue( \
os.path.join(smtk.testing.DATA_DIR, 'gis', 'countries.shp')) os.path.join(smtk.testing.DATA_DIR, 'gis', 'ne_110m_land', 'ne_110m_land.shp'))
res = iop.operate() res = iop.operate()
print '----' print '----'
PrintResultLog(res, always=True) PrintResultLog(res, always=True)
...@@ -74,23 +74,27 @@ class TestPolygonImport(smtk.testing.TestCase): ...@@ -74,23 +74,27 @@ class TestPolygonImport(smtk.testing.TestCase):
freeCells = mod.cells() freeCells = mod.cells()
# Color faces: # Color faces:
for i in range(len(freeCells)): for i in range(len(freeCells)):
freeCells[i].setColor(self.color(i) if freeCells[i].isFace() else (0,0,0,1)) if freeCells[i].isFace():
colorIdx = freeCells[i].integerProperty('pedigree')
freeCells[i].setColor(self.color(colorIdx[0]))
else:
freeCells[i].setColor((0,0,0,1))
ms, vs, mp, ac = self.addModelToScene(mod) ms, vs, mp, ac = self.addModelToScene(mod)
ac.GetProperty().SetLineWidth(2) ac.GetProperty().SetLineWidth(2)
ac.GetProperty().SetPointSize(6) ac.GetProperty().SetPointSize(6)
self.renderer.SetBackground(255, 255, 255) self.renderer.SetBackground(255, 255, 255)
self.renderWindow.SetSize(800,400)
cam = self.renderer.GetActiveCamera() cam = self.renderer.GetActiveCamera()
cam.SetFocalPoint(5,5,0)
cam.SetPosition(5,5,5)
cam.SetViewUp(0,1,0) cam.SetViewUp(0,1,0)
self.renderer.ResetCamera() self.renderer.ResetCamera()
cam.Zoom(2.19)
self.renderWindow.Render() self.renderWindow.Render()
# Skip the image match if we don't have a baseline. # Skip the image match if we don't have a baseline.
# This allows the test to succeed even on systems without the test # This allows the test to succeed even on systems without the test
# data but requires a match on systems with the test data. # data but requires a match on systems with the test data.
self.assertImageMatchIfFileExists(['baselines', 'polygon', 'import.png']) self.assertImageMatch(['baselines', 'polygon', 'import-ne_110m_land.png'], 50.0)
self.interact() self.interact()
else: else:
......
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