88
99
1010#include < string>
11- #include < tiffio.h>
11+ #ifdef HAVE_LIBTIFF
12+ #include < tiffio.h>
13+ #endif
1214#include < sstream>
1315#include " data_structures/Mesh/PixelData.hpp"
1416
@@ -56,7 +58,9 @@ namespace TiffUtils {
5658 outputStr << " NOT SUPPORTED" ;
5759 }
5860 outputStr << " , Photometric: " << iPhotometric;
61+ #ifdef HAVE_LIBTIFF
5962 outputStr << " , StripSize: " << TIFFStripSize (iFile);
63+ #endif /* HAVE_LIBTIFF */
6064
6165 return outputStr.str ();
6266 }
@@ -67,7 +71,12 @@ namespace TiffUtils {
6771 bool isFileOpened () const { return iFile != nullptr ; }
6872
6973 TiffType iType = TiffType::TIFF_INVALID;
74+ #ifdef HAVE_LIBTIFF
7075 TIFF *iFile = nullptr ;
76+ #else
77+ void * iFile = nullptr ;
78+ typedef unsigned int uint32;
79+ #endif /* HAVE_LIBTIFF */
7180 std::string iFileName = " " ;
7281 uint32 iImgWidth = 0 ;
7382 uint32 iImgHeight = 0 ;
@@ -81,6 +90,12 @@ namespace TiffUtils {
8190 TiffInfo (const TiffInfo&) = delete ; // make it noncopyable
8291 TiffInfo& operator =(const TiffInfo&) = delete ; // make it not assignable
8392
93+ friend std::ostream& operator <<(std::ostream &os, const TiffInfo &obj) {
94+ os << obj.toString ();
95+ return os;
96+ }
97+
98+ #ifdef HAVE_LIBTIFF
8499 /* *
85100 * opens TIFF
86101 **/
@@ -142,12 +157,21 @@ namespace TiffUtils {
142157 }
143158 }
144159
145- friend std::ostream& operator <<(std::ostream &os, const TiffInfo &obj) {
146- os << obj.toString ();
147- return os;
160+ #else
161+ bool open (const std::string &aFileName) {
162+ std::cerr << " libapr compiled without LibTIFF support, simulating TIFF reader functionality" << std::endl;
163+ std::cerr << " Trying to open file " << aFileName << " , returning false." << std::endl;
164+ return false ;
148165 }
166+
167+ void close () {
168+ std::cerr << " libapr compiled without LibTIFF support, simulating TIFF reader functionality" << std::endl;
169+ std::cerr << " Shim-closing TIFF file" << std::endl;
170+ }
171+ #endif /* HAVE_LIBTIFF */
149172 };
150173
174+ #ifdef HAVE_LIBTIFF
151175
152176 /* *
153177 * Reads TIFF file to mesh
@@ -287,6 +311,46 @@ namespace TiffUtils {
287311 PixelData<uint16_t > mesh16{aData, true /* copy data*/ };
288312 saveMeshAsTiff (filename, mesh16);
289313 }
314+ #else
315+ template <typename T>
316+ PixelData<T> getMesh (const std::string &aFileName) {
317+ std::cerr << " libapr compiled without LibTIFF support, simulating TIFF reader functionality" << std::endl;
318+ std::cerr << " getMesh() called for " << &aFileName << " , returning empty mesh." << std::endl;
319+
320+ PixelData<T> mesh (1 , 1 , 1 );
321+ return mesh;
322+ }
323+
324+ template <typename T>
325+ PixelData<T> getMesh (const TiffInfo &aTiff) {
326+ std::cerr << " libapr compiled without LibTIFF support, simulating TIFF reader functionality" << std::endl;
327+ std::cerr << " getMesh() called for TiffInfo, returning empty mesh." << std::endl;
328+
329+ PixelData<T> mesh (1 , 1 , 1 );
330+ return mesh;
331+ }
332+
333+ template <typename T>
334+ void getMesh (const TiffInfo &aTiff, PixelData<T> &aInputMesh) {
335+ std::cerr << " libapr compiled without LibTIFF support, simulating TIFF reader functionality" << std::endl;
336+ std::cerr << " getMesh() called for inputMesh, returning empty inputMesh." << std::endl;
337+
338+ PixelData<T> mesh (1 , 1 , 1 );
339+ aInputMesh.swap (mesh);
340+ }
341+
342+ template <typename T>
343+ void saveMeshAsTiff (const std::string &aFileName, const PixelData<T> &aData) {
344+ std::cerr << " libapr compiled without LibTIFF support, simulating TIFF reader functionality" << std::endl;
345+ std::cerr << " saveMeshAsTiff() called for " << aFileName << " , not doing anything." << std::endl;
346+ }
347+
348+ template <typename T>
349+ void saveMeshAsTiffUint16 (const std::string &filename, const PixelData<T> &aData) {
350+ std::cerr << " libapr compiled without LibTIFF support, simulating TIFF reader functionality" << std::endl;
351+ std::cerr << " saveMeshAsTiff() called for " << filename << " , not doing anything." << std::endl;
352+ }
353+ #endif
290354}
291355
292356#endif
0 commit comments