Index: src/sas/sascalc/simulation/pointsmodelpy/Make.mm
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,47 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# <LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+PROJECT = pointsmodelpy
+
+# directory structure
+
+BUILD_DIRS = \
+    libpointsmodelpy \
+    pointsmodelpymodule \
+    pointsmodelpy \
+
+OTHER_DIRS = \
+    tests \
+    examples
+
+RECURSE_DIRS = $(BUILD_DIRS) $(OTHER_DIRS)
+
+#--------------------------------------------------------------------------
+#
+
+all:
+	BLD_ACTION="all" $(MM) recurse
+
+distclean::
+	BLD_ACTION="distclean" $(MM) recurse
+
+clean::
+	BLD_ACTION="clean" $(MM) recurse
+
+tidy::
+	BLD_ACTION="tidy" $(MM) recurse
+
+# version
+# $Id$
+
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/examples/Make.mm
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/examples/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/examples/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,32 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# <LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+PROJECT = pointsmodelpy
+PACKAGE = examples
+
+#--------------------------------------------------------------------------
+#
+
+all: clean
+
+release: clean
+	cvs release .
+
+update: clean
+	cvs update .
+
+
+# version
+# $Id$
+
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/Make.mm
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,69 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+include local.def
+
+PROJECT = pointsmodelpy
+PACKAGE = libpointsmodelpy
+
+PROJ_SAR = $(BLD_LIBDIR)/$(PACKAGE).$(EXT_SAR)
+PROJ_DLL = $(BLD_BINDIR)/$(PACKAGE).$(EXT_SO)
+PROJ_TMPDIR = $(BLD_TMPDIR)/$(PROJECT)/$(PACKAGE)
+PROJ_CLEAN += $(PROJ_SAR) $(PROJ_DLL)
+
+PROJ_SRCS = \
+	lores_model.cc	\
+	points_model.cc	\
+        pdb_model.cc  \
+        complex_model.cc
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# build the library
+
+all: $(PROJ_SAR) export
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ifeq (Win32, ${findstring Win32, $(PLATFORM_ID)})
+
+# build the shared object
+$(PROJ_SAR): product_dirs $(PROJ_OBJS)
+	$(CXX) $(LCXXFLAGS) -o $(PROJ_DLL) \
+	-Wl,--out-implib=$(PROJ_SAR) $(PROJ_OBJS)
+
+# export
+export:: export-headers export-libraries export-binaries
+
+else
+
+# build the shared object
+$(PROJ_SAR): product_dirs $(PROJ_OBJS)
+	$(CXX) $(LCXXFLAGS) -o $(PROJ_SAR) $(PROJ_OBJS) -L$(BLD_LIBDIR)
+
+# export
+export:: export-headers export-libraries
+
+endif
+
+EXPORT_HEADERS = \
+	lores_model.h	\
+	points_model.h	\
+        complex_model.h
+
+EXPORT_LIBS = $(PROJ_SAR)
+EXPORT_BINS = $(PROJ_DLL)
+
+
+# version
+# $Id$
+
+#
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/complex_model.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/complex_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/complex_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,97 @@
+/** \file complex_model.cc */
+
+#include "complex_model.h"
+#include <algorithm>
+#include <stdexcept>
+
+using namespace std;
+
+ComplexModel::ComplexModel(){
+
+}
+
+void ComplexModel::Add(PointsModel *pm)
+{
+  models_.push_back(pm);
+}
+
+double ComplexModel::GetDimBound()
+{
+  //Get the vector of centers of pointsmodel instances
+  //and a vector of individual boundary
+  vector<PointsModel *>::iterator itr;
+  vector<Point3D> veccenter;
+  vector<double> bounds;
+
+  for(itr = models_.begin(); itr != models_.end(); ++itr){
+    if ((*itr)->GetDimBound() != 0){
+      Point3D pp((*itr)->GetCenter()[0],(*itr)->GetCenter()[1],(*itr)->GetCenter()[2]);
+      veccenter.push_back(pp);
+      bounds.push_back((*itr)->GetDimBound());
+    }
+  }
+
+  //max bound
+  double maxbound = *max_element(bounds.begin(),bounds.end());
+
+  //max distance
+  vector<double> vecdist;
+  size_t num = veccenter.size();
+
+  if (num > 1){
+    for (size_t i = 0; i != num; ++i){
+      for (size_t j= 1; j != num; ++j){
+        double dist = veccenter[i].distanceToPoint(veccenter[j]);
+        vecdist.push_back(dist);
+      }
+    }
+  }
+  else{
+    vecdist.push_back(maxbound);
+  }
+
+  double maxcenterdist = *max_element(vecdist.begin(),vecdist.end());
+
+  double finalbound = maxbound + maxcenterdist;
+
+  return finalbound;
+}
+
+vector<double> ComplexModel::GetCenter()
+{
+  double sumx = 0, sumy = 0, sumz = 0;
+  size_t num = 0;
+
+  vector<PointsModel *>::iterator itr;
+  for(itr = models_.begin(); itr != models_.end(); ++itr){
+    sumx += (*itr)->GetCenter()[0];
+    sumy += (*itr)->GetCenter()[1];
+    sumz += (*itr)->GetCenter()[2];
+    ++num;
+  }
+
+  vector<double> v(3);
+  v[0] = sumx/num;
+  v[1] = sumy/num;
+  v[2] = sumz/num;
+  center_ = v;
+  return center_;
+}
+
+int ComplexModel::GetPoints(Point3DVector &vp)
+{
+  if (vp.size() != 0){
+    throw runtime_error("GetPoints(Point3DVector &VP):VP has to be empty"); 
+  }
+
+  vector<PointsModel *>::iterator itr;
+
+  for(itr = models_.begin(); itr != models_.end(); ++itr){
+    vector<Point3D> temp;
+    (*itr)->GetPoints(temp);    	
+    if (temp.size() != 0){
+      vp.insert(vp.end(),temp.begin(),temp.end());
+    }
+  }
+  return vp.size();
+}
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/complex_model.h
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/complex_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/complex_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,36 @@
+/** \file complex_model.h child class of PointsModel */
+
+#ifndef COMPLEX_MODEL_H
+#define COMPLEX_MODEL_H
+
+#include "points_model.h"
+#include <string>
+#include <map>
+
+/**
+ *  Class ComplexModel : container class for LORESModel & PDBModel
+ *  The main functionality is to merge points from instances of 
+ *  LORESModel & PDBModel
+ */
+
+class ComplexModel : public PointsModel {
+ public:
+  ComplexModel();
+  
+  //add PointsModel instance
+  void Add(PointsModel *);
+
+  //Parse all coordinates from ATOM section 
+  //of the PDB file into vector of points
+  int GetPoints(Point3DVector &);
+
+  //Get distance boundary for the pointsmodel instances
+  double GetDimBound();
+
+  vector<double> GetCenter();
+
+ private:
+  vector<PointsModel *> models_;
+};
+
+#endif
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/local.def
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/local.def	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/local.def	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,32 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# <LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+#
+# Local (project) definitions
+#
+
+# C++
+
+PROJ_CXX_INCLUDES += ../../iqPy/libiqPy   \
+                     ../../iqPy/libiqPy/tnt \
+		     ../../geoshapespy/libgeoshapespy   \
+		     ../../analmodelpy/libanalmodelpy   \
+		     ./ 
+
+    PROJ_CXX_FLAGS += $(CXX_SOFLAGS)
+    PROJ_LCXX_FLAGS += $(LCXX_SARFLAGS) -liqPy -lgeoshapespy
+
+# version
+# $Id$
+
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/lores_model.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/lores_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/lores_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,237 @@
+/** \file lores_model.cc */
+
+#include <algorithm>
+#include <stdexcept>
+#include "lores_model.h"
+#include "sphere.h"
+#include "hollow_sphere.h"
+#include "cylinder.h"
+#include "ellipsoid.h"
+#include "single_helix.h"
+#include "Point3D.h"
+
+LORESModel::LORESModel(double density)
+{
+  density_ = density;
+}
+
+GeoShape* LORESModel::GetGeoShape(GeoShape& geo_shape)
+{
+  GeoShape* shape = NULL;
+
+  switch (geo_shape.GetShapeType()){
+    case SPHERE:
+      shape = new Sphere(static_cast<const Sphere&>(geo_shape));
+      break;
+    case HOLLOWSPHERE:
+      shape = new HollowSphere(static_cast<const HollowSphere&>(geo_shape));
+      break;
+    case CYLINDER:
+      shape = new Cylinder(static_cast<const Cylinder&>(geo_shape));
+      break;
+    case ELLIPSOID:
+      shape = new Ellipsoid(static_cast<const Ellipsoid&>(geo_shape));
+      break;
+    case SINGLEHELIX:
+      shape = new SingleHelix(static_cast<const SingleHelix&>(geo_shape));
+      break;
+  
+  }
+
+  return shape;
+}
+
+LORESModel::~LORESModel()
+{
+  for (RealSpaceShapeCollection::iterator it = shapes_.begin();
+       it != shapes_.end(); ++it) {
+    delete *it;
+  }
+}
+
+void LORESModel::SetDensity(double density)
+{
+  density_ = density;
+}
+
+double LORESModel::GetDensity()
+{
+  return density_;
+}
+
+// Add a shape into LORES Model
+void LORESModel::Add(GeoShape& geo_shape,
+                     double sld) {
+  GeoShape* shape = GetGeoShape(geo_shape);
+  assert(shape != NULL);
+
+  RealSpaceShape* real_shape = new RealSpaceShape(shape);
+  FillPoints(real_shape, sld);
+  shapes_.push_back(real_shape);
+}
+
+// Delete ith shape in shapes_ list
+// If we have 3 shapes in our model, the index starts
+// from 0, which means we need to call Delete(0) to delete
+// the first shape, and call Delete(1) to delete the second
+// shape, etc..
+void LORESModel::Delete(size_t i) {
+  if (i >= shapes_.size()) {
+    std::cerr << "Delete shapes out of scope" << std::endl;
+    return;
+  }
+
+  RealSpaceShape* real_shape = shapes_[i];
+  if (i + 1 < shapes_.size()) {
+    // if it is not the last shape, we have to distribute its points
+    // to the shapes after i-th shape.
+    const Point3DVector& points = real_shape->points;
+    for (Point3DVector::const_iterator pit = points.begin();
+         pit != points.end(); ++pit)
+      DistributePoint(*pit, i + 1);
+  }
+
+  shapes_.erase(shapes_.begin() + i);
+  delete real_shape;
+}
+
+// Get the points in the realspaceshapecollection
+int LORESModel::GetPoints(Point3DVector &pp)
+{
+  if (pp.size() != 0){
+    throw runtime_error("GetPoints(Point3DVector &VP):VP has to be empty"); 
+  }
+
+  if (shapes_.size() != 0){
+    for (size_t j = 0; j <shapes_.size(); ++j ){
+      pp.insert(pp.end(),shapes_[j]->points.begin(),shapes_[j]->points.end());
+    }
+  }
+  return pp.size();
+}
+
+//Write points to a file, mainly for testing right now
+void LORESModel::WritePoints2File(Point3DVector &vp){
+  ofstream outfile("test.coor");
+  for(size_t i=0; i<vp.size(); ++i){
+    outfile<<vp[i].getX()<<" "<<vp[i].getY()<<" "<<vp[i].getZ()<<" "<<vp[i].getSLD()<<endl;
+  }
+}
+
+double LORESModel::GetDimBound()
+{
+  if(shapes_.size() == 0)
+    return 0;
+
+  //find maximum distance between centers of shapes
+  //get the vector of centers
+  vector<Point3D> vec_center;
+  for (size_t m = 0; m < shapes_.size(); ++m){
+    assert(shapes_[m]->shape != NULL);
+    vector<double> center(3);
+    center = shapes_[m]->shape->GetCenter();
+    Point3D p_center;
+    p_center.set(center[0],center[1],center[2]);
+    vec_center.push_back(p_center);
+  }
+  size_t vecsize = vec_center.size();
+
+  //get the maximum distance among centers
+  double max_cen_dist;
+  if (vecsize == 1){
+    max_cen_dist = 0;
+  }
+  else{
+    vector<double> vecdist;
+    for (size_t m1=0; m1<vecsize -1; ++m1){
+      for (size_t m2 = m1+1; m2<vecsize; ++m2){
+	double dist = vec_center[m1].distanceToPoint(vec_center[m2]);
+	vecdist.push_back(dist);
+      }
+    }
+    max_cen_dist = *max_element(vecdist.begin(), vecdist.end());
+  }
+  //find the maximum radius for individual shape
+  vector<double> maxradii;
+  for (size_t n = 0; n < shapes_.size(); ++n){
+    assert(shapes_[n]->shape != NULL);
+    double maxradius = shapes_[n]->shape->GetMaxRadius();
+    maxradii.push_back(maxradius);
+  }
+  double max_maxradius = *max_element(maxradii.begin(),maxradii.end());
+  
+  return 2*(max_cen_dist/2 + max_maxradius);
+}
+
+
+// Distribute points of the shape we are going to delete
+void LORESModel::DistributePoint(const Point3D& point, size_t i)
+{
+  for (size_t k = i; k < shapes_.size(); ++k) {
+    assert(shapes_[k]->shape != NULL);
+    if (shapes_[k]->shape->IsInside(point)) {
+      shapes_[k]->points.push_back(point);
+      return;
+    }
+  }
+}
+
+void LORESModel::FillPoints(RealSpaceShape* real_shape, double sld)
+{
+  assert(real_shape != NULL);
+
+  GeoShape* shape = real_shape->shape;
+  assert(shape != NULL);
+
+  int npoints = static_cast<int>(density_ * shape->GetVolume());
+
+  for (int i = 0; i < npoints; ++i){
+    Point3D apoint = shape->GetAPoint(sld);
+    apoint.Transform(shape->GetOrientation(),shape->GetCenter());
+    if (!IsInside(apoint)){
+      real_shape->points.push_back(apoint);
+    }
+  }
+
+}
+
+bool LORESModel::IsInside(const Point3D& point)
+{
+  for (RealSpaceShapeCollection::const_iterator it = shapes_.begin();
+       it != shapes_.end(); ++it) {
+    const GeoShape* shape = (*it)->shape;
+    assert(shape != NULL);
+
+    if (shape->IsInside(point)) {
+       return true;
+    }
+  }
+
+  return false;
+}
+
+vector<double> LORESModel::GetCenter()
+{
+  //get the vector of centers from the list of shapes
+  size_t numshapes = 0;
+  double sumx = 0, sumy = 0, sumz = 0;
+  for (size_t m = 0; m < shapes_.size(); ++m){
+    assert(shapes_[m]->shape != NULL);
+    vector<double> center(3);
+    center = shapes_[m]->shape->GetCenter();
+
+    sumx += center[0];
+    sumy += center[1];
+    sumz += center[2];
+
+    ++numshapes;
+  }
+
+  vector<double> shapescenter(3);
+  shapescenter[0]= sumx/numshapes;
+  shapescenter[1]= sumy/numshapes;
+  shapescenter[2]= sumz/numshapes;
+
+  center_ = shapescenter;
+  return center_;
+}
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/lores_model.h
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/lores_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/lores_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,73 @@
+/** \file lores_model.h child class of PointsModel*/
+
+#ifndef LORESMODEL_H
+#define LORESMODEL_H
+
+#include <deque>
+#include "points_model.h"
+#include "geo_shape.h"
+//temporary
+#include <fstream>
+
+/**
+ *  Class LORESModel, low resolution models
+ */
+
+class LORESModel : public PointsModel {
+ private:
+  typedef vector<Point3D> PointsVector;
+
+  struct RealSpaceShape {
+    GeoShape* shape;
+    PointsVector points;
+
+    RealSpaceShape(GeoShape* s = NULL) : shape(s) {
+    }
+
+    ~RealSpaceShape() {
+      if (shape) delete shape;
+    }
+  };
+
+  typedef deque<RealSpaceShape*> RealSpaceShapeCollection;
+
+ public:
+  LORESModel(double density = 1.0);
+  ~LORESModel();
+
+  // Change density
+  void SetDensity(double density);
+  double GetDensity();
+
+  // Add new shape
+  void Add(GeoShape& geo_shape, double sld = 1);
+
+  // Delete ith shape at shapes_
+  void Delete(size_t i);
+
+  int GetPoints(Point3DVector &);
+  //Write points to a file, mainly for testing right now
+  void WritePoints2File(Point3DVector &);
+
+  //get the maximum possible dimension
+  double GetDimBound();
+
+  //will be used in determining the maximum distance for
+  //P(r) calculation for a complex model (merge several 
+  //pointsmodel instance together
+  vector<double> GetCenter();
+
+ protected:
+  GeoShape* GetGeoShape(GeoShape& geo_shape);
+  void FillPoints(RealSpaceShape* real_shape, double sld);
+  bool IsInside(const Point3D& point);
+  void DistributePoint(const Point3D& point, size_t i);
+
+ private:
+  RealSpaceShapeCollection shapes_;
+  int npoints_;
+  double density_;
+  
+};
+
+#endif
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/pdb_model.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/pdb_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/pdb_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,123 @@
+/** \file pdb_model.cc */
+
+#include "pdb_model.h"
+#include <fstream>
+#include <string>
+#include <cstdlib>
+#include <cmath>
+#include <stdexcept>
+
+using namespace std;
+
+typedef map<string,double>::const_iterator mymapitr;
+
+PDBModel::PDBModel(){
+  res_sld_["ALA"] = 1.645;  res_sld_["ARG"] = 3.466;
+  res_sld_["ASN"] = 3.456;  res_sld_["ASP"] = 3.845;
+  res_sld_["CYS"] = 1.930;  res_sld_["GLU"] = 3.762;
+  res_sld_["GLN"] = 3.373;  res_sld_["GLY"] = 1.728;
+  res_sld_["HIS"] = 4.959;  res_sld_["LLE"] = 1.396;
+  res_sld_["LEU"] = 1.396;  res_sld_["LYS"] = 1.586;
+  res_sld_["MET"] = 1.763;  res_sld_["PHE"] = 4.139;
+  res_sld_["PRO"] = 2.227;  res_sld_["SER"] = 2.225;
+  res_sld_["THR"] = 2.142;  res_sld_["TRP"] = 6.035;
+  res_sld_["TYR"] = 4.719;  res_sld_["VAL"] = 1.479;
+
+  x_max_ = -10000; x_min_ = 10000;
+  y_max_ = -10000; y_min_ = 10000;
+  z_max_ = -10000; z_min_ = 10000;
+}
+
+void PDBModel::AddPDB(const string &pdbfile)
+{
+  pdbnames_.push_back(pdbfile);
+}
+
+void PDBModel::AddPDB(const char* pdbfile)
+{
+  string sname(pdbfile);
+  pdbnames_.push_back(sname);
+}
+
+int PDBModel::GetPoints(Point3DVector &vp)
+{
+  if (vp.size() != 0){
+    throw runtime_error("PDBModel::GetPoints(Point3DVector &VP):VP has to be empty"); 
+  }
+  vector<string>::iterator itr;
+  for (itr = pdbnames_.begin(); itr!=pdbnames_.end(); ++itr){
+    ifstream infile(itr->c_str());
+    if (!infile){
+      cerr << "error: unable to open input file: " 
+	   << infile << endl;
+    }
+    string line;
+    while (getline(infile,line)){
+      size_t len = line.size();
+      string header;
+      
+      //for a line with size >=4, retrieve the header
+      //if the header == "ATOM""
+      //make sure the length of the line >=54, then
+      //retrieve the corresponding coordinates,convert str to double
+      //then assign them to a point3d,which will be append to vp with a SLD
+      if (len >= 4){
+	for (size_t i=0; i !=4; ++i) header += line[i];
+	if (header.compare("ATOM") == 0 && len >53){
+	  string strx,stry,strz;
+	  double x = 0, y = 0, z = 0;
+	  for (size_t j = 30; j!=38; ++j){
+	    strx += line[j];
+	    stry += line[j+8];
+	    strz += line[j+16];
+	  }
+	  x = atof(strx.c_str());
+	  y = atof(stry.c_str());
+	  z = atof(strz.c_str());
+	  
+	  //find residue type, and assign SLD
+	  string resname;
+	  for (size_t k = 17; k!=20; ++k) resname +=line[k];
+	  mymapitr itr = res_sld_.find("ALA");
+	  
+	  //apoint(x,y,z,sld)
+	  Point3D apoint(x,y,z,itr->second);
+	  vp.push_back(apoint);
+	  
+	  //save x y z' max & min to calculate the size boundary
+	  x_max_ = x > x_max_ ? x : x_max_;
+	  x_min_ = x < x_min_ ? x : x_min_;
+	  y_max_ = y > y_max_ ? y : y_max_;
+	  y_min_ = y < y_min_ ? y : y_min_;
+	  z_max_ = z > z_max_ ? z : z_max_;
+	  z_min_ = z < z_min_ ? z : z_min_;
+	}
+      }
+    }
+
+    infile.close();
+  }
+  return vp.size();
+}
+
+double PDBModel::GetDimBound()
+{
+  if (pdbnames_.size() == 0 )
+    return 0;
+
+  //cout <<x_max_<<" "<<x_min_<<" "<<y_max_<<" "<<y_min_<<" "<<z_max_<<" "<<z_min_<<endl;
+  double size = sqrt((x_max_-x_min_)*(x_max_-x_min_)+(y_max_-y_min_)*(y_max_-y_min_)+(z_max_-z_min_)*(z_max_-z_min_));
+  return size;
+}
+
+vector<double> PDBModel::GetCenter()
+{
+
+  vector<double> cen(3);
+  cen[0]= (x_max_+x_min_)/2;
+  cen[1]= (y_max_+y_min_)/2;
+  cen[2]= (z_max_+z_min_)/2;
+  center_ = cen;
+
+  return center_;
+}
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/pdb_model.h
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/pdb_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/pdb_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,43 @@
+/** \file pdb_model.h child class of PointsModel */
+
+#ifndef PDB_MODEL_H
+#define PDB_MODEL_H
+
+#include "points_model.h"
+#include <string>
+#include <map>
+
+/**
+ *  Class PDBModel, PDB models
+ */
+
+class PDBModel : public PointsModel {
+ public:
+  PDBModel();
+  
+  //add pdb file
+  void AddPDB(const string &);
+  void AddPDB(const char*);
+
+  //Parse all coordinates from ATOM section 
+  //of the PDB file into vector of points
+  int GetPoints(Point3DVector &);
+
+  //will be used in determining the maximum distance for
+  //P(r) calculation for a complex model (merge several 
+  //pointsmodel instance together
+  vector<double> GetCenter();
+
+  //get the maximum possible dimension= dist between XYZmax XYZmin
+  //May improve to directly get the dimension from unit cell
+  //if the technique is crystallography
+  double GetDimBound();
+
+ private:
+  vector<string> pdbnames_;
+  map<string,double> res_sld_;
+  double x_max_,x_min_,y_max_,y_min_,z_max_,z_min_;
+};
+
+#endif
+
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/points_model.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/points_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/points_model.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,461 @@
+/** \file points_model.cc */
+
+#include <vector>
+#include <algorithm>
+#include <fstream>
+#include <stdio.h>
+//#include <exception>
+#include <stdexcept>
+#include "points_model.h"
+#include "Point3D.h"
+
+PointsModel::PointsModel()
+{
+  r_grids_num_ = 2000;
+  rmax_ = 0;
+  cormax_ = 0;
+  rstep_ = 0;
+}
+
+void PointsModel::CalculateIQ(IQ *iq)
+{
+  //fourier transform of the returned Array2D<double> from ddFunction()
+  int nIpoints = iq->GetNumI();
+  double qstep = (iq->GetQmax()) / (nIpoints-1);
+  vector<double> fint(nIpoints, 0);
+
+  //I(0) is calculated seperately
+  int num_rstep = pr_.dim1();
+
+  for (int k = 1; k<nIpoints; k++){
+
+    double q = k * qstep;
+
+    double r =0;
+    double debeye = 0;
+    double fadd =0;
+
+
+    for (int i = 1; i < num_rstep; ++i){
+      r = i*rstep_;  //r should start from 1* rstep
+      double qr = q*r;
+      debeye = sin(qr)/qr;
+      fadd = pr_[i][1]*debeye;
+      fint[k] = fint[k] + fadd;
+    }
+  }
+
+  //I(0)
+  double Izero = 0;
+  for (int i = 0; i < num_rstep; ++i)
+    Izero += pr_[i][1];
+  fint[0] = Izero;
+
+  //assign I(Q) with normalization
+  for(int j = 0; j < nIpoints; ++j){
+    (*iq).iq_data[j][0] = j * qstep;
+    (*iq).iq_data[j][1] = fint[j];
+    // remove normalization Izero;
+  }
+}
+
+//return I with a single q value
+double PointsModel::CalculateIQ(double q)
+{
+  //fourier transform of the returned Array2D<double> from ddFunction()
+  int num_rstep = pr_.dim1();
+
+  double r =0;
+  double debeye = 0;
+  double fadd = 0;
+  double Irelative = 0;
+
+  //I(0) is calculated seperately
+  if (q == 0){
+    //I(0)
+    double Izero = 0;
+    for (int i = 0; i < num_rstep; ++i)
+      Izero += pr_[i][1];
+    Irelative = Izero;
+  }
+  else {
+    for (int i = 1; i < num_rstep; ++i){
+      r = i*rstep_;  //r should start from 1* rstep
+      double qr = q*r;
+      debeye = sin(qr)/qr;
+      fadd = pr_[i][1]*debeye;
+      Irelative = Irelative + fadd;
+    }
+  }
+  return Irelative;
+}
+
+double PointsModel::CalculateIQError(double q)
+{
+  //fourier transform of the returned Array2D<double> from ddFunction()
+  int num_rstep = pr_.dim1();
+
+  double r =0;
+  double debeye = 0;
+  double fadd = 0;
+  double Irelative = 0;
+
+  //I(0) is calculated seperately
+  for (int i = 1; i < num_rstep; ++i){
+	  r = i*rstep_;  //r should start from 1* rstep
+	  double qr = q*r;
+	  debeye = sin(qr)/qr;
+	  fadd = fabs(pr_[i][2])*debeye*debeye 
+	  	+ rstep_*rstep_/4.0/r/r*(cos(qr)*cos(qr) + debeye*debeye);
+	  Irelative = Irelative + fadd;
+  }
+  return sqrt(Irelative);
+}
+
+//pass in a vector of points, and calculate the P(r)
+double PointsModel::DistDistribution(const vector<Point3D> &vp)
+{
+  //get r axis:0,rstep,2rstep,3rstep......d_bound
+  int sizeofpr = r_grids_num_ + 1; //+1 just for overflow prevention
+
+  double d_bound = GetDimBound();
+  rstep_ = CalculateRstep(r_grids_num_,d_bound);
+
+  Array2D<double> pr(sizeofpr, 3); //third column is left for error for the future
+  pr = 0;
+
+  for (int i = 1; i != sizeofpr; ++i)
+    pr[i][0] = pr[i-1][0] + rstep_ ;  //column 1:  distance
+
+  int size = vp.size();
+
+  for (int i1 = 0; i1 < size - 1; ++i1) {
+    for (int i2 = i1 + 1; i2 < size; ++i2) {
+      //dist_.push_back(vp[i1].distanceToPoint(vp[i2]));
+      //product_sld_.push_back(vp[i1].getSLD() * vp[i2].getSLD());
+      double a_dist = vp[i1].distanceToPoint(vp[i2]);
+      double its_sld = vp[i1].getSLD() * vp[i2].getSLD();
+
+      //save maximum distance
+      if (a_dist>rmax_) {
+        rmax_ = a_dist;
+      }
+      //insert into pr array
+      int l = int(floor(a_dist/rstep_));
+
+      //cout << "i1,i2,l,a_dist"<<vp[i1]<<" "<<vp[i2]<<" "<<l<<" "<<a_dist<<endl;     
+      //overflow check
+      if (l >= sizeofpr) {
+        cerr << "one distance is out of range: " << l <<endl;
+        //throw "Out of range";
+      }
+      else {
+        pr[l][1] += its_sld;  //column 2 intermediate: sum of SLD of the points with specific distance     
+        // Estimate uncertainty (squared)
+        pr[l][2] += its_sld*its_sld; 
+        //keep maxium Pr absolute number, in order to normalize
+        //if (pr[l][1] > cormax_)	  cormax_ = pr[l][1];
+      }
+    }
+  }
+  
+  //normalize Pr
+  for (int j = 0; j != sizeofpr; ++j){           //final column2 for P(r)
+    //pr[j][1] = pr[j][1]/cormax_;
+
+    // 'Size' is the number of space points, without double counting (excluding 
+    // overlapping regions between shapes). The volume of the combined shape
+    // is given by  V = size * (sum of all sub-volumes) / (Total number of points) 
+    //              V = size / (lores_density)
+    
+    // - To transform the integral to a sum, we need to give a weight
+    // to each entry equal to the average space volume of a point (w = V/N = 1/lores_density).
+    // The final output, I(q), should therefore be multiplied by V*V/N*N.
+    // Since we will be interested in P(r)/V, we only need to multiply by 1/N*(V/N) = 1/N/lores_density.
+    // We don't have access to lores_density from this class; we will therefore apply
+    // this correction externally.
+    //
+    // - Since the loop goes through half the points, multiply by 2.
+    // TODO: have access to lores_density from this class.
+    // 
+    pr[j][1] = 2.0*pr[j][1]/size;
+    pr[j][2] = 4.0*pr[j][2]/size/size;
+  }
+  pr_ = pr;
+
+  return rmax_;
+}
+
+Array2D<double> PointsModel::GetPr()
+{
+  return pr_;
+}
+
+
+double PointsModel::CalculateRstep(int num_grids, double rmax)
+{
+  assert(num_grids > 0);
+
+  double rstep;
+  rstep = rmax / num_grids;
+
+  return rstep;
+}
+
+void PointsModel::OutputPR(const string &fpr){
+  ofstream outfile(fpr.c_str());
+  if (!outfile) {
+    cerr << "error: unable to open output file: "
+	 << outfile << endl;
+    exit(1);
+  }
+  
+  double sum = 0.0;
+  double r_stepsize = 1.0;
+  if (pr_.dim1()>2) r_stepsize = pr_[1][0] - pr_[0][0];
+  
+  for (int i = 0;  i < pr_.dim1(); ++i){
+	  sum += pr_[i][1]*r_stepsize;
+  }
+  
+  for (int i = 0;  i < pr_.dim1(); ++i){
+	  if (pr_[i][1]==0) continue;
+	  outfile << pr_[i][0] << "       " << (pr_[i][1]/sum) << endl;
+  }
+}
+
+void PointsModel::OutputPDB(const vector<Point3D> &vp,const char *fpr){
+  FILE *outfile=NULL;
+  outfile = fopen(fpr,"w+");
+  if (!outfile) {
+    cerr << "error: unable to open output file: "
+	 << outfile << endl;
+    exit(1);
+  }
+  int size = vp.size();
+  int index = 0;
+  for (int i = 0;  i < size; ++i){
+    ++index;
+    fprintf(outfile,"ATOM%7d  C%24.3lf%8.3lf%8.3lf%6.3lf\n", \
+           index,vp[i].getX(),vp[i].getY(),vp[i].getZ(),vp[i].getSLD());
+  }
+  fclose(outfile);
+}
+
+PointsModel::~PointsModel()
+{
+}
+
+void PointsModel::DistDistributionXY(const vector<Point3D> &vp)
+{
+  //the max box get from 3D should be more than enough for 2D,but doesn't hurt
+  double d_bound = GetDimBound();
+
+  //using 1A for rstep, so the total bins is the max distance for the object
+  int sizeofpr = ceil(d_bound) + 1; //+1 just for overflow prevention
+  rstep_ = 1;
+
+  Array2D<double> pr_xy(sizeofpr,sizeofpr); //2D histogram
+
+  //the max frequency in the correlation histogram
+  double cormax_xy_ = 0;
+
+  //initialization
+  pr_xy = 0;
+
+  for (int i = 1; i != sizeofpr; ++i){
+    pr_xy[i][0] = pr_xy[i-1][0] + rstep_ ;  //column 1:  distance
+  }
+
+  int size = vp.size();
+
+  for (int i1 = 0; i1 < size - 1; ++i1) {
+    for (int i2 = i1 + 1; i2 < size; ++i2) {
+      int jx = int(floor(fabs(vp[i1].getX()-vp[i2].getX())/rstep_));
+      int jy = int(floor(fabs(vp[i1].getY()-vp[i2].getY())/rstep_));
+      //the sld for the pair of points
+      double its_sld = vp[i1].getSLD()*vp[i2].getSLD();
+
+      //overflow check
+      if ((jx >= sizeofpr) || (jy >= sizeofpr))
+      {
+        cerr << "one distance is out of range: " <<endl;
+        //throw "Out of range";
+      }
+      else{
+	pr_xy[jx][jy] += its_sld;
+        if (pr_xy[jx][jy] > cormax_xy_ ) cormax_xy_ = pr_xy[jx][jy];
+      }
+    }
+  }
+
+  //normalize Pr_xy
+  for (int m = 0; m != sizeofpr; ++m){           //final column2 for P(r)
+    for (int n = 0; n != sizeofpr; ++n){
+      pr_xy[m][n] = pr_xy[m][n]/cormax_xy_;
+      //cout << "m n:"<<m<<" "<<n<<" "<<pr_xy[m][n]<<endl;
+    }
+  }
+
+  pr_xy_ = pr_xy;
+}
+
+void PointsModel::OutputPR_XY(const std::string &fpr)
+{
+  ofstream outfile(fpr.c_str());
+  if (!outfile) {
+    cerr << "error: unable to open output file: "
+	 << outfile << endl;
+    exit(1);
+  }
+  int size = pr_xy_.dim1();
+  //pr_xy_ is a N x N array
+  for (int i = 0;  i != size; ++i){
+    for (int j = 0; j != size; ++j)
+    {
+      outfile << i << "    " << j <<"    "<< pr_xy_[i][j] << endl;
+    }
+  }
+}
+
+void PointsModel::CalculateIQ_2D(IQ *iq,double phi)
+{
+  int nIpoints = iq->GetNumI();
+  double qstep = (iq->GetQmax()) / (nIpoints-1);
+  vector<double> fint(nIpoints, 0);
+  double Izero = 0;
+
+  //number of bins on x and y axis
+  int size_r = pr_xy_.dim1();
+  //rstep is set to one, otherwise should be cos(phi)*rstep
+  double cosphi = cos(phi);
+  double sinphi = sin(phi);
+
+  for(int k = 1; k != nIpoints; ++k){
+    double q = k * qstep;
+    double tmp = cos(q*(cosphi+sinphi));
+
+    for(int i=0; i!=size_r; ++i){
+      for(int j = 0; j!=size_r; ++j){
+        fint[k] += pr_xy_[i][j]*tmp;
+      }
+    }
+  }
+
+  for(int i=0; i!=size_r; ++i){
+    for(int j = 0; j!=size_r; ++j){
+      Izero += pr_xy_[i][j];
+    }
+  }
+  fint[0] = Izero;
+
+  //assign I(Q) with normalization
+  for(int j = 0; j < nIpoints; ++j){
+    (*iq).iq_data[j][0] = j * qstep;
+    (*iq).iq_data[j][1] = fint[j] / Izero;
+  }
+}
+
+vector<double> PointsModel::GetCenter()
+{
+  vector<double> vp(3,0);
+  return vp;
+}
+
+double PointsModel::CalculateIQ_2D(double qx, double qy)
+{
+  //for each (Qx,Qy) on 2D detector, calculate I
+  double q = sqrt(qx*qx+qy*qy);
+  double I = 0;
+
+  double cosphi = qx/q;
+  double sinphi = qy/q;
+  double tmp = cos(q*(cosphi+sinphi));
+
+  //loop through P(r) on xy plane
+  int size_r = pr_xy_.dim1();
+  for(int i=-size_r+1; i!=size_r; ++i){
+    for(int j = -size_r+1; j!=size_r; ++j){
+      //rstep is set to one, left out from calculation
+      I += pr_xy_[abs(i)][abs(j)]*cos(q*(cosphi*i+sinphi*j));
+    }
+  }
+
+  //return I, without normalization
+  return I;
+}
+
+/*
+ * 2D simulation for oriented systems
+ * The beam direction is assumed to be in the z direction.
+ * 
+ * @param points: vector of space points
+ * @param qx: qx [A-1]
+ * @param qy: qy [A-1]
+ * @return: I(qx, qy) for the system described by the space points [cm-1]
+ * 
+ */
+double PointsModel::CalculateIQ_2D(const vector<Point3D>&points, double qx, double qy){
+	/*
+	 * TODO: the vector of points should really be part of the class
+	 * 	     This is a design flaw inherited from the original programmer.
+	 */
+	
+	int size = points.size();
+
+	double cos_term = 0;
+	double sin_term = 0;
+	for (int i = 0; i < size; i++) {
+	  	//the sld for the pair of points
+	
+		double phase = qx*points[i].getX() + qy*points[i].getY();
+			  	
+		cos_term += cos(phase) * points[i].getSLD();
+		sin_term += sin(phase) * points[i].getSLD();
+	
+	}   			
+
+	// P(q) = 1/V I(q) = (V/N)^2 (1/V) (cos_term^2 + sin_term^2) 
+	// We divide by N here and we will multiply by the density later.
+
+	return (cos_term*cos_term + sin_term*sin_term)/size;	
+}
+
+double PointsModel::CalculateIQ_2D_Error(const vector<Point3D>&points, double qx, double qy){
+	
+	int size = points.size();
+
+	double delta_x, delta_y;
+	double q_t2 = qx*qx + qy*qy;
+	double cos_term = 0;
+	double sin_term = 0;
+	double cos_err = 0;
+	double sin_err = 0;
+	
+	// Estimate the error on the position of each point
+	// in x or y as V^(1/3)/N
+	
+	for (int i = 0; i < size; i++) {
+		
+		
+		//the sld for the pair of points
+	
+		double phase = qx*points[i].getX() + qy*points[i].getY();
+		double sld_fac = points[i].getSLD() * points[i].getSLD();
+		
+		cos_term += cos(phase) * points[i].getSLD();
+		sin_term += sin(phase) * points[i].getSLD();
+
+		sin_err += cos(phase) * cos(phase) * sld_fac;
+		cos_err += sin(phase) * sin(phase) * sld_fac;
+	
+	}   			
+
+	// P(q) = 1/V I(q) = (V/N)^2 (1/V) (cos_term^2 + sin_term^2) 
+	// We divide by N here and we will multiply by the density later.
+
+	// We will need to multiply this error by V^(1/3)/N.
+	// We don't have access to V from within this class.
+	return 2*sqrt(cos_term*cos_term*cos_err*cos_err + sin_term*sin_term*sin_err*sin_err)/size;	
+}
+
Index: src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/points_model.h
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/points_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/libpointsmodelpy/points_model.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,61 @@
+/** \file points_model.h child class of SASmodel*/
+
+#ifndef POINTSMODEL_H
+#define POINTSMODEL_H
+
+#include <vector>
+#include "tnt/tnt.h"
+#include <string>
+#include "Point3D.h"
+#include "iq.h"
+#include "sas_model.h"
+
+using namespace std;
+
+class PointsModel : public SASModel{
+ public:
+  PointsModel();
+  virtual ~PointsModel();
+
+  void CalculateIQ(IQ *iq);
+  double CalculateIQ(double q);
+  double CalculateIQError(double q);
+  
+  // Old lengthy 2D simulation (unchecked) 
+  void CalculateIQ_2D(IQ *iq,double phi);
+  double CalculateIQ_2D(double qx, double qy);
+  
+  // Fast 2D simulation
+  double CalculateIQ_2D(const vector<Point3D>&, double qx, double qy);
+  double CalculateIQ_2D_Error(const vector<Point3D>&, double qx, double qy);
+  
+  //given a set of points, calculate distance correlation
+  //function, and return the max dist
+  double DistDistribution(const vector<Point3D>&);
+  void DistDistributionXY(const vector<Point3D>&);
+
+  Array2D<double> GetPr();
+  void OutputPR(const std::string &);
+  void OutputPR_XY(const std::string &);
+
+  virtual int GetPoints(Point3DVector &) = 0;
+  void OutputPDB(const vector<Point3D>&,const char*);
+
+  //will be used in calculating P(r), the maximum distance
+  virtual double GetDimBound() = 0;
+  //will be used to determin the maximum distance for
+  //several pointsmodel instances
+  virtual vector<double> GetCenter();
+
+ protected:
+  double CalculateRstep(int num_points, double rmax);
+  double rmax_, rstep_,cormax_,cormax_xy_;
+  int r_grids_num_;
+  vector<double> center_;
+
+ private:
+  Array2D<double> pr_,pr_xy_;
+  vector<double> product_sld_;
+};
+
+#endif
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpy/Make.mm
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpy/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpy/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,35 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# <LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+PROJECT = pointsmodelpy
+PACKAGE = pointsmodelpy
+
+#--------------------------------------------------------------------------
+#
+
+all: export
+
+
+#--------------------------------------------------------------------------
+#
+# export
+
+EXPORT_PYTHON_MODULES = \
+    __init__.py
+
+
+export:: export-python-modules
+
+# version
+# $Id$
+
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpy/__init__.py
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpy/__init__.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpy/__init__.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+# 
+#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# 
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+# 
+#  <LicenseText>
+# 
+#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# 
+
+def copyright():
+    return "pointsmodelpy pyre module: Copyright (c) 1998-2005 Michael A.G. Aivazis";
+
+
+# version
+__id__ = "$Id$"
+
+#  End of file 
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/Make.mm
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,32 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# <LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+PROJECT = SASsimulation
+PACKAGE = pointsmodelpymodule
+MODULE = pointsmodelpy
+
+include std-pythonmodule.def
+include local.def
+
+PROJ_CXX_SRCLIB = -lpointsmodelpy -lgeoshapespy -liqPy
+
+PROJ_SRCS = \
+    bindings.cc \
+    exceptions.cc \
+    misc.cc
+
+
+# version
+# $Id$
+
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/bindings.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/bindings.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/bindings.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,166 @@
+// -*- C++ -*-
+// @copyright: University of Tennessee, for the DANSE project
+
+//#include <portinfo>
+#include <Python.h>
+
+#include "bindings.h"
+
+#include "misc.h"          // miscellaneous methods
+
+// the method table
+
+struct PyMethodDef pypointsmodelpy_methods[] = {
+
+    // new_loresmodel
+    {pypointsmodelpy_new_loresmodel__name__, pypointsmodelpy_new_loresmodel,
+     METH_VARARGS, pypointsmodelpy_new_loresmodel__doc__},
+
+    // LORESModel method:add(geoshape,sld)
+    {pypointsmodelpy_lores_add__name__, pypointsmodelpy_lores_add,
+     METH_VARARGS, pypointsmodelpy_lores_add__doc__},
+
+    // LORESModel method:GetPoints(vector<Point3D> &)
+    {pypointsmodelpy_get_lorespoints__name__, pypointsmodelpy_get_lorespoints,
+     METH_VARARGS, pypointsmodelpy_get_lorespoints__doc__},
+
+    // new_pdbmodel
+    {pypointsmodelpy_new_pdbmodel__name__, pypointsmodelpy_new_pdbmodel,
+     METH_VARARGS, pypointsmodelpy_new_pdbmodel__doc__},
+
+    // PDBModel method: AddPDB(const char*)
+    {pypointsmodelpy_pdbmodel_add__name__, pypointsmodelpy_pdbmodel_add,
+     METH_VARARGS, pypointsmodelpy_pdbmodel_add__doc__},
+
+    // PDBModel method: GetPoints(Point3DVector &)
+    {pypointsmodelpy_get_pdbpoints__name__, pypointsmodelpy_get_pdbpoints,
+     METH_VARARGS, pypointsmodelpy_get_pdbpoints__doc__},
+
+    // new_complexmodel
+    {pypointsmodelpy_new_complexmodel__name__, pypointsmodelpy_new_complexmodel,
+     METH_VARARGS, pypointsmodelpy_new_complexmodel__doc__},
+
+    // ComplexModel method: Add(PointsModel *)
+    {pypointsmodelpy_complexmodel_add__name__, pypointsmodelpy_complexmodel_add,
+     METH_VARARGS, pypointsmodelpy_complexmodel_add__doc__},
+
+    // ComplexModel method: GetPoints(Point3DVector &)
+    {pypointsmodelpy_get_complexpoints__name__, pypointsmodelpy_get_complexpoints,
+     METH_VARARGS, pypointsmodelpy_get_complexpoints__doc__},
+
+    //new_point3dvec
+    {pypointsmodelpy_new_point3dvec__name__, pypointsmodelpy_new_point3dvec,
+     METH_VARARGS, pypointsmodelpy_new_point3dvec__doc__},
+
+    //fillpoints
+    //{pypointsmodelpy_fillpoints__name__, pypointsmodelpy_fillpoints,
+    //METH_VARARGS, pypointsmodelpy_fillpoints__doc__},
+
+    //distdistribution calculation for LORES model
+    {pypointsmodelpy_get_lores_pr__name__, pypointsmodelpy_get_lores_pr,
+     METH_VARARGS, pypointsmodelpy_get_lores_pr__doc__},
+
+    //distdistribution 2D (on xy plane)
+    {pypointsmodelpy_distdistribution_xy__name__, pypointsmodelpy_distdistribution_xy,
+     METH_VARARGS, pypointsmodelpy_distdistribution_xy__doc__},
+
+    //distdistribution calculation for PDB model
+    {pypointsmodelpy_get_pdb_pr__name__, pypointsmodelpy_get_pdb_pr,
+     METH_VARARGS, pypointsmodelpy_get_pdb_pr__doc__},
+
+    //distdistribution calculation on XY plane for PDB model
+    {pypointsmodelpy_get_pdb_pr_xy__name__, pypointsmodelpy_get_pdb_pr_xy,
+     METH_VARARGS, pypointsmodelpy_get_pdb_pr_xy__doc__},
+
+    //distdistribution calculation for Complex model
+    {pypointsmodelpy_get_complex_pr__name__, pypointsmodelpy_get_complex_pr,
+     METH_VARARGS, pypointsmodelpy_get_complex_pr__doc__},
+
+    //calculateIQ
+    {pypointsmodelpy_get_lores_iq__name__, pypointsmodelpy_get_lores_iq,
+     METH_VARARGS, pypointsmodelpy_get_lores_iq__doc__},
+
+    //calculateI(single Q)
+    {pypointsmodelpy_get_lores_i__name__, pypointsmodelpy_get_lores_i,
+     METH_VARARGS, pypointsmodelpy_get_lores_i__doc__},
+
+    //calculateI(single Q)
+    {pypointsmodelpy_get_complex_i__name__, pypointsmodelpy_get_complex_i,
+     METH_VARARGS, pypointsmodelpy_get_complex_i__doc__},
+
+    //calculateI(single Q)
+    {pypointsmodelpy_get_complex_i_error__name__, pypointsmodelpy_get_complex_i_error,
+     METH_VARARGS, pypointsmodelpy_get_complex_i_error__doc__},
+
+    //calculateIQ 2D
+    {pypointsmodelpy_calculateIQ_2D__name__, pypointsmodelpy_calculateIQ_2D,
+     METH_VARARGS, pypointsmodelpy_calculateIQ_2D__doc__},
+
+     //calculateIQ 2D(points, Qx,Qy)
+     {pypointsmodelpy_calculateI_Qvxy__name__, pypointsmodelpy_calculateI_Qvxy,
+      METH_VARARGS, pypointsmodelpy_calculateI_Qvxy__doc__},
+
+      //calculateIQ 2D(Qx,Qy)
+      {pypointsmodelpy_calculateI_Qxy__name__, pypointsmodelpy_calculateI_Qxy,
+       METH_VARARGS, pypointsmodelpy_calculateI_Qxy__doc__},
+
+    //PDBModel calculateIQ
+    {pypointsmodelpy_get_pdb_iq__name__, pypointsmodelpy_get_pdb_iq,
+     METH_VARARGS, pypointsmodelpy_get_pdb_iq__doc__},
+
+     //PDBModel calculateIQ(Qx,Qy)
+     {pypointsmodelpy_get_pdb_Iqxy__name__, pypointsmodelpy_get_pdb_Iqxy,
+      METH_VARARGS, pypointsmodelpy_get_pdb_Iqxy__doc__},
+
+      //PDBModel calculateIQ(pts,Qx,Qy)
+      {pypointsmodelpy_get_pdb_Iqvxy__name__, pypointsmodelpy_get_pdb_Iqvxy,
+       METH_VARARGS, pypointsmodelpy_get_pdb_Iqvxy__doc__},
+
+       //ComplexModel calculateIQ(pts,Qx,Qy)
+       {pypointsmodelpy_get_complex_Iqxy__name__, pypointsmodelpy_get_complex_Iqxy,
+        METH_VARARGS, pypointsmodelpy_get_complex_Iqxy__doc__},
+
+        //ComplexModel calculateIQ_2D_Error(pts,Qx,Qy)
+        {pypointsmodelpy_get_complex_Iqxy_err__name__, pypointsmodelpy_get_complex_Iqxy_err,
+         METH_VARARGS, pypointsmodelpy_get_complex_Iqxy_err__doc__},
+
+    //ComplexModel calculateIQ
+    {pypointsmodelpy_get_complex_iq__name__, pypointsmodelpy_get_complex_iq,
+     METH_VARARGS, pypointsmodelpy_get_complex_iq__doc__},
+
+     //outputPR
+     {pypointsmodelpy_outputPR__name__, pypointsmodelpy_outputPR,
+      METH_VARARGS, pypointsmodelpy_outputPR__doc__},
+
+    //getPR
+    {pypointsmodelpy_getPR__name__, pypointsmodelpy_getPR,
+     METH_VARARGS, pypointsmodelpy_getPR__doc__},
+
+    //outputPR_xy
+    {pypointsmodelpy_outputPR_xy__name__, pypointsmodelpy_outputPR_xy,
+     METH_VARARGS, pypointsmodelpy_outputPR_xy__doc__},
+
+    //PDBModel outputPR
+    {pypointsmodelpy_save_pdb_pr__name__, pypointsmodelpy_save_pdb_pr,
+     METH_VARARGS, pypointsmodelpy_save_pdb_pr__doc__},
+
+    //ComplexModel outputPR
+    {pypointsmodelpy_save_complex_pr__name__, pypointsmodelpy_save_complex_pr,
+     METH_VARARGS, pypointsmodelpy_save_complex_pr__doc__},
+
+    //outputPDB
+    {pypointsmodelpy_outputPDB__name__, pypointsmodelpy_outputPDB,
+     METH_VARARGS, pypointsmodelpy_outputPDB__doc__},
+
+    {pypointsmodelpy_copyright__name__, pypointsmodelpy_copyright,
+     METH_VARARGS, pypointsmodelpy_copyright__doc__},
+
+
+// Sentinel
+    {0, 0}
+};
+
+// version
+// $Id$
+
+// End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/bindings.h
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/bindings.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/bindings.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,26 @@
+// -*- C++ -*-
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//                               Michael A.G. Aivazis
+//                        California Institute of Technology
+//                        (C) 1998-2005  All Rights Reserved
+// 
+//  <LicenseText>
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+#if !defined(pypointsmodelpy_bindings_h)
+#define pypointsmodelpy_bindings_h
+
+// the method table
+
+extern struct PyMethodDef pypointsmodelpy_methods[];
+
+#endif
+
+// version
+// $Id$
+
+// End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/exceptions.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/exceptions.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/exceptions.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,22 @@
+// -*- C++ -*-
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//                               Michael A.G. Aivazis
+//                        California Institute of Technology
+//                        (C) 1998-2005  All Rights Reserved
+// 
+//  <LicenseText>
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+//#include <portinfo>
+#include <Python.h>
+
+PyObject *pypointsmodelpy_runtimeError = 0;
+    
+// version
+// $Id$
+
+// End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/exceptions.h
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/exceptions.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/exceptions.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,26 @@
+// -*- C++ -*-
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//                               Michael A.G. Aivazis
+//                        California Institute of Technology
+//                        (C) 1998-2005  All Rights Reserved
+// 
+//  <LicenseText>
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+#if !defined(pypointsmodelpy_exceptions_h)
+#define pypointsmodelpy_exceptions_h
+
+// exceptions
+
+extern PyObject *pypointsmodelpy_runtimeError;
+
+#endif
+
+// version
+// $Id$
+
+// End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/local.def
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/local.def	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/local.def	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,26 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# <LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+# C++
+
+    PROJ_CXX_INCLUDES = ..   \
+			../libpointsmodelpy   \
+			../../analmodelpy/libanalmodelpy  \
+			../../geoshapespy/libgeoshapespy  \
+			../../iqPy/libiqPy  \
+			../../iqPy/libiqPy/tnt  
+
+# version
+# $Id$
+
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/misc.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/misc.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/misc.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,806 @@
+// -*- C++ -*-
+#include <Python.h>
+
+#include <vector>
+#include <cstring>
+#include <stdexcept>
+#include "Point3D.h"
+#include "misc.h"
+#include "lores_model.h"
+#include "pdb_model.h"
+#include "complex_model.h"
+#include "geo_shape.h"
+#include "iq.h"
+
+// copyright
+
+char pypointsmodelpy_copyright__doc__[] = "";
+char pypointsmodelpy_copyright__name__[] = "copyright";
+
+static char pypointsmodelpy_copyright_note[] = 
+    "pointsmodelpy python module: Copyright (c) 2007 University of Tennessee";
+
+
+PyObject * pypointsmodelpy_copyright(PyObject *, PyObject *)
+{
+    return Py_BuildValue("s", pypointsmodelpy_copyright_note);
+}
+    
+// new_loresmodel 
+//wrapper for LORESModel constructor LORESModel(double density)
+
+char pypointsmodelpy_new_loresmodel__doc__[] = "Low-resolution shapes:real space geometric complex models";
+char pypointsmodelpy_new_loresmodel__name__[] = "new_loresmodel";
+
+PyObject * pypointsmodelpy_new_loresmodel(PyObject *, PyObject *args)
+{
+  double density = 0;
+
+  int ok = PyArg_ParseTuple(args, "d",&density);
+  if(!ok) return NULL;
+
+  LORESModel *newlores = new LORESModel(density);
+  return PyCObject_FromVoidPtr(newlores, PyDelLores);
+}
+    
+void PyDelLores(void *ptr){
+  LORESModel * oldlores = static_cast<LORESModel *>(ptr);
+  delete oldlores;
+  return;
+}
+
+//LORESModel methods add(GeoShape &, double sld)
+char pypointsmodelpy_lores_add__name__[] = "lores_add";
+char pypointsmodelpy_lores_add__doc__[] = "loresmodel method:add(Geoshape &,sld)";
+
+PyObject * pypointsmodelpy_lores_add(PyObject *, PyObject *args){
+  double sld = 1;
+  PyObject *pyloresmodel = 0, *pyshape = 0;
+  int ok = PyArg_ParseTuple(args, "OOd", &pyloresmodel, &pyshape, &sld);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pyloresmodel);
+  void *temp2 = PyCObject_AsVoidPtr(pyshape);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  GeoShape * thisshape = static_cast<GeoShape *>(temp2);
+
+  thislores->Add(*thisshape, sld);
+
+  return Py_BuildValue("i", 0);
+}
+
+//LORESModel methods GetPoints(vector<Point3D> &)
+char pypointsmodelpy_get_lorespoints__name__[] = "get_lorespoints";
+char pypointsmodelpy_get_lorespoints__doc__[] = "get the points from the lores model";
+
+PyObject * pypointsmodelpy_get_lorespoints(PyObject *, PyObject *args){
+  PyObject *pyloresmodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pyloresmodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pyloresmodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  int npts = thislores->GetPoints(*thisvec);
+  //temporary
+  thislores->WritePoints2File(*thisvec);
+  return Py_BuildValue("i", npts);
+}
+
+// new_pdbmodel 
+//wrapper for PDBModel constructor PDBModel()
+
+char pypointsmodelpy_new_pdbmodel__doc__[] = "PDB model: contain atomic coordinate from PDB file & Scattering length density";
+char pypointsmodelpy_new_pdbmodel__name__[] = "new_pdbmodel";
+
+PyObject * pypointsmodelpy_new_pdbmodel(PyObject *, PyObject *args)
+{
+  PDBModel *newpdb = new PDBModel();
+  return PyCObject_FromVoidPtr(newpdb, PyDelPDB);
+}
+    
+void PyDelPDB(void *ptr){
+  PDBModel * oldpdb = static_cast<PDBModel *>(ptr);
+  delete oldpdb;
+  return;
+}
+
+//PDBModel methods AddPDB(char * pdbfile) 
+char pypointsmodelpy_pdbmodel_add__name__[] = "pdbmodel_add";
+char pypointsmodelpy_pdbmodel_add__doc__[] = "Add a structure from PDB";
+
+PyObject * pypointsmodelpy_pdbmodel_add(PyObject *, PyObject *args){
+  PyObject *pypdbmodel = 0;
+  char * pdbfile;
+
+  int ok = PyArg_ParseTuple(args, "Os", &pypdbmodel, &pdbfile);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pypdbmodel);
+
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+
+  thispdb->AddPDB(pdbfile);
+
+  return Py_BuildValue("i", 0);
+}
+
+//PDBModel methods GetPoints(Point3DVector &) 
+char pypointsmodelpy_get_pdbpoints__name__[] = "get_pdbpoints";
+char pypointsmodelpy_get_pdbpoints__doc__[] = "Get atomic points from pdb with SLD";
+
+PyObject * pypointsmodelpy_get_pdbpoints(PyObject *, PyObject *args){
+  PyObject *pypdbmodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pypdbmodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pypdbmodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  int npts = thispdb->GetPoints(*thisvec);
+
+  return Py_BuildValue("i", npts);
+}
+
+// new_complexmodel 
+//wrapper for ComplexModel constructor ComplexModel()
+
+char pypointsmodelpy_new_complexmodel__doc__[] = "COMPLEX model: contain LORES and PDB models";
+char pypointsmodelpy_new_complexmodel__name__[] = "new_complexmodel";
+
+PyObject * pypointsmodelpy_new_complexmodel(PyObject *, PyObject *args)
+{
+  ComplexModel *newcomplex = new ComplexModel();
+  return PyCObject_FromVoidPtr(newcomplex, PyDelComplex);
+}
+    
+void PyDelComplex(void *ptr){
+  ComplexModel * oldcomplex = static_cast<ComplexModel *>(ptr);
+  delete oldcomplex;
+  return;
+}
+
+//ComplexModel methods Add(PointsModel *) 
+char pypointsmodelpy_complexmodel_add__name__[] = "complexmodel_add";
+char pypointsmodelpy_complexmodel_add__doc__[] = "Add LORES model or PDB Model,type has to be specified (either PDB or LORES)";
+
+PyObject * pypointsmodelpy_complexmodel_add(PyObject *, PyObject *args){
+  PyObject *pycomplexmodel = 0, *pymodel = 0;
+  char * modeltype;
+
+  int ok = PyArg_ParseTuple(args, "OOs", &pycomplexmodel,&pymodel, &modeltype);
+  if(!ok) return NULL;
+
+  void *temp2 = PyCObject_AsVoidPtr(pycomplexmodel);
+  ComplexModel *thiscomplex = static_cast<ComplexModel *>(temp2);
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  if (strcmp(modeltype,"LORES") == 0){
+    LORESModel * thislores = static_cast<LORESModel *>(temp);
+    thiscomplex->Add(thislores);
+  }
+  else if (strcmp(modeltype,"PDB") == 0){
+    PDBModel * thispdb = static_cast<PDBModel *>(temp);
+    thiscomplex->Add(thispdb);
+  }
+  else{
+    throw runtime_error("The model type is either PDB or LORES");
+  }
+
+  return Py_BuildValue("i", 0);
+}
+
+//ComplexModel methods GetPoints(Point3DVector &) 
+char pypointsmodelpy_get_complexpoints__name__[] = "get_complexpoints";
+char pypointsmodelpy_get_complexpoints__doc__[] = "Get points from complex model (container for LORES & PDB model)";
+
+PyObject * pypointsmodelpy_get_complexpoints(PyObject *, PyObject *args){
+  PyObject *pycomplexmodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pycomplexmodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pycomplexmodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  int npts = thiscomplex->GetPoints(*thisvec);
+
+  return Py_BuildValue("i", npts);
+}
+
+//create a new vector that holds of class Point3D objects 
+char pypointsmodelpy_new_point3dvec__doc__[] = "";
+char pypointsmodelpy_new_point3dvec__name__[] = "new_point3dvec";
+
+PyObject * pypointsmodelpy_new_point3dvec(PyObject *, PyObject *args)
+{
+  PyObject *pyvec = 0;
+
+  vector<Point3D> *newvec = new vector<Point3D>();
+
+  return PyCObject_FromVoidPtr(newvec, PyDelPoint3DVec);
+}
+
+void PyDelPoint3DVec(void *ptr)
+{
+  vector<Point3D> * oldvec = static_cast<vector<Point3D> *>(ptr);
+  delete oldvec;
+  return;
+
+}
+
+//LORESModel method distribution(point3dvec)
+char pypointsmodelpy_get_lores_pr__name__[] = "get_lores_pr";
+char pypointsmodelpy_get_lores_pr__doc__[] = "calculate distance distribution function";
+
+PyObject * pypointsmodelpy_get_lores_pr(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  double rmax = thislores->DistDistribution(*thisvec);
+  
+  return Py_BuildValue("d", rmax);
+}
+
+//LORESModel method distribution_xy(point3dvec)
+char pypointsmodelpy_distdistribution_xy__name__[] = "distdistribution_xy";
+char pypointsmodelpy_distdistribution_xy__doc__[] = "calculate distance distribution function on XY plane";
+
+PyObject * pypointsmodelpy_distdistribution_xy(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+
+  Py_BEGIN_ALLOW_THREADS
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+  thislores->DistDistributionXY(*thisvec);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("i", 0);
+}
+
+//PDBModel method distribution_xy(point3dvec)
+char pypointsmodelpy_get_pdb_pr_xy__name__[] = "get_pdb_pr_xy";
+char pypointsmodelpy_get_pdb_pr_xy__doc__[] = "calculate distance distribution function on XY plane";
+
+PyObject * pypointsmodelpy_get_pdb_pr_xy(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+  thispdb->DistDistributionXY(*thisvec);
+
+  return Py_BuildValue("i", 0);
+}
+
+//PDBModel method distribution(point3dvec)
+char pypointsmodelpy_get_pdb_pr__name__[] = "get_pdb_pr";
+char pypointsmodelpy_get_pdb_pr__doc__[] = "calculate distance distribution function";
+
+PyObject * pypointsmodelpy_get_pdb_pr(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  Py_BEGIN_ALLOW_THREADS
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+  thispdb->DistDistribution(*thisvec);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("i", 0);
+}
+
+//ComplexModel method distribution(point3dvec)
+char pypointsmodelpy_get_complex_pr__name__[] = "get_complex_pr";
+char pypointsmodelpy_get_complex_pr__doc__[] = "calculate distance distribution function";
+
+PyObject * pypointsmodelpy_get_complex_pr(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0, *pypoint3dvec = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pypoint3dvec);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+  Py_BEGIN_ALLOW_THREADS
+  thiscomplex->DistDistribution(*thisvec);
+  Py_END_ALLOW_THREADS
+  return Py_BuildValue("i", 0);
+}
+
+//LORESModel method CalculateIQ(iq)
+char pypointsmodelpy_get_lores_iq__name__[] = "get_lores_iq";
+char pypointsmodelpy_get_lores_iq__doc__[] = "calculate scattering intensity";
+
+PyObject * pypointsmodelpy_get_lores_iq(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0, *pyiq = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pylores, &pyiq);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+  void *temp2 = PyCObject_AsVoidPtr(pyiq);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  IQ * thisiq = static_cast<IQ *>(temp2);
+
+  Py_BEGIN_ALLOW_THREADS
+  thislores->CalculateIQ(thisiq);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("i",0);
+}
+
+//LORESModel method CalculateIQ(q)
+char pypointsmodelpy_get_lores_i__name__[] = "get_lores_i";
+char pypointsmodelpy_get_lores_i__doc__[] = "calculate averaged scattering intensity from a single q";
+
+PyObject * pypointsmodelpy_get_lores_i(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0;
+  double q = 0;
+  int ok = PyArg_ParseTuple(args, "Od", &pylores, &q);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  
+  double I = 0.0;
+  Py_BEGIN_ALLOW_THREADS
+  I = thislores->CalculateIQ(q);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+// method calculateIQ_2D(iq)
+char pypointsmodelpy_calculateIQ_2D__name__[] = "calculateIQ_2D";
+char pypointsmodelpy_calculateIQ_2D__doc__[] = "calculate scattering intensity";
+
+PyObject * pypointsmodelpy_calculateIQ_2D(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0, *pyiq = 0;
+  double theta = 0;
+  int ok = PyArg_ParseTuple(args, "OOd", &pylores, &pyiq,&theta);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+  void *temp2 = PyCObject_AsVoidPtr(pyiq);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  IQ * thisiq = static_cast<IQ *>(temp2);
+  
+  Py_BEGIN_ALLOW_THREADS
+  thislores->CalculateIQ_2D(thisiq,theta);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("i",0);
+}
+
+// method calculateI_Qxy(Qx,Qy)
+char pypointsmodelpy_calculateI_Qxy__name__[] = "calculateI_Qxy";
+char pypointsmodelpy_calculateI_Qxy__doc__[] = "calculate scattering intensity on a 2D pixel";
+
+PyObject * pypointsmodelpy_calculateI_Qxy(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0;
+  double qx = 0, qy = 0;
+  double I = 0;
+
+  int ok = PyArg_ParseTuple(args, "Odd", &pylores, &qx,&qy);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  
+  Py_BEGIN_ALLOW_THREADS
+  I = thislores->CalculateIQ_2D(qx,qy);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+// method calculateI_Qxy(poitns, Qx,Qy)
+char pypointsmodelpy_calculateI_Qvxy__name__[] = "calculateI_Qvxy";
+char pypointsmodelpy_calculateI_Qvxy__doc__[] = "calculate scattering intensity on a 2D pixel";
+
+PyObject * pypointsmodelpy_calculateI_Qvxy(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0, *pypoint3dvec = 0;
+  double qx = 0, qy = 0;
+  double I = 0;
+
+  int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx,&qy);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+  
+  Py_BEGIN_ALLOW_THREADS
+  I = thislores->CalculateIQ_2D(*thisvec, qx,qy);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+// PDBModel method calculateIQ(iq)
+char pypointsmodelpy_get_pdb_iq__name__[] = "get_pdb_iq";
+char pypointsmodelpy_get_pdb_iq__doc__[] = "calculate scattering intensity for PDB model";
+
+PyObject * pypointsmodelpy_get_pdb_iq(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0, *pyiq = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pyiq);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  void *temp2 = PyCObject_AsVoidPtr(pyiq);
+
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+  IQ * thisiq = static_cast<IQ *>(temp2);
+
+  Py_BEGIN_ALLOW_THREADS
+  thispdb->CalculateIQ(thisiq);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("i",0);
+}
+
+// PDBModel method calculateIQ_2D(qx,qy)
+char pypointsmodelpy_get_pdb_Iqxy__name__[] = "get_pdb_Iqxy";
+char pypointsmodelpy_get_pdb_Iqxy__doc__[] = "calculate scattering intensity by a given (qx,qy) for PDB model";
+
+PyObject * pypointsmodelpy_get_pdb_Iqxy(PyObject *, PyObject *args)
+{
+  PyObject *pypdb = 0;
+  double qx = 0, qy = 0;
+  double I = 0;
+
+  int ok = PyArg_ParseTuple(args, "Odd", &pypdb, &qx,&qy);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pypdb);
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+
+  Py_BEGIN_ALLOW_THREADS
+  I = thispdb->CalculateIQ_2D(qx,qy);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+// PDBModel method calculateIQ_2Dv(points,qx,qy)
+char pypointsmodelpy_get_pdb_Iqvxy__name__[] = "get_pdb_Iqvxy";
+char pypointsmodelpy_get_pdb_Iqvxy__doc__[] = "calculate scattering intensity by a given (qx,qy) for PDB model";
+
+PyObject * pypointsmodelpy_get_pdb_Iqvxy(PyObject *, PyObject *args)
+{
+  PyObject *pypdb = 0, *pypoint3dvec = 0;
+  double qx = 0, qy = 0;
+  double I = 0;
+
+  int ok = PyArg_ParseTuple(args, "OOdd", &pypdb, &pypoint3dvec, &qx,&qy);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pypdb);
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  Py_BEGIN_ALLOW_THREADS
+  I = thispdb->CalculateIQ_2D(*thisvec,qx,qy);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+// ComplexModel method calculateIQ(iq)
+char pypointsmodelpy_get_complex_iq__name__[] = "get_complex_iq";
+char pypointsmodelpy_get_complex_iq__doc__[] = "calculate scattering intensity for COMPLEX model";
+
+PyObject * pypointsmodelpy_get_complex_iq(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0, *pyiq = 0;
+  int ok = PyArg_ParseTuple(args, "OO", &pymodel, &pyiq);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+  void *temp2 = PyCObject_AsVoidPtr(pyiq);
+
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+  IQ * thisiq = static_cast<IQ *>(temp2);
+
+  Py_BEGIN_ALLOW_THREADS
+  thiscomplex->CalculateIQ(thisiq);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("i",0);
+}
+
+//LORESModel method CalculateIQ_2D(points,qx,qy) 
+char pypointsmodelpy_get_complex_Iqxy__name__[] = "get_complex_iq_2D";
+char pypointsmodelpy_get_complex_Iqxy__doc__[] = "calculate averaged scattering intensity from a single q";
+
+PyObject * pypointsmodelpy_get_complex_Iqxy(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0, *pypoint3dvec = 0;
+  double qx = 0, qy = 0;
+  int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx, &qy);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  double I = 0.0;
+  Py_BEGIN_ALLOW_THREADS
+  I = thiscomplex->CalculateIQ_2D(*thisvec,qx,qy);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+//LORESModel method CalculateIQ_2D_Error(points,qx,qy) 
+char pypointsmodelpy_get_complex_Iqxy_err__name__[] = "get_complex_iq_2D_err";
+char pypointsmodelpy_get_complex_Iqxy_err__doc__[] = "calculate averaged scattering intensity from a single q";
+
+PyObject * pypointsmodelpy_get_complex_Iqxy_err(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0, *pypoint3dvec = 0;
+  double qx = 0, qy = 0;
+  int ok = PyArg_ParseTuple(args, "OOdd", &pylores, &pypoint3dvec, &qx, &qy);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  double I = 0.0;
+  Py_BEGIN_ALLOW_THREADS
+  I = thiscomplex->CalculateIQ_2D_Error(*thisvec,qx,qy);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+//LORESModel method CalculateIQ(q) 
+char pypointsmodelpy_get_complex_i__name__[] = "get_complex_i";
+char pypointsmodelpy_get_complex_i__doc__[] = "calculate averaged scattering intensity from a single q";
+
+PyObject * pypointsmodelpy_get_complex_i(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0;
+  double q = 0;
+  int ok = PyArg_ParseTuple(args, "Od", &pylores, &q);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+  
+  double I = 0.0;
+  Py_BEGIN_ALLOW_THREADS
+  I = thiscomplex->CalculateIQ(q);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+char pypointsmodelpy_get_complex_i_error__name__[] = "get_complex_i_error";
+char pypointsmodelpy_get_complex_i_error__doc__[] = "calculate error on averaged scattering intensity from a single q";
+
+PyObject * pypointsmodelpy_get_complex_i_error(PyObject *, PyObject *args)
+{
+  PyObject *pylores = 0;
+  double q = 0;
+  int ok = PyArg_ParseTuple(args, "Od", &pylores, &q);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pylores);
+
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+
+  double I = 0.0;
+  Py_BEGIN_ALLOW_THREADS
+  I = thiscomplex->CalculateIQError(q);
+  Py_END_ALLOW_THREADS
+  
+  return Py_BuildValue("d",I);
+}
+
+
+
+
+//method outputPR(string filename)
+char pypointsmodelpy_outputPR__name__[] = "outputPR";
+char pypointsmodelpy_outputPR__doc__[] = "print out P(R) to a file";
+
+PyObject * pypointsmodelpy_outputPR(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0;
+  char *outfile;
+  int ok = PyArg_ParseTuple(args, "Os", &pymodel, &outfile);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+
+  thislores->OutputPR(outfile);
+
+  return Py_BuildValue("i", 0);
+}
+
+
+//method get_pr()
+char pypointsmodelpy_getPR__name__[] = "get_pr";
+char pypointsmodelpy_getPR__doc__[] = "Return P(r) as a list of points";
+
+PyObject * pypointsmodelpy_getPR(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0;
+  char *outfile;
+  int ok = PyArg_ParseTuple(args, "O", &pymodel);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+
+  // Get the P(r) array
+  Array2D<double> pr_ = thislores->GetPr();
+
+  // Create two lists to store the r and P(r) values
+  PyObject* r_list  = PyList_New(0);
+  PyObject* pr_list = PyList_New(0);
+
+  double sum = 0.0;
+  double r_stepsize = 1.0;
+  if (pr_.dim1()>2) r_stepsize = pr_[1][0] - pr_[0][0];
+
+  for (int i = 0;  i < pr_.dim1(); ++i){
+	  sum += pr_[i][1]*r_stepsize;
+  }
+
+  for (int i = 0;  i < pr_.dim1(); ++i){
+	  if (pr_[i][1]==0) continue;
+	  int r_append  = PyList_Append(r_list, Py_BuildValue("d", pr_[i][0]));
+	  int pr_append = PyList_Append(pr_list, Py_BuildValue("d", pr_[i][1]/sum));
+	  if (r_append+pr_append<0) return NULL;
+  }
+
+  return Py_BuildValue("OO", r_list, pr_list);
+}
+
+
+
+//method outputPR_xy(string filename)
+char pypointsmodelpy_outputPR_xy__name__[] = "outputPR_xy";
+char pypointsmodelpy_outputPR_xy__doc__[] = "print out P(R) to a file";
+
+PyObject * pypointsmodelpy_outputPR_xy(PyObject *, PyObject *args)
+{
+  PyObject *pyloresmodel = 0;
+  char *outfile;
+  int ok = PyArg_ParseTuple(args, "Os", &pyloresmodel, &outfile);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pyloresmodel);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+
+  thislores->OutputPR_XY(outfile);
+
+  return Py_BuildValue("i", 0);
+}
+
+//PDBModel method outputPR(string filename)
+char pypointsmodelpy_save_pdb_pr__name__[] = "save_pdb_pr";
+char pypointsmodelpy_save_pdb_pr__doc__[] = "print out P(R) to a file";
+
+PyObject * pypointsmodelpy_save_pdb_pr(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0;
+  char *outfile;
+  int ok = PyArg_ParseTuple(args, "Os", &pymodel, &outfile);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+
+  PDBModel * thispdb = static_cast<PDBModel *>(temp);
+
+  thispdb->OutputPR(outfile);
+
+  return Py_BuildValue("i", 0);
+}
+
+//ComplexModel method outputPR(string filename)
+char pypointsmodelpy_save_complex_pr__name__[] = "save_complex_pr";
+char pypointsmodelpy_save_complex_pr__doc__[] = "print out P(R) to a file";
+
+PyObject * pypointsmodelpy_save_complex_pr(PyObject *, PyObject *args)
+{
+  PyObject *pymodel = 0;
+  char *outfile;
+  int ok = PyArg_ParseTuple(args, "Os", &pymodel, &outfile);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pymodel);
+
+  ComplexModel * thiscomplex = static_cast<ComplexModel *>(temp);
+
+  thiscomplex->OutputPR(outfile);
+
+  return Py_BuildValue("i", 0);
+}
+
+
+//method outputPDB(string filename)
+char pypointsmodelpy_outputPDB__name__[] = "outputPDB";
+char pypointsmodelpy_outputPDB__doc__[] = "save the monte-carlo distributed points of the geomodel into a PDB format file.\
+                                           a .pdb extension will be automatically added";
+
+PyObject * pypointsmodelpy_outputPDB(PyObject *, PyObject *args)
+{
+  PyObject *pyloresmodel = 0, *pypoint3dvec=0;
+  char *outfile;
+  int ok = PyArg_ParseTuple(args, "OOs", &pyloresmodel, &pypoint3dvec,&outfile);
+  if(!ok) return NULL;
+
+  void *temp = PyCObject_AsVoidPtr(pyloresmodel);
+
+  LORESModel * thislores = static_cast<LORESModel *>(temp);
+
+  void *temp2 = PyCObject_AsVoidPtr(pypoint3dvec);
+  vector<Point3D> * thisvec = static_cast<vector<Point3D> *>(temp2);
+
+  thislores->OutputPDB(*thisvec,outfile);
+
+  return Py_BuildValue("i", 0);
+}
+
+// version
+// $Id$
+
+// End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/misc.h
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/misc.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/misc.h	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,238 @@
+#if !defined(pypointsmodelpy_misc_h)
+#define pypointsmodelpy_misc_h
+
+// @copyright: University of Tennessee, for the DANSE project
+extern char pypointsmodelpy_copyright__name__[];
+extern char pypointsmodelpy_copyright__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_copyright(PyObject *, PyObject *);
+
+// LORESModel constructor LORESModel(double density)
+extern char pypointsmodelpy_new_loresmodel__name__[];
+extern char pypointsmodelpy_new_loresmodel__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_new_loresmodel(PyObject *, PyObject *);
+
+//Clean LORESModel constructor memory usage
+static void PyDelLores(void *);
+
+//LORESModel methods add(GeoShapes &, double sld)
+extern char pypointsmodelpy_lores_add__name__[];
+extern char pypointsmodelpy_lores_add__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_lores_add(PyObject *, PyObject *);
+
+//LORESModel methods GetPoints(vector<Point3D> &)
+extern char pypointsmodelpy_get_lorespoints__name__[];
+extern char pypointsmodelpy_get_lorespoints__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_lorespoints(PyObject *, PyObject *);
+
+//PDBModel constructor PDBModel()
+extern char pypointsmodelpy_new_pdbmodel__name__[];
+extern char pypointsmodelpy_new_pdbmodel__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_new_pdbmodel(PyObject *, PyObject *);
+
+//Clean PDBModel constructor memory usage
+static void PyDelPDB(void *);
+
+//PDBModel method AddPDB(string)
+extern char pypointsmodelpy_pdbmodel_add__name__[];
+extern char pypointsmodelpy_pdbmodel_add__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_pdbmodel_add(PyObject *, PyObject *);
+
+//PDBModel method GetPoints(Point3DVector &)
+extern char pypointsmodelpy_get_pdbpoints__name__[];
+extern char pypointsmodelpy_get_pdbpoints__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_pdbpoints(PyObject *, PyObject *);
+
+//ComplexModel constructor ComplexModel()
+extern char pypointsmodelpy_new_complexmodel__name__[];
+extern char pypointsmodelpy_new_complexmodel__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_new_complexmodel(PyObject *, PyObject *);
+
+//Clean Complexodel constructor memory usage
+static void PyDelComplex(void *);
+
+//ComplexModel method AddComplex(string)
+extern char pypointsmodelpy_complexmodel_add__name__[];
+extern char pypointsmodelpy_complexmodel_add__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_complexmodel_add(PyObject *, PyObject *);
+
+//ComplexModel method GetPoints(Point3DVector &)
+extern char pypointsmodelpy_get_complexpoints__name__[];
+extern char pypointsmodelpy_get_complexpoints__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_complexpoints(PyObject *, PyObject *);
+
+//generate a new vector of points3d
+extern char pypointsmodelpy_new_point3dvec__name__[];
+extern char pypointsmodelpy_new_point3dvec__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_new_point3dvec(PyObject *, PyObject *);
+
+//clean new_point3dvec
+static void PyDelPoint3DVec(void *);
+
+// method FillPoints(loresmodel, point3dvec)
+//extern char pypointsmodelpy_fillpoints__name__[];
+//extern char pypointsmodelpy_fillpoints__doc__[];
+//extern "C"
+//PyObject * pypointsmodelpy_fillpoints(PyObject *, PyObject *);
+
+// LORESModel method distdistribution(point3dvec)
+extern char pypointsmodelpy_get_lores_pr__name__[];
+extern char pypointsmodelpy_get_lores_pr__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_lores_pr(PyObject *, PyObject *);
+
+// method distdistribution_xy(point3dvec)
+extern char pypointsmodelpy_distdistribution_xy__name__[];
+extern char pypointsmodelpy_distdistribution_xy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_distdistribution_xy(PyObject *, PyObject *);
+
+// PDBModel method distdistribution(point3dvec)
+extern char pypointsmodelpy_get_pdb_pr__name__[];
+extern char pypointsmodelpy_get_pdb_pr__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_pdb_pr(PyObject *, PyObject *);
+
+// PDBModel method distdistribution_xy(point3dvec)
+extern char pypointsmodelpy_get_pdb_pr_xy__name__[];
+extern char pypointsmodelpy_get_pdb_pr_xy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_pdb_pr_xy(PyObject *, PyObject *);
+
+// ComplexModel method distdistribution(point3dvec)
+extern char pypointsmodelpy_get_complex_pr__name__[];
+extern char pypointsmodelpy_get_complex_pr__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_complex_pr(PyObject *, PyObject *);
+
+// LORESModel method calculateIQ(iq)
+extern char pypointsmodelpy_get_lores_iq__name__[];
+extern char pypointsmodelpy_get_lores_iq__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_lores_iq(PyObject *, PyObject *);
+
+// LORESModel method CalculateIQ(q)
+extern char pypointsmodelpy_get_lores_i__name__[];
+extern char pypointsmodelpy_get_lores_i__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_lores_i(PyObject *, PyObject *);
+
+// ComplexModel method CalculateIQ(q)
+extern char pypointsmodelpy_get_complex_i__name__[];
+extern char pypointsmodelpy_get_complex_i__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_complex_i(PyObject *, PyObject *);
+
+// ComplexModel method CalculateIQError(q)
+extern char pypointsmodelpy_get_complex_i_error__name__[];
+extern char pypointsmodelpy_get_complex_i_error__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_complex_i_error(PyObject *, PyObject *);
+
+// method calculateIQ_2D(iq,theta)
+extern char pypointsmodelpy_calculateIQ_2D__name__[];
+extern char pypointsmodelpy_calculateIQ_2D__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_calculateIQ_2D(PyObject *, PyObject *);
+
+// method calculateI_Qxy(Qx,Qy)
+extern char pypointsmodelpy_calculateI_Qxy__name__[];
+extern char pypointsmodelpy_calculateI_Qxy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_calculateI_Qxy(PyObject *, PyObject *);
+
+// method calculateI_Qvxy(points,Qx,Qy)
+extern char pypointsmodelpy_calculateI_Qvxy__name__[];
+extern char pypointsmodelpy_calculateI_Qvxy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_calculateI_Qvxy(PyObject *, PyObject *);
+
+// PDBModel method calculateIQ(iq)
+extern char pypointsmodelpy_get_pdb_iq__name__[];
+extern char pypointsmodelpy_get_pdb_iq__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_pdb_iq(PyObject *, PyObject *);
+
+// PDBModel method calculateIQ_2D(qx,qy)
+extern char pypointsmodelpy_get_pdb_Iqxy__name__[];
+extern char pypointsmodelpy_get_pdb_Iqxy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_pdb_Iqxy(PyObject *, PyObject *);
+
+// PDBModel method calculateIQ_2D(pts,qx,qy)
+extern char pypointsmodelpy_get_pdb_Iqvxy__name__[];
+extern char pypointsmodelpy_get_pdb_Iqvxy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_pdb_Iqvxy(PyObject *, PyObject *);
+
+// ComplexModel method calculateIQ_2D(pts,qx,qy)
+extern char pypointsmodelpy_get_complex_Iqxy__name__[];
+extern char pypointsmodelpy_get_complex_Iqxy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_complex_Iqxy(PyObject *, PyObject *);
+
+// ComplexModel method calculateIQ_2D_Error(pts,qx,qy)
+extern char pypointsmodelpy_get_complex_Iqxy_err__name__[];
+extern char pypointsmodelpy_get_complex_Iqxy_err__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_complex_Iqxy_err(PyObject *, PyObject *);
+
+// ComplexModel method calculateIQ(iq)
+extern char pypointsmodelpy_get_complex_iq__name__[];
+extern char pypointsmodelpy_get_complex_iq__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_get_complex_iq(PyObject *, PyObject *);
+
+// method outputPR
+extern char pypointsmodelpy_outputPR__name__[];
+extern char pypointsmodelpy_outputPR__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_outputPR(PyObject *, PyObject *);
+
+//method get_pr()
+extern char pypointsmodelpy_getPR__name__[];
+extern char pypointsmodelpy_getPR__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_getPR(PyObject *, PyObject *);
+
+
+// method outputPR_xy
+extern char pypointsmodelpy_outputPR_xy__name__[];
+extern char pypointsmodelpy_outputPR_xy__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_outputPR_xy(PyObject *, PyObject *);
+
+// PDBModel method outputPR
+extern char pypointsmodelpy_save_pdb_pr__name__[];
+extern char pypointsmodelpy_save_pdb_pr__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_save_pdb_pr(PyObject *, PyObject *);
+
+// ComplexModel method outputPR
+extern char pypointsmodelpy_save_complex_pr__name__[];
+extern char pypointsmodelpy_save_complex_pr__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_save_complex_pr(PyObject *, PyObject *);
+
+// method outputPDB
+extern char pypointsmodelpy_outputPDB__name__[];
+extern char pypointsmodelpy_outputPDB__doc__[];
+extern "C"
+PyObject * pypointsmodelpy_outputPDB(PyObject *, PyObject *);
+
+#endif
+
+// version
+// $Id$
+
+// End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/pointsmodelpymodule.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/pointsmodelpymodule.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/pointsmodelpymodule/pointsmodelpymodule.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//                               Michael A.G. Aivazis
+//                        California Institute of Technology
+//                        (C) 1998-2005  All Rights Reserved
+// 
+//  <LicenseText>
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+//#include <portinfo>
+
+#include <Python.h>
+
+#include "exceptions.h"
+#include "bindings.h"
+
+
+char pypointsmodelpy_module__doc__[] = "";
+
+// Initialization function for the module (*must* be called initpointsmodelpy)
+extern "C"
+void
+initpointsmodelpy()
+{
+    // create the module and add the functions
+    PyObject * m = Py_InitModule4(
+        "pointsmodelpy", pypointsmodelpy_methods,
+        pypointsmodelpy_module__doc__, 0, PYTHON_API_VERSION);
+
+    // get its dictionary
+    PyObject * d = PyModule_GetDict(m);
+
+    // check for errors
+    if (PyErr_Occurred()) {
+        Py_FatalError("can't initialize module pointsmodelpy");
+    }
+
+    // install the module exceptions
+    pypointsmodelpy_runtimeError = PyErr_NewException("pointsmodelpy.runtime", 0, 0);
+    PyDict_SetItemString(d, "RuntimeException", pypointsmodelpy_runtimeError);
+
+    return;
+}
+
+// version
+// $Id$
+
+// End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/Make.mm
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/Make.mm	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,61 @@
+# -*- Makefile -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+#
+# <LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+PROJECT = pointsmodelpy
+PACKAGE = tests
+
+PROJ_CLEAN += $(PROJ_CPPTESTS)
+
+PROJ_CXX_INCLUDES += ../../iqPy/libiqPy   \
+                     ../../iqPy/libiqPy/tnt \
+                     ../../geoshapespy/libgeoshapespy   \
+                     ../../analmodelpy/libanalmodelpy   \
+		     ../libpointsmodelpy
+
+PROJ_PYTESTS = signon.py
+PROJ_CPPTESTS = testlores \
+                testpdb  \
+                testcomplexmodel
+PROJ_TESTS = $(PROJ_PYTESTS) $(PROJ_CPPTESTS)
+PROJ_LIBRARIES = -L$(BLD_LIBDIR) -lpointsmodelpy -lgeoshapespy -liqPy
+
+
+#--------------------------------------------------------------------------
+#
+
+all: $(PROJ_TESTS)
+
+test:
+	for test in $(PROJ_TESTS) ; do $${test}; done
+
+release: tidy
+	cvs release .
+
+update: clean
+	cvs update .
+
+#--------------------------------------------------------------------------
+#
+
+testlores: testlores.cc $(BLD_LIBDIR)/libpointsmodelpy.$(EXT_SAR)
+	$(CXX) $(CXXFLAGS) $(LCXXFLAGS) -g -o $@ testlores.cc $(PROJ_LIBRARIES)
+
+testpdb: testpdb.cc $(BLD_LIBDIR)/libpointsmodelpy.$(EXT_SAR)
+	$(CXX) $(CXXFLAGS) $(LCXXFLAGS) -g -o $@ testpdb.cc $(PROJ_LIBRARIES)
+
+testcomplexmodel: testcomplexmodel.cc $(BLD_LIBDIR)/libpointsmodelpy.$(EXT_SAR)
+	$(CXX) $(CXXFLAGS) $(LCXXFLAGS) -g -o $@ testcomplexmodel.cc $(PROJ_LIBRARIES)
+
+# version
+# $Id$
+
+# End of file
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/signon.py
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/signon.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/signon.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# 
+#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# 
+#                               Michael A.G. Aivazis
+#                        California Institute of Technology
+#                        (C) 1998-2005  All Rights Reserved
+# 
+#  <LicenseText>
+# 
+#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# 
+
+if __name__ == "__main__":
+
+    import pointsmodelpy
+    from pointsmodelpy import pointsmodelpy as pointsmodelpymodule
+
+    print "copyright information:"
+    print "   ", pointsmodelpy.copyright()
+    print "   ", pointsmodelpymodule.copyright()
+
+    print
+    print "module information:"
+    print "    file:", pointsmodelpymodule.__file__
+    print "    doc:", pointsmodelpymodule.__doc__
+    print "    contents:", dir(pointsmodelpymodule)
+
+    print
+    print pointsmodelpymodule.hello()
+
+# version
+__id__ = "$Id$"
+
+#  End of file 
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/test.pdb
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/test.pdb	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/test.pdb	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,10 @@
+REMARK FILENAME="if0.pdb"
+REMARK  TOPH19.pep -MACRO for protein sequence
+REMARK DATE:17-Aug-02  11:05:39       created by user:
+ATOM      1  CB  SER     1      -1.115 -11.617 -11.368
+ATOM      2  OG  SER     1       0.202 -11.845 -10.894  1.00 54.67          
+ATOM      3  C   SER     1      -2.076 -12.837  -9.369  1.00 44.10          
+ATOM      4  O   SER     1      -3.108 -12.947  -8.704  1.00 43.77          
+ATOM      5  N   SER     1      -3.465 -12.399 -11.363  1.00 83.41          
+ATOM      6  CA  SER     1      -2.108 -12.709 -10.900  1.00 57.67          
+END
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/test2.pdb
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/test2.pdb	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/test2.pdb	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,7 @@
+ATOM      1  CB  SER     1      -1.115 -11.617 -11.368  1.00 52.49
+ATOM      2  OG  SER     1       0.202 -11.845 -10.894  1.00 54.67
+ATOM      3  C   SER     1      -2.076 -12.837  -9.369  1.00 44.10
+ATOM      4  O   SER     1      -3.108 -12.947  -8.704  1.00 43.77
+ATOM      5  N   SER     1      -3.465 -12.399 -11.363  1.00 83.41
+ATOM      6  CA  SER     1      -2.108 -12.709 -10.900  1.00 57.67
+END
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/test2dui.py
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/test2dui.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/test2dui.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+"""
+Demonstration of drawing a 2D image plot using the "hot" colormap
+"""
+
+#--------------------------------------------------------------------------------
+#  Imports:
+#--------------------------------------------------------------------------------
+
+import wx
+
+from enthought.traits import Any, Instance
+from enthought.enable.wx     import Window
+from enthought.pyface        import ApplicationWindow, GUI
+from enthought.util.numerix  import pi, concatenate, array, zeros, ones, \
+                                    arange, resize, ravel
+from enthought.util.numerix import Float as NumericFloat
+from math import sqrt, sin
+
+from enthought.chaco.plot_component import PlotComponent
+from enthought.chaco.plot_axis import PlotAxis
+from enthought.chaco.plot_canvas import PlotCanvas
+from enthought.chaco.plot_group import PlotGroup
+from enthought.chaco.image_plot_value import ImageData, CmapImagePlotValue
+from enthought.chaco.colormap import LinearColormap
+from enthought.chaco.colormap_legend import ColormapLegend
+from enthought.chaco.default_colormaps import hot, gray
+from enthought.chaco.demo.demo_base import PlotApplicationWindow
+
+
+class ImagePlotApplicationWindow( PlotApplicationWindow ):
+
+    ###########################################################################
+    # PlotApplicationWindow interface.
+    ###########################################################################
+    
+    def _create_plot( self ):
+        """ Create the plot to be displayed. """
+        
+        # Create the image data and the index values
+        #value_grid = zeros((100,100), NumericFloat)
+        from testlores2d import get2d_2        
+        value_grid = get2d_2()
+        #self._compute_function(value_grid)
+        index_vals = (arange(value_grid.shape[0]), arange(value_grid.shape[1]))
+
+        data = ImageData(value_grid, index_vals)
+        print value_grid, index_vals
+        
+        # Create the index axes
+        xaxis = PlotAxis(tick_visible=False, grid_visible=False)
+                        # bound_low = index_vals[0][0], bound_high = index_vals[0][-1])
+        yaxis = PlotAxis(tick_visible=False, grid_visible=False)
+                     #bound_low = index_vals[1][0], bound_high = index_vals[1][-1])
+        xaxis.visible = False
+        yaxis.visible = False
+        
+        # Create the value axis (i.e. colormap)
+        cmap = hot(0,1)
+                
+        # Create the Image PlotValue
+#        image = CmapImagePlotValue(data, cmap, axis_index = xaxis, axis = yaxis, type='image')
+        image = CmapImagePlotValue(data, cmap,type='image')
+        image.weight = 10
+        
+        cmap_legend = ColormapLegend(cmap, margin_width=31, margin_height=31)
+        cmap_legend.weight = 0.4
+        
+        group = PlotGroup(cmap_legend, image, orientation='horizontal')
+
+        return group
+
+    ###########################################################################
+    # Private interface.
+    ###########################################################################
+
+    def _compute_function(self, ary):
+        "Fills in ary with the sin(r)/r function"
+        
+        width, height = ary.shape
+        for i in range(width):
+            for j in range(height):
+                x = i - width / 2.0
+                x = x / (width/2.0) * 15
+                y = j - height / 2.0
+                y = y / (height/2.0) * 15
+                
+                radius = sqrt(x*x + y*y)
+                if radius == 0.0:
+                    ary[i,j] = 1
+                else:
+                    ary[i,j] = sin(radius) / radius
+
+        return
+    
+def main():
+
+    # Create the GUI (this does NOT start the GUI event loop).
+    gui = GUI()
+
+    # Screen size:
+    screen_width = gui.system_metrics.screen_width or 1024
+    screen_height = gui.system_metrics.screen_height or 768
+
+    # Create and open the main window.
+    window = ImagePlotApplicationWindow( title = "Plot" )
+    #window.plot_item = object
+    window.size = ( 2 * screen_width / 3, 2 * screen_height / 3 )
+    window.open()
+    
+    # Start the GUI event loop.
+    gui.start_event_loop()
+
+
+#=============================================================================== 
+#  Program start-up:
+#=============================================================================== 
+
+if __name__ == '__main__':
+    main()
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,41 @@
+#include "complex_model.h"
+#include "lores_model.h"
+#include "sphere.h"
+#include "pdb_model.h"
+#include <vector>
+#include "Point3D.h"
+#include <string>
+
+int main(){
+
+  //Get a few points from a lores model
+  vector<Point3D> vplores;
+  LORESModel lm(0.1);
+  Sphere s1(10);
+  lm.Add(s1,1);
+  lm.GetPoints(vplores);
+  
+  //get a few points from a pdb model
+  vector<Point3D> vppdb;
+  string pdbfile("ff0.pdb");
+  PDBModel p1;
+  p1.AddPDB(pdbfile);
+  p1.GetPoints(vppdb);
+  //should be error,argument vector has to be empty
+  //p1.GetPoints(vppdb);
+
+  //merge points
+  vector<Point3D> vptotal;
+  ComplexModel cm;
+  cm.Add(&lm);
+  cm.Add(&p1);
+  cout << "boundary"<< cm.GetDimBound() <<endl;
+
+  cm.GetPoints(vptotal);
+
+  cm.DistDistribution(vptotal);
+  cm.OutputPR("testcomplexcc.pr");
+  //pm.AddPoints(vptotal,vplores,vppdb);
+
+  return 0;
+}
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.py
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,119 @@
+from sasModeling.pointsmodelpy import pointsmodelpy
+from sasModeling.iqPy import iqPy
+from sasModeling.geoshapespy import geoshapespy
+
+#First testing: a normal case, a lores model holds a sphere
+#and a pdbmodel holds one pdb file. and merged into a complex
+#model, then perform calculation
+def test_complex():
+    p = pointsmodelpy.new_pdbmodel()
+    pointsmodelpy.pdbmodel_add(p,"ff0.pdb")
+
+    vp = pointsmodelpy.new_point3dvec()
+    pointsmodelpy.get_pdbpoints(p,vp);
+
+    pointsmodelpy.get_pdb_pr(p,vp)
+    pointsmodelpy.save_pdb_pr(p,"testcomplex.pr")
+
+    iq = iqPy.new_iq(100,0.001, 0.3)
+    pointsmodelpy.get_pdb_iq(p,iq)
+
+    iqPy.OutputIQ(iq,"testcomplex.iq")
+
+    a = geoshapespy.new_sphere(10)
+    lm = pointsmodelpy.new_loresmodel(0.1)
+    pointsmodelpy.lores_add(lm,a,1.0)
+
+    vpcomplex = pointsmodelpy.new_point3dvec();
+    complex = pointsmodelpy.new_complexmodel()
+    pointsmodelpy.complexmodel_add(complex,p,"PDB");
+    pointsmodelpy.complexmodel_add(complex,lm,"LORES");
+    
+    pointsmodelpy.get_complexpoints(complex,vpcomplex);
+    pointsmodelpy.get_complex_pr(complex,vpcomplex);
+    pointsmodelpy.save_complex_pr(complex,"testcomplex1.pr");
+
+    iqcomplex = iqPy.new_iq(100,0.001, 0.3)
+    pointsmodelpy.get_complex_iq(complex,iqcomplex);
+
+    iqPy.OutputIQ(iq,"testcomplex1.iq")
+
+#testing 2, insert one pdbmodel and one empty loresmodel
+def test_complex2():
+  pdb = pointsmodelpy.new_pdbmodel()
+  pointsmodelpy.pdbmodel_add(pdb,"ff0.pdb")
+
+  lores = pointsmodelpy.new_loresmodel(0.1)
+
+  complex = pointsmodelpy.new_complexmodel()	
+  pointsmodelpy.complexmodel_add(complex,pdb,"PDB");
+  pointsmodelpy.complexmodel_add(complex,lores,"LORES")
+
+  points = pointsmodelpy.new_point3dvec()
+  pointsmodelpy.get_complexpoints(complex,points)
+
+  pointsmodelpy.get_complex_pr(complex,points);
+  pointsmodelpy.save_complex_pr(complex,"testcomplex2.pr")
+
+  iqcomplex = iqPy.new_iq(100,0.001, 0.3)
+  pointsmodelpy.get_complex_iq(complex,iqcomplex)
+
+  iqPy.OutputIQ(iqcomplex,"testcomplex2.iq")
+
+  print "p(r) is saved in testcomplex2.pr"
+  print "I(Q) is saved in testcomplex2.iq"
+  print "pass"
+
+#testing 3, insert one empty pdbmodel and one loresmodel
+def test_complex3():
+  pdb = pointsmodelpy.new_pdbmodel()
+
+  lores = pointsmodelpy.new_loresmodel(0.1)
+  sph = geoshapespy.new_sphere(10)
+  pointsmodelpy.lores_add(lores,sph,1.0)
+
+  complex = pointsmodelpy.new_complexmodel()	
+  pointsmodelpy.complexmodel_add(complex,pdb,"PDB");
+  pointsmodelpy.complexmodel_add(complex,lores,"LORES")
+
+  points = pointsmodelpy.new_point3dvec()
+  pointsmodelpy.get_complexpoints(complex,points)
+
+  pointsmodelpy.get_complex_pr(complex,points);
+  pointsmodelpy.save_complex_pr(complex,"testcomplex3.pr")
+
+  iqcomplex = iqPy.new_iq(100,0.001, 0.3)
+  pointsmodelpy.get_complex_iq(complex,iqcomplex)
+
+  iqPy.OutputIQ(iqcomplex,"testcomplex3.iq")
+
+  print "p(r) is saved in testcomplex3.pr"
+  print "I(Q) is saved in testcomplex3.iq"
+  print "pass"
+
+# Test 2D complex model
+def test_complex4():
+
+
+    a = geoshapespy.new_sphere(10)
+    lm = pointsmodelpy.new_loresmodel(0.1)
+    pointsmodelpy.lores_add(lm,a,1.0)
+
+    vpcomplex = pointsmodelpy.new_point3dvec();
+    complex = pointsmodelpy.new_complexmodel()
+    pointsmodelpy.complexmodel_add(complex,lm,"LORES");
+    
+    pointsmodelpy.get_complexpoints(complex,vpcomplex);
+ 
+    print pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.1,0.1);
+    print pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.01,0.1);
+
+
+if __name__ == "__main__":
+    #print "test 1, adding one nonempty loresmodel and one nonempty pdbmodel to complex model"
+    #test_complex()
+    #print "test 2, adding a nonempty pdbmodel, and adding an empty loresmodel"
+    #test_complex2()
+    #print "test 3, adding an empty pdbmodel, and adding a nonempty loresmodel"
+    #test_complex3()
+    test_complex4()
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,209 @@
+#include <cstdlib>
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include "lores_model.h"
+#include "sphere.h"
+#include "cylinder.h"
+#include "ellipsoid.h"
+#include "Point3D.h"
+
+using namespace std;
+
+void test_calculateIQ(LORESModel &lm);
+
+void WritePointsCoor(vector<Point3D> &vp){
+  ofstream outfile("testcc.coor");
+  for(size_t i=0; i<vp.size(); ++i){
+    outfile<<vp[i].getX()<<" "<<vp[i].getY()<<" "<<vp[i].getZ()<<" "<<1.0<<endl;
+  }
+}
+
+void test_lores(){
+
+  LORESModel lm(0.5);
+  cout << "density is:" << lm.GetDensity() << endl;
+   
+  Sphere s1(10);
+  s1.SetOrientation(10,10,20);
+  s1.SetCenter(10,10,10);
+  lm.Add(s1,1.0);
+   
+  Cylinder c1(5,20);
+  c1.SetCenter(0,0,0);
+  c1.SetOrientation(10,20,30);
+  lm.Add(c1,1.0);
+  
+  /*
+  Cylinder c2(40,100);
+  c2.SetCenter(-30,-40,-35);
+  lm.Add(c2,1.0);
+  */
+  /*
+  Ellipsoid e1(20,15,10);
+  e1.SetCenter(0,0,0);
+  e1.SetOrientation(10,10,20);
+  lm.Add(e1,1.0);
+  */
+  /*test multiple spheres
+  int range = 20;
+  int r = 5;
+  for (int k = 0; k < 1000; ++k) {
+    Sphere s(r + rand() % r);
+    s.SetCenter(rand() % range, rand() % range, rand() % range);
+    lm.Add(s, 1.0);
+  }
+  */
+  /*
+  Sphere s1(10);
+  cout << "sphere information:" << s1.GetVolume() << " " << s1.GetRadius() <<endl;
+  s1.SetOrientation(10,20,10);
+  s1.SetCenter(1,5,2);
+  lm.Add(s1,1.0); 
+
+  Sphere s2(15);
+  s2.SetCenter(20,20,20);
+  lm.Add(s2,2.0);
+
+  Sphere s3(5);
+  s3.SetCenter(0,0,0);
+  lm.Add(s3,2.0);
+
+  Sphere s4(5);
+  s4.SetCenter(0,0,10);
+  lm.Add(s4,2.0);
+
+  Sphere s5(10);
+  s5.SetCenter(20,0,0);
+  lm.Add(s5,2.0);
+  */
+
+  test_calculateIQ(lm);
+}
+
+void test_calculateIQ(LORESModel &lm){
+
+  IQ iq1(10,0.001,0.3);
+  cout << "iq information:" << iq1.GetQmin() <<endl;
+
+  vector<Point3D> vp;
+  lm.GetPoints(vp);
+  WritePointsCoor(vp);
+  cout << "vp size:" <<vp.size()<<endl;
+  cout << "save into pdb file" << endl;
+  lm.OutputPDB(vp,"model.pdb");
+
+  //  for (vector<Point3D>::iterator iter = vp.begin(); 
+  //     iter != vp.end(); ++iter){
+  //  cout << *iter << endl;
+  //}
+
+  lm.DistDistribution(vp);
+  Array2D<double> pr(lm.GetPr());
+  //for(int i = 0; i< pr.dim1(); ++i)
+  //  cout << pr[i][0] << " " << pr[i][1] << " " << pr[i][2] << endl;
+  lm.OutputPR("test.pr");
+  cout << "pass ddfunction, and print out the pr file" <<endl;
+
+  lm.CalculateIQ(&iq1); 
+  cout <<"I(Q): \n" ;
+  //for (int i = 0; i< iq1.iq_data.dim1(); i++)
+  //  cout << iq1.iq_data[i][0]<< " " << iq1.iq_data[i][1] <<endl;
+}
+
+void test_lores2d(){
+
+  LORESModel lm(0.1);
+
+  Cylinder c1(5,20);
+  c1.SetCenter(0,0,0);
+  c1.SetOrientation(10,20,30);
+  lm.Add(c1,1.0);
+
+  vector<Point3D> vp;
+  lm.GetPoints(vp);
+
+  lm.DistDistributionXY(vp);
+  lm.OutputPR_XY("test2d.pr");
+
+  IQ iq(10,0.001,0.3);
+  lm.CalculateIQ_2D(&iq,10);
+
+  iq.OutputIQ("test2d.iq");
+}
+
+void test_lores2d_qxqy(){
+
+  LORESModel lm(0.1);
+
+  Cylinder c1(5,20);
+  c1.SetCenter(0,0,0);
+  c1.SetOrientation(10,20,30);
+  lm.Add(c1,1.0);
+
+  vector<Point3D> vp;
+  lm.GetPoints(vp);
+
+  lm.DistDistributionXY(vp);  
+
+  double aI = lm.CalculateIQ_2D(0.1,0.2);
+
+  cout << " a single I is: "<<aI<<" at Qx,Qy = 0.1,0.2" <<endl;
+}
+
+void test_GetCenter()
+{
+  LORESModel lm(0.1);
+
+  Sphere s1(10);
+  s1.SetCenter(-1,-1,-1);
+  Sphere s2(20);
+  s2.SetCenter(1,1,1);
+
+  lm.Add(s1,1.0);
+  lm.Add(s2,1.0);
+
+  vector<double> center(3);
+  center = lm.GetCenter();
+
+  cout << "center should be (0,0,0) after adding two spheres:"<<endl;
+  cout << center[0] <<" "<< center[1] <<" "<< center[2]<<endl;
+
+}
+
+void test_CalSingleI(){
+  LORESModel lm(0.1);
+
+  Cylinder cyn(10,40);  
+
+  lm.Add(cyn,1.0);
+
+  vector<Point3D> vp;
+  lm.GetPoints(vp);
+
+  lm.DistDistribution(vp);
+
+  double result = lm.CalculateIQ(0.1);
+  cout << "The I(0.1) is: " << result << endl;      
+}
+
+int main(){
+
+  printf("this\n");
+  cout << "Start" << endl;
+  //test_lores();
+  cout <<"testing DistDistributionXY"<<endl;
+  test_lores2d();
+
+  cout <<"testing GetCenter (center of the list of shapes)"<<endl;
+  test_GetCenter();
+
+  cout <<"testing calculate_2d(Qx,Qy)"<<endl;
+  test_lores2d_qxqy();
+  cout << "Pass" << endl;
+
+  cout <<"testing CalculateIQ(q)"<<endl;
+  test_CalSingleI();
+
+  return 0;
+}
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.py
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,63 @@
+if __name__ == "__main__":
+
+    from sasModeling.iqPy import iqPy
+    #from sasModeling.analmodelpy import analmodelpy as analmodelpymodule
+    from sasModeling.geoshapespy import geoshapespy
+    from sasModeling.pointsmodelpy import pointsmodelpy
+
+#    print "copyright information:"
+#    print "   ", pointsmodelpy.copyright()
+#    print "   ", pointsmodelpymodule.copyright()
+
+    print
+    print "module information:"
+    print "    file:", pointsmodelpy.__file__
+    print "    doc:", pointsmodelpy.__doc__
+    print "    contents:", dir(pointsmodelpy)
+    print "    contents:", dir(geoshapespy)
+
+#    a = geoshapespy.new_singlehelix(10,2,30,2)
+    #a = geoshapespy.new_sphere(20)
+    
+    iq = iqPy.new_iq(100,0.001, 0.3)
+
+#    geoshapespy.set_orientation(a,20,40,60)
+#    geoshapespy.set_center(a,0,0,0)
+    lm = pointsmodelpy.new_loresmodel(0.1)
+#    pointsmodelpy.lores_add(lm,a,1.0)
+
+#    b = geoshapespy.new_sphere(15)
+#    geoshapespy.set_center(b,15,15,15)
+#    pointsmodelpy.lores_add(lm,b,2.0)
+
+    
+    c = geoshapespy.new_cylinder(10,40)
+    geoshapespy.set_center(c,1,1,1)
+    geoshapespy.set_orientation(c,0,0,0)
+    pointsmodelpy.lores_add(lm,c,3.0)
+    
+#    d = geoshapespy.new_ellipsoid(10,8,6)
+#    geoshapespy.set_center(d,3,3,3)
+#    geoshapespy.set_orientation(c,30,30,30)
+#    pointsmodelpy.lores_add(lm,d,1.0)
+
+    vp = pointsmodelpy.new_point3dvec()
+    pointsmodelpy.get_lorespoints(lm,vp)
+    pointsmodelpy.outputPDB(lm,vp,"modelpy.pseudo.pdb")
+
+    print "calculating distance distribution"
+    rmax = pointsmodelpy.get_lores_pr(lm,vp)
+    print "finish calculating get_lores_pr, and rmax is:", rmax
+    pointsmodelpy.outputPR(lm,"testlores.pr")
+    pointsmodelpy.get_lores_iq(lm,iq)
+
+    iqPy.OutputIQ(iq, "testlores.iq")
+
+    print "Testing get I from a single q"
+    result = pointsmodelpy.get_lores_i(lm,0.1)
+    print "The I(0.1) is: %s" % str(result) 
+
+# version
+__id__ = "$Id$"
+
+#  End of file 
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/testlores2d.py
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/testlores2d.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/testlores2d.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,115 @@
+def test_lores2d(phi):
+  from sasModeling.pointsmodelpy import pointsmodelpy 
+  from sasModeling.iqPy import iqPy
+  from sasModeling.geoshapespy import geoshapespy
+
+  #lores model is to hold several geometric objects
+  lm = pointsmodelpy.new_loresmodel(0.1)
+
+  #generate single geometry shape
+  c = geoshapespy.new_cylinder(10,40)
+  geoshapespy.set_center(c,1,1,1)
+  geoshapespy.set_orientation(c,0,0,0)
+
+  #add single geometry shape to lores model
+  pointsmodelpy.lores_add(lm,c,3.0)
+
+  #retrieve the points from lores model for sas calculation
+  vp = pointsmodelpy.new_point3dvec()
+  pointsmodelpy.get_lorespoints(lm,vp)
+
+  #Calculate I(Q) and P(r) 2D
+  pointsmodelpy.distdistribution_xy(lm,vp)
+  pointsmodelpy.outputPR_xy(lm,"out_xy.pr")
+  iq = iqPy.new_iq(100,0.001, 0.3)
+  pointsmodelpy.calculateIQ_2D(lm,iq,phi)
+  iqPy.OutputIQ(iq, "out_xy.iq")
+
+def get2d():
+  from math import pi
+  from Numeric import arange,zeros
+  from enthought.util.numerix import Float,zeros
+  from sasModeling.file2array import readfile2array
+  from sasModeling.pointsmodelpy import pointsmodelpy
+  from sasModeling.geoshapespy import geoshapespy
+
+  lm = pointsmodelpy.new_loresmodel(0.1)
+  sph = geoshapespy.new_sphere(20)
+  pointsmodelpy.lores_add(lm,sph,1.0)
+
+  vp = pointsmodelpy.new_point3dvec()
+  pointsmodelpy.get_lorespoints(lm,vp)
+
+  pointsmodelpy.distdistribution_xy(lm,vp)
+
+  value_grid = zeros((100,100),Float)
+  width, height = value_grid.shape
+  print width,height
+
+  I = pointsmodelpy.calculateI_Qxy(lm,0.00001,0.000002)
+  print I
+
+  Imax = 0
+  for i in range(width):
+    for j in range(height):
+      qx = float(i-50)/200.0
+      qy = float(j-50)/200.0
+      value_grid[i,j] = pointsmodelpy.calculateI_Qxy(lm,qx,qy)
+      if value_grid[i][j] > Imax:
+        Imax = value_grid[i][j]
+
+  for i in range(width):
+    for j in range(height):
+      value_grid[i][j] = value_grid[i][j]/Imax
+
+  value_grid[50,50] = 1
+  return value_grid
+
+def get2d_2():
+  from math import pi
+  from Numeric import arange,zeros
+  from enthought.util.numerix import Float,zeros
+  from sasModeling.file2array import readfile2array
+  from sasModeling.pointsmodelpy import pointsmodelpy
+  from sasModeling.geoshapespy import geoshapespy
+
+  lm = pointsmodelpy.new_loresmodel(0.1)
+  cyn = geoshapespy.new_cylinder(5,20)
+  geoshapespy.set_orientation(cyn,0,0,90)
+  pointsmodelpy.lores_add(lm,cyn,1.0)
+
+  vp = pointsmodelpy.new_point3dvec()
+  pointsmodelpy.get_lorespoints(lm,vp)
+
+  pointsmodelpy.distdistribution_xy(lm,vp)
+
+  value_grid = zeros((100,100),Float)
+  width, height = value_grid.shape
+  print width,height
+
+  I = pointsmodelpy.calculateI_Qxy(lm,0.00001,0.000002)
+  print I
+
+  Imax = 0
+  for i in range(width):
+    for j in range(height):
+      qx = float(i-50)/200.0
+      qy = float(j-50)/200.0
+      value_grid[i,j] = pointsmodelpy.calculateI_Qxy(lm,qx,qy)
+      if value_grid[i][j] > Imax:
+        Imax = value_grid[i][j]
+
+  for i in range(width):
+    for j in range(height):
+      value_grid[i][j] = value_grid[i][j]/Imax
+
+  value_grid[50,50] = 1
+  return value_grid
+  
+if __name__ == "__main__":
+
+  print "start to test lores 2D"
+#  test_lores2d(10)
+  value_grid = get2d_2()
+  print value_grid
+  print "pass"
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/testnegativepr.py
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/testnegativepr.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/testnegativepr.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,16 @@
+if __name__ == "__main__":
+  from sasModeling.pointsmodelpy import pointsmodelpy
+  from sasModeling.iqPy import iqPy
+  from sasModeling.geoshapespy import geoshapespy
+
+  a = geoshapespy.new_sphere(10)
+  lm = pointsmodelpy.new_loresmodel(0.0005)
+  pointsmodelpy.lores_add(lm,a,1.0)
+  b = geoshapespy.new_sphere(20)
+  geoshapespy.set_center(b,20,20,20)
+  pointsmodelpy.lores_add(lm,b,-1.0)
+
+  vp = pointsmodelpy.new_point3dvec()
+  pointsmodelpy.get_lorespoints(lm,vp)
+
+  pointsmodelpy.get_lores_pr(lm,vp)
Index: src/sas/sascalc/simulation/pointsmodelpy/tests/testpdb.cc
===================================================================
--- src/sas/sascalc/simulation/pointsmodelpy/tests/testpdb.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sascalc/simulation/pointsmodelpy/tests/testpdb.cc	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -0,0 +1,42 @@
+#include "pdb_model.h"
+#include "Point3D.h"
+#include <vector>
+#include <string>
+#include "iq.h"
+
+typedef vector<Point3D> PointsVector;
+
+int main(){
+
+  //Test PDB with adding one normal pdb file
+  PointsVector vp;
+  IQ iq(100,0.001,0.3);
+
+  string name("test.pdb");
+
+  //initialize a PDBModel with a pdb file name
+  PDBModel mpdb;
+  mpdb.AddPDB(name);
+  //parse coordinates in pdb file into a vector
+  //of points
+  mpdb.GetPoints(vp);
+  //output the vector of points into a pseudo pdb
+  //file, for testing only
+  mpdb.OutputPDB(vp,"testpdb.pdb");
+  mpdb.DistDistribution(vp);
+  mpdb.OutputPR("test.pr");
+  mpdb.CalculateIQ(&iq);
+  iq.OutputIQ("test.iq");
+  cout << "check test.pr and test.iq files" <<endl;
+
+
+  //second test: add second pdb file
+  vector<Point3D> vp2;
+  string second("test2.pdb");
+  mpdb.AddPDB(second);
+  mpdb.GetPoints(vp2);
+  mpdb.OutputPDB(vp2,"testpdb2.pdb");
+  cout <<"check whether testpdb2.pdb has 12 points" <<endl;
+
+  return 0;
+}
