]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move PointWrapper to its own files.
authorBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 3 Jun 2016 15:16:50 +0000 (11:16 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 3 Aug 2016 20:34:02 +0000 (16:34 -0400)
include/deal.II/python/point_wrapper.h [new file with mode: 0644]
source/python/CMakeLists.txt
source/python/export_point.cc
source/python/point_wrapper.cc [new file with mode: 0644]

diff --git a/include/deal.II/python/point_wrapper.h b/include/deal.II/python/point_wrapper.h
new file mode 100644 (file)
index 0000000..b3f081a
--- /dev/null
@@ -0,0 +1,39 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii__point_wrapper_h
+#define dealii__point_wrapper_h
+#include <boost/python.hpp>
+
+namespace PyDealII
+{
+  class PointWrapper
+  {
+  public:
+    PointWrapper(boost::python::list list);
+    double get_x();
+    void set_x(double x);
+    double get_y();
+    void set_y(double y);
+    double get_z();
+    void set_z(double z);
+
+  private:
+    int dim;
+    std::shared_ptr<void> point;
+  };
+}
+
+#endif
index 886dce057e7a3d77df08c6fbf4bfa938dda27409..7607ad8beca1ab854d773cbe7c80f7ac604d71ac 100644 (file)
@@ -23,6 +23,7 @@ SET(_src
   wrappers.cc
   export_point.cc
   export_triangulation.cc
+  point_wrapper.cc
   )
 
 FILE(GLOB _header
index 95b42740b3f3748028fd45025034b32655e293ee..b2f9d42cde25222a08b1bf7a020584105850307b 100644 (file)
 // ---------------------------------------------------------------------
 
 #include <boost/python.hpp>
+#include <deal.II/python/point_wrapper.h>
 #include <deal.II/base/point.h>
 #include <deal.II/base/exceptions.h>
 
 namespace PyDealII
 {
-  class PointWrapper
-  {
-  public:
-    PointWrapper(boost::python::list list);
-    double get_x();
-    void set_x(double x);
-    double get_y();
-    void set_y(double y);
-    double get_z();
-    void set_z(double z);
-
-  private:
-    int dim;
-    std::shared_ptr<void> point;
-  };
-
-
-
-  PointWrapper::PointWrapper(boost::python::list coord)
-  {
-    dim = boost::python::len(coord);
-    if (dim == 2)
-      point.reset(new dealii::Point<2> (boost::python::extract<double>(coord[0]),
-                                        boost::python::extract<double>(coord[1])));
-    else if (dim == 3)
-      point.reset(new dealii::Point<3> (boost::python::extract<double>(coord[0]),
-                                        boost::python::extract<double>(coord[1]),
-                                        boost::python::extract<double>(coord[2])));
-    else
-      AssertThrow(false,
-                  dealii::ExcMessage("The list of coordinates must contain two or three elements."));
-  }
-
-
-
-  double PointWrapper::get_x()
-  {
-    if (dim == 2)
-      return (*std::static_pointer_cast<dealii::Point<2>>(point))(0);
-    else
-      return (*std::static_pointer_cast<dealii::Point<3>>(point))(0);
-  }
-
-
-
-  void PointWrapper::set_x(double x)
-  {
-    if (dim == 2)
-      (*std::static_pointer_cast<dealii::Point<2>>(point))(0) = x;
-    else
-      (*std::static_pointer_cast<dealii::Point<3>>(point))(0) = x;
-  }
-
-
-
-  double PointWrapper::get_y()
-  {
-    if (dim == 2)
-      return (*std::static_pointer_cast<dealii::Point<2>>(point))(1);
-    else
-      return (*std::static_pointer_cast<dealii::Point<3>>(point))(1);
-  }
-
-
-
-  void PointWrapper::set_y(double y)
-  {
-    if (dim == 2)
-      (*std::static_pointer_cast<dealii::Point<2>>(point))(1) = y;
-    else
-      (*std::static_pointer_cast<dealii::Point<3>>(point))(1) = y;
-  }
-
-
-
-  double PointWrapper::get_z()
-  {
-    if (dim == 3)
-      return (*std::static_pointer_cast<dealii::Point<3>>(point))(2);
-    else
-      AssertThrow(false,
-                  dealii::ExcMessage("The z coordinate is only available for three-dimensional points"));
-  }
-
-
-
-  void PointWrapper::set_z(double z)
-  {
-    if (dim == 3)
-      (*std::static_pointer_cast<dealii::Point<3>>(point))(2) = z;
-    else
-      AssertThrow(false,
-                  dealii::ExcMessage("The z coordinate is only available for three-dimensional points"));
-  }
-
-
-
   void export_point()
   {
     boost::python::class_<PointWrapper> ("Point",boost::python::init<boost::python::list>())
@@ -123,5 +27,4 @@ namespace PyDealII
     .add_property("y", &PointWrapper::get_y, &PointWrapper::set_y, "Get the y component of the point.")
     .add_property("z", &PointWrapper::get_z, &PointWrapper::set_z, "Get the z component of the point.");
   }
-
 }
diff --git a/source/python/point_wrapper.cc b/source/python/point_wrapper.cc
new file mode 100644 (file)
index 0000000..07529ac
--- /dev/null
@@ -0,0 +1,97 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/python/point_wrapper.h>
+#include <deal.II/base/point.h>
+
+namespace PyDealII
+{
+  PointWrapper::PointWrapper(boost::python::list coord)
+  {
+    dim = boost::python::len(coord);
+    if (dim == 2)
+      point.reset(new dealii::Point<2> (boost::python::extract<double>(coord[0]),
+                                        boost::python::extract<double>(coord[1])));
+    else if (dim == 3)
+      point.reset(new dealii::Point<3> (boost::python::extract<double>(coord[0]),
+                                        boost::python::extract<double>(coord[1]),
+                                        boost::python::extract<double>(coord[2])));
+    else
+      AssertThrow(false,
+                  dealii::ExcMessage("The list of coordinates must contain two or three elements."));
+  }
+
+
+
+  double PointWrapper::get_x()
+  {
+    if (dim == 2)
+      return (*std::static_pointer_cast<dealii::Point<2>>(point))(0);
+    else
+      return (*std::static_pointer_cast<dealii::Point<3>>(point))(0);
+  }
+
+
+
+  void PointWrapper::set_x(double x)
+  {
+    if (dim == 2)
+      (*std::static_pointer_cast<dealii::Point<2>>(point))(0) = x;
+    else
+      (*std::static_pointer_cast<dealii::Point<3>>(point))(0) = x;
+  }
+
+
+
+  double PointWrapper::get_y()
+  {
+    if (dim == 2)
+      return (*std::static_pointer_cast<dealii::Point<2>>(point))(1);
+    else
+      return (*std::static_pointer_cast<dealii::Point<3>>(point))(1);
+  }
+
+
+
+  void PointWrapper::set_y(double y)
+  {
+    if (dim == 2)
+      (*std::static_pointer_cast<dealii::Point<2>>(point))(1) = y;
+    else
+      (*std::static_pointer_cast<dealii::Point<3>>(point))(1) = y;
+  }
+
+
+
+  double PointWrapper::get_z()
+  {
+    if (dim == 3)
+      return (*std::static_pointer_cast<dealii::Point<3>>(point))(2);
+    else
+      AssertThrow(false,
+                  dealii::ExcMessage("The z coordinate is only available for three-dimensional points"));
+  }
+
+
+
+  void PointWrapper::set_z(double z)
+  {
+    if (dim == 3)
+      (*std::static_pointer_cast<dealii::Point<3>>(point))(2) = z;
+    else
+      AssertThrow(false,
+                  dealii::ExcMessage("The z coordinate is only available for three-dimensional points"));
+  }
+}

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.