Revision: 77137
          http://sourceforge.net/p/brlcad/code/77137
Author:   starseeker
Date:     2020-09-14 03:31:11 +0000 (Mon, 14 Sep 2020)
Log Message:
-----------
Just directly alter the problematic names in the openNURBS headers, so we don't 
have to try and work around it in ours.

Modified Paths:
--------------
    brlcad/trunk/include/brep/defines.h
    brlcad/trunk/src/libgcv/plugins/rhino/rhino_read.cpp
    brlcad/trunk/src/librt/primitives/brep/brep.cpp
    brlcad/trunk/src/other/openNURBS/example_read/example_read.cpp
    brlcad/trunk/src/other/openNURBS/example_roundtrip/example_roundtrip.cpp
    brlcad/trunk/src/other/openNURBS/example_write/example_write.cpp
    brlcad/trunk/src/other/openNURBS/opennurbs_archive.cpp
    brlcad/trunk/src/other/openNURBS/opennurbs_archive.h
    brlcad/trunk/src/other/openNURBS/opennurbs_defines.cpp
    brlcad/trunk/src/other/openNURBS/opennurbs_defines.h
    brlcad/trunk/src/other/openNURBS/opennurbs_extensions.cpp
    brlcad/trunk/src/other/openNURBS/opennurbs_extensions.h
    brlcad/trunk/src/other/openNURBS/opennurbs_string.cpp
    brlcad/trunk/src/other/openNURBS/opennurbs_userdata.cpp
    brlcad/trunk/src/other/openNURBS/opennurbs_zlib.cpp

Modified: brlcad/trunk/include/brep/defines.h
===================================================================
--- brlcad/trunk/include/brep/defines.h 2020-09-14 00:57:56 UTC (rev 77136)
+++ brlcad/trunk/include/brep/defines.h 2020-09-14 03:31:11 UTC (rev 77137)
@@ -43,15 +43,7 @@
 /* don't let opennurbs include windows.h */
 #define ON_NO_WINDOWS 1
 
-/* NOTE: we re-define read/write due to the archive_mode enum that
- * shadows the system symbols.  we undefine when done to not interfere
- * with app code.
- */
-#define read on_read
-#define write on_write
 #include "opennurbs.h"
-#undef read
-#undef write
 
 }
 /* @endcond */

Modified: brlcad/trunk/src/libgcv/plugins/rhino/rhino_read.cpp
===================================================================
--- brlcad/trunk/src/libgcv/plugins/rhino/rhino_read.cpp        2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/libgcv/plugins/rhino/rhino_read.cpp        2020-09-14 
03:31:11 UTC (rev 77137)
@@ -972,7 +972,7 @@
     if (!source_path) return 0;
     FILE *fp = ON::OpenFile(source_path,"rb");
     if (!fp) return 0;
-    ON_BinaryFile file(ON::read3dm,fp);
+    ON_BinaryFile file(ON::on_read3dm,fp);
     if (!file.Read3dmStartSection(&fv, mSC)) return 0;
     if (!file.Read3dmProperties(mprop)) return 0;
     return 1;

Modified: brlcad/trunk/src/librt/primitives/brep/brep.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/brep/brep.cpp     2020-09-14 00:57:56 UTC 
(rev 77136)
+++ brlcad/trunk/src/librt/primitives/brep/brep.cpp     2020-09-14 03:31:11 UTC 
(rev 77137)
@@ -2140,13 +2140,13 @@
 
 
 RT_MemoryArchive::RT_MemoryArchive()
-    : ON_BinaryArchive(ON::write3dm), pos(0), m_buffer()
+    : ON_BinaryArchive(ON::on_write3dm), pos(0), m_buffer()
 {
 }
 
 
 RT_MemoryArchive::RT_MemoryArchive(const void *memory, size_t len)
-    : ON_BinaryArchive(ON::read3dm), pos(0),
+    : ON_BinaryArchive(ON::on_read3dm), pos(0),
       m_buffer((char *)memory, (char *)memory + len)
 {
 }

