1 // -*- C++ -*-
2 //
3 // NeighborLocatorInterface.h: Fake "python" interface to OpenKIM versions
4 // of the neighbor locators.
5 //
6 // Copyright (C) 2012-2013 Jakob Schiotz and the Department of Physics,
7 // Technical University of Denmark.  Email: schiotz@fysik.dtu.dk
8 //
9 // This file is part of Asap version 3.
10 // Asap is released under the GNU Lesser Public License (LGPL) version 3.
11 // However, the parts of Asap distributed within the OpenKIM project
12 // (including this file) are also released under the Common Development
13 // and Distribution License (CDDL) version 1.0.
14 //
15 // This program is free software: you can redistribute it and/or
16 // modify it under the terms of the GNU Lesser General Public License
17 // version 3 as published by the Free Software Foundation.  Permission
18 // to use other versions of the GNU Lesser General Public License may
19 // granted by Jakob Schiotz or the head of department of the
20 // Department of Physics, Technical University of Denmark, as
21 // described in section 14 of the GNU General Public License.
22 //
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26 // GNU General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // and the GNU Lesser Public License along with this program.  If not,
30 // see <http://www.gnu.org/licenses/>.
31 
32 
33 
34 #include "KimAsapPython.h"
35 #include "NeighborCellLocator.h"
36 
37 namespace ASAPSPACE {
38 
PyAsap_NewNeighborCellLocator(KimAtoms * atoms,double rCut,double driftfactor)39 PyAsap_NeighborLocatorObject *PyAsap_NewNeighborCellLocator(KimAtoms *atoms,
40     double rCut, double driftfactor)
41 {
42   PyAsap_NeighborLocatorObject *self;
43 
44   self = (PyAsap_NeighborLocatorObject*) malloc(sizeof(PyAsap_NeighborLocatorObject));
45 
46   if (self == NULL)
47     throw AsapError("OOPS XXXX");
48 
49   self->weakrefs = NULL;
50   self->fulllist = false;
51   self->cobj = new NeighborCellLocator(atoms, rCut, driftfactor);
52   if (self->cobj == NULL)
53     {
54       CHECKREF(self);
55       Py_DECREF(self);
56       throw AsapError("Failed to create a new NeighborCellLocator object.");
57     }
58   return self;
59 }
60 
61 } // end namespace
62