Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaBaseTopology Test] Add battery of tests on topology containers #708

Merged
merged 19 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7fc7096
[SofaBaseTopology tests] ADD: TriangleSetTopology_test class to test …
epernod Jul 4, 2018
ad60ce8
[SofaBaseTopology] FIX: nbPoint was still set to 0 if only Data were …
epernod Jul 4, 2018
51f954d
[SofaBaseTopology tests] ADD: EdgeSetTopology_test class to test Edge…
epernod Jul 5, 2018
92ccbb0
[SofaBaseTopology] FIX: nbPoint was still set to 0 if only Data were …
epernod Jul 5, 2018
7b43912
[SofaBaseTopology test] FIx: forgot to add the obj mesh file with onl…
epernod Jul 5, 2018
e2e7255
[SofaBaseTopology Test] UPDATE: factorize the topology scene creation.
epernod Jul 5, 2018
c7d828b
[SofaBaseTopology] FIX: nbPoint was still set to 0 if only Data were …
epernod Jul 5, 2018
8497b35
[SofaBaseTopology tests] ADD: QuadSetTopology_test class to test quad…
epernod Jul 5, 2018
12435aa
[SofaBaseTopology tests] ADD: Tetrahedron and Hexahedron SetTopology_…
epernod Jul 5, 2018
8e66aff
[SofaBaseTopology Test] Update: small esthetic changes on the differe…
epernod Jul 6, 2018
debb6eb
[SofaBaseTopology] FIX: all getter to the cross topology buffer array…
epernod Jul 6, 2018
6f7b65b
[SofaBaseTopology Tests] Add: option in the fake topology scene to se…
epernod Jul 6, 2018
cb9b8d2
[SofaBaseTopology_test] FIX: remove hardcoded path file by use of Dat…
epernod Jul 10, 2018
8615334
[SofaBaseTopology] Fix: in method getElement(id) check if id is outsi…
epernod Jul 10, 2018
5bf45e3
[SofaBaseTopology_test] Fix: meshTopology need to be init before use …
epernod Jul 10, 2018
0bd2e2b
[SofaBaseTopology] FIX: some buffer creation order where not identica…
epernod Jul 11, 2018
e5a6ff0
[TopologyModifier scene test] FIX: remove triangleFEM from the test. …
epernod Jul 12, 2018
c55a905
[TopologyModifier scene test] FIX: remove triangleFEM from the test. …
epernod Jul 12, 2018
41ebcf3
fix the edgeInRoi test, ground truth has changed since the edge array…
epernod Jul 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions SofaKernel/modules/SofaBaseTopology/EdgeSetTopologyContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ void EdgeSetTopologyContainer::createEdgesAroundVertexArray()
}

helper::ReadAccessor< Data< sofa::helper::vector<Edge> > > m_edge = d_edge;
m_edgesAroundVertex.resize( getNbPoints() );

int nbPoints = getNbPoints();
if (nbPoints == 0) // in case only Data have been copied and not going thourgh AddTriangle methods.
this->setNbPoints(d_initPoints.getValue().size());

m_edgesAroundVertex.resize(getNbPoints());

for (unsigned int edge=0; edge<m_edge.size(); ++edge)
{
// adding edge in the edge shell of both points
Expand Down Expand Up @@ -177,7 +183,10 @@ const EdgeSetTopologyContainer::Edge EdgeSetTopologyContainer::getEdge (EdgeID i
if(!hasEdges())
createEdgeSetArray();

return (d_edge.getValue())[i];
if (i >= getNbEdges())
return Edge(-1, -1);
else
return (d_edge.getValue())[i];
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ void HexahedronSetTopologyContainer::createHexahedraAroundVertexArray()
if(hasHexahedraAroundVertex())
clearHexahedraAroundVertex();

if (getNbPoints() == 0) // in case only Data have been copied and not going thourgh AddTriangle methods.
this->setNbPoints(d_initPoints.getValue().size());

m_hexahedraAroundVertex.resize( getNbPoints() );
helper::ReadAccessor< Data< sofa::helper::vector<Hexahedron> > > m_hexahedron = d_hexahedron;

Expand Down Expand Up @@ -520,7 +523,10 @@ const HexahedronSetTopologyContainer::Hexahedron HexahedronSetTopologyContainer:
if(!hasHexahedra())
createHexahedronSetArray();

return (d_hexahedron.getValue())[i];
if (i >= getNbHexahedra())
return Hexahedron(-1, -1, -1, -1, -1, -1, -1, -1);
else
return (d_hexahedron.getValue())[i];
}

unsigned int HexahedronSetTopologyContainer::getNumberOfHexahedra() const
Expand Down
6 changes: 4 additions & 2 deletions SofaKernel/modules/SofaBaseTopology/MeshTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ void MeshTopology::EdgeUpdate::updateFromSurface()
// edge not in edgeMap so create a new one
edgeIndex=(unsigned int)seqEdges.size();
edgeMap[e]=edgeIndex;
seqEdges.push_back(e);
// To be similar to TriangleSetTopologyContainer::createEdgeSetArray
//seqEdges.push_back(e); Changed to have oriented edges on the border of the triangulation.
seqEdges.push_back(Edge(v1, v2));
}
// else
// {
Expand Down Expand Up @@ -865,7 +867,7 @@ void MeshTopology::createEdgesAroundVertexArray ()
{
// adding edge i in the edge shell of both points
m_edgesAroundVertex[ edges[i][0] ].push_back( i );
m_edgesAroundVertex[ edges[i][1] ].insert( m_edgesAroundVertex[ edges[i][1] ].begin(), i );
m_edgesAroundVertex[ edges[i][1] ].push_back( i );
}
}
}
Expand Down
115 changes: 56 additions & 59 deletions SofaKernel/modules/SofaBaseTopology/MeshTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,61 @@ class SOFA_BASE_TOPOLOGY_API MeshTopology : public core::topology::BaseMeshTopol
//virtual const helper::vector <EdgeID>& getEdgesOnBorder();

