diff --git a/src/Mod/Assembly/App/opendcm/core/constraint.hpp b/src/Mod/Assembly/App/opendcm/core/constraint.hpp index c9cc12259..b4b857ff9 100644 --- a/src/Mod/Assembly/App/opendcm/core/constraint.hpp +++ b/src/Mod/Assembly/App/opendcm/core/constraint.hpp @@ -632,12 +632,14 @@ template template< typename T > void Constraint::holder::LGZ::operator()(T& val) const { + typedef typename Sys::Kernel Kernel; + if(!val.enabled) return; //to treat local gradient zeros we calculate a approximate second derivative of the equations //only do that if neseccary: residual is not zero - if(val.m_residual(0) > 1e-7) { //TODO: use exact precission and scale value + if(!Kernel::isSame(val.m_residual(0),0, 1e-7)) { //TODO: use exact precission and scale value //rotations exist only in cluster if(first->getClusterMode() && !first->isClusterFixed()) { @@ -645,7 +647,7 @@ void Constraint::holder::LGZ::operat for(int i=0; i<3; i++) { //only treat if the gradient realy is zero - if(std::abs(val.m_diff_first_rot(i)) < 1e-7) { + if(Kernel::isSame(val.m_diff_first_rot(i), 0, 1e-7)) { //to get the approximated second derivative we need the slightly moved geometrie const typename Kernel::Vector p_old = first->m_parameter; @@ -658,7 +660,7 @@ void Constraint::holder::LGZ::operat first->m_parameter = p_old; //let's see if the initial LGZ was a real one - if(std::abs(res) > 1e-7) { + if(!Kernel::isSame(res, 0, 1e-7)) { //is a fake zero, let's correct it val.m_diff_first_rot(i) = res; @@ -672,7 +674,7 @@ void Constraint::holder::LGZ::operat for(int i=0; i<3; i++) { //only treat if the gradient realy is zero - if(std::abs(val.m_diff_second_rot(i)) < 1e-7) { + if(Kernel::isSame(val.m_diff_second_rot(i), 0, 1e-7)) { //to get the approximated second derivative we need the slightly moved geometrie const typename Kernel::Vector p_old = second->m_parameter; @@ -685,7 +687,7 @@ void Constraint::holder::LGZ::operat second->m_parameter = p_old; //let's see if the initial LGZ was a real one - if(std::abs(res) > 1e-7) { + if(!Kernel::isSame(res, 0, 1e-7)) { //is a fake zero, let's correct it val.m_diff_second_rot(i) = res; diff --git a/src/Mod/Assembly/App/opendcm/core/kernel.hpp b/src/Mod/Assembly/App/opendcm/core/kernel.hpp index f3d748cfc..f6ecc59a9 100644 --- a/src/Mod/Assembly/App/opendcm/core/kernel.hpp +++ b/src/Mod/Assembly/App/opendcm/core/kernel.hpp @@ -79,7 +79,7 @@ struct Dogleg { number_type tolg, tolx; Kernel* m_kernel; - Dogleg(Kernel* k) : m_kernel(k), tolg(1e-40), tolx(1e-20) { + Dogleg(Kernel* k) : m_kernel(k), tolg(1e-40), tolx(1e-20){ #ifdef USE_LOGGING log.add_attribute("Tag", attrs::constant< std::string >("Dogleg")); @@ -538,7 +538,7 @@ struct Kernel : public PropertyOwner< mpl::vector > { bool isOpposite(const E::MatrixBase& p1,const E::MatrixBase& p2) { return ((p1+p2).squaredNorm() < getProperty()); } - + int solve(MappedEquationSystem& mes) { nothing n; return NonlinearSolver(this).solve(mes, n); @@ -548,7 +548,7 @@ struct Kernel : public PropertyOwner< mpl::vector > { int solve(MappedEquationSystem& mes, Functor& f) { return NonlinearSolver(this).solve(mes, f); }; - + typedef mpl::vector1 properties; }; diff --git a/src/Mod/Assembly/Gui/TaskAssemblyConstraints.ui b/src/Mod/Assembly/Gui/TaskAssemblyConstraints.ui index a4293a677..45d69de56 100644 --- a/src/Mod/Assembly/Gui/TaskAssemblyConstraints.ui +++ b/src/Mod/Assembly/Gui/TaskAssemblyConstraints.ui @@ -18,6 +18,9 @@ + + <html><head/><body><p>The first geometry to which the constraint relates. Note that first and second geometry can be swapt. If you want to clear it, use the button to the right. If it is empty, just select any geometry in the 3D view and it will be added here.</p></body></html> + false @@ -31,6 +34,9 @@ + + <html><head/><body><p>Clear the first geometry</p></body></html> + ... @@ -49,6 +55,9 @@ + + <html><head/><body><p>The second geometry to which the constraint relates. Note that first and second geometry can be swapt. If you want to clear it, use the button to the right. If it is empty, just select any geometry in the 3D view and it will be added here.</p></body></html> + false @@ -62,6 +71,9 @@ + + <html><head/><body><p>Clear the second geometry</p></body></html> + ... @@ -105,6 +117,9 @@ 0 + + <html><head/><body><p>Setthe distance between first and second geometrie. Note that in many cases the shortes distance is used (e.g. line - line)</p></body></html> + Distance @@ -143,6 +158,9 @@ 0 + + <html><head/><body><p>Special constraint which is in general used to let the geometries be on each other. Therefore it's often the same as align, with the difference that it is also defined for points, as a point can lie on a plane. Note that this constraint has a special behaviour for cylinders. For example, a cylindrical surface can't be on a plane, only touch it. Therefore this is not valid. Furthermore point and line coincident with cylinders don't work on the cylinder surface, but on its center line. The reason for that it is, that this centerline would not be accessible with other constraints, but the surface coincident can be also achieved with the align constraint and value 0. At last specialty the cylinder cylinder constraint shall be mentioned: It works also on the cylinder centerlines and therefore makes them concentric. </p></body></html> + Coincident @@ -181,6 +199,9 @@ 0 + + <html><head/><body><p>Fixes the first geometry in its rotation and translation. Note that fix only works its the direct parrent assembly. If you stack assemblys, the parent assembly will not be fixed inside the other ones.</p></body></html> + Fix @@ -219,6 +240,9 @@ 0 + + <html><head/><body><p>Allows to set the orientation of the geometries normals in relation to each other. Possible values are parallel (means equal or opposite normals), equal normals, opposite normals or perpendicular ones. Note that for cylinders the base circles normal is used.</p></body></html> + Orientation @@ -257,6 +281,9 @@ 0 + + <html><head/><body><p>Adds a orientation and a distance constraint. Therefore this constraint is only valid where both of the individual constraints are, e.g. you can't align a point and a plane as point-plane orientation is invalid. Furthermore it can happen that this constraint is only valid for a certain orientation, e.g. plane - line has only a defined distance, when the orientation is perpendicular. The reason behind this is, that a non-perpendicular line would always cut the plane and therefore the shortest distance would always be 0. </p></body></html> + Align @@ -295,6 +322,9 @@ 0 + + <html><head/><body><p>Set the angle between the geometries normals</p></body></html> + Angle @@ -399,12 +429,15 @@ 0 + + 999999.000000000000000 + - + <html><head/><body><p>Use the full solution space. The nearest solution will be found.</p></body></html> ... @@ -441,6 +474,9 @@ 0 + + <html><head/><body><p>Positive solution space. Reduces the valid solutions to the positive domain, e.g. point over the plane at specified distance, not under. Or point outside a cylinder at specified distance, not inside.</p></body></html> + ... @@ -473,6 +509,9 @@ 0 + + <html><head/><body><p>Negative solution space. Reduces the valid solutions to the negative domain, e.g. point under the plane at specified distance, not over. Or point inside a cylinder at specified distance, not outside.</p></body></html> + ... @@ -527,6 +566,9 @@ 0 + + <html><head/><body><p>Makes the geometries normals parallel, that means they can point in the same or opposite direction. Note that for cylinders the base circles normal is used.</p></body></html> + Parallel @@ -562,6 +604,9 @@ 0 + + <html><head/><body><p>Makes the geometries normals point in the same direction. Note that for cylinders the base circles normal is used.</p></body></html> + Equal @@ -600,6 +645,9 @@ 0 + + <html><head/><body><p>Makes the geometries normals point in the opposite direction. Note that for cylinders the base cirles normal is used.</p></body></html> + Opposite @@ -635,6 +683,9 @@ 0 + + <html><head/><body><p>Makes the geometries normals perpendicular. Note that for cylinders the base cirles normal is used.</p></body></html> + false