Index: /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterNodeVisitor.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterNodeVisitor.cpp (revision 11194)
+++ /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterNodeVisitor.cpp (revision 11203)
@@ -26,5 +26,6 @@
 void copyOsgMatrixToLib3dsMatrix(Lib3dsMatrix lib3ds_matrix, const osg::Matrix& osg_matrix)
 {
-    for(int row=0; row<4; ++row) {
+    for(int row=0; row<4; ++row)
+    {
         lib3ds_matrix[row][0] = osg_matrix.ptr()[row*4+0];
         lib3ds_matrix[row][1] = osg_matrix.ptr()[row*4+1];
@@ -34,10 +35,12 @@
 }
 
-inline void copyOsgVectorToLib3dsVector(Lib3dsVector lib3ds_vector, const osg::Vec3f& osg_vector) {
+inline void copyOsgVectorToLib3dsVector(Lib3dsVector lib3ds_vector, const osg::Vec3f& osg_vector)
+{
     lib3ds_vector[0] = osg_vector[0];
     lib3ds_vector[1] = osg_vector[1];
     lib3ds_vector[2] = osg_vector[2];
 }
-inline void copyOsgVectorToLib3dsVector(Lib3dsVector lib3ds_vector, const osg::Vec3d& osg_vector) {
+inline void copyOsgVectorToLib3dsVector(Lib3dsVector lib3ds_vector, const osg::Vec3d& osg_vector)
+{
     lib3ds_vector[0] = osg_vector[0];
     lib3ds_vector[1] = osg_vector[1];
@@ -45,10 +48,12 @@
 }
 
-inline void copyOsgColorToLib3dsColor(Lib3dsVector lib3ds_vector, const osg::Vec4f& osg_vector) {
+inline void copyOsgColorToLib3dsColor(Lib3dsVector lib3ds_vector, const osg::Vec4f& osg_vector)
+{
     lib3ds_vector[0] = osg_vector[0];
     lib3ds_vector[1] = osg_vector[1];
     lib3ds_vector[2] = osg_vector[2];
 }
-inline void copyOsgColorToLib3dsColor(Lib3dsVector lib3ds_vector, const osg::Vec4d& osg_vector) {
+inline void copyOsgColorToLib3dsColor(Lib3dsVector lib3ds_vector, const osg::Vec4d& osg_vector)
+{
     lib3ds_vector[0] = osg_vector[0];
     lib3ds_vector[1] = osg_vector[1];
@@ -56,5 +61,6 @@
 }
 
-inline void copyOsgQuatToLib3dsQuat(float lib3ds_vector[4], const osg::Quat& osg_quat) {
+inline void copyOsgQuatToLib3dsQuat(float lib3ds_vector[4], const osg::Quat& osg_quat)
+{
     //lib3ds_vector[0] = osg_quat[3];        // Not sure
     //lib3ds_vector[1] = osg_quat[0];
@@ -70,5 +76,6 @@
 }
 
-std::string getFileName(const std::string & path) {
+std::string getFileName(const std::string & path)
+{
     unsigned int slashPos = path.find_last_of("/\\");
     if (slashPos == std::string::npos) return path;
@@ -78,5 +85,6 @@
 
 /// Checks if a filename (\b not path) is 8.3 (an empty name is never 8.3, and a path is never 8.3).
-bool is83(const std::string & s) {
+bool is83(const std::string & s)
+{
     // 012345678901
     // ABCDEFGH.ABC
@@ -93,5 +101,6 @@
 
 /// Tests if the given string is a path supported by 3DS format (8.3, 63 chars max).
-bool is3DSpath(const std::string & s, bool extendedFilePaths) {
+bool is3DSpath(const std::string & s, bool extendedFilePaths)
+{
     unsigned int len = s.length();
     if (len >= 64 || len == 0) return false;
@@ -113,5 +122,6 @@
 
 /** writes all primitives of a primitive-set out to a stream, decomposes quads to triangles, line-strips to lines etc */
-class PrimitiveIndexWriter : public osg::PrimitiveIndexFunctor {
+class PrimitiveIndexWriter : public osg::PrimitiveIndexFunctor
+{
 public:
       PrimitiveIndexWriter(osg::Geometry  *    geo, 
@@ -341,5 +351,5 @@
         //break;
     default:
-        osg::notify(osg::WARN) << "3DS WriterNodeVisitor: can't handle mode " << mode << std::endl;
+        OSG_NOTIFY(osg::WARN) << "3DS WriterNodeVisitor: can't handle mode " << mode << std::endl;
         break;
     }
@@ -362,5 +372,6 @@
     //static unsigned int s_objmaterial_id = 0;
     //++s_objmaterial_id;
-    if (mat) {
+    if (mat)
+    {
         assert(stateset);
         diffuse = mat->getDiffuse(osg::Material::FRONT);
@@ -371,22 +382,28 @@
         name = writerNodeVisitor.getUniqueName(mat->getName(),"mat");
         osg::StateAttribute * attribute = stateset->getAttribute(osg::StateAttribute::CULLFACE);
-        if (!attribute) {
+        if (!attribute)
+        {
             double_sided = true;
-        } else {
+        }
+        else
+        {
             assert(dynamic_cast<osg::CullFace *>(attribute));
             osg::CullFace::Mode mode = static_cast<osg::CullFace *>(attribute)->getMode();
             if (mode == osg::CullFace::BACK) double_sided = false;
-            else if (mode == osg::CullFace::FRONT) {
-                osg::notify(osg::WARN) << "3DS Writer: Reversed face (culled FRONT) not supported yet." << std::endl;
+            else if (mode == osg::CullFace::FRONT)
+            {
+                OSG_NOTIFY(osg::WARN) << "3DS Writer: Reversed face (culled FRONT) not supported yet." << std::endl;
                 double_sided = false;
             }
-            else {
+            else
+            {
                 assert(mode == osg::CullFace::FRONT_AND_BACK);
-                osg::notify(osg::WARN) << "3DS Writer: Invisible face (culled FRONT_AND_BACK) not supported yet." << std::endl;
+                OSG_NOTIFY(osg::WARN) << "3DS Writer: Invisible face (culled FRONT_AND_BACK) not supported yet." << std::endl;
                 double_sided = false;
             }
         }
     }
-    if (tex) {
+    if (tex)
+    {
         osg::Image* img = tex->getImage(0);
         if(img)
@@ -398,5 +415,6 @@
     }
 
-    if (name.empty()) {
+    if (name.empty())
+    {
         std::stringstream ss;
         ss << "m" << index;
@@ -466,5 +484,5 @@
                 const std::string & srcDirectory) :
     osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
-    _suceedLastApply(true),
+    _succeeded(true),
     _srcDirectory(srcDirectory),
     file3ds(file3ds),
@@ -480,5 +498,6 @@
         _directory = options->getDatabasePathList().empty() ? osgDB::getFilePath(fileName) : options->getDatabasePathList().front();
 
-    if (options) {
+    if (options)
+    {
         std::istringstream iss(options->getOptionString());
         std::string opt;
@@ -524,10 +543,12 @@
                     path = oss.str();
                 }
-                else {
+                else
+                {
                     path = getPathRelative(_srcDirectory, mat.image->getFileName());
                 }
                 path = convertExt(path, _extendedFilePaths);
 
-                if(!is3DSpath(path, _extendedFilePaths)) {
+                if(!is3DSpath(path, _extendedFilePaths))
+                {
                     path = getUniqueName(path, "", true);
                     //path = osgDB::getSimpleFileName(path);
@@ -547,22 +568,24 @@
                 if (mat.texture_no_tile) tex.flags |= LIB3DS_TEXTURE_NO_TILE;
             }
-            if (!suceedLastApply())
+            if (!succeeded())
                 return;
             lib3ds_file_insert_material(file3ds, mat3ds, itr->second.index);
             break;        // Ugly thing (3)
         }
-        if (!found) throw "Implementation error";                // Ugly thing (4)
-    }
-}
-
-
-std::string WriterNodeVisitor::getUniqueName(const std::string& _defaultValue, const std::string & _defaultPrefix, bool nameIsPath) {
-    static const unsigned int MAX_PREFIX_LEGNTH = 4;
-    if (_defaultPrefix.length()>MAX_PREFIX_LEGNTH) throw "Default prefix is too long";            // Arbitrarily defined to 4 chars.
+        assert(found);        // Ugly thing (4) - Implementation error if !found
+    }
+}
+
+
+std::string WriterNodeVisitor::getUniqueName(const std::string& _defaultValue, const std::string & _defaultPrefix, bool nameIsPath)
+{
+    static const unsigned int MAX_PREFIX_LEGNTH = 4;        // Arbitrarily defined to 4 chars
+    assert(_defaultPrefix.length()<=MAX_PREFIX_LEGNTH);        // Default prefix is too long (implementation error)
 
     // Tests if default name is valid and unique
     bool defaultIs83 = is83(_defaultValue);
     bool defaultIsValid = nameIsPath ? is3DSpath(_defaultValue, _extendedFilePaths) : defaultIs83;
-    if (defaultIsValid && _nameMap.find(_defaultValue) == _nameMap.end()) {
+    if (defaultIsValid && _nameMap.find(_defaultValue) == _nameMap.end())
+    {
         _nameMap.insert(_defaultValue);
         return _defaultValue;
@@ -611,16 +634,21 @@
 
     unsigned int searchStart = 0;
-    if (pairPrefix != _mapPrefix.end()) {
+    if (pairPrefix != _mapPrefix.end())
+    {
         searchStart = pairPrefix->second;
     }
 
-    for(unsigned int i = searchStart; i <= max_val; ++i) {
+    for(unsigned int i = searchStart; i <= max_val; ++i)
+    {
         std::stringstream ss;
         ss << defaultPrefix << i;
         const std::string & res = ss.str();
-        if (_nameMap.find(res) == _nameMap.end()) {
-            if (pairPrefix != _mapPrefix.end()) {
+        if (_nameMap.find(res) == _nameMap.end())
+        {
+            if (pairPrefix != _mapPrefix.end())
+            {
                 pairPrefix->second = i + 1;
-            } else {
+            } else
+            {
                 _mapPrefix.insert(std::pair<std::string, unsigned int>(defaultPrefix, i + 1));
             }
@@ -635,5 +663,9 @@
     // Try with default prefix if not arleady done
     if (defaultPrefix != std::string("_")) return getUniqueName(_defaultValue, "_", nameIsPath);
-    throw "No more names available! Is default prefix too long?";
+
+    // No more names
+    OSG_NOTIFY(osg::FATAL) << "No more names available!" << std::endl;
+    _succeeded = false;
+    return "ERROR";
 }
 
@@ -641,5 +673,6 @@
 {
     MaterialMap::const_iterator itr = _materialMap.find(ss);
-    if (itr != _materialMap.end()) {
+    if (itr != _materialMap.end())
+    {
         assert(itr->second.index>=0);
         return itr->second.index;
@@ -672,5 +705,6 @@
 {
     MapIndices::iterator itIndex = index_vert.find(std::pair<unsigned int, unsigned int>(index, drawable_n));
-    if (itIndex == index_vert.end()) {
+    if (itIndex == index_vert.end())
+    {
         unsigned int indexMesh = index_vert.size();
         index_vert.insert(std::make_pair(std::pair<unsigned int, unsigned int>(index, drawable_n), indexMesh));
@@ -688,7 +722,6 @@
                              Lib3dsMesh        * mesh)
 {
-    osg::notify(osg::DEBUG_INFO) << "Building Mesh" << std::endl;
-
-    if (!mesh) throw "Allocation error";        // TODO
+    OSG_NOTIFY(osg::DEBUG_INFO) << "Building Mesh" << std::endl;
+    assert(mesh);
 
     // Write points
@@ -701,5 +734,10 @@
         assert(g->getVertexArray());
         if (g->getVertexArray()->getType() != osg::Array::Vec3ArrayType)
-            throw "Vertex array is not Vec3. Not implemented";        // TODO
+        {
+            // TODO Handle double presision vertices by converting them to float with a warning
+            OSG_NOTIFY(osg::FATAL) << "Vertex array is not Vec3. Not implemented" << std::endl;
+            _succeeded = false;
+            return;
+        }
         const osg::Vec3Array & vecs= *static_cast<osg::Vec3Array *>(g->getVertexArray());
         copyOsgVectorToLib3dsVector(mesh->vertices[it->second], vecs[it->first.first]*mat);
@@ -712,10 +750,14 @@
         {
             osg::Geometry *g = geo.getDrawable( it->first.second )->asGeometry();
-            osg::Array * array = g->getTexCoordArray(0);
-            if(array)
+            osg::Array * texarray = g->getTexCoordArray(0);
+            if (texarray)
             {
                 if (g->getTexCoordArray(0)->getType() != osg::Array::Vec2ArrayType)
-                    throw "Texture coords array is not Vec2. Not implemented";        // TODO
-                const osg::Vec2Array & vecs= *static_cast<osg::Vec2Array *>(array);
+                {
+                    OSG_NOTIFY(osg::FATAL) << "Texture coords array is not Vec2. Not implemented" << std::endl;
+                    _succeeded = false;
+                    return;
+                }
+                const osg::Vec2Array & vecs= *static_cast<osg::Vec2Array *>(texarray);
                 mesh->texcos[it->second][0] = vecs[it->first.first][0];
                 mesh->texcos[it->second][1] = vecs[it->first.first][1];
@@ -739,5 +781,10 @@
         assert(g->getVertexArray());
         if (g->getVertexArray()->getType() != osg::Array::Vec3ArrayType)
-            throw "Vertex array is not Vec3. Not implemented";        // TODO
+        {
+            // TODO Handle double presision vertices by converting them to float with a warning
+            OSG_NOTIFY(osg::FATAL) << "Vertex array is not Vec3. Not implemented" << std::endl;
+            _succeeded = false;
+            return 0;
+        }
         const osg::Vec3Array & vecs= *static_cast<osg::Vec3Array *>(g->getVertexArray());
         numVertice += vecs.getNumElements();
@@ -753,10 +800,17 @@
                               bool                texcoords)
 {
-    MapIndices index_vert;
-    Lib3dsMesh *mesh = lib3ds_mesh_new( getUniqueName(geo.getName().empty() ? geo.className() : geo.getName(), "geo").c_str() );
-    if (!mesh) throw "Allocation error";
-
     unsigned int nbTrianglesRemaining = listTriangles.size();
-    unsigned int nbVerticesRemaining  = calcVertices(geo);
+    unsigned int nbVerticesRemaining  = calcVertices(geo);        // May set _succeded to false
+    if (!succeeded()) return;
+
+    std::string name( getUniqueName(geo.getName().empty() ? geo.className() : geo.getName(), "geo") );
+    if (!succeeded()) return;
+    Lib3dsMesh *mesh = lib3ds_mesh_new( name.c_str() );
+    if (!mesh)
+    {
+        OSG_NOTIFY(osg::FATAL) << "Allocation error" << std::endl;
+        _succeeded = false;
+        return;
+    }
 
     lib3ds_mesh_resize_faces   (mesh, osg::minimum(nbTrianglesRemaining, MAX_FACES));
@@ -766,9 +820,10 @@
     if (nbVerticesRemaining >= MAX_VERTICES || nbTrianglesRemaining >= MAX_FACES)
     {
-        osg::notify(osg::INFO) << "Sorting elements..." << std::endl;
+        OSG_NOTIFY(osg::INFO) << "Sorting elements..." << std::endl;
         WriterCompareTriangle cmp(geo, nbVerticesRemaining);
         std::sort(listTriangles.begin(), listTriangles.end(), cmp);
     }
 
+    MapIndices index_vert;
     unsigned int numFace = 0;        // Current face index
     for (ListTriangle::iterator it = listTriangles.begin(); it != listTriangles.end(); ++it) //Go through the triangle list to define meshs
@@ -780,5 +835,10 @@
             lib3ds_mesh_resize_faces   (mesh, numFace);
             //lib3ds_mesh_resize_vertices() will be called in buildMesh()
-            buildMesh(geo, mat, index_vert, texcoords, mesh);
+            buildMesh(geo, mat, index_vert, texcoords, mesh);        // May set _succeded to false
+            if (!succeeded())
+            {
+                lib3ds_mesh_free(mesh);
+                return;
+            }
 
             // "Reset" values and start over a new mesh
@@ -790,5 +850,10 @@
 
             mesh = lib3ds_mesh_new( getUniqueName(geo.getName().empty() ? geo.className() : geo.getName(), "geo").c_str());
-            if (!mesh) throw "Allocation error";
+            if (!mesh)
+            {
+                OSG_NOTIFY(osg::FATAL) << "Allocation error" << std::endl;
+                _succeeded = false;
+                return;
+            }
             lib3ds_mesh_resize_faces   (mesh, osg::minimum(nbTrianglesRemaining, MAX_FACES));
             lib3ds_mesh_resize_vertices(mesh, osg::minimum(nbVerticesRemaining,  MAX_VERTICES), texcoords ? 0 : 1, 0);        // Not mandatory but will allocate once a big block
@@ -800,5 +865,11 @@
         face.material = it->first.material;
     }
-    buildMesh(geo, mat, index_vert, texcoords, mesh); //When a Mesh is completed without restriction of vertices number
+
+    buildMesh(geo, mat, index_vert, texcoords, mesh);        // May set _succeded to false
+    if (!succeeded())
+    {
+        lib3ds_mesh_free(mesh);
+        return;
+    }
 }
 
@@ -812,5 +883,10 @@
     {
         if (geo->getVertexArray() && geo->getVertexArray()->getType() != osg::Array::Vec3ArrayType)
-            throw "Vertex array is not Vec3. Not implemented";        // TODO
+        {
+            // TODO Handle double presision vertices by converting them to float with a warning
+            OSG_NOTIFY(osg::FATAL) << "Vertex array is not Vec3. Not implemented" << std::endl;
+            _succeeded = false;
+            return;
+        }
         const osg::Vec3Array * vecs = geo->getVertexArray() ? static_cast<osg::Vec3Array *>(geo->getVertexArray()) : NULL;
         if (vecs) 
@@ -819,10 +895,19 @@
             // Texture coords
             if (geo->getTexCoordArray(0) && geo->getTexCoordArray(0)->getType() != osg::Array::Vec2ArrayType)
-                throw "Texture coords array is not Vec2. Not implemented";        // TODO
+            {
+                OSG_NOTIFY(osg::FATAL) << "Texture coords array is not Vec2. Not implemented" << std::endl;
+                _succeeded = false;
+                return;
+            }
             const osg::Vec2Array * texvecs = geo->getTexCoordArray(0) ? static_cast<osg::Vec2Array *>(geo->getTexCoordArray(0)) : NULL;
             if (texvecs) 
             {
                 unsigned int nb = geo->getTexCoordArray(0)->getNumElements();
-                if (nb != geo->getVertexArray()->getNumElements()) throw "There are more/less texture coords than vertices!";
+                if (nb != geo->getVertexArray()->getNumElements())
+                {
+                    OSG_NOTIFY(osg::FATAL) << "There are more/less texture coords than vertices (corrupted geometry)" << std::endl;
+                    _succeeded = false;
+                    return;
+                }
                 texcoords = true;
             }
@@ -842,16 +927,6 @@
 }
 
-bool WriterNodeVisitor::suceedLastApply() const
-{
-    return _suceedLastApply;
-}
-
-void WriterNodeVisitor::failedApply()
-{
-    _suceedLastApply = false;
-    osg::notify(osg::NOTICE) << "Error going through node" << std::endl;
-}
-
-void WriterNodeVisitor::apply( osg::Geode &node ) {
+void WriterNodeVisitor::apply( osg::Geode &node )
+{
     pushStateSet(node.getStateSet());
     //_nameStack.push_back(node.getName());
@@ -865,20 +940,22 @@
         {
             pushStateSet(g->getStateSet());
-            createListTriangle(g, listTriangles, texcoords, i);
+            createListTriangle(g, listTriangles, texcoords, i);        // May set _succeded to false
             popStateSet(g->getStateSet());
-        }
-    }
-    if (count > 0)
+            if (!succeeded()) break;
+        }
+    }
+    if (succeeded() && count > 0)
     {
         osg::Matrix mat( osg::computeLocalToWorld(getNodePath()) );
-        buildFaces(node, mat, listTriangles, texcoords);
+        buildFaces(node, mat, listTriangles, texcoords);        // May set _succeded to false
     }
     popStateSet(node.getStateSet());
     //_nameStack.pop_back();
-    if (suceedLastApply())
+    if (succeeded())
         traverse(node);
 }
 
-void WriterNodeVisitor::apply( osg::Billboard &node ) {
+void WriterNodeVisitor::apply( osg::Billboard &node )
+{
     // TODO Does not handle Billboards' points yet
 
@@ -889,5 +966,5 @@
     ListTriangle listTriangles;
     bool texcoords = false;
-    osg::notify(osg::NOTICE) << "Warning: 3DS writer is incomplete for Billboards (rotation not implemented)." << std::endl;
+    OSG_NOTIFY(osg::NOTICE) << "Warning: 3DS writer is incomplete for Billboards (rotation not implemented)." << std::endl;
     osg::Matrix m( osg::computeLocalToWorld(getNodePath()) );
     for ( unsigned int i = 0; i < count; i++ )
@@ -901,13 +978,15 @@
             pushStateSet(g->getStateSet());
             createListTriangle(g, listTriangles, texcoords, i);
-            popStateSet(g->getStateSet());
+            popStateSet(g->getStateSet());        // May set _succeded to false
+            if (!succeeded()) break;
 
             osg::Matrix currentBillBoardMat(osg::Matrix::translate(node.getPosition(i)) * m);        // TODO handle rotation
             apply3DSMatrixNode(node, currentBillBoardMat, "bil");        // Add a 3DS matrix node
-            buildFaces(node, currentBillBoardMat, listTriangles, texcoords);
-        }
-    }
-
-    if (suceedLastApply())
+            buildFaces(node, currentBillBoardMat, listTriangles, texcoords);        // May set _succeded to false
+            if (!succeeded()) break;
+        }
+    }
+
+    if (succeeded())
         traverse(node);
     _cur3dsNode = parent;
@@ -922,5 +1001,5 @@
     Lib3dsMeshInstanceNode * parent = _cur3dsNode;
     apply3DSMatrixNode(node, osg::computeLocalToWorld(getNodePath()), "grp");
-    if (suceedLastApply())
+    if (succeeded())
         traverse(node);
     _cur3dsNode = parent;
@@ -933,5 +1012,5 @@
     Lib3dsMeshInstanceNode * parent = _cur3dsNode;
     apply3DSMatrixNode(node, osg::computeLocalToWorld(getNodePath()), "mtx");
-    if (suceedLastApply())
+    if (succeeded())
         traverse(node);
     _cur3dsNode = parent;
Index: /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterNodeVisitor.h
===================================================================
--- /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterNodeVisitor.h (revision 11194)
+++ /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterNodeVisitor.h (revision 11203)
@@ -59,6 +59,5 @@
                         const std::string & srcDirectory);
 
-        bool        suceedLastApply() const;
-        void        failedApply();
+        bool succeeded() const { return _succeeded; }
         virtual void apply(osg::Geode &node);
         virtual void apply(osg::Billboard &node);
@@ -146,6 +145,5 @@
         *  \return the number of vertices in the geode.
         */
-        unsigned int 
-        calcVertices(osg::Geode & geo);
+        unsigned int calcVertices(osg::Geode & geo);
 
         /** 
@@ -198,5 +196,5 @@
         void apply3DSMatrixNode(osg::Node &node, const osg::Matrix & m, const char * const prefix);
 
-        bool                                _suceedLastApply;
+        bool                                _succeeded;
         std::string                         _directory;
         std::string                         _srcDirectory;
Index: /OpenSceneGraph/trunk/src/osgPlugins/3ds/ReaderWriter3DS.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgPlugins/3ds/ReaderWriter3DS.cpp (revision 11194)
+++ /OpenSceneGraph/trunk/src/osgPlugins/3ds/ReaderWriter3DS.cpp (revision 11203)
@@ -95,13 +95,16 @@
 }
 
-void copyLib3dsVec3ToOsgVec3(osg::Vec3f osgVec, const float vertices[3]) {
+void copyLib3dsVec3ToOsgVec3(osg::Vec3f osgVec, const float vertices[3])
+{
     return osgVec.set(vertices[0], vertices[1], vertices[2]);
 }
 
-osg::Vec3f copyLib3dsVec3ToOsgVec3(const float vertices[3]) {
+osg::Vec3f copyLib3dsVec3ToOsgVec3(const float vertices[3])
+{
     return osg::Vec3f(vertices[0], vertices[1], vertices[2]);
 }
 
-osg::Quat copyLib3dsQuatToOsgQuat(const float quat[4]) {
+osg::Quat copyLib3dsQuatToOsgQuat(const float quat[4])
+{
     return osg::Quat(quat[0], quat[1], quat[2], quat[3]);
 }
@@ -226,20 +229,20 @@
 
 #if 0
-    osg::notify(osg::NOTICE)<<"3DS reader sizes:"<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsBool)="<<sizeof(Lib3dsBool)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsByte)="<<sizeof(Lib3dsByte)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsWord)="<<sizeof(Lib3dsWord)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsDword)="<<sizeof(Lib3dsDword)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsIntb)="<<sizeof(Lib3dsIntb)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsIntw)="<<sizeof(Lib3dsIntw)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsIntd)="<<sizeof(Lib3dsIntd)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsFloat)="<<sizeof(Lib3dsFloat)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsDouble)="<<sizeof(Lib3dsDouble)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsVector)="<<sizeof(Lib3dsVector)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsTexel)="<<sizeof(Lib3dsTexel)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsQuat)="<<sizeof(Lib3dsQuat)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsMatrix)="<<sizeof(Lib3dsMatrix)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsRgb)="<<sizeof(Lib3dsRgb)<<std::endl;
-    osg::notify(osg::NOTICE)<<"  sizeof(Lib3dsRgba)="<<sizeof(Lib3dsRgba)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"3DS reader sizes:"<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsBool)="<<sizeof(Lib3dsBool)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsByte)="<<sizeof(Lib3dsByte)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsWord)="<<sizeof(Lib3dsWord)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsDword)="<<sizeof(Lib3dsDword)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsIntb)="<<sizeof(Lib3dsIntb)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsIntw)="<<sizeof(Lib3dsIntw)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsIntd)="<<sizeof(Lib3dsIntd)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsFloat)="<<sizeof(Lib3dsFloat)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsDouble)="<<sizeof(Lib3dsDouble)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsVector)="<<sizeof(Lib3dsVector)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsTexel)="<<sizeof(Lib3dsTexel)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsQuat)="<<sizeof(Lib3dsQuat)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsMatrix)="<<sizeof(Lib3dsMatrix)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsRgb)="<<sizeof(Lib3dsRgb)<<std::endl;
+    OSG_NOTIFY(osg::NOTICE)<<"  sizeof(Lib3dsRgba)="<<sizeof(Lib3dsRgba)<<std::endl;
 #endif
 
@@ -254,5 +257,6 @@
     restoreMatrixTransformsNoMeshes(false)
 {
-    if (options) {
+    if (options)
+    {
         std::istringstream iss(options->getOptionString());
         std::string opt; 
@@ -273,5 +277,6 @@
     These print methods for 3ds hacking
 */
-void pad(int level) {
+void pad(int level)
+{
     for(int i=0;i<level;i++) std::cout<<"  ";
 }
@@ -281,5 +286,6 @@
 void print(Lib3dsNode *node, int level);
 
-void print(Lib3dsMatrix matrix,int level) {
+void print(Lib3dsMatrix matrix,int level)
+{
     pad(level); cout << matrix[0][0] <<" "<< matrix[0][1] <<" "<< matrix[0][2] <<" "<< matrix[0][3] << endl;
     pad(level); cout << matrix[1][0] <<" "<< matrix[1][1] <<" "<< matrix[1][2] <<" "<< matrix[1][3] << endl;
@@ -287,23 +293,33 @@
     pad(level); cout << matrix[3][0] <<" "<< matrix[3][1] <<" "<< matrix[3][2] <<" "<< matrix[3][3] << endl;
 }
-void print(Lib3dsMesh *mesh,int level) {
-    if (mesh) {
+void print(Lib3dsMesh *mesh,int level)
+{
+    if (mesh)
+    {
         pad(level); cout << "mesh name " << mesh->name  << endl;
         print(mesh->matrix,level);
-    } else {
+    }
+    else
+    {
         pad(level); cout << "no mesh " << endl;
     }
 }
-void print(Lib3dsUserData *user,int level) {
-    if (user) {
+void print(Lib3dsUserData *user,int level)
+{
+    if (user)
+    {
         pad(level); cout << "user data" << endl;
         //print(user->mesh,level+1);
-    } else {
+    }
+    else
+    {
         pad(level); cout << "no user data" << endl;
     }
 }
 
-void print(Lib3dsMeshInstanceNode *object,int level) {
-    if (object) {
+void print(Lib3dsMeshInstanceNode *object,int level)
+{
+    if (object)
+    {
         pad(level); cout << "objectdata instance [" << object->instance_name << "]" << endl;
         pad(level); cout << "pivot     " << object->pivot[0] <<" "<< object->pivot[1] <<" "<< object->pivot[2] << endl;
@@ -311,10 +327,13 @@
         pad(level); cout << "scl       " << object->scl[0] <<" "<< object->scl[1] <<" "<< object->scl[2] << endl;
         pad(level); cout << "rot       " << object->rot[0] <<" "<< object->rot[1] <<" "<< object->rot[2] <<" "<< object->rot[3] << endl;
-    } else {
+    }
+    else
+    {
         pad(level); cout << "no object data" << endl;
     }
 }
 
-void print(Lib3dsNode *node, int level) {
+void print(Lib3dsNode *node, int level)
+{
 
     pad(level); cout << "node name [" << node->name << "]" << endl;
@@ -324,8 +343,11 @@
     print(node->matrix,level+1);
 
-    if (node->type == LIB3DS_NODE_MESH_INSTANCE) {
+    if (node->type == LIB3DS_NODE_MESH_INSTANCE)
+    {
         pad(level); cout << "mesh instance data:" << endl;
         print(reinterpret_cast<Lib3dsMeshInstanceNode *>(node),level+1);
-    } else {
+    }
+    else
+    {
         pad(level); cout << "node is not a mesh instance (not handled)" << endl;
     }
@@ -333,5 +355,6 @@
     print(&node->user_ptr,level);
 
-    for(Lib3dsNode *child=node->childs; child; child=child->next) {
+    for(Lib3dsNode *child=node->childs; child; child=child->next)
+    {
         print(child,level+1);
     }
@@ -387,5 +410,6 @@
 // Creates a Geode and Geometry (as parent,child) and adds the Geode to 'parent' parameter iff 'parent' is non-NULL
 // Returns ptr to the Geode
-osg::Node* ReaderWriter3DS::ReaderObject::processMesh(StateSetMap& drawStateMap,osg::Group* parent,Lib3dsMesh* mesh, const osg::Matrix * matrix) {
+osg::Node* ReaderWriter3DS::ReaderObject::processMesh(StateSetMap& drawStateMap,osg::Group* parent,Lib3dsMesh* mesh, const osg::Matrix * matrix)
+{
     typedef std::vector<FaceList> MaterialFaceMap;
     MaterialFaceMap materialFaceMap;
@@ -395,14 +419,17 @@
     for (unsigned int i=0; i<mesh->nfaces; ++i)
     {
-        if (mesh->faces[i].material>=0) {
+        if (mesh->faces[i].material>=0)
+        {
             materialFaceMap[mesh->faces[i].material].push_back(i);
         }
         else
+        {
             defaultMaterialFaceList.push_back(i);
+        }
     }
     if (materialFaceMap.empty() && defaultMaterialFaceList.empty())
     {
-        osg::notify(osg::NOTICE)<<"Warning : no triangles assigned to mesh '"<<mesh->name<<"'"<< std::endl;
-        //osg::notify(osg::INFO) << "No material assigned to mesh '" << mesh->name << "'" << std::endl;
+        OSG_NOTIFY(osg::NOTICE)<<"Warning : no triangles assigned to mesh '"<<mesh->name<<"'"<< std::endl;
+        //OSG_NOTIFY(osg::INFO) << "No material assigned to mesh '" << mesh->name << "'" << std::endl;
         return NULL;
     }
@@ -473,6 +500,8 @@
 
     osg::Matrix meshMat;
-    if (mesh) {
-         if (!noMatrixTransforms) {
+    if (mesh)
+    {
+         if (!noMatrixTransforms)
+         {
             // There can be a transform directly on a mesh instance (= as if a osg::MatrixTransform and a osg::Geode were merged together) in object->pos/rot/scl
             if (!pivoted) {
@@ -493,19 +522,25 @@
 
     bool isOsgNodeMatrixIdentity = false;
-    if (osgNodeMatrix.isIdentity() || (checkForEspilonIdentityMatrices && isIdentityEquivalent(osgNodeMatrix, MATRIX_EPSILON))) {
+    if (osgNodeMatrix.isIdentity() || (checkForEspilonIdentityMatrices && isIdentityEquivalent(osgNodeMatrix, MATRIX_EPSILON)))
+    {
         isOsgNodeMatrixIdentity = true;
     }
 
 
-    //if (node->childs != NULL || pivoted || (!isOsgNodeMatrixIdentity && !noMatrixTransforms)) {
-    if (node->childs != NULL || (!isOsgNodeMatrixIdentity && !noMatrixTransforms)) {
-        if (isOsgNodeMatrixIdentity || noMatrixTransforms) {
+    //if (node->childs != NULL || pivoted || (!isOsgNodeMatrixIdentity && !noMatrixTransforms))
+    if (node->childs != NULL || (!isOsgNodeMatrixIdentity && !noMatrixTransforms))
+    {
+        if (isOsgNodeMatrixIdentity || noMatrixTransforms)
+        {
             group = new osg::Group;
-        } else {
+        }
+        else
+        {
             group = new osg::MatrixTransform(osgNodeMatrix);
         }
     }
 
-    if (group) {
+    if (group)
+    {
         if (strcmp(node->name, "$$$DUMMY") == 0) 
         {
@@ -517,24 +552,32 @@
 
         // Handle all children of this node for hierarchical assemblies
-        for (Lib3dsNode *p=node->childs; p!=NULL; p=p->next) {
+        for (Lib3dsNode *p=node->childs; p!=NULL; p=p->next)
+        {
             group->addChild(processNode(drawStateMap,f,p));
         }
-    } else {
+    }
+    else
+    {
         assert(node->childs == NULL);        // Else we must have a group to put childs into
     }
 
     // Handle mesh
-    if (mesh) {
+    if (mesh)
+    {
         osg::Matrix * meshAppliedMatPtr = NULL;
-        if (!meshMat.isIdentity() && !(checkForEspilonIdentityMatrices && isIdentityEquivalent(meshMat, MATRIX_EPSILON))) {
+        if (!meshMat.isIdentity() && !(checkForEspilonIdentityMatrices && isIdentityEquivalent(meshMat, MATRIX_EPSILON)))
+        {
             meshAppliedMatPtr = &meshMat;
         }
 
-        if(group) {
+        if (group)
+        {
             // add our geometry to group (where our children already are)
             // creates geometry under modifier node
             processMesh(drawStateMap,group,mesh,meshAppliedMatPtr);
             return group;
-        } else {
+        }
+        else
+        {
             // didnt use group for children
             // return a ptr directly to the Geode for this mesh
@@ -542,5 +585,7 @@
         }
 
-    } else {
+    }
+    else
+    {
         // no mesh for this node - probably a camera or something of that persuasion
         //cout << "no mesh for object " << node->name << endl;
@@ -550,5 +595,6 @@
 
 
-static long filei_seek_func(void *self, long offset, Lib3dsIoSeek origin) {
+static long filei_seek_func(void *self, long offset, Lib3dsIoSeek origin)
+{
     std::istream *f = reinterpret_cast<std::istream*>(self);
     ios_base::seekdir o = ios_base::beg;
@@ -560,5 +606,6 @@
 }
 
-static long fileo_seek_func(void *self, long offset, Lib3dsIoSeek origin) {
+static long fileo_seek_func(void *self, long offset, Lib3dsIoSeek origin)
+{
     std::ostream *f = reinterpret_cast<std::ostream*>(self);
     ios_base::seekdir o = ios_base::beg;
@@ -570,10 +617,12 @@
 }
 
-static long filei_tell_func(void *self) {
+static long filei_tell_func(void *self)
+{
     std::istream *f = reinterpret_cast<std::istream*>(self);
     return f->tellg();
 }
 
-static long fileo_tell_func(void *self) {
+static long fileo_tell_func(void *self)
+{
     std::ostream *f = reinterpret_cast<std::ostream*>(self);
     return f->tellp();
@@ -581,5 +630,6 @@
 
 
-static size_t filei_read_func(void *self, void *buffer, size_t size) {
+static size_t filei_read_func(void *self, void *buffer, size_t size)
+{
     std::istream *f = reinterpret_cast<std::istream*>(self);
     f->read(reinterpret_cast<char*>(buffer), size);
@@ -587,5 +637,6 @@
 }
 
-static size_t fileo_write_func(void *self, const void *buffer, size_t size) {
+static size_t fileo_write_func(void *self, const void *buffer, size_t size)
+{
     std::ostream *f = reinterpret_cast<std::ostream*>(self);
     f->write(static_cast<const char*>(buffer), size);
@@ -601,5 +652,5 @@
     else if (level == LIB3DS_LOG_INFO) l = osg::INFO;
     else if (level == LIB3DS_LOG_DEBUG) l = osg::DEBUG_INFO;
-    osg::notify(l) << msg << std::endl;
+    OSG_NOTIFY(l) << msg << std::endl;
 }
 
@@ -700,9 +751,10 @@
         int level=0;
         std::cout << "NODE TRAVERSAL of 3ds file "<<f->name<<std::endl;
-        for(Lib3dsNode *node=f->nodes; node; node=node->next) {
+        for(Lib3dsNode *node=f->nodes; node; node=node->next)
+        {
             print(node,level+1);
         }
         std::cout << "MESH TRAVERSAL of 3ds file "<<f->name<<std::endl;
-        for (int imesh=0; imesh<f->nmeshes; ++imesh) {
+        for (int imesh=0; imesh<f->nmeshes; ++imesh){
             print(f->meshes[imesh],level+1);
         }
@@ -716,6 +768,7 @@
     // MIKEC: have found 3ds files with NO node structure - only meshes, for this case we fall back to the old traverse-by-meshes code
     // Loading and re-exporting these files from 3DS produces a file with correct node structure, so perhaps these are not 100% conformant?
-    if (f->nodes == NULL) {
-        osg::notify(osg::WARN)<<"Warning: in 3ds loader: file has no nodes, traversing by meshes instead"<< std::endl;
+    if (f->nodes == NULL)
+    {
+        OSG_NOTIFY(osg::WARN)<<"Warning: in 3ds loader: file has no nodes, traversing by meshes instead"<< std::endl;
         traverse_nodes=true;
     }
@@ -723,17 +776,24 @@
     osg::Node* group = NULL;
 
-    if (traverse_nodes) { // old method
+    if (traverse_nodes) // old method
+    {
         group = new osg::Group();
-        for (int imesh=0; imesh<f->nmeshes; ++imesh) {
+        for (int imesh=0; imesh<f->nmeshes; ++imesh)
+        {
             reader.processMesh(drawStateMap,group->asGroup(),f->meshes[imesh],NULL);
         }
-    } else { // new method
+    }
+    else
+    { // new method
         Lib3dsNode *node=f->nodes;
         if (!node->next)
+        {
             group = reader.processNode(drawStateMap,f,node);
+        }
         else
         {
             group = new osg::Group();
-            for(; node; node=node->next) {
+            for(; node; node=node->next)
+            {
                 group->asGroup()->addChild(reader.processNode(drawStateMap,f,node));
             }
@@ -744,5 +804,5 @@
     if (osg::getNotifyLevel()>=osg::INFO)
     {
-        osg::notify(osg::NOTICE) << "Final OSG node structure looks like this:"<< endl;
+        OSG_NOTIFY(osg::NOTICE) << "Final OSG node structure looks like this:"<< endl;
         PrintVisitor pv(osg::notify(osg::NOTICE));
         group->accept(pv);
@@ -903,5 +963,5 @@
     if (texture && *(texture->name))
     {
-        osg::notify(osg::INFO)<<"texture->name="<<texture->name<<", _directory="<<_directory<<std::endl;
+        OSG_NOTIFY(osg::INFO)<<"texture->name="<<texture->name<<", _directory="<<_directory<<std::endl;
 
         std::string fileName = osgDB::findFileInDirectory(texture->name,_directory,osgDB::CASE_INSENSITIVE);
@@ -910,5 +970,5 @@
             // file not found in .3ds file's directory, so we'll look in the datafile path list.
             fileName = osgDB::findDataFile(texture->name,options, osgDB::CASE_INSENSITIVE);
-            osg::notify(osg::INFO)<<"texture->name="<<texture->name<<", _directory="<<_directory<<std::endl;
+            OSG_NOTIFY(osg::INFO)<<"texture->name="<<texture->name<<", _directory="<<_directory<<std::endl;
         }
 
@@ -919,28 +979,31 @@
                 // if 3DS file is loaded from http, just attempt to load texture from same location.
                 fileName = _directory + "/" + texture->name;
-            } else {
-                osg::notify(osg::WARN) << "texture '"<<texture->name<<"' not found"<< std::endl;
+            }
+            else
+            {
+                OSG_NOTIFY(osg::WARN) << "texture '"<<texture->name<<"' not found"<< std::endl;
                 return NULL;
             }
         }
 
-        if (label) osg::notify(osg::DEBUG_INFO) << label;
-        else osg::notify(osg::DEBUG_INFO) << "texture name";
-        osg::notify(osg::DEBUG_INFO) << " '"<<texture->name<<"'"<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    texture flag        "<<texture->flags<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_DECALE       "<<((texture->flags)&LIB3DS_TEXTURE_DECALE)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_MIRROR       "<<((texture->flags)&LIB3DS_TEXTURE_MIRROR)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_NEGATE       "<<((texture->flags)&LIB3DS_TEXTURE_NEGATE)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_NO_TILE      "<<((texture->flags)&LIB3DS_TEXTURE_NO_TILE)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_SUMMED_AREA  "<<((texture->flags)&LIB3DS_TEXTURE_SUMMED_AREA)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_ALPHA_SOURCE "<<((texture->flags)&LIB3DS_TEXTURE_ALPHA_SOURCE)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_TINT         "<<((texture->flags)&LIB3DS_TEXTURE_TINT)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_IGNORE_ALPHA "<<((texture->flags)&LIB3DS_TEXTURE_IGNORE_ALPHA)<< std::endl;
-        osg::notify(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_RGB_TINT     "<<((texture->flags)&LIB3DS_TEXTURE_RGB_TINT)<< std::endl;
+        if (label) { OSG_NOTIFY(osg::DEBUG_INFO) << label; }
+        else { OSG_NOTIFY(osg::DEBUG_INFO) << "texture name"; }
+
+        OSG_NOTIFY(osg::DEBUG_INFO) << " '"<<texture->name<<"'"<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    texture flag        "<<texture->flags<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_DECALE       "<<((texture->flags)&LIB3DS_TEXTURE_DECALE)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_MIRROR       "<<((texture->flags)&LIB3DS_TEXTURE_MIRROR)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_NEGATE       "<<((texture->flags)&LIB3DS_TEXTURE_NEGATE)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_NO_TILE      "<<((texture->flags)&LIB3DS_TEXTURE_NO_TILE)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_SUMMED_AREA  "<<((texture->flags)&LIB3DS_TEXTURE_SUMMED_AREA)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_ALPHA_SOURCE "<<((texture->flags)&LIB3DS_TEXTURE_ALPHA_SOURCE)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_TINT         "<<((texture->flags)&LIB3DS_TEXTURE_TINT)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_IGNORE_ALPHA "<<((texture->flags)&LIB3DS_TEXTURE_IGNORE_ALPHA)<< std::endl;
+        OSG_NOTIFY(osg::DEBUG_INFO) << "    LIB3DS_TEXTURE_RGB_TINT     "<<((texture->flags)&LIB3DS_TEXTURE_RGB_TINT)<< std::endl;
 
         osg::ref_ptr<osg::Image> osg_image = osgDB::readRefImageFile(fileName.c_str(), options); //Absolute Path
         if (!osg_image.valid())
         {
-            osg::notify(osg::NOTICE) << "Warning: Cannot create texture "<<texture->name<< std::endl;
+            OSG_NOTIFY(osg::NOTICE) << "Warning: Cannot create texture "<<texture->name<< std::endl;
             return NULL;
         }
@@ -1071,5 +1134,6 @@
 
 
-osgDB::ReaderWriter::WriteResult ReaderWriter3DS::writeNode(const osg::Node& node,const std::string& fileName,const Options* options) const {
+osgDB::ReaderWriter::WriteResult ReaderWriter3DS::writeNode(const osg::Node& node,const std::string& fileName,const Options* options) const
+{
     std::string ext = osgDB::getLowerCaseFileExtension(fileName);
     if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
@@ -1084,14 +1148,8 @@
     if (!file3ds) return WriteResult(WriteResult::ERROR_IN_WRITING_FILE);
 
-    try {
-        osg::ref_ptr<Options> local_opt = options ? static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
-        local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName));
-
-        if (!createFileObject(node, file3ds, fileName, local_opt)) ok = false;
-        if (ok && !lib3ds_file_save(file3ds, fileName.c_str())) ok = false;
-    } catch (...) {
-        lib3ds_file_free(file3ds);
-        throw;
-    }
+    osg::ref_ptr<Options> local_opt = options ? static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
+    local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileName));
+    if (!createFileObject(node, file3ds, fileName, local_opt)) ok = false;
+    if (ok && !lib3ds_file_save(file3ds, fileName.c_str())) ok = false;
     lib3ds_file_free(file3ds);
 
@@ -1101,8 +1159,10 @@
 
 
-osgDB::ReaderWriter::WriteResult ReaderWriter3DS::writeNode(const osg::Node& node,std::ostream& fout,const Options* options) const {
-    //osg::notify(osg::WARN) << "!!WARNING!! 3DS write support is incomplete" << std::endl;
+osgDB::ReaderWriter::WriteResult ReaderWriter3DS::writeNode(const osg::Node& node,std::ostream& fout,const Options* options) const
+{
+    //OSG_NOTIFY(osg::WARN) << "!!WARNING!! 3DS write support is incomplete" << std::endl;
     std::string optFileName;
-    if (options) {
+    if (options)
+    {
         optFileName = options->getPluginStringData("STREAM_FILENAME");
     }
@@ -1111,5 +1171,6 @@
 }
 
-osgDB::ReaderWriter::WriteResult ReaderWriter3DS::doWriteNode(const osg::Node& node,std::ostream& fout, const Options* options, const std::string & fileNamelib3ds) const {
+osgDB::ReaderWriter::WriteResult ReaderWriter3DS::doWriteNode(const osg::Node& node,std::ostream& fout, const Options* options, const std::string & fileNamelib3ds) const
+{
     osg::ref_ptr<Options> local_opt = options ? static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
     local_opt->getDatabasePathList().push_front(osgDB::getFilePath(fileNamelib3ds));
@@ -1127,12 +1188,6 @@
 
     bool ok = true;
-    try {
-        if (!createFileObject(node, file3ds, fileNamelib3ds, local_opt.get())) ok = false;
-        if (ok && !lib3ds_file_write(file3ds, &io)) ok = false;
-        
-    } catch (...) {
-        lib3ds_file_free(file3ds);
-        throw;
-    }
+    if (!createFileObject(node, file3ds, fileNamelib3ds, local_opt.get())) ok = false;
+    if (ok && !lib3ds_file_write(file3ds, &io)) ok = false;
     lib3ds_file_free(file3ds);
 
@@ -1141,11 +1196,11 @@
 }
 
-bool ReaderWriter3DS::createFileObject(const osg::Node& node, Lib3dsFile * file3ds,const std::string& fileName, const osgDB::ReaderWriter::Options* options) const {
+bool ReaderWriter3DS::createFileObject(const osg::Node& node, Lib3dsFile * file3ds,const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
+{
     WriterNodeVisitor w(file3ds, fileName, options, osgDB::getFilePath(node.getName()));
     const_cast<osg::Node &>(node).accept(w);                // Ugly const_cast<> for visitor...
-    if (!w.suceedLastApply())
-        return false;
+    if (!w.succeeded()) return false;
     w.writeMaterials();
-    return true;    //w.good();
-}
-
+    return w.succeeded();
+}
+
Index: /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterCompareTriangle.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterCompareTriangle.cpp (revision 11194)
+++ /OpenSceneGraph/trunk/src/osgPlugins/3ds/WriterCompareTriangle.cpp (revision 11203)
@@ -1,3 +1,4 @@
 #include "WriterCompareTriangle.h"
+#include <assert.h>
 
 WriterCompareTriangle::WriterCompareTriangle(const osg::Geode & geode, unsigned int nbVertices) : geode(geode) 
@@ -51,5 +52,5 @@
     setMaxMin (nbVerticesX, nbVerticesY, nbVerticesZ); // This function prevent from cutting the scene in too many blocs
 
-    osg::notify(osg::INFO)
+    OSG_NOTIFY(osg::INFO)
         << "Cutting x by " << nbVerticesX << std::endl
         << "Cutting y by " << nbVerticesY << std::endl
@@ -120,14 +121,15 @@
     {
         if (x >= boxList[i].xMin() && 
-            x < boxList[i].xMax() &&
+            x <  boxList[i].xMax() &&
             y >= boxList[i].yMin() &&
-            y < boxList[i].yMax() &&
+            y <  boxList[i].yMax() &&
             z >= boxList[i].zMin() &&
-            z < boxList[i].zMax())
+            z <  boxList[i].zMax())
         {
             return i;
         }
     }
-    throw "Point is not in any blocs";
+    assert(false && "Point is not in any blocs");
+    return 0;
 }
 
