Skip to content

Commit

Permalink
[SofaKernel] Remove some NDebug and replace sout/serr by msg
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed Mar 11, 2019
1 parent 2a8c4b6 commit f6a127f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 72 deletions.
110 changes: 46 additions & 64 deletions SofaKernel/modules/SofaBaseTopology/MeshTopology.cpp
Expand Up @@ -1593,9 +1593,8 @@ const vector< MeshTopology::EdgesAroundVertex >& MeshTopology::getEdgesAroundVer
{
if (m_edgesAroundVertex.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
sout << "Warning. [MeshTopology::getEdgesAroundVertexArray] EdgesAroundVertex array is empty." << sendl;
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetEdgesAroundVertexArray EdgesAroundVertex array is empty.";

createEdgesAroundVertexArray();
}
Expand All @@ -1607,9 +1606,8 @@ const vector< MeshTopology::EdgesInTriangle >& MeshTopology::getEdgesInTriangleA
{
if(m_edgesInTriangle.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getEdgesInTriangleArray] EdgesInTriangle array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetEdgesInTriangleArray EdgesInTriangle array is empty.";

createEdgesInTriangleArray();
}
Expand All @@ -1621,9 +1619,8 @@ const vector< MeshTopology::TrianglesAroundVertex >& MeshTopology::getTrianglesA
{
if(m_trianglesAroundVertex.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getTrianglesAroundVertexArray] TrianglesAroundVertex array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetTrianglesAroundVertexArray TrianglesAroundVertex array is empty.";

createTrianglesAroundVertexArray();
}
Expand All @@ -1635,9 +1632,8 @@ const vector< MeshTopology::TrianglesAroundEdge >& MeshTopology::getTrianglesAro
{
if(m_trianglesAroundEdge.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getTrianglesAroundEdgeArray] TrianglesAroundEdge array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetTrianglesAroundEdgeArray TrianglesAroundEdge array is empty.";

createTrianglesAroundEdgeArray();
}
Expand All @@ -1652,9 +1648,8 @@ const vector< MeshTopology::EdgesInQuad >& MeshTopology::getEdgesInQuadArray()
{
if(m_edgesInQuad.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getEdgesInQuadArray] EdgesInQuad array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetEdgesInQuadArray EdgesInQuad array is empty.";

createEdgesInQuadArray();
}
Expand All @@ -1666,9 +1661,8 @@ const vector< MeshTopology::QuadsAroundVertex >& MeshTopology::getQuadsAroundVer
{
if(m_quadsAroundVertex.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getQuadsAroundVertexArray] QuadsAroundVertex array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetQuadsAroundVertexArray QuadsAroundVertex array is empty.";

createQuadsAroundVertexArray();
}
Expand All @@ -1680,9 +1674,8 @@ const vector< MeshTopology::QuadsAroundEdge >& MeshTopology::getQuadsAroundEdgeA
{
if(m_quadsAroundEdge.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getQuadsAroundEdgeArray] QuadsAroundEdge array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetQuadsAroundEdgeArray QuadsAroundEdge array is empty.";

createQuadsAroundEdgeArray();
}
Expand All @@ -1698,9 +1691,8 @@ const vector< MeshTopology::EdgesInTetrahedron >& MeshTopology::getEdgesInTetrah
{
if (m_edgesInTetrahedron.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getEdgesInTetrahedronArray] EdgesInTetrahedron array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetEdgesInTetrahedronArray EdgesInTetrahedron array is empty.";

createEdgesInTetrahedronArray();
}
Expand All @@ -1712,9 +1704,8 @@ const vector< MeshTopology::TrianglesInTetrahedron >& MeshTopology::getTriangles
{
if (m_trianglesInTetrahedron.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::getTrianglesInTetrahedronArray] TrianglesInTetrahedron array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetTrianglesInTetrahedronArray TrianglesInTetrahedron array is empty.";

createTrianglesInTetrahedronArray();
}
Expand All @@ -1726,9 +1717,8 @@ const vector< MeshTopology::TetrahedraAroundVertex >& MeshTopology::getTetrahedr
{
if (m_tetrahedraAroundVertex.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::getTetrahedraAroundVertexArray] TetrahedraAroundVertex array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetTetrahedraAroundVertexArray TetrahedraAroundVertex array is empty.";

createTetrahedraAroundVertexArray();
}
Expand All @@ -1740,9 +1730,8 @@ const vector< MeshTopology::TetrahedraAroundEdge >& MeshTopology::getTetrahedraA
{
if (m_tetrahedraAroundEdge.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::getTetrahedraAroundEdgeArray] TetrahedraAroundEdge array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetTetrahedraAroundEdgeArray TetrahedraAroundEdge array is empty.";

createTetrahedraAroundEdgeArray();
}
Expand All @@ -1753,9 +1742,8 @@ const vector< MeshTopology::TetrahedraAroundTriangle >& MeshTopology::getTetrahe
{
if (m_tetrahedraAroundTriangle.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::getTetrahedraAroundTriangleArray] TetrahedraAroundTriangle array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetTetrahedraAroundTriangleArray TetrahedraAroundTriangle array is empty.";

createTetrahedraAroundTriangleArray();
}
Expand All @@ -1770,9 +1758,8 @@ const vector< MeshTopology::EdgesInHexahedron >& MeshTopology::getEdgesInHexahed
{
if (m_edgesInHexahedron.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::getEdgesInHexahedronArray] EdgesInHexahedron array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetEdgesInHexahedronArray EdgesInHexahedron array is empty.";

createEdgesInHexahedronArray();
}
Expand All @@ -1784,9 +1771,8 @@ const vector< MeshTopology::QuadsInHexahedron >& MeshTopology::getQuadsInHexahed
{
if (m_quadsInHexahedron.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::getQuadsInHexahedronArray] QuadsInHexahedron array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetQuadsInHexahedronArray QuadsInHexahedron array is empty.";

createQuadsInHexahedronArray();
}
Expand All @@ -1798,9 +1784,8 @@ const vector< MeshTopology::HexahedraAroundVertex >& MeshTopology::getHexahedraA
{
if (m_hexahedraAroundVertex.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getHexahedraAroundVertexArray] HexahedraAroundVertex array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetHexahedraAroundVertexArray HexahedraAroundVertex array is empty.";

createHexahedraAroundVertexArray();
}
Expand All @@ -1812,9 +1797,8 @@ const vector< MeshTopology::HexahedraAroundEdge >& MeshTopology::getHexahedraAro
{
if (m_hexahedraAroundEdge.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::getHexahedraAroundEdgeArray] HexahedraAroundEdge array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetHexahedraAroundEdgeArray HexahedraAroundEdge array is empty.";

createHexahedraAroundEdgeArray();
}
Expand All @@ -1826,9 +1810,8 @@ const vector< MeshTopology::HexahedraAroundQuad >& MeshTopology::getHexahedraAro
{
if (m_hexahedraAroundQuad.empty()) // this method should only be called when the array exists.
{
#ifndef NDEBUG
msg_info()<< "Warning. [MeshTopology::getHexahedraAroundQuadArray] HexahedraAroundQuad array is empty.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "GetHexahedraAroundQuadArray HexahedraAroundQuad array is empty.";

createHexahedraAroundQuadArray();
}
Expand Down Expand Up @@ -2246,9 +2229,8 @@ void MeshTopology::reOrientateTriangle(TriangleID id)
{
if (id >= (unsigned int)this->getNbTriangles())
{
#ifndef NDEBUG
msg_info() << "Warning. [MeshTopology::reOrientateTriangle] Triangle ID out of bounds.";
#endif
if (CHECK_TOPOLOGY)
msg_warning() << "reOrientateTriangle Triangle ID out of bounds.";
return;
}
Triangle& tri = (*seqTriangles.beginEdit())[id];
Expand Down Expand Up @@ -2344,17 +2326,17 @@ bool MeshTopology::checkConnexity()

if (nbr == 0)
{
#ifndef NDEBUG
msg_error() << "Warning. [MeshTopology::checkConnexity] Can't compute connexity as some element are missing";
#endif
if (CHECK_TOPOLOGY)
msg_error() << "CheckConnexity: Can't compute connexity as some element are missing.";

return false;
}

sofa::helper::vector <unsigned int> elemAll = this->getConnectedElement(0);

if (elemAll.size() != nbr)
{
msg_error() << "Warning: in computing connexity, elements are missings. There is more than one connexe component.";
msg_error() << "CheckConnexity: elements are missings. There is more than one connexe component.";
return false;
}

Expand All @@ -2379,9 +2361,9 @@ size_t MeshTopology::getNumberOfConnectedComponent()

if (nbr == 0)
{
#ifndef NDEBUG
msg_error() << "Warning. [MeshTopology::getNumberOfConnectedComponent] Can't compute connexity as there are no elements";
#endif
if (CHECK_TOPOLOGY)
msg_error() << "GetNumberOfConnectedComponent Can't compute connexity as there are no elements.";

return 0;
}

Expand Down Expand Up @@ -2467,9 +2449,9 @@ const sofa::helper::vector <unsigned int> MeshTopology::getConnectedElement(unsi
if (elemPreviousFront.empty())
{
end = true;
#ifndef NDEBUG
msg_error() << "Loop for computing connexity has reach end.";
#endif
if (CHECK_TOPOLOGY)
msg_error() << "Loop for computing connexity has reach end.";

}

// iterate
Expand Down
Expand Up @@ -244,7 +244,7 @@ void PointLocalMinDistanceFilter::handleTopologyChange()
{
if(this->isRigid())
{
msg_error() << "WARNING: filters optimization needed for topological change on rigid collision model";
msg_error() << "Filters optimization needed for topological change on rigid collision model";
this->invalidate(); // all the filters will be recomputed, not only those involved in the topological change
}

Expand All @@ -262,8 +262,6 @@ void PointLocalMinDistanceFilter::handleTopologyChange()

void PointLocalMinDistanceFilter::PointInfoHandler::applyCreateFunction(unsigned int /*pointIndex*/, PointInfo &pInfo, const sofa::helper::vector< unsigned int > &, const sofa::helper::vector< double >&)
{

std::cout<<" LMDFilterPointCreationFunction is called"<<std::endl;
const PointLocalMinDistanceFilter *pLMDFilter = this->f;
pInfo.setLMDFilters(pLMDFilter);

Expand Down
Expand Up @@ -92,13 +92,13 @@ TriangleLocalMinDistanceFilter::~TriangleLocalMinDistanceFilter()
void TriangleLocalMinDistanceFilter::init()
{
bmt = getContext()->getMeshTopology();
std::cout<<"Mesh Topology found :"<<bmt->getName()<<std::endl;
msg_info() << "Mesh Topology found :" << bmt->getName();
component::container::MechanicalObject<sofa::defaulttype::Vec3Types>* mstateVec3d= dynamic_cast<component::container::MechanicalObject<Vec3Types>*>(getContext()->getMechanicalState());


if(mstateVec3d == NULL)
{
serr<<"WARNING: init failed for TriangleLocalMinDistanceFilter no mstateVec3d found"<<sendl;
msg_warning() << "Init failed for TriangleLocalMinDistanceFilter no mstateVec3d found.";
}

if (bmt != nullptr)
Expand Down Expand Up @@ -146,12 +146,11 @@ void TriangleLocalMinDistanceFilter::init()
tInfo[i].setPositionFiltering(&mstateVec3d->read(core::ConstVecCoordId::position())->getValue());
}
m_triangleInfo.endEdit();
std::cout<<"create m_pointInfo, m_lineInfo, m_triangleInfo" <<std::endl;
}

if(this->isRigid())
{
std::cout<<"++++++ Is rigid Found in init "<<std::endl;
msg_info() << "++++++ Is rigid Found in init ";
// Precomputation of the filters in the rigid case
//triangles:
helper::vector< TriangleInfo >& tInfo = *(m_triangleInfo.beginEdit());
Expand Down Expand Up @@ -190,7 +189,7 @@ void TriangleLocalMinDistanceFilter::handleTopologyChange()
{
if(this->isRigid())
{
msg_error() << "WARNING: filters optimization needed for topological change on rigid collision model";
msg_error() << "Filters optimization needed for topological change on rigid collision model";
this->invalidate(); // all the filters will be recomputed, not only those involved in the topological change
}
}
Expand Down

0 comments on commit f6a127f

Please sign in to comment.