[cgma-dev] r5024 - cgm/trunk/geom/OCC

hongjun at mcs.anl.gov hongjun at mcs.anl.gov
Mon Jun 20 12:22:03 CDT 2011


Author: hongjun
Date: 2011-06-20 12:22:00 -0500 (Mon, 20 Jun 2011)
New Revision: 5024

Modified:
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
Log:
o "read" and "write" from/to buffer functions are reverted to use buffers directly
o passes make check


Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2011-06-17 20:29:32 UTC (rev 5023)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2011-06-20 17:22:00 UTC (rev 5024)
@@ -1366,29 +1366,26 @@
 				   bool b_write_buffer,
                                    TDF_Label label)
 {
-  Standard_CString file_name = "tempfile";
-  if(!Write(Sh, const_cast<char*>(file_name),label))
-      return CUBIT_FAILURE; 
+  // make buffer as ouput stream
+  std::stringbuf sb;
+  std::iostream os(&sb);
+  OCCShapeAttributeSet SS;
+  
+  // write to output stream
+  SS.Add(Sh);
+  os << "DBRep_DrawableShape\n";  // for easy Draw read
+  SS.Write(os);
+  CubitBoolean isGood = os.good();
+  if (!isGood) return isGood;
+  SS.Write(Sh,os,&label);
+  isGood = os.good();
+  if (!isGood) return isGood;
+  
+  n_buffer_size = os.rdbuf()->pubseekoff(0, std::ios_base::end, std::ios::out);
 
-  // get size of file
-  ifstream infile (file_name, ifstream::binary);
-  infile.seekg(0,ifstream::end);
-  long size=infile.tellg();
-  infile.seekg(0);
-
-  if (b_write_buffer) {
-    if(n_buffer_size < size) {
-      PRINT_ERROR("Buffer size is not enough, increase buffer size.\n");
-      infile.close();
-      remove(file_name);
-      return CUBIT_FAILURE;
-    }
-    infile.read(pBuffer,size);
-  }
-  else n_buffer_size = size;
-
-  infile.close();
-  remove(file_name);
+  // get real geometries from output stream to buffer
+  if (b_write_buffer) os.read(pBuffer, n_buffer_size);
+  
   return CUBIT_TRUE;


More information about the cgma-dev mailing list