Commit 7600ff1a authored by Pierre Kraemer's avatar Pierre Kraemer

debug abs / fabs ..

parent 6065ae86
......@@ -11,5 +11,5 @@ schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName());
schnapps.linkViewAndMap(v.getName(), obj.getName());
#differentialPropertiesPlugin.computeNormal(obj.getName());
#differentialPropertiesPlugin.computeCurvature(obj.getName());
differentialPropertiesPlugin.computeNormal(obj.getName());
differentialPropertiesPlugin.computeCurvature(obj.getName());
......@@ -1207,16 +1207,16 @@ void EdgeSelector_Curvature<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
REAL err = 0 ;
// REAL norm_deviation_1 = REAL(1) / abs(norm * normal[v1]) ;
// REAL norm_deviation_2 = REAL(1) / abs(norm * normal[v2]) ;
// REAL norm_deviation_1 = REAL(1) / fabs(norm * normal[v1]) ;
// REAL norm_deviation_2 = REAL(1) / fabs(norm * normal[v2]) ;
// err += norm_deviation_1 + norm_deviation_2 ;
REAL mCurv_deviation_1 = abs(mCurv - (kmax[v1] + kmin[v1] / REAL(2))) ;
REAL mCurv_deviation_2 = abs(mCurv - (kmax[v2] + kmin[v2] / REAL(2))) ;
REAL mCurv_deviation_1 = fabs(mCurv - (kmax[v1] + kmin[v1] / REAL(2))) ;
REAL mCurv_deviation_2 = fabs(mCurv - (kmax[v2] + kmin[v2] / REAL(2))) ;
err += mCurv_deviation_1 + mCurv_deviation_2 ;
// REAL cDir1_deviation_1 = REAL(1) / abs(cDir1 * Kmax[v1]) ;
// REAL cDir1_deviation_2 = REAL(1) / abs(cDir1 * Kmax[v2]) ;
// REAL cDir1_deviation_1 = REAL(1) / fabs(cDir1 * Kmax[v1]) ;
// REAL cDir1_deviation_2 = REAL(1) / fabs(cDir1 * Kmax[v2]) ;
// err += cDir1_deviation_1 + cDir1_deviation_2 ;
einfo.it = edges.insert(std::make_pair(err, d)) ;
......@@ -1440,7 +1440,7 @@ void EdgeSelector_CurvatureTensor<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
Eigen::SelfAdjointEigenSolver<E_MATRIX> solver (Utils::convertRef<E_MATRIX>(tens1),Eigen::EigenvaluesOnly);
const VEC3& e_val = Utils::convertRef<VEC3>(solver.eigenvalues());
REAL err = std::max(std::max(abs(e_val[0]), abs(e_val[1])) , abs(e_val[2])) ;
REAL err = std::max(std::max(fabs(e_val[0]), fabs(e_val[1])) , fabs(e_val[2])) ;
// if (v1 % 5000 == 0) CGoGNout << e_val << CGoGNendl << err << CGoGNendl ;
......
......@@ -148,8 +148,8 @@ void Approximator_HemiFuncCoefs<PFP>::approximate(Dart d)
const VEC3& N1 = m_frameN[d] ;
const VEC3& N2 = m_frameN[dd] ;
//assert(abs(T * N1) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the first tangent plane") ;
//assert(abs(T * N2) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the second tangent plane") ;
//assert(fabs(T * N1) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the first tangent plane") ;
//assert(fabs(T * N2) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the second tangent plane") ;
// Compute D1' and D2'
VEC3 B1prime = N1 ^ T ;
......@@ -327,8 +327,8 @@ void Approximator_HemiFuncCoefsHalfEdge<PFP>::approximate(Dart d)
const VEC3& N1 = m_frameN[d] ;
const VEC3& N2 = m_frameN[dd] ;
//assert(abs(T * N1) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the first tangent plane") ;
//assert(abs(T * N2) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the second tangent plane") ;
//assert(fabs(T * N1) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the first tangent plane") ;
//assert(fabs(T * N2) < 1e-6 || !"Approximator_FrameInterpolation<PFP>::approximate: T is not located in the second tangent plane") ;
// Compute D1' and D2'
VEC3 B1prime = N1 ^ T ;
......
......@@ -537,8 +537,8 @@ void normalCycles_SortAndSetEigenComponents(
{
// sort eigen components : ev[inormal] has minimal absolute value ; kmin = ev[imin] <= ev[imax] = kmax
int inormal=0, imin, imax ;
if (abs(e_val[1]) < abs(e_val[inormal])) inormal = 1;
if (abs(e_val[2]) < abs(e_val[inormal])) inormal = 2;
if (fabs(e_val[1]) < fabs(e_val[inormal])) inormal = 1;
if (fabs(e_val[2]) < fabs(e_val[inormal])) inormal = 2;
imin = (inormal + 1) % 3;
imax = (inormal + 2) % 3;
if (e_val[imax] < e_val[imin]) { int tmp = imin ; imin = imax ; imax = tmp ; }
......@@ -578,8 +578,8 @@ void normalCycles_SortTensor(Geom::Matrix<3,3,typename PFP::REAL> & tensor, unsi
// switch kmin and kmax w.r.t. Kmin and Kmax
int inormal=0, imin, imax ;
if (abs(e_val[1]) < abs(e_val[inormal])) inormal = 1;
if (abs(e_val[2]) < abs(e_val[inormal])) inormal = 2;
if (fabs(e_val[1]) < fabs(e_val[inormal])) inormal = 1;
if (fabs(e_val[2]) < fabs(e_val[inormal])) inormal = 2;
imin = (inormal + 1) % 3;
imax = (inormal + 2) % 3;
if (e_val[imax] < e_val[imin]) { int tmp = imin ; imin = imax ; imax = tmp ; }
......
......@@ -321,14 +321,14 @@ void ridgeLines(
if( (e1 < 0 && e2 > 0) || (e1 > 0 && e2 < 0) )
{
REAL alpha = abs(e1) / ( abs(e1) + abs(e2) ) ;
REAL alpha = fabs(e1) / ( fabs(e1) + fabs(e2) ) ;
ridge_segments[d].p1.d = v1 ;
ridge_segments[d].p1.w = alpha ;
p1set = true ;
}
if( (e2 < 0 && e3 > 0) || (e2 > 0 && e3 < 0) )
{
REAL alpha = abs(e2) / ( abs(e2) + abs(e3) ) ;
REAL alpha = fabs(e2) / ( fabs(e2) + fabs(e3) ) ;
if(!p1set)
{
ridge_segments[d].p1.d = v2 ;
......@@ -345,7 +345,7 @@ void ridgeLines(
}
if( (e3 < 0 && e1 > 0) || (e3 > 0 && e1 < 0) )
{
REAL alpha = abs(e3) / ( abs(e1) + abs(e3) ) ;
REAL alpha = fabs(e3) / ( fabs(e1) + fabs(e3) ) ;
if(p1set && !p2set)
{
ridge_segments[d].p2.d = v3 ;
......
......@@ -729,7 +729,7 @@ float Image<DataType>::computeCurvatureCount3(const DataType *ptrVox, const std:
// return (valY + valZ)/2.0f;
unsigned short m1,m2;
if ((abs(vals[0]) < abs(vals[1])) && (abs(vals[0]) < abs(vals[2])))
if ((fabs(vals[0]) < fabs(vals[1])) && (fabs(vals[0]) < fabs(vals[2])))
{
m1 =1;
m2 =2;
......@@ -737,7 +737,7 @@ float Image<DataType>::computeCurvatureCount3(const DataType *ptrVox, const std:
else
{
m1=0;
if (abs(vals[1]) < abs(vals[2]))
if (fabs(vals[1]) < fabs(vals[2]))
m2 = 2;
else
m2 = 1;
......@@ -753,7 +753,7 @@ float Image<DataType>::computeCurvatureCount3(const DataType *ptrVox, const std:
if ((vals[m2] - vals[m1])>0.8f)
return 1.0f;
return std::max(std::max(abs(vals[0]),abs(vals[1])),abs(vals[2]));
return std::max(std::max(fabs(vals[0]),fabs(vals[1])),fabs(vals[2]));
}
......
......@@ -117,7 +117,7 @@ void Plane3D<T>::project(Vector<3,T>& p) const
{
#define PRECISION 1e-10
T d = -distance(p) ;
if(std::abs(d) > PRECISION)
if(fabs(d) > PRECISION)
{
Vector<3,T> v = m_normal * d ;
p += v ;
......
......@@ -35,6 +35,7 @@
namespace CGoGN
{
namespace Utils
{
......@@ -70,7 +71,6 @@ FrameManipulator::FrameManipulator():
points.reserve(6*nb_segments+30);
points.resize(6*nb_segments+6);
unsigned int second = 2*(nb_segments+1);
unsigned int third = 4*(nb_segments+1);
......@@ -90,7 +90,6 @@ FrameManipulator::FrameManipulator():
points[third + 2*i+1] = Geom::Vec3f(xx,yy,0.0f);
}
points.push_back(Geom::Vec3f(0.0f,0.0f,0.0f));
points.push_back(Geom::Vec3f(0.23f,0.0f,0.0f));
......@@ -118,7 +117,6 @@ FrameManipulator::FrameManipulator():
points.push_back(Geom::Vec3f(-0.03f,0.7f, 0.0f));
points.push_back(Geom::Vec3f(0.0f, 0.7f, 0.03f));
points.push_back(Geom::Vec3f(0.0f,0.0f, 0.27f));
points.push_back(Geom::Vec3f(0.0f,0.0f, 0.75f));
points.push_back(Geom::Vec3f(0.0f,0.0f, 0.9f));
......@@ -128,7 +126,6 @@ FrameManipulator::FrameManipulator():
points.push_back(Geom::Vec3f(0.0f,-0.03f,0.7f));
points.push_back(Geom::Vec3f(0.03f,0.0f, 0.7f));
m_vboPos->bind();
glBufferData(GL_ARRAY_BUFFER, points.size() * sizeof(Geom::Vec3f), &(points[0]), GL_STREAM_DRAW);
......@@ -153,7 +150,6 @@ float FrameManipulator::getSize()
return m_scaleRendering;
}
void FrameManipulator::draw()
{
Utils::GLSLShader::pushTransfo();
......@@ -163,7 +159,6 @@ void FrameManipulator::draw()
glPushAttrib(GL_LINE_BIT);
m_shader->enableVertexAttribs();
if (!m_locked_axis[Xr])
{
if (m_highlighted == Xr)
......@@ -203,53 +198,53 @@ void FrameManipulator::draw()
}
else
{
if (!m_locked_axis[Xs])
{
if (m_highlighted == Xs)
{
glLineWidth(6.0f);
m_shader->setColor(Geom::Vec4f(1.0f,1.0f,0.0f,0.0f));
}
else
if (!m_locked_axis[Xs])
{
glLineWidth(3.0f);
m_shader->setColor(Geom::Vec4f(1.0f,0.0f,0.0f,0.0f));
if (m_highlighted == Xs)
{
glLineWidth(6.0f);
m_shader->setColor(Geom::Vec4f(1.0f,1.0f,0.0f,0.0f));
}
else
{
glLineWidth(3.0f);
m_shader->setColor(Geom::Vec4f(1.0f,0.0f,0.0f,0.0f));
}
m_shader->bind();
glDrawArrays(GL_LINES, 6*nb_segments+6, 2);
}
m_shader->bind();
glDrawArrays(GL_LINES, 6*nb_segments+6, 2);
}
if (!m_locked_axis[Ys])
{
if (m_highlighted == Ys)
{
glLineWidth(6.0f);
m_shader->setColor(Geom::Vec4f(1.0f,1.0f,0.0f,0.0f));
}
else
if (!m_locked_axis[Ys])
{
glLineWidth(3.0f);
m_shader->setColor(Geom::Vec4f(0.0f,0.7f,0.0f,0.0f));
if (m_highlighted == Ys)
{
glLineWidth(6.0f);
m_shader->setColor(Geom::Vec4f(1.0f,1.0f,0.0f,0.0f));
}
else
{
glLineWidth(3.0f);
m_shader->setColor(Geom::Vec4f(0.0f,0.7f,0.0f,0.0f));
}
m_shader->bind();
glDrawArrays(GL_LINES, 6*nb_segments+8, 2);
}
m_shader->bind();
glDrawArrays(GL_LINES, 6*nb_segments+8, 2);
}
if (!m_locked_axis[Zs])
{
if (m_highlighted == Zs)
if (!m_locked_axis[Zs])
{
glLineWidth(6.0f);
m_shader->setColor(Geom::Vec4f(1.0f,1.0f,0.0f,0.0f));
}
else
{
glLineWidth(3.0f);
m_shader->setColor(Geom::Vec4f(0.0f,0.0f,0.7f,0.0f));
if (m_highlighted == Zs)
{
glLineWidth(6.0f);
m_shader->setColor(Geom::Vec4f(1.0f,1.0f,0.0f,0.0f));
}
else
{
glLineWidth(3.0f);
m_shader->setColor(Geom::Vec4f(0.0f,0.0f,0.7f,0.0f));
}
m_shader->bind();
glDrawArrays(GL_LINES, 6*nb_segments+10, 2);
}
m_shader->bind();
glDrawArrays(GL_LINES, 6*nb_segments+10, 2);
}
}
......@@ -305,7 +300,6 @@ void FrameManipulator::draw()
glDrawArrays(GL_TRIANGLE_FAN, 6*nb_segments+30, 6);
}
m_shader->disableVertexAttribs();
glPopAttrib();
......@@ -314,8 +308,6 @@ void FrameManipulator::draw()
m_shader->unbind();
}
void FrameManipulator::highlight(unsigned int axis)
{
if (m_highlighted == axis)
......@@ -324,8 +316,6 @@ void FrameManipulator::highlight(unsigned int axis)
m_highlighted = axis;
}
unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV, float epsilon)
{
Geom::Vec3f P,V;
......@@ -429,7 +419,6 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV
}
}
if (axisPickable(Yt) || axisPickable(Ys))
{
Geom::Vec3f PY(0.0f,3.6f*m_lengthAxes[1],0.0f);
......@@ -448,7 +437,6 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV
}
}
if (axisPickable(Zt) || axisPickable(Zs))
{
Geom::Vec3f PZ(0.0f,0.0f,3.6f*m_lengthAxes[2]);
......@@ -489,7 +477,6 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV
return NONE;
}
void FrameManipulator::rotate(unsigned int axis, float angle)
{
// create axis
......@@ -498,16 +485,13 @@ void FrameManipulator::rotate(unsigned int axis, float angle)
glm::mat4 tr = glm::rotate(glm::mat4(1.0f),angle,ax);
m_rotations = m_rotations*tr;
}
void FrameManipulator::translate(unsigned int axis, float x)
{
m_trans += x*m_scaleRendering * glm::vec3(m_rotations[axis-Xt][0],m_rotations[axis-Xt][1],m_rotations[axis-Xt][2]);
}
void FrameManipulator::setLengthAxes()
{
float avgScale =(m_scale[0]+m_scale[1]+m_scale[2])/3.0f;
......@@ -519,7 +503,6 @@ void FrameManipulator::setLengthAxes()
float sc1 = m_scale[1]/avgScale;
float sc2 = m_scale[2]/avgScale;
positions[ind] = 0.23f*sc0;
ind+=7;
positions[ind] = 0.23f*sc1;
......@@ -591,10 +574,8 @@ void FrameManipulator::setLengthAxes()
m_vboPos->releasePtr();
m_lengthAxes = Geom::Vec3f(0.25f*sc0, 0.25f*sc1, 0.25f*sc2);
}
void FrameManipulator::scale(unsigned int axis, float sc)
{
if (axis==CENTER)
......@@ -607,10 +588,8 @@ void FrameManipulator::scale(unsigned int axis, float sc)
m_scale[axis-Xs] *= sc;
setLengthAxes();
}
glm::mat4 FrameManipulator::transfoRenderFrame()
{
glm::mat4 tr = glm::translate(glm::mat4(1.0f), m_trans);
......@@ -628,7 +607,6 @@ glm::mat4 FrameManipulator::transfo()
return glm::scale(tr,glm::vec3(m_scale[0],m_scale[1],m_scale[2]));
}
void FrameManipulator::setTranslation(const Geom::Vec3f& P)
{
m_trans[0] = P[0];
......@@ -636,8 +614,6 @@ void FrameManipulator::setTranslation(const Geom::Vec3f& P)
m_trans[2] = P[2];
}
void FrameManipulator::setScale(const Geom::Vec3f& S)
{
m_scale[0] = S[0];
......@@ -647,7 +623,6 @@ void FrameManipulator::setScale(const Geom::Vec3f& S)
setLengthAxes();
}
bool FrameManipulator::setOrientation(const Geom::Vec3f& X, const Geom::Vec3f& Y)
{
Geom::Vec3f Z = X^Y;
......@@ -670,10 +645,8 @@ bool FrameManipulator::setOrientation(const Geom::Vec3f& X, const Geom::Vec3f& Y
return true;
}
void FrameManipulator::setTransformation( const glm::mat4& transfo)
{
setTranslation(Geom::Vec3f(transfo[3][0],transfo[3][1],transfo[3][2]));
Geom::Vec3f Rx( transfo[0][0], transfo[0][1], transfo[0][2]);
......@@ -720,8 +693,6 @@ void FrameManipulator::lock(unsigned int axis)
setLengthAxes();
}
void FrameManipulator::unlock(unsigned int axis)
{
assert(axis <=Scales);
......@@ -749,7 +720,6 @@ void FrameManipulator::unlock(unsigned int axis)
setLengthAxes();
}
bool FrameManipulator::locked(unsigned int axis)
{
assert(axis <=Zs);
......@@ -783,8 +753,6 @@ void FrameManipulator::lockPicking(unsigned int axis)
setLengthAxes();
}
void FrameManipulator::unlockPicking(unsigned int axis)
{
assert(axis <=Scales);
......@@ -812,8 +780,6 @@ void FrameManipulator::unlockPicking(unsigned int axis)
setLengthAxes();
}
bool FrameManipulator::lockedPicking(unsigned int axis)
{
return m_lockedPicking_axis[axis];
......@@ -827,7 +793,6 @@ Geom::Vec3f FrameManipulator::getAxis(unsigned int ax)
return Geom::Vec3f(m_rotations[i][0],m_rotations[i][1],m_rotations[i][2]);
}
void FrameManipulator::storeProjection(unsigned int ax)
{
Geom::Vec3f O = getPosition();
......@@ -844,10 +809,8 @@ void FrameManipulator::storeProjection(unsigned int ax)
glm::vec3 winA = glm::project(glm::vec3(A[0],A[1],A[2]), GLSLShader::currentModelView(), GLSLShader::currentProjection(), viewport);
m_projectedSelectedAxis = Geom::Vec3f(winA[0]-winO[0], winA[1]-winO[1],winA[2]-winO[2]);
}
}
float FrameManipulator::angleFromMouse(int x, int y, int dx, int dy)
{
Geom::Vec3f V(float(x) - m_projectedOrigin[0], float(y) - m_projectedOrigin[1],0.0f);
......@@ -874,7 +837,6 @@ float FrameManipulator::distanceFromMouse(int dx, int dy)
float FrameManipulator::scaleFromMouse(int dx, int dy)
{
if (abs(dx) > abs(dy))
{
if (dx>0)
......@@ -902,7 +864,6 @@ void FrameManipulator::translateInScreen(int dx, int dy)
m_trans[1] = P[1];
m_trans[2] = P[2];
storeProjection(NONE);
}
void FrameManipulator::rotateInScreen(int dx, int dy)
......@@ -919,10 +880,8 @@ void FrameManipulator::rotateInScreen(int dx, int dy)
glm::mat4 tr = glm::rotate(glm::mat4(1.0f),sqrtf(float(dx*dx+dy*dy))/2.0f,glm::vec3(axisRotation[0],axisRotation[1],axisRotation[2]));
m_rotations = tr*m_rotations;
}
} // namespace Utils
}
}
} // namespace CGoGN
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment