<commit_before>#ifndef STAN_MATH_PRIM_PROB_ORDERED_PROBIT_LPMF_HPP
#define STAN_MATH_PRIM_PROB_ORDERED_PROBIT_LPMF_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/log.hpp>
#include <stan/math/prim/fun/log_diff_exp.hpp>
#include <stan/math/prim/fun/log1m_exp.hpp>
#include <stan/math/prim/fun/size_mvt.hpp>
#include <stan/math/prim/fun/to_ref.hpp>
#include <stan/math/prim/prob/std_normal_lcdf.hpp>
#include <vector>
#include <cmath>

namespace stan {
namespace math {

/** \ingroup multivar_dists
 * Returns the (natural) log probability of the specified array
 * of integers given the vector of continuous locations and
 * array of specified cutpoints in an ordered probit model.
 *
 *
Typically the continuous location
 * will be the dot product of a vector of regression coefficients
 * and a vector of predictors for the outcome.
 *
 * @tparam propto True if calculating up to a proportion.
 * @tparam T_y Type of y variable - `int` or `std::vector<int>`.
 * @tparam T_loc Location type - Eigen vector or scalar.
 * @tparam T_cut Cut-point type - Eigen vector or a std vector of Eigen vectors.
 * @param y integer or Array of integers
 * @param lambda Location.
 * @param c Positive increasing vectors of cutpoints.
 * @return Log probability of outcome given location and
 * cutpoints.
 * @throw std::domain_error If the outcome is not between 1 and
 * the number of cutpoints plus 2; if the cutpoint vector contains a
 * non-positive or non-finite value; or if the cutpoint vector is not sorted in
 * ascending order.
 * @throw std::invalid_argument If y and lambda are different
 * lengths; if the cutpoint vector is empty; if y and the array of cutpoints are
 * of different lengths.
 */
template <bool propto, typename T_y, typename T_loc, typename T_cut>
return_type_t<T_loc, T_cut> ordered_probit_lpmf(const T_y& y,
                                                const T_loc& lambda,
                                                const T_cut& c) {
  using std::exp;
  using std::log;
  using T_lambda_ref = ref_type_t<T_loc>;
  static const char* function = "ordered_probit";

  check_nonzero_size(function, "Cut-points", c);
  int N = size(lambda);
  int C_l = size_mvt(c);
  vector_seq_view<T_cut> c_vec(c);
  int K = c_vec[0].size() + 1;

  check_consistent_sizes(function, "Integers", y, "Locations", lambda);
  if (C_l > 1) {
    check_size_match(function, "Length of location variables ", N,
                     "Number of cutpoint vectors ", C_l);
  }

  check_bounded(function, "Random variable", y, 1, K);
  scalar_seq_view<T_y> y_vec(y);
  check_nonzero_size(function, "First cutpoint set", c_vec[0]);
  for (int i = 0; i < size_mvt(c); ++i) {
    check_size_match(function, "One cutpoint set", K - 1, "First cutpoint set",
                     c_vec[i].size());
    check_ordered(function, "Cut-points", c_vec[i]);
    if (K > 2) {
      check_finite(function, "Final cut point", c_vec[i].coeff(K - 2));
    }
    check_finite(function, "First cut point", c_vec[i].coeff(0));
  }

  T_lambda_ref lambda_ref = lambda;
  check_finite(function, "Location parameter", lambda_ref);
  scalar_seq_view<T_lambda_ref> lambda_vec(lambda_ref);

  return_type_t<T_loc, T_cut> logp_n(0.0);

  for (int i = 0; i < N; ++i) {
    int K = c_vec[i].size() + 1;

    if (y_vec[i] == 1) {
      logp_n += log1m_exp(std_normal_lcdf(lambda_vec[i] - c_vec[i].coeff(0)));
    } else if (y_vec[i] == K) {
      logp_n += std_normal_lcdf(lambda_vec[i] - c_vec[i].coeff(K - 2));
    } else {
      logp_n += log_diff_exp(
          std_normal_lcdf(lambda_vec[i] - c_vec[i].coeff(y_vec[i] - 2)),
          std_normal_lcdf(lambda_vec[i] - c_vec[i].coeff(y_vec[i] - 1)));
    }
  }
  return logp_n;
}

template <typename T_y, typename T_loc, typename T_cut>
return_type_t<T_loc, T_cut> ordered_probit_lpmf(const T_y& y,
                                                const T_loc& lambda,
                                                const T_cut& c) {
  return ordered_probit_lpmf<false>(y, lambda, c);
}
}  // namespace math
}  // namespace stan
#endif
<commit_msg>Use lcdf with reversed arguments for y=1<commit_after>#ifndef STAN_MATH_PRIM_PROB_ORDERED_PROBIT_LPMF_HPP
#define STAN_MATH_PRIM_PROB_ORDERED_PROBIT_LPMF_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/log.hpp>
#include <stan/math/prim/fun/log_diff_exp.hpp>
#include <stan/math/prim/fun/log1m_exp.hpp>
#include <stan/math/prim/fun/size_mvt.hpp>
#include <stan/math/prim/fun/to_ref.hpp>
#include <stan/math/prim/prob/std_normal_lcdf.hpp>
#include <vector>
#include <cmath>

namespace stan {
namespace math {

/** \ingroup multivar_dists
 * Returns the (natural) log probability of the specified array
 * of integers given the vector of continuous locations and
 * array of specified cutpoints in an ordered probit model.
 *
 *
Typically the continuous location
 * will be the dot product of a vector of regression coefficients
 * and a vector of predictors for the outcome.
 *
 * @tparam propto True if calculating up to a proportion.
 * @tparam T_y Type of y variable - `int` or `std::vector<int>`.
 * @tparam T_loc Location type - Eigen vector or scalar.
 * @tparam T_cut Cut-point type - Eigen vector or a std vector of Eigen vectors.
 * @param y integer or Array of integers
 * @param lambda Location.
 * @param c Positive increasing vectors of cutpoints.
 * @return Log probability of outcome given location and
 * cutpoints.
 * @throw std::domain_error If the outcome is not between 1 and
 * the number of cutpoints plus 2; if the cutpoint vector contains a
 * non-positive or non-finite value; or if the cutpoint vector is not sorted in
 * ascending order.
 * @throw std::invalid_argument If y and lambda are different
 * lengths; if the cutpoint vector is empty; if y and the array of cutpoints are
 * of different lengths.
 */
template <bool propto, typename T_y, typename T_loc, typename T_cut>
return_type_t<T_loc, T_cut> ordered_probit_lpmf(const T_y& y,
                                                const T_loc& lambda,
                                                const T_cut& c) {
  using std::exp;
  using std::log;
  using T_lambda_ref = ref_type_t<T_loc>;
  static const char* function = "ordered_probit";

  check_nonzero_size(function, "Cut-points", c);
  int N = size(lambda);
  int C_l = size_mvt(c);
  vector_seq_view<T_cut> c_vec(c);
  int K = c_vec[0].size() + 1;

  check_consistent_sizes(function, "Integers", y, "Locations", lambda);
  if (C_l > 1) {
    check_size_match(function, "Length of location variables ", N,
                     "Number of cutpoint vectors ", C_l);
  }

  check_bounded(function, "Random variable", y, 1, K);
  scalar_seq_view<T_y> y_vec(y);
  check_nonzero_size(function, "First cutpoint set", c_vec[0]);
  for (int i = 0; i < size_mvt(c); ++i) {
    check_size_match(function, "One cutpoint set", K - 1, "First cutpoint set",
                     c_vec[i].size());
    check_ordered(function, "Cut-points", c_vec[i]);
    if (K > 2) {
      check_finite(function, "Final cut point", c_vec[i].coeff(K - 2));
    }
    check_finite(function, "First cut point", c_vec[i].coeff(0));
  }

  T_lambda_ref lambda_ref = lambda;
  check_finite(function, "Location parameter", lambda_ref);
  scalar_seq_view<T_lambda_ref> lambda_vec(lambda_ref);

  return_type_t<T_loc, T_cut> logp_n(0.0);

  for (int i = 0; i < N; ++i) {
    int K = c_vec[i].size() + 1;

    if (y_vec[i] == 1) {
      logp_n += std_normal_lcdf(c_vec[i].coeff(0) - lambda_vec[i]);
    } else if (y_vec[i] == K) {
      logp_n += std_normal_lcdf(lambda_vec[i] - c_vec[i].coeff(K - 2));
    } else {
      logp_n += log_diff_exp(
          std_normal_lcdf(lambda_vec[i] - c_vec[i].coeff(y_vec[i] - 2)),
          std_normal_lcdf(lambda_vec[i] - c_vec[i].coeff(y_vec[i] - 1)));
    }
  }
  return logp_n;
}

template <typename T_y, typename T_loc, typename T_cut>
return_type_t<T_loc, T_cut> ordered_probit_lpmf(const T_y& y,
                                                const T_loc& lambda,
                                                const T_cut& c) {
  return ordered_probit_lpmf<false>(y, lambda, c);
}
}  // namespace math
}  // namespace stan
#endif
<|endoftext|>


<commit_before>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: analyticalSES.C,v 1.13 2003/08/26 09:18:27 oliver Exp $
//

#include <BALL/STRUCTURE/analyticalSES.h>
#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/atomContainer.h>

namespace BALL
{

  extern int connolly_ (int number_of_atoms, double *coordinates, double *radius,
												double *volume, double *area, double probe, double exclude, double* atom_areas);

	float calculateSESArea
		(const AtomContainer& fragment, float probe_radius)
	{
		// extract all atoms: iterate over all composites and
		// check whether they are Atoms
		vector<const Atom*>	atoms;
		AtomConstIterator	it = fragment.beginAtom();
		for (; +it; ++it)
		{
			if (it->getRadius() > 0.0)
			{
				atoms.push_back(&*it);
			}
		}

		// if no atoms are found, return zero
		if (atoms.size() == 0)
		{
			return 0;
		}

		// create the field required by nsc and fill it with the atom coordinates
		double* coordinates = new double[atoms.size() * 3];
		double* radii = new double[atoms.size()];
		double* atom_areas = new double[atoms.size()];
		for (Size i = 0; i < atoms.size(); i++)
		{
			float tmp[3];
			atoms[i]->getPosition().get(tmp);
			coordinates[i * 3]			= tmp[0];
			coordinates[i * 3 + 1]	= tmp[1];
			coordinates[i * 3 + 2]	= tmp[2];
			radii[i] = atoms[i]->getRadius();
		}

		double area;
		double volume;
		int number_of_atoms = (int)atoms.size();

		// int connolly_ (int number_of_atoms, double *coordinates, double *radius,
		//								double *volume, double *area, double probe, double exclude, double* atom_areas);
		// call connolly_
		connolly_(number_of_atoms, coordinates, radii,
							&volume, &area, probe_radius, 0.0, atom_areas);

		// free the input fields
		delete [] coordinates;
		delete [] radii;
		delete [] atom_areas;

		return area;
	}

