예제 #1
0
TEST(FileIO, DISABLED_TetGenSmeshInterface)
#endif
{
    std::string const file_name (BaseLib::BuildInfo::data_path + "/FileIO/AmmerSubsurfaceCoarse.vtu");
    std::unique_ptr<MeshLib::Mesh const> const mesh (MeshLib::IO::readMeshFromFile(file_name));

    std::string const tg_new_name ("TestSmeshWriter");
    std::string const output_name(BaseLib::BuildInfo::tests_tmp_path + tg_new_name + ".smesh");
    std::vector<MeshLib::Node> attr_pnts;
    FileIO::TetGenInterface tgi;
    bool result (tgi.writeTetGenSmesh(output_name, *mesh, attr_pnts));
    ASSERT_TRUE(result);

    GeoLib::GEOObjects geo_objects;
    result = tgi.readTetGenGeometry(output_name, geo_objects);
    ASSERT_TRUE(result);
    std::string const ref_name(BaseLib::BuildInfo::data_path + "/FileIO/AmmerSubsurfaceCoarse.smesh");
    result = tgi.readTetGenGeometry(ref_name, geo_objects);
    ASSERT_TRUE(result);

    std::vector<GeoLib::Point*> const& ref_pnts (*geo_objects.getPointVec("AmmerSubsurfaceCoarse"));
    std::vector<GeoLib::Point*> const& new_pnts (*geo_objects.getPointVec(tg_new_name));
    ASSERT_EQ(ref_pnts.size(), new_pnts.size());

    std::vector<GeoLib::Surface*> const& ref_sfc (*geo_objects.getSurfaceVec("AmmerSubsurfaceCoarse"));
    std::vector<GeoLib::Surface*> const& new_sfc (*geo_objects.getSurfaceVec(tg_new_name));
    ASSERT_EQ(ref_sfc.size(), new_sfc.size());

    for (std::size_t i=0; i<ref_sfc.size(); ++i)
        ASSERT_EQ(ref_sfc[i]->getNumberOfTriangles(), new_sfc[i]->getNumberOfTriangles());

    std::remove(output_name.c_str());
}
예제 #2
0
void MshView::exportToTetGen()
{
	QModelIndex const index = this->selectionModel()->currentIndex();
	if (!index.isValid())
		return;

	MeshLib::Mesh const*const mesh = static_cast<MshModel*>(this->model())->getMesh(index);
	QSettings const settings;
	QString const filename = QFileDialog::getSaveFileName(this, "Write TetGen input file to",
		settings.value("lastOpenedTetgenFileDirectory").toString(),
		"TetGen Geometry (*.smesh)");
	if (!filename.isEmpty())
	{
		FileIO::TetGenInterface tg;
		std::vector<MeshLib::Node> attr;
		tg.writeTetGenSmesh(filename.toStdString(), *mesh, attr);
	}
}