Commit 8161c2fe authored by David Thompson's avatar David Thompson
Browse files

Fix build and tweak Import operator.

The polygon-model feature size is now set as a fraction of the
bounds of the file being imported.
parent c4bbb0fc
......@@ -6,6 +6,7 @@ foreach(target
vtkInteractionStyle
vtkRenderingFreeType
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingGL2PS${VTK_RENDERING_BACKEND}
)
if (TARGET ${target})
list(APPEND __dependencies ${target})
......
......@@ -25,6 +25,16 @@ install(FILES PointerDefs.h DESTINATION include/smtk/${SMTK_VERSION}/smtk/bridge
add_library(smtkExodusSession ${exodusSrcs})
#set smtkExodusSession to publicly link to smtkCore and VTK
set(__dependencies)
foreach(lib IN ITEMS
vtkIOMPIImage
vtkIOMPIParallel
)
if (TARGET ${lib})
list(APPEND __dependencies ${lib})
endif()
endforeach()
target_link_libraries(smtkExodusSession
LINK_PUBLIC
smtkCore
......@@ -36,10 +46,9 @@ target_link_libraries(smtkExodusSession
vtkImagingCore
vtkFiltersGeneral
vtkIOParallelExodus
vtkIOMPIImage
vtkIOGeometry
vtkIOMPIParallel
vtkFiltersGeometry
${__dependencies}
${Boost_LIBRARIES}
)
smtk_export_header(smtkExodusSession Exports.h)
......
......@@ -37,7 +37,7 @@ namespace smtk {
typedef smtk::shared_ptr<face> FacePtr;
typedef long long Coord;
typedef typename boost::polygon::high_precision_type<Coord>::type HighPrecisionCoord;
typedef boost::polygon::high_precision_type<Coord>::type HighPrecisionCoord;
typedef smtk::common::UUID Id;
typedef boost::polygon::point_data<Coord> Point;
typedef boost::polygon::point_data<HighPrecisionCoord> HighPrecisionPoint;
......
......@@ -694,7 +694,8 @@ struct Neighborhood
// If this is a new region, create a record for it.
if (this->m_regions.find(winner) == this->m_regions.end())
{
this->m_regions[winner] = smtk::make_shared<Region>(*ringB, !isOutB);
bool seedSense = !isOutB;
this->m_regions[winner] = smtk::make_shared<Region>(*ringB, seedSense);
}
if (this->m_regions.find(loser) != this->m_regions.end())
{
......
......@@ -132,7 +132,7 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh,
if (pedigree && numNewEdges > 0)
{
vtkIdType pedId = pedigree[pidx];
// std::cout << "pedid: " << pedId << std::endl;
//std::cout << "pedid: " << pedId << std::endl;
while(pidx < numPedIDs - 1 && pedId == pedigree[pidx + 1])
{
// The next line cell is an inner loop
......@@ -141,7 +141,7 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh,
numNewEdges += polyLines2modelEdges(mesh, edgeOp, createdEds, pointsItem,
pts, npts, logger);
}
// std::cout << "inner pedid: " << pedId << std::endl;
//std::cout << "inner pedid: " << pedId << std::endl;
++pidx;
}
}
......@@ -149,7 +149,7 @@ int polyLines2modelEdgesAndFaces(vtkPolyData *mesh,
{
numEdges += numNewEdges;
faceSpec->associations()->setValues(createdEds.begin(), createdEds.end());
// std::cout << "number of created new edges: " << createdEds.size() << std::endl;
//std::cout << "number of created new edges: " << createdEds.size() << std::endl;
smtk::attribute::IntItem::Ptr orientArr = faceSpec->findInt("orientations");
std::vector<int> orients (numNewEdges, -1);
//orients[0] = 1; // first one is outer loop
......@@ -372,8 +372,30 @@ OperatorResult Import::operateInternal()
smtkInfoMacro(log(), "Failed to create CreateModel op.");
result = this->createResult(OPERATION_FAILED);
}
modOp->findInt("model scale")->setValue(1);
modOp->findDouble("feature size")->setValue(1.0);
//modOp->findInt("model scale")->setValue(1);
double bds[6];
polyOutput->GetBounds(bds);
double diam = 0.0;
for (int i = 0; i < 3; ++i)
{
diam += (bds[2*i + 1] - bds[2*i]) * (bds[2*i + 1] - bds[2*i]);
}
diam = sqrt(diam);
//std::cout << "diam " << diam << "\n";
// Use the lower-left-front bounds as the origin of the plane.
// This keeps the projected integer coordinates small when the dataset is not
// well-centered about the origin and makes overflow less likely.
// However, it does mean that multiple imported polygon models in the same
// plane will not share coordinates exactly.
for (int i = 0; i < 3; ++i)
{
modOp->findDouble("origin")->setValue(i, bds[2 * i]);
}
// Infer a feature size from the bounds:
modOp->findDouble("feature size")->setValue(diam / 1000.0);
OperatorResult modResult = modOp->operate();
if (modResult->findInt("outcome")->value() != OPERATION_SUCCEEDED)
{
......
#!/usr/bin/python
import sys
import os
#=============================================================================
#
# Copyright (c) Kitware, Inc.
# All rights reserved.
# See LICENSE.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the above copyright notice for more information.
#
#=============================================================================
import smtk
from smtk.simple import *
import smtk.testing
class TestPolygonImport(smtk.testing.TestCase):
def setUp(self):
self.writeJSON = True
self.mgr = smtk.model.Manager.create()
sess = self.mgr.createSession('polygon')
brg = sess.session()
print sess
print brg
sess.assignDefaultName()
SetActiveSession(sess)
print '\n\n%s: type "%s" %s %s' % \
(sess.name(), brg.name(), sess.flagSummary(0), brg.sessionId())
print ' Site: %s' % (sess.site() or 'local')
# We could evaluate the session tag as JSON, but most of
# the information is available through methods above that
# we needed to test:
sessiontag = sess.tag()
print '\n'
#opnames = sess.operatorNames()
#print opnames
def testImportShapefile(self):
iop = GetActiveSession().op('import')
iop.findAsFile('filename').setValue( \
os.path.join(smtk.testing.DATA_DIR, 'gis', 'ponds_lidar_cropped.shp'))
res = iop.operate()
print '----'
PrintResultLog(res, always=True)
cre = res.findModelEntity('created')
print cre
print '----'
self.assertEqual(cre.numberOfValues(), 1, 'Import failed to create a single model')
mod = smtk.model.Model(cre.value(0))
if self.writeJSON:
smtk.io.ExportJSON.fromModelManagerToFile(self.mgr, '/tmp/shapefile.json')
if self.haveVTK() and self.haveVTKExtension():
self.startRenderTest()
mod = smtk.model.Model(mod)
[mod.addCell(x) for x in self.mgr.findEntitiesOfType(smtk.model.CELL_ENTITY, False)]
ms, vs, mp, ac = self.addModelToScene(mod)
ac.GetProperty().SetLineWidth(2)
ac.GetProperty().SetPointSize(6)
cam = self.renderer.GetActiveCamera()
cam.SetFocalPoint(5,5,0)
cam.SetPosition(5,5,5)
cam.SetViewUp(0,1,0)
self.renderer.ResetCamera()
self.renderWindow.Render()
# 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(['baselines', 'polygon', 'import.png'])
self.interact()
else:
self.assertFalse(
self.haveVTKExtension(),
'Could not import vtk. Python path is {pp}'.format(pp=sys.path))
if __name__ == '__main__':
smtk.testing.process_arguments()
smtk.testing.main()
set (__dependencies)
# Test for targets that might be required or
# might not exist.
foreach(target
vtkInteractionStyle
vtkRenderingFreeType
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingMatplotlib
vtkRenderingVolume
vtkRenderingVolume${VTK_RENDERING_BACKEND}
vtkRenderingContext${VTK_RENDERING_BACKEND}
vtkRenderingGL2PS${VTK_RENDERING_BACKEND}
)
if (TARGET ${target})
list(APPEND __dependencies ${target})
endif()
endforeach()
# if there is Remus, add map file reader and support files.
if(SMTK_ENABLE_REMUS_SUPPORT)
vtk_module(vtkSMTKMeshingExt
......@@ -11,12 +29,7 @@ if(SMTK_ENABLE_REMUS_SUPPORT)
vtkIOGeometry
vtkIOParallelExodus
vtkRenderingCore
vtkRenderingFreeType
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingMatplotlib
vtkRenderingVolume
vtkRenderingVolume${VTK_RENDERING_BACKEND}
vtkRenderingContext${VTK_RENDERING_BACKEND}
${__dependencies}
vtksys
EXCLUDE_FROM_WRAP_HIERARCHY
)
......
......@@ -57,6 +57,7 @@ foreach(target
vtkRenderingContext${VTK_RENDERING_BACKEND}
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingVolume${VTK_RENDERING_BACKEND}
vtkRenderingGL2PS${VTK_RENDERING_BACKEND}
vtkIOGeometry
vtkIOMPIParallel
vtkIOMPIImage
......
set (__dependencies)
# Test for targets that might be required or
# might not exist.
foreach(target
vtkInteractionStyle
vtkRenderingFreeType
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingGL2PS${VTK_RENDERING_BACKEND}
)
if (TARGET ${target})
list(APPEND __dependencies ${target})
endif()
endforeach()
vtk_module(vtkSMTKSourceExt
DEPENDS
vtkCommonCore
......@@ -9,6 +24,8 @@ vtk_module(vtkSMTKSourceExt
vtkViewsInfovis
vtkIOXML
vtkIOLegacy
PRIVATE_DEPENDS
${__dependencies}
TEST_DEPENDS
vtkTestingRendering
EXCLUDE_FROM_WRAP_HIERARCHY
......
......@@ -3,7 +3,6 @@ target_link_libraries(displayModel
smtkCore
vtkSMTKSourceExt
vtkTestingRendering
${SMTK_VTK_TARGET_LIST}
)
add_executable(displayMultiBlockModel MACOSX_BUNDLE displayMultiBlockModel.cxx)
......
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