  float calculateSESAtomAreas
		(const AtomContainer& fragment, HashMap<const Atom*,float>& atom_areas, float probe_radius)
	{
		// extract all atoms: iterate over all composites and
		// check whether they are Atoms
		vector<const Atom*>	atoms;
		AtomConstIterator	it = fragment.beginAtom();
		for (; +it; ++it)
		{
			if (it->getRadius() > 0.0)
			{
				atoms.push_back(&*it);
			}
		}

		// if no atoms are found, return zero
		if (atoms.size() == 0)
		{
			return 0;
		}

		// create the field required by nsc and fill it with the atom coordinates
		double* coordinates = new double[atoms.size() * 3];
		double* radii = new double[atoms.size()];
		double* tmp_atom_areas = new double[atoms.size()];
		for (Size i = 0; i < atoms.size(); i++)
		{
			float tmp[3];
			atoms[i]->getPosition().get(tmp);
			coordinates[i * 3]			= tmp[0];
			coordinates[i * 3 + 1]	= tmp[1];
			coordinates[i * 3 + 2]	= tmp[2];
			radii[i] = atoms[i]->getRadius();
		}

		double area;
		double volume;
		int number_of_atoms = (int)atoms.size();

		// call connolly_
		connolly_(number_of_atoms, coordinates, radii,
							&volume, &area, probe_radius, 0.0, tmp_atom_areas);

		// extract the atom areas and store them in the hash map
		atom_areas.clear();
		for (Position i = 0; i < atoms.size(); ++i)
		{
			atom_areas.insert(std::pair<const Atom*, float>(atoms[i], tmp_atom_areas[i]));
		}

		// free the input fields
		delete [] coordinates;
		delete [] radii;
		delete [] tmp_atom_areas;

		return area;
	}

	float calculateSESVolume
		(const AtomContainer& fragment, float probe_radius)
	{
		// extract all atoms: iterate over all composites and
		// check whether they are Atoms
		vector<const Atom*>	atoms;
		AtomConstIterator	it = fragment.beginAtom();
		for (; +it; ++it)
		{
			if (it->getRadius() > 0.0)
			{
				atoms.push_back(&*it);
			}
		}

		// if no atoms are found, return zero
		if (atoms.size() == 0)
		{
			return 0;
		}

		// create the field required by nsc and fill it with the atom coordinates
		double* coordinates = new double[atoms.size() * 3];
		double* radii = new double[atoms.size()];
		double* tmp_atom_areas = new double[atoms.size()];
		for (Size i = 0; i < atoms.size(); i++)
		{
			float tmp[3];
			atoms[i]->getPosition().get(tmp);
			coordinates[i * 3]			= tmp[0];
			coordinates[i * 3 + 1]	= tmp[1];
			coordinates[i * 3 + 2]	= tmp[2];
			radii[i] = atoms[i]->getRadius();
		}

		double area;
		double volume;
		int number_of_atoms = (int)atoms.size();

		// call connolly_
		connolly_(number_of_atoms, coordinates, radii,
							&volume, &area, probe_radius, 0.0, tmp_atom_areas);

		// free the input fields
		delete [] coordinates;
		delete [] radii;
		delete [] tmp_atom_areas;

		return volume;
	}

} // namespace BALL
<commit_msg>*** empty log message ***<commit_after>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: analyticalSES.C,v 1.13.30.1 2007/06/18 06:27:31 oliver Exp $
//
// Author:
//   Oliver Kohlbacher
//

#include <BALL/STRUCTURE/analyticalSES.h>
#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/atomContainer.h>

namespace BALL
{

  extern int connolly_ (int number_of_atoms, double *coordinates, double *radius,
												double *volume, double *area, double probe, double exclude, double* atom_areas);

	float calculateSESArea
		(const AtomContainer& fragment, float probe_radius)
	{
		// extract all atoms: iterate over all composites and
		// check whether they are Atoms
		vector<const Atom*>	atoms;
		AtomConstIterator	it = fragment.beginAtom();
		for (; +it; ++it)
		{
			if (it->getRadius() > 0.0)
			{
				atoms.push_back(&*it);
			}
		}

		// if no atoms are found, return zero
		if (atoms.size() == 0)
		{
			return 0;
		}

		// create the field required by nsc and fill it with the atom coordinates
		double* coordinates = new double[atoms.size() * 3];
		double* radii = new double[atoms.size()];
		double* atom_areas = new double[atoms.size()];
		for (Size i = 0; i < atoms.size(); i++)
		{
			float tmp[3];
			atoms[i]->getPosition().get(tmp);
			coordinates[i * 3]			= tmp[0];
			coordinates[i * 3 + 1]	= tmp[1];
			coordinates[i * 3 + 2]	= tmp[2];
			radii[i] = atoms[i]->getRadius();
		}

		double area;
		double volume;
		int number_of_atoms = (int)atoms.size();

		// int connolly_ (int number_of_atoms, double *coordinates, double *radius,
		//								double *volume, double *area, double probe, double exclude, double* atom_areas);
		// call connolly_
		connolly_(number_of_atoms, coordinates, radii,
							&volume, &area, probe_radius, 0.0, atom_areas);

		// free the input fields
		delete [] coordinates;
		delete [] radii;
		delete [] atom_areas;

		return area;
	}

  float calculateSESAtomAreas
		(const AtomContainer& fragment, HashMap<const Atom*,float>& atom_areas, float probe_radius)
	{
		// extract all atoms: iterate over all composites and
		// check whether they are Atoms
		vector<const Atom*>	atoms;
		AtomConstIterator	it = fragment.beginAtom();
		for (; +it; ++it)
		{
			if (it->getRadius() > 0.0)
			{
				atoms.push_back(&*it);
			}
		}

		// if no atoms are found, return zero
		if (atoms.size() == 0)
		{
			return 0;
		}

		// create the field required by nsc and fill it with the atom coordinates
		double* coordinates = new double[atoms.size() * 3];
		double* radii = new double[atoms.size()];
		double* tmp_atom_areas = new double[atoms.size()];
		for (Size i = 0; i < atoms.size(); i++)
		{
			float tmp[3];
			atoms[i]->getPosition().get(tmp);
			coordinates[i * 3]			= tmp[0];
			coordinates[i * 3 + 1]	= tmp[1];
			coordinates[i * 3 + 2]	= tmp[2];
			radii[i] = atoms[i]->getRadius();
		}

		double area;
		double volume;
		int number_of_atoms = (int)atoms.size();

		// call connolly_
		connolly_(number_of_atoms, coordinates, radii,
							&volume, &area, probe_radius, 0.0, tmp_atom_areas);

		// extract the atom areas and store them in the hash map
		atom_areas.clear();
		for (Position i = 0; i < atoms.size(); ++i)
		{
			atom_areas.insert(std::pair<const Atom*, float>(atoms[i], tmp_atom_areas[i]));
		}

		// free the input fields
		delete [] coordinates;
		delete [] radii;
		delete [] tmp_atom_areas;

		return area;
	}

	float calculateSESVolume
		(const AtomContainer& fragment, float probe_radius)
	{
		// extract all atoms: iterate over all composites and
		// check whether they are Atoms
		vector<const Atom*>	atoms;
		AtomConstIterator	it = fragment.beginAtom();
		for (; +it; ++it)
		{
			if (it->getRadius() > 0.0)
			{
				atoms.push_back(&*it);
			}
		}

		// if no atoms are found, return zero
		if (atoms.size() == 0)
		{
			return 0;
		}

		// create the field required by nsc and fill it with the atom coordinates
		double* coordinates = new double[atoms.size() * 3];
		double* radii = new double[atoms.size()];
		double* tmp_atom_areas = new double[atoms.size()];
		for (Size i = 0; i < atoms.size(); i++)
		{
			float tmp[3];
			atoms[i]->getPosition().get(tmp);
			coordinates[i * 3]			= tmp[0];
			coordinates[i * 3 + 1]	= tmp[1];
			coordinates[i * 3 + 2]	= tmp[2];
			radii[i] = atoms[i]->getRadius();
		}

		double area;
		double volume;
		int number_of_atoms = (int)atoms.size();

		// call connolly_
		connolly_(number_of_atoms, coordinates, radii,
							&volume, &area, probe_radius, 0.0, tmp_atom_areas);

		// free the input fields
		delete [] coordinates;
		delete [] radii;
		delete [] tmp_atom_areas;

		return volume;
	}

} // namespace BALL
<|endoftext|>


<commit_before>#include "datasets.hpp"

#include <iostream>
#include <iomanip>

#include "dataset_iterator.hpp"

namespace dicom
{

namespace data
{

namespace dataset
{

using namespace attribute;

std::ostream& operator<<(std::ostream& os, const dataset_type& data)
{

   int depth = 0;
   for (const auto attr : dataset_iterator_adaptor(data)) {
      if (attr.first == elementfield::tag_type {0xfffe, 0xe0dd}) {
         depth--;
      }
      if (attr.second.value_rep == VR::SQ) {
         depth++;
      }

      std::fill_n(std::ostream_iterator<char>(os), depth, '\t');
      os << attr.first << "\t";
      attr.second.value_field->print(os);
      std::cout << "\n";

   }

   return os;
}

std::size_t dataset_size(dataset_type data, bool explicitvr)
{
   return std::accumulate(data.begin(), data.end(), 0,
      [explicitvr](int acc, const std::pair<const elementfield::tag_type, elementfield>& attr) {
      return acc += attr.second.value_len + 4 + 4
            + (explicitvr ? 2 : 0);
   });
}

}

}

}
<commit_msg>completed operator<< for datasets<commit_after>#include "datasets.hpp"

#include <iostream>
#include <iomanip>

#include "dataset_iterator.hpp"
#include "data/dictionary/dictionary.hpp"
#include "data/dictionary/dictionary_entry.hpp"

namespace dicom
{

namespace data
{

namespace dataset
{

using namespace attribute;

std::ostream& operator<<(std::ostream& os, const dataset_type& data)
{

   int depth = 0;
   for (const auto attr : dataset_iterator_adaptor(data)) {
      if (attr.first == elementfield::tag_type {0xfffe, 0xe0dd}) {
         depth--;
      }
      if (attr.second.value_rep == VR::SQ) {
         depth++;
      }

      std::fill_n(std::ostream_iterator<char>(os), depth, '\t');
      os << attr.first << " ";
      if (attr.second.value_rep.is_initialized()) {
         os << dictionary::dictionary_entry::vr_of_string.right.at(attr.second.value_rep.get());
      } else {
         os << "NN (unknown)";
      }
      os << " " << attr.second.value_len << "\t\t";
      attr.second.value_field->print(os);
      std::cout << "\n";
   }

   return os;
}

std::size_t dataset_size(dataset_type data, bool explicitvr)
{
   return std::accumulate(data.begin(), data.end(), 0,
      [explicitvr](int acc, const std::pair<const elementfield::tag_type, elementfield>& attr) {
      return acc += attr.second.value_len + 4 + 4
            + (explicitvr ? 2 : 0);
   });
}

}

}

}
<|endoftext|>


<commit_before>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

// System includes

// External includes
#include <boost/python.hpp>