Modified: brlcad/trunk/src/other/openNURBS/example_read/example_read.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/example_read/example_read.cpp      
2020-09-14 00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/example_read/example_read.cpp      
2020-09-14 03:31:11 UTC (rev 77137)
@@ -42,7 +42,7 @@
     return false;
   }
 
-  ON_BinaryFile file( ON::read3dm, fp );
+  ON_BinaryFile file( ON::on_read3dm, fp );
 
   int version = 0;
   ON_String comment_block;
@@ -101,7 +101,7 @@
   dump.PushIndent();
 
   // create achive object from file pointer
-  ON_BinaryFile archive( ON::read3dm, archive_fp );
+  ON_BinaryFile archive( ON::on_read3dm, archive_fp );
 
   // read the contents of the file into "model"
   bool rc = model.Read( archive, &dump );

Modified: 
brlcad/trunk/src/other/openNURBS/example_roundtrip/example_roundtrip.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/example_roundtrip/example_roundtrip.cpp    
2020-09-14 00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/example_roundtrip/example_roundtrip.cpp    
2020-09-14 03:31:11 UTC (rev 77137)
@@ -66,7 +66,7 @@
     dump->PushIndent();
 
     // create achive object from file pointer
-    ON_BinaryFile archive( ON::read3dm, archive_fp );
+    ON_BinaryFile archive( ON::on_read3dm, archive_fp );
 
     // read the contents of the file into "model"
     bool rc = model.Read( archive, dump );

Modified: brlcad/trunk/src/other/openNURBS/example_write/example_write.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/example_write/example_write.cpp    
2020-09-14 00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/example_write/example_write.cpp    
2020-09-14 03:31:11 UTC (rev 77137)
@@ -131,7 +131,7 @@
   }
 
   // archive to write to
-  ON_BinaryFile archive( ON::write3dm, fp );
+  ON_BinaryFile archive( ON::on_write3dm, fp );
 
   // Set uuid's, indices, etc.
   model.Polish();
@@ -254,7 +254,7 @@
     mo.m_attributes.m_name = "last point";
   }
 
-  ON_BinaryFile archive( ON::write3dm, fp ); // fp = pointer from 
fopoen(...,"wb")
+  ON_BinaryFile archive( ON::on_write3dm, fp ); // fp = pointer from 
fopoen(...,"wb")
 
   // start section comment
   const char* sStartSectionComment = __FILE__ "write_points_example()" 
__DATE__;
@@ -394,7 +394,7 @@
   // start section comments
   const char* sStartSectionComment = __FILE__ "write_curves_example()" 
__DATE__;
 
-  ON_BinaryFile archive( ON::write3dm, fp ); // fp = pointer from 
fopoen(...,"wb")
+  ON_BinaryFile archive( ON::on_write3dm, fp ); // fp = pointer from 
fopoen(...,"wb")
 
   // Set uuid's, indices, etc.
   model.Polish();
@@ -471,7 +471,7 @@
   bool ok = false;
   if ( nurbs_surface.IsValid() ) 
   {
-    ON_BinaryFile archive( ON::write3dm, fp );
+    ON_BinaryFile archive( ON::on_write3dm, fp );
     ok = ON_WriteOneObjectArchive( archive, version, nurbs_surface );
   }
 
@@ -569,7 +569,7 @@
     // them by averaging face normals.
     if ( !mesh.HasVertexNormals() )
       mesh.ComputeVertexNormals();
-    ON_BinaryFile archive( ON::write3dm, fp );
+    ON_BinaryFile archive( ON::on_write3dm, fp );
     ok = ON_WriteOneObjectArchive( archive, version, mesh );
   }
 
