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/scene_graph')
-rw-r--r--source/blender/freestyle/intern/scene_graph/DrawingStyle.h128
-rw-r--r--source/blender/freestyle/intern/scene_graph/FrsMaterial.h379
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp331
-rw-r--r--source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h322
-rw-r--r--source/blender/freestyle/intern/scene_graph/LineRep.cpp71
-rw-r--r--source/blender/freestyle/intern/scene_graph/LineRep.h158
-rw-r--r--source/blender/freestyle/intern/scene_graph/Node.h115
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.cpp143
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeCamera.h216
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp46
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h111
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.cpp126
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeGroup.h89
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeLight.cpp86
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeLight.h113
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeShape.cpp63
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeShape.h103
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.cpp178
-rw-r--r--source/blender/freestyle/intern/scene_graph/NodeTransform.h110
-rw-r--r--source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp46
-rw-r--r--source/blender/freestyle/intern/scene_graph/OrientedLineRep.h66
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.cpp35
-rw-r--r--source/blender/freestyle/intern/scene_graph/Rep.h173
-rw-r--r--source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.cpp110
-rw-r--r--source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h109
-rw-r--r--source/blender/freestyle/intern/scene_graph/SceneVisitor.cpp35
-rw-r--r--source/blender/freestyle/intern/scene_graph/SceneVisitor.h102
-rw-r--r--source/blender/freestyle/intern/scene_graph/TriangleRep.cpp69
-rw-r--r--source/blender/freestyle/intern/scene_graph/TriangleRep.h150
-rw-r--r--source/blender/freestyle/intern/scene_graph/VertexRep.cpp41
-rw-r--r--source/blender/freestyle/intern/scene_graph/VertexRep.h141
31 files changed, 3965 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/scene_graph/DrawingStyle.h b/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
new file mode 100644
index 00000000000..000b6c8575d
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/DrawingStyle.h
@@ -0,0 +1,128 @@
+/*
+ * ***** 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_DRAWING_STYLE_H__
+#define __FREESTYLE_DRAWING_STYLE_H__
+
+/** \file blender/freestyle/intern/scene_graph/DrawingStyle.h
+ * \ingroup freestyle
+ * \brief Class to define the drawing style of a node
+ * \author Stephane Grabli
+ * \date 10/10/2002
+ */
+
+class DrawingStyle
+{
+public:
+ enum STYLE {
+ FILLED,
+ LINES,
+ POINTS,
+ INVISIBLE,
+ };
+
+ inline DrawingStyle()
+ {
+ Style = FILLED;
+ LineWidth = 2.0f;
+ PointSize = 2.0f;
+ LightingEnabled = true;
+ }
+
+ inline explicit DrawingStyle(const DrawingStyle& iBrother);
+
+ virtual ~DrawingStyle() {}
+
+ /*! operators */
+ inline DrawingStyle& operator=(const DrawingStyle& ds);
+
+ inline void setStyle(const STYLE iStyle)
+ {
+ Style = iStyle;
+ }
+
+ inline void setLineWidth(const float iLineWidth)
+ {
+ LineWidth = iLineWidth;
+ }
+
+ inline void setPointSize(const float iPointSize)
+ {
+ PointSize = iPointSize;
+ }
+
+ inline void setLightingEnabled(const bool on)
+ {
+ LightingEnabled = on;
+ }
+
+ inline STYLE style() const
+ {
+ return Style;
+ }
+
+ inline float lineWidth() const
+ {
+ return LineWidth;
+ }
+
+ inline float pointSize() const
+ {
+ return PointSize;
+ }
+
+ inline bool lightingEnabled() const
+ {
+ return LightingEnabled;
+ }
+
+private:
+ STYLE Style;
+ float LineWidth;
+ float PointSize;
+ bool LightingEnabled;
+};
+
+DrawingStyle::DrawingStyle(const DrawingStyle& iBrother)
+{
+ Style = iBrother.Style;
+ LineWidth = iBrother.LineWidth;
+ PointSize = iBrother.PointSize;
+ LightingEnabled = iBrother.LightingEnabled;
+}
+
+DrawingStyle& DrawingStyle::operator=(const DrawingStyle& ds)
+{
+ Style = ds.Style;
+ LineWidth = ds.LineWidth;
+ PointSize = ds.PointSize;
+ LightingEnabled = ds.LightingEnabled;
+
+ return *this;
+}
+
+#endif // __FREESTYLE_DRAWING_STYLE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/FrsMaterial.h b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
new file mode 100644
index 00000000000..831c384d472
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/FrsMaterial.h
@@ -0,0 +1,379 @@
+/*
+ * ***** 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_MATERIAL_H__
+#define __FREESTYLE_MATERIAL_H__
+
+/** \file blender/freestyle/intern/scene_graph/FrsMaterial.h
+ * \ingroup freestyle
+ * \brief Class used to handle materials.
+ * \author Stephane Grabli
+ * \date 10/10/2002
+ */
+
+#include "../system/FreestyleConfig.h"
+
+/*! Class defining a material */
+class FrsMaterial
+{
+public:
+ /*! Default constructor */
+ inline FrsMaterial();
+
+ /*! Builds a Material from its diffuse, ambiant, specular, emissive colors and a shininess coefficient.
+ * \param iDiffuse
+ * A 4 element float-array containing the diffuse color.
+ * \param iAmbiant
+ * A 4 element float-array containing the ambiant color.
+ * \param iSpecular
+ * A 4 element float-array containing the specular color.
+ * \param iEmission
+ * A 4 element float-array containing the emissive color.
+ * \param iShininess
+ * The shininess coefficient.
+ */
+ inline FrsMaterial(const float *iDiffuse, const float *iAmbiant, const float *iSpecular, const float *iEmission,
+ const float iShininess);
+
+ /*! Copy constructor */
+ inline FrsMaterial(const FrsMaterial& m);
+
+ /*! Destructor */
+ virtual ~FrsMaterial() {}
+
+
+ /*! Returns the diffuse color as a 4 float array */
+ inline const float *diffuse() const
+ {
+ return Diffuse;
+ }
+
+ /*! Returns the red component of the diffuse color */
+ inline const float diffuseR() const
+ {
+ return Diffuse[0];
+ }
+
+ /*! Returns the green component of the diffuse color */
+ inline const float diffuseG() const
+ {
+ return Diffuse[1];
+ }
+
+ /*! Returns the blue component of the diffuse color */
+ inline const float diffuseB() const
+ {
+ return Diffuse[2];
+ }
+
+ /*! Returns the alpha component of the diffuse color */
+ inline const float diffuseA() const
+ {
+ return Diffuse[3];
+ }
+
+ /*! Returns the specular color as a 4 float array */
+ inline const float *specular() const
+ {
+ return Specular;
+ }
+
+ /*! Returns the red component of the specular color */
+ inline const float specularR() const
+ {
+ return Specular[0];
+ }
+
+ /*! Returns the green component of the specular color */
+ inline const float specularG() const
+ {
+ return Specular[1];
+ }
+
+ /*! Returns the blue component of the specular color */
+ inline const float specularB() const
+ {
+ return Specular[2];
+ }
+
+ /*! Returns the alpha component of the specular color */
+ inline const float specularA() const
+ {
+ return Specular[3];
+ }
+
+ /*! Returns the ambiant color as a 4 float array */
+ inline const float *ambient() const
+ {
+ return Ambient;
+ }
+
+ /*! Returns the red component of the ambiant color */
+ inline const float ambientR() const
+ {
+ return Ambient[0];
+ }
+
+ /*! Returns the green component of the ambiant color */
+ inline const float ambientG() const
+ {
+ return Ambient[1];
+ }
+
+ /*! Returns the blue component of the ambiant color */
+ inline const float ambientB() const
+ {
+ return Ambient[2];
+ }
+
+ /*! Returns the alpha component of the ambiant color */
+ inline const float ambientA() const
+ {
+ return Ambient[3];
+ }
+
+ /*! Returns the emissive color as a 4 float array */
+ inline const float *emission() const
+ {
+ return Emission;
+ }
+
+ /*! Returns the red component of the emissive color */
+ inline const float emissionR() const
+ {
+ return Emission[0];
+ }
+
+ /*! Returns the green component of the emissive color */
+ inline const float emissionG() const
+ {
+ return Emission[1];
+ }
+
+ /*! Returns the blue component of the emissive color */
+ inline const float emissionB() const
+ {
+ return Emission[2];
+ }
+
+ /*! Returns the alpha component of the emissive color */
+ inline const float emissionA() const
+ {
+ return Emission[3];
+ }
+
+ /*! Returns the shininess coefficient */
+ inline const float shininess() const
+ {
+ return Shininess;
+ }
+
+ /*! Sets the diffuse color.
+ * \param r
+ * Red component
+ * \param g
+ * Green component
+ * \param b
+ * Blue component
+ * \param a
+ * Alpha component
+ */
+ inline void setDiffuse(const float r, const float g, const float b, const float a);
+
+ /*! Sets the specular color.
+ * \param r
+ * Red component
+ * \param g
+ * Green component
+ * \param b
+ * Blue component
+ * \param a
+ * Alpha component
+ */
+ inline void setSpecular(const float r, const float g, const float b, const float a);
+
+ /*! Sets the ambiant color.
+ * \param r
+ * Red component
+ * \param g
+ * Green component
+ * \param b
+ * Blue component
+ * \param a
+ * Alpha component
+ */
+ inline void setAmbient(const float r, const float g, const float b, const float a);
+
+ /*! Sets the emissive color.
+ * \param r
+ * Red component
+ * \param g
+ * Green component
+ * \param b
+ * Blue component
+ * \param a
+ * Alpha component
+ */
+ inline void setEmission(const float r, const float g, const float b, const float a);
+
+ /*! Sets the shininess.
+ * \param s
+ * Shininess
+ */
+ inline void setShininess(const float s);
+
+ /* operators */
+ inline FrsMaterial& operator=(const FrsMaterial& m);
+ inline bool operator!=(const FrsMaterial& m) const;
+ inline bool operator==(const FrsMaterial& m) const;
+
+private:
+ /*! Material properties */
+ float Diffuse[4];
+ float Specular[4];
+ float Ambient[4];
+ float Emission[4];
+ float Shininess;
+};
+
+FrsMaterial::FrsMaterial()
+{
+ Ambient[0] = Ambient[1] = Ambient[2] = 0.2f;
+ Ambient[3] = 1.0f;
+
+ Diffuse[0] = Diffuse[1] = Diffuse[2] = 0.8f;
+ Diffuse[3] = 1.0f;
+
+ Emission[0] = Emission[1] = Emission[2] = 0.0f;
+ Emission[3] = 1.0f;
+
+ Specular[0] = Specular[1] = Specular[2] = 0.0f;
+ Specular[3] = 1.0f;
+
+ Shininess = 0.0f;
+}
+
+FrsMaterial::FrsMaterial(const float *iDiffuse, const float *iAmbiant, const float *iSpecular, const float *iEmission,
+ const float iShininess)
+{
+ for (int i = 0; i < 4; i++) {
+ Diffuse[i] = iDiffuse[i];
+ Specular[i] = iSpecular[i];
+ Ambient[i] = iAmbiant[i];
+ Emission[i] = iEmission[i];
+ }
+
+ Shininess = iShininess;
+}
+
+FrsMaterial::FrsMaterial(const FrsMaterial& m)
+{
+ for (int i = 0; i < 4; i++) {
+ Diffuse[i] = m.diffuse()[i];
+ Specular[i] = m.specular()[i];
+ Ambient[i] = m.ambient()[i];
+ Emission[i] = m.emission()[i];
+ }
+
+ Shininess = m.shininess();
+}
+
+void FrsMaterial::setDiffuse(const float r, const float g, const float b, const float a)
+{
+ Diffuse[0] = r;
+ Diffuse[1] = g;
+ Diffuse[2] = b;
+ Diffuse[3] = a;
+}
+
+void FrsMaterial::setSpecular(const float r, const float g, const float b, const float a)
+{
+ Specular[0] = r;
+ Specular[1] = g;
+ Specular[2] = b;
+ Specular[3] = a;
+}
+
+void FrsMaterial::setAmbient(const float r, const float g, const float b, const float a)
+{
+ Ambient[0] = r;
+ Ambient[1] = g;
+ Ambient[2] = b;
+ Ambient[3] = a;
+}
+
+void FrsMaterial::setEmission(const float r, const float g, const float b, const float a)
+{
+ Emission[0] = r;
+ Emission[1] = g;
+ Emission[2] = b;
+ Emission[3] = a;
+}
+
+void FrsMaterial::setShininess(const float s)
+{
+ Shininess = s;
+}
+
+FrsMaterial& FrsMaterial::operator=(const FrsMaterial& m)
+{
+ for (int i = 0; i < 4; i++) {
+ Diffuse[i] = m.diffuse()[i];
+ Specular[i] = m.specular()[i];
+ Ambient[i] = m.ambient()[i];
+ Emission[i] = m.emission()[i];
+ }
+
+ Shininess = m.shininess();
+ return *this;
+}
+
+bool FrsMaterial::operator!=(const FrsMaterial& m) const
+{
+ if (Shininess != m.shininess())
+ return true;
+
+ for (int i = 0; i < 4; i++) {
+ if (Diffuse[i] != m.diffuse()[i])
+ return true;
+ if (Specular[i] != m.specular()[i])
+ return true;
+ if (Ambient[i] != m.ambient()[i])
+ return true;
+ if (Emission[i] != m.emission()[i])
+ return true;
+ }
+
+ return false;
+}
+
+bool FrsMaterial::operator==(const FrsMaterial& m) const
+{
+ return (!((*this) != m));
+}
+
+#endif // __FREESTYLE_MATERIAL_H__
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
new file mode 100644
index 00000000000..f373b730d0f
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
@@ -0,0 +1,331 @@
+/*
+ * ***** 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/scene_graph/IndexedFaceSet.cpp
+ * \ingroup freestyle
+ * \brief A Set of indexed faces to represent a surfacic object
+ * \author Stephane Grabli
+ * \date 22/01/2002
+ */
+
+#include "IndexedFaceSet.h"
+
+IndexedFaceSet::IndexedFaceSet() : Rep()
+{
+ _Vertices = NULL;
+ _Normals = NULL;
+ _FrsMaterials = 0;
+ _TexCoords = 0;
+ _FaceEdgeMarks = 0;
+ _VSize = 0;
+ _NSize = 0;
+ _MSize = 0;
+ _TSize = 0;
+ _NumFaces = 0;
+ _NumVertexPerFace = NULL;
+ _FaceStyle = NULL;
+ _VIndices = NULL;
+ _VISize = 0;
+ _NIndices = NULL;
+ _NISize = 0;
+ _MIndices = NULL;
+ _MISize = 0;
+ _TIndices = NULL;
+ _TISize = 0;
+ _displayList = 0;
+}
+
+IndexedFaceSet::IndexedFaceSet(real *iVertices, unsigned iVSize, real *iNormals, unsigned iNSize,
+ FrsMaterial **iMaterials, unsigned iMSize, real *iTexCoords, unsigned iTSize,
+ unsigned iNumFaces, unsigned *iNumVertexPerFace, TRIANGLES_STYLE *iFaceStyle,
+ FaceEdgeMark *iFaceEdgeMarks, unsigned *iVIndices, unsigned iVISize,
+ unsigned *iNIndices, unsigned iNISize, unsigned *iMIndices, unsigned iMISize,
+ unsigned *iTIndices, unsigned iTISize, unsigned iCopy)
+: Rep()
+{
+ if (1 == iCopy) {
+ _VSize = iVSize;
+ _Vertices = new real[_VSize];
+ memcpy(_Vertices, iVertices, iVSize * sizeof(real));
+
+ _NSize = iNSize;
+ _Normals = new real[_NSize];
+ memcpy(_Normals, iNormals, iNSize * sizeof(real));
+
+ _MSize = iMSize;
+ _FrsMaterials = 0;
+ if (iMaterials) {
+ _FrsMaterials = new FrsMaterial * [_MSize];
+ for (unsigned int i = 0; i < _MSize; ++i)
+ _FrsMaterials[i] = new FrsMaterial(*(iMaterials[i]));
+ }
+ _TSize = iTSize;
+ _TexCoords = 0;
+ if (_TSize) {
+ _TexCoords = new real[_TSize];
+ memcpy(_TexCoords, iTexCoords, iTSize * sizeof(real));
+ }
+
+ _NumFaces = iNumFaces;
+ _NumVertexPerFace = new unsigned[_NumFaces];
+ memcpy(_NumVertexPerFace, iNumVertexPerFace, _NumFaces * sizeof(unsigned));
+
+ _FaceStyle = new TRIANGLES_STYLE[_NumFaces];
+ memcpy(_FaceStyle, iFaceStyle, _NumFaces * sizeof(TRIANGLES_STYLE));
+
+ _FaceEdgeMarks = new FaceEdgeMark[_NumFaces];
+ memcpy(_FaceEdgeMarks, iFaceEdgeMarks, _NumFaces * sizeof(FaceEdgeMark));
+
+ _VISize = iVISize;
+ _VIndices = new unsigned[_VISize];
+ memcpy(_VIndices, iVIndices, _VISize * sizeof(unsigned));
+
+ _NISize = iNISize;
+ _NIndices = new unsigned[_NISize];
+ memcpy(_NIndices, iNIndices, _NISize * sizeof(unsigned));
+
+ _MISize = iMISize;
+ _MIndices = 0;
+ if (iMIndices) {
+ _MIndices = new unsigned[_MISize];
+ memcpy(_MIndices, iMIndices, _MISize * sizeof(unsigned));
+ }
+ _TISize = iTISize;
+ _TIndices = 0;
+ if (_TISize) {
+ _TIndices = new unsigned[_TISize];
+ memcpy(_TIndices, iTIndices, _TISize * sizeof(unsigned));
+ }
+ }
+ else {
+ _VSize = iVSize;
+ _Vertices = iVertices;
+
+ _NSize = iNSize;
+ _Normals = iNormals;
+
+ _MSize = iMSize;
+ _FrsMaterials = 0;
+ if (iMaterials)
+ _FrsMaterials = iMaterials;
+
+ _TSize = iTSize;
+ _TexCoords = iTexCoords;
+
+ _NumFaces = iNumFaces;
+ _NumVertexPerFace = iNumVertexPerFace;
+ _FaceStyle = iFaceStyle;
+ _FaceEdgeMarks = iFaceEdgeMarks;
+
+ _VISize = iVISize;
+ _VIndices = iVIndices;
+
+ _NISize = iNISize;
+ _NIndices = iNIndices;
+
+ _MISize = iMISize;
+ _MIndices = 0;
+ if (iMISize)
+ _MIndices = iMIndices;
+
+ _TISize = iTISize;
+ _TIndices = iTIndices;
+ }
+
+ _displayList = 0;
+}
+
+IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet& iBrother) : Rep(iBrother)
+{
+ _VSize = iBrother.vsize();
+ _Vertices = new real[_VSize];
+ memcpy(_Vertices, iBrother.vertices(), _VSize * sizeof(real));
+
+ _NSize = iBrother.nsize();
+ _Normals = new real[_NSize];
+ memcpy(_Normals, iBrother.normals(), _NSize * sizeof(real));
+
+ _MSize = iBrother.msize();
+ if (_MSize) {
+ _FrsMaterials = new FrsMaterial * [_MSize];
+ for (unsigned int i = 0; i < _MSize; ++i) {
+ _FrsMaterials[i] = new FrsMaterial(*(iBrother._FrsMaterials[i]));
+ }
+ }
+ else {
+ _FrsMaterials = 0;
+ }
+
+ _TSize = iBrother.tsize();
+ _TexCoords = 0;
+ if (_TSize) {
+ _TexCoords = new real[_TSize];
+ memcpy(_TexCoords, iBrother.texCoords(), _TSize * sizeof(real));
+ }
+
+ _NumFaces = iBrother.numFaces();
+ _NumVertexPerFace = new unsigned[_NumFaces];
+ memcpy(_NumVertexPerFace, iBrother.numVertexPerFaces(), _NumFaces * sizeof(unsigned));
+
+ _FaceStyle = new TRIANGLES_STYLE[_NumFaces];
+ memcpy(_FaceStyle, iBrother.trianglesStyle(), _NumFaces * sizeof(TRIANGLES_STYLE));
+
+ _FaceEdgeMarks = new FaceEdgeMark[_NumFaces];
+ memcpy(_FaceEdgeMarks, iBrother.faceEdgeMarks(), _NumFaces * sizeof(FaceEdgeMark));
+
+ _VISize = iBrother.visize();
+ _VIndices = new unsigned[_VISize];
+ memcpy(_VIndices, iBrother.vindices(), _VISize * sizeof(unsigned));
+
+ _NISize = iBrother.nisize();
+ _NIndices = new unsigned[_NISize];
+ memcpy(_NIndices, iBrother.nindices(), _NISize * sizeof(unsigned));
+
+ _MISize = iBrother.misize();
+ if (_MISize) {
+ _MIndices = new unsigned[_MISize];
+ memcpy(_MIndices, iBrother.mindices(), _MISize * sizeof(unsigned));
+ }
+ else {
+ _MIndices = 0;
+ }
+
+ _TISize = iBrother.tisize();
+ _TIndices = 0;
+ if (_TISize) {
+ _TIndices = new unsigned[_TISize];
+ memcpy(_TIndices, iBrother.tindices(), _TISize * sizeof(unsigned));
+ }
+
+ _displayList = 0;
+}
+
+IndexedFaceSet::~IndexedFaceSet()
+{
+ if (NULL != _Vertices) {
+ delete[] _Vertices;
+ _Vertices = NULL;
+ }
+
+ if (NULL != _Normals)
+ {
+ delete[] _Normals;
+ _Normals = NULL;
+ }
+
+ if (NULL != _FrsMaterials) {
+ for (unsigned int i = 0; i < _MSize; ++i)
+ delete _FrsMaterials[i];
+ delete[] _FrsMaterials;
+ _FrsMaterials = NULL;
+ }
+
+ if (NULL != _TexCoords) {
+ delete[] _TexCoords;
+ _TexCoords = NULL;
+ }
+
+ if (NULL != _NumVertexPerFace) {
+ delete[] _NumVertexPerFace;
+ _NumVertexPerFace = NULL;
+ }
+
+ if (NULL != _FaceStyle) {
+ delete[] _FaceStyle;
+ _FaceStyle = NULL;
+ }
+
+ if (NULL != _FaceEdgeMarks) {
+ delete[] _FaceEdgeMarks;
+ _FaceEdgeMarks = NULL;
+ }
+
+ if (NULL != _VIndices) {
+ delete[] _VIndices;
+ _VIndices = NULL;
+ }
+
+ if (NULL != _NIndices) {
+ delete[] _NIndices;
+ _NIndices = NULL;
+ }
+
+ if (NULL != _MIndices) {
+ delete[] _MIndices;
+ _MIndices = NULL;
+ }
+ if (NULL != _TIndices) {
+ delete[] _TIndices;
+ _TIndices = NULL;
+ }
+
+ // should find a way to deallocates the displayList
+ // glDeleteLists(GLuint list, GLSizei range)
+ _displayList = 0;
+}
+
+void IndexedFaceSet::accept(SceneVisitor& v)
+{
+ Rep::accept(v);
+ v.visitIndexedFaceSet(*this);
+}
+
+void IndexedFaceSet::ComputeBBox()
+{
+ real XMax = _Vertices[0];
+ real YMax = _Vertices[1];
+ real ZMax = _Vertices[2];
+
+ real XMin = _Vertices[0];
+ real YMin = _Vertices[1];
+ real ZMin = _Vertices[2];
+
+ // parse all the coordinates to find the Xmax, YMax, ZMax
+ real *v = _Vertices;
+
+ for (unsigned int i = 0; i < (_VSize / 3); ++i) {
+ if (*v > XMax)
+ XMax = *v;
+ if (*v < XMin)
+ XMin = *v;
+ ++v;
+
+ if (*v > YMax)
+ YMax = *v;
+ if (*v < YMin)
+ YMin = *v;
+ ++v;
+
+ if (*v > ZMax)
+ ZMax = *v;
+ if (*v < ZMin)
+ ZMin = *v;
+ ++v;
+ }
+
+ setBBox(BBox<Vec3r>(Vec3r(XMin, YMin, ZMin), Vec3r(XMax, YMax, ZMax)));
+}
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
new file mode 100644
index 00000000000..6ec769f4caf
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -0,0 +1,322 @@
+/*
+ * ***** 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_INDEXED_FACE_SET_H__
+#define __FREESTYLE_INDEXED_FACE_SET_H__
+
+/** \file blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+ * \ingroup freestyle
+ * \brief A Set of indexed faces to represent a surfacic object
+ * \author Stephane Grabli
+ * \date 22/01/2002
+ */
+
+#include <memory.h>
+#include <stdio.h>
+
+//! inherits from class Rep
+#include "Rep.h"
+
+#include "../system/FreestyleConfig.h"
+
+class LIB_SCENE_GRAPH_EXPORT IndexedFaceSet : public Rep
+{
+public:
+ /*! Triangles description style:*/
+ enum TRIANGLES_STYLE {
+ TRIANGLE_STRIP,
+ TRIANGLE_FAN,
+ TRIANGLES,
+ };
+
+ /*! User-specified face and edge marks for feature edge detection */
+ /* XXX Why in hel not use an enum here too? */
+ typedef unsigned char FaceEdgeMark;
+ static const FaceEdgeMark FACE_MARK = 1 << 0;
+ static const FaceEdgeMark EDGE_MARK_V1V2 = 1 << 1;
+ static const FaceEdgeMark EDGE_MARK_V2V3 = 1 << 2;
+ static const FaceEdgeMark EDGE_MARK_V3V1 = 1 << 3;
+
+ /*! Builds an empty indexed face set */
+ IndexedFaceSet();
+
+ /*! Builds an indexed face set
+ * iVertices
+ * The array of object vertices 3D coordinates (for all faces).
+ * If iCopy != 0, the array is copied; you must desallocate iVertices. Else you must not.
+ * iVSize
+ * The size of iVertices (must be a multiple of 3)
+ * iNormals
+ * The array of object normals 3D coordinates.
+ * If iCopy != 0, the array is copied; you must desallocate iNormals. Else you must not.
+ * iNSize
+ * The size of iNormals
+ * iMaterials
+ * The array of materials
+ * iMSize
+ * The size of iMaterials
+ * iTexCoords
+ * The array of texture coordinates.
+ * iTSize
+ * The size of iTexCoords (must be multiple of 2)
+ * iNumFaces
+ * The number of faces
+ * iNumVertexPerFace
+ * Array containing the number of vertices per face.
+ * iFaceStyle
+ * Array containing the description style of each faces.
+ * The style belongs to:
+ * - TRIANGLE_STRIP: the face indices describe a triangle strip
+ * - TRIANGLE_FAN : the face indices describe a triangle fan
+ * - TRIANGLES : the face indices describe single triangles
+ * If iCopy != 0, the array is copied; you must desallocate iFaceStyle. Else you must not.
+ * iVIndices,
+ * Array of vertices indices.
+ * The integers contained in this array must be multiple of 3.
+ * If iCopy != 0, the array is copied; you must desallocate iVIndices. Else you must not.
+ * iVISize
+ * The size of iVIndices.
+ * iNIndices
+ * Array of normals indices.
+ * The integers contained in this array must be multiple of 3.
+ * If iCopy != 0, the array is copied; you must desallocate iNIndices. Else you must not.
+ * iNISize
+ * The size of iNIndices
+ * iMIndices
+ * The Material indices (per vertex)
+ * iMISize
+ * The size of iMIndices
+ * iTIndices
+ * The Texture coordinates indices (per vertex). The integers contained in this array must be multiple of 2.
+ * iTISize
+ * The size of iMIndices
+ * iCopy
+ * 0 : the arrays are not copied. The pointers passed as arguments are used. IndexedFaceSet takes these
+ * arrays desallocation in charge.
+ * 1 : the arrays are copied. The caller is in charge of the arrays, passed as arguments desallocation.
+ */
+ IndexedFaceSet(real *iVertices, unsigned iVSize, real *iNormals, unsigned iNSize, FrsMaterial **iMaterials,
+ unsigned iMSize, real *iTexCoords, unsigned iTSize, unsigned iNumFaces, unsigned *iNumVertexPerFace,
+ TRIANGLES_STYLE *iFaceStyle, FaceEdgeMark *iFaceEdgeMarks, unsigned *iVIndices, unsigned iVISize,
+ unsigned *iNIndices, unsigned iNISize, unsigned *iMIndices, unsigned iMISize, unsigned *iTIndices,
+ unsigned iTISize, unsigned iCopy = 1);
+
+ /*! Builds an indexed face set from an other indexed face set */
+ IndexedFaceSet(const IndexedFaceSet& iBrother);
+
+ void swap(IndexedFaceSet& ioOther)
+ {
+ std::swap(_Vertices, ioOther._Vertices);
+ std::swap(_Normals, ioOther._Normals);
+ std::swap(_FrsMaterials, ioOther._FrsMaterials);
+ std::swap(_TexCoords, ioOther._TexCoords);
+ std::swap(_FaceEdgeMarks, ioOther._FaceEdgeMarks);
+
+ std::swap(_VSize, ioOther._VSize);
+ std::swap(_NSize, ioOther._NSize);
+ std::swap(_MSize, ioOther._MSize);
+ std::swap(_TSize, ioOther._TSize);
+
+ std::swap(_NumFaces, ioOther._NumFaces);
+ std::swap(_NumVertexPerFace, ioOther._NumVertexPerFace);
+ std::swap(_FaceStyle, ioOther._FaceStyle);
+
+ std::swap(_VIndices, ioOther._VIndices);
+ std::swap(_NIndices, ioOther._NIndices);
+ std::swap(_MIndices, ioOther._MIndices); // Material Indices
+ std::swap(_TIndices, ioOther._TIndices);
+
+ std::swap(_VISize, ioOther._VISize);
+ std::swap(_NISize, ioOther._NISize);
+ std::swap(_MISize, ioOther._MISize);
+ std::swap(_TISize, ioOther._TISize);
+
+ std::swap(_displayList, ioOther._displayList);
+
+ Rep::swap(ioOther);
+ }
+
+ IndexedFaceSet& operator=(const IndexedFaceSet& iBrother)
+ {
+ IndexedFaceSet tmp(iBrother);
+ swap(tmp);
+ return *this;
+ }
+
+ /*! Desctructor
+ * desallocates all the ressources
+ */
+ virtual ~IndexedFaceSet();
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+
+ /*! Compute the Bounding Box */
+ virtual void ComputeBBox();
+
+ /*! modifiers */
+ inline void setDisplayList(unsigned int index)
+ {
+ _displayList = index;
+ }
+
+ /*! Accessors */
+ virtual const real * vertices() const
+ {
+ return _Vertices;
+ }
+
+ virtual const real * normals() const
+ {
+ return _Normals;
+ }
+
+ virtual const FrsMaterial*const* frs_materials() const
+ {
+ return _FrsMaterials;
+ }
+
+ virtual const real* texCoords() const
+ {
+ return _TexCoords;
+ }
+
+ virtual const unsigned vsize() const
+ {
+ return _VSize;
+ }
+
+ virtual const unsigned nsize() const
+ {
+ return _NSize;
+ }
+
+ virtual const unsigned msize() const
+ {
+ return _MSize;
+ }
+
+ virtual const unsigned tsize() const
+ {
+ return _TSize;
+ }
+
+ virtual const unsigned numFaces() const
+ {
+ return _NumFaces;
+ }
+
+ virtual const unsigned * numVertexPerFaces() const
+ {
+ return _NumVertexPerFace;
+ }
+
+ virtual const TRIANGLES_STYLE * trianglesStyle() const
+ {
+ return _FaceStyle;
+ }
+
+ virtual const unsigned char * faceEdgeMarks() const
+ {
+ return _FaceEdgeMarks;
+ }
+
+ virtual const unsigned* vindices() const
+ {
+ return _VIndices;
+ }
+
+ virtual const unsigned* nindices() const
+ {
+ return _NIndices;
+ }
+
+ virtual const unsigned* mindices() const
+ {
+ return _MIndices;
+ }
+
+ virtual const unsigned* tindices() const
+ {
+ return _TIndices;
+ }
+
+ virtual const unsigned visize() const
+ {
+ return _VISize;
+ }
+
+ virtual const unsigned nisize() const
+ {
+ return _NISize;
+ }
+
+ virtual const unsigned misize() const
+ {
+ return _MISize;
+ }
+
+ virtual const unsigned tisize() const
+ {
+ return _TISize;
+ }
+
+ inline unsigned int displayList() const
+ {
+ return _displayList;
+ }
+
+protected:
+ real *_Vertices;
+ real *_Normals;
+ FrsMaterial **_FrsMaterials;
+ real *_TexCoords;
+
+ unsigned _VSize;
+ unsigned _NSize;
+ unsigned _MSize;
+ unsigned _TSize;
+
+ unsigned _NumFaces;
+ unsigned *_NumVertexPerFace;
+ TRIANGLES_STYLE *_FaceStyle;
+ FaceEdgeMark *_FaceEdgeMarks;
+
+ unsigned *_VIndices;
+ unsigned *_NIndices;
+ unsigned *_MIndices; // Material Indices
+ unsigned *_TIndices; // Texture coordinates Indices
+
+ unsigned _VISize;
+ unsigned _NISize;
+ unsigned _MISize;
+ unsigned _TISize;
+
+ unsigned int _displayList;
+};
+
+#endif // __FREESTYLE_INDEXED_FACE_SET_H__
diff --git a/source/blender/freestyle/intern/scene_graph/LineRep.cpp b/source/blender/freestyle/intern/scene_graph/LineRep.cpp
new file mode 100644
index 00000000000..bf442bccbc1
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/LineRep.cpp
@@ -0,0 +1,71 @@
+/*
+ * ***** 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/scene_graph/LineRep.cpp
+ * \ingroup freestyle
+ * \brief Class to define the representation of 3D Line.
+ * \author Stephane Grabli
+ * \date 26/03/2002
+ */
+
+#include "LineRep.h"
+
+void LineRep::ComputeBBox()
+{
+ real XMax = _vertices.front()[0];
+ real YMax = _vertices.front()[1];
+ real ZMax = _vertices.front()[2];
+
+ real XMin = _vertices.front()[0];
+ real YMin = _vertices.front()[1];
+ real ZMin = _vertices.front()[2];
+
+ // parse all the coordinates to find
+ // the XMax, YMax, ZMax
+ vector<Vec3r>::iterator v;
+ for (v = _vertices.begin(); v != _vertices.end(); ++v) {
+ // X
+ if ((*v)[0] > XMax)
+ XMax = (*v)[0];
+ if ((*v)[0] < XMin)
+ XMin = (*v)[0];
+
+ // Y
+ if ((*v)[1] > YMax)
+ YMax = (*v)[1];
+ if ((*v)[1] < YMin)
+ YMin = (*v)[1];
+
+ // Z
+ if ((*v)[2] > ZMax)
+ ZMax = (*v)[2];
+ if ((*v)[2] < ZMin)
+ ZMin = (*v)[2];
+ }
+
+ setBBox(BBox<Vec3r>(Vec3r(XMin, YMin, ZMin), Vec3r(XMax, YMax, ZMax)));
+}
diff --git a/source/blender/freestyle/intern/scene_graph/LineRep.h b/source/blender/freestyle/intern/scene_graph/LineRep.h
new file mode 100644
index 00000000000..3d93db4835d
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/LineRep.h
@@ -0,0 +1,158 @@
+/*
+ * ***** 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_LINE_REP_H__
+#define __FREESTYLE_LINE_REP_H__
+
+/** \file blender/freestyle/intern/scene_graph/LineRep.h
+ * \ingroup freestyle
+ * \brief Class to define the representation of 3D Line.
+ * \author Stephane Grabli
+ * \date 26/03/2002
+ */
+
+#include <list>
+#include <vector>
+
+#include "Rep.h"
+
+#include "../system/FreestyleConfig.h"
+
+using namespace std;
+
+/*! Base class for all lines objects */
+class LIB_SCENE_GRAPH_EXPORT LineRep : public Rep
+{
+public:
+ /*! Line description style */
+ enum LINES_STYLE {
+ LINES,
+ LINE_STRIP,
+ LINE_LOOP,
+ };
+
+ inline LineRep() : Rep()
+ {
+ _width = 0.0f;
+ }
+
+ /*! Builds a single line from 2 vertices
+ * v1
+ * first vertex
+ * v2
+ * second vertex
+ */
+ inline LineRep(const Vec3r& v1, const Vec3r& v2) : Rep()
+ {
+ setStyle(LINES);
+ AddVertex(v1);
+ AddVertex(v2);
+ _width = 0.0f;
+ }
+
+ /*! Builds a line rep from a vertex chain */
+ inline LineRep(const vector<Vec3r>& vertices) : Rep()
+ {
+ _vertices = vertices;
+ setStyle(LINE_STRIP);
+ _width = 0.0f;
+ }
+
+ /*! Builds a line rep from a vertex chain */
+ inline LineRep(const list<Vec3r>& vertices) : Rep()
+ {
+ for (list<Vec3r>::const_iterator v = vertices.begin(), end = vertices.end(); v != end; ++v) {
+ _vertices.push_back(*v);
+ }
+ setStyle(LINE_STRIP);
+ _width = 0.0f;
+ }
+
+ virtual ~LineRep()
+ {
+ _vertices.clear();
+ }
+
+ /*! accessors */
+ inline const LINES_STYLE style() const
+ {
+ return _Style;
+ }
+
+ inline const vector<Vec3r>& vertices() const
+ {
+ return _vertices;
+ }
+
+ inline float width() const
+ {
+ return _width;
+ }
+
+ /*! modifiers */
+ inline void setStyle(const LINES_STYLE iStyle)
+ {
+ _Style = iStyle;
+ }
+
+ inline void AddVertex(const Vec3r& iVertex)
+ {
+ _vertices.push_back(iVertex);
+ }
+
+ inline void setVertices(const vector<Vec3r>& iVertices)
+ {
+ if (0 != _vertices.size()) {
+ _vertices.clear();
+ }
+ for (vector<Vec3r>::const_iterator v = iVertices.begin(), end = iVertices.end(); v != end; ++v) {
+ _vertices.push_back(*v);
+ }
+ }
+
+ inline void setWidth(float iWidth)
+ {
+ _width = iWidth;
+ }
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v)
+ {
+ Rep::accept(v);
+ v.visitLineRep(*this);
+ }
+
+ /*! Computes the line bounding box.*/
+ virtual void ComputeBBox();
+
+private:
+ LINES_STYLE _Style;
+ vector<Vec3r> _vertices;
+ float _width;
+};
+
+#endif // __FREESTYLE_LINE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/Node.h b/source/blender/freestyle/intern/scene_graph/Node.h
new file mode 100644
index 00000000000..626a0913233
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/Node.h
@@ -0,0 +1,115 @@
+/*
+ * ***** 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_NODE_H__
+#define __FREESTYLE_NODE_H__
+
+/** \file blender/freestyle/intern/scene_graph/Node.h
+ * \ingroup freestyle
+ * \brief Abstract class for scene graph nodes. Inherits from BaseObject which defines the addRef release mechanism.
+ * \author Stephane Grabli
+ * \date 24/01/2002
+ */
+
+#include "SceneVisitor.h"
+
+#include "../system/BaseObject.h"
+#include "../system/FreestyleConfig.h"
+#include "../system/Precision.h"
+
+#include "../geometry/BBox.h"
+#include "../geometry/Geom.h"
+
+using namespace std;
+using namespace Geometry;
+
+class LIB_SCENE_GRAPH_EXPORT Node : public BaseObject
+{
+public:
+ inline Node() : BaseObject() {}
+
+ inline Node(const Node& iBrother) : BaseObject()
+ {
+ _BBox = iBrother.bbox();
+ }
+
+ virtual ~Node(){}
+
+ /*! Accept the corresponding visitor
+ * Each inherited node must overload this method
+ */
+ virtual void accept(SceneVisitor& v)
+ {
+ v.visitNode(*this);
+ }
+
+ /*! bounding box management */
+ /*! Returns the node bounding box
+ * If no bounding box exists, an empty bbox is returned
+ */
+ virtual const BBox<Vec3r>& bbox() const
+ {
+ return _BBox;
+ }
+
+ /*! Sets the Node bounding box */
+ virtual void setBBox(const BBox<Vec3r>& iBox)
+ {
+ _BBox = iBox;
+ }
+
+ /*! Makes the union of _BBox and iBox */
+ virtual void AddBBox(const BBox<Vec3r>& iBox)
+ {
+ if(iBox.empty())
+ return;
+
+ if(_BBox.empty())
+ _BBox = iBox;
+ else
+ _BBox += iBox;
+ }
+
+ /*! Updates the BBox */
+ virtual const BBox<Vec3r>& UpdateBBox()
+ {
+ return _BBox;
+ }
+
+ /*! Clears the bounding box */
+ virtual void clearBBox()
+ {
+ _BBox.clear();
+ }
+
+protected:
+
+private:
+ BBox<Vec3r> _BBox;
+};
+
+#endif // __FREESTYLE_NODE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
new file mode 100644
index 00000000000..d8b01bf3f64
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.cpp
@@ -0,0 +1,143 @@
+/*
+ * ***** 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/scene_graph/NodeCamera.cpp
+ * \ingroup freestyle
+ * \brief Class to represent a light node
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include <math.h>
+#include <string.h> // for memcpy
+
+#include "NodeCamera.h"
+
+static void loadIdentity(double * matrix)
+{
+ int i;
+
+ // Build Identity matrix
+ for (i = 0; i < 16; ++i) {
+ double value ;
+ if ((i % 5) == 0)
+ value = 1.0;
+ else
+ value = 0;
+ matrix[i] = value;
+ }
+}
+
+NodeCamera::NodeCamera(CameraType camera_type) : camera_type_(camera_type)
+{
+ loadIdentity(modelview_matrix_);
+ loadIdentity(projection_matrix_);
+}
+
+NodeCamera::NodeCamera(const NodeCamera& iBrother) : camera_type_(iBrother.camera_type_)
+{
+ memcpy(modelview_matrix_, iBrother.modelview_matrix_, 16 * sizeof(double));
+ memcpy(projection_matrix_, iBrother.projection_matrix_, 16 * sizeof(double));
+}
+
+void NodeCamera::accept(SceneVisitor& v)
+{
+ v.visitNodeCamera(*this);
+}
+
+void NodeCamera::setModelViewMatrix(double modelview_matrix[16])
+{
+ memcpy(modelview_matrix_, modelview_matrix, 16 * sizeof(double));
+}
+
+void NodeCamera::setProjectionMatrix(double projection_matrix[16])
+{
+ memcpy(projection_matrix_, projection_matrix, 16 * sizeof(double));
+}
+
+NodeOrthographicCamera::NodeOrthographicCamera()
+: NodeCamera(NodeCamera::ORTHOGRAPHIC), left_(0), right_(0), bottom_(0), top_(0), zNear_(0), zFar_(0)
+{
+ loadIdentity(projection_matrix_);
+ loadIdentity(modelview_matrix_);
+}
+
+NodeOrthographicCamera::NodeOrthographicCamera(double left, double right, double bottom, double top,
+ double zNear, double zFar)
+: NodeCamera(NodeCamera::ORTHOGRAPHIC), left_(left), right_(right), bottom_(bottom), top_(top),
+ zNear_(zNear), zFar_(zFar)
+{
+ loadIdentity(projection_matrix_);
+
+ projection_matrix_[0] = 2.0 / (right - left);
+ projection_matrix_[3] = -(right + left) / (right - left) ;
+ projection_matrix_[5] = 2.0 / (top - bottom);
+ projection_matrix_[7] = -(top + bottom) / (top - bottom) ;
+ projection_matrix_[10] = -2.0 / (zFar - zNear);
+ projection_matrix_[11] = -(zFar + zNear) / (zFar - zNear);
+}
+
+NodeOrthographicCamera::NodeOrthographicCamera(const NodeOrthographicCamera& iBrother)
+: NodeCamera(iBrother), left_(iBrother.left_), right_(iBrother.right_), bottom_(iBrother.bottom_), top_(iBrother.top_),
+ zNear_(iBrother.zNear_), zFar_(iBrother.zFar_)
+{
+}
+
+NodePerspectiveCamera::NodePerspectiveCamera() : NodeCamera(NodeCamera::PERSPECTIVE)
+{
+}
+
+NodePerspectiveCamera::NodePerspectiveCamera(double fovy, double aspect, double zNear, double zFar)
+: NodeCamera(NodeCamera::PERSPECTIVE)
+{
+ loadIdentity(projection_matrix_);
+
+ double f = cos(fovy / 2.0) / sin(fovy / 2.0); // cotangent
+
+ projection_matrix_[0] = f / aspect;
+ projection_matrix_[5] = f;
+ projection_matrix_[10] = (zNear + zFar) / (zNear - zFar);
+ projection_matrix_[11] = (2.0 * zNear * zFar) / (zNear - zFar);
+ projection_matrix_[14] = -1.0;
+ projection_matrix_[15] = 0;
+}
+
+NodePerspectiveCamera::NodePerspectiveCamera(double left, double right, double bottom, double top,
+ double zNear, double zFar)
+: NodeCamera(NodeCamera::PERSPECTIVE)
+{
+ loadIdentity(projection_matrix_);
+
+ projection_matrix_[0] = (2.0 * zNear) / (right - left);
+ projection_matrix_[2] = (right + left) / (right - left);
+ projection_matrix_[5] = (2.0 * zNear) / (top - bottom);
+ projection_matrix_[6] = (top + bottom) / (top - bottom);
+ projection_matrix_[10] = -(zFar + zNear) / (zFar - zNear);
+ projection_matrix_[11] = -(2.0 * zFar * zNear) / (zFar - zNear);
+ projection_matrix_[14] = -1.0;
+ projection_matrix_[15] = 0;
+}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeCamera.h b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
new file mode 100644
index 00000000000..f7141a72a51
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeCamera.h
@@ -0,0 +1,216 @@
+/*
+ * ***** 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_NODE_CAMERA_H__
+#define __FREESTYLE_NODE_CAMERA_H__
+
+/** \file blender/freestyle/intern/scene_graph/NodeCamera.h
+ * \ingroup freestyle
+ * \brief Class to represent a light node
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include "Node.h"
+
+#include "../geometry/Geom.h"
+
+#include "../system/FreestyleConfig.h"
+
+using namespace Geometry;
+
+class NodeOrthographicCamera;
+
+class NodePerspectiveCamera;
+
+class LIB_SCENE_GRAPH_EXPORT NodeCamera : public Node
+{
+public:
+ typedef enum {
+ PERSPECTIVE,
+ ORTHOGRAPHIC,
+ GENERIC,
+ } CameraType;
+
+ /*! Default matrices: Identity for both projection and modelview. */
+ NodeCamera(CameraType camera_type = GENERIC);
+ NodeCamera(const NodeCamera& iBrother);
+
+ virtual ~NodeCamera() {}
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+
+ /*! Matrix is copied */
+ void setModelViewMatrix(double modelview_matrix[16]);
+
+ /*! Matrix is copied */
+ void setProjectionMatrix(double projection_matrix[16]);
+
+ double * modelViewMatrix()
+ {
+ return modelview_matrix_;
+ }
+
+ double * projectionMatrix()
+ {
+ return projection_matrix_;
+ }
+
+protected:
+ // row major right handed matrix
+ double modelview_matrix_[16];
+ // row major right handed matrix
+ double projection_matrix_[16];
+
+ CameraType camera_type_;
+};
+
+class LIB_SCENE_GRAPH_EXPORT NodeOrthographicCamera : public NodeCamera
+{
+public:
+ NodeOrthographicCamera();
+
+ /*! Builds a parallel projection matrix a la glOrtho.
+ * A 0 0 tx
+ * 0 B 0 ty
+ * 0 0 C tz
+ * 0 0 0 1
+ *
+ * where
+ * A = 2 / (right - left)
+ * B = 2 / (top - bottom)
+ * C = -2 / (far - near)
+ * tx = -(right + left) / (right - left)
+ * ty = -(top + bottom) / (top - bottom)
+ * tz = -(zFar + zNear) / (zFar - zNear)
+ */
+ NodeOrthographicCamera(double left, double right, double bottom, double top, double zNear, double zFar);
+
+ double left() const
+ {
+ return left_;
+ }
+
+ double right() const
+ {
+ return right_;
+ }
+
+ double bottom() const
+ {
+ return bottom_;
+ }
+
+ double top() const
+ {
+ return top_;
+ }
+
+ double zNear() const
+ {
+ return zNear_;
+ }
+
+ double zFar() const
+ {
+ return zFar_;
+ }
+
+ NodeOrthographicCamera(const NodeOrthographicCamera& iBrother);
+
+private:
+ double left_;
+ double right_;
+ double bottom_;
+ double top_;
+ double zNear_;
+ double zFar_;
+};
+
+class LIB_SCENE_GRAPH_EXPORT NodePerspectiveCamera : public NodeCamera
+{
+public:
+ NodePerspectiveCamera();
+
+ /*! Builds a perspective projection matrix a la gluPerspective.
+ * Given f defined as follows:
+ * fovy
+ * f = cotangent(____)
+ * 2
+ * The generated matrix is
+ * ( f )
+ * | ______ 0 0 0 |
+ * | aspect |
+ * | |
+ * | 0 f 0 0 |
+ * | |
+ * | zNear+zFar 2*zNear*zFar |
+ * | 0 0 __________ ____________ |
+ * | zNear-zFar zNear-zFar |
+ * | |
+ * ( 0 0 -1 0 )
+ * \param fovy
+ * Field of View specified in radians.
+ */
+ NodePerspectiveCamera(double fovy, double aspect, double zNear, double zFar);
+
+ /*! Builds a perspective projection matrix a la glFrustum.
+ * ( 2*zNear )
+ * | __________ 0 A 0 |
+ * | right-left |
+ * | |
+ * | 2*zNear |
+ * | 0 __________ B 0 |
+ * | top-bottom |
+ * | |
+ * | 0 0 C D |
+ * | |
+ * | 0 0 -1 0 |
+ * ( )
+ *
+ * right+left
+ * A = __________
+ * right-left
+ *
+ * top+bottom
+ * B = __________
+ * top-bottom
+ *
+ * zFar+zNear
+ * C = - __________
+ * zFar-zNear
+ *
+ * 2*zFar*zNear
+ * D = - ____________
+ * zFar-zNear
+ */
+ NodePerspectiveCamera(double left, double right, double bottom, double top, double zNear, double zFar);
+};
+
+
+#endif // __FREESTYLE_NODE_CAMERA_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
new file mode 100644
index 00000000000..fed589b17c5
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.cpp
@@ -0,0 +1,46 @@
+/*
+ * ***** 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/scene_graph/NodeDrawingStyle.cpp
+ * \ingroup freestyle
+ * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from NodeGroup.
+ * \author Stephane Grabli
+ * \date 06/02/2002
+ */
+
+#include "NodeDrawingStyle.h"
+
+void NodeDrawingStyle::accept(SceneVisitor& v)
+{
+ v.visitNodeDrawingStyle(*this);
+
+ v.visitNodeDrawingStyleBefore(*this);
+ v.visitDrawingStyle(_DrawingStyle);
+ for (vector<Node*>::iterator node = _Children.begin(), end = _Children.end(); node != end; ++node)
+ (*node)->accept(v);
+ v.visitNodeDrawingStyleAfter(*this);
+}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
new file mode 100644
index 00000000000..29a05290df1
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
@@ -0,0 +1,111 @@
+/*
+ * ***** 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_NODE_DRAWING_STYLE_H__
+#define __FREESTYLE_NODE_DRAWING_STYLE_H__
+
+/** \file blender/freestyle/intern/scene_graph/NodeDrawingStyle.h
+ * \ingroup freestyle
+ * \brief Class to define a Drawing Style to be applied to the underlying children. Inherits from NodeGroup.
+ * \author Stephane Grabli
+ * \date 06/02/2002
+ */
+
+#include "DrawingStyle.h"
+#include "NodeGroup.h"
+
+#include "../system/FreestyleConfig.h"
+
+class LIB_SCENE_GRAPH_EXPORT NodeDrawingStyle : public NodeGroup
+{
+public:
+ inline NodeDrawingStyle() : NodeGroup() {}
+ virtual ~NodeDrawingStyle() {}
+
+ inline const DrawingStyle& drawingStyle() const
+ {
+ return _DrawingStyle;
+ }
+
+ inline void setDrawingStyle(const DrawingStyle& iDrawingStyle)
+ {
+ _DrawingStyle = iDrawingStyle;
+ }
+
+ /*! Sets the style. Must be one of FILLED, LINES, POINTS, INVISIBLE. */
+ inline void setStyle(const DrawingStyle::STYLE iStyle)
+ {
+ _DrawingStyle.setStyle(iStyle);
+ }
+
+ /*! Sets the line width in the LINES style case */
+ inline void setLineWidth(const float iLineWidth)
+ {
+ _DrawingStyle.setLineWidth(iLineWidth);
+ }
+
+ /*! Sets the Point size in the POINTS style case */
+ inline void setPointSize(const float iPointSize)
+ {
+ _DrawingStyle.setPointSize(iPointSize);
+ }
+
+ /*! Enables or disables the lighting. TRUE = enable */
+ inline void setLightingEnabled(const bool iEnableLighting)
+ {
+ _DrawingStyle.setLightingEnabled(iEnableLighting);
+ }
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+
+ /*! accessors */
+ inline DrawingStyle::STYLE style() const
+ {
+ return _DrawingStyle.style();
+ }
+
+ inline float lineWidth() const
+ {
+ return _DrawingStyle.lineWidth();
+ }
+
+ inline float pointSize() const
+ {
+ return _DrawingStyle.pointSize();
+ }
+
+ inline bool lightingEnabled() const
+ {
+ return _DrawingStyle.lightingEnabled();
+ }
+
+private:
+ DrawingStyle _DrawingStyle;
+};
+
+#endif // __FREESTYLE_NODE_DRAWING_STYLE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
new file mode 100644
index 00000000000..3ac9cbbcbdc
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.cpp
@@ -0,0 +1,126 @@
+/*
+ * ***** 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/scene_graph/NodeGroup.cpp
+ * \ingroup freestyle
+ * \brief Class to represent a group node. This node can contains several children.
+ * \brief It also contains a transform matrix indicating the transform state of the underlying children.
+ * \author Stephane Grabli
+ * \date 24/01/2002
+ */
+
+#include "NodeGroup.h"
+
+void NodeGroup::AddChild(Node *iChild)
+{
+ if (NULL == iChild)
+ return;
+
+ _Children.push_back(iChild);
+ iChild->addRef();
+}
+
+int NodeGroup::destroy()
+{
+ /*! Node::destroy makes a release on the object and then returns the reference counter.
+ * If the reference counter is equal to 0, that means that nobody else is linking this node group and
+ * that we can destroy the whole underlying tree.
+ * Else, one or several Node link this node group, and we only returns the reference counter
+ * decremented by Node::destroy();
+ */
+ int refThis = Node::destroy();
+
+ // if refThis != 0, we can't destroy the tree
+ if (0 != refThis)
+ return refThis;
+
+ // If we are here, that means that nobody else needs our NodeGroup and we can destroy it.
+ int refCount = 0;
+ vector<Node *>::iterator node;
+
+ for (node = _Children.begin(); node != _Children.end(); ++node) {
+ refCount = (*node)->destroy();
+ if (0 == refCount)
+ delete (*node);
+ }
+
+ _Children.clear();
+
+ return refThis;
+}
+
+void NodeGroup::accept(SceneVisitor& v)
+{
+ v.visitNodeGroup(*this);
+
+ v.visitNodeGroupBefore(*this);
+ for (vector<Node *>::iterator node = _Children.begin(), end = _Children.end(); node != end; ++node)
+ (*node)->accept(v);
+ v.visitNodeGroupAfter(*this);
+}
+
+void NodeGroup::DetachChildren()
+{
+ vector<Node *>::iterator node;
+
+ for (node = _Children.begin(); node != _Children.end(); ++node) {
+ (*node)->release();
+ }
+
+ _Children.clear();
+}
+
+void NodeGroup::DetachChild(Node *iChild)
+{
+ /* int found = 0; */ /* UNUSED */
+ vector<Node*>::iterator node;
+
+ for (node = _Children.begin(); node != _Children.end(); ++node) {
+ if ((*node) == iChild) {
+ (*node)->release();
+ _Children.erase(node);
+ /* found = 1; */ /* UNUSED */
+ break;
+ }
+ }
+}
+
+void NodeGroup::RetrieveChildren(vector<Node*>& oNodes)
+{
+ oNodes = _Children;
+}
+
+const BBox<Vec3r>& NodeGroup::UpdateBBox()
+{
+ vector<Node *>::iterator node;
+ clearBBox();
+ for (node = _Children.begin(); node != _Children.end(); ++node) {
+ AddBBox((*node)->UpdateBBox());
+ }
+
+ return Node::UpdateBBox();
+}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeGroup.h b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
new file mode 100644
index 00000000000..1c5b106d5c6
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeGroup.h
@@ -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 *****
+ */
+
+#ifndef __FREESTYLE_NODE_GROUP_H__
+#define __FREESTYLE_NODE_GROUP_H__
+
+/** \file blender/freestyle/intern/scene_graph/NodeGroup.h
+ * \ingroup freestyle
+ * \brief Class to represent a group node. This node can contains several children.
+ * \brief It also contains a transform matrix indicating the transform state of the underlying children.
+ * \author Stephane Grabli
+ * \date 24/01/2002
+ */
+
+#include <vector>
+
+#include "Node.h"
+
+#include "../system/FreestyleConfig.h"
+
+using namespace std;
+
+class LIB_SCENE_GRAPH_EXPORT NodeGroup : public Node
+{
+public:
+ inline NodeGroup(): Node() {}
+ virtual ~NodeGroup(){}
+
+ /*! Adds a child. Makes a addRef on the iChild reference counter */
+ virtual void AddChild(Node *iChild);
+
+ /*! destroys all the underlying nodes
+ * Returns the reference counter after having done a release()
+ */
+ virtual int destroy();
+
+ /*! Detaches all the children */
+ virtual void DetachChildren();
+
+ /*! Detached the sepcified child */
+ virtual void DetachChild(Node *iChild);
+
+ /*! Retrieve children */
+ virtual void RetrieveChildren(vector<Node*>& oNodes);
+
+ /*! Renders every children */
+// virtual void Render(Renderer *iRenderer);
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+
+ /*! Updates the BBox */
+ virtual const BBox<Vec3r>& UpdateBBox();
+
+ /*! Returns the number of children */
+ virtual int numberOfChildren()
+ {
+ return _Children.size();
+ }
+
+protected:
+ vector<Node*> _Children;
+};
+
+#endif // __FREESTYLE_NODE_GROUP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeLight.cpp b/source/blender/freestyle/intern/scene_graph/NodeLight.cpp
new file mode 100644
index 00000000000..f410d2da18e
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeLight.cpp
@@ -0,0 +1,86 @@
+/*
+ * ***** 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/scene_graph/NodeLight.cpp
+ * \ingroup freestyle
+ * \brief Class to represent a light node
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include "NodeLight.h"
+
+int NodeLight::numberOfLights = 0;
+
+NodeLight::NodeLight() : Node()
+{
+ if (numberOfLights > 7) {
+ _number = 7;
+ }
+ else {
+ _number = numberOfLights;
+ numberOfLights++;
+ }
+
+ Ambient[0] = Ambient[1] = Ambient[2] = 0.0f;
+ Ambient[3] = 1.0f;
+
+ for (int i = 0; i < 4; i++) {
+ Diffuse[i] = 1.0f;
+ Specular[i] = 1.0f;
+ }
+
+ Position[0] = Position[1] = Position[3] = 0.0f;
+ Position[2] = 1.0f;
+
+ on = true;
+}
+
+NodeLight::NodeLight(NodeLight& iBrother) : Node(iBrother)
+{
+ if (numberOfLights > 7) {
+ _number = 7;
+ }
+ else {
+ _number = numberOfLights;
+ numberOfLights++;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ Ambient[i] = iBrother.ambient()[i];
+ Diffuse[i] = iBrother.diffuse()[i];
+ Specular[i] = iBrother.specular()[i];
+ Position[i] = iBrother.position()[i];
+ }
+
+ on = iBrother.isOn();
+}
+
+void NodeLight::accept(SceneVisitor& v)
+{
+ v.visitNodeLight(*this);
+}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeLight.h b/source/blender/freestyle/intern/scene_graph/NodeLight.h
new file mode 100644
index 00000000000..49484d8b9b3
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeLight.h
@@ -0,0 +1,113 @@
+/*
+ * ***** 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_NODE_LIGHT_H__
+#define __FREESTYLE_NODE_LIGHT_H__
+
+/** \file blender/freestyle/intern/scene_graph/NodeLight.h
+ * \ingroup freestyle
+ * \brief Class to represent a light node
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include "Node.h"
+
+#include "../geometry/Geom.h"
+
+#include "../system/FreestyleConfig.h"
+
+using namespace Geometry;
+
+class LIB_SCENE_GRAPH_EXPORT NodeLight : public Node
+{
+public:
+ NodeLight();
+ NodeLight(NodeLight& iBrother);
+
+ virtual ~NodeLight() {}
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+
+ /*! Accessors for the light properties */
+ inline const float * ambient() const
+ {
+ return Ambient;
+ }
+
+ inline const float * diffuse() const
+ {
+ return Diffuse;
+ }
+
+ inline const float * specular() const
+ {
+ return Specular;
+ }
+
+ inline const float * position() const
+ {
+ return Position;
+ }
+
+ inline bool isOn() const
+ {
+ return on;
+ }
+
+ inline int number() const
+ {
+ return _number;
+ }
+
+private:
+ // Data members
+ // ============
+
+ /*! on=true, the light is on */
+ bool on;
+
+ /*! The color definition */
+ float Ambient[4];
+ float Diffuse[4];
+ float Specular[4];
+
+ /*! Light position. if w = 0, the light is placed at infinite. */
+ float Position[4];
+
+ /*! used to manage the number of lights */
+ /*! numberOfLights
+ * the number of lights in the scene.
+ * Initially, 0.
+ */
+ static int numberOfLights;
+ /*! The current lignt number */
+ int _number;
+};
+
+#endif // __FREESTYLE_NODE_LIGHT_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.cpp b/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
new file mode 100644
index 00000000000..b1593c9f43b
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.cpp
@@ -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 *****
+ */
+
+/** \file blender/freestyle/intern/scene_graph/NodeShape.cpp
+ * \ingroup freestyle
+ * \brief Class to build a shape node. It contains a Rep, which is the shape geometry
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include "NodeShape.h"
+
+NodeShape::~NodeShape()
+{
+ vector<Rep *>::iterator rep;
+
+ if (0 != _Shapes.size()) {
+ for (rep = _Shapes.begin(); rep != _Shapes.end(); ++rep) {
+ int refCount = (*rep)->destroy();
+ if (0 == refCount)
+ delete (*rep);
+ }
+
+ _Shapes.clear();
+ }
+}
+
+void NodeShape::accept(SceneVisitor& v)
+{
+ v.visitNodeShape(*this);
+
+ v.visitFrsMaterial(_FrsMaterial);
+
+ v.visitNodeShapeBefore(*this);
+ vector<Rep *>::iterator rep;
+ for (rep = _Shapes.begin(); rep != _Shapes.end(); ++rep)
+ (*rep)->accept(v);
+ v.visitNodeShapeAfter(*this);
+}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeShape.h b/source/blender/freestyle/intern/scene_graph/NodeShape.h
new file mode 100644
index 00000000000..046d8b0e392
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeShape.h
@@ -0,0 +1,103 @@
+/*
+ * ***** 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_NODE_SHAPE_H__
+#define __FREESTYLE_NODE_SHAPE_H__
+
+/** \file blender/freestyle/intern/scene_graph/NodeShape.h
+ * \ingroup freestyle
+ * \brief Class to build a shape node. It contains a Rep, which is the shape geometry
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include <vector>
+
+#include "../geometry/BBox.h"
+#include "../geometry/Geom.h"
+
+#include "../system/FreestyleConfig.h"
+
+#include "FrsMaterial.h"
+#include "Node.h"
+#include "Rep.h"
+
+using namespace std;
+using namespace Geometry;
+
+class LIB_SCENE_GRAPH_EXPORT NodeShape : public Node
+{
+public:
+ inline NodeShape() : Node() {}
+
+ virtual ~NodeShape();
+
+ /*! Adds a Rep to the _Shapes list
+ * The delete of the rep is done when it is not used any more by the Scene Manager.
+ * So, it must not be deleted by the caller
+ */
+ virtual void AddRep(Rep *iRep)
+ {
+ if (NULL == iRep)
+ return;
+ _Shapes.push_back(iRep);
+ iRep->addRef();
+
+ // updates bbox:
+ AddBBox(iRep->bbox());
+ }
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+
+ /*! Sets the shape material */
+ inline void setFrsMaterial(const FrsMaterial& iMaterial)
+ {
+ _FrsMaterial = iMaterial;
+ }
+
+ /*! accessors */
+ /*! returns the shape's material */
+ inline FrsMaterial& frs_material()
+ {
+ return _FrsMaterial;
+ }
+
+ inline const vector<Rep*>& shapes()
+ {
+ return _Shapes;
+ }
+
+private:
+ /*! list of shapes */
+ vector<Rep*> _Shapes;
+
+ /*! Shape Material */
+ FrsMaterial _FrsMaterial;
+};
+
+#endif // __FREESTYLE_NODE_SHAPE_H__
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
new file mode 100644
index 00000000000..aa01200a4d2
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.cpp
@@ -0,0 +1,178 @@
+/*
+ * ***** 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/scene_graph/NodeTransform.cpp
+ * \ingroup freestyle
+ * \brief Class to represent a transform node. A Transform node contains one or several children,
+ * \brief all affected by the transformation.
+ * \author Stephane Grabli
+ * \date 06/02/2002
+ */
+
+#include "NodeTransform.h"
+
+#include "../system/FreestyleConfig.h"
+
+void NodeTransform::Translate(real x, real y, real z)
+{
+ _Matrix(0, 3) += x;
+ _Matrix(1, 3) += y;
+ _Matrix(2, 3) += z;
+}
+
+void NodeTransform::Rotate(real iAngle, real x, real y, real z)
+{
+ //Normalize the x,y,z vector;
+ real norm = (real)sqrt(x * x + y * y + z * z);
+ if (0 == norm)
+ return;
+
+ x /= norm;
+ y /= norm;
+ z /= norm;
+
+ /* find the corresponding matrix with the Rodrigues formula:
+ * R = I + sin(iAngle)*Ntilda + (1-cos(iAngle))*Ntilda*Ntilda
+ */
+ Matrix33r Ntilda;
+ Ntilda(0, 0) = Ntilda(1, 1) = Ntilda(2, 2) = 0.0f;
+ Ntilda(0, 1) = -z;
+ Ntilda(0, 2) = y;
+ Ntilda(1, 0) = z;
+ Ntilda(1, 2) = -x;
+ Ntilda(2, 0) = -y;
+ Ntilda(2, 1) = x;
+
+ const Matrix33r Ntilda2(Ntilda * Ntilda);
+
+
+ const real sinAngle = (real)sin((iAngle / 180.0f) * M_PI);
+ const real cosAngle = (real)cos((iAngle / 180.0f) * M_PI);
+
+ Matrix33r NS(Ntilda * sinAngle);
+ Matrix33r NC(Ntilda2 * (1.0f - cosAngle));
+ Matrix33r R;
+ R = Matrix33r::identity();
+ R += NS + NC;
+
+ // R4 is the corresponding 4x4 matrix
+ Matrix44r R4;
+ R4 = Matrix44r::identity();
+
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++)
+ R4(i, j) = R(i, j);
+ }
+
+ // Finally, we multiply our current matrix by R4:
+ Matrix44r mat_tmp(_Matrix);
+ _Matrix = mat_tmp * R4;
+}
+
+void NodeTransform::Scale(real x, real y, real z)
+{
+ _Matrix(0, 0) *= x;
+ _Matrix(1, 1) *= y;
+ _Matrix(2, 2) *= z;
+
+ _Scaled = true;
+}
+
+void NodeTransform::MultiplyMatrix(const Matrix44r &iMatrix)
+{
+ Matrix44r mat_tmp(_Matrix);
+ _Matrix = mat_tmp * iMatrix;
+}
+
+void NodeTransform::setMatrix(const Matrix44r &iMatrix)
+{
+ _Matrix = iMatrix;
+ if (isScaled(iMatrix))
+ _Scaled = true;
+}
+
+void NodeTransform::accept(SceneVisitor& v)
+{
+ v.visitNodeTransform(*this);
+
+ v.visitNodeTransformBefore(*this);
+ for (vector<Node *>::iterator node = _Children.begin(), end = _Children.end(); node != end; ++node)
+ (*node)->accept(v);
+ v.visitNodeTransformAfter(*this);
+}
+
+void NodeTransform::AddBBox(const BBox<Vec3r>& iBBox)
+{
+ Vec3r oldMin(iBBox.getMin());
+ Vec3r oldMax(iBBox.getMax());
+
+ // compute the 8 corners of the bbox
+ HVec3r box[8];
+ box[0] = HVec3r(iBBox.getMin());
+ box[1] = HVec3r(oldMax[0], oldMin[1], oldMin[2]);
+ box[2] = HVec3r(oldMax[0], oldMax[1], oldMin[2]);
+ box[3] = HVec3r(oldMin[0], oldMax[1], oldMin[2]);
+ box[4] = HVec3r(oldMin[0], oldMin[1], oldMax[2]);
+ box[5] = HVec3r(oldMax[0], oldMin[1], oldMax[2]);
+ box[6] = HVec3r(oldMax[0], oldMax[1], oldMax[2]);
+ box[7] = HVec3r(oldMin[0], oldMax[1], oldMax[2]);
+
+ // Computes the transform iBBox
+ HVec3r tbox[8];
+ unsigned int i;
+ for (i = 0; i < 8; i++)
+ tbox[i] = _Matrix * box[i];
+
+ Vec3r newMin(tbox[0]);
+ Vec3r newMax(tbox[0]);
+ for (i = 0; i < 8; i++) {
+ for (unsigned int j = 0; j < 3; j++) {
+ if (newMin[j] > tbox[i][j])
+ newMin[j] = tbox[i][j];
+ if (newMax[j] < tbox[i][j])
+ newMax[j] = tbox[i][j];
+ }
+ }
+
+ BBox<Vec3r> transformBox(newMin, newMax);
+
+ Node::AddBBox(transformBox);
+}
+
+bool NodeTransform::isScaled(const Matrix44r &M)
+{
+ for (unsigned int j = 0; j < 3; j++) {
+ real norm = 0;
+ for (unsigned int i = 0; i < 3; i++) {
+ norm += M(i, j) * M(i, j);
+ }
+ if ((norm > 1.01) || (norm < 0.99))
+ return true;
+ }
+
+ return false;
+}
diff --git a/source/blender/freestyle/intern/scene_graph/NodeTransform.h b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
new file mode 100644
index 00000000000..e98045989d3
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/NodeTransform.h
@@ -0,0 +1,110 @@
+/*
+ * ***** 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_NODE_TRANSFORM_H__
+#define __FREESTYLE_NODE_TRANSFORM_H__
+
+/** \file blender/freestyle/intern/scene_graph/NodeTransform.h
+ * \ingroup freestyle
+ * \brief Class to represent a transform node. A Transform node contains one or several children,
+ * \brief all affected by the transformation.
+ * \author Stephane Grabli
+ * \date 06/02/2002
+ */
+
+#include "NodeGroup.h"
+
+#include "../geometry/Geom.h"
+
+#include "../system/FreestyleConfig.h"
+
+using namespace Geometry;
+
+class LIB_SCENE_GRAPH_EXPORT NodeTransform : public NodeGroup
+{
+public:
+ inline NodeTransform() : NodeGroup()
+ {
+ _Matrix = Matrix44r::identity();
+ _Scaled = false;
+ }
+
+ virtual ~NodeTransform() {}
+
+ /*! multiplys the current matrix by the x, y, z translation matrix. */
+ void Translate(real x, real y, real z);
+
+ /*! multiplys the current matrix by a rotation matrix
+ * iAngle
+ * The rotation angle
+ * x, y, z
+ * The rotation axis
+ */
+ void Rotate(real iAngle, real x, real y, real z);
+
+ /*! multiplys the current matrix by a scaling matrix.
+ * x, y, z
+ * The scaling coefficients with respect to the x,y,z axis
+ */
+ void Scale(real x, real y, real z);
+
+ /*! Multiplys the current matrix by iMatrix */
+ void MultiplyMatrix(const Matrix44r &iMatrix);
+
+ /*! Sets the current matrix to iMatrix */
+ void setMatrix(const Matrix44r &iMatrix);
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+
+ /*! Overloads the Node::AddBBox in order to take care about the transformation */
+ virtual void AddBBox(const BBox<Vec3r>& iBBox);
+
+ /*! Checks whether a matrix contains a scale factor or not.
+ * Returns true if yes.
+ * M
+ * The matrix to check
+ */
+ bool isScaled(const Matrix44r &M);
+
+ /*! accessors */
+ inline const Matrix44r& matrix() const
+ {
+ return _Matrix;
+ }
+
+ inline bool scaled() const
+ {
+ return _Scaled;
+ }
+
+private:
+ Matrix44r _Matrix;
+ bool _Scaled;
+};
+
+#endif // __FREESTYLE_NODE_TRANSFORM_H__
diff --git a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
new file mode 100644
index 00000000000..8b29c0256ff
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.cpp
@@ -0,0 +1,46 @@
+/*
+ * ***** 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/scene_graph/OrientedLineRep.cpp
+ * \ingroup freestyle
+ * \brief Class to display an oriented line representation.
+ * \author Stephane Grabli
+ * \date 24/10/2002
+ */
+
+#include "OrientedLineRep.h"
+
+#include "../system/BaseObject.h"
+
+void OrientedLineRep::accept(SceneVisitor& v)
+{
+ Rep::accept(v);
+ if (!frs_material())
+ v.visitOrientedLineRep(*this);
+ else
+ v.visitLineRep(*this);
+}
diff --git a/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
new file mode 100644
index 00000000000..45cda3610f2
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/OrientedLineRep.h
@@ -0,0 +1,66 @@
+/*
+ * ***** 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_ORIENTED_LINE_REP_H__
+#define __FREESTYLE_ORIENTED_LINE_REP_H__
+
+/** \file blender/freestyle/intern/scene_graph/OrientedLineRep.h
+ * \ingroup freestyle
+ * \brief Class to display an oriented line representation.
+ * \author Stephane Grabli
+ * \date 24/10/2002
+ */
+
+#include "LineRep.h"
+
+#include "../system/FreestyleConfig.h"
+
+class LIB_SCENE_GRAPH_EXPORT OrientedLineRep : public LineRep
+{
+public:
+ OrientedLineRep() : LineRep() {}
+ /*! Builds a single line from 2 vertices
+ * v1
+ * first vertex
+ * v2
+ * second vertex
+ */
+ inline OrientedLineRep(const Vec3r& v1, const Vec3r& v2) : LineRep(v1,v2) {}
+
+ /*! Builds a line rep from a vertex chain */
+ inline OrientedLineRep(const vector<Vec3r>& vertices) : LineRep(vertices) {}
+
+ /*! Builds a line rep from a vertex chain */
+ inline OrientedLineRep(const list<Vec3r>& vertices) : LineRep(vertices) {}
+
+ virtual ~OrientedLineRep() {}
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v);
+};
+
+#endif // __FREESTYLE_ORIENTED_LINE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.cpp b/source/blender/freestyle/intern/scene_graph/Rep.cpp
new file mode 100644
index 00000000000..0319a617a68
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/Rep.cpp
@@ -0,0 +1,35 @@
+/*
+ * ***** 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/scene_graph/Rep.cpp
+ * \ingroup freestyle
+ * \brief Base class for all shapes. Inherits from BasicObjects for references counter management (addRef, release).
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include "Rep.h"
diff --git a/source/blender/freestyle/intern/scene_graph/Rep.h b/source/blender/freestyle/intern/scene_graph/Rep.h
new file mode 100644
index 00000000000..c1b29d3fceb
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/Rep.h
@@ -0,0 +1,173 @@
+/*
+ * ***** 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_REP_H__
+#define __FREESTYLE_REP_H__
+
+/** \file blender/freestyle/intern/scene_graph/Rep.h
+ * \ingroup freestyle
+ * \brief Base class for all shapes. Inherits from BasicObjects for references counter management (addRef, release).
+ * \author Stephane Grabli
+ * \date 25/01/2002
+ */
+
+#include "FrsMaterial.h"
+#include "SceneVisitor.h"
+
+#include "../geometry/BBox.h"
+#include "../geometry/Geom.h"
+
+#include "../system/BaseObject.h"
+#include "../system/Id.h"
+#include "../system/Precision.h"
+
+using namespace Geometry;
+
+class LIB_SCENE_GRAPH_EXPORT Rep : public BaseObject
+{
+public:
+ inline Rep() : BaseObject()
+ {
+ _Id = 0;
+ _FrsMaterial = 0;
+ }
+
+ inline Rep(const Rep& iBrother) : BaseObject()
+ {
+ _Id = iBrother._Id;
+ _Name = iBrother._Name;
+ if (0 == iBrother._FrsMaterial)
+ _FrsMaterial = 0;
+ else
+ _FrsMaterial = new FrsMaterial(*(iBrother._FrsMaterial));
+
+ _BBox = iBrother.bbox();
+ }
+
+ inline void swap(Rep& ioOther)
+ {
+ std::swap(_BBox,ioOther._BBox);
+ std::swap(_Id, ioOther._Id);
+ std::swap(_Name, ioOther._Name);
+ std::swap(_FrsMaterial,ioOther._FrsMaterial);
+ }
+
+ Rep& operator=(const Rep& iBrother)
+ {
+ if (&iBrother != this) {
+ _Id = iBrother._Id;
+ _Name = iBrother._Name;
+ if (0 == iBrother._FrsMaterial) {
+ _FrsMaterial = 0;
+ }
+ else {
+ if (_FrsMaterial == 0) {
+ _FrsMaterial = new FrsMaterial(*iBrother._FrsMaterial);
+ }
+ else {
+ (*_FrsMaterial) = (*(iBrother._FrsMaterial));
+ }
+ _BBox = iBrother.bbox();
+ }
+ }
+ return *this;
+ }
+
+ virtual ~Rep()
+ {
+ if (0 != _FrsMaterial) {
+ delete _FrsMaterial;
+ _FrsMaterial = 0;
+ }
+ }
+
+ /*! Accept the corresponding visitor
+ * Must be overload by inherited classes
+ */
+ virtual void accept(SceneVisitor& v)
+ {
+ if (_FrsMaterial)
+ v.visitFrsMaterial(*_FrsMaterial);
+ v.visitRep(*this);
+ }
+
+ /*! Computes the rep bounding box.
+ * Each Inherited rep must compute its bbox depending on the way the data are stored. So, each inherited class
+ * must overload this method
+ */
+ virtual void ComputeBBox() = 0;
+
+ /*! Returns the rep bounding box */
+ virtual const BBox<Vec3r>& bbox() const
+ {
+ return _BBox;
+ }
+
+ inline Id getId() const
+ {
+ return _Id;
+ }
+
+ inline const string& getName() const
+ {
+ return _Name;
+ }
+
+ inline const FrsMaterial * frs_material() const
+ {
+ return _FrsMaterial;
+ }
+
+ /*! Sets the Rep bounding box */
+ virtual void setBBox(const BBox<Vec3r>& iBox)
+ {
+ _BBox = iBox;
+ }
+
+ inline void setId(const Id& id)
+ {
+ _Id = id;
+ }
+
+ inline void setName(const string& name)
+ {
+ _Name = name;
+ }
+
+ inline void setFrsMaterial(const FrsMaterial& iMaterial)
+ {
+ _FrsMaterial = new FrsMaterial(iMaterial);
+ }
+
+private:
+ BBox<Vec3r> _BBox;
+ Id _Id;
+ string _Name;
+ FrsMaterial *_FrsMaterial;
+};
+
+#endif // __FREESTYLE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.cpp b/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.cpp
new file mode 100644
index 00000000000..8be3f2527b6
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.cpp
@@ -0,0 +1,110 @@
+/*
+ * ***** 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/scene_graph/ScenePrettyPrinter.cpp
+ * \ingroup freestyle
+ * \brief Class to display textual information about a scene graph.
+ * \author Stephane Grabli
+ * \author Emmanuel Turquin
+ * \date 26/04/2003
+ */
+
+#include <iomanip>
+
+#include "IndexedFaceSet.h"
+#include "ScenePrettyPrinter.h"
+
+#define VISIT(CLASS) \
+ void ScenePrettyPrinter::visit##CLASS(CLASS&) \
+ { \
+ _ofs << _space << #CLASS << endl; \
+ }
+
+VISIT(Node)
+VISIT(NodeShape)
+VISIT(NodeGroup)
+VISIT(NodeLight)
+VISIT(NodeDrawingStyle)
+VISIT(NodeTransform)
+
+void ScenePrettyPrinter::visitNodeShapeBefore(NodeShape&)
+{
+ increaseSpace();
+}
+
+void ScenePrettyPrinter::visitNodeShapeAfter(NodeShape&)
+{
+ decreaseSpace();
+}
+
+void ScenePrettyPrinter::visitNodeGroupBefore(NodeGroup&)
+{
+ increaseSpace();
+}
+
+void ScenePrettyPrinter::visitNodeGroupAfter(NodeGroup&)
+{
+ decreaseSpace();
+}
+
+void ScenePrettyPrinter::visitNodeDrawingStyleBefore(NodeDrawingStyle&)
+{
+ increaseSpace();
+}
+
+void ScenePrettyPrinter::visitNodeDrawingStyleAfter(NodeDrawingStyle&)
+{
+ decreaseSpace();
+}
+
+void ScenePrettyPrinter::visitNodeTransformBefore(NodeTransform&)
+{
+ increaseSpace();
+}
+
+void ScenePrettyPrinter::visitNodeTransformAfter(NodeTransform&)
+{
+ decreaseSpace();
+}
+
+VISIT(LineRep)
+VISIT(OrientedLineRep)
+VISIT(TriangleRep)
+VISIT(VertexRep)
+
+void ScenePrettyPrinter::visitIndexedFaceSet(IndexedFaceSet& ifs)
+{
+ const real *vertices = ifs.vertices();
+ unsigned vsize = ifs.vsize();
+
+ _ofs << _space << "IndexedFaceSet" << endl;
+ const real *p = vertices;
+ for (unsigned int i = 0; i < vsize / 3; i++) {
+ _ofs << _space << " " << setw(3) << setfill('0') << i << ": " << p[0] << ", " << p[1] << ", " << p[2] << endl;
+ p += 3;
+ }
+}
diff --git a/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h b/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h
new file mode 100644
index 00000000000..39fb9eceef8
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h
@@ -0,0 +1,109 @@
+/*
+ * ***** 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_SCENE_PRETTY_PRINTER_H__
+#define __FREESTYLE_SCENE_PRETTY_PRINTER_H__
+
+/** \file blender/freestyle/intern/scene_graph/ScenePrettyPrinter.h
+ * \ingroup freestyle
+ * \brief Class to display textual information about a scene graph.
+ * \author Stephane Grabli
+ * \author Emmanuel Turquin
+ * \date 26/04/2003
+ */
+
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#include "SceneVisitor.h"
+
+using namespace std;
+
+class ScenePrettyPrinter : public SceneVisitor
+{
+public:
+ ScenePrettyPrinter(const string filename = "SceneLog.txt") : SceneVisitor()
+ {
+ if (!filename.empty())
+ _ofs.open(filename.c_str());
+ if (!_ofs.is_open())
+ cerr << "Warning, unable to open file \"" << filename << "\"" << endl;
+ _space = "";
+ }
+
+ virtual ~ScenePrettyPrinter()
+ {
+ if (_ofs.is_open())
+ _ofs.close();
+ }
+
+
+ //
+ // visitClass methods
+ //
+ //////////////////////////////////////////////
+
+ VISIT_DECL(Node);
+ VISIT_DECL(NodeShape);
+ VISIT_DECL(NodeGroup);
+ VISIT_DECL(NodeLight);
+ VISIT_DECL(NodeDrawingStyle);
+ VISIT_DECL(NodeTransform);
+
+ VISIT_DECL(LineRep);
+ VISIT_DECL(OrientedLineRep);
+ VISIT_DECL(TriangleRep);
+ VISIT_DECL(VertexRep);
+ VISIT_DECL(IndexedFaceSet);
+
+ virtual void visitNodeShapeBefore(NodeShape&);
+ virtual void visitNodeShapeAfter(NodeShape&);
+ virtual void visitNodeGroupBefore(NodeGroup&);
+ virtual void visitNodeGroupAfter(NodeGroup&);
+ virtual void visitNodeDrawingStyleBefore(NodeDrawingStyle&);
+ virtual void visitNodeDrawingStyleAfter(NodeDrawingStyle&);
+ virtual void visitNodeTransformBefore(NodeTransform&);
+ virtual void visitNodeTransformAfter(NodeTransform&);
+
+protected:
+ void increaseSpace()
+ {
+ _space += " ";
+ }
+
+ void decreaseSpace()
+ {
+ _space.erase(0, 2);
+ }
+
+private:
+ ofstream _ofs;
+ string _space;
+};
+
+#endif // __FREESTYLE_SCENE_PRETTY_PRINTER_H__
diff --git a/source/blender/freestyle/intern/scene_graph/SceneVisitor.cpp b/source/blender/freestyle/intern/scene_graph/SceneVisitor.cpp
new file mode 100644
index 00000000000..32ba38ece80
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/SceneVisitor.cpp
@@ -0,0 +1,35 @@
+/*
+ * ***** 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/scene_graph/SceneVisitor.cpp
+ * \ingroup freestyle
+ * \brief Class to visit (without doing anything) a scene graph structure
+ * \author Emmanuel Turquin
+ * \date 26/04/2003
+ */
+
+#include "SceneVisitor.h"
diff --git a/source/blender/freestyle/intern/scene_graph/SceneVisitor.h b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
new file mode 100644
index 00000000000..57d3f9189ed
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/SceneVisitor.h
@@ -0,0 +1,102 @@
+/*
+ * ***** 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_SCENE_VISITOR_H__
+#define __FREESTYLE_SCENE_VISITOR_H__
+
+/** \file blender/freestyle/intern/scene_graph/SceneVisitor.h
+ * \ingroup freestyle
+ * \brief Class to visit (without doing anything) a scene graph structure
+ * \author Emmanuel Turquin
+ * \date 26/04/2003
+ */
+
+#include "../system/FreestyleConfig.h"
+
+#define VISIT_COMPLETE_DEF(type) \
+ virtual void visit##type(type&) {} \
+ virtual void visit##type##Before(type&) {} \
+ virtual void visit##type##After(type&) {}
+
+#define VISIT_DECL(type) \
+ virtual void visit##type(type&);
+
+#define VISIT_COMPLETE_DECL(type) \
+ virtual void visit##type##Before(type&); \
+ virtual void visit##type(type&); \
+ virtual void visit##type##After(type&);
+
+class Node;
+class NodeShape;
+class NodeGroup;
+class NodeLight;
+class NodeCamera;
+class NodeDrawingStyle;
+class NodeTransform;
+
+class Rep;
+class LineRep;
+class OrientedLineRep;
+class TriangleRep;
+class VertexRep;
+class IndexedFaceSet;
+class DrawingStyle;
+class FrsMaterial;
+
+class LIB_SCENE_GRAPH_EXPORT SceneVisitor
+{
+public:
+ SceneVisitor() {}
+ virtual ~SceneVisitor() {}
+
+ virtual void beginScene() {}
+ virtual void endScene() {}
+
+ //
+ // visitClass methods
+ //
+ //////////////////////////////////////////////
+
+ VISIT_COMPLETE_DEF(Node)
+ VISIT_COMPLETE_DEF(NodeShape)
+ VISIT_COMPLETE_DEF(NodeGroup)
+ VISIT_COMPLETE_DEF(NodeLight)
+ VISIT_COMPLETE_DEF(NodeCamera)
+ VISIT_COMPLETE_DEF(NodeDrawingStyle)
+ VISIT_COMPLETE_DEF(NodeTransform)
+
+ VISIT_COMPLETE_DEF(Rep)
+ VISIT_COMPLETE_DEF(LineRep)
+ VISIT_COMPLETE_DEF(OrientedLineRep)
+ VISIT_COMPLETE_DEF(TriangleRep)
+ VISIT_COMPLETE_DEF(VertexRep)
+ VISIT_COMPLETE_DEF(IndexedFaceSet)
+ VISIT_COMPLETE_DEF(DrawingStyle)
+ VISIT_COMPLETE_DEF(FrsMaterial)
+};
+
+#endif // __FREESTYLE_SCENE_VISITOR_H__
diff --git a/source/blender/freestyle/intern/scene_graph/TriangleRep.cpp b/source/blender/freestyle/intern/scene_graph/TriangleRep.cpp
new file mode 100644
index 00000000000..01053561aae
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/TriangleRep.cpp
@@ -0,0 +1,69 @@
+/*
+ * ***** 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/scene_graph/TriangleRep.cpp
+ * \ingroup freestyle
+ * \brief Class to define the represenation of a triangle
+ * \author Stephane Grabli
+ * \date 16/12/2002
+ */
+
+#include "TriangleRep.h"
+
+void TriangleRep::ComputeBBox()
+{
+ real XMax = _vertices[0][0];
+ real YMax = _vertices[0][1];
+ real ZMax = _vertices[0][2];
+
+ real XMin = _vertices[0][0];
+ real YMin = _vertices[0][1];
+ real ZMin = _vertices[0][2];
+
+ // parse all the coordinates to find the XMax, YMax, ZMax
+ for (int i = 0; i < 3; ++i) {
+ // X
+ if (_vertices[i][0] > XMax)
+ XMax = _vertices[i][0];
+ if (_vertices[i][0] < XMin)
+ XMin = _vertices[i][0];
+
+ // Y
+ if (_vertices[i][1] > YMax)
+ YMax = _vertices[i][1];
+ if (_vertices[i][1] < YMin)
+ YMin = _vertices[i][1];
+
+ // Z
+ if (_vertices[i][2] > ZMax)
+ ZMax = _vertices[i][2];
+ if (_vertices[i][2] < ZMin)
+ ZMin = _vertices[i][2];
+ }
+
+ setBBox(BBox<Vec3r>(Vec3r(XMin, YMin, ZMin), Vec3r(XMax, YMax, ZMax)));
+}
diff --git a/source/blender/freestyle/intern/scene_graph/TriangleRep.h b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
new file mode 100644
index 00000000000..c65eee72e03
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/TriangleRep.h
@@ -0,0 +1,150 @@
+/*
+ * ***** 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_TRIANGLE_REP_H__
+#define __FREESTYLE_TRIANGLE_REP_H__
+
+/** \file blender/freestyle/intern/scene_graph/TriangleRep.h
+ * \ingroup freestyle
+ * \brief Class to define the represenation of a triangle
+ * \author Stephane Grabli
+ * \date 16/12/2002
+ */
+
+//! inherits from class Rep
+#include "Rep.h"
+
+/*! Base class for all lines objects */
+class LIB_SCENE_GRAPH_EXPORT TriangleRep : public Rep
+{
+public:
+ /*! Line description style */
+ enum TRIANGLE_STYLE {
+ FILL,
+ LINES,
+ };
+
+private:
+ TRIANGLE_STYLE _Style;
+ Vec3r _vertices[3];
+ Vec3r _colors[3];
+
+public:
+ inline TriangleRep() : Rep()
+ {
+ _Style = FILL;
+ }
+
+ /*! Builds a triangle from 3 vertices
+ * v0
+ * first vertex
+ * v1
+ * second vertex
+ * v2
+ * third vertex
+ */
+ inline TriangleRep(const Vec3r& v0, const Vec3r& v1, const Vec3r& v2) : Rep()
+ {
+ _vertices[0] = v0;
+ _vertices[1] = v1;
+ _vertices[2] = v2;
+ _Style = FILL;
+ }
+
+ inline TriangleRep(const Vec3r& v0, const Vec3r& c0, const Vec3r& v1, const Vec3r& c1,
+ const Vec3r& v2, const Vec3r& c2)
+ : Rep()
+ {
+ _vertices[0] = v0;
+ _vertices[1] = v1;
+ _vertices[2] = v2;
+ _colors[0] = c0;
+ _colors[1] = c1;
+ _colors[2] = c2;
+ _Style = FILL;
+ }
+
+ virtual ~TriangleRep() {}
+
+ /*! accessors */
+ inline const TRIANGLE_STYLE style() const
+ {
+ return _Style;
+ }
+
+ inline const Vec3r& vertex(int index) const
+ {
+ return _vertices[index];
+ }
+
+ inline const Vec3r& color(int index) const
+ {
+ return _colors[index];
+ }
+
+ /*! modifiers */
+ inline void setStyle(const TRIANGLE_STYLE iStyle)
+ {
+ _Style = iStyle;
+ }
+
+ inline void setVertex(int index, const Vec3r& iVertex)
+ {
+ _vertices[index] = iVertex;
+ }
+
+ inline void setColor(int index, const Vec3r& iColor)
+ {
+ _colors[index] = iColor;
+ }
+
+ inline void setVertices(const Vec3r& v0, const Vec3r& v1, const Vec3r& v2)
+ {
+ _vertices[0] = v0;
+ _vertices[1] = v1;
+ _vertices[2] = v2;
+ }
+
+ inline void setColors(const Vec3r& c0, const Vec3r& c1, const Vec3r& c2)
+ {
+ _colors[0] = c0;
+ _colors[1] = c1;
+ _colors[2] = c2;
+ }
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v)
+ {
+ Rep::accept(v);
+ v.visitTriangleRep(*this);
+ }
+
+ /*! Computes the triangle bounding box.*/
+ virtual void ComputeBBox();
+};
+
+#endif // __FREESTYLE_TRIANGLE_REP_H__
diff --git a/source/blender/freestyle/intern/scene_graph/VertexRep.cpp b/source/blender/freestyle/intern/scene_graph/VertexRep.cpp
new file mode 100644
index 00000000000..75b0d4b91b3
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/VertexRep.cpp
@@ -0,0 +1,41 @@
+/*
+ * ***** 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/scene_graph/VertexRep.cpp
+ * \ingroup freestyle
+ * \brief Class to define the representation of a vertex for displaying purpose.
+ * \author Stephane Grabli
+ * \date 03/04/2002
+ */
+
+#include "VertexRep.h"
+
+void VertexRep::ComputeBBox()
+{
+ setBBox(BBox<Vec3r>(Vec3r(_coordinates[0], _coordinates[1], _coordinates[2]),
+ Vec3r(_coordinates[0], _coordinates[1], _coordinates[2])));
+}
diff --git a/source/blender/freestyle/intern/scene_graph/VertexRep.h b/source/blender/freestyle/intern/scene_graph/VertexRep.h
new file mode 100644
index 00000000000..7483806f1fe
--- /dev/null
+++ b/source/blender/freestyle/intern/scene_graph/VertexRep.h
@@ -0,0 +1,141 @@
+/*
+ * ***** 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_VERTEX_REP_H__
+#define __FREESTYLE_VERTEX_REP_H__
+
+/** \file blender/freestyle/intern/scene_graph/VertexRep.h
+ * \ingroup freestyle
+ * \brief Class to define the representation of a vertex for displaying purpose.
+ * \author Stephane Grabli
+ * \date 03/04/2002
+ */
+
+#include "Rep.h"
+
+class LIB_SCENE_GRAPH_EXPORT VertexRep : public Rep
+{
+public:
+ inline VertexRep() : Rep()
+ {
+ _vid = 0;
+ _PointSize = 0.0f;
+ }
+
+ inline VertexRep(real x, real y, real z, int id = 0) : Rep()
+ {
+ _coordinates[0] = x;
+ _coordinates[1] = y;
+ _coordinates[2] = z;
+
+ _vid = id;
+ _PointSize = 0.0f;
+ }
+
+ inline ~VertexRep() {}
+
+ /*! Accept the corresponding visitor */
+ virtual void accept(SceneVisitor& v)
+ {
+ Rep::accept(v);
+ v.visitVertexRep(*this);
+ }
+
+ /*! Computes the rep bounding box. */
+ virtual void ComputeBBox();
+
+ /*! accessors */
+ inline const int vid() const
+ {
+ return _vid;
+ }
+
+ inline const real * coordinates() const
+ {
+ return _coordinates;
+ }
+
+ inline real x() const
+ {
+ return _coordinates[0];
+ }
+
+ inline real y() const
+ {
+ return _coordinates[1];
+ }
+
+ inline real z() const
+ {
+ return _coordinates[2];
+ }
+
+ inline float pointSize() const
+ {
+ return _PointSize;
+ }
+
+ /*! modifiers */
+ inline void setVid(int id)
+ {
+ _vid = id;
+ }
+
+ inline void setX(real x)
+ {
+ _coordinates[0] = x;
+ }
+
+ inline void setY(real y)
+ {
+ _coordinates[1] = y;
+ }
+
+ inline void setZ(real z)
+ {
+ _coordinates[2] = z;
+ }
+
+ inline void setCoordinates(real x, real y, real z)
+ {
+ _coordinates[0] = x;
+ _coordinates[1] = y;
+ _coordinates[2] = z;
+ }
+
+ inline void setPointSize(float iPointSize)
+ {
+ _PointSize = iPointSize;
+ }
+
+private:
+ int _vid; // vertex id
+ real _coordinates[3];
+ float _PointSize;
+};
+
+#endif // __FREESTYLE_VERTEX_REP_H__