//virtual const helper::vector <PointID>& getPointsOnBorder();

/** \brief Returns the EdgesInTriangle array (i.e. provide the 3 edge indices for each triangle). */
const helper::vector< EdgesInTriangle > &getEdgesInTriangleArray();

/** \brief Returns the TrianglesAroundVertex array (i.e. provide the triangles indices adjacent to each vertex). */
const helper::vector< TrianglesAroundVertex > &getTrianglesAroundVertexArray();

/** \brief Returns the TrianglesAroundEdge array (i.e. provide the triangles indices adjacent to each edge). */
const helper::vector< TrianglesAroundEdge > &getTrianglesAroundEdgeArray();



/** \brief Returns the EdgesInQuadArray array (i.e. provide the 4 edge indices for each quad) */
const helper::vector< EdgesInQuad > &getEdgesInQuadArray();

/** \brief Returns the QuadsAroundVertex array (i.e. provide the quad indices adjacent to each vertex). */
const helper::vector< QuadsAroundVertex > &getQuadsAroundVertexArray();

/** \brief Returns the QuadsAroundEdge array (i.e. provide the quad indices adjacent to each edge). */
const helper::vector< QuadsAroundEdge > &getQuadsAroundEdgeArray();



/** \brief Returns the EdgesInHexahedron array (i.e. provide the 12 edge indices for each hexahedron). */
const helper::vector< EdgesInHexahedron > &getEdgesInHexahedronArray();

/** \brief Returns the QuadsInHexahedron array (i.e. provide the 8 quad indices for each hexahedron). */
const helper::vector< QuadsInHexahedron > &getQuadsInHexahedronArray();

/** \brief Returns the HexahedraAroundVertex array (i.e. provide the hexahedron indices adjacent to each vertex).*/
const helper::vector< HexahedraAroundVertex > &getHexahedraAroundVertexArray();

/** \brief Returns the HexahedraAroundEdge array (i.e. provide the hexahedron indices adjacent to each edge). */
const helper::vector< HexahedraAroundEdge > &getHexahedraAroundEdgeArray();

/** \brief Returns the HexahedraAroundQuad array (i.e. provide the hexahedron indices adjacent to each quad). */
const helper::vector< HexahedraAroundQuad > &getHexahedraAroundQuadArray();



/** \brief Returns the EdgesInTetrahedron array (i.e. provide the 6 edge indices for each tetrahedron). */
const helper::vector< EdgesInTetrahedron > &getEdgesInTetrahedronArray();

/** \brief Returns the TrianglesInTetrahedron array (i.e. provide the 4 triangle indices for each tetrahedron). */
const helper::vector< TrianglesInTetrahedron > &getTrianglesInTetrahedronArray();

/** \brief Returns the TetrahedraAroundVertex array (i.e. provide the tetrahedron indices adjacent to each vertex). */
const helper::vector< TetrahedraAroundVertex > &getTetrahedraAroundVertexArray();

/** \brief Returns the TetrahedraAroundEdge array (i.e. provide the tetrahedron indices adjacent to each edge). */
const helper::vector< TetrahedraAroundEdge > &getTetrahedraAroundEdgeArray();

/** \brief Returns the TetrahedraAroundTriangle array (i.e. provide the tetrahedron indices adjacent to each triangle). */
const helper::vector< TetrahedraAroundTriangle > &getTetrahedraAroundTriangleArray();

public:
typedef helper::vector<defaulttype::Vec<3, SReal > > SeqPoints;
Data< SeqPoints > seqPoints; ///< List of point positions
Expand Down Expand Up @@ -480,65 +535,7 @@ class SOFA_BASE_TOPOLOGY_API MeshTopology : public core::topology::BaseMeshTopol
*/
void createHexahedraAroundQuadArray();




/** \brief Returns the EdgesInTriangle array (i.e. provide the 3 edge indices for each triangle). */
const helper::vector< EdgesInTriangle > &getEdgesInTriangleArray();

/** \brief Returns the TrianglesAroundVertex array (i.e. provide the triangles indices adjacent to each vertex). */
const helper::vector< TrianglesAroundVertex > &getTrianglesAroundVertexArray();

