diff --git a/cadfac/tst/GeomLinkerTestSuite.h b/cadfac/tst/GeomLinkerTestSuite.h index a7c4d14de..c3fcd4941 100644 --- a/cadfac/tst/GeomLinkerTestSuite.h +++ b/cadfac/tst/GeomLinkerTestSuite.h @@ -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(1)); ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim(2)); ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim(4)); @@ -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(1),2); + linker.linkToPoint(m_vol.get(2),3); + linker.linkToPoint(m_vol.get(4),5); + linker.linkToPoint(m_vol.get(7),8); + + ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim(1)); + ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim(2)); + ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim(4)); + ASSERT_EQ(cad::GeomMeshLinker::LinkPoint, linker.getGeomDim(7)); + ASSERT_EQ(2, linker.getGeomId(1)); + ASSERT_EQ(3, linker.getGeomId(2)); + ASSERT_EQ(5, linker.getGeomId(4)); + ASSERT_EQ(8, linker.getGeomId(7)); + + linker.linkToCurve(m_vol.get(14),2); + linker.linkToCurve(m_vol.get(67),7); + linker.linkToCurve(m_vol.get(83),6); + linker.linkToCurve(m_vol.get(109),1); + + ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim(14)); + ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim(67)); + ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim(83)); + ASSERT_EQ(cad::GeomMeshLinker::LinkCurve, linker.getGeomDim(109)); + ASSERT_EQ(2, linker.getGeomId(14)); + ASSERT_EQ(7, linker.getGeomId(67)); + ASSERT_EQ(6, linker.getGeomId(83)); + ASSERT_EQ(1, linker.getGeomId(109)); + + linker.linkToSurface(m_vol.get(90), 6); + linker.linkToSurface(m_vol.get(145), 1); + + ASSERT_EQ(cad::GeomMeshLinker::LinkSurface, linker.getGeomDim(90)); + ASSERT_EQ(cad::GeomMeshLinker::LinkSurface, linker.getGeomDim(145)); + ASSERT_EQ(6, linker.getGeomId(90)); + ASSERT_EQ(1, linker.getGeomId(145)); + + linker.writeVTKDebugMesh("toto_type_link_debug.vtk"); +} + diff --git a/cadfac/tst/GeomTopologyTestSuite.h b/cadfac/tst/GeomTopologyTestSuite.h index 8dfc3db20..424af9541 100644 --- a/cadfac/tst/GeomTopologyTestSuite.h +++ b/cadfac/tst/GeomTopologyTestSuite.h @@ -35,16 +35,32 @@ TEST(GeomTopologyTestSuite, cube_topo) // tests on the points std::vector 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 curves; manager.getCurves(curves); for(auto c:curves){ + ASSERT_EQ(c->dim(), 1); ASSERT_EQ(c->volumes().size(),1); std::vector surfs =c->surfaces(); std::vector pts =c->points(); @@ -56,6 +72,7 @@ TEST(GeomTopologyTestSuite, cube_topo) std::vector 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); @@ -64,7 +81,17 @@ TEST(GeomTopologyTestSuite, cube_topo) // tests on the volumes std::vector 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);