multiple debug updates
This commit is contained in:
parent
cdd83966b1
commit
9bd19328ca
|
@ -53,6 +53,16 @@ ItemAssembly::ItemAssembly() {
|
|||
ADD_PROPERTY(ApplyAtFailure,(false));
|
||||
ADD_PROPERTY(Precision,(1e-6));
|
||||
ADD_PROPERTY(SaveState,(false));
|
||||
ADD_PROPERTY(Iterations,(5e3));
|
||||
ADD_PROPERTY(LogLevel, (long(1)));
|
||||
|
||||
std::vector<std::string> vec;
|
||||
vec.push_back("iteration");
|
||||
vec.push_back("solving");
|
||||
vec.push_back("manipulation");
|
||||
vec.push_back("information");
|
||||
vec.push_back("error");
|
||||
LogLevel.setEnumVector(vec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -71,6 +81,7 @@ App::DocumentObjectExecReturn* ItemAssembly::execute(void) {
|
|||
m_downstream_placement = Base::Placement(Base::Vector3<double>(0,0,0), Base::Rotation());
|
||||
Base::Placement dummy;
|
||||
initSolver(boost::shared_ptr<Solver>(), dummy, false);
|
||||
initConstraints(boost::shared_ptr<Solver>());
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
|
||||
|
@ -80,6 +91,7 @@ App::DocumentObjectExecReturn* ItemAssembly::execute(void) {
|
|||
m_solver->setOption<dcm::solverfailure>(dcm::IgnoreResults);
|
||||
|
||||
m_solver->setOption<dcm::precision>(Precision.getValue());
|
||||
m_solver->setOption<dcm::iterations>(Iterations.getValue());
|
||||
|
||||
if(SaveState.getValue()) {
|
||||
|
||||
|
@ -88,8 +100,10 @@ App::DocumentObjectExecReturn* ItemAssembly::execute(void) {
|
|||
m_solver->saveState(myfile);
|
||||
myfile.close();
|
||||
};
|
||||
|
||||
m_solver->setLoggingFilter(dcm::severity >= (dcm::severity_level)LogLevel.getValue());
|
||||
|
||||
#endif
|
||||
initConstraints(boost::shared_ptr<Solver>());
|
||||
|
||||
//solve the system
|
||||
m_solver->solve();
|
||||
|
@ -109,6 +123,12 @@ App::DocumentObjectExecReturn* ItemAssembly::execute(void) {
|
|||
//throw Base::Exception(message.str().c_str());
|
||||
Base::Console().Error(message.str().c_str());
|
||||
}
|
||||
catch(Standard_ConstructionError& e) {
|
||||
message.clear();
|
||||
message << "Construction Error raised in assembly solver during execution: ";
|
||||
message << e.GetMessageString()<< std::endl;
|
||||
Base::Console().Error(message.str().c_str());
|
||||
}
|
||||
catch
|
||||
(...) {
|
||||
message.clear();
|
||||
|
@ -321,3 +341,6 @@ void ItemAssembly::finish(boost::shared_ptr<Solver> subsystem) {
|
|||
};
|
||||
|
||||
} //assembly
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -88,6 +88,8 @@ public:
|
|||
App::PropertyBool ApplyAtFailure;
|
||||
App::PropertyFloat Precision;
|
||||
App::PropertyBool SaveState;
|
||||
App::PropertyInteger Iterations;
|
||||
App::PropertyEnumeration LogLevel;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,14 +30,15 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#include "opendcm/core.hpp"
|
||||
#include "opendcm/module3d.hpp"
|
||||
#include "opendcm/modulepart.hpp"
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
#include "opendcm/modulestate.hpp"
|
||||
#endif
|
||||
#include "opendcm/module3d.hpp"
|
||||
#include "opendcm/modulepart.hpp"
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
|
@ -49,182 +50,240 @@ struct gp_pnt_accessor {
|
|||
template<typename Scalar, int ID, typename T>
|
||||
Scalar get(T& t) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
return t.X();
|
||||
case 1:
|
||||
return t.Y();
|
||||
case 2:
|
||||
return t.Z();
|
||||
default:
|
||||
return 0;
|
||||
case 0:
|
||||
return t.X();
|
||||
|
||||
case 1:
|
||||
return t.Y();
|
||||
|
||||
case 2:
|
||||
return t.Z();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
template<typename Scalar, int ID, typename T>
|
||||
void set(Scalar value, T& t) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
t.SetX(value);
|
||||
break;
|
||||
case 1:
|
||||
t.SetY(value);
|
||||
break;
|
||||
case 2:
|
||||
t.SetZ(value);
|
||||
break;
|
||||
case 0:
|
||||
t.SetX(value);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
t.SetY(value);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
t.SetZ(value);
|
||||
break;
|
||||
};
|
||||
};
|
||||
template<typename T>
|
||||
void finalize(T& t) {};
|
||||
};
|
||||
|
||||
struct gp_lin_accessor {
|
||||
|
||||
gp_Pnt pnt;
|
||||
double dx,dy,dz;
|
||||
|
||||
template<typename Scalar, int ID, typename T>
|
||||
Scalar get(T& t) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
return t.Location().X();
|
||||
case 1:
|
||||
return t.Location().Y();
|
||||
case 2:
|
||||
return t.Location().Z();
|
||||
case 3:
|
||||
return t.Direction().X();
|
||||
case 4:
|
||||
return t.Direction().Y();
|
||||
case 5:
|
||||
return t.Direction().Z();
|
||||
default:
|
||||
return 0;
|
||||
case 0:
|
||||
return t.Location().X();
|
||||
|
||||
case 1:
|
||||
return t.Location().Y();
|
||||
|
||||
case 2:
|
||||
return t.Location().Z();
|
||||
|
||||
case 3:
|
||||
return t.Direction().X();
|
||||
|
||||
case 4:
|
||||
return t.Direction().Y();
|
||||
|
||||
case 5:
|
||||
return t.Direction().Z();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
template<typename Scalar, int ID, typename T>
|
||||
void set(Scalar value, T& t) {
|
||||
gp_Pnt p = t.Location();
|
||||
gp_Dir d = t.Direction();
|
||||
|
||||
switch(ID) {
|
||||
case 0:
|
||||
p.SetX(value);
|
||||
break;
|
||||
case 1:
|
||||
p.SetY(value);
|
||||
break;
|
||||
case 2:
|
||||
p.SetZ(value);
|
||||
break;
|
||||
case 3:
|
||||
d.SetX(value);
|
||||
break;
|
||||
case 4:
|
||||
d.SetY(value);
|
||||
break;
|
||||
case 5:
|
||||
d.SetZ(value);
|
||||
break;
|
||||
case 0:
|
||||
pnt.SetX(value);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pnt.SetY(value);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
pnt.SetZ(value);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
dx=(value);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
dy=(value);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
dz=(value);
|
||||
break;
|
||||
};
|
||||
t.SetLocation(p);
|
||||
t.SetDirection(d);
|
||||
};
|
||||
template<typename T>
|
||||
void finalize(T& t) {
|
||||
t.SetLocation(pnt);
|
||||
t.SetDirection(gp_Dir(dx,dy,dz));
|
||||
};
|
||||
};
|
||||
|
||||
struct gp_pln_accessor {
|
||||
|
||||
gp_Pnt pnt;
|
||||
double dx,dy,dz;
|
||||
|
||||
template<typename Scalar, int ID, typename T>
|
||||
Scalar get(T& t) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
return t.Axis().Location().X();
|
||||
case 1:
|
||||
return t.Axis().Location().Y();
|
||||
case 2:
|
||||
return t.Axis().Location().Z();
|
||||
case 3:
|
||||
return t.Axis().Direction().X();
|
||||
case 4:
|
||||
return t.Axis().Direction().Y();
|
||||
case 5:
|
||||
return t.Axis().Direction().Z();
|
||||
default:
|
||||
return 0;
|
||||
case 0:
|
||||
return t.Axis().Location().X();
|
||||
|
||||
case 1:
|
||||
return t.Axis().Location().Y();
|
||||
|
||||
case 2:
|
||||
return t.Axis().Location().Z();
|
||||
|
||||
case 3:
|
||||
return t.Axis().Direction().X();
|
||||
|
||||
case 4:
|
||||
return t.Axis().Direction().Y();
|
||||
|
||||
case 5:
|
||||
return t.Axis().Direction().Z();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
template<typename Scalar, int ID, typename T>
|
||||
void set(Scalar value, T& t) {
|
||||
gp_Pnt p = t.Axis().Location();
|
||||
gp_Dir d = t.Axis().Direction();
|
||||
switch(ID) {
|
||||
case 0:
|
||||
p.SetX(value);
|
||||
break;
|
||||
case 1:
|
||||
p.SetY(value);
|
||||
break;
|
||||
case 2:
|
||||
p.SetZ(value);
|
||||
break;
|
||||
case 3:
|
||||
d.SetX(value);
|
||||
break;
|
||||
case 4:
|
||||
d.SetY(value);
|
||||
break;
|
||||
case 5:
|
||||
d.SetZ(value);
|
||||
break;
|
||||
case 0:
|
||||
pnt.SetX(value);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pnt.SetY(value);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
pnt.SetZ(value);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
dx=value;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
dy=value;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
dz=value;
|
||||
break;
|
||||
};
|
||||
t.SetAxis(gp_Ax1(p,d));
|
||||
};
|
||||
template<typename T>
|
||||
void finalize(T& t) {
|
||||
t.SetAxis(gp_Ax1(pnt,gp_Dir(dx,dy,dz)));
|
||||
};
|
||||
};
|
||||
|
||||
struct gp_cylinder_accessor {
|
||||
|
||||
gp_Pnt pnt;
|
||||
double dx,dy,dz;
|
||||
|
||||
template<typename Scalar, int ID, typename T>
|
||||
Scalar get(T& t) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
return t.Axis().Location().X();
|
||||
case 1:
|
||||
return t.Axis().Location().Y();
|
||||
case 2:
|
||||
return t.Axis().Location().Z();
|
||||
case 3:
|
||||
return t.Axis().Direction().X();
|
||||
case 4:
|
||||
return t.Axis().Direction().Y();
|
||||
case 5:
|
||||
return t.Axis().Direction().Z();
|
||||
case 6:
|
||||
return t.Radius();
|
||||
default:
|
||||
return 0;
|
||||
case 0:
|
||||
return t.Axis().Location().X();
|
||||
|
||||
case 1:
|
||||
return t.Axis().Location().Y();
|
||||
|
||||
case 2:
|
||||
return t.Axis().Location().Z();
|
||||
|
||||
case 3:
|
||||
return t.Axis().Direction().X();
|
||||
|
||||
case 4:
|
||||
return t.Axis().Direction().Y();
|
||||
|
||||
case 5:
|
||||
return t.Axis().Direction().Z();
|
||||
|
||||
case 6:
|
||||
return t.Radius();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
template<typename Scalar, int ID, typename T>
|
||||
void set(Scalar value, T& t) {
|
||||
gp_Pnt p = t.Axis().Location();
|
||||
gp_Dir d = t.Axis().Direction();
|
||||
|
||||
switch(ID) {
|
||||
case 0:
|
||||
p.SetX(value);
|
||||
break;
|
||||
case 1:
|
||||
p.SetY(value);
|
||||
break;
|
||||
case 2:
|
||||
p.SetZ(value);
|
||||
break;
|
||||
case 3:
|
||||
d.SetX(value);
|
||||
break;
|
||||
case 4:
|
||||
d.SetY(value);
|
||||
break;
|
||||
case 5:
|
||||
d.SetZ(value);
|
||||
break;
|
||||
case 6:
|
||||
t.SetRadius(value);
|
||||
break;
|
||||
case 0:
|
||||
pnt.SetX(value);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pnt.SetY(value);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
pnt.SetZ(value);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
dx=value;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
dy=value;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
dz=value;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
t.SetRadius(value);
|
||||
break;
|
||||
};
|
||||
t.SetAxis(gp_Ax1(p,d));
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void finalize(T& t) {
|
||||
t.SetAxis(gp_Ax1(pnt,gp_Dir(dx,dy,dz)));
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -236,49 +295,63 @@ struct placement_accessor {
|
|||
template<typename Scalar, int ID, typename T>
|
||||
Scalar get(T& t) {
|
||||
t.getRotation().getValue(q0,q1,q2,q3);
|
||||
|
||||
switch(ID) {
|
||||
case 0:
|
||||
return q3;
|
||||
case 1:
|
||||
return q0;
|
||||
case 2:
|
||||
return q1;
|
||||
case 3:
|
||||
return q2;
|
||||
case 4:
|
||||
return t.getPosition()[0];
|
||||
case 5:
|
||||
return t.getPosition()[1];
|
||||
case 6:
|
||||
return t.getPosition()[2];
|
||||
default:
|
||||
return 0;
|
||||
case 0:
|
||||
return q3;
|
||||
|
||||
case 1:
|
||||
return q0;
|
||||
|
||||
case 2:
|
||||
return q1;
|
||||
|
||||
case 3:
|
||||
return q2;
|
||||
|
||||
case 4:
|
||||
return t.getPosition()[0];
|
||||
|
||||
case 5:
|
||||
return t.getPosition()[1];
|
||||
|
||||
case 6:
|
||||
return t.getPosition()[2];
|
||||
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
template<typename Scalar, int ID, typename T>
|
||||
void set(Scalar value, T& t) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
q3 = value;
|
||||
break;
|
||||
case 1:
|
||||
q0 = value;
|
||||
break;
|
||||
case 2:
|
||||
q1 = value;
|
||||
break;
|
||||
case 3:
|
||||
q2 = value;
|
||||
break;
|
||||
case 4:
|
||||
vec[0] = value;
|
||||
break;
|
||||
case 5:
|
||||
vec[1] = value;
|
||||
break;
|
||||
case 6:
|
||||
vec[2] = value;
|
||||
break;
|
||||
case 0:
|
||||
q3 = value;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
q0 = value;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
q1 = value;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
q2 = value;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
vec[0] = value;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
vec[1] = value;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
vec[2] = value;
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -333,7 +406,7 @@ typedef dcm::ModulePart< mpl::vector1< Base::Placement >, std::string > ModulePa
|
|||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
typedef dcm::System<Kernel, Module3D, ModulePart, dcm::ModuleState> Solver;
|
||||
#elif
|
||||
#else
|
||||
typedef dcm::System<Kernel, Module3D, ModulePart> Solver;
|
||||
#endif
|
||||
|
||||
|
@ -342,4 +415,4 @@ typedef Module3D::type<Solver>::Geometry3D Geometry3D;
|
|||
typedef Module3D::type<Solver>::Constraint3D Constraint3D;
|
||||
|
||||
|
||||
#endif //SOLVER_H
|
||||
#endif //SOLVER_H
|
||||
|
|
|
@ -623,7 +623,8 @@ public:
|
|||
* Sometimes it is needed to add a vertex with given global identifier. As the global vertex can not
|
||||
* be changed after creation, this method can be used to specify the global vertex by which this
|
||||
* graph vertex can be identified. The given global vertex is not checked, you need to ensure that
|
||||
* it is a unique id. The ID generator is changed so that it creates only identifier bigger than v.
|
||||
* it is a unique id or the already existing vertex is returned.
|
||||
* The ID generator is changed so that it creates only identifier bigger than v.
|
||||
*
|
||||
* @return fusion::vector<LocalVertex, GlobalVertex> the local and global vertex descriptor
|
||||
**/
|
||||
|
|
|
@ -217,7 +217,7 @@ class Geometry {
|
|||
|
||||
#ifdef USE_LOGGING
|
||||
protected:
|
||||
src::logger log;
|
||||
dcm_logger log;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
@ -327,13 +327,7 @@ public:
|
|||
void recalculate(DiffTransform& trans);
|
||||
|
||||
typename Kernel::Vector3 getPoint() {
|
||||
if(m_isInCluster)
|
||||
return m_toplocal.template segment<Dim>(0);
|
||||
else if(m_init)
|
||||
return m_rotated.template segment<Dim>(0);
|
||||
else
|
||||
return m_global.template segment<Dim>(0);
|
||||
|
||||
};
|
||||
|
||||
//use m_value or parametermap as new value, dependend on the solving mode
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2012 Stefan Troeger <stefantroeger@gmx.net>
|
||||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2012 Stefan Troeger <stefantroeger@gmx.net>
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef DCM_CLUSTERGRAPH_IMP_HPP
|
||||
|
@ -134,7 +134,7 @@ struct obj_helper {
|
|||
|
||||
//used with vertex bundle type
|
||||
template<typename bundle>
|
||||
typename boost::enable_if < boost::is_same<bundle, typename boost::vertex_bundle_type<Graph>::type>, result_type >::type
|
||||
typename boost::enable_if < boost::is_same<bundle, typename boost::vertex_bundle_type<Graph>::type>, result_type >::type
|
||||
operator()(bundle& p) {
|
||||
|
||||
if(Type::value)
|
||||
|
@ -504,16 +504,22 @@ template< typename edge_prop, typename vertex_prop, typename cluster_prop, typen
|
|||
fusion::vector<LocalVertex, GlobalVertex>
|
||||
ClusterGraph<edge_prop, vertex_prop, cluster_prop, objects>::addVertex(GlobalVertex gv) {
|
||||
|
||||
vertex_bundle vp;
|
||||
fusion::at_c<0> (vp) = gv;
|
||||
LocalVertex v = boost::add_vertex(vp, *this);
|
||||
|
||||
//ensure that we never create this id, as it is used now
|
||||
if(gv > m_id->count())
|
||||
m_id->setCount(gv);
|
||||
|
||||
setChanged();
|
||||
return fusion::make_vector(v, gv);
|
||||
std::pair<LocalVertex, bool> res = getLocalVertex(gv);
|
||||
|
||||
if(!res.second) {
|
||||
vertex_bundle vp;
|
||||
fusion::at_c<0> (vp) = gv;
|
||||
LocalVertex v = boost::add_vertex(vp, *this);
|
||||
|
||||
//ensure that we never create this id, as it is used now
|
||||
if(gv > m_id->count())
|
||||
m_id->setCount(gv);
|
||||
|
||||
return fusion::make_vector(v, gv);
|
||||
};
|
||||
|
||||
return fusion::make_vector(res.first, gv);
|
||||
};
|
||||
|
||||
template< typename edge_prop, typename vertex_prop, typename cluster_prop, typename objects>
|
||||
|
|
|
@ -107,7 +107,7 @@ void Geometry<Kernel, Dim, TagList>::init() {
|
|||
m_init = false;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "Init: "<<m_global.transpose();
|
||||
BOOST_LOG_SEV(log, information) << "Init: "<<m_global.transpose();
|
||||
#endif
|
||||
|
||||
};
|
||||
|
@ -198,7 +198,7 @@ void Geometry<Kernel, Dim, TagList>::recalculate(DiffTransform& trans) {
|
|||
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isnormal(m_rotated.norm()) || !boost::math::isnormal(m_diffparam.norm())) {
|
||||
BOOST_LOG(log) << "Unnormal recalculated value detected: "<<m_rotated.transpose()<<std::endl
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal recalculated value detected: "<<m_rotated.transpose()<<std::endl
|
||||
<< "or unnormal recalculated diff detected: "<<std::endl<<m_diffparam<<std::endl
|
||||
<<" with Transform: "<<std::endl<<trans;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ void Geometry<Kernel, Dim, TagList>::finishCalculation() {
|
|||
//recalculate(1.); //remove scaling to get right global value
|
||||
m_global = m_rotated;
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "Finish cluster calculation";
|
||||
BOOST_LOG_SEV(log, information) << "Finish cluster calculation";
|
||||
#endif
|
||||
}
|
||||
//TODO:non cluster paramter scaling
|
||||
|
@ -221,7 +221,7 @@ void Geometry<Kernel, Dim, TagList>::finishCalculation() {
|
|||
m_global = m_parameter;
|
||||
normalize();
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "Finish calculation";
|
||||
BOOST_LOG_SEV(log, information) << "Finish calculation";
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -247,7 +247,7 @@ void Geometry<Kernel, Dim, TagList>::transform(const Transform& t, VectorType& v
|
|||
}
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "Transformed with cluster: "<<m_isInCluster
|
||||
BOOST_LOG_SEV(log, manipulation) << "Transformed with cluster: "<<m_isInCluster
|
||||
<< ", init: "<<m_init<<" into: "<< vec.transpose();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ Dogleg<Kernel>::Dogleg(Kernel* k) : m_kernel(k), tolg(1e-40), tolx(1e-20) {
|
|||
};
|
||||
|
||||
template<typename Kernel>
|
||||
Dogleg<Kernel>::Dogleg() : tolg(1e-40), tolx(1e-20) {
|
||||
Dogleg<Kernel>::Dogleg() : tolg(1e-6), tolx(1e-3) {
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
log.add_attribute("Tag", attrs::constant< std::string >("Dogleg"));
|
||||
|
@ -62,16 +62,17 @@ void Dogleg<Kernel>::calculateStep(const Eigen::MatrixBase<Derived>& g, const Ei
|
|||
const typename Kernel::Vector h_gn = jacobi.fullPivLu().solve(-residual);
|
||||
const double eigen_error = (jacobi*h_gn + residual).norm();
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(h_gn.norm())) {
|
||||
BOOST_LOG(log)<< "Unnormal gauss-newton detected: "<<h_gn.norm();
|
||||
|
||||
if(!boost::math::isfinite(h_gn.norm())) {
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal gauss-newton detected: "<<h_gn.norm();
|
||||
}
|
||||
|
||||
if(!boost::math::isfinite(h_sd.norm())) {
|
||||
BOOST_LOG(log)<< "Unnormal steepest descent detected: "<<h_sd.norm();
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal steepest descent detected: "<<h_sd.norm();
|
||||
}
|
||||
|
||||
if(!boost::math::isfinite(alpha)) {
|
||||
BOOST_LOG(log)<< "Unnormal alpha detected: "<<alpha;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal alpha detected: "<<alpha;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -86,7 +87,7 @@ void Dogleg<Kernel>::calculateStep(const Eigen::MatrixBase<Derived>& g, const Ei
|
|||
#ifdef USE_LOGGING
|
||||
|
||||
if(!boost::math::isfinite(h_dl.norm())) {
|
||||
BOOST_LOG(log)<< "Unnormal dogleg descent detected: "<<h_dl.norm();
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal dogleg descent detected: "<<h_dl.norm();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -113,15 +114,15 @@ void Dogleg<Kernel>::calculateStep(const Eigen::MatrixBase<Derived>& g, const Ei
|
|||
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(c)) {
|
||||
BOOST_LOG(log)<< "Unnormal dogleg c detected: "<<c;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal dogleg c detected: "<<c;
|
||||
}
|
||||
|
||||
if(!boost::math::isfinite(bas)) {
|
||||
BOOST_LOG(log)<< "Unnormal dogleg bas detected: "<<bas;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal dogleg bas detected: "<<bas;
|
||||
}
|
||||
|
||||
if(!boost::math::isfinite(beta)) {
|
||||
BOOST_LOG(log)<< "Unnormal dogleg beta detected: "<<beta;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal dogleg beta detected: "<<beta;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -149,15 +150,15 @@ int Dogleg<Kernel>::solve(typename Kernel::MappedEquationSystem& sys, Functor& r
|
|||
|
||||
sys.recalculate();
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "initial jacobi: "<<std::endl<<sys.Jacobi<<std::endl
|
||||
<< "residual: "<<sys.Residual.transpose()<<std::endl
|
||||
<< "maximal differential: "<<sys.Jacobi.template lpNorm<Eigen::Infinity>();
|
||||
BOOST_LOG_SEV(log, solving) << "initial jacobi: "<<std::endl<<sys.Jacobi<<std::endl
|
||||
<< "residual: "<<sys.Residual.transpose()<<std::endl
|
||||
<< "maximal differential: "<<sys.Jacobi.template lpNorm<Eigen::Infinity>();
|
||||
#endif
|
||||
sys.removeLocalGradientZeros();
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "LGZ jacobi: "<<std::endl<<sys.Jacobi<<std::endl
|
||||
<< "maximal differential: "<<sys.Jacobi.template lpNorm<Eigen::Infinity>();
|
||||
BOOST_LOG_SEV(log, solving) << "LGZ jacobi: "<<std::endl<<sys.Jacobi<<std::endl
|
||||
<< "maximal differential: "<<sys.Jacobi.template lpNorm<Eigen::Infinity>();
|
||||
#endif
|
||||
|
||||
err = sys.Residual.norm();
|
||||
|
@ -179,17 +180,18 @@ int Dogleg<Kernel>::solve(typename Kernel::MappedEquationSystem& sys, Functor& r
|
|||
unused=0;
|
||||
counter=0;
|
||||
|
||||
int maxIterNumber = 10000;//MaxIterations * xsize;
|
||||
int maxIterNumber = m_kernel->template getProperty<iterations>();
|
||||
number_type pr = m_kernel->template getProperty<precision>()*sys.Scaling;
|
||||
number_type diverging_lim = 1e6*err + 1e12;
|
||||
|
||||
do {
|
||||
|
||||
// check if finished
|
||||
if(fx_inf <= m_kernel->template getProperty<precision>()*sys.Scaling) // Success
|
||||
if(fx_inf <= pr) // Success
|
||||
stop = 1;
|
||||
else if(g_inf <= tolg)
|
||||
else if(g_inf <= tolg*pr)
|
||||
throw solving_error() << boost::errinfo_errno(2) << error_message("g infinity norm smaller below limit");
|
||||
else if(delta <= tolx)
|
||||
else if(delta <= tolx*pr)
|
||||
throw solving_error() << boost::errinfo_errno(3) << error_message("step size below limit");
|
||||
else if(iter >= maxIterNumber)
|
||||
throw solving_error() << boost::errinfo_errno(4) << error_message("maximal iterations reached");
|
||||
|
@ -210,11 +212,12 @@ int Dogleg<Kernel>::solve(typename Kernel::MappedEquationSystem& sys, Functor& r
|
|||
//get the update step
|
||||
calculateStep(g, sys.Jacobi, sys.Residual, h_dl, delta);
|
||||
|
||||
// #ifdef USE_LOGGING
|
||||
// BOOST_LOG(log)<< "Step in iter "<<iter<<std::endl
|
||||
// << "Step: "<<h_dl.transpose()<<std::endl
|
||||
// << "Jacobi: "<<sys.Jacobi<<std::endl;
|
||||
// #endif
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG_SEV(log, iteration) << "Step in iter "<<iter<<std::endl
|
||||
<< "Step: "<<h_dl.transpose()<<std::endl
|
||||
<< "Jacobi: "<<sys.Jacobi<<std::endl
|
||||
<< "Residual: "<<sys.Residual.transpose();
|
||||
#endif
|
||||
|
||||
// calculate the linear model
|
||||
dL = sys.Residual.norm() - (sys.Residual + sys.Jacobi*h_dl).norm();
|
||||
|
@ -226,11 +229,11 @@ int Dogleg<Kernel>::solve(typename Kernel::MappedEquationSystem& sys, Functor& r
|
|||
#ifdef USE_LOGGING
|
||||
|
||||
if(!boost::math::isfinite(sys.Residual.norm())) {
|
||||
BOOST_LOG(log)<< "Unnormal residual detected: "<<sys.Residual.norm();
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal residual detected: "<<sys.Residual.norm();
|
||||
}
|
||||
|
||||
if(!boost::math::isfinite(sys.Jacobi.sum())) {
|
||||
BOOST_LOG(log)<< "Unnormal jacobi detected: "<<sys.Jacobi.sum();
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal jacobi detected: "<<sys.Jacobi.sum();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -253,17 +256,17 @@ int Dogleg<Kernel>::solve(typename Kernel::MappedEquationSystem& sys, Functor& r
|
|||
nu = 2*nu;
|
||||
}
|
||||
|
||||
// #ifdef USE_LOGGING
|
||||
// BOOST_LOG(log)<<"Result of step dF: "<<dF<<", dL: "<<dL<<std::endl
|
||||
// << "New Residual: "<< sys.Residual.transpose()<<std::endl;
|
||||
// #endif
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG_SEV(log, iteration)<<"Result of step dF: "<<dF<<", dL: "<<dL<<std::endl
|
||||
<< "New Residual: "<< sys.Residual.transpose()<<std::endl;
|
||||
#endif
|
||||
|
||||
if(dF > 0 && dL > 0) {
|
||||
|
||||
//see if we got too high differentials
|
||||
if(sys.Jacobi.template lpNorm<Eigen::Infinity>() > 2) {
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "High differential detected: "<<sys.Jacobi.template lpNorm<Eigen::Infinity>()<<" in iteration: "<<iter;
|
||||
BOOST_LOG_SEV(log, iteration)<< "High differential detected: "<<sys.Jacobi.template lpNorm<Eigen::Infinity>()<<" in iteration: "<<iter;
|
||||
#endif
|
||||
rescale();
|
||||
sys.recalculate();
|
||||
|
@ -287,7 +290,7 @@ int Dogleg<Kernel>::solve(typename Kernel::MappedEquationSystem& sys, Functor& r
|
|||
}
|
||||
else {
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "Reject step in iter "<<iter<<", dF: "<<dF<<", dL: "<<dL;
|
||||
BOOST_LOG_SEV(log, iteration)<< "Reject step in iter "<<iter<<", dF: "<<dF<<", dL: "<<dL;
|
||||
#endif
|
||||
sys.Residual = F_old;
|
||||
sys.Jacobi = J_old;
|
||||
|
@ -305,8 +308,10 @@ int Dogleg<Kernel>::solve(typename Kernel::MappedEquationSystem& sys, Functor& r
|
|||
time = (double(end-start) * 1000.) / double(CLOCKS_PER_SEC);
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) <<"Done solving: "<<err<<", iter: "<<iter<<", unused: "<<unused<<", reason:"<< stop;
|
||||
BOOST_LOG(log)<< "final jacobi: "<<std::endl<<sys.Jacobi;
|
||||
BOOST_LOG_SEV(log, solving)<<"Done solving: "<<err<<", iter: "<<iter<<", unused: "<<unused<<", reason:"<< stop;
|
||||
BOOST_LOG_SEV(log, solving)<< "final jacobi: "<<std::endl<<sys.Jacobi
|
||||
<< "residual: "<<sys.Residual.transpose()<<std::endl
|
||||
<< "maximal differential: "<<sys.Jacobi.template lpNorm<Eigen::Infinity>();
|
||||
#endif
|
||||
|
||||
return stop;
|
||||
|
|
|
@ -62,6 +62,14 @@ template<typename Scalar, int Dim>
|
|||
const typename Transform<Scalar, Dim>::Rotation& Transform<Scalar, Dim>::rotation() const {
|
||||
return m_rotation;
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
template<typename Derived>
|
||||
Transform<Scalar, Dim>& Transform<Scalar, Dim>::setRotation(const Eigen::RotationBase<Derived,Dim>& rotation) {
|
||||
m_rotation = rotation.derived().normalized();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
template<typename Derived>
|
||||
Transform<Scalar, Dim>& Transform<Scalar, Dim>::rotate(const Eigen::RotationBase<Derived,Dim>& rotation) {
|
||||
|
@ -73,6 +81,13 @@ template<typename Scalar, int Dim>
|
|||
const typename Transform<Scalar, Dim>::Translation& Transform<Scalar, Dim>::translation() const {
|
||||
return m_translation;
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
Transform<Scalar, Dim>& Transform<Scalar, Dim>::setTranslation(const Translation& translation) {
|
||||
m_translation = translation;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
Transform<Scalar, Dim>& Transform<Scalar, Dim>::translate(const Translation& translation) {
|
||||
m_translation = m_translation*translation;
|
||||
|
@ -89,6 +104,11 @@ Transform<Scalar, Dim>& Transform<Scalar, Dim>::scale(const Scalar& scaling) {
|
|||
return *this;
|
||||
}
|
||||
template<typename Scalar, int Dim>
|
||||
Transform<Scalar, Dim>& Transform<Scalar, Dim>::setScale(const Scaling& scaling) {
|
||||
m_scale.factor() = scaling.factor();
|
||||
return *this;
|
||||
}
|
||||
template<typename Scalar, int Dim>
|
||||
Transform<Scalar, Dim>& Transform<Scalar, Dim>::scale(const Scaling& scaling) {
|
||||
m_scale.factor() *= scaling.factor();
|
||||
return *this;
|
||||
|
|
|
@ -64,12 +64,23 @@ struct precision {
|
|||
};
|
||||
};
|
||||
|
||||
struct iterations {
|
||||
|
||||
typedef int type;
|
||||
typedef setting_property kind;
|
||||
struct default_value {
|
||||
int operator()() {
|
||||
return 5e3;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//and the solver itself
|
||||
template<typename Kernel>
|
||||
struct Dogleg {
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
dcm_logger log;
|
||||
#endif
|
||||
|
||||
typedef typename Kernel::number_type number_type;
|
||||
|
@ -96,7 +107,7 @@ struct Dogleg {
|
|||
};
|
||||
|
||||
template<typename Scalar, template<class> class Nonlinear = Dogleg>
|
||||
struct Kernel : public PropertyOwner< mpl::vector1<precision> > {
|
||||
struct Kernel : public PropertyOwner< mpl::vector2<precision, iterations> > {
|
||||
|
||||
//basics
|
||||
typedef Scalar number_type;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#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/sources/severity_logger.hpp>
|
||||
#include <boost/log/attributes.hpp>
|
||||
#include <boost/log/sources/logger.hpp>
|
||||
#include <boost/log/sources/record_ostream.hpp>
|
||||
|
@ -44,8 +44,20 @@ namespace keywords = boost::log::keywords;
|
|||
|
||||
namespace dcm {
|
||||
|
||||
enum severity_level {
|
||||
|
||||
iteration,
|
||||
solving,
|
||||
manipulation,
|
||||
information,
|
||||
error
|
||||
};
|
||||
|
||||
BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", severity_level)
|
||||
|
||||
static int counter = 0;
|
||||
typedef sinks::synchronous_sink< sinks::text_file_backend > sink_t;
|
||||
typedef src::severity_logger< severity_level > dcm_logger;
|
||||
|
||||
inline boost::shared_ptr< sink_t > init_log() {
|
||||
|
||||
|
|
|
@ -283,6 +283,13 @@ public:
|
|||
Shedule m_sheduler;
|
||||
Kernel m_kernel;
|
||||
std::vector<boost::shared_ptr<System> > m_subsystems;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
template<typename Expr>
|
||||
void setLoggingFilter(const Expr& ex) {
|
||||
sink->set_filter(ex);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
//implementations which always need to be with the definition as they can't be externalised
|
||||
|
|
|
@ -58,12 +58,16 @@ public:
|
|||
//***********************
|
||||
const Rotation& rotation() const;
|
||||
template<typename Derived>
|
||||
Transform& setRotation(const Eigen::RotationBase<Derived,Dim>& rotation);
|
||||
template<typename Derived>
|
||||
Transform& rotate(const Eigen::RotationBase<Derived,Dim>& rotation);
|
||||
|
||||
const Translation& translation() const;
|
||||
Transform& setTranslation(const Translation& translation);
|
||||
Transform& translate(const Translation& translation);
|
||||
|
||||
const Scaling& scaling() const;
|
||||
Transform& setScale(const Scaling& scaling);
|
||||
Transform& scale(const Scalar& scaling);
|
||||
Transform& scale(const Scaling& scaling);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <Eigen/StdVector>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <opendcm/core/logging.hpp>
|
||||
#include <opendcm/core/kernel.hpp>
|
||||
#include "defines.hpp"
|
||||
|
@ -44,7 +45,7 @@ enum Scalemode {
|
|||
};
|
||||
|
||||
template<typename Sys>
|
||||
struct ClusterMath {
|
||||
struct ClusterMath : public boost::noncopyable {
|
||||
|
||||
public:
|
||||
typedef typename Sys::Kernel Kernel;
|
||||
|
@ -91,6 +92,12 @@ public:
|
|||
void initFixMaps();
|
||||
|
||||
typename Kernel::Transform3D& getTransform();
|
||||
typename Kernel::Transform3D::Translation const& getTranslation() const;
|
||||
typename Kernel::Transform3D::Rotation const& getRotation() const;
|
||||
void setTransform(typename Kernel::Transform3D const& t);
|
||||
void setTranslation(typename Kernel::Transform3D::Translation const& );
|
||||
void setRotation(typename Kernel::Transform3D::Rotation const&);
|
||||
|
||||
void mapsToTransform(typename Kernel::Transform3D& trans);
|
||||
void transformToMaps(typename Kernel::Transform3D& trans);
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ struct Distance::type< Kernel, tag::point3D, tag::line3D > {
|
|||
Vector3 diff, n, dist;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
dcm_logger log;
|
||||
attrs::mutable_constant< std::string > tag;
|
||||
|
||||
type() : tag("Distance point3D line3D") {
|
||||
|
@ -98,7 +98,7 @@ struct Distance::type< Kernel, tag::point3D, tag::line3D > {
|
|||
Vector3 pp = line.head(3) + (line.head(3)-point.head(3)).norm()*line.template segment<3>(3);
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isnormal(pp.norm()))
|
||||
BOOST_LOG(log) << "Unnormal pseudopoint detected";
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal pseudopoint detected";
|
||||
#endif
|
||||
v2.push_back(pp);
|
||||
};
|
||||
|
@ -114,7 +114,7 @@ struct Distance::type< Kernel, tag::point3D, tag::line3D > {
|
|||
const Scalar res = dist.norm() - sc_value;
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal residual detected: "<<res;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal residual detected: "<<res;
|
||||
#endif
|
||||
return res;
|
||||
};
|
||||
|
@ -131,7 +131,7 @@ struct Distance::type< Kernel, tag::point3D, tag::line3D > {
|
|||
const Scalar res = dist.dot(d_dist)/dist.norm();
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal first cluster gradient detected: "<<res
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal first cluster gradient detected: "<<res
|
||||
<<" with point: "<<point.transpose()<<", line: "<<line.transpose()
|
||||
<<" and dpoint: "<<dpoint.transpose();
|
||||
#endif
|
||||
|
@ -151,7 +151,7 @@ struct Distance::type< Kernel, tag::point3D, tag::line3D > {
|
|||
const Scalar res = dist.dot(d_dist)/dist.norm();
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal second cluster gradient detected: "<<res
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal second cluster gradient detected: "<<res
|
||||
<<" with point: "<<point.transpose()<<", line: "<<line.transpose()
|
||||
<< "and dline: "<<dline.transpose();
|
||||
#endif
|
||||
|
@ -217,7 +217,7 @@ struct Distance::type< Kernel, tag::point3D, tag::plane3D > {
|
|||
v2.push_back(pp);
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isnormal(pp.norm()))
|
||||
BOOST_LOG(log) << "Unnormal pseudopoint detected";
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal pseudopoint detected";
|
||||
#endif
|
||||
};
|
||||
void setScale(Scalar scale) {
|
||||
|
@ -239,7 +239,7 @@ struct Distance::type< Kernel, tag::point3D, tag::plane3D > {
|
|||
return result + sc_value;
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(result))
|
||||
BOOST_LOG(log) << "Unnormal residual detected: " << result;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal residual detected: " << result;
|
||||
#endif
|
||||
return result;
|
||||
};
|
||||
|
@ -253,7 +253,7 @@ struct Distance::type< Kernel, tag::point3D, tag::plane3D > {
|
|||
const Scalar res = (dparam1.head(3)).dot(param2.tail(3)) / param2.tail(3).norm();
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal first cluster gradient detected: "<<res;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal first cluster gradient detected: "<<res;
|
||||
#endif
|
||||
//r = sqrt(x^2) = (x^2)^(1/2)
|
||||
//r' = 1/2(x^2)^(-1/2) * (x^2)'
|
||||
|
@ -279,7 +279,7 @@ struct Distance::type< Kernel, tag::point3D, tag::plane3D > {
|
|||
const Scalar res = (((-dp2).dot(n) + (p1-p2).dot(dn)) / n.norm() - (p1-p2).dot(n)* n.dot(dn)/std::pow(n.norm(),3));
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal second cluster gradient detected: "<<res;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal second cluster gradient detected: "<<res;
|
||||
#endif
|
||||
if(sspace == bidirectional && result<0.)
|
||||
return -res;
|
||||
|
@ -423,7 +423,7 @@ struct Distance::type< Kernel, tag::line3D, tag::line3D > {
|
|||
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(pp1.norm()) || !boost::math::isfinite(pp2.norm()))
|
||||
BOOST_LOG(log) << "Unnormal pseudopoint detected";
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal pseudopoint detected";
|
||||
#endif
|
||||
|
||||
v1.push_back(pp1);
|
||||
|
@ -451,7 +451,7 @@ struct Distance::type< Kernel, tag::line3D, tag::line3D > {
|
|||
const Scalar res = std::abs(cdn) / nxn.norm();
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal residual detected: "<<res;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal residual detected: "<<res;
|
||||
#endif
|
||||
return res;
|
||||
};
|
||||
|
@ -475,7 +475,7 @@ struct Distance::type< Kernel, tag::line3D, tag::line3D > {
|
|||
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(diff))
|
||||
BOOST_LOG(log) << "Unnormal first cluster gradient detected: "<<diff
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal first cluster gradient detected: "<<diff
|
||||
<<" with line1: "<<line1.transpose()<<", line2: "<<line2.transpose()
|
||||
<<" and dline1: "<<dline1.transpose();
|
||||
#endif
|
||||
|
@ -501,7 +501,7 @@ struct Distance::type< Kernel, tag::line3D, tag::line3D > {
|
|||
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(diff))
|
||||
BOOST_LOG(log) << "Unnormal first cluster gradient detected: "<<diff
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal first cluster gradient detected: "<<diff
|
||||
<<" with line1: "<<line1.transpose()<<", line2: "<<line2.transpose()
|
||||
<<" and dline2: "<<dline2.transpose();
|
||||
#endif
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace modell {
|
|||
a.template set<Scalar, 0>(v(0), t);
|
||||
a.template set<Scalar, 1>(v(1), t);
|
||||
a.template set<Scalar, 2>(v(2), t);
|
||||
a.finalize(t);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -87,6 +88,7 @@ namespace modell {
|
|||
a.template set<Scalar, 3>(v(3), t);
|
||||
a.template set<Scalar, 4>(v(4), t);
|
||||
a.template set<Scalar, 5>(v(5), t);
|
||||
a.finalize(t);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -122,6 +124,7 @@ namespace modell {
|
|||
a.template set<Scalar, 4>(v(4), t);
|
||||
a.template set<Scalar, 5>(v(5), t);
|
||||
a.template set<Scalar, 6>(v(6), t);
|
||||
a.finalize(t);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -138,6 +141,8 @@ struct dummy_accessor {
|
|||
void set(Scalar value, T& t) {
|
||||
//TODO: throw
|
||||
};
|
||||
template<typename T>
|
||||
void finalize(T& t) {};
|
||||
};
|
||||
|
||||
//dummy geometry traits for boost blank, wil bever be used
|
||||
|
|
|
@ -105,6 +105,31 @@ typename ClusterMath<Sys>::Kernel::Transform3D& ClusterMath<Sys>::getTransform()
|
|||
return m_transform;
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
typename ClusterMath<Sys>::Kernel::Transform3D::Translation const& ClusterMath<Sys>::getTranslation() const {
|
||||
return m_transform.translation();
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
typename ClusterMath<Sys>::Kernel::Transform3D::Rotation const& ClusterMath<Sys>::getRotation() const {
|
||||
return m_transform.rotation();
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
void ClusterMath<Sys>::setTransform(typename ClusterMath<Sys>::Kernel::Transform3D const& t) {
|
||||
m_transform = t;
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
void ClusterMath<Sys>::setTranslation(typename ClusterMath<Sys>::Kernel::Transform3D::Translation const& t) {
|
||||
m_transform.setTranslation(t);
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
void ClusterMath<Sys>::setRotation(typename ClusterMath<Sys>::Kernel::Transform3D::Rotation const& r) {
|
||||
m_transform.setRotation(r);
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
void ClusterMath<Sys>::mapsToTransform(typename ClusterMath<Sys>::Kernel::Transform3D& trans) {
|
||||
//add scale only after possible reset
|
||||
|
@ -173,7 +198,7 @@ void ClusterMath<Sys>::resetClusterRotation(typename ClusterMath<Sys>::Kernel::T
|
|||
|
||||
trans = m_resetTransform.inverse()*trans;
|
||||
m_ssrTransform *= m_resetTransform;
|
||||
m_transform = m_resetTransform.inverse()*m_transform;
|
||||
//m_transform = m_resetTransform.inverse()*m_transform;
|
||||
|
||||
//apply the needed transformation to all geometries local values
|
||||
typedef typename std::vector<Geom>::iterator iter;
|
||||
|
@ -593,6 +618,12 @@ void ClusterMath<Sys>::applyClusterScale(Scalar scale, bool isFixed) {
|
|||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "sstrans scale: "<<ssTrans.scaling().factor();
|
||||
BOOST_LOG(log) << "finish transform scale: "<<m_transform.scaling().factor();
|
||||
//we may want to access the scale points for debuging (I mean you, freecad assembly debug!), so
|
||||
//it is important to transform them too to ensure the points are in the same coordinate system
|
||||
typename Vec::iterator it;
|
||||
for(it=m_points.begin(); it!=m_points.end(); it++) {
|
||||
(*it) = ssTrans * (*it);
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ template<typename Sys>
|
|||
void MES<Sys>::removeLocalGradientZeros() {
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "remove local gradient zero";
|
||||
BOOST_LOG_SEV(log, information) << "remove local gradient zero";
|
||||
#endif
|
||||
//let the constraints treat the local zeros
|
||||
typedef typename Cluster::template object_iterator<Constraint3D> oiter;
|
||||
|
@ -269,7 +269,7 @@ void SystemSolver<Sys>::solveCluster(boost::shared_ptr<Cluster> cluster, Sys& sy
|
|||
if(params <= 0 || constraints <= 0) {
|
||||
//TODO:throw
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "Error in system counting: params = " << params << " and constraints = "<<constraints;
|
||||
BOOST_LOG_SEV(log, error)<< "Error in system counting: params = " << params << " and constraints = "<<constraints;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -337,11 +337,11 @@ void SystemSolver<Sys>::solveCluster(boost::shared_ptr<Cluster> cluster, Sys& sy
|
|||
}
|
||||
|
||||
try {
|
||||
//if we don't have rotations we need no expensive scaling code
|
||||
/* //if we don't have rotations we need no expensive scaling code
|
||||
if(!mes.hasAccessType(rotation)) {
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "No rotation parameters in system, solve without scaling";
|
||||
BOOST_LOG_SEV(log, solving)<< "No rotation parameters in system, solve without scaling";
|
||||
#endif
|
||||
DummyScaler re;
|
||||
sys.kernel().solve(mes, re);
|
||||
|
@ -369,7 +369,7 @@ void SystemSolver<Sys>::solveCluster(boost::shared_ptr<Cluster> cluster, Sys& sy
|
|||
|
||||
//if(!has_cycle) {
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "non-cyclic system dedected: solve rotation only";
|
||||
BOOST_LOG_SEV(log, solving)<< "non-cyclic system dedected: solve rotation only";
|
||||
#endif
|
||||
//cool, lets do uncylic. first all rotational constraints with rotational parameters
|
||||
mes.setAccess(rotation);
|
||||
|
@ -404,7 +404,7 @@ void SystemSolver<Sys>::solveCluster(boost::shared_ptr<Cluster> cluster, Sys& sy
|
|||
done = true;
|
||||
else {
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "Solve Translation after Rotations are not enough";
|
||||
BOOST_LOG_SEV(log, solving)<< "Solve Translation after Rotations are not enough";
|
||||
#endif
|
||||
|
||||
//let's try translation only
|
||||
|
@ -423,9 +423,9 @@ void SystemSolver<Sys>::solveCluster(boost::shared_ptr<Cluster> cluster, Sys& sy
|
|||
//};
|
||||
|
||||
//not done already? try it the hard way!
|
||||
if(!done) {
|
||||
if(!done) {*/
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "Full scale solver used";
|
||||
BOOST_LOG_SEV(log, solving)<< "Full scale solver used";
|
||||
#endif
|
||||
mes.setAccess(complete);
|
||||
mes.recalculate();
|
||||
|
@ -434,10 +434,10 @@ void SystemSolver<Sys>::solveCluster(boost::shared_ptr<Cluster> cluster, Sys& sy
|
|||
re();
|
||||
sys.kernel().solve(mes, re);
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log)<< "Numbers of rescale: "<<re.rescales;
|
||||
BOOST_LOG_SEV(log, solving)<< "Numbers of rescale: "<<re.rescales;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
/* };
|
||||
}*/
|
||||
|
||||
//done solving, write the results back
|
||||
finish(cluster, sys, mes);
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include <boost/spirit/include/phoenix.hpp>
|
||||
#include <boost/phoenix/function/adapt_function.hpp>
|
||||
#include <boost/phoenix/bind.hpp>
|
||||
#include <boost/fusion/include/adapt_adt.hpp>
|
||||
#include <boost/phoenix/fusion/at.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/greater.hpp>
|
||||
|
@ -234,6 +236,48 @@ bool VectorInput(Geom& v, Row& r, Value& val) {
|
|||
return true; // output continues
|
||||
};
|
||||
|
||||
template <typename Translation, typename Row, typename Value>
|
||||
bool TranslationOutput(Translation& v, Row& r, Value& val) {
|
||||
|
||||
if(r < 3) {
|
||||
|
||||
val = v.getTranslation().vector()(r++);
|
||||
return true; // output continues
|
||||
}
|
||||
|
||||
return false; // fail the output
|
||||
};
|
||||
|
||||
template <typename CM>
|
||||
bool TranslationInput(CM& t, std::vector<double> const& val) {
|
||||
|
||||
t.setTranslation(typename CM::Kernel::Transform3D::Translation(val[0],val[1],val[2]));
|
||||
return true; // output continues
|
||||
};
|
||||
|
||||
template <typename CM, typename Row, typename Value>
|
||||
bool RotationOutput(CM& v, Row& r, Value& val) {
|
||||
|
||||
if(r < 3) {
|
||||
|
||||
val = v.getRotation().vec()(r++);
|
||||
return true; // output continues
|
||||
}
|
||||
else if( r < 4 ) {
|
||||
val = v.getRotation().w();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; // fail the output
|
||||
};
|
||||
|
||||
template <typename CM>
|
||||
bool RotationInput(CM& t, std::vector<double> const& val) {
|
||||
|
||||
t.setRotation(typename CM::Kernel::Transform3D::Rotation(val[3], val[0], val[1], val[2]));
|
||||
return true; // output continues
|
||||
};
|
||||
|
||||
template<typename Geom>
|
||||
struct inject_set {
|
||||
|
||||
|
@ -302,6 +346,8 @@ static science_type const scientific = science_type();
|
|||
|
||||
BOOST_PHOENIX_ADAPT_FUNCTION(bool, vector_out, dcm::details::VectorOutput, 3)
|
||||
BOOST_PHOENIX_ADAPT_FUNCTION(bool, vector_in, dcm::details::VectorInput, 3)
|
||||
BOOST_PHOENIX_ADAPT_FUNCTION(bool, translation_out, dcm::details::TranslationOutput, 3)
|
||||
BOOST_PHOENIX_ADAPT_FUNCTION(bool, rotation_out, dcm::details::RotationOutput, 3)
|
||||
BOOST_PHOENIX_ADAPT_FUNCTION(bool, create, dcm::details::Create, 4)
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
|
@ -331,6 +377,14 @@ void parser_generator< typename details::getModule3D<System>::type::vertex_prop
|
|||
r = karma::lit("<type>Vertex</type>")
|
||||
<< karma::eol << "<value>" << karma::int_ << "</value>";
|
||||
};
|
||||
/*
|
||||
template<typename System, typename iterator>
|
||||
void parser_generator< typename details::getModule3D<System>::type::math_prop , System, iterator >::init(generator& r) {
|
||||
|
||||
r = karma::lit("<type>Math3D</type>")
|
||||
<< karma::eol << "<Translation>" << (details::scientific[ boost::spirit::_pass = translation_out(karma::_val, karma::_a, karma::_1) ] % ' ') << "</Translation>"
|
||||
<< karma::eol << karma::eps[karma::_a = 0] << "<Rotation>" << (details::scientific[ boost::spirit::_pass = rotation_out(karma::_val, karma::_a, karma::_1) ] % ' ') << "</Rotation>";
|
||||
};*/
|
||||
|
||||
template<typename System, typename iterator>
|
||||
void parser_generator< typename details::getModule3D<System>::type::Constraint3D , System, iterator >::init(generator& r) {
|
||||
|
@ -373,6 +427,13 @@ void parser_parser< typename details::getModule3D<System>::type::vertex_prop, Sy
|
|||
|
||||
r %= qi::lit("<type>Vertex</type>") >> "<value>" >> qi::int_ >> "</value>";
|
||||
};
|
||||
/*
|
||||
template<typename System, typename iterator>
|
||||
void parser_parser< typename details::getModule3D<System>::type::math_prop, System, iterator >::init(parser& r) {
|
||||
|
||||
//r = qi::lit("<type>Math3D</type>") >> "<Translation>" >> (*qi::double_)[ phx::bind(&details::TranslationInput<details::ClusterMath<System> >, qi::_val, qi::_1) ] >> "</Translation>"
|
||||
// >> "<Rotation>" >> (*qi::double_)[ phx::bind(&details::RotationInput<details::ClusterMath<System> >,qi::_val, qi::_1) ] >> "</Rotation>";
|
||||
};*/
|
||||
|
||||
template<typename System, typename iterator>
|
||||
void parser_parser< typename details::getModule3D<System>::type::Constraint3D, System, iterator >::init(parser& r) {
|
||||
|
|
|
@ -46,7 +46,7 @@ struct MES : public Sys::Kernel::MappedEquationSystem {
|
|||
boost::shared_ptr<Cluster> m_cluster;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
dcm_logger log;
|
||||
#endif
|
||||
|
||||
MES(boost::shared_ptr<Cluster> cl, int par, int eqn);
|
||||
|
|
|
@ -63,6 +63,17 @@ struct parser_generator< typename details::getModule3D<System>::type::vertex_pro
|
|||
typedef karma::rule<iterator, GlobalVertex()> generator;
|
||||
static void init(generator& r);
|
||||
};
|
||||
/*
|
||||
template<typename System>
|
||||
struct parser_generate< typename details::getModule3D<System>::type::math_prop , System>
|
||||
: public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_generator< typename details::getModule3D<System>::type::math_prop , System, iterator > {
|
||||
|
||||
typedef karma::rule<iterator, details::ClusterMath<System>&(), karma::locals<int> > generator;
|
||||
static void init(generator& r);
|
||||
};*/
|
||||
|
||||
template<typename System>
|
||||
struct parser_generate< typename details::getModule3D<System>::type::Constraint3D , System>
|
||||
|
@ -127,7 +138,17 @@ struct parser_parser< typename details::getModule3D<System>::type::vertex_prop,
|
|||
typedef qi::rule<iterator, GlobalVertex(), qi::space_type> parser;
|
||||
static void init(parser& r);
|
||||
};
|
||||
/*
|
||||
template<typename System>
|
||||
struct parser_parse< typename details::getModule3D<System>::type::math_prop, System>
|
||||
: public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_parser< typename details::getModule3D<System>::type::math_prop, System, iterator > {
|
||||
|
||||
typedef qi::rule<iterator, details::ClusterMath<System>(), qi::space_type > parser;
|
||||
static void init(parser& r);
|
||||
};*/
|
||||
|
||||
template<typename System>
|
||||
struct parser_parse< typename details::getModule3D<System>::type::Constraint3D , System>
|
||||
|
|
|
@ -58,7 +58,7 @@ struct ModulePart {
|
|||
protected:
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
dcm_logger log;
|
||||
#endif
|
||||
|
||||
//check if we have module3d in this system
|
||||
|
@ -299,7 +299,7 @@ ModulePart<Typelist, ID>::type<Sys>::Part_base::Part_base(const T& geometry, Sys
|
|||
m_cluster->template getProperty<typename module3d::math_prop>().getTransform() = m_transform;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "Init: "<<m_transform;
|
||||
BOOST_LOG_SEV(log, information) << "Init: "<<m_transform;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -419,7 +419,7 @@ void ModulePart<Typelist, ID>::type<Sys>::Part_base::finishCalculation() {
|
|||
apply(vis);
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
BOOST_LOG(log) << "New Value: "<<m_transform;
|
||||
BOOST_LOG_SEV(log, manipulation) << "New Value: "<<m_transform;
|
||||
#endif
|
||||
|
||||
//emit the signal for new values
|
||||
|
|
|
@ -41,7 +41,7 @@ struct Distance::type< Kernel, tag::point3D, tag::segment3D > {
|
|||
Vector3 v01, v02, v12, cross;
|
||||
|
||||
#ifdef USE_LOGGING
|
||||
src::logger log;
|
||||
dcm_logger log;
|
||||
attrs::mutable_constant< std::string > tag;
|
||||
|
||||
type() : tag("Distance point3D segment3D") {
|
||||
|
@ -55,7 +55,7 @@ struct Distance::type< Kernel, tag::point3D, tag::segment3D > {
|
|||
Vector3 pp = segment.head(3) + (segment.head(3)-point.head(3)).norm()*dir;
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isnormal(pp.norm()))
|
||||
BOOST_LOG(log) << "Unnormal pseudopoint detected";
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal pseudopoint detected";
|
||||
#endif
|
||||
v2.push_back(pp);
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ struct Distance::type< Kernel, tag::point3D, tag::segment3D > {
|
|||
const Scalar res = cross.norm()/v12_n - sc_value;
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal residual detected: "<<res;
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal residual detected: "<<res;
|
||||
#endif
|
||||
return res;
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ struct Distance::type< Kernel, tag::point3D, tag::segment3D > {
|
|||
const Scalar res = cross.dot(d_cross)/(cross_n*v12_n);
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal first cluster gradient detected: "<<res
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal first cluster gradient detected: "<<res
|
||||
<<" with point: "<<point.transpose()<<", segment: "<<segment.transpose()
|
||||
<<" and dpoint: "<<dpoint.transpose();
|
||||
#endif
|
||||
|
@ -109,7 +109,7 @@ struct Distance::type< Kernel, tag::point3D, tag::segment3D > {
|
|||
const Scalar res = cross.dot(d_cross)/(cross_n*v12_n) - v12.dot(d_v12)*cross_v12_n;
|
||||
#ifdef USE_LOGGING
|
||||
if(!boost::math::isfinite(res))
|
||||
BOOST_LOG(log) << "Unnormal second cluster gradient detected: "<<res
|
||||
BOOST_LOG_SEV(log, error) << "Unnormal second cluster gradient detected: "<<res
|
||||
<<" with point: "<<point.transpose()<<", segment: "<<segment.transpose()
|
||||
<< "and dsegment: "<<dsegment.transpose();
|
||||
#endif
|
||||
|
|
|
@ -66,7 +66,7 @@ prop_parser<PropList, Prop, Par>::prop_parser() : prop_parser<PropList, Prop, Pa
|
|||
typedef typename mpl::find<PropList, Prop>::type::pos pos;
|
||||
|
||||
Par::init(subrule);
|
||||
start = qi::lit("<Property>") >> subrule[phx::at_c<pos::value>(*qi::_r1) = qi::_1] >> qi::lit("</Property>");
|
||||
//start = qi::lit("<Property>") >> subrule[phx::at_c<pos::value>(*qi::_r1) = qi::_1] >> qi::lit("</Property>");
|
||||
};
|
||||
|
||||
template<typename Sys, typename PropertyList>
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
<string>Angle</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintAngle.svg</normaloff>:/icons/constraints/Assembly_ConstraintAngle.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -157,7 +157,7 @@
|
|||
<string>Coincident</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintCoincidence.svg</normaloff>:/icons/constraints/Assembly_ConstraintCoincidence.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -198,7 +198,7 @@
|
|||
<string>Fix</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintLock.svg</normaloff>:/icons/constraints/Assembly_ConstraintLock.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -239,7 +239,7 @@
|
|||
<string>Distance</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintDistance.svg</normaloff>:/icons/constraints/Assembly_ConstraintDistance.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -280,7 +280,7 @@
|
|||
<string>Orientation</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintOrientation.svg</normaloff>:/icons/constraints/Assembly_ConstraintOrientation.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -321,7 +321,7 @@
|
|||
<string>Align</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintAlignment.svg</normaloff>:/icons/constraints/Assembly_ConstraintAlignment.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -422,6 +422,9 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
|
@ -436,7 +439,7 @@
|
|||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintBidirectional.svg</normaloff>:/icons/constraints/Assembly_ConstraintBidirectional.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -474,8 +477,8 @@
|
|||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional2.svg</normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional2.svg</iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional1.svg</normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional1.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -509,8 +512,8 @@
|
|||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional1.svg</normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional1.svg</iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional2.svg</normaloff>:/icons/constraints/Assembly_ConstraintUnidirectional2.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -566,7 +569,7 @@
|
|||
<string>Parallel</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintParallel.svg</normaloff>:/icons/constraints/Assembly_ConstraintParallel.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -604,7 +607,7 @@
|
|||
<string>Equal</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintEqual.svg</normaloff>:/icons/constraints/Assembly_ConstraintEqual.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -645,7 +648,7 @@
|
|||
<string>Opposite</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintOpposite.svg</normaloff>:/icons/constraints/Assembly_ConstraintOpposite.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -686,7 +689,7 @@
|
|||
<string>Perpend.</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="Resources/Assembly.qrc">
|
||||
<normaloff>:/icons/constraints/Assembly_ConstraintPerpendicular.svg</normaloff>:/icons/constraints/Assembly_ConstraintPerpendicular.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
|
@ -729,6 +732,7 @@
|
|||
</widget>
|
||||
<resources>
|
||||
<include location="../../../Gui/Icons/resource.qrc"/>
|
||||
<include location="Resources/Assembly.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
|
@ -25,20 +25,35 @@
|
|||
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/nodes/SoGroup.h>
|
||||
#include <Inventor/nodes/SoAnnotation.h>
|
||||
#include <Inventor/nodes/SoSwitch.h>
|
||||
#include <Inventor/nodes/SoDrawStyle.h>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderPart.h"
|
||||
//#include <Gui/Command.h>
|
||||
//#include <Gui/Document.h>
|
||||
#include <Mod/Assembly/App/ItemPart.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
using namespace AssemblyGui;
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
SbColor PointColor(1.0f,0.0f,0.0f);
|
||||
SbColor PseudoColor(0.0f,0.0f,1.0f);
|
||||
SbColor MidpointColor(0.0f,1.0f,1.0f);
|
||||
SbColor ZeroColor(1.0f,1.0f,0.0f);
|
||||
#endif
|
||||
|
||||
PROPERTY_SOURCE(AssemblyGui::ViewProviderItemPart,AssemblyGui::ViewProviderItem)
|
||||
|
||||
ViewProviderItemPart::ViewProviderItemPart()
|
||||
{
|
||||
sPixmap = "Assembly_Assembly_Part_Tree.svg";
|
||||
sPixmap = "Assembly_Assembly_Part_Tree.svg";
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
ADD_PROPERTY(ShowScalePoints,(false));
|
||||
#endif
|
||||
}
|
||||
|
||||
ViewProviderItemPart::~ViewProviderItemPart()
|
||||
|
@ -50,22 +65,46 @@ bool ViewProviderItemPart::doubleClicked(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderItemPart::attach(App::DocumentObject *pcFeat)
|
||||
void ViewProviderItemPart::attach(App::DocumentObject* pcFeat)
|
||||
{
|
||||
// call parent attach method
|
||||
ViewProviderGeometryObject::attach(pcFeat);
|
||||
|
||||
|
||||
// putting all together with the switch
|
||||
addDisplayMaskMode(getChildRoot(), "Main");
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
|
||||
m_anno = new SoAnnotation;
|
||||
m_switch = new SoSwitch;
|
||||
m_switch->addChild(m_anno);
|
||||
|
||||
m_material = new SoMaterial;
|
||||
m_anno->addChild(m_material);
|
||||
|
||||
SoMaterialBinding* MtlBind = new SoMaterialBinding;
|
||||
MtlBind->value = SoMaterialBinding::PER_VERTEX;
|
||||
m_anno->addChild(MtlBind);
|
||||
|
||||
m_pointsCoordinate = new SoCoordinate3;
|
||||
m_anno->addChild(m_pointsCoordinate);
|
||||
|
||||
SoDrawStyle* DrawStyle = new SoDrawStyle;
|
||||
DrawStyle->pointSize = 8;
|
||||
m_anno->addChild(DrawStyle);
|
||||
m_points = new SoMarkerSet;
|
||||
m_points->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
|
||||
m_anno->addChild(m_points);
|
||||
|
||||
pcRoot->addChild(m_switch);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ViewProviderItemPart::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if ( strcmp("Main",ModeName)==0 )
|
||||
if(strcmp("Main",ModeName)==0)
|
||||
setDisplayMaskMode("Main");
|
||||
|
||||
ViewProviderGeometryObject::setDisplayMode( ModeName );
|
||||
ViewProviderGeometryObject::setDisplayMode(ModeName);
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderItemPart::getDisplayModes(void) const
|
||||
|
@ -83,9 +122,10 @@ std::vector<App::DocumentObject*> ViewProviderItemPart::claimChildren(void)const
|
|||
{
|
||||
std::vector<App::DocumentObject*> res;
|
||||
|
||||
res.insert( res.end(), static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().begin(),static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().end());
|
||||
res.insert(res.end(), static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().begin(),static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().end());
|
||||
|
||||
if(static_cast<Assembly::ItemPart*>(getObject())->Model.getValue())
|
||||
res.push_back( static_cast<Assembly::ItemPart*>(getObject())->Model.getValue());
|
||||
res.push_back(static_cast<Assembly::ItemPart*>(getObject())->Model.getValue());
|
||||
|
||||
return res;
|
||||
|
||||
|
@ -95,10 +135,104 @@ std::vector<App::DocumentObject*> ViewProviderItemPart::claimChildren3D(void)con
|
|||
{
|
||||
std::vector<App::DocumentObject*> res;
|
||||
|
||||
res.insert( res.end(), static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().begin(),static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().end());
|
||||
res.insert(res.end(), static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().begin(),static_cast<Assembly::ItemPart*>(getObject())->Annotation.getValues().end());
|
||||
|
||||
if(static_cast<Assembly::ItemPart*>(getObject())->Model.getValue())
|
||||
res.push_back( static_cast<Assembly::ItemPart*>(getObject())->Model.getValue());
|
||||
res.push_back(static_cast<Assembly::ItemPart*>(getObject())->Model.getValue());
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
|
||||
void ViewProviderItemPart::onChanged(const App::Property* prop) {
|
||||
|
||||
if(prop == &ShowScalePoints) {
|
||||
if(ShowScalePoints.getValue()) {
|
||||
m_switch->whichChild = 0;
|
||||
|
||||
int counter = 0;
|
||||
boost::shared_ptr<Part3D> part = static_cast<Assembly::ItemPart*>(getObject())->m_part;
|
||||
|
||||
if(!part) {
|
||||
ViewProviderItem::onChanged(prop);
|
||||
return;
|
||||
}
|
||||
|
||||
dcm::detail::Transform<double,3> transform = part->m_cluster->getProperty<Module3D::type<Solver>::math_prop>().m_transform;
|
||||
dcm::detail::Transform<double,3> ssrTransform = part->m_cluster->getProperty<Module3D::type<Solver>::math_prop>().m_ssrTransform;
|
||||
|
||||
dcm::detail::Transform<double,3> trans = ssrTransform.inverse();
|
||||
|
||||
int PseudoSize = part->m_cluster->getProperty<Module3D::type<Solver>::math_prop>().m_pseudo.size();
|
||||
typedef dcm::details::ClusterMath<Solver>::Vec Vector;
|
||||
Vector& pv = part->m_cluster->getProperty<Module3D::type<Solver>::math_prop>().m_points;
|
||||
|
||||
for(Vector::iterator it = pv.begin(); it != pv.end(); it++) {
|
||||
|
||||
Kernel::Vector3 vec = trans * (*it);
|
||||
m_pointsCoordinate->point.set1Value(counter, SbVec3f(vec(0),vec(1),vec(2)));
|
||||
|
||||
if(counter < PseudoSize)
|
||||
m_material->diffuseColor.set1Value(counter, PseudoColor);
|
||||
else
|
||||
m_material->diffuseColor.set1Value(counter, PointColor);
|
||||
|
||||
counter++;
|
||||
};
|
||||
|
||||
//midpoint
|
||||
Kernel::Vector3 midpoint = trans * Kernel::Vector3(0,0,0);
|
||||
|
||||
m_pointsCoordinate->point.set1Value(counter, SbVec3f(midpoint(0),midpoint(1),midpoint(2)));
|
||||
|
||||
m_material->diffuseColor.set1Value(counter, MidpointColor);
|
||||
|
||||
counter++;
|
||||
|
||||
//origin
|
||||
Kernel::Vector3 origin = Kernel::Vector3(0,0,0);
|
||||
|
||||
m_pointsCoordinate->point.set1Value(counter, SbVec3f(origin(0),origin(1),origin(2)));
|
||||
|
||||
m_material->diffuseColor.set1Value(counter, ZeroColor);
|
||||
|
||||
counter++;
|
||||
|
||||
m_points->numPoints = counter;
|
||||
|
||||
//test
|
||||
boost::shared_ptr<Geometry3D> g = part->m_cluster->getProperty<Module3D::type<Solver>::math_prop>().m_geometry[0];
|
||||
|
||||
std::stringstream str;
|
||||
|
||||
str<<"Global: "<<g->m_global.transpose()<<std::endl;
|
||||
|
||||
str<<"Global TLPoint: "<<(trans * g->getPoint()).transpose()<<std::endl;
|
||||
|
||||
Kernel::Vector3 v = g->m_global.head(3);
|
||||
|
||||
str<<"Local Point : "<<(transform.inverse()*v).transpose()<<std::endl;
|
||||
|
||||
str<<"Local TLPoint: "<<(ssrTransform.inverse()*g->getPoint()).transpose()<<std::endl;
|
||||
|
||||
str<<"PVPoint : "<<(pv[0]).transpose()<<std::endl;
|
||||
|
||||
str<<"Local PVPoint: "<<(ssrTransform.inverse()*pv[0]).transpose()<<std::endl;
|
||||
|
||||
Base::Console().Message(str.str().c_str());
|
||||
|
||||
}
|
||||
else {
|
||||
m_switch->whichChild = -1;
|
||||
m_pointsCoordinate->point.setValues(0, 0, (SbVec3f*)NULL);
|
||||
m_material->diffuseColor.setValues(0, 0, (SbColor*)NULL);
|
||||
m_points->numPoints = 0;
|
||||
}
|
||||
};
|
||||
|
||||
ViewProviderItem::onChanged(prop);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
#define ASSEMBLYGUI_ViewProviderPart_H
|
||||
|
||||
#include "ViewProvider.h"
|
||||
#include <Inventor/nodes/SoAnnotation.h>
|
||||
#include <Inventor/nodes/SoMarkerSet.h>
|
||||
#include <Inventor/nodes/SoCoordinate3.h>
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoSwitch.h>
|
||||
|
||||
|
||||
namespace AssemblyGui {
|
||||
|
@ -49,7 +54,18 @@ public:
|
|||
virtual std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
|
||||
virtual std::vector<App::DocumentObject*> claimChildren3D(void)const;
|
||||
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
//draw the dcm points
|
||||
SoAnnotation* m_anno;
|
||||
SoSwitch* m_switch;
|
||||
SoMaterial* m_material;
|
||||
SoCoordinate3* m_pointsCoordinate;
|
||||
SoMarkerSet* m_points;
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
App::PropertyBool ShowScalePoints;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user