Commit 4f119e3b authored by David Thompson's avatar David Thompson
Browse files

Fix various warnings and stupid logic.

parent 446a7d1e
......@@ -51,5 +51,5 @@ namespace smtk
#endif
};
}
#endif /* __smtk_SharedPtr_h */
......@@ -167,7 +167,7 @@ namespace smtk
namespace common
{
typedef smtk::shared_ptr< smtk::common::Resource > ResourcePtr;
};
}
//Shiboken requires that we use fully qualified namespaces for all
//types that these shared_ptr and weak_ptr are holding
......@@ -209,7 +209,7 @@ namespace smtk
typedef smtk::shared_ptr< smtk::attribute::Definition > OperatorDefinition;
typedef smtk::shared_ptr< smtk::attribute::Attribute > OperatorSpecification;
typedef smtk::shared_ptr< smtk::attribute::Attribute > OperatorResult;
};
}
namespace attribute
{
......@@ -272,7 +272,7 @@ namespace smtk
// Note used by SMTK but added for completeness
typedef smtk::shared_ptr< smtk::attribute::System > SystemPtr;
};
}
namespace bridge
{
......@@ -289,7 +289,7 @@ namespace smtk
//custom user data classes
typedef smtk::shared_ptr< smtk::simulation::ExportSpec > ExportSpecPtr;
typedef smtk::shared_ptr< smtk::simulation::UserData > UserDataPtr;
};
}
namespace view
{
......@@ -302,7 +302,7 @@ namespace smtk
typedef smtk::shared_ptr< smtk::view::ModelEntity> ModelEntityPtr;
typedef smtk::shared_ptr< smtk::view::Root> RootPtr;
typedef smtk::shared_ptr< smtk::view::SimpleExpression> SimpleExpressionPtr;
};
}
#ifdef smtk_has_owner_less
//special map and set typedefs for better safety with sets of weak pointers
......@@ -317,13 +317,13 @@ namespace smtk
smtk::owner_less< attribute::WeakItemDefinitionPtr > > WeakItemDefinitionPtrSet;
typedef std::set< attribute::WeakItemPtr,
smtk::owner_less< attribute::WeakItemPtr > > WeakItemPtrSet;
};
}
namespace view
{
typedef std::set< view::WeakBasePtr,
smtk::owner_less<view::WeakBasePtr > > WeakViewPtrSet;
};
}
#else
//we can use less than operator
......@@ -333,12 +333,12 @@ namespace smtk
typedef std::set< attribute::WeakDefinitionPtr > WeakDefinitionPtrSet;
typedef std::set< attribute::WeakItemDefinitionPtr > WeakItemDefinitionPtrSet;
typedef std::set< attribute::WeakItemPtr > WeakItemPtrSet;
};
}
namespace view
{
typedef std::set< view::WeakBasePtr > WeakBasePtrSet;
};
}
#endif
// These are used internally by SMTK
......
......@@ -43,7 +43,7 @@
typedef smtk::shared_ptr< __VA_ARGS__ > Ptr; \
typedef smtk::shared_ptr< const __VA_ARGS__ > ConstPtr; \
typedef smtk::weak_ptr< __VA_ARGS__ > WeakPtr; \
typedef smtk::weak_ptr< const __VA_ARGS__ > WeakConstPtr;
typedef smtk::weak_ptr< const __VA_ARGS__ > WeakConstPtr
/**\brief Add a typedef to the superclass of this class.
*
......@@ -58,7 +58,7 @@
*/
#define smtkSuperclassMacro(...) \
typedef __VA_ARGS__ Superclass; \
typedef smtk::shared_ptr< __VA_ARGS__ > SuperclassPtr;
typedef smtk::shared_ptr< __VA_ARGS__ > SuperclassPtr
/**\brief Add static create() methods to a class.
*
......@@ -169,7 +169,7 @@
/// A convenience macro for declaring shared_from_this and create methods.
#define smtkSharedPtrCreateMacro(...) \
smtkSharedFromThisMacro( __VA_ARGS__ ); \
smtkCreateMacro( __VA_ARGS__ );
smtkCreateMacro( __VA_ARGS__ )
/**\brief A convenience macro to use in the body of create methods that take arguments.
*
......@@ -207,6 +207,6 @@
SharedPtrBaseType::Ptr( \
__VA_ARGS__ \
) \
);
)
#endif // __smtk_SharedFromThis_h
......@@ -56,15 +56,15 @@ public:
bool setValue(const smtk::model::EntityRef& val);
bool setValue(std::size_t element, const smtk::model::EntityRef& val);
template<typename I>
bool setValues(I begin, I end)
bool setValues(I vbegin, I vend)
{
bool ok = false;
std::size_t num = end - begin;
std::size_t num = vend - vbegin;
if (this->setNumberOfValues(num))
{
ok = true;
std::size_t i = 0;
for (I it = begin; it != end; ++it, ++i)
for (I it = vbegin; it != vend; ++it, ++i)
if (!this->setValue(i, *it))
{
ok = false;
......
......@@ -50,15 +50,15 @@ namespace smtk
{return this->setValue(0, val);}
bool setValue(std::size_t element, const DataT &val);
template<typename I>
bool setValues(I begin, I end)
bool setValues(I vbegin, I vend)
{
bool ok = false;
std::size_t num = end - begin;
std::size_t num = vend - vbegin;
if (this->setNumberOfValues(num))
{
ok = true;
std::size_t i = 0;
for (I it = begin; it != end; ++it, ++i)
for (I it = vbegin; it != vend; ++it, ++i)
if (!this->setValue(i, *it))
{
ok = false;
......
......@@ -81,7 +81,7 @@ smtk::model::OperatorResult BooleanIntersection::operateInternal()
EntityRefArray expunged;
bool ok = true;
ok |= this->cgmEntities(
ok &= this->cgmEntities(
*this->specification()->associations().get(),
cgmBodiesIn,
/* keep_inputs */ 1,
......@@ -98,7 +98,7 @@ smtk::model::OperatorResult BooleanIntersection::operateInternal()
if (toolIn->numberOfValues() > 0)
{
DLIList<Body*> cgmToolBodies;
ok |= this->cgmEntities(
ok &= this->cgmEntities(
*this->findModelEntity("tool").get(),
cgmToolBodies, keepInputs, expunged);
if (!ok)
......
......@@ -62,15 +62,15 @@ smtk::model::OperatorResult BooleanSubtraction::operateInternal()
DLIList<Body*> cgmToolsIn;
Body* cgmBody;
EntityRefArray expunged;
bool ok;
ok |= this->cgmEntities(*this->specification()->associations().get(), cgmBodiesIn, keepInputs, expunged);
bool ok = true;
ok &= this->cgmEntities(*this->specification()->associations().get(), cgmBodiesIn, keepInputs, expunged);
if (!ok)
{
smtkInfoMacro(log(), "Need at least 1 workpiece, none of the associated entities were valid.");
return this->createResult(smtk::model::OPERATION_FAILED);
}
ok |= this->cgmEntities(*this->findModelEntity("tools").get(), cgmToolsIn, keepInputs, expunged);
ok &= this->cgmEntities(*this->findModelEntity("tools").get(), cgmToolsIn, keepInputs, expunged);
if (!ok)
{
smtkInfoMacro(log(), "Need at least 1 tool; none of the specified entities were valid.");
......
......@@ -61,7 +61,7 @@ smtk::model::OperatorResult BooleanUnion::operateInternal()
Body* cgmBody;
EntityRefArray expunged;
bool ok = true;
ok |= this->cgmEntities(*this->specification()->associations().get(), cgmBodiesIn, keepInputs, expunged);
ok &= this->cgmEntities(*this->specification()->associations().get(), cgmBodiesIn, keepInputs, expunged);
if (cgmBodiesIn.size() < 2)
{
......
......@@ -60,9 +60,9 @@ smtk::model::OperatorResult Sweep::operateInternal()
DLIList<RefEntity*> cgmThingsToSweep;
DLIList<RefEdge*> cgmSweepPath;
bool ok = true;
ok |= this->cgmEntities(*this->specification()->associations().get(), cgmThingsToSweep, keepInputs, expunged);
ok &= this->cgmEntities(*this->specification()->associations().get(), cgmThingsToSweep, keepInputs, expunged);
if (sweepOp == 2) // sweep along curve
ok |= this->cgmEntities(*this->findModelEntity("sweep path").get(), cgmSweepPath, keepInputs, expunged);
ok &= this->cgmEntities(*this->findModelEntity("sweep path").get(), cgmSweepPath, keepInputs, expunged);
if (!ok)
return this->createResult(smtk::model::OPERATION_FAILED);
......
......@@ -10,6 +10,7 @@ set(smtkCGMSessionPythonDataTests
cgmLoadFile
)
message("PYTHONPATH=${SHIBOKEN_SMTK_PYTHON};${LIB_ENV_VAR}")
foreach (test ${smtkCGMSessionPythonTests})
add_test(${test}Py ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test}.py)
set_tests_properties(${test}Py
......
......@@ -17,6 +17,8 @@ from smtk.simple import *
mgr = smtk.model.Manager.create()
sess = mgr.createSession('cgm')
brg = sess.session()
print sess
print brg
sess.assignDefaultName()
SetActiveSession(sess)
print '\n\n%s: type "%s" %s %s' % \
......
......@@ -98,7 +98,7 @@ EntityRef EntityIterator::operator ++ ()
* This advances the iterator but returns the item that
* was current before advancing the iterator.
*/
EntityRef EntityIterator::operator ++ (int i)
EntityRef EntityIterator::operator ++ (int)
{
if (this->isAtEnd())
return EntityRef();
......
......@@ -28,8 +28,8 @@ enum IteratorStyle
class SMTKCORE_EXPORT EntityIterator
{
public:
template<typename C> void traverse(C begin, C end);
template<typename C> void traverse(C begin, C end, IteratorStyle style);
template<typename C> void traverse(C ebegin, C eend);
template<typename C> void traverse(C ebegin, C eend, IteratorStyle style);
void traverse(const EntityRef& x);
void traverse(const EntityRef& x, IteratorStyle style);
......@@ -56,22 +56,22 @@ protected:
/**\brief Iterate over the given entities and **only** those entities.
*/
template<typename C>
void EntityIterator::traverse(C begin, C end)
void EntityIterator::traverse(C ebegin, C eend)
{
this->traverse(begin, end, ITERATE_BARE);
this->traverse(ebegin, eend, ITERATE_BARE);
}
/**\brief Iterate over the given entities and the specified \a related records.
*/
template<typename C>
void EntityIterator::traverse(C begin, C end, IteratorStyle related)
void EntityIterator::traverse(C ebegin, C eend, IteratorStyle related)
{
this->m_related = related;
this->m_visited.clear();
if (this->m_related == ITERATE_MODELS)
{
Model parent;
for (C rit = begin; rit != end; ++rit)
for (C rit = ebegin; rit != eend; ++rit)
{
if ((parent = rit->owningModel()).isValid())
{
......@@ -96,7 +96,7 @@ void EntityIterator::traverse(C begin, C end, IteratorStyle related)
}
else
{
this->m_visited.insert(begin, end);
this->m_visited.insert(ebegin, eend);
}
}
......
......@@ -1357,18 +1357,18 @@ void Manager::assignDefaultNamesToModelChildren(const smtk::common::UUID& modelI
if (model.isValid())
{
oops = false;
EntityIterator it;
it.traverse(model, ITERATE_MODELS);
EntityIterator eit;
eit.traverse(model, ITERATE_MODELS);
model.assignDefaultName();
std::string modelName = model.name();
UUIDs dummy;
for (it.begin(); !it.isAtEnd(); ++it)
for (eit.begin(); !eit.isAtEnd(); ++eit)
{
if (it->isSessionRef())
(*it).assignDefaultName();
if (eit->isSessionRef())
(*eit).assignDefaultName();
else
this->assignDefaultNamesWithOwner(
this->m_topology->find(it->entity()),
this->m_topology->find(eit->entity()),
model.entity(),
modelName, dummy, true);
}
......
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