// Local includes
#include "IECore/bindings/RefCountedBinding.h"
#include "IECore/bindings/RunTimeTypedBinding.h"
#include "IECore/bindings/ExceptionBinding.h"
#include "IECore/bindings/ImathBinding.h"
#include "IECore/bindings/KDTreeBinding.h"
#include "IECore/bindings/IndexedIOInterfaceBinding.h"
#include "IECore/bindings/DataBinding.h"
#include "IECore/bindings/SimpleTypedDataBinding.h"
#include "IECore/bindings/VectorTypedDataBinding.h"
#include "IECore/bindings/ObjectBinding.h"
#include "IECore/bindings/TypeIdBinding.h"
#include "IECore/bindings/CompoundDataBinding.h"
#include "IECore/bindings/MessageHandlerBinding.h"
#include "IECore/bindings/AttributeCacheBinding.h"
#include "IECore/bindings/ReaderBinding.h"
#include "IECore/bindings/ParticleReaderBinding.h"
#include "IECore/bindings/PDCParticleReaderBinding.h"
#include "IECore/bindings/BlindDataHolderBinding.h"
#include "IECore/bindings/RenderableBinding.h"
#include "IECore/bindings/VisibleRenderableBinding.h"
#include "IECore/bindings/StateRenderableBinding.h"
#include "IECore/bindings/RendererBinding.h"
#include "IECore/bindings/WriterBinding.h"
#include "IECore/bindings/ParticleWriterBinding.h"
#include "IECore/bindings/PDCParticleWriterBinding.h"
#include "IECore/bindings/ParameterBinding.h"
#include "IECore/bindings/NumericParameterBinding.h"
#include "IECore/bindings/TypedParameterBinding.h"
#include "IECore/bindings/CompoundParameterBinding.h"
#include "IECore/bindings/ValidatedStringParameterBinding.h"
#include "IECore/bindings/PathParameterBinding.h"
#include "IECore/bindings/FileNameParameterBinding.h"
#include "IECore/bindings/DirNameParameterBinding.h"
#include "IECore/bindings/CompoundObjectBinding.h"
#include "IECore/bindings/ObjectReaderBinding.h"
#include "IECore/bindings/ObjectWriterBinding.h"
#include "IECore/bindings/PrimitiveBinding.h"
#include "IECore/bindings/PrimitiveVariableBinding.h"
#include "IECore/bindings/PointsPrimitiveBinding.h"
#include "IECore/bindings/TimerBinding.h"
#include "IECore/bindings/TurbulenceBinding.h"
#include "IECore/bindings/ShaderBinding.h"
#include "IECore/bindings/SearchPathBinding.h"
#include "IECore/bindings/CachedReaderBinding.h"
#include "IECore/bindings/ParameterisedBinding.h"
#include "IECore/bindings/OpBinding.h"
#include "IECore/bindings/ObjectParameterBinding.h"
#include "IECore/bindings/ModifyOpBinding.h"
#include "IECore/bindings/PrimitiveOpBinding.h"
#include "IECore/bindings/ImagePrimitiveBinding.h"
#include "IECore/bindings/ImageReaderBinding.h"
#include "IECore/bindings/ImageWriterBinding.h"
#include "IECore/bindings/PerlinNoiseBinding.h"
#include "IECore/bindings/EXRImageReaderBinding.h"
#include "IECore/bindings/EXRImageWriterBinding.h"
#include "IECore/bindings/HalfBinding.h"
#include "IECore/bindings/TIFFImageReaderBinding.h"
#include "IECore/bindings/TIFFImageWriterBinding.h"
#include "IECore/bindings/CINImageReaderBinding.h"
#include "IECore/bindings/CINImageWriterBinding.h"
#include "IECore/bindings/DPXImageReaderBinding.h"
#include "IECore/bindings/DPXImageWriterBinding.h"
#include "IECore/bindings/JPEGImageReaderBinding.h"
#include "IECore/bindings/JPEGImageWriterBinding.h"
#include "IECore/bindings/MeshPrimitiveBinding.h"
#include "IECore/bindings/MotionPrimitiveBinding.h"
#include "IECore/bindings/TransformBinding.h"
#include "IECore/bindings/MatrixTransformBinding.h"
#include "IECore/bindings/GroupBinding.h"
#include "IECore/bindings/AttributeStateBinding.h"
#include "IECore/bindings/MatrixMotionTransformBinding.h"
#include "IECore/bindings/OBJReaderBinding.h"
#include "IECore/bindings/NullObjectBinding.h"
#include "IECore/bindings/ObjectInterpolatorBinding.h"
#include "IECore/bindings/PointNormalsOpBinding.h"
#include "IECore/bindings/PointDensitiesOpBinding.h"
#include "IECore/bindings/InterpolatedCacheBinding.h"
#include "IECore/bindings/TransformationMatrixBinding.h"
#include "IECore/bindings/TransformationMatrixDataBinding.h"
#include "IECore/bindings/HierarchicalCacheBinding.h"
#include "IECore/bindings/BoundedKDTreeBinding.h"
#include "IECore/bindings/VectorDataFilterOpBinding.h"
#include "IECore/bindings/TypedObjectParameterBinding.h"
#include "IECore/bindings/HeaderGeneratorBinding.h"
#include "IECore/bindings/PreWorldRenderableBinding.h"
#include "IECore/bindings/CameraBinding.h"
#include "IECore/bindings/NURBSPrimitiveBinding.h"
#include "IECore/bindings/DataCastOpBinding.h"
#include "IECore/bindings/DataPromoteOpBinding.h"
#include "IECore/bindings/MatrixMultiplyOpBinding.h"
#include "IECore/bindings/PointBoundsOpBinding.h"
#include "IECore/bindings/ImathRandomBinding.h"
#include "IECore/bindings/RandomRotationOpBinding.h"
#include "IECore/bindings/ImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/CachedImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveBuilderBinding.h"
#include "IECore/bindings/MarchingCubesBinding.h"
#include "IECore/bindings/PointMeshOpBinding.h"
#include "IECore/bindings/CSGImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/SphereImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/PlaneImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/BlobbyImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/ParticleMeshOpBinding.h"
#include "IECore/bindings/TypedPrimitiveOpBinding.h"
#include "IECore/bindings/PrimitiveEvaluatorBinding.h"
#include "IECore/bindings/MeshPrimitiveEvaluatorBinding.h"
#include "IECore/bindings/PrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceOpBinding.h"
#include "IECore/bindings/TriangulateOpBinding.h"
#include "IECore/bindings/SpherePrimitiveBinding.h"
#include "IECore/bindings/SpherePrimitiveEvaluatorBinding.h"
#include "IECore/IECore.h"

using namespace IECore;
using namespace boost::python;

// Module declaration

BOOST_PYTHON_MODULE(_IECore)
{
	bindRefCounted();(void)
	bindRunTimeTyped();
	bindException();
	bindImath();
	bindKDTree();
	bindObject();
	bindTypeId();
	bindData();
	bindAllSimpleTypedData();
	bindAllVectorTypedData();
	bindCompoundData();
	bindIndexedIO();
	bindMessageHandler();
	bindAttributeCache();
	bindParameterised();
	bindOp();
	bindReader();
	bindParticleReader();
	bindPDCParticleReader();
	bindBlindDataHolder();
	bindRenderable();
	bindStateRenderable();
	bindVisibleRenderable();
	bindRenderer();
	bindWriter();
	bindParticleWriter();
	bindPDCParticleWriter();
	bindObjectReader();
	bindObjectWriter();
	bindParameter();
	bindNumericParameter();
	bindTypedParameter();
	bindCompoundParameter();
	bindValidatedStringParameter();
	bindPathParameter();
	bindFileNameParameter();
	bindDirNameParameter();
	bindCompoundObject();
	bindPrimitive();
	bindPrimitiveVariable();
	bindPointsPrimitive();
	bindPerlinNoise();
	bindHalf();
	bindTimer();
	bindTurbulence();
	bindShader();
	bindSearchPath();
	bindCachedReader();
	bindObjectParameter();
	bindModifyOp();
	bindPrimitiveOp();
	bindImagePrimitive();
	bindImageReader();
	bindImageWriter();
	bindEXRImageReader();
	bindEXRImageWriter();

#ifdef IECORE_WITH_TIFF
	bindTIFFImageReader();
	bindTIFFImageWriter();
#endif

	bindCINImageReader();
	bindCINImageWriter();
	bindDPXImageReader();
	bindDPXImageWriter();

#ifdef IECORE_WITH_JPEG
	bindJPEGImageReader();
	bindJPEGImageWriter();
#endif

	bindMeshPrimitive();
	bindMotionPrimitive();
	bindTransform();
	bindMatrixTransform();
	bindMatrixMotionTransform();
	bindGroup();
	bindAttributeState();
	bindOBJReader();
	bindNullObject();
	bindObjectInterpolator();
	bindPointNormalsOp();
	bindPointDensitiesOp();
	bindInterpolatedCache();
	bindTransformationMatrix();
	bindTransformationMatrixData();
	bindHierarchicalCache();
	bindBoundedKDTree();
	bindVectorDataFilterOp();
	bindTypedObjectParameter();
	bindHeaderGenerator();
	bindPreWorldRenderable();
	bindCamera();
	bindNURBSPrimitive();
	bindDataCastOp();
	bindDataPromoteOp();
	bindMatrixMultiplyOp();
	bindPointBoundsOp();
	bindImathRandom();
	bindRandomRotationOp();
	bindImplicitSurfaceFunction();
	bindCachedImplicitSurfaceFunction();
	bindMeshPrimitiveBuilder();
	bindMarchingCubes();
	bindPointMeshOp();
	bindCSGImplicitSurfaceFunction();
	bindSphereImplicitSurfaceFunction();
	bindPlaneImplicitSurfaceFunction();
	bindBlobbyImplicitSurfaceFunction();
	bindParticleMeshOp();
	bindTypedPrimitiveOp();
	bindPrimitiveEvaluator();
	bindMeshPrimitiveEvaluator();
	bindPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceOp();
	bindTriangulateOp();
	bindSpherePrimitive();
	bindSpherePrimitiveEvaluator();

	def( "majorVersion", &IECore::majorVersion );
	def( "minorVersion", &IECore::minorVersion );
	def( "patchVersion", &IECore::patchVersion );
	def( "versionString", &IECore::versionString, return_value_policy<copy_const_reference>() );
	def( "withTIFF", &IECore::withTIFF );
	def( "withJPEG", &IECore::withJPEG );
	def( "withSQLite", &IECore::withSQLite );
}
<commit_msg>Removed accidentally added token<commit_after>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

// System includes

// External includes
#include <boost/python.hpp>

