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

-Added tests for cad #255

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 72 additions & 0 deletions cadfac/tst/GeomLinkerTestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ TEST(GeomLinkerTestSuite, fromSurfMesh)
vtkW.setDataOptions(gmds::N|gmds::R);
vtkW.write("toto_link.vtk");

VTKWriter vtkE(&ioService);
vtkE.setCellOptions(gmds::N|gmds::E);
vtkE.setDataOptions(gmds::N|gmds::E);
vtkE.write("toto_link_e.vtk");

VTKWriter vtkF(&ioService);
vtkF.setCellOptions(gmds::N|gmds::F);
vtkF.setDataOptions(gmds::N|gmds::F);
vtkF.write("toto_link_f.vtk");

ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim<Node>(1));
ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim<Node>(2));
ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim<Node>(4));
Expand Down Expand Up @@ -84,3 +94,65 @@ TEST(GeomLinkerTestSuite, fromSurfMesh)
ASSERT_EQ(2, linker.getGeomId(n1));

}
/*----------------------------------------------------------------------------*/
TEST(GeomLinkerTestSuite, linkUsingTypes){
Mesh m_vol(gmds::MeshModel(DIM3|R|F|E|N|
R2N|R2F|R2E|
F2N|F2R|F2E|
E2F|E2N|N2E|N2R));

std::string dir(TEST_SAMPLES_DIR);
std::string vtk_file = dir+"/tet_in_box.vtk";
IGMeshIOService ioService(&m_vol);

VTKReader vtkReader(&ioService);
vtkReader.setCellOptions(gmds::N|gmds::R);
vtkReader.read(vtk_file);

MeshDoctor doc(&m_vol);
doc.buildFacesAndR2F();
doc.buildEdgesAndX2E();
doc.updateUpwardConnectivity();

cad::FACManager manager;
cad::GeomMeshLinker linker(&m_vol,&manager);

linker.linkToPoint(m_vol.get<Node>(1),2);
linker.linkToPoint(m_vol.get<Node>(2),3);
linker.linkToPoint(m_vol.get<Node>(4),5);
linker.linkToPoint(m_vol.get<Node>(7),8);

ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim<Node>(1));
ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim<Node>(2));
ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim<Node>(4));
ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim<Node>(7));
ASSERT_EQ(2, linker.getGeomId<Node>(1));
ASSERT_EQ(3, linker.getGeomId<Node>(2));
ASSERT_EQ(5, linker.getGeomId<Node>(4));
ASSERT_EQ(8, linker.getGeomId<Node>(7));

linker.linkToCurve(m_vol.get<Edge>(14),2);
linker.linkToCurve(m_vol.get<Edge>(67),7);
linker.linkToCurve(m_vol.get<Edge>(83),6);
linker.linkToCurve(m_vol.get<Edge>(109),1);

ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim<Edge>(14));
ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim<Edge>(67));
ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim<Edge>(83));
ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim<Edge>(109));
ASSERT_EQ(2, linker.getGeomId<Edge>(14));
ASSERT_EQ(7, linker.getGeomId<Edge>(67));
ASSERT_EQ(6, linker.getGeomId<Edge>(83));
ASSERT_EQ(1, linker.getGeomId<Edge>(109));

linker.linkToSurface(m_vol.get<Face>(90), 6);
linker.linkToSurface(m_vol.get<Face>(145), 1);

ASSERT_EQ(cad::GeomMeshLinker::LinkSurface, linker.getGeomDim<Face>(90));
ASSERT_EQ(cad::GeomMeshLinker::LinkSurface, linker.getGeomDim<Face>(145));
ASSERT_EQ(6, linker.getGeomId<Face>(90));
ASSERT_EQ(1, linker.getGeomId<Face>(145));

linker.writeVTKDebugMesh("toto_type_link_debug.vtk");
}

27 changes: 27 additions & 0 deletions cadfac/tst/GeomTopologyTestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,32 @@ TEST(GeomTopologyTestSuite, cube_topo)
// tests on the points
std::vector<cad::GeomPoint*> pnts;
manager.getPoints(pnts);
math::Point math_p(pnts[0]->point());
ASSERT_EQ(math_p.X(),0);
ASSERT_EQ(math_p.Y(),0);
ASSERT_EQ(math_p.Z(),0);
for(auto p:pnts){
ASSERT_EQ(p->dim(), 0);
ASSERT_EQ(p->volumes().size(),1);
ASSERT_EQ(p->surfaces().size(),3);
ASSERT_EQ(p->curves().size(),3);

p->setName("Point"+std::to_string(p->id()));
ASSERT_EQ(p->name(), "Point"+std::to_string(p->id()));

}
cad::GeomPoint* last_p = pnts[pnts.size()-1];
last_p->project(math_p);

ASSERT_EQ(math_p.X(),last_p->X());
ASSERT_EQ(math_p.Y(),last_p->Y());
ASSERT_EQ(math_p.Z(),last_p->Z());
//==================================
// tests on the curves
std::vector<cad::GeomCurve*> curves;
manager.getCurves(curves);
for(auto c:curves){
ASSERT_EQ(c->dim(), 1);
ASSERT_EQ(c->volumes().size(),1);
std::vector<cad::GeomSurface*> surfs =c->surfaces();
std::vector<cad::GeomPoint*> pts =c->points();
Expand All @@ -56,6 +72,7 @@ TEST(GeomTopologyTestSuite, cube_topo)
std::vector<cad::GeomSurface*> surfs;
manager.getSurfaces(surfs);
for(auto s:surfs){
ASSERT_EQ(s->dim(), 2);
ASSERT_EQ(s->volumes().size(),1);
ASSERT_EQ(s->curves().size(),4);
ASSERT_EQ(s->points().size(),4);
Expand All @@ -64,7 +81,17 @@ TEST(GeomTopologyTestSuite, cube_topo)
// tests on the volumes
std::vector<cad::GeomVolume*> vols;
manager.getVolumes(vols);
cad::GeomVolume* vol(vols[0]);
math::Point p(0,0,0);

try{
vol->project(p);
}catch(GMDSException &e){
ASSERT_EQ(e.what(),std::string("GeomVolume::project not implemented"));
}

for(auto v:vols){
ASSERT_EQ(v->dim(), 3);
ASSERT_EQ(v->surfaces().size(),6);
ASSERT_EQ(v->curves().size(),12);
ASSERT_EQ(v->points().size(),8);
Expand Down