# HG changeset patch
# User John Donoghue
# Date 1427226192 14400
#      Tue Mar 24 15:43:12 2015 -0400
# Node ID 10c944ddf62fac761bc23b73c39d6d3f66e8a98e
# Parent  8c754089f61d23af9e6a842d1dac4de61fbc82a9
update Octave_map to octave_map for octave-4.0.0

* src/Makefile.in: added addition gdcm libs -lgdcmCommon -lgdcmDSED -lgdcmDICT

* src/dicominfo.cpp: update Octave_map to octave_map.

* src/dicomwrite.cpp: update Octave_map to octave_map.

* src/configure.ac: add back up gdcm search if cmake cant be found

diff -r 8c754089f61d -r 10c944ddf62f src/Makefile.in
--- a/src/Makefile.in	Sun Nov 09 17:20:45 2014 +0000
+++ b/src/Makefile.in	Tue Mar 24 15:43:12 2015 -0400
@@ -5,7 +5,7 @@
 
 ## Ideally we'd get @GDCM_LIB_FLAGS@ from configure but that would be -rdynamic
 ## which mkoctfile does not handle
-GDCM_LIB_FLAGS = -lgdcmMSFF
+GDCM_LIB_FLAGS = -lgdcmMSFF -lgdcmCommon -lgdcmDSED -lgdcmDICT
 
 need_dict = dicominfo.oct dicomwrite.oct dicomlookup.oct
 
diff -r 8c754089f61d -r 10c944ddf62f src/configure.ac
--- a/src/configure.ac	Sun Nov 09 17:20:45 2014 +0000
+++ b/src/configure.ac	Tue Mar 24 15:43:12 2015 -0400
@@ -11,6 +11,28 @@
 dnl
 CMAKE_FIND_PACKAGE([GDCM], [CXX])
 
+# if didnt find any libs, try looking ourselves
+if test "x$GDCM_LIBS" ==  "x"; then
+  AC_MSG_CHECKING([again for gdcm])
+  GDCM_CXXFLAGS=
+  GDCM_LIBS=
+  for gdcm_dir in "$prefix/include" /include /usr/include /usr/local/include
+  do
+    if test -z $gdcm_inc; then
+      if test -d $gdcm_dir; then
+        gdcm_inc=`find $gdcm_dir -maxdepth 1 -type d -name 'gdcm*' | head -1`
+        GDCM_CXXFLAGS=-I$gdcm_inc
+      fi
+    fi
+  done
+  
+  if test -z "$GDCM_CXXFLAGS"; then
+    AC_MSG_RESULT([no])
+  else
+    AC_MSG_RESULT([yes])
+  fi
+fi
+
 ## set temporarily to search for the headers only
 OLD_CPPFLAGS=$CPPFLAGS
 CPPFLAGS="$CPPFLAGS $GDCM_CXXFLAGS"
diff -r 8c754089f61d -r 10c944ddf62f src/dicominfo.cpp
--- a/src/dicominfo.cpp	Sun Nov 09 17:20:45 2014 +0000
+++ b/src/dicominfo.cpp	Tue Mar 24 15:43:12 2015 -0400
@@ -76,10 +76,10 @@
 char* byteval2string(char * d, int d_len_p, const gdcm::ByteValue *bv);
 char* name2Keyword(char *d, int *d_len_p, const char* s);
 Matrix str2DoubleVec(const char*);
-Octave_map dump(const char filename[], int chatty);
-void dumpDataSet(Octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth);
+octave_map dump(const char filename[], int chatty);
+void dumpDataSet(octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth);
 void getFileModTime(char *timeStr, const char *filename);
-void dumpElement(Octave_map *om, const gdcm::DataElement * elem, int chatty, int sequenceDepth);
+void dumpElement(octave_map *om, const gdcm::DataElement * elem, int chatty, int sequenceDepth);
 void dumpSequence(octave_value *ov, gdcm::SequenceOfItems *seq, int chatty, int sequenceDepth);
 int element2value(std::string & varname, octave_value *ov, const gdcm::DataElement * elem, int chatty, int sequenceDepth) ;
 
@@ -163,7 +163,7 @@
 		}
 	}
 	
-	Octave_map om=dump(filename.c_str(),chatty);
+	octave_map om=dump(filename.c_str(),chatty);
 	retval(0)=om;
 
 	load_dicom_dict(current_dict.c_str()); // reset dictionary to initial value
@@ -172,9 +172,9 @@
 #endif
 
 