// Local includes
#include "IECore/bindings/RefCountedBinding.h"
#include "IECore/bindings/RunTimeTypedBinding.h"
#include "IECore/bindings/ExceptionBinding.h"
#include "IECore/bindings/ImathBinding.h"
#include "IECore/bindings/KDTreeBinding.h"
#include "IECore/bindings/IndexedIOInterfaceBinding.h"
#include "IECore/bindings/DataBinding.h"
#include "IECore/bindings/SimpleTypedDataBinding.h"
#include "IECore/bindings/VectorTypedDataBinding.h"
#include "IECore/bindings/ObjectBinding.h"
#include "IECore/bindings/TypeIdBinding.h"
#include "IECore/bindings/CompoundDataBinding.h"
#include "IECore/bindings/MessageHandlerBinding.h"
#include "IECore/bindings/AttributeCacheBinding.h"
#include "IECore/bindings/ReaderBinding.h"
#include "IECore/bindings/ParticleReaderBinding.h"
#include "IECore/bindings/PDCParticleReaderBinding.h"
#include "IECore/bindings/BlindDataHolderBinding.h"
#include "IECore/bindings/RenderableBinding.h"
#include "IECore/bindings/VisibleRenderableBinding.h"
#include "IECore/bindings/StateRenderableBinding.h"
#include "IECore/bindings/RendererBinding.h"
#include "IECore/bindings/WriterBinding.h"
#include "IECore/bindings/ParticleWriterBinding.h"
#include "IECore/bindings/PDCParticleWriterBinding.h"
#include "IECore/bindings/ParameterBinding.h"
#include "IECore/bindings/NumericParameterBinding.h"
#include "IECore/bindings/TypedParameterBinding.h"
#include "IECore/bindings/CompoundParameterBinding.h"
#include "IECore/bindings/ValidatedStringParameterBinding.h"
#include "IECore/bindings/PathParameterBinding.h"
#include "IECore/bindings/FileNameParameterBinding.h"
#include "IECore/bindings/DirNameParameterBinding.h"
#include "IECore/bindings/CompoundObjectBinding.h"
#include "IECore/bindings/ObjectReaderBinding.h"
#include "IECore/bindings/ObjectWriterBinding.h"
#include "IECore/bindings/PrimitiveBinding.h"
#include "IECore/bindings/PrimitiveVariableBinding.h"
#include "IECore/bindings/PointsPrimitiveBinding.h"
#include "IECore/bindings/TimerBinding.h"
#include "IECore/bindings/TurbulenceBinding.h"
#include "IECore/bindings/ShaderBinding.h"
#include "IECore/bindings/SearchPathBinding.h"
#include "IECore/bindings/CachedReaderBinding.h"
#include "IECore/bindings/ParameterisedBinding.h"
#include "IECore/bindings/OpBinding.h"
#include "IECore/bindings/ObjectParameterBinding.h"
#include "IECore/bindings/ModifyOpBinding.h"
#include "IECore/bindings/PrimitiveOpBinding.h"
#include "IECore/bindings/ImagePrimitiveBinding.h"
#include "IECore/bindings/ImageReaderBinding.h"
#include "IECore/bindings/ImageWriterBinding.h"
#include "IECore/bindings/PerlinNoiseBinding.h"
#include "IECore/bindings/EXRImageReaderBinding.h"
#include "IECore/bindings/EXRImageWriterBinding.h"
#include "IECore/bindings/HalfBinding.h"
#include "IECore/bindings/TIFFImageReaderBinding.h"
#include "IECore/bindings/TIFFImageWriterBinding.h"
#include "IECore/bindings/CINImageReaderBinding.h"
#include "IECore/bindings/CINImageWriterBinding.h"
#include "IECore/bindings/DPXImageReaderBinding.h"
#include "IECore/bindings/DPXImageWriterBinding.h"
#include "IECore/bindings/JPEGImageReaderBinding.h"
#include "IECore/bindings/JPEGImageWriterBinding.h"
#include "IECore/bindings/MeshPrimitiveBinding.h"
#include "IECore/bindings/MotionPrimitiveBinding.h"
#include "IECore/bindings/TransformBinding.h"
#include "IECore/bindings/MatrixTransformBinding.h"
#include "IECore/bindings/GroupBinding.h"
#include "IECore/bindings/AttributeStateBinding.h"
#include "IECore/bindings/MatrixMotionTransformBinding.h"
#include "IECore/bindings/OBJReaderBinding.h"
#include "IECore/bindings/NullObjectBinding.h"
#include "IECore/bindings/ObjectInterpolatorBinding.h"
#include "IECore/bindings/PointNormalsOpBinding.h"
#include "IECore/bindings/PointDensitiesOpBinding.h"
#include "IECore/bindings/InterpolatedCacheBinding.h"
#include "IECore/bindings/TransformationMatrixBinding.h"
#include "IECore/bindings/TransformationMatrixDataBinding.h"
#include "IECore/bindings/HierarchicalCacheBinding.h"
#include "IECore/bindings/BoundedKDTreeBinding.h"
#include "IECore/bindings/VectorDataFilterOpBinding.h"
#include "IECore/bindings/TypedObjectParameterBinding.h"
#include "IECore/bindings/HeaderGeneratorBinding.h"
#include "IECore/bindings/PreWorldRenderableBinding.h"
#include "IECore/bindings/CameraBinding.h"
#include "IECore/bindings/NURBSPrimitiveBinding.h"
#include "IECore/bindings/DataCastOpBinding.h"
#include "IECore/bindings/DataPromoteOpBinding.h"
#include "IECore/bindings/MatrixMultiplyOpBinding.h"
#include "IECore/bindings/PointBoundsOpBinding.h"
#include "IECore/bindings/ImathRandomBinding.h"
#include "IECore/bindings/RandomRotationOpBinding.h"
#include "IECore/bindings/ImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/CachedImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveBuilderBinding.h"
#include "IECore/bindings/MarchingCubesBinding.h"
#include "IECore/bindings/PointMeshOpBinding.h"
#include "IECore/bindings/CSGImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/SphereImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/PlaneImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/BlobbyImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/ParticleMeshOpBinding.h"
#include "IECore/bindings/TypedPrimitiveOpBinding.h"
#include "IECore/bindings/PrimitiveEvaluatorBinding.h"
#include "IECore/bindings/MeshPrimitiveEvaluatorBinding.h"
#include "IECore/bindings/PrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceOpBinding.h"
#include "IECore/bindings/TriangulateOpBinding.h"
#include "IECore/bindings/SpherePrimitiveBinding.h"
#include "IECore/bindings/SpherePrimitiveEvaluatorBinding.h"
#include "IECore/IECore.h"

using namespace IECore;
using namespace boost::python;

// Module declaration

BOOST_PYTHON_MODULE(_IECore)
{
	bindRefCounted();
	bindRunTimeTyped();
	bindException();
	bindImath();
	bindKDTree();
	bindObject();
	bindTypeId();
	bindData();
	bindAllSimpleTypedData();
	bindAllVectorTypedData();
	bindCompoundData();
	bindIndexedIO();
	bindMessageHandler();
	bindAttributeCache();
	bindParameterised();
	bindOp();
	bindReader();
	bindParticleReader();
	bindPDCParticleReader();
	bindBlindDataHolder();
	bindRenderable();
	bindStateRenderable();
	bindVisibleRenderable();
	bindRenderer();
	bindWriter();
	bindParticleWriter();
	bindPDCParticleWriter();
	bindObjectReader();
	bindObjectWriter();
	bindParameter();
	bindNumericParameter();
	bindTypedParameter();
	bindCompoundParameter();
	bindValidatedStringParameter();
	bindPathParameter();
	bindFileNameParameter();
	bindDirNameParameter();
	bindCompoundObject();
	bindPrimitive();
	bindPrimitiveVariable();
	bindPointsPrimitive();
	bindPerlinNoise();
	bindHalf();
	bindTimer();
	bindTurbulence();
	bindShader();
	bindSearchPath();
	bindCachedReader();
	bindObjectParameter();
	bindModifyOp();
	bindPrimitiveOp();
	bindImagePrimitive();
	bindImageReader();
	bindImageWriter();
	bindEXRImageReader();
	bindEXRImageWriter();

#ifdef IECORE_WITH_TIFF
	bindTIFFImageReader();
	bindTIFFImageWriter();
#endif

	bindCINImageReader();
	bindCINImageWriter();
	bindDPXImageReader();
	bindDPXImageWriter();

#ifdef IECORE_WITH_JPEG
	bindJPEGImageReader();
	bindJPEGImageWriter();
#endif

	bindMeshPrimitive();
	bindMotionPrimitive();
	bindTransform();
	bindMatrixTransform();
	bindMatrixMotionTransform();
	bindGroup();
	bindAttributeState();
	bindOBJReader();
	bindNullObject();
	bindObjectInterpolator();
	bindPointNormalsOp();
	bindPointDensitiesOp();
	bindInterpolatedCache();
	bindTransformationMatrix();
	bindTransformationMatrixData();
	bindHierarchicalCache();
	bindBoundedKDTree();
	bindVectorDataFilterOp();
	bindTypedObjectParameter();
	bindHeaderGenerator();
	bindPreWorldRenderable();
	bindCamera();
	bindNURBSPrimitive();
	bindDataCastOp();
	bindDataPromoteOp();
	bindMatrixMultiplyOp();
	bindPointBoundsOp();
	bindImathRandom();
	bindRandomRotationOp();
	bindImplicitSurfaceFunction();
	bindCachedImplicitSurfaceFunction();
	bindMeshPrimitiveBuilder();
	bindMarchingCubes();
	bindPointMeshOp();
	bindCSGImplicitSurfaceFunction();
	bindSphereImplicitSurfaceFunction();
	bindPlaneImplicitSurfaceFunction();
	bindBlobbyImplicitSurfaceFunction();
	bindParticleMeshOp();
	bindTypedPrimitiveOp();
	bindPrimitiveEvaluator();
	bindMeshPrimitiveEvaluator();
	bindPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceOp();
	bindTriangulateOp();
	bindSpherePrimitive();
	bindSpherePrimitiveEvaluator();

	def( "majorVersion", &IECore::majorVersion );
	def( "minorVersion", &IECore::minorVersion );
	def( "patchVersion", &IECore::patchVersion );
	def( "versionString", &IECore::versionString, return_value_policy<copy_const_reference>() );
	def( "withTIFF", &IECore::withTIFF );
	def( "withJPEG", &IECore::withJPEG );
	def( "withSQLite", &IECore::withSQLite );
}
<|endoftext|>


<commit_before>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

// System includes

// External includes
#include <boost/python.hpp>

