/[escript]/trunk/ripley/src/ripleycpp.cpp
ViewVC logotype

Diff of /trunk/ripley/src/ripleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4825 by jfenwick, Wed Apr 2 03:53:23 2014 UTC revision 4828 by sshaw, Wed Apr 2 07:01:38 2014 UTC
# Line 175  escript::Domain_ptr _brick(double _n0, d Line 175  escript::Domain_ptr _brick(double _n0, d
175          z1=extract<double>(l2);          z1=extract<double>(l2);
176      } else      } else
177          throw RipleyException("Argument l2 must be a float or 2-tuple");          throw RipleyException("Argument l2 must be a float or 2-tuple");
   
178      boost::python::list pypoints=extract<boost::python::list>(objpoints);      boost::python::list pypoints=extract<boost::python::list>(objpoints);
179      boost::python::list pytags=extract<boost::python::list>(objtags);      boost::python::list pytags=extract<boost::python::list>(objtags);
180      int numpts=extract<int>(pypoints.attr("__len__")());      int numpts=extract<int>(pypoints.attr("__len__")());
181      int numtags=extract<int>(pytags.attr("__len__")());      int numtags=extract<int>(pytags.attr("__len__")());
182        if (numtags != numpts)
183            throw RipleyException("Number of tags does not match number of points.");
184      std::vector<double> points;      std::vector<double> points;
185      std::vector<int> tags;      std::vector<int> tags;
186      tags.resize(numtags, -1);      tags.resize(numtags, -1);
187      for (int i=0;i<numpts;++i) {      for (int i=0;i<numpts;++i) {
188          boost::python::object temp=pypoints[i];          tuple temp = extract<tuple>(pypoints[i]);
189          int l=extract<int>(temp.attr("__len__")());          int l=extract<int>(temp.attr("__len__")());
190            if (l != 3)
191                throw RipleyException("Number of coordinates for each dirac point must match dimensions.");
192          for (int k=0;k<l;++k) {          for (int k=0;k<l;++k) {
193              points.push_back(extract<double>(temp[k]));              points.push_back(extract<double>(temp[k]));
194          }          }
# Line 251  escript::Domain_ptr _rectangle(double _n Line 254  escript::Domain_ptr _rectangle(double _n
254          y1=extract<double>(l1);          y1=extract<double>(l1);
255      } else      } else
256          throw RipleyException("Argument l1 must be a float or 2-tuple");          throw RipleyException("Argument l1 must be a float or 2-tuple");
           
257      boost::python::list pypoints=extract<boost::python::list>(objpoints);      boost::python::list pypoints=extract<boost::python::list>(objpoints);
258      boost::python::list pytags=extract<boost::python::list>(objtags);      boost::python::list pytags=extract<boost::python::list>(objtags);
259      int numpts=extract<int>(pypoints.attr("__len__")());      int numpts=extract<int>(pypoints.attr("__len__")());
260      int numtags=extract<int>(pytags.attr("__len__")());      int numtags=extract<int>(pytags.attr("__len__")());
261        if (numtags != numpts)
262            throw RipleyException("Number of tags does not match number of points.");
263      std::vector<double> points;      std::vector<double> points;
264      std::vector<int> tags;      std::vector<int> tags;
265      tags.resize(numtags, -1);      tags.resize(numtags, -1);
266      for (int i=0;i<numpts;++i) {      for (int i=0;i<numpts;++i) {
267          boost::python::object temp=pypoints[i];          tuple temp = extract<tuple>(pypoints[i]);
268          int l=extract<int>(temp.attr("__len__")());          int l=extract<int>(temp.attr("__len__")());
269            if (l != 2)
270                throw RipleyException("Number of coordinates for each dirac point must match dimensions.");
271          for (int k=0;k<l;++k) {          for (int k=0;k<l;++k) {
272              points.push_back(extract<double>(temp[k]));              points.push_back(extract<double>(temp[k]));
273          }          }

Legend:
Removed from v.4825  
changed lines
  Added in v.4828

  ViewVC Help
Powered by ViewVC 1.1.26