mirror of https://github.com/CGAL/cgal
Merge pull request #6034 from sloriot/CGAL_data-moving_files
CGAL Data: doc + more data moves
This commit is contained in:
commit
7b9113ac0c
|
|
@ -28,6 +28,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
#if defined(BOOST_MSVC)
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
|
|
@ -164,6 +165,11 @@ public:
|
||||||
return private_read(::_readImage(file));
|
return private_read(::_readImage(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool read(const std::string& file)
|
||||||
|
{
|
||||||
|
return read(file.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
bool read_raw(const char* file,
|
bool read_raw(const char* file,
|
||||||
const unsigned int rx,
|
const unsigned int rx,
|
||||||
const unsigned int ry,
|
const unsigned int ry,
|
||||||
|
|
|
||||||
|
|
@ -191,28 +191,12 @@ int main() {
|
||||||
image.set_data(nullptr); // trick to avoid ~Image_3 segfault.
|
image.set_data(nullptr); // trick to avoid ~Image_3 segfault.
|
||||||
|
|
||||||
|
|
||||||
const char* filenames[] = {
|
const std::string filename = CGAL::data_file_path("images/skull_2.9.inr");
|
||||||
"data/skull_2.9.inr",
|
|
||||||
"../../examples/Surface_mesher/data/skull_2.9.inr",
|
|
||||||
"../../../Surface_mesher/examples/Surface_mesher/data/skull_2.9.inr",
|
|
||||||
"../Surface_mesher_Examples/data/skull_2.9.inr"
|
|
||||||
};
|
|
||||||
|
|
||||||
std::size_t file_index = 0;
|
std::cerr << "Opening file " << filename << "...\n";
|
||||||
for( ; file_index < sizeof(filenames); ++file_index)
|
|
||||||
{
|
|
||||||
std::ifstream image_file(filenames[file_index], std::ios_base::binary | std::ios_base::in );
|
|
||||||
if(image_file) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(file_index < sizeof(filenames) );
|
|
||||||
|
|
||||||
std::cerr << "Opening file " << filenames[file_index] << "...\n";
|
|
||||||
|
|
||||||
CGAL::Image_3 image2;
|
CGAL::Image_3 image2;
|
||||||
const bool result = image2.read(filenames[file_index]);
|
const bool result = image2.read(filename);
|
||||||
assert(result);
|
assert(result);
|
||||||
|
|
||||||
std::cerr << "Image info:"
|
std::cerr << "Image info:"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace CGAL{
|
||||||
|
/// returns the full path of a data file from \cgal.
|
||||||
|
/// The data files are located in the `data` directory of a \cgal release
|
||||||
|
/// or in the directory `Data/data` from a git branch checkout.
|
||||||
|
/// That function uses as prefix the environment variable `CGAL_DATA_DIR` if set, and
|
||||||
|
/// the value of the macro `CGAL_DATA_DIR` otherwise.
|
||||||
|
/// When using `cmake` and a standard \cgal setup, linking the target using that function
|
||||||
|
/// with the target `CGAL::Data` will automatically set the macro `CGAL_DATA_DIR`
|
||||||
|
/// pointing to the data directory of the \cgal version used.
|
||||||
|
/// The function will attempt to open the file at the returned location
|
||||||
|
/// and will print a warning message via `std::cerr` if the file could not be opened.
|
||||||
|
std::string data_file_path(const std::string& filename);
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -28,7 +28,7 @@ using namespace CGAL::parameters;
|
||||||
|
|
||||||
int main(int argc, char*argv[])
|
int main(int argc, char*argv[])
|
||||||
{
|
{
|
||||||
const char* fname = (argc>1)?argv[1]:"data/skull_2.9.inr";
|
const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/skull_2.9.inr");
|
||||||
// Load image
|
// Load image
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if(!image.read(fname)){
|
if(!image.read(fname)){
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ struct Image_to_multiple_iso_level_sets {
|
||||||
|
|
||||||
int main(int argc, char*argv[])
|
int main(int argc, char*argv[])
|
||||||
{
|
{
|
||||||
const char* fname = (argc>1)?argv[1]:"data/skull_2.9.inr";
|
const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/skull_2.9.inr");
|
||||||
// Load image
|
// Load image
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if(!image.read(fname)){
|
if(!image.read(fname)){
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ using namespace CGAL::parameters;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char* fname = (argc > 1) ? argv[1] : "data/skull_2.9.inr";
|
const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("images/skull_2.9.inr");
|
||||||
/// [Load image]
|
/// [Load image]
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if (!image.read(fname)) {
|
if (!image.read(fname)) {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ using namespace CGAL::parameters;
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
/// [Loads image]
|
/// [Loads image]
|
||||||
const char* fname = (argc>1)?argv[1]:"data/liver.inr.gz";
|
const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/liver.inr.gz");
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if(!image.read(fname)){
|
if(!image.read(fname)){
|
||||||
std::cerr << "Error: Cannot read file " << fname << std::endl;
|
std::cerr << "Error: Cannot read file " << fname << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ using namespace CGAL::parameters;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char* fname = (argc>1)?argv[1]:"data/liver.inr.gz";
|
const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/liver.inr.gz");
|
||||||
// Loads image
|
// Loads image
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if(!image.read(fname)){
|
if(!image.read(fname)){
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ using namespace CGAL::parameters;
|
||||||
// not documented.
|
// not documented.
|
||||||
bool add_1D_features(const CGAL::Image_3& image,
|
bool add_1D_features(const CGAL::Image_3& image,
|
||||||
Mesh_domain& domain,
|
Mesh_domain& domain,
|
||||||
const char* lines_fname)
|
const std::string lines_fname)
|
||||||
{
|
{
|
||||||
typedef K::Point_3 Point_3;
|
typedef K::Point_3 Point_3;
|
||||||
typedef unsigned char Word_type;
|
typedef unsigned char Word_type;
|
||||||
|
|
@ -72,7 +72,7 @@ bool add_1D_features(const CGAL::Image_3& image,
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char* fname = (argc>1)?argv[1]:"data/420.inr";
|
const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/420.inr");
|
||||||
// Loads image
|
// Loads image
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if(!image.read(fname)){
|
if(!image.read(fname)){
|
||||||
|
|
@ -84,7 +84,7 @@ int main(int argc, char* argv[])
|
||||||
Mesh_domain domain = Mesh_domain::create_labeled_image_mesh_domain(image);
|
Mesh_domain domain = Mesh_domain::create_labeled_image_mesh_domain(image);
|
||||||
|
|
||||||
/// Declare 1D-features, see above [Call add_1D_features]
|
/// Declare 1D-features, see above [Call add_1D_features]
|
||||||
const char* lines_fname = (argc>2)?argv[2]:"data/420.polylines.txt";
|
const std::string lines_fname = (argc>2)?argv[2]:CGAL::data_file_path("images/420.polylines.txt");
|
||||||
|
|
||||||
if(!add_1D_features(image, domain, lines_fname)) {
|
if(!add_1D_features(image, domain, lines_fname)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ using namespace CGAL::parameters;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char* fname = (argc>1)?argv[1]:"data/liver.inr.gz";
|
const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/liver.inr.gz");
|
||||||
// Domain
|
// Domain
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if(!image.read(fname)){
|
if(!image.read(fname)){
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ using namespace CGAL::parameters;
|
||||||
|
|
||||||
int main(int argc, char*argv[])
|
int main(int argc, char*argv[])
|
||||||
{
|
{
|
||||||
const char* fname = (argc>1)?argv[1]:"data/liver.inr.gz";
|
const std::string fname = (argc>1)?argv[1]:CGAL::data_file_path("images/liver.inr.gz");
|
||||||
// Domain
|
// Domain
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if(!image.read(fname)){
|
if(!image.read(fname)){
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
template <typename Point_3>
|
template <typename Point_3>
|
||||||
bool read_polylines(const char* fname,
|
bool read_polylines(const std::string fname,
|
||||||
std::vector<std::vector<Point_3> >& polylines)
|
std::vector<std::vector<Point_3> >& polylines)
|
||||||
{
|
{
|
||||||
std::ifstream ifs(fname);
|
std::ifstream ifs(fname);
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -55,7 +55,7 @@ public:
|
||||||
// Data generation
|
// Data generation
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
Image image;
|
Image image;
|
||||||
if (!image.read("data/skull_2.9.inr"))
|
if (!image.read(CGAL::data_file_path("images/skull_2.9.inr")))
|
||||||
{
|
{
|
||||||
std::cout << "Image reading error. Exit test.\n";
|
std::cout << "Image reading error. Exit test.\n";
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public:
|
||||||
// Data generation
|
// Data generation
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
Image image;
|
Image image;
|
||||||
if (!image.read("data/skull_2.9.inr"))
|
if (!image.read(CGAL::data_file_path("images/skull_2.9.inr")))
|
||||||
{
|
{
|
||||||
std::cout << "Image reading error. Exit test.\n";
|
std::cout << "Image reading error. Exit test.\n";
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public:
|
||||||
// Data generation
|
// Data generation
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
Image image;
|
Image image;
|
||||||
image.read("data/liver.inr.gz");
|
image.read(CGAL::data_file_path("images/liver.inr.gz"));
|
||||||
|
|
||||||
std::cout << "\tSeed is\t"
|
std::cout << "\tSeed is\t"
|
||||||
<< CGAL::get_default_random().get_seed() << std::endl;
|
<< CGAL::get_default_random().get_seed() << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public:
|
||||||
// Data generation
|
// Data generation
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
Image image;
|
Image image;
|
||||||
image.read("data/liver.inr.gz");
|
image.read(CGAL::data_file_path("images/liver.inr.gz"));
|
||||||
|
|
||||||
std::cout << "\tSeed is\t"
|
std::cout << "\tSeed is\t"
|
||||||
<< CGAL::get_default_random().get_seed() << std::endl;
|
<< CGAL::get_default_random().get_seed() << std::endl;
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -22,7 +22,7 @@ int main() {
|
||||||
C2t3 c2t3 (tr); // 2D-complex in 3D-Delaunay triangulation
|
C2t3 c2t3 (tr); // 2D-complex in 3D-Delaunay triangulation
|
||||||
|
|
||||||
// the 'function' is a 3D gray level image
|
// the 'function' is a 3D gray level image
|
||||||
Gray_level_image image("data/skull_2.9.inr", 2.9f);
|
Gray_level_image image(CGAL::data_file_path("images/skull_2.9.inr"), 2.9f);
|
||||||
|
|
||||||
// Carefully chosen bounding sphere: the center must be inside the
|
// Carefully chosen bounding sphere: the center must be inside the
|
||||||
// surface defined by 'image' and the radius must be high enough so that
|
// surface defined by 'image' and the radius must be high enough so that
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <CGAL/auto_link/ImageIO.h>
|
#include <CGAL/auto_link/ImageIO.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifdef CGAL_SURFACE_MESHER_DEBUG_GRAY_LEVEL_IMAGE_3_CONSTRUCTOR
|
#ifdef CGAL_SURFACE_MESHER_DEBUG_GRAY_LEVEL_IMAGE_3_CONSTRUCTOR
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
@ -44,7 +45,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Gray_level_image_3(const char* file, float isoval, bool positive_inside_=true, float value_outside = 0.f)
|
Gray_level_image_3(const std::string& file, float isoval, bool positive_inside_=true, float value_outside = 0.f)
|
||||||
: Image_3(),
|
: Image_3(),
|
||||||
isovalue(isoval),
|
isovalue(isoval),
|
||||||
positive_inside(positive_inside_),
|
positive_inside(positive_inside_),
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -32,7 +32,7 @@ using namespace CGAL::parameters;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const char* filename = "data/liver.inr.gz";
|
const std::string filename = CGAL::data_file_path("images/liver.inr.gz");
|
||||||
|
|
||||||
CGAL::Image_3 image;
|
CGAL::Image_3 image;
|
||||||
if (!image.read(filename)) {
|
if (!image.read(filename)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue