diff --git a/src/Mod/Assembly/App/Constraint.cpp b/src/Mod/Assembly/App/Constraint.cpp index fa5fc368d..ad8f3cb86 100644 --- a/src/Mod/Assembly/App/Constraint.cpp +++ b/src/Mod/Assembly/App/Constraint.cpp @@ -165,8 +165,16 @@ void Constraint::init(Assembly::ItemAssembly* ass) }; //all other constraints need poth parts - if(!part1 || !part2) + if(!part1 || !part2) { + Base::Console().Message("Geometry initialisation error: invalid parts\n"); return; + }; + + //and both geometries + if(!m_first_geom || !m_second_geom) { + Base::Console().Message("Geometry initialisation error: invalid geometries\n"); + return; + }; //we may need the orientation dcm::Direction dir; diff --git a/src/Mod/Assembly/App/ItemAssembly.cpp b/src/Mod/Assembly/App/ItemAssembly.cpp index d342aa55f..a0f1306aa 100644 --- a/src/Mod/Assembly/App/ItemAssembly.cpp +++ b/src/Mod/Assembly/App/ItemAssembly.cpp @@ -49,6 +49,10 @@ ItemAssembly::ItemAssembly() { ADD_PROPERTY(Items,(0)); ADD_PROPERTY(Annotations,(0)); ADD_PROPERTY(Rigid,(true)); +#ifdef ASSEMBLY_DEBUG_FACILITIES + ADD_PROPERTY(ApplyAtFailure,(false)); + ADD_PROPERTY(Precision,(1e-6)); +#endif } short ItemAssembly::mustExecute() const { @@ -66,6 +70,15 @@ App::DocumentObjectExecReturn* ItemAssembly::execute(void) { m_downstream_placement = Base::Placement(Base::Vector3(0,0,0), Base::Rotation()); Base::Placement dummy; initSolver(boost::shared_ptr(), dummy, false); + +#ifdef ASSEMBLY_DEBUG_FACILITIES + if(ApplyAtFailure.getValue()) + m_solver->setOption(dcm::ApplyResults); + else + m_solver->setOption(dcm::IgnoreResults); + + m_solver->setOption(Precision.getValue()); +#endif initConstraints(boost::shared_ptr()); //solve the system @@ -213,9 +226,12 @@ void ItemAssembly::initSolver(boost::shared_ptr parent, Base::Placement& if(parent) { if(Rigid.getValue() || stopped) { - m_solver = boost::shared_ptr(parent->createSubsystem()); + m_solver = parent->createSubsystem(); m_solver->setTransformation(this->Placement.getValue()); stopped = true; //all below belongs to this rigid group + + //connect the recalculated signal in case we need to update the placement + m_solver->connectSignal(boost::bind(&ItemAssembly::finish, this, _1)); } else { m_solver = parent; @@ -223,14 +239,9 @@ void ItemAssembly::initSolver(boost::shared_ptr parent, Base::Placement& m_downstream_placement = PL_downstream; } } - - //connect the recalculated signal in case we need to update the placement - m_solver->connectSignal(boost::bind(&ItemAssembly::finish, this, _1)); typedef std::vector::const_iterator iter; - const std::vector& vector = Items.getValues(); - for(iter it=vector.begin(); it != vector.end(); it++) { if((*it)->getTypeId() == Assembly::ItemAssembly::getClassTypeId()) { diff --git a/src/Mod/Assembly/App/ItemAssembly.h b/src/Mod/Assembly/App/ItemAssembly.h index 058d09f74..653a264ff 100644 --- a/src/Mod/Assembly/App/ItemAssembly.h +++ b/src/Mod/Assembly/App/ItemAssembly.h @@ -78,6 +78,12 @@ public: boost::shared_ptr m_solver; Base::Placement m_downstream_placement; + +#ifdef ASSEMBLY_DEBUG_FACILITIES + App::PropertyBool ApplyAtFailure; + App::PropertyFloat Precision; +#endif + private: std::stringstream message; }; diff --git a/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp b/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp index 3a224534d..ccbb10a32 100644 --- a/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp +++ b/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp @@ -26,5 +26,3 @@ int ItemAssemblyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) { return 0; } - - diff --git a/src/Mod/Assembly/App/opendcm/core/constraint.hpp b/src/Mod/Assembly/App/opendcm/core/constraint.hpp index a1e5bd9fe..7fcc1b9d5 100644 --- a/src/Mod/Assembly/App/opendcm/core/constraint.hpp +++ b/src/Mod/Assembly/App/opendcm/core/constraint.hpp @@ -111,7 +111,7 @@ protected: int equationCount(); - void calculate(Scalar scale, bool rotation_only = false); + void calculate(Scalar scale, AccessType access = general); void treatLGZ(); void setMaps(MES& mes); void collectPseudoPoints(Vec& vec1, Vec& vec2); @@ -128,7 +128,8 @@ protected: typename Kernel::VectorMap m_diff_second, m_diff_second_rot; //second geometry diff typename Kernel::VectorMap m_residual; - bool pure_rotation, enabled; + bool enabled; + AccessType access; typedef Equation eq_type; }; @@ -136,7 +137,7 @@ protected: struct placeholder { virtual ~placeholder() {} virtual placeholder* resetConstraint(geom_ptr first, geom_ptr second) const = 0; - virtual void calculate(geom_ptr first, geom_ptr second, Scalar scale, bool rotation_only = false) = 0; + virtual void calculate(geom_ptr first, geom_ptr second, Scalar scale, AccessType access = general) = 0; virtual void treatLGZ(geom_ptr first, geom_ptr second) = 0; virtual int equationCount() = 0; virtual void setMaps(MES& mes, geom_ptr first, geom_ptr second) = 0; @@ -199,9 +200,9 @@ public: geom_ptr first, second; Scalar scale; - bool rot_only; + AccessType access; - Calculater(geom_ptr f, geom_ptr s, Scalar sc, bool rotation_only = false); + Calculater(geom_ptr f, geom_ptr s, Scalar sc, AccessType a = general); template< typename T > void operator()(T& val) const; @@ -285,7 +286,7 @@ public: holder(Objects& obj); - virtual void calculate(geom_ptr first, geom_ptr second, Scalar scale, bool rotation_only = false); + virtual void calculate(geom_ptr first, geom_ptr second, Scalar scale, AccessType a = general); virtual void treatLGZ(geom_ptr first, geom_ptr second); virtual placeholder* resetConstraint(geom_ptr first, geom_ptr second) const; virtual void setMaps(MES& mes, geom_ptr first, geom_ptr second); diff --git a/src/Mod/Assembly/App/opendcm/core/equations.hpp b/src/Mod/Assembly/App/opendcm/core/equations.hpp index 0b1004937..28b56ac9c 100644 --- a/src/Mod/Assembly/App/opendcm/core/equations.hpp +++ b/src/Mod/Assembly/App/opendcm/core/equations.hpp @@ -147,7 +147,7 @@ struct pushed_seq { typedef constraint_sequence type; };*/ -template +template struct Equation : public EQ { typedef typename mpl::if_, Option, mpl::vector