diff --git a/src/Mod/Assembly/App/CMakeLists.txt b/src/Mod/Assembly/App/CMakeLists.txt index c96dbc9fa..bcbd962e4 100644 --- a/src/Mod/Assembly/App/CMakeLists.txt +++ b/src/Mod/Assembly/App/CMakeLists.txt @@ -24,6 +24,8 @@ include_directories( set(Assembly_LIBS ${ODE_LIBRARIES} ${OCC_LIBRARIES} + ${Boost_LIBRARIES} + ${Boost_LOG_LIBRARY_RELEASE} Part FreeCADApp ) diff --git a/src/Mod/Assembly/App/opendcm/core/geometry.hpp b/src/Mod/Assembly/App/opendcm/core/geometry.hpp index d85852bcd..eff183ec2 100644 --- a/src/Mod/Assembly/App/opendcm/core/geometry.hpp +++ b/src/Mod/Assembly/App/opendcm/core/geometry.hpp @@ -49,6 +49,10 @@ #include "logging.hpp" #include "transformation.hpp" +#ifdef USE_LOGGING +#include +#endif + namespace mpl = boost::mpl; namespace fusion = boost::fusion; diff --git a/src/Mod/Assembly/App/opendcm/core/logging.hpp b/src/Mod/Assembly/App/opendcm/core/logging.hpp index fd915a36f..bef24ef9b 100644 --- a/src/Mod/Assembly/App/opendcm/core/logging.hpp +++ b/src/Mod/Assembly/App/opendcm/core/logging.hpp @@ -22,24 +22,23 @@ #ifdef USE_LOGGING +#define BOOST_LOG_DYN_LINK + #include #include +#include +#include #include -#include -#include -#include #include #include -#include -#include +#include #include namespace logging = boost::log; namespace sinks = boost::log::sinks; namespace src = boost::log::sources; -namespace fmt = boost::log::formatters; -namespace flt = boost::log::filters; +namespace expr = boost::log::expressions; namespace attrs = boost::log::attributes; namespace keywords = boost::log::keywords; @@ -68,10 +67,10 @@ inline boost::shared_ptr< sink_t > init_log() { boost::shared_ptr< sink_t > sink(new sink_t(backend)); sink->set_formatter( - fmt::stream <<"[" << fmt::attr("Tag") <<"] " - << fmt::if_(flt::has_attr("ID")) [ - fmt::stream << "["<< fmt::attr< std::string >("ID")<<"] "] - << fmt::message() + expr::stream <<"[" << expr::attr("Tag") <<"] " + << expr::if_(expr::has_attr("ID")) [ + expr::stream << "["<< expr::attr< std::string >("ID")<<"] "] + << expr::smessage ); core->add_sink(sink); diff --git a/src/Mod/Assembly/App/opendcm/core/transformation.hpp b/src/Mod/Assembly/App/opendcm/core/transformation.hpp index 91b7057af..26f17ded7 100644 --- a/src/Mod/Assembly/App/opendcm/core/transformation.hpp +++ b/src/Mod/Assembly/App/opendcm/core/transformation.hpp @@ -267,23 +267,20 @@ public: }; }; -}//detail -}//DCM - /*When you overload a binary operator as a member function of a class the overload is used * when the first operand is of the class type.For stream operators, the first operand * is the stream and not (usually) the custom class. */ -template -std::ostream& operator<<(std::ostream& os, const dcm::detail::Transform& t) { +template +std::basic_ostream& operator<<(std::basic_ostream& os, const dcm::detail::Transform& t) { os << "Rotation: " << t.rotation().coeffs().transpose() << std::endl << "Translation: " << t.translation().vector().transpose() < -std::ostream& operator<<(std::ostream& os, dcm::detail::DiffTransform& t) { +template +std::basic_ostream& operator<<(std::basic_ostream& os, dcm::detail::DiffTransform& t) { os << "Rotation: " << t.rotation().coeffs().transpose() << std::endl << "Translation: " << t.translation().vector().transpose() < { if(sspace == negative_directional) return result + sc_value; #ifdef USE_LOGGING - if(!boost::math::isfinite(res)) + if(!boost::math::isfinite(result)) BOOST_LOG(log) << "Unnormal residual detected: " << result; #endif return result; diff --git a/src/Mod/Assembly/App/opendcm/module3d/module.hpp b/src/Mod/Assembly/App/opendcm/module3d/module.hpp index bdd1e7cd5..ba1642902 100644 --- a/src/Mod/Assembly/App/opendcm/module3d/module.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d/module.hpp @@ -140,6 +140,10 @@ struct Module3D { typedef typename mpl::push_front::type ExtTypeList; typedef typename boost::make_variant_over< ExtTypeList >::type Variant; +#ifdef USE_LOGGING + src::logger log; +#endif + struct cloner : boost::static_visitor { typedef typename boost::make_variant_over< ExtTypeList >::type Variant; @@ -314,9 +318,9 @@ struct Module3D { using inheriter_base::m_this; public: - using inheriter_base::createGeometry3D; - using inheriter_base::createConstraint3D; - + using inheriter_base::createGeometry3D; + using inheriter_base::createConstraint3D; + template Geom createGeometry3D(T geom, Identifier id); Geom createGeometry3D(Identifier id); diff --git a/src/Mod/Assembly/App/opendcm/module3d/solver.hpp b/src/Mod/Assembly/App/opendcm/module3d/solver.hpp index 9a231abb8..1fc399fc6 100644 --- a/src/Mod/Assembly/App/opendcm/module3d/solver.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d/solver.hpp @@ -52,6 +52,10 @@ struct MES : public Sys::Kernel::MappedEquationSystem { typedef typename Sys::Kernel::MappedEquationSystem Base; boost::shared_ptr m_cluster; + +#ifdef USE_LOGGING + src::logger log; +#endif MES(boost::shared_ptr cl, int par, int eqn); virtual void recalculate(); @@ -126,7 +130,9 @@ struct SystemSolver : public Job { template MES::MES(boost::shared_ptr cl, int par, int eqn) : Base(par, eqn), m_cluster(cl) { - +#ifdef USE_LOGGING + log.add_attribute("Tag", attrs::constant< std::string >("MES3D")); +#endif }; template @@ -160,6 +166,9 @@ void MES::recalculate() { template void MES::removeLocalGradientZeros() { +#ifdef USE_LOGGING + BOOST_LOG(log) << "remove local gradient zero"; +#endif //let the constraints treat the local zeros typedef typename Cluster::template object_iterator oiter; typedef typename boost::graph_traits::edge_iterator eiter; @@ -414,7 +423,7 @@ void SystemSolver::solveCluster(boost::shared_ptr cluster, Sys& sy bool done = false; if(!has_cycle) { #ifdef USE_LOGGING - BOOST_LOG(log)<< "non-cyclic system dedected" + BOOST_LOG(log)<< "non-cyclic system dedected"; #endif //cool, lets do uncylic. first all rotational constraints with rotational parameters mes.setAccess(rotation); @@ -447,7 +456,7 @@ void SystemSolver::solveCluster(boost::shared_ptr cluster, Sys& sy //not done already? try it the hard way! if(!done) { #ifdef USE_LOGGING - BOOST_LOG(log)<< "Full scale solver used" + BOOST_LOG(log)<< "Full scale solver used"; #endif Rescaler re(cluster, mes); re(); diff --git a/src/Mod/Assembly/App/opendcm/moduleShape3d/module.hpp b/src/Mod/Assembly/App/opendcm/moduleShape3d/module.hpp index dc157c81d..4517144e1 100644 --- a/src/Mod/Assembly/App/opendcm/moduleShape3d/module.hpp +++ b/src/Mod/Assembly/App/opendcm/moduleShape3d/module.hpp @@ -265,6 +265,10 @@ struct ModuleShape3D { void recalc(boost::shared_ptr g); protected: +#ifdef USE_LOGGING + src::logger log; +#endif + typedef details::Geometry Base; typedef Object ObjBase; typedef typename mpl::push_front::type ExtTypeList; diff --git a/src/Mod/Assembly/CMakeLists.txt b/src/Mod/Assembly/CMakeLists.txt index ff46393cc..0f3d8eecf 100644 --- a/src/Mod/Assembly/CMakeLists.txt +++ b/src/Mod/Assembly/CMakeLists.txt @@ -1,4 +1,11 @@ +option(FREECAD_ASSEMBLY_SOLVER_LOGS "Generate extensive logs of the assembly solving process" OFF) + +if(FREECAD_ASSEMBLY_SOLVER_LOGS) + find_package(Boost COMPONENTS log REQUIRED) + add_definitions(-DUSE_LOGGING) +endif(FREECAD_ASSEMBLY_SOLVER_LOGS) + add_subdirectory(App) if(BUILD_GUI) add_subdirectory(Gui)