@@ -1166,7 +1166,7 @@
   bool ok = false;
   if ( brep.IsValid( &error_log ) )
   {
-    ON_BinaryFile archive(ON::write3dm,fp);
+    ON_BinaryFile archive(ON::on_write3dm,fp);
     ok = ON_WriteOneObjectArchive( archive, version, brep );
   }
   

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_archive.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_archive.cpp      2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_archive.cpp      2020-09-14 
03:31:11 UTC (rev 77137)
@@ -581,13 +581,13 @@
 bool
 ON_BinaryArchive::ReadMode() const
 {
-  return (m_mode & ON::read) ? true : false;
+  return (m_mode & ON::on_read) ? true : false;
 }
 
 bool
 ON_BinaryArchive::WriteMode() const
 {
-  return (m_mode & ON::write) ? true : false;
+  return (m_mode & ON::on_write) ? true : false;
 }
 
 bool
@@ -7659,7 +7659,7 @@
 
   int layer_index = -1;
 
-  if (    ON::read3dm == m_mode
+  if (    ON::on_read3dm == m_mode
        && 0 == m_3dm_opennurbs_version
        && 1 == m_3dm_version
        && 0 != m_V1_layer_list
@@ -7784,7 +7784,7 @@
   }
   else if (rc && layer)
   {
-    if (    ON::read3dm == m_mode
+    if (    ON::on_read3dm == m_mode
          && 0 == m_3dm_opennurbs_version
          && 1 == m_3dm_version
          )
@@ -13128,7 +13128,7 @@
                && 0 == m_3dm_start_section_offset
                && ON_BinaryArchive::no_active_table == m_active_table
                && 0 == m_chunk
-               && ON::read3dm == m_mode
+               && ON::on_read3dm == m_mode
                )
           {
             // In Read3dmStartSection(), we search for the string 
@@ -14719,7 +14719,7 @@
           int archive_3dm_version,
           int archive_opennurbs_version
           )
-: ON_BinaryArchive(ON::read3dm)
+: ON_BinaryArchive(ON::on_read3dm)
 , m_p(0)
 , m_buffer(0)
 , m_sizeof_buffer(0)
@@ -14854,7 +14854,7 @@
           int archive_3dm_version,
           int archive_opennurbs_version
           )
-: ON_BinaryArchive(ON::write3dm)
+: ON_BinaryArchive(ON::on_write3dm)
 , m_p(0)
 , m_buffer(0)
 , m_sizeof_buffer(0)

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_archive.h
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_archive.h        2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_archive.h        2020-09-14 
03:31:11 UTC (rev 77137)
@@ -2680,7 +2680,7 @@
   // compressed buffer I/O uses zlib 1.1.3 inflate()/deflate()
   struct
   {
-    ON::archive_mode mode; // ON::read = read and inflate,  ON::write = 
deflate and write
+    ON::archive_mode mode; // ON::on_read = read and inflate,  ON::on_write = 
deflate and write
     enum
     {
       sizeof_x_buffer = 16384
@@ -3065,7 +3065,7 @@
 
           const char* filename = "myfile.3dm";
           FILE* fp = ON::OpenFile( filename, "wb" );
-          ON_BinaryFile file( fp, ON::write3dm );
+          ON_BinaryFile file( fp, ON::on_write3dm );
           ON_BOOL32 ok = ON_WriteArchive( archive, geometry );
           ON::CloseFile( fp );
 

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_defines.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_defines.cpp      2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_defines.cpp      2020-09-14 
03:31:11 UTC (rev 77137)
@@ -1694,13 +1694,13 @@
 ON::archive_mode ON::ArchiveMode(int i)
 {
   // convert integer to endian enum
-  archive_mode a = read;
+  archive_mode a = on_read;
   switch(i) {
-  case read:      a = read; break;
-  case write:     a = write; break;
-  case readwrite: a = readwrite; break;
-  case read3dm:   a = read3dm; break;
-  case write3dm:  a = write3dm; break;
+  case on_read:      a = on_read; break;
+  case on_write:     a = on_write; break;
+  case on_readwrite: a = on_readwrite; break;
+  case on_read3dm:   a = on_read3dm; break;
+  case on_write3dm:  a = on_write3dm; break;
   }
   return a;
 }

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_defines.h
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_defines.h        2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_defines.h        2020-09-14 
03:31:11 UTC (rev 77137)
@@ -815,11 +815,11 @@
   enum archive_mode
   {
     unknown_archive_mode = 0,
-    read      = 1, // all read modes have bit 0x0001 set
-    write     = 2, // all write modes have bit 0x0002 set
-    readwrite = 3,
-    read3dm   = 5,
-    write3dm  = 6
+    on_read      = 1, // all read modes have bit 0x0001 set
+    on_write     = 2, // all write modes have bit 0x0002 set
+    on_readwrite = 3,
+    on_read3dm   = 5,
+    on_write3dm  = 6
   };
   static archive_mode ArchiveMode(int); // convert integer to endian enum
 

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_extensions.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_extensions.cpp   2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_extensions.cpp   2020-09-14 
03:31:11 UTC (rev 77137)
@@ -2130,7 +2130,7 @@
     FILE* fp = ON::OpenFile(filename,"rb");
     if ( 0 != fp )
     {
-      ON_BinaryFile file(ON::read3dm,fp);
+      ON_BinaryFile file(ON::on_read3dm,fp);
       rc = Read(file,error_log);
       ON::CloseFile(fp);
     }
@@ -2150,7 +2150,7 @@
     FILE* fp = ON::OpenFile(filename,L"rb");
     if ( 0 != fp )
     {
-      ON_BinaryFile file(ON::read3dm,fp);
+      ON_BinaryFile file(ON::on_read3dm,fp);
       rc = Read(file,error_log);
       ON::CloseFile(fp);
     }
@@ -3001,7 +3001,7 @@
     FILE* fp = ON::OpenFile( filename, "wb" );
     if ( 0 != fp )
     {
-      ON_BinaryFile file( ON::write3dm, fp );
+      ON_BinaryFile file( ON::on_write3dm, fp );
       ONX_Model_WriteHelper(file);
       rc = Write( file, version, sStartSectionComment, error_log );
       ON::CloseFile(fp);
@@ -3023,7 +3023,7 @@
     FILE* fp = ON::OpenFile( filename, L"wb" );
     if ( 0 != fp )
     {
-      ON_BinaryFile file( ON::write3dm, fp );
+      ON_BinaryFile file( ON::on_write3dm, fp );
       ONX_Model_WriteHelper(file);
       rc = Write( file, version, sStartSectionComment, error_log );
       ON::CloseFile(fp);
@@ -3066,9 +3066,9 @@
 
   if ( !archive.WriteMode() )
   {
-    // You passed in a bogus archive.  You must pass ON::write3dm to the
+    // You passed in a bogus archive.  You must pass ON::on_write3dm to the
     // archive constructor.
-    if ( error_log) error_log->Print("ONX_Model::Write archive.Mode() is not 
ON::write3dm.\n"
+    if ( error_log) error_log->Print("ONX_Model::Write archive.Mode() is not 
ON::on_write3dm.\n"
                     "See ONX_Model::Write example in the header file.\n");
     return false;
   }
@@ -3079,10 +3079,10 @@
   ok = archive.Write3dmStartSection( version, m_sStartSectionComments );
   if ( !ok )
   {
-    // make sure your archive was created with ON::write3dm mode.
+    // make sure your archive was created with ON::on_write3dm mode.
     if ( error_log) error_log->Print("ONX_Model::Write 
archive.Write3dmStartSection() failed.\n"
                     "Your archive is not properly initialized\n"
-                    "(make sure you passed ON::write3dm to the constructor),\n"
+                    "(make sure you passed ON::on_write3dm to the 
constructor),\n"
                     "a file is locked, a disk is locked, or something along 
those lines.\n");
     return false;
   }

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_extensions.h
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_extensions.h     2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_extensions.h     2020-09-14 
03:31:11 UTC (rev 77137)
@@ -237,7 +237,7 @@
 
             if ( 0 != fp )
             {
-              ON_BinaryFile archive( ON::read3dm, fp );
+              ON_BinaryFile archive( ON::on_read3dm, fp );
               bModelRead = model.read( archive, error_log );
               ON::CloseFile( fp );
             }
@@ -334,7 +334,7 @@
               {
                 const char* sStartSectionComment = "...";
                 int version = 5; // 2, 3, 4 or 5 are valid
-                ON_BinaryFile archive( ON::write3dm, fp );
+                ON_BinaryFile archive( ON::on_write3dm, fp );
                 ok = model.write( archive, 
                                   version, 
                                   sStartSectionComment, 

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_string.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_string.cpp       2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_string.cpp       2020-09-14 
03:31:11 UTC (rev 77137)
@@ -1525,7 +1525,7 @@
   int version = 0;
   if ( 0 != fp )
   {
-    ON_BinaryFile archive(ON::read3dm,fp);
+    ON_BinaryFile archive(ON::on_read3dm,fp);
     if ( !archive.Read3dmStartSection(&version,sStartSectionComment) )
       version = 0;
   }

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_userdata.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_userdata.cpp     2020-09-14 
00:57:56 UTC (rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_userdata.cpp     2020-09-14 
03:31:11 UTC (rev 77137)
@@ -394,7 +394,7 @@
   size_t m_buffer_position;
 };
 
-ON_UnknownUserDataArchive::ON_UnknownUserDataArchive( const 
ON_UnknownUserData& ud ) : ON_BinaryArchive( ON::read3dm )
+ON_UnknownUserDataArchive::ON_UnknownUserDataArchive( const 
ON_UnknownUserData& ud ) : ON_BinaryArchive( ON::on_read3dm )
 {
   SetArchive3dmVersion(ud.m_3dm_version);
   m_sizeof_buffer = ud.m_sizeof_buffer;

Modified: brlcad/trunk/src/other/openNURBS/opennurbs_zlib.cpp
===================================================================
--- brlcad/trunk/src/other/openNURBS/opennurbs_zlib.cpp 2020-09-14 00:57:56 UTC 
(rev 77136)
+++ brlcad/trunk/src/other/openNURBS/opennurbs_zlib.cpp 2020-09-14 03:31:11 UTC 
(rev 77137)
@@ -525,11 +525,11 @@
   // inflateInit() and deflateInit() are in zlib 1.3.3
   bool rc = false;
   if ( WriteMode() ) {
-    rc = ( m_zlib.mode == ON::write ) ? true : false;
+    rc = ( m_zlib.mode == ON::on_write ) ? true : false;
     if ( !rc ) {
       CompressionEnd();
       if ( Z_OK == deflateInit( &m_zlib.strm, Z_BEST_COMPRESSION ) ) {
-        m_zlib.mode = ON::write;
+        m_zlib.mode = ON::on_write;
         rc = true;
       }
       else {
@@ -538,11 +538,11 @@
     }
   }
   else if ( ReadMode() ) {
-    rc = ( m_zlib.mode == ON::read ) ? true : false;
+    rc = ( m_zlib.mode == ON::on_read ) ? true : false;
     if ( !rc ) {
       CompressionEnd();
       if ( Z_OK == inflateInit( &m_zlib.strm ) ) {
-        m_zlib.mode = ON::read;
+        m_zlib.mode = ON::on_read;
         rc = true;
       }
       else {
@@ -560,12 +560,12 @@
 {
   // inflateEnd() and deflateEnd() are in zlib 1.3.3
   switch ( m_zlib.mode ) {
-  case ON::read:
-  case ON::read3dm:
+  case ON::on_read:
+  case ON::on_read3dm:
     inflateEnd(&m_zlib.strm);
     break;
-  case ON::write:
-  case ON::write3dm:
+  case ON::on_write:
+  case ON::on_write3dm:
     deflateEnd(&m_zlib.strm);
     break;
   default: // to quiet lint

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to