Bibliography.cpp
Go to the documentation of this file.
00001 // kate: replace-tabs off; indent-width 4; indent-mode normal
00002 // vim: ts=4:sw=4:noexpandtab
00003 /*
00004 
00005 Copyright (c) 2010--2012,
00006 François Pomerleau and Stephane Magnenat, ASL, ETHZ, Switzerland
00007 You can contact the authors at <f dot pomerleau at gmail dot com> and
00008 <stephane at magnenat dot net>
00009 
00010 All rights reserved.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014     * Redistributions of source code must retain the above copyright
00015       notice, this list of conditions and the following disclaimer.
00016     * Redistributions in binary form must reproduce the above copyright
00017       notice, this list of conditions and the following disclaimer in the
00018       documentation and/or other materials provided with the distribution.
00019     * Neither the name of the <organization> nor the
00020       names of its contributors may be used to endorse or promote products
00021       derived from this software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026 DISCLAIMED. IN NO EVENT SHALL ETH-ASL BE LIABLE FOR ANY
00027 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00030 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #include "Bibliography.h"
00037 
00038 #include <boost/typeof/typeof.hpp>
00039 #include <boost/lexical_cast.hpp>
00040 #define BOOST_ASSIGN_MAX_PARAMS 6
00041 #include <iostream>
00042 #include <cassert>
00043 #include <stdexcept>
00044 
00045 namespace PointMatcherSupport
00046 {
00047         using namespace std;
00048         
00049         template<typename M>
00050         bool contains(const M& m, const typename M::key_type& k)
00051         {
00052                 BOOST_AUTO(it,m.find(k));
00053                 return (it!=m.end());
00054         }
00055         
00056         template<typename M>
00057         const typename M::mapped_type& get(const M& m, const typename M::key_type& k)
00058         {
00059                 BOOST_AUTO(it,m.find(k));
00060                 if (it!=m.end())
00061                         return it->second;
00062                 else
00063                         throw std::runtime_error("unknown key");
00064         }
00065         
00066         static Bibliography bibliography()
00067         {
00068                 return {
00069                         {"Phillips2007VarTrimmed", {
00070                                 {"type", "inproceedings"},
00071                                 {"title", "Outlier robust ICP for minimizing fractional RMSD"},
00072                                 {"author", "Phillips, J.M. and Liu, R. and Tomasi, C."},
00073                                 {"booktitle", "3-D Digital Imaging and Modeling, 2007. 3DIM '07. Sixth International Conference on"},
00074                                 {"year", "2007"},
00075                                 {"pages", "427--434"},
00076                                 {"publisher", "IEEE Press"},
00077                                 {"doi", "10.1109/3DIM.2007.39"},
00078                                 {"fulltext", "http://x86.cs.duke.edu/~tomasi/papers/phillips/phillips3DIM07.pdf"}
00079                         }},
00080                         {"Chetverikov2002Trimmed", {
00081                                 {"type", "inproceedings"},
00082                                 {"title", "The Trimmed Iterative Closest Point Algorithm"},
00083                                 {"author", "Chetverikov, D. and Svirko, D. and Stepanov, D. and Krsek, P."},
00084                                 {"booktitle", "Pattern Recognition, 2002. Proceedings. 16th International Conference on"},
00085                                 {"year", "2002"},
00086                                 {"pages", "545--548"},
00087                                 {"publisher", "IEEE Press"},
00088                                 {"doi", "10.1109/ICPR.2002.1047997 "},
00089                                 {"fulltext", "http://hci.iwr.uni-heidelberg.de/publications/dip/2002/ICPR2002/DATA/10_1_03.PDF"}
00090                         }},
00091                         {"Besl1992Point2Point", {
00092                                 {"type", "inproceedings"},
00093                                 {"title", "A Method for Registration of 3-D Shapes"},
00094                                 {"author", "Besl, P.J. and McKay, H.D."},
00095                                 {"booktitle", "Pattern Analysis and Machine Intelligence, IEEE Transactions"},
00096                                 {"year", "1992"},
00097                                 {"pages", "239--256"},
00098                                 {"publisher", "IEEE Press"},
00099                                 {"doi", "10.1109/34.121791"},
00100                                 {"fulltext", "http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=121791"}
00101                         }},
00102                         {"Censi2007ICPCovariance", {
00103                                 {"type", "inproceedings" },
00104                                 {"title", "An Accurate Closed-Form Estimate of {ICP}'s Covariance" },
00105                                 {"author", "Censi, A." },
00106                                 {"booktitle", "Proceedings of the {IEEE} International Conference on Robotics and Automation ({ICRA})" },
00107                                 {"year", "2007" },
00108                                 {"pages", "3167--3172" },
00109                                 {"publisher", "IEEE Press" },
00110                                 {"doi", "10.1109/ROBOT.2007.363961" },
00111                                 {"fulltext", "http://purl.org/censi/research/2007-icra-icpcov.pdf"}
00112                         }},
00113                         {"Chen1991Point2Plane", {
00114                                 {"type", "inproceedings"},
00115                                 {"title", "Object modeling by registration of multiple range images"},
00116                                 {"author", "Chen, Y. and Medioni, G."},
00117                                 {"booktitle", "Robotics and Automation, 1991. Proceedings., 1991 IEEE International Conference on"},
00118                                 {"year", "1991"},
00119                                 {"pages", "2724--2729"},
00120                                 {"publisher", "IEEE Press"},
00121                                 {"doi", "10.1109/ROBOT.1991.132043"},
00122                                 {"fulltext", "http://ieeexplore.ieee.org/search/srchabstract.jsp?tp=&arnumber=132043"}
00123                         }},
00124                         {"Masuda1996Random", {
00125                                 {"type", "inproceedings"},
00126                                 {"title", "Registration and integration of multiple range images for 3-D model construction"},
00127                                 {"author", "Masuda, T. and Sakaue, K. and Yokoya, N."},
00128                                 {"booktitle", "Pattern Recognition, 1996., Proceedings of the 13th International Conference on"},
00129                                 {"year", "1996"},
00130                                 {"pages", "879--883"},
00131                                 {"publisher", "IEEE Press"},
00132                                 {"doi", "10.1109/ICPR.1996.546150"},
00133                                 {"fulltext", "http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=546150"}
00134                         }},
00135                         {"Diebel2004Median", {
00136                                 {"type", "inproceedings"},
00137                                 {"title", "Simultaneous Localization and Mapping with Active Stereo Vision"},
00138                                 {"author", "Diebel, J. and Reutersward, K. and Thrun, S. and Davis, J. and Gupta, R."},
00139                                 {"booktitle", "Intelligent Robots and Systems, 2004. (IROS 2004). Proceedings. 2004 IEEE/RSJ International Conference on"},
00140                                 {"year", "2004"},
00141                                 {"pages", "3436--3443"},
00142                                 {"publisher", "IEEE Press"},
00143                                 {"doi", "10.1109/IROS.2004.1389948"},
00144                                 {"fulltext", "http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1389948"}
00145                         }},
00146                         {"Pomerleau2012Noise", {
00147                                 {"type", "inproceedings"},
00148                                 {"title", "Noise Characterization of Depth Sensors for Surface Inspections"},
00149                                 {"author", "F. Pomerleau, A. Breitenmoser, M. Liu, F. Colas, R. Siegwart"},
00150                                 {"booktitle", " International Conference on Applied Robotics for the Power Industry, 2012. (CARPI 2012). Proceedings of the IEEE"},
00151                                 {"year", "2012"},
00152                                 {"pages", "1--8"},
00153                                 {"publisher", "IEEE Press"},
00154                                 {"doi", ""},
00155                                 {"fulltext", ""}
00156                         }},
00157                         {"RobustWeightFunctions", {
00158                                 {"type", "article"},
00159                                 {"title", "Robust regression using iteratively reweighted least-squares"},
00160                                 {"author", "Paul W Holland and Roy E Welsch"},
00161                                 {"booktitle", "Communications in Statistics - Theory and Methods"},
00162                                 {"year", "1977"},
00163                                 {"pages", "813-827"},
00164                                 {"publisher", ""},
00165                                 {"doi", "10.1080/03610927708827533"},
00166                                 {"fulltext", ""}
00167                         }},
00168                         {"Umeyama1991", {
00169                                 {"type", "article"},
00170                                 {"author", "Umeyama, Shinji"},
00171                                 {"title", "Least-Squares Estimation of Transformation Parameters Between Two Point Patterns"},
00172                                 {"journal", "IEEE Trans. Pattern Anal. Mach. Intell."},
00173                                 {"issue_date", "April 1991"},
00174                                 {"volume", "13"},
00175                                 {"number", "4"},
00176                                 {"month", "apr"},
00177                                 {"year", "1991"},
00178                                 {"issn", "0162-8828"},
00179                                 {"pages", "376--380"},
00180                                 {"numpages", "5"},
00181                                 {"url", "https://doi.org/10.1109/34.88573"},
00182                                 {"doi", "10.1109/34.88573"},
00183                                 {"acmid", "105525"},
00184                                 {"publisher", "IEEE Computer Society"},
00185                                 {"address", "Washington, DC, USA"}
00186                         }},
00187                         {"Rusinkiewicz2001", {
00188                                 {"type", "inproceedings"},
00189                                 {"author", "Rusinkiewicz, Szymon and Levoy, Marc"},
00190                                 {"title", "Efficient Variants of the ICP Algorithm"},
00191                                 {"journal", "Proceedings Third International Conference on 3-D Digital Imaging and Modeling"},
00192                                 {"year", "2001"},
00193                                 {"isbn", "0769509843"},
00194                                 {"pages", "145--152"},
00195                                 {"doi", "10.1109/IM.2001.924423"},
00196                                 {"publisher", "IEEE Computer Society"},
00197                                 {"address", "Quebec City, Quebec, Canada"}
00198                         }},
00199                         {"Gelfand2003", {
00200                                 {"type", "inproceedings"},
00201                                 {"author", "Gelfand, N. and Ikemoto, L. and Rusinkiewicz, Szymon and Levoy, M."},
00202                                 {"title", "Geometrically stable sampling for the ICP algorithm"},
00203                                 {"journal", "Fourth International Conference on 3-D Digital Imaging and Modeling, 2003. 3DIM 2003. Proceedings."},
00204                                 {"year", "2003"},
00205                                 {"isbn", "0-7695-1991-1"},
00206                                 {"pages", "260--267"},
00207                                 {"doi", "10.1109/IM.2003.1240258"},
00208                                 {"publisher", "IEEE Computer Society"}
00209                         }}
00210                 };
00211         }
00212         
00213         CurrentBibliography::CurrentBibliography(Mode mode):
00214                 mode(mode)
00215         {}
00216         
00217         void CurrentBibliography::dump(std::ostream& os) const
00218         {
00219                 switch (mode)
00220                 {
00221                         case NORMAL: dumpText(os); break;
00222                         case ROSWIKI: dumpWiki(os); break;
00223                         case BIBTEX: dumpBibtex(os); break;
00224                         default: assert(false); break;
00225                 };
00226         }
00227         
00228         void CurrentBibliography::dumpText(std::ostream& os) const
00229         {
00230                 Bibliography biblio(bibliography());
00231                 for (size_t i = 0; i < entries.size(); ++i)
00232                 {
00233                         const string& entryName(entries[i]);
00234                         if (!contains(biblio, entryName))
00235                                 throw runtime_error(string("Broken bibliography, missing entry " + entryName));
00236                         const StringMap& entry(get(biblio, entryName));
00237                         
00238                         os << "[" << i+1 << "]";
00239                         if (contains(entry, "title"))
00240                                 os << " " << get(entry, "title") << ".";
00241                         if (contains(entry, "author"))
00242                                 os << " " << get(entry, "author") << "";
00243                         if (contains(entry, "booktitle"))
00244                                 os << " In " << get(entry, "booktitle") << ".";
00245                         if (contains(entry, "journal"))
00246                                 os << " " << get(entry, "journal") << ".";
00247                         if (contains(entry, "pages"))
00248                                 os << " " << get(entry, "pages") << ".";
00249                         if (contains(entry, "year"))
00250                                 os << " " << get(entry, "year") << ".";
00251                         os << endl << endl;
00252                 }
00253         }
00254 
00255         void CurrentBibliography::dumpWiki(std::ostream& os) const
00256         {
00257                 Bibliography biblio(bibliography());
00258                 for (size_t i = 0; i < entries.size(); ++i)
00259                 {
00260                         const string& entryName(entries[i]);
00261                         if (!contains(biblio, entryName))
00262                                 throw runtime_error(string("Broken bibliography, missing entry " + entryName));
00263                         const StringMap& entry(get(biblio, entryName));
00264                         
00265                         os << " * " << "<<Anchor(" << entryName << ")>>[" << i+1 << "] -";
00266                         if (contains(entry, "title"))
00267                                 os << " '''" << get(entry, "title") << ".'''";
00268                         if (contains(entry, "author"))
00269                                 os << " " << get(entry, "author") << "";
00270                         if (contains(entry, "booktitle"))
00271                                 os << " ''In " << get(entry, "booktitle") << ".''";
00272                         if (contains(entry, "journal"))
00273                                 os << " " << get(entry, "journal") << ".";
00274                         if (contains(entry, "pages"))
00275                                 os << " " << get(entry, "pages") << ".";
00276                         if (contains(entry, "year"))
00277                                 os << " " << get(entry, "year") << ".";
00278                         if (contains(entry, "doi"))
00279                                 os << " DOI: [[https://doi.org/" << get(entry, "doi") << "|" << get(entry, "doi") << "]].";
00280                         if (contains(entry, "fulltext"))
00281                                 os << " [[" << get(entry, "fulltext") << "|full text]].";
00282                         os << endl;
00283                 }
00284         }
00285 
00286         void CurrentBibliography::dumpBibtex(std::ostream& os) const
00287         {
00288                 Bibliography biblio(bibliography());
00289                 for (size_t i = 0; i < entries.size(); ++i)
00290                 {
00291                         const string& entryName(entries[i]);
00292                         if (!contains(biblio, entryName))
00293                                 throw runtime_error(string("Broken bibliography, missing entry " + entryName));
00294                         const StringMap& entry(get(biblio, entryName));
00295                         
00296                         os << "@" << get(entry, "type") << "{" << entryName << endl;
00297                         if (contains(entry, "title"))
00298                                 os << "\ttitle={" << get(entry, "title") << "}," << endl;
00299                         if (contains(entry, "author"))
00300                                 os << "\tauthor={" << get(entry, "author") << "}," << endl;
00301                         if (contains(entry, "booktitle"))
00302                                 os << "\tbooktitle={" << get(entry, "booktitle") << "}," << endl;
00303                         if (contains(entry, "journal"))
00304                                 os << "\tjournal={" << get(entry, "journal") << "}," << endl;
00305                         if (contains(entry, "pages"))
00306                                 os << "\tpages={" << get(entry, "pages") << "}," << endl;
00307                         if (contains(entry, "year"))
00308                                 os << "\tyear={" << get(entry, "year") << "}," << endl;
00309                         os << "}" << endl << endl;
00310                 }
00311         }
00312         
00313         static StringVector splitString(const string& text, char delim)
00314         {
00315                 StringVector res;
00316                 size_t pos = 0;
00317                 while(true)
00318                 {
00319                         const size_t nextPos = text.find(delim, pos);
00320                         if (nextPos == text.npos)
00321                         {
00322                                 res.push_back(text.substr(pos));
00323                                 break;
00324                         }
00325                         else
00326                                 res.push_back(text.substr(pos, nextPos - pos));
00327                         pos = nextPos + 1;
00328                 }
00329                 return res;
00330         }
00331         
00332         std::string getAndReplaceBibEntries(const std::string& text, CurrentBibliography& curBib)
00333         {
00334                 CurrentBibliography::Mode mode(curBib.mode);
00335                 BibIndices& indices(curBib.indices);
00336                 StringVector& entries(curBib.entries);
00337                 
00338                 string newText;
00339                 const StringVector words(splitString(text, ' '));
00340                 for (size_t i = 0; i < words.size(); ++i)
00341                 {
00342                         const string& word(words[i]);
00343                         const size_t l(word.length());
00344                         const size_t p(word.find('}'));
00345                         if ((l > 7) && (word.substr(0, 6) == "\\cite{") && (p != string::npos))
00346                         {
00347                                 if (mode == CurrentBibliography::ROSWIKI)
00348                                         newText += "&#91;";
00349                                 else
00350                                         newText += '[';
00351                                 const StringVector keys(splitString(word.substr(6, p-6), ','));
00352                                 for (size_t j = 0; j < keys.size(); ++j)
00353                                 {
00354                                         const string key(keys[j]);
00355                                         if (mode == CurrentBibliography::ROSWIKI)
00356                                                 newText += "[[#" + key + "|";
00357                                         if (contains(indices, key))
00358                                         {
00359                                                 newText += std::to_string(get(indices, key)+1);
00360                                         }
00361                                         else
00362                                         {
00363                                                 size_t index(entries.size());
00364                                                 entries.push_back(key);
00365                                                 indices[key] = index;
00366                                                 newText += std::to_string(index+1);
00367                                         }
00368                                         if (mode == CurrentBibliography::ROSWIKI)
00369                                                 newText += "]]";
00370                                         if (j+1 != keys.size())
00371                                                 newText += ',';
00372                                 }
00373                                 if (mode == CurrentBibliography::ROSWIKI)
00374                                         newText += "&#93;";
00375                                 else
00376                                         newText += ']';
00377                                 newText += word.substr(p+1);
00378                         }
00379                         else
00380                                 newText += word;
00381                         if (i+1 != words.size())
00382                                 newText += ' ';
00383                 }
00384                 if (mode == CurrentBibliography::BIBTEX)
00385                         return text;
00386                 else
00387                         return newText;
00388         }
00389 }; // PointMatcherSupport


libpointmatcher
Author(s):
autogenerated on Thu Jun 20 2019 19:51:29