// Local includes
#include "IECore/bindings/RefCountedBinding.h"
#include "IECore/bindings/RunTimeTypedBinding.h"
#include "IECore/bindings/ExceptionBinding.h"
#include "IECore/bindings/ImathBinding.h"
#include "IECore/bindings/KDTreeBinding.h"
#include "IECore/bindings/IndexedIOInterfaceBinding.h"
#include "IECore/bindings/DataBinding.h"
#include "IECore/bindings/SimpleTypedDataBinding.h"
#include "IECore/bindings/VectorTypedDataBinding.h"
#include "IECore/bindings/ObjectBinding.h"
#include "IECore/bindings/TypeIdBinding.h"
#include "IECore/bindings/CompoundDataBinding.h"
#include "IECore/bindings/MessageHandlerBinding.h"
#include "IECore/bindings/AttributeCacheBinding.h"
#include "IECore/bindings/ReaderBinding.h"
#include "IECore/bindings/ParticleReaderBinding.h"
#include "IECore/bindings/PDCParticleReaderBinding.h"
#include "IECore/bindings/BlindDataHolderBinding.h"
#include "IECore/bindings/RenderableBinding.h"
#include "IECore/bindings/VisibleRenderableBinding.h"
#include "IECore/bindings/StateRenderableBinding.h"
#include "IECore/bindings/RendererBinding.h"
#include "IECore/bindings/WriterBinding.h"
#include "IECore/bindings/ParticleWriterBinding.h"
#include "IECore/bindings/PDCParticleWriterBinding.h"
#include "IECore/bindings/ParameterBinding.h"
#include "IECore/bindings/NumericParameterBinding.h"
#include "IECore/bindings/TypedParameterBinding.h"
#include "IECore/bindings/CompoundParameterBinding.h"
#include "IECore/bindings/ValidatedStringParameterBinding.h"
#include "IECore/bindings/PathParameterBinding.h"
#include "IECore/bindings/FileNameParameterBinding.h"
#include "IECore/bindings/DirNameParameterBinding.h"
#include "IECore/bindings/CompoundObjectBinding.h"
#include "IECore/bindings/ObjectReaderBinding.h"
#include "IECore/bindings/ObjectWriterBinding.h"
#include "IECore/bindings/PrimitiveBinding.h"
#include "IECore/bindings/PrimitiveVariableBinding.h"
#include "IECore/bindings/PointsPrimitiveBinding.h"
#include "IECore/bindings/TimerBinding.h"
#include "IECore/bindings/TurbulenceBinding.h"
#include "IECore/bindings/ShaderBinding.h"
#include "IECore/bindings/SearchPathBinding.h"
#include "IECore/bindings/CachedReaderBinding.h"
#include "IECore/bindings/ParameterisedBinding.h"
#include "IECore/bindings/OpBinding.h"
#include "IECore/bindings/ObjectParameterBinding.h"
#include "IECore/bindings/ModifyOpBinding.h"
#include "IECore/bindings/PrimitiveOpBinding.h"
#include "IECore/bindings/ImagePrimitiveBinding.h"
#include "IECore/bindings/ImageReaderBinding.h"
#include "IECore/bindings/ImageWriterBinding.h"
#include "IECore/bindings/PerlinNoiseBinding.h"
#include "IECore/bindings/EXRImageReaderBinding.h"
#include "IECore/bindings/EXRImageWriterBinding.h"
#include "IECore/bindings/HalfBinding.h"
#include "IECore/bindings/TIFFImageReaderBinding.h"
#include "IECore/bindings/TIFFImageWriterBinding.h"
#include "IECore/bindings/CINImageReaderBinding.h"
#include "IECore/bindings/CINImageWriterBinding.h"
#include "IECore/bindings/DPXImageReaderBinding.h"
#include "IECore/bindings/DPXImageWriterBinding.h"
#include "IECore/bindings/JPEGImageReaderBinding.h"
#include "IECore/bindings/JPEGImageWriterBinding.h"
#include "IECore/bindings/MeshPrimitiveBinding.h"
#include "IECore/bindings/MotionPrimitiveBinding.h"
#include "IECore/bindings/TransformBinding.h"
#include "IECore/bindings/MatrixTransformBinding.h"
#include "IECore/bindings/GroupBinding.h"
#include "IECore/bindings/AttributeStateBinding.h"
#include "IECore/bindings/MatrixMotionTransformBinding.h"
#include "IECore/bindings/OBJReaderBinding.h"
#include "IECore/bindings/NullObjectBinding.h"
#include "IECore/bindings/ObjectInterpolatorBinding.h"
#include "IECore/bindings/PointNormalsOpBinding.h"
#include "IECore/bindings/PointDensitiesOpBinding.h"
#include "IECore/bindings/InterpolatedCacheBinding.h"
#include "IECore/bindings/TransformationMatrixBinding.h"
#include "IECore/bindings/TransformationMatrixDataBinding.h"
#include "IECore/bindings/HierarchicalCacheBinding.h"
#include "IECore/bindings/BoundedKDTreeBinding.h"
#include "IECore/bindings/VectorDataFilterOpBinding.h"
#include "IECore/bindings/TypedObjectParameterBinding.h"
#include "IECore/bindings/HeaderGeneratorBinding.h"
#include "IECore/bindings/PreWorldRenderableBinding.h"
#include "IECore/bindings/CameraBinding.h"
#include "IECore/bindings/NURBSPrimitiveBinding.h"
#include "IECore/bindings/DataCastOpBinding.h"
#include "IECore/bindings/DataPromoteOpBinding.h"
#include "IECore/bindings/MatrixMultiplyOpBinding.h"
#include "IECore/bindings/PointBoundsOpBinding.h"
#include "IECore/bindings/ImathRandomBinding.h"
#include "IECore/bindings/RandomRotationOpBinding.h"
#include "IECore/bindings/ImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/CachedImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveBuilderBinding.h"
#include "IECore/bindings/MarchingCubesBinding.h"
#include "IECore/bindings/PointMeshOpBinding.h"
#include "IECore/bindings/CSGImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/SphereImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/PlaneImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/BlobbyImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/ParticleMeshOpBinding.h"
#include "IECore/bindings/TypedPrimitiveOpBinding.h"
#include "IECore/bindings/PrimitiveEvaluatorBinding.h"
#include "IECore/bindings/MeshPrimitiveEvaluatorBinding.h"
#include "IECore/bindings/PrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceOpBinding.h"
#include "IECore/bindings/TriangulateOpBinding.h"
#include "IECore/bindings/InternedBinding.h"
#include "IECore/bindings/SpherePrimitiveBinding.h"
#include "IECore/bindings/SpherePrimitiveEvaluatorBinding.h"
#include "IECore/bindings/InverseDistanceWeightedInterpolationBinding.h"
#include "IECore/bindings/ImageCropOpBinding.h"
#include "IECore/bindings/MeshPrimitiveShrinkWrapOpBinding.h"
#include "IECore/bindings/ImagePrimitiveEvaluatorBinding.h"
#include "IECore/bindings/MathBinding.h"
#include "IECore/IECore.h"

using namespace IECore;
using namespace boost::python;

// Module declaration

BOOST_PYTHON_MODULE(_IECore)
{
	bindRefCounted();
	bindRunTimeTyped();
	bindException();
	bindImath();
	bindKDTree();
	bindObject();
	bindTypeId();
	bindData();
	bindAllSimpleTypedData();
	bindAllVectorTypedData();
	bindCompoundData();
	bindIndexedIO();
	bindMessageHandler();
	bindAttributeCache();
	bindParameterised();
	bindOp();
	bindReader();
	bindParticleReader();
	bindPDCParticleReader();
	bindBlindDataHolder();
	bindRenderable();
	bindStateRenderable();
	bindVisibleRenderable();
	bindRenderer();
	bindWriter();
	bindParticleWriter();
	bindPDCParticleWriter();
	bindObjectReader();
	bindObjectWriter();
	bindParameter();
	bindNumericParameter();
	bindTypedParameter();
	bindCompoundParameter();
	bindValidatedStringParameter();
	bindPathParameter();
	bindFileNameParameter();
	bindDirNameParameter();
	bindCompoundObject();
	bindPrimitive();
	bindPrimitiveVariable();
	bindPointsPrimitive();
	bindPerlinNoise();
	bindHalf();
	bindTimer();
	bindTurbulence();
	bindShader();
	bindSearchPath();
	bindCachedReader();
	bindObjectParameter();
	bindModifyOp();
	bindPrimitiveOp();
	bindImagePrimitive();
	bindImageReader();
	bindImageWriter();
	bindEXRImageReader();
	bindEXRImageWriter();

#ifdef IECORE_WITH_TIFF
	bindTIFFImageReader();
	bindTIFFImageWriter();
#endif

	bindCINImageReader();
	bindCINImageWriter();
	bindDPXImageReader();
	bindDPXImageWriter();

#ifdef IECORE_WITH_JPEG
	bindJPEGImageReader();
	bindJPEGImageWriter();
#endif

	bindMeshPrimitive();
	bindMotionPrimitive();
	bindTransform();
	bindMatrixTransform();
	bindMatrixMotionTransform();
	bindGroup();
	bindAttributeState();
	bindOBJReader();
	bindNullObject();
	bindObjectInterpolator();
	bindPointNormalsOp();
	bindPointDensitiesOp();
	bindInterpolatedCache();
	bindTransformationMatrix();
	bindTransformationMatrixData();
	bindHierarchicalCache();
	bindBoundedKDTree();
	bindVectorDataFilterOp();
	bindTypedObjectParameter();
	bindHeaderGenerator();
	bindPreWorldRenderable();
	bindCamera();
	bindNURBSPrimitive();
	bindDataCastOp();
	bindDataPromoteOp();
	bindMatrixMultiplyOp();
	bindPointBoundsOp();
	bindImathRandom();
	bindRandomRotationOp();
	bindImplicitSurfaceFunction();
	bindCachedImplicitSurfaceFunction();
	bindMeshPrimitiveBuilder();
	bindMarchingCubes();
	bindPointMeshOp();
	bindCSGImplicitSurfaceFunction();
	bindSphereImplicitSurfaceFunction();
	bindPlaneImplicitSurfaceFunction();
	bindBlobbyImplicitSurfaceFunction();
	bindParticleMeshOp();
	bindTypedPrimitiveOp();
	bindPrimitiveEvaluator();
	bindMeshPrimitiveEvaluator();
	bindPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceOp();
	bindTriangulateOp();
	bindInterned();
	bindSpherePrimitive();
	bindSpherePrimitiveEvaluator();
	bindInverseDistanceWeightedInterpolation();
	bindImageCropOp();
	bindMeshPrimitiveShrinkWrapOp();
	bindImagePrimitiveEvaluator();
	bindMath();

	def( "majorVersion", &IECore::majorVersion );
	def( "minorVersion", &IECore::minorVersion );
	def( "patchVersion", &IECore::patchVersion );
	def( "versionString", &IECore::versionString, return_value_policy<copy_const_reference>() );
	def( "withTIFF", &IECore::withTIFF );
	def( "withJPEG", &IECore::withJPEG );
	def( "withSQLite", &IECore::withSQLite );
}
<commit_msg>Added ScopedMessageHandler binding<commit_after>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2008, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

// System includes

// External includes
#include <boost/python.hpp>

