New export through plugin scheme for yafray. It is working on linux and mac os x
[blender.git] / source / blender / yafray / intern / yafexternal.cpp
1 #include "yafexternal.h"
2 #include <iostream>
3 namespace yafray {
4
5 bool paramMap_t::getParam(const std::string &name,std::string &s)
6 {
7         if(includes(name,TYPE_STRING)) s=(*this)[name].getStr();
8                 else return false;
9         return true;
10 }
11                         
12 bool paramMap_t::getParam(const std::string &name,bool &b)
13 {
14         std::string str;
15         if(includes(name,TYPE_STRING)) 
16         {
17                 str=(*this)[name].getStr();
18                 if(str=="on") b=true;
19                 else if(str=="off") b=false;
20                 else return false;
21         }
22         else return false;
23         return true;
24 }
25
26 bool paramMap_t::getParam(const std::string &name,float &f)
27 {
28         if(includes(name,TYPE_FLOAT)) f=(*this)[name].getFnum();
29                 else return false;
30         return true;
31 }
32                         
33 bool paramMap_t::getParam(const std::string &name,double &f)
34 {
35         if(includes(name,TYPE_FLOAT)) f=(*this)[name].getFnum();
36                 else return false;
37         return true;
38 }
39                         
40 bool paramMap_t::getParam(const std::string &name,int &i)
41 {
42         if(includes(name,TYPE_FLOAT)) i=(int)(*this)[name].getFnum();
43                 else return false;
44         return true;
45 }
46
47 bool paramMap_t::getParam(const std::string &name,point3d_t &p)
48 {
49         if(includes(name,TYPE_POINT)) p=(*this)[name].getP();
50                 else return false;
51         return true;
52 }
53                         
54 bool paramMap_t::getParam(const std::string &name,color_t &c)
55 {
56         if(includes(name,TYPE_COLOR)) c=(*this)[name].getC();
57                 else return false;
58         return true;
59 }
60
61 bool paramMap_t::getParam(const std::string &name,colorA_t &c)
62 {
63         if(includes(name,TYPE_COLOR)) c=(*this)[name].getAC();
64                 else return false;
65         return true;
66 }
67
68 bool paramMap_t::includes(const std::string &label,int type)
69 {
70         const_iterator i=find(label);
71         if(i==end()) return false;
72         if((*i).second.type!=type) return false;
73         return true;
74 }
75
76 void paramMap_t::checkUnused(const std::string &env)
77 {
78         for(const_iterator i=begin();i!=end();++i)
79                 if(!( (*i).second.used ))
80                         std::cout<<"[WARNING]:Unused param "<<(*i).first<<" in "<<env<<"\n";
81 }
82
83 }