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

Progress on face creation.

Some utility methods for creating SMTK entity records in common arrangemnts.
parent 4780ed34
......@@ -29,6 +29,9 @@ namespace smtk
//bring the correct shared_ptr implementation into our project namespace
using @POINTER_NAMESPACE@::shared_ptr;
//bring the correct make_shared implementation into our project namespace
using @POINTER_NAMESPACE@::make_shared;
//bring the correct weak_ptr implementation into our project namespace
using @POINTER_NAMESPACE@::weak_ptr;
......
......@@ -36,6 +36,9 @@ target_link_libraries(smtkExodusSession
vtkImagingCore
vtkFiltersGeneral
vtkIOParallelExodus
vtkIOMPIImage
vtkIOGeometry
vtkIOMPIParallel
vtkFiltersGeometry
${Boost_LIBRARIES}
)
......
......@@ -664,9 +664,10 @@ struct Neighborhood
// If this is a new region, create a record for it.
if (!this->m_regions[winner])
{
this->m_regions[winner] = smtk::shared_ptr<Region>(new Region(*ringB, !isOutB));
this->m_regions[winner] = smtk::make_shared<Region>(*ringB, !isOutB);
}
this->m_regions[winner]->merge(this->m_regions[loser].get());
this->m_regions.erase(loser);
}
else
{ // Add coedges (of exiting edges on inside of A--B) to region.
......@@ -931,6 +932,13 @@ struct Neighborhood
}
}
#else // 0
std::set<RegionId> found = this->m_regionIds.roots();
std::cout << "Top-level:";
for (std::set<RegionId>::const_iterator rit = found.begin(); rit != found.end(); ++rit)
{
std::cout << " " << this->m_regionIds.find(*rit);
}
std::cout << "\n";
for (RegionId x = 0; x < static_cast<RegionId>(this->m_fragments->size() * 2); ++x)
{
if (this->m_regions.find(x) != this->m_regions.end())
......@@ -939,7 +947,7 @@ struct Neighborhood
if (regRec)
{
std::cout << " Region " << x;
std::cout << " seed frag " << regRec->m_seedFragment << " sense " << regRec->m_seedSense << " has " << regRec->m_innerLoops.size() << " holes.\n";
std::cout << " seed frag " << regRec->m_seedFragment << " sense " << regRec->m_seedSense << "\n";//" has " << regRec->m_innerLoops.size() << " holes.\n";
}
}
}
......
......@@ -140,6 +140,16 @@ class TestPolygonCreation(smtk.testing.TestCase):
arf = SplitEdge(elist, [2, 4])
innerLoopVerts = [ \
[1.25,3.35], [1.65,3.75], [1.25,3.75], [1.25,3.35], \
[1.35,3.25], [1.75,3.25], [1.75,3.65], [1.35,3.25], \
#[0.25,4.25], [0.75,4.25], [0.75,4.75], [0.25,4.25], \
#[0.25,4.25], [0.25,4.75], [0.75,4.75], \
]
innerLoopOffsets = [0, 4];
#innerLoopOffsets = [0, 4, 8, 12];
elist = CreateEdge(innerLoopVerts, offsets=innerLoopOffsets, model=mod)
smtk.io.ExportJSON.fromModelManagerToFile(self.mgr, '/tmp/poly.json')
flist = CreateFaces(mod)
......@@ -176,10 +186,11 @@ class TestPolygonCreation(smtk.testing.TestCase):
cam.SetViewUp(0,1,0)
self.renderer.ResetCamera()
self.renderWindow.Render()
smtk.testing.INTERACTIVE = True
# 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', 'creation.png'])
self.assertImageMatchIfFileExists(['baselines', 'polygon', 'createFaces.png'])
self.interact()
else:
......
......@@ -62,6 +62,9 @@ foreach(target
vtkRenderingContext${VTK_RENDERING_BACKEND}
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingVolume${VTK_RENDERING_BACKEND}
vtkIOGeometry
vtkIOMPIParallel
vtkIOMPIImage
)
if (TARGET ${target})
list(APPEND SMTK_VTK_TARGET_LIST ${target})
......
......@@ -33,6 +33,27 @@ smtk::model::EdgeUses Edge::edgeUses() const
return this->uses<EdgeUses>();
}
/**\brief Return the edge use-record with the given \a sense and \a orientation, creating it if needed.
*
* The \a orientation specifies whether the edge use-record refers to the positive (\a orientation true)
* or negative direction of the edge.
*
* The \a sense specifies the context in which the edge is used.
* For models whose parametric dimension is 2, the \a sense should always be 0.
* For models with higher dimension (e.g., volumetric models), each loop
* referring to an edge should have a unique combination of (sense, orientation).
*/
EdgeUse Edge::findOrAddEdgeUse(Orientation orientation, int sense)
{
smtk::model::Manager::Ptr mgr(this->m_manager.lock());
if (this->isValid())
{
return EdgeUse(mgr,
mgr->findCreateOrReplaceCellUseOfSenseAndOrientation(this->m_entity, sense, orientation));
}
return EdgeUse();
}
/**\brief Return the vertices which bound this edge.
*
* This method is provided for convenience.
......
......@@ -34,6 +34,8 @@ public:
EdgeUses edgeUses() const;
Vertices vertices() const;
EdgeUse findOrAddEdgeUse(Orientation o, int sense = 0);
};
} // namespace model
......
......@@ -370,6 +370,19 @@ public:
Instance addInstance();
Instance addInstance(const EntityRef& instanceOf);
template<typename T>
bool insertModelFaceWithOrientedOuterLoop(
const smtk::common::UUID& faceId, // to be created
const smtk::common::UUID& faceUseId, // to be created
const smtk::common::UUID& loopId, // to be created
const T& orderedEdgesWithOrientation);
template<typename T>
bool insertModelFaceOrientedInnerLoop(
const smtk::common::UUID& loopId, // to be created
const smtk::common::UUID& preExistingLoopId, // the outer loop to contain the inner loop
const T& orderedEdgesWithOrientation);
void observe(ManagerEventType event, ConditionCallback functionHandle, void* callData);
void observe(ManagerEventType event, OneToOneCallback functionHandle, void* callData);
void observe(ManagerEventType event, OneToManyCallback functionHandle, void* callData);
......
//=========================================================================
// 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.
//=========================================================================
#ifndef __smtk_model_Manager_txx
#define __smtk_model_Manager_txx
namespace smtk {
namespace model {
/**\brief Create face, face-use, loop, and potentially edge-use records given edges.
*
* Only one face use (the positive use) will be populated for the face.
* The edges must be ordered from head to tail in a counter-clockwise loop (relative to
* the orientation of the face use) and the \a orderedEdgesWithOrientation
* object passed to this method must be an STL-like container of
* pair<smtk::model::Edge, bool> entries.
* The boolean value stored with each edge indicates the orientation of
* each model edge relative to the loop.
*/
template<typename T>
bool Manager::insertModelFaceWithOrientedOuterLoop(
const smtk::common::UUID& faceId, // to be created
const smtk::common::UUID& faceUseId, // to be created
const smtk::common::UUID& loopId, // to be created
const T& orderedEdgesWithOrientation)
{
// First, create the ID'd top-level entity records:
Face f = this->insertFace(faceId);
FaceUse fu = this->insertFaceUse(faceUseId);
Loop l = this->setLoop(loopId, fu);
// Now loop over the container's entries (which must behave like std::pair<smtk::model::Edge, bool>)
// adding edge uses for each edge to the loop.
for (T::const_iterator oeit = orderedEdgesWithOrientation.begin(); oeit != orderedEdgesWithOrientation.end(); ++oeit)
{
EdgeUse eu = oeit->first.findOrAddEdgeUse(oeit->second, 0);
l.addUse(eu);
}
return true;
}
/**\brief Create an inner loop (hole) in a face-use and add ordered edge uses to it.
*
* The edges must be ordered from head to tail in a counter-clockwise loop (relative to
* the orientation of the face use) and the \a orderedEdgesWithOrientation
* object passed to this method must be an STL-like container of
* pair<smtk::model::Edge, bool> entries.
* The boolean value stored with each edge indicates the orientation of
* each model edge relative to the loop.
*/
template<typename T>
bool insertModelFaceOrientedInnerLoop(
const smtk::common::UUID& loopId,
const smtk::common::UUID& preExistingLoopId,
const T& orderedEdgesWithOrientation)
{
Loop outer(sharedFromThis(),preExistingLoopId);
if (!outer.isValid())
{
smtkErrorMacro(this->log(),
"Asked to add an inner loop to invalid outer loop " << outer.name());
return false;
}
Loop inner = this->setLoop(loopId, outer);
// Now loop over the container's entries (which must behave like std::pair<smtk::model::Edge, bool>)
// adding edge uses for each edge to the loop.
for (T::const_iterator oeit = orderedEdgesWithOrientation.begin(); oeit != orderedEdgesWithOrientation.end(); ++oeit)
{
EdgeUse eu = oeit->first.findOrAddEdgeUse(oeit->second, 0);
inner.addUse(eu);
}
return true;
}
} // model namespace
} // smtk namespace
#endif // __smtk_model_Manager_txx
......@@ -50,6 +50,8 @@
<suppress-warning text="skipping function 'smtk::model::EntityRef::addMemberEntities', unmatched parameter type 'T'"/>
<suppress-warning text="skipping function 'smtk::model::EntityRef::relationsAs', unmatched return type 'T'"/>
<suppress-warning text="skipping function 'smtk::model::Group::addEntities', unmatched parameter type 'T const&amp;'"/>
<suppress-warning text="skipping function 'smtk::model::Manager::insertModelFaceOrientedInnerLoop', unmatched parameter type 'T const&amp;'"/>
<suppress-warning text="skipping function 'smtk::model::Manager::insertModelFaceWithOrientedOuterLoop', unmatched parameter type 'T const&amp;'"/>
<suppress-warning text="skipping function 'smtk::model::Model::addSubmodels', unmatched parameter type 'T const&amp;'"/>
<suppress-warning text="skipping function 'smtk::model::Model::appendCells', unmatched parameter type 'T&amp;'"/>
<suppress-warning text="skipping function 'smtk::model::Model::removeSubmodels', unmatched parameter type 'T const&amp;'"/>
......
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