// Local includes
#include "IECore/bindings/RefCountedBinding.h"
#include "IECore/bindings/RunTimeTypedBinding.h"
#include "IECore/bindings/ExceptionBinding.h"
#include "IECore/bindings/ImathBinding.h"
#include "IECore/bindings/KDTreeBinding.h"
#include "IECore/bindings/IndexedIOInterfaceBinding.h"
#include "IECore/bindings/DataBinding.h"
#include "IECore/bindings/SimpleTypedDataBinding.h"
#include "IECore/bindings/VectorTypedDataBinding.h"
#include "IECore/bindings/ObjectBinding.h"
#include "IECore/bindings/TypeIdBinding.h"
#include "IECore/bindings/CompoundDataBinding.h"
#include "IECore/bindings/MessageHandlerBinding.h"
#include "IECore/bindings/AttributeCacheBinding.h"
#include "IECore/bindings/ReaderBinding.h"
#include "IECore/bindings/ParticleReaderBinding.h"
#include "IECore/bindings/PDCParticleReaderBinding.h"
#include "IECore/bindings/BlindDataHolderBinding.h"
#include "IECore/bindings/RenderableBinding.h"
#include "IECore/bindings/VisibleRenderableBinding.h"
#include "IECore/bindings/StateRenderableBinding.h"
#include "IECore/bindings/RendererBinding.h"
#include "IECore/bindings/WriterBinding.h"
#include "IECore/bindings/ParticleWriterBinding.h"
#include "IECore/bindings/PDCParticleWriterBinding.h"
#include "IECore/bindings/ParameterBinding.h"
#include "IECore/bindings/NumericParameterBinding.h"
#include "IECore/bindings/TypedParameterBinding.h"
#include "IECore/bindings/CompoundParameterBinding.h"
#include "IECore/bindings/ValidatedStringParameterBinding.h"
#include "IECore/bindings/PathParameterBinding.h"
#include "IECore/bindings/FileNameParameterBinding.h"
#include "IECore/bindings/DirNameParameterBinding.h"
#include "IECore/bindings/CompoundObjectBinding.h"
#include "IECore/bindings/ObjectReaderBinding.h"
#include "IECore/bindings/ObjectWriterBinding.h"
#include "IECore/bindings/PrimitiveBinding.h"
#include "IECore/bindings/PrimitiveVariableBinding.h"
#include "IECore/bindings/PointsPrimitiveBinding.h"
#include "IECore/bindings/TimerBinding.h"
#include "IECore/bindings/TurbulenceBinding.h"
#include "IECore/bindings/ShaderBinding.h"
#include "IECore/bindings/SearchPathBinding.h"
#include "IECore/bindings/CachedReaderBinding.h"
#include "IECore/bindings/ParameterisedBinding.h"
#include "IECore/bindings/OpBinding.h"
#include "IECore/bindings/ObjectParameterBinding.h"
#include "IECore/bindings/ModifyOpBinding.h"
#include "IECore/bindings/PrimitiveOpBinding.h"
#include "IECore/bindings/ImagePrimitiveBinding.h"
#include "IECore/bindings/ImageReaderBinding.h"
#include "IECore/bindings/ImageWriterBinding.h"
#include "IECore/bindings/PerlinNoiseBinding.h"
#include "IECore/bindings/EXRImageReaderBinding.h"
#include "IECore/bindings/EXRImageWriterBinding.h"
#include "IECore/bindings/HalfBinding.h"
#include "IECore/bindings/TIFFImageReaderBinding.h"
#include "IECore/bindings/TIFFImageWriterBinding.h"
#include "IECore/bindings/CINImageReaderBinding.h"
#include "IECore/bindings/CINImageWriterBinding.h"
#include "IECore/bindings/DPXImageReaderBinding.h"
#include "IECore/bindings/DPXImageWriterBinding.h"
#include "IECore/bindings/JPEGImageReaderBinding.h"
#include "IECore/bindings/JPEGImageWriterBinding.h"
#include "IECore/bindings/MeshPrimitiveBinding.h"
#include "IECore/bindings/MotionPrimitiveBinding.h"
#include "IECore/bindings/TransformBinding.h"
#include "IECore/bindings/MatrixTransformBinding.h"
#include "IECore/bindings/GroupBinding.h"
#include "IECore/bindings/AttributeStateBinding.h"
#include "IECore/bindings/MatrixMotionTransformBinding.h"
#include "IECore/bindings/OBJReaderBinding.h"
#include "IECore/bindings/NullObjectBinding.h"
#include "IECore/bindings/ObjectInterpolatorBinding.h"
#include "IECore/bindings/PointNormalsOpBinding.h"
#include "IECore/bindings/PointDensitiesOpBinding.h"
#include "IECore/bindings/InterpolatedCacheBinding.h"
#include "IECore/bindings/TransformationMatrixBinding.h"
#include "IECore/bindings/TransformationMatrixDataBinding.h"
#include "IECore/bindings/HierarchicalCacheBinding.h"
#include "IECore/bindings/BoundedKDTreeBinding.h"
#include "IECore/bindings/VectorDataFilterOpBinding.h"
#include "IECore/bindings/TypedObjectParameterBinding.h"
#include "IECore/bindings/HeaderGeneratorBinding.h"
#include "IECore/bindings/PreWorldRenderableBinding.h"
#include "IECore/bindings/CameraBinding.h"
#include "IECore/bindings/NURBSPrimitiveBinding.h"
#include "IECore/bindings/DataCastOpBinding.h"
#include "IECore/bindings/DataPromoteOpBinding.h"
#include "IECore/bindings/MatrixMultiplyOpBinding.h"
#include "IECore/bindings/PointBoundsOpBinding.h"
#include "IECore/bindings/ImathRandomBinding.h"
#include "IECore/bindings/RandomRotationOpBinding.h"
#include "IECore/bindings/ImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/CachedImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveBuilderBinding.h"
#include "IECore/bindings/MarchingCubesBinding.h"
#include "IECore/bindings/PointMeshOpBinding.h"
#include "IECore/bindings/CSGImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/SphereImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/PlaneImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/BlobbyImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/ParticleMeshOpBinding.h"
#include "IECore/bindings/TypedPrimitiveOpBinding.h"
#include "IECore/bindings/PrimitiveEvaluatorBinding.h"
#include "IECore/bindings/MeshPrimitiveEvaluatorBinding.h"
#include "IECore/bindings/PrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceFunctionBinding.h"
#include "IECore/bindings/MeshPrimitiveImplicitSurfaceOpBinding.h"
#include "IECore/bindings/TriangulateOpBinding.h"
#include "IECore/bindings/InternedBinding.h"
#include "IECore/bindings/SpherePrimitiveBinding.h"
#include "IECore/bindings/SpherePrimitiveEvaluatorBinding.h"
#include "IECore/bindings/InverseDistanceWeightedInterpolationBinding.h"
#include "IECore/bindings/ImageCropOpBinding.h"
#include "IECore/bindings/MeshPrimitiveShrinkWrapOpBinding.h"
#include "IECore/bindings/ImagePrimitiveEvaluatorBinding.h"
#include "IECore/bindings/ScopedMessageHandlerBinding.h"
#include "IECore/bindings/MathBinding.h"
#include "IECore/IECore.h"

using namespace IECore;
using namespace boost::python;

// Module declaration

BOOST_PYTHON_MODULE(_IECore)
{
	bindRefCounted();
	bindRunTimeTyped();
	bindException();
	bindImath();
	bindKDTree();
	bindObject();
	bindTypeId();
	bindData();
	bindAllSimpleTypedData();
	bindAllVectorTypedData();
	bindCompoundData();
	bindIndexedIO();
	bindMessageHandler();
	bindAttributeCache();
	bindParameterised();
	bindOp();
	bindReader();
	bindParticleReader();
	bindPDCParticleReader();
	bindBlindDataHolder();
	bindRenderable();
	bindStateRenderable();
	bindVisibleRenderable();
	bindRenderer();
	bindWriter();
	bindParticleWriter();
	bindPDCParticleWriter();
	bindObjectReader();
	bindObjectWriter();
	bindParameter();
	bindNumericParameter();
	bindTypedParameter();
	bindCompoundParameter();
	bindValidatedStringParameter();
	bindPathParameter();
	bindFileNameParameter();
	bindDirNameParameter();
	bindCompoundObject();
	bindPrimitive();
	bindPrimitiveVariable();
	bindPointsPrimitive();
	bindPerlinNoise();
	bindHalf();
	bindTimer();
	bindTurbulence();
	bindShader();
	bindSearchPath();
	bindCachedReader();
	bindObjectParameter();
	bindModifyOp();
	bindPrimitiveOp();
	bindImagePrimitive();
	bindImageReader();
	bindImageWriter();
	bindEXRImageReader();
	bindEXRImageWriter();

#ifdef IECORE_WITH_TIFF
	bindTIFFImageReader();
	bindTIFFImageWriter();
#endif

	bindCINImageReader();
	bindCINImageWriter();
	bindDPXImageReader();
	bindDPXImageWriter();

#ifdef IECORE_WITH_JPEG
	bindJPEGImageReader();
	bindJPEGImageWriter();
#endif

	bindMeshPrimitive();
	bindMotionPrimitive();
	bindTransform();
	bindMatrixTransform();
	bindMatrixMotionTransform();
	bindGroup();
	bindAttributeState();
	bindOBJReader();
	bindNullObject();
	bindObjectInterpolator();
	bindPointNormalsOp();
	bindPointDensitiesOp();
	bindInterpolatedCache();
	bindTransformationMatrix();
	bindTransformationMatrixData();
	bindHierarchicalCache();
	bindBoundedKDTree();
	bindVectorDataFilterOp();
	bindTypedObjectParameter();
	bindHeaderGenerator();
	bindPreWorldRenderable();
	bindCamera();
	bindNURBSPrimitive();
	bindDataCastOp();
	bindDataPromoteOp();
	bindMatrixMultiplyOp();
	bindPointBoundsOp();
	bindImathRandom();
	bindRandomRotationOp();
	bindImplicitSurfaceFunction();
	bindCachedImplicitSurfaceFunction();
	bindMeshPrimitiveBuilder();
	bindMarchingCubes();
	bindPointMeshOp();
	bindCSGImplicitSurfaceFunction();
	bindSphereImplicitSurfaceFunction();
	bindPlaneImplicitSurfaceFunction();
	bindBlobbyImplicitSurfaceFunction();
	bindParticleMeshOp();
	bindTypedPrimitiveOp();
	bindPrimitiveEvaluator();
	bindMeshPrimitiveEvaluator();
	bindPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceFunction();
	bindMeshPrimitiveImplicitSurfaceOp();
	bindTriangulateOp();
	bindInterned();
	bindSpherePrimitive();
	bindSpherePrimitiveEvaluator();
	bindInverseDistanceWeightedInterpolation();
	bindImageCropOp();
	bindMeshPrimitiveShrinkWrapOp();
	bindImagePrimitiveEvaluator();
	bindScopedMessageHandler();
	bindMath();

	def( "majorVersion", &IECore::majorVersion );
	def( "minorVersion", &IECore::minorVersion );
	def( "patchVersion", &IECore::patchVersion );
	def( "versionString", &IECore::versionString, return_value_policy<copy_const_reference>() );
	def( "withTIFF", &IECore::withTIFF );
	def( "withJPEG", &IECore::withJPEG );
	def( "withSQLite", &IECore::withSQLite );
}
<|endoftext|>


<commit_before>#include <Utils/ImageIO.h>

#include <fstream>

// static const char* BM = "BM";

struct BitmapFileHeader_Struct
{
	short magicNumber;         // magic number : BM = 0x42 0x4D (others are possibles...)
	int fileSize;              // size of the bmp file
	short editorReserved1;     // ID editor
	short editorReserved2;     // ID editor
	unsigned int dataOffset;// offset of data
};

// BMP HEADER SIZE
static const unsigned int DIB_BITMAPCOREHEADER = 12;
static const unsigned int DIB_OS21XBITMAPHEADER = DIB_BITMAPCOREHEADER;
static const unsigned int DIB_OS22XBITMAPHEADER = 64;
static const unsigned int DIB_BITMAPINFOHEADER = 40;
static const unsigned int DIB_BITMAPV2INFOHEADER = 52;
static const unsigned int DIB_BITMAPV3INFOHEADER = 56;
static const unsigned int DIB_BITMAPV4HEADER = 108;
static const unsigned int DIB_BITMAPV5HEADER = 124;

struct BitmapCoreHeader_Struct
{
	unsigned int dib;	//offset 0x0E
	unsigned short width;	// offset 0x12
	unsigned short height;	// offset 0x14
	unsigned short numberOfColorPlanes;	// (1) offset 0x16
	unsigned short bpp;	// 0x18
};

static const unsigned int BI_RGB = 0;	// none
/*static const unsigned int BI_RLE8;
static const unsigned int BI_RLE4;
static const unsigned int BI_BITFIELDS;
static const unsigned int BI_JPEG;
static const unsigned int BI_PNG;
static const unsigned int BI_ALPHABITFIELDS;
static const unsigned int BI_CMYK;
static const unsigned int BI_CMYKRLE8;
static const unsigned int BI_CMYKRLE4;*/

struct BitmapInfoHeader_Struct
{
	unsigned int dib;	// offset 0x0E
	signed int width;
	signed int height;
	unsigned short numberOfColorPlanes; // (1)
	unsigned short bpp;
	int compressionMethod; // (0 for none)
	int rawDataSize; // (0 for BI_RGB)
	int horizontalResolution;	// pixel per meter
	int verticalResolution;	// pixel per meter
	int paletteColorNumber; // (0 by default)
	int importantColorUsedNumber; // (0 by default)
};

union DibHeader_Union
{
    BitmapCoreHeader_Struct bitmapCoreHeader;
    BitmapInfoHeader_Struct bitmapInfoHeader;
};

// template for file reading
template<class T>
T read(std::ifstream & stream)
{
    T value;
    stream.read( (char*)&value, sizeof(T) );
    return value;
}
template<class T>
void write(std::ofstream & stream, T value)
{
    stream.write( (char*)&value, sizeof(T) );
}

void seek(std::ifstream& stream, long offset)
{
	stream.seekg(offset);
}
long pos(std::ofstream& stream)
{
	return stream.tellp();
}

IMPGEARS_BEGIN

//--------------------------------------------------------------
void bmp_save(const std::string& filename, const Image::Ptr img);
void tga_save(const std::string& filename, const Image::Ptr img);
Image::Ptr bmp_load(std::string& filename);

