diff --git a/Changes b/Changes index 2e102b1959..fb17e701ec 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,12 @@ 10.7.x.x (relative to 10.7.0.0a6) ======== +Breaking Changes +---------------- +- HenyeyGreenstein.h : Removed. +- SweepAndPrune.h : Removed. +- RadixSort.h : Removed. 10.7.0.0a6 (relative to 10.7.0.0a5) ========== diff --git a/include/IECore/HenyeyGreenstein.h b/include/IECore/HenyeyGreenstein.h deleted file mode 100644 index 4b61b7cb15..0000000000 --- a/include/IECore/HenyeyGreenstein.h +++ /dev/null @@ -1,57 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 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. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORE_HENYEYGREENSTEIN_H -#define IECORE_HENYEYGREENSTEIN_H - -namespace IECore -{ - -/// Vectors must be normalized already. -template -inline typename Vec::BaseType henyeyGreenstein( typename Vec::BaseType g, const Vec &incident, const Vec &outgoing ); - -/// Theta in radians. -template -inline T henyeyGreenstein( T g, T theta ); - -template -inline T henyeyGreensteinCT( T g, T cosTheta ); - - -} // namespace IECore - -#include "IECore/HenyeyGreenstein.inl" - -#endif // IECORE_HENYEYGREENSTEIN_H diff --git a/include/IECore/HenyeyGreenstein.inl b/include/IECore/HenyeyGreenstein.inl deleted file mode 100644 index 0defb9ce4f..0000000000 --- a/include/IECore/HenyeyGreenstein.inl +++ /dev/null @@ -1,67 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 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. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECORE_HENYEYGREENSTEIN_INL -#define IECORE_HENYEYGREENSTEIN_INL - -#include "IECore/Math.h" - -namespace IECore -{ - -template -inline typename Vec::BaseType henyeyGreenstein( typename Vec::BaseType g, const Vec &incident, const Vec &outgoing ) -{ - return henyeyGreensteinCT( g, incident.dot( outgoing ) ); -} - -template -inline T henyeyGreenstein( T g, T theta ) -{ - return henyeyGreensteinCT( g, std::cos( theta ) ); -} - -template -inline T henyeyGreensteinCT( T g, T cosTheta ) -{ - T g2 = g * g; - T top = T( 1 ) - g2; - T bottom = T( 1 ) + g2 - ( T( 2 ) * g * cosTheta ); - bottom = T( 4 * M_PI ) * std::pow( bottom, T( 1.5 ) ); - return top / bottom; -} - -} // namespace IECore - -#endif // IECORE_HENYEYGREENSTEIN_INL diff --git a/include/IECore/RadixSort.h b/include/IECore/RadixSort.h deleted file mode 100644 index 45ce4cb628..0000000000 --- a/include/IECore/RadixSort.h +++ /dev/null @@ -1,98 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, 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. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_CORE_RADIXSORT_H -#define IE_CORE_RADIXSORT_H - -#include "IECore/Export.h" -#include "IECore/VectorTypedData.h" - -#include - -namespace IECore -{ - -/// A RadixSort implementation derived from Pierre Terdiman's OPCODE library, which has as "free for use in any commercial -/// or non-commercial program" licence. The RadixSort class maintains state so that successive calls to it are able to exploit any coherence -/// in the source data. Sorting is done in ascending order. -/// \ingroup mathGroup -class IECORE_API RadixSort -{ - public: - - static_assert( sizeof( int ) == 4 ); - static_assert( sizeof( unsigned int ) == 4 ); - static_assert( sizeof( float ) == 4 ); - - RadixSort(); - virtual ~RadixSort(); - - /// Sort the given vector of floats, returning a vector of indices representing a mapping from - /// the given input to the sorted result. For example, the position of input[3] in the sorted result can be - /// found in indices[3]. - const std::vector &operator()( const std::vector &input ); - - /// Sort the given vector of unsigned ints, returning a vector of indices representing a mapping from - /// the given input to the sorted result. For example, the position of input[3] in the sorted result can be - /// found in indices[3]. - const std::vector &operator()( const std::vector &input ); - - /// Sort the given vector of signed ints, returning a vector of indices representing a mapping from - /// the given input to the sorted result. For example, the position of input[3] in the sorted result can be - /// found in indices[3]. - const std::vector &operator()( const std::vector &input ); - - private: - - template - bool createHistograms( const std::vector &input ); - - unsigned int m_currentSize; - - unsigned int m_histogram[1024]; - unsigned int *m_link[256]; - - UIntVectorDataPtr m_ranks; - UIntVectorDataPtr m_ranks2; - - template - bool checkPassValidity( const std::vector &input, unsigned int j, unsigned int* &curCount, unsigned char &uniqueVal ); - - void resize( unsigned int s ); - void checkResize( unsigned int s ); -}; - -} // namespace IECore - -#endif // IE_CORE_RADIXSORT_H diff --git a/include/IECore/SweepAndPrune.h b/include/IECore/SweepAndPrune.h deleted file mode 100644 index 9eb0a1bfbc..0000000000 --- a/include/IECore/SweepAndPrune.h +++ /dev/null @@ -1,81 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2011, 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. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_CORE_SWEEPANDPRUNE_H -#define IE_CORE_SWEEPANDPRUNE_H - -#include "IECore/RadixSort.h" - -#include - -namespace IECore -{ - -/// \ingroup mathGroup -template class CB> -class SweepAndPrune -{ - public: - typedef BoundIterator Iterator; - typedef typename std::iterator_traits::value_type Bound; - - typedef CB Callback; - - typedef enum - { - XYZ, - XZY, - YXZ, - YZX, - ZXY, - ZYX - } AxisOrder; - - SweepAndPrune(); - virtual ~SweepAndPrune(); - - void intersectingBounds( BoundIterator first, BoundIterator last, Callback &cb, AxisOrder axisOrder = XZY ); - - protected: - - inline bool axisIntersects( const Bound &b1, const Bound &b2, char axis ); - - RadixSort m_radixSort; -}; - -} // namespace IECore - -#include "IECore/SweepAndPrune.inl" - -#endif // IE_CORE_SWEEPANDPRUNE_H diff --git a/include/IECore/SweepAndPrune.inl b/include/IECore/SweepAndPrune.inl deleted file mode 100644 index dfcfffe193..0000000000 --- a/include/IECore/SweepAndPrune.inl +++ /dev/null @@ -1,177 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 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. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IE_CORE_SWEEPANDPRUNE_INL -#define IE_CORE_SWEEPANDPRUNE_INL - -#include "IECore/BoxTraits.h" -#include "IECore/VectorOps.h" - -#include -#include -#include - -#include - -namespace IECore -{ - -template class CB> -SweepAndPrune::SweepAndPrune( ) -{ -} - -template class CB> -SweepAndPrune::~SweepAndPrune( ) -{ -} - -template class CB> -bool SweepAndPrune::axisIntersects( const Bound &b0, const Bound &b1, char axis ) -{ - if ( vecGet( BoxTraits::max(b0), axis ) < vecGet( BoxTraits::min(b1), axis ) - || vecGet( BoxTraits::min(b0), axis ) > vecGet( BoxTraits::max(b1), axis ) ) - { - assert( !b0.intersects(b1) ); - return false; - } - - return true; -} - -template class CB> -void SweepAndPrune::intersectingBounds( BoundIterator first, BoundIterator last, typename SweepAndPrune::Callback &cb, AxisOrder axisOrder ) -{ - size_t numBounds = std::distance( first, last ); - - /// Can't radix sort more than this! - assert( numBounds <= std::numeric_limits< uint32_t >::max() ); - - if (! numBounds ) - { - return; - } - - char axes[3] = { 0, 1, 2 }; - - switch (axisOrder) - { - case XYZ : - axes[0] = 0; axes[1] = 1; axes[2] = 2; break; - case XZY : - axes[0] = 0; axes[1] = 2; axes[2] = 1; break; - case YXZ : - axes[0] = 1; axes[1] = 0; axes[2] = 2; break; - case YZX : - axes[0] = 1; axes[1] = 2; axes[2] = 0; break; - case ZXY : - axes[0] = 2; axes[1] = 0; axes[2] = 1; break; - case ZYX : - axes[0] = 2; axes[1] = 1; axes[2] = 0; break; - default: - assert( false ); - } - - assert( axes[0] + axes[1] + axes[2] == 3 ); - - typedef std::pair< bool, BoundIterator> IntervalId; - - std::vector intervalIds; - std::vector boundExtents; - boundExtents.reserve( numBounds * 2 ); - intervalIds.reserve( numBounds * 2 ); - - for ( BoundIterator it = first; it != last; ++it ) - { - boundExtents.push_back( vecGet( BoxTraits::min(*it), axes[0] ) ); - intervalIds.push_back( IntervalId( true, it ) ); - - boundExtents.push_back( vecGet( BoxTraits::max(*it), axes[0] ) ); - intervalIds.push_back( IntervalId( false, it ) ); - } - - assert( boundExtents.size() == intervalIds.size() ); - - const std::vector &sortedIndices = m_radixSort( boundExtents ); - - typedef std::vector ActiveSet; - ActiveSet activeSet; - - for ( std::vector::const_iterator st = sortedIndices.begin(); st != sortedIndices.end(); ++st ) - { - const IntervalId &id = intervalIds[ *st ]; - - if ( id.first ) - { - const Bound& bound0 = *id.second; - - for ( typename ActiveSet::const_iterator it = activeSet.begin(); it != activeSet.end(); it++ ) - { - assert( id.second != *it ); - - if ( axisIntersects( bound0, **it, axes[1] ) ) - { - if ( axisIntersects( bound0, **it, axes[2] ) ) - { - assert( bound0.intersects( **it ) ); - - cb( id.second, *it ); - } - else - { - assert( !bound0.intersects( **it ) ); - } - } - else - { - assert( !bound0.intersects( **it ) ); - } - } - - activeSet.push_back( id.second ); - } - else - { - assert( activeSet.size() ); - typename ActiveSet::iterator it = std::find ( activeSet.begin(), activeSet.end(), id.second ); - assert( it != activeSet.end() ); - activeSet.erase( it ); - } - } -} - -} // namespace IECore - - -#endif // IE_CORE_SWEEPANDPRUNE_INL diff --git a/include/IECorePython/HenyeyGreensteinBinding.h b/include/IECorePython/HenyeyGreensteinBinding.h deleted file mode 100644 index 9ecc309a0a..0000000000 --- a/include/IECorePython/HenyeyGreensteinBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, 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. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_HENYEYGREENSTEINBINDING_H -#define IECOREPYTHON_HENYEYGREENSTEINBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ -IECOREPYTHON_API void bindHenyeyGreenstein(); -} - -#endif // IECOREPYTHON_HENYEYGREENSTEINBINDING_H diff --git a/include/IECorePython/RadixSortBinding.h b/include/IECorePython/RadixSortBinding.h deleted file mode 100644 index ec67cdcec2..0000000000 --- a/include/IECorePython/RadixSortBinding.h +++ /dev/null @@ -1,46 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, 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. -// -////////////////////////////////////////////////////////////////////////// - -#ifndef IECOREPYTHON_RADIXSORTBINDING_H -#define IECOREPYTHON_RADIXSORTBINDING_H - -#include "IECorePython/Export.h" - -namespace IECorePython -{ -IECOREPYTHON_API void bindRadixSort(); -} - -#endif // IECOREPYTHON_RADIXSORTBINDING_H - diff --git a/src/IECore/RadixSort.cpp b/src/IECore/RadixSort.cpp deleted file mode 100644 index eb70a51749..0000000000 --- a/src/IECore/RadixSort.cpp +++ /dev/null @@ -1,505 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 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. -// -////////////////////////////////////////////////////////////////////////// - -#include "IECore/RadixSort.h" - -#include "IECore/ByteOrder.h" - -#include - -using namespace IECore; - -static_assert( sizeof(int) == 4 ); -static_assert( sizeof(unsigned int) == 4 ); -static_assert( sizeof(float) == 4 ); - -RadixSort::RadixSort() : m_currentSize( 0 ), m_ranks( nullptr ), m_ranks2( nullptr ) -{ - m_ranks = new UIntVectorData(); - m_ranks2 = new UIntVectorData(); - - m_currentSize |= 0x80000000; -} - -RadixSort::~RadixSort() -{ -} - -void RadixSort::resize( unsigned int s ) -{ - m_ranks->writable().resize( s ); - m_ranks2->writable().resize( s ); -} - -template -bool RadixSort::checkPassValidity( const std::vector &input, unsigned int pass, unsigned int* &curCount, unsigned char &uniqueVal ) -{ - curCount = &m_histogram[ pass << 8 ]; - -#ifdef IE_CORE_BIG_ENDIAN - uniqueVal = *((( unsigned char* )( &input[0] ) ) + sizeof(T) - 1 - pass ); -#else - uniqueVal = *((( unsigned char* )( &input[0] ) ) + pass ); -#endif - - if ( curCount[ uniqueVal ] == input.size() ) - { - return false; - } - - return true; -} - -void RadixSort::checkResize( unsigned int s ) -{ - unsigned int curSize = ( m_currentSize & 0x7fffffff ); - - if ( s != curSize ) - { - resize( s ); - - m_currentSize = s; - m_currentSize |= 0x80000000; - } -} - -const std::vector &RadixSort::operator()( const std::vector &input2 ) -{ - const unsigned int nb = input2.size(); - checkResize( nb ); - - if ( !nb ) - { - assert( m_ranks ); - return m_ranks->readable(); - } - - const unsigned int *input = ( const unsigned int * ) &input2[0]; - - bool alreadySorted = createHistograms< float >( input2 ); - if ( alreadySorted ) - { - return m_ranks->readable(); - } - - unsigned int numNegativeValues = 0; - - const unsigned int *h3 = &m_histogram[ 768 ]; - for ( unsigned int i = 128; i < 256; i ++ ) - { - numNegativeValues += h3[i]; - } - - for ( unsigned int j = 0; j < 4; j ++ ) - { - if ( j != 3 ) - { - unsigned char uniqueVal = 0; - unsigned int *curCount = nullptr; - - bool performPass = checkPassValidity( input2, j, curCount, uniqueVal ); - - if ( performPass ) - { - m_link[0] = &m_ranks2->writable()[0]; - - for ( unsigned int i = 1; i < 256; i++ ) - { - m_link[i] = m_link[ i - 1 ] + curCount[ i - 1 ]; - } - - const unsigned char *inputBytes = ( const unsigned char * ) input; -#ifdef IE_CORE_BIG_ENDIAN - inputBytes += sizeof(float) - 1 - j; -#else - inputBytes += j; -#endif - - if ( m_currentSize & 0x80000000 ) - { - for ( unsigned int i = 0; i < nb; i++ ) - { - *m_link[ inputBytes[i<<2] ]++ = i; - } - m_currentSize&=0x7fffffff; - } - else - { - for ( UIntVectorData::ValueType::const_iterator it = m_ranks->readable().begin(); it != m_ranks->readable().end(); ++it ) - { - unsigned int id = *it; - *m_link[ inputBytes[ id << 2 ] ]++ = id; - } - } - - std::swap( m_ranks, m_ranks2 ); - } - } - else - { - unsigned char uniqueVal = 0; - unsigned int *curCount = nullptr; - bool performPass = checkPassValidity( input2, j, curCount, uniqueVal ); - - if ( performPass ) - { - m_link[0] = &m_ranks2->writable()[numNegativeValues]; - for ( unsigned int i = 1; i < 128; i++ ) - { - m_link[i] = m_link[ i - 1 ] + curCount[ i - 1 ]; - } - - m_link[255] = &m_ranks2->writable()[0]; - for ( unsigned int i = 0; i < 127; i ++ ) - { - m_link[254 - i ] = m_link[255-i] + curCount[255 - i ]; - } - - for ( unsigned int i = 128; i < 256; i ++ ) - { - m_link[i] += curCount[i]; - } - - if ( m_currentSize & 0x80000000 ) - { - for ( unsigned int i = 0; i < nb; i++ ) - { - unsigned int radix = input[i] >> 24; - - if ( radix < 128 ) - { - *m_link[ radix ]++ = i; - } - else - { - *( --m_link[ radix] ) = i; - } - } - m_currentSize&=0x7fffffff; - } - else - { - for ( unsigned int i = 0; i < nb; i ++ ) - { - unsigned int radix = input[ m_ranks->readable()[i] ] >> 24; - - if ( radix < 128 ) - { - *m_link[ radix ] ++ = m_ranks->readable()[i]; - } - else - { - *( --m_link[ radix ] ) = m_ranks->readable()[i]; - } - } - } - - std::swap( m_ranks, m_ranks2 ); - } - else - { - if ( uniqueVal >= 128 ) - { - if ( m_currentSize & 0x80000000 ) - { - for ( unsigned int i = 0; i < nb; i++ ) - { - m_ranks2->writable()[i] = nb - i - 1; - } - m_currentSize&=0x7fffffff; - } - else - { - for ( unsigned int i = 0; i < nb; i++ ) - { - m_ranks2->writable()[i] = m_ranks->readable()[ nb - i - 1 ]; - } - } - - std::swap( m_ranks, m_ranks2 ); - } - } - } - } - - return m_ranks->readable(); -} - -const std::vector &RadixSort::operator()( const std::vector &input2 ) -{ - const unsigned int nb = input2.size(); - checkResize( nb ); - - if ( !nb ) - { - return m_ranks->readable(); - } - const unsigned int *input = &input2[0]; - - bool alreadySorted = createHistograms< unsigned int >( input2 ); - if ( alreadySorted ) - { - return m_ranks->readable(); - } - - for ( unsigned int j = 0; j < 4; j ++ ) - { - unsigned char uniqueVal = 0; - unsigned int *curCount = nullptr; - bool performPass = checkPassValidity( input2, j, curCount, uniqueVal ); - - if ( performPass ) - { - m_link[0] = &m_ranks2->writable()[0]; - - for( unsigned int i = 1; i < 256; i++ ) - { - m_link[i] = m_link[i - 1] + curCount[ i - 1 ]; - } - - const unsigned char *inputBytes = ( const unsigned char * )( input ); -#ifdef IE_CORE_BIG_ENDIAN - inputBytes += sizeof(unsigned int) - 1 - j; -#else - inputBytes += j; -#endif - - if (m_currentSize & 0x80000000) - { - for ( unsigned int i = 0; i < nb; i++ ) - { - *m_link[ inputBytes[ (i<<2) ] ]++ = i; - } - m_currentSize &= 0x7fffffff; - } - else - { - for ( UIntVectorData::ValueType::const_iterator it = m_ranks->readable().begin(); it != m_ranks->readable().end(); ++it ) - { - unsigned int id = *it; - - *m_link[ inputBytes[ (id << 2) ] ]++ = id; - } - } - - std::swap( m_ranks, m_ranks2 ); - } - } - - return m_ranks->readable(); -} - -const std::vector &RadixSort::operator()( const std::vector &input2 ) -{ - const unsigned int nb = input2.size(); - checkResize( nb ); - - if ( !nb ) - { - return m_ranks->readable(); - } - const unsigned int *input = ( const unsigned int * ) &input2[0]; - - bool alreadySorted = createHistograms< int >( input2 ); - if ( alreadySorted ) - { - return m_ranks->readable(); - } - - unsigned int numNegativeValues = 0; - unsigned int* h3= &m_histogram[768]; - for ( unsigned int i = 128; i < 256; i++ ) - { - numNegativeValues += h3[i]; - } - - for ( unsigned int j = 0; j < 4; j ++ ) - { - unsigned char uniqueVal = 0; - unsigned int *curCount = nullptr; - bool performPass = checkPassValidity( input2, j, curCount, uniqueVal ); - - if ( performPass ) - { - if ( j != 3 ) - { - m_link[0] = &m_ranks2->writable()[0]; - - for( unsigned int i = 1; i < 256; i++ ) - { - m_link[i] = m_link[i - 1] + curCount[ i - 1 ]; - } - } - else - { - m_link[0] = &m_ranks2->writable()[numNegativeValues]; - for( unsigned int i = 1; i < 128; i++ ) - { - m_link[i] = m_link[i - 1] + curCount[ i - 1 ]; - } - m_link[128] = &m_ranks2->writable()[0]; - for( unsigned int i = 129; i < 256; i++ ) - { - m_link[i] = m_link[i - 1] + curCount[ i - 1 ]; - } - } - - const unsigned char *inputBytes = ( const unsigned char * )( input ); -#ifdef IE_CORE_BIG_ENDIAN - inputBytes += sizeof(int) - 1 - j; -#else - inputBytes += j; -#endif - - if (m_currentSize & 0x80000000) - { - for ( unsigned int i = 0; i < nb; i++ ) - { - *m_link[ inputBytes[ i<<2 ] ]++ = i; - } - m_currentSize &= 0x7fffffff; - } - else - { - for ( UIntVectorData::ValueType::const_iterator it = m_ranks->readable().begin(); it != m_ranks->readable().end(); ++it ) - { - unsigned int id = *it; - *m_link[ inputBytes[ id << 2 ] ]++ = id; - } - } - - std::swap( m_ranks, m_ranks2 ); - } - } - - return m_ranks->readable(); -} - - -template -bool RadixSort::createHistograms( const std::vector &input ) -{ - static_assert( sizeof(T) == 4 ); - - memset( &m_histogram[0], 0, 256 * 4 * sizeof( unsigned int ) ); - - const unsigned char *p = reinterpret_cast< const unsigned char * > ( &input[0] ); - const unsigned char *pEnd = &p[ input.size() * 4 ] ; - -#ifdef IE_CORE_BIG_ENDIAN - unsigned int *h3 = &m_histogram[0]; - unsigned int *h2 = &m_histogram[256]; - unsigned int *h1 = &m_histogram[512]; - unsigned int *h0 = &m_histogram[768]; -#else - unsigned int *h0 = &m_histogram[0]; - unsigned int *h1 = &m_histogram[256]; - unsigned int *h2 = &m_histogram[512]; - unsigned int *h3 = &m_histogram[768]; -#endif - - bool alreadySorted = true; - - if ( m_currentSize & 0x80000000 ) - { - const T *running = &input[0]; - T prevVal = *running; - - while ( p != pEnd ) - { - T val = *running++; - - if ( val < prevVal ) - { - alreadySorted = false; - break; - } - - prevVal = val; - - h0[ *p++ ] ++; - h1[ *p++ ] ++; - h2[ *p++ ] ++; - h3[ *p++ ] ++; - } - - if ( alreadySorted ) - { - for ( unsigned int i = 0; i < input.size(); i ++ ) - { - m_ranks->writable()[i] = i; - } - return true; - } - } - else - { - const unsigned int* indices = &m_ranks->readable()[0]; - T prevVal = input[ *indices ]; - - while ( p != pEnd ) - { - T val = input[ *indices++ ]; - if ( val < prevVal ) - { - alreadySorted = false; - break; - } - - prevVal = val; - - h0[ *p++ ] ++; - h1[ *p++ ] ++; - h2[ *p++ ] ++; - h3[ *p++ ] ++; - } - - if ( alreadySorted ) - { - return true; - } - - } - - while ( p != pEnd ) - { - h0[ *p++ ] ++; - h1[ *p++ ] ++; - h2[ *p++ ] ++; - h3[ *p++ ] ++; - } - - return false; -} - diff --git a/src/IECorePython/HenyeyGreensteinBinding.cpp b/src/IECorePython/HenyeyGreensteinBinding.cpp deleted file mode 100644 index 70923f36ce..0000000000 --- a/src/IECorePython/HenyeyGreensteinBinding.cpp +++ /dev/null @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, 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. -// -////////////////////////////////////////////////////////////////////////// - -// This include needs to be the very first to prevent problems with warnings -// regarding redefinition of _POSIX_C_SOURCE -#include "boost/python.hpp" - -#include "IECorePython/HenyeyGreensteinBinding.h" - -#include "IECore/Export.h" -#include "IECore/HenyeyGreenstein.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathVec.h" -IECORE_POP_DEFAULT_VISIBILITY - -using namespace boost::python; -using namespace IECore; - -namespace IECorePython -{ - -void bindHenyeyGreenstein() -{ - def( "henyeyGreenstein", (double (*)( double, const Imath::V3d &, const Imath::V3d & ))&henyeyGreenstein ); - def( "henyeyGreenstein", (double (*)( double, double ))&henyeyGreenstein ); - def( "henyeyGreensteinCT", &henyeyGreensteinCT ); -} - -} diff --git a/src/IECorePython/RadixSortBinding.cpp b/src/IECorePython/RadixSortBinding.cpp deleted file mode 100644 index 1cb78ad7d6..0000000000 --- a/src/IECorePython/RadixSortBinding.cpp +++ /dev/null @@ -1,72 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2010, 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. -// -////////////////////////////////////////////////////////////////////////// - -#include "boost/python.hpp" - -#include "IECorePython/RadixSortBinding.h" - -#include "IECore/RadixSort.h" - -using namespace IECore; -using namespace boost::python; -using namespace IECore; - -namespace IECorePython -{ - -struct RadixSortWrapper : public RadixSort -{ - template - UIntVectorDataPtr sort( typename TypedData< std::vector >::ConstPtr input ) - { - const std::vector &indices = this->operator()( input->readable() ); - - UIntVectorDataPtr result = new UIntVectorData(); - result->writable().assign( indices.begin(), indices.end() ); - - return result; - } -}; - -void bindRadixSort() -{ - class_< RadixSortWrapper, boost::noncopyable>( "RadixSort", no_init ) - .def( init<>() ) - .def( "sort", &RadixSortWrapper::sort ) - .def( "sort", &RadixSortWrapper::sort ) - .def( "sort", &RadixSortWrapper::sort ) - ; -} - -} diff --git a/src/IECorePythonModule/IECore.cpp b/src/IECorePythonModule/IECore.cpp index a7c02308ec..e3f9d898e1 100644 --- a/src/IECorePythonModule/IECore.cpp +++ b/src/IECorePythonModule/IECore.cpp @@ -110,14 +110,12 @@ #include "IECorePython/BezierAlgoBinding.h" #include "IECorePython/ToCoreConverterBinding.h" #include "IECorePython/PolygonAlgoBinding.h" -#include "IECorePython/RadixSortBinding.h" #include "IECorePython/AngleConversionBinding.h" #include "IECorePython/SplineBinding.h" #include "IECorePython/SplineDataBinding.h" #include "IECorePython/RampBinding.h" #include "IECorePython/RampDataBinding.h" #include "IECorePython/ObjectVectorBinding.h" -#include "IECorePython/HenyeyGreensteinBinding.h" #include "IECorePython/OversamplesCalculatorBinding.h" #include "IECorePython/DateTimeDataBinding.h" #include "IECorePython/FrameListBinding.h" @@ -261,14 +259,12 @@ BOOST_PYTHON_MODULE(_IECore) bindBezierAlgo(); bindToCoreConverter(); bindPolygonAlgo(); - bindRadixSort(); bindAngleConversion(); bindSpline(); bindSplineData(); bindRamp(); bindRampData(); bindObjectVector(); - bindHenyeyGreenstein(); bindDateTimeData(); bindFrameList(); bindEmptyFrameList(); diff --git a/test/IECore/All.py b/test/IECore/All.py index 42a10e4632..04cb8a598f 100644 --- a/test/IECore/All.py +++ b/test/IECore/All.py @@ -102,7 +102,6 @@ from CubicBasisTest import * from BezierAlgoTest import * from UnicodeToStringTest import * -from RadixSortTest import * from AngleConversionTest import * from SplineTest import * from SplineDataTest import * diff --git a/test/IECore/IECoreTest.cpp b/test/IECore/IECoreTest.cpp index bd77eac4d5..234c16a1e0 100644 --- a/test/IECore/IECoreTest.cpp +++ b/test/IECore/IECoreTest.cpp @@ -51,8 +51,6 @@ IECORE_POP_DEFAULT_VISIBILITY #include "DataConvertTest.h" #include "DespatchTypedDataTest.h" #include "CompilerTest.h" -#include "RadixSortTest.h" -#include "SweepAndPruneTest.h" #include "InternedStringTest.h" #include "LevenbergMarquardtTest.h" #include "SpaceTransformTest.h" @@ -86,8 +84,6 @@ bool init() addDataConvertTest(test); addDespatchTypedDataTest(test); addCompilerTest(test); - addRadixSortTest(test); - addSweepAndPruneTest(test); addLevenbergMarquardtTest(test); addSpaceTransformTest(test); addLookupTest(test); diff --git a/test/IECore/RadixSortTest.cpp b/test/IECore/RadixSortTest.cpp deleted file mode 100644 index 0cf8ce1487..0000000000 --- a/test/IECore/RadixSortTest.cpp +++ /dev/null @@ -1,47 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 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. -// -////////////////////////////////////////////////////////////////////////// - -#include "RadixSortTest.h" - -#include - -namespace IECore -{ - -void addRadixSortTest(boost::unit_test::test_suite* test) -{ - test->add( new RadixSortTestSuite() ); -} - -} diff --git a/test/IECore/RadixSortTest.h b/test/IECore/RadixSortTest.h deleted file mode 100644 index ec34ebb21d..0000000000 --- a/test/IECore/RadixSortTest.h +++ /dev/null @@ -1,115 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2009, 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. -// -////////////////////////////////////////////////////////////////////////// - - -#ifndef IE_CORE_RADIXSORTTEST_H -#define IE_CORE_RADIXSORTTEST_H - -#include "IECore/Export.h" -#include "IECore/RadixSort.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "boost/test/unit_test.hpp" -IECORE_POP_DEFAULT_VISIBILITY - -#include "boost/random.hpp" - -#include -#include -#include -#include - -#include - -using namespace Imath; - -namespace IECore -{ - -void addRadixSortTest( boost::unit_test::test_suite* test ); - -struct RadixSortTest -{ - template - void test() - { - unsigned seed = 42; - boost::mt19937 generator( static_cast( seed ) ); - - boost::uniform_real<> uni_dist( std::numeric_limits::min(), std::numeric_limits::max() ); - boost::variate_generator > uni( generator, uni_dist ); - - // Run 50 tests, each sorting 100000 numbers - const unsigned numTests = 50u; - const unsigned numValuesPerTest = 100000u; - - for ( unsigned i = 0; i < numTests; i ++ ) - { - std::vector input; - - for ( unsigned n = 0; n < numValuesPerTest; n++ ) - { - input.push_back( static_cast( uni() ) ); - } - - RadixSort sorter; - - const std::vector &indices = sorter( input ); - BOOST_CHECK_EQUAL( indices.size(), numValuesPerTest ); - - for ( unsigned n = 1; n < numValuesPerTest; n++ ) - { - BOOST_CHECK(( input[ indices[n] ] >= input[ indices[n - 1] ] ) ); - } - } - } -}; - -struct RadixSortTestSuite : public boost::unit_test::test_suite -{ - - RadixSortTestSuite() : boost::unit_test::test_suite( "RadixSortTestSuite" ) - { - static boost::shared_ptr instance( new RadixSortTest() ); - - add( BOOST_CLASS_TEST_CASE( &RadixSortTest::test, instance ) ); - add( BOOST_CLASS_TEST_CASE( &RadixSortTest::test, instance ) ); - add( BOOST_CLASS_TEST_CASE( &RadixSortTest::test, instance ) ); - } - -}; -} - - -#endif // IE_CORE_RADIXSORTTEST_H diff --git a/test/IECore/RadixSortTest.py b/test/IECore/RadixSortTest.py deleted file mode 100644 index e4af51edec..0000000000 --- a/test/IECore/RadixSortTest.py +++ /dev/null @@ -1,101 +0,0 @@ -########################################################################## -# -# Copyright (c) 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. -# -########################################################################## - -import random -import unittest -import IECore - -class RadixSortTest( unittest.TestCase ) : - - def testFloat( self ) : - - random.seed( 12 ) - - s = IECore.RadixSort() - - d = IECore.FloatVectorData() - - for i in range( 0, 10000 ): - d.append( random.uniform( IECore.FloatData().minValue, IECore.FloatData().maxValue ) ) - - idx = s.sort( d ) - - self.assertEqual( len(idx), 10000 ) - - for i in range( 1, 10000 ): - - self.assertTrue( d[ idx[ i ] ] >= d[ idx[ i - 1 ] ] ) - - def testInt( self ) : - - random.seed( 13 ) - - s = IECore.RadixSort() - - d = IECore.IntVectorData() - - for i in range( 0, 10000 ): - d.append( int( random.uniform( IECore.IntData().minValue, IECore.IntData().maxValue ) ) ) - - idx = s.sort( d ) - - self.assertEqual( len(idx), 10000 ) - - for i in range( 1, 10000 ): - - self.assertTrue( d[ idx[ i ] ] >= d[ idx[ i - 1 ] ] ) - - def testUInt( self ) : - - random.seed( 14 ) - - s = IECore.RadixSort() - - d = IECore.UIntVectorData() - - for i in range( 0, 10000 ): - d.append( int( random.uniform( IECore.UIntData().minValue, IECore.UIntData().maxValue ) ) ) - - idx = s.sort( d ) - - self.assertEqual( len(idx), 10000 ) - - for i in range( 1, 10000 ): - - self.assertTrue( d[ idx[ i ] ] >= d[ idx[ i - 1 ] ] ) - - -if __name__ == "__main__": - unittest.main() - diff --git a/test/IECore/SweepAndPruneTest.cpp b/test/IECore/SweepAndPruneTest.cpp deleted file mode 100644 index f2daea3775..0000000000 --- a/test/IECore/SweepAndPruneTest.cpp +++ /dev/null @@ -1,47 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 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. -// -////////////////////////////////////////////////////////////////////////// - -#include "SweepAndPruneTest.h" - -#include - -namespace IECore -{ - -void addSweepAndPruneTest(boost::unit_test::test_suite* test) -{ - test->add( new SweepAndPruneTestSuite() ); -} - -} diff --git a/test/IECore/SweepAndPruneTest.h b/test/IECore/SweepAndPruneTest.h deleted file mode 100644 index c04effd774..0000000000 --- a/test/IECore/SweepAndPruneTest.h +++ /dev/null @@ -1,192 +0,0 @@ -////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2008-2009, 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. -// -////////////////////////////////////////////////////////////////////////// - - -#ifndef IE_CORE_SWEEPANDPRUNETEST_H -#define IE_CORE_SWEEPANDPRUNETEST_H - -#include "IECore/BoxTraits.h" -#include "IECore/Export.h" -#include "IECore/SweepAndPrune.h" -#include "IECore/VectorOps.h" -#include "IECore/VectorTraits.h" - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "Imath/ImathBox.h" -#include "Imath/ImathVec.h" -IECORE_POP_DEFAULT_VISIBILITY - -IECORE_PUSH_DEFAULT_VISIBILITY -#include "boost/test/unit_test.hpp" -IECORE_POP_DEFAULT_VISIBILITY - -#include "boost/random.hpp" - -#include -#include -#include -#include - -#include - -using namespace Imath; - -namespace IECore -{ - -void addSweepAndPruneTest( boost::unit_test::test_suite* test ); - -struct SweepAndPruneTest -{ - template - struct TestCallback - { - typedef std::set< std::pair< unsigned int, unsigned int > > IntersectingBoundIndices; - IntersectingBoundIndices m_indices; - - BoundIterator m_begin; - unsigned int m_numBoxesPerTest; - - TestCallback( BoundIterator begin, unsigned int numBoxesPerTest ) : m_begin( begin ), m_numBoxesPerTest( numBoxesPerTest ) - { - } - - void operator()( BoundIterator b1, BoundIterator b2 ) - { - BOOST_CHECK( b1->intersects( *b2 ) ); - - unsigned int idx0 = std::distance( m_begin, b1 ); - unsigned int idx1 = std::distance( m_begin, b2 ); - - BOOST_CHECK( idx0 < m_numBoxesPerTest ); - BOOST_CHECK( idx1 < m_numBoxesPerTest ); - - BOOST_CHECK( idx0 != idx1 ); -#ifndef NDEBUG - unsigned oldSize = m_indices.size(); -#endif - - m_indices.insert( IntersectingBoundIndices::value_type( idx0, idx1 ) ); - m_indices.insert( IntersectingBoundIndices::value_type( idx1, idx0 ) ); - - assert( m_indices.size() == oldSize + 2); - } - }; - - template - void test() - { - unsigned seed = 42; - boost::mt19937 generator( static_cast( seed ) ); - - typedef typename BoxTraits::BaseType VecType; - - boost::uniform_real<> uni_dist( 0.0f, 1.0f ); - boost::variate_generator > uni( generator, uni_dist ); - - // Run 50 tests, each intersecting 1000 boxes within a random 5x5x5 world - const unsigned numTests = 10u; - const unsigned numBoxesPerTest = 1000u; - const unsigned numPostChecksPerTest = numBoxesPerTest; - - for ( unsigned i = 0; i < numTests; i ++ ) - { - std::vector input; - - for ( unsigned n = 0; n < numBoxesPerTest; n++ ) - { - T b; - - VecType corner( uni() * 5.0, uni() * 5.0, uni() * 5.0 ); - VecType size( uni(), uni(), uni() ); - - b.extendBy( corner ); - b.extendBy( corner + size ); - - input.push_back( b ); - } - - typedef typename std::vector::iterator BoundIterator; - - typedef SweepAndPrune SAP; - - SAP sap; - typename SAP::Callback cb( input.begin(), numBoxesPerTest ); - - sap.intersectingBounds( input.begin(), input.end(), cb, SAP::XZY ); - - /// Pick some random box pairs - for ( unsigned n = 0; n < numPostChecksPerTest; n++ ) - { - unsigned int idx0 = (unsigned int)( uni() * numBoxesPerTest ); - unsigned int idx1 = 0; - do - { - idx1 = (unsigned int)( uni() * numBoxesPerTest ); - } - while ( idx0 == idx1 ); - - assert( idx0 != idx1 ); - assert( idx0 < numBoxesPerTest ); - assert( idx1 < numBoxesPerTest ); - - /// If SweepAndPrune hasn't determined this pair is intersecting, verify it actually is not. - if ( cb.m_indices.find( typename TestCallback::IntersectingBoundIndices::value_type( idx0, idx1 ) ) == cb.m_indices.end() ) - { - const T &bound0 = input[ idx0 ]; - const T &bound1 = input[ idx1 ]; - - BOOST_CHECK( ! bound0.intersects( bound1 ) ); - } - } - } - } -}; - -struct SweepAndPruneTestSuite : public boost::unit_test::test_suite -{ - - SweepAndPruneTestSuite() : boost::unit_test::test_suite( "SweepAndPruneTestSuite" ) - { - static boost::shared_ptr instance( new SweepAndPruneTest() ); - - add( BOOST_CLASS_TEST_CASE( &SweepAndPruneTest::test, instance ) ); - add( BOOST_CLASS_TEST_CASE( &SweepAndPruneTest::test, instance ) ); - } - -}; -} - - -#endif // IE_CORE_SWEEPANDPRUNETEST_H