/* -*- C++ -*- * Copyright ©2005 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #include "magellan/content.h" #include #include #include #include "magellan/options.h" #include "magellan/vectors.h" #include "content_outline.h" #include "content_outline_rawcontourset.h" extern "C" PluginInfo* getmodules(int i) { if(i==0) { PluginInfo_Content* pi = new PluginInfo_Content(); pi->name = "Outline content"; pi->author = "Hugo Mills"; pi->copyright = "©2008 Hugo Mills"; pi->version = 0x00001; pi->parser = Content_Outline::parse; return pi; } else return NULL; } Content* Content_Outline::parse( ConfigLexer* lex, const std::string& type, const std::string& subtype ) { if(type != "outline") return NULL; std::string filename = ""; while(!lex->eos()) { if(readkeyedvalue(lex, "file", &filename) ) { } else throw(UnknownConfigToken(lex)); } if(filename == "") throw PluginInitError("Filename not specified"); std::string tmp = opts->find_data_file("outline/", filename); if(tmp == "") throw(PluginInitError("File '" + filename + "' not found")); return new Content_Outline(filename); } Content_Outline::Content_Outline( const std::string& filename ) { // Load data from file /* std::istream in("moo"); while(!in.eof()) { // Stuff } */ } Content_Outline::~Content_Outline() { } void Content_Outline::plot( Output* output, XfView* viewport, XfMap* projection, XfOrbit* orbit, XfSphere* globe) { // For each closed loop for(int cont = 0; cont < data.ncontours(); cont++) { for(int outl = 0; outl < data.noutlines(cont); outl++) { TracePointCollection crossings; crossings.reserve(data.npoints(cont, outl)); TPCInsertIterator it = back_inserter(crossings); TraceState* state = projection->initpath( it, data.point(cont, outl, 0)); // Map the points and work out the path crossings for(int pt = 1; pt < data.npoints(cont, outl); pt++) { projection->pathpoint(state, it, data.point(cont, outl, pt)); } projection->endpath(state); // Convert to a set of open paths, ordered by lambda value // of the path start point. If the path in question is // closed (i.e. start & end points don't have lambdas), // then just take the path on its own. // If the path is open, reconstruct a closed path, by // picking (and removing from the list) the path segment // with the next largest lambda value after the lambda for // the end of the current path. Join the two by use of // tracepath(). Finish the path if the segment picked is // the same as the segment that we started with. } } }