Revision: 41115
http://brlcad.svn.sourceforge.net/brlcad/?rev=41115&view=rev
Author: brlcad
Date: 2010-10-20 20:05:12 +0000 (Wed, 20 Oct 2010)
Log Message:
-----------
fix a slew of compilation problems. includes a bunch of shadow warnings and
unordered args but also a missing virtual destructor, exact floating point
comparisons, and returning bools where expecting doubles.
Modified Paths:
--------------
brlcad/trunk/src/libpc/pcConstraint.cpp
brlcad/trunk/src/libpc/pcMathVM.cpp
brlcad/trunk/src/libpc/pcMathVM.h
brlcad/trunk/src/libpc/pcNetwork.cpp
brlcad/trunk/src/libpc/pcNetwork.h
brlcad/trunk/src/libpc/pcParameter.cpp
brlcad/trunk/src/libpc/pcSolver.h
brlcad/trunk/src/libpc/pcVCSet.cpp
brlcad/trunk/src/libpc/pcVariable.cpp
brlcad/trunk/src/libpc/pcVariable.h
brlcad/trunk/src/libpc/solver_test.cpp
Modified: brlcad/trunk/src/libpc/pcConstraint.cpp
===================================================================
--- brlcad/trunk/src/libpc/pcConstraint.cpp 2010-10-20 19:59:45 UTC (rev
41114)
+++ brlcad/trunk/src/libpc/pcConstraint.cpp 2010-10-20 20:05:12 UTC (rev
41115)
@@ -52,8 +52,10 @@
}
}
-bool ConstraintInterface::operator() (VCSet & vcset, std::list<std::string>
Vid) const {
+bool ConstraintInterface::operator() (VCSet & vcset, std::list<std::string>
Vid) const
+{
typedef Variable<double> * Vi;
+
for (int i =0; i < nargs_; i++) {
for (int j = 0; j < dimension_; j++) {
a[i][j] = ((Vi) vcset.getVariablebyID(Vid.front()))->getValue();
@@ -61,42 +63,43 @@
}
}
- if (fp_) {
- if ( fp_(a) == 0) {
- return true;
- } else {
- return false;
- }
- } else {
+ if (!fp_) {
std::cout << "!!! Constraint evaluation pointer NULL\n";
+ return false;
}
+
+ if ( fp_(a) == 0) {
+ return true;
+ }
+
+ return false;
}
Constraint::Constraint(VCSet &vcs) :
- vcset(vcs),
status(0),
- cif(NULL)
+ cif(NULL),
+ vcset(vcs)
{
}
Constraint::Constraint(VCSet &vcs, std::string Cid, std::string Cexpression,
functor pf) :
+ status(0),
+ cif(NULL),
vcset(vcs),
- status(0),
id(Cid),
expression(Cexpression),
- cif(NULL),
eval(pf)
{
}
Constraint::Constraint(VCSet &vcs, std::string Cid, std::string Cexpression,
functor pf, std::list<std::string> Vid) :
+ status(0),
+ cif(NULL),
vcset(vcs),
- status(0),
id(Cid),
expression(Cexpression),
- cif(NULL),
- eval(pf),
- Variables(Vid)
+ Variables(Vid),
+ eval(pf)
{
std::list<std::string>::iterator i = Variables.begin();
std::list<std::string>::iterator end = Variables.end();
@@ -105,11 +108,11 @@
}
Constraint::Constraint(VCSet &vcs, std::string Cid, std::string Cexpression,
functor pf, int count, va_list * args) :
+ status(0),
+ cif(NULL),
vcset(vcs),
- status(0),
id(Cid),
expression(Cexpression),
- cif(NULL),
eval(pf)
{
for (int i=0; i<count; i++) {
@@ -119,12 +122,12 @@
}
}
-Constraint::Constraint(VCSet &vcs, pc_constrnt * c)
- : vcset(vcs),
- status(0),
- id(bu_vls_addr(&(c->name))),
- expression(""),
- cif(c)
+Constraint::Constraint(VCSet &vcs, pc_constrnt * c) :
+ status(0),
+ cif(c),
+ vcset(vcs),
+ id(bu_vls_addr(&(c->name))),
+ expression("")
{
eval = boost::ref(cif);
std::list<std::string> t;
Modified: brlcad/trunk/src/libpc/pcMathVM.cpp
===================================================================
--- brlcad/trunk/src/libpc/pcMathVM.cpp 2010-10-20 19:59:45 UTC (rev 41114)
+++ brlcad/trunk/src/libpc/pcMathVM.cpp 2010-10-20 20:05:12 UTC (rev 41115)
@@ -31,12 +31,15 @@
#include <cassert>
#include <map>
+#include "vmath.h"
+
+
void copyStack(Stack::container_t & lhs, Stack::container_t const & rhs)
{
lhs.clear();
Stack::container_t::const_iterator i = rhs.begin();
- Stack::container_t::const_iterator const end = rhs.end();
- for(;i !=end; ++i)
+ Stack::container_t::const_iterator const rhsend = rhs.end();
+ for(; i != rhsend; ++i)
lhs.push_back((*i)->clone());
}
@@ -55,8 +58,8 @@
{
data.clear();
Stack::container_t::const_iterator i = a.begin();
- Stack::container_t::const_iterator const end = a.end();
- for (; i != end; ++i)
+ Stack::container_t::const_iterator const aend = a.end();
+ for (; i != aend; ++i)
data.push_back((*i)->clone());
}
@@ -149,9 +152,9 @@
return makeIterator(data.erase(location.base()));
}
-Stack::iterator Stack::erase(iterator begin, iterator end)
+Stack::iterator Stack::erase(iterator begin_range, iterator end_range)
{
- return makeIterator(data.erase(begin.base(), end.base()));
+ return makeIterator(data.erase(begin_range.base(), end_range.base()));
}
Stack::iterator Stack::insert(iterator location, Node * n)
@@ -274,8 +277,8 @@
: arity_(0)
{}
-UserFunction::UserFunction(std::string const & name, std::size_t const farity)
- : MathFunction(name),
+UserFunction::UserFunction(std::string const & function_name, std::size_t
const farity)
+ : MathFunction(function_name),
arity_(farity)
{}
@@ -432,7 +435,7 @@
double OrNode::OrFunc::evalp(std::vector<double> const & params) const
{
- return bool (params[0]) ? true : bool(evaluate(rhs_stack_));
+ return (!NEAR_ZERO(params[0], SMALL_FASTF)) ? 1.0 : evaluate(rhs_stack_);
}
/** FuncDefNode methods */
@@ -506,7 +509,7 @@
double BranchNode::BranchFunc::evalp(std::vector<double> const & params) const
{
- return evaluate(params[0] ? stack1_ : stack2_);
+ return evaluate(!NEAR_ZERO(params[0], SMALL_FASTF) ? stack1_ : stack2_);
}
/** Functions assisting evaluation */
Modified: brlcad/trunk/src/libpc/pcMathVM.h
===================================================================
--- brlcad/trunk/src/libpc/pcMathVM.h 2010-10-20 19:59:45 UTC (rev 41114)
+++ brlcad/trunk/src/libpc/pcMathVM.h 2010-10-20 20:05:12 UTC (rev 41115)
@@ -146,8 +146,8 @@
/* function pointer to a function taking a unary argument */
typedef T (* function_ptr) (T);
- MathF1(std::string const & name, function_ptr fp)
- : MathFunction(name),
+ MathF1(std::string const & function_name, function_ptr fp)
+ : MathFunction(function_name),
funct(fp)
{}
@@ -169,11 +169,11 @@
{
/* function pointer to a function taking two arguments */
typedef T (* function_ptr) (T, T);
- MathF2(std::string const & name, function_ptr fp)
- : MathFunction(name),
+ MathF2(std::string const & function_name, function_ptr fp)
+ : MathFunction(function_name),
funct(fp)
{
- std::cout << "Constructed " << name << std::endl;
+ std::cout << "Constructed " << function_name << std::endl;
}
/** arity return method */
std::size_t arity() const { return 2; }
Modified: brlcad/trunk/src/libpc/pcNetwork.cpp
===================================================================
--- brlcad/trunk/src/libpc/pcNetwork.cpp 2010-10-20 19:59:45 UTC (rev
41114)
+++ brlcad/trunk/src/libpc/pcNetwork.cpp 2010-10-20 20:05:12 UTC (rev
41115)
@@ -30,7 +30,7 @@
template<class T>
BinaryNetwork<T>::BinaryNetwork()
{
-};
+}
template<class T>
BinaryNetwork<T>::BinaryNetwork(std::vector<Variable<T> *> V,
std::vector<Constraint *> C) {
@@ -81,7 +81,7 @@
}
template<class T>
-void BinaryNetwork<T>::setVariable(Vertex v, Variable<T>* var)
+void BinaryNetwork<T>::setVariable(Vertex vertex, Variable<T>* var)
{
G[v] = var;
}
@@ -89,9 +89,9 @@
template<class T>
bool BinaryNetwork<T>::check()
{
- typename GraphTraits::edge_iterator e_i, e_end;
- for (tie(e_i, e_end) = edges(G); e_i != e_end; ++e_i) {
- e = *e_i;
+ typename GraphTraits::edge_iterator edge_i, edge_end;
+ for (tie(edge_i, edge_end) = edges(G); edge_i != edge_end; ++edge_i) {
+ e = *edge_i;
if (! G[e]->check()) {
return false;
}
@@ -110,19 +110,17 @@
Vertexwriter<T> vw(G);
Edgewriter<T> ew(G);
- boost::default_writer dw;
- boost::default_writer gw;
boost::write_graphviz(std::cout, G, vw, ew,
boost::make_graph_attributes_writer(graph_attr,
vertex_attr, edge_attr));
}
template<class T>
-void BinaryNetwork<T>::getVertexbyID(std::string Vid, Vertex& v)
+void BinaryNetwork<T>::getVertexbyID(std::string Vid, Vertex& vertex)
{
for (tie(v_i, v_end) = vertices(G); v_i != v_end; ++v_i) {
if ( G[*v_i]->getID() == Vid ) {
- v = *v_i;
+ vertex = *v_i;
return ;
}
}
Modified: brlcad/trunk/src/libpc/pcNetwork.h
===================================================================
--- brlcad/trunk/src/libpc/pcNetwork.h 2010-10-20 19:59:45 UTC (rev 41114)
+++ brlcad/trunk/src/libpc/pcNetwork.h 2010-10-20 20:05:12 UTC (rev 41115)
@@ -52,7 +52,7 @@
typedef boost::graph_traits<Graph> GraphTraits;
typedef typename GraphTraits::vertex_descriptor Vertex;
public:
- Vertexwriter(const Graph& g):g(g) {};
+ Vertexwriter(const Graph& graph) : g(graph) {};
void operator() (std::ostream& output, const Vertex& v) const {
output << "[label=\"" << g[v]->getID() << "\"]";
}
@@ -67,7 +67,7 @@
typedef boost::graph_traits<Graph> GraphTraits;
typedef typename GraphTraits::edge_descriptor Edge;
public:
- Edgewriter(const Graph& g):g(g) {};
+ Edgewriter(const Graph& graph) : g(graph) {};
void operator() (std::ostream& output, const Edge& e) const {
output << "[label=\"" << g[e]->getExp() << "\"]";
}
Modified: brlcad/trunk/src/libpc/pcParameter.cpp
===================================================================
--- brlcad/trunk/src/libpc/pcParameter.cpp 2010-10-20 19:59:45 UTC (rev
41114)
+++ brlcad/trunk/src/libpc/pcParameter.cpp 2010-10-20 20:05:12 UTC (rev
41115)
@@ -72,9 +72,9 @@
return makeIterator(Variables.erase(location.base()));
}
-Parameter::iterator Parameter::erase(iterator begin, iterator end)
+Parameter::iterator Parameter::erase(iterator beginning, iterator ending)
{
- return makeIterator(Variables.erase(begin.base(), end.base()));
+ return makeIterator(Variables.erase(beginning.base(), ending.base()));
}
std::string Parameter::getName() const
Modified: brlcad/trunk/src/libpc/pcSolver.h
===================================================================
--- brlcad/trunk/src/libpc/pcSolver.h 2010-10-20 19:59:45 UTC (rev 41114)
+++ brlcad/trunk/src/libpc/pcSolver.h 2010-10-20 20:05:12 UTC (rev 41115)
@@ -54,8 +54,8 @@
Solver::Solver()
: num_checks_(0),
num_solutions_(0),
- solved_(false),
- initiated_(false)
+ initiated_(false),
+ solved_(false)
{}
/* Generic solver for VCSet */
@@ -92,7 +92,7 @@
template <typename T>
bool PCSolver<T>::generator() {
std::list<VariableAbstract *>::iterator i, j, k;
- bool atend = true;
+ // bool atend = true;
i = vars_.begin();
j = vars_.end();
typedef Variable<T> * Vp;
@@ -253,7 +253,7 @@
std::list<VariableAbstract *> vars_;
VCSet * vcs;
- int labelsize();
+ size_t labelsize();
bool backtrack();
bool check();
};
@@ -264,7 +264,7 @@
{}
template <typename T>
-int BackTrackSolver<T>::labelsize() {
+size_t BackTrackSolver<T>::labelsize() {
int sum = 0;
Varlist::iterator i = vars_.begin();
Varlist::iterator end = vars_.end();
@@ -387,7 +387,7 @@
class BinaryNetwork<T>* N;
std::list<VariableAbstract *> vars_;
- int labelsize();
+ size_t labelsize();
bool backtrack();
bool check();
};
@@ -398,7 +398,7 @@
{}
template <typename T>
-int BTSolver<T>::labelsize() {
+size_t BTSolver<T>::labelsize() {
int i=0;
for (tie(v_i,v_end) = vertices(N->G); v_i != v_end; ++v_i)
if (labels[*v_i] == true) i++;
Modified: brlcad/trunk/src/libpc/pcVCSet.cpp
===================================================================
--- brlcad/trunk/src/libpc/pcVCSet.cpp 2010-10-20 19:59:45 UTC (rev 41114)
+++ brlcad/trunk/src/libpc/pcVCSet.cpp 2010-10-20 20:05:12 UTC (rev 41115)
@@ -168,16 +168,18 @@
/** @todo remove std::list passing */
std::list<std::string> VCSet::getParamVariables(const char * pname)
{
- Parameter * p = getParameter(pname);
- if (p) {
- std::list<std::string> V;
- Parameter::iterator i = p->begin();
- Parameter::iterator end = p->end();
- for (; i !=end; i++) {
- V.push_back(i->getID());
- }
+ std::list<std::string> V;
+ Parameter *p = getParameter(pname);
+ if (!p) {
return V;
}
+
+ Parameter::iterator i = p->begin();
+ Parameter::iterator end = p->end();
+ for (; i !=end; i++) {
+ V.push_back(i->getID());
+ }
+ return V;
}
void VCSet::display()
Modified: brlcad/trunk/src/libpc/pcVariable.cpp
===================================================================
--- brlcad/trunk/src/libpc/pcVariable.cpp 2010-10-20 19:59:45 UTC (rev
41114)
+++ brlcad/trunk/src/libpc/pcVariable.cpp 2010-10-20 20:05:12 UTC (rev
41115)
@@ -36,6 +36,10 @@
{
}
+VariableAbstract::~VariableAbstract()
+{
+}
+
void VariableAbstract::display()
{
}
Modified: brlcad/trunk/src/libpc/pcVariable.h
===================================================================
--- brlcad/trunk/src/libpc/pcVariable.h 2010-10-20 19:59:45 UTC (rev 41114)
+++ brlcad/trunk/src/libpc/pcVariable.h 2010-10-20 20:05:12 UTC (rev 41115)
@@ -58,14 +58,14 @@
typedef typename IntervalList::size_type size_type;
typedef typename IntervalList::difference_type difference_type;
typedef typename boost::indirect_iterator
- <typename IntervalList::iterator> iterator;
+ <typename IntervalList::iterator> iterator;
typedef typename boost::indirect_iterator
- <typename IntervalList::const_iterator> const_iterator;
+ <typename IntervalList::const_iterator> const_iterator;
/** Constructors and Destructor */
Domain() {}
~Domain() {}
- Domain(T low,T high,T step);
+ Domain(T low, T high, T step);
/** Data access methods */
int size() { return Interv.size(); }
@@ -103,8 +103,8 @@
/** Comparison */
bool operator==(Domain<T> & d) {
- if (Interv == d.Interv) return true;
- else return false; }
+ if (Interv == d.Interv) return true;
+ else return false; }
/** Display method */
void display();
private:
@@ -113,6 +113,7 @@
void packIntervals ();
};
+
class VariableAbstract {
public:
VariableAbstract(std::string vid ="");
@@ -137,6 +138,7 @@
int constrained_;
};
+
template<class T>
class Variable : public VariableAbstract {
public:
@@ -183,6 +185,7 @@
Domain<T> D;
};
+
template<class T>
class Solution {
public:
@@ -200,17 +203,20 @@
DomSet Domset_;
};
+
template<class T>
class SearchStructure {
};
+
/* Domain Class Functions */
template<class T>
-Domain<T>::Domain(T low,T high,T step) {
- addInterval(Interval<T>(low, high, step) );
+Domain<T>::Domain(T low, T high, T step) {
+ addInterval(Interval<T>(low, high, step));
}
+
template<class T>
void Domain<T>::addInterval(const Interval<T> t)
{
@@ -222,10 +228,11 @@
this->Interv.push_back(t);
else
*/
- this->Interv.insert(i,t);
+ this->Interv.insert(i, t);
packIntervals();
}
+
template<typename T>
typename Domain<T>::iterator
makeIterator(typename Domain<T>::IntervalList::iterator i)
@@ -233,6 +240,7 @@
return boost::make_indirect_iterator(i);
}
+
template<typename T>
typename Domain<T>::const_iterator
makeIterator(typename Domain<T>::IntervalList::const_iterator i)
@@ -240,6 +248,7 @@
return boost::make_indirect_iterator(i);
}
+
template<typename T>
typename Domain<T>::iterator
Domain<T>::begin()
@@ -247,6 +256,7 @@
return makeIterator(Interv.begin());
}
+
template<typename T>
typename Domain<T>::iterator
Domain<T>::end()
@@ -254,6 +264,7 @@
return makeIterator(Interv.end());
}
+
template<typename T>
typename Domain<T>::const_iterator
Domain<T>::begin() const
@@ -261,6 +272,7 @@
return makeIterator(Interv.begin());
}
+
template<typename T>
typename Domain<T>::const_iterator
Domain<T>::end() const
@@ -268,6 +280,7 @@
return makeIterator(Interv.end());
}
+
template<typename T>
typename Domain<T>::iterator
Domain<T>::erase(iterator location)
@@ -275,6 +288,7 @@
return makeIterator(Interv.erase(location.base()));
}
+
template<typename T>
typename Domain<T>::iterator
Domain<T>::erase(iterator begini, iterator endi)
@@ -282,6 +296,7 @@
return makeIterator(Interv.erase(begini.base(), endi.base()));
}
+
template<typename T>
typename Domain<T>::iterator
Domain<T>::insert(iterator location, Interval<T> * I)
@@ -290,11 +305,13 @@
return makeIterator(Interv.insert(location.base(), I));
}
+
template<class T>
void Domain<T>::addInterval(T low, T high, T step) {
- addInterval(Interval<T>(low,high,step));
+ addInterval(Interval<T>(low, high, step));
}
+
template<class T>
void Domain<T>::intersectInterval(Interval<T> t)
{
@@ -302,12 +319,12 @@
addInterval(t);
} else {
typename std::list<Interval<T> >::iterator i = this->Interv.begin();
- while (i != Interv.end() && i->getHigh() < t.getLow() )
+ while (i != Interv.end() && i->getHigh() < t.getLow())
Interv.erase(i++);
i->setLow(t.getLow());
i = Interv.end();
i--;
- while (i != Interv.begin() && i->getLow() > t.getHigh() )
+ while (i != Interv.begin() && i->getLow() > t.getHigh())
Interv.erase(i--);
i->setHigh(t.getHigh());
i->setStep(t.getStep());
@@ -323,60 +340,63 @@
throw new pcException("Variable not in domain");
}
/*
-template<class T>
-Interval<T> & Domain<T>::getPreviousInterval(T t) throw(pcException)
-{
- typename std::list<Interval<T> >::iterator i;
- for (i = this->Interv.begin(); i != this->Interv.end(); i++) {
- if (i->inInterval(t))
- break;
- }
- if (*i == Interv.front())
- return Interv.back();
- else {
- i--;
- return *i;
- }
- throw new pcException("Variable not in domain");
-}
+ template<class T>
+ Interval<T> & Domain<T>::getPreviousInterval(T t) throw(pcException)
+ {
+ typename std::list<Interval<T> >::iterator i;
+ for (i = this->Interv.begin(); i != this->Interv.end(); i++) {
+ if (i->inInterval(t))
+ break;
+ }
+ if (*i == Interv.front())
+ return Interv.back();
+ else {
+ i--;
+ return *i;
+ }
+ throw new pcException("Variable not in domain");
+ }
-template<class T>
-Interval<T> & Domain<T>::getNextInterval(T t) throw(pcException)
-{
- typename std::list<Interval<T> >::iterator i;
- for (i = this->Interv.begin(); i != this->Interv.end(); i++) {
- if (i->inInterval(t))
- break;
- }
- if (*i == Interv.back())
- return Interv.front();
- else {
- i++;
- return *i;
- }
- throw new pcException("Variable not in domain");
-}
+
+ template<class T>
+ Interval<T> & Domain<T>::getNextInterval(T t) throw(pcException)
+ {
+ typename std::list<Interval<T> >::iterator i;
+ for (i = this->Interv.begin(); i != this->Interv.end(); i++) {
+ if (i->inInterval(t))
+ break;
+ }
+ if (*i == Interv.back())
+ return Interv.front();
+ else {
+ i++;
+ return *i;
+ }
+ throw new pcException("Variable not in domain");
+ }
*/
template<class T>
T Domain<T>::getNextLow (T value)
{
typename std::list<Interval<T> >::iterator i = this->Interv.begin();
while (i!=Interv.end() && i->getLow() < value) i++;
- if( i == Interv.end() )
+ if (i == Interv.end())
return Interv.begin()->getLow();
else
return i->getLow();
}
+
template<class T>
bool Domain<T>::isEmpty()
{
- if ( Interv.empty() )
+ if (Interv.empty())
return true;
else
return false;
}
+
template<class T>
bool Domain<T>::isDisjoint()
{
@@ -386,15 +406,17 @@
return true;
}
+
template<class T>
bool Domain<T>::isUnique()
{
- if ( Interv.size() == 1 && Interv.front().isUnique() )
+ if (Interv.size() == 1 && Interv.front().isUnique())
return true;
else
return false;
}
+
template<class T>
void Domain<T>::display()
{
@@ -425,15 +447,16 @@
}
}
+
template<class T>
void Domain<T>::packIntervals ()
{
if (Interv.size()>1) {
- typename std::list<Interval<T> >::iterator i,j,temp;
+ typename std::list<Interval<T> >::iterator i, j, temp;
i=j=Interv.begin();j++;
do {
- if (i->getHigh() > j->getLow() ) {
+ if (i->getHigh() > j->getLow()) {
if (mergeIntervals(i) !=0) {
std::cout << "Error: Incompatible stepsizes" << std::endl;
std::exit(-1);
@@ -442,13 +465,14 @@
break;
}
} else {
- i++,j++;
+ i++, j++;
continue;
}
} while (j != Interv.end());
}
}
+
/**
* Variable Class methods
*/
@@ -461,11 +485,13 @@
{
}
+
template<class T>
Variable<T>::~Variable()
{
}
+
template<class T>
Variable<T>& Variable<T>::operator++()
{
@@ -482,18 +508,21 @@
}
}
+
template<class T>
void Variable<T>::addInterval(const Interval<T> t)
{
D.addInterval(t);
}
+
template<class T>
void Variable<T>::addInterval(T low, T high, T step)
{
D.addInterval(low, high, step);
}
+
template<class T>
void Variable<T>::display()
{
@@ -504,6 +533,7 @@
D.display();
}
+
template<class T>
bool Variable<T>::atUpperBoundary()
{
@@ -514,6 +544,7 @@
return false;
}
+
template<class T>
bool Variable<T>::atLowerBoundary()
{
@@ -524,6 +555,7 @@
return false;
}
+
template<class T>
bool Variable<T>::atCriticalBelow()
{
@@ -534,6 +566,7 @@
return false;
}
+
template<class T>
bool Variable<T>::atCriticalAbove()
{
@@ -544,17 +577,19 @@
return false;
}
+
/* Solution Class Functions */
template<typename T>
void Solution<T>::insert(VariableAbstract * v)
{
Variable<T> * vt = (Variable<T> *) v;
- Domain<T> dom(vt->getValue(),vt->getValue(),vt->getStep());
+ Domain<T> dom(vt->getValue(), vt->getValue(), vt->getStep());
Varset_.push_back(v);
//Domset_.back().push_back(dom);
}
+
template<class T>
bool Solution<T>::addSolution(VarSet & V)
{
@@ -569,11 +604,10 @@
typename DomSet::iterator j = Domset_.begin();
Domains D;
- bool validnew = true;
for (; i != Varset_.end(); ++i) {
Variable<T> * vt = (Variable<T> *) *i;
- Domain<T> dom(vt->getValue(),vt->getValue(),vt->getStep());
+ Domain<T> dom(vt->getValue(), vt->getValue(), vt->getStep());
D.push_back(dom);
}
@@ -594,7 +628,7 @@
std::cout << std::endl;
if (!Domset_.empty()) {
for (j = Domset_.begin(); j != Domset_.end(); ++j) {
- for ( k = j->begin(); k != j->end(); ++k) {
+ for (k = j->begin(); k != j->end(); ++k) {
std::cout << k->getFirst() << "\t";
}
std::cout << std::endl;
@@ -604,13 +638,14 @@
std::cout << "Number of Solutions: " << Domset_.size() << std::endl;
}
+
template<class T>
void Solution<T>::cdisplay()
{
if (Domset_.size() < 2)
display();
else {
- int l;
+ size_t l;
VarSet::iterator i;
typename DomSet::iterator j;
typename Domains::iterator k;
@@ -624,39 +659,40 @@
if (!Domset_.empty()) {
j = Domset_.begin();
- for ( k = j->begin(), l=0; k != j->end(); ++k,++l) {
+ for (k = j->begin(), l=0; k != j->end(); ++k, ++l) {
minmax.push_back(k->getFirst());
minmax.push_back(k->getFirst());
}
for (j = Domset_.begin(); j != Domset_.end(); ++j) {
- for ( k = j->begin(), l = 0; k != j->end(); ++k,++l) {
+ for (k = j->begin(), l = 0; k != j->end(); ++k, ++l) {
T value = k->getFirst();
minmax[2*l] = (value < minmax[2*l])?value:minmax[2*l];
minmax[2*l+1] = (value > minmax[2*l])?value:minmax[2*l+1];
}
}
}
- for (l = 0; l < minmax.size()/2; ++l) {
- std::cout << minmax[2*l] << "\t";
- }
- std::cout << std::endl;
+ for (l = 0; l < minmax.size()/2; ++l) {
+ std::cout << minmax[2*l] << "\t";
+ }
+ std::cout << std::endl;
- for (l = 0; l < minmax.size()/2; ++l) {
- if ( !NEAR_ZERO(minmax[2*l] - minmax[2*l+1], SMALL_FASTF) ) /* TODO:
needs proper tolerancing */
- std::cout << "to" << "\t";
- }
- std::cout << std::endl;
+ for (l = 0; l < minmax.size()/2; ++l) {
+ if (!NEAR_ZERO(minmax[2*l] - minmax[2*l+1], SMALL_FASTF)) /* TODO:
needs proper tolerancing */
+ std::cout << "to" << "\t";
+ }
+ std::cout << std::endl;
- for (l = 0; l < minmax.size()/2; ++l) {
- if ( !NEAR_ZERO(minmax[2*l] - minmax[2*l+1], SMALL_FASTF) ) /* TODO:
needs proper tolerancing */
- std::cout << minmax[2*l+1] << "\t";
- }
+ for (l = 0; l < minmax.size()/2; ++l) {
+ if (!NEAR_ZERO(minmax[2*l] - minmax[2*l+1], SMALL_FASTF)) /* TODO:
needs proper tolerancing */
+ std::cout << minmax[2*l+1] << "\t";
+ }
- std::cout << std::endl << "Number of Solutions: " << Domset_.size() <<
std::endl;
+ std::cout << std::endl << "Number of Solutions: " << Domset_.size() <<
std::endl;
}
}
+
template<typename T>
void Solution<T>::clear()
{
@@ -664,6 +700,7 @@
Domset_.clear();
}
+
#endif
/** @} */
/*
Modified: brlcad/trunk/src/libpc/solver_test.cpp
===================================================================
--- brlcad/trunk/src/libpc/solver_test.cpp 2010-10-20 19:59:45 UTC (rev
41114)
+++ brlcad/trunk/src/libpc/solver_test.cpp 2010-10-20 20:05:12 UTC (rev
41115)
@@ -41,7 +41,7 @@
/* Constraint functions */
struct f1 {
public:
- bool operator() (VCSet & vcset, std::list<std::string> Vid) const {
+ bool operator() (VCSet & vcset, std::list<std::string> UNUSED(Vid)) const {
typedef Variable<int> * Vi ;
int A = ((Variable<int>*) vcset.getVariablebyID("A"))->getValue();
int B = ((Vi) vcset.getVariablebyID("B"))->getValue();
@@ -50,7 +50,7 @@
} f1;
struct f2 {
public:
- bool operator() (VCSet & vcset, std::list<std::string> Vid) const {
+ bool operator() (VCSet & vcset, std::list<std::string> UNUSED(Vid)) const {
typedef Variable<int> * Vi ;
int B = ((Vi) vcset.getVariablebyID("B"))->getValue();
int C = ((Vi) vcset.getVariablebyID("C"))->getValue();
@@ -60,7 +60,7 @@
struct f3 {
public:
- bool operator() (VCSet & vcset, std::list<std::string> Vid) const {
+ bool operator() (VCSet & vcset, std::list<std::string> UNUSED(Vid)) const {
typedef Variable<int> * Vi ;
int A = ((Vi) vcset.getVariablebyID("A"))->getValue();
int D = ((Vi) vcset.getVariablebyID("D"))->getValue();
@@ -70,7 +70,7 @@
struct f4 {
public:
- bool operator() (VCSet & vcset, std::list<std::string> Vid) const {
+ bool operator() (VCSet & vcset, std::list<std::string> UNUSED(Vid)) const {
typedef Variable<int> * Vi ;
int C = ((Vi) vcset.getVariablebyID("C"))->getValue();
int A = ((Vi) vcset.getVariablebyID("A"))->getValue();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits