docs, bundle required libs in repo

This commit is contained in:
alemuntoni 2022-11-25 15:09:45 +01:00
parent 20d2e2e470
commit f7eeb4ba92
23 changed files with 86723 additions and 14 deletions

5
.gitignore vendored
View File

@ -23,6 +23,11 @@ build/*
install/* install/*
# external libraries automatically downloaded by cmake # external libraries automatically downloaded by cmake
src/external/easyexif*/test-images/*
src/external/glew*/auto/*
src/external/glew*/build/*
src/external/glew*/config/*
src/external/glew*/doc/*
src/external/downloads/* src/external/downloads/*
src/external/tmp.zip src/external/tmp.zip

View File

@ -13,7 +13,8 @@ option(
ON) ON)
set(MESHLAB_EXTERNAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/downloads") set(MESHLAB_EXTERNAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/downloads")
set(MESHLAB_EXTERNAL_DOWNLOAD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/downloads") set(MESHLAB_EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(MESHLAB_EXTERNAL_DOWNLOAD_DIR "${MESHLAB_EXTERNAL_DIR}/downloads")
add_library(external-disable-warnings INTERFACE) add_library(external-disable-warnings INTERFACE)
if(MESHLAB_BUILD_EXTERNAL_SOURCES_WITHOUT_WARNINGS) if(MESHLAB_BUILD_EXTERNAL_SOURCES_WITHOUT_WARNINGS)

View File

@ -2,17 +2,21 @@
This folder contains a set of `cmake` configuration files to download and build external libraries required by MeshLab and its plugins. This folder contains a set of `cmake` configuration files to download and build external libraries required by MeshLab and its plugins.
Most of the times, `cmake` will first try to find the required external libraries, and only if they are not found, it will download them. Most of the times, `cmake` will first try to find the external libraries installed in the system, and only if they are not found, it will download them.
## Required libraries ## Required libraries
The libraries that are required to build MeshLab are: The libraries that are required to build MeshLab are:
- Eigen
- GLEW - GLEW
- easyexif - easyexif
Since these libraries are required, they are bundled into the `external` directory (with the exception of eigen, which is bundled in the VCGLib subrepo).
Without these two libraries (or their relative system provided libraries), MeshLab cannot be built. Without these two libraries (or their relative system provided libraries), MeshLab cannot be built.
All the other libraries are optional, and they will be downloaded automatically by cmake during configuration in the `external/downloads`.
## Optional libraries ## Optional libraries
All the other libraries are optional. Cmake adopts the following strategy: All the other libraries are optional. Cmake adopts the following strategy:

29
src/external/easyexif-1.0/.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
demo
*.exe
*.out
*.app

10
src/external/easyexif-1.0/CONTRIBUTORS vendored Normal file
View File

@ -0,0 +1,10 @@
The following people have contributed patches or issues to EasyEXIF:
Seth Fowler
Val Malykh
Carlos Apablaza Brito
Simon Fuhrmann
Toshiaki Ohkuma
pet.b.hunt
Jason Moey
Tomas Volf

24
src/external/easyexif-1.0/LICENSE vendored Normal file
View File

@ -0,0 +1,24 @@
Copyright (c) 2010-2015 Mayank Lahiri
mlahiri@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

75
src/external/easyexif-1.0/README.md vendored Normal file
View File

@ -0,0 +1,75 @@
easyexif
========
A tiny ISO-compliant C++ EXIF parsing library.
EasyEXIF is a tiny, lightweight C++ library that parses basic information out of EXIF files. It uses only the std::string library and is otherwise pure C++. You pass it the the binary contents of an entire JPEG file, and it parses out a few of the most important EXIF fields for you.
Why use this library? __Include one .h file, compile one .cc file, and that's it.__
Sometimes you just need to quickly extract basic information from a JPEG file's EXIF headers: the time the image was taken (not the file timestamp, the camera's internal time), the F-stop or exposure time, GPS information embedded in the EXIF file, what the camera make and model was, etc. Unfortunately, all the EXIF libraries out there are not very lightweight or easy to integrate into larger programs. EasyEXIF aims to solve that problem, and is released under a very liberal BSD License for use practically anywhere.
### Features:
1. Supports common Exif fields including GPS, ISO speed, etc.
2. Extensively documented in the source.
3. Valgrind tested for memory leaks.
4. Handles corrupt JPEGs.
5. Compiles without complaints using `-Wall -Wextra -Werror -pedantic -ansi` on gcc v4.8.2
6. No uses of new/malloc.
### License
BSD.
### Contributions
Reasonable pull requests are gladly accepted.
The following people have committed patches to EasyExif.
* Tomas Volf
* Seth Fowler
* Val Malykh
* Carlos Apablaza Brito
* Simon Fuhrmann
* Toshiaki Ohkuma
* pet.b.hunt
* Jason Moey
### Example:
```C++
#include "exif.h"
EXIFInfo result;
result.parseFrom(JPEGFileBuffer, BufferSize);
printf("Camera make : %s\n", result.Make.c_str());
printf("Camera model : %s\n", result.Model.c_str());
printf("Software : %s\n", result.Software.c_str());
printf("Bits per sample : %d\n", result.BitsPerSample);
printf("Image width : %d\n", result.ImageWidth);
printf("Image height : %d\n", result.ImageHeight);
printf("Image description : %s\n", result.ImageDescription.c_str());
printf("Image orientation : %d\n", result.Orientation);
printf("Image copyright : %s\n", result.Copyright.c_str());
printf("Image date/time : %s\n", result.DateTime.c_str());
printf("Original date/time: %s\n", result.DateTimeOriginal.c_str());
printf("Digitize date/time: %s\n", result.DateTimeDigitized.c_str());
printf("Subsecond time : %s\n", result.SubSecTimeOriginal.c_str());
printf("Exposure time : 1/%d s\n", (unsigned) (1.0/result.ExposureTime));
printf("F-stop : f/%.1f\n", result.FNumber);
printf("ISO speed : %d\n", result.ISOSpeedRatings);
printf("Subject distance : %f m\n", result.SubjectDistance);
printf("Exposure bias : %f EV\n", result.ExposureBiasValue);
printf("Flash used? : %d\n", result.Flash);
printf("Metering mode : %d\n", result.MeteringMode);
printf("Lens focal length : %f mm\n", result.FocalLength);
printf("35mm focal length : %u mm\n", result.FocalLengthIn35mm);
printf("GPS Latitude : %f deg\n", result.GeoLocation.Latitude);
printf("GPS Longitude : %f deg\n", result.GeoLocation.Longitude);
printf("GPS Altitude : %f m\n", result.GeoLocation.Altitude);
```

82
src/external/easyexif-1.0/demo.cpp vendored Normal file
View File

@ -0,0 +1,82 @@
#include <stdio.h>
#include "exif.h"
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Usage: demo <JPEG file>\n");
return -1;
}
// Read the JPEG file into a buffer
FILE *fp = fopen(argv[1], "rb");
if (!fp) {
printf("Can't open file.\n");
return -1;
}
fseek(fp, 0, SEEK_END);
unsigned long fsize = ftell(fp);
rewind(fp);
unsigned char *buf = new unsigned char[fsize];
if (fread(buf, 1, fsize, fp) != fsize) {
printf("Can't read file.\n");
delete[] buf;
return -2;
}
fclose(fp);
// Parse EXIF
easyexif::EXIFInfo result;
int code = result.parseFrom(buf, fsize);
delete[] buf;
if (code) {
printf("Error parsing EXIF: code %d\n", code);
return -3;
}
// Dump EXIF information
printf("Camera make : %s\n", result.Make.c_str());
printf("Camera model : %s\n", result.Model.c_str());
printf("Software : %s\n", result.Software.c_str());
printf("Bits per sample : %d\n", result.BitsPerSample);
printf("Image width : %d\n", result.ImageWidth);
printf("Image height : %d\n", result.ImageHeight);
printf("Image description : %s\n", result.ImageDescription.c_str());
printf("Image orientation : %d\n", result.Orientation);
printf("Image copyright : %s\n", result.Copyright.c_str());
printf("Image date/time : %s\n", result.DateTime.c_str());
printf("Original date/time : %s\n", result.DateTimeOriginal.c_str());
printf("Digitize date/time : %s\n", result.DateTimeDigitized.c_str());
printf("Subsecond time : %s\n", result.SubSecTimeOriginal.c_str());
printf("Exposure time : 1/%d s\n",
(unsigned)(1.0 / result.ExposureTime));
printf("F-stop : f/%.1f\n", result.FNumber);
printf("ISO speed : %d\n", result.ISOSpeedRatings);
printf("Subject distance : %f m\n", result.SubjectDistance);
printf("Exposure bias : %f EV\n", result.ExposureBiasValue);
printf("Flash used? : %d\n", result.Flash);
printf("Metering mode : %d\n", result.MeteringMode);
printf("Lens focal length : %f mm\n", result.FocalLength);
printf("35mm focal length : %u mm\n", result.FocalLengthIn35mm);
printf("GPS Latitude : %f deg (%f deg, %f min, %f sec %c)\n",
result.GeoLocation.Latitude, result.GeoLocation.LatComponents.degrees,
result.GeoLocation.LatComponents.minutes,
result.GeoLocation.LatComponents.seconds,
result.GeoLocation.LatComponents.direction);
printf("GPS Longitude : %f deg (%f deg, %f min, %f sec %c)\n",
result.GeoLocation.Longitude, result.GeoLocation.LonComponents.degrees,
result.GeoLocation.LonComponents.minutes,
result.GeoLocation.LonComponents.seconds,
result.GeoLocation.LonComponents.direction);
printf("GPS Altitude : %f m\n", result.GeoLocation.Altitude);
printf("GPS Precision (DOP) : %f\n", result.GeoLocation.DOP);
printf("Lens min focal length: %f mm\n", result.LensInfo.FocalLengthMin);
printf("Lens max focal length: %f mm\n", result.LensInfo.FocalLengthMax);
printf("Lens f-stop min : f/%.1f\n", result.LensInfo.FStopMin);
printf("Lens f-stop max : f/%.1f\n", result.LensInfo.FStopMax);
printf("Lens make : %s\n", result.LensInfo.Make.c_str());
printf("Lens model : %s\n", result.LensInfo.Model.c_str());
printf("Focal plane XRes : %f\n", result.LensInfo.FocalPlaneXResolution);
printf("Focal plane YRes : %f\n", result.LensInfo.FocalPlaneYResolution);
return 0;
}

892
src/external/easyexif-1.0/exif.cpp vendored Normal file
View File

@ -0,0 +1,892 @@
/**************************************************************************
exif.cpp -- A simple ISO C++ library to parse basic EXIF
information from a JPEG file.
Copyright (c) 2010-2015 Mayank Lahiri
mlahiri@gmail.com
All rights reserved (BSD License).
See exif.h for version history.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "exif.h"
#include <algorithm>
#include <cstdint>
#include <stdio.h>
#include <vector>
using std::string;
namespace {
struct Rational {
uint32_t numerator, denominator;
operator double() const {
if (denominator < 1e-20) {
return 0;
}
return static_cast<double>(numerator) / static_cast<double>(denominator);
}
};
// IF Entry
class IFEntry {
public:
using byte_vector = std::vector<uint8_t>;
using ascii_vector = std::string;
using short_vector = std::vector<uint16_t>;
using long_vector = std::vector<uint32_t>;
using rational_vector = std::vector<Rational>;
IFEntry()
: tag_(0xFF), format_(0xFF), data_(0), length_(0), val_byte_(nullptr) {}
IFEntry(const IFEntry &) = delete;
IFEntry &operator=(const IFEntry &) = delete;
IFEntry(IFEntry &&other)
: tag_(other.tag_),
format_(other.format_),
data_(other.data_),
length_(other.length_),
val_byte_(other.val_byte_) {
other.tag_ = 0xFF;
other.format_ = 0xFF;
other.data_ = 0;
other.length_ = 0;
other.val_byte_ = nullptr;
}
~IFEntry() { delete_union(); }
unsigned short tag() const { return tag_; }
void tag(unsigned short tag) { tag_ = tag; }
unsigned short format() const { return format_; }
bool format(unsigned short format) {
switch (format) {
case 0x01:
case 0x02:
case 0x03:
case 0x04:
case 0x05:
case 0x07:
case 0x09:
case 0x0a:
case 0xff:
break;
default:
return false;
}
delete_union();
format_ = format;
new_union();
return true;
}
unsigned data() const { return data_; }
void data(unsigned data) { data_ = data; }
unsigned length() const { return length_; }
void length(unsigned length) { length_ = length; }
// functions to access the data
//
// !! it's CALLER responsibility to check that format !!
// !! is correct before accessing it's field !!
//
// - getters are use here to allow future addition
// of checks if format is correct
byte_vector &val_byte() { return *val_byte_; }
ascii_vector &val_string() { return *val_string_; }
short_vector &val_short() { return *val_short_; }
long_vector &val_long() { return *val_long_; }
rational_vector &val_rational() { return *val_rational_; }
private:
// Raw fields
unsigned short tag_;
unsigned short format_;
unsigned data_;
unsigned length_;
// Parsed fields
union {
byte_vector *val_byte_;
ascii_vector *val_string_;
short_vector *val_short_;
long_vector *val_long_;
rational_vector *val_rational_;
};
void delete_union() {
switch (format_) {
case 0x1:
delete val_byte_;
val_byte_ = nullptr;
break;
case 0x2:
delete val_string_;
val_string_ = nullptr;
break;
case 0x3:
delete val_short_;
val_short_ = nullptr;
break;
case 0x4:
delete val_long_;
val_long_ = nullptr;
break;
case 0x5:
delete val_rational_;
val_rational_ = nullptr;
break;
case 0xff:
break;
default:
// should not get here
// should I throw an exception or ...?
break;
}
}
void new_union() {
switch (format_) {
case 0x1:
val_byte_ = new byte_vector();
break;
case 0x2:
val_string_ = new ascii_vector();
break;
case 0x3:
val_short_ = new short_vector();
break;
case 0x4:
val_long_ = new long_vector();
break;
case 0x5:
val_rational_ = new rational_vector();
break;
case 0xff:
break;
default:
// should not get here
// should I throw an exception or ...?
break;
}
}
};
// Helper functions
template <typename T, bool alignIntel>
T parse(const unsigned char *buf);
template <>
uint8_t parse<uint8_t, false>(const unsigned char *buf) {
return *buf;
}
template <>
uint8_t parse<uint8_t, true>(const unsigned char *buf) {
return *buf;
}
template <>
uint16_t parse<uint16_t, false>(const unsigned char *buf) {
return (static_cast<uint16_t>(buf[0]) << 8) | buf[1];
}
template <>
uint16_t parse<uint16_t, true>(const unsigned char *buf) {
return (static_cast<uint16_t>(buf[1]) << 8) | buf[0];
}
template <>
uint32_t parse<uint32_t, false>(const unsigned char *buf) {
return (static_cast<uint32_t>(buf[0]) << 24) |
(static_cast<uint32_t>(buf[1]) << 16) |
(static_cast<uint32_t>(buf[2]) << 8) | buf[3];
}
template <>
uint32_t parse<uint32_t, true>(const unsigned char *buf) {
return (static_cast<uint32_t>(buf[3]) << 24) |
(static_cast<uint32_t>(buf[2]) << 16) |
(static_cast<uint32_t>(buf[1]) << 8) | buf[0];
}
template <>
Rational parse<Rational, true>(const unsigned char *buf) {
Rational r;
r.numerator = parse<uint32_t, true>(buf);
r.denominator = parse<uint32_t, true>(buf + 4);
return r;
}
template <>
Rational parse<Rational, false>(const unsigned char *buf) {
Rational r;
r.numerator = parse<uint32_t, false>(buf);
r.denominator = parse<uint32_t, false>(buf + 4);
return r;
}
/**
* Try to read entry.length() values for this entry.
*
* Returns:
* true - entry.length() values were read
* false - something went wrong, vec's content was not touched
*/
template <typename T, bool alignIntel, typename C>
bool extract_values(C &container, const unsigned char *buf, const unsigned base,
const unsigned len, const IFEntry &entry) {
const unsigned char *data;
uint32_t reversed_data;
// if data fits into 4 bytes, they are stored directly in
// the data field in IFEntry
if (sizeof(T) * entry.length() <= 4) {
if (alignIntel) {
reversed_data = entry.data();
} else {
reversed_data = entry.data();
// this reversing works, but is ugly
unsigned char *data = reinterpret_cast<unsigned char *>(&reversed_data);
unsigned char tmp;
tmp = data[0];
data[0] = data[3];
data[3] = tmp;
tmp = data[1];
data[1] = data[2];
data[2] = tmp;
}
data = reinterpret_cast<const unsigned char *>(&(reversed_data));
} else {
data = buf + base + entry.data();
if (data + sizeof(T) * entry.length() > buf + len) {
return false;
}
}
container.resize(entry.length());
for (size_t i = 0; i < entry.length(); ++i) {
container[i] = parse<T, alignIntel>(data + sizeof(T) * i);
}
return true;
}
template <bool alignIntel>
void parseIFEntryHeader(const unsigned char *buf, unsigned short &tag,
unsigned short &format, unsigned &length,
unsigned &data) {
// Each directory entry is composed of:
// 2 bytes: tag number (data field)
// 2 bytes: data format
// 4 bytes: number of components
// 4 bytes: data value or offset to data value
tag = parse<uint16_t, alignIntel>(buf);
format = parse<uint16_t, alignIntel>(buf + 2);
length = parse<uint32_t, alignIntel>(buf + 4);
data = parse<uint32_t, alignIntel>(buf + 8);
}
template <bool alignIntel>
void parseIFEntryHeader(const unsigned char *buf, IFEntry &result) {
unsigned short tag;
unsigned short format;
unsigned length;
unsigned data;
parseIFEntryHeader<alignIntel>(buf, tag, format, length, data);
result.tag(tag);
result.format(format);
result.length(length);
result.data(data);
}
template <bool alignIntel>
IFEntry parseIFEntry_temp(const unsigned char *buf, const unsigned offs,
const unsigned base, const unsigned len) {
IFEntry result;
// check if there even is enough data for IFEntry in the buffer
if (buf + offs + 12 > buf + len) {
result.tag(0xFF);
return result;
}
parseIFEntryHeader<alignIntel>(buf + offs, result);
// Parse value in specified format
switch (result.format()) {
case 1:
if (!extract_values<uint8_t, alignIntel>(result.val_byte(), buf, base,
len, result)) {
result.tag(0xFF);
}
break;
case 2:
// string is basically sequence of uint8_t (well, according to EXIF even
// uint7_t, but
// we don't have that), so just read it as bytes
if (!extract_values<uint8_t, alignIntel>(result.val_string(), buf, base,
len, result)) {
result.tag(0xFF);
}
// and cut zero byte at the end, since we don't want that in the
// std::string
if (result.val_string()[result.val_string().length() - 1] == '\0') {
result.val_string().resize(result.val_string().length() - 1);
}
break;
case 3:
if (!extract_values<uint16_t, alignIntel>(result.val_short(), buf, base,
len, result)) {
result.tag(0xFF);
}
break;
case 4:
if (!extract_values<uint32_t, alignIntel>(result.val_long(), buf, base,
len, result)) {
result.tag(0xFF);
}
break;
case 5:
if (!extract_values<Rational, alignIntel>(result.val_rational(), buf,
base, len, result)) {
result.tag(0xFF);
}
break;
case 7:
case 9:
case 10:
break;
default:
result.tag(0xFF);
}
return result;
}
// helper functions for convinience
template <typename T>
T parse_value(const unsigned char *buf, bool alignIntel) {
if (alignIntel) {
return parse<T, true>(buf);
} else {
return parse<T, false>(buf);
}
}
void parseIFEntryHeader(const unsigned char *buf, bool alignIntel,
unsigned short &tag, unsigned short &format,
unsigned &length, unsigned &data) {
if (alignIntel) {
parseIFEntryHeader<true>(buf, tag, format, length, data);
} else {
parseIFEntryHeader<false>(buf, tag, format, length, data);
}
}
IFEntry parseIFEntry(const unsigned char *buf, const unsigned offs,
const bool alignIntel, const unsigned base,
const unsigned len) {
if (alignIntel) {
return std::move(parseIFEntry_temp<true>(buf, offs, base, len));
} else {
return std::move(parseIFEntry_temp<false>(buf, offs, base, len));
}
}
}
//
// Locates the EXIF segment and parses it using parseFromEXIFSegment
//
int easyexif::EXIFInfo::parseFrom(const unsigned char *buf, unsigned len) {
// Sanity check: all JPEG files start with 0xFFD8.
if (!buf || len < 4) return PARSE_EXIF_ERROR_NO_JPEG;
if (buf[0] != 0xFF || buf[1] != 0xD8) return PARSE_EXIF_ERROR_NO_JPEG;
// Sanity check: some cameras pad the JPEG image with null bytes at the end.
// Normally, we should able to find the JPEG end marker 0xFFD9 at the end
// of the image, but not always. As long as there are null/0xFF bytes at the
// end of the image buffer, keep decrementing len until an 0xFFD9 is found,
// or some other bytes are. If the first non-zero/0xFF bytes from the end are
// not 0xFFD9, then we can be reasonably sure that the buffer is not a JPEG.
while (len > 2) {
if (buf[len - 1] == 0 || buf[len - 1] == 0xFF) {
len--;
} else {
if (buf[len - 1] != 0xD9 || buf[len - 2] != 0xFF) {
return PARSE_EXIF_ERROR_NO_JPEG;
} else {
break;
}
}
}
clear();
// Scan for EXIF header (bytes 0xFF 0xE1) and do a sanity check by
// looking for bytes "Exif\0\0". The marker length data is in Motorola
// byte order, which results in the 'false' parameter to parse16().
// The marker has to contain at least the TIFF header, otherwise the
// EXIF data is corrupt. So the minimum length specified here has to be:
// 2 bytes: section size
// 6 bytes: "Exif\0\0" string
// 2 bytes: TIFF header (either "II" or "MM" string)
// 2 bytes: TIFF magic (short 0x2a00 in Motorola byte order)
// 4 bytes: Offset to first IFD
// =========
// 16 bytes
unsigned offs = 0; // current offset into buffer
for (offs = 0; offs < len - 1; offs++)
if (buf[offs] == 0xFF && buf[offs + 1] == 0xE1) break;
if (offs + 4 > len) return PARSE_EXIF_ERROR_NO_EXIF;
offs += 2;
unsigned short section_length = parse_value<uint16_t>(buf + offs, false);
if (offs + section_length > len || section_length < 16)
return PARSE_EXIF_ERROR_CORRUPT;
offs += 2;
return parseFromEXIFSegment(buf + offs, len - offs);
}
int easyexif::EXIFInfo::parseFrom(const string &data) {
return parseFrom((const unsigned char *)data.data(), data.length());
}
//
// Main parsing function for an EXIF segment.
//
// PARAM: 'buf' start of the EXIF TIFF, which must be the bytes "Exif\0\0".
// PARAM: 'len' length of buffer
//
int easyexif::EXIFInfo::parseFromEXIFSegment(const unsigned char *buf,
unsigned len) {
bool alignIntel = true; // byte alignment (defined in EXIF header)
unsigned offs = 0; // current offset into buffer
if (!buf || len < 6) return PARSE_EXIF_ERROR_NO_EXIF;
if (!std::equal(buf, buf + 6, "Exif\0\0")) return PARSE_EXIF_ERROR_NO_EXIF;
offs += 6;
// Now parsing the TIFF header. The first two bytes are either "II" or
// "MM" for Intel or Motorola byte alignment. Sanity check by parsing
// the unsigned short that follows, making sure it equals 0x2a. The
// last 4 bytes are an offset into the first IFD, which are added to
// the global offset counter. For this block, we expect the following
// minimum size:
// 2 bytes: 'II' or 'MM'
// 2 bytes: 0x002a
// 4 bytes: offset to first IDF
// -----------------------------
// 8 bytes
if (offs + 8 > len) return PARSE_EXIF_ERROR_CORRUPT;
unsigned tiff_header_start = offs;
if (buf[offs] == 'I' && buf[offs + 1] == 'I')
alignIntel = true;
else {
if (buf[offs] == 'M' && buf[offs + 1] == 'M')
alignIntel = false;
else
return PARSE_EXIF_ERROR_UNKNOWN_BYTEALIGN;
}
this->ByteAlign = alignIntel;
offs += 2;
if (0x2a != parse_value<uint16_t>(buf + offs, alignIntel))
return PARSE_EXIF_ERROR_CORRUPT;
offs += 2;
unsigned first_ifd_offset = parse_value<uint32_t>(buf + offs, alignIntel);
offs += first_ifd_offset - 4;
if (offs >= len) return PARSE_EXIF_ERROR_CORRUPT;
// Now parsing the first Image File Directory (IFD0, for the main image).
// An IFD consists of a variable number of 12-byte directory entries. The
// first two bytes of the IFD section contain the number of directory
// entries in the section. The last 4 bytes of the IFD contain an offset
// to the next IFD, which means this IFD must contain exactly 6 + 12 * num
// bytes of data.
if (offs + 2 > len) return PARSE_EXIF_ERROR_CORRUPT;
int num_entries = parse_value<uint16_t>(buf + offs, alignIntel);
if (offs + 6 + 12 * num_entries > len) return PARSE_EXIF_ERROR_CORRUPT;
offs += 2;
unsigned exif_sub_ifd_offset = len;
unsigned gps_sub_ifd_offset = len;
while (--num_entries >= 0) {
IFEntry result =
parseIFEntry(buf, offs, alignIntel, tiff_header_start, len);
offs += 12;
switch (result.tag()) {
case 0x102:
// Bits per sample
if (result.format() == 3)
this->BitsPerSample = result.val_short().front();
break;
case 0x10E:
// Image description
if (result.format() == 2) this->ImageDescription = result.val_string();
break;
case 0x10F:
// Digicam make
if (result.format() == 2) this->Make = result.val_string();
break;
case 0x110:
// Digicam model
if (result.format() == 2) this->Model = result.val_string();
break;
case 0x112:
// Orientation of image
if (result.format() == 3)
this->Orientation = result.val_short().front();
break;
case 0x131:
// Software used for image
if (result.format() == 2) this->Software = result.val_string();
break;
case 0x132:
// EXIF/TIFF date/time of image modification
if (result.format() == 2) this->DateTime = result.val_string();
break;
case 0x8298:
// Copyright information
if (result.format() == 2) this->Copyright = result.val_string();
break;
case 0x8825:
// GPS IFS offset
gps_sub_ifd_offset = tiff_header_start + result.data();
break;
case 0x8769:
// EXIF SubIFD offset
exif_sub_ifd_offset = tiff_header_start + result.data();
break;
}
}
// Jump to the EXIF SubIFD if it exists and parse all the information
// there. Note that it's possible that the EXIF SubIFD doesn't exist.
// The EXIF SubIFD contains most of the interesting information that a
// typical user might want.
if (exif_sub_ifd_offset + 4 <= len) {
offs = exif_sub_ifd_offset;
int num_entries = parse_value<uint16_t>(buf + offs, alignIntel);
if (offs + 6 + 12 * num_entries > len) return PARSE_EXIF_ERROR_CORRUPT;
offs += 2;
while (--num_entries >= 0) {
IFEntry result =
parseIFEntry(buf, offs, alignIntel, tiff_header_start, len);
switch (result.tag()) {
case 0x829a:
// Exposure time in seconds
if (result.format() == 5)
this->ExposureTime = result.val_rational().front();
break;
case 0x829d:
// FNumber
if (result.format() == 5)
this->FNumber = result.val_rational().front();
break;
case 0x8827:
// ISO Speed Rating
if (result.format() == 3)
this->ISOSpeedRatings = result.val_short().front();
break;
case 0x9003:
// Original date and time
if (result.format() == 2)
this->DateTimeOriginal = result.val_string();
break;
case 0x9004:
// Digitization date and time
if (result.format() == 2)
this->DateTimeDigitized = result.val_string();
break;
case 0x9201:
// Shutter speed value
if (result.format() == 5)
this->ShutterSpeedValue = result.val_rational().front();
break;
case 0x9204:
// Exposure bias value
if (result.format() == 5)
this->ExposureBiasValue = result.val_rational().front();
break;
case 0x9206:
// Subject distance
if (result.format() == 5)
this->SubjectDistance = result.val_rational().front();
break;
case 0x9209:
// Flash used
if (result.format() == 3) this->Flash = result.data() ? 1 : 0;
break;
case 0x920a:
// Focal length
if (result.format() == 5)
this->FocalLength = result.val_rational().front();
break;
case 0x9207:
// Metering mode
if (result.format() == 3)
this->MeteringMode = result.val_short().front();
break;
case 0x9291:
// Subsecond original time
if (result.format() == 2)
this->SubSecTimeOriginal = result.val_string();
break;
case 0xa002:
// EXIF Image width
if (result.format() == 4)
this->ImageWidth = result.val_long().front();
if (result.format() == 3)
this->ImageWidth = result.val_short().front();
break;
case 0xa003:
// EXIF Image height
if (result.format() == 4)
this->ImageHeight = result.val_long().front();
if (result.format() == 3)
this->ImageHeight = result.val_short().front();
break;
case 0xa20e:
// EXIF Focal plane X-resolution
if (result.format() == 5) {
this->LensInfo.FocalPlaneXResolution = result.val_rational()[0];
}
break;
case 0xa20f:
// EXIF Focal plane Y-resolution
if (result.format() == 5) {
this->LensInfo.FocalPlaneYResolution = result.val_rational()[0];
}
break;
case 0xa405:
// Focal length in 35mm film
if (result.format() == 3)
this->FocalLengthIn35mm = result.val_short().front();
break;
case 0xa432:
// Focal length and FStop.
if (result.format() == 5) {
this->LensInfo.FocalLengthMin = result.val_rational()[0];
this->LensInfo.FocalLengthMax = result.val_rational()[1];
this->LensInfo.FStopMin = result.val_rational()[2];
this->LensInfo.FStopMax = result.val_rational()[3];
}
break;
case 0xa433:
// Lens make.
if (result.format() == 2) {
this->LensInfo.Make = result.val_string();
}
break;
case 0xa434:
// Lens model.
if (result.format() == 2) {
this->LensInfo.Model = result.val_string();
}
break;
}
offs += 12;
}
}
// Jump to the GPS SubIFD if it exists and parse all the information
// there. Note that it's possible that the GPS SubIFD doesn't exist.
if (gps_sub_ifd_offset + 4 <= len) {
offs = gps_sub_ifd_offset;
int num_entries = parse_value<uint16_t>(buf + offs, alignIntel);
if (offs + 6 + 12 * num_entries > len) return PARSE_EXIF_ERROR_CORRUPT;
offs += 2;
while (--num_entries >= 0) {
unsigned short tag, format;
unsigned length, data;
parseIFEntryHeader(buf + offs, alignIntel, tag, format, length, data);
switch (tag) {
case 1:
// GPS north or south
this->GeoLocation.LatComponents.direction = *(buf + offs + 8);
if (this->GeoLocation.LatComponents.direction == 0) {
this->GeoLocation.LatComponents.direction = '?';
}
if ('S' == this->GeoLocation.LatComponents.direction) {
this->GeoLocation.Latitude = -this->GeoLocation.Latitude;
}
break;
case 2:
// GPS latitude
if (format == 5 && length == 3) {
this->GeoLocation.LatComponents.degrees = parse_value<Rational>(
buf + data + tiff_header_start, alignIntel);
this->GeoLocation.LatComponents.minutes = parse_value<Rational>(
buf + data + tiff_header_start + 8, alignIntel);
this->GeoLocation.LatComponents.seconds = parse_value<Rational>(
buf + data + tiff_header_start + 16, alignIntel);
this->GeoLocation.Latitude =
this->GeoLocation.LatComponents.degrees +
this->GeoLocation.LatComponents.minutes / 60 +
this->GeoLocation.LatComponents.seconds / 3600;
if ('S' == this->GeoLocation.LatComponents.direction) {
this->GeoLocation.Latitude = -this->GeoLocation.Latitude;
}
}
break;
case 3:
// GPS east or west
this->GeoLocation.LonComponents.direction = *(buf + offs + 8);
if (this->GeoLocation.LonComponents.direction == 0) {
this->GeoLocation.LonComponents.direction = '?';
}
if ('W' == this->GeoLocation.LonComponents.direction) {
this->GeoLocation.Longitude = -this->GeoLocation.Longitude;
}
break;
case 4:
// GPS longitude
if (format == 5 && length == 3) {
this->GeoLocation.LonComponents.degrees = parse_value<Rational>(
buf + data + tiff_header_start, alignIntel);
this->GeoLocation.LonComponents.minutes = parse_value<Rational>(
buf + data + tiff_header_start + 8, alignIntel);
this->GeoLocation.LonComponents.seconds = parse_value<Rational>(
buf + data + tiff_header_start + 16, alignIntel);
this->GeoLocation.Longitude =
this->GeoLocation.LonComponents.degrees +
this->GeoLocation.LonComponents.minutes / 60 +
this->GeoLocation.LonComponents.seconds / 3600;
if ('W' == this->GeoLocation.LonComponents.direction)
this->GeoLocation.Longitude = -this->GeoLocation.Longitude;
}
break;
case 5:
// GPS altitude reference (below or above sea level)
this->GeoLocation.AltitudeRef = *(buf + offs + 8);
if (1 == this->GeoLocation.AltitudeRef) {
this->GeoLocation.Altitude = -this->GeoLocation.Altitude;
}
break;
case 6:
// GPS altitude
if (format == 5) {
this->GeoLocation.Altitude = parse_value<Rational>(
buf + data + tiff_header_start, alignIntel);
if (1 == this->GeoLocation.AltitudeRef) {
this->GeoLocation.Altitude = -this->GeoLocation.Altitude;
}
}
break;
case 11:
// GPS degree of precision (DOP)
if (format == 5) {
this->GeoLocation.DOP = parse_value<Rational>(
buf + data + tiff_header_start, alignIntel);
}
break;
}
offs += 12;
}
}
return PARSE_EXIF_SUCCESS;
}
void easyexif::EXIFInfo::clear() {
// Strings
ImageDescription = "";
Make = "";
Model = "";
Software = "";
DateTime = "";
DateTimeOriginal = "";
DateTimeDigitized = "";
SubSecTimeOriginal = "";
Copyright = "";
// Shorts / unsigned / double
ByteAlign = 0;
Orientation = 0;
BitsPerSample = 0;
ExposureTime = 0;
FNumber = 0;
ISOSpeedRatings = 0;
ShutterSpeedValue = 0;
ExposureBiasValue = 0;
SubjectDistance = 0;
FocalLength = 0;
FocalLengthIn35mm = 0;
Flash = 0;
MeteringMode = 0;
ImageWidth = 0;
ImageHeight = 0;
// Geolocation
GeoLocation.Latitude = 0;
GeoLocation.Longitude = 0;
GeoLocation.Altitude = 0;
GeoLocation.AltitudeRef = 0;
GeoLocation.DOP = 0;
GeoLocation.LatComponents.degrees = 0;
GeoLocation.LatComponents.minutes = 0;
GeoLocation.LatComponents.seconds = 0;
GeoLocation.LatComponents.direction = '?';
GeoLocation.LonComponents.degrees = 0;
GeoLocation.LonComponents.minutes = 0;
GeoLocation.LonComponents.seconds = 0;
GeoLocation.LonComponents.direction = '?';
// LensInfo
LensInfo.FocalLengthMax = 0;
LensInfo.FocalLengthMin = 0;
LensInfo.FStopMax = 0;
LensInfo.FStopMin = 0;
LensInfo.FocalPlaneYResolution = 0;
LensInfo.FocalPlaneXResolution = 0;
LensInfo.Make = "";
LensInfo.Model = "";
}

