2
* @file AssistantMakefilelibExport.cpp
8
/* This is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This software is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU General Public
19
* License along with this software; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include "AssistantMakefilelibExport.h"
26
#include <makefilelib/char_type.h>
32
#include <makefilelib/Comment.h>
33
#include <makefilelib/Variable.h>
34
#include <makefilelib/VariableDef.h>
35
#include <makefilelib/VariableRef.h>
36
#include <makefilelib/MakefileItem.h>
37
#include <makefilelib/Makefile.h>
38
#include <makefilelib/AutoVariable.h>
39
#include <makefilelib/Newline.h>
40
#include <makefilelib/Rule.h>
41
#include <makefilelib/Conditional.h>
42
#include <makefilelib/Manager.h>
43
#include <makefilelib/Anything.h>
45
#include <panodata/PanoramaData.h>
46
#include <hugin_utils/utils.h>
47
#include "algorithms/optimizer/ImageGraph.h"
51
using namespace makefile;
53
using namespace vigra;
54
namespace mf = makefile;
56
/// Automates an very often occuring sequence
57
#define newVarDef(var, name, ...) \
58
mf::Variable* var = mgr.own(new mf::Variable(name, __VA_ARGS__)); \
61
void AssistantMakefilelibExport::echoInfo(Rule& inforule, const std::string& info)
64
inforule.addCommand("echo " + info, false);
66
inforule.addCommand("echo '" + info + "'", false);
70
bool AssistantMakefilelibExport::createItems()
72
// we use this Variable for initializing pointers that get an object only under certain conditions
73
mf::Variable* nullvar = mgr.own(new mf::Variable("NOT_DEFINED", "This_variable_has_not_been_defined"));
75
mgr.own_add((new Comment(
76
"makefile for automatic panorama generating, created by hugin using the new makefilelib")));
79
mgr.own_add(new Comment("Force using cmd.exe"));
80
mf::Variable* winshell = mgr.own(new mf::Variable("SHELL", getenv("ComSpec")));
81
winshell->getDef().add();
85
// set the tool commands
86
mgr.own_add(new Comment("Tool configuration"));
87
newVarDef(vicpfind, "ICPFIND", progs.icpfind)
88
newVarDef(vceleste, "CELESTE", progs.celeste)
89
newVarDef(vcheckpto, "CHECKPTO", progs.checkpto)
90
newVarDef(vcpclean, "CPCLEAN", progs.cpclean)
91
newVarDef(vautooptimiser, "AUTOOPTIMISER", progs.autooptimiser)
92
newVarDef(vpanomodify, "PANO_MODIFY", progs.pano_modify)
94
newVarDef(vproject, "PROJECT", projectFile, Makefile::MAKE);
95
newVarDef(vprojectShell, "PROJECT_SHELL", projectFile,Makefile::SHELL)
97
Rule* all = mgr.own(new Rule());
98
all->addTarget("all");
99
all->addPrereq(vproject->getRef());
101
mf::string outinproject=cstr(" -o ")+vprojectShell->getRef()+cstr(" ")+vprojectShell->getRef();
102
bool runicp=(pano.getNrOfCtrlPoints()==0);
105
//we check, if all images are connected
106
//if not, we run also icpfind
108
createCPGraph(pano, graph);
110
runicp=findCPComponents(graph, comps)>1;
112
//build commandline for icpfind
116
echoInfo(*all,"Finding control points...");
117
all->addCommand(vicpfind->getRef()+outinproject);
118
//building celeste command
121
mf::string celesteCommand=vceleste->getRef()+" ";
122
valuestream.str(""); // clear the streams buffer
123
valuestream << " -t " << celesteThreshold;
124
celesteCommand+=valuestream.str()+" ";
125
if(celesteSmallRadius)
126
celesteCommand+="-r 1 ";
127
echoInfo(*all,"Remove control points in clouds...");
128
all->addCommand(celesteCommand+cstr(" -o ")+vprojectShell->getRef()+cstr(" -i ")+vprojectShell->getRef());
130
//building cpclean command
133
all->addCommand(vcheckpto->getRef()+" "+vprojectShell->getRef());
134
echoInfo(*all,"Statistical cleaning of control points...");
135
all->addCommand(vcpclean->getRef()+outinproject);
139
all->addCommand(vcheckpto->getRef()+" "+vprojectShell->getRef());
140
echoInfo(*all,"Optimise project...");
141
all->addCommand(vautooptimiser->getRef()+" -a -m -l -s"+outinproject);
142
// if necessary scale down final pano
143
echoInfo(*all,"Setting output options...");
147
valuestream << " --canvas=" << hugin_utils::roundi(scale*100) << "%%";
149
all->addCommand(vpanomodify->getRef()+valuestream.str()+cstr(" --crop=AUTO")+outinproject);