update logging to be used with boost1.54 and make it a compile option
This commit is contained in:
parent
c1d799e831
commit
9fdeef50fe
|
@ -24,6 +24,8 @@ include_directories(
|
|||
set(Assembly_LIBS
|
||||
${ODE_LIBRARIES}
|
||||
${OCC_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${Boost_LOG_LIBRARY_RELEASE}
|
||||
Part
|
||||
FreeCADApp
|
||||
)
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
#include "logging.hpp"
|
||||
#include "transformation.hpp"
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
#include <boost/math/special_functions.hpp>
|
||||
#endif
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
|
|
|
@ -22,24 +22,23 @@
|
|||
|
||||
#ifdef USE_LOGGING
|
||||
|
||||
#define BOOST_LOG_DYN_LINK
|
||||
|
||||
#include <boost/log/core.hpp>
|
||||
#include <boost/log/sinks.hpp>
|
||||
#include <boost/log/expressions/formatters.hpp>
|
||||
#include <boost/log/sources/basic_logger.hpp>
|
||||
#include <boost/log/attributes.hpp>
|
||||
#include <boost/log/attributes/attribute_def.hpp>
|
||||
#include <boost/log/utility/init/to_file.hpp>
|
||||
#include <boost/log/utility/init/common_attributes.hpp>
|
||||
#include <boost/log/sources/logger.hpp>
|
||||
#include <boost/log/sources/record_ostream.hpp>
|
||||
#include <boost/log/formatters.hpp>
|
||||
#include <boost/log/filters.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
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<std::string>("Tag") <<"] "
|
||||
<< fmt::if_(flt::has_attr<std::string>("ID")) [
|
||||
fmt::stream << "["<< fmt::attr< std::string >("ID")<<"] "]
|
||||
<< fmt::message()
|
||||
expr::stream <<"[" << expr::attr<std::string>("Tag") <<"] "
|
||||
<< expr::if_(expr::has_attr<std::string>("ID")) [
|
||||
expr::stream << "["<< expr::attr< std::string >("ID")<<"] "]
|
||||
<< expr::smessage
|
||||
);
|
||||
|
||||
core->add_sink(sink);
|
||||
|
|
|
@ -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<typename Kernel, int Dim>
|
||||
std::ostream& operator<<(std::ostream& os, const dcm::detail::Transform<Kernel, Dim>& t) {
|
||||
template<typename charT, typename traits, typename Kernel, int Dim>
|
||||
std::basic_ostream<charT,traits>& operator<<(std::basic_ostream<charT,traits>& os, const dcm::detail::Transform<Kernel, Dim>& t) {
|
||||
os << "Rotation: " << t.rotation().coeffs().transpose() << std::endl
|
||||
<< "Translation: " << t.translation().vector().transpose() <<std::endl
|
||||
<< "Scale: " << t.scaling().factor();
|
||||
return os;
|
||||
}
|
||||
|
||||
template<typename Kernel, int Dim>
|
||||
std::ostream& operator<<(std::ostream& os, dcm::detail::DiffTransform<Kernel, Dim>& t) {
|
||||
template<typename charT, typename traits,typename Kernel, int Dim>
|
||||
std::basic_ostream<charT,traits>& operator<<(std::basic_ostream<charT,traits>& os, dcm::detail::DiffTransform<Kernel, Dim>& t) {
|
||||
os << "Rotation: " << t.rotation().coeffs().transpose() << std::endl
|
||||
<< "Translation: " << t.translation().vector().transpose() <<std::endl
|
||||
<< "Scale: " << t.scaling().factor() << std::endl
|
||||
|
@ -291,5 +288,10 @@ std::ostream& operator<<(std::ostream& os, dcm::detail::DiffTransform<Kernel, Di
|
|||
return os;
|
||||
}
|
||||
|
||||
}//detail
|
||||
}//DCM
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //DCM_TRANSFORMATION
|
||||
|
|
|
@ -236,7 +236,7 @@ struct Distance::type< Kernel, tag::point3D, tag::plane3D > {
|
|||
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;
|
||||
|
|
|
@ -140,6 +140,10 @@ struct Module3D {
|
|||
typedef typename mpl::push_front<Typelist, boost::blank>::type ExtTypeList;
|
||||
typedef typename boost::make_variant_over< ExtTypeList >::type Variant;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
#endif
|
||||
|
||||
struct cloner : boost::static_visitor<void> {
|
||||
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<typename T>
|
||||
Geom createGeometry3D(T geom, Identifier id);
|
||||
Geom createGeometry3D(Identifier id);
|
||||
|
|
|
@ -52,6 +52,10 @@ struct MES : public Sys::Kernel::MappedEquationSystem {
|
|||
typedef typename Sys::Kernel::MappedEquationSystem Base;
|
||||
|
||||
boost::shared_ptr<Cluster> m_cluster;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
#endif
|
||||
|
||||
MES(boost::shared_ptr<Cluster> cl, int par, int eqn);
|
||||
virtual void recalculate();
|
||||
|
@ -126,7 +130,9 @@ struct SystemSolver : public Job<Sys> {
|
|||
|
||||
template<typename Sys>
|
||||
MES<Sys>::MES(boost::shared_ptr<Cluster> 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<typename Sys>
|
||||
|
@ -160,6 +166,9 @@ void MES<Sys>::recalculate() {
|
|||
template<typename Sys>
|
||||
void MES<Sys>::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<Constraint3D> oiter;
|
||||
typedef typename boost::graph_traits<Cluster>::edge_iterator eiter;
|
||||
|
@ -414,7 +423,7 @@ void SystemSolver<Sys>::solveCluster(boost::shared_ptr<Cluster> 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<Sys>::solveCluster(boost::shared_ptr<Cluster> 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();
|
||||
|
|
|
@ -265,6 +265,10 @@ struct ModuleShape3D {
|
|||
void recalc(boost::shared_ptr<Geometry3D> g);
|
||||
protected:
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
#endif
|
||||
|
||||
typedef details::Geometry<typename Sys::Kernel, 3, typename Sys::geometries> Base;
|
||||
typedef Object<Sys, Derived, ShapeSig > ObjBase;
|
||||
typedef typename mpl::push_front<TypeList, boost::blank>::type ExtTypeList;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user