163
src/external/easyexif-1.0/exif.h vendored Normal file
View File

@ -0,0 +1,163 @@
/**************************************************************************
exif.h -- A simple ISO C++ library to parse basic EXIF
information from a JPEG file.
Based on the description of the EXIF file format at:
-- http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
-- http://www.media.mit.edu/pia/Research/deepview/exif.html
-- http://www.exif.org/Exif2-2.PDF
Copyright (c) 2010-2015 Mayank Lahiri
mlahiri@gmail.com
All rights reserved.
VERSION HISTORY:
================
2.2: Release December 2014
--
2.1: Released July 2013
-- fixed a bug where JPEGs without an EXIF SubIFD would not be parsed
-- fixed a bug in parsing GPS coordinate seconds
-- fixed makefile bug
-- added two pathological test images from Matt Galloway
http://www.galloway.me.uk/2012/01/uiimageorientation-exif-orientation-sample-images/
-- split main parsing routine for easier integration into Firefox
2.0: Released February 2013
-- complete rewrite
-- no new/delete
-- added GPS support
1.0: Released 2010
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __EXIF_H
#define __EXIF_H
#include <string>
namespace easyexif {
//
// Class responsible for storing and parsing EXIF information from a JPEG blob
//
class EXIFInfo {
public:
// Parsing function for an entire JPEG image buffer.
//
// PARAM 'data': A pointer to a JPEG image.
// PARAM 'length': The length of the JPEG image.
// RETURN: PARSE_EXIF_SUCCESS (0) on succes with 'result' filled out
// error code otherwise, as defined by the PARSE_EXIF_ERROR_* macros
int parseFrom(const unsigned char *data, unsigned length);
int parseFrom(const std::string &data);
// Parsing function for an EXIF segment. This is used internally by parseFrom()
// but can be called for special cases where only the EXIF section is
// available (i.e., a blob starting with the bytes "Exif\0\0").
int parseFromEXIFSegment(const unsigned char *buf, unsigned len);
// Set all data members to default values.
void clear();
// Data fields filled out by parseFrom()
char ByteAlign; // 0 = Motorola byte alignment, 1 = Intel
std::string ImageDescription; // Image description
std::string Make; // Camera manufacturer's name
std::string Model; // Camera model
unsigned short Orientation; // Image orientation, start of data corresponds to
// 0: unspecified in EXIF data
// 1: upper left of image
// 3: lower right of image
// 6: upper right of image
// 8: lower left of image
// 9: undefined
unsigned short BitsPerSample; // Number of bits per component
std::string Software; // Software used
std::string DateTime; // File change date and time
std::string DateTimeOriginal; // Original file date and time (may not exist)
std::string DateTimeDigitized; // Digitization date and time (may not exist)
std::string SubSecTimeOriginal; // Sub-second time that original picture was taken
std::string Copyright; // File copyright information
double ExposureTime; // Exposure time in seconds
double FNumber; // F/stop
unsigned short ISOSpeedRatings; // ISO speed
double ShutterSpeedValue; // Shutter speed (reciprocal of exposure time)
double ExposureBiasValue; // Exposure bias value in EV
double SubjectDistance; // Distance to focus point in meters
double FocalLength; // Focal length of lens in millimeters
unsigned short FocalLengthIn35mm; // Focal length in 35mm film
char Flash; // 0 = no flash, 1 = flash used
unsigned short MeteringMode; // Metering mode
// 1: average
// 2: center weighted average
// 3: spot
// 4: multi-spot
// 5: multi-segment
unsigned ImageWidth; // Image width reported in EXIF data
unsigned ImageHeight; // Image height reported in EXIF data
struct Geolocation_t { // GPS information embedded in file
double Latitude; // Image latitude expressed as decimal
double Longitude; // Image longitude expressed as decimal
double Altitude; // Altitude in meters, relative to sea level
char AltitudeRef; // 0 = above sea level, -1 = below sea level
double DOP; // GPS degree of precision (DOP)
struct Coord_t {
double degrees;
double minutes;
double seconds;
char direction;
} LatComponents, LonComponents; // Latitude, Longitude expressed in deg/min/sec
} GeoLocation;
struct LensInfo_t { // Lens information
double FStopMin; // Min aperture (f-stop)
double FStopMax; // Max aperture (f-stop)
double FocalLengthMin; // Min focal length (mm)
double FocalLengthMax; // Max focal length (mm)
double FocalPlaneXResolution; // Focal plane X-resolution
double FocalPlaneYResolution; // Focal plane Y-resolution
std::string Make; // Lens manufacturer
std::string Model; // Lens model
} LensInfo;
EXIFInfo() {
clear();
}
};
}
// Parse was successful
#define PARSE_EXIF_SUCCESS 0
// No JPEG markers found in buffer, possibly invalid JPEG file
#define PARSE_EXIF_ERROR_NO_JPEG 1982
// No EXIF header found in JPEG file.
#define PARSE_EXIF_ERROR_NO_EXIF 1983
// Byte alignment specified in EXIF file was unknown (not Motorola or Intel).
#define PARSE_EXIF_ERROR_UNKNOWN_BYTEALIGN 1984
// EXIF header was found, but data was corrupted.
#define PARSE_EXIF_ERROR_CORRUPT 1985
#endif

26
src/external/easyexif-1.0/test.sh vendored Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
make
DEMONAME=./demo
if [ ! -e ./demo ]; then
# check if demo.exe exists, needed on windows
if [ -e ./demo.exe ]; then
DEMONAME=./demo.exe
else
echo Cannot find executable.
exit 1
fi
fi
for jpeg in `ls test-images/*.jpg`; do
$DEMONAME $jpeg > /tmp/`basename $jpeg`.actual
diff $jpeg.expected /tmp/`basename $jpeg`.actual > /tmp/diff.out
if [[ -s /tmp/diff.out ]] ; then
echo "FAILED ON $jpeg"
cat /tmp/diff.out
exit
fi ;
echo "PASS $jpeg"
done

View File

@ -2,12 +2,13 @@
# Copyright 2019, 2020, Visual Computing Lab, ISTI - Italian National Research Council # Copyright 2019, 2020, Visual Computing Lab, ISTI - Italian National Research Council
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
option(MESHLAB_ALLOW_DOWNLOAD_SOURCE_EASYEXIF "Allow download and use of EasyExif source" ON) option(MESHLAB_ALLOW_BUNDLED_SOURCE_EASYEXIF "Allow use bundled source of EasyExif" ON)
if(MESHLAB_ALLOW_DOWNLOAD_SOURCE_EASYEXIF) if(MESHLAB_ALLOW_BUNDLED_SOURCE_EASYEXIF)
set(EASYEXIF_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/easyexif-1.0") set(EASYEXIF_DIR "${MESHLAB_EXTERNAL_DIR}/easyexif-1.0")
set(EASYEXIF_CHECK "${EASYEXIF_DIR}/exif.h") set(EASYEXIF_CHECK "${EASYEXIF_DIR}/exif.h")
# just to be sure, but this library is bundled in meshlab repo and download shouldn't be necessary
if (NOT EXISTS ${EASYEXIF_CHECK}) if (NOT EXISTS ${EASYEXIF_CHECK})
set(EASYEXIF_LINK set(EASYEXIF_LINK
https://github.com/mayanklahiri/easyexif/archive/refs/tags/v1.0.zip https://github.com/mayanklahiri/easyexif/archive/refs/tags/v1.0.zip
@ -17,19 +18,19 @@ if(MESHLAB_ALLOW_DOWNLOAD_SOURCE_EASYEXIF)
NAME "EasyExif" NAME "EasyExif"
LINK ${EASYEXIF_LINK} LINK ${EASYEXIF_LINK}
MD5 ${EASYEXIF_MD5} MD5 ${EASYEXIF_MD5}
DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR}) DIR ${MESHLAB_EXTERNAL_DIR})
if (NOT download_and_unzip_SUCCESS) if (NOT download_and_unzip_SUCCESS)
message(FATAL_ERROR "- EasyExif - download failed.") message(FATAL_ERROR "- EasyExif - download failed.")
endif() endif()
endif() endif()
if (EXISTS ${EASYEXIF_CHECK}) if (EXISTS ${EASYEXIF_CHECK})
message(STATUS "- EasyExif - using downloaded source") message(STATUS "- EasyExif - using bundled source")
add_library(external-easyexif STATIC ${EASYEXIF_DIR}/exif.h ${EASYEXIF_DIR}/exif.cpp) add_library(external-easyexif STATIC ${EASYEXIF_DIR}/exif.h ${EASYEXIF_DIR}/exif.cpp)
target_include_directories(external-easyexif PUBLIC ${EASYEXIF_DIR}) target_include_directories(external-easyexif PUBLIC ${EASYEXIF_DIR})
endif() endif()
else() else()
message( message(
FATAL_ERROR FATAL_ERROR
"EeasyExif is required - MESHLAB_ALLOW_DOWNLOAD_SOURCE_EASYEXIF must be ON.") "EeasyExif is required - MESHLAB_ALLOW_BUNDLED_SOURCE_EASYEXIF must be ON.")
endif() endif()

73
src/external/glew-2.2.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,73 @@
The OpenGL Extension Wrangler Library
Copyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>
Copyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>
Copyright (C) 2002, Lev Povalahev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name of the author may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Mesa 3-D graphics library
Version: 7.0
Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2007 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Materials.
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.

258
src/external/glew-2.2.0/README.md vendored Normal file
View File

@ -0,0 +1,258 @@
# GLEW - The OpenGL Extension Wrangler Library
The OpenGL Extension Wrangler Library (GLEW) is a cross-platform open-source C/C++ extension loading library. GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform. OpenGL core and extension functionality is exposed in a single header file. GLEW has been tested on a variety of operating systems, including Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris.
![](http://glew.sourceforge.net/glew.png)
http://glew.sourceforge.net/
https://github.com/nigels-com/glew
[![Build Status](https://travis-ci.org/nigels-com/glew.svg?branch=master)](https://travis-ci.org/nigels-com/glew)
[![Gitter](https://badges.gitter.im/nigels-com/glew.svg)](https://gitter.im/nigels-com/glew?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Download](https://img.shields.io/sourceforge/dm/glew.svg)](https://sourceforge.net/projects/glew/files/latest/download)
## Table of Contents
* [Downloads](#downloads)
* [Recent snapshots](#recent-snapshots)
* [Build](#build)
* [Linux and Mac](#linux-and-mac)
* [Using GNU Make](#using-gnu-make)
* [Install build tools](#install-build-tools)
* [Build](#build-1)
* [Linux EGL](#linux-egl)
* [Linux OSMesa](#linux-osmesa)
* [Linux mingw-w64](#linux-mingw-w64)
* [Using cmake](#using-cmake)
* [Install build tools](#install-build-tools-1)
* [Build](#build-2)
* [Windows](#windows)
* [Visual Studio](#visual-studio)
* [MSYS/Mingw](#msysmingw)
* [MSYS2/Mingw-w64](#msys2mingw-w64)
* [glewinfo](#glewinfo)
* [Code Generation](#code-generation)
* [Authors](#authors)
* [Contributions](#contributions)
* [Copyright and Licensing](#copyright-and-licensing)
## Downloads
Current release is [2.1.0](https://sourceforge.net/projects/glew/files/glew/2.1.0/).
[(Change Log)](http://glew.sourceforge.net/log.html)
Sources available as
[ZIP](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.zip/download) or
[TGZ](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.tgz/download).
Windows binaries for [32-bit and 64-bit](https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0-win32.zip/download).
### Recent snapshots
Snapshots may contain new features, bug-fixes or new OpenGL extensions ahead of tested, official releases.
[glew-20200115.tgz](https://sourceforge.net/projects/glew/files/glew/snapshots/glew-20200115.tgz/download) *GLEW 2.2.0 RC3: fixes*
[glew-20190928.tgz](https://sourceforge.net/projects/glew/files/glew/snapshots/glew-20190928.tgz/download) *GLEW 2.2.0 RC2: New extensions, bug fixes*
## Build
It is highly recommended to build from a tgz or zip release snapshot.
The code generation workflow is a complex brew of gnu make, perl and python, that works best on Linux or Mac.
The code generation is known to work on Windows using [MSYS2](https://www.msys2.org/).
For most end-users of GLEW the official releases are the best choice, with first class support.
### Linux and Mac
#### Using GNU Make
GNU make is the primary build system for GLEW, historically.
It includes targets for building the sources and headers, for maintenance purposes.
##### Install build tools
Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libxmu-dev libxi-dev libgl-dev`
RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel`
FreeBSD: `# pkg install xorg lang/gcc git cmake gmake bash python perl5`
##### Build
$ make
$ sudo make install
$ make clean
Targets: `all, glew.lib (sub-targets: glew.lib.shared, glew.lib.static), glew.bin, clean, install, uninstall`
Variables: `SYSTEM=linux-clang, GLEW_DEST=/usr/local, STRIP=`
_Note: you may need to call `make` in the **auto** folder first_
##### Linux EGL
$ sudo apt install libegl1-mesa-dev
$ make SYSTEM=linux-egl
##### Linux OSMesa
$ sudo apt install libosmesa-dev
$ make SYSTEM=linux-osmesa
##### Linux mingw-w64
$ sudo apt install mingw-w64
$ make SYSTEM=linux-mingw32
$ make SYSTEM=linux-mingw64
#### Using cmake
The cmake build is mostly contributer maintained.
Due to the multitude of use cases this is maintained on a _best effort_ basis.
Pull requests are welcome.
*CMake 2.8.12 or higher is required.*
##### Install build tools
Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libxmu-dev libxi-dev libgl-dev cmake git`
RedHat/CentOS/Fedora: `$ sudo yum install libXmu-devel libXi-devel libGL-devel cmake git`
##### Build
$ cd build
$ cmake ./cmake
$ make -j4
| Target | Description |
| ---------- | ----------- |
| glew | Build the glew shared library. |
| glew_s | Build the glew static library. |
| glewinfo | Build the `glewinfo` executable (requires `BUILD_UTILS` to be `ON`). |
| visualinfo | Build the `visualinfo` executable (requires `BUILD_UTILS` to be `ON`). |
| install | Install all enabled targets into `CMAKE_INSTALL_PREFIX`. |
| clean | Clean up build artifacts. |
| all | Build all enabled targets (default target). |
| Variables | Description |
| --------------- | ----------- |
| BUILD_UTILS | Build the `glewinfo` and `visualinfo` executables. |
| GLEW_REGAL | Build in Regal mode. |
| GLEW_OSMESA | Build in off-screen Mesa mode. |
| BUILD_FRAMEWORK | Build as MacOSX Framework. Setting `CMAKE_INSTALL_PREFIX` to `/Library/Frameworks` is recommended. |
### Windows
#### Visual Studio
Use the provided Visual Studio project file in build/vc15/
Projects for vc6, vc10, vc12 and vc14 are also provided
#### MSYS/Mingw
Available from [Mingw](http://www.mingw.org/)
Requirements: bash, make, gcc
$ mingw32-make
$ mingw32-make install
$ mingw32-make install.all
Alternative toolchain: `SYSTEM=mingw-win32`
#### MSYS2/Mingw-w64
Available from [Msys2](http://msys2.github.io/) and/or [Mingw-w64](http://mingw-w64.org/)
Requirements: bash, make, gcc
$ pacman -S gcc make mingw-w64-i686-gcc mingw-w64-x86_64-gcc
$ make
$ make install
$ make install.all
Alternative toolchain: `SYSTEM=msys, SYSTEM=msys-win32, SYSTEM=msys-win64`
## glewinfo
`glewinfo` is a command-line tool useful for inspecting the capabilities of an
OpenGL implementation and GLEW support for that. Please include `glewinfo.txt`
with bug reports, as appropriate.
---------------------------
GLEW Extension Info
---------------------------
GLEW version 2.0.0
Reporting capabilities of pixelformat 3
Running on a Intel(R) HD Graphics 3000 from Intel
OpenGL version 3.1.0 - Build 9.17.10.4229 is supported
GL_VERSION_1_1: OK
---------------
GL_VERSION_1_2: OK
---------------
glCopyTexSubImage3D: OK
glDrawRangeElements: OK
glTexImage3D: OK
glTexSubImage3D: OK
...
## Code Generation
A Unix or Mac environment is needed for building GLEW from scratch to
include new extensions, or customize the code generation. The extension
data is regenerated from the top level source directory with:
make extensions
An alternative to generating the GLEW sources from scratch is to
download a pre-generated (unsupported) snapshot:
https://sourceforge.net/projects/glew/files/glew/snapshots/
## Authors
GLEW is currently maintained by [Nigel Stewart](https://github.com/nigels-com)
with bug fixes, new OpenGL extension support and new releases.
GLEW was developed by [Milan Ikits](http://www.cs.utah.edu/~ikits/)
and [Marcelo Magallon](http://wwwvis.informatik.uni-stuttgart.de/~magallon/).
Aaron Lefohn, Joe Kniss, and Chris Wyman were the first users and also
assisted with the design and debugging process.
The acronym GLEW originates from Aaron Lefohn.
Pasi K&auml;rkk&auml;inen identified and fixed several problems with
GLX and SDL. Nate Robins created the `wglinfo` utility, to
which modifications were made by Michael Wimmer.
## Contributions
GLEW welcomes community contributions. Typically these are co-ordinated
via [Issues](https://github.com/nigels-com/glew/issues) or
[Pull Requests](https://github.com/nigels-com/glew/pulls) in the
GitHub web interface.
Be sure to mention platform and compiler toolchain details when filing
a bug report. The output of `glewinfo` can be quite useful for discussion
also.
Generally GLEW is usually released once a year, around the time of the Siggraph
computer graphics conference. If you're not using the current release
version of GLEW, be sure to check if the issue or bug is fixed there.
## Copyright and Licensing
GLEW is originally derived from the EXTGL project by Lev Povalahev.
The source code is licensed under the
[Modified BSD License](http://glew.sourceforge.net/glew.txt), the
[Mesa 3-D License](http://glew.sourceforge.net/mesa.txt) (MIT) and the
[Khronos License](http://glew.sourceforge.net/khronos.txt) (MIT).
The automatic code generation scripts are released under the
[GNU GPL](http://glew.sourceforge.net/gpl.txt).

11
src/external/glew-2.2.0/glew.pc.in vendored Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=@libdir@
includedir=${prefix}/include
Name: glew
Description: The OpenGL Extension Wrangler library
Version: @version@
Cflags: -I${includedir} @cflags@
Libs: -L${libdir} -l@libname@ @libgl@
Requires: @requireslib@

3051
src/external/glew-2.2.0/include/GL/eglew.h vendored Normal file

File diff suppressed because it is too large Load Diff

26427
src/external/glew-2.2.0/include/GL/glew.h vendored Normal file

File diff suppressed because it is too large Load Diff

1831
src/external/glew-2.2.0/include/GL/glxew.h vendored Normal file

File diff suppressed because it is too large Load Diff

1468
src/external/glew-2.2.0/include/GL/wglew.h vendored Normal file

File diff suppressed because it is too large Load Diff

31949
src/external/glew-2.2.0/src/glew.c vendored Normal file

File diff suppressed because it is too large Load Diff

19031
src/external/glew-2.2.0/src/glewinfo.c vendored Normal file

File diff suppressed because it is too large Load Diff

1297
src/external/glew-2.2.0/src/visualinfo.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
# Copyright 2019, 2020, Visual Computing Lab, ISTI - Italian National Research Council # Copyright 2019, 2020, Visual Computing Lab, ISTI - Italian National Research Council
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
option(MESHLAB_ALLOW_DOWNLOAD_SOURCE_GLEW "Allow download and use of GLEW source" ON) option(MESHLAB_ALLOW_BUNDLED_SOURCE_GLEW "Allow use bundled source of GLEW" ON)
option(MESHLAB_ALLOW_SYSTEM_GLEW "Allow use of system-provided GLEW" ON) option(MESHLAB_ALLOW_SYSTEM_GLEW "Allow use of system-provided GLEW" ON)
unset(HAVE_SYSTEM_GLEW) unset(HAVE_SYSTEM_GLEW)
@ -23,10 +23,11 @@ if(MESHLAB_ALLOW_SYSTEM_GLEW AND HAVE_SYSTEM_GLEW)
else() else()
message(FATAL_ERROR "OpenGL not found or your CMake version is too old!") message(FATAL_ERROR "OpenGL not found or your CMake version is too old!")
endif() endif()
elseif(MESHLAB_ALLOW_DOWNLOAD_SOURCE_GLEW) elseif(MESHLAB_ALLOW_BUNDLED_SOURCE_GLEW)
set(GLEW_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/glew-2.2.0") set(GLEW_DIR "${MESHLAB_EXTERNAL_DIR}/glew-2.2.0")
set(GLEW_CHECK "${GLEW_DIR}/src/glew.c") set(GLEW_CHECK "${GLEW_DIR}/src/glew.c")
# just to be sure, but this library is bundled in meshlab repo and download shouldn't be necessary
if (NOT EXISTS ${GLEW_CHECK}) if (NOT EXISTS ${GLEW_CHECK})
set(GLEW_LINK set(GLEW_LINK
https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.zip https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.zip
@ -36,14 +37,14 @@ elseif(MESHLAB_ALLOW_DOWNLOAD_SOURCE_GLEW)
NAME "GLEW" NAME "GLEW"
LINK ${GLEW_LINK} LINK ${GLEW_LINK}
MD5 ${GLEW_MD5} MD5 ${GLEW_MD5}
DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR}) DIR ${MESHLAB_EXTERNAL_DIR})
if (NOT download_and_unzip_SUCCESS) if (NOT download_and_unzip_SUCCESS)
message(FATAL_ERROR "- GLEW - download failed.") message(FATAL_ERROR "- GLEW - download failed.")
endif() endif()
endif() endif()
if (EXISTS ${GLEW_CHECK}) if (EXISTS ${GLEW_CHECK})
message(STATUS "- GLEW - using downloaded source") message(STATUS "- GLEW - using bundled source")
add_library(external-glew SHARED "${GLEW_DIR}/src/glew.c") add_library(external-glew SHARED "${GLEW_DIR}/src/glew.c")
target_include_directories(external-glew SYSTEM PUBLIC ${GLEW_DIR}/include) target_include_directories(external-glew SYSTEM PUBLIC ${GLEW_DIR}/include)
if(TARGET OpenGL::GL) if(TARGET OpenGL::GL)
@ -60,5 +61,5 @@ elseif(MESHLAB_ALLOW_DOWNLOAD_SOURCE_GLEW)
else() else()
message( message(
FATAL_ERROR FATAL_ERROR
"GLEW is required - at least one of MESHLAB_ALLOW_SYSTEM_GLEW or MESHLAB_ALLOW_DOWNLOAD_SOURCE_GLEW must be ON and found.") "GLEW is required - at least one of MESHLAB_ALLOW_SYSTEM_GLEW or MESHLAB_ALLOW_BUNDLED_SOURCE_GLEW must be ON and found.")
endif() endif()