//--------------------------------------------------------------
ImageIO::ImageIO()
{
}

//--------------------------------------------------------------
ImageIO::~ImageIO()
{
}

//--------------------------------------------------------------
void ImageIO::save(const Image::Ptr image, std::string filename)
{
    save(image,filename,Options());
}

//--------------------------------------------------------------
Image::Ptr ImageIO::load(std::string filename)
{
	return load(filename,Options());
}

//--------------------------------------------------------------
void ImageIO::save(const Image::Ptr image, std::string filename, const Options& opts)
{
    if(opts.fileType == FileType_BMP)
    {
        // todo
        // bmp_save(filename, image);
    }
    else if(opts.fileType == FileType_TGA)
    {
        tga_save(filename, image);
    }
}

//--------------------------------------------------------------
Image::Ptr ImageIO::load(std::string filename, const Options& opts)
{
	Image::Ptr res;
    if(opts.fileType == FileType_BMP)
    {
        res = bmp_load(filename);
    }
    else if(opts.fileType == FileType_TGA)
    {
        // todo
        // tga_load(filename, image);
    }
	return res;
}

//--------------------------------------------------------------
void tga_save(const std::string& filename, const Image::Ptr img)
{
    std::ofstream ostrm(filename,std::ios::binary);
    unsigned char v = 0;
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); //ID length (1o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Color map type (1o)
    if(img->channels() == 1) v = 3; // black and white
    if(img->channels() == 3 || img->channels() == 4) v = 2;	// TrueColor
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Image type (1o)
    v = 0;	// no color map
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    unsigned short d = 0;
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // X-origin (2o)
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // Y-origin (2o)
    d = img->width();
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // width (2o)
    d = img->height();
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // height (2o)
    // v = 8;	// default for black and white
    v = img->channels() * 8;	// 24 for RGB; 32 for RGBA
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // px depth (1o)
    v = 0;
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // description (1o)
    ostrm.write(reinterpret_cast<char*>(img->asGrid()->data()), (img->width()*img->height()*img->channels())); // image data
}

//--------------------------------------------------------------
void bmp_save(const std::string& filename, const Image::Ptr img)
{
    BitmapFileHeader_Struct fileHeader;
    DibHeader_Union dibHeader;
    int dib;

    dib = DIB_BITMAPINFOHEADER;

    BitmapInfoHeader_Struct& header = dibHeader.bitmapInfoHeader;

    header.dib = dib;
    header.width = img->width();
    header.height = img->height();
    header.numberOfColorPlanes = 1;
    header.bpp = img->channels()*8;
    header.compressionMethod = 0;
    header.rawDataSize = 0;
    header.horizontalResolution = 0;
    header.verticalResolution = 0;
    header.paletteColorNumber = 0;
    header.importantColorUsedNumber = 0;

    int rawSize = (int)( (dibHeader.bitmapInfoHeader.bpp * dibHeader.bitmapInfoHeader.width + 31)/32 ) * 4;
    int bufferSize = rawSize * dibHeader.bitmapInfoHeader.height;

    fileHeader.magicNumber = 0x424d;
    fileHeader.dataOffset = 54;
    fileHeader.fileSize = fileHeader.dataOffset + bufferSize;

    std::ofstream os(filename.c_str(), std::ifstream::binary);
    if(os)
    {
        // bmp header
        //magicNumber
        write<char>(os, 0x42);
        write<char>(os, 0x4d);

        write<int>(os, fileHeader.fileSize);
        write<short>(os, 0);
        write<short>(os, 0);
        write<unsigned int>(os, fileHeader.dataOffset);

        // dib header
        BitmapInfoHeader_Struct& header = dibHeader.bitmapInfoHeader;
        write<unsigned int>(os, header.dib);
        write<int>(os, header.width);
        write<int>(os, header.height);
        write<short>(os, header.numberOfColorPlanes);
        write<short>(os, header.bpp);
        write<int>(os, header.compressionMethod);
        write<int>(os, header.rawDataSize);
        write<int>(os, header.horizontalResolution);
        write<int>(os, header.verticalResolution);
        write<int>(os, header.paletteColorNumber);
        write<int>(os, header.importantColorUsedNumber);

        char buffer[rawSize];
        for(int i=0; i<header.height; ++i)
        {
			unsigned char* dataPtr = &(img->asGrid()->data()[i*rawSize]);
			memset(buffer, 0, rawSize);
            memcpy(buffer, dataPtr, rawSize);
            os.write((char*)buffer, rawSize);
        }
        os.flush();
        os.close();
    }
}

//--------------------------------------------------------------
Image::Ptr bmp_load(std::string& filename)
{
    BitmapFileHeader_Struct fileHeader;
    DibHeader_Union dibHeader;
    int dib;

    std::ifstream is(filename.c_str(), std::ifstream::binary);
    if (!is)
	{
        std::cout << "bmp loading failed \"" << filename << "\" : Could not open " << filename << std::endl;
		return nullptr;
	}

	// check bmp file
	if(read<char>(is) != 'B' || read<char>(is) != 'M')
	{
		std::cerr << "bmp loading failed \"" << filename << "\" : bmp magic number FAILED" << std::endl;
		return nullptr;
	}

	// read file header
	fileHeader.fileSize = read<int>(is);
	read<short>(is); // reserved 1
	read<short>(is); // reserved 2
	fileHeader.dataOffset = read<unsigned int>(is);

	dib = read<int>(is);
	if(dib != DIB_BITMAPINFOHEADER && dib != DIB_BITMAPV4HEADER && dib != DIB_BITMAPV5HEADER)
	{
		std::cerr << "bmp loading failed \"" << filename << "\" : DIB not supported : " << dib << std::endl;
		return nullptr;
	}

	BitmapInfoHeader_Struct& header = dibHeader.bitmapInfoHeader;
	header.dib = dib;
	header.width = read<int>(is);
	header.height = read<int>(is);
	header.numberOfColorPlanes = read<short>(is);
	header.bpp = read<short>(is);
	header.compressionMethod = read<int>(is);
	header.rawDataSize = read<int>(is);
	header.horizontalResolution = read<int>(is);
	header.verticalResolution = read<int>(is);
	header.paletteColorNumber = read<int>(is);
	header.importantColorUsedNumber = read<int>(is);

	unsigned int rawSize = (unsigned int)( (header.bpp * header.width + 31)/32 ) * 4; // take floor of [(bpp*width+31)/32]
	// unsigned int bufferSize = rawSize * header.height; // should take absolute value of height

	int chnls = 3;
	if(header.bpp == 24)
		chnls = 3;
	else if(header.bpp == 32)
		chnls = 4;

	// go to pixel data
	seek(is, fileHeader.dataOffset);

	Image::Ptr loaded = Image::create(header.width, header.height, chnls);
	unsigned char buffer[rawSize];
	for(int i=0; i<header.height; ++i)
	{
		is.read((char*)buffer, rawSize);
		memcpy(&(loaded->asGrid()->data()[i*rawSize]), buffer, rawSize);
	}
	return loaded;
}

IMPGEARS_END
<commit_msg>ImageIO can now load TGA<commit_after>#include <Utils/ImageIO.h>

#include <fstream>

// static const char* BM = "BM";

struct BitmapFileHeader_Struct
{
	short magicNumber;         // magic number : BM = 0x42 0x4D (others are possibles...)
	int fileSize;              // size of the bmp file
	short editorReserved1;     // ID editor
	short editorReserved2;     // ID editor
	unsigned int dataOffset;// offset of data
};

// BMP HEADER SIZE
static const unsigned int DIB_BITMAPCOREHEADER = 12;
static const unsigned int DIB_OS21XBITMAPHEADER = DIB_BITMAPCOREHEADER;
static const unsigned int DIB_OS22XBITMAPHEADER = 64;
static const unsigned int DIB_BITMAPINFOHEADER = 40;
static const unsigned int DIB_BITMAPV2INFOHEADER = 52;
static const unsigned int DIB_BITMAPV3INFOHEADER = 56;
static const unsigned int DIB_BITMAPV4HEADER = 108;
static const unsigned int DIB_BITMAPV5HEADER = 124;

struct BitmapCoreHeader_Struct
{
	unsigned int dib;	//offset 0x0E
	unsigned short width;	// offset 0x12
	unsigned short height;	// offset 0x14
	unsigned short numberOfColorPlanes;	// (1) offset 0x16
	unsigned short bpp;	// 0x18
};

static const unsigned int BI_RGB = 0;	// none
/*static const unsigned int BI_RLE8;
static const unsigned int BI_RLE4;
static const unsigned int BI_BITFIELDS;
static const unsigned int BI_JPEG;
static const unsigned int BI_PNG;
static const unsigned int BI_ALPHABITFIELDS;
static const unsigned int BI_CMYK;
static const unsigned int BI_CMYKRLE8;
static const unsigned int BI_CMYKRLE4;*/

struct BitmapInfoHeader_Struct
{
	unsigned int dib;	// offset 0x0E
	signed int width;
	signed int height;
	unsigned short numberOfColorPlanes; // (1)
	unsigned short bpp;
	int compressionMethod; // (0 for none)
	int rawDataSize; // (0 for BI_RGB)
	int horizontalResolution;	// pixel per meter
	int verticalResolution;	// pixel per meter
	int paletteColorNumber; // (0 by default)
	int importantColorUsedNumber; // (0 by default)
};

union DibHeader_Union
{
    BitmapCoreHeader_Struct bitmapCoreHeader;
    BitmapInfoHeader_Struct bitmapInfoHeader;
};

// template for file reading
template<class T>
T read(std::ifstream & stream)
{
    T value;
    stream.read( (char*)&value, sizeof(T) );
    return value;
}
template<class T>
void write(std::ofstream & stream, T value)
{
    stream.write( (char*)&value, sizeof(T) );
}

void seek(std::ifstream& stream, long offset)
{
	stream.seekg(offset);
}
long pos(std::ofstream& stream)
{
	return stream.tellp();
}

IMPGEARS_BEGIN

//--------------------------------------------------------------
void bmp_save(const std::string& filename, const Image::Ptr img);
void tga_save(const std::string& filename, const Image::Ptr img);
Image::Ptr bmp_load(std::string& filename);
Image::Ptr tga_load(std::string& filename);

//--------------------------------------------------------------
ImageIO::ImageIO()
{
}

//--------------------------------------------------------------
ImageIO::~ImageIO()
{
}

//--------------------------------------------------------------
void ImageIO::save(const Image::Ptr image, std::string filename)
{
    save(image,filename,Options());
}

//--------------------------------------------------------------
Image::Ptr ImageIO::load(std::string filename)
{
	return load(filename,Options());
}

//--------------------------------------------------------------
void ImageIO::save(const Image::Ptr image, std::string filename, const Options& opts)
{
    if(opts.fileType == FileType_BMP)
    {
        // todo
        // bmp_save(filename, image);
    }
    else if(opts.fileType == FileType_TGA)
    {
        tga_save(filename, image);
    }
}

//--------------------------------------------------------------
Image::Ptr ImageIO::load(std::string filename, const Options& opts)
{
	Image::Ptr res;
    if(opts.fileType == FileType_BMP)
    {
        res = bmp_load(filename);
    }
    else if(opts.fileType == FileType_TGA)
    {
        res = tga_load(filename);
    }
	return res;
}

