[cig-commits] r13480 - in short/3D/PyLith/trunk/playpen: . swigtest swigtest/applications swigtest/libsrc swigtest/modulesrc swigtest/python
brad at geodynamics.org
brad at geodynamics.org
Tue Dec 9 14:03:54 PST 2008
Author: brad
Date: 2008-12-09 14:03:31 -0800 (Tue, 09 Dec 2008)
New Revision: 13480
Added:
short/3D/PyLith/trunk/playpen/swigtest/
short/3D/PyLith/trunk/playpen/swigtest/Makefile.am
short/3D/PyLith/trunk/playpen/swigtest/applications/
short/3D/PyLith/trunk/playpen/swigtest/applications/Makefile.am
short/3D/PyLith/trunk/playpen/swigtest/applications/testapp.cfg
short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.cc
short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.py
short/3D/PyLith/trunk/playpen/swigtest/configure.ac
short/3D/PyLith/trunk/playpen/swigtest/libsrc/
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.cc
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.hh
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Makefile.am
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.cc
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.hh
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.cc
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.hh
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.cc
short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.hh
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Bar.i
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Makefile.am
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Scene.i
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Shape.i
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Sphere.i
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/geometry.i
short/3D/PyLith/trunk/playpen/swigtest/modulesrc/setup.py.orig
short/3D/PyLith/trunk/playpen/swigtest/python/
short/3D/PyLith/trunk/playpen/swigtest/python/Bar.py
short/3D/PyLith/trunk/playpen/swigtest/python/Makefile.am
short/3D/PyLith/trunk/playpen/swigtest/python/Scene.py
short/3D/PyLith/trunk/playpen/swigtest/python/Shape.py
short/3D/PyLith/trunk/playpen/swigtest/python/Sphere.py
short/3D/PyLith/trunk/playpen/swigtest/python/__init__.py
Log:
Added swigtest.
Property changes on: short/3D/PyLith/trunk/playpen/swigtest
___________________________________________________________________
Name: svn:externals
+ m4 http://geodynamics.org/svn/cig/cs/autoconf/trunk
Added: short/3D/PyLith/trunk/playpen/swigtest/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/Makefile.am (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/Makefile.am 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,22 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+ACLOCAL_AMFLAGS = -I ./m4
+
+SUBDIRS = \
+ libsrc \
+ modulesrc \
+ python \
+ applications
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/applications/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/applications/Makefile.am (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/applications/Makefile.am 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,27 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+bin_PROGRAMS = testswig
+
+bin_SCRIPTS = testswig.py
+
+INCLUDES = -I$(top_srcdir)/libsrc
+
+testswig_SOURCES = \
+ testswig.cc
+testswig_LDADD = \
+ $(top_builddir)/libsrc/libswigtest.la
+
+CLEANFILES = $(bin_SCRIPTS)
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/applications/testapp.cfg
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/applications/testapp.cfg (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/applications/testapp.cfg 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,10 @@
+[testapp.scene.bar]
+length = 5.0
+width = 1.5
+color = red
+id = 1
+
+[testapp.scene.sphere]
+radius = 3.0
+color = blue
+id = 2
\ No newline at end of file
Added: short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.cc (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.cc 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+
+#include "Bar.hh"
+#include "Sphere.hh"
+#include "Scene.hh"
+
+int
+main(int argc,
+ char** argv)
+{
+ geometry::Bar bar;
+ bar.length(4.0);
+ bar.width(2.0);
+ bar.color("yellow");
+ bar.id(0);
+
+ geometry::Sphere sphere;
+ sphere.radius(3.0);
+ sphere.color("green");
+ sphere.id(1);
+
+ geometry::Scene scene;
+ scene.bar(&bar);
+ scene.sphere(&sphere);
+ scene.view();
+
+ return 0;
+}
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.py
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.py (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/applications/testswig.py 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+from pyre.applications.Script import Script as Application
+
+# TestApp class
+class TestApp(Application):
+ """
+ Python TestApp application.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Application.Inventory):
+ """
+ Python object for managing PyLithApp facilities and properties.
+ """
+
+ import pyre.inventory
+
+ from swigtest.Scene import Scene
+ scene = pyre.inventory.facility("scene", family="scene", factory=Scene)
+ scene.meta['tip'] = "Scene."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="testapp"):
+ """
+ Constructor.
+ """
+ Application.__init__(self, name)
+ return
+
+
+ def main(self, *args, **kwds):
+ """
+ Run the application.
+ """
+ import swigtest.geometry as geometry
+
+ bar = geometry.Bar()
+ bar.length(4.0)
+ bar.width(2.0)
+ bar.color("yellow")
+ bar.id(0)
+
+ sphere = geometry.Sphere()
+ sphere.radius(3.0);
+ sphere.color("green");
+ sphere.id(1);
+
+ scene = geometry.Scene()
+ scene.bar(bar);
+ scene.sphere(sphere);
+ scene.view();
+
+ self.scene.view()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Application._configure(self)
+ self.scene = self.inventory.scene
+ return
+
+# ======================================================================
+if __name__ == '__main__':
+ app = TestApp()
+ app.run()
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/configure.ac
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/configure.ac (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/configure.ac 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,55 @@
+# -*- autoconf -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+AC_PREREQ(2.59)
+AC_INIT([swigtest], [0.1.0], [baagaard at usgs.gov])
+AC_CONFIG_HEADER([portinfo])
+AC_CONFIG_AUX_DIR([./aux-config])
+AM_INIT_AUTOMAKE([foreign])
+
+# ----------------------------------------------------------------------
+AC_PROG_CXX
+AC_PROG_CC
+
+AC_PROG_LIBTOOL
+if test "$allow_undefined_flag" = unsupported; then
+ # See issue119.
+ AM_LDFLAGS="-no-undefined $AM_LDFLAGS"
+fi
+AM_CONDITIONAL([NO_UNDEFINED], [test "$allow_undefined_flag" = unsupported])
+AC_SUBST(AM_LDFLAGS)
+
+# ----------------------------------------------------------------------
+# PYTHIA
+AC_LANG(C++)
+
+# Check for Python modules and packages.
+AC_ARG_VAR(PYTHON, [Python interpreter])
+AC_ARG_VAR(PYTHONPATH, [Python module search path])
+CIT_PYTHON_SYSCONFIG
+AM_PATH_PYTHON([2.3])
+
+
+# SWIG
+AC_PROG_SWIG
+
+# ----------------------------------------------------------------------
+AC_CONFIG_FILES([Makefile
+ libsrc/Makefile
+ modulesrc/Makefile
+ python/Makefile
+ applications/Makefile])
+
+AC_OUTPUT
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.cc (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.cc 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+
+#include "Bar.hh"
+
+#include <iostream>
+#include <stdexcept>
+
+geometry::Bar::Bar(void) :
+ _length(0),
+ _width(0)
+{}
+geometry::Bar::~Bar(void)
+{}
+
+void
+geometry::Bar::length(const double value) {
+ if (value <= 0)
+ throw std::runtime_error("Length must be positive.");
+ _length = value;
+}
+double
+geometry::Bar::length(void) const {
+ return _length;
+}
+
+void
+geometry::Bar::width(const double value) {
+ if (value <= 0)
+ throw std::runtime_error("Width must be positive.");
+ _width = value;
+}
+double
+geometry::Bar::width(void) const {
+ return _width;
+}
+
+void
+geometry::Bar::view(void) const {
+ std::cout << "Bar:\n"
+ << " length: " << _length << "\n"
+ << " width: " << _width << "\n"
+ << " color: " << _color << "\n"
+ << " id: " << _id << "\n"
+ << std::endl;
+}
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.hh (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Bar.hh 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(bar_hh)
+#define bar_hh
+
+#include "Shape.hh"
+
+namespace geometry {
+ class Bar;
+} // geometry
+
+class geometry::Bar : public Shape
+{ // Bar
+public :
+
+ Bar(void);
+ ~Bar(void);
+
+ void length(const double value);
+ double length(void) const;
+
+ void width(const double value);
+ double width(void) const;
+
+ void view(void) const;
+
+private :
+
+ double _length;
+ double _width;
+
+}; // Bar
+
+#endif // bar_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Makefile.am (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Makefile.am 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,28 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+lib_LTLIBRARIES = libswigtest.la
+
+libswigtest_la_SOURCES = \
+ Bar.cc \
+ Shape.cc \
+ Sphere.cc \
+ Scene.cc
+
+libswigtest_la_LDFLAGS = $(AM_LDFLAGS)
+
+INCLUDES =
+
+libswigtest_la_LIBADD =
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.cc (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.cc 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+
+#include "Scene.hh"
+
+#include "Bar.hh"
+#include "Sphere.hh"
+
+#include <iostream>
+
+geometry::Scene::Scene(void) :
+ _bar(0),
+ _sphere(0)
+{}
+geometry::Scene::~Scene(void)
+{}
+
+void
+geometry::Scene::bar(Bar* const value) {
+ _bar = value;
+}
+const geometry::Bar*
+geometry::Scene::bar(void) const {
+ return _bar;
+}
+
+void
+geometry::Scene::sphere(Sphere* const value) {
+ _sphere = value;
+}
+const geometry::Sphere*
+geometry::Scene::sphere(void) const {
+ return _sphere;
+}
+
+void
+geometry::Scene::view(void) const {
+ std::cout << "Scene:\n";
+ if (0 != _bar)
+ _bar->view();
+ else
+ std::cout << " Bar: None\n";
+ if (0 != _sphere)
+ _sphere->view();
+ else
+ std::cout << " Sphere: None\n";
+}
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.hh (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Scene.hh 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(scene_hh)
+#define scene_hh
+
+namespace geometry {
+ class Scene;
+
+ class Bar;
+ class Sphere;
+} // geometry
+
+class geometry::Scene
+{ // Scene
+public :
+
+ Scene(void);
+ ~Scene(void);
+
+ void bar(Bar* const value);
+ const Bar* bar(void) const;
+
+ void sphere(Sphere* const value);
+ const Sphere* sphere(void) const;
+
+ void view(void) const;
+
+private :
+
+ Bar* _bar;
+ Sphere* _sphere;
+
+}; // Scene
+
+#endif // scene_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.cc (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.cc 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+
+#include "Shape.hh"
+
+#include <stdexcept>
+
+geometry::Shape::Shape(void) :
+ _id(0)
+{}
+geometry::Shape::~Shape(void)
+{}
+
+void
+geometry::Shape::color(const char* value) {
+ _color = value;
+}
+const char*
+geometry::Shape::color(void) const {
+ return _color.c_str();
+}
+
+void
+geometry::Shape::id(const int value) {
+ _id = value;
+}
+int
+geometry::Shape::id(void) const {
+ return _id;
+}
+
+void
+geometry::Shape::view(void) const {
+ throw std::runtime_error("Not implemented.");
+}
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.hh (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Shape.hh 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(shape_hh)
+#define shape_hh
+
+#include <string>
+
+namespace geometry {
+ class Shape;
+} // geometry
+
+class geometry::Shape
+{ // Shape
+public :
+
+ Shape(void);
+ virtual ~Shape(void);
+
+ void color(const char* value);
+ const char* color(void) const;
+
+ void id(const int value);
+ int id(void) const;
+
+ virtual void view(void) const;
+
+protected :
+
+ std::string _color;
+ int _id;
+
+}; // Shape
+
+#endif // shape_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.cc (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.cc 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+
+#include "Sphere.hh"
+
+#include <iostream>
+#include <stdexcept>
+
+geometry::Sphere::Sphere(void) :
+ _radius(0)
+{}
+geometry::Sphere::~Sphere(void)
+{}
+
+void
+geometry::Sphere::radius(const double value) {
+ if (value <= 0)
+ throw std::runtime_error("Radius must be positive.");
+ _radius = value;
+}
+double
+geometry::Sphere::radius(void) const {
+ return _radius;
+}
+
+void
+geometry::Sphere::view(void) const {
+ std::cout << "Sphere:\n"
+ << " radius: " << _radius << "\n"
+ << " color: " << _color << "\n"
+ << " id: " << _id << "\n"
+ << std::endl;
+}
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.hh
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.hh (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/libsrc/Sphere.hh 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(sphere_hh)
+#define sphere_hh
+
+#include "Shape.hh"
+
+namespace geometry {
+ class Sphere;
+} // geometry
+
+class geometry::Sphere : public Shape
+{ // Sphere
+public :
+
+ Sphere(void);
+ ~Sphere(void);
+
+ void radius(const double value);
+ double radius(void) const;
+
+ void view(void) const;
+
+private :
+
+ double _radius;
+
+}; // Sphere
+
+#endif // sphere_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Bar.i
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Bar.i (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Bar.i 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+namespace geometry {
+
+class Bar : public Shape
+{ // Bar
+public :
+
+ Bar(void);
+ ~Bar(void);
+
+ void length(const double value);
+ double length(void) const;
+
+ void width(const double value);
+ double width(void) const;
+
+ void view(void) const;
+
+}; // Bar
+
+
+} // namespace geometry
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Makefile.am (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Makefile.am 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,48 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+pkgpyexec_LTLIBRARIES = _geometrymodule.la
+
+_geometrymodule_la_LDFLAGS = -module -avoid-version \
+ $(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
+
+swig_sources = \
+ geometry.i \
+ Bar.i \
+ Shape.i \
+ Sphere.i \
+ Scene.i
+
+dist__geometrymodule_la_SOURCES = $(swig_sources)
+
+pkgpyexec_PYTHON = geometry.py
+
+_geometrymodule_la_SOURCES = \
+ geometry_wrap.cxx
+
+_geometrymodule_la_LIBADD = \
+ $(top_builddir)/libsrc/libswigtest.la
+if NO_UNDEFINED
+_geometrymodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+endif
+
+INCLUDES = -I$(top_srcdir)/libsrc -I$(PYTHON_INCDIR)
+
+$(srcdir)/geometry_wrap.cxx $(srcdir)/geometry.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $<
+
+
+CLEANFILES = $(srcdir)/geometry_wrap.cxx $(srcdir)/geometry.py
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Scene.i
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Scene.i (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Scene.i 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+namespace geometry {
+
+class Bar;
+class Sphere;
+
+class Scene
+{ // Scene
+public :
+
+ Scene(void);
+ ~Scene(void);
+
+ void bar(geometry::Bar* const value);
+ const geometry::Bar* bar(void) const;
+
+ void sphere(geometry::Sphere* const value);
+ const geometry::Sphere* sphere(void) const;
+
+ void view(void) const;
+
+}; // Scene
+
+} // namespace geometry
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Shape.i
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Shape.i (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Shape.i 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+namespace geometry {
+
+class Shape
+{ // Shape
+public :
+
+ Shape(void);
+ virtual ~Shape(void);
+
+ void color(const char* value);
+ const char* color(void) const;
+
+ void id(const int value);
+ int id(void) const;
+
+ virtual void view(void) const = 0;
+
+}; // Shape
+
+} // namespace geometry
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Sphere.i
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Sphere.i (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/modulesrc/Sphere.i 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,32 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+namespace geometry {
+
+class Sphere : public Shape
+{ // Sphere
+public :
+
+ Sphere(void);
+ ~Sphere(void);
+
+ void radius(const double value);
+ double radius(void) const;
+
+ void view(void) const;
+
+}; // Sphere
+
+} // namespace geometry
+
+
+// End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/modulesrc/geometry.i
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/modulesrc/geometry.i (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/modulesrc/geometry.i 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,24 @@
+// SWIG interface
+%module(directors="1") geometry
+%feature("director");
+
+// Header files for module C++ code
+%{
+#include "Bar.hh"
+#include "Sphere.hh"
+#include "Scene.hh"
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ }
+}
+
+%include "Shape.i"
+%include "Bar.i"
+%include "Sphere.i"
+%include "Scene.i"
Added: short/3D/PyLith/trunk/playpen/swigtest/modulesrc/setup.py.orig
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/modulesrc/setup.py.orig (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/modulesrc/setup.py.orig 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+"""
+setup.py file for SWIG example
+"""
+
+from distutils.core import setup, Extension
+
+
+foo_module = Extension('_foo',
+ sources=['foo_wrap.cxx'],
+ include_dirs=['../libsrc'],
+ library_dirs=['../libsrc'],
+ libraries=['foo'],
+ )
+
+setup (name='foo',
+ version='0.1',
+ author="SWIG Docs",
+ description = """Simple swig example from docs""",
+ ext_modules = [foo_module],
+ py_modules = ["foo"],
+ )
Added: short/3D/PyLith/trunk/playpen/swigtest/python/Bar.py
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/python/Bar.py (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/python/Bar.py 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+from Shape import Shape
+from geometry import Bar as ModuleBar
+
+# Bar class
+class Bar(Shape, ModuleBar):
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Shape.Inventory):
+ """Python object for managing Bar facilities and properties."""
+
+ import pyre.inventory
+
+ length = pyre.inventory.float("length", default=1.0)
+ length.meta['tip'] = "Length of bar."
+
+ width = pyre.inventory.float("width", default=1.0)
+ width.meta['tip'] = "Width of bar."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="bar"):
+ """
+ Constructor.
+ """
+ Shape.__init__(self, name)
+ ModuleBar.__init__(self)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Shape._configure(self)
+
+ self.length(self.inventory.length)
+ self.width(self.inventory.width)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def shape():
+ return Bar()
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/python/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/python/Makefile.am (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/python/Makefile.am 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,21 @@
+# -*- Makefile -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+pkgpyexec_PYTHON = \
+ __init__.py \
+ Shape.py \
+ Bar.py \
+ Sphere.py \
+ Scene.py
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/python/Scene.py
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/python/Scene.py (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/python/Scene.py 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+from pyre.components.Component import Component
+from geometry import Scene as ModuleScene
+
+# Scene class
+class Scene(Component, ModuleScene):
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """Python object for managing Scene facilities and properties."""
+
+ import pyre.inventory
+
+ from Bar import Bar
+ bar = pyre.inventory.facility("bar", family="shape", factory=Bar)
+ bar.meta['tip'] = "Bar in scene."
+
+ from Sphere import Sphere
+ sphere = pyre.inventory.facility("sphere", family="shape", factory=Sphere)
+ sphere.meta['tip'] = "Sphere in scene."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="scene"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name)
+ ModuleScene.__init__(self)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Component._configure(self)
+
+ self.bar(self.inventory.bar)
+ self.sphere(self.inventory.sphere)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def scene():
+ return Scene()
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/python/Shape.py
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/python/Shape.py (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/python/Shape.py 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+from pyre.components.Component import Component
+
+# Shape class
+class Shape(Component):
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """Python object for managing Shape facilities and properties."""
+
+ import pyre.inventory
+
+ color = pyre.inventory.str("color", default="black")
+ color.meta['tip'] = "Color of object."
+
+ id = pyre.inventory.int("id", default=1)
+ id.meta['tip'] = "Id number for bar."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="shape"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name, facility="shape")
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Component._configure(self)
+
+ self.color(self.inventory.color)
+ self.id(self.inventory.id)
+ return
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/python/Sphere.py
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/python/Sphere.py (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/python/Sphere.py 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+from Shape import Shape
+from geometry import Sphere as ModuleSphere
+
+# Sphere class
+class Sphere(Shape, ModuleSphere):
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Shape.Inventory):
+ """Python object for managing Sphere facilities and properties."""
+
+ import pyre.inventory
+
+ radius = pyre.inventory.float("radius", default=1.0)
+ radius.meta['tip'] = "Radius of sphere."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="sphere"):
+ """
+ Constructor.
+ """
+ Shape.__init__(self, name)
+ ModuleSphere.__init__(self)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ Shape._configure(self)
+
+ self.radius(self.inventory.radius)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def shape():
+ return Sphere()
+
+
+# End of file
Added: short/3D/PyLith/trunk/playpen/swigtest/python/__init__.py
===================================================================
--- short/3D/PyLith/trunk/playpen/swigtest/python/__init__.py (rev 0)
+++ short/3D/PyLith/trunk/playpen/swigtest/python/__init__.py 2008-12-09 22:03:31 UTC (rev 13480)
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+__all__ = ['Bar',
+ 'Shape',
+ 'Scene',
+ 'Sphere',
+ ]
+
+
+# End of file
More information about the CIG-COMMITS
mailing list