-Octave_map dump(const char filename[], int chatty) {
+octave_map dump(const char filename[], int chatty) {
 	// output struct
-	Octave_map om;
+	octave_map om;
 	// Instantiate the reader:
 	gdcm::Reader reader;
 	reader.SetFileName( filename );
@@ -187,10 +187,10 @@
 	gdcm::DataSet &ds = file.GetDataSet();
 	gdcm::FileMetaInformation &hds=file.GetHeader();
 	
-	om.assign("Filename",filename);
+	om.assign("Filename", octave_value(filename));
 	char dateStr[TIME_STR_LEN+1];
 	getFileModTime(dateStr, filename);
-	om.assign("FileModDate", dateStr);
+	om.assign("FileModDate", octave_value(dateStr));
 	if(chatty) octave_stdout << "# file info\nFilename:" 
 		<< filename << "\nFileModDate:" << dateStr << '\n';
 	
@@ -202,7 +202,7 @@
 	return om;
 }
 
-void dumpDataSet(Octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth) {
+void dumpDataSet(octave_map *om, const gdcm::DataSet *ds, int chatty, int sequenceDepth) {
 	
 	const gdcm::DataSet::DataElementSet DES=ds->GetDES(); // gdcm::DataSet::DataElementSet is a std::set
 	gdcm::DataSet::Iterator it;
@@ -212,7 +212,7 @@
 	}
 }
 
-void dumpElement(Octave_map *om, const gdcm::DataElement * elem, 
+void dumpElement(octave_map *om, const gdcm::DataElement * elem, 
 				int chatty, int sequenceDepth) {
 	std::string varname;
 	octave_value ov;
@@ -220,7 +220,7 @@
 		om->assign(varname.c_str(), ov);
 	} else {
 		if (0==varname.length()) return ;
-		om->assign(varname.c_str(), "not assigned");
+		om->assign(varname.c_str(), octave_value("not assigned"));
 	}
 }
 
@@ -453,10 +453,10 @@
 	const octave_idx_type nDataSet=seq->GetNumberOfItems(); // objects in sequence
 	if (chatty) octave_stdout << nDataSet << " object" << ((nDataSet==1)?"":"s") << std::endl;
 	char item_name_buf[16];
-	Octave_map om;
+	octave_map om;
 	for (octave_idx_type j=1; j<=nDataSet; j++ ) {
 		const gdcm::DataSet::DataElementSet des=seq->GetItem(j).GetNestedDataSet().GetDES() ;
-		Octave_map subom;
+		octave_map subom;
 		for (gdcm::DataSet::Iterator it=des.begin(); it != des.end(); it++) {
 			std::string key("");
 			octave_value subov;
@@ -464,7 +464,7 @@
 				subom.assign(key.c_str(), subov);
 			} else {
 				if (0==key.length()) continue ;
-				subom.assign(key.c_str(), "not assigned");
+				subom.assign(key.c_str(), octave_value("not assigned"));
 			}
 		}
 		snprintf(item_name_buf,15,"Item_%i",j);
diff -r 8c754089f61d -r 10c944ddf62f src/dicomwrite.cpp
--- a/src/dicomwrite.cpp	Sun Nov 09 17:20:45 2014 +0000
+++ b/src/dicomwrite.cpp	Tue Mar 24 15:43:12 2015 -0400
@@ -43,7 +43,7 @@
 // TODO all fns here should throw exceptions, not use this "std::string & err" arg
 
 void struct2metadata(gdcm::ImageWriter *w, gdcm::File *file, const octave_value  & ov, bool trial, int sequenceDepth) ;
-void structarray2sequence(gdcm::SequenceOfItems & sq, Octave_map * om, bool trial, int sequenceDepth);
+void structarray2sequence(gdcm::SequenceOfItems & sq, octave_map * om, bool trial, int sequenceDepth);
 void value2element (gdcm::DataElement * de, const octave_value * ov, gdcm::Tag * tag, const std::string & keyword, bool trial, bool * handled, int sequenceDepth);
 void octaveVal2dicomImage(gdcm::ImageWriter *w, octave_value *pixval) ;
 void genMinimalMetaData(gdcm::ImageWriter *w, gdcm::File *file);
@@ -132,9 +132,9 @@
 	}
 	gdcm::DataSet ds;
 	gdcm::FileMetaInformation hds;
-	Octave_map om=ov.map_value();
+	octave_map om=ov.map_value();
 	uint32_t skipped = 0;
-	for (Octave_map::iterator it = om.begin(); it != om.end(); it++) {
+	for (octave_map::iterator it = om.begin(); it != om.end(); it++) {
 		std::string keyword(om.key(it));
 		Cell cell = om.contents(it);
 		if (!dicom_is_present(keyword)) {
@@ -179,17 +179,17 @@
 	return ;
 }
 
-void structarray2sequence(gdcm::SequenceOfItems & sq, Octave_map * om, bool trial, int sequenceDepth) {
-	for (Octave_map::iterator it = om->begin(); it != om->end(); it++) {
+void structarray2sequence(gdcm::SequenceOfItems & sq, octave_map * om, bool trial, int sequenceDepth) {
+	for (octave_map::iterator it = om->begin(); it != om->end(); it++) {
 		gdcm::Item item;
 		// item.SetVLToUndefined(); //TODO: does VL need to be set for items that contain datasets?
 		gdcm::DataSet &nds = item.GetNestedDataSet();
 		std::string itemname(om->key(it));
 		// TODO: test itemname is something like Item_n.
 		Cell cell = om->contents(it);
-		Octave_map subom = cell(0).map_value();
+		octave_map subom = cell(0).map_value();
 		// octave_stdout << itemname <<std::endl;
-		for (Octave_map::iterator subit = subom.begin(); subit != subom.end(); subit++) {
+		for (octave_map::iterator subit = subom.begin(); subit != subom.end(); subit++) {
 			std::string subkeyword(subom.key(subit));
 			gdcm::DataElement de;
 			gdcm::Tag tag;
@@ -289,7 +289,7 @@
 		}
 		octave_stdout << std::endl;
 		//int nObj = ov->numel() ;
-		Octave_map subom = ov->map_value();
+		octave_map subom = ov->map_value();
 		gdcm::SmartPointer<gdcm::SequenceOfItems> sq = new gdcm::SequenceOfItems();
 		try {
 			structarray2sequence(*sq, &subom, trial, ++sequenceDepth) ;