Image::Ptr tga_load(std::string& filename)
{
	unsigned short w, h; unsigned char chnl;

    std::ifstream istrm(filename,std::ios::binary);
    unsigned char v = 0;
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); //ID length (1o)
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // Color map type (1o)
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // Image type (1o)

    // if(v == 3) chnl = 1; // black and white
    // if(v == 2) chnl = 3; // TrueColor

    v = 0;	// no color map
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    unsigned short d = 0;
    istrm.read(reinterpret_cast<char*>(&d), sizeof d); // X-origin (2o)
    istrm.read(reinterpret_cast<char*>(&d), sizeof d); // Y-origin (2o)

    istrm.read(reinterpret_cast<char*>(&w), sizeof w); // width (2o)
    istrm.read(reinterpret_cast<char*>(&h), sizeof h); // height (2o)

    istrm.read(reinterpret_cast<char*>(&chnl), sizeof chnl); // px depth (1o)

    // chnl = 1;	// default for black and white
    chnl /= 8;	// 24 for RGB; 32 for RGBA

    v = 0;
    istrm.read(reinterpret_cast<char*>(&v), sizeof v); // description (1o)

    Image::Ptr img = Image::create(w,h,chnl);

    istrm.read(reinterpret_cast<char*>(img->asGrid()->data()), (img->width()*img->height()*img->channels())); // image data
	return img;
}

//--------------------------------------------------------------
void tga_save(const std::string& filename, const Image::Ptr img)
{
    std::ofstream ostrm(filename,std::ios::binary);
    unsigned char v = 0;
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); //ID length (1o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Color map type (1o)
    if(img->channels() == 1) v = 3; // black and white
    if(img->channels() == 3 || img->channels() == 4) v = 2;	// TrueColor
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Image type (1o)
    v = 0;	// no color map
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // Colormap spec (5o)
    unsigned short d = 0;
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // X-origin (2o)
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // Y-origin (2o)
    d = img->width();
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // width (2o)
    d = img->height();
    ostrm.write(reinterpret_cast<char*>(&d), sizeof d); // height (2o)
    // v = 8;	// default for black and white
    v = img->channels() * 8;	// 24 for RGB; 32 for RGBA
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // px depth (1o)
    v = 0;
    ostrm.write(reinterpret_cast<char*>(&v), sizeof v); // description (1o)
    ostrm.write(reinterpret_cast<char*>(img->asGrid()->data()), (img->width()*img->height()*img->channels())); // image data
}

//--------------------------------------------------------------
void bmp_save(const std::string& filename, const Image::Ptr img)
{
    BitmapFileHeader_Struct fileHeader;
    DibHeader_Union dibHeader;
    int dib;

    dib = DIB_BITMAPINFOHEADER;

    BitmapInfoHeader_Struct& header = dibHeader.bitmapInfoHeader;

    header.dib = dib;
    header.width = img->width();
    header.height = img->height();
    header.numberOfColorPlanes = 1;
    header.bpp = img->channels()*8;
    header.compressionMethod = 0;
    header.rawDataSize = 0;
    header.horizontalResolution = 0;
    header.verticalResolution = 0;
    header.paletteColorNumber = 0;
    header.importantColorUsedNumber = 0;

    int rawSize = (int)( (dibHeader.bitmapInfoHeader.bpp * dibHeader.bitmapInfoHeader.width + 31)/32 ) * 4;
    int bufferSize = rawSize * dibHeader.bitmapInfoHeader.height;

    fileHeader.magicNumber = 0x424d;
    fileHeader.dataOffset = 54;
    fileHeader.fileSize = fileHeader.dataOffset + bufferSize;

    std::ofstream os(filename.c_str(), std::ifstream::binary);
    if(os)
    {
        // bmp header
        //magicNumber
        write<char>(os, 0x42);
        write<char>(os, 0x4d);

        write<int>(os, fileHeader.fileSize);
        write<short>(os, 0);
        write<short>(os, 0);
        write<unsigned int>(os, fileHeader.dataOffset);

        // dib header
        BitmapInfoHeader_Struct& header = dibHeader.bitmapInfoHeader;
        write<unsigned int>(os, header.dib);
        write<int>(os, header.width);
        write<int>(os, header.height);
        write<short>(os, header.numberOfColorPlanes);
        write<short>(os, header.bpp);
        write<int>(os, header.compressionMethod);
        write<int>(os, header.rawDataSize);
        write<int>(os, header.horizontalResolution);
        write<int>(os, header.verticalResolution);
        write<int>(os, header.paletteColorNumber);
        write<int>(os, header.importantColorUsedNumber);

        char buffer[rawSize];
        for(int i=0; i<header.height; ++i)
        {
			unsigned char* dataPtr = &(img->asGrid()->data()[i*rawSize]);
			memset(buffer, 0, rawSize);
            memcpy(buffer, dataPtr, rawSize);
            os.write((char*)buffer, rawSize);
        }
        os.flush();
        os.close();
    }
}

//--------------------------------------------------------------
Image::Ptr bmp_load(std::string& filename)
{
    BitmapFileHeader_Struct fileHeader;
    DibHeader_Union dibHeader;
    int dib;

    std::ifstream is(filename.c_str(), std::ifstream::binary);
    if (!is)
	{
        std::cout << "bmp loading failed \"" << filename << "\" : Could not open " << filename << std::endl;
		return nullptr;
	}

	// check bmp file
	if(read<char>(is) != 'B' || read<char>(is) != 'M')
	{
		std::cerr << "bmp loading failed \"" << filename << "\" : bmp magic number FAILED" << std::endl;
		return nullptr;
	}

	// read file header
	fileHeader.fileSize = read<int>(is);
	read<short>(is); // reserved 1
	read<short>(is); // reserved 2
	fileHeader.dataOffset = read<unsigned int>(is);

	dib = read<int>(is);
	if(dib != DIB_BITMAPINFOHEADER && dib != DIB_BITMAPV4HEADER && dib != DIB_BITMAPV5HEADER)
	{
		std::cerr << "bmp loading failed \"" << filename << "\" : DIB not supported : " << dib << std::endl;
		return nullptr;
	}

	BitmapInfoHeader_Struct& header = dibHeader.bitmapInfoHeader;
	header.dib = dib;
	header.width = read<int>(is);
	header.height = read<int>(is);
	header.numberOfColorPlanes = read<short>(is);
	header.bpp = read<short>(is);
	header.compressionMethod = read<int>(is);
	header.rawDataSize = read<int>(is);
	header.horizontalResolution = read<int>(is);
	header.verticalResolution = read<int>(is);
	header.paletteColorNumber = read<int>(is);
	header.importantColorUsedNumber = read<int>(is);

	unsigned int rawSize = (unsigned int)( (header.bpp * header.width + 31)/32 ) * 4; // take floor of [(bpp*width+31)/32]
	// unsigned int bufferSize = rawSize * header.height; // should take absolute value of height

	int chnls = 3;
	if(header.bpp == 24)
		chnls = 3;
	else if(header.bpp == 32)
		chnls = 4;

	// go to pixel data
	seek(is, fileHeader.dataOffset);

	Image::Ptr loaded = Image::create(header.width, header.height, chnls);
	unsigned char buffer[rawSize];
	for(int i=0; i<header.height; ++i)
	{
		is.read((char*)buffer, rawSize);
		memcpy(&(loaded->asGrid()->data()[i*rawSize]), buffer, rawSize);
	}
	return loaded;
}

IMPGEARS_END
<|endoftext|>


<commit_before>/*
 * The Apache Software License, Version 1.1
 *
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xalan" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
#if !defined(AIXDEFINITIONS_HEADER_GUARD_1357924680)
#define AIXDEFINITIONS_HEADER_GUARD_1357924680

// ---------------------------------------------------------------------------
//  A define in the build for each project is also used to control whether
//  the export keyword is from the project's viewpoint or the client's.
//  These defines provide the platform specific keywords that they need
//  to do this.
// ---------------------------------------------------------------------------

#define XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT
#define XALAN_PLATFORM_EXPORT_FUNCTION(T) T XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT_FUNCTION(T) T XALAN_PLATFORM_IMPORT

#define XALAN_OLD_STYLE_CASTS
#define XALAN_NO_NAMESPACES
#define XALAN_NO_MUTABLE
#define XALAN_SGI_BASED_STL
#define XALAN_NO_MEMBER_TEMPLATES
#define XALAN_AMBIGUOUS_EVEN_IF_NOT_CALLED
#define XALAN_CANNOT_MUTATE_ANONYMOUS_OBJECT
#define XALAN_CANNOT_DELETE_CONST
#define XALAN_BOOL_AS_INT
#define XALAN_NO_STD_ALLOCATORS
#define XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION
#define XALAN_NO_ALGORITHMS_WITH_BUILTINS
#define XALAN_AUTO_PTR_NEEDS_DEFINITION
#define XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS
#define XALAN_NO_COVARIANT_RETURN_TYPE
#define XALAN_WIDE_STRING_UCODE_PROBLEM
#define XALAN_RTTI_AVAILABLE
#define XALAN_NO_TYPEINFO
#define XALAN_ICU_BRIDGE_UCHAR_MISMATCH
#define XALAN_LSTRSUPPORT
#define XALAN_AUTO_PTR_REQUIRES_DEFINITION
#define XALAN_NEEDS_EXPLICIT_TEMPLATE_INSTANTIATION

// STL Port Definitions
#define __STL_NO_SGI_IOSTREAMS
#include <stl/_config.h>

#endif	// AIXDEFINITIONS_HEADER_GUARD_1357924680
<commit_msg>Resolve scope for AIX.<commit_after>/*
 * The Apache Software License, Version 1.1
 *
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xalan" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
#if !defined(AIXDEFINITIONS_HEADER_GUARD_1357924680)
#define AIXDEFINITIONS_HEADER_GUARD_1357924680

// ---------------------------------------------------------------------------
//  A define in the build for each project is also used to control whether
//  the export keyword is from the project's viewpoint or the client's.
//  These defines provide the platform specific keywords that they need
//  to do this.
// ---------------------------------------------------------------------------

#define XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT
#define XALAN_PLATFORM_EXPORT_FUNCTION(T) T XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT_FUNCTION(T) T XALAN_PLATFORM_IMPORT

#define XALAN_OLD_STYLE_CASTS
#define XALAN_NO_NAMESPACES
#define XALAN_NO_MUTABLE
#define XALAN_SGI_BASED_STL
#define XALAN_NO_MEMBER_TEMPLATES
#define XALAN_AMBIGUOUS_EVEN_IF_NOT_CALLED
#define XALAN_CANNOT_MUTATE_ANONYMOUS_OBJECT
#define XALAN_CANNOT_DELETE_CONST
#define XALAN_BOOL_AS_INT
#define XALAN_NO_STD_ALLOCATORS
#define XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION
#define XALAN_NO_ALGORITHMS_WITH_BUILTINS
#define XALAN_AUTO_PTR_NEEDS_DEFINITION
#define XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS
#define XALAN_NO_COVARIANT_RETURN_TYPE
#define XALAN_WIDE_STRING_UCODE_PROBLEM
#define XALAN_RTTI_AVAILABLE
#define XALAN_NO_TYPEINFO
#define XALAN_ICU_BRIDGE_UCHAR_MISMATCH
#define XALAN_LSTRSUPPORT
#define XALAN_AUTO_PTR_REQUIRES_DEFINITION
#define XALAN_NEEDS_EXPLICIT_TEMPLATE_INSTANTIATION
#define XALAN_OSTREAM_HAS_WCHAR_T

// STL Port Definitions
#define __STL_NO_SGI_IOSTREAMS
#include <stl/_config.h>

#endif	// AIXDEFINITIONS_HEADER_GUARD_1357924680
<|endoftext|>