extend debug facilities with state writing and add externalisation to make it compile with a decent amout of memory
This commit is contained in:
parent
fce34e05fc
commit
4b5e387da4
|
@ -58,6 +58,15 @@ SET(Module_SRCS
|
|||
)
|
||||
SOURCE_GROUP("Module" FILES ${Module_SRCS})
|
||||
|
||||
|
||||
set(Solver_SRC Solver/solver_3d_ext1.cpp
|
||||
Solver/solver_3d_ext2.cpp
|
||||
Solver/solver_3d_ext3.cpp
|
||||
Solver/solver_state_ext1.cpp
|
||||
Solver/solver_state_ext2.cpp
|
||||
)
|
||||
SOURCE_GROUP("Solver" FILES ${Solver_SRC})
|
||||
|
||||
SET(Python_SRCS
|
||||
ItemPy.xml
|
||||
ItemPyImp.cpp
|
||||
|
@ -76,15 +85,9 @@ SET(Assembly_SRCS
|
|||
${Features_SRCS}
|
||||
${Python_SRCS}
|
||||
${Module_SRCS}
|
||||
${Solver_SRC}
|
||||
)
|
||||
|
||||
#set(log_LIB boost_log
|
||||
# rt
|
||||
# ${Boost_SYSTEM_LIBRARY}
|
||||
# ${Boost_FILESYSTEM_LIBRARY}
|
||||
# ${Boost_THREAD_LIBRARY}
|
||||
#)
|
||||
|
||||
add_library(Assembly SHARED ${Assembly_SRCS})
|
||||
target_link_libraries(Assembly ${Assembly_LIBS} ${log_LIB})
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include "Solver.h"
|
||||
#include "Solver/Solver.h"
|
||||
#include "ItemAssembly.h"
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <App/FeaturePython.h>
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "Solver.h"
|
||||
#include "Solver/Solver.h"
|
||||
|
||||
namespace Assembly
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ ItemAssembly::ItemAssembly() {
|
|||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
ADD_PROPERTY(ApplyAtFailure,(false));
|
||||
ADD_PROPERTY(Precision,(1e-6));
|
||||
ADD_PROPERTY(SaveState,(false));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -79,6 +80,14 @@ App::DocumentObjectExecReturn* ItemAssembly::execute(void) {
|
|||
m_solver->setOption<dcm::solverfailure>(dcm::IgnoreResults);
|
||||
|
||||
m_solver->setOption<dcm::precision>(Precision.getValue());
|
||||
|
||||
if(SaveState.getValue()) {
|
||||
|
||||
ofstream myfile;
|
||||
myfile.open("solverstate.txt");
|
||||
m_solver->saveState(myfile);
|
||||
myfile.close();
|
||||
};
|
||||
#endif
|
||||
initConstraints(boost::shared_ptr<Solver>());
|
||||
|
||||
|
@ -259,8 +268,8 @@ void ItemAssembly::initSolver(boost::shared_ptr<Solver> parent, Base::Placement&
|
|||
PL_downstream *= this->Placement.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
//we always need to store the downstream placement as we may be a subassembly in a
|
||||
|
||||
//we always need to store the downstream placement as we may be a subassembly in a
|
||||
//non-rigid subassembly
|
||||
m_downstream_placement = PL_downstream;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <App/PropertyStandard.h>
|
||||
|
||||
#include "Item.h"
|
||||
#include "Solver.h"
|
||||
#include "Solver/Solver.h"
|
||||
|
||||
namespace Assembly
|
||||
{
|
||||
|
@ -87,6 +87,7 @@ public:
|
|||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
App::PropertyBool ApplyAtFailure;
|
||||
App::PropertyFloat Precision;
|
||||
App::PropertyBool SaveState;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Item.h"
|
||||
#include "Solver.h"
|
||||
#include "Solver/Solver.h"
|
||||
|
||||
|
||||
namespace Assembly
|
||||
|
|
|
@ -23,10 +23,20 @@
|
|||
#ifndef SOLVER_H
|
||||
#define SOLVER_H
|
||||
|
||||
#define DCM_EXTERNAL_CORE
|
||||
#define DCM_EXTERNAL_3D
|
||||
#define DCM_EXTERNAL_STATE
|
||||
|
||||
#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 <Base/Placement.h>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
|
@ -320,7 +330,12 @@ struct geometry_traits<Base::Placement> {
|
|||
typedef dcm::Kernel<double> Kernel;
|
||||
typedef dcm::Module3D< mpl::vector4< gp_Pnt, gp_Lin, gp_Pln, gp_Cylinder>, std::string > Module3D;
|
||||
typedef dcm::ModulePart< mpl::vector1< Base::Placement >, std::string > ModulePart;
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
typedef dcm::System<Kernel, Module3D, ModulePart, dcm::ModuleState> Solver;
|
||||
#elif
|
||||
typedef dcm::System<Kernel, Module3D, ModulePart> Solver;
|
||||
#endif
|
||||
|
||||
typedef ModulePart::type<Solver>::Part Part3D;
|
||||
typedef Module3D::type<Solver>::Geometry3D Geometry3D;
|
30
src/Mod/Assembly/App/Solver/solver_3d_ext1.cpp
Normal file
30
src/Mod/Assembly/App/Solver/solver_3d_ext1.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#include "Solver.h"
|
||||
|
||||
#ifdef DCM_EXTERNAL_CORE
|
||||
#include DCM_EXTERNAL_CORE_INCLUDE_01
|
||||
DCM_EXTERNAL_CORE_01( Solver )
|
||||
#endif
|
||||
|
||||
#ifdef DCM_EXTERNAL_3D
|
||||
#include DCM_EXTERNAL_3D_INCLUDE_01
|
||||
DCM_EXTERNAL_3D_01( Solver )
|
||||
#endif
|
25
src/Mod/Assembly/App/Solver/solver_3d_ext2.cpp
Normal file
25
src/Mod/Assembly/App/Solver/solver_3d_ext2.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#include "Solver.h"
|
||||
|
||||
#ifdef DCM_EXTERNAL_3D
|
||||
#include DCM_EXTERNAL_3D_INCLUDE_02
|
||||
DCM_EXTERNAL_3D_02(Solver)
|
||||
#endif
|
25
src/Mod/Assembly/App/Solver/solver_3d_ext3.cpp
Normal file
25
src/Mod/Assembly/App/Solver/solver_3d_ext3.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#include "Solver.h"
|
||||
|
||||
#ifdef DCM_EXTERNAL_3D
|
||||
#include DCM_EXTERNAL_3D_INCLUDE_03
|
||||
DCM_EXTERNAL_3D_03(Solver)
|
||||
#endif
|
44
src/Mod/Assembly/App/Solver/solver_state_ext1.cpp
Normal file
44
src/Mod/Assembly/App/Solver/solver_state_ext1.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#include "Solver.h"
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_001
|
||||
DCM_EXTERNAL_STATE_001( Solver )
|
||||
#endif
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_002
|
||||
DCM_EXTERNAL_STATE_002( Solver )
|
||||
#endif
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_003
|
||||
DCM_EXTERNAL_STATE_003( Solver )
|
||||
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_009
|
||||
DCM_EXTERNAL_STATE_009( Solver )
|
||||
#endif
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_004
|
||||
DCM_EXTERNAL_STATE_004( Solver )
|
||||
#endif
|
||||
|
40
src/Mod/Assembly/App/Solver/solver_state_ext2.cpp
Normal file
40
src/Mod/Assembly/App/Solver/solver_state_ext2.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#include "Solver.h"
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_005
|
||||
DCM_EXTERNAL_STATE_005( Solver )
|
||||
#endif
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_006
|
||||
DCM_EXTERNAL_STATE_006( Solver )
|
||||
#endif
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_007
|
||||
DCM_EXTERNAL_STATE_007( Solver )
|
||||
#endif
|
||||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
#include DCM_EXTERNAL_STATE_INCLUDE_008
|
||||
DCM_EXTERNAL_STATE_008( Solver )
|
||||
#endif
|
|
@ -49,6 +49,9 @@
|
|||
#define DCM_EXTERNAL_CORE_INCLUDE_01 "opendcm/core/imp/system_imp.hpp"
|
||||
#define DCM_EXTERNAL_CORE_01( Sys )\
|
||||
template class dcm::System<Sys::Kernel, Sys::Module1, Sys::Module2, Sys::Module3>; \
|
||||
template struct dcm::Equation<dcm::Distance, mpl::vector2<double, dcm::SolutionSpace>, 1>; \
|
||||
template struct dcm::Equation<dcm::Orientation, dcm::Direction, 2, dcm::rotation>; \
|
||||
template struct dcm::Equation<dcm::Angle, mpl::vector2<double, dcm::SolutionSpace>, 3, dcm::rotation>;
|
||||
|
||||
#endif //external
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ struct seq_has_option {
|
|||
typedef typename mpl::not_<boost::is_same<typename mpl::find<bool_seq, mpl::true_>::type, mpl::end<bool_seq> > >::type type;
|
||||
};
|
||||
|
||||
template<typename seq>
|
||||
template<typename seq, typename Derived>
|
||||
struct constraint_sequence : public seq {
|
||||
|
||||
template<typename T>
|
||||
|
@ -118,12 +118,12 @@ struct constraint_sequence : public seq {
|
|||
//we also allow to set values directly into the equation, as this makes it more compftable for multi constraints
|
||||
//as align. Note that this only works if all option types of all equations in this sequence are distinguishable
|
||||
template<typename T>
|
||||
typename boost::enable_if<typename seq_has_option<seq, T>::type, constraint_sequence<seq>&>::type
|
||||
typename boost::enable_if<typename seq_has_option<seq, T>::type, Derived&>::type
|
||||
operator=(const T& val) {
|
||||
|
||||
fusion::filter_view<constraint_sequence, has_option<mpl::_, T > > view(*this);
|
||||
fusion::front(view) = val;
|
||||
return *this;
|
||||
return *((Derived*)this);
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -193,7 +193,7 @@ struct Equation : public EQ {
|
|||
*/
|
||||
|
||||
//set default option values, neeeded for repedability and to prevent unexpected behaviour
|
||||
virtual void setDefault() = 0;
|
||||
virtual void setDefault() {};
|
||||
};
|
||||
|
||||
template <typename charT, typename traits, typename Eq>
|
||||
|
|
|
@ -182,12 +182,6 @@ Equation<Derived, Option, id, a>::operator &(T& val) {
|
|||
};
|
||||
*/
|
||||
|
||||
template<typename Derived, typename Option, int id, AccessType a >
|
||||
void Equation<Derived, Option, id, a>::setDefault() {
|
||||
fusion::at_key<double>(values) = std::make_pair(false, 0.);
|
||||
fusion::at_key<SolutionSpace>(values) = std::make_pair(false, bidirectional);
|
||||
};
|
||||
|
||||
//convinience stream functions for debugging
|
||||
template <typename charT, typename traits>
|
||||
struct print_pair {
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define DCM_KERNEL_IMP_H
|
||||
|
||||
#include "../kernel.hpp"
|
||||
#include <Base/Console.h>
|
||||
#include <boost/math/special_functions.hpp>
|
||||
#include <Eigen/QR>
|
||||
|
||||
|
|
|
@ -88,50 +88,6 @@ void System<KernelType, T1, T2, T3>::clear() {
|
|||
fusion::for_each(*m_storage, clearer());
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
typename std::vector< boost::shared_ptr<Object> >::iterator System<KernelType, T1, T2, T3>::begin() {
|
||||
|
||||
typedef typename mpl::find<objects, Object>::type iterator;
|
||||
typedef typename mpl::distance<typename mpl::begin<objects>::type, iterator>::type distance;
|
||||
BOOST_MPL_ASSERT((mpl::not_<boost::is_same<iterator, typename mpl::end<objects>::type > >));
|
||||
return fusion::at<distance>(*m_storage).begin();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
typename std::vector< boost::shared_ptr<Object> >::iterator System<KernelType, T1, T2, T3>::end() {
|
||||
|
||||
typedef typename mpl::find<objects, Object>::type iterator;
|
||||
typedef typename mpl::distance<typename mpl::begin<objects>::type, iterator>::type distance;
|
||||
BOOST_MPL_ASSERT((mpl::not_<boost::is_same<iterator, typename mpl::end<objects>::type > >));
|
||||
return fusion::at<distance>(*m_storage).end();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
std::vector< boost::shared_ptr<Object> >& System<KernelType, T1, T2, T3>::objectVector() {
|
||||
|
||||
typedef typename mpl::find<objects, Object>::type iterator;
|
||||
typedef typename mpl::distance<typename mpl::begin<objects>::type, iterator>::type distance;
|
||||
BOOST_MPL_ASSERT((mpl::not_<boost::is_same<iterator, typename mpl::end<objects>::type > >));
|
||||
return fusion::at<distance>(*m_storage);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
void System<KernelType, T1, T2, T3>::push_back(boost::shared_ptr<Object> ptr) {
|
||||
objectVector<Object>().push_back(ptr);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
void System<KernelType, T1, T2, T3>::erase(boost::shared_ptr<Object> ptr) {
|
||||
|
||||
std::vector< boost::shared_ptr<Object> >& vec = objectVector<Object>();
|
||||
vec.erase(std::remove(vec.begin(), vec.end(), ptr), vec.end());
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
SolverInfo System<KernelType, T1, T2, T3>::solve() {
|
||||
clock_t start = clock();
|
||||
|
@ -180,45 +136,6 @@ typename std::vector<boost::shared_ptr<System<KernelType, T1, T2, T3> > >::itera
|
|||
return m_subsystems.end();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::enable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, typename Option::type& >::type
|
||||
System<KernelType, T1, T2, T3>::getOption() {
|
||||
return m_options->template getProperty<Option>();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::disable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, typename Option::type& >::type
|
||||
System<KernelType, T1, T2, T3>::getOption() {
|
||||
return m_kernel.template getProperty<Option>();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::enable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, void >::type
|
||||
System<KernelType, T1, T2, T3>::setOption(typename Option::type value) {
|
||||
m_options->template setProperty<Option>(value);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::disable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, void >::type
|
||||
System<KernelType, T1, T2, T3>::setOption(typename Option::type value) {
|
||||
m_kernel.template setProperty<Option>(value);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename Option::type&
|
||||
System<KernelType, T1, T2, T3>::option() {
|
||||
return getOption<Option>();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
KernelType& System<KernelType, T1, T2, T3>::kernel() {
|
||||
return m_kernel;
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/mpl/less_equal.hpp>
|
||||
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#include "property.hpp"
|
||||
#include "clustergraph.hpp"
|
||||
#include "sheduler.hpp"
|
||||
|
@ -283,6 +285,92 @@ public:
|
|||
std::vector<boost::shared_ptr<System> > m_subsystems;
|
||||
};
|
||||
|
||||
//implementations which always need to be with the definition as they can't be externalised
|
||||
//*****************************************************************************************
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
typename std::vector< boost::shared_ptr<Object> >::iterator System<KernelType, T1, T2, T3>::begin() {
|
||||
|
||||
typedef typename mpl::find<objects, Object>::type iterator;
|
||||
typedef typename mpl::distance<typename mpl::begin<objects>::type, iterator>::type distance;
|
||||
BOOST_MPL_ASSERT((mpl::not_<boost::is_same<iterator, typename mpl::end<objects>::type > >));
|
||||
return fusion::at<distance>(*m_storage).begin();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
typename std::vector< boost::shared_ptr<Object> >::iterator System<KernelType, T1, T2, T3>::end() {
|
||||
|
||||
typedef typename mpl::find<objects, Object>::type iterator;
|
||||
typedef typename mpl::distance<typename mpl::begin<objects>::type, iterator>::type distance;
|
||||
BOOST_MPL_ASSERT((mpl::not_<boost::is_same<iterator, typename mpl::end<objects>::type > >));
|
||||
return fusion::at<distance>(*m_storage).end();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
std::vector< boost::shared_ptr<Object> >& System<KernelType, T1, T2, T3>::objectVector() {
|
||||
|
||||
typedef typename mpl::find<objects, Object>::type iterator;
|
||||
typedef typename mpl::distance<typename mpl::begin<objects>::type, iterator>::type distance;
|
||||
BOOST_MPL_ASSERT((mpl::not_<boost::is_same<iterator, typename mpl::end<objects>::type > >));
|
||||
return fusion::at<distance>(*m_storage);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
void System<KernelType, T1, T2, T3>::push_back(boost::shared_ptr<Object> ptr) {
|
||||
objectVector<Object>().push_back(ptr);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Object>
|
||||
void System<KernelType, T1, T2, T3>::erase(boost::shared_ptr<Object> ptr) {
|
||||
|
||||
std::vector< boost::shared_ptr<Object> >& vec = objectVector<Object>();
|
||||
vec.erase(std::remove(vec.begin(), vec.end(), ptr), vec.end());
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::enable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, typename Option::type& >::type
|
||||
System<KernelType, T1, T2, T3>::getOption() {
|
||||
return m_options->template getProperty<Option>();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::disable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, typename Option::type& >::type
|
||||
System<KernelType, T1, T2, T3>::getOption() {
|
||||
return m_kernel.template getProperty<Option>();
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::enable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, void >::type
|
||||
System<KernelType, T1, T2, T3>::setOption(typename Option::type value) {
|
||||
m_options->template setProperty<Option>(value);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename boost::disable_if< boost::is_same< typename mpl::find<typename KernelType::PropertySequence, Option>::type,
|
||||
typename mpl::end<typename KernelType::PropertySequence>::type >, void >::type
|
||||
System<KernelType, T1, T2, T3>::setOption(typename Option::type value) {
|
||||
m_kernel.template setProperty<Option>(value);
|
||||
};
|
||||
|
||||
template< typename KernelType, typename T1, typename T2, typename T3 >
|
||||
template<typename Option>
|
||||
typename Option::type&
|
||||
System<KernelType, T1, T2, T3>::option() {
|
||||
return getOption<Option>();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifndef DCM_EXTERNAL_CORE
|
||||
|
|
|
@ -155,9 +155,9 @@ std::basic_ostream<charT,traits>& operator<<(std::basic_ostream<charT,traits>& o
|
|||
}//detail
|
||||
}//DCM
|
||||
|
||||
#ifndef DCM_EXTERNAL_CORE
|
||||
//#ifndef DCM_EXTERNAL_CORE
|
||||
#include "imp/transformation_imp.hpp"
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
#endif //DCM_TRANSFORMATION
|
||||
|
|
|
@ -120,7 +120,7 @@ struct al_orientation::type< Kernel, tag::cylinder3D, tag::cylinder3D > : public
|
|||
|
||||
//use al_orientation to ensure the correct orientations for alignment (distance is only defined for special
|
||||
//orientations)
|
||||
struct Alignment : public constraint_sequence< fusion::vector2< Distance, details::al_orientation > > {
|
||||
struct Alignment : public constraint_sequence< fusion::vector2< Distance, details::al_orientation >, Alignment > {
|
||||
|
||||
using constraint_sequence::operator=;
|
||||
};
|
||||
|
|
|
@ -278,7 +278,7 @@ struct ci_distance::type< Kernel, tag::cylinder3D, tag::cylinder3D > : public dc
|
|||
|
||||
}//details
|
||||
|
||||
struct Coincidence : public dcm::constraint_sequence< fusion::vector2< details::ci_distance, details::ci_orientation > > {
|
||||
struct Coincidence : public dcm::constraint_sequence< fusion::vector2< details::ci_distance, details::ci_orientation >, Coincidence > {
|
||||
//allow to set the distance
|
||||
Coincidence& operator()(Direction val) {
|
||||
fusion::at_c<1>(*this) = val;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "geometry.hpp"
|
||||
#include <opendcm/core/constraint.hpp>
|
||||
#include <boost/fusion/include/copy.hpp>
|
||||
#include <boost/math/special_functions.hpp>
|
||||
|
||||
namespace dcm {
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <boost/phoenix/fusion/at.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/greater.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
||||
namespace karma_ascii = boost::spirit::karma::ascii;
|
||||
namespace qi_ascii = boost::spirit::qi::ascii;
|
||||
|
@ -56,17 +57,23 @@ struct geom_visitor : public boost::static_visitor<std::string> {
|
|||
//we use stings in case new geometry gets added and the weights shift, meaning: backwards
|
||||
//compatible
|
||||
std::string type;
|
||||
|
||||
switch(geometry_traits<T>::tag::weight::value) {
|
||||
case tag::weight::direction::value :
|
||||
return "direction";
|
||||
|
||||
case tag::weight::point::value :
|
||||
return "point";
|
||||
|
||||
case tag::weight::line::value :
|
||||
return "line";
|
||||
|
||||
case tag::weight::plane::value :
|
||||
return "plane";
|
||||
|
||||
case tag::weight::cylinder::value :
|
||||
return "cylinder";
|
||||
|
||||
default:
|
||||
return "unknown";
|
||||
};
|
||||
|
@ -91,8 +98,8 @@ struct getWeightType {
|
|||
typedef typename mpl::if_< boost::is_same<iter, typename mpl::end<Vector>::type >, mpl::void_, typename mpl::deref<iter>::type>::type type;
|
||||
};
|
||||
|
||||
typedef std::vector< fusion::vector2<std::string, std::string> > string_vec;
|
||||
typedef std::vector< fusion::vector2<std::vector<char>, std::vector<char> > > char_vec;
|
||||
typedef std::vector< fusion::vector2<std::string, std::vector<double> > > string_vec;
|
||||
typedef std::vector< fusion::vector2<std::vector<char>, std::vector<double> > > char_vec;
|
||||
|
||||
template<typename C>
|
||||
string_vec getConstraints(boost::shared_ptr<C> con) {
|
||||
|
@ -100,35 +107,65 @@ string_vec getConstraints(boost::shared_ptr<C> con) {
|
|||
string_vec vec;
|
||||
std::vector<boost::any> cvec = con->getGenericConstraints();
|
||||
|
||||
boost::any al_o, d;
|
||||
typename std::vector<boost::any>::iterator it;
|
||||
for(it = cvec.begin(); it != cvec.end(); it++) {
|
||||
|
||||
if(cvec.size()==1) {
|
||||
it = cvec.begin();
|
||||
|
||||
if((*it).type() == typeid(dcm::Distance)) {
|
||||
double v = fusion::at_key<double>(boost::any_cast<dcm::Distance>(*it).values).second;
|
||||
std::string value = boost::lexical_cast<std::string>(v);
|
||||
vec.push_back(fusion::make_vector(std::string("Distance"), value));
|
||||
SolutionSpace s = fusion::at_key<SolutionSpace>(boost::any_cast<dcm::Distance>(*it).values).second;
|
||||
std::vector<double> dvec;
|
||||
dvec.push_back(v);
|
||||
dvec.push_back(s);
|
||||
vec.push_back(fusion::make_vector(std::string("Distance"), dvec));
|
||||
}
|
||||
else if((*it).type() == typeid(dcm::Angle)) {
|
||||
double v = fusion::at_key<double>(boost::any_cast<dcm::Angle>(*it).values).second;
|
||||
std::string value = boost::lexical_cast<std::string>(v);
|
||||
std::vector<double> value;
|
||||
value.push_back(v);
|
||||
vec.push_back(fusion::make_vector(std::string("Angle"), value));
|
||||
}
|
||||
else if((*it).type() == typeid(dcm::Orientation)) {
|
||||
int v = fusion::at_key<dcm::Direction>(boost::any_cast<dcm::Orientation>(*it).values).second;
|
||||
std::string value = boost::lexical_cast<std::string>(v);
|
||||
std::vector<double> value;
|
||||
value.push_back(v);
|
||||
vec.push_back(fusion::make_vector(std::string("Orientation"), value));
|
||||
}
|
||||
else if((*it).type() == typeid(dcm::details::ci_orientation)) {
|
||||
int v = fusion::at_key<dcm::Direction>(boost::any_cast<dcm::details::ci_orientation>(*it).values).second;
|
||||
std::string value = boost::lexical_cast<std::string>(v);
|
||||
vec.push_back(fusion::make_vector(std::string("Coincidence"), value));
|
||||
}
|
||||
else {
|
||||
for(it=cvec.begin(); it!=cvec.end(); it++) {
|
||||
if((*it).type() == typeid(dcm::details::ci_orientation)) {
|
||||
int v = fusion::at_key<dcm::Direction>(boost::any_cast<dcm::details::ci_orientation>(*it).values).second;
|
||||
std::vector<double> value;
|
||||
value.push_back(v);
|
||||
vec.push_back(fusion::make_vector(std::string("Coincidence"), value));
|
||||
}
|
||||
else if((*it).type() == typeid(dcm::details::al_orientation)) {
|
||||
int o = fusion::at_key<dcm::Direction>(boost::any_cast<dcm::details::al_orientation>(*it).values).second;
|
||||
|
||||
double v;
|
||||
SolutionSpace s;
|
||||
|
||||
if(it==cvec.begin()) {
|
||||
v = fusion::at_key<double>(boost::any_cast<dcm::Distance>(cvec.back()).values).second;
|
||||
s = fusion::at_key<SolutionSpace>(boost::any_cast<dcm::Distance>(cvec.back()).values).second;
|
||||
}
|
||||
else {
|
||||
v = fusion::at_key<double>(boost::any_cast<dcm::Distance>(cvec.front()).values).second;
|
||||
s = fusion::at_key<SolutionSpace>(boost::any_cast<dcm::Distance>(cvec.front()).values).second;
|
||||
}
|
||||
|
||||
std::vector<double> value;
|
||||
value.push_back(o);
|
||||
value.push_back(v);
|
||||
value.push_back(s);
|
||||
vec.push_back(fusion::make_vector(std::string("Alignment"), value));
|
||||
};
|
||||
}
|
||||
else if((*it).type() == typeid(dcm::details::al_orientation)) {
|
||||
int v = fusion::at_key<dcm::Direction>(boost::any_cast<dcm::details::al_orientation>(*it).values).second;
|
||||
std::string value = boost::lexical_cast<std::string>(v);
|
||||
vec.push_back(fusion::make_vector(std::string("Alignment"), value));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
return vec;
|
||||
};
|
||||
|
||||
|
@ -138,40 +175,35 @@ void constraintCreation(typename char_vec::iterator it,
|
|||
boost::shared_ptr<C> con) {
|
||||
|
||||
std::string first(fusion::at_c<0>(*it).begin(), fusion::at_c<0>(*it).end());
|
||||
std::string second(fusion::at_c<1>(*it).begin(), fusion::at_c<1>(*it).end());
|
||||
std::vector<double> second = fusion::at_c<1>(*it);
|
||||
|
||||
if(first.compare("Distance") == 0) {
|
||||
double v = boost::lexical_cast<double>(second);
|
||||
typename details::fusion_vec<dcm::Distance>::type val;
|
||||
fusion::front(val)=v;
|
||||
typename details::fusion_vec<dcm::Distance>::type val;
|
||||
(fusion::front(val)=second[0])= (SolutionSpace)second[1];
|
||||
con->template initialize(val);
|
||||
return;
|
||||
}
|
||||
else if(first.compare("Orientation") == 0) {
|
||||
dcm::Direction v = (dcm::Direction)boost::lexical_cast<int>(second);
|
||||
typename details::fusion_vec<dcm::Orientation>::type val;
|
||||
fusion::front(val)=v;
|
||||
typename details::fusion_vec<dcm::Orientation>::type val;
|
||||
fusion::front(val)= (dcm::Direction)second[0];
|
||||
con->template initialize(val);
|
||||
return;
|
||||
}
|
||||
else if(first.compare("Angle") == 0) {
|
||||
double v = boost::lexical_cast<double>(second);
|
||||
typename details::fusion_vec<dcm::Angle>::type val;
|
||||
fusion::front(val)=v;
|
||||
typename details::fusion_vec<dcm::Angle>::type val;
|
||||
fusion::front(val)=second[0];
|
||||
con->template initialize(val);
|
||||
return;
|
||||
}
|
||||
else if(first.compare("Coincidence") == 0) {
|
||||
dcm::Direction v = (dcm::Direction)boost::lexical_cast<int>(second);
|
||||
typename details::fusion_vec<dcm::Coincidence>::type val;
|
||||
val=v;
|
||||
typename details::fusion_vec<dcm::Coincidence>::type val;
|
||||
val= (dcm::Direction)second[0];
|
||||
con->template initialize(val);
|
||||
return;
|
||||
}
|
||||
else if(first.compare("Alignment") == 0) {
|
||||
double v = boost::lexical_cast<double>(second);
|
||||
typename details::fusion_vec<dcm::Alignment>::type val;
|
||||
val=v;
|
||||
typename details::fusion_vec<dcm::Alignment>::type val;
|
||||
((val=(dcm::Direction)second[0])=second[1])=(dcm::SolutionSpace)second[2];
|
||||
con->template initialize(val);
|
||||
return;
|
||||
}
|
||||
|
@ -190,6 +222,7 @@ bool VectorOutput(Geom& v, Row& r, Value& val) {
|
|||
val = v->m_global(r++);
|
||||
return true; // output continues
|
||||
}
|
||||
|
||||
return false; // fail the output
|
||||
};
|
||||
|
||||
|
@ -244,6 +277,7 @@ bool Create(System* sys, std::string& type,
|
|||
else if(type.compare("cylinder") == 0) {
|
||||
inject_set<typename getWeightType<Typelist, tag::weight::cylinder>::type>::apply(v, geom);
|
||||
};
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -304,7 +338,7 @@ void parser_generator< typename details::getModule3D<System>::type::Constraint3D
|
|||
r = karma::lit("<type>Constraint3D</type>") << karma::eol
|
||||
<< "<connect first=" << karma::int_[karma::_1 = phx::at_c<1>(phx::bind(&Constraint3D::template getProperty<edge_prop>, karma::_val))]
|
||||
<< " second=" << karma::int_[karma::_1 = phx::at_c<2>(phx::bind(&Constraint3D::template getProperty<edge_prop>, karma::_val))] << "></connect>"
|
||||
<< (*(karma::eol<<"<constraint type="<<karma_ascii::string<<">"<<karma_ascii::string<<"</constraint>"))[karma::_1 = phx::bind(&details::getConstraints<Constraint3D>, karma::_val)];
|
||||
<< (*(karma::eol<<"<constraint type="<<karma_ascii::string<<">"<<*(karma::double_<<" ")<<"</constraint>"))[karma::_1 = phx::bind(&details::getConstraints<Constraint3D>, karma::_val)];
|
||||
};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
|
@ -350,7 +384,7 @@ void parser_parser< typename details::getModule3D<System>::type::Constraint3D, S
|
|||
phx::bind(&System::Cluster::template getObject<Geometry3D, GlobalVertex>, phx::bind(&System::m_cluster, qi::_r1), qi::_1),
|
||||
phx::bind(&System::Cluster::template getObject<Geometry3D, GlobalVertex>, phx::bind(&System::m_cluster, qi::_r1), qi::_2)))
|
||||
]
|
||||
>> (*("<constraint type=" >> *qi_ascii::alpha >> ">" >> *qi_ascii::alnum >>"</constraint>"))[phx::bind(&details::setConstraints<Constraint3D>, qi::_1, qi::_val)];
|
||||
>> (*("<constraint type=" >> *qi_ascii::alpha >> ">" >> *qi::double_ >>"</constraint>"))[phx::bind(&details::setConstraints<Constraint3D>, qi::_1, qi::_val)];
|
||||
};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
|
|
|
@ -61,7 +61,7 @@ struct t1 {
|
|||
BOOST_FUSION_ADAPT_TPL_STRUCT(
|
||||
(Kernel)(M1)(M2)(M3),
|
||||
(dcm::System)(Kernel)(M1)(M2)(M3),
|
||||
(typename t1<Kernel>::template t2<M1>::template t3<M2>::template t4<M3>::type::OptionOwner::Properties, m_options.m_properties)
|
||||
(typename t1<Kernel>::template t2<M1>::template t3<M2>::template t4<M3>::type::OptionOwner::Properties, m_options->m_properties)
|
||||
(typename Kernel::Properties, m_kernel.m_properties)
|
||||
(boost::shared_ptr<typename t1<Kernel>::template t2<M1>::template t3<M2>::template t4<M3>::type::Cluster>, m_cluster)
|
||||
)
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#ifndef DCM_EDGE_GENERATOR_IMP_H
|
||||
#define DCM_EDGE_GENERATOR_IMP_H
|
||||
|
||||
#include "edge_vertex_generator.hpp"
|
||||
#include "boost/phoenix/fusion/at.hpp"
|
||||
|
||||
namespace dcm {
|
||||
namespace details {
|
||||
|
||||
template<typename Sys>
|
||||
edge_generator<Sys>::edge_generator() : edge_generator<Sys>::base_type(edge_range) {
|
||||
|
||||
globaledge = karma::int_[phx::bind(&Extractor<Sys>::getGlobalEdgeID, &ex, karma::_val, karma::_1)]
|
||||
<< " source=" << karma::int_[phx::bind(&Extractor<Sys>::getGlobalEdgeSource, &ex, karma::_val, karma::_1)]
|
||||
<< " target=" << karma::int_[phx::bind(&Extractor<Sys>::getGlobalEdgeTarget, &ex, karma::_val, karma::_1)] << '>'
|
||||
<< "+" << objects[karma::_1 = phx::at_c<0>(karma::_val)] << "-\n" ;
|
||||
|
||||
|
||||
globaledge_range = *(karma::lit("<GlobalEdge id=")<<globaledge<<karma::lit("</GlobalEdge>"));
|
||||
|
||||
edge = karma::lit("source=")<<karma::int_[karma::_1 = phx::at_c<1>(karma::_val)] << " target="<<karma::int_[karma::_1 = phx::at_c<2>(karma::_val)] << ">+"
|
||||
<< edge_prop[karma::_1 = phx::at_c<0>(phx::at_c<0>(karma::_val))]
|
||||
<< karma::eol << globaledge_range[karma::_1 = phx::at_c<1>(phx::at_c<0>(karma::_val))] << '-' << karma::eol;
|
||||
|
||||
edge_range = (karma::lit("<Edge ") << edge << karma::lit("</Edge>")) % karma::eol;
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
vertex_generator<Sys>::vertex_generator() : vertex_generator<Sys>::base_type(vertex_range) {
|
||||
|
||||
vertex = karma::int_ << ">+" << vertex_prop << objects << "-\n";
|
||||
|
||||
vertex_range = '\n' << (karma::lit("<Vertex id=") << vertex << karma::lit("</Vertex>")) % karma::eol;
|
||||
};
|
||||
|
||||
}//details
|
||||
}//dcm
|
||||
|
||||
#endif
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#ifndef DCM_EDGE_PARSER_IMP_H
|
||||
#define DCM_EDGE_PARSER_IMP_H
|
||||
|
||||
#include "edge_vertex_parser.hpp"
|
||||
#include "boost/phoenix/fusion/at.hpp"
|
||||
|
||||
namespace dcm {
|
||||
namespace details {
|
||||
|
||||
template<typename Sys>
|
||||
edge_parser<Sys>::edge_parser() : edge_parser<Sys>::base_type(edge) {
|
||||
|
||||
global_edge = qi::lit("<GlobalEdge") >> qi::lit("id=") >> qi::int_[phx::bind(&GlobalEdge::ID, phx::at_c<1>(qi::_val)) = qi::_1]
|
||||
>> qi::lit("source=") >> qi::int_[phx::bind(&GlobalEdge::source, phx::at_c<1>(qi::_val)) = qi::_1]
|
||||
>> qi::lit("target=") >> qi::int_[phx::bind(&GlobalEdge::target, phx::at_c<1>(qi::_val)) = qi::_1] >> '>'
|
||||
>> objects(qi::_r1)[phx::at_c<0>(qi::_val) = qi::_1] >> "</GlobalEdge>";
|
||||
|
||||
edge = (qi::lit("<Edge") >> "source=" >> qi::int_ >> "target=" >> qi::int_ >> '>')[qi::_val = phx::bind((&Sys::Cluster::addEdgeGlobal), qi::_r1, qi::_1, qi::_2)]
|
||||
>> edge_prop[phx::bind(&Injector<Sys>::setEdgeProperties, &in, qi::_r1, phx::at_c<0>(qi::_val), qi::_1)]
|
||||
>> (*global_edge(qi::_r2))[phx::bind(&Injector<Sys>::setEdgeBundles, &in, qi::_r1, phx::at_c<0>(qi::_val), qi::_1)]
|
||||
>> ("</Edge>");
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
vertex_parser<Sys>::vertex_parser() : vertex_parser<Sys>::base_type(vertex) {
|
||||
|
||||
vertex = qi::lit("<Vertex")[phx::bind(&Injector<Sys>::addVertex, &in, qi::_r1, qi::_val)] >> qi::lit("id=")
|
||||
>> qi::int_[phx::at_c<1>(qi::_val) = phx::bind(&Sys::Cluster::setGlobalVertex, qi::_r1, phx::at_c<0>(qi::_val), qi::_1)]
|
||||
>> '>' >> prop[phx::bind(&Injector<Sys>::setVertexProperties, &in, qi::_r1, phx::at_c<0>(qi::_val), qi::_1)]
|
||||
>> objects(qi::_r2)[phx::bind(&Injector<Sys>::setVertexObjects, &in, qi::_r1, phx::at_c<0>(qi::_val), qi::_1)]
|
||||
>> ("</Vertex>");
|
||||
};
|
||||
|
||||
}//details
|
||||
}//dcm
|
||||
|
||||
#endif
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#ifndef DCM_GENERATOR_IMP_H
|
||||
#define DCM_GENERATOR_IMP_H
|
||||
|
||||
#include "generator.hpp"
|
||||
#include "opendcm/core/clustergraph.hpp"
|
||||
|
||||
#include <boost/fusion/include/std_pair.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
|
||||
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT(
|
||||
(T1)(T2)(T3)(T4),
|
||||
(dcm::ClusterGraph) (T1)(T2)(T3)(T4),
|
||||
(int, test)
|
||||
(typename dcm::details::pts<T3>::type, m_properties))
|
||||
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct transform_attribute<dcm::ClusterGraph<T1,T2,T3,T4>* const, dcm::ClusterGraph<T1,T2,T3,T4>&, karma::domain>
|
||||
{
|
||||
typedef dcm::ClusterGraph<T1,T2,T3,T4>& type;
|
||||
static type pre(dcm::ClusterGraph<T1,T2,T3,T4>* const& val) {
|
||||
return *val;
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace dcm {
|
||||
|
||||
template<typename Sys>
|
||||
generator<Sys>::generator() : generator<Sys>::base_type(start) {
|
||||
|
||||
cluster %= karma::omit[karma::int_] << cluster_prop
|
||||
<< -karma::buffer[karma::eol << (cluster_pair % karma::eol)[phx::bind(&Extractor<Sys>::getClusterRange, &ex, karma::_val, karma::_1)]]
|
||||
<< -vertex_range[phx::bind(&Extractor<Sys>::getVertexRange, &ex, karma::_val, karma::_1)]
|
||||
<< -karma::buffer[karma::eol << edge_range[phx::bind(&Extractor<Sys>::getEdgeRange, &ex, karma::_val, karma::_1)]]
|
||||
<< "-" << karma::eol
|
||||
<< karma::lit("</Cluster>");
|
||||
|
||||
cluster_pair %= karma::lit("<Cluster id=") << karma::int_ << ">+"
|
||||
<< karma::attr_cast<graph*,graph&>(cluster);
|
||||
|
||||
start %= karma::lit("<Cluster id=0>+") << cluster;
|
||||
};
|
||||
|
||||
}//namespace dcm
|
||||
|
||||
#endif //DCM_GENERATOR_H
|
||||
|
||||
|
||||
|
|
@ -43,7 +43,6 @@ typename boost::enable_if<mpl::less< dist, mpl::size<srs> >, void >::type recurs
|
|||
template<typename srs, typename prs, typename dist>
|
||||
typename boost::disable_if<mpl::less< dist, mpl::size<srs> >, void >::type recursive_obj_init(srs& sseq, prs& pseq) {};
|
||||
|
||||
|
||||
template<typename Sys, typename ObjList, typename Object, typename Par>
|
||||
obj_parser<Sys, ObjList, Object, Par>::obj_parser(): obj_parser::base_type(start) {
|
||||
|
||||
|
@ -61,6 +60,17 @@ void obj_parser<Sys, ObjList, Object, Par>::setProperties(boost::shared_ptr<Obje
|
|||
if(ptr) ptr->m_properties = seq;
|
||||
};
|
||||
|
||||
template<typename ParentRuleSequence, typename Rule>
|
||||
typename boost::disable_if<typename fusion::result_of::empty<ParentRuleSequence>::type, void>::type
|
||||
initalizeLastObjRule(ParentRuleSequence& pr, Rule& r) {
|
||||
r = *(fusion::back(pr)(&qi::_val, qi::_r1));
|
||||
};
|
||||
|
||||
template<typename ParentRuleSequence, typename Rule>
|
||||
typename boost::enable_if<typename fusion::result_of::empty<ParentRuleSequence>::type, void>::type
|
||||
initalizeLastObjRule(ParentRuleSequence& pr, Rule& r) {};
|
||||
|
||||
|
||||
template<typename Sys>
|
||||
obj_par<Sys>::obj_par(): obj_par<Sys>::base_type(obj) {
|
||||
|
||||
|
@ -68,7 +78,7 @@ obj_par<Sys>::obj_par(): obj_par<Sys>::base_type(obj) {
|
|||
typename fusion::result_of::as_vector<parent_rules_sequence>::type,
|
||||
mpl::int_<0> >(sub_rules, parent_rules);
|
||||
|
||||
obj = *(fusion::back(parent_rules)(&qi::_val, qi::_r1));
|
||||
initalizeLastObjRule(parent_rules, obj);
|
||||
};
|
||||
|
||||
}//details
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
#ifndef DCM_OBJECT_GENERATOR_IMP_H
|
||||
#define DCM_OBJECT_GENERATOR_IMP_H
|
||||
|
||||
|
||||
#include "traits_impl.hpp"
|
||||
#include "object_generator.hpp"
|
||||
#include "property_generator_imp.hpp"
|
||||
|
||||
#include "boost/phoenix/fusion/at.hpp"
|
||||
|
||||
using namespace boost::spirit::karma;
|
||||
namespace karma = boost::spirit::karma;
|
||||
namespace phx = boost::phoenix;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
namespace dcm {
|
||||
|
||||
typedef std::ostream_iterator<char> Iterator;
|
||||
|
||||
|
||||
namespace details {
|
||||
|
||||
template<typename Sys, typename Object, typename Gen>
|
||||
obj_grammar<Sys, Object,Gen>::obj_grammar() : obj_grammar<Sys, Object,Gen>::base_type(start) {
|
||||
Gen::init(subrule);
|
||||
start = lit("\n<Object>") << '+' << eol << subrule
|
||||
<< prop[phx::bind(&obj_grammar::getProperties, _val, karma::_1)]
|
||||
<< '-' << eol << lit("</Object>");
|
||||
};
|
||||
|
||||
template<typename Sys, typename Object, typename Gen>
|
||||
void obj_grammar<Sys, Object,Gen>::getProperties(boost::shared_ptr<Object> ptr, typename details::pts<typename Object::PropertySequence>::type& seq) {
|
||||
|
||||
if(ptr) seq = ptr->m_properties;
|
||||
else {
|
||||
//TODO: throw
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
obj_gen<Sys>::obj_gen() : obj_gen<Sys>::base_type(obj) {
|
||||
|
||||
obj = -(eps(valid<0>::value) << eps(phx::at_c<index<0>::value>(_val)) << fusion::at<index<0> >(rules)[karma::_1 = phx::at_c<index<0>::value>(_val)])
|
||||
<< -(eps(valid<1>::value) << eps(phx::at_c<index<1>::value>(_val)) << fusion::at<index<1> >(rules)[karma::_1 = phx::at_c<index<1>::value>(_val)])
|
||||
<< -(eps(valid<2>::value) << eps(phx::at_c<index<2>::value>(_val)) << fusion::at<index<2> >(rules)[karma::_1 = phx::at_c<index<2>::value>(_val)])
|
||||
<< -(eps(valid<3>::value) << eps(phx::at_c<index<3>::value>(_val)) << fusion::at<index<3> >(rules)[karma::_1 = phx::at_c<index<3>::value>(_val)])
|
||||
<< -(eps(valid<4>::value) << eps(phx::at_c<index<4>::value>(_val)) << fusion::at<index<4> >(rules)[karma::_1 = phx::at_c<index<4>::value>(_val)])
|
||||
<< -(eps(valid<5>::value) << eps(phx::at_c<index<5>::value>(_val)) << fusion::at<index<5> >(rules)[karma::_1 = phx::at_c<index<5>::value>(_val)])
|
||||
<< -(eps(valid<6>::value) << eps(phx::at_c<index<6>::value>(_val)) << fusion::at<index<6> >(rules)[karma::_1 = phx::at_c<index<6>::value>(_val)])
|
||||
<< -(eps(valid<7>::value) << eps(phx::at_c<index<7>::value>(_val)) << fusion::at<index<7> >(rules)[karma::_1 = phx::at_c<index<7>::value>(_val)])
|
||||
<< -(eps(valid<8>::value) << eps(phx::at_c<index<8>::value>(_val)) << fusion::at<index<8> >(rules)[karma::_1 = phx::at_c<index<8>::value>(_val)])
|
||||
<< -(eps(valid<9>::value) << eps(phx::at_c<index<9>::value>(_val)) << fusion::at<index<9> >(rules)[karma::_1 = phx::at_c<index<9>::value>(_val)]);
|
||||
|
||||
};
|
||||
|
||||
} //namespace details
|
||||
}//dcm
|
||||
|
||||
#endif //DCM_OBJECT_GENERATOR_H
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#ifndef DCM_OBJECT_PARSER_IMP_H
|
||||
#define DCM_OBJECT_PARSER_IMP_H
|
||||
|
||||
#include "object_parser.hpp"
|
||||
#include "property_parser_imp.hpp"
|
||||
#include "boost/phoenix/fusion/at.hpp"
|
||||
|
||||
namespace dcm {
|
||||
namespace details {
|
||||
|
||||
template<typename srs, typename prs, typename dist>
|
||||
typename boost::enable_if<mpl::less< dist, mpl::size<srs> >, void >::type recursive_obj_init( srs& sseq, prs& pseq ) {
|
||||
|
||||
if(dist::value == 0) {
|
||||
fusion::at<dist>(pseq) %= fusion::at<dist>(sseq)(qi::_r1, qi::_r2);
|
||||
}
|
||||
else {
|
||||
fusion::at<dist>(pseq) %= fusion::at<typename mpl::prior< typename mpl::max<dist, mpl::int_<1> >::type >::type>(pseq)(qi::_r1, qi::_r2) | fusion::at<dist>(sseq)(qi::_r1, qi::_r2);
|
||||
}
|
||||
|
||||
recursive_obj_init<srs, prs, typename mpl::next<dist>::type>(sseq, pseq);
|
||||
};
|
||||
|
||||
template<typename srs, typename prs, typename dist>
|
||||
typename boost::disable_if<mpl::less< dist, mpl::size<srs> >, void >::type recursive_obj_init( srs& sseq, prs& pseq ){};
|
||||
|
||||
|
||||
template<typename Sys, typename ObjList, typename Object, typename Par>
|
||||
obj_parser<Sys, ObjList, Object, Par>::obj_parser(): obj_parser::base_type(start) {
|
||||
|
||||
typedef typename mpl::find<ObjList, Object>::type::pos pos;
|
||||
|
||||
Par::init(subrule);
|
||||
start = qi::lit("<Object>") >> subrule(qi::_r2)[phx::at_c<pos::value>(*qi::_r1) = qi::_1]
|
||||
>> qi::eps(phx::at_c<pos::value>(*qi::_r1))[ phx::bind(&Sys::template push_back<Object>, qi::_r2, phx::at_c<pos::value>(*qi::_r1))]
|
||||
>> prop[phx::bind(&obj_parser::setProperties, phx::at_c<pos::value>(*qi::_r1), qi::_1)]
|
||||
>> qi::lit("</Object>");
|
||||
};
|
||||
|
||||
template<typename Sys, typename ObjList, typename Object, typename Par>
|
||||
void obj_parser<Sys, ObjList, Object, Par>::setProperties(boost::shared_ptr<Object> ptr, typename details::pts<typename Object::PropertySequence>::type& seq) {
|
||||
if(ptr) ptr->m_properties = seq;
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
obj_par<Sys>::obj_par(): obj_par<Sys>::base_type(obj) {
|
||||
|
||||
recursive_obj_init<typename fusion::result_of::as_vector<sub_rules_sequence>::type,
|
||||
typename fusion::result_of::as_vector<parent_rules_sequence>::type,
|
||||
mpl::int_<0> >(sub_rules, parent_rules);
|
||||
|
||||
obj = *(fusion::back(parent_rules)(&qi::_val, qi::_r1));
|
||||
};
|
||||
|
||||
}//details
|
||||
}//DCM
|
||||
|
||||
|
||||
#endif
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#ifndef DCM_PARSER_IMP_H
|
||||
#define DCM_PARSER_IMP_H
|
||||
|
||||
#include <boost/spirit/include/qi_attr_cast.hpp>
|
||||
|
||||
#include "opendcm/core/system.hpp"
|
||||
|
||||
#include <boost/fusion/include/std_pair.hpp>
|
||||
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT(
|
||||
(T1)(T2)(T3)(T4),
|
||||
(dcm::ClusterGraph) (T1)(T2)(T3)(T4),
|
||||
(typename dcm::details::pts<T3>::type, m_properties))
|
||||
|
||||
#include "parser.hpp"
|
||||
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct transform_attribute<dcm::ClusterGraph<T1,T2,T3,T4>*, dcm::ClusterGraph<T1,T2,T3,T4>, qi::domain>
|
||||
{
|
||||
typedef dcm::ClusterGraph<T1,T2,T3,T4>& type;
|
||||
static type pre(dcm::ClusterGraph<T1,T2,T3,T4>* const& val) {
|
||||
return *val;
|
||||
}
|
||||
static void post(dcm::ClusterGraph<T1,T2,T3,T4>* const& val, dcm::ClusterGraph<T1,T2,T3,T4> const& attr) {}
|
||||
static void fail(dcm::ClusterGraph<T1,T2,T3,T4>* const&) {}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace dcm {
|
||||
|
||||
typedef boost::spirit::istream_iterator IIterator;
|
||||
|
||||
template<typename Sys>
|
||||
parser<Sys>::parser() : parser<Sys>::base_type(cluster) {
|
||||
|
||||
cluster %= qi::lit("<Cluster id=") >> qi::omit[qi::int_[qi::_a = qi::_1]] >> ">"
|
||||
>> -(qi::eps( qi::_a > 0 )[qi::_val = phx::new_<typename Sys::Cluster>()])
|
||||
>> qi::eps[phx::bind(&Sys::Cluster::setCopyMode, qi::_val, true)]
|
||||
>> qi::eps[phx::bind(&Injector<Sys>::setVertexProperty, &in, qi::_val, qi::_a)]
|
||||
>> qi::attr_cast<graph*, graph>(cluster_prop >> qi::eps)
|
||||
>> qi::omit[(*cluster(qi::_r1))[qi::_b = qi::_1]]
|
||||
>> qi::omit[*vertex(qi::_val, qi::_r1)]
|
||||
>> qi::omit[*edge(qi::_val, qi::_r1)]
|
||||
>> qi::eps[phx::bind(&Injector<Sys>::addClusters, &in, qi::_b, qi::_val)]
|
||||
>> qi::eps[phx::bind(&Sys::Cluster::setCopyMode, qi::_val, false)]
|
||||
>> "</Cluster>";// >> str[&sp::print];
|
||||
};
|
||||
|
||||
}
|
||||
#endif //DCM_PARSER_H
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef DCM_PROPERTY_GENERATOR_IMP_H
|
||||
#define DCM_PROPERTY_GENERATOR_IMP_H
|
||||
|
||||
#include "property_generator.hpp"
|
||||
#include "traits_impl.hpp"
|
||||
|
||||
namespace dcm {
|
||||
|
||||
typedef std::ostream_iterator<char> Iterator;
|
||||
|
||||
namespace details {
|
||||
|
||||
//grammar for a single property
|
||||
template<typename Prop, typename Gen>
|
||||
prop_grammar<Prop, Gen>::prop_grammar() : prop_grammar<Prop, Gen>::base_type(start) {
|
||||
|
||||
Gen::init(subrule);
|
||||
start = karma::lit("\n<Property>") << '+' << karma::eol << subrule
|
||||
<< '-' << karma::eol << karma::lit("</Property>");
|
||||
};
|
||||
|
||||
template<typename Sys, typename PropertyList>
|
||||
prop_gen<Sys, PropertyList>::prop_gen() : prop_gen<Sys, PropertyList>::base_type(prop) {
|
||||
|
||||
prop = fusion::at_c<0>(rules) << fusion::at_c<1>(rules) << fusion::at_c<2>(rules)
|
||||
<< fusion::at_c<3>(rules) << fusion::at_c<4>(rules) << fusion::at_c<5>(rules)
|
||||
<< fusion::at_c<6>(rules) << fusion::at_c<7>(rules) << fusion::at_c<8>(rules)
|
||||
<< fusion::at_c<9>(rules);
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
cluster_prop_gen<Sys>::cluster_prop_gen() : prop_gen<Sys, typename Sys::Cluster::cluster_properties>() {};
|
||||
|
||||
template<typename Sys>
|
||||
vertex_prop_gen<Sys>::vertex_prop_gen() : prop_gen<Sys, typename Sys::Cluster::vertex_properties>() {};
|
||||
|
||||
template<typename Sys>
|
||||
edge_prop_gen<Sys>::edge_prop_gen() : prop_gen<Sys, typename Sys::Cluster::edge_properties>() {};
|
||||
|
||||
}//details
|
||||
}//dcm
|
||||
|
||||
#endif //DCM_PROPERTY_GENERATOR_H
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
#ifndef DCM_PROPERTY_PARSER_IMP_H
|
||||
#define DCM_PROPERTY_PARSER_IMP_H
|
||||
|
||||
#include "property_parser.hpp"
|
||||
#include <boost/fusion/include/back.hpp>
|
||||
#include <boost/phoenix/fusion/at.hpp>
|
||||
|
||||
|
||||
namespace dcm {
|
||||
|
||||
typedef boost::spirit::istream_iterator IIterator;
|
||||
|
||||
namespace details {
|
||||
|
||||
template<typename srs, typename prs, typename dist>
|
||||
typename boost::enable_if<mpl::less< dist, mpl::size<srs> >, void >::type recursive_init( srs& sseq, prs& pseq ) {
|
||||
|
||||
if(dist::value == 0) {
|
||||
fusion::at<dist>(pseq) %= fusion::at<dist>(sseq)(qi::_r1);
|
||||
}
|
||||
else {
|
||||
fusion::at<dist>(pseq) %= fusion::at<typename mpl::prior< typename mpl::max<dist, mpl::int_<1> >::type >::type>(pseq)(qi::_r1) | fusion::at<dist>(sseq)(qi::_r1);
|
||||
}
|
||||
|
||||
recursive_init<srs, prs, typename mpl::next<dist>::type>(sseq, pseq);
|
||||
};
|
||||
|
||||
template<typename srs, typename prs, typename dist>
|
||||
typename boost::disable_if<mpl::less< dist, mpl::size<srs> >, void >::type recursive_init( srs& sseq, prs& pseq ){};
|
||||
|
||||
template<typename PropList, typename Prop, typename Par>
|
||||
prop_parser<PropList, Prop, Par>::prop_parser() : prop_parser<PropList, Prop, Par>::base_type(start) {
|
||||
|
||||
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>");
|
||||
};
|
||||
|
||||
template<typename Sys, typename PropertyList>
|
||||
prop_par<Sys, PropertyList>::prop_par() : prop_par<Sys, PropertyList>::base_type(prop) {
|
||||
|
||||
recursive_init<typename fusion::result_of::as_vector<sub_rules_sequence>::type,
|
||||
typename fusion::result_of::as_vector<parent_rules_sequence>::type,
|
||||
mpl::int_<0> >(sub_rules, parent_rules);
|
||||
|
||||
prop = *(fusion::back(parent_rules)(&qi::_val));
|
||||
};
|
||||
|
||||
template<typename Sys>
|
||||
cluster_prop_par<Sys>::cluster_prop_par() : prop_par<Sys, typename Sys::Cluster::cluster_properties>() {};
|
||||
|
||||
template<typename Sys>
|
||||
vertex_prop_par<Sys>::vertex_prop_par() : prop_par<Sys, typename Sys::Cluster::vertex_properties>() {};
|
||||
|
||||
template<typename Sys>
|
||||
edge_prop_par<Sys>::edge_prop_par() : prop_par<Sys, typename Sys::Cluster::edge_properties>() {};
|
||||
|
||||
} //DCM
|
||||
} //details
|
||||
|
||||
#endif
|
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
openDCM, dimensional constraint manager
|
||||
Copyright (C) 2013 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 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.
|
||||
*/
|
||||
|
||||
//move the traits specializations outside of the traits definition to avoid the spirit header parsing every
|
||||
//time this module is included and just parse it in externalisation mode when the generator is build
|
||||
|
||||
#ifndef DCM_PARSER_TRAITS_IMPL_H
|
||||
#define DCM_PARSER_TRAITS_IMPL_H
|
||||
|
||||
#include "traits.hpp"
|
||||
#include "defines.hpp"
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
#include <boost/spirit/include/karma_string.hpp>
|
||||
#include <boost/spirit/include/karma_int.hpp>
|
||||
#include <boost/spirit/include/karma_bool.hpp>
|
||||
#include <boost/spirit/include/karma_rule.hpp>
|
||||
#include <boost/spirit/include/karma_auto.hpp>
|
||||
|
||||
namespace karma = boost::spirit::karma;
|
||||
namespace qi = boost::spirit::qi;
|
||||
|
||||
namespace boost {
|
||||
namespace spirit {
|
||||
namespace traits {
|
||||
template <>
|
||||
struct create_generator<dcm::No_Identifier> {
|
||||
|
||||
typedef BOOST_TYPEOF(karma::eps(false)) type;
|
||||
static type call() {
|
||||
return karma::eps(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace dcm {
|
||||
|
||||
template<typename System>
|
||||
struct parser_generate<type_prop, System> : public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_generator<type_prop, System, iterator> {
|
||||
typedef karma::rule<iterator, int&()> generator;
|
||||
|
||||
static void init(generator& r) {
|
||||
r = karma::lit("<type>clustertype</type>\n<value>") << karma::int_ <<"</value>";
|
||||
};
|
||||
};
|
||||
|
||||
template<typename System>
|
||||
struct parser_generate<changed_prop, System> : public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_generator<changed_prop, System, iterator> {
|
||||
typedef karma::rule<iterator, bool&()> generator;
|
||||
|
||||
static void init(generator& r) {
|
||||
r = karma::lit("<type>clusterchanged</type>\n<value>") << karma::bool_ <<"</value>";
|
||||
};
|
||||
};
|
||||
|
||||
template<typename System>
|
||||
struct parser_generate<id_prop<typename System::Identifier>, System>
|
||||
: public mpl::not_<boost::is_same<typename System::Identifier, No_Identifier> > {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_generator<id_prop<typename System::Identifier>, System, iterator> {
|
||||
typedef karma::rule<iterator, typename System::Identifier()> generator;
|
||||
|
||||
static void init(generator& r) {
|
||||
r = karma::lit("<type>id</type>\n<value>") << karma::auto_ <<"</value>";
|
||||
};
|
||||
};
|
||||
|
||||
template<typename System>
|
||||
struct parser_parse<type_prop, System> : public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_parser<type_prop, System, iterator> {
|
||||
typedef qi::rule<iterator, int(), qi::space_type> parser;
|
||||
|
||||
static void init(parser& r) {
|
||||
r = qi::lit("<type>clustertype</type>") >> ("<value>") >> qi::int_ >>"</value>";
|
||||
};
|
||||
};
|
||||
|
||||
template<typename System>
|
||||
struct parser_parse<changed_prop, System> : public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_parser<changed_prop, System, iterator> {
|
||||
typedef qi::rule<iterator, bool(), qi::space_type> parser;
|
||||
|
||||
static void init(parser& r) {
|
||||
r = qi::lit("<type>clusterchanged</type>") >> ("<value>") >> qi::bool_ >>"</value>" ;
|
||||
};
|
||||
};
|
||||
|
||||
template<typename System>
|
||||
struct parser_parse<id_prop<typename System::Identifier>, System>
|
||||
: public mpl::not_<boost::is_same<typename System::Identifier, No_Identifier> > {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_parser<id_prop<typename System::Identifier>, System, iterator> {
|
||||
typedef qi::rule<iterator, typename System::Identifier(), qi::space_type> parser;
|
||||
|
||||
static void init(parser& r) {
|
||||
r = qi::lit("<type>id</type>") >> ("<value>") >> qi::auto_ >>"</value>";
|
||||
};
|
||||
};
|
||||
/*
|
||||
template<typename System>
|
||||
struct parser_generate<details::cluster_vertex_prop, System>
|
||||
: public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_generator<details::cluster_vertex_prop, System, iterator> {
|
||||
typedef karma::rule<iterator, int()> generator;
|
||||
|
||||
static void init(generator& r) {
|
||||
r = karma::lit("<type>id</type>\n<value>") << karma::int_ <<"</value>";
|
||||
};
|
||||
};
|
||||
|
||||
template<typename System>
|
||||
struct parser_parse<details::cluster_vertex_prop, System> : public mpl::true_ {};
|
||||
|
||||
template<typename System, typename iterator>
|
||||
struct parser_parser<details::cluster_vertex_prop, System, iterator> {
|
||||
typedef qi::rule<iterator, int(), qi::space_type> parser;
|
||||
|
||||
static void init(parser& r) {
|
||||
r = qi::lit("<type>id</type>") >> ("<value>") >> qi::int_ >>"</value>";
|
||||
};
|
||||
};*/
|
||||
|
||||
} //namespace dcm
|
||||
|
||||
#endif //DCM_PARSER_TRAITS_IMPL_H
|
|
@ -35,17 +35,17 @@
|
|||
|
||||
#ifdef DCM_EXTERNAL_STATE
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_001 <opendcm/moduleState/edge_vertex_generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_001 <opendcm/moduleState/imp/edge_vertex_generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_001( System )\
|
||||
template struct dcm::details::edge_generator<System>; \
|
||||
template struct dcm::details::vertex_generator<System>; \
|
||||
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_002 <opendcm/moduleState/object_generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_002 <opendcm/moduleState/imp/object_generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_002( System )\
|
||||
template struct dcm::details::obj_gen<System>; \
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_003 <opendcm/moduleState/property_generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_003 <opendcm/moduleState/imp/property_generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_003( System )\
|
||||
template struct dcm::details::vertex_prop_gen<System>; \
|
||||
template struct dcm::details::edge_prop_gen<System>; \
|
||||
|
@ -53,11 +53,11 @@
|
|||
template struct dcm::details::system_prop_gen<System>; \
|
||||
template struct dcm::details::kernel_prop_gen<System>;
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_004 <opendcm/moduleState/generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_004 <opendcm/moduleState/imp/generator_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_004( System )\
|
||||
template struct dcm::generator<System>; \
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_005 <opendcm/moduleState/property_parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_005 <opendcm/moduleState/imp/property_parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_005( System )\
|
||||
template struct dcm::details::vertex_prop_par<System>; \
|
||||
template struct dcm::details::edge_prop_par<System>; \
|
||||
|
@ -65,16 +65,16 @@
|
|||
template struct dcm::details::system_prop_par<System>; \
|
||||
template struct dcm::details::kernel_prop_par<System>;
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_006 <opendcm/moduleState/object_parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_006 <opendcm/moduleState/imp/object_parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_006( System )\
|
||||
template struct dcm::details::obj_par<System>; \
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_007 <opendcm/moduleState/edge_vertex_parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_007 <opendcm/moduleState/imp/edge_vertex_parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_007( System )\
|
||||
template struct dcm::details::edge_parser<System>; \
|
||||
template struct dcm::details::vertex_parser<System>; \
|
||||
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_008 <opendcm/moduleState/parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_INCLUDE_008 <opendcm/moduleState/imp/parser_imp.hpp>
|
||||
#define DCM_EXTERNAL_STATE_008( System )\
|
||||
template struct dcm::parser<System>; \
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <Gui/Selection.h>
|
||||
#include "ViewProviderConstraint.h"
|
||||
#include <opendcm/core.hpp>
|
||||
#include <Solver.h>
|
||||
#include <Solver/Solver.h>
|
||||
#include <boost/signals.hpp>
|
||||
#include "ui_TaskAssemblyConstraints.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user