Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/freestyle/intern/system')
-rw-r--r--source/blender/freestyle/intern/system/BaseIterator.h97
-rw-r--r--source/blender/freestyle/intern/system/BaseObject.cpp36
-rw-r--r--source/blender/freestyle/intern/system/BaseObject.h77
-rw-r--r--source/blender/freestyle/intern/system/Cast.h49
-rw-r--r--source/blender/freestyle/intern/system/Exception.cpp37
-rw-r--r--source/blender/freestyle/intern/system/Exception.h70
-rw-r--r--source/blender/freestyle/intern/system/FreestyleConfig.h96
-rw-r--r--source/blender/freestyle/intern/system/Id.h142
-rw-r--r--source/blender/freestyle/intern/system/Interpreter.h65
-rw-r--r--source/blender/freestyle/intern/system/Iterator.cpp32
-rw-r--r--source/blender/freestyle/intern/system/Iterator.h75
-rw-r--r--source/blender/freestyle/intern/system/PointerSequence.h96
-rw-r--r--source/blender/freestyle/intern/system/Precision.h44
-rw-r--r--source/blender/freestyle/intern/system/ProgressBar.h96
-rw-r--r--source/blender/freestyle/intern/system/PseudoNoise.cpp116
-rw-r--r--source/blender/freestyle/intern/system/PseudoNoise.h60
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.cpp38
-rw-r--r--source/blender/freestyle/intern/system/PythonInterpreter.h198
-rw-r--r--source/blender/freestyle/intern/system/RandGen.cpp132
-rw-r--r--source/blender/freestyle/intern/system/RandGen.h54
-rw-r--r--source/blender/freestyle/intern/system/RenderMonitor.h63
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.cpp89
-rw-r--r--source/blender/freestyle/intern/system/StringUtils.h75
-rw-r--r--source/blender/freestyle/intern/system/TimeStamp.cpp38
-rw-r--r--source/blender/freestyle/intern/system/TimeStamp.h78
-rw-r--r--source/blender/freestyle/intern/system/TimeUtils.h64
26 files changed, 2017 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/system/BaseIterator.h b/source/blender/freestyle/intern/system/BaseIterator.h
new file mode 100644
index 00000000000..836f6c83eb8
--- /dev/null
+++ b/source/blender/freestyle/intern/system/BaseIterator.h
@@ -0,0 +1,97 @@
+/*
+ * ***** 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
+{
+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;
+};
+
+template <class Element>
+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;
+};
+
+class InputIteratorTag_Traits
+{
+public:
+ typedef std::input_iterator_tag iterator_category;
+};
+
+class BidirectionalIteratorTag_Traits
+{
+public:
+ typedef std::bidirectional_iterator_tag iterator_category;
+};
+
+template<class Traits, class IteratorTagTraits>
+class IteratorBase
+{
+public:
+ virtual ~IteratorBase() {}
+
+ 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;
+
+protected:
+ IteratorBase() {}
+};
+
+#endif // BASEITERATOR_H
diff --git a/source/blender/freestyle/intern/system/BaseObject.cpp b/source/blender/freestyle/intern/system/BaseObject.cpp
new file mode 100644
index 00000000000..2088585c33b
--- /dev/null
+++ b/source/blender/freestyle/intern/system/BaseObject.cpp
@@ -0,0 +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
new file mode 100644
index 00000000000..1fe2770c313
--- /dev/null
+++ b/source/blender/freestyle/intern/system/BaseObject.h
@@ -0,0 +1,77 @@
+/*
+ * ***** 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__
+
+/** \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;
+ }
+
+ 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();
+ }
+
+ /*! 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;
+ }
+
+private:
+ unsigned _ref_counter;
+};
+
+#endif // __FREESTYLE_BASE_OBJECT_H__
diff --git a/source/blender/freestyle/intern/system/Cast.h b/source/blender/freestyle/intern/system/Cast.h
new file mode 100644
index 00000000000..02dd5699214
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Cast.h
@@ -0,0 +1,49 @@
+/*
+ * ***** 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__
+
+/** \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 // __FREESTYLE_CAST_H__
diff --git a/source/blender/freestyle/intern/system/Exception.cpp b/source/blender/freestyle/intern/system/Exception.cpp
new file mode 100644
index 00000000000..7c7c16fdf40
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Exception.cpp
@@ -0,0 +1,37 @@
+/*
+ * ***** 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/Exception.cpp
+ * \ingroup freestyle
+ * \brief Singleton to manage exceptions
+ * \author Stephane Grabli
+ * \date 10/01/2003
+ */
+
+#include "Exception.h"
+
+Exception::exception_type Exception::_exception = Exception::NO_EXCEPTION;
diff --git a/source/blender/freestyle/intern/system/Exception.h b/source/blender/freestyle/intern/system/Exception.h
new file mode 100644
index 00000000000..b9bfa00cf97
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Exception.h
@@ -0,0 +1,70 @@
+/*
+ * ***** 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__
+
+/** \file blender/freestyle/intern/system/Exception.h
+ * \ingroup freestyle
+ * \brief Singleton to manage exceptions
+ * \author Stephane Grabli
+ * \date 10/01/2003
+ */
+
+#include "FreestyleConfig.h"
+
+class LIB_SYSTEM_EXPORT Exception
+{
+public:
+ typedef enum {
+ NO_EXCEPTION,
+ UNDEFINED,
+ } exception_type;
+
+ static int getException()
+ {
+ exception_type e = _exception;
+ _exception = NO_EXCEPTION;
+ return e;
+ }
+
+ static int raiseException(exception_type exception = UNDEFINED)
+ {
+ _exception = exception;
+ return _exception;
+ }
+
+ static void reset()
+ {
+ _exception = NO_EXCEPTION;
+ }
+
+private:
+ static exception_type _exception;
+};
+
+#endif // __FREESTYLE_EXCEPTION_H__
diff --git a/source/blender/freestyle/intern/system/FreestyleConfig.h b/source/blender/freestyle/intern/system/FreestyleConfig.h
new file mode 100644
index 00000000000..9d81af1be3b
--- /dev/null
+++ b/source/blender/freestyle/intern/system/FreestyleConfig.h
@@ -0,0 +1,96 @@
+/*
+ * ***** 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
+// 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
+
+#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_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_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_STROKE_EXPORT
+# define LIB_STROKE_EXPORT
+#endif // LIB_STROKE_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
+
+} // end of namespace Config
+
+#endif // __FREESTYLE_CONFIG_H__
diff --git a/source/blender/freestyle/intern/system/Id.h b/source/blender/freestyle/intern/system/Id.h
new file mode 100644
index 00000000000..d6e39bff167
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Id.h
@@ -0,0 +1,142 @@
+/*
+ * ***** 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;
+ }
+
+private:
+ 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;
+}
+
+# endif // __FREESTYLE_ID_H__
diff --git a/source/blender/freestyle/intern/system/Interpreter.h b/source/blender/freestyle/intern/system/Interpreter.h
new file mode 100644
index 00000000000..7928db9aed2
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Interpreter.h
@@ -0,0 +1,65 @@
+/*
+ * ***** 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
+
+ virtual int interpretFile(const string& filename) = 0;
+
+ virtual string getLanguage() const
+ {
+ return _language;
+ }
+
+ virtual void reset() = 0;
+
+protected:
+ string _language;
+};
+
+#endif // __FREESTYLE_INTERPRETER_H__
diff --git a/source/blender/freestyle/intern/system/Iterator.cpp b/source/blender/freestyle/intern/system/Iterator.cpp
new file mode 100644
index 00000000000..2e89880b3d7
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Iterator.cpp
@@ -0,0 +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
new file mode 100644
index 00000000000..9cd0f16275b
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Iterator.h
@@ -0,0 +1,75 @@
+/*
+ * ***** 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;
+
+class Iterator
+{
+public:
+ virtual ~Iterator() {}
+
+ virtual string getExactTypeName() const
+ {
+ return "Iterator";
+ }
+
+ virtual int increment()
+ {
+ cerr << "Warning: increment() not implemented" << endl;
+ return 0;
+ }
+
+ virtual int decrement()
+ {
+ cerr << "Warning: decrement() not implemented" << endl;
+ return 0;
+ }
+
+ 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 // __FREESTYLE_ITERATOR_H__
diff --git a/source/blender/freestyle/intern/system/PointerSequence.h b/source/blender/freestyle/intern/system/PointerSequence.h
new file mode 100644
index 00000000000..c97f4516d00
--- /dev/null
+++ b/source/blender/freestyle/intern/system/PointerSequence.h
@@ -0,0 +1,96 @@
+/*
+ * ***** 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__
+
+/** \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
+{
+ PointerSequence (PointerSequence& other);
+ PointerSequence& operator=(PointerSequence& other);
+
+ static void destroyer(T t)
+ {
+ delete t;
+ }
+
+public:
+ PointerSequence () {};
+
+ ~PointerSequence ()
+ {
+ destroy();
+ }
+
+ void destroy ()
+ {
+ for_each(this->begin(), this->end(), destroyer);
+ }
+};
+
+#endif // __FREESTYLE_POINTER_SEQUENCE_H__
diff --git a/source/blender/freestyle/intern/system/Precision.h b/source/blender/freestyle/intern/system/Precision.h
new file mode 100644
index 00000000000..c2a9e24e635
--- /dev/null
+++ b/source/blender/freestyle/intern/system/Precision.h
@@ -0,0 +1,44 @@
+/*
+ * ***** 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__
+
+/** \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
+
+#endif // __FREESTYLE_PRECISION_H__
diff --git a/source/blender/freestyle/intern/system/ProgressBar.h b/source/blender/freestyle/intern/system/ProgressBar.h
new file mode 100644
index 00000000000..2837c148754
--- /dev/null
+++ b/source/blender/freestyle/intern/system/ProgressBar.h
@@ -0,0 +1,96 @@
+/*
+ * ***** 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;
+ }
+
+protected:
+ unsigned _numtotalsteps;
+ unsigned _progress;
+ string _label;
+};
+
+#endif // __FREESTYLE_PROGRESS_BAR_H__
diff --git a/source/blender/freestyle/intern/system/PseudoNoise.cpp b/source/blender/freestyle/intern/system/PseudoNoise.cpp
new file mode 100644
index 00000000000..27158bfd4aa
--- /dev/null
+++ b/source/blender/freestyle/intern/system/PseudoNoise.cpp
@@ -0,0 +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 *****
+ */
+
+/** \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 "PseudoNoise.h"
+#include "RandGen.h"
+
+static const unsigned NB_VALUE_NOISE = 512;
+
+real *PseudoNoise::_values;
+
+PseudoNoise::PseudoNoise() {}
+
+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();
+}
+
+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;
+}
+
+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);
+}
+
+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 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);
+#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 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 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
new file mode 100644
index 00000000000..7b414ae76e5
--- /dev/null
+++ b/source/blender/freestyle/intern/system/PseudoNoise.h
@@ -0,0 +1,60 @@
+/*
+ * ***** 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();
+
+ virtual ~PseudoNoise() {}
+
+ real smoothNoise(real x);
+ real linearNoise(real x);
+
+ real turbulenceSmooth(real x, unsigned nbOctave = 8);
+ real turbulenceLinear(real x, unsigned nbOctave = 8);
+
+ static void init(long seed);
+
+protected:
+ static real *_values;
+};
+
+#endif // __FREESTYLE_PSEUDO_NOISE_H__
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.cpp b/source/blender/freestyle/intern/system/PythonInterpreter.cpp
new file mode 100644
index 00000000000..aa8df8f418b
--- /dev/null
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.cpp
@@ -0,0 +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 *****
+ */
+
+/** \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;
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
new file mode 100644
index 00000000000..6093b6e4dcd
--- /dev/null
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -0,0 +1,198 @@
+/*
+ * ***** 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_context.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+#include "BKE_text.h"
+
+#include "BPY_extern.h"
+
+}
+
+class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter
+{
+public:
+ PythonInterpreter()
+ {
+ _language = "Python";
+ _context = 0;
+ //Py_Initialize();
+ }
+
+ virtual ~PythonInterpreter()
+ {
+ //Py_Finalize();
+ }
+
+ void setContext(bContext *C)
+ {
+ _context = C;
+ }
+
+ int interpretFile(const string& filename)
+ {
+ initPath();
+
+ 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);
+#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;
+ }
+#endif
+
+ if (status != 1) {
+ cerr << "\nError executing Python script from PythonInterpreter::interpretFile" << endl;
+ cerr << "File: " << fn << endl;
+ cerr << "Errors: " << endl;
+ BKE_reports_print(reports, RPT_ERROR);
+ return 1;
+ }
+
+ // cleaning up
+ BKE_reports_clear(reports);
+
+ return 0;
+ }
+
+ int interpretText(struct Text *text, const string& name) {
+ initPath();
+
+ ReportList *reports = CTX_wm_reports(_context);
+
+ BKE_reports_clear(reports);
+
+ if (!BPY_text_exec(_context, text, reports, false)) {
+ cerr << "\nError executing Python script from PythonInterpreter::interpretText" << endl;
+ cerr << "Name: " << name << endl;
+ cerr << "Errors: " << endl;
+ BKE_reports_print(reports, RPT_ERROR);
+ return 1;
+ }
+
+ BKE_reports_clear(reports);
+
+ return 0;
+ }
+
+ struct Options
+ {
+ static void setPythonPath(const string& path)
+ {
+ _path = path;
+ }
+
+ static string getPythonPath()
+ {
+ return _path;
+ }
+ };
+
+ void reset()
+ {
+ Py_Finalize();
+ Py_Initialize();
+ _initialized = false;
+ }
+
+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()) {
+ if (G.debug & G_DEBUG_FREESTYLE) {
+ cout << "Adding Python path: " << *it << endl;
+ }
+ cmd = "sys.path.append(r\"" + *it + "\")\n";
+ txt_insert_buf(text, const_cast<char *>(cmd.c_str()));
+ }
+ }
+
+ 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;
+};
+
+#endif // __FREESTYLE_PYTHON_INTERPRETER_H__
diff --git a/source/blender/freestyle/intern/system/RandGen.cpp b/source/blender/freestyle/intern/system/RandGen.cpp
new file mode 100644
index 00000000000..193df1b4239
--- /dev/null
+++ b/source/blender/freestyle/intern/system/RandGen.cpp
@@ -0,0 +1,132 @@
+/*
+ * ***** 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/RandGen.cpp
+ * \ingroup freestyle
+ * \brief Pseudo-random number generator
+ * \author Fredo Durand
+ * \date 20/05/2003
+ */
+
+#include "RandGen.h"
+
+//
+// Macro definitions
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#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); \
+ (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]));
+}
+
+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]);
+}
diff --git a/source/blender/freestyle/intern/system/RandGen.h b/source/blender/freestyle/intern/system/RandGen.h
new file mode 100644
index 00000000000..914b405d7f3
--- /dev/null
+++ b/source/blender/freestyle/intern/system/RandGen.h
@@ -0,0 +1,54 @@
+/*
+ * ***** 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);
+
+private:
+ static void next();
+};
+
+#endif // __FREESTYLE_RAND_GEN_H__
diff --git a/source/blender/freestyle/intern/system/RenderMonitor.h b/source/blender/freestyle/intern/system/RenderMonitor.h
new file mode 100644
index 00000000000..bd50e0c5392
--- /dev/null
+++ b/source/blender/freestyle/intern/system/RenderMonitor.h
@@ -0,0 +1,63 @@
+/*
+ * ***** 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;
+ }
+
+ virtual ~RenderMonitor() {}
+
+ inline bool testBreak()
+ {
+ return _re && _re->test_break(_re->tbh);
+ }
+
+protected:
+ Render *_re;
+};
+
+#endif // __FREESTYLE_RENDER_MONITOR_H__
diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp
new file mode 100644
index 00000000000..ee06d3d1f4b
--- /dev/null
+++ b/source/blender/freestyle/intern/system/StringUtils.cpp
@@ -0,0 +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 *****
+ */
+
+/** \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;
+ string res;
+ char cleaned[FILE_MAX];
+ unsigned size = path.size();
+
+ 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));
+
+ 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();
+}
+
+} // end of namespace StringUtils
diff --git a/source/blender/freestyle/intern/system/StringUtils.h b/source/blender/freestyle/intern/system/StringUtils.h
new file mode 100644
index 00000000000..d8970da0dce
--- /dev/null
+++ b/source/blender/freestyle/intern/system/StringUtils.h
@@ -0,0 +1,75 @@
+/*
+ * ***** 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);
+
+// STL related
+struct ltstr
+{
+ bool operator()(const char *s1, const char *s2) const
+ {
+ return strcmp(s1, s2) < 0;
+ }
+};
+
+} // end of namespace StringUtils
+
+#endif // __FREESTYLE_STRING_UTILS_H__
diff --git a/source/blender/freestyle/intern/system/TimeStamp.cpp b/source/blender/freestyle/intern/system/TimeStamp.cpp
new file mode 100644
index 00000000000..6a7f0b00b79
--- /dev/null
+++ b/source/blender/freestyle/intern/system/TimeStamp.cpp
@@ -0,0 +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 *****
+ */
+
+/** \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;
diff --git a/source/blender/freestyle/intern/system/TimeStamp.h b/source/blender/freestyle/intern/system/TimeStamp.h
new file mode 100644
index 00000000000..6f9bb3d4e44
--- /dev/null
+++ b/source/blender/freestyle/intern/system/TimeStamp.h
@@ -0,0 +1,78 @@
+/*
+ * ***** 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__
+
+/** \file blender/freestyle/intern/system/TimeStamp.h
+ * \ingroup freestyle
+ * \brief Class defining a singleton used as timestamp
+ * \author Stephane Grabli
+ * \date 12/12/2002
+ */
+
+#include "FreestyleConfig.h"
+
+class LIB_SYSTEM_EXPORT TimeStamp
+{
+public:
+ static inline TimeStamp *instance()
+ {
+ if (_instance == NULL)
+ _instance = new TimeStamp;
+ return _instance;
+ }
+
+ inline unsigned getTimeStamp() const
+ {
+ return _time_stamp;
+ }
+
+ inline void increment()
+ {
+ ++_time_stamp;
+ }
+
+ inline void reset()
+ {
+ _time_stamp = 1;
+ }
+
+protected:
+ TimeStamp()
+ {
+ _time_stamp = 1;
+ }
+
+ TimeStamp(const TimeStamp&) {}
+
+private:
+ static TimeStamp *_instance;
+ unsigned _time_stamp;
+};
+
+#endif // __FREESTYLE_TIME_STAMP_H__
diff --git a/source/blender/freestyle/intern/system/TimeUtils.h b/source/blender/freestyle/intern/system/TimeUtils.h
new file mode 100644
index 00000000000..d42813dd560
--- /dev/null
+++ b/source/blender/freestyle/intern/system/TimeUtils.h
@@ -0,0 +1,64 @@
+/*
+ * ***** 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
+{
+public:
+ inline Chronometer() {}
+ inline ~Chronometer() {}
+
+ inline clock_t start()
+ {
+ _start = clock();
+ return _start;
+ }
+
+ inline double stop()
+ {
+ clock_t stop = clock();
+ return (double)(stop - _start) / CLOCKS_PER_SEC;
+ }
+
+private:
+ clock_t _start;
+};
+
+#endif // __FREESTYLE_TIME_UTILS_H__