diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-29 00:21:05 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-29 00:21:05 +0400 |
commit | e5791cf48e10ec1336f463b7fccff6b302621eb9 (patch) | |
tree | 58ea33117cc9be35713b6d93ea9d1dfa538ca5bd /source/blender/freestyle/intern/system | |
parent | 9fe9c1d6436e400217fdfd8999117a4719efdf68 (diff) |
Another mega (literally :p) code clean-up patch by Bastien Montagne, thanks again!
Diffstat (limited to 'source/blender/freestyle/intern/system')
26 files changed, 1658 insertions, 1317 deletions
diff --git a/source/blender/freestyle/intern/system/BaseIterator.h b/source/blender/freestyle/intern/system/BaseIterator.h index 45cc19df4fe..836f6c83eb8 100644 --- a/source/blender/freestyle/intern/system/BaseIterator.h +++ b/source/blender/freestyle/intern/system/BaseIterator.h @@ -1,90 +1,97 @@ -// -// Filename : BaseIterator.h -// Author(s) : Stephane Grabli -// Purpose : Classes defining the basic "Iterator" design pattern -// Date of creation : 18/03/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef BASEITERATOR_H -# define BASEITERATOR_H - -# include <iterator> +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_BASE_ITERATOR_H__ +#define __FREESTYLE_BASE_ITERATOR_H__ + +/** \file blender/freestyle/intern/system/BaseIterator.h + * \ingroup freestyle + * \brief Classes defining the basic "Iterator" design pattern + * \author Stephane Grabli + * \date 18/03/2003 + */ + +#include <iterator> // use for iterators defintions template <class Element> class Nonconst_traits; template <class Element> -class Const_traits { +class Const_traits +{ public: - typedef Element value_type; - typedef const Element& reference; - typedef const Element* pointer; - typedef ptrdiff_t difference_type; - typedef Nonconst_traits<Element> Non_const_traits; + typedef Element value_type; + typedef const Element& reference; + typedef const Element *pointer; + typedef ptrdiff_t difference_type; + typedef Nonconst_traits<Element> Non_const_traits; }; template <class Element> -class Nonconst_traits { +class Nonconst_traits +{ public: - typedef Element value_type; - typedef Element& reference; - typedef Element* pointer; - typedef ptrdiff_t difference_type; - typedef Nonconst_traits<Element> Non_const_traits; + typedef Element value_type; + typedef Element& reference; + typedef Element *pointer; + typedef ptrdiff_t difference_type; + typedef Nonconst_traits<Element> Non_const_traits; }; -class InputIteratorTag_Traits { +class InputIteratorTag_Traits +{ public: - typedef std::input_iterator_tag iterator_category; + typedef std::input_iterator_tag iterator_category; }; -class BidirectionalIteratorTag_Traits { +class BidirectionalIteratorTag_Traits +{ public: - typedef std::bidirectional_iterator_tag iterator_category; + typedef std::bidirectional_iterator_tag iterator_category; }; template<class Traits, class IteratorTagTraits> class IteratorBase { public: + virtual ~IteratorBase() {} - virtual ~IteratorBase() {} + virtual bool begin() const = 0; + virtual bool end() const = 0; - virtual bool begin() const = 0; - virtual bool end() const = 0; - - typedef typename IteratorTagTraits::iterator_category iterator_category; - typedef typename Traits::value_type value_type; - typedef typename Traits::difference_type difference_type; - typedef typename Traits::pointer pointer; - typedef typename Traits::reference reference; + typedef typename IteratorTagTraits::iterator_category iterator_category; + typedef typename Traits::value_type value_type; + typedef typename Traits::difference_type difference_type; + typedef typename Traits::pointer pointer; + typedef typename Traits::reference reference; protected: - - IteratorBase() {} + IteratorBase() {} }; #endif // BASEITERATOR_H diff --git a/source/blender/freestyle/intern/system/BaseObject.cpp b/source/blender/freestyle/intern/system/BaseObject.cpp index 0cf1c917195..2088585c33b 100644 --- a/source/blender/freestyle/intern/system/BaseObject.cpp +++ b/source/blender/freestyle/intern/system/BaseObject.cpp @@ -1 +1,36 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/freestyle/intern/system/BaseObject.cpp + * \ingroup freestyle + * \brief Base Class for most shared objects (Node, Rep). Defines the addRef, release system. + * \brief Inspired by COM IUnknown system. + * \author Stephane Grabli + * \date 06/02/2002 + */ + #include "BaseObject.h" diff --git a/source/blender/freestyle/intern/system/BaseObject.h b/source/blender/freestyle/intern/system/BaseObject.h index a8515f98385..1fe2770c313 100644 --- a/source/blender/freestyle/intern/system/BaseObject.h +++ b/source/blender/freestyle/intern/system/BaseObject.h @@ -1,73 +1,77 @@ -// -// Filename : BaseObject.h -// Author(s) : Stephane Grabli -// Purpose : Base Class for most shared objects (Node, Rep). -// Defines the addRef, release system. -// Inspired by COM IUnknown system. -// Date of creation : 06/02/2002 -// -/////////////////////////////////////////////////////////////////////////////// +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __FREESTYLE_BASE_OBJECT_H__ +#define __FREESTYLE_BASE_OBJECT_H__ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef BASEOBJECT_H -# define BASEOBJECT_H +/** \file blender/freestyle/intern/system/BaseObject.h + * \ingroup freestyle + * \brief Base Class for most shared objects (Node, Rep). Defines the addRef, release system. + * \brief Inspired by COM IUnknown system. + * \author Stephane Grabli + * \date 06/02/2002 + */ #include "FreestyleConfig.h" class LIB_SYSTEM_EXPORT BaseObject { public: + inline BaseObject() + { + _ref_counter = 0; + } - inline BaseObject() { - _ref_counter = 0; - } - - virtual ~BaseObject() {} + virtual ~BaseObject() {} - /*! At least makes a release on this. - * The BaseObject::destroy method must be - * explicitely called at the end of any - * overloaded destroy - */ - virtual int destroy() { - return release(); - } + /*! At least makes a release on this. + * The BaseObject::destroy method must be explicitely called at the end of any overloaded destroy + */ + virtual int destroy() + { + return release(); + } - /*! Increments the reference counter */ - inline int addRef() { - return ++_ref_counter; - } + /*! Increments the reference counter */ + inline int addRef() + { + return ++_ref_counter; + } - /*! Decrements the reference counter */ - inline int release() { - if (_ref_counter) - _ref_counter--; - return _ref_counter; - } + /*! Decrements the reference counter */ + inline int release() + { + if (_ref_counter) + _ref_counter--; + return _ref_counter; + } private: - - unsigned _ref_counter; + unsigned _ref_counter; }; -#endif // BASEOBJECT_H +#endif // __FREESTYLE_BASE_OBJECT_H__ diff --git a/source/blender/freestyle/intern/system/Cast.h b/source/blender/freestyle/intern/system/Cast.h index 15af767443e..02dd5699214 100644 --- a/source/blender/freestyle/intern/system/Cast.h +++ b/source/blender/freestyle/intern/system/Cast.h @@ -1,44 +1,49 @@ -// -// Filename : Cast.h -// Author(s) : Emmanuel Turquin -// Purpose : Cast function -// Date of creation : 01/07/2003 -// -/////////////////////////////////////////////////////////////////////////////// +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __FREESTYLE_CAST_H__ +#define __FREESTYLE_CAST_H__ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef CAST_HPP -# define CAST_HPP - -namespace Cast { - - template <class T, class U> - U* cast(T* in) { - if (!in) - return NULL; - return dynamic_cast<U*>(in); - } +/** \file blender/freestyle/intern/system/Cast.h + * \ingroup freestyle + * \brief Cast function + * \author Emmanuel Turquin + * \date 01/07/2003 + */ +namespace Cast +{ + template <class T, class U> + U *cast(T *in) + { + if (!in) + return NULL; + return dynamic_cast<U*>(in); + } } // end of namespace Cast -#endif // CAST_HPP +#endif // __FREESTYLE_CAST_H__ diff --git a/source/blender/freestyle/intern/system/Exception.cpp b/source/blender/freestyle/intern/system/Exception.cpp index d1d12d18297..7c7c16fdf40 100644 --- a/source/blender/freestyle/intern/system/Exception.cpp +++ b/source/blender/freestyle/intern/system/Exception.cpp @@ -1,23 +1,36 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/Exception.cpp + * \ingroup freestyle + * \brief Singleton to manage exceptions + * \author Stephane Grabli + * \date 10/01/2003 + */ #include "Exception.h" diff --git a/source/blender/freestyle/intern/system/Exception.h b/source/blender/freestyle/intern/system/Exception.h index 378de6b558f..b9bfa00cf97 100644 --- a/source/blender/freestyle/intern/system/Exception.h +++ b/source/blender/freestyle/intern/system/Exception.h @@ -1,64 +1,70 @@ -// -// Filename : Exception.h -// Author(s) : Stephane Grabli -// Purpose : Singleton to manage exceptions -// Date of creation : 10/01/2003 -// -/////////////////////////////////////////////////////////////////////////////// +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __FREESTYLE_EXCEPTION_H__ +#define __FREESTYLE_EXCEPTION_H__ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/Exception.h + * \ingroup freestyle + * \brief Singleton to manage exceptions + * \author Stephane Grabli + * \date 10/01/2003 + */ -#ifndef EXCEPTION_H -# define EXCEPTION_H - -# include "FreestyleConfig.h" +#include "FreestyleConfig.h" class LIB_SYSTEM_EXPORT Exception { public: + typedef enum { + NO_EXCEPTION, + UNDEFINED, + } exception_type; - typedef enum { - NO_EXCEPTION, - UNDEFINED - } exception_type; - - static int getException() { - exception_type e = _exception; - _exception = NO_EXCEPTION; - return e; - } + static int getException() + { + exception_type e = _exception; + _exception = NO_EXCEPTION; + return e; + } - static int raiseException(exception_type exception = UNDEFINED) { - _exception = exception; - return _exception; - } + static int raiseException(exception_type exception = UNDEFINED) + { + _exception = exception; + return _exception; + } - static void reset() { - _exception = NO_EXCEPTION; - } + static void reset() + { + _exception = NO_EXCEPTION; + } private: - - static exception_type _exception; + static exception_type _exception; }; -#endif // EXCEPTION_H +#endif // __FREESTYLE_EXCEPTION_H__ diff --git a/source/blender/freestyle/intern/system/FreestyleConfig.h b/source/blender/freestyle/intern/system/FreestyleConfig.h index f06b9928d1d..9d81af1be3b 100644 --- a/source/blender/freestyle/intern/system/FreestyleConfig.h +++ b/source/blender/freestyle/intern/system/FreestyleConfig.h @@ -1,90 +1,96 @@ -// -// Filename : Config.h -// Author(s) : Emmanuel Turquin -// Purpose : Configuration definitions -// Date of creation : 25/02/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef CONFIG_H -# define CONFIG_H - -# include <string> -# include "BLI_math.h" +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_CONFIG_H__ +#define __FREESTYLE_CONFIG_H__ + +/** \file blender/freestyle/intern/system/Config.h + * \ingroup freestyle + * \brief Configuration definitions + * \author Emmanuel Turquin + * \date 25/02/2003 + */ + +#include <string> + +#include "BLI_math.h" using namespace std; namespace Config { - // Directory separators -# ifdef WIN32 - static const string DIR_SEP("\\"); - static const string PATH_SEP(";"); -# else - static const string DIR_SEP("/"); - static const string PATH_SEP(":"); -# endif // WIN32 +// Directory separators +// TODO Use Blender's stuff for such things! +#ifdef WIN32 + static const string DIR_SEP("\\"); + static const string PATH_SEP(";"); +#else + static const string DIR_SEP("/"); + static const string PATH_SEP(":"); +#endif // WIN32 - // DLL import/export macros for Win32 +// DLL import/export macros for Win32 -# ifndef LIB_SYSTEM_EXPORT -# define LIB_SYSTEM_EXPORT -# endif // LIB_SYSTEM_EXPORT +#ifndef LIB_SYSTEM_EXPORT +# define LIB_SYSTEM_EXPORT +#endif // LIB_SYSTEM_EXPORT -# ifndef LIB_IMAGE_EXPORT -# define LIB_IMAGE_EXPORT -# endif // LIB_IMAGE_EXPORT +#ifndef LIB_IMAGE_EXPORT +# define LIB_IMAGE_EXPORT +#endif // LIB_IMAGE_EXPORT -# ifndef LIB_GEOMETRY_EXPORT -# define LIB_GEOMETRY_EXPORT -# endif // LIB_GEOMETRY_EXPORT +#ifndef LIB_GEOMETRY_EXPORT +# define LIB_GEOMETRY_EXPORT +#endif // LIB_GEOMETRY_EXPORT -# ifndef LIB_SCENE_GRAPH_EXPORT -# define LIB_SCENE_GRAPH_EXPORT -# endif // LIB_SCENE_GRAPH_EXPORT +#ifndef LIB_SCENE_GRAPH_EXPORT +# define LIB_SCENE_GRAPH_EXPORT +#endif // LIB_SCENE_GRAPH_EXPORT -# ifndef LIB_WINGED_EDGE_EXPORT -# define LIB_WINGED_EDGE_EXPORT -# endif // LIB_WINGED_EDGE_EXPORT +#ifndef LIB_WINGED_EDGE_EXPORT +# define LIB_WINGED_EDGE_EXPORT +#endif // LIB_WINGED_EDGE_EXPORT -# ifndef LIB_VIEW_MAP_EXPORT -# define LIB_VIEW_MAP_EXPORT -# endif // LIB_VIEW_MAP_EXPORT +#ifndef LIB_VIEW_MAP_EXPORT +# define LIB_VIEW_MAP_EXPORT +#endif // LIB_VIEW_MAP_EXPORT -# ifndef LIB_STROKE_EXPORT -# define LIB_STROKE_EXPORT -# endif // LIB_STROKE_EXPORT +#ifndef LIB_STROKE_EXPORT +# define LIB_STROKE_EXPORT +#endif // LIB_STROKE_EXPORT -# ifndef LIB_RENDERING_EXPORT -# define LIB_RENDERING_EXPORT -# endif // LIB_RENDERING_EXPORT +#ifndef LIB_RENDERING_EXPORT +# define LIB_RENDERING_EXPORT +#endif // LIB_RENDERING_EXPORT -# ifndef LIB_WRAPPER_EXPORT -# define LIB_WRAPPER_EXPORT -# endif // LIB_WRAPPER_EXPORT +#ifndef LIB_WRAPPER_EXPORT +# define LIB_WRAPPER_EXPORT +#endif // LIB_WRAPPER_EXPORT } // end of namespace Config -#endif // CONFIG_H +#endif // __FREESTYLE_CONFIG_H__ diff --git a/source/blender/freestyle/intern/system/Id.h b/source/blender/freestyle/intern/system/Id.h index 1f2206ed337..d6e39bff167 100644 --- a/source/blender/freestyle/intern/system/Id.h +++ b/source/blender/freestyle/intern/system/Id.h @@ -1,126 +1,142 @@ -// -// Filename : Id.h -// Author(s) : Emmanuel Turquin -// Purpose : Identification system -// Date of creation : 01/07/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef ID_H -# define ID_H - -/*! Class used to tag any object by an id . +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_ID_H__ +#define __FREESTYLE_ID_H__ + +/** \file blender/freestyle/intern/system/Id.h + * \ingroup freestyle + * \brief Identification system + * \author Emmanuel Turquin + * \date 01/07/2003 + */ + +/*! Class used to tag any object by an id. * It is made of two unsigned integers. */ class Id { public: - - typedef unsigned id_type; - - /*! Default constructor */ - Id() { - _first = 0; - _second = 0; - } - - /*! Builds an Id from an integer. - * The second number is set to 0. - */ - Id(id_type id) { - _first = id; - _second = 0; - } - - /*! Builds the Id from the two numbers */ - Id(id_type ifirst, id_type isecond) { - _first = ifirst; - _second = isecond; - } - - /*! Copy constructor */ - Id(const Id& iBrother) { - _first = iBrother._first; - _second = iBrother._second; - } - - /*! Operator= */ - Id& operator=(const Id& iBrother) { - _first = iBrother._first; - _second = iBrother._second; - return *this; - } - - /*! Returns the first Id number */ - id_type getFirst() const { - return _first; - } - - /*! Returns the second Id number */ - id_type getSecond() const { - return _second; - } - - /*! Sets the first number constituing the Id */ - void setFirst(id_type first) { - _first = first; - } - - /*! Sets the second number constituing the Id */ - void setSecond(id_type second) { - _second = second; - } - - /*! Operator== */ - bool operator==(const Id& id) const { - return ((_first == id._first) && (_second == id._second)); - } - - /*! Operator!= */ - bool operator!=(const Id& id) const { - return !((*this)==id); - } - - /*! Operator< */ - bool operator<(const Id& id) const { - if (_first < id._first) - return true; - if (_first == id._first && _second < id._second) - return true; - return false; -} + typedef unsigned id_type; + + /*! Default constructor */ + Id() + { + _first = 0; + _second = 0; + } + + /*! Builds an Id from an integer. + * The second number is set to 0. + */ + Id(id_type id) + { + _first = id; + _second = 0; + } + + /*! Builds the Id from the two numbers */ + Id(id_type ifirst, id_type isecond) + { + _first = ifirst; + _second = isecond; + } + + /*! Copy constructor */ + Id(const Id& iBrother) + { + _first = iBrother._first; + _second = iBrother._second; + } + + /*! Operator= */ + Id& operator=(const Id& iBrother) + { + _first = iBrother._first; + _second = iBrother._second; + return *this; + } + + /*! Returns the first Id number */ + id_type getFirst() const + { + return _first; + } + + /*! Returns the second Id number */ + id_type getSecond() const + { + return _second; + } + + /*! Sets the first number constituing the Id */ + void setFirst(id_type first) + { + _first = first; + } + + /*! Sets the second number constituing the Id */ + void setSecond(id_type second) + { + _second = second; + } + + /*! Operator== */ + bool operator==(const Id& id) const + { + return ((_first == id._first) && (_second == id._second)); + } + + /*! Operator!= */ + bool operator!=(const Id& id) const + { + return !((*this) == id); + } + + /*! Operator< */ + bool operator<(const Id& id) const + { + if (_first < id._first) + return true; + if (_first == id._first && _second < id._second) + return true; + return false; + } private: - - id_type _first; - id_type _second; + id_type _first; + id_type _second; }; // stream operator -inline std::ostream& operator<<(std::ostream& s, const Id& id) { - s << "[" << id.getFirst() << ", " << id.getSecond() << "]"; - return s; +inline std::ostream& operator<<(std::ostream& s, const Id& id) +{ + s << "[" << id.getFirst() << ", " << id.getSecond() << "]"; + return s; } -# endif // ID_H +# endif // __FREESTYLE_ID_H__ diff --git a/source/blender/freestyle/intern/system/Interpreter.h b/source/blender/freestyle/intern/system/Interpreter.h index 75aaa2ccd18..7928db9aed2 100644 --- a/source/blender/freestyle/intern/system/Interpreter.h +++ b/source/blender/freestyle/intern/system/Interpreter.h @@ -1,56 +1,65 @@ -// -// Filename : Interpreter.h -// Author(s) : Emmanuel Turquin -// Purpose : Base Class of all script interpreters -// Date of creation : 17/04/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef INTERPRETER_H -# define INTERPRETER_H - -# include <string> +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_INTERPRETER_H__ +#define __FREESTYLE_INTERPRETER_H__ + +/** \file blender/freestyle/intern/system/Interpreter.h + * \ingroup freestyle + * \brief Base Class of all script interpreters + * \author Emmanuel Turquin + * \date 17/04/2003 + */ + +#include <string> using namespace std; class LIB_SYSTEM_EXPORT Interpreter { - public: - - Interpreter() { _language = "Unknown"; } - - virtual ~Interpreter() {}; //soc +public: + Interpreter() + { + _language = "Unknown"; + } - virtual int interpretFile(const string& filename) = 0; + virtual ~Interpreter() {}; //soc - virtual string getLanguage() const { return _language; } + virtual int interpretFile(const string& filename) = 0; - virtual void reset() = 0; + virtual string getLanguage() const + { + return _language; + } - protected: + virtual void reset() = 0; - string _language; +protected: + string _language; }; -#endif // INTERPRETER_H +#endif // __FREESTYLE_INTERPRETER_H__ diff --git a/source/blender/freestyle/intern/system/Iterator.cpp b/source/blender/freestyle/intern/system/Iterator.cpp index 67acc893589..2e89880b3d7 100644 --- a/source/blender/freestyle/intern/system/Iterator.cpp +++ b/source/blender/freestyle/intern/system/Iterator.cpp @@ -1 +1,32 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/freestyle/intern/system/Iterator.cpp + * \ingroup freestyle + */ + #include "Iterator.h" diff --git a/source/blender/freestyle/intern/system/Iterator.h b/source/blender/freestyle/intern/system/Iterator.h index 1801c1e3b2f..9cd0f16275b 100644 --- a/source/blender/freestyle/intern/system/Iterator.h +++ b/source/blender/freestyle/intern/system/Iterator.h @@ -1,41 +1,75 @@ -#ifndef ITERATOR_H -#define ITERATOR_H +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_ITERATOR_H__ +#define __FREESTYLE_ITERATOR_H__ + +/** \file blender/freestyle/intern/system/Iterator.h + * \ingroup freestyle + */ #include <iostream> #include <string> -using namespace std; +using namespace std; class Iterator { public: + virtual ~Iterator() {} - virtual ~Iterator() {} - - virtual string getExactTypeName() const { - return "Iterator"; - } - - virtual int increment() { - cerr << "Warning: increment() not implemented" << endl; - return 0; - } + virtual string getExactTypeName() const + { + return "Iterator"; + } - virtual int decrement() { - cerr << "Warning: decrement() not implemented" << endl; - return 0; - } + virtual int increment() + { + cerr << "Warning: increment() not implemented" << endl; + return 0; + } - virtual bool isBegin() const { - cerr << "Warning: isBegin() not implemented" << endl; - return false; - } + virtual int decrement() + { + cerr << "Warning: decrement() not implemented" << endl; + return 0; + } - virtual bool isEnd() const { - cerr << "Warning: isEnd() not implemented" << endl; - return false; - } + virtual bool isBegin() const + { + cerr << "Warning: isBegin() not implemented" << endl; + return false; + } + virtual bool isEnd() const + { + cerr << "Warning: isEnd() not implemented" << endl; + return false; + } }; -#endif // ITERATOR_H +#endif // __FREESTYLE_ITERATOR_H__ diff --git a/source/blender/freestyle/intern/system/PointerSequence.h b/source/blender/freestyle/intern/system/PointerSequence.h index 72c6aa458fd..c97f4516d00 100644 --- a/source/blender/freestyle/intern/system/PointerSequence.h +++ b/source/blender/freestyle/intern/system/PointerSequence.h @@ -1,97 +1,96 @@ -// -// Filename : PointerSequence.h -// Author(s) : Alexander Beels -// Purpose : Class to define a cell grid surrounding -// the projected image of a scene -// Date of creation : 22/11/2010 -// -/////////////////////////////////////////////////////////////////////////////// +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __FREESTYLE_POINTER_SEQUENCE_H__ +#define __FREESTYLE_POINTER_SEQUENCE_H__ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -// -// Simple RAII wrappers for std:: sequential containers -// -/////////////////////////////////////////////////////////////////////////////// - -// -// PointerSequence -// -// Produces a wrapped version of a sequence type (std::vector, std::deque, std::list) -// that will take ownership of pointers tht it stores. Those pointers will be deleted -// in its destructor. -// -// Because the contained pointers are wholly owned by the sequence, you cannot make a -// copy of the sequence. Making a copy would result in a double free. -// -// This is a no-frills class that provides no additional facilities. The user is -// responsible for managing any pointers that are removed from the list, and for making -// sure that any pointers contained in the class are not deleted elsewhere. Because -// this class does no reference counting, the user must also make sure that any pointer -// appears only once in the sequence. -// -// If more sophisticated facilities are needed, use tr1::shared_ptr or boost::shared_ptr. -// This class is only intended to allow one to eke by in projects where tr1 or boost are -// not available. -// -// Usage: The template takes two parameters, the standard container, and the class held -// in the container. This is a limitation of C++ templates, where T::iterator is not a -// type when T is a template parameter. If anyone knows a way around this -// limitation, then the second parameter can be eliminated. -// -// Example: -// PointerSequence<vector<Widget*>, Widget*> v; -// v.push_back(new Widget); -// cout << v[0] << endl; // operator[] is provided by std::vector, not by PointerSequence -// v.destroy(); // Deletes all pointers in sequence and sets them to NULL. -// -// The idiom for removing a pointer from a sequence is: -// Widget* w = v[3]; -// v.erase(v.begin() + 3); // or v[3] = 0; -// The user is now responsible for disposing of w properly. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef POINTERSEQUENCE_H -# define POINTERSEQUENCE_H +/** \file blender/freestyle/intern/system/PointerSequence.h + * \ingroup freestyle + * \brief Simple RAII wrappers for std:: sequential containers + * \author 22/11/2010 + * \date 18/03/2003 + * + * PointerSequence + * + * Produces a wrapped version of a sequence type (std::vector, std::deque, std::list) that will take ownership of + * pointers tht it stores. Those pointers will be deleted in its destructor. + * + * Because the contained pointers are wholly owned by the sequence, you cannot make a copy of the sequence. + * Making a copy would result in a double free. + * + * This is a no-frills class that provides no additional facilities. The user is responsible for managing any + * pointers that are removed from the list, and for making sure that any pointers contained in the class are not + * deleted elsewhere. Because this class does no reference counting, the user must also make sure that any pointer + * appears only once in the sequence. + * + * If more sophisticated facilities are needed, use tr1::shared_ptr or boost::shared_ptr. + * This class is only intended to allow one to eke by in projects where tr1 or boost are not available. + * + * Usage: The template takes two parameters, the standard container, and the class held in the container. This is a + * limitation of C++ templates, where T::iterator is not a type when T is a template parameter. If anyone knows a way + * around this limitation, then the second parameter can be eliminated. + * + * Example: + * PointerSequence<vector<Widget*>, Widget*> v; + * v.push_back(new Widget); + * cout << v[0] << endl; // operator[] is provided by std::vector, not by PointerSequence + * v.destroy(); // Deletes all pointers in sequence and sets them to NULL. + * + * The idiom for removing a pointer from a sequence is: + * Widget* w = v[3]; + * v.erase(v.begin() + 3); // or v[3] = 0; + * The user is now responsible for disposing of w properly. + */ #include <algorithm> template <typename C, typename T> -class PointerSequence : public C { +class PointerSequence : public C +{ PointerSequence (PointerSequence& other); - PointerSequence& operator= (PointerSequence& other); - static void destroyer (T t) { + PointerSequence& operator=(PointerSequence& other); + + static void destroyer(T t) + { delete t; } + public: PointerSequence () {}; - ~PointerSequence () { + + ~PointerSequence () + { destroy(); } - void destroy () { - for_each (this->begin(), this->end(), destroyer); + + void destroy () + { + for_each(this->begin(), this->end(), destroyer); } }; -#endif // POINTERSEQUENCE_H - +#endif // __FREESTYLE_POINTER_SEQUENCE_H__ diff --git a/source/blender/freestyle/intern/system/Precision.h b/source/blender/freestyle/intern/system/Precision.h index 24327a280df..c2a9e24e635 100644 --- a/source/blender/freestyle/intern/system/Precision.h +++ b/source/blender/freestyle/intern/system/Precision.h @@ -1,39 +1,44 @@ -// -// Filename : Precision.h -// Author(s) : Stephane Grabli -// Purpose : Define the float precision used in the program -// Date of creation : 30/07/2002 -// -/////////////////////////////////////////////////////////////////////////////// +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __FREESTYLE_PRECISION_H__ +#define __FREESTYLE_PRECISION_H__ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef PRECISION_H -# define PRECISION_H +/** \file blender/freestyle/intern/system/Precision.h + * \ingroup freestyle + * \brief Define the float precision used in the program + * \author Stephane Grabli + * \date 30/07/2002 + */ typedef double real; -# ifndef SWIG -static const real M_EPSILON = 0.00000001; -# endif // SWIG +#ifndef SWIG + static const real M_EPSILON = 0.00000001; +#endif // SWIG -#endif // PRECISION_H +#endif // __FREESTYLE_PRECISION_H__ diff --git a/source/blender/freestyle/intern/system/ProgressBar.h b/source/blender/freestyle/intern/system/ProgressBar.h index 5b61f936c90..2837c148754 100644 --- a/source/blender/freestyle/intern/system/ProgressBar.h +++ b/source/blender/freestyle/intern/system/ProgressBar.h @@ -1,85 +1,96 @@ -// -// Filename : ProgressBar.h -// Author(s) : Stephane Grabli -// Purpose : Class to encapsulate a progress bar -// Date of creation : 27/08/2002 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef PROGRESSBAR_H -# define PROGRESSBAR_H - -# include <string> +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_PROGRESS_BAR_H__ +#define __FREESTYLE_PROGRESS_BAR_H__ + +/** \file blender/freestyle/intern/system/ProgressBar.h + * \ingroup freestyle + * \brief Class to encapsulate a progress bar + * \author Stephane Grabli + * \date 27/08/2002 + */ + +#include <string> using namespace std; class ProgressBar { public: + inline ProgressBar() + { + _numtotalsteps = 0; + _progress = 0; + } + + virtual ~ProgressBar() {} + + virtual void reset() + { + _numtotalsteps = 0; + _progress = 0; + } + + virtual void setTotalSteps(unsigned n) + { + _numtotalsteps = n; + } + + virtual void setProgress(unsigned i) + { + _progress = i; + } + + virtual void setLabelText(const string& s) + { + _label = s; + } + + /*! accessors */ + inline unsigned int getTotalSteps() const + { + return _numtotalsteps; + } + + inline unsigned int getProgress() const + { + return _progress; + } + + inline string getLabelText() const + { + return _label; + } - inline ProgressBar() { - _numtotalsteps = 0; - _progress = 0; - } - - virtual ~ProgressBar() {} - - virtual void reset() { - _numtotalsteps = 0; - _progress = 0; - } - - virtual void setTotalSteps(unsigned n) { - _numtotalsteps = n; - } - - virtual void setProgress(unsigned i) { - _progress = i; - } - - virtual void setLabelText(const string& s) { - _label = s; - } - - /*! accessors */ - inline unsigned int getTotalSteps() const { - return _numtotalsteps; - } - - inline unsigned int getProgress() const { - return _progress; - } - - inline string getLabelText() const { - return _label; - } - protected: - - unsigned _numtotalsteps; - unsigned _progress; - string _label; + unsigned _numtotalsteps; + unsigned _progress; + string _label; }; -#endif // PROGRESSBAR_H +#endif // __FREESTYLE_PROGRESS_BAR_H__ diff --git a/source/blender/freestyle/intern/system/PseudoNoise.cpp b/source/blender/freestyle/intern/system/PseudoNoise.cpp index 069027ed3e0..27158bfd4aa 100644 --- a/source/blender/freestyle/intern/system/PseudoNoise.cpp +++ b/source/blender/freestyle/intern/system/PseudoNoise.cpp @@ -1,109 +1,116 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/PseudoNoise.cpp + * \ingroup freestyle + * \brief Class to define a pseudo Perlin noise + * \author Fredo Durand + * \date 16/06/2003 + */ #include <math.h> -#include "RandGen.h" + #include "PseudoNoise.h" +#include "RandGen.h" static const unsigned NB_VALUE_NOISE = 512; real *PseudoNoise::_values; -PseudoNoise::PseudoNoise () -{ -} +PseudoNoise::PseudoNoise() {} -void -PseudoNoise::init (long seed) +void PseudoNoise::init(long seed) { - _values = new real[NB_VALUE_NOISE]; - RandGen::srand48(seed); - for (unsigned int i=0; i<NB_VALUE_NOISE; i++) - _values[i] = -1.0 + 2.0 * RandGen::drand48(); + _values = new real[NB_VALUE_NOISE]; + RandGen::srand48(seed); + for (unsigned int i = 0; i < NB_VALUE_NOISE; i++) + _values[i] = -1.0 + 2.0 * RandGen::drand48(); } -real -PseudoNoise::linearNoise (real x) +real PseudoNoise::linearNoise(real x) { - real tmp; - int i = modf(x, &tmp) * NB_VALUE_NOISE; - real x1=_values[i], x2=_values[(i+1)%NB_VALUE_NOISE]; - real t = modf(x * NB_VALUE_NOISE, &tmp); - return x1*(1-t)+x2*t; + real tmp; + int i = modf(x, &tmp) * NB_VALUE_NOISE; + real x1 = _values[i], x2 = _values[(i + 1) % NB_VALUE_NOISE]; + real t = modf(x * NB_VALUE_NOISE, &tmp); + return x1 * (1 - t) + x2 * t; } -static real -LanczosWindowed(real t) +static real LanczosWindowed(real t) { - if (fabs(t)>2) return 0; - if (fabs(t)<M_EPSILON) return 1.0; - return sin(M_PI*t)/(M_PI*t) * sin(M_PI*t/2.0)/(M_PI*t/2.0); + if (fabs(t) > 2) + return 0; + if (fabs(t) < M_EPSILON) + return 1.0; + return sin(M_PI * t) / (M_PI * t) * sin(M_PI * t / 2.0) / (M_PI * t / 2.0); } -real -PseudoNoise::smoothNoise (real x) +real PseudoNoise::smoothNoise(real x) { - real tmp; - int i = modf(x, &tmp) * NB_VALUE_NOISE; - int h = i - 1; - if (h < 0) - { - h = NB_VALUE_NOISE + h; - } + real tmp; + int i = modf(x, &tmp) * NB_VALUE_NOISE; + int h = i - 1; + if (h < 0) { + h = NB_VALUE_NOISE + h; + } - real x1=_values[i], x2=_values[(i+1)%NB_VALUE_NOISE]; - real x0=_values[h], x3=_values[(i+2)%NB_VALUE_NOISE]; + real x1 = _values[i], x2 = _values[(i + 1) % NB_VALUE_NOISE]; + real x0 = _values[h], x3 = _values[(i + 2) % NB_VALUE_NOISE]; - real t = modf(x * NB_VALUE_NOISE, &tmp); - real y0=LanczosWindowed(-1-t); - real y1=LanczosWindowed(-t); - real y2=LanczosWindowed(1-t); - real y3=LanczosWindowed(2-t); - // cerr<<"x0="<<x0<<" x1="<<x1<<" x2="<<x2<<" x3="<<x3<<endl; - // cerr<<"y0="<<y0<<" y1="<<y1<<" y2="<<y2<<" y3="<<y3<<" :"; - return (x0*y0+x1*y1+x2*y2+x3*y3)/(y0+y1+y2+y3); + real t = modf(x * NB_VALUE_NOISE, &tmp); + real y0 = LanczosWindowed(-1 -t); + real y1 = LanczosWindowed(-t); + real y2 = LanczosWindowed(1 - t); + real y3 = LanczosWindowed(2 - t); +#if 0 + cerr << "x0=" << x0 << " x1=" << x1 << " x2=" << x2 << " x3=" << x3 << endl; + cerr << "y0=" << y0 << " y1=" << y1 << " y2=" << y2 << " y3=" << y3 << " :" << endl; +#endif + return (x0 * y0 + x1 * y1 + x2 * y2 + x3 * y3) / (y0 + y1 + y2 + y3); } -real -PseudoNoise::turbulenceSmooth (real x, unsigned nbOctave) +real PseudoNoise::turbulenceSmooth(real x, unsigned nbOctave) { - real y=0; - real k=1.0; - for (unsigned i=0; i<nbOctave; i++) - { - y=y+k*smoothNoise(x*k); - k=k/2.0; - } - return y; + real y = 0; + real k = 1.0; + for (unsigned int i = 0; i < nbOctave; i++) { + y = y + k * smoothNoise(x * k); + k = k / 2.0; + } + return y; } -real -PseudoNoise::turbulenceLinear (real x, unsigned nbOctave) +real PseudoNoise::turbulenceLinear(real x, unsigned nbOctave) { - real y=0; - real k=1.0; - for (unsigned i=0; i<nbOctave; i++) - { - y=y+k*linearNoise(x*k); - k=k/2.0; - } - return y; + real y = 0; + real k = 1.0; + for (unsigned int i = 0; i < nbOctave; i++) { + y = y + k * linearNoise(x * k); + k = k / 2.0; + } + return y; } diff --git a/source/blender/freestyle/intern/system/PseudoNoise.h b/source/blender/freestyle/intern/system/PseudoNoise.h index 43143865600..7b414ae76e5 100644 --- a/source/blender/freestyle/intern/system/PseudoNoise.h +++ b/source/blender/freestyle/intern/system/PseudoNoise.h @@ -1,58 +1,60 @@ -// -// Filename : PseudoNoise.h -// Author(s) : Fredo Durand -// Purpose : Class to define a pseudo Perlin noise -// Date of creation : 16/06/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef PSEUDONOISE_H -# define PSEUDONOISE_H - -# include "FreestyleConfig.h" -# include "Precision.h" - -class LIB_SYSTEM_EXPORT PseudoNoise +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_PSEUDO_NOISE_H__ +#define __FREESTYLE_PSEUDO_NOISE_H__ + +/** \file blender/freestyle/intern/system/PseudoNoise.h + * \ingroup freestyle + * \brief Class to define a pseudo Perlin noise + * \author Fredo Durand + * \date 16/06/2003 + */ + +#include "FreestyleConfig.h" +#include "Precision.h" + +class LIB_SYSTEM_EXPORT PseudoNoise { public: + PseudoNoise(); - PseudoNoise (); + virtual ~PseudoNoise() {} - virtual ~PseudoNoise () {} - - real smoothNoise (real x); - real linearNoise (real x); + real smoothNoise(real x); + real linearNoise(real x); - real turbulenceSmooth (real x, unsigned nbOctave = 8); - real turbulenceLinear (real x, unsigned nbOctave = 8); + real turbulenceSmooth(real x, unsigned nbOctave = 8); + real turbulenceLinear(real x, unsigned nbOctave = 8); - static void init (long seed); + static void init(long seed); protected: - - static real *_values; + static real *_values; }; -#endif // PSEUDONOISE_H - +#endif // __FREESTYLE_PSEUDO_NOISE_H__ diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.cpp b/source/blender/freestyle/intern/system/PythonInterpreter.cpp index 821bd32b40b..aa8df8f418b 100644 --- a/source/blender/freestyle/intern/system/PythonInterpreter.cpp +++ b/source/blender/freestyle/intern/system/PythonInterpreter.cpp @@ -1,25 +1,38 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/PythonInterpreter.cpp + * \ingroup freestyle + * \brief Python Interpreter + * \author Emmanuel Turquin + * \date 17/04/2003 + */ #include "PythonInterpreter.h" -string PythonInterpreter::_path = ""; -bool PythonInterpreter::_initialized = false; +string PythonInterpreter::_path = ""; +bool PythonInterpreter::_initialized = false; diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index 81e2f70c82e..c6acf502e5e 100644 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -1,180 +1,196 @@ -// -// Filename : PythonInterpreter.h -// Author(s) : Emmanuel Turquin -// Purpose : Python Interpreter -// Date of creation : 17/04/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef PYTHON_INTERPRETER_H -# define PYTHON_INTERPRETER_H - -# include <Python.h> -# include <iostream> -# include "StringUtils.h" -# include "Interpreter.h" +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_PYTHON_INTERPRETER_H__ +#define __FREESTYLE_PYTHON_INTERPRETER_H__ + +/** \file blender/freestyle/intern/system/PythonInterpreter.h + * \ingroup freestyle + * \brief Python Interpreter + * \author Emmanuel Turquin + * \date 17/04/2003 + */ + +#include <iostream> +#include <Python.h> + +#include "StringUtils.h" +#include "Interpreter.h" //soc extern "C" { + #include "MEM_guardedalloc.h" + #include "DNA_text_types.h" -#include "BKE_main.h" + #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" #include "BKE_report.h" #include "BKE_text.h" -#include "BKE_library.h" + #include "BPY_extern.h" + } class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter { - public: - - PythonInterpreter() { - _language = "Python"; - _context = 0; - //Py_Initialize(); - } +public: + PythonInterpreter() + { + _language = "Python"; + _context = 0; + //Py_Initialize(); + } - virtual ~PythonInterpreter() { - //Py_Finalize(); - } + virtual ~PythonInterpreter() + { + //Py_Finalize(); + } - void setContext(bContext *C) { - _context = C; - } + void setContext(bContext *C) + { + _context = C; + } - int interpretFile(const string& filename) { + int interpretFile(const string& filename) + { + initPath(); - initPath(); - - ReportList* reports = CTX_wm_reports(_context); - BKE_reports_clear(reports); - char *fn = const_cast<char*>(filename.c_str()); + ReportList *reports = CTX_wm_reports(_context); + BKE_reports_clear(reports); + char *fn = const_cast<char*>(filename.c_str()); #if 0 - int status = BPY_filepath_exec(_context, fn, reports); + int status = BPY_filepath_exec(_context, fn, reports); #else - int status; - Text *text = BKE_text_load(fn, G.main->name); - if (text) { - status = BPY_text_exec(_context, text, reports, false); - BKE_text_unlink(G.main, text); - BKE_libblock_free(&G.main->text, text); - } else { - BKE_reportf(reports, RPT_ERROR, "Cannot open file: %s", fn); - status = 0; - } + int status; + Text *text = BKE_text_load(fn, G.main->name); + if (text) { + status = BPY_text_exec(_context, text, reports, false); + BKE_text_unlink(G.main, text); + BKE_libblock_free(&G.main->text, text); + } + else { + BKE_reportf(reports, RPT_ERROR, "Cannot open file: %s", fn); + status = 0; + } #endif - if (status != 1) { - cout << "\nError executing Python script from PythonInterpreter::interpretFile" << endl; - cout << "File: " << fn << endl; - cout << "Errors: " << endl; - BKE_reports_print(reports, RPT_ERROR); - return 1; + if (status != 1) { + cout << "\nError executing Python script from PythonInterpreter::interpretFile" << endl; + cout << "File: " << fn << endl; + cout << "Errors: " << endl; + BKE_reports_print(reports, RPT_ERROR); + return 1; + } + + // cleaning up + BKE_reports_clear(reports); + + return 0; } - // cleaning up - BKE_reports_clear(reports); - - return 0; - } + int interpretText(struct Text *text, const string& name) { + initPath(); - int interpretText(struct Text *text, const string& name) { + ReportList *reports = CTX_wm_reports(_context); - initPath(); + BKE_reports_clear(reports); - ReportList* reports = CTX_wm_reports(_context); + if (!BPY_text_exec(_context, text, reports, false)) { + cout << "\nError executing Python script from PythonInterpreter::interpretText" << endl; + cout << "Name: " << name << endl; + cout << "Errors: " << endl; + BKE_reports_print(reports, RPT_ERROR); + return 1; + } - BKE_reports_clear(reports); + BKE_reports_clear(reports); - if (!BPY_text_exec(_context, text, reports, false)) { - cout << "\nError executing Python script from PythonInterpreter::interpretText" << endl; - cout << "Name: " << name << endl; - cout << "Errors: " << endl; - BKE_reports_print(reports, RPT_ERROR); - return 1; + return 0; } - BKE_reports_clear(reports); + struct Options + { + static void setPythonPath(const string& path) + { + _path = path; + } - return 0; - } + static string getPythonPath() + { + return _path; + } + }; - struct Options - { - static void setPythonPath(const string& path) { - _path = path; - } + void reset() + { + Py_Finalize(); + Py_Initialize(); + _initialized = false; + } - static string getPythonPath() { - return _path; - } - }; +private: + bContext *_context; + + void initPath() + { + if (_initialized) + return; + + vector<string> pathnames; + StringUtils::getPathName(_path, "", pathnames); + + struct Text *text = BKE_text_add("tmp_freestyle_initpath.txt"); + string cmd = "import sys\n"; + txt_insert_buf(text, const_cast<char*>(cmd.c_str())); + + for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it) { + if (!it->empty()) { + cout << "Adding Python path: " << *it << endl; + cmd = "sys.path.append(r\"" + *it + "\")\n"; + txt_insert_buf(text, const_cast<char*>(cmd.c_str())); + } + } - void reset() { - Py_Finalize(); - Py_Initialize(); - _initialized = false; - } + BPY_text_exec(_context, text, NULL, false); -private: + // cleaning up + BKE_text_unlink(G.main, text); + BKE_libblock_free(&G.main->text, text); - bContext* _context; - - void initPath() { - if (_initialized) - return; - - vector<string> pathnames; - StringUtils::getPathName(_path, "", pathnames); - - struct Text *text = BKE_text_add("tmp_freestyle_initpath.txt"); - string cmd = "import sys\n"; - txt_insert_buf(text, const_cast<char*>(cmd.c_str())); - - for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end();++it) { - if ( !it->empty() ) { - cout << "Adding Python path: " << *it << endl; - cmd = "sys.path.append(r\"" + *it + "\")\n"; - txt_insert_buf(text, const_cast<char*>(cmd.c_str())); - } + //PyRun_SimpleString("from Freestyle import *"); + _initialized = true; } - - BPY_text_exec(_context, text, NULL, false); - - // cleaning up - BKE_text_unlink(G.main, text); - BKE_libblock_free(&G.main->text, text); - - //PyRun_SimpleString("from Freestyle import *"); - _initialized = true; - } - - static bool _initialized; - static string _path; + + static bool _initialized; + static string _path; }; -#endif // PYTHON_INTERPRETER_H +#endif // __FREESTYLE_PYTHON_INTERPRETER_H__ diff --git a/source/blender/freestyle/intern/system/RandGen.cpp b/source/blender/freestyle/intern/system/RandGen.cpp index a328cb7f583..193df1b4239 100644 --- a/source/blender/freestyle/intern/system/RandGen.cpp +++ b/source/blender/freestyle/intern/system/RandGen.cpp @@ -1,23 +1,36 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/RandGen.cpp + * \ingroup freestyle + * \brief Pseudo-random number generator + * \author Fredo Durand + * \date 20/05/2003 + */ #include "RandGen.h" @@ -26,61 +39,94 @@ // /////////////////////////////////////////////////////////////////////////////// -#define N 16 -#define MASK ((unsigned)(1 << (N - 1)) + (1 << (N - 1)) - 1) -#define X0 0x330E -#define X1 0xABCD -#define X2 0x1234 -#define A0 0xE66D -#define A1 0xDEEC -#define A2 0x5 -#define C 0xB -#define HI_BIT (1L << (2 * N - 1)) +#define N 16 +#define MASK ((unsigned)(1 << (N - 1)) + (1 << (N - 1)) - 1) +#define X0 0x330E +#define X1 0xABCD +#define X2 0x1234 +#define A0 0xE66D +#define A1 0xDEEC +#define A2 0x5 +#define C 0xB +#define HI_BIT (1L << (2 * N - 1)) -#define LOW(x) ((unsigned)(x) & MASK) -#define HIGH(x) LOW((x) >> N) -#define MUL(x, y, z) { long l = (long)(x) * (long)(y); \ - (z)[0] = LOW(l); (z)[1] = HIGH(l); } -#define CARRY(x, y) ((unsigned long)((long)(x) + (long)(y)) > MASK) -#define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y))) -#define SET3(x, x0, x1, x2) ((x)[0] = (x0), (x)[1] = (x1), (x)[2] = (x2)) -#define SETLOW(x, y, n) SET3(x, LOW((y)[n]), LOW((y)[(n)+1]), LOW((y)[(n)+2])) -#define SEED(x0, x1, x2) (SET3(x, x0, x1, x2), SET3(a, A0, A1, A2), c = C) -#define REST(v) for (i = 0; i < 3; i++) { xsubi[i] = x[i]; x[i] = temp[i]; } \ - return (v); -#define NEST(TYPE, f, F) TYPE f(register unsigned short *xsubi) { \ - register int i; register TYPE v; unsigned temp[3]; \ - for (i = 0; i < 3; i++) { temp[i] = x[i]; x[i] = LOW(xsubi[i]); } \ - v = F(); REST(v); } +#define LOW(x) ((unsigned)(x) & MASK) +#define HIGH(x) LOW((x) >> N) -static unsigned x[3] = { X0, X1, X2 }, a[3] = { A0, A1, A2 }, c = C; +#define MUL(x, y, z) \ + { \ + long l = (long)(x) * (long)(y); \ + (z)[0] = LOW(l); \ + (z)[1] = HIGH(l); \ + } + +#define CARRY(x, y) ((unsigned long)((long)(x) + (long)(y)) > MASK) +#define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y))) +#define SET3(x, x0, x1, x2) ((x)[0] = (x0), (x)[1] = (x1), (x)[2] = (x2)) +#define SETLOW(x, y, n) SET3(x, LOW((y)[n]), LOW((y)[(n)+1]), LOW((y)[(n)+2])) +#define SEED(x0, x1, x2) (SET3(x, x0, x1, x2), SET3(a, A0, A1, A2), c = C) + +#define REST(v) \ + for (i = 0; i < 3; i++) { \ + xsubi[i] = x[i]; \ + x[i] = temp[i]; \ + } \ + return (v); \ + (void) 0 + +#define NEST(TYPE, f, F) \ + TYPE f(register unsigned short *xsubi) { \ + register int i; \ + register TYPE v; \ + unsigned temp[3]; \ + for (i = 0; i < 3; i++) { \ + temp[i] = x[i]; \ + x[i] = LOW(xsubi[i]); \ + } \ + v = F(); \ + REST(v); \ + } + +static unsigned x[3] = { + X0, + X1, + X2 +}; +static unsigned a[3] = { + A0, + A1, + A2 +}; +static unsigned c = C; // // Methods implementation // /////////////////////////////////////////////////////////////////////////////// -real RandGen::drand48() { - static real two16m = 1.0 / (1L << N); - next(); - return (two16m * (two16m * (two16m * x[0] + x[1]) + x[2])); +real RandGen::drand48() +{ + static real two16m = 1.0 / (1L << N); + next(); + return (two16m * (two16m * (two16m * x[0] + x[1]) + x[2])); } -void RandGen::srand48(long seedval) { - SEED(X0, LOW(seedval), HIGH(seedval)); +void RandGen::srand48(long seedval) +{ + SEED(X0, LOW(seedval), HIGH(seedval)); } -void RandGen::next() { - unsigned p[2], q[2], r[2], carry0, carry1; - - MUL(a[0], x[0], p); - ADDEQU(p[0], c, carry0); - ADDEQU(p[1], carry0, carry1); - MUL(a[0], x[1], q); - ADDEQU(p[1], q[0], carry0); - MUL(a[1], x[0], r); - x[2] = LOW(carry0 + carry1 + CARRY(p[1], r[0]) + q[1] + r[1] + - a[0] * x[2] + a[1] * x[1] + a[2] * x[0]); - x[1] = LOW(p[1] + r[0]); - x[0] = LOW(p[0]); +void RandGen::next() +{ + unsigned p[2], q[2], r[2], carry0, carry1; + + MUL(a[0], x[0], p); + ADDEQU(p[0], c, carry0); + ADDEQU(p[1], carry0, carry1); + MUL(a[0], x[1], q); + ADDEQU(p[1], q[0], carry0); + MUL(a[1], x[0], r); + x[2] = LOW(carry0 + carry1 + CARRY(p[1], r[0]) + q[1] + r[1] + a[0] * x[2] + a[1] * x[1] + a[2] * x[0]); + x[1] = LOW(p[1] + r[0]); + x[0] = LOW(p[0]); } diff --git a/source/blender/freestyle/intern/system/RandGen.h b/source/blender/freestyle/intern/system/RandGen.h index 409d3b79609..914b405d7f3 100644 --- a/source/blender/freestyle/intern/system/RandGen.h +++ b/source/blender/freestyle/intern/system/RandGen.h @@ -1,48 +1,54 @@ -// -// Filename : RandGen.h -// Author(s) : Fredo Durand -// Purpose : Pseudo-random number generator -// Date of creation : 20/05/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef RAND_GEN_H -# define RAND_GEN_H - -# include "FreestyleConfig.h" -# include "../system/Precision.h" +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_RAND_GEN_H__ +#define __FREESTYLE_RAND_GEN_H__ + +/** \file blender/freestyle/intern/system/RandGen.h + * \ingroup freestyle + * \brief Pseudo-random number generator + * \author Fredo Durand + * \date 20/05/2003 + */ + +// TODO Check whether we could replace this with BLI rand stuff... + +#include "FreestyleConfig.h" + +#include "../system/Precision.h" class LIB_SYSTEM_EXPORT RandGen { public: - - static real drand48(); - static void srand48(long value); + static real drand48(); + static void srand48(long value); private: - - static void next(); + static void next(); }; -#endif // RAND_GEN_H +#endif // __FREESTYLE_RAND_GEN_H__ diff --git a/source/blender/freestyle/intern/system/RenderMonitor.h b/source/blender/freestyle/intern/system/RenderMonitor.h index 7d148e65c90..bd50e0c5392 100644 --- a/source/blender/freestyle/intern/system/RenderMonitor.h +++ b/source/blender/freestyle/intern/system/RenderMonitor.h @@ -1,47 +1,63 @@ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef RENDERMONITOR_H -#define RENDERMONITOR_H +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_RENDER_MONITOR_H__ +#define __FREESTYLE_RENDER_MONITOR_H__ + +/** \file blender/freestyle/intern/system/BaseIterator.h + * \ingroup freestyle + * \brief Classes defining the basic "Iterator" design pattern + * \author Stephane Grabli + * \date 18/03/2003 + */ extern "C" { + #include "render_types.h" + } class RenderMonitor { public: + inline RenderMonitor(Render *re) + { + _re = re; + } - inline RenderMonitor(Render *re) { - _re = re; - } + virtual ~RenderMonitor() {} - virtual ~RenderMonitor() {} + inline bool testBreak() + { + return _re && _re->test_break(_re->tbh); + } - inline bool testBreak() { - return _re && _re->test_break(_re->tbh); - } - protected: - - Render *_re; + Render *_re; }; -#endif // RENDERMONITOR_H +#endif // __FREESTYLE_RENDER_MONITOR_H__ diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp index 58798daf42a..ee06d3d1f4b 100644 --- a/source/blender/freestyle/intern/system/StringUtils.cpp +++ b/source/blender/freestyle/intern/system/StringUtils.cpp @@ -1,74 +1,89 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/StringUtils.cpp + * \ingroup freestyle + * \brief String utilities + * \author Emmanuel Turquin + * \date 20/05/2003 + */ //soc #include <qfileinfo.h> + #include "FreestyleConfig.h" #include "StringUtils.h" namespace StringUtils { - void getPathName(const string& path, const string& base, vector<string>& pathnames) { - string dir; +void getPathName(const string& path, const string& base, vector<string>& pathnames) +{ + string dir; string res; char cleaned[FILE_MAX]; - unsigned size = path.size(); - - pathnames.push_back(base); + unsigned size = path.size(); - for ( unsigned pos = 0, sep = path.find(Config::PATH_SEP, pos); - pos < size; - pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) { + pathnames.push_back(base); + for (unsigned int pos = 0, sep = path.find(Config::PATH_SEP, pos); + pos < size; + pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) + { if (sep == (unsigned)string::npos) sep = size; - + dir = path.substr(pos, sep - pos); BLI_strncpy(cleaned, dir.c_str(), FILE_MAX); BLI_cleanup_file(NULL, cleaned); - res = toAscii( string(cleaned) ); - + res = toAscii(string(cleaned)); + if (!base.empty()) res += Config::DIR_SEP + base; - + pathnames.push_back(res); - } - } - - string toAscii( const string &str ){ - stringstream out(""); - char s; - - for(unsigned int i=0; i < str.size() ; i++){ - s = ((char)(str.at(i) & 0x7F)); - out << s; - } - - return out.str(); } - - const char* toAscii( const char *str ){ - return toAscii(string(str)).c_str(); +} + +string toAscii(const string &str) +{ + stringstream out(""); + char s; + + for (unsigned int i = 0; i < str.size() ; i++) { + s = ((char)(str.at(i) & 0x7F)); + out << s; } - + return out.str(); +} + +const char *toAscii(const char *str) +{ + return toAscii(string(str)).c_str(); +} } // end of namespace StringUtils diff --git a/source/blender/freestyle/intern/system/StringUtils.h b/source/blender/freestyle/intern/system/StringUtils.h index d44d3f62732..d8970da0dce 100644 --- a/source/blender/freestyle/intern/system/StringUtils.h +++ b/source/blender/freestyle/intern/system/StringUtils.h @@ -1,62 +1,75 @@ -// -// Filename : StringUtils.h -// Author(s) : Emmanuel Turquin -// Purpose : String utilities -// Date of creation : 20/05/2003 -// -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef STRING_UTILS_H -# define STRING_UTILS_H - -# include <cstring> -# include <vector> -# include <string> -# include <sstream> -# include <iostream> -# include "FreestyleConfig.h" +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_STRING_UTILS_H__ +#define __FREESTYLE_STRING_UTILS_H__ + +/** \file blender/freestyle/intern/system/StringUtils.h + * \ingroup freestyle + * \brief String utilities + * \author Emmanuel Turquin + * \date 20/05/2003 + */ + +#include <cstring> +#include <iostream> +#include <sstream> +#include <string> +#include <vector> + +#include "FreestyleConfig.h" //soc extern "C" { + #include "BKE_utildefines.h" + #include "BLI_blenlib.h" + } using namespace std; namespace StringUtils { - LIB_SYSTEM_EXPORT - void getPathName(const string& path, const string& base, vector<string>& pathnames); - string toAscii( const string &str ); - const char* toAscii( const char *str ); +LIB_SYSTEM_EXPORT +void getPathName(const string& path, const string& base, vector<string>& pathnames); +string toAscii(const string &str); +const char *toAscii(const char *str); - // STL related - struct ltstr{ - bool operator()(const char* s1, const char* s2) const{ - return strcmp(s1, s2) < 0; - } +// STL related +struct ltstr +{ + bool operator()(const char *s1, const char *s2) const + { + return strcmp(s1, s2) < 0; + } }; } // end of namespace StringUtils -#endif // STRING_UTILS_H +#endif // __FREESTYLE_STRING_UTILS_H__ diff --git a/source/blender/freestyle/intern/system/TimeStamp.cpp b/source/blender/freestyle/intern/system/TimeStamp.cpp index c66e1131611..6a7f0b00b79 100644 --- a/source/blender/freestyle/intern/system/TimeStamp.cpp +++ b/source/blender/freestyle/intern/system/TimeStamp.cpp @@ -1,25 +1,38 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/TimeStamp.cpp + * \ingroup freestyle + * \brief Class defining a singleton used as timestamp + * \author Stephane Grabli + * \date 12/12/2002 + */ #include "TimeStamp.h" -LIB_SYSTEM_EXPORT -TimeStamp* TimeStamp::_instance = 0; +LIB_SYSTEM_EXPORT +TimeStamp *TimeStamp::_instance = 0; diff --git a/source/blender/freestyle/intern/system/TimeStamp.h b/source/blender/freestyle/intern/system/TimeStamp.h index 568a7851e30..6f9bb3d4e44 100644 --- a/source/blender/freestyle/intern/system/TimeStamp.h +++ b/source/blender/freestyle/intern/system/TimeStamp.h @@ -1,71 +1,78 @@ -// -// Filename : TimeStamp.h -// Author(s) : Stephane Grabli -// Purpose : Class defining a singleton used as timestamp -// Date of creation : 12/12/2002 -// -/////////////////////////////////////////////////////////////////////////////// +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __FREESTYLE_TIME_STAMP_H__ +#define __FREESTYLE_TIME_STAMP_H__ -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// +/** \file blender/freestyle/intern/system/TimeStamp.h + * \ingroup freestyle + * \brief Class defining a singleton used as timestamp + * \author Stephane Grabli + * \date 12/12/2002 + */ -#ifndef TIMESTAMP_H -# define TIMESTAMP_H +#include "FreestyleConfig.h" -# include "FreestyleConfig.h" - -class LIB_SYSTEM_EXPORT TimeStamp +class LIB_SYSTEM_EXPORT TimeStamp { - public: - - static inline TimeStamp* instance() { - if (_instance == 0) - _instance = new TimeStamp; - return _instance; - } - - inline unsigned getTimeStamp() const { - return _time_stamp; - } +public: + static inline TimeStamp *instance() + { + if (_instance == NULL) + _instance = new TimeStamp; + return _instance; + } - inline void increment() { - ++_time_stamp; - } + inline unsigned getTimeStamp() const + { + return _time_stamp; + } - inline void reset() { - _time_stamp = 1; - } + inline void increment() + { + ++_time_stamp; + } - protected: - - TimeStamp() { - _time_stamp = 1; - } + inline void reset() + { + _time_stamp = 1; + } - TimeStamp(const TimeStamp&) {} +protected: + TimeStamp() + { + _time_stamp = 1; + } - private: + TimeStamp(const TimeStamp&) {} - static TimeStamp* _instance; - unsigned _time_stamp; +private: + static TimeStamp *_instance; + unsigned _time_stamp; }; -#endif // TIMESTAMP_H +#endif // __FREESTYLE_TIME_STAMP_H__ diff --git a/source/blender/freestyle/intern/system/TimeUtils.h b/source/blender/freestyle/intern/system/TimeUtils.h index 99dd5b0a669..d42813dd560 100644 --- a/source/blender/freestyle/intern/system/TimeUtils.h +++ b/source/blender/freestyle/intern/system/TimeUtils.h @@ -1,58 +1,64 @@ -// -// Filename : TimeUtils.h -// Author(s) : Stephane Grabli -// Purpose : Class to measure ellapsed time -// Date of creation : 10/04/2002 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TIMEUTILS_H -# define TIMEUTILS_H +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_TIME_UTILS_H__ +#define __FREESTYLE_TIME_UTILS_H__ + +/** \file blender/freestyle/intern/system/TimeUtils.h + * \ingroup freestyle + * \brief Class to measure ellapsed time + * \author Stephane Grabli + * \date 10/04/2002 + */ #include <time.h> + #include "FreestyleConfig.h" -class Chronometer +class Chronometer { - public: - - inline Chronometer() {} - inline ~Chronometer() {} - - inline clock_t start() { - _start = clock(); - return _start; - } +public: + inline Chronometer() {} + inline ~Chronometer() {} - inline double stop() { - clock_t stop = clock(); - return (double)(stop - _start) / CLOCKS_PER_SEC ; - } + inline clock_t start() + { + _start = clock(); + return _start; + } - private: + inline double stop() + { + clock_t stop = clock(); + return (double)(stop - _start) / CLOCKS_PER_SEC; + } - clock_t _start; +private: + clock_t _start; }; -#endif // TIMEUTILS_H +#endif // __FREESTYLE_TIME_UTILS_H__ |