/** \brief Returns the TrianglesAroundEdge array (i.e. provide the triangles indices adjacent to each edge). */
const helper::vector< TrianglesAroundEdge > &getTrianglesAroundEdgeArray();



/** \brief Returns the EdgesInQuadArray array (i.e. provide the 4 edge indices for each quad) */
const helper::vector< EdgesInQuad > &getEdgesInQuadArray();

/** \brief Returns the QuadsAroundVertex array (i.e. provide the quad indices adjacent to each vertex). */
const helper::vector< QuadsAroundVertex > &getQuadsAroundVertexArray();

/** \brief Returns the QuadsAroundEdge array (i.e. provide the quad indices adjacent to each edge). */
const helper::vector< QuadsAroundEdge > &getQuadsAroundEdgeArray();



/** \brief Returns the EdgesInHexahedron array (i.e. provide the 12 edge indices for each hexahedron). */
const helper::vector< EdgesInHexahedron > &getEdgesInHexahedronArray();

/** \brief Returns the QuadsInHexahedron array (i.e. provide the 8 quad indices for each hexahedron). */
const helper::vector< QuadsInHexahedron > &getQuadsInHexahedronArray();

/** \brief Returns the HexahedraAroundVertex array (i.e. provide the hexahedron indices adjacent to each vertex).*/
const helper::vector< HexahedraAroundVertex > &getHexahedraAroundVertexArray();

/** \brief Returns the HexahedraAroundEdge array (i.e. provide the hexahedron indices adjacent to each edge). */
const helper::vector< HexahedraAroundEdge > &getHexahedraAroundEdgeArray();

/** \brief Returns the HexahedraAroundQuad array (i.e. provide the hexahedron indices adjacent to each quad). */
const helper::vector< HexahedraAroundQuad > &getHexahedraAroundQuadArray();



/** \brief Returns the EdgesInTetrahedron array (i.e. provide the 6 edge indices for each tetrahedron). */
const helper::vector< EdgesInTetrahedron > &getEdgesInTetrahedronArray();

/** \brief Returns the TrianglesInTetrahedron array (i.e. provide the 4 triangle indices for each tetrahedron). */
const helper::vector< TrianglesInTetrahedron > &getTrianglesInTetrahedronArray();

/** \brief Returns the TetrahedraAroundVertex array (i.e. provide the tetrahedron indices adjacent to each vertex). */
const helper::vector< TetrahedraAroundVertex > &getTetrahedraAroundVertexArray();

/** \brief Returns the TetrahedraAroundEdge array (i.e. provide the tetrahedron indices adjacent to each edge). */
const helper::vector< TetrahedraAroundEdge > &getTetrahedraAroundEdgeArray();

/** \brief Returns the TetrahedraAroundTriangle array (i.e. provide the tetrahedron indices adjacent to each triangle). */
const helper::vector< TetrahedraAroundTriangle > &getTetrahedraAroundTriangleArray();




public:
/** \brief Returns the index of the edge joining vertex v1 and vertex v2; returns -1 if no edge exists
*
Expand Down
13 changes: 10 additions & 3 deletions SofaKernel/modules/SofaBaseTopology/QuadSetTopologyContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ void QuadSetTopologyContainer::createQuadsAroundVertexArray()
{
clearQuadsAroundVertex();
}

m_quadsAroundVertex.resize( getNbPoints() );

helper::ReadAccessor< Data< sofa::helper::vector<Quad> > > m_quad = d_quad;

if (getNbPoints() == 0) // in case only Data have been copied and not going thourgh AddTriangle methods.
this->setNbPoints(d_initPoints.getValue().size());

m_quadsAroundVertex.resize(getNbPoints());

for (size_t i=0; i<m_quad.size(); ++i)
{
// adding quad i in the quad shell of all points
Expand Down Expand Up @@ -250,7 +254,10 @@ const QuadSetTopologyContainer::Quad QuadSetTopologyContainer::getQuad (QuadID i
if(!hasQuads())
createQuadSetArray();

return (d_quad.getValue())[i];
if (i >= getNbQuads())
return Quad(-1, -1, -1, -1);
else
return (d_quad.getValue())[i];
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ cmake_minimum_required(VERSION 3.1)
project(SofaBaseTopology_test)

set(SOURCE_FILES
fake_TopologyScene.h
fake_TopologyScene.cpp

PointSetTopology_test.cpp
EdgeSetTopology_test.cpp
TriangleSetTopology_test.cpp
QuadSetTopology_test.cpp
TetrahedronSetTopology_test.cpp
HexahedronSetTopology_test.cpp

MeshTopology_test.cpp

RegularGridTopology_test.cpp
TetrahedronNumericalIntegration_test.cpp
TriangleNumericalIntegration_test.cpp)

add_definitions("-DSOFABASETOPOLOGY_TEST_SCENES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/scenes\"")
add_definitions("-DSOFABASETOPOLOGY_TEST_RESOURCES_DIR=\"${CMAKE_SOURCE_DIR}/share\"")
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} SofaGTestMain SofaTest)

Expand Down
Loading