mirror of
https://github.com/opencv/opencv.git
synced 2025-01-19 23:19:23 +08:00
removed embedded (obsolete) OpenEXR files; repaired OpenEXR bindings
This commit is contained in:
parent
afdaafd4b8
commit
576adb434d
60
3rdparty/include/OpenEXR/Iex.h
vendored
60
3rdparty/include/OpenEXR/Iex.h
vendored
@ -1,60 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IEX_H
|
||||
#define INCLUDED_IEX_H
|
||||
|
||||
|
||||
//--------------------------------
|
||||
//
|
||||
// Exception handling
|
||||
//
|
||||
//--------------------------------
|
||||
|
||||
|
||||
#include "IexMacros.h"
|
||||
#include "IexBaseExc.h"
|
||||
#include "IexMathExc.h"
|
||||
#include "IexThrowErrnoExc.h"
|
||||
|
||||
// Note that we do not include file IexErrnoExc.h here. That file
|
||||
// defines over 150 classes and significantly slows down compilation.
|
||||
// If you throw ErrnoExc exceptions using the throwErrnoExc() function,
|
||||
// you don't need IexErrnoExc.h. You have to include IexErrnoExc.h
|
||||
// only if you want to catch specific subclasses of ErrnoExc.
|
||||
|
||||
|
||||
#endif
|
266
3rdparty/include/OpenEXR/IexBaseExc.h
vendored
266
3rdparty/include/OpenEXR/IexBaseExc.h
vendored
@ -1,266 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IEXBASEEXC_H
|
||||
#define INCLUDED_IEXBASEEXC_H
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
//
|
||||
// A general exception base class, and a few
|
||||
// useful exceptions derived from the base class.
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
|
||||
namespace Iex {
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
// Tell MS VC++ to suppress exception specification warnings
|
||||
#pragma warning(disable:4290)
|
||||
#endif
|
||||
|
||||
//-------------------------------
|
||||
// Our most basic exception class
|
||||
//-------------------------------
|
||||
|
||||
class BaseExc: public std::string, public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------
|
||||
// Constructors and destructor
|
||||
//----------------------------
|
||||
|
||||
BaseExc (const char *s = 0) throw(); // std::string (s)
|
||||
BaseExc (const std::string &s) throw(); // std::string (s)
|
||||
BaseExc (std::stringstream &s) throw(); // std::string (s.str())
|
||||
|
||||
BaseExc (const BaseExc &be) throw();
|
||||
virtual ~BaseExc () throw ();
|
||||
|
||||
//--------------------------------------------
|
||||
// what() method -- e.what() returns e.c_str()
|
||||
//--------------------------------------------
|
||||
|
||||
virtual const char * what () const throw ();
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Convenient methods to change the exception's text
|
||||
//--------------------------------------------------
|
||||
|
||||
BaseExc & assign (std::stringstream &s); // assign (s.str())
|
||||
BaseExc & operator = (std::stringstream &s);
|
||||
|
||||
BaseExc & append (std::stringstream &s); // append (s.str())
|
||||
BaseExc & operator += (std::stringstream &s);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// These methods from the base class get obscured by
|
||||
// the definitions above.
|
||||
//--------------------------------------------------
|
||||
|
||||
BaseExc & assign (const char *s);
|
||||
BaseExc & operator = (const char *s);
|
||||
|
||||
BaseExc & append (const char *s);
|
||||
BaseExc & operator += (const char *s);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Stack trace for the point at which the exception
|
||||
// was thrown. The stack trace will be an empty
|
||||
// string unless a working stack-tracing routine
|
||||
// has been installed (see below, setStackTracer()).
|
||||
//--------------------------------------------------
|
||||
|
||||
const std::string & stackTrace () const;
|
||||
|
||||
private:
|
||||
|
||||
std::string _stackTrace;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// A macro to save typing when declararing an exception
|
||||
// class derived directly or indirectly from BaseExc:
|
||||
//-----------------------------------------------------
|
||||
|
||||
#define DEFINE_EXC(name, base) \
|
||||
class name: public base \
|
||||
{ \
|
||||
public: \
|
||||
name (const char* text=0) throw(): base (text) {} \
|
||||
name (const std::string &text) throw(): base (text) {} \
|
||||
name (std::stringstream &text) throw(): base (text) {} \
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Some exceptions which should be useful in most programs
|
||||
//--------------------------------------------------------
|
||||
|
||||
DEFINE_EXC (ArgExc, BaseExc) // Invalid arguments to a function call
|
||||
|
||||
DEFINE_EXC (LogicExc, BaseExc) // General error in a program's logic,
|
||||
// for example, a function was called
|
||||
// in a context where the call does
|
||||
// not make sense.
|
||||
|
||||
DEFINE_EXC (InputExc, BaseExc) // Invalid input data, e.g. from a file
|
||||
|
||||
DEFINE_EXC (IoExc, BaseExc) // Input or output operation failed
|
||||
|
||||
DEFINE_EXC (MathExc, BaseExc) // Arithmetic exception; more specific
|
||||
// exceptions derived from this class
|
||||
// are defined in ExcMath.h
|
||||
|
||||
DEFINE_EXC (ErrnoExc, BaseExc) // Base class for exceptions corresponding
|
||||
// to errno values (see errno.h); more
|
||||
// specific exceptions derived from this
|
||||
// class are defined in ExcErrno.h
|
||||
|
||||
DEFINE_EXC (NoImplExc, BaseExc) // Missing method exception e.g. from a
|
||||
// call to a method that is only partially
|
||||
// or not at all implemented. A reminder
|
||||
// to lazy software people to get back
|
||||
// to work.
|
||||
|
||||
DEFINE_EXC (NullExc, BaseExc) // A pointer is inappropriately null.
|
||||
|
||||
DEFINE_EXC (TypeExc, BaseExc) // An object is an inappropriate type,
|
||||
// i.e. a dynamnic_cast failed.
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Stack-tracing support:
|
||||
//
|
||||
// setStackTracer(st)
|
||||
//
|
||||
// installs a stack-tracing routine, st, which will be called from
|
||||
// class BaseExc's constructor every time an exception derived from
|
||||
// BaseExc is thrown. The stack-tracing routine should return a
|
||||
// string that contains a printable representation of the program's
|
||||
// current call stack. This string will be stored in the BaseExc
|
||||
// object; the string is accesible via the BaseExc::stackTrace()
|
||||
// method.
|
||||
//
|
||||
// setStackTracer(0)
|
||||
//
|
||||
// removes the current stack tracing routine. When an exception
|
||||
// derived from BaseExc is thrown, the stack trace string stored
|
||||
// in the BaseExc object will be empty.
|
||||
//
|
||||
// stackTracer()
|
||||
//
|
||||
// returns a pointer to the current stack-tracing routine, or 0
|
||||
// if there is no current stack stack-tracing routine.
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
typedef std::string (* StackTracer) ();
|
||||
|
||||
void setStackTracer (StackTracer stackTracer);
|
||||
StackTracer stackTracer ();
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline functions
|
||||
//-----------------
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator = (std::stringstream &s)
|
||||
{
|
||||
return assign (s);
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator += (std::stringstream &s)
|
||||
{
|
||||
return append (s);
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::assign (const char *s)
|
||||
{
|
||||
std::string::assign(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator = (const char *s)
|
||||
{
|
||||
return assign(s);
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::append (const char *s)
|
||||
{
|
||||
std::string::append(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator += (const char *s)
|
||||
{
|
||||
return append(s);
|
||||
}
|
||||
|
||||
|
||||
inline const std::string &
|
||||
BaseExc::stackTrace () const
|
||||
{
|
||||
return _stackTrace;
|
||||
}
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
#pragma warning(default:4290)
|
||||
#endif
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
210
3rdparty/include/OpenEXR/IexErrnoExc.h
vendored
210
3rdparty/include/OpenEXR/IexErrnoExc.h
vendored
@ -1,210 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IEXERRNOEXC_H
|
||||
#define INCLUDED_IEXERRNOEXC_H
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//
|
||||
// Exceptions which correspond to "errno" error codes.
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Iex {
|
||||
|
||||
|
||||
DEFINE_EXC (EpermExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoentExc, ErrnoExc)
|
||||
DEFINE_EXC (EsrchExc, ErrnoExc)
|
||||
DEFINE_EXC (EintrExc, ErrnoExc)
|
||||
DEFINE_EXC (EioExc, ErrnoExc)
|
||||
DEFINE_EXC (EnxioExc, ErrnoExc)
|
||||
DEFINE_EXC (E2bigExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoexecExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadfExc, ErrnoExc)
|
||||
DEFINE_EXC (EchildExc, ErrnoExc)
|
||||
DEFINE_EXC (EagainExc, ErrnoExc)
|
||||
DEFINE_EXC (EnomemExc, ErrnoExc)
|
||||
DEFINE_EXC (EaccesExc, ErrnoExc)
|
||||
DEFINE_EXC (EfaultExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotblkExc, ErrnoExc)
|
||||
DEFINE_EXC (EbusyExc, ErrnoExc)
|
||||
DEFINE_EXC (EexistExc, ErrnoExc)
|
||||
DEFINE_EXC (ExdevExc, ErrnoExc)
|
||||
DEFINE_EXC (EnodevExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotdirExc, ErrnoExc)
|
||||
DEFINE_EXC (EisdirExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvalExc, ErrnoExc)
|
||||
DEFINE_EXC (EnfileExc, ErrnoExc)
|
||||
DEFINE_EXC (EmfileExc, ErrnoExc)
|
||||
DEFINE_EXC (EnottyExc, ErrnoExc)
|
||||
DEFINE_EXC (EtxtbsyExc, ErrnoExc)
|
||||
DEFINE_EXC (EfbigExc, ErrnoExc)
|
||||
DEFINE_EXC (EnospcExc, ErrnoExc)
|
||||
DEFINE_EXC (EspipeExc, ErrnoExc)
|
||||
DEFINE_EXC (ErofsExc, ErrnoExc)
|
||||
DEFINE_EXC (EmlinkExc, ErrnoExc)
|
||||
DEFINE_EXC (EpipeExc, ErrnoExc)
|
||||
DEFINE_EXC (EdomExc, ErrnoExc)
|
||||
DEFINE_EXC (ErangeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnomsgExc, ErrnoExc)
|
||||
DEFINE_EXC (EidrmExc, ErrnoExc)
|
||||
DEFINE_EXC (EchrngExc, ErrnoExc)
|
||||
DEFINE_EXC (El2nsyncExc, ErrnoExc)
|
||||
DEFINE_EXC (El3hltExc, ErrnoExc)
|
||||
DEFINE_EXC (El3rstExc, ErrnoExc)
|
||||
DEFINE_EXC (ElnrngExc, ErrnoExc)
|
||||
DEFINE_EXC (EunatchExc, ErrnoExc)
|
||||
DEFINE_EXC (EnocsiExc, ErrnoExc)
|
||||
DEFINE_EXC (El2hltExc, ErrnoExc)
|
||||
DEFINE_EXC (EdeadlkExc, ErrnoExc)
|
||||
DEFINE_EXC (EnolckExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadeExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadrExc, ErrnoExc)
|
||||
DEFINE_EXC (ExfullExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoanoExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadrqcExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadsltExc, ErrnoExc)
|
||||
DEFINE_EXC (EdeadlockExc, ErrnoExc)
|
||||
DEFINE_EXC (EbfontExc, ErrnoExc)
|
||||
DEFINE_EXC (EnostrExc, ErrnoExc)
|
||||
DEFINE_EXC (EnodataExc, ErrnoExc)
|
||||
DEFINE_EXC (EtimeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnosrExc, ErrnoExc)
|
||||
DEFINE_EXC (EnonetExc, ErrnoExc)
|
||||
DEFINE_EXC (EnopkgExc, ErrnoExc)
|
||||
DEFINE_EXC (EremoteExc, ErrnoExc)
|
||||
DEFINE_EXC (EnolinkExc, ErrnoExc)
|
||||
DEFINE_EXC (EadvExc, ErrnoExc)
|
||||
DEFINE_EXC (EsrmntExc, ErrnoExc)
|
||||
DEFINE_EXC (EcommExc, ErrnoExc)
|
||||
DEFINE_EXC (EprotoExc, ErrnoExc)
|
||||
DEFINE_EXC (EmultihopExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadmsgExc, ErrnoExc)
|
||||
DEFINE_EXC (EnametoolongExc, ErrnoExc)
|
||||
DEFINE_EXC (EoverflowExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotuniqExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadfdExc, ErrnoExc)
|
||||
DEFINE_EXC (EremchgExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibaccExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibbadExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibscnExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibmaxExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibexecExc, ErrnoExc)
|
||||
DEFINE_EXC (EilseqExc, ErrnoExc)
|
||||
DEFINE_EXC (EnosysExc, ErrnoExc)
|
||||
DEFINE_EXC (EloopExc, ErrnoExc)
|
||||
DEFINE_EXC (ErestartExc, ErrnoExc)
|
||||
DEFINE_EXC (EstrpipeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotemptyExc, ErrnoExc)
|
||||
DEFINE_EXC (EusersExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotsockExc, ErrnoExc)
|
||||
DEFINE_EXC (EdestaddrreqExc, ErrnoExc)
|
||||
DEFINE_EXC (EmsgsizeExc, ErrnoExc)
|
||||
DEFINE_EXC (EprototypeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoprotooptExc, ErrnoExc)
|
||||
DEFINE_EXC (EprotonosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EsocktnosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EopnotsuppExc, ErrnoExc)
|
||||
DEFINE_EXC (EpfnosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EafnosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EaddrinuseExc, ErrnoExc)
|
||||
DEFINE_EXC (EaddrnotavailExc, ErrnoExc)
|
||||
DEFINE_EXC (EnetdownExc, ErrnoExc)
|
||||
DEFINE_EXC (EnetunreachExc, ErrnoExc)
|
||||
DEFINE_EXC (EnetresetExc, ErrnoExc)
|
||||
DEFINE_EXC (EconnabortedExc, ErrnoExc)
|
||||
DEFINE_EXC (EconnresetExc, ErrnoExc)
|
||||
DEFINE_EXC (EnobufsExc, ErrnoExc)
|
||||
DEFINE_EXC (EisconnExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotconnExc, ErrnoExc)
|
||||
DEFINE_EXC (EshutdownExc, ErrnoExc)
|
||||
DEFINE_EXC (EtoomanyrefsExc, ErrnoExc)
|
||||
DEFINE_EXC (EtimedoutExc, ErrnoExc)
|
||||
DEFINE_EXC (EconnrefusedExc, ErrnoExc)
|
||||
DEFINE_EXC (EhostdownExc, ErrnoExc)
|
||||
DEFINE_EXC (EhostunreachExc, ErrnoExc)
|
||||
DEFINE_EXC (EalreadyExc, ErrnoExc)
|
||||
DEFINE_EXC (EinprogressExc, ErrnoExc)
|
||||
DEFINE_EXC (EstaleExc, ErrnoExc)
|
||||
DEFINE_EXC (EioresidExc, ErrnoExc)
|
||||
DEFINE_EXC (EucleanExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotnamExc, ErrnoExc)
|
||||
DEFINE_EXC (EnavailExc, ErrnoExc)
|
||||
DEFINE_EXC (EisnamExc, ErrnoExc)
|
||||
DEFINE_EXC (EremoteioExc, ErrnoExc)
|
||||
DEFINE_EXC (EinitExc, ErrnoExc)
|
||||
DEFINE_EXC (EremdevExc, ErrnoExc)
|
||||
DEFINE_EXC (EcanceledExc, ErrnoExc)
|
||||
DEFINE_EXC (EnolimfileExc, ErrnoExc)
|
||||
DEFINE_EXC (EproclimExc, ErrnoExc)
|
||||
DEFINE_EXC (EdisjointExc, ErrnoExc)
|
||||
DEFINE_EXC (EnologinExc, ErrnoExc)
|
||||
DEFINE_EXC (EloginlimExc, ErrnoExc)
|
||||
DEFINE_EXC (EgrouploopExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoattachExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotsupExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoattrExc, ErrnoExc)
|
||||
DEFINE_EXC (EdircorruptedExc, ErrnoExc)
|
||||
DEFINE_EXC (EdquotExc, ErrnoExc)
|
||||
DEFINE_EXC (EnfsremoteExc, ErrnoExc)
|
||||
DEFINE_EXC (EcontrollerExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotcontrollerExc, ErrnoExc)
|
||||
DEFINE_EXC (EenqueuedExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotenqueuedExc, ErrnoExc)
|
||||
DEFINE_EXC (EjoinedExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotjoinedExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoprocExc, ErrnoExc)
|
||||
DEFINE_EXC (EmustrunExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotstoppedExc, ErrnoExc)
|
||||
DEFINE_EXC (EclockcpuExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvalstateExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoexistExc, ErrnoExc)
|
||||
DEFINE_EXC (EendofminorExc, ErrnoExc)
|
||||
DEFINE_EXC (EbufsizeExc, ErrnoExc)
|
||||
DEFINE_EXC (EemptyExc, ErrnoExc)
|
||||
DEFINE_EXC (EnointrgroupExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvalmodeExc, ErrnoExc)
|
||||
DEFINE_EXC (EcantextentExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvaltimeExc, ErrnoExc)
|
||||
DEFINE_EXC (EdestroyedExc, ErrnoExc)
|
||||
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
148
3rdparty/include/OpenEXR/IexMacros.h
vendored
148
3rdparty/include/OpenEXR/IexMacros.h
vendored
@ -1,148 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IEXMACROS_H
|
||||
#define INCLUDED_IEXMACROS_H
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//
|
||||
// Macros which make throwing exceptions more convenient
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// A macro to throw exceptions whose text is assembled using stringstreams.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// THROW (InputExc, "Syntax error in line " << line ", " << file << ".");
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define THROW(type, text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
throw type (s); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Macros to add to or to replace the text of an exception.
|
||||
// The new text is assembled using stringstreams.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// Append to end of an exception's text:
|
||||
//
|
||||
// catch (BaseExc &e)
|
||||
// {
|
||||
// APPEND_EXC (e, " Directory " << name << " does not exist.");
|
||||
// throw;
|
||||
// }
|
||||
//
|
||||
// Replace an exception's text:
|
||||
//
|
||||
// catch (BaseExc &e)
|
||||
// {
|
||||
// REPLACE_EXC (e, "Directory " << name << " does not exist. " << e);
|
||||
// throw;
|
||||
// }
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define APPEND_EXC(exc, text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
exc.append (s); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define REPLACE_EXC(exc, text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
exc.assign (s); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// A macro to throw ErrnoExc exceptions whose text is assembled
|
||||
// using stringstreams:
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// THROW_ERRNO ("Cannot open file " << name << " (%T).");
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
|
||||
#define THROW_ERRNO(text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
::Iex::throwErrnoExc (s.str()); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// A macro to throw exceptions if an assertion is false.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// ASSERT (NullExc, ptr != NULL, "Null pointer" );
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
|
||||
#define ASSERT(assertion, type, text) \
|
||||
do \
|
||||
{ \
|
||||
if( (assertion) == false ) \
|
||||
THROW( type, text ); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
#endif
|
58
3rdparty/include/OpenEXR/IexMathExc.h
vendored
58
3rdparty/include/OpenEXR/IexMathExc.h
vendored
@ -1,58 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IEXMATHEXC_H
|
||||
#define INCLUDED_IEXMATHEXC_H
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Iex {
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Exception classess which correspond to specific floating
|
||||
// point exceptions.
|
||||
//---------------------------------------------------------
|
||||
|
||||
DEFINE_EXC (OverflowExc, MathExc) // Overflow
|
||||
DEFINE_EXC (UnderflowExc, MathExc) // Underflow
|
||||
DEFINE_EXC (DivzeroExc, MathExc) // Division by zero
|
||||
DEFINE_EXC (InexactExc, MathExc) // Inexact result
|
||||
DEFINE_EXC (InvalidFpOpExc, MathExc) // Invalid operation
|
||||
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
96
3rdparty/include/OpenEXR/IexThrowErrnoExc.h
vendored
96
3rdparty/include/OpenEXR/IexThrowErrnoExc.h
vendored
@ -1,96 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IEXTHROWERRNOEXC_H
|
||||
#define INCLUDED_IEXTHROWERRNOEXC_H
|
||||
|
||||
//----------------------------------------------------------
|
||||
//
|
||||
// A function which throws ExcErrno exceptions
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Iex {
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
// Function throwErrnoExc() throws an exception which corresponds to
|
||||
// error code errnum. The exception text is initialized with a copy
|
||||
// of the string passed to throwErrnoExc(), where all occurrences of
|
||||
// "%T" have been replaced with the output of strerror(oserror()).
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// If opening file /tmp/output failed with an ENOENT error code,
|
||||
// calling
|
||||
//
|
||||
// throwErrnoExc ();
|
||||
//
|
||||
// or
|
||||
//
|
||||
// throwErrnoExc ("%T.");
|
||||
//
|
||||
// will throw an EnoentExc whose text reads
|
||||
//
|
||||
// No such file or directory.
|
||||
//
|
||||
// More detailed messages can be assembled using stringstreams:
|
||||
//
|
||||
// std::stringstream s;
|
||||
// s << "Cannot open file " << name << " (%T).";
|
||||
// throwErrnoExc (s);
|
||||
//
|
||||
// The resulting exception contains the following text:
|
||||
//
|
||||
// Cannot open file /tmp/output (No such file or directory).
|
||||
//
|
||||
// Alternatively, you may want to use the THROW_ERRNO macro defined
|
||||
// in IexMacros.h:
|
||||
//
|
||||
// THROW_ERRNO ("Cannot open file " << name << " (%T).")
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void throwErrnoExc (const std::string &txt, int errnum);
|
||||
void throwErrnoExc (const std::string &txt = "%T." /*, int errnum = oserror() */);
|
||||
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
141
3rdparty/include/OpenEXR/IlmThread.h
vendored
141
3rdparty/include/OpenEXR/IlmThread.h
vendored
@ -1,141 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_ILM_THREAD_H
|
||||
#define INCLUDED_ILM_THREAD_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Thread
|
||||
//
|
||||
// Class Thread is a portable interface to a system-dependent thread
|
||||
// primitive. In order to make a thread actually do something useful,
|
||||
// you must derive a subclass from class Thread and implement the
|
||||
// run() function. If the operating system supports threading then
|
||||
// the run() function will be executed int a new thread.
|
||||
//
|
||||
// The actual creation of the thread is done by the start() routine
|
||||
// which then calls the run() function. In general the start()
|
||||
// routine should be called from the constructor of the derived class.
|
||||
//
|
||||
// The base-class thread destructor will join/destroy the thread.
|
||||
//
|
||||
// IMPORTANT: Due to the mechanisms that encapsulate the low-level
|
||||
// threading primitives in a C++ class there is a race condition
|
||||
// with code resembling the following:
|
||||
//
|
||||
// {
|
||||
// WorkerThread myThread;
|
||||
// } // myThread goes out of scope, is destroyed
|
||||
// // and the thread is joined
|
||||
//
|
||||
// The race is between the parent thread joining the child thread
|
||||
// in the destructor of myThread, and the run() function in the
|
||||
// child thread. If the destructor gets executed first then run()
|
||||
// will be called with an invalid "this" pointer.
|
||||
//
|
||||
// This issue can be fixed by using a Semaphore to keep track of
|
||||
// whether the run() function has already been called. You can
|
||||
// include a Semaphore member variable within your derived class
|
||||
// which you post() on in the run() function, and wait() on in the
|
||||
// destructor before the thread is joined. Alternatively you could
|
||||
// do something like this:
|
||||
//
|
||||
// Semaphore runStarted;
|
||||
//
|
||||
// void WorkerThread::run ()
|
||||
// {
|
||||
// runStarted.post()
|
||||
// // do some work
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// WorkerThread myThread;
|
||||
// runStarted.wait (); // ensure that we have started
|
||||
// // the run function
|
||||
// } // myThread goes out of scope, is destroyed
|
||||
// // and the thread is joined
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "OpenEXRConfig.h"
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
#ifdef NOMINMAX
|
||||
#undef NOMINMAX
|
||||
#endif
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#elif HAVE_PTHREAD
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace IlmThread {
|
||||
|
||||
//
|
||||
// Query function to determine if the current platform supports
|
||||
// threads AND this library was compiled with threading enabled.
|
||||
//
|
||||
|
||||
bool supportsThreads ();
|
||||
|
||||
|
||||
class Thread
|
||||
{
|
||||
public:
|
||||
|
||||
Thread ();
|
||||
virtual ~Thread ();
|
||||
|
||||
void start ();
|
||||
virtual void run () = 0;
|
||||
|
||||
private:
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
HANDLE _thread;
|
||||
#elif HAVE_PTHREAD
|
||||
pthread_t _thread;
|
||||
#endif
|
||||
|
||||
void operator = (const Thread& t); // not implemented
|
||||
Thread (const Thread& t); // not implemented
|
||||
};
|
||||
|
||||
|
||||
} // namespace IlmThread
|
||||
|
||||
#endif
|
158
3rdparty/include/OpenEXR/IlmThreadMutex.h
vendored
158
3rdparty/include/OpenEXR/IlmThreadMutex.h
vendored
@ -1,158 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_ILM_THREAD_MUTEX_H
|
||||
#define INCLUDED_ILM_THREAD_MUTEX_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Mutex, class Lock
|
||||
//
|
||||
// Class Mutex is a wrapper for a system-dependent mutual exclusion
|
||||
// mechanism. Actual locking and unlocking of a Mutex object must
|
||||
// be performed using an instance of a Lock (defined below).
|
||||
//
|
||||
// Class lock provides safe locking and unlocking of mutexes even in
|
||||
// the presence of C++ exceptions. Constructing a Lock object locks
|
||||
// the mutex; destroying the Lock unlocks the mutex.
|
||||
//
|
||||
// Lock objects are not themselves thread-safe. You should never
|
||||
// share a Lock object among multiple threads.
|
||||
//
|
||||
// Typical usage:
|
||||
//
|
||||
// Mutex mtx; // Create a Mutex object that is visible
|
||||
// //to multiple threads
|
||||
//
|
||||
// ... // create some threads
|
||||
//
|
||||
// // Then, within each thread, construct a critical section like so:
|
||||
//
|
||||
// {
|
||||
// Lock lock (mtx); // Lock constructor locks the mutex
|
||||
// ... // do some computation on shared data
|
||||
// } // leaving the block unlocks the mutex
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "OpenEXRConfig.h"
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
#ifdef NOMINMAX
|
||||
#undef NOMINMAX
|
||||
#endif
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#elif HAVE_PTHREAD
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace IlmThread {
|
||||
|
||||
class Lock;
|
||||
|
||||
|
||||
class Mutex
|
||||
{
|
||||
public:
|
||||
|
||||
Mutex ();
|
||||
virtual ~Mutex ();
|
||||
|
||||
private:
|
||||
|
||||
void lock () const;
|
||||
void unlock () const;
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
mutable CRITICAL_SECTION _mutex;
|
||||
#elif HAVE_PTHREAD
|
||||
mutable pthread_mutex_t _mutex;
|
||||
#endif
|
||||
|
||||
void operator = (const Mutex& M); // not implemented
|
||||
Mutex (const Mutex& M); // not implemented
|
||||
|
||||
friend class Lock;
|
||||
};
|
||||
|
||||
|
||||
class Lock
|
||||
{
|
||||
public:
|
||||
|
||||
Lock (const Mutex& m, bool autoLock = true):
|
||||
_mutex (m),
|
||||
_locked (false)
|
||||
{
|
||||
if (autoLock)
|
||||
{
|
||||
_mutex.lock();
|
||||
_locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
~Lock ()
|
||||
{
|
||||
if (_locked)
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void acquire ()
|
||||
{
|
||||
_mutex.lock();
|
||||
_locked = true;
|
||||
}
|
||||
|
||||
void release ()
|
||||
{
|
||||
_mutex.unlock();
|
||||
_locked = false;
|
||||
}
|
||||
|
||||
bool locked ()
|
||||
{
|
||||
return _locked;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const Mutex & _mutex;
|
||||
bool _locked;
|
||||
};
|
||||
|
||||
|
||||
} // namespace IlmThread
|
||||
|
||||
#endif
|
156
3rdparty/include/OpenEXR/IlmThreadPool.h
vendored
156
3rdparty/include/OpenEXR/IlmThreadPool.h
vendored
@ -1,156 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_ILM_THREAD_POOL_H
|
||||
#define INCLUDED_ILM_THREAD_POOL_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Task, class ThreadPool, class TaskGroup
|
||||
//
|
||||
// Class ThreadPool manages a set of worker threads and accepts
|
||||
// tasks for processing. Tasks added to the thread pool are
|
||||
// executed concurrently by the worker threads.
|
||||
//
|
||||
// Class Thread provides an abstract interface for a task which
|
||||
// a ThreadPool works on. Derived classes need to implement the
|
||||
// execute() function which performs the actual task.
|
||||
//
|
||||
// Class TaskTroup allows synchronization on the completion of a set
|
||||
// of tasks. Every task that is added to a ThreadPool belongs to a
|
||||
// single TaskGroup. The destructor of the TaskGroup waits for all
|
||||
// tasks in the group to finish.
|
||||
//
|
||||
// Note: if you plan to use the ThreadPool interface in your own
|
||||
// applications note that the implementation of the ThreadPool calls
|
||||
// opertor delete on tasks as they complete. If you define a custom
|
||||
// operator new for your tasks, for instance to use a custom heap,
|
||||
// then you must also write an appropriate operator delete.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace IlmThread {
|
||||
|
||||
class TaskGroup;
|
||||
class Task;
|
||||
|
||||
|
||||
class ThreadPool
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Constructor -- creates numThreads worker threads which
|
||||
// wait until a task is available.
|
||||
//-------------------------------------------------------
|
||||
|
||||
ThreadPool (unsigned numThreads = 0);
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Destructor -- waits for all tasks to complete, joins all
|
||||
// the threads to the calling thread, and then destroys them.
|
||||
//-----------------------------------------------------------
|
||||
|
||||
virtual ~ThreadPool ();
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Query and set the number of worker threads in the pool.
|
||||
//
|
||||
// Warning: never call setNumThreads from within a worker
|
||||
// thread as this will almost certainly cause a deadlock
|
||||
// or crash.
|
||||
//--------------------------------------------------------
|
||||
|
||||
int numThreads () const;
|
||||
void setNumThreads (int count);
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Add a task for processing. The ThreadPool can handle any
|
||||
// number of tasks regardless of the number of worker threads.
|
||||
// The tasks are first added onto a queue, and are executed
|
||||
// by threads as they become available, in FIFO order.
|
||||
//------------------------------------------------------------
|
||||
|
||||
void addTask (Task* task);
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Access functions for the global threadpool
|
||||
//-------------------------------------------
|
||||
|
||||
static ThreadPool& globalThreadPool ();
|
||||
static void addGlobalTask (Task* task);
|
||||
|
||||
struct Data;
|
||||
|
||||
protected:
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
class Task
|
||||
{
|
||||
public:
|
||||
|
||||
Task (TaskGroup* g);
|
||||
virtual ~Task ();
|
||||
|
||||
virtual void execute () = 0;
|
||||
TaskGroup * group();
|
||||
|
||||
protected:
|
||||
|
||||
TaskGroup * _group;
|
||||
};
|
||||
|
||||
|
||||
class TaskGroup
|
||||
{
|
||||
public:
|
||||
|
||||
TaskGroup();
|
||||
~TaskGroup();
|
||||
|
||||
struct Data;
|
||||
Data* const _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace IlmThread
|
||||
|
||||
#endif
|
109
3rdparty/include/OpenEXR/IlmThreadSemaphore.h
vendored
109
3rdparty/include/OpenEXR/IlmThreadSemaphore.h
vendored
@ -1,109 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_ILM_THREAD_SEMAPHORE_H
|
||||
#define INCLUDED_ILM_THREAD_SEMAPHORE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Semaphore -- a wrapper class for
|
||||
// system-dependent counting semaphores
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "OpenEXRConfig.h"
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
#ifdef NOMINMAX
|
||||
#undef NOMINMAX
|
||||
#endif
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#elif HAVE_PTHREAD && !HAVE_POSIX_SEMAPHORES
|
||||
#include <pthread.h>
|
||||
#elif HAVE_PTHREAD && HAVE_POSIX_SEMAPHORES
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
namespace IlmThread {
|
||||
|
||||
|
||||
class Semaphore
|
||||
{
|
||||
public:
|
||||
|
||||
Semaphore (unsigned int value = 0);
|
||||
virtual ~Semaphore();
|
||||
|
||||
void wait();
|
||||
void post();
|
||||
int value() const;
|
||||
|
||||
private:
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
|
||||
mutable HANDLE _semaphore;
|
||||
|
||||
#elif HAVE_PTHREAD && !HAVE_POSIX_SEMAPHORES
|
||||
|
||||
//
|
||||
// If the platform has Posix threads but no semapohores,
|
||||
// then we implement them ourselves using condition variables
|
||||
//
|
||||
|
||||
struct sema_t
|
||||
{
|
||||
unsigned int count;
|
||||
unsigned long numWaiting;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t nonZero;
|
||||
};
|
||||
|
||||
mutable sema_t _semaphore;
|
||||
|
||||
#elif HAVE_PTHREAD && HAVE_POSIX_SEMAPHORES
|
||||
|
||||
mutable sem_t _semaphore;
|
||||
|
||||
#endif
|
||||
|
||||
void operator = (const Semaphore& s); // not implemented
|
||||
Semaphore (const Semaphore& s); // not implemented
|
||||
};
|
||||
|
||||
|
||||
} // namespace IlmThread
|
||||
|
||||
#endif
|
277
3rdparty/include/OpenEXR/ImathBox.h
vendored
277
3rdparty/include/OpenEXR/ImathBox.h
vendored
@ -1,277 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHBOX_H
|
||||
#define INCLUDED_IMATHBOX_H
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// class Imath::Box<class T>
|
||||
// --------------------------------
|
||||
//
|
||||
// This class imposes the following requirements on its
|
||||
// parameter class:
|
||||
//
|
||||
// 1) The class T must implement these operators:
|
||||
// + - < > <= >= =
|
||||
// with the signature (T,T) and the expected
|
||||
// return values for a numeric type.
|
||||
//
|
||||
// 2) The class T must implement operator=
|
||||
// with the signature (T,float and/or double)
|
||||
//
|
||||
// 3) The class T must have a constructor which takes
|
||||
// a float (and/or double) for use in initializing the box.
|
||||
//
|
||||
// 4) The class T must have a function T::dimensions()
|
||||
// which returns the number of dimensions in the class
|
||||
// (since its assumed its a vector) -- preferably, this
|
||||
// returns a constant expression.
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Box
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------
|
||||
// Data Members are public
|
||||
//-------------------------
|
||||
|
||||
T min;
|
||||
T max;
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Constructors - an "empty" box is created by default
|
||||
//-----------------------------------------------------
|
||||
|
||||
Box();
|
||||
Box(const T& point);
|
||||
Box(const T& minT, const T& maxT);
|
||||
|
||||
//--------------------
|
||||
// Operators: ==, !=
|
||||
//--------------------
|
||||
|
||||
bool operator == (const Box<T> &src) const;
|
||||
bool operator != (const Box<T> &src) const;
|
||||
|
||||
//------------------
|
||||
// Box manipulation
|
||||
//------------------
|
||||
|
||||
void makeEmpty();
|
||||
void extendBy(const T& point);
|
||||
void extendBy(const Box<T>& box);
|
||||
|
||||
//---------------------------------------------------
|
||||
// Query functions - these compute results each time
|
||||
//---------------------------------------------------
|
||||
|
||||
T size() const;
|
||||
T center() const;
|
||||
bool intersects(const T &point) const;
|
||||
bool intersects(const Box<T> &box) const;
|
||||
|
||||
unsigned int majorAxis() const;
|
||||
|
||||
//----------------
|
||||
// Classification
|
||||
//----------------
|
||||
|
||||
bool isEmpty() const;
|
||||
bool hasVolume() const;
|
||||
};
|
||||
|
||||
|
||||
//--------------------
|
||||
// Convenient typedefs
|
||||
//--------------------
|
||||
|
||||
|
||||
typedef Box <V2s> Box2s;
|
||||
typedef Box <V2i> Box2i;
|
||||
typedef Box <V2f> Box2f;
|
||||
typedef Box <V2d> Box2d;
|
||||
typedef Box <V3s> Box3s;
|
||||
typedef Box <V3i> Box3i;
|
||||
typedef Box <V3f> Box3f;
|
||||
typedef Box <V3d> Box3d;
|
||||
|
||||
|
||||
//----------------
|
||||
// Implementation
|
||||
//----------------
|
||||
|
||||
|
||||
template <class T>
|
||||
inline Box<T>::Box()
|
||||
{
|
||||
makeEmpty();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Box<T>::Box(const T& point)
|
||||
{
|
||||
min = point;
|
||||
max = point;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Box<T>::Box(const T& minV, const T& maxV)
|
||||
{
|
||||
min = minV;
|
||||
max = maxV;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
Box<T>::operator == (const Box<T> &src) const
|
||||
{
|
||||
return (min == src.min && max == src.max);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
Box<T>::operator != (const Box<T> &src) const
|
||||
{
|
||||
return (min != src.min || max != src.max);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Box<T>::makeEmpty()
|
||||
{
|
||||
min = T(T::baseTypeMax());
|
||||
max = T(T::baseTypeMin());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Box<T>::extendBy(const T& point)
|
||||
{
|
||||
for (unsigned int i=0; i<min.dimensions(); i++)
|
||||
{
|
||||
if ( point[i] < min[i] ) min[i] = point[i];
|
||||
if ( point[i] > max[i] ) max[i] = point[i];
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Box<T>::extendBy(const Box<T>& box)
|
||||
{
|
||||
for (unsigned int i=0; i<min.dimensions(); i++)
|
||||
{
|
||||
if ( box.min[i] < min[i] ) min[i] = box.min[i];
|
||||
if ( box.max[i] > max[i] ) max[i] = box.max[i];
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool Box<T>::intersects(const T& point) const
|
||||
{
|
||||
for (unsigned int i=0; i<min.dimensions(); i++)
|
||||
{
|
||||
if (point[i] < min[i] || point[i] > max[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool Box<T>::intersects(const Box<T>& box) const
|
||||
{
|
||||
for (unsigned int i=0; i<min.dimensions(); i++)
|
||||
{
|
||||
if (box.max[i] < min[i] || box.min[i] > max[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Box<T>::size() const
|
||||
{
|
||||
if (isEmpty())
|
||||
return T (0);
|
||||
|
||||
return max-min;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Box<T>::center() const
|
||||
{
|
||||
return (max+min)/2;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool Box<T>::isEmpty() const
|
||||
{
|
||||
for (unsigned int i=0; i<min.dimensions(); i++)
|
||||
{
|
||||
if (max[i] < min[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool Box<T>::hasVolume() const
|
||||
{
|
||||
for (unsigned int i=0; i<min.dimensions(); i++)
|
||||
{
|
||||
if (max[i] <= min[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline unsigned int Box<T>::majorAxis() const
|
||||
{
|
||||
unsigned int major = 0;
|
||||
T s = size();
|
||||
|
||||
for (unsigned int i=1; i<min.dimensions(); i++)
|
||||
{
|
||||
if ( s[i] > s[major] ) major = i;
|
||||
}
|
||||
|
||||
return major;
|
||||
}
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
611
3rdparty/include/OpenEXR/ImathBoxAlgo.h
vendored
611
3rdparty/include/OpenEXR/ImathBoxAlgo.h
vendored
@ -1,611 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHBOXALGO_H
|
||||
#define INCLUDED_IMATHBOXALGO_H
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// This file contains algorithms applied to or in conjunction
|
||||
// with bounding boxes (Imath::Box). These algorithms require
|
||||
// more headers to compile. The assumption made is that these
|
||||
// functions are called much less often than the basic box
|
||||
// functions or these functions require more support classes.
|
||||
//
|
||||
// Contains:
|
||||
//
|
||||
// T clip<T>(const T& in, const Box<T>& box)
|
||||
//
|
||||
// Vec3<T> closestPointOnBox(const Vec3<T>&, const Box<Vec3<T>>& )
|
||||
//
|
||||
// Vec3<T> closestPointInBox(const Vec3<T>&, const Box<Vec3<T>>& )
|
||||
//
|
||||
// void transform(Box<Vec3<T>>&, const Matrix44<T>&)
|
||||
//
|
||||
// bool findEntryAndExitPoints(const Line<T> &line,
|
||||
// const Box< Vec3<T> > &box,
|
||||
// Vec3<T> &enterPoint,
|
||||
// Vec3<T> &exitPoint)
|
||||
//
|
||||
// bool intersects(const Box<Vec3<T>> &box,
|
||||
// const Line3<T> &line,
|
||||
// Vec3<T> result)
|
||||
//
|
||||
// bool intersects(const Box<Vec3<T>> &box, const Line3<T> &line)
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "ImathBox.h"
|
||||
#include "ImathMatrix.h"
|
||||
#include "ImathLineAlgo.h"
|
||||
#include "ImathPlane.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T clip(const T& in, const Box<T>& box)
|
||||
{
|
||||
//
|
||||
// Clip a point so that it lies inside the given bbox
|
||||
//
|
||||
|
||||
T out;
|
||||
|
||||
for (int i=0; i<(int)box.min.dimensions(); i++)
|
||||
{
|
||||
if (in[i] < box.min[i]) out[i] = box.min[i];
|
||||
else if (in[i] > box.max[i]) out[i] = box.max[i];
|
||||
else out[i] = in[i];
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return p if p is inside the box.
|
||||
//
|
||||
|
||||
template <class T>
|
||||
Vec3<T>
|
||||
closestPointInBox(const Vec3<T>& p, const Box< Vec3<T> >& box )
|
||||
{
|
||||
Imath::V3f b;
|
||||
|
||||
if (p.x < box.min.x)
|
||||
b.x = box.min.x;
|
||||
else if (p.x > box.max.x)
|
||||
b.x = box.max.x;
|
||||
else
|
||||
b.x = p.x;
|
||||
|
||||
if (p.y < box.min.y)
|
||||
b.y = box.min.y;
|
||||
else if (p.y > box.max.y)
|
||||
b.y = box.max.y;
|
||||
else
|
||||
b.y = p.y;
|
||||
|
||||
if (p.z < box.min.z)
|
||||
b.z = box.min.z;
|
||||
else if (p.z > box.max.z)
|
||||
b.z = box.max.z;
|
||||
else
|
||||
b.z = p.z;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Vec3<T> closestPointOnBox(const Vec3<T>& pt, const Box< Vec3<T> >& box )
|
||||
{
|
||||
//
|
||||
// This sucker is specialized to work with a Vec3f and a box
|
||||
// made of Vec3fs.
|
||||
//
|
||||
|
||||
Vec3<T> result;
|
||||
|
||||
// trivial cases first
|
||||
if (box.isEmpty())
|
||||
return pt;
|
||||
else if (pt == box.center())
|
||||
{
|
||||
// middle of z side
|
||||
result[0] = (box.max[0] + box.min[0])/2.0;
|
||||
result[1] = (box.max[1] + box.min[1])/2.0;
|
||||
result[2] = box.max[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the closest point on a unit box (from -1 to 1),
|
||||
// then scale up.
|
||||
|
||||
// Find the vector from center to the point, then scale
|
||||
// to a unit box.
|
||||
Vec3<T> vec = pt - box.center();
|
||||
T sizeX = box.max[0]-box.min[0];
|
||||
T sizeY = box.max[1]-box.min[1];
|
||||
T sizeZ = box.max[2]-box.min[2];
|
||||
|
||||
T halfX = sizeX/2.0;
|
||||
T halfY = sizeY/2.0;
|
||||
T halfZ = sizeZ/2.0;
|
||||
if (halfX > 0.0)
|
||||
vec[0] /= halfX;
|
||||
if (halfY > 0.0)
|
||||
vec[1] /= halfY;
|
||||
if (halfZ > 0.0)
|
||||
vec[2] /= halfZ;
|
||||
|
||||
// Side to snap side that has greatest magnitude in the vector.
|
||||
Vec3<T> mag;
|
||||
mag[0] = fabs(vec[0]);
|
||||
mag[1] = fabs(vec[1]);
|
||||
mag[2] = fabs(vec[2]);
|
||||
|
||||
result = mag;
|
||||
|
||||
// Check if beyond corners
|
||||
if (result[0] > 1.0)
|
||||
result[0] = 1.0;
|
||||
if (result[1] > 1.0)
|
||||
result[1] = 1.0;
|
||||
if (result[2] > 1.0)
|
||||
result[2] = 1.0;
|
||||
|
||||
// snap to appropriate side
|
||||
if ((mag[0] > mag[1]) && (mag[0] > mag[2]))
|
||||
{
|
||||
result[0] = 1.0;
|
||||
}
|
||||
else if ((mag[1] > mag[0]) && (mag[1] > mag[2]))
|
||||
{
|
||||
result[1] = 1.0;
|
||||
}
|
||||
else if ((mag[2] > mag[0]) && (mag[2] > mag[1]))
|
||||
{
|
||||
result[2] = 1.0;
|
||||
}
|
||||
else if ((mag[0] == mag[1]) && (mag[0] == mag[2]))
|
||||
{
|
||||
// corner
|
||||
result = Vec3<T>(1,1,1);
|
||||
}
|
||||
else if (mag[0] == mag[1])
|
||||
{
|
||||
// edge parallel with z
|
||||
result[0] = 1.0;
|
||||
result[1] = 1.0;
|
||||
}
|
||||
else if (mag[0] == mag[2])
|
||||
{
|
||||
// edge parallel with y
|
||||
result[0] = 1.0;
|
||||
result[2] = 1.0;
|
||||
}
|
||||
else if (mag[1] == mag[2])
|
||||
{
|
||||
// edge parallel with x
|
||||
result[1] = 1.0;
|
||||
result[2] = 1.0;
|
||||
}
|
||||
|
||||
// Now make everything point the right way
|
||||
for (int i=0; i < 3; i++)
|
||||
{
|
||||
if (vec[i] < 0.0)
|
||||
result[i] = -result[i];
|
||||
}
|
||||
|
||||
// scale back up and move to center
|
||||
result[0] *= halfX;
|
||||
result[1] *= halfY;
|
||||
result[2] *= halfZ;
|
||||
|
||||
result += box.center();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class S, class T>
|
||||
Box< Vec3<S> >
|
||||
transform(const Box< Vec3<S> >& box, const Matrix44<T>& m)
|
||||
{
|
||||
// Transforms Box3f by matrix, enlarging Box3f to contain result.
|
||||
// Clever method courtesy of Graphics Gems, pp. 548-550
|
||||
//
|
||||
// This works for projection matrices as well as simple affine
|
||||
// transformations. Coordinates of the box are rehomogenized if there
|
||||
// is a projection matrix
|
||||
|
||||
// a transformed empty box is still empty
|
||||
if (box.isEmpty())
|
||||
return box;
|
||||
|
||||
// If the last column is close enuf to ( 0 0 0 1 ) then we use the
|
||||
// fast, affine version. The tricky affine method could maybe be
|
||||
// extended to deal with the projection case as well, but its not
|
||||
// worth it right now.
|
||||
|
||||
if (m[0][3] * m[0][3] + m[1][3] * m[1][3] + m[2][3] * m[2][3]
|
||||
+ (1.0 - m[3][3]) * (1.0 - m[3][3]) < 0.00001)
|
||||
{
|
||||
// Affine version, use the Graphics Gems hack
|
||||
int i, j;
|
||||
Box< Vec3<S> > newBox;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
newBox.min[i] = newBox.max[i] = (S) m[3][i];
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
float a, b;
|
||||
|
||||
a = (S) m[j][i] * box.min[j];
|
||||
b = (S) m[j][i] * box.max[j];
|
||||
|
||||
if (a < b)
|
||||
{
|
||||
newBox.min[i] += a;
|
||||
newBox.max[i] += b;
|
||||
}
|
||||
else
|
||||
{
|
||||
newBox.min[i] += b;
|
||||
newBox.max[i] += a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newBox;
|
||||
}
|
||||
|
||||
// This is a projection matrix. Do things the naive way.
|
||||
Vec3<S> points[8];
|
||||
|
||||
/* Set up the eight points at the corners of the extent */
|
||||
points[0][0] = points[1][0] = points[2][0] = points[3][0] = box.min[0];
|
||||
points[4][0] = points[5][0] = points[6][0] = points[7][0] = box.max[0];
|
||||
|
||||
points[0][1] = points[1][1] = points[4][1] = points[5][1] = box.min[1];
|
||||
points[2][1] = points[3][1] = points[6][1] = points[7][1] = box.max[1];
|
||||
|
||||
points[0][2] = points[2][2] = points[4][2] = points[6][2] = box.min[2];
|
||||
points[1][2] = points[3][2] = points[5][2] = points[7][2] = box.max[2];
|
||||
|
||||
Box< Vec3<S> > newBox;
|
||||
for (int i = 0; i < 8; i++)
|
||||
newBox.extendBy(points[i] * m);
|
||||
|
||||
return newBox;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Box< Vec3<T> >
|
||||
affineTransform(const Box< Vec3<T> > &bbox, const Matrix44<T> &M)
|
||||
{
|
||||
float min0, max0, min1, max1, min2, max2, a, b;
|
||||
float min0new, max0new, min1new, max1new, min2new, max2new;
|
||||
|
||||
min0 = bbox.min[0];
|
||||
max0 = bbox.max[0];
|
||||
min1 = bbox.min[1];
|
||||
max1 = bbox.max[1];
|
||||
min2 = bbox.min[2];
|
||||
max2 = bbox.max[2];
|
||||
|
||||
min0new = max0new = M[3][0];
|
||||
a = M[0][0] * min0;
|
||||
b = M[0][0] * max0;
|
||||
if (a < b) {
|
||||
min0new += a;
|
||||
max0new += b;
|
||||
} else {
|
||||
min0new += b;
|
||||
max0new += a;
|
||||
}
|
||||
a = M[1][0] * min1;
|
||||
b = M[1][0] * max1;
|
||||
if (a < b) {
|
||||
min0new += a;
|
||||
max0new += b;
|
||||
} else {
|
||||
min0new += b;
|
||||
max0new += a;
|
||||
}
|
||||
a = M[2][0] * min2;
|
||||
b = M[2][0] * max2;
|
||||
if (a < b) {
|
||||
min0new += a;
|
||||
max0new += b;
|
||||
} else {
|
||||
min0new += b;
|
||||
max0new += a;
|
||||
}
|
||||
|
||||
min1new = max1new = M[3][1];
|
||||
a = M[0][1] * min0;
|
||||
b = M[0][1] * max0;
|
||||
if (a < b) {
|
||||
min1new += a;
|
||||
max1new += b;
|
||||
} else {
|
||||
min1new += b;
|
||||
max1new += a;
|
||||
}
|
||||
a = M[1][1] * min1;
|
||||
b = M[1][1] * max1;
|
||||
if (a < b) {
|
||||
min1new += a;
|
||||
max1new += b;
|
||||
} else {
|
||||
min1new += b;
|
||||
max1new += a;
|
||||
}
|
||||
a = M[2][1] * min2;
|
||||
b = M[2][1] * max2;
|
||||
if (a < b) {
|
||||
min1new += a;
|
||||
max1new += b;
|
||||
} else {
|
||||
min1new += b;
|
||||
max1new += a;
|
||||
}
|
||||
|
||||
min2new = max2new = M[3][2];
|
||||
a = M[0][2] * min0;
|
||||
b = M[0][2] * max0;
|
||||
if (a < b) {
|
||||
min2new += a;
|
||||
max2new += b;
|
||||
} else {
|
||||
min2new += b;
|
||||
max2new += a;
|
||||
}
|
||||
a = M[1][2] * min1;
|
||||
b = M[1][2] * max1;
|
||||
if (a < b) {
|
||||
min2new += a;
|
||||
max2new += b;
|
||||
} else {
|
||||
min2new += b;
|
||||
max2new += a;
|
||||
}
|
||||
a = M[2][2] * min2;
|
||||
b = M[2][2] * max2;
|
||||
if (a < b) {
|
||||
min2new += a;
|
||||
max2new += b;
|
||||
} else {
|
||||
min2new += b;
|
||||
max2new += a;
|
||||
}
|
||||
|
||||
Box< Vec3<T> > xbbox;
|
||||
|
||||
xbbox.min[0] = min0new;
|
||||
xbbox.max[0] = max0new;
|
||||
xbbox.min[1] = min1new;
|
||||
xbbox.max[1] = max1new;
|
||||
xbbox.min[2] = min2new;
|
||||
xbbox.max[2] = max2new;
|
||||
|
||||
return xbbox;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
bool findEntryAndExitPoints(const Line3<T>& line,
|
||||
const Box<Vec3<T> >& box,
|
||||
Vec3<T> &enterPoint,
|
||||
Vec3<T> &exitPoint)
|
||||
{
|
||||
if ( box.isEmpty() ) return false;
|
||||
if ( line.distanceTo(box.center()) > box.size().length()/2. ) return false;
|
||||
|
||||
Vec3<T> points[8], inter, bary;
|
||||
Plane3<T> plane;
|
||||
int i, v0, v1, v2;
|
||||
bool front = false, valid, validIntersection = false;
|
||||
|
||||
// set up the eight coords of the corners of the box
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
points[i].setValue( i & 01 ? box.min[0] : box.max[0],
|
||||
i & 02 ? box.min[1] : box.max[1],
|
||||
i & 04 ? box.min[2] : box.max[2]);
|
||||
}
|
||||
|
||||
// intersect the 12 triangles.
|
||||
for(i = 0; i < 12; i++)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0: v0 = 2; v1 = 1; v2 = 0; break; // +z
|
||||
case 1: v0 = 2; v1 = 3; v2 = 1; break;
|
||||
|
||||
case 2: v0 = 4; v1 = 5; v2 = 6; break; // -z
|
||||
case 3: v0 = 6; v1 = 5; v2 = 7; break;
|
||||
|
||||
case 4: v0 = 0; v1 = 6; v2 = 2; break; // -x
|
||||
case 5: v0 = 0; v1 = 4; v2 = 6; break;
|
||||
|
||||
case 6: v0 = 1; v1 = 3; v2 = 7; break; // +x
|
||||
case 7: v0 = 1; v1 = 7; v2 = 5; break;
|
||||
|
||||
case 8: v0 = 1; v1 = 4; v2 = 0; break; // -y
|
||||
case 9: v0 = 1; v1 = 5; v2 = 4; break;
|
||||
|
||||
case 10: v0 = 2; v1 = 7; v2 = 3; break; // +y
|
||||
case 11: v0 = 2; v1 = 6; v2 = 7; break;
|
||||
}
|
||||
if((valid=intersect (line, points[v0], points[v1], points[v2],
|
||||
inter, bary, front)) == true)
|
||||
{
|
||||
if(front == true)
|
||||
{
|
||||
enterPoint = inter;
|
||||
validIntersection = valid;
|
||||
}
|
||||
else
|
||||
{
|
||||
exitPoint = inter;
|
||||
validIntersection = valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
return validIntersection;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool intersects(const Box< Vec3<T> > &box,
|
||||
const Line3<T> &line,
|
||||
Vec3<T> &result)
|
||||
{
|
||||
/*
|
||||
Fast Ray-Box Intersection
|
||||
by Andrew Woo
|
||||
from "Graphics Gems", Academic Press, 1990
|
||||
*/
|
||||
|
||||
const int right = 0;
|
||||
const int left = 1;
|
||||
const int middle = 2;
|
||||
|
||||
const Vec3<T> &minB = box.min;
|
||||
const Vec3<T> &maxB = box.max;
|
||||
const Vec3<T> &origin = line.pos;
|
||||
const Vec3<T> &dir = line.dir;
|
||||
|
||||
bool inside = true;
|
||||
char quadrant[3];
|
||||
int whichPlane;
|
||||
float maxT[3];
|
||||
float candidatePlane[3];
|
||||
|
||||
/* Find candidate planes; this loop can be avoided if
|
||||
rays cast all from the eye(assume perpsective view) */
|
||||
for (int i=0; i<3; i++)
|
||||
{
|
||||
if(origin[i] < minB[i])
|
||||
{
|
||||
quadrant[i] = left;
|
||||
candidatePlane[i] = minB[i];
|
||||
inside = false;
|
||||
}
|
||||
else if (origin[i] > maxB[i])
|
||||
{
|
||||
quadrant[i] = right;
|
||||
candidatePlane[i] = maxB[i];
|
||||
inside = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
quadrant[i] = middle;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ray origin inside bounding box */
|
||||
if ( inside )
|
||||
{
|
||||
result = origin;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Calculate T distances to candidate planes */
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (quadrant[i] != middle && dir[i] !=0.)
|
||||
{
|
||||
maxT[i] = (candidatePlane[i]-origin[i]) / dir[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
maxT[i] = -1.;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get largest of the maxT's for final choice of intersection */
|
||||
whichPlane = 0;
|
||||
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
if (maxT[whichPlane] < maxT[i])
|
||||
{
|
||||
whichPlane = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check final candidate actually inside box */
|
||||
if (maxT[whichPlane] < 0.) return false;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (whichPlane != i)
|
||||
{
|
||||
result[i] = origin[i] + maxT[whichPlane] *dir[i];
|
||||
|
||||
if ((quadrant[i] == right && result[i] < minB[i]) ||
|
||||
(quadrant[i] == left && result[i] > maxB[i]))
|
||||
{
|
||||
return false; /* outside box */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result[i] = candidatePlane[i];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool intersects(const Box< Vec3<T> > &box, const Line3<T> &line)
|
||||
{
|
||||
Vec3<T> ignored;
|
||||
return intersects(box,line,ignored);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
734
3rdparty/include/OpenEXR/ImathColor.h
vendored
734
3rdparty/include/OpenEXR/ImathColor.h
vendored
@ -1,734 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHCOLOR_H
|
||||
#define INCLUDED_IMATHCOLOR_H
|
||||
|
||||
//----------------------------------------------------
|
||||
//
|
||||
// A three and four component color class template.
|
||||
//
|
||||
//----------------------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "half.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Color3: public Vec3 <T>
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------
|
||||
// Constructors
|
||||
//-------------
|
||||
|
||||
Color3 (); // no initialization
|
||||
explicit Color3 (T a); // (a a a)
|
||||
Color3 (T a, T b, T c); // (a b c)
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// Copy constructors and assignment
|
||||
//---------------------------------
|
||||
|
||||
Color3 (const Color3 &c);
|
||||
template <class S> Color3 (const Vec3<S> &v);
|
||||
|
||||
const Color3 & operator = (const Color3 &c);
|
||||
|
||||
|
||||
//------------------------
|
||||
// Component-wise addition
|
||||
//------------------------
|
||||
|
||||
const Color3 & operator += (const Color3 &c);
|
||||
Color3 operator + (const Color3 &c) const;
|
||||
|
||||
|
||||
//---------------------------
|
||||
// Component-wise subtraction
|
||||
//---------------------------
|
||||
|
||||
const Color3 & operator -= (const Color3 &c);
|
||||
Color3 operator - (const Color3 &c) const;
|
||||
|
||||
|
||||
//------------------------------------
|
||||
// Component-wise multiplication by -1
|
||||
//------------------------------------
|
||||
|
||||
Color3 operator - () const;
|
||||
const Color3 & negate ();
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Component-wise multiplication
|
||||
//------------------------------
|
||||
|
||||
const Color3 & operator *= (const Color3 &c);
|
||||
const Color3 & operator *= (T a);
|
||||
Color3 operator * (const Color3 &c) const;
|
||||
Color3 operator * (T a) const;
|
||||
|
||||
|
||||
//------------------------
|
||||
// Component-wise division
|
||||
//------------------------
|
||||
|
||||
const Color3 & operator /= (const Color3 &c);
|
||||
const Color3 & operator /= (T a);
|
||||
Color3 operator / (const Color3 &c) const;
|
||||
Color3 operator / (T a) const;
|
||||
};
|
||||
|
||||
template <class T> class Color4
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------
|
||||
// Access to elements
|
||||
//-------------------
|
||||
|
||||
T r, g, b, a;
|
||||
|
||||
T & operator [] (int i);
|
||||
const T & operator [] (int i) const;
|
||||
|
||||
|
||||
//-------------
|
||||
// Constructors
|
||||
//-------------
|
||||
|
||||
Color4 (); // no initialization
|
||||
explicit Color4 (T a); // (a a a a)
|
||||
Color4 (T a, T b, T c, T d); // (a b c d)
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// Copy constructors and assignment
|
||||
//---------------------------------
|
||||
|
||||
Color4 (const Color4 &v);
|
||||
template <class S> Color4 (const Color4<S> &v);
|
||||
|
||||
const Color4 & operator = (const Color4 &v);
|
||||
|
||||
|
||||
//----------------------
|
||||
// Compatibility with Sb
|
||||
//----------------------
|
||||
|
||||
template <class S>
|
||||
void setValue (S a, S b, S c, S d);
|
||||
|
||||
template <class S>
|
||||
void setValue (const Color4<S> &v);
|
||||
|
||||
template <class S>
|
||||
void getValue (S &a, S &b, S &c, S &d) const;
|
||||
|
||||
template <class S>
|
||||
void getValue (Color4<S> &v) const;
|
||||
|
||||
T * getValue();
|
||||
const T * getValue() const;
|
||||
|
||||
|
||||
//---------
|
||||
// Equality
|
||||
//---------
|
||||
|
||||
template <class S>
|
||||
bool operator == (const Color4<S> &v) const;
|
||||
|
||||
template <class S>
|
||||
bool operator != (const Color4<S> &v) const;
|
||||
|
||||
|
||||
//------------------------
|
||||
// Component-wise addition
|
||||
//------------------------
|
||||
|
||||
const Color4 & operator += (const Color4 &v);
|
||||
Color4 operator + (const Color4 &v) const;
|
||||
|
||||
|
||||
//---------------------------
|
||||
// Component-wise subtraction
|
||||
//---------------------------
|
||||
|
||||
const Color4 & operator -= (const Color4 &v);
|
||||
Color4 operator - (const Color4 &v) const;
|
||||
|
||||
|
||||
//------------------------------------
|
||||
// Component-wise multiplication by -1
|
||||
//------------------------------------
|
||||
|
||||
Color4 operator - () const;
|
||||
const Color4 & negate ();
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Component-wise multiplication
|
||||
//------------------------------
|
||||
|
||||
const Color4 & operator *= (const Color4 &v);
|
||||
const Color4 & operator *= (T a);
|
||||
Color4 operator * (const Color4 &v) const;
|
||||
Color4 operator * (T a) const;
|
||||
|
||||
|
||||
//------------------------
|
||||
// Component-wise division
|
||||
//------------------------
|
||||
|
||||
const Color4 & operator /= (const Color4 &v);
|
||||
const Color4 & operator /= (T a);
|
||||
Color4 operator / (const Color4 &v) const;
|
||||
Color4 operator / (T a) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Number of dimensions, i.e. number of elements in a Color4
|
||||
//----------------------------------------------------------
|
||||
|
||||
static unsigned int dimensions() {return 4;}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Limitations of type T (see also class limits<T>)
|
||||
//-------------------------------------------------
|
||||
|
||||
static T baseTypeMin() {return limits<T>::min();}
|
||||
static T baseTypeMax() {return limits<T>::max();}
|
||||
static T baseTypeSmallest() {return limits<T>::smallest();}
|
||||
static T baseTypeEpsilon() {return limits<T>::epsilon();}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Base type -- in templates, which accept a parameter, V, which
|
||||
// could be a Color4<T>, you can refer to T as
|
||||
// V::BaseType
|
||||
//--------------------------------------------------------------
|
||||
|
||||
typedef T BaseType;
|
||||
};
|
||||
|
||||
//--------------
|
||||
// Stream output
|
||||
//--------------
|
||||
|
||||
template <class T>
|
||||
std::ostream & operator << (std::ostream &s, const Color4<T> &v);
|
||||
|
||||
//----------------------------------------------------
|
||||
// Reverse multiplication: S * Color4<T>
|
||||
//----------------------------------------------------
|
||||
|
||||
template <class S, class T> Color4<T> operator * (S a, const Color4<T> &v);
|
||||
|
||||
//-------------------------
|
||||
// Typedefs for convenience
|
||||
//-------------------------
|
||||
|
||||
typedef Color3<float> Color3f;
|
||||
typedef Color3<half> Color3h;
|
||||
typedef Color3<unsigned char> Color3c;
|
||||
typedef Color3<half> C3h;
|
||||
typedef Color3<float> C3f;
|
||||
typedef Color3<unsigned char> C3c;
|
||||
typedef Color4<float> Color4f;
|
||||
typedef Color4<half> Color4h;
|
||||
typedef Color4<unsigned char> Color4c;
|
||||
typedef Color4<float> C4f;
|
||||
typedef Color4<half> C4h;
|
||||
typedef Color4<unsigned char> C4c;
|
||||
typedef unsigned int PackedColor;
|
||||
|
||||
|
||||
//-------------------------
|
||||
// Implementation of Color3
|
||||
//-------------------------
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color3<T>::Color3 (): Vec3 <T> ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color3<T>::Color3 (T a): Vec3 <T> (a)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color3<T>::Color3 (T a, T b, T c): Vec3 <T> (a, b, c)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color3<T>::Color3 (const Color3 &c): Vec3 <T> (c)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline
|
||||
Color3<T>::Color3 (const Vec3<S> &v): Vec3 <T> (v)
|
||||
{
|
||||
//empty
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::operator = (const Color3 &c)
|
||||
{
|
||||
*((Vec3<T> *) this) = c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::operator += (const Color3 &c)
|
||||
{
|
||||
*((Vec3<T> *) this) += c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color3<T>
|
||||
Color3<T>::operator + (const Color3 &c) const
|
||||
{
|
||||
return Color3 (*(Vec3<T> *)this + (const Vec3<T> &)c);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::operator -= (const Color3 &c)
|
||||
{
|
||||
*((Vec3<T> *) this) -= c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color3<T>
|
||||
Color3<T>::operator - (const Color3 &c) const
|
||||
{
|
||||
return Color3 (*(Vec3<T> *)this - (const Vec3<T> &)c);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color3<T>
|
||||
Color3<T>::operator - () const
|
||||
{
|
||||
return Color3 (-(*(Vec3<T> *)this));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::negate ()
|
||||
{
|
||||
((Vec3<T> *) this)->negate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::operator *= (const Color3 &c)
|
||||
{
|
||||
*((Vec3<T> *) this) *= c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::operator *= (T a)
|
||||
{
|
||||
*((Vec3<T> *) this) *= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color3<T>
|
||||
Color3<T>::operator * (const Color3 &c) const
|
||||
{
|
||||
return Color3 (*(Vec3<T> *)this * (const Vec3<T> &)c);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color3<T>
|
||||
Color3<T>::operator * (T a) const
|
||||
{
|
||||
return Color3 (*(Vec3<T> *)this * a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::operator /= (const Color3 &c)
|
||||
{
|
||||
*((Vec3<T> *) this) /= c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color3<T> &
|
||||
Color3<T>::operator /= (T a)
|
||||
{
|
||||
*((Vec3<T> *) this) /= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color3<T>
|
||||
Color3<T>::operator / (const Color3 &c) const
|
||||
{
|
||||
return Color3 (*(Vec3<T> *)this / (const Vec3<T> &)c);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color3<T>
|
||||
Color3<T>::operator / (T a) const
|
||||
{
|
||||
return Color3 (*(Vec3<T> *)this / a);
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// Implementation of Color4
|
||||
//-----------------------
|
||||
|
||||
template <class T>
|
||||
inline T &
|
||||
Color4<T>::operator [] (int i)
|
||||
{
|
||||
return (&r)[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T &
|
||||
Color4<T>::operator [] (int i) const
|
||||
{
|
||||
return (&r)[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color4<T>::Color4 ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color4<T>::Color4 (T x)
|
||||
{
|
||||
r = g = b = a = x;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color4<T>::Color4 (T x, T y, T z, T w)
|
||||
{
|
||||
r = x;
|
||||
g = y;
|
||||
b = z;
|
||||
a = w;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Color4<T>::Color4 (const Color4 &v)
|
||||
{
|
||||
r = v.r;
|
||||
g = v.g;
|
||||
b = v.b;
|
||||
a = v.a;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline
|
||||
Color4<T>::Color4 (const Color4<S> &v)
|
||||
{
|
||||
r = T (v.r);
|
||||
g = T (v.g);
|
||||
b = T (v.b);
|
||||
a = T (v.a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::operator = (const Color4 &v)
|
||||
{
|
||||
r = v.r;
|
||||
g = v.g;
|
||||
b = v.b;
|
||||
a = v.a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Color4<T>::setValue (S x, S y, S z, S w)
|
||||
{
|
||||
r = T (x);
|
||||
g = T (y);
|
||||
b = T (z);
|
||||
a = T (w);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Color4<T>::setValue (const Color4<S> &v)
|
||||
{
|
||||
r = T (v.r);
|
||||
g = T (v.g);
|
||||
b = T (v.b);
|
||||
a = T (v.a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Color4<T>::getValue (S &x, S &y, S &z, S &w) const
|
||||
{
|
||||
x = S (r);
|
||||
y = S (g);
|
||||
z = S (b);
|
||||
w = S (a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Color4<T>::getValue (Color4<S> &v) const
|
||||
{
|
||||
v.r = S (r);
|
||||
v.g = S (g);
|
||||
v.b = S (b);
|
||||
v.a = S (a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T *
|
||||
Color4<T>::getValue()
|
||||
{
|
||||
return (T *) &r;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T *
|
||||
Color4<T>::getValue() const
|
||||
{
|
||||
return (const T *) &r;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline bool
|
||||
Color4<T>::operator == (const Color4<S> &v) const
|
||||
{
|
||||
return r == v.r && g == v.g && b == v.b && a == v.a;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline bool
|
||||
Color4<T>::operator != (const Color4<S> &v) const
|
||||
{
|
||||
return r != v.r || g != v.g || b != v.b || a != v.a;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::operator += (const Color4 &v)
|
||||
{
|
||||
r += v.r;
|
||||
g += v.g;
|
||||
b += v.b;
|
||||
a += v.a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color4<T>
|
||||
Color4<T>::operator + (const Color4 &v) const
|
||||
{
|
||||
return Color4 (r + v.r, g + v.g, b + v.b, a + v.a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::operator -= (const Color4 &v)
|
||||
{
|
||||
r -= v.r;
|
||||
g -= v.g;
|
||||
b -= v.b;
|
||||
a -= v.a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color4<T>
|
||||
Color4<T>::operator - (const Color4 &v) const
|
||||
{
|
||||
return Color4 (r - v.r, g - v.g, b - v.b, a - v.a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color4<T>
|
||||
Color4<T>::operator - () const
|
||||
{
|
||||
return Color4 (-r, -g, -b, -a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::negate ()
|
||||
{
|
||||
r = -r;
|
||||
g = -g;
|
||||
b = -b;
|
||||
a = -a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::operator *= (const Color4 &v)
|
||||
{
|
||||
r *= v.r;
|
||||
g *= v.g;
|
||||
b *= v.b;
|
||||
a *= v.a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::operator *= (T x)
|
||||
{
|
||||
r *= x;
|
||||
g *= x;
|
||||
b *= x;
|
||||
a *= x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color4<T>
|
||||
Color4<T>::operator * (const Color4 &v) const
|
||||
{
|
||||
return Color4 (r * v.r, g * v.g, b * v.b, a * v.a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color4<T>
|
||||
Color4<T>::operator * (T x) const
|
||||
{
|
||||
return Color4 (r * x, g * x, b * x, a * x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::operator /= (const Color4 &v)
|
||||
{
|
||||
r /= v.r;
|
||||
g /= v.g;
|
||||
b /= v.b;
|
||||
a /= v.a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Color4<T> &
|
||||
Color4<T>::operator /= (T x)
|
||||
{
|
||||
r /= x;
|
||||
g /= x;
|
||||
b /= x;
|
||||
a /= x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color4<T>
|
||||
Color4<T>::operator / (const Color4 &v) const
|
||||
{
|
||||
return Color4 (r / v.r, g / v.g, b / v.b, a / v.a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Color4<T>
|
||||
Color4<T>::operator / (T x) const
|
||||
{
|
||||
return Color4 (r / x, g / x, b / x, a / x);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
std::ostream &
|
||||
operator << (std::ostream &s, const Color4<T> &v)
|
||||
{
|
||||
return s << '(' << v.r << ' ' << v.g << ' ' << v.b << ' ' << v.a << ')';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Implementation of reverse multiplication
|
||||
//-----------------------------------------
|
||||
|
||||
template <class S, class T>
|
||||
inline Color4<T>
|
||||
operator * (S x, const Color4<T> &v)
|
||||
{
|
||||
return Color4<T> (x * v.r, x * v.g, x * v.b, x * v.a);
|
||||
}
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
256
3rdparty/include/OpenEXR/ImathColorAlgo.h
vendored
256
3rdparty/include/OpenEXR/ImathColorAlgo.h
vendored
@ -1,256 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHCOLORALGO_H
|
||||
#define INCLUDED_IMATHCOLORALGO_H
|
||||
|
||||
|
||||
#include "ImathColor.h"
|
||||
#include "ImathMath.h"
|
||||
#include "ImathLimits.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
//
|
||||
// Non-templated helper routines for color conversion.
|
||||
// These routines eliminate type warnings under g++.
|
||||
//
|
||||
|
||||
Vec3<double> hsv2rgb_d(const Vec3<double> &hsv);
|
||||
|
||||
Color4<double> hsv2rgb_d(const Color4<double> &hsv);
|
||||
|
||||
|
||||
Vec3<double> rgb2hsv_d(const Vec3<double> &rgb);
|
||||
|
||||
Color4<double> rgb2hsv_d(const Color4<double> &rgb);
|
||||
|
||||
|
||||
//
|
||||
// Color conversion functions and general color algorithms
|
||||
//
|
||||
// hsv2rgb(), rgb2hsv(), rgb2packed(), packed2rgb()
|
||||
// see each funtion definition for details.
|
||||
//
|
||||
|
||||
template<class T>
|
||||
Vec3<T>
|
||||
hsv2rgb(const Vec3<T> &hsv)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
Vec3<double> v = Vec3<double>(hsv.x / double(limits<T>::max()),
|
||||
hsv.y / double(limits<T>::max()),
|
||||
hsv.z / double(limits<T>::max()));
|
||||
Vec3<double> c = hsv2rgb_d(v);
|
||||
return Vec3<T>((T) (c.x * limits<T>::max()),
|
||||
(T) (c.y * limits<T>::max()),
|
||||
(T) (c.z * limits<T>::max()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3<double> v = Vec3<double>(hsv.x, hsv.y, hsv.z);
|
||||
Vec3<double> c = hsv2rgb_d(v);
|
||||
return Vec3<T>((T) c.x, (T) c.y, (T) c.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Color4<T>
|
||||
hsv2rgb(const Color4<T> &hsv)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
Color4<double> v = Color4<double>(hsv.r / float(limits<T>::max()),
|
||||
hsv.g / float(limits<T>::max()),
|
||||
hsv.b / float(limits<T>::max()),
|
||||
hsv.a / float(limits<T>::max()));
|
||||
Color4<double> c = hsv2rgb_d(v);
|
||||
return Color4<T>((T) (c.r * limits<T>::max()),
|
||||
(T) (c.g * limits<T>::max()),
|
||||
(T) (c.b * limits<T>::max()),
|
||||
(T) (c.a * limits<T>::max()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Color4<double> v = Color4<double>(hsv.r, hsv.g, hsv.g, hsv.a);
|
||||
Color4<double> c = hsv2rgb_d(v);
|
||||
return Color4<T>((T) c.r, (T) c.g, (T) c.b, (T) c.a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Vec3<T>
|
||||
rgb2hsv(const Vec3<T> &rgb)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
Vec3<double> v = Vec3<double>(rgb.x / double(limits<T>::max()),
|
||||
rgb.y / double(limits<T>::max()),
|
||||
rgb.z / double(limits<T>::max()));
|
||||
Vec3<double> c = rgb2hsv_d(v);
|
||||
return Vec3<T>((T) (c.x * limits<T>::max()),
|
||||
(T) (c.y * limits<T>::max()),
|
||||
(T) (c.z * limits<T>::max()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3<double> v = Vec3<double>(rgb.x, rgb.y, rgb.z);
|
||||
Vec3<double> c = rgb2hsv_d(v);
|
||||
return Vec3<T>((T) c.x, (T) c.y, (T) c.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Color4<T>
|
||||
rgb2hsv(const Color4<T> &rgb)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
Color4<double> v = Color4<double>(rgb.r / float(limits<T>::max()),
|
||||
rgb.g / float(limits<T>::max()),
|
||||
rgb.b / float(limits<T>::max()),
|
||||
rgb.a / float(limits<T>::max()));
|
||||
Color4<double> c = rgb2hsv_d(v);
|
||||
return Color4<T>((T) (c.r * limits<T>::max()),
|
||||
(T) (c.g * limits<T>::max()),
|
||||
(T) (c.b * limits<T>::max()),
|
||||
(T) (c.a * limits<T>::max()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Color4<double> v = Color4<double>(rgb.r, rgb.g, rgb.g, rgb.a);
|
||||
Color4<double> c = rgb2hsv_d(v);
|
||||
return Color4<T>((T) c.r, (T) c.g, (T) c.b, (T) c.a);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
PackedColor
|
||||
rgb2packed(const Vec3<T> &c)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
float x = c.x / float(limits<T>::max());
|
||||
float y = c.y / float(limits<T>::max());
|
||||
float z = c.z / float(limits<T>::max());
|
||||
return rgb2packed( V3f(x,y,z) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( (PackedColor) (c.x * 255) |
|
||||
(((PackedColor) (c.y * 255)) << 8) |
|
||||
(((PackedColor) (c.z * 255)) << 16) | 0xFF000000 );
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
PackedColor
|
||||
rgb2packed(const Color4<T> &c)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
float r = c.r / float(limits<T>::max());
|
||||
float g = c.g / float(limits<T>::max());
|
||||
float b = c.b / float(limits<T>::max());
|
||||
float a = c.a / float(limits<T>::max());
|
||||
return rgb2packed( C4f(r,g,b,a) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( (PackedColor) (c.r * 255) |
|
||||
(((PackedColor) (c.g * 255)) << 8) |
|
||||
(((PackedColor) (c.b * 255)) << 16) |
|
||||
(((PackedColor) (c.a * 255)) << 24));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This guy can't return the result because the template
|
||||
// parameter would not be in the function signiture. So instead,
|
||||
// its passed in as an argument.
|
||||
//
|
||||
|
||||
template <class T>
|
||||
void
|
||||
packed2rgb(PackedColor packed, Vec3<T> &out)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
T f = limits<T>::max() / ((PackedColor)0xFF);
|
||||
out.x = (packed & 0xFF) * f;
|
||||
out.y = ((packed & 0xFF00) >> 8) * f;
|
||||
out.z = ((packed & 0xFF0000) >> 16) * f;
|
||||
}
|
||||
else
|
||||
{
|
||||
T f = T(1) / T(255);
|
||||
out.x = (packed & 0xFF) * f;
|
||||
out.y = ((packed & 0xFF00) >> 8) * f;
|
||||
out.z = ((packed & 0xFF0000) >> 16) * f;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
packed2rgb(PackedColor packed, Color4<T> &out)
|
||||
{
|
||||
if ( limits<T>::isIntegral() )
|
||||
{
|
||||
T f = limits<T>::max() / ((PackedColor)0xFF);
|
||||
out.r = (packed & 0xFF) * f;
|
||||
out.g = ((packed & 0xFF00) >> 8) * f;
|
||||
out.b = ((packed & 0xFF0000) >> 16) * f;
|
||||
out.a = ((packed & 0xFF000000) >> 24) * f;
|
||||
}
|
||||
else
|
||||
{
|
||||
T f = T(1) / T(255);
|
||||
out.r = (packed & 0xFF) * f;
|
||||
out.g = ((packed & 0xFF00) >> 8) * f;
|
||||
out.b = ((packed & 0xFF0000) >> 16) * f;
|
||||
out.a = ((packed & 0xFF000000) >> 24) * f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
903
3rdparty/include/OpenEXR/ImathEuler.h
vendored
903
3rdparty/include/OpenEXR/ImathEuler.h
vendored
@ -1,903 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHEULER_H
|
||||
#define INCLUDED_IMATHEULER_H
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// template class Euler<T>
|
||||
//
|
||||
// This class represents euler angle orientations. The class
|
||||
// inherits from Vec3 to it can be freely cast. The additional
|
||||
// information is the euler priorities rep. This class is
|
||||
// essentially a rip off of Ken Shoemake's GemsIV code. It has
|
||||
// been modified minimally to make it more understandable, but
|
||||
// hardly enough to make it easy to grok completely.
|
||||
//
|
||||
// There are 24 possible combonations of Euler angle
|
||||
// representations of which 12 are common in CG and you will
|
||||
// probably only use 6 of these which in this scheme are the
|
||||
// non-relative-non-repeating types.
|
||||
//
|
||||
// The representations can be partitioned according to two
|
||||
// criteria:
|
||||
//
|
||||
// 1) Are the angles measured relative to a set of fixed axis
|
||||
// or relative to each other (the latter being what happens
|
||||
// when rotation matrices are multiplied together and is
|
||||
// almost ubiquitous in the cg community)
|
||||
//
|
||||
// 2) Is one of the rotations repeated (ala XYX rotation)
|
||||
//
|
||||
// When you construct a given representation from scratch you
|
||||
// must order the angles according to their priorities. So, the
|
||||
// easiest is a softimage or aerospace (yaw/pitch/roll) ordering
|
||||
// of ZYX.
|
||||
//
|
||||
// float x_rot = 1;
|
||||
// float y_rot = 2;
|
||||
// float z_rot = 3;
|
||||
//
|
||||
// Eulerf angles(z_rot, y_rot, x_rot, Eulerf::ZYX);
|
||||
// -or-
|
||||
// Eulerf angles( V3f(z_rot,y_rot,z_rot), Eulerf::ZYX );
|
||||
//
|
||||
// If instead, the order was YXZ for instance you would have to
|
||||
// do this:
|
||||
//
|
||||
// float x_rot = 1;
|
||||
// float y_rot = 2;
|
||||
// float z_rot = 3;
|
||||
//
|
||||
// Eulerf angles(y_rot, x_rot, z_rot, Eulerf::YXZ);
|
||||
// -or-
|
||||
// Eulerf angles( V3f(y_rot,x_rot,z_rot), Eulerf::YXZ );
|
||||
//
|
||||
// Notice how the order you put the angles into the three slots
|
||||
// should correspond to the enum (YXZ) ordering. The input angle
|
||||
// vector is called the "ijk" vector -- not an "xyz" vector. The
|
||||
// ijk vector order is the same as the enum. If you treat the
|
||||
// Euler<> as a Vec<> (which it inherts from) you will find the
|
||||
// angles are ordered in the same way, i.e.:
|
||||
//
|
||||
// V3f v = angles;
|
||||
// // v.x == y_rot, v.y == x_rot, v.z == z_rot
|
||||
//
|
||||
// If you just want the x, y, and z angles stored in a vector in
|
||||
// that order, you can do this:
|
||||
//
|
||||
// V3f v = angles.toXYZVector()
|
||||
// // v.x == x_rot, v.y == y_rot, v.z == z_rot
|
||||
//
|
||||
// If you want to set the Euler with an XYZVector use the
|
||||
// optional layout argument:
|
||||
//
|
||||
// Eulerf angles(x_rot, y_rot, z_rot,
|
||||
// Eulerf::YXZ,
|
||||
// Eulerf::XYZLayout);
|
||||
//
|
||||
// This is the same as:
|
||||
//
|
||||
// Eulerf angles(y_rot, x_rot, z_rot, Eulerf::YXZ);
|
||||
//
|
||||
// Note that this won't do anything intelligent if you have a
|
||||
// repeated axis in the euler angles (e.g. XYX)
|
||||
//
|
||||
// If you need to use the "relative" versions of these, you will
|
||||
// need to use the "r" enums.
|
||||
//
|
||||
// The units of the rotation angles are assumed to be radians.
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
#include "ImathMath.h"
|
||||
#include "ImathVec.h"
|
||||
#include "ImathQuat.h"
|
||||
#include "ImathMatrix.h"
|
||||
#include "ImathLimits.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace Imath {
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
// Disable MS VC++ warnings about conversion from double to float
|
||||
#pragma warning(disable:4244)
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class Euler : public Vec3<T>
|
||||
{
|
||||
public:
|
||||
|
||||
using Vec3<T>::x;
|
||||
using Vec3<T>::y;
|
||||
using Vec3<T>::z;
|
||||
|
||||
enum Order
|
||||
{
|
||||
//
|
||||
// All 24 possible orderings
|
||||
//
|
||||
|
||||
XYZ = 0x0101, // "usual" orderings
|
||||
XZY = 0x0001,
|
||||
YZX = 0x1101,
|
||||
YXZ = 0x1001,
|
||||
ZXY = 0x2101,
|
||||
ZYX = 0x2001,
|
||||
|
||||
XZX = 0x0011, // first axis repeated
|
||||
XYX = 0x0111,
|
||||
YXY = 0x1011,
|
||||
YZY = 0x1111,
|
||||
ZYZ = 0x2011,
|
||||
ZXZ = 0x2111,
|
||||
|
||||
XYZr = 0x2000, // relative orderings -- not common
|
||||
XZYr = 0x2100,
|
||||
YZXr = 0x1000,
|
||||
YXZr = 0x1100,
|
||||
ZXYr = 0x0000,
|
||||
ZYXr = 0x0100,
|
||||
|
||||
XZXr = 0x2110, // relative first axis repeated
|
||||
XYXr = 0x2010,
|
||||
YXYr = 0x1110,
|
||||
YZYr = 0x1010,
|
||||
ZYZr = 0x0110,
|
||||
ZXZr = 0x0010,
|
||||
// ||||
|
||||
// VVVV
|
||||
// Legend: ABCD
|
||||
// A -> Initial Axis (0==x, 1==y, 2==z)
|
||||
// B -> Parity Even (1==true)
|
||||
// C -> Initial Repeated (1==true)
|
||||
// D -> Frame Static (1==true)
|
||||
//
|
||||
|
||||
Legal = XYZ | XZY | YZX | YXZ | ZXY | ZYX |
|
||||
XZX | XYX | YXY | YZY | ZYZ | ZXZ |
|
||||
XYZr| XZYr| YZXr| YXZr| ZXYr| ZYXr|
|
||||
XZXr| XYXr| YXYr| YZYr| ZYZr| ZXZr,
|
||||
|
||||
Min = 0x0000,
|
||||
Max = 0x2111,
|
||||
Default = XYZ
|
||||
};
|
||||
|
||||
enum Axis { X = 0, Y = 1, Z = 2 };
|
||||
|
||||
enum InputLayout { XYZLayout, IJKLayout };
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Constructors -- all default to ZYX non-relative ala softimage
|
||||
// (where there is no argument to specify it)
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Euler();
|
||||
Euler(const Euler&);
|
||||
Euler(Order p);
|
||||
Euler(const Vec3<T> &v, Order o = Default, InputLayout l = IJKLayout);
|
||||
Euler(T i, T j, T k, Order o = Default, InputLayout l = IJKLayout);
|
||||
Euler(const Euler<T> &euler, Order newp);
|
||||
Euler(const Matrix33<T> &, Order o = Default);
|
||||
Euler(const Matrix44<T> &, Order o = Default);
|
||||
|
||||
//---------------------------------
|
||||
// Algebraic functions/ Operators
|
||||
//---------------------------------
|
||||
|
||||
const Euler<T>& operator= (const Euler<T>&);
|
||||
const Euler<T>& operator= (const Vec3<T>&);
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Set the euler value
|
||||
// This does NOT convert the angles, but setXYZVector()
|
||||
// does reorder the input vector.
|
||||
//--------------------------------------------------------
|
||||
|
||||
static bool legal(Order);
|
||||
|
||||
void setXYZVector(const Vec3<T> &);
|
||||
|
||||
Order order() const;
|
||||
void setOrder(Order);
|
||||
|
||||
void set(Axis initial,
|
||||
bool relative,
|
||||
bool parityEven,
|
||||
bool firstRepeats);
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Conversions, toXYZVector() reorders the angles so that
|
||||
// the X rotation comes first, followed by the Y and Z
|
||||
// in cases like XYX ordering, the repeated angle will be
|
||||
// in the "z" component
|
||||
//---------------------------------------------------------
|
||||
|
||||
void extract(const Matrix33<T>&);
|
||||
void extract(const Matrix44<T>&);
|
||||
void extract(const Quat<T>&);
|
||||
|
||||
Matrix33<T> toMatrix33() const;
|
||||
Matrix44<T> toMatrix44() const;
|
||||
Quat<T> toQuat() const;
|
||||
Vec3<T> toXYZVector() const;
|
||||
|
||||
//---------------------------------------------------
|
||||
// Use this function to unpack angles from ijk form
|
||||
//---------------------------------------------------
|
||||
|
||||
void angleOrder(int &i, int &j, int &k) const;
|
||||
|
||||
//---------------------------------------------------
|
||||
// Use this function to determine mapping from xyz to ijk
|
||||
// - reshuffles the xyz to match the order
|
||||
//---------------------------------------------------
|
||||
|
||||
void angleMapping(int &i, int &j, int &k) const;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Utility methods for getting continuous rotations. None of these
|
||||
// methods change the orientation given by its inputs (or at least
|
||||
// that is the intent).
|
||||
//
|
||||
// angleMod() converts an angle to its equivalent in [-PI, PI]
|
||||
//
|
||||
// simpleXYZRotation() adjusts xyzRot so that its components differ
|
||||
// from targetXyzRot by no more than +-PI
|
||||
//
|
||||
// nearestRotation() adjusts xyzRot so that its components differ
|
||||
// from targetXyzRot by as little as possible.
|
||||
// Note that xyz here really means ijk, because
|
||||
// the order must be provided.
|
||||
//
|
||||
// makeNear() adjusts "this" Euler so that its components differ
|
||||
// from target by as little as possible. This method
|
||||
// might not make sense for Eulers with different order
|
||||
// and it probably doesn't work for repeated axis and
|
||||
// relative orderings (TODO).
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
static float angleMod (T angle);
|
||||
static void simpleXYZRotation (Vec3<T> &xyzRot,
|
||||
const Vec3<T> &targetXyzRot);
|
||||
static void nearestRotation (Vec3<T> &xyzRot,
|
||||
const Vec3<T> &targetXyzRot,
|
||||
Order order = XYZ);
|
||||
|
||||
void makeNear (const Euler<T> &target);
|
||||
|
||||
bool frameStatic() const { return _frameStatic; }
|
||||
bool initialRepeated() const { return _initialRepeated; }
|
||||
bool parityEven() const { return _parityEven; }
|
||||
Axis initialAxis() const { return _initialAxis; }
|
||||
|
||||
protected:
|
||||
|
||||
bool _frameStatic : 1; // relative or static rotations
|
||||
bool _initialRepeated : 1; // init axis repeated as last
|
||||
bool _parityEven : 1; // "parity of axis permutation"
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
Axis _initialAxis ; // First axis of rotation
|
||||
#else
|
||||
Axis _initialAxis : 2; // First axis of rotation
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//--------------------
|
||||
// Convenient typedefs
|
||||
//--------------------
|
||||
|
||||
typedef Euler<float> Eulerf;
|
||||
typedef Euler<double> Eulerd;
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template<class T>
|
||||
inline void
|
||||
Euler<T>::angleOrder(int &i, int &j, int &k) const
|
||||
{
|
||||
i = _initialAxis;
|
||||
j = _parityEven ? (i+1)%3 : (i > 0 ? i-1 : 2);
|
||||
k = _parityEven ? (i > 0 ? i-1 : 2) : (i+1)%3;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void
|
||||
Euler<T>::angleMapping(int &i, int &j, int &k) const
|
||||
{
|
||||
int m[3];
|
||||
|
||||
m[_initialAxis] = 0;
|
||||
m[(_initialAxis+1) % 3] = _parityEven ? 1 : 2;
|
||||
m[(_initialAxis+2) % 3] = _parityEven ? 2 : 1;
|
||||
i = m[0];
|
||||
j = m[1];
|
||||
k = m[2];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void
|
||||
Euler<T>::setXYZVector(const Vec3<T> &v)
|
||||
{
|
||||
int i,j,k;
|
||||
angleMapping(i,j,k);
|
||||
(*this)[i] = v.x;
|
||||
(*this)[j] = v.y;
|
||||
(*this)[k] = v.z;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Vec3<T>
|
||||
Euler<T>::toXYZVector() const
|
||||
{
|
||||
int i,j,k;
|
||||
angleMapping(i,j,k);
|
||||
return Vec3<T>((*this)[i],(*this)[j],(*this)[k]);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Euler<T>::Euler() :
|
||||
Vec3<T>(0,0,0),
|
||||
_frameStatic(true),
|
||||
_initialRepeated(false),
|
||||
_parityEven(true),
|
||||
_initialAxis(X)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
Euler<T>::Euler(typename Euler<T>::Order p) :
|
||||
Vec3<T>(0,0,0),
|
||||
_frameStatic(true),
|
||||
_initialRepeated(false),
|
||||
_parityEven(true),
|
||||
_initialAxis(X)
|
||||
{
|
||||
setOrder(p);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Euler<T>::Euler( const Vec3<T> &v,
|
||||
typename Euler<T>::Order p,
|
||||
typename Euler<T>::InputLayout l )
|
||||
{
|
||||
setOrder(p);
|
||||
if ( l == XYZLayout ) setXYZVector(v);
|
||||
else { x = v.x; y = v.y; z = v.z; }
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Euler<T>::Euler(const Euler<T> &euler)
|
||||
{
|
||||
operator=(euler);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Euler<T>::Euler(const Euler<T> &euler,Order p)
|
||||
{
|
||||
setOrder(p);
|
||||
Matrix33<T> M = euler.toMatrix33();
|
||||
extract(M);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Euler<T>::Euler( T xi, T yi, T zi,
|
||||
typename Euler<T>::Order p,
|
||||
typename Euler<T>::InputLayout l)
|
||||
{
|
||||
setOrder(p);
|
||||
if ( l == XYZLayout ) setXYZVector(Vec3<T>(xi,yi,zi));
|
||||
else { x = xi; y = yi; z = zi; }
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Euler<T>::Euler( const Matrix33<T> &M, typename Euler::Order p )
|
||||
{
|
||||
setOrder(p);
|
||||
extract(M);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Euler<T>::Euler( const Matrix44<T> &M, typename Euler::Order p )
|
||||
{
|
||||
setOrder(p);
|
||||
extract(M);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Euler<T>::extract(const Quat<T> &q)
|
||||
{
|
||||
extract(q.toMatrix33());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Euler<T>::extract(const Matrix33<T> &M)
|
||||
{
|
||||
int i,j,k;
|
||||
angleOrder(i,j,k);
|
||||
|
||||
if (_initialRepeated)
|
||||
{
|
||||
//
|
||||
// Extract the first angle, x.
|
||||
//
|
||||
|
||||
x = Math<T>::atan2 (M[j][i], M[k][i]);
|
||||
|
||||
//
|
||||
// Remove the x rotation from M, so that the remaining
|
||||
// rotation, N, is only around two axes, and gimbal lock
|
||||
// cannot occur.
|
||||
//
|
||||
|
||||
Vec3<T> r (0, 0, 0);
|
||||
r[i] = (_parityEven? -x: x);
|
||||
|
||||
Matrix44<T> N;
|
||||
N.rotate (r);
|
||||
|
||||
N = N * Matrix44<T> (M[0][0], M[0][1], M[0][2], 0,
|
||||
M[1][0], M[1][1], M[1][2], 0,
|
||||
M[2][0], M[2][1], M[2][2], 0,
|
||||
0, 0, 0, 1);
|
||||
//
|
||||
// Extract the other two angles, y and z, from N.
|
||||
//
|
||||
|
||||
T sy = Math<T>::sqrt (N[j][i]*N[j][i] + N[k][i]*N[k][i]);
|
||||
y = Math<T>::atan2 (sy, N[i][i]);
|
||||
z = Math<T>::atan2 (N[j][k], N[j][j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Extract the first angle, x.
|
||||
//
|
||||
|
||||
x = Math<T>::atan2 (M[j][k], M[k][k]);
|
||||
|
||||
//
|
||||
// Remove the x rotation from M, so that the remaining
|
||||
// rotation, N, is only around two axes, and gimbal lock
|
||||
// cannot occur.
|
||||
//
|
||||
|
||||
Vec3<T> r (0, 0, 0);
|
||||
r[i] = (_parityEven? -x: x);
|
||||
|
||||
Matrix44<T> N;
|
||||
N.rotate (r);
|
||||
|
||||
N = N * Matrix44<T> (M[0][0], M[0][1], M[0][2], 0,
|
||||
M[1][0], M[1][1], M[1][2], 0,
|
||||
M[2][0], M[2][1], M[2][2], 0,
|
||||
0, 0, 0, 1);
|
||||
//
|
||||
// Extract the other two angles, y and z, from N.
|
||||
//
|
||||
|
||||
T cy = Math<T>::sqrt (N[i][i]*N[i][i] + N[i][j]*N[i][j]);
|
||||
y = Math<T>::atan2 (-N[i][k], cy);
|
||||
z = Math<T>::atan2 (-N[j][i], N[j][j]);
|
||||
}
|
||||
|
||||
if (!_parityEven)
|
||||
*this *= -1;
|
||||
|
||||
if (!_frameStatic)
|
||||
{
|
||||
T t = x;
|
||||
x = z;
|
||||
z = t;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Euler<T>::extract(const Matrix44<T> &M)
|
||||
{
|
||||
int i,j,k;
|
||||
angleOrder(i,j,k);
|
||||
|
||||
if (_initialRepeated)
|
||||
{
|
||||
//
|
||||
// Extract the first angle, x.
|
||||
//
|
||||
|
||||
x = Math<T>::atan2 (M[j][i], M[k][i]);
|
||||
|
||||
//
|
||||
// Remove the x rotation from M, so that the remaining
|
||||
// rotation, N, is only around two axes, and gimbal lock
|
||||
// cannot occur.
|
||||
//
|
||||
|
||||
Vec3<T> r (0, 0, 0);
|
||||
r[i] = (_parityEven? -x: x);
|
||||
|
||||
Matrix44<T> N;
|
||||
N.rotate (r);
|
||||
N = N * M;
|
||||
|
||||
//
|
||||
// Extract the other two angles, y and z, from N.
|
||||
//
|
||||
|
||||
T sy = Math<T>::sqrt (N[j][i]*N[j][i] + N[k][i]*N[k][i]);
|
||||
y = Math<T>::atan2 (sy, N[i][i]);
|
||||
z = Math<T>::atan2 (N[j][k], N[j][j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Extract the first angle, x.
|
||||
//
|
||||
|
||||
x = Math<T>::atan2 (M[j][k], M[k][k]);
|
||||
|
||||
//
|
||||
// Remove the x rotation from M, so that the remaining
|
||||
// rotation, N, is only around two axes, and gimbal lock
|
||||
// cannot occur.
|
||||
//
|
||||
|
||||
Vec3<T> r (0, 0, 0);
|
||||
r[i] = (_parityEven? -x: x);
|
||||
|
||||
Matrix44<T> N;
|
||||
N.rotate (r);
|
||||
N = N * M;
|
||||
|
||||
//
|
||||
// Extract the other two angles, y and z, from N.
|
||||
//
|
||||
|
||||
T cy = Math<T>::sqrt (N[i][i]*N[i][i] + N[i][j]*N[i][j]);
|
||||
y = Math<T>::atan2 (-N[i][k], cy);
|
||||
z = Math<T>::atan2 (-N[j][i], N[j][j]);
|
||||
}
|
||||
|
||||
if (!_parityEven)
|
||||
*this *= -1;
|
||||
|
||||
if (!_frameStatic)
|
||||
{
|
||||
T t = x;
|
||||
x = z;
|
||||
z = t;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Matrix33<T> Euler<T>::toMatrix33() const
|
||||
{
|
||||
int i,j,k;
|
||||
angleOrder(i,j,k);
|
||||
|
||||
Vec3<T> angles;
|
||||
|
||||
if ( _frameStatic ) angles = (*this);
|
||||
else angles = Vec3<T>(z,y,x);
|
||||
|
||||
if ( !_parityEven ) angles *= -1.0;
|
||||
|
||||
T ci = Math<T>::cos(angles.x);
|
||||
T cj = Math<T>::cos(angles.y);
|
||||
T ch = Math<T>::cos(angles.z);
|
||||
T si = Math<T>::sin(angles.x);
|
||||
T sj = Math<T>::sin(angles.y);
|
||||
T sh = Math<T>::sin(angles.z);
|
||||
|
||||
T cc = ci*ch;
|
||||
T cs = ci*sh;
|
||||
T sc = si*ch;
|
||||
T ss = si*sh;
|
||||
|
||||
Matrix33<T> M;
|
||||
|
||||
if ( _initialRepeated )
|
||||
{
|
||||
M[i][i] = cj; M[j][i] = sj*si; M[k][i] = sj*ci;
|
||||
M[i][j] = sj*sh; M[j][j] = -cj*ss+cc; M[k][j] = -cj*cs-sc;
|
||||
M[i][k] = -sj*ch; M[j][k] = cj*sc+cs; M[k][k] = cj*cc-ss;
|
||||
}
|
||||
else
|
||||
{
|
||||
M[i][i] = cj*ch; M[j][i] = sj*sc-cs; M[k][i] = sj*cc+ss;
|
||||
M[i][j] = cj*sh; M[j][j] = sj*ss+cc; M[k][j] = sj*cs-sc;
|
||||
M[i][k] = -sj; M[j][k] = cj*si; M[k][k] = cj*ci;
|
||||
}
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Matrix44<T> Euler<T>::toMatrix44() const
|
||||
{
|
||||
int i,j,k;
|
||||
angleOrder(i,j,k);
|
||||
|
||||
Vec3<T> angles;
|
||||
|
||||
if ( _frameStatic ) angles = (*this);
|
||||
else angles = Vec3<T>(z,y,x);
|
||||
|
||||
if ( !_parityEven ) angles *= -1.0;
|
||||
|
||||
T ci = Math<T>::cos(angles.x);
|
||||
T cj = Math<T>::cos(angles.y);
|
||||
T ch = Math<T>::cos(angles.z);
|
||||
T si = Math<T>::sin(angles.x);
|
||||
T sj = Math<T>::sin(angles.y);
|
||||
T sh = Math<T>::sin(angles.z);
|
||||
|
||||
T cc = ci*ch;
|
||||
T cs = ci*sh;
|
||||
T sc = si*ch;
|
||||
T ss = si*sh;
|
||||
|
||||
Matrix44<T> M;
|
||||
|
||||
if ( _initialRepeated )
|
||||
{
|
||||
M[i][i] = cj; M[j][i] = sj*si; M[k][i] = sj*ci;
|
||||
M[i][j] = sj*sh; M[j][j] = -cj*ss+cc; M[k][j] = -cj*cs-sc;
|
||||
M[i][k] = -sj*ch; M[j][k] = cj*sc+cs; M[k][k] = cj*cc-ss;
|
||||
}
|
||||
else
|
||||
{
|
||||
M[i][i] = cj*ch; M[j][i] = sj*sc-cs; M[k][i] = sj*cc+ss;
|
||||
M[i][j] = cj*sh; M[j][j] = sj*ss+cc; M[k][j] = sj*cs-sc;
|
||||
M[i][k] = -sj; M[j][k] = cj*si; M[k][k] = cj*ci;
|
||||
}
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Quat<T> Euler<T>::toQuat() const
|
||||
{
|
||||
Vec3<T> angles;
|
||||
int i,j,k;
|
||||
angleOrder(i,j,k);
|
||||
|
||||
if ( _frameStatic ) angles = (*this);
|
||||
else angles = Vec3<T>(z,y,x);
|
||||
|
||||
if ( !_parityEven ) angles.y = -angles.y;
|
||||
|
||||
T ti = angles.x*0.5;
|
||||
T tj = angles.y*0.5;
|
||||
T th = angles.z*0.5;
|
||||
T ci = Math<T>::cos(ti);
|
||||
T cj = Math<T>::cos(tj);
|
||||
T ch = Math<T>::cos(th);
|
||||
T si = Math<T>::sin(ti);
|
||||
T sj = Math<T>::sin(tj);
|
||||
T sh = Math<T>::sin(th);
|
||||
T cc = ci*ch;
|
||||
T cs = ci*sh;
|
||||
T sc = si*ch;
|
||||
T ss = si*sh;
|
||||
|
||||
T parity = _parityEven ? 1.0 : -1.0;
|
||||
|
||||
Quat<T> q;
|
||||
Vec3<T> a;
|
||||
|
||||
if ( _initialRepeated )
|
||||
{
|
||||
a[i] = cj*(cs + sc);
|
||||
a[j] = sj*(cc + ss) * parity,
|
||||
a[k] = sj*(cs - sc);
|
||||
q.r = cj*(cc - ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
a[i] = cj*sc - sj*cs,
|
||||
a[j] = (cj*ss + sj*cc) * parity,
|
||||
a[k] = cj*cs - sj*sc;
|
||||
q.r = cj*cc + sj*ss;
|
||||
}
|
||||
|
||||
q.v = a;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool
|
||||
Euler<T>::legal(typename Euler<T>::Order order)
|
||||
{
|
||||
return (order & ~Legal) ? false : true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename Euler<T>::Order
|
||||
Euler<T>::order() const
|
||||
{
|
||||
int foo = (_initialAxis == Z ? 0x2000 : (_initialAxis == Y ? 0x1000 : 0));
|
||||
|
||||
if (_parityEven) foo |= 0x0100;
|
||||
if (_initialRepeated) foo |= 0x0010;
|
||||
if (_frameStatic) foo++;
|
||||
|
||||
return (Order)foo;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Euler<T>::setOrder(typename Euler<T>::Order p)
|
||||
{
|
||||
set( p & 0x2000 ? Z : (p & 0x1000 ? Y : X), // initial axis
|
||||
!(p & 0x1), // static?
|
||||
!!(p & 0x100), // permutation even?
|
||||
!!(p & 0x10)); // initial repeats?
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Euler<T>::set(typename Euler<T>::Axis axis,
|
||||
bool relative,
|
||||
bool parityEven,
|
||||
bool firstRepeats)
|
||||
{
|
||||
_initialAxis = axis;
|
||||
_frameStatic = !relative;
|
||||
_parityEven = parityEven;
|
||||
_initialRepeated = firstRepeats;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const Euler<T>& Euler<T>::operator= (const Euler<T> &euler)
|
||||
{
|
||||
x = euler.x;
|
||||
y = euler.y;
|
||||
z = euler.z;
|
||||
_initialAxis = euler._initialAxis;
|
||||
_frameStatic = euler._frameStatic;
|
||||
_parityEven = euler._parityEven;
|
||||
_initialRepeated = euler._initialRepeated;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const Euler<T>& Euler<T>::operator= (const Vec3<T> &v)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::ostream& operator << (std::ostream &o, const Euler<T> &euler)
|
||||
{
|
||||
char a[3] = { 'X', 'Y', 'Z' };
|
||||
|
||||
const char* r = euler.frameStatic() ? "" : "r";
|
||||
int i,j,k;
|
||||
euler.angleOrder(i,j,k);
|
||||
|
||||
if ( euler.initialRepeated() ) k = i;
|
||||
|
||||
return o << "("
|
||||
<< euler.x << " "
|
||||
<< euler.y << " "
|
||||
<< euler.z << " "
|
||||
<< a[i] << a[j] << a[k] << r << ")";
|
||||
}
|
||||
|
||||
template <class T>
|
||||
float
|
||||
Euler<T>::angleMod (T angle)
|
||||
{
|
||||
angle = fmod(T (angle), T (2 * M_PI));
|
||||
|
||||
if (angle < -M_PI) angle += 2 * M_PI;
|
||||
if (angle > +M_PI) angle -= 2 * M_PI;
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
Euler<T>::simpleXYZRotation (Vec3<T> &xyzRot, const Vec3<T> &targetXyzRot)
|
||||
{
|
||||
Vec3<T> d = xyzRot - targetXyzRot;
|
||||
xyzRot[0] = targetXyzRot[0] + angleMod(d[0]);
|
||||
xyzRot[1] = targetXyzRot[1] + angleMod(d[1]);
|
||||
xyzRot[2] = targetXyzRot[2] + angleMod(d[2]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
Euler<T>::nearestRotation (Vec3<T> &xyzRot, const Vec3<T> &targetXyzRot,
|
||||
Order order)
|
||||
{
|
||||
int i,j,k;
|
||||
Euler<T> e (0,0,0, order);
|
||||
e.angleOrder(i,j,k);
|
||||
|
||||
simpleXYZRotation(xyzRot, targetXyzRot);
|
||||
|
||||
Vec3<T> otherXyzRot;
|
||||
otherXyzRot[i] = M_PI+xyzRot[i];
|
||||
otherXyzRot[j] = M_PI-xyzRot[j];
|
||||
otherXyzRot[k] = M_PI+xyzRot[k];
|
||||
|
||||
simpleXYZRotation(otherXyzRot, targetXyzRot);
|
||||
|
||||
Vec3<T> d = xyzRot - targetXyzRot;
|
||||
Vec3<T> od = otherXyzRot - targetXyzRot;
|
||||
T dMag = d.dot(d);
|
||||
T odMag = od.dot(od);
|
||||
|
||||
if (odMag < dMag)
|
||||
{
|
||||
xyzRot = otherXyzRot;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
Euler<T>::makeNear (const Euler<T> &target)
|
||||
{
|
||||
Vec3<T> xyzRot = toXYZVector();
|
||||
Euler<T> targetSameOrder = Euler<T>(target, order());
|
||||
Vec3<T> targetXyz = targetSameOrder.toXYZVector();
|
||||
|
||||
nearestRotation(xyzRot, targetXyz, order());
|
||||
|
||||
setXYZVector(xyzRot);
|
||||
}
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
#pragma warning(default:4244)
|
||||
#endif
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
|
||||
#endif
|
70
3rdparty/include/OpenEXR/ImathExc.h
vendored
70
3rdparty/include/OpenEXR/ImathExc.h
vendored
@ -1,70 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHEXC_H
|
||||
#define INCLUDED_IMATHEXC_H
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
//
|
||||
// Imath library-specific exceptions
|
||||
//
|
||||
//-----------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
DEFINE_EXC (NullVecExc, ::Iex::MathExc) // Attempt to normalize
|
||||
// null vector
|
||||
|
||||
DEFINE_EXC (NullQuatExc, ::Iex::MathExc) // Attempt to normalize
|
||||
// null quaternion
|
||||
|
||||
DEFINE_EXC (SingMatrixExc, ::Iex::MathExc) // Attempt to invert
|
||||
// singular matrix
|
||||
|
||||
DEFINE_EXC (ZeroScaleExc, ::Iex::MathExc) // Attempt to remove zero
|
||||
// scaling from matrix
|
||||
|
||||
DEFINE_EXC (IntVecNormalizeExc, ::Iex::MathExc) // Attempt to normalize
|
||||
// a vector of whose elements
|
||||
// are an integer type
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
190
3rdparty/include/OpenEXR/ImathFrame.h
vendored
190
3rdparty/include/OpenEXR/ImathFrame.h
vendored
@ -1,190 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHFRAME_H
|
||||
#define INCLUDED_IMATHFRAME_H
|
||||
|
||||
namespace Imath {
|
||||
|
||||
template<class T> class Vec3;
|
||||
template<class T> class Matrix44;
|
||||
|
||||
//
|
||||
// These methods compute a set of reference frames, defined by their
|
||||
// transformation matrix, along a curve. It is designed so that the
|
||||
// array of points and the array of matrices used to fetch these routines
|
||||
// don't need to be ordered as the curve.
|
||||
//
|
||||
// A typical usage would be :
|
||||
//
|
||||
// m[0] = Imath::firstFrame( p[0], p[1], p[2] );
|
||||
// for( int i = 1; i < n - 1; i++ )
|
||||
// {
|
||||
// m[i] = Imath::nextFrame( m[i-1], p[i-1], p[i], t[i-1], t[i] );
|
||||
// }
|
||||
// m[n-1] = Imath::lastFrame( m[n-2], p[n-2], p[n-1] );
|
||||
//
|
||||
// See Graphics Gems I for the underlying algorithm.
|
||||
//
|
||||
|
||||
template<class T> Matrix44<T> firstFrame( const Vec3<T>&, // First point
|
||||
const Vec3<T>&, // Second point
|
||||
const Vec3<T>& ); // Third point
|
||||
|
||||
template<class T> Matrix44<T> nextFrame( const Matrix44<T>&, // Previous matrix
|
||||
const Vec3<T>&, // Previous point
|
||||
const Vec3<T>&, // Current point
|
||||
Vec3<T>&, // Previous tangent
|
||||
Vec3<T>& ); // Current tangent
|
||||
|
||||
template<class T> Matrix44<T> lastFrame( const Matrix44<T>&, // Previous matrix
|
||||
const Vec3<T>&, // Previous point
|
||||
const Vec3<T>& ); // Last point
|
||||
|
||||
//
|
||||
// firstFrame - Compute the first reference frame along a curve.
|
||||
//
|
||||
// This function returns the transformation matrix to the reference frame
|
||||
// defined by the three points 'pi', 'pj' and 'pk'. Note that if the two
|
||||
// vectors <pi,pj> and <pi,pk> are colinears, an arbitrary twist value will
|
||||
// be choosen.
|
||||
//
|
||||
// Throw 'NullVecExc' if 'pi' and 'pj' are equals.
|
||||
//
|
||||
|
||||
template<class T> Matrix44<T> firstFrame
|
||||
(
|
||||
const Vec3<T>& pi, // First point
|
||||
const Vec3<T>& pj, // Second point
|
||||
const Vec3<T>& pk ) // Third point
|
||||
{
|
||||
Vec3<T> t = pj - pi; t.normalizeExc();
|
||||
|
||||
Vec3<T> n = t.cross( pk - pi ); n.normalize();
|
||||
if( n.length() == 0.0f )
|
||||
{
|
||||
int i = fabs( t[0] ) < fabs( t[1] ) ? 0 : 1;
|
||||
if( fabs( t[2] ) < fabs( t[i] )) i = 2;
|
||||
|
||||
Vec3<T> v( 0.0, 0.0, 0.0 ); v[i] = 1.0;
|
||||
n = t.cross( v ); n.normalize();
|
||||
}
|
||||
|
||||
Vec3<T> b = t.cross( n );
|
||||
|
||||
Matrix44<T> M;
|
||||
|
||||
M[0][0] = t[0]; M[0][1] = t[1]; M[0][2] = t[2]; M[0][3] = 0.0,
|
||||
M[1][0] = n[0]; M[1][1] = n[1]; M[1][2] = n[2]; M[1][3] = 0.0,
|
||||
M[2][0] = b[0]; M[2][1] = b[1]; M[2][2] = b[2]; M[2][3] = 0.0,
|
||||
M[3][0] = pi[0]; M[3][1] = pi[1]; M[3][2] = pi[2]; M[3][3] = 1.0;
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
//
|
||||
// nextFrame - Compute the next reference frame along a curve.
|
||||
//
|
||||
// This function returns the transformation matrix to the next reference
|
||||
// frame defined by the previously computed transformation matrix and the
|
||||
// new point and tangent vector along the curve.
|
||||
//
|
||||
|
||||
template<class T> Matrix44<T> nextFrame
|
||||
(
|
||||
const Matrix44<T>& Mi, // Previous matrix
|
||||
const Vec3<T>& pi, // Previous point
|
||||
const Vec3<T>& pj, // Current point
|
||||
Vec3<T>& ti, // Previous tangent vector
|
||||
Vec3<T>& tj ) // Current tangent vector
|
||||
{
|
||||
Vec3<T> a(0.0, 0.0, 0.0); // Rotation axis.
|
||||
T r = 0.0; // Rotation angle.
|
||||
|
||||
if( ti.length() != 0.0 && tj.length() != 0.0 )
|
||||
{
|
||||
ti.normalize(); tj.normalize();
|
||||
T dot = ti.dot( tj );
|
||||
|
||||
//
|
||||
// This is *really* necessary :
|
||||
//
|
||||
|
||||
if( dot > 1.0 ) dot = 1.0;
|
||||
else if( dot < -1.0 ) dot = -1.0;
|
||||
|
||||
r = acosf( dot );
|
||||
a = ti.cross( tj );
|
||||
}
|
||||
|
||||
if( a.length() != 0.0 && r != 0.0 )
|
||||
{
|
||||
Matrix44<T> R; R.setAxisAngle( a, r );
|
||||
Matrix44<T> Tj; Tj.translate( pj );
|
||||
Matrix44<T> Ti; Ti.translate( -pi );
|
||||
|
||||
return Mi * Ti * R * Tj;
|
||||
}
|
||||
else
|
||||
{
|
||||
Matrix44<T> Tr; Tr.translate( pj - pi );
|
||||
|
||||
return Mi * Tr;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// lastFrame - Compute the last reference frame along a curve.
|
||||
//
|
||||
// This function returns the transformation matrix to the last reference
|
||||
// frame defined by the previously computed transformation matrix and the
|
||||
// last point along the curve.
|
||||
//
|
||||
|
||||
template<class T> Matrix44<T> lastFrame
|
||||
(
|
||||
const Matrix44<T>& Mi, // Previous matrix
|
||||
const Vec3<T>& pi, // Previous point
|
||||
const Vec3<T>& pj ) // Last point
|
||||
{
|
||||
Matrix44<T> Tr; Tr.translate( pj - pi );
|
||||
|
||||
return Mi * Tr;
|
||||
}
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
697
3rdparty/include/OpenEXR/ImathFrustum.h
vendored
697
3rdparty/include/OpenEXR/ImathFrustum.h
vendored
@ -1,697 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHFRUSTUM_H
|
||||
#define INCLUDED_IMATHFRUSTUM_H
|
||||
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathPlane.h"
|
||||
#include "ImathLine.h"
|
||||
#include "ImathMatrix.h"
|
||||
#include "ImathLimits.h"
|
||||
#include "ImathFun.h"
|
||||
#include "IexMathExc.h"
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
#ifdef near
|
||||
#undef near
|
||||
#endif
|
||||
#ifdef far
|
||||
#undef far
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace Imath {
|
||||
|
||||
//
|
||||
// template class Frustum<T>
|
||||
//
|
||||
// The frustum is always located with the eye point at the
|
||||
// origin facing down -Z. This makes the Frustum class
|
||||
// compatable with OpenGL (or anything that assumes a camera
|
||||
// looks down -Z, hence with a right-handed coordinate system)
|
||||
// but not with RenderMan which assumes the camera looks down
|
||||
// +Z. Additional functions are provided for conversion from
|
||||
// and from various camera coordinate spaces.
|
||||
//
|
||||
|
||||
|
||||
template<class T>
|
||||
class Frustum
|
||||
{
|
||||
public:
|
||||
Frustum();
|
||||
Frustum(const Frustum &);
|
||||
Frustum(T near, T far, T left, T right, T top, T bottom, bool ortho=false);
|
||||
Frustum(T near, T far, T fovx, T fovy, T aspect);
|
||||
virtual ~Frustum();
|
||||
|
||||
//--------------------
|
||||
// Assignment operator
|
||||
//--------------------
|
||||
|
||||
const Frustum &operator = (const Frustum &);
|
||||
|
||||
//--------------------
|
||||
// Operators: ==, !=
|
||||
//--------------------
|
||||
|
||||
bool operator == (const Frustum<T> &src) const;
|
||||
bool operator != (const Frustum<T> &src) const;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Set functions change the entire state of the Frustum
|
||||
//--------------------------------------------------------
|
||||
|
||||
void set(T near, T far,
|
||||
T left, T right,
|
||||
T top, T bottom,
|
||||
bool ortho=false);
|
||||
|
||||
void set(T near, T far, T fovx, T fovy, T aspect);
|
||||
|
||||
//------------------------------------------------------
|
||||
// These functions modify an already valid frustum state
|
||||
//------------------------------------------------------
|
||||
|
||||
void modifyNearAndFar(T near, T far);
|
||||
void setOrthographic(bool);
|
||||
|
||||
//--------------
|
||||
// Access
|
||||
//--------------
|
||||
|
||||
bool orthographic() const { return _orthographic; }
|
||||
T near() const { return _near; }
|
||||
T far() const { return _far; }
|
||||
T left() const { return _left; }
|
||||
T right() const { return _right; }
|
||||
T bottom() const { return _bottom; }
|
||||
T top() const { return _top; }
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Sets the planes in p to be the six bounding planes of the frustum, in
|
||||
// the following order: top, right, bottom, left, near, far.
|
||||
// Note that the planes have normals that point out of the frustum.
|
||||
// The version of this routine that takes a matrix applies that matrix
|
||||
// to transform the frustum before setting the planes.
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void planes(Plane3<T> p[6]);
|
||||
void planes(Plane3<T> p[6], const Matrix44<T> &M);
|
||||
|
||||
//----------------------
|
||||
// Derived Quantities
|
||||
//----------------------
|
||||
|
||||
T fovx() const;
|
||||
T fovy() const;
|
||||
T aspect() const;
|
||||
Matrix44<T> projectionMatrix() const;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Takes a rectangle in the screen space (i.e., -1 <= left <= right <= 1
|
||||
// and -1 <= bottom <= top <= 1) of this Frustum, and returns a new
|
||||
// Frustum whose near clipping-plane window is that rectangle in local
|
||||
// space.
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
Frustum<T> window(T left, T right, T top, T bottom) const;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Projection is in screen space / Conversion from Z-Buffer
|
||||
//----------------------------------------------------------
|
||||
|
||||
Line3<T> projectScreenToRay( const Vec2<T> & ) const;
|
||||
Vec2<T> projectPointToScreen( const Vec3<T> & ) const;
|
||||
|
||||
T ZToDepth(long zval, long min, long max) const;
|
||||
T normalizedZToDepth(T zval) const;
|
||||
long DepthToZ(T depth, long zmin, long zmax) const;
|
||||
|
||||
T worldRadius(const Vec3<T> &p, T radius) const;
|
||||
T screenRadius(const Vec3<T> &p, T radius) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
Vec2<T> screenToLocal( const Vec2<T> & ) const;
|
||||
Vec2<T> localToScreen( const Vec2<T> & ) const;
|
||||
|
||||
protected:
|
||||
T _near;
|
||||
T _far;
|
||||
T _left;
|
||||
T _right;
|
||||
T _top;
|
||||
T _bottom;
|
||||
bool _orthographic;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Frustum<T>::Frustum()
|
||||
{
|
||||
set(T (0.1),
|
||||
T (1000.0),
|
||||
T (-1.0),
|
||||
T (1.0),
|
||||
T (1.0),
|
||||
T (-1.0),
|
||||
false);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Frustum<T>::Frustum(const Frustum &f)
|
||||
{
|
||||
*this = f;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Frustum<T>::Frustum(T n, T f, T l, T r, T t, T b, bool o)
|
||||
{
|
||||
set(n,f,l,r,t,b,o);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Frustum<T>::Frustum(T near, T far, T fovx, T fovy, T aspect)
|
||||
{
|
||||
set(near,far,fovx,fovy,aspect);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Frustum<T>::~Frustum()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const Frustum<T> &
|
||||
Frustum<T>::operator = (const Frustum &f)
|
||||
{
|
||||
_near = f._near;
|
||||
_far = f._far;
|
||||
_left = f._left;
|
||||
_right = f._right;
|
||||
_top = f._top;
|
||||
_bottom = f._bottom;
|
||||
_orthographic = f._orthographic;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
Frustum<T>::operator == (const Frustum<T> &src) const
|
||||
{
|
||||
return
|
||||
_near == src._near &&
|
||||
_far == src._far &&
|
||||
_left == src._left &&
|
||||
_right == src._right &&
|
||||
_top == src._top &&
|
||||
_bottom == src._bottom &&
|
||||
_orthographic == src._orthographic;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
Frustum<T>::operator != (const Frustum<T> &src) const
|
||||
{
|
||||
return !operator== (src);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Frustum<T>::set(T n, T f, T l, T r, T t, T b, bool o)
|
||||
{
|
||||
_near = n;
|
||||
_far = f;
|
||||
_left = l;
|
||||
_right = r;
|
||||
_bottom = b;
|
||||
_top = t;
|
||||
_orthographic = o;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Frustum<T>::modifyNearAndFar(T n, T f)
|
||||
{
|
||||
if ( _orthographic )
|
||||
{
|
||||
_near = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
Line3<T> lowerLeft( Vec3<T>(0,0,0), Vec3<T>(_left,_bottom,-_near) );
|
||||
Line3<T> upperRight( Vec3<T>(0,0,0), Vec3<T>(_right,_top,-_near) );
|
||||
Plane3<T> nearPlane( Vec3<T>(0,0,-1), n );
|
||||
|
||||
Vec3<T> ll,ur;
|
||||
nearPlane.intersect(lowerLeft,ll);
|
||||
nearPlane.intersect(upperRight,ur);
|
||||
|
||||
_left = ll.x;
|
||||
_right = ur.x;
|
||||
_top = ur.y;
|
||||
_bottom = ll.y;
|
||||
_near = n;
|
||||
_far = f;
|
||||
}
|
||||
|
||||
_far = f;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Frustum<T>::setOrthographic(bool ortho)
|
||||
{
|
||||
_orthographic = ortho;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Frustum<T>::set(T near, T far, T fovx, T fovy, T aspect)
|
||||
{
|
||||
if (fovx != 0 && fovy != 0)
|
||||
throw Iex::ArgExc ("fovx and fovy cannot both be non-zero.");
|
||||
|
||||
if (fovx != 0)
|
||||
{
|
||||
_right = near * Math<T>::tan(fovx/2.0);
|
||||
_left = -_right;
|
||||
_top = ((_right - _left)/aspect)/2.0;
|
||||
_bottom = -_top;
|
||||
}
|
||||
else
|
||||
{
|
||||
_top = near * Math<T>::tan(fovy/2.0);
|
||||
_bottom = -_top;
|
||||
_right = (_top - _bottom) * aspect / 2.0;
|
||||
_left = -_right;
|
||||
}
|
||||
_near = near;
|
||||
_far = far;
|
||||
_orthographic = false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T Frustum<T>::fovx() const
|
||||
{
|
||||
return Math<T>::atan2(_right,_near) - Math<T>::atan2(_left,_near);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T Frustum<T>::fovy() const
|
||||
{
|
||||
return Math<T>::atan2(_top,_near) - Math<T>::atan2(_bottom,_near);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T Frustum<T>::aspect() const
|
||||
{
|
||||
T rightMinusLeft = _right-_left;
|
||||
T topMinusBottom = _top-_bottom;
|
||||
|
||||
if (abs(topMinusBottom) < 1 &&
|
||||
abs(rightMinusLeft) > limits<T>::max() * abs(topMinusBottom))
|
||||
{
|
||||
throw Iex::DivzeroExc ("Bad viewing frustum: "
|
||||
"aspect ratio cannot be computed.");
|
||||
}
|
||||
|
||||
return rightMinusLeft / topMinusBottom;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Matrix44<T> Frustum<T>::projectionMatrix() const
|
||||
{
|
||||
T rightPlusLeft = _right+_left;
|
||||
T rightMinusLeft = _right-_left;
|
||||
|
||||
T topPlusBottom = _top+_bottom;
|
||||
T topMinusBottom = _top-_bottom;
|
||||
|
||||
T farPlusNear = _far+_near;
|
||||
T farMinusNear = _far-_near;
|
||||
|
||||
if ((abs(rightMinusLeft) < 1 &&
|
||||
abs(rightPlusLeft) > limits<T>::max() * abs(rightMinusLeft)) ||
|
||||
(abs(topMinusBottom) < 1 &&
|
||||
abs(topPlusBottom) > limits<T>::max() * abs(topMinusBottom)) ||
|
||||
(abs(farMinusNear) < 1 &&
|
||||
abs(farPlusNear) > limits<T>::max() * abs(farMinusNear)))
|
||||
{
|
||||
throw Iex::DivzeroExc ("Bad viewing frustum: "
|
||||
"projection matrix cannot be computed.");
|
||||
}
|
||||
|
||||
if ( _orthographic )
|
||||
{
|
||||
T tx = -rightPlusLeft / rightMinusLeft;
|
||||
T ty = -topPlusBottom / topMinusBottom;
|
||||
T tz = -farPlusNear / farMinusNear;
|
||||
|
||||
if ((abs(rightMinusLeft) < 1 &&
|
||||
2 > limits<T>::max() * abs(rightMinusLeft)) ||
|
||||
(abs(topMinusBottom) < 1 &&
|
||||
2 > limits<T>::max() * abs(topMinusBottom)) ||
|
||||
(abs(farMinusNear) < 1 &&
|
||||
2 > limits<T>::max() * abs(farMinusNear)))
|
||||
{
|
||||
throw Iex::DivzeroExc ("Bad viewing frustum: "
|
||||
"projection matrix cannot be computed.");
|
||||
}
|
||||
|
||||
T A = 2 / rightMinusLeft;
|
||||
T B = 2 / topMinusBottom;
|
||||
T C = -2 / farMinusNear;
|
||||
|
||||
return Matrix44<T>( A, 0, 0, 0,
|
||||
0, B, 0, 0,
|
||||
0, 0, C, 0,
|
||||
tx, ty, tz, 1.f );
|
||||
}
|
||||
else
|
||||
{
|
||||
T A = rightPlusLeft / rightMinusLeft;
|
||||
T B = topPlusBottom / topMinusBottom;
|
||||
T C = -farPlusNear / farMinusNear;
|
||||
|
||||
T farTimesNear = -2 * _far * _near;
|
||||
if (abs(farMinusNear) < 1 &&
|
||||
abs(farTimesNear) > limits<T>::max() * abs(farMinusNear))
|
||||
{
|
||||
throw Iex::DivzeroExc ("Bad viewing frustum: "
|
||||
"projection matrix cannot be computed.");
|
||||
}
|
||||
|
||||
T D = farTimesNear / farMinusNear;
|
||||
|
||||
T twoTimesNear = 2 * _near;
|
||||
|
||||
if ((abs(rightMinusLeft) < 1 &&
|
||||
abs(twoTimesNear) > limits<T>::max() * abs(rightMinusLeft)) ||
|
||||
(abs(topMinusBottom) < 1 &&
|
||||
abs(twoTimesNear) > limits<T>::max() * abs(topMinusBottom)))
|
||||
{
|
||||
throw Iex::DivzeroExc ("Bad viewing frustum: "
|
||||
"projection matrix cannot be computed.");
|
||||
}
|
||||
|
||||
T E = twoTimesNear / rightMinusLeft;
|
||||
T F = twoTimesNear / topMinusBottom;
|
||||
|
||||
return Matrix44<T>( E, 0, 0, 0,
|
||||
0, F, 0, 0,
|
||||
A, B, C, -1,
|
||||
0, 0, D, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Frustum<T> Frustum<T>::window(T l, T r, T t, T b) const
|
||||
{
|
||||
// move it to 0->1 space
|
||||
|
||||
Vec2<T> bl = screenToLocal( Vec2<T>(l,b) );
|
||||
Vec2<T> tr = screenToLocal( Vec2<T>(r,t) );
|
||||
|
||||
return Frustum<T>(_near, _far, bl.x, tr.x, tr.y, bl.y, _orthographic);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Vec2<T> Frustum<T>::screenToLocal(const Vec2<T> &s) const
|
||||
{
|
||||
return Vec2<T>( _left + (_right-_left) * (1.f+s.x) / 2.f,
|
||||
_bottom + (_top-_bottom) * (1.f+s.y) / 2.f );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Vec2<T> Frustum<T>::localToScreen(const Vec2<T> &p) const
|
||||
{
|
||||
T leftPlusRight = _left - 2 * p.x + _right;
|
||||
T leftMinusRight = _left-_right;
|
||||
T bottomPlusTop = _bottom - 2 * p.y + _top;
|
||||
T bottomMinusTop = _bottom-_top;
|
||||
|
||||
if ((abs(leftMinusRight) < 1 &&
|
||||
abs(leftPlusRight) > limits<T>::max() * abs(leftMinusRight)) ||
|
||||
(abs(bottomMinusTop) < 1 &&
|
||||
abs(bottomPlusTop) > limits<T>::max() * abs(bottomMinusTop)))
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Bad viewing frustum: "
|
||||
"local-to-screen transformation cannot be computed");
|
||||
}
|
||||
|
||||
return Vec2<T>( leftPlusRight / leftMinusRight,
|
||||
bottomPlusTop / bottomMinusTop );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Line3<T> Frustum<T>::projectScreenToRay(const Vec2<T> &p) const
|
||||
{
|
||||
Vec2<T> point = screenToLocal(p);
|
||||
if (orthographic())
|
||||
return Line3<T>( Vec3<T>(point.x,point.y, 0.0),
|
||||
Vec3<T>(point.x,point.y,-_near));
|
||||
else
|
||||
return Line3<T>( Vec3<T>(0, 0, 0), Vec3<T>(point.x,point.y,-_near));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Vec2<T> Frustum<T>::projectPointToScreen(const Vec3<T> &point) const
|
||||
{
|
||||
if (orthographic() || point.z == 0)
|
||||
return localToScreen( Vec2<T>( point.x, point.y ) );
|
||||
else
|
||||
return localToScreen( Vec2<T>( point.x * _near / -point.z,
|
||||
point.y * _near / -point.z ) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T Frustum<T>::ZToDepth(long zval,long zmin,long zmax) const
|
||||
{
|
||||
int zdiff = zmax - zmin;
|
||||
|
||||
if (zdiff == 0)
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Bad call to Frustum::ZToDepth: zmax == zmin");
|
||||
}
|
||||
|
||||
if ( zval > zmax+1 ) zval -= zdiff;
|
||||
|
||||
T fzval = (T(zval) - T(zmin)) / T(zdiff);
|
||||
return normalizedZToDepth(fzval);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T Frustum<T>::normalizedZToDepth(T zval) const
|
||||
{
|
||||
T Zp = zval * 2.0 - 1;
|
||||
|
||||
if ( _orthographic )
|
||||
{
|
||||
return -(Zp*(_far-_near) + (_far+_near))/2;
|
||||
}
|
||||
else
|
||||
{
|
||||
T farTimesNear = 2 * _far * _near;
|
||||
T farMinusNear = Zp * (_far - _near) - _far - _near;
|
||||
|
||||
if (abs(farMinusNear) < 1 &&
|
||||
abs(farTimesNear) > limits<T>::max() * abs(farMinusNear))
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Frustum::normalizedZToDepth cannot be computed. The "
|
||||
"near and far clipping planes of the viewing frustum "
|
||||
"may be too close to each other");
|
||||
}
|
||||
|
||||
return farTimesNear / farMinusNear;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
long Frustum<T>::DepthToZ(T depth,long zmin,long zmax) const
|
||||
{
|
||||
long zdiff = zmax - zmin;
|
||||
T farMinusNear = _far-_near;
|
||||
|
||||
if ( _orthographic )
|
||||
{
|
||||
T farPlusNear = 2*depth + _far + _near;
|
||||
|
||||
if (abs(farMinusNear) < 1 &&
|
||||
abs(farPlusNear) > limits<T>::max() * abs(farMinusNear))
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Bad viewing frustum: near and far clipping planes "
|
||||
"are too close to each other");
|
||||
}
|
||||
|
||||
T Zp = -farPlusNear/farMinusNear;
|
||||
return long(0.5*(Zp+1)*zdiff) + zmin;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Perspective
|
||||
|
||||
T farTimesNear = 2*_far*_near;
|
||||
if (abs(depth) < 1 &&
|
||||
abs(farTimesNear) > limits<T>::max() * abs(depth))
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Bad call to DepthToZ function: value of `depth' "
|
||||
"is too small");
|
||||
}
|
||||
|
||||
T farPlusNear = farTimesNear/depth + _far + _near;
|
||||
if (abs(farMinusNear) < 1 &&
|
||||
abs(farPlusNear) > limits<T>::max() * abs(farMinusNear))
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Bad viewing frustum: near and far clipping planes "
|
||||
"are too close to each other");
|
||||
}
|
||||
|
||||
T Zp = farPlusNear/farMinusNear;
|
||||
return long(0.5*(Zp+1)*zdiff) + zmin;
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T Frustum<T>::screenRadius(const Vec3<T> &p, T radius) const
|
||||
{
|
||||
// Derivation:
|
||||
// Consider X-Z plane.
|
||||
// X coord of projection of p = xp = p.x * (-_near / p.z)
|
||||
// Let q be p + (radius, 0, 0).
|
||||
// X coord of projection of q = xq = (p.x - radius) * (-_near / p.z)
|
||||
// X coord of projection of segment from p to q = r = xp - xq
|
||||
// = radius * (-_near / p.z)
|
||||
// A similar analysis holds in the Y-Z plane.
|
||||
// So r is the quantity we want to return.
|
||||
|
||||
if (abs(p.z) > 1 || abs(-_near) < limits<T>::max() * abs(p.z))
|
||||
{
|
||||
return radius * (-_near / p.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Bad call to Frustum::screenRadius: the magnitude of `p' "
|
||||
"is too small");
|
||||
}
|
||||
|
||||
return radius * (-_near / p.z);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T Frustum<T>::worldRadius(const Vec3<T> &p, T radius) const
|
||||
{
|
||||
if (abs(-_near) > 1 || abs(p.z) < limits<T>::max() * abs(-_near))
|
||||
{
|
||||
return radius * (p.z / -_near);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Iex::DivzeroExc
|
||||
("Bad viewing frustum: the near clipping plane is too "
|
||||
"close to zero");
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Frustum<T>::planes(Plane3<T> p[6])
|
||||
{
|
||||
//
|
||||
// Plane order: Top, Right, Bottom, Left, Near, Far.
|
||||
// Normals point outwards.
|
||||
//
|
||||
|
||||
Vec3<T> a( _left, _bottom, -_near);
|
||||
Vec3<T> b( _left, _top, -_near);
|
||||
Vec3<T> c( _right, _top, -_near);
|
||||
Vec3<T> d( _right, _bottom, -_near);
|
||||
Vec3<T> o(0,0,0);
|
||||
|
||||
p[0].set( o, c, b );
|
||||
p[1].set( o, d, c );
|
||||
p[2].set( o, a, d );
|
||||
p[3].set( o, b, a );
|
||||
p[4].set( Vec3<T>(0, 0, 1), -_near );
|
||||
p[5].set( Vec3<T>(0, 0,-1), _far );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Frustum<T>::planes(Plane3<T> p[6], const Matrix44<T> &M)
|
||||
{
|
||||
//
|
||||
// Plane order: Top, Right, Bottom, Left, Near, Far.
|
||||
// Normals point outwards.
|
||||
//
|
||||
|
||||
Vec3<T> a = Vec3<T>( _left, _bottom, -_near) * M;
|
||||
Vec3<T> b = Vec3<T>( _left, _top, -_near) * M;
|
||||
Vec3<T> c = Vec3<T>( _right, _top, -_near) * M;
|
||||
Vec3<T> d = Vec3<T>( _right, _bottom, -_near) * M;
|
||||
double s = _far / double(_near);
|
||||
T farLeft = (T) (s * _left);
|
||||
T farRight = (T) (s * _right);
|
||||
T farTop = (T) (s * _top);
|
||||
T farBottom = (T) (s * _bottom);
|
||||
Vec3<T> e = Vec3<T>( farLeft, farBottom, -_far) * M;
|
||||
Vec3<T> f = Vec3<T>( farLeft, farTop, -_far) * M;
|
||||
Vec3<T> g = Vec3<T>( farRight, farTop, -_far) * M;
|
||||
Vec3<T> o = Vec3<T>(0,0,0) * M;
|
||||
|
||||
p[0].set( o, c, b );
|
||||
p[1].set( o, d, c );
|
||||
p[2].set( o, a, d );
|
||||
p[3].set( o, b, a );
|
||||
p[4].set( a, d, c );
|
||||
p[5].set( e, f, g );
|
||||
}
|
||||
|
||||
typedef Frustum<float> Frustumf;
|
||||
typedef Frustum<double> Frustumd;
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
272
3rdparty/include/OpenEXR/ImathFun.h
vendored
272
3rdparty/include/OpenEXR/ImathFun.h
vendored
@ -1,272 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHFUN_H
|
||||
#define INCLUDED_IMATHFUN_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Miscellaneous utility functions
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImathLimits.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
template <class T>
|
||||
inline T
|
||||
abs (T a)
|
||||
{
|
||||
return (a > 0) ? a : -a;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline int
|
||||
sign (T a)
|
||||
{
|
||||
return (a > 0)? 1 : ((a < 0) ? -1 : 0);
|
||||
}
|
||||
|
||||
|
||||
template <class T, class Q>
|
||||
inline T
|
||||
lerp (T a, T b, Q t)
|
||||
{
|
||||
return (T) (a + (b - a) * t);
|
||||
}
|
||||
|
||||
|
||||
template <class T, class Q>
|
||||
inline T
|
||||
ulerp (T a, T b, Q t)
|
||||
{
|
||||
return (T) ((a > b)? (a - (a - b) * t): (a + (b - a) * t));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T
|
||||
lerpfactor(T m, T a, T b)
|
||||
{
|
||||
//
|
||||
// Return how far m is between a and b, that is return t such that
|
||||
// if:
|
||||
// t = lerpfactor(m, a, b);
|
||||
// then:
|
||||
// m = lerp(a, b, t);
|
||||
//
|
||||
// If a==b, return 0.
|
||||
//
|
||||
|
||||
T d = b - a;
|
||||
T n = m - a;
|
||||
|
||||
if (abs(d) > T(1) || abs(n) < limits<T>::max() * abs(d))
|
||||
return n / d;
|
||||
|
||||
return T(0);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T
|
||||
clamp (T a, T l, T h)
|
||||
{
|
||||
return (a < l)? l : ((a > h)? h : a);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline int
|
||||
cmp (T a, T b)
|
||||
{
|
||||
return Imath::sign (a - b);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline int
|
||||
cmpt (T a, T b, T t)
|
||||
{
|
||||
return (Imath::abs (a - b) <= t)? 0 : cmp (a, b);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
iszero (T a, T t)
|
||||
{
|
||||
return (Imath::abs (a) <= t) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
inline bool
|
||||
equal (T1 a, T2 b, T3 t)
|
||||
{
|
||||
return Imath::abs (a - b) <= t;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int
|
||||
floor (T x)
|
||||
{
|
||||
return (x >= 0)? int (x): -(int (-x) + (-x > int (-x)));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline int
|
||||
ceil (T x)
|
||||
{
|
||||
return -floor (-x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline int
|
||||
trunc (T x)
|
||||
{
|
||||
return (x >= 0) ? int(x) : -int(-x);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Integer division and remainder where the
|
||||
// remainder of x/y has the same sign as x:
|
||||
//
|
||||
// divs(x,y) == (abs(x) / abs(y)) * (sign(x) * sign(y))
|
||||
// mods(x,y) == x - y * divs(x,y)
|
||||
//
|
||||
|
||||
inline int
|
||||
divs (int x, int y)
|
||||
{
|
||||
return (x >= 0)? ((y >= 0)? ( x / y): -( x / -y)):
|
||||
((y >= 0)? -(-x / y): (-x / -y));
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
mods (int x, int y)
|
||||
{
|
||||
return (x >= 0)? ((y >= 0)? ( x % y): ( x % -y)):
|
||||
((y >= 0)? -(-x % y): -(-x % -y));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Integer division and remainder where the
|
||||
// remainder of x/y is always positive:
|
||||
//
|
||||
// divp(x,y) == floor (double(x) / double (y))
|
||||
// modp(x,y) == x - y * divp(x,y)
|
||||
//
|
||||
|
||||
inline int
|
||||
divp (int x, int y)
|
||||
{
|
||||
return (x >= 0)? ((y >= 0)? ( x / y): -( x / -y)):
|
||||
((y >= 0)? -((y-1-x) / y): ((-y-1-x) / -y));
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
modp (int x, int y)
|
||||
{
|
||||
return x - y * divp (x, y);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Successor and predecessor for floating-point numbers:
|
||||
//
|
||||
// succf(f) returns float(f+e), where e is the smallest
|
||||
// positive number such that float(f+e) != f.
|
||||
//
|
||||
// predf(f) returns float(f-e), where e is the smallest
|
||||
// positive number such that float(f-e) != f.
|
||||
//
|
||||
// succd(d) returns double(d+e), where e is the smallest
|
||||
// positive number such that double(d+e) != d.
|
||||
//
|
||||
// predd(d) returns double(d-e), where e is the smallest
|
||||
// positive number such that double(d-e) != d.
|
||||
//
|
||||
// Exceptions: If the input value is an infinity or a nan,
|
||||
// succf(), predf(), succd(), and predd() all
|
||||
// return the input value without changing it.
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
float succf (float f);
|
||||
float predf (float f);
|
||||
|
||||
double succd (double d);
|
||||
double predd (double d);
|
||||
|
||||
//
|
||||
// Return true if the number is not a NaN or Infinity.
|
||||
//
|
||||
|
||||
inline bool
|
||||
finitef (float f)
|
||||
{
|
||||
union {float f; int i;} u;
|
||||
u.f = f;
|
||||
|
||||
return (u.i & 0x7f800000) != 0x7f800000;
|
||||
}
|
||||
|
||||
inline bool
|
||||
finited (double d)
|
||||
{
|
||||
#if ULONG_MAX == 18446744073709551615LU
|
||||
typedef long unsigned int Int64;
|
||||
#else
|
||||
typedef long long unsigned int Int64;
|
||||
#endif
|
||||
|
||||
union {double d; Int64 i;} u;
|
||||
u.d = d;
|
||||
|
||||
return (u.i & 0x7ff0000000000000LL) != 0x7ff0000000000000LL;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
159
3rdparty/include/OpenEXR/ImathGL.h
vendored
159
3rdparty/include/OpenEXR/ImathGL.h
vendored
@ -1,159 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHGL_H
|
||||
#define INCLUDED_IMATHGL_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathMatrix.h"
|
||||
#include "IexMathExc.h"
|
||||
#include "ImathFun.h"
|
||||
|
||||
inline void glVertex ( const Imath::V3f &v ) { glVertex3f(v.x,v.y,v.z); }
|
||||
inline void glVertex ( const Imath::V2f &v ) { glVertex2f(v.x,v.y); }
|
||||
inline void glNormal ( const Imath::V3f &n ) { glNormal3f(n.x,n.y,n.z); }
|
||||
inline void glColor ( const Imath::V3f &c ) { glColor3f(c.x,c.y,c.z); }
|
||||
inline void glTranslate ( const Imath::V3f &t ) { glTranslatef(t.x,t.y,t.z); }
|
||||
|
||||
inline void glTexCoord( const Imath::V2f &t )
|
||||
{
|
||||
glTexCoord2f(t.x,t.y);
|
||||
}
|
||||
|
||||
inline void glDisableTexture()
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
const float GL_FLOAT_MAX = 1.8e+19; // sqrt (FLT_MAX)
|
||||
|
||||
inline bool
|
||||
badFloat (float f)
|
||||
{
|
||||
return !Imath::finitef (f) || f < - GL_FLOAT_MAX || f > GL_FLOAT_MAX;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
inline void
|
||||
throwBadMatrix (const Imath::M44f& m)
|
||||
{
|
||||
if (badFloat (m[0][0]) ||
|
||||
badFloat (m[0][1]) ||
|
||||
badFloat (m[0][2]) ||
|
||||
badFloat (m[0][3]) ||
|
||||
badFloat (m[1][0]) ||
|
||||
badFloat (m[1][1]) ||
|
||||
badFloat (m[1][2]) ||
|
||||
badFloat (m[1][3]) ||
|
||||
badFloat (m[2][0]) ||
|
||||
badFloat (m[2][1]) ||
|
||||
badFloat (m[2][2]) ||
|
||||
badFloat (m[2][3]) ||
|
||||
badFloat (m[3][0]) ||
|
||||
badFloat (m[3][1]) ||
|
||||
badFloat (m[3][2]) ||
|
||||
badFloat (m[3][3]))
|
||||
throw Iex::OverflowExc ("GL matrix overflow");
|
||||
}
|
||||
|
||||
inline void
|
||||
glMultMatrix( const Imath::M44f& m )
|
||||
{
|
||||
throwBadMatrix (m);
|
||||
glMultMatrixf( (GLfloat*)m[0] );
|
||||
}
|
||||
|
||||
inline void
|
||||
glMultMatrix( const Imath::M44f* m )
|
||||
{
|
||||
throwBadMatrix (*m);
|
||||
glMultMatrixf( (GLfloat*)(*m)[0] );
|
||||
}
|
||||
|
||||
inline void
|
||||
glLoadMatrix( const Imath::M44f& m )
|
||||
{
|
||||
throwBadMatrix (m);
|
||||
glLoadMatrixf( (GLfloat*)m[0] );
|
||||
}
|
||||
|
||||
inline void
|
||||
glLoadMatrix( const Imath::M44f* m )
|
||||
{
|
||||
throwBadMatrix (*m);
|
||||
glLoadMatrixf( (GLfloat*)(*m)[0] );
|
||||
}
|
||||
|
||||
|
||||
namespace Imath {
|
||||
|
||||
//
|
||||
// Class objects that push/pop the GL state. These objects assist with
|
||||
// proper cleanup of the state when exceptions are thrown.
|
||||
//
|
||||
|
||||
class GLPushMatrix {
|
||||
public:
|
||||
|
||||
GLPushMatrix () { glPushMatrix(); }
|
||||
~GLPushMatrix() { glPopMatrix(); }
|
||||
};
|
||||
|
||||
class GLPushAttrib {
|
||||
public:
|
||||
|
||||
GLPushAttrib (GLbitfield mask) { glPushAttrib (mask); }
|
||||
~GLPushAttrib() { glPopAttrib(); }
|
||||
};
|
||||
|
||||
class GLBegin {
|
||||
public:
|
||||
|
||||
GLBegin (GLenum mode) { glBegin (mode); }
|
||||
~GLBegin() { glEnd(); }
|
||||
};
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
54
3rdparty/include/OpenEXR/ImathGLU.h
vendored
54
3rdparty/include/OpenEXR/ImathGLU.h
vendored
@ -1,54 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHGLU_H
|
||||
#define INCLUDED_IMATHGLU_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#include "ImathVec.h"
|
||||
|
||||
inline
|
||||
void
|
||||
gluLookAt(const Imath::V3f &pos, const Imath::V3f &interest, const Imath::V3f &up)
|
||||
{
|
||||
gluLookAt(pos.x, pos.y, pos.z,
|
||||
interest.x, interest.y, interest.z,
|
||||
up.x, up.y, up.z);
|
||||
}
|
||||
|
||||
#endif
|
66
3rdparty/include/OpenEXR/ImathHalfLimits.h
vendored
66
3rdparty/include/OpenEXR/ImathHalfLimits.h
vendored
@ -1,66 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHHALFLIMITS_H
|
||||
#define INCLUDED_IMATHHALFLIMITS_H
|
||||
|
||||
//--------------------------------------------------
|
||||
//
|
||||
// Imath-style limits for class half.
|
||||
//
|
||||
//--------------------------------------------------
|
||||
|
||||
#include "ImathLimits.h"
|
||||
#include "half.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <>
|
||||
struct limits <half>
|
||||
{
|
||||
static float min() {return -HALF_MAX;}
|
||||
static float max() {return HALF_MAX;}
|
||||
static float smallest() {return HALF_MIN;}
|
||||
static float epsilon() {return HALF_EPSILON;}
|
||||
static bool isIntegral() {return false;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
224
3rdparty/include/OpenEXR/ImathInterval.h
vendored
224
3rdparty/include/OpenEXR/ImathInterval.h
vendored
@ -1,224 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHINTERVAL_H
|
||||
#define INCLUDED_IMATHINTERVAL_H
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//
|
||||
// class Imath::Interval<class T>
|
||||
// --------------------------------
|
||||
//
|
||||
// An Interval has a min and a max and some miscellaneous
|
||||
// functions. It is basically a Box<T> that allows T to be
|
||||
// a scalar.
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Interval
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------
|
||||
// Data Members are public
|
||||
//-------------------------
|
||||
|
||||
T min;
|
||||
T max;
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Constructors - an "empty" Interval is created by default
|
||||
//-----------------------------------------------------
|
||||
|
||||
Interval();
|
||||
Interval(const T& point);
|
||||
Interval(const T& minT, const T& maxT);
|
||||
|
||||
//--------------------------------
|
||||
// Operators: we get != from STL
|
||||
//--------------------------------
|
||||
|
||||
bool operator == (const Interval<T> &src) const;
|
||||
|
||||
//------------------
|
||||
// Interval manipulation
|
||||
//------------------
|
||||
|
||||
void makeEmpty();
|
||||
void extendBy(const T& point);
|
||||
void extendBy(const Interval<T>& interval);
|
||||
|
||||
//---------------------------------------------------
|
||||
// Query functions - these compute results each time
|
||||
//---------------------------------------------------
|
||||
|
||||
T size() const;
|
||||
T center() const;
|
||||
bool intersects(const T &point) const;
|
||||
bool intersects(const Interval<T> &interval) const;
|
||||
|
||||
//----------------
|
||||
// Classification
|
||||
//----------------
|
||||
|
||||
bool hasVolume() const;
|
||||
bool isEmpty() const;
|
||||
};
|
||||
|
||||
|
||||
//--------------------
|
||||
// Convenient typedefs
|
||||
//--------------------
|
||||
|
||||
|
||||
typedef Interval <float> Intervalf;
|
||||
typedef Interval <double> Intervald;
|
||||
typedef Interval <short> Intervals;
|
||||
typedef Interval <int> Intervali;
|
||||
|
||||
//----------------
|
||||
// Implementation
|
||||
//----------------
|
||||
|
||||
|
||||
template <class T>
|
||||
inline Interval<T>::Interval()
|
||||
{
|
||||
makeEmpty();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Interval<T>::Interval(const T& point)
|
||||
{
|
||||
min = point;
|
||||
max = point;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Interval<T>::Interval(const T& minV, const T& maxV)
|
||||
{
|
||||
min = minV;
|
||||
max = maxV;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
Interval<T>::operator == (const Interval<T> &src) const
|
||||
{
|
||||
return (min == src.min && max == src.max);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Interval<T>::makeEmpty()
|
||||
{
|
||||
min = limits<T>::max();
|
||||
max = limits<T>::min();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Interval<T>::extendBy(const T& point)
|
||||
{
|
||||
if ( point < min )
|
||||
min = point;
|
||||
|
||||
if ( point > max )
|
||||
max = point;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Interval<T>::extendBy(const Interval<T>& interval)
|
||||
{
|
||||
if ( interval.min < min )
|
||||
min = interval.min;
|
||||
|
||||
if ( interval.max > max )
|
||||
max = interval.max;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
Interval<T>::intersects(const T& point) const
|
||||
{
|
||||
return point >= min && point <= max;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
Interval<T>::intersects(const Interval<T>& interval) const
|
||||
{
|
||||
return interval.max >= min && interval.min <= max;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T
|
||||
Interval<T>::size() const
|
||||
{
|
||||
return max-min;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T
|
||||
Interval<T>::center() const
|
||||
{
|
||||
return (max+min)/2;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
Interval<T>::isEmpty() const
|
||||
{
|
||||
return max < min;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool Interval<T>::hasVolume() const
|
||||
{
|
||||
return max > min;
|
||||
}
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
265
3rdparty/include/OpenEXR/ImathLimits.h
vendored
265
3rdparty/include/OpenEXR/ImathLimits.h
vendored
@ -1,265 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHLIMITS_H
|
||||
#define INCLUDED_IMATHLIMITS_H
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//
|
||||
// Limitations of the basic C++ numerical data types
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
|
||||
//------------------------------------------
|
||||
// In Windows, min and max are macros. Yay.
|
||||
//------------------------------------------
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//
|
||||
// Template class limits<T> returns information about the limits
|
||||
// of numerical data type T:
|
||||
//
|
||||
// min() largest possible negative value of type T
|
||||
//
|
||||
// max() largest possible positive value of type T
|
||||
//
|
||||
// smallest() smallest possible positive value of type T
|
||||
//
|
||||
// epsilon() smallest possible e of type T, for which
|
||||
// 1 + e != 1
|
||||
//
|
||||
// isIntegral() returns true if T is an integral type
|
||||
//
|
||||
// isSigned() returns true if T is signed
|
||||
//
|
||||
// Class limits<T> is useful to implement template classes or
|
||||
// functions which depend on the limits of a numerical type
|
||||
// which is not known in advance; for example:
|
||||
//
|
||||
// template <class T> max (T x[], int n)
|
||||
// {
|
||||
// T m = limits<T>::min();
|
||||
//
|
||||
// for (int i = 0; i < n; i++)
|
||||
// if (m < x[i])
|
||||
// m = x[i];
|
||||
//
|
||||
// return m;
|
||||
// }
|
||||
//
|
||||
// Class limits<T> has been implemented for the following types:
|
||||
//
|
||||
// char, signed char, unsigned char
|
||||
// short, unsigned short
|
||||
// int, unsigned int
|
||||
// long, unsigned long
|
||||
// float
|
||||
// double
|
||||
// long double
|
||||
//
|
||||
// Class limits<T> has only static member functions, all of which
|
||||
// are implemented as inlines. No objects of type limits<T> are
|
||||
// ever created.
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
|
||||
template <class T> struct limits
|
||||
{
|
||||
static T min();
|
||||
static T max();
|
||||
static T smallest();
|
||||
static T epsilon();
|
||||
static bool isIntegral();
|
||||
static bool isSigned();
|
||||
};
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <>
|
||||
struct limits <char>
|
||||
{
|
||||
static char min() {return CHAR_MIN;}
|
||||
static char max() {return CHAR_MAX;}
|
||||
static char smallest() {return 1;}
|
||||
static char epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return (char) ~0 < 0;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <signed char>
|
||||
{
|
||||
static signed char min() {return SCHAR_MIN;}
|
||||
static signed char max() {return SCHAR_MAX;}
|
||||
static signed char smallest() {return 1;}
|
||||
static signed char epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <unsigned char>
|
||||
{
|
||||
static unsigned char min() {return 0;}
|
||||
static unsigned char max() {return UCHAR_MAX;}
|
||||
static unsigned char smallest() {return 1;}
|
||||
static unsigned char epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return false;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <short>
|
||||
{
|
||||
static short min() {return SHRT_MIN;}
|
||||
static short max() {return SHRT_MAX;}
|
||||
static short smallest() {return 1;}
|
||||
static short epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <unsigned short>
|
||||
{
|
||||
static unsigned short min() {return 0;}
|
||||
static unsigned short max() {return USHRT_MAX;}
|
||||
static unsigned short smallest() {return 1;}
|
||||
static unsigned short epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return false;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <int>
|
||||
{
|
||||
static int min() {return INT_MIN;}
|
||||
static int max() {return INT_MAX;}
|
||||
static int smallest() {return 1;}
|
||||
static int epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <unsigned int>
|
||||
{
|
||||
static unsigned int min() {return 0;}
|
||||
static unsigned int max() {return UINT_MAX;}
|
||||
static unsigned int smallest() {return 1;}
|
||||
static unsigned int epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return false;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <long>
|
||||
{
|
||||
static long min() {return LONG_MIN;}
|
||||
static long max() {return LONG_MAX;}
|
||||
static long smallest() {return 1;}
|
||||
static long epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <unsigned long>
|
||||
{
|
||||
static unsigned long min() {return 0;}
|
||||
static unsigned long max() {return ULONG_MAX;}
|
||||
static unsigned long smallest() {return 1;}
|
||||
static unsigned long epsilon() {return 1;}
|
||||
static bool isIntegral() {return true;}
|
||||
static bool isSigned() {return false;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <float>
|
||||
{
|
||||
static float min() {return -FLT_MAX;}
|
||||
static float max() {return FLT_MAX;}
|
||||
static float smallest() {return FLT_MIN;}
|
||||
static float epsilon() {return FLT_EPSILON;}
|
||||
static bool isIntegral() {return false;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <double>
|
||||
{
|
||||
static double min() {return -DBL_MAX;}
|
||||
static double max() {return DBL_MAX;}
|
||||
static double smallest() {return DBL_MIN;}
|
||||
static double epsilon() {return DBL_EPSILON;}
|
||||
static bool isIntegral() {return false;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct limits <long double>
|
||||
{
|
||||
static long double min() {return -LDBL_MAX;}
|
||||
static long double max() {return LDBL_MAX;}
|
||||
static long double smallest() {return LDBL_MIN;}
|
||||
static long double epsilon() {return LDBL_EPSILON;}
|
||||
static bool isIntegral() {return false;}
|
||||
static bool isSigned() {return true;}
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
184
3rdparty/include/OpenEXR/ImathLine.h
vendored
184
3rdparty/include/OpenEXR/ImathLine.h
vendored
@ -1,184 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHLINE_H
|
||||
#define INCLUDED_IMATHLINE_H
|
||||
|
||||
//-------------------------------------
|
||||
//
|
||||
// A 3D line class template
|
||||
//
|
||||
//-------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathLimits.h"
|
||||
#include "ImathMatrix.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Line3
|
||||
{
|
||||
public:
|
||||
|
||||
Vec3<T> pos;
|
||||
Vec3<T> dir;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Constructors - default is normalized units along direction
|
||||
//-------------------------------------------------------------
|
||||
|
||||
Line3() {}
|
||||
Line3(const Vec3<T>& point1, const Vec3<T>& point2);
|
||||
|
||||
//------------------
|
||||
// State Query/Set
|
||||
//------------------
|
||||
|
||||
void set(const Vec3<T>& point1,
|
||||
const Vec3<T>& point2);
|
||||
|
||||
//-------
|
||||
// F(t)
|
||||
//-------
|
||||
|
||||
Vec3<T> operator() (T parameter) const;
|
||||
|
||||
//---------
|
||||
// Query
|
||||
//---------
|
||||
|
||||
T distanceTo(const Vec3<T>& point) const;
|
||||
T distanceTo(const Line3<T>& line) const;
|
||||
Vec3<T> closestPointTo(const Vec3<T>& point) const;
|
||||
Vec3<T> closestPointTo(const Line3<T>& line) const;
|
||||
};
|
||||
|
||||
|
||||
//--------------------
|
||||
// Convenient typedefs
|
||||
//--------------------
|
||||
|
||||
typedef Line3<float> Line3f;
|
||||
typedef Line3<double> Line3d;
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
inline Line3<T>::Line3(const Vec3<T> &p0, const Vec3<T> &p1)
|
||||
{
|
||||
set(p0,p1);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Line3<T>::set(const Vec3<T> &p0, const Vec3<T> &p1)
|
||||
{
|
||||
pos = p0; dir = p1-p0;
|
||||
dir.normalize();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Vec3<T> Line3<T>::operator()(T parameter) const
|
||||
{
|
||||
return pos + dir * parameter;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Line3<T>::distanceTo(const Vec3<T>& point) const
|
||||
{
|
||||
return (closestPointTo(point)-point).length();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Vec3<T> Line3<T>::closestPointTo(const Vec3<T>& point) const
|
||||
{
|
||||
return ((point - pos) ^ dir) * dir + pos;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Line3<T>::distanceTo(const Line3<T>& line) const
|
||||
{
|
||||
T d = (dir % line.dir) ^ (line.pos - pos);
|
||||
return (d >= 0)? d: -d;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Vec3<T>
|
||||
Line3<T>::closestPointTo(const Line3<T>& line) const
|
||||
{
|
||||
// Assumes the lines are normalized
|
||||
|
||||
Vec3<T> posLpos = pos - line.pos ;
|
||||
T c = dir ^ posLpos;
|
||||
T a = line.dir ^ dir;
|
||||
T f = line.dir ^ posLpos ;
|
||||
T num = c - a * f;
|
||||
|
||||
T denom = a*a - 1;
|
||||
|
||||
T absDenom = ((denom >= 0)? denom: -denom);
|
||||
|
||||
if (absDenom < 1)
|
||||
{
|
||||
T absNum = ((num >= 0)? num: -num);
|
||||
|
||||
if (absNum >= absDenom * limits<T>::max())
|
||||
return pos;
|
||||
}
|
||||
|
||||
return pos + dir * (num / denom);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::ostream& operator<< (std::ostream &o, const Line3<T> &line)
|
||||
{
|
||||
return o << "(" << line.pos << ", " << line.dir << ")";
|
||||
}
|
||||
|
||||
template<class S, class T>
|
||||
inline Line3<S> operator * (const Line3<S> &line, const Matrix44<T> &M)
|
||||
{
|
||||
return Line3<S>( line.pos * M, (line.pos + line.dir) * M );
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
333
3rdparty/include/OpenEXR/ImathLineAlgo.h
vendored
333
3rdparty/include/OpenEXR/ImathLineAlgo.h
vendored
@ -1,333 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHLINEALGO_H
|
||||
#define INCLUDED_IMATHLINEALGO_H
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// This file contains algorithms applied to or in conjunction
|
||||
// with lines (Imath::Line). These algorithms may require
|
||||
// more headers to compile. The assumption made is that these
|
||||
// functions are called much less often than the basic line
|
||||
// functions or these functions require more support classes
|
||||
//
|
||||
// Contains:
|
||||
//
|
||||
// bool closestPoints(const Line<T>& line1,
|
||||
// const Line<T>& line2,
|
||||
// Vec3<T>& point1,
|
||||
// Vec3<T>& point2)
|
||||
//
|
||||
// bool intersect( const Line3<T> &line,
|
||||
// const Vec3<T> &v0,
|
||||
// const Vec3<T> &v1,
|
||||
// const Vec3<T> &v2,
|
||||
// Vec3<T> &pt,
|
||||
// Vec3<T> &barycentric,
|
||||
// bool &front)
|
||||
//
|
||||
// V3f
|
||||
// closestVertex(const Vec3<T> &v0,
|
||||
// const Vec3<T> &v1,
|
||||
// const Vec3<T> &v2,
|
||||
// const Line3<T> &l)
|
||||
//
|
||||
// V3f
|
||||
// nearestPointOnTriangle(const Vec3<T> &v0,
|
||||
// const Vec3<T> &v1,
|
||||
// const Vec3<T> &v2,
|
||||
// const Line3<T> &l)
|
||||
//
|
||||
// V3f
|
||||
// rotatePoint(const Vec3<T> p, Line3<T> l, float angle)
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
#include "ImathLine.h"
|
||||
#include "ImathVecAlgo.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
bool closestPoints(const Line3<T>& line1,
|
||||
const Line3<T>& line2,
|
||||
Vec3<T>& point1,
|
||||
Vec3<T>& point2)
|
||||
{
|
||||
//
|
||||
// Compute the closest points on two lines. This was originally
|
||||
// lifted from inventor. This function assumes that the line
|
||||
// directions are normalized. The original math has been collapsed.
|
||||
//
|
||||
|
||||
T A = line1.dir ^ line2.dir;
|
||||
|
||||
if ( A == 1 ) return false;
|
||||
|
||||
T denom = A * A - 1;
|
||||
|
||||
T B = (line1.dir ^ line1.pos) - (line1.dir ^ line2.pos);
|
||||
T C = (line2.dir ^ line1.pos) - (line2.dir ^ line2.pos);
|
||||
|
||||
point1 = line1(( B - A * C ) / denom);
|
||||
point2 = line2(( B * A - C ) / denom);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
bool intersect( const Line3<T> &line,
|
||||
const Vec3<T> &v0,
|
||||
const Vec3<T> &v1,
|
||||
const Vec3<T> &v2,
|
||||
Vec3<T> &pt,
|
||||
Vec3<T> &barycentric,
|
||||
bool &front)
|
||||
{
|
||||
// Intersect the line with a triangle.
|
||||
// 1. find plane of triangle
|
||||
// 2. find intersection point of ray and plane
|
||||
// 3. pick plane to project point and triangle into
|
||||
// 4. check each edge of triangle to see if point is inside it
|
||||
|
||||
//
|
||||
// XXX TODO - this routine is way too long
|
||||
// - the value of EPSILON is dubious
|
||||
// - there should be versions of this
|
||||
// routine that do not calculate the
|
||||
// barycentric coordinates or the
|
||||
// front flag
|
||||
|
||||
const float EPSILON = 1e-6;
|
||||
|
||||
T d, t, d01, d12, d20, vd0, vd1, vd2, ax, ay, az, sense;
|
||||
Vec3<T> v01, v12, v20, c;
|
||||
int axis0, axis1;
|
||||
|
||||
// calculate plane for polygon
|
||||
v01 = v1 - v0;
|
||||
v12 = v2 - v1;
|
||||
|
||||
// c is un-normalized normal
|
||||
c = v12.cross(v01);
|
||||
|
||||
d = c.length();
|
||||
if(d < EPSILON)
|
||||
return false; // cant hit a triangle with no area
|
||||
c = c * (1. / d);
|
||||
|
||||
// calculate distance to plane along ray
|
||||
|
||||
d = line.dir.dot(c);
|
||||
if (d < EPSILON && d > -EPSILON)
|
||||
return false; // line is parallel to plane containing triangle
|
||||
|
||||
t = (v0 - line.pos).dot(c) / d;
|
||||
|
||||
if(t < 0)
|
||||
return false;
|
||||
|
||||
// calculate intersection point
|
||||
pt = line.pos + t * line.dir;
|
||||
|
||||
// is point inside triangle? Project to 2d to find out
|
||||
// use the plane that has the largest absolute value
|
||||
// component in the normal
|
||||
ax = c[0] < 0 ? -c[0] : c[0];
|
||||
ay = c[1] < 0 ? -c[1] : c[1];
|
||||
az = c[2] < 0 ? -c[2] : c[2];
|
||||
|
||||
if(ax > ay && ax > az)
|
||||
{
|
||||
// project on x=0 plane
|
||||
|
||||
axis0 = 1;
|
||||
axis1 = 2;
|
||||
sense = c[0] < 0 ? -1 : 1;
|
||||
}
|
||||
else if(ay > az)
|
||||
{
|
||||
axis0 = 2;
|
||||
axis1 = 0;
|
||||
sense = c[1] < 0 ? -1 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
axis0 = 0;
|
||||
axis1 = 1;
|
||||
sense = c[2] < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
// distance from v0-v1 must be less than distance from v2 to v0-v1
|
||||
d01 = sense * ((pt[axis0] - v0[axis0]) * v01[axis1]
|
||||
- (pt[axis1] - v0[axis1]) * v01[axis0]);
|
||||
|
||||
if(d01 < 0) return false;
|
||||
|
||||
vd2 = sense * ((v2[axis0] - v0[axis0]) * v01[axis1]
|
||||
- (v2[axis1] - v0[axis1]) * v01[axis0]);
|
||||
|
||||
if(d01 > vd2) return false;
|
||||
|
||||
// distance from v1-v2 must be less than distance from v1 to v2-v0
|
||||
d12 = sense * ((pt[axis0] - v1[axis0]) * v12[axis1]
|
||||
- (pt[axis1] - v1[axis1]) * v12[axis0]);
|
||||
|
||||
if(d12 < 0) return false;
|
||||
|
||||
vd0 = sense * ((v0[axis0] - v1[axis0]) * v12[axis1]
|
||||
- (v0[axis1] - v1[axis1]) * v12[axis0]);
|
||||
|
||||
if(d12 > vd0) return false;
|
||||
|
||||
// calculate v20, and do check on final side of triangle
|
||||
v20 = v0 - v2;
|
||||
d20 = sense * ((pt[axis0] - v2[axis0]) * v20[axis1]
|
||||
- (pt[axis1] - v2[axis1]) * v20[axis0]);
|
||||
|
||||
if(d20 < 0) return false;
|
||||
|
||||
vd1 = sense * ((v1[axis0] - v2[axis0]) * v20[axis1]
|
||||
- (v1[axis1] - v2[axis1]) * v20[axis0]);
|
||||
|
||||
if(d20 > vd1) return false;
|
||||
|
||||
// vd0, vd1, and vd2 will always be non-zero for a triangle
|
||||
// that has non-zero area (we return before this for
|
||||
// zero area triangles)
|
||||
barycentric = Vec3<T>(d12 / vd0, d20 / vd1, d01 / vd2);
|
||||
front = line.dir.dot(c) < 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Vec3<T>
|
||||
closestVertex(const Vec3<T> &v0,
|
||||
const Vec3<T> &v1,
|
||||
const Vec3<T> &v2,
|
||||
const Line3<T> &l)
|
||||
{
|
||||
Vec3<T> nearest = v0;
|
||||
T neardot = (v0 - l.closestPointTo(v0)).length2();
|
||||
|
||||
T tmp = (v1 - l.closestPointTo(v1)).length2();
|
||||
|
||||
if (tmp < neardot)
|
||||
{
|
||||
neardot = tmp;
|
||||
nearest = v1;
|
||||
}
|
||||
|
||||
tmp = (v2 - l.closestPointTo(v2)).length2();
|
||||
if (tmp < neardot)
|
||||
{
|
||||
neardot = tmp;
|
||||
nearest = v2;
|
||||
}
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Vec3<T>
|
||||
nearestPointOnTriangle(const Vec3<T> &v0,
|
||||
const Vec3<T> &v1,
|
||||
const Vec3<T> &v2,
|
||||
const Line3<T> &l)
|
||||
{
|
||||
Vec3<T> pt, barycentric;
|
||||
bool front;
|
||||
|
||||
if (intersect (l, v0, v1, v2, pt, barycentric, front))
|
||||
return pt;
|
||||
|
||||
//
|
||||
// The line did not intersect the triangle, so to be picky, you should
|
||||
// find the closest edge that it passed over/under, but chances are that
|
||||
// 1) another triangle will be closer
|
||||
// 2) the app does not need this much precision for a ray that does not
|
||||
// intersect the triangle
|
||||
// 3) the expense of the calculation is not worth it since this is the
|
||||
// common case
|
||||
//
|
||||
// XXX TODO This is bogus -- nearestPointOnTriangle() should do
|
||||
// what its name implies; it should return a point
|
||||
// on an edge if some edge is closer to the line than
|
||||
// any vertex. If the application does not want the
|
||||
// extra calculations, it should be possible to specify
|
||||
// that; it is not up to this nearestPointOnTriangle()
|
||||
// to make the decision.
|
||||
|
||||
return closestVertex(v0, v1, v2, l);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Vec3<T>
|
||||
rotatePoint(const Vec3<T> p, Line3<T> l, T angle)
|
||||
{
|
||||
//
|
||||
// Rotate the point p around the line l by the given angle.
|
||||
//
|
||||
|
||||
//
|
||||
// Form a coordinate frame with <x,y,a>. The rotation is the in xy
|
||||
// plane.
|
||||
//
|
||||
|
||||
Vec3<T> q = l.closestPointTo(p);
|
||||
Vec3<T> x = p - q;
|
||||
T radius = x.length();
|
||||
|
||||
x.normalize();
|
||||
Vec3<T> y = (x % l.dir).normalize();
|
||||
|
||||
T cosangle = Math<T>::cos(angle);
|
||||
T sinangle = Math<T>::sin(angle);
|
||||
|
||||
Vec3<T> r = q + x * radius * cosangle + y * radius * sinangle;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
191
3rdparty/include/OpenEXR/ImathMath.h
vendored
191
3rdparty/include/OpenEXR/ImathMath.h
vendored
@ -1,191 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHMATH_H
|
||||
#define INCLUDED_IMATHMATH_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// ImathMath.h
|
||||
//
|
||||
// This file contains template functions which call the double-
|
||||
// precision math functions defined in math.h (sin(), sqrt(),
|
||||
// exp() etc.), with specializations that call the faster
|
||||
// single-precision versions (sinf(), sqrtf(), expf() etc.)
|
||||
// when appropriate.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// double x = Math<double>::sqrt (3); // calls ::sqrt(double);
|
||||
// float y = Math<float>::sqrt (3); // calls ::sqrtf(float);
|
||||
//
|
||||
// When would I want to use this?
|
||||
//
|
||||
// You may be writing a template which needs to call some function
|
||||
// defined in math.h, for example to extract a square root, but you
|
||||
// don't know whether to call the single- or the double-precision
|
||||
// version of this function (sqrt() or sqrtf()):
|
||||
//
|
||||
// template <class T>
|
||||
// T
|
||||
// glorp (T x)
|
||||
// {
|
||||
// return sqrt (x + 1); // should call ::sqrtf(float)
|
||||
// } // if x is a float, but we
|
||||
// // don't know if it is
|
||||
//
|
||||
// Using the templates in this file, you can make sure that
|
||||
// the appropriate version of the math function is called:
|
||||
//
|
||||
// template <class T>
|
||||
// T
|
||||
// glorp (T x, T y)
|
||||
// {
|
||||
// return Math<T>::sqrt (x + 1); // calls ::sqrtf(float) if x
|
||||
// } // is a float, ::sqrt(double)
|
||||
// // otherwise
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "ImathPlatform.h"
|
||||
#include <math.h>
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
struct Math
|
||||
{
|
||||
static T acos (T x) {return ::acos (double(x));}
|
||||
static T asin (T x) {return ::asin (double(x));}
|
||||
static T atan (T x) {return ::atan (double(x));}
|
||||
static T atan2 (T x, T y) {return ::atan2 (double(x), double(y));}
|
||||
static T cos (T x) {return ::cos (double(x));}
|
||||
static T sin (T x) {return ::sin (double(x));}
|
||||
static T tan (T x) {return ::tan (double(x));}
|
||||
static T cosh (T x) {return ::cosh (double(x));}
|
||||
static T sinh (T x) {return ::sinh (double(x));}
|
||||
static T tanh (T x) {return ::tanh (double(x));}
|
||||
static T exp (T x) {return ::exp (double(x));}
|
||||
static T log (T x) {return ::log (double(x));}
|
||||
static T log10 (T x) {return ::log10 (double(x));}
|
||||
static T modf (T x, T *iptr)
|
||||
{
|
||||
double ival;
|
||||
T rval( ::modf (double(x),&ival));
|
||||
*iptr = ival;
|
||||
return rval;
|
||||
}
|
||||
static T pow (T x, T y) {return ::pow (double(x), double(y));}
|
||||
static T sqrt (T x) {return ::sqrt (double(x));}
|
||||
static T ceil (T x) {return ::ceil (double(x));}
|
||||
static T fabs (T x) {return ::fabs (double(x));}
|
||||
static T floor (T x) {return ::floor (double(x));}
|
||||
static T fmod (T x, T y) {return ::fmod (double(x), double(y));}
|
||||
static T hypot (T x, T y) {return ::hypot (double(x), double(y));}
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct Math<float>
|
||||
{
|
||||
static float acos (float x) {return ::acosf (x);}
|
||||
static float asin (float x) {return ::asinf (x);}
|
||||
static float atan (float x) {return ::atanf (x);}
|
||||
static float atan2 (float x, float y) {return ::atan2f (x, y);}
|
||||
static float cos (float x) {return ::cosf (x);}
|
||||
static float sin (float x) {return ::sinf (x);}
|
||||
static float tan (float x) {return ::tanf (x);}
|
||||
static float cosh (float x) {return ::coshf (x);}
|
||||
static float sinh (float x) {return ::sinhf (x);}
|
||||
static float tanh (float x) {return ::tanhf (x);}
|
||||
static float exp (float x) {return ::expf (x);}
|
||||
static float log (float x) {return ::logf (x);}
|
||||
static float log10 (float x) {return ::log10f (x);}
|
||||
static float modf (float x, float *y) {return ::modff (x, y);}
|
||||
static float pow (float x, float y) {return ::powf (x, y);}
|
||||
static float sqrt (float x) {return ::sqrtf (x);}
|
||||
static float ceil (float x) {return ::ceilf (x);}
|
||||
static float fabs (float x) {return ::fabsf (x);}
|
||||
static float floor (float x) {return ::floorf (x);}
|
||||
static float fmod (float x, float y) {return ::fmodf (x, y);}
|
||||
#if !defined(_MSC_VER)
|
||||
static float hypot (float x, float y) {return ::hypotf (x, y);}
|
||||
#else
|
||||
static float hypot (float x, float y) {return ::sqrtf(x*x + y*y);}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Compare two numbers and test if they are "approximately equal":
|
||||
//
|
||||
// equalWithAbsError (x1, x2, e)
|
||||
//
|
||||
// Returns true if x1 is the same as x2 with an absolute error of
|
||||
// no more than e,
|
||||
//
|
||||
// abs (x1 - x2) <= e
|
||||
//
|
||||
// equalWithRelError (x1, x2, e)
|
||||
//
|
||||
// Returns true if x1 is the same as x2 with an relative error of
|
||||
// no more than e,
|
||||
//
|
||||
// abs (x1 - x2) <= e * x1
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
equalWithAbsError (T x1, T x2, T e)
|
||||
{
|
||||
return ((x1 > x2)? x1 - x2: x2 - x1) <= e;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
equalWithRelError (T x1, T x2, T e)
|
||||
{
|
||||
return ((x1 > x2)? x1 - x2: x2 - x1) <= e * ((x1 > 0)? x1: -x1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
3249
3rdparty/include/OpenEXR/ImathMatrix.h
vendored
3249
3rdparty/include/OpenEXR/ImathMatrix.h
vendored
File diff suppressed because it is too large
Load Diff
1114
3rdparty/include/OpenEXR/ImathMatrixAlgo.h
vendored
1114
3rdparty/include/OpenEXR/ImathMatrixAlgo.h
vendored
File diff suppressed because it is too large
Load Diff
256
3rdparty/include/OpenEXR/ImathPlane.h
vendored
256
3rdparty/include/OpenEXR/ImathPlane.h
vendored
@ -1,256 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHPLANE_H
|
||||
#define INCLUDED_IMATHPLANE_H
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// template class Plane3
|
||||
//
|
||||
// The Imath::Plane3<> class represents a half space, so the
|
||||
// normal may point either towards or away from origin. The
|
||||
// plane P can be represented by Imath::Plane3 as either p or -p
|
||||
// corresponding to the two half-spaces on either side of the
|
||||
// plane. Any function which computes a distance will return
|
||||
// either negative or positive values for the distance indicating
|
||||
// which half-space the point is in. Note that reflection, and
|
||||
// intersection functions will operate as expected.
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathLine.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Plane3
|
||||
{
|
||||
public:
|
||||
|
||||
Vec3<T> normal;
|
||||
T distance;
|
||||
|
||||
Plane3() {}
|
||||
Plane3(const Vec3<T> &normal, T distance);
|
||||
Plane3(const Vec3<T> &point, const Vec3<T> &normal);
|
||||
Plane3(const Vec3<T> &point1,
|
||||
const Vec3<T> &point2,
|
||||
const Vec3<T> &point3);
|
||||
|
||||
//----------------------
|
||||
// Various set methods
|
||||
//----------------------
|
||||
|
||||
void set(const Vec3<T> &normal,
|
||||
T distance);
|
||||
|
||||
void set(const Vec3<T> &point,
|
||||
const Vec3<T> &normal);
|
||||
|
||||
void set(const Vec3<T> &point1,
|
||||
const Vec3<T> &point2,
|
||||
const Vec3<T> &point3 );
|
||||
|
||||
//----------------------
|
||||
// Utilities
|
||||
//----------------------
|
||||
|
||||
bool intersect(const Line3<T> &line,
|
||||
Vec3<T> &intersection) const;
|
||||
|
||||
bool intersectT(const Line3<T> &line,
|
||||
T ¶meter) const;
|
||||
|
||||
T distanceTo(const Vec3<T> &) const;
|
||||
|
||||
Vec3<T> reflectPoint(const Vec3<T> &) const;
|
||||
Vec3<T> reflectVector(const Vec3<T> &) const;
|
||||
};
|
||||
|
||||
|
||||
//--------------------
|
||||
// Convenient typedefs
|
||||
//--------------------
|
||||
|
||||
typedef Plane3<float> Plane3f;
|
||||
typedef Plane3<double> Plane3d;
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
inline Plane3<T>::Plane3(const Vec3<T> &p0,
|
||||
const Vec3<T> &p1,
|
||||
const Vec3<T> &p2)
|
||||
{
|
||||
set(p0,p1,p2);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Plane3<T>::Plane3(const Vec3<T> &n, T d)
|
||||
{
|
||||
set(n, d);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Plane3<T>::Plane3(const Vec3<T> &p, const Vec3<T> &n)
|
||||
{
|
||||
set(p, n);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Plane3<T>::set(const Vec3<T>& point1,
|
||||
const Vec3<T>& point2,
|
||||
const Vec3<T>& point3)
|
||||
{
|
||||
normal = (point2 - point1) % (point3 - point1);
|
||||
normal.normalize();
|
||||
distance = normal ^ point1;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Plane3<T>::set(const Vec3<T>& point, const Vec3<T>& n)
|
||||
{
|
||||
normal = n;
|
||||
normal.normalize();
|
||||
distance = normal ^ point;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Plane3<T>::set(const Vec3<T>& n, T d)
|
||||
{
|
||||
normal = n;
|
||||
normal.normalize();
|
||||
distance = d;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Plane3<T>::distanceTo(const Vec3<T> &point) const
|
||||
{
|
||||
return (point ^ normal) - distance;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Vec3<T> Plane3<T>::reflectPoint(const Vec3<T> &point) const
|
||||
{
|
||||
return normal * distanceTo(point) * -2.0 + point;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline Vec3<T> Plane3<T>::reflectVector(const Vec3<T> &v) const
|
||||
{
|
||||
return normal * (normal ^ v) * 2.0 - v;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline bool Plane3<T>::intersect(const Line3<T>& line, Vec3<T>& point) const
|
||||
{
|
||||
T d = normal ^ line.dir;
|
||||
if ( d == 0.0 ) return false;
|
||||
T t = - ((normal ^ line.pos) - distance) / d;
|
||||
point = line(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool Plane3<T>::intersectT(const Line3<T>& line, T &t) const
|
||||
{
|
||||
T d = normal ^ line.dir;
|
||||
if ( d == 0.0 ) return false;
|
||||
t = - ((normal ^ line.pos) - distance) / d;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::ostream &operator<< (std::ostream &o, const Plane3<T> &plane)
|
||||
{
|
||||
return o << "(" << plane.normal << ", " << plane.distance
|
||||
<< ")";
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Plane3<T> operator* (const Plane3<T> &plane, const Matrix44<T> &M)
|
||||
{
|
||||
// T
|
||||
// -1
|
||||
// Could also compute M but that would suck.
|
||||
//
|
||||
|
||||
Vec3<T> dir1 = Vec3<T> (1, 0, 0) % plane.normal;
|
||||
T dir1Len = dir1 ^ dir1;
|
||||
|
||||
Vec3<T> tmp = Vec3<T> (0, 1, 0) % plane.normal;
|
||||
T tmpLen = tmp ^ tmp;
|
||||
|
||||
if (tmpLen > dir1Len)
|
||||
{
|
||||
dir1 = tmp;
|
||||
dir1Len = tmpLen;
|
||||
}
|
||||
|
||||
tmp = Vec3<T> (0, 0, 1) % plane.normal;
|
||||
tmpLen = tmp ^ tmp;
|
||||
|
||||
if (tmpLen > dir1Len)
|
||||
{
|
||||
dir1 = tmp;
|
||||
}
|
||||
|
||||
Vec3<T> dir2 = dir1 % plane.normal;
|
||||
Vec3<T> point = plane.distance * plane.normal;
|
||||
|
||||
return Plane3<T> ( point * M,
|
||||
(point + dir2) * M,
|
||||
(point + dir1) * M );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Plane3<T> operator- (const Plane3<T> &plane)
|
||||
{
|
||||
return Plane3<T>(-plane.normal,-plane.distance);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
92
3rdparty/include/OpenEXR/ImathPlatform.h
vendored
92
3rdparty/include/OpenEXR/ImathPlatform.h
vendored
@ -1,92 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHPLATFORM_H
|
||||
#define INCLUDED_IMATHPLATFORM_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// ImathPlatform.h
|
||||
//
|
||||
// This file contains functions and constants which aren't
|
||||
// provided by the system libraries, compilers, or includes on
|
||||
// certain platforms.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#if defined _WIN32 || defined _WIN64
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Fixes for the "restrict" keyword. These #ifdef's for detecting
|
||||
// compiler versions courtesy of Boost's select_compiler_config.hpp;
|
||||
// here is the copyright notice for that file:
|
||||
//
|
||||
// (C) Copyright Boost.org 2001. Permission to copy, use, modify, sell and
|
||||
// and distribute this software is granted provided this copyright notice
|
||||
// appears in all copies. This software is provided "as is" without express
|
||||
// or implied warranty, and with no claim as to its suitability for any
|
||||
// purpose.
|
||||
//
|
||||
// Some compilers support "restrict", in which case we do nothing.
|
||||
// Other compilers support some variant of it (e.g. "__restrict").
|
||||
// If we don't know anything about the compiler, we define "restrict"
|
||||
// to be a no-op.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if defined __GNUC__
|
||||
#if !defined(restrict)
|
||||
#define restrict __restrict
|
||||
#endif
|
||||
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
|
||||
// supports restrict, do nothing.
|
||||
|
||||
#elif defined __sgi
|
||||
// supports restrict, do nothing.
|
||||
|
||||
#else
|
||||
#define restrict
|
||||
|
||||
#endif
|
||||
|
||||
#endif // INCLUDED_IMATHPLATFORM_H
|
690
3rdparty/include/OpenEXR/ImathQuat.h
vendored
690
3rdparty/include/OpenEXR/ImathQuat.h
vendored
@ -1,690 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHQUAT_H
|
||||
#define INCLUDED_IMATHQUAT_H
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// template class Quat<T>
|
||||
//
|
||||
// "Quaternions came from Hamilton ... and have been an unmixed
|
||||
// evil to those who have touched them in any way. Vector is a
|
||||
// useless survival ... and has never been of the slightest use
|
||||
// to any creature."
|
||||
//
|
||||
// - Lord Kelvin
|
||||
//
|
||||
// This class implements the quaternion numerical type -- you
|
||||
// will probably want to use this class to represent orientations
|
||||
// in R3 and to convert between various euler angle reps. You
|
||||
// should probably use Imath::Euler<> for that.
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#include "ImathExc.h"
|
||||
#include "ImathMatrix.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Imath {
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
// Disable MS VC++ warnings about conversion from double to float
|
||||
#pragma warning(disable:4244)
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class Quat;
|
||||
|
||||
template<class T>
|
||||
Quat<T> slerp (const Quat<T> &q1,const Quat<T> &q2, T t);
|
||||
|
||||
template<class T>
|
||||
Quat<T> squad (const Quat<T> &q1,const Quat<T> &q2,
|
||||
const Quat<T> &qa,const Quat<T> &qb, T t);
|
||||
|
||||
template<class T>
|
||||
void intermediate (const Quat<T> &q0, const Quat<T> &q1,
|
||||
const Quat<T> &q2, const Quat<T> &q3,
|
||||
Quat<T> &qa, Quat<T> &qb);
|
||||
|
||||
template <class T>
|
||||
class Quat
|
||||
{
|
||||
public:
|
||||
|
||||
T r; // real part
|
||||
Vec3<T> v; // imaginary vector
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Constructors - default constructor is identity quat
|
||||
//-----------------------------------------------------
|
||||
|
||||
Quat() : r(1), v(0,0,0) {}
|
||||
|
||||
template <class S>
|
||||
Quat( const Quat<S>& q) : r(q.r), v(q.v) {}
|
||||
|
||||
Quat( T s, T i, T j, T k ) : r(s), v(i,j,k) {}
|
||||
|
||||
Quat( T s, Vec3<T> d ) : r(s), v(d) {}
|
||||
|
||||
static Quat<T> identity() { return Quat<T>(); }
|
||||
|
||||
//------------------------------------------------
|
||||
// Basic Algebra - Operators and Methods
|
||||
// The operator return values are *NOT* normalized
|
||||
//
|
||||
// operator^ is 4D dot product
|
||||
// operator/ uses the inverse() quaternion
|
||||
// operator~ is conjugate -- if (S+V) is quat then
|
||||
// the conjugate (S+V)* == (S-V)
|
||||
//
|
||||
// some operators (*,/,*=,/=) treat the quat as
|
||||
// a 4D vector when one of the operands is scalar
|
||||
//------------------------------------------------
|
||||
|
||||
const Quat<T>& operator= (const Quat<T>&);
|
||||
const Quat<T>& operator*= (const Quat<T>&);
|
||||
const Quat<T>& operator*= (T);
|
||||
const Quat<T>& operator/= (const Quat<T>&);
|
||||
const Quat<T>& operator/= (T);
|
||||
const Quat<T>& operator+= (const Quat<T>&);
|
||||
const Quat<T>& operator-= (const Quat<T>&);
|
||||
T& operator[] (int index); // as 4D vector
|
||||
T operator[] (int index) const;
|
||||
|
||||
template <class S> bool operator == (const Quat<S> &q) const;
|
||||
template <class S> bool operator != (const Quat<S> &q) const;
|
||||
|
||||
Quat<T>& invert(); // this -> 1 / this
|
||||
Quat<T> inverse() const;
|
||||
Quat<T>& normalize(); // returns this
|
||||
Quat<T> normalized() const;
|
||||
T length() const; // in R4
|
||||
|
||||
//-----------------------
|
||||
// Rotation conversion
|
||||
//-----------------------
|
||||
|
||||
Quat<T>& setAxisAngle(const Vec3<T>& axis, T radians);
|
||||
Quat<T>& setRotation(const Vec3<T>& fromDirection,
|
||||
const Vec3<T>& toDirection);
|
||||
|
||||
T angle() const;
|
||||
Vec3<T> axis() const;
|
||||
|
||||
Matrix33<T> toMatrix33() const;
|
||||
Matrix44<T> toMatrix44() const;
|
||||
|
||||
Quat<T> log() const;
|
||||
Quat<T> exp() const;
|
||||
};
|
||||
|
||||
|
||||
//--------------------
|
||||
// Convenient typedefs
|
||||
//--------------------
|
||||
|
||||
typedef Quat<float> Quatf;
|
||||
typedef Quat<double> Quatd;
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template<class T>
|
||||
inline const Quat<T>& Quat<T>::operator= (const Quat<T>& q)
|
||||
{
|
||||
r = q.r;
|
||||
v = q.v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const Quat<T>& Quat<T>::operator*= (const Quat<T>& q)
|
||||
{
|
||||
T rtmp = r * q.r - (v ^ q.v);
|
||||
v = r * q.v + v * q.r + v % q.v;
|
||||
r = rtmp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const Quat<T>& Quat<T>::operator*= (T t)
|
||||
{
|
||||
r *= t;
|
||||
v *= t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const Quat<T>& Quat<T>::operator/= (const Quat<T>& q)
|
||||
{
|
||||
*this = *this * q.inverse();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const Quat<T>& Quat<T>::operator/= (T t)
|
||||
{
|
||||
r /= t;
|
||||
v /= t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const Quat<T>& Quat<T>::operator+= (const Quat<T>& q)
|
||||
{
|
||||
r += q.r;
|
||||
v += q.v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const Quat<T>& Quat<T>::operator-= (const Quat<T>& q)
|
||||
{
|
||||
r -= q.r;
|
||||
v -= q.v;
|
||||
return *this;
|
||||
}
|
||||
template<class T>
|
||||
inline T& Quat<T>::operator[] (int index)
|
||||
{
|
||||
return index ? v[index-1] : r;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T Quat<T>::operator[] (int index) const
|
||||
{
|
||||
return index ? v[index-1] : r;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline bool
|
||||
Quat<T>::operator == (const Quat<S> &q) const
|
||||
{
|
||||
return r == q.r && v == q.v;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline bool
|
||||
Quat<T>::operator != (const Quat<S> &q) const
|
||||
{
|
||||
return r != q.r || v != q.v;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T operator^ (const Quat<T>& q1,const Quat<T>& q2)
|
||||
{
|
||||
return q1.r * q2.r + (q1.v ^ q2.v);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Quat<T>::length() const
|
||||
{
|
||||
return Math<T>::sqrt( r * r + (v ^ v) );
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Quat<T>& Quat<T>::normalize()
|
||||
{
|
||||
if ( T l = length() ) { r /= l; v /= l; }
|
||||
else { r = 1; v = Vec3<T>(0); }
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Quat<T> Quat<T>::normalized() const
|
||||
{
|
||||
if ( T l = length() ) return Quat( r / l, v / l );
|
||||
return Quat();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> Quat<T>::inverse() const
|
||||
{
|
||||
// 1 Q*
|
||||
// - = ---- where Q* is conjugate (operator~)
|
||||
// Q Q* Q and (Q* Q) == Q ^ Q (4D dot)
|
||||
|
||||
T qdot = *this ^ *this;
|
||||
return Quat( r / qdot, -v / qdot );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T>& Quat<T>::invert()
|
||||
{
|
||||
T qdot = (*this) ^ (*this);
|
||||
r /= qdot;
|
||||
v = -v / qdot;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Quat<T>
|
||||
slerp(const Quat<T> &q1,const Quat<T> &q2, T t)
|
||||
{
|
||||
//
|
||||
// Spherical linear interpolation.
|
||||
//
|
||||
// NOTE: Assumes q1 and q2 are normalized and that 0 <= t <= 1.
|
||||
//
|
||||
// This method does *not* interpolate along the shortest arc
|
||||
// between q1 and q2. If you desire interpolation along the
|
||||
// shortest arc, then consider flipping the second quaternion
|
||||
// explicitly before calling slerp. The implementation of squad()
|
||||
// depends on a slerp() that interpolates as is, without the
|
||||
// automatic flipping.
|
||||
//
|
||||
|
||||
T cosomega = q1 ^ q2;
|
||||
if (cosomega >= (T) 1.0)
|
||||
{
|
||||
//
|
||||
// Special case: q1 and q2 are the same, so just return one of them.
|
||||
// This also catches the case where cosomega is very slightly > 1.0
|
||||
//
|
||||
|
||||
return q1;
|
||||
}
|
||||
|
||||
T sinomega = Math<T>::sqrt (1 - cosomega * cosomega);
|
||||
|
||||
Quat<T> result;
|
||||
|
||||
if (sinomega * limits<T>::max() > 1)
|
||||
{
|
||||
T omega = Math<T>::acos (cosomega);
|
||||
T s1 = Math<T>::sin ((1.0 - t) * omega) / sinomega;
|
||||
T s2 = Math<T>::sin (t * omega) / sinomega;
|
||||
|
||||
result = s1 * q1 + s2 * q2;
|
||||
}
|
||||
else if (cosomega > 0)
|
||||
{
|
||||
//
|
||||
// omega == 0
|
||||
//
|
||||
|
||||
T s1 = 1.0 - t;
|
||||
T s2 = t;
|
||||
|
||||
result = s1 * q1 + s2 * q2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// omega == -pi
|
||||
//
|
||||
|
||||
result.v.x = - q1.v.y;
|
||||
result.v.y = q1.v.x;
|
||||
result.v.z = - q1.r;
|
||||
result.r = q1.v.z;
|
||||
|
||||
T s1 = Math<T>::sin ((0.5 - t) * M_PI);
|
||||
T s2 = Math<T>::sin (t * M_PI);
|
||||
|
||||
result = s1 * q1 + s2 * result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Quat<T> spline(const Quat<T> &q0, const Quat<T> &q1,
|
||||
const Quat<T> &q2, const Quat<T> &q3,
|
||||
T t)
|
||||
{
|
||||
// Spherical Cubic Spline Interpolation -
|
||||
// from Advanced Animation and Rendering
|
||||
// Techniques by Watt and Watt, Page 366:
|
||||
// A spherical curve is constructed using three
|
||||
// spherical linear interpolations of a quadrangle
|
||||
// of unit quaternions: q1, qa, qb, q2.
|
||||
// Given a set of quaternion keys: q0, q1, q2, q3,
|
||||
// this routine does the interpolation between
|
||||
// q1 and q2 by constructing two intermediate
|
||||
// quaternions: qa and qb. The qa and qb are
|
||||
// computed by the intermediate function to
|
||||
// guarantee the continuity of tangents across
|
||||
// adjacent cubic segments. The qa represents in-tangent
|
||||
// for q1 and the qb represents the out-tangent for q2.
|
||||
//
|
||||
// The q1 q2 is the cubic segment being interpolated.
|
||||
// The q0 is from the previous adjacent segment and q3 is
|
||||
// from the next adjacent segment. The q0 and q3 are used
|
||||
// in computing qa and qb.
|
||||
//
|
||||
|
||||
Quat<T> qa = intermediate (q0, q1, q2);
|
||||
Quat<T> qb = intermediate (q1, q2, q3);
|
||||
Quat<T> result = squad(q1, qa, qb, q2, t);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Quat<T> squad(const Quat<T> &q1, const Quat<T> &qa,
|
||||
const Quat<T> &qb, const Quat<T> &q2,
|
||||
T t)
|
||||
{
|
||||
// Spherical Quadrangle Interpolation -
|
||||
// from Advanced Animation and Rendering
|
||||
// Techniques by Watt and Watt, Page 366:
|
||||
// It constructs a spherical cubic interpolation as
|
||||
// a series of three spherical linear interpolations
|
||||
// of a quadrangle of unit quaternions.
|
||||
//
|
||||
|
||||
Quat<T> r1 = slerp(q1, q2, t);
|
||||
Quat<T> r2 = slerp(qa, qb, t);
|
||||
Quat<T> result = slerp(r1, r2, 2*t*(1-t));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Quat<T> intermediate(const Quat<T> &q0, const Quat<T> &q1, const Quat<T> &q2)
|
||||
{
|
||||
// From advanced Animation and Rendering
|
||||
// Techniques by Watt and Watt, Page 366:
|
||||
// computing the inner quadrangle
|
||||
// points (qa and qb) to guarantee tangent
|
||||
// continuity.
|
||||
//
|
||||
Quat<T> q1inv = q1.inverse();
|
||||
Quat<T> c1 = q1inv*q2;
|
||||
Quat<T> c2 = q1inv*q0;
|
||||
Quat<T> c3 = (T) (-0.25) * (c2.log() + c1.log());
|
||||
Quat<T> qa = q1 * c3.exp();
|
||||
qa.normalize();
|
||||
return qa;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Quat<T> Quat<T>::log() const
|
||||
{
|
||||
//
|
||||
// For unit quaternion, from Advanced Animation and
|
||||
// Rendering Techniques by Watt and Watt, Page 366:
|
||||
//
|
||||
|
||||
T theta = Math<T>::acos (std::min (r, (T) 1.0));
|
||||
if (theta == 0)
|
||||
return Quat<T> (0, v);
|
||||
|
||||
T sintheta = Math<T>::sin (theta);
|
||||
|
||||
T k;
|
||||
if (abs (sintheta) < 1 && abs (theta) >= limits<T>::max() * abs (sintheta))
|
||||
k = 0;
|
||||
else
|
||||
k = theta / sintheta;
|
||||
|
||||
return Quat<T> ((T) 0, v.x * k, v.y * k, v.z * k);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Quat<T> Quat<T>::exp() const
|
||||
{
|
||||
//
|
||||
// For pure quaternion (zero scalar part):
|
||||
// from Advanced Animation and Rendering
|
||||
// Techniques by Watt and Watt, Page 366:
|
||||
//
|
||||
|
||||
T theta = v.length();
|
||||
T sintheta = Math<T>::sin (theta);
|
||||
|
||||
T k;
|
||||
if (abs (theta) < 1 && abs (sintheta) >= limits<T>::max() * abs (theta))
|
||||
k = 0;
|
||||
else
|
||||
k = sintheta / theta;
|
||||
|
||||
T costheta = Math<T>::cos (theta);
|
||||
|
||||
return Quat<T> (costheta, v.x * k, v.y * k, v.z * k);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Quat<T>::angle() const
|
||||
{
|
||||
return 2.0*Math<T>::acos(r);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Vec3<T> Quat<T>::axis() const
|
||||
{
|
||||
return v.normalized();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Quat<T>& Quat<T>::setAxisAngle(const Vec3<T>& axis, T radians)
|
||||
{
|
||||
r = Math<T>::cos(radians/2);
|
||||
v = axis.normalized() * Math<T>::sin(radians/2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Quat<T>&
|
||||
Quat<T>::setRotation(const Vec3<T>& from, const Vec3<T>& to)
|
||||
{
|
||||
//
|
||||
// Ported from SbRotation
|
||||
//
|
||||
|
||||
T cost = from.dot(to) / Math<T>::sqrt(from.dot(from) * to.dot(to));
|
||||
|
||||
// check for degeneracies
|
||||
if (cost > 0.99999)
|
||||
{
|
||||
//
|
||||
// Vectors are parallel.
|
||||
//
|
||||
|
||||
r = 1.0;
|
||||
v = Vec3<T>(0);
|
||||
}
|
||||
else if (cost < -0.99999)
|
||||
{
|
||||
//
|
||||
// Vectors are opposite. Find an axis to rotate around,
|
||||
// which should be perpendicular to the original axis.
|
||||
//
|
||||
|
||||
Vec3<T> frm = from.normalized();
|
||||
v = frm.cross(Vec3<T>(1, 0, 0));
|
||||
if (v.length() < 0.00001)
|
||||
v = frm.cross(Vec3<T>(0, 1, 0));
|
||||
r = 0;
|
||||
v.normalize();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Use half-angle formulae:
|
||||
// cos^2 t = ( 1 + cos (2t) ) / 2
|
||||
// w part is cosine of half the rotation angle
|
||||
//
|
||||
|
||||
r = Math<T>::sqrt(0.5 * (1.0 + cost));
|
||||
|
||||
//
|
||||
// sin^2 t = ( 1 - cos (2t) ) / 2
|
||||
// Do the normalization of the axis vector at the same time so
|
||||
// we only call sqrt once.
|
||||
//
|
||||
|
||||
v = from.cross(to);
|
||||
v *= Math<T>::sqrt((0.5 * (1.0 - cost))/(v.dot(v)));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Matrix33<T> Quat<T>::toMatrix33() const
|
||||
{
|
||||
return Matrix33<T>(1. - 2.0 * (v.y * v.y + v.z * v.z),
|
||||
2.0 * (v.x * v.y + v.z * r),
|
||||
2.0 * (v.z * v.x - v.y * r),
|
||||
|
||||
2.0 * (v.x * v.y - v.z * r),
|
||||
1. - 2.0 * (v.z * v.z + v.x * v.x),
|
||||
2.0 * (v.y * v.z + v.x * r),
|
||||
|
||||
2.0 * (v.z * v.x + v.y * r),
|
||||
2.0 * (v.y * v.z - v.x * r),
|
||||
1. - 2.0 * (v.y * v.y + v.x * v.x));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Matrix44<T> Quat<T>::toMatrix44() const
|
||||
{
|
||||
return Matrix44<T>(1. - 2.0 * (v.y * v.y + v.z * v.z),
|
||||
2.0 * (v.x * v.y + v.z * r),
|
||||
2.0 * (v.z * v.x - v.y * r),
|
||||
0.,
|
||||
2.0 * (v.x * v.y - v.z * r),
|
||||
1. - 2.0 * (v.z * v.z + v.x * v.x),
|
||||
2.0 * (v.y * v.z + v.x * r),
|
||||
0.,
|
||||
2.0 * (v.z * v.x + v.y * r),
|
||||
2.0 * (v.y * v.z - v.x * r),
|
||||
1. - 2.0 * (v.y * v.y + v.x * v.x),
|
||||
0.,
|
||||
0.,
|
||||
0.,
|
||||
0.,
|
||||
1.0 );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Matrix33<T> operator* (const Matrix33<T> &M, const Quat<T> &q)
|
||||
{
|
||||
return M * q.toMatrix33();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Matrix33<T> operator* (const Quat<T> &q, const Matrix33<T> &M)
|
||||
{
|
||||
return q.toMatrix33() * M;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::ostream& operator<< (std::ostream &o, const Quat<T> &q)
|
||||
{
|
||||
return o << "(" << q.r
|
||||
<< " " << q.v.x
|
||||
<< " " << q.v.y
|
||||
<< " " << q.v.z
|
||||
<< ")";
|
||||
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator* (const Quat<T>& q1, const Quat<T>& q2)
|
||||
{
|
||||
// (S1+V1) (S2+V2) = S1 S2 - V1.V2 + S1 V2 + V1 S2 + V1 x V2
|
||||
return Quat<T>( q1.r * q2.r - (q1.v ^ q2.v),
|
||||
q1.r * q2.v + q1.v * q2.r + q1.v % q2.v );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator/ (const Quat<T>& q1, const Quat<T>& q2)
|
||||
{
|
||||
return q1 * q2.inverse();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator/ (const Quat<T>& q,T t)
|
||||
{
|
||||
return Quat<T>(q.r/t,q.v/t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator* (const Quat<T>& q,T t)
|
||||
{
|
||||
return Quat<T>(q.r*t,q.v*t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator* (T t, const Quat<T>& q)
|
||||
{
|
||||
return Quat<T>(q.r*t,q.v*t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator+ (const Quat<T>& q1, const Quat<T>& q2)
|
||||
{
|
||||
return Quat<T>( q1.r + q2.r, q1.v + q2.v );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator- (const Quat<T>& q1, const Quat<T>& q2)
|
||||
{
|
||||
return Quat<T>( q1.r - q2.r, q1.v - q2.v );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator~ (const Quat<T>& q)
|
||||
{
|
||||
return Quat<T>( q.r, -q.v ); // conjugate: (S+V)* = S-V
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Quat<T> operator- (const Quat<T>& q)
|
||||
{
|
||||
return Quat<T>( -q.r, -q.v );
|
||||
}
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
#pragma warning(default:4244)
|
||||
#endif
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
461
3rdparty/include/OpenEXR/ImathRandom.h
vendored
461
3rdparty/include/OpenEXR/ImathRandom.h
vendored
@ -1,461 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHRANDOM_H
|
||||
#define INCLUDED_IMATHRANDOM_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Generators for uniformly distributed pseudo-random numbers and
|
||||
// functions that use those generators to generate numbers with
|
||||
// different distributions:
|
||||
//
|
||||
// class Rand32
|
||||
// class Rand48
|
||||
// solidSphereRand()
|
||||
// hollowSphereRand()
|
||||
// gaussRand()
|
||||
// gaussSphereRand()
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Here is the copyright for the *rand48() functions implemented for
|
||||
// Windows.
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (c) 1993 Martin Birgmeier
|
||||
// All rights reserved.
|
||||
//
|
||||
// You may redistribute unmodified or modified versions of this source
|
||||
// code provided that the above copyright notice and this and the
|
||||
// following conditions are retained.
|
||||
//
|
||||
// This software is provided ``as is'', and comes with no warranties
|
||||
// of any kind. I shall in no event be liable for anything that happens
|
||||
// to anyone/anything when using this software.
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Fast random-number generator that generates
|
||||
// a uniformly distributed sequence with a period
|
||||
// length of 2^32.
|
||||
//-----------------------------------------------
|
||||
|
||||
class Rand32
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
Rand32 (unsigned long int seed = 0);
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Re-initialize with a given seed
|
||||
//--------------------------------
|
||||
|
||||
void init (unsigned long int seed);
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Get the next value in the sequence (range: [false, true])
|
||||
//----------------------------------------------------------
|
||||
|
||||
bool nextb ();
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Get the next value in the sequence (range: [0 ... 0xffffffff])
|
||||
//---------------------------------------------------------------
|
||||
|
||||
unsigned long int nexti ();
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Get the next value in the sequence (range: [0 ... 1[)
|
||||
//------------------------------------------------------
|
||||
|
||||
float nextf ();
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get the next value in the sequence (range [rangeMin ... rangeMax[)
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
float nextf (float rangeMin, float rangeMax);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void next ();
|
||||
|
||||
unsigned long int _state;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Random-number generator based on the C Standard Library
|
||||
// functions drand48(), lrand48() & company; generates a
|
||||
// uniformly distributed sequence.
|
||||
//--------------------------------------------------------
|
||||
|
||||
class Rand48
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
Rand48 (unsigned long int seed = 0);
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Re-initialize with a given seed
|
||||
//--------------------------------
|
||||
|
||||
void init (unsigned long int seed);
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Get the next value in the sequence (range: [false, true])
|
||||
//----------------------------------------------------------
|
||||
|
||||
bool nextb ();
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Get the next value in the sequence (range: [0 ... 0x7fffffff])
|
||||
//---------------------------------------------------------------
|
||||
|
||||
long int nexti ();
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Get the next value in the sequence (range: [0 ... 1[)
|
||||
//------------------------------------------------------
|
||||
|
||||
double nextf ();
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get the next value in the sequence (range [rangeMin ... rangeMax[)
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
double nextf (double rangeMin, double rangeMax);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
unsigned short int _state[3];
|
||||
|
||||
#if defined ( _WIN32 ) || defined ( _WIN64 ) || defined ( __MWERKS__ )
|
||||
void shiftState();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Return random points uniformly distributed in a sphere with
|
||||
// radius 1 around the origin (distance from origin <= 1).
|
||||
//------------------------------------------------------------
|
||||
|
||||
template <class Vec, class Rand>
|
||||
Vec
|
||||
solidSphereRand (Rand &rand);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Return random points uniformly distributed on the surface of
|
||||
// a sphere with radius 1 around the origin.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
template <class Vec, class Rand>
|
||||
Vec
|
||||
hollowSphereRand (Rand &rand);
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Return random numbers with a normal (Gaussian)
|
||||
// distribution with zero mean and unit variance.
|
||||
//-----------------------------------------------
|
||||
|
||||
template <class Rand>
|
||||
float
|
||||
gaussRand (Rand &rand);
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Return random points whose distance from the origin
|
||||
// has a normal (Gaussian) distribution with zero mean
|
||||
// and unit variance.
|
||||
//----------------------------------------------------
|
||||
|
||||
template <class Vec, class Rand>
|
||||
Vec
|
||||
gaussSphereRand (Rand &rand);
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
|
||||
inline void
|
||||
Rand32::init (unsigned long int seed)
|
||||
{
|
||||
_state = (seed * 0xa5a573a5L) ^ 0x5a5a5a5aL;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Rand32::Rand32 (unsigned long int seed)
|
||||
{
|
||||
init (seed);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
Rand32::next ()
|
||||
{
|
||||
_state = 1664525L * _state + 1013904223L;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
Rand32::nextb ()
|
||||
{
|
||||
next ();
|
||||
// Return the 31st (most significant) bit, by and-ing with 2 ^ 31.
|
||||
return !!(_state & 2147483648UL);
|
||||
}
|
||||
|
||||
|
||||
inline unsigned long int
|
||||
Rand32::nexti ()
|
||||
{
|
||||
next ();
|
||||
return _state & 0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
inline float
|
||||
Rand32::nextf ()
|
||||
{
|
||||
next ();
|
||||
return ((int) (_state & 0xffffff)) * ((float) (1.0F / 0x1000000));
|
||||
}
|
||||
|
||||
|
||||
inline float
|
||||
Rand32::nextf (float rangeMin, float rangeMax)
|
||||
{
|
||||
return rangeMin + nextf() * (rangeMax - rangeMin);
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
Rand48::init (unsigned long int seed)
|
||||
{
|
||||
seed = (seed * 0xa5a573a5L) ^ 0x5a5a5a5aL;
|
||||
|
||||
_state[0] = (unsigned short int) (seed);
|
||||
_state[1] = (unsigned short int) (seed >> 16);
|
||||
_state[2] = (unsigned short int) (seed);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Rand48::Rand48 (unsigned long int seed)
|
||||
{
|
||||
init (seed);
|
||||
}
|
||||
|
||||
|
||||
#if defined ( _WIN32 ) || defined ( _WIN64 ) || defined ( __MWERKS__ )
|
||||
|
||||
inline void
|
||||
Rand48::shiftState()
|
||||
{
|
||||
unsigned long accu;
|
||||
unsigned short temp[2];
|
||||
|
||||
accu = 0xe66dUL * ( unsigned long )_state[0] + 0x000bUL;
|
||||
|
||||
temp[0] = ( unsigned short )accu; /* lower 16 bits */
|
||||
accu >>= sizeof( unsigned short ) * 8;
|
||||
|
||||
accu += 0xe66dUL * ( unsigned long )_state[1] +
|
||||
0xdeecUL * ( unsigned long )_state[0];
|
||||
|
||||
temp[1] = ( unsigned short )accu; /* middle 16 bits */
|
||||
accu >>= sizeof( unsigned short ) * 8;
|
||||
|
||||
accu += 0xe66dUL * _state[2] +
|
||||
0xdeecUL * _state[1] +
|
||||
0x0005UL * _state[0];
|
||||
|
||||
_state[0] = temp[0];
|
||||
_state[1] = temp[1];
|
||||
_state[2] = ( unsigned short )accu;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline bool
|
||||
Rand48::nextb ()
|
||||
{
|
||||
#if defined ( _WIN32 ) || defined ( _WIN64 ) || defined ( __MWERKS__ )
|
||||
shiftState();
|
||||
return ( ( long( _state[2] ) << 15 ) + ( long( _state[1] ) >> 1 ) ) & 0x1;
|
||||
#else
|
||||
return nrand48 (_state) & 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline long int
|
||||
Rand48::nexti ()
|
||||
{
|
||||
#if defined ( _WIN32 ) || defined ( _WIN64 ) || defined ( __MWERKS__ )
|
||||
shiftState();
|
||||
return ( long( _state[2] ) << 15 ) + ( long( _state[1] ) >> 1 );
|
||||
#else
|
||||
return nrand48 (_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline double
|
||||
Rand48::nextf ()
|
||||
{
|
||||
#if defined ( _WIN32 ) || defined ( _WIN64 ) || defined ( __MWERKS__ )
|
||||
shiftState();
|
||||
return ldexp( double( _state[0] ), -48 ) +
|
||||
ldexp( double( _state[1] ), -32 ) +
|
||||
ldexp( double( _state[2] ), -16 );
|
||||
#else
|
||||
return erand48 (_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline double
|
||||
Rand48::nextf (double rangeMin, double rangeMax)
|
||||
{
|
||||
return rangeMin + nextf() * (rangeMax - rangeMin);
|
||||
}
|
||||
|
||||
|
||||
template <class Vec, class Rand>
|
||||
Vec
|
||||
solidSphereRand (Rand &rand)
|
||||
{
|
||||
Vec v;
|
||||
|
||||
do
|
||||
{
|
||||
for (unsigned int i = 0; i < Vec::dimensions(); i++)
|
||||
v[i] = (typename Vec::BaseType) rand.nextf (-1, 1);
|
||||
}
|
||||
while (v.length2() > 1);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
template <class Vec, class Rand>
|
||||
Vec
|
||||
hollowSphereRand (Rand &rand)
|
||||
{
|
||||
Vec v;
|
||||
typename Vec::BaseType length;
|
||||
|
||||
do
|
||||
{
|
||||
for (unsigned int i = 0; i < Vec::dimensions(); i++)
|
||||
v[i] = (typename Vec::BaseType) rand.nextf (-1, 1);
|
||||
|
||||
length = v.length();
|
||||
}
|
||||
while (length > 1 || length == 0);
|
||||
|
||||
return v / length;
|
||||
}
|
||||
|
||||
|
||||
template <class Rand>
|
||||
float
|
||||
gaussRand (Rand &rand)
|
||||
{
|
||||
float x; // Note: to avoid numerical problems with very small
|
||||
float y; // numbers, we make these variables singe-precision
|
||||
float length2; // floats, but later we call the double-precision log()
|
||||
// and sqrt() functions instead of logf() and sqrtf().
|
||||
do
|
||||
{
|
||||
x = float (rand.nextf (-1, 1));
|
||||
y = float (rand.nextf (-1, 1));
|
||||
length2 = x * x + y * y;
|
||||
}
|
||||
while (length2 >= 1 || length2 == 0);
|
||||
|
||||
return x * sqrt (-2 * log (length2) / length2);
|
||||
}
|
||||
|
||||
|
||||
template <class Vec, class Rand>
|
||||
Vec
|
||||
gaussSphereRand (Rand &rand)
|
||||
{
|
||||
return hollowSphereRand <Vec> (rand) * gaussRand (rand);
|
||||
}
|
||||
|
||||
double drand48();
|
||||
long int lrand48();
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
217
3rdparty/include/OpenEXR/ImathRoots.h
vendored
217
3rdparty/include/OpenEXR/ImathRoots.h
vendored
@ -1,217 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHROOTS_H
|
||||
#define INCLUDED_IMATHROOTS_H
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Functions to solve linear, quadratic or cubic equations
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#include <complex>
|
||||
|
||||
namespace Imath {
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Find the real solutions of a linear, quadratic or cubic equation:
|
||||
//
|
||||
// function equation solved
|
||||
//
|
||||
// solveLinear (a, b, x) a * x + b == 0
|
||||
// solveQuadratic (a, b, c, x) a * x*x + b * x + c == 0
|
||||
// solveNormalizedCubic (r, s, t, x) x*x*x + r * x*x + s * x + t == 0
|
||||
// solveCubic (a, b, c, d, x) a * x*x*x + b * x*x + c * x + d == 0
|
||||
//
|
||||
// Return value:
|
||||
//
|
||||
// 3 three real solutions, stored in x[0], x[1] and x[2]
|
||||
// 2 two real solutions, stored in x[0] and x[1]
|
||||
// 1 one real solution, stored in x[1]
|
||||
// 0 no real solutions
|
||||
// -1 all real numbers are solutions
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// * It is possible that an equation has real solutions, but that the
|
||||
// solutions (or some intermediate result) are not representable.
|
||||
// In this case, either some of the solutions returned are invalid
|
||||
// (nan or infinity), or, if floating-point exceptions have been
|
||||
// enabled with Iex::mathExcOn(), an Iex::MathExc exception is
|
||||
// thrown.
|
||||
//
|
||||
// * Cubic equations are solved using Cardano's Formula; even though
|
||||
// only real solutions are produced, some intermediate results are
|
||||
// complex (std::complex<T>).
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
template <class T> int solveLinear (T a, T b, T &x);
|
||||
template <class T> int solveQuadratic (T a, T b, T c, T x[2]);
|
||||
template <class T> int solveNormalizedCubic (T r, T s, T t, T x[3]);
|
||||
template <class T> int solveCubic (T a, T b, T c, T d, T x[3]);
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
int
|
||||
solveLinear (T a, T b, T &x)
|
||||
{
|
||||
if (a != 0)
|
||||
{
|
||||
x = -b / a;
|
||||
return 1;
|
||||
}
|
||||
else if (b != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
int
|
||||
solveQuadratic (T a, T b, T c, T x[2])
|
||||
{
|
||||
if (a == 0)
|
||||
{
|
||||
return solveLinear (b, c, x[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
T D = b * b - 4 * a * c;
|
||||
|
||||
if (D > 0)
|
||||
{
|
||||
T s = sqrt (D);
|
||||
|
||||
x[0] = (-b + s) / (2 * a);
|
||||
x[1] = (-b - s) / (2 * a);
|
||||
return 2;
|
||||
}
|
||||
if (D == 0)
|
||||
{
|
||||
x[0] = -b / (2 * a);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
int
|
||||
solveNormalizedCubic (T r, T s, T t, T x[3])
|
||||
{
|
||||
T p = (3 * s - r * r) / 3;
|
||||
T q = 2 * r * r * r / 27 - r * s / 3 + t;
|
||||
T p3 = p / 3;
|
||||
T q2 = q / 2;
|
||||
T D = p3 * p3 * p3 + q2 * q2;
|
||||
|
||||
if (D == 0 && p3 == 0)
|
||||
{
|
||||
x[0] = -r / 3;
|
||||
x[1] = -r / 3;
|
||||
x[2] = -r / 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::complex<T> u = std::pow (-q / 2 + std::sqrt (std::complex<T> (D)),
|
||||
T (1) / T (3));
|
||||
|
||||
std::complex<T> v = -p / (T (3) * u);
|
||||
|
||||
const T sqrt3 = T (1.73205080756887729352744634150587); // enough digits
|
||||
// for long double
|
||||
std::complex<T> y0 (u + v);
|
||||
|
||||
std::complex<T> y1 (-(u + v) / T (2) +
|
||||
(u - v) / T (2) * std::complex<T> (0, sqrt3));
|
||||
|
||||
std::complex<T> y2 (-(u + v) / T (2) -
|
||||
(u - v) / T (2) * std::complex<T> (0, sqrt3));
|
||||
|
||||
if (D > 0)
|
||||
{
|
||||
x[0] = y0.real() - r / 3;
|
||||
return 1;
|
||||
}
|
||||
else if (D == 0)
|
||||
{
|
||||
x[0] = y0.real() - r / 3;
|
||||
x[1] = y1.real() - r / 3;
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
x[0] = y0.real() - r / 3;
|
||||
x[1] = y1.real() - r / 3;
|
||||
x[2] = y2.real() - r / 3;
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
int
|
||||
solveCubic (T a, T b, T c, T d, T x[3])
|
||||
{
|
||||
if (a == 0)
|
||||
{
|
||||
return solveQuadratic (b, c, d, x);
|
||||
}
|
||||
else
|
||||
{
|
||||
return solveNormalizedCubic (b / a, c / a, d / a, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
659
3rdparty/include/OpenEXR/ImathShear.h
vendored
659
3rdparty/include/OpenEXR/ImathShear.h
vendored
@ -1,659 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHSHEAR_H
|
||||
#define INCLUDED_IMATHSHEAR_H
|
||||
|
||||
//----------------------------------------------------
|
||||
//
|
||||
// Shear6 class template.
|
||||
//
|
||||
//----------------------------------------------------
|
||||
|
||||
#include "ImathExc.h"
|
||||
#include "ImathLimits.h"
|
||||
#include "ImathMath.h"
|
||||
#include "ImathVec.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
|
||||
|
||||
template <class T> class Shear6
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------
|
||||
// Access to elements
|
||||
//-------------------
|
||||
|
||||
T xy, xz, yz, yx, zx, zy;
|
||||
|
||||
T & operator [] (int i);
|
||||
const T & operator [] (int i) const;
|
||||
|
||||
|
||||
//-------------
|
||||
// Constructors
|
||||
//-------------
|
||||
|
||||
Shear6 (); // (0 0 0 0 0 0)
|
||||
Shear6 (T XY, T XZ, T YZ); // (XY XZ YZ 0 0 0)
|
||||
Shear6 (const Vec3<T> &v); // (v.x v.y v.z 0 0 0)
|
||||
template <class S> // (v.x v.y v.z 0 0 0)
|
||||
Shear6 (const Vec3<S> &v);
|
||||
Shear6 (T XY, T XZ, T YZ, // (XY XZ YZ YX ZX ZY)
|
||||
T YX, T ZX, T ZY);
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// Copy constructors and assignment
|
||||
//---------------------------------
|
||||
|
||||
Shear6 (const Shear6 &h);
|
||||
template <class S> Shear6 (const Shear6<S> &h);
|
||||
|
||||
const Shear6 & operator = (const Shear6 &h);
|
||||
template <class S>
|
||||
const Shear6 & operator = (const Vec3<S> &v);
|
||||
|
||||
|
||||
//----------------------
|
||||
// Compatibility with Sb
|
||||
//----------------------
|
||||
|
||||
template <class S>
|
||||
void setValue (S XY, S XZ, S YZ, S YX, S ZX, S ZY);
|
||||
|
||||
template <class S>
|
||||
void setValue (const Shear6<S> &h);
|
||||
|
||||
template <class S>
|
||||
void getValue (S &XY, S &XZ, S &YZ,
|
||||
S &YX, S &ZX, S &ZY) const;
|
||||
|
||||
template <class S>
|
||||
void getValue (Shear6<S> &h) const;
|
||||
|
||||
T * getValue();
|
||||
const T * getValue() const;
|
||||
|
||||
|
||||
//---------
|
||||
// Equality
|
||||
//---------
|
||||
|
||||
template <class S>
|
||||
bool operator == (const Shear6<S> &h) const;
|
||||
|
||||
template <class S>
|
||||
bool operator != (const Shear6<S> &h) const;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Compare two shears and test if they are "approximately equal":
|
||||
//
|
||||
// equalWithAbsError (h, e)
|
||||
//
|
||||
// Returns true if the coefficients of this and h are the same with
|
||||
// an absolute error of no more than e, i.e., for all i
|
||||
//
|
||||
// abs (this[i] - h[i]) <= e
|
||||
//
|
||||
// equalWithRelError (h, e)
|
||||
//
|
||||
// Returns true if the coefficients of this and h are the same with
|
||||
// a relative error of no more than e, i.e., for all i
|
||||
//
|
||||
// abs (this[i] - h[i]) <= e * abs (this[i])
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool equalWithAbsError (const Shear6<T> &h, T e) const;
|
||||
bool equalWithRelError (const Shear6<T> &h, T e) const;
|
||||
|
||||
|
||||
//------------------------
|
||||
// Component-wise addition
|
||||
//------------------------
|
||||
|
||||
const Shear6 & operator += (const Shear6 &h);
|
||||
Shear6 operator + (const Shear6 &h) const;
|
||||
|
||||
|
||||
//---------------------------
|
||||
// Component-wise subtraction
|
||||
//---------------------------
|
||||
|
||||
const Shear6 & operator -= (const Shear6 &h);
|
||||
Shear6 operator - (const Shear6 &h) const;
|
||||
|
||||
|
||||
//------------------------------------
|
||||
// Component-wise multiplication by -1
|
||||
//------------------------------------
|
||||
|
||||
Shear6 operator - () const;
|
||||
const Shear6 & negate ();
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Component-wise multiplication
|
||||
//------------------------------
|
||||
|
||||
const Shear6 & operator *= (const Shear6 &h);
|
||||
const Shear6 & operator *= (T a);
|
||||
Shear6 operator * (const Shear6 &h) const;
|
||||
Shear6 operator * (T a) const;
|
||||
|
||||
|
||||
//------------------------
|
||||
// Component-wise division
|
||||
//------------------------
|
||||
|
||||
const Shear6 & operator /= (const Shear6 &h);
|
||||
const Shear6 & operator /= (T a);
|
||||
Shear6 operator / (const Shear6 &h) const;
|
||||
Shear6 operator / (T a) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Number of dimensions, i.e. number of elements in a Shear6
|
||||
//----------------------------------------------------------
|
||||
|
||||
static unsigned int dimensions() {return 6;}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Limitations of type T (see also class limits<T>)
|
||||
//-------------------------------------------------
|
||||
|
||||
static T baseTypeMin() {return limits<T>::min();}
|
||||
static T baseTypeMax() {return limits<T>::max();}
|
||||
static T baseTypeSmallest() {return limits<T>::smallest();}
|
||||
static T baseTypeEpsilon() {return limits<T>::epsilon();}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Base type -- in templates, which accept a parameter, V, which
|
||||
// could be either a Vec2<T> or a Shear6<T>, you can refer to T as
|
||||
// V::BaseType
|
||||
//--------------------------------------------------------------
|
||||
|
||||
typedef T BaseType;
|
||||
};
|
||||
|
||||
|
||||
//--------------
|
||||
// Stream output
|
||||
//--------------
|
||||
|
||||
template <class T>
|
||||
std::ostream & operator << (std::ostream &s, const Shear6<T> &h);
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Reverse multiplication: scalar * Shear6<T>
|
||||
//----------------------------------------------------
|
||||
|
||||
template <class S, class T> Shear6<T> operator * (S a, const Shear6<T> &h);
|
||||
|
||||
|
||||
//-------------------------
|
||||
// Typedefs for convenience
|
||||
//-------------------------
|
||||
|
||||
typedef Vec3 <float> Shear3f;
|
||||
typedef Vec3 <double> Shear3d;
|
||||
typedef Shear6 <float> Shear6f;
|
||||
typedef Shear6 <double> Shear6d;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------
|
||||
// Implementation of Shear6
|
||||
//-----------------------
|
||||
|
||||
template <class T>
|
||||
inline T &
|
||||
Shear6<T>::operator [] (int i)
|
||||
{
|
||||
return (&xy)[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T &
|
||||
Shear6<T>::operator [] (int i) const
|
||||
{
|
||||
return (&xy)[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Shear6<T>::Shear6 ()
|
||||
{
|
||||
xy = xz = yz = yx = zx = zy = 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Shear6<T>::Shear6 (T XY, T XZ, T YZ)
|
||||
{
|
||||
xy = XY;
|
||||
xz = XZ;
|
||||
yz = YZ;
|
||||
yx = 0;
|
||||
zx = 0;
|
||||
zy = 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Shear6<T>::Shear6 (const Vec3<T> &v)
|
||||
{
|
||||
xy = v.x;
|
||||
xz = v.y;
|
||||
yz = v.z;
|
||||
yx = 0;
|
||||
zx = 0;
|
||||
zy = 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline
|
||||
Shear6<T>::Shear6 (const Vec3<S> &v)
|
||||
{
|
||||
xy = T (v.x);
|
||||
xz = T (v.y);
|
||||
yz = T (v.z);
|
||||
yx = 0;
|
||||
zx = 0;
|
||||
zy = 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Shear6<T>::Shear6 (T XY, T XZ, T YZ, T YX, T ZX, T ZY)
|
||||
{
|
||||
xy = XY;
|
||||
xz = XZ;
|
||||
yz = YZ;
|
||||
yx = YX;
|
||||
zx = ZX;
|
||||
zy = ZY;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Shear6<T>::Shear6 (const Shear6 &h)
|
||||
{
|
||||
xy = h.xy;
|
||||
xz = h.xz;
|
||||
yz = h.yz;
|
||||
yx = h.yx;
|
||||
zx = h.zx;
|
||||
zy = h.zy;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline
|
||||
Shear6<T>::Shear6 (const Shear6<S> &h)
|
||||
{
|
||||
xy = T (h.xy);
|
||||
xz = T (h.xz);
|
||||
yz = T (h.yz);
|
||||
yx = T (h.yx);
|
||||
zx = T (h.zx);
|
||||
zy = T (h.zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator = (const Shear6 &h)
|
||||
{
|
||||
xy = h.xy;
|
||||
xz = h.xz;
|
||||
yz = h.yz;
|
||||
yx = h.yx;
|
||||
zx = h.zx;
|
||||
zy = h.zy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator = (const Vec3<S> &v)
|
||||
{
|
||||
xy = T (v.x);
|
||||
xz = T (v.y);
|
||||
yz = T (v.z);
|
||||
yx = 0;
|
||||
zx = 0;
|
||||
zy = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Shear6<T>::setValue (S XY, S XZ, S YZ, S YX, S ZX, S ZY)
|
||||
{
|
||||
xy = T (XY);
|
||||
xz = T (XZ);
|
||||
yz = T (YZ);
|
||||
yx = T (YX);
|
||||
zx = T (ZX);
|
||||
zy = T (ZY);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Shear6<T>::setValue (const Shear6<S> &h)
|
||||
{
|
||||
xy = T (h.xy);
|
||||
xz = T (h.xz);
|
||||
yz = T (h.yz);
|
||||
yx = T (h.yx);
|
||||
zx = T (h.zx);
|
||||
zy = T (h.zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Shear6<T>::getValue (S &XY, S &XZ, S &YZ, S &YX, S &ZX, S &ZY) const
|
||||
{
|
||||
XY = S (xy);
|
||||
XZ = S (xz);
|
||||
YZ = S (yz);
|
||||
YX = S (yx);
|
||||
ZX = S (zx);
|
||||
ZY = S (zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline void
|
||||
Shear6<T>::getValue (Shear6<S> &h) const
|
||||
{
|
||||
h.xy = S (xy);
|
||||
h.xz = S (xz);
|
||||
h.yz = S (yz);
|
||||
h.yx = S (yx);
|
||||
h.zx = S (zx);
|
||||
h.zy = S (zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T *
|
||||
Shear6<T>::getValue()
|
||||
{
|
||||
return (T *) &xy;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T *
|
||||
Shear6<T>::getValue() const
|
||||
{
|
||||
return (const T *) &xy;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline bool
|
||||
Shear6<T>::operator == (const Shear6<S> &h) const
|
||||
{
|
||||
return xy == h.xy && xz == h.xz && yz == h.yz &&
|
||||
yx == h.yx && zx == h.zx && zy == h.zy;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template <class S>
|
||||
inline bool
|
||||
Shear6<T>::operator != (const Shear6<S> &h) const
|
||||
{
|
||||
return xy != h.xy || xz != h.xz || yz != h.yz ||
|
||||
yx != h.yx || zx != h.zx || zy != h.zy;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
Shear6<T>::equalWithAbsError (const Shear6<T> &h, T e) const
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
if (!Imath::equalWithAbsError ((*this)[i], h[i], e))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
Shear6<T>::equalWithRelError (const Shear6<T> &h, T e) const
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
if (!Imath::equalWithRelError ((*this)[i], h[i], e))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator += (const Shear6 &h)
|
||||
{
|
||||
xy += h.xy;
|
||||
xz += h.xz;
|
||||
yz += h.yz;
|
||||
yx += h.yx;
|
||||
zx += h.zx;
|
||||
zy += h.zy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Shear6<T>
|
||||
Shear6<T>::operator + (const Shear6 &h) const
|
||||
{
|
||||
return Shear6 (xy + h.xy, xz + h.xz, yz + h.yz,
|
||||
yx + h.yx, zx + h.zx, zy + h.zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator -= (const Shear6 &h)
|
||||
{
|
||||
xy -= h.xy;
|
||||
xz -= h.xz;
|
||||
yz -= h.yz;
|
||||
yx -= h.yx;
|
||||
zx -= h.zx;
|
||||
zy -= h.zy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Shear6<T>
|
||||
Shear6<T>::operator - (const Shear6 &h) const
|
||||
{
|
||||
return Shear6 (xy - h.xy, xz - h.xz, yz - h.yz,
|
||||
yx - h.yx, zx - h.zx, zy - h.zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Shear6<T>
|
||||
Shear6<T>::operator - () const
|
||||
{
|
||||
return Shear6 (-xy, -xz, -yz, -yx, -zx, -zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::negate ()
|
||||
{
|
||||
xy = -xy;
|
||||
xz = -xz;
|
||||
yz = -yz;
|
||||
yx = -yx;
|
||||
zx = -zx;
|
||||
zy = -zy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator *= (const Shear6 &h)
|
||||
{
|
||||
xy *= h.xy;
|
||||
xz *= h.xz;
|
||||
yz *= h.yz;
|
||||
yx *= h.yx;
|
||||
zx *= h.zx;
|
||||
zy *= h.zy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator *= (T a)
|
||||
{
|
||||
xy *= a;
|
||||
xz *= a;
|
||||
yz *= a;
|
||||
yx *= a;
|
||||
zx *= a;
|
||||
zy *= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Shear6<T>
|
||||
Shear6<T>::operator * (const Shear6 &h) const
|
||||
{
|
||||
return Shear6 (xy * h.xy, xz * h.xz, yz * h.yz,
|
||||
yx * h.yx, zx * h.zx, zy * h.zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Shear6<T>
|
||||
Shear6<T>::operator * (T a) const
|
||||
{
|
||||
return Shear6 (xy * a, xz * a, yz * a,
|
||||
yx * a, zx * a, zy * a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator /= (const Shear6 &h)
|
||||
{
|
||||
xy /= h.xy;
|
||||
xz /= h.xz;
|
||||
yz /= h.yz;
|
||||
yx /= h.yx;
|
||||
zx /= h.zx;
|
||||
zy /= h.zy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const Shear6<T> &
|
||||
Shear6<T>::operator /= (T a)
|
||||
{
|
||||
xy /= a;
|
||||
xz /= a;
|
||||
yz /= a;
|
||||
yx /= a;
|
||||
zx /= a;
|
||||
zy /= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Shear6<T>
|
||||
Shear6<T>::operator / (const Shear6 &h) const
|
||||
{
|
||||
return Shear6 (xy / h.xy, xz / h.xz, yz / h.yz,
|
||||
yx / h.yx, zx / h.zx, zy / h.zy);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Shear6<T>
|
||||
Shear6<T>::operator / (T a) const
|
||||
{
|
||||
return Shear6 (xy / a, xz / a, yz / a,
|
||||
yx / a, zx / a, zy / a);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------
|
||||
// Stream output implementation
|
||||
//-----------------------------
|
||||
|
||||
template <class T>
|
||||
std::ostream &
|
||||
operator << (std::ostream &s, const Shear6<T> &h)
|
||||
{
|
||||
return s << '('
|
||||
<< h.xy << ' ' << h.xz << ' ' << h.yz
|
||||
<< h.yx << ' ' << h.zx << ' ' << h.zy
|
||||
<< ')';
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Implementation of reverse multiplication
|
||||
//-----------------------------------------
|
||||
|
||||
template <class S, class T>
|
||||
inline Shear6<T>
|
||||
operator * (S a, const Shear6<T> &h)
|
||||
{
|
||||
return Shear6<T> (a * h.xy, a * h.xz, a * h.yz,
|
||||
a * h.yx, a * h.zx, a * h.zy);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
177
3rdparty/include/OpenEXR/ImathSphere.h
vendored
177
3rdparty/include/OpenEXR/ImathSphere.h
vendored
@ -1,177 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHSPHERE_H
|
||||
#define INCLUDED_IMATHSPHERE_H
|
||||
|
||||
//-------------------------------------
|
||||
//
|
||||
// A 3D sphere class template
|
||||
//
|
||||
//-------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathBox.h"
|
||||
#include "ImathLine.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
template <class T>
|
||||
class Sphere3
|
||||
{
|
||||
public:
|
||||
|
||||
Vec3<T> center;
|
||||
T radius;
|
||||
|
||||
//---------------
|
||||
// Constructors
|
||||
//---------------
|
||||
|
||||
Sphere3() : center(0,0,0), radius(0) {}
|
||||
Sphere3(const Vec3<T> &c, T r) : center(c), radius(r) {}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities:
|
||||
//
|
||||
// s.circumscribe(b) sets center and radius of sphere s
|
||||
// so that the s tightly encloses box b.
|
||||
//
|
||||
// s.intersectT (l, t) If sphere s and line l intersect, then
|
||||
// intersectT() computes the smallest t,
|
||||
// t >= 0, so that l(t) is a point on the
|
||||
// sphere. intersectT() then returns true.
|
||||
//
|
||||
// If s and l do not intersect, intersectT()
|
||||
// returns false.
|
||||
//
|
||||
// s.intersect (l, i) If sphere s and line l intersect, then
|
||||
// intersect() calls s.intersectT(l,t) and
|
||||
// computes i = l(t).
|
||||
//
|
||||
// If s and l do not intersect, intersect()
|
||||
// returns false.
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void circumscribe(const Box<Vec3<T> > &box);
|
||||
bool intersect(const Line3<T> &l, Vec3<T> &intersection) const;
|
||||
bool intersectT(const Line3<T> &l, T &t) const;
|
||||
};
|
||||
|
||||
|
||||
//--------------------
|
||||
// Convenient typedefs
|
||||
//--------------------
|
||||
|
||||
typedef Sphere3<float> Sphere3f;
|
||||
typedef Sphere3<double> Sphere3d;
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
void Sphere3<T>::circumscribe(const Box<Vec3<T> > &box)
|
||||
{
|
||||
center = T(0.5) * (box.min + box.max);
|
||||
radius = (box.max - center).length();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
bool Sphere3<T>::intersectT(const Line3<T> &line, T &t) const
|
||||
{
|
||||
bool doesIntersect = true;
|
||||
|
||||
Vec3<T> v = line.pos - center;
|
||||
T B = 2.0 * (line.dir ^ v);
|
||||
T C = (v ^ v) - (radius * radius);
|
||||
|
||||
// compute discriminant
|
||||
// if negative, there is no intersection
|
||||
|
||||
T discr = B*B - 4.0*C;
|
||||
|
||||
if (discr < 0.0)
|
||||
{
|
||||
// line and Sphere3 do not intersect
|
||||
|
||||
doesIntersect = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// t0: (-B - sqrt(B^2 - 4AC)) / 2A (A = 1)
|
||||
|
||||
T sqroot = Math<T>::sqrt(discr);
|
||||
t = (-B - sqroot) * 0.5;
|
||||
|
||||
if (t < 0.0)
|
||||
{
|
||||
// no intersection, try t1: (-B + sqrt(B^2 - 4AC)) / 2A (A = 1)
|
||||
|
||||
t = (-B + sqroot) * 0.5;
|
||||
}
|
||||
|
||||
if (t < 0.0)
|
||||
doesIntersect = false;
|
||||
}
|
||||
|
||||
return doesIntersect;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
bool Sphere3<T>::intersect(const Line3<T> &line, Vec3<T> &intersection) const
|
||||
{
|
||||
T t;
|
||||
|
||||
if (intersectT (line, t))
|
||||
{
|
||||
intersection = line(t);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} //namespace Imath
|
||||
|
||||
#endif
|
1426
3rdparty/include/OpenEXR/ImathVec.h
vendored
1426
3rdparty/include/OpenEXR/ImathVec.h
vendored
File diff suppressed because it is too large
Load Diff
146
3rdparty/include/OpenEXR/ImathVecAlgo.h
vendored
146
3rdparty/include/OpenEXR/ImathVecAlgo.h
vendored
@ -1,146 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMATHVECALGO_H
|
||||
#define INCLUDED_IMATHVECALGO_H
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// This file contains algorithms applied to or in conjunction
|
||||
// with points (Imath::Vec2 and Imath::Vec3).
|
||||
// The assumption made is that these functions are called much
|
||||
// less often than the basic point functions or these functions
|
||||
// require more support classes.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathLimits.h"
|
||||
|
||||
namespace Imath {
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Find the projection of vector t onto vector s (Vec2 and Vec3)
|
||||
//--------------------------------------------------------------
|
||||
|
||||
template <class Vec> Vec project (const Vec &s, const Vec &t);
|
||||
|
||||
|
||||
//----------------------------------------------
|
||||
// Find a vector which is perpendicular to s and
|
||||
// in the same plane as s and t (Vec2 and Vec3)
|
||||
//----------------------------------------------
|
||||
|
||||
template <class Vec> Vec orthogonal (const Vec &s, const Vec &t);
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Find the direction of a ray s after reflection
|
||||
// off a plane with normal t (Vec2 and Vec3)
|
||||
//-----------------------------------------------
|
||||
|
||||
template <class Vec> Vec reflect (const Vec &s, const Vec &t);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Find the vertex of triangle (v0, v1, v2), which is closest to point p
|
||||
// (Vec2 and Vec3).
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
template <class Vec> Vec closestVertex (const Vec &v0,
|
||||
const Vec &v1,
|
||||
const Vec &v2,
|
||||
const Vec &p);
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class Vec>
|
||||
Vec
|
||||
project (const Vec &s, const Vec &t)
|
||||
{
|
||||
Vec sNormalized = s.normalized();
|
||||
return sNormalized * (sNormalized ^ t);
|
||||
}
|
||||
|
||||
template <class Vec>
|
||||
Vec
|
||||
orthogonal (const Vec &s, const Vec &t)
|
||||
{
|
||||
return t - project (s, t);
|
||||
}
|
||||
|
||||
template <class Vec>
|
||||
Vec
|
||||
reflect (const Vec &s, const Vec &t)
|
||||
{
|
||||
return s - typename Vec::BaseType(2) * (s - project(t, s));
|
||||
}
|
||||
|
||||
template <class Vec>
|
||||
Vec
|
||||
closestVertex(const Vec &v0,
|
||||
const Vec &v1,
|
||||
const Vec &v2,
|
||||
const Vec &p)
|
||||
{
|
||||
Vec nearest = v0;
|
||||
typename Vec::BaseType neardot = (v0 - p).length2();
|
||||
typename Vec::BaseType tmp = (v1 - p).length2();
|
||||
|
||||
if (tmp < neardot)
|
||||
{
|
||||
neardot = tmp;
|
||||
nearest = v1;
|
||||
}
|
||||
|
||||
tmp = (v2 - p).length2();
|
||||
|
||||
if (tmp < neardot)
|
||||
{
|
||||
neardot = tmp;
|
||||
nearest = v2;
|
||||
}
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imath
|
||||
|
||||
#endif
|
261
3rdparty/include/OpenEXR/ImfArray.h
vendored
261
3rdparty/include/OpenEXR/ImfArray.h
vendored
@ -1,261 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_ARRAY_H
|
||||
#define INCLUDED_IMF_ARRAY_H
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// class Array
|
||||
// class Array2D
|
||||
//
|
||||
// "Arrays of T" whose sizes are not known at compile time.
|
||||
// When an array goes out of scope, its elements are automatically
|
||||
// deleted.
|
||||
//
|
||||
// Usage example:
|
||||
//
|
||||
// struct C
|
||||
// {
|
||||
// C () {std::cout << "C::C (" << this << ")\n";};
|
||||
// virtual ~C () {std::cout << "C::~C (" << this << ")\n";};
|
||||
// };
|
||||
//
|
||||
// int
|
||||
// main ()
|
||||
// {
|
||||
// Array <C> a(3);
|
||||
//
|
||||
// C &b = a[1];
|
||||
// const C &c = a[1];
|
||||
// C *d = a + 2;
|
||||
// const C *e = a;
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Array
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------
|
||||
// Constructors and destructors
|
||||
//-----------------------------
|
||||
|
||||
Array () {_data = 0;}
|
||||
Array (long size) {_data = new T[size];}
|
||||
~Array () {delete [] _data;}
|
||||
|
||||
|
||||
//-----------------------------
|
||||
// Access to the array elements
|
||||
//-----------------------------
|
||||
|
||||
operator T * () {return _data;}
|
||||
operator const T * () const {return _data;}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Resize and clear the array (the contents of the array
|
||||
// are not preserved across the resize operation).
|
||||
//
|
||||
// resizeEraseUnsafe() is more memory efficient than
|
||||
// resizeErase() because it deletes the old memory block
|
||||
// before allocating a new one, but if allocating the
|
||||
// new block throws an exception, resizeEraseUnsafe()
|
||||
// leaves the array in an unusable state.
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
void resizeErase (long size);
|
||||
void resizeEraseUnsafe (long size);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array (const Array &); // Copying and assignment
|
||||
Array & operator = (const Array &); // are not implemented
|
||||
|
||||
T * _data;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class Array2D
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------
|
||||
// Constructors and destructors
|
||||
//-----------------------------
|
||||
|
||||
Array2D (); // empty array, 0 by 0 elements
|
||||
Array2D (long sizeX, long sizeY); // sizeX by sizeY elements
|
||||
~Array2D ();
|
||||
|
||||
|
||||
//-----------------------------
|
||||
// Access to the array elements
|
||||
//-----------------------------
|
||||
|
||||
T * operator [] (long x);
|
||||
const T * operator [] (long x) const;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Resize and clear the array (the contents of the array
|
||||
// are not preserved across the resize operation).
|
||||
//
|
||||
// resizeEraseUnsafe() is more memory efficient than
|
||||
// resizeErase() because it deletes the old memory block
|
||||
// before allocating a new one, but if allocating the
|
||||
// new block throws an exception, resizeEraseUnsafe()
|
||||
// leaves the array in an unusable state.
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
void resizeErase (long sizeX, long sizeY);
|
||||
void resizeEraseUnsafe (long sizeX, long sizeY);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array2D (const Array2D &); // Copying and assignment
|
||||
Array2D & operator = (const Array2D &); // are not implemented
|
||||
|
||||
long _sizeY;
|
||||
T * _data;
|
||||
};
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array<T>::resizeErase (long size)
|
||||
{
|
||||
T *tmp = new T[size];
|
||||
delete [] _data;
|
||||
_data = tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array<T>::resizeEraseUnsafe (long size)
|
||||
{
|
||||
delete [] _data;
|
||||
_data = 0;
|
||||
_data = new T[size];
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::Array2D ():
|
||||
_sizeY (0), _data (0)
|
||||
{
|
||||
// emtpy
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::Array2D (long sizeX, long sizeY):
|
||||
_sizeY (sizeY), _data (new T[sizeX * sizeY])
|
||||
{
|
||||
// emtpy
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::~Array2D ()
|
||||
{
|
||||
delete [] _data;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T *
|
||||
Array2D<T>::operator [] (long x)
|
||||
{
|
||||
return _data + x * _sizeY;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const T *
|
||||
Array2D<T>::operator [] (long x) const
|
||||
{
|
||||
return _data + x * _sizeY;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array2D<T>::resizeErase (long sizeX, long sizeY)
|
||||
{
|
||||
T *tmp = new T[sizeX * sizeY];
|
||||
delete [] _data;
|
||||
_sizeY = sizeY;
|
||||
_data = tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array2D<T>::resizeEraseUnsafe (long sizeX, long sizeY)
|
||||
{
|
||||
delete [] _data;
|
||||
_data = 0;
|
||||
_sizeY = 0;
|
||||
_data = new T[sizeX * sizeY];
|
||||
_sizeY = sizeY;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
422
3rdparty/include/OpenEXR/ImfAttribute.h
vendored
422
3rdparty/include/OpenEXR/ImfAttribute.h
vendored
@ -1,422 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Attribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
#include <ImfIO.h>
|
||||
#include <ImfXdr.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
//---------------------------
|
||||
// Constructor and destructor
|
||||
//---------------------------
|
||||
|
||||
Attribute ();
|
||||
virtual ~Attribute ();
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Get this attribute's type name
|
||||
//-------------------------------
|
||||
|
||||
virtual const char * typeName () const = 0;
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Make a copy of this attribute
|
||||
//------------------------------
|
||||
|
||||
virtual Attribute * copy () const = 0;
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Type-specific attribute I/O and copying
|
||||
//----------------------------------------
|
||||
|
||||
virtual void writeValueTo (OStream &os,
|
||||
int version) const = 0;
|
||||
|
||||
virtual void readValueFrom (IStream &is,
|
||||
int size,
|
||||
int version) = 0;
|
||||
|
||||
virtual void copyValueFrom (const Attribute &other) = 0;
|
||||
|
||||
|
||||
//------------------
|
||||
// Attribute factory
|
||||
//------------------
|
||||
|
||||
static Attribute * newAttribute (const char typeName[]);
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Test if a given attribute type has already been registered
|
||||
//-----------------------------------------------------------
|
||||
|
||||
static bool knownType (const char typeName[]);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------
|
||||
// Register an attribute type so that newAttribute()
|
||||
// knows how to make objects of this type.
|
||||
//--------------------------------------------------
|
||||
|
||||
static void registerAttributeType (const char typeName[],
|
||||
Attribute *(*newAttribute)());
|
||||
|
||||
//------------------------------------------------------
|
||||
// Un-register an attribute type so that newAttribute()
|
||||
// no longer knows how to make objects of this type (for
|
||||
// debugging only).
|
||||
//------------------------------------------------------
|
||||
|
||||
static void unRegisterAttributeType (const char typeName[]);
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Class template for attributes of a specific type
|
||||
//-------------------------------------------------
|
||||
|
||||
template <class T>
|
||||
class TypedAttribute: public Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------
|
||||
// Constructors and destructor
|
||||
//------------_---------------
|
||||
|
||||
TypedAttribute ();
|
||||
TypedAttribute (const T &value);
|
||||
TypedAttribute (const TypedAttribute<T> &other);
|
||||
virtual ~TypedAttribute ();
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Access to the attribute's value
|
||||
//--------------------------------
|
||||
|
||||
T & value ();
|
||||
const T & value () const;
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Get this attribute's type name.
|
||||
//--------------------------------
|
||||
|
||||
virtual const char * typeName () const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Static version of typeName()
|
||||
// This function must be specialized for each value type T.
|
||||
//---------------------------------------------------------
|
||||
|
||||
static const char * staticTypeName ();
|
||||
|
||||
|
||||
//---------------------
|
||||
// Make a new attribute
|
||||
//---------------------
|
||||
|
||||
static Attribute * makeNewAttribute ();
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Make a copy of this attribute
|
||||
//------------------------------
|
||||
|
||||
virtual Attribute * copy () const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Type-specific attribute I/O and copying.
|
||||
// Depending on type T, these functions may have to be specialized.
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
virtual void writeValueTo (OStream &os,
|
||||
int version) const;
|
||||
|
||||
virtual void readValueFrom (IStream &is,
|
||||
int size,
|
||||
int version);
|
||||
|
||||
virtual void copyValueFrom (const Attribute &other);
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Dynamic casts that throw exceptions instead of returning 0.
|
||||
//------------------------------------------------------------
|
||||
|
||||
static TypedAttribute * cast (Attribute *attribute);
|
||||
static const TypedAttribute * cast (const Attribute *attribute);
|
||||
static TypedAttribute & cast (Attribute &attribute);
|
||||
static const TypedAttribute & cast (const Attribute &attribute);
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Register this attribute type so that Attribute::newAttribute()
|
||||
// knows how to make objects of this type.
|
||||
//
|
||||
// Note that this function is not thread-safe because it modifies
|
||||
// a global variable in the IlmIlm library. A thread in a multi-
|
||||
// threaded program may call registerAttributeType() only when no
|
||||
// other thread is accessing any functions or classes in the
|
||||
// IlmImf library.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
static void registerAttributeType ();
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Un-register this attribute type (for debugging only)
|
||||
//-----------------------------------------------------
|
||||
|
||||
static void unRegisterAttributeType ();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
T _value;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------
|
||||
// Implementation of TypedAttribute<T>
|
||||
//------------------------------------
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::TypedAttribute (): _value (T())
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::TypedAttribute (const T &value): _value (value)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::TypedAttribute (const TypedAttribute<T> &other):
|
||||
_value ()
|
||||
{
|
||||
copyValueFrom (other);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::~TypedAttribute ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T &
|
||||
TypedAttribute<T>::value ()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const T &
|
||||
TypedAttribute<T>::value () const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const char *
|
||||
TypedAttribute<T>::typeName () const
|
||||
{
|
||||
return staticTypeName();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Attribute *
|
||||
TypedAttribute<T>::makeNewAttribute ()
|
||||
{
|
||||
return new TypedAttribute<T>();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Attribute *
|
||||
TypedAttribute<T>::copy () const
|
||||
{
|
||||
Attribute * attribute = new TypedAttribute<T>();
|
||||
attribute->copyValueFrom (*this);
|
||||
return attribute;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedAttribute<T>::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedAttribute<T>::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedAttribute<T>::copyValueFrom (const Attribute &other)
|
||||
{
|
||||
_value = cast(other)._value;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T> *
|
||||
TypedAttribute<T>::cast (Attribute *attribute)
|
||||
{
|
||||
TypedAttribute<T> *t =
|
||||
dynamic_cast <TypedAttribute<T> *> (attribute);
|
||||
|
||||
if (t == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const TypedAttribute<T> *
|
||||
TypedAttribute<T>::cast (const Attribute *attribute)
|
||||
{
|
||||
const TypedAttribute<T> *t =
|
||||
dynamic_cast <const TypedAttribute<T> *> (attribute);
|
||||
|
||||
if (t == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline TypedAttribute<T> &
|
||||
TypedAttribute<T>::cast (Attribute &attribute)
|
||||
{
|
||||
return *cast (&attribute);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const TypedAttribute<T> &
|
||||
TypedAttribute<T>::cast (const Attribute &attribute)
|
||||
{
|
||||
return *cast (&attribute);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
TypedAttribute<T>::registerAttributeType ()
|
||||
{
|
||||
Attribute::registerAttributeType (staticTypeName(), makeNewAttribute);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
TypedAttribute<T>::unRegisterAttributeType ()
|
||||
{
|
||||
Attribute::unRegisterAttributeType (staticTypeName());
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#if defined(OPENEXR_DLL) && defined(_MSC_VER)
|
||||
// Tell MS VC++ to disable "non dll-interface class used as base
|
||||
// for dll-interface class" and "no suitable definition provided
|
||||
// for explicit template"
|
||||
#pragma warning (disable : 4275 4661)
|
||||
|
||||
#if defined (ILMIMF_EXPORTS)
|
||||
#define IMF_EXPIMP_TEMPLATE
|
||||
#else
|
||||
#define IMF_EXPIMP_TEMPLATE extern
|
||||
#endif
|
||||
|
||||
IMF_EXPIMP_TEMPLATE template class Imf::TypedAttribute<float>;
|
||||
IMF_EXPIMP_TEMPLATE template class Imf::TypedAttribute<double>;
|
||||
|
||||
#pragma warning(default : 4251)
|
||||
#undef EXTERN_TEMPLATE
|
||||
#endif
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
73
3rdparty/include/OpenEXR/ImfBoxAttribute.h
vendored
73
3rdparty/include/OpenEXR/ImfBoxAttribute.h
vendored
@ -1,73 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_BOX_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_BOX_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Box2iAttribute
|
||||
// class Box2fAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include "ImathBox.h"
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::Box2i> Box2iAttribute;
|
||||
template <> const char *Box2iAttribute::staticTypeName ();
|
||||
template <> void Box2iAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void Box2iAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::Box2f> Box2fAttribute;
|
||||
template <> const char *Box2fAttribute::staticTypeName ();
|
||||
template <> void Box2fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void Box2fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfBoxAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
465
3rdparty/include/OpenEXR/ImfCRgbaFile.h
vendored
465
3rdparty/include/OpenEXR/ImfCRgbaFile.h
vendored
@ -1,465 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
Digital Ltd. LLC
|
||||
|
||||
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 Industrial Light & Magic nor the names of
|
||||
its contributors 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 INCLUDED_IMF_C_RGBA_FILE_H
|
||||
#define INCLUDED_IMF_C_RGBA_FILE_H
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Interpreting unsigned shorts as 16-bit floating point numbers
|
||||
*/
|
||||
|
||||
typedef unsigned short ImfHalf;
|
||||
|
||||
void ImfFloatToHalf (float f,
|
||||
ImfHalf *h);
|
||||
|
||||
void ImfFloatToHalfArray (int n,
|
||||
const float f[/*n*/],
|
||||
ImfHalf h[/*n*/]);
|
||||
|
||||
float ImfHalfToFloat (ImfHalf h);
|
||||
|
||||
void ImfHalfToFloatArray (int n,
|
||||
const ImfHalf h[/*n*/],
|
||||
float f[/*n*/]);
|
||||
|
||||
/*
|
||||
** RGBA pixel; memory layout must be the same as struct Imf::Rgba.
|
||||
*/
|
||||
|
||||
struct ImfRgba
|
||||
{
|
||||
ImfHalf r;
|
||||
ImfHalf g;
|
||||
ImfHalf b;
|
||||
ImfHalf a;
|
||||
};
|
||||
|
||||
typedef struct ImfRgba ImfRgba;
|
||||
|
||||
/*
|
||||
** Magic number; this must be the same as Imf::MAGIC
|
||||
*/
|
||||
|
||||
#define IMF_MAGIC 20000630
|
||||
|
||||
/*
|
||||
** Version number; this must be the same as Imf::EXR_VERSION
|
||||
*/
|
||||
|
||||
#define IMF_VERSION_NUMBER 2
|
||||
|
||||
/*
|
||||
** Line order; values must the the same as in Imf::LineOrder.
|
||||
*/
|
||||
|
||||
#define IMF_INCREASING_Y 0
|
||||
#define IMF_DECREASING_Y 1
|
||||
#define IMF_RAMDOM_Y 2
|
||||
|
||||
|
||||
/*
|
||||
** Compression types; values must be the same as in Imf::Compression.
|
||||
*/
|
||||
|
||||
#define IMF_NO_COMPRESSION 0
|
||||
#define IMF_RLE_COMPRESSION 1
|
||||
#define IMF_ZIPS_COMPRESSION 2
|
||||
#define IMF_ZIP_COMPRESSION 3
|
||||
#define IMF_PIZ_COMPRESSION 4
|
||||
#define IMF_PXR24_COMPRESSION 5
|
||||
|
||||
|
||||
/*
|
||||
** Channels; values must be the same as in Imf::RgbaChannels.
|
||||
*/
|
||||
|
||||
#define IMF_WRITE_R 0x01
|
||||
#define IMF_WRITE_G 0x02
|
||||
#define IMF_WRITE_B 0x04
|
||||
#define IMF_WRITE_A 0x08
|
||||
#define IMF_WRITE_Y 0x10
|
||||
#define IMF_WRITE_C 0x20
|
||||
#define IMF_WRITE_RGB 0x07
|
||||
#define IMF_WRITE_RGBA 0x0f
|
||||
#define IMF_WRITE_YC 0x30
|
||||
#define IMF_WRITE_YA 0x18
|
||||
#define IMF_WRITE_YCA 0x38
|
||||
|
||||
|
||||
/*
|
||||
** Level modes; values must be the same as in Imf::LevelMode
|
||||
*/
|
||||
|
||||
#define IMF_ONE_LEVEL 0
|
||||
#define IMF_MIPMAP_LEVELS 1
|
||||
#define IMF_RIPMAP_LEVELS 2
|
||||
|
||||
|
||||
/*
|
||||
** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
|
||||
*/
|
||||
|
||||
#define IMF_ROUND_DOWN 0
|
||||
#define IMF_ROUND_UP 1
|
||||
|
||||
|
||||
/*
|
||||
** RGBA file header
|
||||
*/
|
||||
|
||||
struct ImfHeader;
|
||||
typedef struct ImfHeader ImfHeader;
|
||||
|
||||
ImfHeader * ImfNewHeader (void);
|
||||
|
||||
void ImfDeleteHeader (ImfHeader *hdr);
|
||||
|
||||
ImfHeader * ImfCopyHeader (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetDisplayWindow (ImfHeader *hdr,
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
void ImfHeaderDisplayWindow (const ImfHeader *hdr,
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
void ImfHeaderSetDataWindow (ImfHeader *hdr,
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
void ImfHeaderDataWindow (const ImfHeader *hdr,
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
|
||||
float pixelAspectRatio);
|
||||
|
||||
float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
|
||||
float x, float y);
|
||||
|
||||
void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
|
||||
float *x, float *y);
|
||||
|
||||
void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
|
||||
float width);
|
||||
|
||||
float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetLineOrder (ImfHeader *hdr,
|
||||
int lineOrder);
|
||||
|
||||
int ImfHeaderLineOrder (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetCompression (ImfHeader *hdr,
|
||||
int compression);
|
||||
|
||||
int ImfHeaderCompression (const ImfHeader *hdr);
|
||||
|
||||
int ImfHeaderSetIntAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int value);
|
||||
|
||||
int ImfHeaderIntAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *value);
|
||||
|
||||
int ImfHeaderSetFloatAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float value);
|
||||
|
||||
int ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
double value);
|
||||
|
||||
int ImfHeaderFloatAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *value);
|
||||
|
||||
int ImfHeaderDoubleAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
double *value);
|
||||
|
||||
int ImfHeaderSetStringAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const char value[]);
|
||||
|
||||
int ImfHeaderStringAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
const char **value);
|
||||
|
||||
int ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
int ImfHeaderBox2iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
int ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float xMin, float yMin,
|
||||
float xMax, float yMax);
|
||||
|
||||
int ImfHeaderBox2fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *xMin, float *yMin,
|
||||
float *xMax, float *yMax);
|
||||
|
||||
int ImfHeaderSetV2iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int x, int y);
|
||||
|
||||
int ImfHeaderV2iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *x, int *y);
|
||||
|
||||
int ImfHeaderSetV2fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float x, float y);
|
||||
|
||||
int ImfHeaderV2fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *x, float *y);
|
||||
|
||||
int ImfHeaderSetV3iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int x, int y, int z);
|
||||
|
||||
int ImfHeaderV3iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *x, int *y, int *z);
|
||||
|
||||
int ImfHeaderSetV3fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float x, float y, float z);
|
||||
|
||||
int ImfHeaderV3fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *x, float *y, float *z);
|
||||
|
||||
int ImfHeaderSetM33fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const float m[3][3]);
|
||||
|
||||
int ImfHeaderM33fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float m[3][3]);
|
||||
|
||||
int ImfHeaderSetM44fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const float m[4][4]);
|
||||
|
||||
int ImfHeaderM44fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float m[4][4]);
|
||||
|
||||
/*
|
||||
** RGBA output file
|
||||
*/
|
||||
|
||||
struct ImfOutputFile;
|
||||
typedef struct ImfOutputFile ImfOutputFile;
|
||||
|
||||
ImfOutputFile * ImfOpenOutputFile (const char name[],
|
||||
const ImfHeader *hdr,
|
||||
int channels);
|
||||
|
||||
int ImfCloseOutputFile (ImfOutputFile *out);
|
||||
|
||||
int ImfOutputSetFrameBuffer (ImfOutputFile *out,
|
||||
const ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfOutputWritePixels (ImfOutputFile *out,
|
||||
int numScanLines);
|
||||
|
||||
int ImfOutputCurrentScanLine (const ImfOutputFile *out);
|
||||
|
||||
const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);
|
||||
|
||||
int ImfOutputChannels (const ImfOutputFile *out);
|
||||
|
||||
|
||||
/*
|
||||
** Tiled RGBA output file
|
||||
*/
|
||||
|
||||
struct ImfTiledOutputFile;
|
||||
typedef struct ImfTiledOutputFile ImfTiledOutputFile;
|
||||
|
||||
ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[],
|
||||
const ImfHeader *hdr,
|
||||
int channels,
|
||||
int xSize, int ySize,
|
||||
int mode, int rmode);
|
||||
|
||||
int ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
|
||||
const ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
|
||||
int dx, int dy,
|
||||
int lx, int ly);
|
||||
|
||||
int ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,
|
||||
int dxMin, int dxMax,
|
||||
int dyMin, int dyMax,
|
||||
int lx, int ly);
|
||||
|
||||
const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputChannels (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
|
||||
int ImfTiledOutputLevelRoundingMode
|
||||
(const ImfTiledOutputFile *out);
|
||||
|
||||
|
||||
/*
|
||||
** RGBA input file
|
||||
*/
|
||||
|
||||
struct ImfInputFile;
|
||||
typedef struct ImfInputFile ImfInputFile;
|
||||
|
||||
ImfInputFile * ImfOpenInputFile (const char name[]);
|
||||
|
||||
int ImfCloseInputFile (ImfInputFile *in);
|
||||
|
||||
int ImfInputSetFrameBuffer (ImfInputFile *in,
|
||||
ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfInputReadPixels (ImfInputFile *in,
|
||||
int scanLine1,
|
||||
int scanLine2);
|
||||
|
||||
const ImfHeader * ImfInputHeader (const ImfInputFile *in);
|
||||
|
||||
int ImfInputChannels (const ImfInputFile *in);
|
||||
|
||||
const char * ImfInputFileName (const ImfInputFile *in);
|
||||
|
||||
|
||||
/*
|
||||
** Tiled RGBA input file
|
||||
*/
|
||||
|
||||
struct ImfTiledInputFile;
|
||||
typedef struct ImfTiledInputFile ImfTiledInputFile;
|
||||
|
||||
ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]);
|
||||
|
||||
int ImfCloseTiledInputFile (ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
|
||||
ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfTiledInputReadTile (ImfTiledInputFile *in,
|
||||
int dx, int dy,
|
||||
int lx, int ly);
|
||||
|
||||
int ImfTiledInputReadTiles (ImfTiledInputFile *in,
|
||||
int dxMin, int dxMax,
|
||||
int dyMin, int dyMax,
|
||||
int lx, int ly);
|
||||
|
||||
const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputChannels (const ImfTiledInputFile *in);
|
||||
|
||||
const char * ImfTiledInputFileName (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputTileXSize (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputTileYSize (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputLevelMode (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputLevelRoundingMode
|
||||
(const ImfTiledInputFile *in);
|
||||
|
||||
/*
|
||||
** Lookup tables
|
||||
*/
|
||||
|
||||
struct ImfLut;
|
||||
typedef struct ImfLut ImfLut;
|
||||
|
||||
ImfLut * ImfNewRound12logLut (int channels);
|
||||
|
||||
ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);
|
||||
|
||||
void ImfDeleteLut (ImfLut *lut);
|
||||
|
||||
void ImfApplyLut (ImfLut *lut,
|
||||
ImfRgba *data,
|
||||
int nData,
|
||||
int stride);
|
||||
/*
|
||||
** Most recent error message
|
||||
*/
|
||||
|
||||
const char * ImfErrorMessage (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
392
3rdparty/include/OpenEXR/ImfChannelList.h
vendored
392
3rdparty/include/OpenEXR/ImfChannelList.h
vendored
@ -1,392 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_CHANNEL_LIST_H
|
||||
#define INCLUDED_IMF_CHANNEL_LIST_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Channel
|
||||
// class ChannelList
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfName.h>
|
||||
#include <ImfPixelType.h>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
struct Channel
|
||||
{
|
||||
//------------------------------
|
||||
// Data type; see ImfPixelType.h
|
||||
//------------------------------
|
||||
|
||||
PixelType type;
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Subsampling: pixel (x, y) is present in the
|
||||
// channel only if
|
||||
//
|
||||
// x % xSampling == 0 && y % ySampling == 0
|
||||
//
|
||||
//--------------------------------------------
|
||||
|
||||
int xSampling;
|
||||
int ySampling;
|
||||
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
Channel (PixelType type = HALF,
|
||||
int xSampling = 1,
|
||||
int ySampling = 1);
|
||||
|
||||
|
||||
//------------
|
||||
// Operator ==
|
||||
//------------
|
||||
|
||||
bool operator == (const Channel &other) const;
|
||||
};
|
||||
|
||||
|
||||
class ChannelList
|
||||
{
|
||||
public:
|
||||
|
||||
//--------------
|
||||
// Add a channel
|
||||
//--------------
|
||||
|
||||
void insert (const char name[],
|
||||
const Channel &channel);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Access to existing channels:
|
||||
//
|
||||
// [n] Returns a reference to the channel with name n.
|
||||
// If no channel with name n exists, an Iex::ArgExc
|
||||
// is thrown.
|
||||
//
|
||||
// findChannel(n) Returns a pointer to the channel with name n,
|
||||
// or 0 if no channel with name n exists.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
Channel & operator [] (const char name[]);
|
||||
const Channel & operator [] (const char name[]) const;
|
||||
|
||||
Channel * findChannel (const char name[]);
|
||||
const Channel * findChannel (const char name[]) const;
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Iterator-style access to existing channels
|
||||
//-------------------------------------------
|
||||
|
||||
typedef std::map <Name, Channel> ChannelMap;
|
||||
|
||||
class Iterator;
|
||||
class ConstIterator;
|
||||
|
||||
Iterator begin ();
|
||||
ConstIterator begin () const;
|
||||
Iterator end ();
|
||||
ConstIterator end () const;
|
||||
Iterator find (const char name[]);
|
||||
ConstIterator find (const char name[]) const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Support for image layers:
|
||||
//
|
||||
// In an image file with many channels it is sometimes useful to
|
||||
// group the channels into "layers", that is, into sets of channels
|
||||
// that logically belong together. Grouping channels into layers
|
||||
// is done using a naming convention: channel C in layer L is
|
||||
// called "L.C".
|
||||
//
|
||||
// For example, a computer graphic image may contain separate
|
||||
// R, G and B channels for light that originated at each of
|
||||
// several different virtual light sources. The channels in
|
||||
// this image might be called "light1.R", "light1.G", "light1.B",
|
||||
// "light2.R", "light2.G", "light2.B", etc.
|
||||
//
|
||||
// Note that this naming convention allows layers to be nested;
|
||||
// for example, "light1.specular.R" identifies the "R" channel
|
||||
// in the "specular" sub-layer of layer "light1".
|
||||
//
|
||||
// Channel names that don't contain a "." or that contain a
|
||||
// "." only at the beginning or at the end are not considered
|
||||
// to be part of any layer.
|
||||
//
|
||||
// layers(lns) sorts the channels in this ChannelList
|
||||
// into layers and stores the names of
|
||||
// all layers, sorted alphabetically,
|
||||
// into string set lns.
|
||||
//
|
||||
// channelsInLayer(ln,f,l) stores a pair of iterators in f and l
|
||||
// such that the loop
|
||||
//
|
||||
// for (ConstIterator i = f; i != l; ++i)
|
||||
// ...
|
||||
//
|
||||
// iterates over all channels in layer ln.
|
||||
// channelsInLayer (ln, l, p) calls
|
||||
// channelsWithPrefix (ln + ".", l, p).
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
void layers (std::set <std::string> &layerNames) const;
|
||||
|
||||
void channelsInLayer (const std::string &layerName,
|
||||
Iterator &first,
|
||||
Iterator &last);
|
||||
|
||||
void channelsInLayer (const std::string &layerName,
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Find all channels whose name begins with a given prefix:
|
||||
//
|
||||
// channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
|
||||
// such that the following loop iterates over all channels whose name
|
||||
// begins with string p:
|
||||
//
|
||||
// for (ConstIterator i = f; i != l; ++i)
|
||||
// ...
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void channelsWithPrefix (const char prefix[],
|
||||
Iterator &first,
|
||||
Iterator &last);
|
||||
|
||||
void channelsWithPrefix (const char prefix[],
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const;
|
||||
|
||||
//------------
|
||||
// Operator ==
|
||||
//------------
|
||||
|
||||
bool operator == (const ChannelList &other) const;
|
||||
|
||||
private:
|
||||
|
||||
ChannelMap _map;
|
||||
};
|
||||
|
||||
|
||||
//----------
|
||||
// Iterators
|
||||
//----------
|
||||
|
||||
class ChannelList::Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
Iterator ();
|
||||
Iterator (const ChannelList::ChannelMap::iterator &i);
|
||||
|
||||
Iterator & operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
Channel & channel () const;
|
||||
|
||||
private:
|
||||
|
||||
friend class ChannelList::ConstIterator;
|
||||
|
||||
ChannelList::ChannelMap::iterator _i;
|
||||
};
|
||||
|
||||
|
||||
class ChannelList::ConstIterator
|
||||
{
|
||||
public:
|
||||
|
||||
ConstIterator ();
|
||||
ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
|
||||
ConstIterator (const ChannelList::Iterator &other);
|
||||
|
||||
ConstIterator & operator ++ ();
|
||||
ConstIterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
const Channel & channel () const;
|
||||
|
||||
private:
|
||||
|
||||
friend bool operator == (const ConstIterator &, const ConstIterator &);
|
||||
friend bool operator != (const ConstIterator &, const ConstIterator &);
|
||||
|
||||
ChannelList::ChannelMap::const_iterator _i;
|
||||
};
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline Functions
|
||||
//-----------------
|
||||
|
||||
inline
|
||||
ChannelList::Iterator::Iterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
|
||||
_i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline ChannelList::Iterator &
|
||||
ChannelList::Iterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline ChannelList::Iterator
|
||||
ChannelList::Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
ChannelList::Iterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline Channel &
|
||||
ChannelList::Iterator::channel () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
ChannelList::ConstIterator::ConstIterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
ChannelList::ConstIterator::ConstIterator
|
||||
(const ChannelList::ChannelMap::const_iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
|
||||
_i (other._i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline ChannelList::ConstIterator &
|
||||
ChannelList::ConstIterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline ChannelList::ConstIterator
|
||||
ChannelList::ConstIterator::operator ++ (int)
|
||||
{
|
||||
ConstIterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
ChannelList::ConstIterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
inline const Channel &
|
||||
ChannelList::ConstIterator::channel () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const ChannelList::ConstIterator &x,
|
||||
const ChannelList::ConstIterator &y)
|
||||
{
|
||||
return x._i == y._i;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const ChannelList::ConstIterator &x,
|
||||
const ChannelList::ConstIterator &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
@ -1,67 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_CHANNEL_LIST_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_CHANNEL_LIST_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ChannelListAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfChannelList.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<ChannelList> ChannelListAttribute;
|
||||
template <> const char *ChannelListAttribute::staticTypeName ();
|
||||
template <> void ChannelListAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void ChannelListAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfChannelListAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
127
3rdparty/include/OpenEXR/ImfChromaticities.h
vendored
127
3rdparty/include/OpenEXR/ImfChromaticities.h
vendored
@ -1,127 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_CHROMATICITIES_H
|
||||
#define INCLUDED_IMF_CHROMATICITIES_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// CIE (x,y) chromaticities, and conversions between
|
||||
// RGB tiples and CIE XYZ tristimulus values.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathMatrix.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
struct Chromaticities
|
||||
{
|
||||
Imath::V2f red;
|
||||
Imath::V2f green;
|
||||
Imath::V2f blue;
|
||||
Imath::V2f white;
|
||||
|
||||
Chromaticities (const Imath::V2f &red = Imath::V2f (0.6400f, 0.3300f),
|
||||
const Imath::V2f &green = Imath::V2f (0.3000f, 0.6000f),
|
||||
const Imath::V2f &blue = Imath::V2f (0.1500f, 0.0600f),
|
||||
const Imath::V2f &white = Imath::V2f (0.3127f, 0.3290f));
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Conversions between RGB and CIE XYZ
|
||||
//
|
||||
// RGB to XYZ:
|
||||
//
|
||||
// Given a set of chromaticities, c, and the luminance, Y, of the RGB
|
||||
// triple (1,1,1), or "white", RGBtoXYZ(c,Y) computes a matrix, M, so
|
||||
// that multiplying an RGB value, v, with M produces an equivalent
|
||||
// XYZ value, w. (w == v * M)
|
||||
//
|
||||
// If we define that
|
||||
//
|
||||
// (Xr, Yr, Zr) == (1, 0, 0) * M
|
||||
// (Xg, Yg, Zg) == (0, 1, 0) * M
|
||||
// (Xb, Yb, Zb) == (0, 0, 1) * M
|
||||
// (Xw, Yw, Zw) == (1, 1, 1) * M,
|
||||
//
|
||||
// then the following statements are true:
|
||||
//
|
||||
// Xr / (Xr + Yr + Zr) == c.red.x
|
||||
// Yr / (Xr + Yr + Zr) == c.red.y
|
||||
//
|
||||
// Xg / (Xg + Yg + Zg) == c.red.x
|
||||
// Yg / (Xg + Yg + Zg) == c.red.y
|
||||
//
|
||||
// Xb / (Xb + Yb + Zb) == c.red.x
|
||||
// Yb / (Xb + Yb + Zb) == c.red.y
|
||||
//
|
||||
// Xw / (Xw + Yw + Zw) == c.red.x
|
||||
// Yw / (Xw + Yw + Zw) == c.red.y
|
||||
//
|
||||
// Yw == Y.
|
||||
//
|
||||
// XYZ to RGB:
|
||||
//
|
||||
// YYZtoRGB(c,Y) returns RGBtoXYZ(c,Y).inverse().
|
||||
//
|
||||
// Warning:
|
||||
//
|
||||
// It would seem that RGBtoXYZ() and XYZtoRGB() are all you need
|
||||
// to convert RGB values with one set of primary and white point
|
||||
// chromaticities into perceptually equivalent RGB values with
|
||||
// different primary and white point chromaticities:
|
||||
//
|
||||
// M44f M = RGBtoXYZ (chromaticities1, Y1) *
|
||||
// XYZtoRGB (chromaticities2, Y2);
|
||||
//
|
||||
// However, this simple conversion does not account for white point
|
||||
// adaptation, and produces undesirable results. The proper thing
|
||||
// to do is to perform a Bradford or a von Kries transform, which
|
||||
// moves the white point of the original color space to the white
|
||||
// point of the destination color space, dragging other colors with
|
||||
// it in a sensible fashion.
|
||||
//
|
||||
|
||||
Imath::M44f RGBtoXYZ (const Chromaticities chroma, float Y);
|
||||
Imath::M44f XYZtoRGB (const Chromaticities chroma, float Y);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
@ -1,72 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_CHROMATICITIES_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_CHROMATICITIES_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ChromaticitiesAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfChromaticities.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Chromaticities> ChromaticitiesAttribute;
|
||||
|
||||
template <>
|
||||
const char *ChromaticitiesAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
void ChromaticitiesAttribute::writeValueTo (OStream &, int) const;
|
||||
|
||||
template <>
|
||||
void ChromaticitiesAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfChromaticitiesAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
64
3rdparty/include/OpenEXR/ImfCompression.h
vendored
64
3rdparty/include/OpenEXR/ImfCompression.h
vendored
@ -1,64 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_COMPRESSION_H
|
||||
#define INCLUDED_IMF_COMPRESSION_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// enum Compression
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
enum Compression
|
||||
{
|
||||
NO_COMPRESSION = 0, // no compression
|
||||
RLE_COMPRESSION = 1, // run length encoding
|
||||
ZIPS_COMPRESSION = 2, // zlib compression, one scan line at a time
|
||||
ZIP_COMPRESSION = 3, // zlib compression, in blocks of 16 scan lines
|
||||
PIZ_COMPRESSION = 4, // piz-based wavelet compression
|
||||
PXR24_COMPRESSION = 5, // lossy 24-bit float compression
|
||||
|
||||
NUM_COMPRESSION_METHODS // number of different compression methods
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
@ -1,66 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_COMPRESSION_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_COMPRESSION_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class CompressionAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfCompression.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Compression> CompressionAttribute;
|
||||
template <> const char *CompressionAttribute::staticTypeName ();
|
||||
template <> void CompressionAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void CompressionAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfCompressionAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
104
3rdparty/include/OpenEXR/ImfConvert.h
vendored
104
3rdparty/include/OpenEXR/ImfConvert.h
vendored
@ -1,104 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_CONVERT_H
|
||||
#define INCLUDED_IMF_CONVERT_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Routines for converting between pixel data types,
|
||||
// with well-defined behavior for exceptional cases,
|
||||
// without depending on how hardware and operating
|
||||
// system handle integer overflows and floating-point
|
||||
// exceptions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "half.h"
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Conversion from half or float to unsigned int:
|
||||
//
|
||||
// input result
|
||||
// ---------------------------------------------------
|
||||
//
|
||||
// finite, >= 0 input, cast to unsigned int
|
||||
// (rounds towards zero)
|
||||
//
|
||||
// finite, < 0 0
|
||||
//
|
||||
// NaN 0
|
||||
//
|
||||
// +infinity UINT_MAX
|
||||
//
|
||||
// -infinity 0
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int halfToUint (half h);
|
||||
unsigned int floatToUint (float f);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Conversion from unsigned int or float to half:
|
||||
//
|
||||
// input result
|
||||
// ---------------------------------------------------
|
||||
//
|
||||
// finite, closest possible half
|
||||
// magnitude <= HALF_MAX
|
||||
//
|
||||
// finite, > HALF_MAX +infinity
|
||||
//
|
||||
// finite, < -HALF_MAX -infinity
|
||||
//
|
||||
// NaN NaN
|
||||
//
|
||||
// +infinity +infinity
|
||||
//
|
||||
// -infinity -infinity
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
half uintToHalf (unsigned int ui);
|
||||
half floatToHalf (float f);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
63
3rdparty/include/OpenEXR/ImfDoubleAttribute.h
vendored
63
3rdparty/include/OpenEXR/ImfDoubleAttribute.h
vendored
@ -1,63 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_DOUBLE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_DOUBLE_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class DoubleAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<double> DoubleAttribute;
|
||||
template <> const char *DoubleAttribute::staticTypeName ();
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfDoubleAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
322
3rdparty/include/OpenEXR/ImfEnvmap.h
vendored
322
3rdparty/include/OpenEXR/ImfEnvmap.h
vendored
@ -1,322 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_ENVMAP_H
|
||||
#define INCLUDED_IMF_ENVMAP_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Environment maps
|
||||
//
|
||||
// Environment maps define a mapping from 3D directions to 2D
|
||||
// pixel space locations. Environment maps are typically used
|
||||
// in 3D rendering, for effects such as quickly approximating
|
||||
// how shiny surfaces reflect their environment.
|
||||
//
|
||||
// Environment maps can be stored in scanline-based or in tiled
|
||||
// OpenEXR files. The fact that an image is an environment map
|
||||
// is indicated by the presence of an EnvmapAttribute whose name
|
||||
// is "envmap". (Convenience functions to access this attribute
|
||||
// are defined in header file ImfStandardAttributes.h.)
|
||||
// The attribute's value defines the mapping from 3D directions
|
||||
// to 2D pixel space locations.
|
||||
//
|
||||
// This header file defines the set of possible EnvmapAttribute
|
||||
// values.
|
||||
//
|
||||
// For each possible EnvmapAttribute value, this header file also
|
||||
// defines a set of convienience functions to convert between 3D
|
||||
// directions and 2D pixel locations.
|
||||
//
|
||||
// Most of the convenience functions defined below require a
|
||||
// dataWindow parameter. For scanline-based images, and for
|
||||
// tiled images with level mode ONE_LEVEL, the dataWindow
|
||||
// parameter should be set to the image's data window, as
|
||||
// defined in the image header. For tiled images with level
|
||||
// mode MIPMAP_LEVELS or RIPMAP_LEVELS, the data window of the
|
||||
// image level that is being accessed should be used instead.
|
||||
// (See the dataWindowForLevel() methods in ImfTiledInputFile.h
|
||||
// and ImfTiledOutputFile.h.)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImathBox.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//--------------------------------
|
||||
// Supported environment map types
|
||||
//--------------------------------
|
||||
|
||||
enum Envmap
|
||||
{
|
||||
ENVMAP_LATLONG = 0, // Latitude-longitude environment map
|
||||
ENVMAP_CUBE = 1, // Cube map
|
||||
|
||||
NUM_ENVMAPTYPES // Number of different environment map types
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Latitude-Longitude Map:
|
||||
//
|
||||
// The environment is projected onto the image using polar coordinates
|
||||
// (latitude and longitude). A pixel's x coordinate corresponds to
|
||||
// its longitude, and the y coordinate corresponds to its latitude.
|
||||
// Pixel (dataWindow.min.x, dataWindow.min.y) has latitude +pi/2 and
|
||||
// longitude +pi; pixel (dataWindow.max.x, dataWindow.max.y) has
|
||||
// latitude -pi/2 and longitude -pi.
|
||||
//
|
||||
// In 3D space, latitudes -pi/2 and +pi/2 correspond to the negative and
|
||||
// positive y direction. Latitude 0, longitude 0 points into positive
|
||||
// z direction; and latitude 0, longitude pi/2 points into positive x
|
||||
// direction.
|
||||
//
|
||||
// The size of the data window should be 2*N by N pixels (width by height),
|
||||
// where N can be any integer greater than 0.
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
namespace LatLongMap
|
||||
{
|
||||
//----------------------------------------------------
|
||||
// Convert a 3D direction to a 2D vector whose x and y
|
||||
// components represent the corresponding latitude
|
||||
// and longitude.
|
||||
//----------------------------------------------------
|
||||
|
||||
Imath::V2f latLong (const Imath::V3f &direction);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Convert the position of a pixel to a 2D vector whose
|
||||
// x and y components represent the corresponding latitude
|
||||
// and longitude.
|
||||
//--------------------------------------------------------
|
||||
|
||||
Imath::V2f latLong (const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &pixelPosition);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Convert a 2D vector, whose x and y components represent
|
||||
// longitude and latitude, into a corresponding pixel position.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
Imath::V2f pixelPosition (const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &latLong);
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Convert a 3D direction vector into a corresponding
|
||||
// pixel position. pixelPosition(dw,dir) is equivalent
|
||||
// to pixelPosition(dw,latLong(dw,dir)).
|
||||
//-----------------------------------------------------
|
||||
|
||||
Imath::V2f pixelPosition (const Imath::Box2i &dataWindow,
|
||||
const Imath::V3f &direction);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Convert the position of a pixel in a latitude-longitude
|
||||
// map into a corresponding 3D direction.
|
||||
//--------------------------------------------------------
|
||||
|
||||
Imath::V3f direction (const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &pixelPosition);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Cube Map:
|
||||
//
|
||||
// The environment is projected onto the six faces of an
|
||||
// axis-aligned cube. The cube's faces are then arranged
|
||||
// in a 2D image as shown below.
|
||||
//
|
||||
// 2-----------3
|
||||
// / /|
|
||||
// / / | Y
|
||||
// / / | |
|
||||
// 6-----------7 | |
|
||||
// | | | |
|
||||
// | | | |
|
||||
// | 0 | 1 *------- X
|
||||
// | | / /
|
||||
// | | / /
|
||||
// | |/ /
|
||||
// 4-----------5 Z
|
||||
//
|
||||
// dataWindow.min
|
||||
// /
|
||||
// /
|
||||
// +-----------+
|
||||
// |3 Y 7|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---Z | +X face
|
||||
// | | |
|
||||
// | | |
|
||||
// |1 5|
|
||||
// +-----------+
|
||||
// |6 Y 2|
|
||||
// | | |
|
||||
// | | |
|
||||
// | Z---+--- | -X face
|
||||
// | | |
|
||||
// | | |
|
||||
// |4 0|
|
||||
// +-----------+
|
||||
// |6 Z 7|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---X | +Y face
|
||||
// | | |
|
||||
// | | |
|
||||
// |2 3|
|
||||
// +-----------+
|
||||
// |0 1|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---X | -Y face
|
||||
// | | |
|
||||
// | | |
|
||||
// |4 Z 5|
|
||||
// +-----------+
|
||||
// |7 Y 6|
|
||||
// | | |
|
||||
// | | |
|
||||
// | X---+--- | +Z face
|
||||
// | | |
|
||||
// | | |
|
||||
// |5 4|
|
||||
// +-----------+
|
||||
// |2 Y 3|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---X | -Z face
|
||||
// | | |
|
||||
// | | |
|
||||
// |0 1|
|
||||
// +-----------+
|
||||
// /
|
||||
// /
|
||||
// dataWindow.max
|
||||
//
|
||||
// The size of the data window should be N by 6*N pixels
|
||||
// (width by height), where N can be any integer greater
|
||||
// than 0.
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
//------------------------------------
|
||||
// Names for the six faces of the cube
|
||||
//------------------------------------
|
||||
|
||||
enum CubeMapFace
|
||||
{
|
||||
CUBEFACE_POS_X, // +X face
|
||||
CUBEFACE_NEG_X, // -X face
|
||||
CUBEFACE_POS_Y, // +Y face
|
||||
CUBEFACE_NEG_Y, // -Y face
|
||||
CUBEFACE_POS_Z, // +Z face
|
||||
CUBEFACE_NEG_Z, // -Z face
|
||||
};
|
||||
|
||||
namespace CubeMap
|
||||
{
|
||||
//---------------------------------------------
|
||||
// Width and height of a cube's face, in pixels
|
||||
//---------------------------------------------
|
||||
|
||||
int sizeOfFace (const Imath::Box2i &dataWindow);
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// Compute the region in the environment map
|
||||
// that is covered by the specified face.
|
||||
//------------------------------------------
|
||||
|
||||
Imath::Box2i dataWindowForFace (CubeMapFace face,
|
||||
const Imath::Box2i &dataWindow);
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Convert the coordinates of a pixel within a face
|
||||
// [in the range from (0,0) to (s-1,s-1), where
|
||||
// s == sizeOfFace(dataWindow)] to pixel coordinates
|
||||
// in the environment map.
|
||||
//----------------------------------------------------
|
||||
|
||||
Imath::V2f pixelPosition (CubeMapFace face,
|
||||
const Imath::Box2i &dataWindow,
|
||||
Imath::V2f positionInFace);
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Convert a 3D direction into a cube face, and a pixel position
|
||||
// within that face.
|
||||
//
|
||||
// If you have a 3D direction, dir, the following code fragment
|
||||
// finds the position, pos, of the corresponding pixel in an
|
||||
// environment map with data window dw:
|
||||
//
|
||||
// CubeMapFace f;
|
||||
// V2f pif, pos;
|
||||
//
|
||||
// faceAndPixelPosition (dir, dw, f, pif);
|
||||
// pos = pixelPosition (f, dw, pif);
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void faceAndPixelPosition (const Imath::V3f &direction,
|
||||
const Imath::Box2i &dataWindow,
|
||||
CubeMapFace &face,
|
||||
Imath::V2f &positionInFace);
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// Given a cube face and a pixel position within that face,
|
||||
// compute the corresponding 3D direction.
|
||||
// --------------------------------------------------------
|
||||
|
||||
Imath::V3f direction (CubeMapFace face,
|
||||
const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &positionInFace);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
65
3rdparty/include/OpenEXR/ImfEnvmapAttribute.h
vendored
65
3rdparty/include/OpenEXR/ImfEnvmapAttribute.h
vendored
@ -1,65 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_ENVMAP_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_ENVMAP_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class EnvmapAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfEnvmap.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Envmap> EnvmapAttribute;
|
||||
template <> const char *EnvmapAttribute::staticTypeName ();
|
||||
template <> void EnvmapAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void EnvmapAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfEnvmapAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
63
3rdparty/include/OpenEXR/ImfFloatAttribute.h
vendored
63
3rdparty/include/OpenEXR/ImfFloatAttribute.h
vendored
@ -1,63 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_FLOAT_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_FLOAT_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class FloatAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<float> FloatAttribute;
|
||||
template <> const char *FloatAttribute::staticTypeName ();
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfFloatAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
368
3rdparty/include/OpenEXR/ImfFrameBuffer.h
vendored
368
3rdparty/include/OpenEXR/ImfFrameBuffer.h
vendored
@ -1,368 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_FRAME_BUFFER_H
|
||||
#define INCLUDED_IMF_FRAME_BUFFER_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Slice
|
||||
// class FrameBuffer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfName.h>
|
||||
#include <ImfPixelType.h>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Description of a single slice of the frame buffer:
|
||||
//
|
||||
// Note -- terminology: as part of a file, a component of
|
||||
// an image (e.g. red, green, blue, depth etc.) is called
|
||||
// a "channel". As part of a frame buffer, an image
|
||||
// component is called a "slice".
|
||||
//-------------------------------------------------------
|
||||
|
||||
struct Slice
|
||||
{
|
||||
//------------------------------
|
||||
// Data type; see ImfPixelType.h
|
||||
//------------------------------
|
||||
|
||||
PixelType type;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Memory layout: The address of pixel (x, y) is
|
||||
//
|
||||
// base + (xp / xSampling) * xStride + (yp / ySampling) * yStride
|
||||
//
|
||||
// where xp and yp are computed as follows:
|
||||
//
|
||||
// * If we are reading or writing a scanline-based file:
|
||||
//
|
||||
// xp = x
|
||||
// yp = y
|
||||
//
|
||||
// * If we are reading a tile whose upper left coorner is at (xt, yt):
|
||||
//
|
||||
// if xTileCoords is true then xp = x - xt, else xp = x
|
||||
// if yTileCoords is true then yp = y - yt, else yp = y
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
char * base;
|
||||
size_t xStride;
|
||||
size_t yStride;
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Subsampling: pixel (x, y) is present in the
|
||||
// slice only if
|
||||
//
|
||||
// x % xSampling == 0 && y % ySampling == 0
|
||||
//
|
||||
//--------------------------------------------
|
||||
|
||||
int xSampling;
|
||||
int ySampling;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Default value, used to fill the slice when a file without
|
||||
// a channel that corresponds to this slice is read.
|
||||
//----------------------------------------------------------
|
||||
|
||||
double fillValue;
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// For tiled files, the xTileCoords and yTileCoords flags
|
||||
// determine whether pixel addressing is performed using
|
||||
// absolute coordinates or coordinates relative to a
|
||||
// tile's upper left corner. (See the comment on base,
|
||||
// xStride and yStride, above.)
|
||||
//
|
||||
// For scanline-based files these flags have no effect;
|
||||
// pixel addressing is always done using absolute
|
||||
// coordinates.
|
||||
//-------------------------------------------------------
|
||||
|
||||
bool xTileCoords;
|
||||
bool yTileCoords;
|
||||
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
Slice (PixelType type = HALF,
|
||||
char * base = 0,
|
||||
size_t xStride = 0,
|
||||
size_t yStride = 0,
|
||||
int xSampling = 1,
|
||||
int ySampling = 1,
|
||||
double fillValue = 0.0,
|
||||
bool xTileCoords = false,
|
||||
bool yTileCoords = false);
|
||||
};
|
||||
|
||||
|
||||
class FrameBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Add a slice
|
||||
//------------
|
||||
|
||||
void insert (const char name[],
|
||||
const Slice &slice);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Access to existing slices:
|
||||
//
|
||||
// [n] Returns a reference to the slice with name n.
|
||||
// If no slice with name n exists, an Iex::ArgExc
|
||||
// is thrown.
|
||||
//
|
||||
// findSlice(n) Returns a pointer to the slice with name n,
|
||||
// or 0 if no slice with name n exists.
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Slice & operator [] (const char name[]);
|
||||
const Slice & operator [] (const char name[]) const;
|
||||
|
||||
Slice * findSlice (const char name[]);
|
||||
const Slice * findSlice (const char name[]) const;
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Iterator-style access to existing slices
|
||||
//-----------------------------------------
|
||||
|
||||
typedef std::map <Name, Slice> SliceMap;
|
||||
|
||||
class Iterator;
|
||||
class ConstIterator;
|
||||
|
||||
Iterator begin ();
|
||||
ConstIterator begin () const;
|
||||
Iterator end ();
|
||||
ConstIterator end () const;
|
||||
Iterator find (const char name[]);
|
||||
ConstIterator find (const char name[]) const;
|
||||
|
||||
private:
|
||||
|
||||
SliceMap _map;
|
||||
};
|
||||
|
||||
|
||||
//----------
|
||||
// Iterators
|
||||
//----------
|
||||
|
||||
class FrameBuffer::Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
Iterator ();
|
||||
Iterator (const FrameBuffer::SliceMap::iterator &i);
|
||||
|
||||
Iterator & operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
Slice & slice () const;
|
||||
|
||||
private:
|
||||
|
||||
friend class FrameBuffer::ConstIterator;
|
||||
|
||||
FrameBuffer::SliceMap::iterator _i;
|
||||
};
|
||||
|
||||
|
||||
class FrameBuffer::ConstIterator
|
||||
{
|
||||
public:
|
||||
|
||||
ConstIterator ();
|
||||
ConstIterator (const FrameBuffer::SliceMap::const_iterator &i);
|
||||
ConstIterator (const FrameBuffer::Iterator &other);
|
||||
|
||||
ConstIterator & operator ++ ();
|
||||
ConstIterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
const Slice & slice () const;
|
||||
|
||||
private:
|
||||
|
||||
friend bool operator == (const ConstIterator &, const ConstIterator &);
|
||||
friend bool operator != (const ConstIterator &, const ConstIterator &);
|
||||
|
||||
FrameBuffer::SliceMap::const_iterator _i;
|
||||
};
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline Functions
|
||||
//-----------------
|
||||
|
||||
inline
|
||||
FrameBuffer::Iterator::Iterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
FrameBuffer::Iterator::Iterator (const FrameBuffer::SliceMap::iterator &i):
|
||||
_i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline FrameBuffer::Iterator &
|
||||
FrameBuffer::Iterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline FrameBuffer::Iterator
|
||||
FrameBuffer::Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
FrameBuffer::Iterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline Slice &
|
||||
FrameBuffer::Iterator::slice () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
FrameBuffer::ConstIterator::ConstIterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
FrameBuffer::ConstIterator::ConstIterator
|
||||
(const FrameBuffer::SliceMap::const_iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
FrameBuffer::ConstIterator::ConstIterator (const FrameBuffer::Iterator &other):
|
||||
_i (other._i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline FrameBuffer::ConstIterator &
|
||||
FrameBuffer::ConstIterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline FrameBuffer::ConstIterator
|
||||
FrameBuffer::ConstIterator::operator ++ (int)
|
||||
{
|
||||
ConstIterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
FrameBuffer::ConstIterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
inline const Slice &
|
||||
FrameBuffer::ConstIterator::slice () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const FrameBuffer::ConstIterator &x,
|
||||
const FrameBuffer::ConstIterator &y)
|
||||
{
|
||||
return x._i == y._i;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const FrameBuffer::ConstIterator &x,
|
||||
const FrameBuffer::ConstIterator &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
557
3rdparty/include/OpenEXR/ImfHeader.h
vendored
557
3rdparty/include/OpenEXR/ImfHeader.h
vendored
@ -1,557 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_HEADER_H
|
||||
#define INCLUDED_IMF_HEADER_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Header
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfLineOrder.h>
|
||||
#include <ImfCompression.h>
|
||||
#include <ImfName.h>
|
||||
#include <ImfTileDescription.h>
|
||||
#include <ImfInt64.h>
|
||||
#include "ImathVec.h"
|
||||
#include "ImathBox.h"
|
||||
#include "IexBaseExc.h"
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class Attribute;
|
||||
class ChannelList;
|
||||
class IStream;
|
||||
class OStream;
|
||||
class PreviewImage;
|
||||
|
||||
|
||||
class Header
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Default constructor -- the display window and the data window
|
||||
// are both set to Box2i (V2i (0, 0), V2i (width-1, height-1).
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Header (int width = 64,
|
||||
int height = 64,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f &screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression = ZIP_COMPRESSION);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Constructor -- the data window is specified explicitly; the display
|
||||
// window is set to Box2i (V2i (0, 0), V2i (width-1, height-1).
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
Header (int width,
|
||||
int height,
|
||||
const Imath::Box2i &dataWindow,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f &screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression = ZIP_COMPRESSION);
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Constructor -- the display window and the data window are
|
||||
// both specified explicitly.
|
||||
//----------------------------------------------------------
|
||||
|
||||
Header (const Imath::Box2i &displayWindow,
|
||||
const Imath::Box2i &dataWindow,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f &screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression = ZIP_COMPRESSION);
|
||||
|
||||
|
||||
//-----------------
|
||||
// Copy constructor
|
||||
//-----------------
|
||||
|
||||
Header (const Header &other);
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
~Header ();
|
||||
|
||||
|
||||
//-----------
|
||||
// Assignment
|
||||
//-----------
|
||||
|
||||
Header & operator = (const Header &other);
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Add an attribute:
|
||||
//
|
||||
// insert(n,attr) If no attribute with name n exists, a new
|
||||
// attribute with name n, and the same type as
|
||||
// attr, is added, and the value of attr is
|
||||
// copied into the new attribute.
|
||||
//
|
||||
// If an attribute with name n exists, and its
|
||||
// type is the same as attr, the value of attr
|
||||
// is copied into this attribute.
|
||||
//
|
||||
// If an attribute with name n exists, and its
|
||||
// type is different from attr, an Iex::TypeExc
|
||||
// is thrown.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void insert (const char name[],
|
||||
const Attribute &attribute);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Access to existing attributes:
|
||||
//
|
||||
// [n] Returns a reference to the attribute
|
||||
// with name n. If no attribute with
|
||||
// name n exists, an Iex::ArgExc is thrown.
|
||||
//
|
||||
// typedAttribute<T>(n) Returns a reference to the attribute
|
||||
// with name n and type T. If no attribute
|
||||
// with name n exists, an Iex::ArgExc is
|
||||
// thrown. If an attribute with name n
|
||||
// exists, but its type is not T, an
|
||||
// Iex::TypeExc is thrown.
|
||||
//
|
||||
// findTypedAttribute<T>(n) Returns a pointer to the attribute with
|
||||
// name n and type T, or 0 if no attribute
|
||||
// with name n and type T exists.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
Attribute & operator [] (const char name[]);
|
||||
const Attribute & operator [] (const char name[]) const;
|
||||
|
||||
template <class T> T& typedAttribute (const char name[]);
|
||||
template <class T> const T& typedAttribute (const char name[]) const;
|
||||
|
||||
template <class T> T* findTypedAttribute (const char name[]);
|
||||
template <class T> const T* findTypedAttribute (const char name[]) const;
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
// Iterator-style access to existing attributes
|
||||
//---------------------------------------------
|
||||
|
||||
typedef std::map <Name, Attribute *> AttributeMap;
|
||||
|
||||
class Iterator;
|
||||
class ConstIterator;
|
||||
|
||||
Iterator begin ();
|
||||
ConstIterator begin () const;
|
||||
Iterator end ();
|
||||
ConstIterator end () const;
|
||||
Iterator find (const char name[]);
|
||||
ConstIterator find (const char name[]) const;
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Access to predefined attributes
|
||||
//--------------------------------
|
||||
|
||||
Imath::Box2i & displayWindow ();
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
|
||||
Imath::Box2i & dataWindow ();
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
|
||||
float & pixelAspectRatio ();
|
||||
const float & pixelAspectRatio () const;
|
||||
|
||||
Imath::V2f & screenWindowCenter ();
|
||||
const Imath::V2f & screenWindowCenter () const;
|
||||
|
||||
float & screenWindowWidth ();
|
||||
const float & screenWindowWidth () const;
|
||||
|
||||
ChannelList & channels ();
|
||||
const ChannelList & channels () const;
|
||||
|
||||
LineOrder & lineOrder ();
|
||||
const LineOrder & lineOrder () const;
|
||||
|
||||
Compression & compression ();
|
||||
const Compression & compression () const;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Tile Description:
|
||||
//
|
||||
// The tile description is a TileDescriptionAttribute whose name
|
||||
// is "tiles". The "tiles" attribute must be present in any tiled
|
||||
// image file. When present, it describes various properties of the
|
||||
// tiles that make up the file.
|
||||
//
|
||||
// Convenience functions:
|
||||
//
|
||||
// setTileDescription(td)
|
||||
// calls insert ("tiles", TileDescriptionAttribute (td))
|
||||
//
|
||||
// tileDescription()
|
||||
// returns typedAttribute<TileDescriptionAttribute>("tiles").value()
|
||||
//
|
||||
// hasTileDescription()
|
||||
// return findTypedAttribute<TileDescriptionAttribute>("tiles") != 0
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void setTileDescription (const TileDescription & td);
|
||||
|
||||
TileDescription & tileDescription ();
|
||||
const TileDescription & tileDescription () const;
|
||||
|
||||
bool hasTileDescription() const;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Preview image:
|
||||
//
|
||||
// The preview image is a PreviewImageAttribute whose name is "preview".
|
||||
// This attribute is special -- while an image file is being written,
|
||||
// the pixels of the preview image can be changed repeatedly by calling
|
||||
// OutputFile::updatePreviewImage().
|
||||
//
|
||||
// Convenience functions:
|
||||
//
|
||||
// setPreviewImage(p)
|
||||
// calls insert ("preview", PreviewImageAttribute (p))
|
||||
//
|
||||
// previewImage()
|
||||
// returns typedAttribute<PreviewImageAttribute>("preview").value()
|
||||
//
|
||||
// hasPreviewImage()
|
||||
// return findTypedAttribute<PreviewImageAttribute>("preview") != 0
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void setPreviewImage (const PreviewImage &p);
|
||||
|
||||
PreviewImage & previewImage ();
|
||||
const PreviewImage & previewImage () const;
|
||||
|
||||
bool hasPreviewImage () const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Sanity check -- examines the header, and throws an exception
|
||||
// if it finds something wrong (empty display window, negative
|
||||
// pixel aspect ratio, unknown compression sceme etc.)
|
||||
//
|
||||
// set isTiled to true if you are checking a tiled/multi-res
|
||||
// header
|
||||
//-------------------------------------------------------------
|
||||
|
||||
void sanityCheck (bool isTiled = false) const;
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Input and output:
|
||||
//
|
||||
// If the header contains a preview image attribute, then writeTo()
|
||||
// returns the position of that attribute in the output stream; this
|
||||
// information is used by OutputFile::updatePreviewImage().
|
||||
// If the header contains no preview image attribute, then writeTo()
|
||||
// returns 0.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
Int64 writeTo (OStream &os,
|
||||
bool isTiled = false) const;
|
||||
|
||||
void readFrom (IStream &is, int &version);
|
||||
|
||||
private:
|
||||
|
||||
AttributeMap _map;
|
||||
};
|
||||
|
||||
|
||||
//----------
|
||||
// Iterators
|
||||
//----------
|
||||
|
||||
class Header::Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
Iterator ();
|
||||
Iterator (const Header::AttributeMap::iterator &i);
|
||||
|
||||
Iterator & operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
Attribute & attribute () const;
|
||||
|
||||
private:
|
||||
|
||||
friend class Header::ConstIterator;
|
||||
|
||||
Header::AttributeMap::iterator _i;
|
||||
};
|
||||
|
||||
|
||||
class Header::ConstIterator
|
||||
{
|
||||
public:
|
||||
|
||||
ConstIterator ();
|
||||
ConstIterator (const Header::AttributeMap::const_iterator &i);
|
||||
ConstIterator (const Header::Iterator &other);
|
||||
|
||||
ConstIterator & operator ++ ();
|
||||
ConstIterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
const Attribute & attribute () const;
|
||||
|
||||
private:
|
||||
|
||||
friend bool operator == (const ConstIterator &, const ConstIterator &);
|
||||
friend bool operator != (const ConstIterator &, const ConstIterator &);
|
||||
|
||||
Header::AttributeMap::const_iterator _i;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Library initialization:
|
||||
//
|
||||
// In a multithreaded program, staticInitialize() must be called once
|
||||
// during startup, before the program accesses any other functions or
|
||||
// classes in the IlmImf library. Calling staticInitialize() in this
|
||||
// way avoids races during initialization of the library's global
|
||||
// variables.
|
||||
//
|
||||
// Single-threaded programs are not required to call staticInitialize();
|
||||
// initialization of the library's global variables happens automatically.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void staticInitialize ();
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline Functions
|
||||
//-----------------
|
||||
|
||||
|
||||
inline
|
||||
Header::Iterator::Iterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Header::Iterator::Iterator (const Header::AttributeMap::iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline Header::Iterator &
|
||||
Header::Iterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Header::Iterator
|
||||
Header::Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
Header::Iterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline Attribute &
|
||||
Header::Iterator::attribute () const
|
||||
{
|
||||
return *_i->second;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Header::ConstIterator::ConstIterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
Header::ConstIterator::ConstIterator
|
||||
(const Header::AttributeMap::const_iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Header::ConstIterator::ConstIterator (const Header::Iterator &other):
|
||||
_i (other._i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline Header::ConstIterator &
|
||||
Header::ConstIterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Header::ConstIterator
|
||||
Header::ConstIterator::operator ++ (int)
|
||||
{
|
||||
ConstIterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
Header::ConstIterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline const Attribute &
|
||||
Header::ConstIterator::attribute () const
|
||||
{
|
||||
return *_i->second;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const Header::ConstIterator &x, const Header::ConstIterator &y)
|
||||
{
|
||||
return x._i == y._i;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const Header::ConstIterator &x, const Header::ConstIterator &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
// Template definitions
|
||||
//---------------------
|
||||
|
||||
template <class T>
|
||||
T &
|
||||
Header::typedAttribute (const char name[])
|
||||
{
|
||||
Attribute *attr = &(*this)[name];
|
||||
T *tattr = dynamic_cast <T*> (attr);
|
||||
|
||||
if (tattr == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return *tattr;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const T &
|
||||
Header::typedAttribute (const char name[]) const
|
||||
{
|
||||
const Attribute *attr = &(*this)[name];
|
||||
const T *tattr = dynamic_cast <const T*> (attr);
|
||||
|
||||
if (tattr == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return *tattr;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T *
|
||||
Header::findTypedAttribute (const char name[])
|
||||
{
|
||||
AttributeMap::iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: dynamic_cast <T*> (i->second);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const T *
|
||||
Header::findTypedAttribute (const char name[]) const
|
||||
{
|
||||
AttributeMap::const_iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: dynamic_cast <const T*> (i->second);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
79
3rdparty/include/OpenEXR/ImfHuf.h
vendored
79
3rdparty/include/OpenEXR/ImfHuf.h
vendored
@ -1,79 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_HUF_H
|
||||
#define INCLUDED_IMF_HUF_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 16-bit Huffman compression and decompression:
|
||||
//
|
||||
// hufCompress (r, nr, c)
|
||||
//
|
||||
// Compresses the contents of array r (of length nr),
|
||||
// stores the compressed data in array c, and returns
|
||||
// the size of the compressed data (in bytes).
|
||||
//
|
||||
// To avoid buffer overflows, the size of array c should
|
||||
// be at least 2 * nr + 65536.
|
||||
//
|
||||
// hufUncompress (c, nc, r, nr)
|
||||
//
|
||||
// Uncompresses the data in array c (with length nc),
|
||||
// and stores the results in array r (with length nr).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
int
|
||||
hufCompress (const unsigned short raw[/*nRaw*/],
|
||||
int nRaw,
|
||||
char compressed[/*2 * nRaw + 65536*/]);
|
||||
|
||||
|
||||
void
|
||||
hufUncompress (const char compressed[/*nCompressed*/],
|
||||
int nCompressed,
|
||||
unsigned short raw[/*nRaw*/],
|
||||
int nRaw);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
252
3rdparty/include/OpenEXR/ImfIO.h
vendored
252
3rdparty/include/OpenEXR/ImfIO.h
vendored
@ -1,252 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_IO_H
|
||||
#define INCLUDED_IMF_IO_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Low-level file input and output for OpenEXR.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfInt64.h>
|
||||
#include <string>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// class IStream -- an abstract base class for input streams.
|
||||
//-----------------------------------------------------------
|
||||
|
||||
class IStream
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~IStream ();
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Does this input stream support memory-mapped IO?
|
||||
//
|
||||
// Memory-mapped streams can avoid an extra copy;
|
||||
// memory-mapped read operations return a pointer
|
||||
// to an internal buffer instead of copying data
|
||||
// into a buffer supplied by the caller.
|
||||
//-------------------------------------------------
|
||||
|
||||
virtual bool isMemoryMapped () const;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Read from the stream:
|
||||
//
|
||||
// read(c,n) reads n bytes from the stream, and stores
|
||||
// them in array c. If the stream contains less than n
|
||||
// bytes, or if an I/O error occurs, read(c,n) throws
|
||||
// an exception. If read(c,n) reads the last byte from
|
||||
// the file it returns false, otherwise it returns true.
|
||||
//------------------------------------------------------
|
||||
|
||||
virtual bool read (char c[/*n*/], int n) = 0;
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// Read from a memory-mapped stream:
|
||||
//
|
||||
// readMemoryMapped(n) reads n bytes from the stream
|
||||
// and returns a pointer to the first byte. The
|
||||
// returned pointer remains valid until the stream
|
||||
// is closed. If there are less than n byte left to
|
||||
// read in the stream or if the stream is not memory-
|
||||
// mapped, readMemoryMapped(n) throws an exception.
|
||||
//---------------------------------------------------
|
||||
|
||||
virtual char * readMemoryMapped (int n);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Get the current reading position, in bytes from the
|
||||
// beginning of the file. If the next call to read() will
|
||||
// read the first byte in the file, tellg() returns 0.
|
||||
//--------------------------------------------------------
|
||||
|
||||
virtual Int64 tellg () = 0;
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Set the current reading position.
|
||||
// After calling seekg(i), tellg() returns i.
|
||||
//-------------------------------------------
|
||||
|
||||
virtual void seekg (Int64 pos) = 0;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Clear error conditions after an operation has failed.
|
||||
//------------------------------------------------------
|
||||
|
||||
virtual void clear ();
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Get the name of the file associated with this stream.
|
||||
//------------------------------------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
protected:
|
||||
|
||||
IStream (const char fileName[]);
|
||||
|
||||
private:
|
||||
|
||||
IStream (const IStream &); // not implemented
|
||||
IStream & operator = (const IStream &); // not implemented
|
||||
|
||||
std::string _fileName;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// class OStream -- an abstract base class for output streams
|
||||
//-----------------------------------------------------------
|
||||
|
||||
class OStream
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~OStream ();
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Write to the stream:
|
||||
//
|
||||
// write(c,n) takes n bytes from array c, and stores them
|
||||
// in the stream. If an I/O error occurs, write(c,n) throws
|
||||
// an exception.
|
||||
//----------------------------------------------------------
|
||||
|
||||
virtual void write (const char c[/*n*/], int n) = 0;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Get the current writing position, in bytes from the
|
||||
// beginning of the file. If the next call to write() will
|
||||
// start writing at the beginning of the file, tellp()
|
||||
// returns 0.
|
||||
//---------------------------------------------------------
|
||||
|
||||
virtual Int64 tellp () = 0;
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Set the current writing position.
|
||||
// After calling seekp(i), tellp() returns i.
|
||||
//-------------------------------------------
|
||||
|
||||
virtual void seekp (Int64 pos) = 0;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Get the name of the file associated with this stream.
|
||||
//------------------------------------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
protected:
|
||||
|
||||
OStream (const char fileName[]);
|
||||
|
||||
private:
|
||||
|
||||
OStream (const OStream &); // not implemented
|
||||
OStream & operator = (const OStream &); // not implemented
|
||||
|
||||
std::string _fileName;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------
|
||||
// Helper classes for Xdr
|
||||
//-----------------------
|
||||
|
||||
struct StreamIO
|
||||
{
|
||||
static void
|
||||
writeChars (OStream &os, const char c[/*n*/], int n)
|
||||
{
|
||||
os.write (c, n);
|
||||
}
|
||||
|
||||
static bool
|
||||
readChars (IStream &is, char c[/*n*/], int n)
|
||||
{
|
||||
return is.read (c, n);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CharPtrIO
|
||||
{
|
||||
static void
|
||||
writeChars (char *&op, const char c[/*n*/], int n)
|
||||
{
|
||||
while (n--)
|
||||
*op++ = *c++;
|
||||
}
|
||||
|
||||
static bool
|
||||
readChars (const char *&ip, char c[/*n*/], int n)
|
||||
{
|
||||
while (n--)
|
||||
*c++ = *ip++;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
209
3rdparty/include/OpenEXR/ImfInputFile.h
vendored
209
3rdparty/include/OpenEXR/ImfInputFile.h
vendored
@ -1,209 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_INPUT_FILE_H
|
||||
#define INCLUDED_IMF_INPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class InputFile -- a scanline-based interface that can be used
|
||||
// to read both scanline-based and tiled OpenEXR image files.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImfTiledOutputFile.h>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class TiledInputFile;
|
||||
class ScanLineInputFile;
|
||||
|
||||
|
||||
class InputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// A constructor that opens the file with the specified name.
|
||||
// Destroying the InputFile object will close the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to read the file (see ImfThreading.h).
|
||||
//-----------------------------------------------------------
|
||||
|
||||
InputFile (const char fileName[], int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// A constructor that attaches the new InputFile object to a
|
||||
// file that has already been opened. Destroying the InputFile
|
||||
// object will not close the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to read the file (see ImfThreading.h).
|
||||
//-------------------------------------------------------------
|
||||
|
||||
InputFile (IStream &is, int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~InputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// Access to the file name
|
||||
//------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
|
||||
|
||||
//----------------------------------
|
||||
// Access to the file format version
|
||||
//----------------------------------
|
||||
|
||||
int version () const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Set the current frame buffer -- copies the FrameBuffer
|
||||
// object into the InputFile object.
|
||||
//
|
||||
// The current frame buffer is the destination for the pixel
|
||||
// data read from the file. The current frame buffer must be
|
||||
// set at least once before readPixels() is called.
|
||||
// The current frame buffer can be changed after each call
|
||||
// to readPixels().
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Check if the file is complete:
|
||||
//
|
||||
// isComplete() returns true if all pixels in the data window are
|
||||
// present in the input file, or false if any pixels are missing.
|
||||
// (Another program may still be busy writing the file, or file
|
||||
// writing may have been aborted prematurely.)
|
||||
//---------------------------------------------------------------
|
||||
|
||||
bool isComplete () const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Read pixel data:
|
||||
//
|
||||
// readPixels(s1,s2) reads all scan lines with y coordinates
|
||||
// in the interval [min (s1, s2), max (s1, s2)] from the file,
|
||||
// and stores them in the current frame buffer.
|
||||
//
|
||||
// Both s1 and s2 must be within the interval
|
||||
// [header().dataWindow().min.y, header().dataWindow().max.y]
|
||||
//
|
||||
// The scan lines can be read from the file in random order, and
|
||||
// individual scan lines may be skipped or read multiple times.
|
||||
// For maximum efficiency, the scan lines should be read in the
|
||||
// order in which they were written to the file.
|
||||
//
|
||||
// readPixels(s) calls readPixels(s,s).
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void readPixels (int scanLine1, int scanLine2);
|
||||
void readPixels (int scanLine);
|
||||
|
||||
|
||||
//----------------------------------------------
|
||||
// Read a block of raw pixel data from the file,
|
||||
// without uncompressing it (this function is
|
||||
// used to implement OutputFile::copyPixels()).
|
||||
//----------------------------------------------
|
||||
|
||||
void rawPixelData (int firstScanLine,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize);
|
||||
|
||||
//--------------------------------------------------
|
||||
// Read a tile of raw pixel data from the file,
|
||||
// without uncompressing it (this function is
|
||||
// used to implement TiledOutputFile::copyPixels()).
|
||||
//--------------------------------------------------
|
||||
|
||||
void rawTileData (int &dx, int &dy,
|
||||
int &lx, int &ly,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize);
|
||||
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
InputFile (const InputFile &); // not implemented
|
||||
InputFile & operator = (const InputFile &); // not implemented
|
||||
|
||||
void initialize ();
|
||||
TiledInputFile * tFile ();
|
||||
|
||||
friend void TiledOutputFile::copyPixels (InputFile &);
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
61
3rdparty/include/OpenEXR/ImfInt64.h
vendored
61
3rdparty/include/OpenEXR/ImfInt64.h
vendored
@ -1,61 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_INT64_H
|
||||
#define INCLUDED_IMF_INT64_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Int64 -- unsigned 64-bit integers
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && _MSC_VER >= 1300
|
||||
typedef unsigned __int64 Int64;
|
||||
#elif ULONG_MAX == 18446744073709551615LU
|
||||
typedef long unsigned int Int64;
|
||||
#else
|
||||
typedef long long unsigned int Int64;
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
63
3rdparty/include/OpenEXR/ImfIntAttribute.h
vendored
63
3rdparty/include/OpenEXR/ImfIntAttribute.h
vendored
@ -1,63 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_INT_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_INT_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class IntAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<int> IntAttribute;
|
||||
template <> const char *IntAttribute::staticTypeName ();
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfIntAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
161
3rdparty/include/OpenEXR/ImfKeyCode.h
vendored
161
3rdparty/include/OpenEXR/ImfKeyCode.h
vendored
@ -1,161 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_KEY_CODE_H
|
||||
#define INCLUDED_IMF_KEY_CODE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class KeyCode
|
||||
//
|
||||
// A KeyCode object uniquely identifies a motion picture film frame.
|
||||
// The following fields specifiy film manufacturer, film type, film
|
||||
// roll and the frame's position within the roll:
|
||||
//
|
||||
// filmMfcCode film manufacturer code
|
||||
// range: 0 - 99
|
||||
//
|
||||
// filmType film type code
|
||||
// range: 0 - 99
|
||||
//
|
||||
// prefix prefix to identify film roll
|
||||
// range: 0 - 999999
|
||||
//
|
||||
// count count, increments once every perfsPerCount
|
||||
// perforations (see below)
|
||||
// range: 0 - 9999
|
||||
//
|
||||
// perfOffset offset of frame, in perforations from
|
||||
// zero-frame reference mark
|
||||
// range: 0 - 119
|
||||
//
|
||||
// perfsPerFrame number of perforations per frame
|
||||
// range: 1 - 15
|
||||
//
|
||||
// typical values:
|
||||
//
|
||||
// 1 for 16mm film
|
||||
// 3, 4, or 8 for 35mm film
|
||||
// 5, 8 or 15 for 65mm film
|
||||
//
|
||||
// perfsPerCount number of perforations per count
|
||||
// range: 20 - 120
|
||||
//
|
||||
// typical values:
|
||||
//
|
||||
// 20 for 16mm film
|
||||
// 64 for 35mm film
|
||||
// 80 or 120 for 65mm film
|
||||
//
|
||||
// For more information about the interpretation of those fields see
|
||||
// the following standards and recommended practice publications:
|
||||
//
|
||||
// SMPTE 254 Motion-Picture Film (35-mm) - Manufacturer-Printed
|
||||
// Latent Image Identification Information
|
||||
//
|
||||
// SMPTE 268M File Format for Digital Moving-Picture Exchange (DPX)
|
||||
// (section 6.1)
|
||||
//
|
||||
// SMPTE 270 Motion-Picture Film (65-mm) - Manufacturer- Printed
|
||||
// Latent Image Identification Information
|
||||
//
|
||||
// SMPTE 271 Motion-Picture Film (16-mm) - Manufacturer- Printed
|
||||
// Latent Image Identification Information
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class KeyCode
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------
|
||||
// Constructors and assignment operator
|
||||
//-------------------------------------
|
||||
|
||||
KeyCode (int filmMfcCode = 0,
|
||||
int filmType = 0,
|
||||
int prefix = 0,
|
||||
int count = 0,
|
||||
int perfOffset = 0,
|
||||
int perfsPerFrame = 4,
|
||||
int perfsPerCount = 64);
|
||||
|
||||
KeyCode (const KeyCode &other);
|
||||
KeyCode & operator = (const KeyCode &other);
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Access to individual fields
|
||||
//----------------------------
|
||||
|
||||
int filmMfcCode () const;
|
||||
void setFilmMfcCode (int filmMfcCode);
|
||||
|
||||
int filmType () const;
|
||||
void setFilmType (int filmType);
|
||||
|
||||
int prefix () const;
|
||||
void setPrefix (int prefix);
|
||||
|
||||
int count () const;
|
||||
void setCount (int count);
|
||||
|
||||
int perfOffset () const;
|
||||
void setPerfOffset (int perfOffset);
|
||||
|
||||
int perfsPerFrame () const;
|
||||
void setPerfsPerFrame (int perfsPerFrame);
|
||||
|
||||
int perfsPerCount () const;
|
||||
void setPerfsPerCount (int perfsPerCount);
|
||||
|
||||
private:
|
||||
|
||||
int _filmMfcCode;
|
||||
int _filmType;
|
||||
int _prefix;
|
||||
int _count;
|
||||
int _perfOffset;
|
||||
int _perfsPerFrame;
|
||||
int _perfsPerCount;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
72
3rdparty/include/OpenEXR/ImfKeyCodeAttribute.h
vendored
72
3rdparty/include/OpenEXR/ImfKeyCodeAttribute.h
vendored
@ -1,72 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_KEY_CODE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_KEY_CODE_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class KeyCodeAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfKeyCode.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<KeyCode> KeyCodeAttribute;
|
||||
|
||||
template <>
|
||||
const char *KeyCodeAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
void KeyCodeAttribute::writeValueTo (OStream &, int) const;
|
||||
|
||||
template <>
|
||||
void KeyCodeAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfKeyCodeAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
64
3rdparty/include/OpenEXR/ImfLineOrder.h
vendored
64
3rdparty/include/OpenEXR/ImfLineOrder.h
vendored
@ -1,64 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_LINE_ORDER_H
|
||||
#define INCLUDED_IMF_LINE_ORDER_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// enum LineOrder
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
enum LineOrder
|
||||
{
|
||||
INCREASING_Y = 0, // first scan line has lowest y coordinate
|
||||
|
||||
DECREASING_Y = 1, // first scan line has highest y coordinate
|
||||
|
||||
RANDOM_Y = 2, // only for tiled files; tiles are written
|
||||
// in random order
|
||||
|
||||
NUM_LINEORDERS // number of different line orders
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
66
3rdparty/include/OpenEXR/ImfLineOrderAttribute.h
vendored
66
3rdparty/include/OpenEXR/ImfLineOrderAttribute.h
vendored
@ -1,66 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_LINE_ORDER_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_LINE_ORDER_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class LineOrderAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfLineOrder.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<LineOrder> LineOrderAttribute;
|
||||
template <> const char *LineOrderAttribute::staticTypeName ();
|
||||
template <> void LineOrderAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void LineOrderAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfLineOrderAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
185
3rdparty/include/OpenEXR/ImfLut.h
vendored
185
3rdparty/include/OpenEXR/ImfLut.h
vendored
@ -1,185 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_LUT_H
|
||||
#define INCLUDED_IMF_LUT_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Lookup tables for efficient application
|
||||
// of half --> half functions to pixel data,
|
||||
// and some commonly applied functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfRgbaFile.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include "ImathBox.h"
|
||||
#include "halfFunction.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//
|
||||
// Lookup table for individual half channels.
|
||||
//
|
||||
|
||||
class HalfLut
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
template <class Function>
|
||||
HalfLut (Function f);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Apply the table to data[0], data[stride] ... data[(nData-1) * stride]
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void apply (half *data,
|
||||
int nData,
|
||||
int stride = 1) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Apply the table to a frame buffer slice (see ImfFrameBuffer.h)
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void apply (const Slice &data,
|
||||
const Imath::Box2i &dataWindow) const;
|
||||
|
||||
private:
|
||||
|
||||
halfFunction <half> _lut;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Lookup table for combined RGBA data.
|
||||
//
|
||||
|
||||
class RgbaLut
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
template <class Function>
|
||||
RgbaLut (Function f, RgbaChannels chn = WRITE_RGB);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Apply the table to data[0], data[stride] ... data[(nData-1) * stride]
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void apply (Rgba *data,
|
||||
int nData,
|
||||
int stride = 1) const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Apply the table to a frame buffer (see RgbaOutpuFile.setFrameBuffer())
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void apply (Rgba *base,
|
||||
int xStride,
|
||||
int yStride,
|
||||
const Imath::Box2i &dataWindow) const;
|
||||
|
||||
private:
|
||||
|
||||
halfFunction <half> _lut;
|
||||
RgbaChannels _chn;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// 12bit log rounding reduces data to 20 stops with 200 steps per stop.
|
||||
// That makes 4000 numbers. An extra 96 just come along for the ride.
|
||||
// Zero explicitly remains zero. The first non-zero half will map to 1
|
||||
// in the 0-4095 12log space. A nice power of two number is placed at
|
||||
// the center [2000] and that number is near 0.18.
|
||||
//
|
||||
|
||||
half round12log (half x);
|
||||
|
||||
|
||||
//
|
||||
// Round to n-bit precision (n should be between 0 and 10).
|
||||
// After rounding, the significand's 10-n least significant
|
||||
// bits will be zero.
|
||||
//
|
||||
|
||||
struct roundNBit
|
||||
{
|
||||
roundNBit (int n): n(n) {}
|
||||
half operator () (half x) {return x.round(n);}
|
||||
int n;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Template definitions
|
||||
//
|
||||
|
||||
|
||||
template <class Function>
|
||||
HalfLut::HalfLut (Function f):
|
||||
_lut(f, -HALF_MAX, HALF_MAX, half (0),
|
||||
half::posInf(), half::negInf(), half::qNan())
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class Function>
|
||||
RgbaLut::RgbaLut (Function f, RgbaChannels chn):
|
||||
_lut(f, -HALF_MAX, HALF_MAX, half (0),
|
||||
half::posInf(), half::negInf(), half::qNan()),
|
||||
_chn(chn)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
73
3rdparty/include/OpenEXR/ImfMatrixAttribute.h
vendored
73
3rdparty/include/OpenEXR/ImfMatrixAttribute.h
vendored
@ -1,73 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_MATRIX_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_MATRIX_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class M33fAttribute
|
||||
// class M44fAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include "ImathMatrix.h"
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::M33f> M33fAttribute;
|
||||
template <> const char *M33fAttribute::staticTypeName ();
|
||||
template <> void M33fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void M33fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::M44f> M44fAttribute;
|
||||
template <> const char *M44fAttribute::staticTypeName ();
|
||||
template <> void M44fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void M44fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfMatrixAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
146
3rdparty/include/OpenEXR/ImfName.h
vendored
146
3rdparty/include/OpenEXR/ImfName.h
vendored
@ -1,146 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_NAME_H
|
||||
#define INCLUDED_IMF_NAME_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ImfName -- a zero-terminated string
|
||||
// with a fixed, small maximum length
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class Name
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------
|
||||
// Constructors
|
||||
//-------------
|
||||
|
||||
Name ();
|
||||
Name (const char text[]);
|
||||
|
||||
|
||||
//--------------------
|
||||
// Assignment operator
|
||||
//--------------------
|
||||
|
||||
Name & operator = (const char text[]);
|
||||
|
||||
|
||||
//---------------------
|
||||
// Access to the string
|
||||
//---------------------
|
||||
|
||||
const char * text () const {return _text;}
|
||||
const char * operator * () const {return _text;}
|
||||
|
||||
//---------------
|
||||
// Maximum length
|
||||
//---------------
|
||||
|
||||
static const int SIZE = 32;
|
||||
static const int MAX_LENGTH = SIZE - 1;
|
||||
|
||||
private:
|
||||
|
||||
char _text[SIZE];
|
||||
};
|
||||
|
||||
|
||||
bool operator == (const Name &x, const Name &y);
|
||||
bool operator != (const Name &x, const Name &y);
|
||||
bool operator < (const Name &x, const Name &y);
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline functions
|
||||
//-----------------
|
||||
|
||||
inline Name &
|
||||
Name::operator = (const char text[])
|
||||
{
|
||||
strncpy (_text, text, MAX_LENGTH);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Name::Name ()
|
||||
{
|
||||
_text[0] = 0;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Name::Name (const char text[])
|
||||
{
|
||||
*this = text;
|
||||
_text [MAX_LENGTH] = 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const Name &x, const Name &y)
|
||||
{
|
||||
return strcmp (*x, *y) == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const Name &x, const Name &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator < (const Name &x, const Name &y)
|
||||
{
|
||||
return strcmp (*x, *y) < 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace IMF
|
||||
|
||||
#endif
|
114
3rdparty/include/OpenEXR/ImfOpaqueAttribute.h
vendored
114
3rdparty/include/OpenEXR/ImfOpaqueAttribute.h
vendored
@ -1,114 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_OPAQUE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_OPAQUE_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class OpaqueAttribute
|
||||
//
|
||||
// When an image file is read, OpqaqueAttribute objects are used
|
||||
// to hold the values of attributes whose types are not recognized
|
||||
// by the reading program. OpaqueAttribute objects can be read
|
||||
// from an image file, copied, and written back to to another image
|
||||
// file, but their values are inaccessible.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfArray.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class OpaqueAttribute: public Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------
|
||||
// Constructors and destructor
|
||||
//----------------------------
|
||||
|
||||
OpaqueAttribute (const char typeName[]);
|
||||
OpaqueAttribute (const OpaqueAttribute &other);
|
||||
virtual ~OpaqueAttribute ();
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Get this attribute's type name
|
||||
//-------------------------------
|
||||
|
||||
virtual const char * typeName () const;
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Make a copy of this attribute
|
||||
//------------------------------
|
||||
|
||||
virtual Attribute * copy () const;
|
||||
|
||||
|
||||
//----------------
|
||||
// I/O and copying
|
||||
//----------------
|
||||
|
||||
virtual void writeValueTo (OStream &os,
|
||||
int version) const;
|
||||
|
||||
virtual void readValueFrom (IStream &is,
|
||||
int size,
|
||||
int version);
|
||||
|
||||
virtual void copyValueFrom (const Attribute &other);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array<char> _typeName;
|
||||
long _dataSize;
|
||||
Array<char> _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfOpaqueAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
241
3rdparty/include/OpenEXR/ImfOutputFile.h
vendored
241
3rdparty/include/OpenEXR/ImfOutputFile.h
vendored
@ -1,241 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_OUTPUT_FILE_H
|
||||
#define INCLUDED_IMF_OUTPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class OutputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class InputFile;
|
||||
struct PreviewRgba;
|
||||
|
||||
|
||||
class OutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Constructor -- opens the file and writes the file header.
|
||||
// The file header is also copied into the OutputFile object,
|
||||
// and can later be accessed via the header() method.
|
||||
// Destroying this OutputFile object automatically closes
|
||||
// the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to write the file (see ImfThreading.h).
|
||||
//-----------------------------------------------------------
|
||||
|
||||
OutputFile (const char fileName[], const Header &header,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Constructor -- attaches the new OutputFile object to a file
|
||||
// that has already been opened, and writes the file header.
|
||||
// The file header is also copied into the OutputFile object,
|
||||
// and can later be accessed via the header() method.
|
||||
// Destroying this OutputFile object does not automatically
|
||||
// close the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to write the file (see ImfThreading.h).
|
||||
//------------------------------------------------------------
|
||||
|
||||
OutputFile (OStream &os, const Header &header,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Destroying the OutputFile object before writing
|
||||
// all scan lines within the data window results in
|
||||
// an incomplete file.
|
||||
//-------------------------------------------------
|
||||
|
||||
virtual ~OutputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// Access to the file name
|
||||
//------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Set the current frame buffer -- copies the FrameBuffer
|
||||
// object into the OutputFile object.
|
||||
//
|
||||
// The current frame buffer is the source of the pixel
|
||||
// data written to the file. The current frame buffer
|
||||
// must be set at least once before writePixels() is
|
||||
// called. The current frame buffer can be changed
|
||||
// after each call to writePixels.
|
||||
//-------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Write pixel data:
|
||||
//
|
||||
// writePixels(n) retrieves the next n scan lines worth of data from
|
||||
// the current frame buffer, starting with the scan line indicated by
|
||||
// currentScanLine(), and stores the data in the output file, and
|
||||
// progressing in the direction indicated by header.lineOrder().
|
||||
//
|
||||
// To produce a complete and correct file, exactly m scan lines must
|
||||
// be written, where m is equal to
|
||||
// header().dataWindow().max.y - header().dataWindow().min.y + 1.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void writePixels (int numScanLines = 1);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Access to the current scan line:
|
||||
//
|
||||
// currentScanLine() returns the y coordinate of the first scan line
|
||||
// that will be read from the current frame buffer during the next
|
||||
// call to writePixels().
|
||||
//
|
||||
// If header.lineOrder() == INCREASING_Y:
|
||||
//
|
||||
// The current scan line before the first call to writePixels()
|
||||
// is header().dataWindow().min.y. After writing each scan line,
|
||||
// the current scan line is incremented by 1.
|
||||
//
|
||||
// If header.lineOrder() == DECREASING_Y:
|
||||
//
|
||||
// The current scan line before the first call to writePixels()
|
||||
// is header().dataWindow().max.y. After writing each scan line,
|
||||
// the current scan line is decremented by 1.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
int currentScanLine () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Shortcut to copy all pixels from an InputFile into this file,
|
||||
// without uncompressing and then recompressing the pixel data.
|
||||
// This file's header must be compatible with the InputFile's
|
||||
// header: The two header's "dataWindow", "compression",
|
||||
// "lineOrder" and "channels" attributes must be the same.
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void copyPixels (InputFile &in);
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Updating the preview image:
|
||||
//
|
||||
// updatePreviewImage() supplies a new set of pixels for the
|
||||
// preview image attribute in the file's header. If the header
|
||||
// does not contain a preview image, updatePreviewImage() throws
|
||||
// an Iex::LogicExc.
|
||||
//
|
||||
// Note: updatePreviewImage() is necessary because images are
|
||||
// often stored in a file incrementally, a few scan lines at a
|
||||
// time, while the image is being generated. Since the preview
|
||||
// image is an attribute in the file's header, it gets stored in
|
||||
// the file as soon as the file is opened, but we may not know
|
||||
// what the preview image should look like until we have written
|
||||
// the last scan line of the main image.
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba newPixels[]);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Break a scan line -- for testing and debugging only:
|
||||
//
|
||||
// breakScanLine(y,p,n,c) introduces an error into the
|
||||
// output file by writing n copies of character c, starting
|
||||
// p bytes from the beginning of the pixel data block that
|
||||
// contains scan line y.
|
||||
//
|
||||
// Warning: Calling this function usually results in a
|
||||
// broken image file. The file or parts of it may not
|
||||
// be readable, or the file may contain bad data.
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
void breakScanLine (int y, int offset, int length, char c);
|
||||
|
||||
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
OutputFile (const OutputFile &); // not implemented
|
||||
OutputFile & operator = (const OutputFile &); // not implemented
|
||||
|
||||
void initialize (const Header &header);
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
61
3rdparty/include/OpenEXR/ImfPixelType.h
vendored
61
3rdparty/include/OpenEXR/ImfPixelType.h
vendored
@ -1,61 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_PIXEL_TYPE_H
|
||||
#define INCLUDED_IMF_PIXEL_TYPE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// enum PixelType
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
enum PixelType
|
||||
{
|
||||
UINT = 0, // unsigned int (32 bit)
|
||||
HALF = 1, // half (16 bit floating point)
|
||||
FLOAT = 2, // float (32 bit floating point)
|
||||
|
||||
NUM_PIXELTYPES // number of different pixel types
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
131
3rdparty/include/OpenEXR/ImfPreviewImage.h
vendored
131
3rdparty/include/OpenEXR/ImfPreviewImage.h
vendored
@ -1,131 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_PREVIEW_IMAGE_H
|
||||
#define INCLUDED_IMF_PREVIEW_IMAGE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class PreviewImage -- a usually small, low-dynamic range image,
|
||||
// that is intended to be stored in an image file's header.
|
||||
//
|
||||
// struct PreviewRgba -- holds the value of a PreviewImage pixel.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
struct PreviewRgba
|
||||
{
|
||||
unsigned char r; // Red, green and blue components of
|
||||
unsigned char g; // the pixel's color; intensity is
|
||||
unsigned char b; // proportional to pow (x/255, 2.2),
|
||||
// where x is r, g, or b.
|
||||
|
||||
unsigned char a; // The pixel's alpha; 0 == transparent,
|
||||
// 255 == opaque.
|
||||
|
||||
PreviewRgba (unsigned char r = 0,
|
||||
unsigned char g = 0,
|
||||
unsigned char b = 0,
|
||||
unsigned char a = 255)
|
||||
: r(r), g(g), b(b), a(a) {}
|
||||
};
|
||||
|
||||
|
||||
class PreviewImage
|
||||
{
|
||||
public:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Constructor:
|
||||
//
|
||||
// PreviewImage(w,h,p) constructs a preview image with w by h pixels
|
||||
// whose initial values are specified in pixel array p. The x and y
|
||||
// coordinates of the pixels in p go from 0 to w-1, and from 0 to h-1.
|
||||
// The pixel with coordinates (x, y) is at address p + y*w + x.
|
||||
// Pixel (0, 0) is in the upper left corner of the preview image.
|
||||
// If p is zero, the pixels in the preview image are initialized with
|
||||
// (r = 0, b = 0, g = 0, a = 255).
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
PreviewImage (unsigned int width = 0,
|
||||
unsigned int height = 0,
|
||||
const PreviewRgba pixels[] = 0);
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Copy constructor, destructor and assignment operator
|
||||
//-----------------------------------------------------
|
||||
|
||||
PreviewImage (const PreviewImage &other);
|
||||
~PreviewImage ();
|
||||
|
||||
PreviewImage & operator = (const PreviewImage &other);
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Access to width, height and to the pixel array
|
||||
//-----------------------------------------------
|
||||
|
||||
unsigned int width () const {return _width;}
|
||||
unsigned int height () const {return _height;}
|
||||
|
||||
PreviewRgba * pixels () {return _pixels;}
|
||||
const PreviewRgba * pixels () const {return _pixels;}
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Access to individual pixels
|
||||
//----------------------------
|
||||
|
||||
PreviewRgba & pixel (unsigned int x, unsigned int y)
|
||||
{return _pixels[y * _width + x];}
|
||||
|
||||
const PreviewRgba & pixel (unsigned int x, unsigned int y) const
|
||||
{return _pixels[y * _width + x];}
|
||||
|
||||
private:
|
||||
|
||||
unsigned int _width;
|
||||
unsigned int _height;
|
||||
PreviewRgba * _pixels;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
@ -1,71 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_PREVIEW_IMAGE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_PREVIEW_IMAGE_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class PreviewImageAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfPreviewImage.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<PreviewImage> PreviewImageAttribute;
|
||||
|
||||
template <>
|
||||
const char *PreviewImageAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
void PreviewImageAttribute::writeValueTo (OStream &, int) const;
|
||||
|
||||
template <>
|
||||
void PreviewImageAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfPreviewImageAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
104
3rdparty/include/OpenEXR/ImfRgba.h
vendored
104
3rdparty/include/OpenEXR/ImfRgba.h
vendored
@ -1,104 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_RGBA_H
|
||||
#define INCLUDED_IMF_RGBA_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Rgba
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "half.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
//
|
||||
// RGBA pixel
|
||||
//
|
||||
|
||||
struct Rgba
|
||||
{
|
||||
half r;
|
||||
half g;
|
||||
half b;
|
||||
half a;
|
||||
|
||||
Rgba () {}
|
||||
Rgba (half r, half g, half b, half a = 1.f): r (r), g (g), b (b), a (a) {}
|
||||
|
||||
Rgba & operator = (const Rgba &other)
|
||||
{
|
||||
r = other.r;
|
||||
g = other.g;
|
||||
b = other.b;
|
||||
a = other.a;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Channels in an RGBA file
|
||||
//
|
||||
|
||||
enum RgbaChannels
|
||||
{
|
||||
WRITE_R = 0x01, // Red
|
||||
WRITE_G = 0x02, // Green
|
||||
WRITE_B = 0x04, // Blue
|
||||
WRITE_A = 0x08, // Alpha
|
||||
|
||||
WRITE_Y = 0x10, // Luminance, for black-and-white images,
|
||||
// or in combination with chroma
|
||||
|
||||
WRITE_C = 0x20, // Chroma (two subsampled channels, RY and BY,
|
||||
// supported only for scanline-based files)
|
||||
|
||||
WRITE_RGB = 0x07, // Red, green, blue
|
||||
WRITE_RGBA = 0x0f, // Red, green, blue, alpha
|
||||
|
||||
WRITE_YC = 0x30, // Luminance, chroma
|
||||
WRITE_YA = 0x18, // Luminance, alpha
|
||||
WRITE_YCA = 0x38 // Luminance, chroma, alpha
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
315
3rdparty/include/OpenEXR/ImfRgbaFile.h
vendored
315
3rdparty/include/OpenEXR/ImfRgbaFile.h
vendored
@ -1,315 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_RGBA_FILE_H
|
||||
#define INCLUDED_IMF_RGBA_FILE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Simplified RGBA image I/O
|
||||
//
|
||||
// class RgbaOutputFile
|
||||
// class RgbaInputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImfRgba.h>
|
||||
#include "ImathVec.h"
|
||||
#include "ImathBox.h"
|
||||
#include "half.h"
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class OutputFile;
|
||||
class InputFile;
|
||||
struct PreviewRgba;
|
||||
|
||||
//
|
||||
// RGBA output file.
|
||||
//
|
||||
|
||||
class RgbaOutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//---------------------------------------------------
|
||||
// Constructor -- header is constructed by the caller
|
||||
//---------------------------------------------------
|
||||
|
||||
RgbaOutputFile (const char name[],
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Constructor -- header is constructed by the caller,
|
||||
// file is opened by the caller, destructor will not
|
||||
// automatically close the file.
|
||||
//----------------------------------------------------
|
||||
|
||||
RgbaOutputFile (OStream &os,
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Constructor -- header data are explicitly specified as function
|
||||
// call arguments (empty dataWindow means "same as displayWindow")
|
||||
//----------------------------------------------------------------
|
||||
|
||||
RgbaOutputFile (const char name[],
|
||||
const Imath::Box2i &displayWindow,
|
||||
const Imath::Box2i &dataWindow = Imath::Box2i(),
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression compression = PIZ_COMPRESSION,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Constructor -- like the previous one, but both
|
||||
// the display window and the data window are
|
||||
// Box2i (V2i (0, 0), V2i (width - 1, height -1))
|
||||
//-----------------------------------------------
|
||||
|
||||
RgbaOutputFile (const char name[],
|
||||
int width,
|
||||
int height,
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression compression = PIZ_COMPRESSION,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~RgbaOutputFile ();
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// Define a frame buffer as the pixel data source:
|
||||
// Pixel (x, y) is at address
|
||||
//
|
||||
// base + x * xStride + y * yStride
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const Rgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
// Write pixel data (see class Imf::OutputFile)
|
||||
//---------------------------------------------
|
||||
|
||||
void writePixels (int numScanLines = 1);
|
||||
int currentScanLine () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const Imath::V2f screenWindowCenter () const;
|
||||
float screenWindowWidth () const;
|
||||
LineOrder lineOrder () const;
|
||||
Compression compression () const;
|
||||
RgbaChannels channels () const;
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Update the preview image (see Imf::OutputFile::updatePreviewImage())
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba[]);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Rounding control for luminance/chroma images:
|
||||
//
|
||||
// If the output file contains luminance and chroma channels (WRITE_YC
|
||||
// or WRITE_YCA), then the the significands of the luminance and
|
||||
// chroma values are rounded to roundY and roundC bits respectively (see
|
||||
// function half::round()). Rounding improves compression with minimal
|
||||
// image degradation, usually much less than the degradation caused by
|
||||
// chroma subsampling. By default, roundY is 7, and roundC is 5.
|
||||
//
|
||||
// If the output file contains RGB channels or a luminance channel,
|
||||
// without chroma, then no rounding is performed.
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void setYCRounding (unsigned int roundY,
|
||||
unsigned int roundC);
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Break a scan line -- for testing and debugging only
|
||||
// (see Imf::OutputFile::updatePreviewImage()
|
||||
//
|
||||
// Warning: Calling this function usually results in a
|
||||
// broken image file. The file or parts of it may not
|
||||
// be readable, or the file may contain bad data.
|
||||
//
|
||||
//----------------------------------------------------
|
||||
|
||||
void breakScanLine (int y,
|
||||
int offset,
|
||||
int length,
|
||||
char c);
|
||||
private:
|
||||
|
||||
RgbaOutputFile (const RgbaOutputFile &); // not implemented
|
||||
RgbaOutputFile & operator = (const RgbaOutputFile &); // not implemented
|
||||
|
||||
class ToYca;
|
||||
|
||||
OutputFile * _outputFile;
|
||||
ToYca * _toYca;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// RGBA input file
|
||||
//
|
||||
|
||||
class RgbaInputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Constructor -- opens the file with the specified name,
|
||||
// destructor will automatically close the file.
|
||||
//-------------------------------------------------------
|
||||
|
||||
RgbaInputFile (const char name[], int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Constructor -- attaches the new RgbaInputFile object to a
|
||||
// file that has already been opened by the caller.
|
||||
// Destroying the RgbaInputFile object will not automatically
|
||||
// close the file.
|
||||
//-----------------------------------------------------------
|
||||
|
||||
RgbaInputFile (IStream &is, int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~RgbaInputFile ();
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Define a frame buffer as the pixel data destination:
|
||||
// Pixel (x, y) is at address
|
||||
//
|
||||
// base + x * xStride + y * yStride
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
|
||||
void setFrameBuffer (Rgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Read pixel data (see class Imf::InputFile)
|
||||
//-------------------------------------------
|
||||
|
||||
void readPixels (int scanLine1, int scanLine2);
|
||||
void readPixels (int scanLine);
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const Imath::V2f screenWindowCenter () const;
|
||||
float screenWindowWidth () const;
|
||||
LineOrder lineOrder () const;
|
||||
Compression compression () const;
|
||||
RgbaChannels channels () const;
|
||||
const char * fileName () const;
|
||||
bool isComplete () const;
|
||||
|
||||
//----------------------------------
|
||||
// Access to the file format version
|
||||
//----------------------------------
|
||||
|
||||
int version () const;
|
||||
|
||||
private:
|
||||
|
||||
RgbaInputFile (const RgbaInputFile &); // not implemented
|
||||
RgbaInputFile & operator = (const RgbaInputFile &); // not implemented
|
||||
|
||||
class FromYca;
|
||||
|
||||
InputFile * _inputFile;
|
||||
FromYca * _fromYca;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
248
3rdparty/include/OpenEXR/ImfRgbaYca.h
vendored
248
3rdparty/include/OpenEXR/ImfRgbaYca.h
vendored
@ -1,248 +0,0 @@
|
||||
#ifndef INCLUDED_IMF_RGBA_YCA_H
|
||||
#define INCLUDED_IMF_RGBA_YCA_H
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucasfilm
|
||||
// Entertainment Company Ltd. Portions contributed and copyright held by
|
||||
// others as indicated. 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 Industrial Light & Magic 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Conversion between RGBA (red, green, blue alpha)
|
||||
// and YCA (luminance, subsampled chroma, alpha) data:
|
||||
//
|
||||
// Luminance, Y, is computed as a weighted sum of R, G, and B:
|
||||
//
|
||||
// Y = yw.x * R + yw.y * G + yw.z * B
|
||||
//
|
||||
// Function computeYw() computes a set of RGB-to-Y weights, yw,
|
||||
// from a set of primary and white point chromaticities.
|
||||
//
|
||||
// Chroma, C, consists of two components, RY and BY:
|
||||
//
|
||||
// RY = (R - Y) / Y
|
||||
// BY = (B - Y) / Y
|
||||
//
|
||||
// For efficiency, the x and y subsampling rates for chroma are
|
||||
// hardwired to 2, and the chroma subsampling and reconstruction
|
||||
// filters are fixed 27-pixel wide windowed sinc functions.
|
||||
//
|
||||
// Starting with an image that has RGBA data for all pixels,
|
||||
//
|
||||
// RGBA RGBA RGBA RGBA ... RGBA RGBA
|
||||
// RGBA RGBA RGBA RGBA ... RGBA RGBA
|
||||
// RGBA RGBA RGBA RGBA ... RGBA RGBA
|
||||
// RGBA RGBA RGBA RGBA ... RGBA RGBA
|
||||
// ...
|
||||
// RGBA RGBA RGBA RGBA ... RGBA RGBA
|
||||
// RGBA RGBA RGBA RGBA ... RGBA RGBA
|
||||
//
|
||||
// function RGBAtoYCA() converts the pixels to YCA format:
|
||||
//
|
||||
// YCA YCA YCA YCA ... YCA YCA
|
||||
// YCA YCA YCA YCA ... YCA YCA
|
||||
// YCA YCA YCA YCA ... YCA YCA
|
||||
// YCA YCA YCA YCA ... YCA YCA
|
||||
// ...
|
||||
// YCA YCA YCA YCA ... YCA YCA
|
||||
// YCA YCA YCA YCA ... YCA YCA
|
||||
//
|
||||
// Next, decimateChomaHoriz() eliminates the chroma values from
|
||||
// the odd-numbered pixels in every scan line:
|
||||
//
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// ...
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
//
|
||||
// decimateChromaVert() eliminates all chroma values from the
|
||||
// odd-numbered scan lines:
|
||||
//
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// YA YA YA YA ... YA YA
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// YA YA YA YA ... YA YA
|
||||
// ...
|
||||
// YCA YA YCA YA ... YCA YA
|
||||
// YA YA YA YA ... YA YA
|
||||
//
|
||||
// Finally, roundYCA() reduces the precision of the luminance
|
||||
// and chroma values so that the pixel data shrink more when
|
||||
// they are saved in a compressed file.
|
||||
//
|
||||
// The output of roundYCA() can be converted back to a set
|
||||
// of RGBA pixel data that is visually very similar to the
|
||||
// original RGBA image, by calling reconstructChromaHoriz(),
|
||||
// reconstructChromaVert(), YCAtoRGBA(), and finally
|
||||
// fixSaturation().
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfRgba.h>
|
||||
#include <ImfChromaticities.h>
|
||||
|
||||
namespace Imf {
|
||||
namespace RgbaYca {
|
||||
|
||||
|
||||
//
|
||||
// Width of the chroma subsampling and reconstruction filters
|
||||
//
|
||||
|
||||
static const int N = 27;
|
||||
static const int N2 = N / 2;
|
||||
|
||||
|
||||
//
|
||||
// Convert a set of primary chromaticities into a set of weighting
|
||||
// factors for computing a pixels's luminance, Y, from R, G and B
|
||||
//
|
||||
|
||||
Imath::V3f computeYw (const Chromaticities &cr);
|
||||
|
||||
|
||||
//
|
||||
// Convert an array of n RGBA pixels, rgbaIn, to YCA (luminance/chroma/alpha):
|
||||
//
|
||||
// ycaOut[i].g = Y (rgbaIn[i]);
|
||||
// ycaOut[i].r = RY (rgbaIn[i]);
|
||||
// ycaOut[i].b = BY (rgbaIn[i]);
|
||||
// ycaOut[i].a = aIsValid? rgbaIn[i].a: 1
|
||||
//
|
||||
// yw is a set of RGB-to-Y weighting factors, as computed by computeYw().
|
||||
//
|
||||
|
||||
void RGBAtoYCA (const Imath::V3f &yw,
|
||||
int n,
|
||||
bool aIsValid,
|
||||
const Rgba rgbaIn[/*n*/],
|
||||
Rgba ycaOut[/*n*/]);
|
||||
|
||||
//
|
||||
// Perform horizontal low-pass filtering and subsampling of
|
||||
// the chroma channels of an array of n pixels. In order
|
||||
// to avoid indexing off the ends of the input array during
|
||||
// low-pass filtering, ycaIn must have N2 extra pixels at
|
||||
// both ends. Before calling decimateChromaHoriz(), the extra
|
||||
// pixels should be filled with copies of the first and last
|
||||
// "real" input pixel.
|
||||
//
|
||||
|
||||
void decimateChromaHoriz (int n,
|
||||
const Rgba ycaIn[/*n+N-1*/],
|
||||
Rgba ycaOut[/*n*/]);
|
||||
|
||||
//
|
||||
// Perform vertical chroma channel low-pass filtering and subsampling.
|
||||
// N scan lines of input pixels are combined into a single scan line
|
||||
// of output pixels.
|
||||
//
|
||||
|
||||
void decimateChromaVert (int n,
|
||||
const Rgba * const ycaIn[N],
|
||||
Rgba ycaOut[/*n*/]);
|
||||
|
||||
//
|
||||
// Round the luminance and chroma channels of an array of YCA
|
||||
// pixels that has already been filtered and subsampled.
|
||||
// The signifcands of the pixels' luminance and chroma values
|
||||
// are rounded to roundY and roundC bits respectively.
|
||||
//
|
||||
|
||||
void roundYCA (int n,
|
||||
unsigned int roundY,
|
||||
unsigned int roundC,
|
||||
const Rgba ycaIn[/*n*/],
|
||||
Rgba ycaOut[/*n*/]);
|
||||
|
||||
//
|
||||
// For a scan line that has valid chroma data only for every other pixel,
|
||||
// reconstruct the missing chroma values.
|
||||
//
|
||||
|
||||
void reconstructChromaHoriz (int n,
|
||||
const Rgba ycaIn[/*n+N-1*/],
|
||||
Rgba ycaOut[/*n*/]);
|
||||
|
||||
//
|
||||
// For a scan line that has only luminance and no valid chroma data,
|
||||
// reconstruct chroma from the surronding N scan lines.
|
||||
//
|
||||
|
||||
void reconstructChromaVert (int n,
|
||||
const Rgba * const ycaIn[N],
|
||||
Rgba ycaOut[/*n*/]);
|
||||
|
||||
//
|
||||
// Convert an array of n YCA (luminance/chroma/alpha) pixels to RGBA.
|
||||
// This function is the inverse of RGBAtoYCA().
|
||||
// yw is a set of RGB-to-Y weighting factors, as computed by computeYw().
|
||||
//
|
||||
|
||||
void YCAtoRGBA (const Imath::V3f &yw,
|
||||
int n,
|
||||
const Rgba ycaIn[/*n*/],
|
||||
Rgba rgbaOut[/*n*/]);
|
||||
|
||||
//
|
||||
// Eliminate super-saturated pixels:
|
||||
//
|
||||
// Converting an image from RGBA to YCA, low-pass filtering chroma,
|
||||
// and converting the result back to RGBA can produce pixels with
|
||||
// super-saturated colors, where one or two of the RGB components
|
||||
// become zero or negative. (The low-pass and reconstruction filters
|
||||
// introduce some amount of ringing into the chroma components.
|
||||
// This can lead to negative RGB values near high-contrast edges.)
|
||||
//
|
||||
// The fixSaturation() function finds super-saturated pixels and
|
||||
// corrects them by desaturating their colors while maintaining
|
||||
// their luminance. fixSaturation() takes three adjacent input
|
||||
// scan lines, rgbaIn[0], rgbaIn[1], rgbaIn[2], adjusts the
|
||||
// saturation of rgbaIn[1], and stores the result in rgbaOut.
|
||||
//
|
||||
|
||||
void fixSaturation (const Imath::V3f &yw,
|
||||
int n,
|
||||
const Rgba * const rgbaIn[3],
|
||||
Rgba rgbaOut[/*n*/]);
|
||||
|
||||
} // namespace RgbaYca
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
251
3rdparty/include/OpenEXR/ImfStandardAttributes.h
vendored
251
3rdparty/include/OpenEXR/ImfStandardAttributes.h
vendored
@ -1,251 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_STANDARD_ATTRIBUTES_H
|
||||
#define INCLUDED_IMF_STANDARD_ATTRIBUTES_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Optional Standard Attributes -- these attributes are "optional"
|
||||
// because not every image file header has them, but they define a
|
||||
// "standard" way to represent commonly used data in the file header.
|
||||
//
|
||||
// For each attribute, with name "foo", and type "T", the following
|
||||
// functions are automatically generated via macros:
|
||||
//
|
||||
// void addFoo (Header &header, const T &value);
|
||||
// bool hasFoo (const Header &header);
|
||||
// const TypedAttribute<T> & fooAttribute (const Header &header);
|
||||
// TypedAttribute<T> & fooAttribute (Header &header);
|
||||
// const T & foo (const Header &Header);
|
||||
// T & foo (Header &Header);
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFloatAttribute.h>
|
||||
#include <ImfStringAttribute.h>
|
||||
#include <ImfChromaticitiesAttribute.h>
|
||||
#include <ImfEnvmapAttribute.h>
|
||||
#include <ImfKeyCodeAttribute.h>
|
||||
#include <ImfTimeCodeAttribute.h>
|
||||
|
||||
|
||||
#define IMF_STD_ATTRIBUTE_DEF(name,suffix,type) \
|
||||
\
|
||||
void add##suffix (Header &header, const type &v); \
|
||||
bool has##suffix (const Header &header); \
|
||||
const TypedAttribute<type> & name##Attribute (const Header &header); \
|
||||
TypedAttribute<type> & name##Attribute (Header &header); \
|
||||
const type & name (const Header &header); \
|
||||
type & name (Header &header);
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//
|
||||
// chromaticities -- for RGB images, specifies the CIE (x,y)
|
||||
// chromaticities of the primaries and the white point
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (chromaticities, Chromaticities, Chromaticities)
|
||||
|
||||
|
||||
//
|
||||
// whiteLuminance -- for RGB images, defines the luminance, in Nits
|
||||
// (candelas per square meter) of the RGB value (1.0, 1.0, 1.0).
|
||||
//
|
||||
// If the chromaticities and the whiteLuminance of an RGB image are
|
||||
// known, then it is possible to convert the image's pixels from RGB
|
||||
// to CIE XYZ tristimulus values (see function RGBtoXYZ() in header
|
||||
// file ImfChromaticities.h).
|
||||
//
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (whiteLuminance, WhiteLuminance, float)
|
||||
|
||||
|
||||
//
|
||||
// xDensity -- horizontal output density, in pixels per inch.
|
||||
// The image's vertical output density is xDensity * pixelAspectRatio.
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (xDensity, XDensity, float)
|
||||
|
||||
|
||||
//
|
||||
// owner -- name of the owner of the image
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (owner, Owner, std::string)
|
||||
|
||||
|
||||
//
|
||||
// comments -- additional image information in human-readable
|
||||
// form, for example a verbal description of the image
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (comments, Comments, std::string)
|
||||
|
||||
|
||||
//
|
||||
// capDate -- the date when the image was created or captured,
|
||||
// in local time, and formatted as
|
||||
//
|
||||
// YYYY:MM:DD hh:mm:ss
|
||||
//
|
||||
// where YYYY is the year (4 digits, e.g. 2003), MM is the month
|
||||
// (2 digits, 01, 02, ... 12), DD is the day of the month (2 digits,
|
||||
// 01, 02, ... 31), hh is the hour (2 digits, 00, 01, ... 23), mm
|
||||
// is the minute, and ss is the second (2 digits, 00, 01, ... 59).
|
||||
//
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (capDate, CapDate, std::string)
|
||||
|
||||
|
||||
//
|
||||
// utcOffset -- offset of local time at capDate from
|
||||
// Universal Coordinated Time (UTC), in seconds:
|
||||
//
|
||||
// UTC == local time + utcOffset
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (utcOffset, utcOffset, float)
|
||||
|
||||
|
||||
//
|
||||
// longitude, latitude, altitude -- for images of real objects, the
|
||||
// location where the image was recorded. Longitude and latitude are
|
||||
// in degrees east of Greenwich and north of the equator. Altitude
|
||||
// is in meters above sea level. For example, Kathmandu, Nepal is
|
||||
// at longitude 85.317, latitude 27.717, altitude 1305.
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (longitude, Longitude, float)
|
||||
IMF_STD_ATTRIBUTE_DEF (latitude, Latitude, float)
|
||||
IMF_STD_ATTRIBUTE_DEF (altitude, Altitude, float)
|
||||
|
||||
|
||||
//
|
||||
// focus -- the camera's focus distance, in meters
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (focus, Focus, float)
|
||||
|
||||
|
||||
//
|
||||
// exposure -- exposure time, in seconds
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (expTime, ExpTime, float)
|
||||
|
||||
|
||||
//
|
||||
// aperture -- the camera's lens aperture, in f-stops (focal length
|
||||
// of the lens divided by the diameter of the iris opening)
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (aperture, Aperture, float)
|
||||
|
||||
|
||||
//
|
||||
// isoSpeed -- the ISO speed of the film or image sensor
|
||||
// that was used to record the image
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (isoSpeed, IsoSpeed, float)
|
||||
|
||||
|
||||
//
|
||||
// envmap -- if this attribute is present, the image represents
|
||||
// an environment map. The attribute's value defines how 3D
|
||||
// directions are mapped to 2D pixel locations. For details
|
||||
// see header file ImfEnvmap.h
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (envmap, Envmap, Envmap)
|
||||
|
||||
|
||||
//
|
||||
// keyCode -- for motion picture film frames. Identifies film
|
||||
// manufacturer, film type, film roll and frame position within
|
||||
// the roll.
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (keyCode, KeyCode, KeyCode)
|
||||
|
||||
|
||||
//
|
||||
// timeCode -- time and control code
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (timeCode, TimeCode, TimeCode)
|
||||
|
||||
|
||||
//
|
||||
// wrapmodes -- determines how texture map images are extrapolated.
|
||||
// If an OpenEXR file is used as a texture map for 3D rendering,
|
||||
// texture coordinates (0.0, 0.0) and (1.0, 1.0) correspond to
|
||||
// the upper left and lower right corners of the data window.
|
||||
// If the image is mapped onto a surface with texture coordinates
|
||||
// outside the zero-to-one range, then the image must be extrapolated.
|
||||
// This attribute tells the renderer how to do this extrapolation.
|
||||
// The attribute contains either a pair of comma-separated keywords,
|
||||
// to specify separate extrapolation modes for the horizontal and
|
||||
// vertical directions; or a single keyword, to specify extrapolation
|
||||
// in both directions (e.g. "clamp,periodic" or "clamp"). Extra white
|
||||
// space surrounding the keywords is allowed, but should be ignored
|
||||
// by the renderer ("clamp, black " is equivalent to "clamp,black").
|
||||
// The keywords listed below are predefined; some renderers may support
|
||||
// additional extrapolation modes:
|
||||
//
|
||||
// black pixels outside the zero-to-one range are black
|
||||
//
|
||||
// clamp texture coordinates less than 0.0 and greater
|
||||
// than 1.0 are clamped to 0.0 and 1.0 respectively
|
||||
//
|
||||
// periodic the texture image repeats periodically
|
||||
//
|
||||
// mirror the texture image repeats periodically, but
|
||||
// every other instance is mirrored
|
||||
//
|
||||
|
||||
IMF_STD_ATTRIBUTE_DEF (wrapmodes, Wrapmodes, std::string)
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
156
3rdparty/include/OpenEXR/ImfStdIO.h
vendored
156
3rdparty/include/OpenEXR/ImfStdIO.h
vendored
@ -1,156 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_STD_IO_H
|
||||
#define INCLUDED_IMF_STD_IO_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Low-level file input and output for OpenEXR
|
||||
// based on C++ standard iostreams.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfIO.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//-------------------------------------------
|
||||
// class StdIFStream -- an implementation of
|
||||
// class IStream based on class std::ifstream
|
||||
//-------------------------------------------
|
||||
|
||||
class StdIFStream: public IStream
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------
|
||||
// A constructor that opens the file with the given name.
|
||||
// The destructor will close the file.
|
||||
//-------------------------------------------------------
|
||||
|
||||
StdIFStream (const char fileName[]);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// A constructor that uses a std::ifstream that has already
|
||||
// been opened by the caller. The StdIFStream's destructor
|
||||
// will not close the std::ifstream.
|
||||
//---------------------------------------------------------
|
||||
|
||||
StdIFStream (std::ifstream &is, const char fileName[]);
|
||||
|
||||
|
||||
virtual ~StdIFStream ();
|
||||
|
||||
virtual bool read (char c[/*n*/], int n);
|
||||
virtual Int64 tellg ();
|
||||
virtual void seekg (Int64 pos);
|
||||
virtual void clear ();
|
||||
|
||||
private:
|
||||
|
||||
std::ifstream * _is;
|
||||
bool _deleteStream;
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// class StdOFStream -- an implementation of
|
||||
// class OStream based on class std::ofstream
|
||||
//-------------------------------------------
|
||||
|
||||
class StdOFStream: public OStream
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------
|
||||
// A constructor that opens the file with the given name.
|
||||
// The destructor will close the file.
|
||||
//-------------------------------------------------------
|
||||
|
||||
StdOFStream (const char fileName[]);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// A constructor that uses a std::ofstream that has already
|
||||
// been opened by the caller. The StdOFStream's destructor
|
||||
// will not close the std::ofstream.
|
||||
//---------------------------------------------------------
|
||||
|
||||
StdOFStream (std::ofstream &os, const char fileName[]);
|
||||
|
||||
|
||||
virtual ~StdOFStream ();
|
||||
|
||||
virtual void write (const char c[/*n*/], int n);
|
||||
virtual Int64 tellp ();
|
||||
virtual void seekp (Int64 pos);
|
||||
|
||||
private:
|
||||
|
||||
std::ofstream * _os;
|
||||
bool _deleteStream;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// class StdOSStream -- an implementation of class
|
||||
// OStream, based on class std::ostringstream
|
||||
//------------------------------------------------
|
||||
|
||||
class StdOSStream: public OStream
|
||||
{
|
||||
public:
|
||||
|
||||
StdOSStream ();
|
||||
|
||||
virtual void write (const char c[/*n*/], int n);
|
||||
virtual Int64 tellp ();
|
||||
virtual void seekp (Int64 pos);
|
||||
|
||||
std::string str () const {return _os.str();}
|
||||
|
||||
private:
|
||||
|
||||
std::ostringstream _os;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
66
3rdparty/include/OpenEXR/ImfStringAttribute.h
vendored
66
3rdparty/include/OpenEXR/ImfStringAttribute.h
vendored
@ -1,66 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_STRING_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_STRING_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class StringAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<std::string> StringAttribute;
|
||||
template <> const char *StringAttribute::staticTypeName ();
|
||||
template <> void StringAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void StringAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfStringAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
63
3rdparty/include/OpenEXR/ImfTestFile.h
vendored
63
3rdparty/include/OpenEXR/ImfTestFile.h
vendored
@ -1,63 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TEST_FILE_H
|
||||
#define INCLUDED_IMF_TEST_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Utility routines to test quickly if a given
|
||||
// file is an OpenEXR file, and whether the
|
||||
// file is scanline-based or tiled.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class IStream;
|
||||
|
||||
|
||||
bool isOpenExrFile (const char fileName[], bool &isTiled);
|
||||
bool isOpenExrFile (const char fileName[]);
|
||||
bool isTiledOpenExrFile (const char fileName[]);
|
||||
bool isOpenExrFile (IStream &is, bool &isTiled);
|
||||
bool isOpenExrFile (IStream &is);
|
||||
bool isTiledOpenExrFile (IStream &is);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
92
3rdparty/include/OpenEXR/ImfThreading.h
vendored
92
3rdparty/include/OpenEXR/ImfThreading.h
vendored
@ -1,92 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_THREADING_H
|
||||
#define INCLUDED_IMF_THREADING_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Threading support for the IlmImf library
|
||||
//
|
||||
// The IlmImf library uses threads to perform reading and writing
|
||||
// of OpenEXR files in parallel. The thread that calls the library
|
||||
// always performs the actual file IO (this is usually the main
|
||||
// application thread) whereas a several worker threads perform
|
||||
// data compression and decompression. The number of worker
|
||||
// threads can be any non-negative value (a value of zero reverts
|
||||
// to single-threaded operation). As long as there is at least
|
||||
// one worker thread, file IO and compression can potentially be
|
||||
// done concurrently through pinelining. If there are two or more
|
||||
// worker threads, then pipelining as well as concurrent compression
|
||||
// of multiple blocks can be performed.
|
||||
//
|
||||
// Threading in the Imf library is controllable at two granularities:
|
||||
//
|
||||
// * The functions in this file query and control the total number
|
||||
// of worker threads, which will be created globally for the whole
|
||||
// library. Regardless of how many input or output files are
|
||||
// opened simultaneously, the library will use at most this number
|
||||
// of worker threads to perform all work. The default number of
|
||||
// global worker threads is zero (i.e. single-threaded operation;
|
||||
// everything happens in the thread that calls the library).
|
||||
//
|
||||
// * Furthermore, it is possible to set the number of threads that
|
||||
// each input or output file should keep busy. This number can
|
||||
// be explicitly set for each file. The default behavior is for
|
||||
// each file to try to occupy all worker threads in the library's
|
||||
// thread pool.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Return the number of Imf-global worker threads used for parallel
|
||||
// compression and decompression of OpenEXR files.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int globalThreadCount ();
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Change the number of Imf-global worker threads
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void setGlobalThreadCount (int count);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
102
3rdparty/include/OpenEXR/ImfTileDescription.h
vendored
102
3rdparty/include/OpenEXR/ImfTileDescription.h
vendored
@ -1,102 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TILE_DESCRIPTION_H
|
||||
#define INCLUDED_IMF_TILE_DESCRIPTION_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class TileDescription and enum LevelMode
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
enum LevelMode
|
||||
{
|
||||
ONE_LEVEL = 0,
|
||||
MIPMAP_LEVELS = 1,
|
||||
RIPMAP_LEVELS = 2,
|
||||
|
||||
NUM_LEVELMODES // number of different level modes
|
||||
};
|
||||
|
||||
|
||||
enum LevelRoundingMode
|
||||
{
|
||||
ROUND_DOWN = 0,
|
||||
ROUND_UP = 1,
|
||||
|
||||
NUM_ROUNDINGMODES // number of different rounding modes
|
||||
};
|
||||
|
||||
|
||||
class TileDescription
|
||||
{
|
||||
public:
|
||||
|
||||
unsigned int xSize; // size of a tile in the x dimension
|
||||
unsigned int ySize; // size of a tile in the y dimension
|
||||
LevelMode mode;
|
||||
LevelRoundingMode roundingMode;
|
||||
|
||||
TileDescription (unsigned int xs = 32,
|
||||
unsigned int ys = 32,
|
||||
LevelMode m = ONE_LEVEL,
|
||||
LevelRoundingMode r = ROUND_DOWN)
|
||||
:
|
||||
xSize (xs),
|
||||
ySize (ys),
|
||||
mode (m),
|
||||
roundingMode (r)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
bool
|
||||
operator == (const TileDescription &other) const
|
||||
{
|
||||
return xSize == other.xSize &&
|
||||
ySize == other.ySize &&
|
||||
mode == other.mode &&
|
||||
roundingMode == other.roundingMode;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TILE_DESCRIPTION_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_TILE_DESCRIPTION_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class TileDescriptionAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfTileDescription.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<TileDescription> TileDescriptionAttribute;
|
||||
|
||||
template <>
|
||||
const char *
|
||||
TileDescriptionAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
void
|
||||
TileDescriptionAttribute::writeValueTo (OStream &, int) const;
|
||||
|
||||
template <>
|
||||
void
|
||||
TileDescriptionAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfTileDescriptionAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
381
3rdparty/include/OpenEXR/ImfTiledInputFile.h
vendored
381
3rdparty/include/OpenEXR/ImfTiledInputFile.h
vendored
@ -1,381 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TILED_INPUT_FILE_H
|
||||
#define INCLUDED_IMF_TILED_INPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class TiledInputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include "ImathBox.h"
|
||||
#include <ImfTileDescription.h>
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class TiledInputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// A constructor that opens the file with the specified name, and
|
||||
// reads the file header. The constructor throws an Iex::ArgExc
|
||||
// exception if the file is not tiled.
|
||||
// The numThreads parameter specifies how many worker threads this
|
||||
// file will try to keep busy when decompressing individual tiles.
|
||||
// Destroying TiledInputFile objects constructed with this constructor
|
||||
// automatically closes the corresponding files.
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
TiledInputFile (const char fileName[],
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// A constructor that attaches the new TiledInputFile object
|
||||
// to a file that has already been opened.
|
||||
// Destroying TiledInputFile objects constructed with this
|
||||
// constructor does not automatically close the corresponding
|
||||
// files.
|
||||
// ----------------------------------------------------------
|
||||
|
||||
TiledInputFile (IStream &is, int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~TiledInputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// Access to the file name
|
||||
//------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
|
||||
|
||||
//----------------------------------
|
||||
// Access to the file format version
|
||||
//----------------------------------
|
||||
|
||||
int version () const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Set the current frame buffer -- copies the FrameBuffer
|
||||
// object into the TiledInputFile object.
|
||||
//
|
||||
// The current frame buffer is the destination for the pixel
|
||||
// data read from the file. The current frame buffer must be
|
||||
// set at least once before readTile() is called.
|
||||
// The current frame buffer can be changed after each call
|
||||
// to readTile().
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Check if the file is complete:
|
||||
//
|
||||
// isComplete() returns true if all pixels in the data window
|
||||
// (in all levels) are present in the input file, or false if
|
||||
// any pixels are missing. (Another program may still be busy
|
||||
// writing the file, or file writing may have been aborted
|
||||
// prematurely.)
|
||||
//------------------------------------------------------------
|
||||
|
||||
bool isComplete () const;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Utility functions:
|
||||
//--------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Multiresolution mode and tile size:
|
||||
// The following functions return the xSize, ySize and mode
|
||||
// fields of the file header's TileDescriptionAttribute.
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Number of levels:
|
||||
//
|
||||
// numXLevels() returns the file's number of levels in x direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL:
|
||||
// return value is: 1
|
||||
//
|
||||
// if levelMode() == MIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (w) / log (2)) + 1
|
||||
//
|
||||
// where
|
||||
// w is the width of the image's data window, max.x - min.x + 1,
|
||||
// y is the height of the image's data window, max.y - min.y + 1,
|
||||
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||
//
|
||||
// numYLevels() returns the file's number of levels in y direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (h) / log (2)) + 1
|
||||
//
|
||||
//
|
||||
// numLevels() is a convenience function for use with
|
||||
// MIPMAP_LEVELS files.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// an Iex::LogicExc exception is thrown
|
||||
//
|
||||
// isValidLevel(lx, ly) returns true if the file contains
|
||||
// a level with level number (lx, ly), false if not.
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Dimensions of a level:
|
||||
//
|
||||
// levelWidth(lx) returns the width of a level with level
|
||||
// number (lx, *), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (w / pow (2, lx)))
|
||||
//
|
||||
//
|
||||
// levelHeight(ly) returns the height of a level with level
|
||||
// number (*, ly), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (h / pow (2, ly)))
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Number of tiles:
|
||||
//
|
||||
// numXTiles(lx) returns the number of tiles in x direction
|
||||
// that cover a level with level number (lx, *), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//
|
||||
// numYTiles(ly) returns the number of tiles in y direction
|
||||
// that cover a level with level number (*, ly), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Level pixel ranges:
|
||||
//
|
||||
// dataWindowForLevel(lx, ly) returns a 2-dimensional region of
|
||||
// valid pixel coordinates for a level with level number (lx, ly)
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x, dataWindow.min.y)
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||
//
|
||||
// dataWindowForLevel(level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForLevel(level, level).
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
Imath::Box2i dataWindowForLevel (int l = 0) const;
|
||||
Imath::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Tile pixel ranges:
|
||||
//
|
||||
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a tile with tile coordinates
|
||||
// (dx,dy) and level number (lx, ly).
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x + dx * tileXSize(),
|
||||
// dataWindow.min.y + dy * tileYSize())
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||
//
|
||||
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForTile(dx, dy, level, level).
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy, int l = 0) const;
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Read pixel data:
|
||||
//
|
||||
// readTile(dx, dy, lx, ly) reads the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly),
|
||||
// and stores it in the current frame buffer.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels()-1]
|
||||
// ly must lie in the inverval [0, numYLevels()-1]
|
||||
//
|
||||
// readTile(dx, dy, level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It calls
|
||||
// readTile(dx, dy, level, level).
|
||||
//
|
||||
// The two readTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// reading multiple tiles at once. If multi-threading is used
|
||||
// the multiple tiles are read concurrently.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the
|
||||
// tile's level, are never accessed by readTile().
|
||||
//
|
||||
// Attempting to access a tile that is not present in the file
|
||||
// throws an InputExc exception.
|
||||
//
|
||||
//------------------------------------------------------------
|
||||
|
||||
void readTile (int dx, int dy, int l = 0);
|
||||
void readTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Read a tile of raw pixel data from the file,
|
||||
// without uncompressing it (this function is
|
||||
// used to implement TiledOutputFile::copyPixels()).
|
||||
//--------------------------------------------------
|
||||
|
||||
void rawTileData (int &dx, int &dy,
|
||||
int &lx, int &ly,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize);
|
||||
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
friend class InputFile;
|
||||
|
||||
TiledInputFile (const TiledInputFile &); // not implemented
|
||||
TiledInputFile & operator = (const TiledInputFile &); // not implemented
|
||||
|
||||
TiledInputFile (const Header &header, IStream *is, int version,
|
||||
int numThreads);
|
||||
|
||||
void initialize ();
|
||||
|
||||
bool isValidTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
size_t bytesPerLineForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
475
3rdparty/include/OpenEXR/ImfTiledOutputFile.h
vendored
475
3rdparty/include/OpenEXR/ImfTiledOutputFile.h
vendored
@ -1,475 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TILED_OUTPUT_FILE_H
|
||||
#define INCLUDED_IMF_TILED_OUTPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class TiledOutputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include "ImathBox.h"
|
||||
#include <ImfTileDescription.h>
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class TiledInputFile;
|
||||
class InputFile;
|
||||
struct PreviewRgba;
|
||||
|
||||
|
||||
class TiledOutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A constructor that opens the file with the specified name, and
|
||||
// writes the file header. The file header is also copied into the
|
||||
// TiledOutputFile object, and can later be accessed via the header()
|
||||
// method.
|
||||
//
|
||||
// Destroying TiledOutputFile constructed with this constructor
|
||||
// automatically closes the corresponding files.
|
||||
//
|
||||
// The header must contain a TileDescriptionAttribute called "tiles".
|
||||
//
|
||||
// The x and y subsampling factors for all image channels must be 1;
|
||||
// subsampling is not supported.
|
||||
//
|
||||
// Tiles can be written to the file in arbitrary order. The line
|
||||
// order attribute can be used to cause the tiles to be sorted in
|
||||
// the file. When the file is read later, reading the tiles in the
|
||||
// same order as they are in the file tends to be significantly
|
||||
// faster than reading the tiles in random order (see writeTile,
|
||||
// below).
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
TiledOutputFile (const char fileName[],
|
||||
const Header &header,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// A constructor that attaches the new TiledOutputFile object to
|
||||
// a file that has already been opened. Destroying TiledOutputFile
|
||||
// objects constructed with this constructor does not automatically
|
||||
// close the corresponding files.
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
TiledOutputFile (OStream &os,
|
||||
const Header &header,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Destroying a TiledOutputFile object before all tiles
|
||||
// have been written results in an incomplete file.
|
||||
//-----------------------------------------------------
|
||||
|
||||
virtual ~TiledOutputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// Access to the file name
|
||||
//------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Set the current frame buffer -- copies the FrameBuffer
|
||||
// object into the TiledOutputFile object.
|
||||
//
|
||||
// The current frame buffer is the source of the pixel
|
||||
// data written to the file. The current frame buffer
|
||||
// must be set at least once before writeTile() is
|
||||
// called. The current frame buffer can be changed
|
||||
// after each call to writeTile().
|
||||
//-------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//-------------------
|
||||
// Utility functions:
|
||||
//-------------------
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Multiresolution mode and tile size:
|
||||
// The following functions return the xSize, ySize and mode
|
||||
// fields of the file header's TileDescriptionAttribute.
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Number of levels:
|
||||
//
|
||||
// numXLevels() returns the file's number of levels in x direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL:
|
||||
// return value is: 1
|
||||
//
|
||||
// if levelMode() == MIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (w) / log (2)) + 1
|
||||
//
|
||||
// where
|
||||
// w is the width of the image's data window, max.x - min.x + 1,
|
||||
// y is the height of the image's data window, max.y - min.y + 1,
|
||||
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||
//
|
||||
// numYLevels() returns the file's number of levels in y direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (h) / log (2)) + 1
|
||||
//
|
||||
//
|
||||
// numLevels() is a convenience function for use with MIPMAP_LEVELS
|
||||
// files.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// an Iex::LogicExc exception is thrown
|
||||
//
|
||||
// isValidLevel(lx, ly) returns true if the file contains
|
||||
// a level with level number (lx, ly), false if not.
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Dimensions of a level:
|
||||
//
|
||||
// levelWidth(lx) returns the width of a level with level
|
||||
// number (lx, *), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (w / pow (2, lx)))
|
||||
//
|
||||
//
|
||||
// levelHeight(ly) returns the height of a level with level
|
||||
// number (*, ly), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (h / pow (2, ly)))
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Number of tiles:
|
||||
//
|
||||
// numXTiles(lx) returns the number of tiles in x direction
|
||||
// that cover a level with level number (lx, *), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//
|
||||
// numYTiles(ly) returns the number of tiles in y direction
|
||||
// that cover a level with level number (*, ly), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Level pixel ranges:
|
||||
//
|
||||
// dataWindowForLevel(lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a level with
|
||||
// level number (lx, ly)
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x, dataWindow.min.y)
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||
//
|
||||
// dataWindowForLevel(level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForLevel(level, level).
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
Imath::Box2i dataWindowForLevel (int l = 0) const;
|
||||
Imath::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Tile pixel ranges:
|
||||
//
|
||||
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a tile with tile coordinates
|
||||
// (dx,dy) and level number (lx, ly).
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x + dx * tileXSize(),
|
||||
// dataWindow.min.y + dy * tileYSize())
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||
//
|
||||
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForTile(dx, dy, level, level).
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy,
|
||||
int l = 0) const;
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Write pixel data:
|
||||
//
|
||||
// writeTile(dx, dy, lx, ly) writes the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly) to
|
||||
// the file.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx) - 1]
|
||||
// dy must lie in the interval [0, numYTiles(ly) - 1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels() - 1]
|
||||
// ly must lie in the inverval [0, numYLevels() - 1]
|
||||
//
|
||||
// writeTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVEL files. It calls
|
||||
// writeTile(dx, dy, level, level).
|
||||
//
|
||||
// The two writeTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// writing multiple tiles at once. If multi-threading is used
|
||||
// multiple tiles are written concurrently. The tile coordinates,
|
||||
// dx1, dx2 and dy1, dy2, specify inclusive ranges of tile
|
||||
// coordinates. It is valid for dx1 < dx2 or dy1 < dy2; the
|
||||
// tiles are always written in the order specified by the line
|
||||
// order attribute. Hence, it is not possible to specify an
|
||||
// "invalid" or empty tile range.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the tile's
|
||||
// level, are never accessed by writeTile().
|
||||
//
|
||||
// Each tile in the file must be written exactly once.
|
||||
//
|
||||
// The file's line order attribute determines the order of the tiles
|
||||
// in the file:
|
||||
//
|
||||
// INCREASING_Y In the file, the tiles for each level are stored
|
||||
// in a contiguous block. The levels are ordered
|
||||
// like this:
|
||||
//
|
||||
// (0, 0) (1, 0) ... (nx-1, 0)
|
||||
// (0, 1) (1, 1) ... (nx-1, 1)
|
||||
// ...
|
||||
// (0,ny-1) (1,ny-1) ... (nx-1,ny-1)
|
||||
//
|
||||
// where nx = numXLevels(), and ny = numYLevels().
|
||||
// In an individual level, (lx, ly), the tiles
|
||||
// are stored in the following order:
|
||||
//
|
||||
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||
// ...
|
||||
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||
//
|
||||
// where tx = numXTiles(lx),
|
||||
// and ty = numYTiles(ly).
|
||||
//
|
||||
// DECREASING_Y As for INCREASING_Y, the tiles for each level
|
||||
// are stored in a contiguous block. The levels
|
||||
// are ordered the same way as for INCREASING_Y,
|
||||
// but within an individual level, the tiles
|
||||
// are stored in this order:
|
||||
//
|
||||
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||
// ...
|
||||
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||
//
|
||||
//
|
||||
// RANDOM_Y The order of the calls to writeTile() determines
|
||||
// the order of the tiles in the file.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void writeTile (int dx, int dy, int l = 0);
|
||||
void writeTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Shortcut to copy all pixels from a TiledInputFile into this file,
|
||||
// without uncompressing and then recompressing the pixel data.
|
||||
// This file's header must be compatible with the TiledInputFile's
|
||||
// header: The two header's "dataWindow", "compression",
|
||||
// "lineOrder", "channels", and "tiles" attributes must be the same.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void copyPixels (TiledInputFile &in);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Shortcut to copy all pixels from an InputFile into this file,
|
||||
// without uncompressing and then recompressing the pixel data.
|
||||
// This file's header must be compatible with the InputFile's
|
||||
// header: The two header's "dataWindow", "compression",
|
||||
// "lineOrder", "channels", and "tiles" attributes must be the same.
|
||||
//
|
||||
// To use this function, the InputFile must be tiled.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void copyPixels (InputFile &in);
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Updating the preview image:
|
||||
//
|
||||
// updatePreviewImage() supplies a new set of pixels for the
|
||||
// preview image attribute in the file's header. If the header
|
||||
// does not contain a preview image, updatePreviewImage() throws
|
||||
// an Iex::LogicExc.
|
||||
//
|
||||
// Note: updatePreviewImage() is necessary because images are
|
||||
// often stored in a file incrementally, a few tiles at a time,
|
||||
// while the image is being generated. Since the preview image
|
||||
// is an attribute in the file's header, it gets stored in the
|
||||
// file as soon as the file is opened, but we may not know what
|
||||
// the preview image should look like until we have written the
|
||||
// last tile of the main image.
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba newPixels[]);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Break a tile -- for testing and debugging only:
|
||||
//
|
||||
// breakTile(dx,dy,lx,ly,p,n,c) introduces an error into the
|
||||
// output file by writing n copies of character c, starting
|
||||
// p bytes from the beginning of the tile with tile coordinates
|
||||
// (dx, dy) and level number (lx, ly).
|
||||
//
|
||||
// Warning: Calling this function usually results in a broken
|
||||
// image file. The file or parts of it may not be readable,
|
||||
// or the file may contain bad data.
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
|
||||
void breakTile (int dx, int dy,
|
||||
int lx, int ly,
|
||||
int offset,
|
||||
int length,
|
||||
char c);
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
TiledOutputFile (const TiledOutputFile &); // not implemented
|
||||
TiledOutputFile & operator = (const TiledOutputFile &); // not implemented
|
||||
|
||||
void initialize (const Header &header);
|
||||
|
||||
bool isValidTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
size_t bytesPerLineForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
453
3rdparty/include/OpenEXR/ImfTiledRgbaFile.h
vendored
453
3rdparty/include/OpenEXR/ImfTiledRgbaFile.h
vendored
@ -1,453 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TILED_RGBA_FILE_H
|
||||
#define INCLUDED_IMF_TILED_RGBA_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Simplified RGBA image I/O for tiled files
|
||||
//
|
||||
// class TiledRgbaOutputFile
|
||||
// class TiledRgbaInputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include "ImathVec.h"
|
||||
#include "ImathBox.h"
|
||||
#include "half.h"
|
||||
#include <ImfTileDescription.h>
|
||||
#include <ImfRgba.h>
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class TiledOutputFile;
|
||||
class TiledInputFile;
|
||||
struct PreviewRgba;
|
||||
|
||||
|
||||
//
|
||||
// Tiled RGBA output file.
|
||||
//
|
||||
|
||||
class TiledRgbaOutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//---------------------------------------------------
|
||||
// Constructor -- rgbaChannels, tileXSize, tileYSize,
|
||||
// levelMode, and levelRoundingMode overwrite the
|
||||
// channel list and tile description attribute in the
|
||||
// header that is passed as an argument to the
|
||||
// constructor.
|
||||
//---------------------------------------------------
|
||||
|
||||
TiledRgbaOutputFile (const char name[],
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels,
|
||||
int tileXSize,
|
||||
int tileYSize,
|
||||
LevelMode mode,
|
||||
LevelRoundingMode rmode = ROUND_DOWN,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// Constructor -- like the previous one, but the new
|
||||
// TiledRgbaOutputFile is attached to a file that has
|
||||
// already been opened by the caller. Destroying
|
||||
// TiledRgbaOutputFileObjects constructed with this
|
||||
// constructor does not automatically close the
|
||||
// corresponding files.
|
||||
//---------------------------------------------------
|
||||
|
||||
TiledRgbaOutputFile (OStream &os,
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels,
|
||||
int tileXSize,
|
||||
int tileYSize,
|
||||
LevelMode mode,
|
||||
LevelRoundingMode rmode = ROUND_DOWN,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Constructor -- header data are explicitly specified
|
||||
// as function call arguments (an empty dataWindow means
|
||||
// "same as displayWindow")
|
||||
//------------------------------------------------------
|
||||
|
||||
TiledRgbaOutputFile (const char name[],
|
||||
int tileXSize,
|
||||
int tileYSize,
|
||||
LevelMode mode,
|
||||
LevelRoundingMode rmode,
|
||||
const Imath::Box2i &displayWindow,
|
||||
const Imath::Box2i &dataWindow = Imath::Box2i(),
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f screenWindowCenter =
|
||||
Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression compression = ZIP_COMPRESSION,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Constructor -- like the previous one, but both
|
||||
// the display window and the data window are
|
||||
// Box2i (V2i (0, 0), V2i (width - 1, height -1))
|
||||
//-----------------------------------------------
|
||||
|
||||
TiledRgbaOutputFile (const char name[],
|
||||
int width,
|
||||
int height,
|
||||
int tileXSize,
|
||||
int tileYSize,
|
||||
LevelMode mode,
|
||||
LevelRoundingMode rmode = ROUND_DOWN,
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f screenWindowCenter =
|
||||
Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression compression = ZIP_COMPRESSION,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
virtual ~TiledRgbaOutputFile ();
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// Define a frame buffer as the pixel data source:
|
||||
// Pixel (x, y) is at address
|
||||
//
|
||||
// base + x * xStride + y * yStride
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const Rgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const Imath::V2f screenWindowCenter () const;
|
||||
float screenWindowWidth () const;
|
||||
LineOrder lineOrder () const;
|
||||
Compression compression () const;
|
||||
RgbaChannels channels () const;
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Utility functions (same as in Imf::TiledOutputFile)
|
||||
//----------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
Imath::Box2i dataWindowForLevel (int l = 0) const;
|
||||
Imath::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy,
|
||||
int l = 0) const;
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Write pixel data:
|
||||
//
|
||||
// writeTile(dx, dy, lx, ly) writes the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly) to
|
||||
// the file.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels()-1]
|
||||
// ly must lie in the inverval [0, numYLevels()-1]
|
||||
//
|
||||
// writeTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVEL files. It calls
|
||||
// writeTile(dx, dy, level, level).
|
||||
//
|
||||
// The two writeTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// writing multiple tiles at once. If multi-threading is used
|
||||
// multiple tiles are written concurrently.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the tile's
|
||||
// level, are never accessed by writeTile().
|
||||
//
|
||||
// Each tile in the file must be written exactly once.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void writeTile (int dx, int dy, int l = 0);
|
||||
void writeTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void writeTiles (int dxMin, int dxMax, int dyMin, int dyMax,
|
||||
int lx, int ly);
|
||||
|
||||
void writeTiles (int dxMin, int dxMax, int dyMin, int dyMax,
|
||||
int l = 0);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Update the preview image (see Imf::TiledOutputFile::updatePreviewImage())
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba[]);
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// Break a tile -- for testing and debugging only
|
||||
// (see Imf::TiledOutputFile::breakTile())
|
||||
//
|
||||
// Warning: Calling this function usually results
|
||||
// in a broken image file. The file or parts of
|
||||
// it may not be readable, or the file may contain
|
||||
// bad data.
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
void breakTile (int dx, int dy,
|
||||
int lx, int ly,
|
||||
int offset,
|
||||
int length,
|
||||
char c);
|
||||
private:
|
||||
|
||||
//
|
||||
// Copy constructor and assignment are not implemented
|
||||
//
|
||||
|
||||
TiledRgbaOutputFile (const TiledRgbaOutputFile &);
|
||||
TiledRgbaOutputFile & operator = (const TiledRgbaOutputFile &);
|
||||
|
||||
class ToYa;
|
||||
|
||||
TiledOutputFile * _outputFile;
|
||||
ToYa * _toYa;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Tiled RGBA input file
|
||||
//
|
||||
|
||||
class TiledRgbaInputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Constructor -- opens the file with the specified name.
|
||||
// Destroying TiledRgbaInputFile objects constructed with
|
||||
// this constructor automatically closes the corresponding
|
||||
// files.
|
||||
//--------------------------------------------------------
|
||||
|
||||
TiledRgbaInputFile (const char name[],
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Constructor -- attaches the new TiledRgbaInputFile
|
||||
// object to a file that has already been opened by the
|
||||
// caller.
|
||||
// Destroying TiledRgbaInputFile objects constructed with
|
||||
// this constructor does not automatically close the
|
||||
// corresponding files.
|
||||
//-------------------------------------------------------
|
||||
|
||||
TiledRgbaInputFile (IStream &is, int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~TiledRgbaInputFile ();
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Define a frame buffer as the pixel data destination:
|
||||
// Pixel (x, y) is at address
|
||||
//
|
||||
// base + x * xStride + y * yStride
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
|
||||
void setFrameBuffer (Rgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const Imath::V2f screenWindowCenter () const;
|
||||
float screenWindowWidth () const;
|
||||
LineOrder lineOrder () const;
|
||||
Compression compression () const;
|
||||
RgbaChannels channels () const;
|
||||
const char * fileName () const;
|
||||
bool isComplete () const;
|
||||
|
||||
//----------------------------------
|
||||
// Access to the file format version
|
||||
//----------------------------------
|
||||
|
||||
int version () const;
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// Utility functions (same as in Imf::TiledInputFile)
|
||||
//---------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
Imath::Box2i dataWindowForLevel (int l = 0) const;
|
||||
Imath::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy,
|
||||
int l = 0) const;
|
||||
|
||||
Imath::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Read pixel data:
|
||||
//
|
||||
// readTile(dx, dy, lx, ly) reads the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly),
|
||||
// and stores it in the current frame buffer.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels()-1]
|
||||
// ly must lie in the inverval [0, numYLevels()-1]
|
||||
//
|
||||
// readTile(dx, dy, level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It calls
|
||||
// readTile(dx, dy, level, level).
|
||||
//
|
||||
// The two readTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// reading multiple tiles at once. If multi-threading is used
|
||||
// multiple tiles are read concurrently.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the
|
||||
// tile's level, are never accessed by readTile().
|
||||
//
|
||||
// Attempting to access a tile that is not present in the file
|
||||
// throws an InputExc exception.
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
void readTile (int dx, int dy, int l = 0);
|
||||
void readTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void readTiles (int dxMin, int dxMax,
|
||||
int dyMin, int dyMax, int lx, int ly);
|
||||
|
||||
void readTiles (int dxMin, int dxMax,
|
||||
int dyMin, int dyMax, int l = 0);
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// Copy constructor and assignment are not implemented
|
||||
//
|
||||
|
||||
TiledRgbaInputFile (const TiledRgbaInputFile &);
|
||||
TiledRgbaInputFile & operator = (const TiledRgbaInputFile &);
|
||||
|
||||
class FromYa;
|
||||
|
||||
TiledInputFile * _inputFile;
|
||||
FromYa * _fromYa;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
226
3rdparty/include/OpenEXR/ImfTimeCode.h
vendored
226
3rdparty/include/OpenEXR/ImfTimeCode.h
vendored
@ -1,226 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TIME_CODE_H
|
||||
#define INCLUDED_IMF_TIME_CODE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class TimeCode
|
||||
//
|
||||
// A TimeCode object stores time and control codes as described
|
||||
// in SMPTE standard 12M-1999. A TimeCode object contains the
|
||||
// following fields:
|
||||
//
|
||||
// Time Address:
|
||||
//
|
||||
// hours integer, range 0 - 23
|
||||
// minutes integer, range 0 - 59
|
||||
// seconds integer, range 0 - 59
|
||||
// frame integer, range 0 - 29
|
||||
//
|
||||
// Flags:
|
||||
//
|
||||
// drop frame flag boolean
|
||||
// color frame flag boolean
|
||||
// field/phase flag boolean
|
||||
// bgf0 boolean
|
||||
// bgf1 boolean
|
||||
// bgf2 boolean
|
||||
//
|
||||
// Binary groups for user-defined data and control codes:
|
||||
//
|
||||
// binary group 1 integer, range 0 - 15
|
||||
// binary group 2 integer, range 0 - 15
|
||||
// ...
|
||||
// binary group 8 integer, range 0 - 15
|
||||
//
|
||||
// Class TimeCode contains methods to convert between the fields
|
||||
// listed above and a more compact representation where the fields
|
||||
// are packed into two unsigned 32-bit integers. In the packed
|
||||
// integer representations, bit 0 is the least significant bit,
|
||||
// and bit 31 is the most significant bit of the integer value.
|
||||
//
|
||||
// The time address and flags fields can be packed in three
|
||||
// different ways:
|
||||
//
|
||||
// bits packing for packing for packing for
|
||||
// 24-frame 60-field 50-field
|
||||
// film television television
|
||||
//
|
||||
// 0 - 3 frame units frame units frame units
|
||||
// 4 - 5 frame tens frame tens frame tens
|
||||
// 6 unused, set to 0 drop frame flag unused, set to 0
|
||||
// 7 unused, set to 0 color frame flag color frame flag
|
||||
// 8 - 11 seconds units seconds units seconds units
|
||||
// 12 - 14 seconds tens seconds tens seconds tens
|
||||
// 15 phase flag field/phase flag bgf0
|
||||
// 16 - 19 minutes units minutes units minutes units
|
||||
// 20 - 22 minutes tens minutes tens minutes tens
|
||||
// 23 bgf0 bgf0 bgf2
|
||||
// 24 - 27 hours units hours units hours units
|
||||
// 28 - 29 hours tens hours tens hours tens
|
||||
// 30 bgf1 bgf1 bgf1
|
||||
// 31 bgf2 bgf2 field/phase flag
|
||||
//
|
||||
// User-defined data and control codes are packed as follows:
|
||||
//
|
||||
// bits field
|
||||
//
|
||||
// 0 - 3 binary group 1
|
||||
// 4 - 7 binary group 2
|
||||
// 8 - 11 binary group 3
|
||||
// 12 - 15 binary group 4
|
||||
// 16 - 19 binary group 5
|
||||
// 20 - 23 binary group 6
|
||||
// 24 - 27 binary group 7
|
||||
// 28 - 31 binary group 8
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class TimeCode
|
||||
{
|
||||
public:
|
||||
|
||||
//---------------------
|
||||
// Bit packing variants
|
||||
//---------------------
|
||||
|
||||
enum Packing
|
||||
{
|
||||
TV60_PACKING, // packing for 60-field television
|
||||
TV50_PACKING, // packing for 50-field television
|
||||
FILM24_PACKING // packing for 24-frame film
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
// Constructors and assignment operator
|
||||
//-------------------------------------
|
||||
|
||||
TimeCode (); // all fields set to 0 or false
|
||||
|
||||
TimeCode (int hours,
|
||||
int minutes,
|
||||
int seconds,
|
||||
int frame,
|
||||
bool dropFrame = false,
|
||||
bool colorFrame = false,
|
||||
bool fieldPhase = false,
|
||||
bool bgf0 = false,
|
||||
bool bgf1 = false,
|
||||
bool bgf2 = false,
|
||||
int binaryGroup1 = 0,
|
||||
int binaryGroup2 = 0,
|
||||
int binaryGroup3 = 0,
|
||||
int binaryGroup4 = 0,
|
||||
int binaryGroup5 = 0,
|
||||
int binaryGroup6 = 0,
|
||||
int binaryGroup7 = 0,
|
||||
int binaryGroup8 = 0);
|
||||
|
||||
TimeCode (unsigned int timeAndFlags,
|
||||
unsigned int userData = 0,
|
||||
Packing packing = TV60_PACKING);
|
||||
|
||||
TimeCode (const TimeCode &other);
|
||||
|
||||
TimeCode & operator = (const TimeCode &other);
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Access to individual fields
|
||||
//----------------------------
|
||||
|
||||
int hours () const;
|
||||
void setHours (int value);
|
||||
|
||||
int minutes () const;
|
||||
void setMinutes (int value);
|
||||
|
||||
int seconds () const;
|
||||
void setSeconds (int value);
|
||||
|
||||
int frame () const;
|
||||
void setFrame (int value);
|
||||
|
||||
bool dropFrame () const;
|
||||
void setDropFrame (bool value);
|
||||
|
||||
bool colorFrame () const;
|
||||
void setColorFrame (bool value);
|
||||
|
||||
bool fieldPhase () const;
|
||||
void setFieldPhase (bool value);
|
||||
|
||||
bool bgf0 () const;
|
||||
void setBgf0 (bool value);
|
||||
|
||||
bool bgf1 () const;
|
||||
void setBgf1 (bool value);
|
||||
|
||||
bool bgf2 () const;
|
||||
void setBgf2 (bool value);
|
||||
|
||||
int binaryGroup (int group) const; // group must be between 1 and 8
|
||||
void setBinaryGroup (int group, int value);
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// Access to packed representations
|
||||
//---------------------------------
|
||||
|
||||
unsigned int timeAndFlags (Packing packing = TV60_PACKING) const;
|
||||
|
||||
void setTimeAndFlags (unsigned int value,
|
||||
Packing packing = TV60_PACKING);
|
||||
|
||||
unsigned int userData () const;
|
||||
|
||||
void setUserData (unsigned int value);
|
||||
|
||||
private:
|
||||
|
||||
unsigned int _time;
|
||||
unsigned int _user;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
72
3rdparty/include/OpenEXR/ImfTimeCodeAttribute.h
vendored
72
3rdparty/include/OpenEXR/ImfTimeCodeAttribute.h
vendored
@ -1,72 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_TIME_CODE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_TIME_CODE_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class TimeCodeAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfTimeCode.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<TimeCode> TimeCodeAttribute;
|
||||
|
||||
template <>
|
||||
const char *TimeCodeAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
void TimeCodeAttribute::writeValueTo (OStream &, int) const;
|
||||
|
||||
template <>
|
||||
void TimeCodeAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfTimeCodeAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
87
3rdparty/include/OpenEXR/ImfVecAttribute.h
vendored
87
3rdparty/include/OpenEXR/ImfVecAttribute.h
vendored
@ -1,87 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_VEC_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_VEC_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class V2iAttribute
|
||||
// class V2fAttribute
|
||||
// class V3iAttribute
|
||||
// class V3fAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include "ImathVec.h"
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::V2i> V2iAttribute;
|
||||
template <> const char *V2iAttribute::staticTypeName ();
|
||||
template <> void V2iAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void V2iAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::V2f> V2fAttribute;
|
||||
template <> const char *V2fAttribute::staticTypeName ();
|
||||
template <> void V2fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void V2fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::V3i> V3iAttribute;
|
||||
template <> const char *V3iAttribute::staticTypeName ();
|
||||
template <> void V3iAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void V3iAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::V3f> V3fAttribute;
|
||||
template <> const char *V3fAttribute::staticTypeName ();
|
||||
template <> void V3fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void V3fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfVecAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
117
3rdparty/include/OpenEXR/ImfVersion.h
vendored
117
3rdparty/include/OpenEXR/ImfVersion.h
vendored
@ -1,117 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_VERSION_H
|
||||
#define INCLUDED_IMF_VERSION_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Magic and version number.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
//
|
||||
// The MAGIC number is stored in the first four bytes of every
|
||||
// OpenEXR image file. This can be used to quickly test whether
|
||||
// a given file is an OpenEXR image file (see isImfMagic(), below).
|
||||
//
|
||||
|
||||
const int MAGIC = 20000630;
|
||||
|
||||
|
||||
//
|
||||
// The second item in each OpenEXR image file, right after the
|
||||
// magic number, is a four-byte file version identifier. Depending
|
||||
// on a file's version identifier, a file reader can enable various
|
||||
// backwards-compatibility switches, or it can quickly reject files
|
||||
// that it cannot read.
|
||||
//
|
||||
// The version identifier is split into an 8-bit version number,
|
||||
// and a 24-bit flags field.
|
||||
//
|
||||
|
||||
const int VERSION_NUMBER_FIELD = 0x000000ff;
|
||||
const int VERSION_FLAGS_FIELD = 0xffffff00;
|
||||
|
||||
|
||||
//
|
||||
// Value that goes into VERSION_NUMBER_FIELD.
|
||||
//
|
||||
|
||||
const int EXR_VERSION = 2;
|
||||
|
||||
|
||||
//
|
||||
// Flags that can go into VERSION_FLAGS_FIELD.
|
||||
// Flags can only occupy the 1 bits in VERSION_FLAGS_FIELD.
|
||||
//
|
||||
|
||||
const int TILED_FLAG = 0x00000200;
|
||||
|
||||
|
||||
//
|
||||
// Bitwise OR of all known flags.
|
||||
//
|
||||
|
||||
const int ALL_FLAGS = TILED_FLAG;
|
||||
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
|
||||
inline bool isTiled (int version) {return !!(version & TILED_FLAG);}
|
||||
inline int makeTiled (int version) {return version | TILED_FLAG;}
|
||||
inline int makeNotTiled (int version) {return version & ~TILED_FLAG;}
|
||||
inline int getVersion (int version) {return version & VERSION_NUMBER_FIELD;}
|
||||
inline int getFlags (int version) {return version & VERSION_FLAGS_FIELD;}
|
||||
inline bool supportsFlags (int flags) {return !(flags & ~ALL_FLAGS);}
|
||||
|
||||
|
||||
//
|
||||
// Given the first four bytes of a file, returns true if the
|
||||
// file is probably an OpenEXR image file, false if not.
|
||||
//
|
||||
|
||||
bool isImfMagic (const char bytes[4]);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
70
3rdparty/include/OpenEXR/ImfWav.h
vendored
70
3rdparty/include/OpenEXR/ImfWav.h
vendored
@ -1,70 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_WAV_H
|
||||
#define INCLUDED_IMF_WAV_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 16-bit Haar Wavelet encoding and decoding
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
void
|
||||
wav2Encode
|
||||
(unsigned short *in, // io: values in[y][x] are transformed in place
|
||||
int nx, // i : x size
|
||||
int ox, // i : x offset
|
||||
int ny, // i : y size
|
||||
int oy, // i : y offset
|
||||
unsigned short mx); // i : maximum in[x][y] value
|
||||
|
||||
void
|
||||
wav2Decode
|
||||
(unsigned short *in, // io: values in[y][x] are transformed in place
|
||||
int nx, // i : x size
|
||||
int ox, // i : x offset
|
||||
int ny, // i : y size
|
||||
int oy, // i : y offset
|
||||
unsigned short mx); // i : maximum in[x][y] value
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
916
3rdparty/include/OpenEXR/ImfXdr.h
vendored
916
3rdparty/include/OpenEXR/ImfXdr.h
vendored
@ -1,916 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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 INCLUDED_IMF_XDR_H
|
||||
#define INCLUDED_IMF_XDR_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Xdr -- routines to convert data between the machine's native
|
||||
// format and a machine-independent external data representation:
|
||||
//
|
||||
// write<R> (T &o, S v); converts a value, v, of type S
|
||||
// into a machine-independent
|
||||
// representation and stores the
|
||||
// result in an output buffer, o.
|
||||
//
|
||||
// read<R> (T &i, S &v); reads the machine-independent
|
||||
// representation of a value of type
|
||||
// S from input buffer i, converts
|
||||
// the value into the machine's native
|
||||
// representation, and stores the result
|
||||
// in v.
|
||||
//
|
||||
// size<S>(); returns the size, in bytes, of the
|
||||
// machine-independent representation
|
||||
// of an object of type S.
|
||||
//
|
||||
// The write() and read() routines are templates; data can be written
|
||||
// to and read from any output or input buffer type T for which a helper
|
||||
// class, R, exits. Class R must define a method to store a char array
|
||||
// in a T, and a method to read a char array from a T:
|
||||
//
|
||||
// struct R
|
||||
// {
|
||||
// static void
|
||||
// writeChars (T &o, const char c[/*n*/], int n)
|
||||
// {
|
||||
// ... // Write c[0], c[1] ... c[n-1] to output buffer o.
|
||||
// }
|
||||
//
|
||||
// static void
|
||||
// readChars (T &i, char c[/*n*/], int n)
|
||||
// {
|
||||
// ... // Read n characters from input buffer i
|
||||
// // and copy them to c[0], c[1] ... c[n-1].
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// Example - writing to and reading from iostreams:
|
||||
//
|
||||
// struct CharStreamIO
|
||||
// {
|
||||
// static void
|
||||
// writeChars (ostream &os, const char c[], int n)
|
||||
// {
|
||||
// os.write (c, n);
|
||||
// }
|
||||
//
|
||||
// static void
|
||||
// readChars (istream &is, char c[], int n)
|
||||
// {
|
||||
// is.read (c, n);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// ...
|
||||
//
|
||||
// Xdr::write<CharStreamIO> (os, 3);
|
||||
// Xdr::write<CharStreamIO> (os, 5.0);
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfInt64.h>
|
||||
#include "IexMathExc.h"
|
||||
#include "half.h"
|
||||
#include <limits.h>
|
||||
|
||||
namespace Imf {
|
||||
namespace Xdr {
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Write data to an output stream
|
||||
//-------------------------------
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, bool v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, char v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, signed char v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, unsigned char v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, signed short v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, unsigned short v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, signed int v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, unsigned int v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, signed long v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, unsigned long v);
|
||||
|
||||
#if ULONG_MAX != 18446744073709551615LU
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, Int64 v);
|
||||
|
||||
#endif
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, float v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, double v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, half v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, const char v[/*n*/], int n); // fixed-size char array
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, const char v[]); // zero-terminated string
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Append padding bytes to an output stream
|
||||
//-----------------------------------------
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
pad (T &out, int n); // write n padding bytes
|
||||
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Read data from an input stream
|
||||
//-------------------------------
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, bool &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, char &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, signed char &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, unsigned char &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, signed short &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, unsigned short &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, signed int &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, unsigned int &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, signed long &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, unsigned long &v);
|
||||
|
||||
#if ULONG_MAX != 18446744073709551615LU
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, Int64 &v);
|
||||
|
||||
#endif
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, float &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, double &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, half &v);
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, char v[/*n*/], int n); // fixed-size char array
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, int n, char v[/*n*/]); // zero-terminated string
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Skip over padding bytes in an input stream
|
||||
//-------------------------------------------
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
skip (T &in, int n); // skip n padding bytes
|
||||
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Size of the machine-independent
|
||||
// representation of an object of type S
|
||||
//--------------------------------------
|
||||
|
||||
template <class S>
|
||||
int
|
||||
size ();
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
writeSignedChars (T &out, const signed char c[], int n)
|
||||
{
|
||||
S::writeChars (out, (const char *) c, n);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
writeUnsignedChars (T &out, const unsigned char c[], int n)
|
||||
{
|
||||
S::writeChars (out, (const char *) c, n);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
readSignedChars (T &in, signed char c[], int n)
|
||||
{
|
||||
S::readChars (in, (char *) c, n);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
readUnsignedChars (T &in, unsigned char c[], int n)
|
||||
{
|
||||
S::readChars (in, (char *) c, n);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
write (T &out, bool v)
|
||||
{
|
||||
char c = !!v;
|
||||
S::writeChars (out, &c, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
write (T &out, char v)
|
||||
{
|
||||
S::writeChars (out, &v, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
write (T &out, signed char v)
|
||||
{
|
||||
writeSignedChars<S> (out, &v, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
write (T &out, unsigned char v)
|
||||
{
|
||||
writeUnsignedChars<S> (out, &v, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, signed short v)
|
||||
{
|
||||
signed char b[2];
|
||||
|
||||
b[0] = (signed char) (v);
|
||||
b[1] = (signed char) (v >> 8);
|
||||
|
||||
writeSignedChars<S> (out, b, 2);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, unsigned short v)
|
||||
{
|
||||
unsigned char b[2];
|
||||
|
||||
b[0] = (unsigned char) (v);
|
||||
b[1] = (unsigned char) (v >> 8);
|
||||
|
||||
writeUnsignedChars<S> (out, b, 2);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, signed int v)
|
||||
{
|
||||
signed char b[4];
|
||||
|
||||
b[0] = (signed char) (v);
|
||||
b[1] = (signed char) (v >> 8);
|
||||
b[2] = (signed char) (v >> 16);
|
||||
b[3] = (signed char) (v >> 24);
|
||||
|
||||
writeSignedChars<S> (out, b, 4);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, unsigned int v)
|
||||
{
|
||||
unsigned char b[4];
|
||||
|
||||
b[0] = (unsigned char) (v);
|
||||
b[1] = (unsigned char) (v >> 8);
|
||||
b[2] = (unsigned char) (v >> 16);
|
||||
b[3] = (unsigned char) (v >> 24);
|
||||
|
||||
writeUnsignedChars<S> (out, b, 4);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, signed long v)
|
||||
{
|
||||
signed char b[8];
|
||||
|
||||
b[0] = (signed char) (v);
|
||||
b[1] = (signed char) (v >> 8);
|
||||
b[2] = (signed char) (v >> 16);
|
||||
b[3] = (signed char) (v >> 24);
|
||||
|
||||
#if LONG_MAX == 2147483647
|
||||
|
||||
if (v >= 0)
|
||||
{
|
||||
b[4] = 0;
|
||||
b[5] = 0;
|
||||
b[6] = 0;
|
||||
b[7] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
b[4] = ~0;
|
||||
b[5] = ~0;
|
||||
b[6] = ~0;
|
||||
b[7] = ~0;
|
||||
}
|
||||
|
||||
#elif LONG_MAX == 9223372036854775807L
|
||||
|
||||
b[4] = (signed char) (v >> 32);
|
||||
b[5] = (signed char) (v >> 40);
|
||||
b[6] = (signed char) (v >> 48);
|
||||
b[7] = (signed char) (v >> 56);
|
||||
|
||||
#else
|
||||
|
||||
#error write<T> (T &out, signed long v) not implemented
|
||||
|
||||
#endif
|
||||
|
||||
writeSignedChars<S> (out, b, 8);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, unsigned long v)
|
||||
{
|
||||
unsigned char b[8];
|
||||
|
||||
b[0] = (unsigned char) (v);
|
||||
b[1] = (unsigned char) (v >> 8);
|
||||
b[2] = (unsigned char) (v >> 16);
|
||||
b[3] = (unsigned char) (v >> 24);
|
||||
|
||||
#if ULONG_MAX == 4294967295U
|
||||
|
||||
b[4] = 0;
|
||||
b[5] = 0;
|
||||
b[6] = 0;
|
||||
b[7] = 0;
|
||||
|
||||
#elif ULONG_MAX == 18446744073709551615LU
|
||||
|
||||
b[4] = (unsigned char) (v >> 32);
|
||||
b[5] = (unsigned char) (v >> 40);
|
||||
b[6] = (unsigned char) (v >> 48);
|
||||
b[7] = (unsigned char) (v >> 56);
|
||||
|
||||
#else
|
||||
|
||||
#error write<T> (T &out, unsigned long v) not implemented
|
||||
|
||||
#endif
|
||||
|
||||
writeUnsignedChars<S> (out, b, 8);
|
||||
}
|
||||
|
||||
|
||||
#if ULONG_MAX != 18446744073709551615LU
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, Int64 v)
|
||||
{
|
||||
unsigned char b[8];
|
||||
|
||||
b[0] = (unsigned char) (v);
|
||||
b[1] = (unsigned char) (v >> 8);
|
||||
b[2] = (unsigned char) (v >> 16);
|
||||
b[3] = (unsigned char) (v >> 24);
|
||||
b[4] = (unsigned char) (v >> 32);
|
||||
b[5] = (unsigned char) (v >> 40);
|
||||
b[6] = (unsigned char) (v >> 48);
|
||||
b[7] = (unsigned char) (v >> 56);
|
||||
|
||||
writeUnsignedChars<S> (out, b, 8);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, float v)
|
||||
{
|
||||
union {unsigned int i; float f;} u;
|
||||
u.f = v;
|
||||
|
||||
unsigned char b[4];
|
||||
|
||||
b[0] = (unsigned char) (u.i);
|
||||
b[1] = (unsigned char) (u.i >> 8);
|
||||
b[2] = (unsigned char) (u.i >> 16);
|
||||
b[3] = (unsigned char) (u.i >> 24);
|
||||
|
||||
writeUnsignedChars<S> (out, b, 4);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, double v)
|
||||
{
|
||||
union {Int64 i; double d;} u;
|
||||
u.d = v;
|
||||
|
||||
unsigned char b[8];
|
||||
|
||||
b[0] = (unsigned char) (u.i);
|
||||
b[1] = (unsigned char) (u.i >> 8);
|
||||
b[2] = (unsigned char) (u.i >> 16);
|
||||
b[3] = (unsigned char) (u.i >> 24);
|
||||
b[4] = (unsigned char) (u.i >> 32);
|
||||
b[5] = (unsigned char) (u.i >> 40);
|
||||
b[6] = (unsigned char) (u.i >> 48);
|
||||
b[7] = (unsigned char) (u.i >> 56);
|
||||
|
||||
writeUnsignedChars<S> (out, b, 8);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
write (T &out, half v)
|
||||
{
|
||||
unsigned char b[2];
|
||||
|
||||
b[0] = (unsigned char) (v.bits());
|
||||
b[1] = (unsigned char) (v.bits() >> 8);
|
||||
|
||||
writeUnsignedChars<S> (out, b, 2);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
write (T &out, const char v[], int n) // fixed-size char array
|
||||
{
|
||||
S::writeChars (out, v, n);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
write (T &out, const char v[]) // zero-terminated string
|
||||
{
|
||||
while (*v)
|
||||
{
|
||||
S::writeChars (out, v, 1);
|
||||
++v;
|
||||
}
|
||||
|
||||
S::writeChars (out, v, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
pad (T &out, int n) // add n padding bytes
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
const char c = 0;
|
||||
S::writeChars (out, &c, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
read (T &in, bool &v)
|
||||
{
|
||||
char c;
|
||||
|
||||
S::readChars (in, &c, 1);
|
||||
v = !!c;
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
read (T &in, char &v)
|
||||
{
|
||||
S::readChars (in, &v, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
read (T &in, signed char &v)
|
||||
{
|
||||
readSignedChars<S> (in, &v, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
read (T &in, unsigned char &v)
|
||||
{
|
||||
readUnsignedChars<S> (in, &v, 1);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, signed short &v)
|
||||
{
|
||||
signed char b[2];
|
||||
|
||||
readSignedChars<S> (in, b, 2);
|
||||
|
||||
v = (b[0] & 0x00ff) |
|
||||
(b[1] << 8);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, unsigned short &v)
|
||||
{
|
||||
unsigned char b[2];
|
||||
|
||||
readUnsignedChars<S> (in, b, 2);
|
||||
|
||||
v = (b[0] & 0x00ff) |
|
||||
(b[1] << 8);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, signed int &v)
|
||||
{
|
||||
signed char b[4];
|
||||
|
||||
readSignedChars<S> (in, b, 4);
|
||||
|
||||
v = (b[0] & 0x000000ff) |
|
||||
((b[1] << 8) & 0x0000ff00) |
|
||||
((b[2] << 16) & 0x00ff0000) |
|
||||
(b[3] << 24);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, unsigned int &v)
|
||||
{
|
||||
unsigned char b[4];
|
||||
|
||||
readUnsignedChars<S> (in, b, 4);
|
||||
|
||||
v = (b[0] & 0x000000ff) |
|
||||
((b[1] << 8) & 0x0000ff00) |
|
||||
((b[2] << 16) & 0x00ff0000) |
|
||||
(b[3] << 24);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, signed long &v)
|
||||
{
|
||||
signed char b[8];
|
||||
|
||||
readSignedChars<S> (in, b, 8);
|
||||
|
||||
#if LONG_MAX == 2147483647
|
||||
|
||||
v = (b[0] & 0x000000ff) |
|
||||
((b[1] << 8) & 0x0000ff00) |
|
||||
((b[2] << 16) & 0x00ff0000) |
|
||||
(b[3] << 24);
|
||||
|
||||
if (( b[4] || b[5] || b[6] || b[7]) &&
|
||||
(~b[4] || ~b[5] || ~b[6] || ~b[7]))
|
||||
{
|
||||
throw Iex::OverflowExc ("Long int overflow - read a large "
|
||||
"64-bit integer in a 32-bit process.");
|
||||
}
|
||||
|
||||
#elif LONG_MAX == 9223372036854775807L
|
||||
|
||||
v = ((long) b[0] & 0x00000000000000ff) |
|
||||
(((long) b[1] << 8) & 0x000000000000ff00) |
|
||||
(((long) b[2] << 16) & 0x0000000000ff0000) |
|
||||
(((long) b[3] << 24) & 0x00000000ff000000) |
|
||||
(((long) b[4] << 32) & 0x000000ff00000000) |
|
||||
(((long) b[5] << 40) & 0x0000ff0000000000) |
|
||||
(((long) b[6] << 48) & 0x00ff000000000000) |
|
||||
((long) b[7] << 56);
|
||||
|
||||
#else
|
||||
|
||||
#error read<T> (T &in, signed long &v) not implemented
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, unsigned long &v)
|
||||
{
|
||||
unsigned char b[8];
|
||||
|
||||
readUnsignedChars<S> (in, b, 8);
|
||||
|
||||
#if ULONG_MAX == 4294967295U
|
||||
|
||||
v = (b[0] & 0x000000ff) |
|
||||
((b[1] << 8) & 0x0000ff00) |
|
||||
((b[2] << 16) & 0x00ff0000) |
|
||||
(b[3] << 24);
|
||||
|
||||
if (b[4] || b[5] || b[6] || b[7])
|
||||
{
|
||||
throw Iex::OverflowExc ("Long int overflow - read a large "
|
||||
"64-bit integer in a 32-bit process.");
|
||||
}
|
||||
|
||||
#elif ULONG_MAX == 18446744073709551615LU
|
||||
|
||||
v = ((unsigned long) b[0] & 0x00000000000000ff) |
|
||||
(((unsigned long) b[1] << 8) & 0x000000000000ff00) |
|
||||
(((unsigned long) b[2] << 16) & 0x0000000000ff0000) |
|
||||
(((unsigned long) b[3] << 24) & 0x00000000ff000000) |
|
||||
(((unsigned long) b[4] << 32) & 0x000000ff00000000) |
|
||||
(((unsigned long) b[5] << 40) & 0x0000ff0000000000) |
|
||||
(((unsigned long) b[6] << 48) & 0x00ff000000000000) |
|
||||
((unsigned long) b[7] << 56);
|
||||
|
||||
#else
|
||||
|
||||
#error read<T> (T &in, unsigned long &v) not implemented
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if ULONG_MAX != 18446744073709551615LU
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, Int64 &v)
|
||||
{
|
||||
unsigned char b[8];
|
||||
|
||||
readUnsignedChars<S> (in, b, 8);
|
||||
|
||||
v = ((Int64) b[0] & 0x00000000000000ffLL) |
|
||||
(((Int64) b[1] << 8) & 0x000000000000ff00LL) |
|
||||
(((Int64) b[2] << 16) & 0x0000000000ff0000LL) |
|
||||
(((Int64) b[3] << 24) & 0x00000000ff000000LL) |
|
||||
(((Int64) b[4] << 32) & 0x000000ff00000000LL) |
|
||||
(((Int64) b[5] << 40) & 0x0000ff0000000000LL) |
|
||||
(((Int64) b[6] << 48) & 0x00ff000000000000LL) |
|
||||
((Int64) b[7] << 56);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, float &v)
|
||||
{
|
||||
unsigned char b[4];
|
||||
|
||||
readUnsignedChars<S> (in, b, 4);
|
||||
|
||||
union {unsigned int i; float f;} u;
|
||||
|
||||
u.i = (b[0] & 0x000000ff) |
|
||||
((b[1] << 8) & 0x0000ff00) |
|
||||
((b[2] << 16) & 0x00ff0000) |
|
||||
(b[3] << 24);
|
||||
|
||||
v = u.f;
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, double &v)
|
||||
{
|
||||
unsigned char b[8];
|
||||
|
||||
readUnsignedChars<S> (in, b, 8);
|
||||
|
||||
union {Int64 i; double d;} u;
|
||||
|
||||
u.i = ((Int64) b[0] & 0x00000000000000ffULL) |
|
||||
(((Int64) b[1] << 8) & 0x000000000000ff00ULL) |
|
||||
(((Int64) b[2] << 16) & 0x0000000000ff0000ULL) |
|
||||
(((Int64) b[3] << 24) & 0x00000000ff000000ULL) |
|
||||
(((Int64) b[4] << 32) & 0x000000ff00000000ULL) |
|
||||
(((Int64) b[5] << 40) & 0x0000ff0000000000ULL) |
|
||||
(((Int64) b[6] << 48) & 0x00ff000000000000ULL) |
|
||||
((Int64) b[7] << 56);
|
||||
|
||||
v = u.d;
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
read (T &in, half &v)
|
||||
{
|
||||
unsigned char b[2];
|
||||
|
||||
readUnsignedChars<S> (in, b, 2);
|
||||
|
||||
v.setBits ((b[0] & 0x00ff) | (b[1] << 8));
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
inline void
|
||||
read (T &in, char v[], int n) // fixed-size char array
|
||||
{
|
||||
S::readChars (in, v, n);
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
read (T &in, int n, char v[]) // zero-terminated string
|
||||
{
|
||||
while (n >= 0)
|
||||
{
|
||||
S::readChars (in, v, 1);
|
||||
|
||||
if (*v == 0)
|
||||
break;
|
||||
|
||||
--n;
|
||||
++v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
void
|
||||
skip (T &in, int n) // skip n padding bytes
|
||||
{
|
||||
char c[1024];
|
||||
|
||||
while (n >= (int) sizeof (c))
|
||||
{
|
||||
if (!S::readChars (in, c, sizeof (c)))
|
||||
return;
|
||||
|
||||
n -= sizeof (c);
|
||||
}
|
||||
|
||||
if (n >= 1)
|
||||
S::readChars (in, c, n);
|
||||
}
|
||||
|
||||
|
||||
template <> inline int size <bool> () {return 1;}
|
||||
template <> inline int size <char> () {return 1;}
|
||||
template <> inline int size <signed char> () {return 1;}
|
||||
template <> inline int size <unsigned char> () {return 1;}
|
||||
template <> inline int size <signed short> () {return 2;}
|
||||
template <> inline int size <unsigned short> () {return 2;}
|
||||
template <> inline int size <signed int> () {return 4;}
|
||||
template <> inline int size <unsigned int> () {return 4;}
|
||||
template <> inline int size <signed long> () {return 8;}
|
||||
template <> inline int size <unsigned long> () {return 8;}
|
||||
template <> inline int size <float> () {return 4;}
|
||||
template <> inline int size <double> () {return 8;}
|
||||
template <> inline int size <half> () {return 2;}
|
||||
|
||||
|
||||
} // namespace Xdr
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
43
3rdparty/include/OpenEXR/OpenEXRConfig.h
vendored
43
3rdparty/include/OpenEXR/OpenEXRConfig.h
vendored
@ -1,43 +0,0 @@
|
||||
//
|
||||
// This is a hard-coded config file for Windows platforms. Don't
|
||||
// change any of these settings.
|
||||
//
|
||||
|
||||
//
|
||||
// Define and set to 1 if the target system has POSIX thread support
|
||||
// and you want OpenEXR to use it for multithreaded file I/O.
|
||||
//
|
||||
|
||||
/* #undef HAVE_PTHREAD */
|
||||
|
||||
//
|
||||
// Define and set to 1 if the target system supports POSIX semaphores
|
||||
// and you want OpenEXR to use them; otherwise, OpenEXR will use its
|
||||
// own semaphore implementation.
|
||||
//
|
||||
|
||||
/* #undef HAVE_POSIX_SEMAPHORES */
|
||||
|
||||
//
|
||||
// Define and set to 1 if the target system is a Darwin-based system
|
||||
// (e.g., OS X).
|
||||
//
|
||||
|
||||
/* #undef HAVE_DARWIN */
|
||||
|
||||
//
|
||||
// Define and set to 1 if the target system supports a proc filesystem
|
||||
// compatible with the Linux kernel's proc filesystem. Note that this
|
||||
// is only used by a program in the IlmImfTest test suite, it's not
|
||||
// used by any OpenEXR library or application code.
|
||||
//
|
||||
|
||||
/* #undef HAVE_LINUX_PROCFS */
|
||||
|
||||
//
|
||||
// Define and set to 1 if the target system has a complete <iomanip>
|
||||
// implementation, specifically if it supports the std::right
|
||||
// formatter.
|
||||
//
|
||||
|
||||
#define HAVE_COMPLETE_IOMANIP 1
|
775
3rdparty/include/OpenEXR/half.h
vendored
775
3rdparty/include/OpenEXR/half.h
vendored
@ -1,775 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Primary authors:
|
||||
// Florian Kainz <kainz@ilm.com>
|
||||
// Rod Bogart <rgb@ilm.com>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// half -- a 16-bit floating point number class:
|
||||
//
|
||||
// Type half can represent positive and negative numbers, whose
|
||||
// magnitude is between roughly 6.1e-5 and 6.5e+4, with a relative
|
||||
// error of 9.8e-4; numbers smaller than 6.1e-5 can be represented
|
||||
// with an absolute error of 6.0e-8. All integers from -2048 to
|
||||
// +2048 can be represented exactly.
|
||||
//
|
||||
// Type half behaves (almost) like the built-in C++ floating point
|
||||
// types. In arithmetic expressions, half, float and double can be
|
||||
// mixed freely. Here are a few examples:
|
||||
//
|
||||
// half a (3.5);
|
||||
// float b (a + sqrt (a));
|
||||
// a += b;
|
||||
// b += a;
|
||||
// b = a + 7;
|
||||
//
|
||||
// Conversions from half to float are lossless; all half numbers
|
||||
// are exactly representable as floats.
|
||||
//
|
||||
// Conversions from float to half may not preserve the float's
|
||||
// value exactly. If a float is not representable as a half, the
|
||||
// float value is rounded to the nearest representable half. If
|
||||
// a float value is exactly in the middle between the two closest
|
||||
// representable half values, then the float value is rounded to
|
||||
// the half with the greater magnitude.
|
||||
//
|
||||
// Overflows during float-to-half conversions cause arithmetic
|
||||
// exceptions. An overflow occurs when the float value to be
|
||||
// converted is too large to be represented as a half, or if the
|
||||
// float value is an infinity or a NAN.
|
||||
//
|
||||
// The implementation of type half makes the following assumptions
|
||||
// about the implementation of the built-in C++ types:
|
||||
//
|
||||
// float is an IEEE 754 single-precision number
|
||||
// sizeof (float) == 4
|
||||
// sizeof (unsigned int) == sizeof (float)
|
||||
// alignof (unsigned int) == alignof (float)
|
||||
// sizeof (unsigned short) == 2
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef _HALF_H_
|
||||
#define _HALF_H_
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class half
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------
|
||||
// Constructors
|
||||
//-------------
|
||||
|
||||
half (); // no initialization
|
||||
half (float f);
|
||||
|
||||
|
||||
//--------------------
|
||||
// Conversion to float
|
||||
//--------------------
|
||||
|
||||
operator float () const;
|
||||
|
||||
|
||||
//------------
|
||||
// Unary minus
|
||||
//------------
|
||||
|
||||
half operator - () const;
|
||||
|
||||
|
||||
//-----------
|
||||
// Assignment
|
||||
//-----------
|
||||
|
||||
half & operator = (half h);
|
||||
half & operator = (float f);
|
||||
|
||||
half & operator += (half h);
|
||||
half & operator += (float f);
|
||||
|
||||
half & operator -= (half h);
|
||||
half & operator -= (float f);
|
||||
|
||||
half & operator *= (half h);
|
||||
half & operator *= (float f);
|
||||
|
||||
half & operator /= (half h);
|
||||
half & operator /= (float f);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Round to n-bit precision (n should be between 0 and 10).
|
||||
// After rounding, the significand's 10-n least significant
|
||||
// bits will be zero.
|
||||
//---------------------------------------------------------
|
||||
|
||||
half round (unsigned int n) const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Classification:
|
||||
//
|
||||
// h.isFinite() returns true if h is a normalized number,
|
||||
// a denormalized number or zero
|
||||
//
|
||||
// h.isNormalized() returns true if h is a normalized number
|
||||
//
|
||||
// h.isDenormalized() returns true if h is a denormalized number
|
||||
//
|
||||
// h.isZero() returns true if h is zero
|
||||
//
|
||||
// h.isNan() returns true if h is a NAN
|
||||
//
|
||||
// h.isInfinity() returns true if h is a positive
|
||||
// or a negative infinity
|
||||
//
|
||||
// h.isNegative() returns true if the sign bit of h
|
||||
// is set (negative)
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
bool isFinite () const;
|
||||
bool isNormalized () const;
|
||||
bool isDenormalized () const;
|
||||
bool isZero () const;
|
||||
bool isNan () const;
|
||||
bool isInfinity () const;
|
||||
bool isNegative () const;
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Special values
|
||||
//
|
||||
// posInf() returns +infinity
|
||||
//
|
||||
// negInf() returns +infinity
|
||||
//
|
||||
// qNan() returns a NAN with the bit
|
||||
// pattern 0111111111111111
|
||||
//
|
||||
// sNan() returns a NAN with the bit
|
||||
// pattern 0111110111111111
|
||||
//--------------------------------------------
|
||||
|
||||
static half posInf ();
|
||||
static half negInf ();
|
||||
static half qNan ();
|
||||
static half sNan ();
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Access to the internal representation
|
||||
//--------------------------------------
|
||||
|
||||
unsigned short bits () const;
|
||||
void setBits (unsigned short bits);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
union uif
|
||||
{
|
||||
unsigned int i;
|
||||
float f;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
static short convert (int i);
|
||||
static float overflow ();
|
||||
|
||||
unsigned short _h;
|
||||
|
||||
//---------------------------------------------------
|
||||
// Windows dynamic libraries don't like static
|
||||
// member variables.
|
||||
//---------------------------------------------------
|
||||
#ifndef OPENEXR_DLL
|
||||
static const uif _toFloat[1 << 16];
|
||||
static const unsigned short _eLut[1 << 9];
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(OPENEXR_DLL)
|
||||
//--------------------------------------
|
||||
// Lookup tables defined for Windows DLL
|
||||
//--------------------------------------
|
||||
#if defined(HALF_EXPORTS)
|
||||
extern __declspec(dllexport) half::uif _toFloat[1 << 16];
|
||||
extern __declspec(dllexport) unsigned short _eLut[1 << 9];
|
||||
#else
|
||||
extern __declspec(dllimport) half::uif _toFloat[1 << 16];
|
||||
extern __declspec(dllimport) unsigned short _eLut[1 << 9];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//-----------
|
||||
// Stream I/O
|
||||
//-----------
|
||||
|
||||
std::ostream & operator << (std::ostream &os, half h);
|
||||
std::istream & operator >> (std::istream &is, half &h);
|
||||
|
||||
|
||||
//----------
|
||||
// Debugging
|
||||
//----------
|
||||
|
||||
void printBits (std::ostream &os, half h);
|
||||
void printBits (std::ostream &os, float f);
|
||||
void printBits (char c[19], half h);
|
||||
void printBits (char c[35], float f);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Limits
|
||||
//
|
||||
// Visual C++ will complain if HALF_MIN, HALF_NRM_MIN etc. are not float
|
||||
// constants, but at least one other compiler (gcc 2.96) produces incorrect
|
||||
// results if they are.
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
|
||||
#define HALF_MIN 5.96046448e-08f // Smallest positive half
|
||||
|
||||
#define HALF_NRM_MIN 6.10351562e-05f // Smallest positive normalized half
|
||||
|
||||
#define HALF_MAX 65504.0f // Largest positive half
|
||||
|
||||
#define HALF_EPSILON 0.00097656f // Smallest positive e for which
|
||||
// half (1.0 + e) != half (1.0)
|
||||
#else
|
||||
|
||||
#define HALF_MIN 5.96046448e-08 // Smallest positive half
|
||||
|
||||
#define HALF_NRM_MIN 6.10351562e-05 // Smallest positive normalized half
|
||||
|
||||
#define HALF_MAX 65504.0 // Largest positive half
|
||||
|
||||
#define HALF_EPSILON 0.00097656 // Smallest positive e for which
|
||||
// half (1.0 + e) != half (1.0)
|
||||
#endif
|
||||
|
||||
|
||||
#define HALF_MANT_DIG 11 // Number of digits in mantissa
|
||||
// (significand + hidden leading 1)
|
||||
|
||||
#define HALF_DIG 2 // Number of base 10 digits that
|
||||
// can be represented without change
|
||||
|
||||
#define HALF_RADIX 2 // Base of the exponent
|
||||
|
||||
#define HALF_MIN_EXP -13 // Minimum negative integer such that
|
||||
// HALF_RADIX raised to the power of
|
||||
// one less than that integer is a
|
||||
// normalized half
|
||||
|
||||
#define HALF_MAX_EXP 16 // Maximum positive integer such that
|
||||
// HALF_RADIX raised to the power of
|
||||
// one less than that integer is a
|
||||
// normalized half
|
||||
|
||||
#define HALF_MIN_10_EXP -4 // Minimum positive integer such
|
||||
// that 10 raised to that power is
|
||||
// a normalized half
|
||||
|
||||
#define HALF_MAX_10_EXP 4 // Maximum positive integer such
|
||||
// that 10 raised to that power is
|
||||
// a normalized half
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Implementation --
|
||||
//
|
||||
// Representation of a float:
|
||||
//
|
||||
// We assume that a float, f, is an IEEE 754 single-precision
|
||||
// floating point number, whose bits are arranged as follows:
|
||||
//
|
||||
// 31 (msb)
|
||||
// |
|
||||
// | 30 23
|
||||
// | | |
|
||||
// | | | 22 0 (lsb)
|
||||
// | | | | |
|
||||
// X XXXXXXXX XXXXXXXXXXXXXXXXXXXXXXX
|
||||
//
|
||||
// s e m
|
||||
//
|
||||
// S is the sign-bit, e is the exponent and m is the significand.
|
||||
//
|
||||
// If e is between 1 and 254, f is a normalized number:
|
||||
//
|
||||
// s e-127
|
||||
// f = (-1) * 2 * 1.m
|
||||
//
|
||||
// If e is 0, and m is not zero, f is a denormalized number:
|
||||
//
|
||||
// s -126
|
||||
// f = (-1) * 2 * 0.m
|
||||
//
|
||||
// If e and m are both zero, f is zero:
|
||||
//
|
||||
// f = 0.0
|
||||
//
|
||||
// If e is 255, f is an "infinity" or "not a number" (NAN),
|
||||
// depending on whether m is zero or not.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// 0 00000000 00000000000000000000000 = 0.0
|
||||
// 0 01111110 00000000000000000000000 = 0.5
|
||||
// 0 01111111 00000000000000000000000 = 1.0
|
||||
// 0 10000000 00000000000000000000000 = 2.0
|
||||
// 0 10000000 10000000000000000000000 = 3.0
|
||||
// 1 10000101 11110000010000000000000 = -124.0625
|
||||
// 0 11111111 00000000000000000000000 = +infinity
|
||||
// 1 11111111 00000000000000000000000 = -infinity
|
||||
// 0 11111111 10000000000000000000000 = NAN
|
||||
// 1 11111111 11111111111111111111111 = NAN
|
||||
//
|
||||
// Representation of a half:
|
||||
//
|
||||
// Here is the bit-layout for a half number, h:
|
||||
//
|
||||
// 15 (msb)
|
||||
// |
|
||||
// | 14 10
|
||||
// | | |
|
||||
// | | | 9 0 (lsb)
|
||||
// | | | | |
|
||||
// X XXXXX XXXXXXXXXX
|
||||
//
|
||||
// s e m
|
||||
//
|
||||
// S is the sign-bit, e is the exponent and m is the significand.
|
||||
//
|
||||
// If e is between 1 and 30, h is a normalized number:
|
||||
//
|
||||
// s e-15
|
||||
// h = (-1) * 2 * 1.m
|
||||
//
|
||||
// If e is 0, and m is not zero, h is a denormalized number:
|
||||
//
|
||||
// S -14
|
||||
// h = (-1) * 2 * 0.m
|
||||
//
|
||||
// If e and m are both zero, h is zero:
|
||||
//
|
||||
// h = 0.0
|
||||
//
|
||||
// If e is 31, h is an "infinity" or "not a number" (NAN),
|
||||
// depending on whether m is zero or not.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// 0 00000 0000000000 = 0.0
|
||||
// 0 01110 0000000000 = 0.5
|
||||
// 0 01111 0000000000 = 1.0
|
||||
// 0 10000 0000000000 = 2.0
|
||||
// 0 10000 1000000000 = 3.0
|
||||
// 1 10101 1111000001 = -124.0625
|
||||
// 0 11111 0000000000 = +infinity
|
||||
// 1 11111 0000000000 = -infinity
|
||||
// 0 11111 1000000000 = NAN
|
||||
// 1 11111 1111111111 = NAN
|
||||
//
|
||||
// Conversion:
|
||||
//
|
||||
// Converting from a float to a half requires some non-trivial bit
|
||||
// manipulations. In some cases, this makes conversion relatively
|
||||
// slow, but the most common case is accelerated via table lookups.
|
||||
//
|
||||
// Converting back from a half to a float is easier because we don't
|
||||
// have to do any rounding. In addition, there are only 65536
|
||||
// different half numbers; we can convert each of those numbers once
|
||||
// and store the results in a table. Later, all conversions can be
|
||||
// done using only simple table lookups.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------
|
||||
// Simple constructors
|
||||
//--------------------
|
||||
|
||||
inline
|
||||
half::half ()
|
||||
{
|
||||
// no initialization
|
||||
}
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Half-from-float constructor
|
||||
//----------------------------
|
||||
|
||||
inline
|
||||
half::half (float f)
|
||||
{
|
||||
if (f == 0)
|
||||
{
|
||||
//
|
||||
// Common special case - zero.
|
||||
// For speed, we don't preserve the zero's sign.
|
||||
//
|
||||
|
||||
_h = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// We extract the combined sign and exponent, e, from our
|
||||
// floating-point number, f. Then we convert e to the sign
|
||||
// and exponent of the half number via a table lookup.
|
||||
//
|
||||
// For the most common case, where a normalized half is produced,
|
||||
// the table lookup returns a non-zero value; in this case, all
|
||||
// we have to do, is round f's significand to 10 bits and combine
|
||||
// the result with e.
|
||||
//
|
||||
// For all other cases (overflow, zeroes, denormalized numbers
|
||||
// resulting from underflow, infinities and NANs), the table
|
||||
// lookup returns zero, and we call a longer, non-inline function
|
||||
// to do the float-to-half conversion.
|
||||
//
|
||||
|
||||
uif x;
|
||||
|
||||
x.f = f;
|
||||
|
||||
register int e = (x.i >> 23) & 0x000001ff;
|
||||
|
||||
e = _eLut[e];
|
||||
|
||||
if (e)
|
||||
{
|
||||
//
|
||||
// Simple case - round the significand and
|
||||
// combine it with the sign and exponent.
|
||||
//
|
||||
|
||||
_h = e + (((x.i & 0x007fffff) + 0x00001000) >> 13);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Difficult case - call a function.
|
||||
//
|
||||
|
||||
_h = convert (x.i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// Half-to-float conversion via table lookup
|
||||
//------------------------------------------
|
||||
|
||||
inline
|
||||
half::operator float () const
|
||||
{
|
||||
return _toFloat[_h].f;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------
|
||||
// Round to n-bit precision
|
||||
//-------------------------
|
||||
|
||||
inline half
|
||||
half::round (unsigned int n) const
|
||||
{
|
||||
//
|
||||
// Parameter check.
|
||||
//
|
||||
|
||||
if (n >= 10)
|
||||
return *this;
|
||||
|
||||
//
|
||||
// Disassemble h into the sign, s,
|
||||
// and the combined exponent and significand, e.
|
||||
//
|
||||
|
||||
unsigned short s = _h & 0x8000;
|
||||
unsigned short e = _h & 0x7fff;
|
||||
|
||||
//
|
||||
// Round the exponent and significand to the nearest value
|
||||
// where ones occur only in the (10-n) most significant bits.
|
||||
// Note that the exponent adjusts automatically if rounding
|
||||
// up causes the significand to overflow.
|
||||
//
|
||||
|
||||
e >>= 9 - n;
|
||||
e += e & 1;
|
||||
e <<= 9 - n;
|
||||
|
||||
//
|
||||
// Check for exponent overflow.
|
||||
//
|
||||
|
||||
if (e >= 0x7c00)
|
||||
{
|
||||
//
|
||||
// Overflow occurred -- truncate instead of rounding.
|
||||
//
|
||||
|
||||
e = _h;
|
||||
e >>= 10 - n;
|
||||
e <<= 10 - n;
|
||||
}
|
||||
|
||||
//
|
||||
// Put the original sign bit back.
|
||||
//
|
||||
|
||||
half h;
|
||||
h._h = s | e;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------
|
||||
// Other inline functions
|
||||
//-----------------------
|
||||
|
||||
inline half
|
||||
half::operator - () const
|
||||
{
|
||||
half h;
|
||||
h._h = _h ^ 0x8000;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator = (half h)
|
||||
{
|
||||
_h = h._h;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator = (float f)
|
||||
{
|
||||
*this = half (f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator += (half h)
|
||||
{
|
||||
*this = half (float (*this) + float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator += (float f)
|
||||
{
|
||||
*this = half (float (*this) + f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator -= (half h)
|
||||
{
|
||||
*this = half (float (*this) - float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator -= (float f)
|
||||
{
|
||||
*this = half (float (*this) - f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator *= (half h)
|
||||
{
|
||||
*this = half (float (*this) * float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator *= (float f)
|
||||
{
|
||||
*this = half (float (*this) * f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator /= (half h)
|
||||
{
|
||||
*this = half (float (*this) / float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator /= (float f)
|
||||
{
|
||||
*this = half (float (*this) / f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isFinite () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
return e < 31;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isNormalized () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
return e > 0 && e < 31;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isDenormalized () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
unsigned short m = _h & 0x3ff;
|
||||
return e == 0 && m != 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isZero () const
|
||||
{
|
||||
return (_h & 0x7fff) == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isNan () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
unsigned short m = _h & 0x3ff;
|
||||
return e == 31 && m != 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isInfinity () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
unsigned short m = _h & 0x3ff;
|
||||
return e == 31 && m == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isNegative () const
|
||||
{
|
||||
return (_h & 0x8000) != 0;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::posInf ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0x7c00;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::negInf ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0xfc00;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::qNan ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0x7fff;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::sNan ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0x7dff;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline unsigned short
|
||||
half::bits () const
|
||||
{
|
||||
return _h;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
half::setBits (unsigned short bits)
|
||||
{
|
||||
_h = bits;
|
||||
}
|
||||
|
||||
#undef HALF_EXPORT_CONST
|
||||
|
||||
#endif
|
159
3rdparty/include/OpenEXR/halfFunction.h
vendored
159
3rdparty/include/OpenEXR/halfFunction.h
vendored
@ -1,159 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Primary authors:
|
||||
// Florian Kainz <kainz@ilm.com>
|
||||
// Rod Bogart <rgb@ilm.com>
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// halfFunction<T> -- a class for fast evaluation
|
||||
// of half --> T functions
|
||||
//
|
||||
// The constructor for a halfFunction object,
|
||||
//
|
||||
// halfFunction (function,
|
||||
// domainMin, domainMax,
|
||||
// defaultValue,
|
||||
// posInfValue, negInfValue,
|
||||
// nanValue);
|
||||
//
|
||||
// evaluates the function for all finite half values in the interval
|
||||
// [domainMin, domainMax], and stores the results in a lookup table.
|
||||
// For finite half values that are not in [domainMin, domainMax], the
|
||||
// constructor stores defaultValue in the table. For positive infinity,
|
||||
// negative infinity and NANs, posInfValue, negInfValue and nanValue
|
||||
// are stored in the table.
|
||||
//
|
||||
// The tabulated function can then be evaluated quickly for arbitrary
|
||||
// half values by calling the the halfFunction object's operator()
|
||||
// method.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// #include <math.h>
|
||||
// #include <halfFunction.h>
|
||||
//
|
||||
// halfFunction<half> hsin (sin);
|
||||
//
|
||||
// halfFunction<half> hsqrt (sqrt, // function
|
||||
// 0, HALF_MAX, // domain
|
||||
// half::qNan(), // sqrt(x) for x < 0
|
||||
// half::posInf(), // sqrt(+inf)
|
||||
// half::qNan(), // sqrt(-inf)
|
||||
// half::qNan()); // sqrt(nan)
|
||||
//
|
||||
// half x = hsin (1);
|
||||
// half y = hsqrt (3.5);
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef _HALF_FUNCTION_H_
|
||||
#define _HALF_FUNCTION_H_
|
||||
|
||||
#include <float.h>
|
||||
#include "half.h"
|
||||
|
||||
|
||||
template <class T>
|
||||
class halfFunction
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
template <class Function>
|
||||
halfFunction (Function f,
|
||||
half domainMin = -HALF_MAX,
|
||||
half domainMax = HALF_MAX,
|
||||
T defaultValue = 0,
|
||||
T posInfValue = 0,
|
||||
T negInfValue = 0,
|
||||
T nanValue = 0);
|
||||
|
||||
//-----------
|
||||
// Evaluation
|
||||
//-----------
|
||||
|
||||
T operator () (half x) const;
|
||||
|
||||
private:
|
||||
|
||||
T _lut[1 << 16];
|
||||
};
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
template <class Function>
|
||||
halfFunction<T>::halfFunction (Function f,
|
||||
half domainMin,
|
||||
half domainMax,
|
||||
T defaultValue,
|
||||
T posInfValue,
|
||||
T negInfValue,
|
||||
T nanValue)
|
||||
{
|
||||
for (int i = 0; i < (1 << 16); i++)
|
||||
{
|
||||
half x;
|
||||
x.setBits (i);
|
||||
|
||||
if (x.isNan())
|
||||
_lut[i] = nanValue;
|
||||
else if (x.isInfinity())
|
||||
_lut[i] = x.isNegative()? negInfValue: posInfValue;
|
||||
else if (x < domainMin || x > domainMax)
|
||||
_lut[i] = defaultValue;
|
||||
else
|
||||
_lut[i] = f (x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T
|
||||
halfFunction<T>::operator () (half x) const
|
||||
{
|
||||
return _lut[x.bits()];
|
||||
}
|
||||
|
||||
|
||||
#endif
|
102
3rdparty/include/OpenEXR/halfLimits.h
vendored
102
3rdparty/include/OpenEXR/halfLimits.h
vendored
@ -1,102 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// 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 Industrial Light & Magic nor the names of
|
||||
// its contributors 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Primary authors:
|
||||
// Florian Kainz <kainz@ilm.com>
|
||||
// Rod Bogart <rgb@ilm.com>
|
||||
|
||||
|
||||
#ifndef INCLUDED_HALF_LIMITS_H
|
||||
#define INCLUDED_HALF_LIMITS_H
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// C++ standard library-style numeric_limits for class half
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#include <limits>
|
||||
#include "half.h"
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
class numeric_limits <half>
|
||||
{
|
||||
public:
|
||||
|
||||
static const bool is_specialized = true;
|
||||
|
||||
static half min () throw () {return HALF_NRM_MIN;}
|
||||
static half max () throw () {return HALF_MAX;}
|
||||
|
||||
static const int digits = HALF_MANT_DIG;
|
||||
static const int digits10 = HALF_DIG;
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = false;
|
||||
static const bool is_exact = false;
|
||||
static const int radix = HALF_RADIX;
|
||||
static half epsilon () throw () {return HALF_EPSILON;}
|
||||
static half round_error () throw () {return HALF_EPSILON / 2;}
|
||||
|
||||
static const int min_exponent = HALF_MIN_EXP;
|
||||
static const int min_exponent10 = HALF_MIN_10_EXP;
|
||||
static const int max_exponent = HALF_MAX_EXP;
|
||||
static const int max_exponent10 = HALF_MAX_10_EXP;
|
||||
|
||||
static const bool has_infinity = true;
|
||||
static const bool has_quiet_NaN = true;
|
||||
static const bool has_signaling_NaN = true;
|
||||
static const float_denorm_style has_denorm = denorm_present;
|
||||
static const bool has_denorm_loss = false;
|
||||
static half infinity () throw () {return half::posInf();}
|
||||
static half quiet_NaN () throw () {return half::qNan();}
|
||||
static half signaling_NaN () throw () {return half::sNan();}
|
||||
static half denorm_min () throw () {return HALF_MIN;}
|
||||
|
||||
static const bool is_iec559 = false;
|
||||
static const bool is_bounded = false;
|
||||
static const bool is_modulo = false;
|
||||
|
||||
static const bool traps = true;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_to_nearest;
|
||||
};
|
||||
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
BIN
3rdparty/lib/Half.lib
vendored
BIN
3rdparty/lib/Half.lib
vendored
Binary file not shown.
BIN
3rdparty/lib/Iex.lib
vendored
BIN
3rdparty/lib/Iex.lib
vendored
Binary file not shown.
BIN
3rdparty/lib/IlmImf.lib
vendored
BIN
3rdparty/lib/IlmImf.lib
vendored
Binary file not shown.
BIN
3rdparty/lib/IlmThread.lib
vendored
BIN
3rdparty/lib/IlmThread.lib
vendored
Binary file not shown.
BIN
3rdparty/lib/Imath.lib
vendored
BIN
3rdparty/lib/Imath.lib
vendored
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user