File: InsertGenerator3DPy.cc

package info (click to toggle)
python-demgengeo 0.99~bzr106-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,552 kB
  • sloc: cpp: 12,251; python: 1,251; makefile: 261; sh: 26
file content (138 lines) | stat: -rw-r--r-- 5,847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2007-2011 by The University of Queensland //
// Earth Systems Science Computational Centre (ESSCC)      //
// http://www.uq.edu.au/esscc                              //
//                                                         //
// Primary Business: Brisbane, Queensland, Australia       //
// Licensed under the Open Software License version 3.0    //
// http://www.opensource.org/licenses/osl-3.0.php          //
//                                                         //
/////////////////////////////////////////////////////////////

#include <boost/version.hpp>
#include <iostream>
#include <sstream>
#include "InsertGenerator3DPy.h"

using namespace boost::python;

    using boost::python::arg;
    void exportAGenerator3D()
    {
      // Check that Boost 1.34.0 or higher is being used.
      // If so, disable auto-generation of C++ signatures for Epydoc
      // (which stumbles over indentation in the auto-generated strings).
      #if ((BOOST_VERSION / 100000 >= 1) \
          && (BOOST_VERSION / 100 % 1000 >= 34)) \
          || (BOOST_VERSION / 100000 >= 2)
        boost::python::docstring_options no_autogen(true,false);
      #endif

      class_<AGenerator3D, boost::noncopyable>("AGenerator3D", "Abstract base class for 3D InsertGenerators", no_init);
    }

    void exportInsertGenerator3D()
    {
      // Check that Boost 1.34.0 or higher is being used.
      // If so, disable auto-generation of C++ signatures for Epydoc
      // (which stumbles over indentation in the auto-generated strings).
      #if ((BOOST_VERSION / 100000 >= 1) \
          && (BOOST_VERSION / 100 % 1000 >= 34)) \
          || (BOOST_VERSION / 100000 >= 2)
        boost::python::docstring_options no_autogen(true,false);
      #endif

      class_<InsertGenerator3D, bases<AGenerator3D> >(
        "InsertGenerator3D",
        "A particle packing algorithm for filling L{AVolume3D} spaces.",
        init<>()
      )
      .def(init<const InsertGenerator3D &>())
      .def(
        init<double,double,int,int,double>(
          ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance") ),
          "Initialises a particle packer in preparation for filling an\n"
          "L{AVolume3D} with particles whose radii are in the specified range.\n"
          "The packing will terminate after the specified number of \n"
          "insertion failures. The iterative solver will compute only the\n"
          "specified maximum number of iterations. Particles are permitted \n"
          "to overlap by the specified tolerance.\n" 
          "@type minRadius: double\n"
          "@kwarg minRadius: the minimum radius of particles to pack\n"
          "@type maxRadius: double\n"
          "@kwarg maxRadius: the maximum radius of particles to pack\n"
          "@type insertFails: int\n"
          "@kwarg insertFails: the number of particle insertion failures before the packer terminates\n"
          "@type maxIterations: int\n"
          "@kwarg maxIterations: the maximum number of iterations of the solver\n"
          "@type tolerance: double\n"
          "@kwarg tolerance: the overlap tolerance permitted\n"
          "@rtype: void\n"
        )
      )
      .def(
	   init<double,double,int,int,double,bool>(
	   ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance"),arg("seed") ),
          "@type seed: bool\n"
          "@kwarg seed: randomize the random number generator if True (optional)\n"
        )
      )
      .def(
        "generatePacking",
        &InsertGenerator3D::generatePacking3,
        ( arg("volume"), arg("ntable"), arg("groupID")=0 ),
        "Generates a particle assembly to fill the specified volume.\n"
        "@type volume: L{AVolume3D}\n"
        "@kwarg volume: the 3D volume to fill with particles\n"
        "@type ntable: L{MNTable3D}\n"
        "@kwarg ntable: the neighbours table particles are inserted into\n"
        "@type groupID: int\n"
        "@kwarg groupID: the group ID assigned to particles (default: 0)\n"
        "@rtype: void\n" 
      )
      .def(
        "generatePacking",
        &InsertGenerator3D::generatePacking4,
        ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag") ),
        "@type tag: int\n"
        "@kwarg tag: the tag assigned to the generated particles\n"
        " (optional if not followed by C{ShapeList})\n"
      )
      .def(
        "generatePackingMaxVolume",
        &InsertGenerator3D::generatePackingMaxVolume,
        ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag"), arg("maxVolume") ),
	"Fill the specified L{AVolume3D} with particles until the accumulated particle volume exceeds the specified C{maxVolume}.\n"
        "@type maxVolume: float\n"
        "@kwarg maxVolume: the maximum cumulative volume of the inserted particles\n"
      )
      .def(
        "generatePacking",
        &InsertGenerator3D::generatePacking,
          ( arg("volume"), arg("ntable"), arg("groupID")=0 , arg("tag"), arg("shapeList") ),
          "@type shapeList: L{ShapeList}\n"  
          "@kwarg shapeList: the list of shapes to be inserted (optional)\n"
      )
      .def(
	   "setNextTag",
           &InsertGenerator3D::setNextTag,
	   ( arg("tag") ),
	   "Sets tag for the next particles generated\n"
	   "@type tag: int\n"
	   "@kwarg tag: tag to assign the next particles generated by the L{InsertGenerator3D}\n"
       )
      .def(
	"setOldSeeding",
	&InsertGenerator3D::setOldSeeding,
	( arg("old")),
	"Sets seeding behavior to older method.\n"
        "@type old: bool\n"  
        "@kwarg old: toggle between old and new seeding methods.\n"
      )
      .def(self_ns::str(self))
      ;
    }