Changeset 4830 for nanovis/branches/1.1
- Timestamp:
- Dec 9, 2014 10:32:28 PM (9 years ago)
- Location:
- nanovis/branches/1.1
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.1/Command.cpp
r4829 r4830 1211 1211 } 1212 1212 const char *tag = Tcl_GetString(objv[4]); 1213 Rappture::Buffer buf; 1213 1214 Rappture::Buffer buf(nbytes); 1214 1215 if (GetDataStream(interp, buf, nbytes) != TCL_OK) { 1215 1216 return TCL_ERROR; 1216 1217 } 1217 const char *bytes; 1218 size_t nBytes; 1219 1220 bytes = buf.bytes(); 1221 nBytes = buf.size(); 1218 const char *bytes = buf.bytes(); 1219 size_t nBytes = buf.size(); 1222 1220 1223 1221 TRACE("Checking header[%.20s]", bytes); … … 1227 1225 if ((nBytes > 5) && (strncmp(bytes, "<HDR>", 5) == 0)) { 1228 1226 TRACE("ZincBlende Stream loading..."); 1229 //std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary); 1230 //fdata.write(buf.bytes(),buf.size()); 1231 //vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata); 1232 1233 volume = NvZincBlendeReconstructor::getInstance()->loadFromMemory((void*) buf.bytes()); 1227 volume = NvZincBlendeReconstructor::getInstance()->loadFromMemory(buf.bytes()); 1234 1228 if (volume == NULL) { 1235 1229 Tcl_AppendResult(interp, "can't get volume instance", (char *)NULL); … … 1275 1269 } 1276 1270 TRACE("DX loading..."); 1277 std::stringstream fdata;1278 fdata.write(bytes, nBytes);1279 1271 if (nBytes <= 0) { 1280 1272 ERROR("data buffer is empty"); 1281 1273 abort(); 1282 1274 } 1275 std::stringstream fdata; 1276 fdata.write(bytes, nBytes); 1283 1277 Rappture::Outcome context; 1284 1278 volume = load_dx_volume_stream(context, tag, fdata); … … 1296 1290 volume->visible(true); 1297 1291 1298 char info[1024];1299 ssize_t nWritten;1300 1301 1292 if (Volume::updatePending) { 1302 1293 NanoVis::setVolumeRanges(); 1303 1294 } 1304 1295 1305 // FIXME: strlen(info) is the return value of sprintf 1306 sprintf(info, "nv>data tag %s min %g max %g vmin %g vmax %g\n", tag, 1307 volume->wAxis.min(), volume->wAxis.max(), 1308 Volume::valueMin, Volume::valueMax); 1309 nWritten = write(1, info, strlen(info)); 1310 assert(nWritten == (ssize_t)strlen(info)); 1296 char info[1024]; 1297 int cmdLength = 1298 sprintf(info, "nv>data tag %s min %g max %g vmin %g vmax %g\n", tag, 1299 volume->wAxis.min(), volume->wAxis.max(), 1300 Volume::valueMin, Volume::valueMax); 1301 ssize_t nWritten = write(1, info, (size_t)cmdLength); 1302 if (nWritten != (ssize_t)cmdLength) { 1303 ERROR("Short write"); 1304 return TCL_ERROR; 1305 } 1311 1306 } 1312 1307 return TCL_OK; … … 1709 1704 const char *tag = Tcl_GetString(objv[4]); 1710 1705 1711 Rappture::Buffer buf ;1706 Rappture::Buffer buf(nBytes); 1712 1707 if (GetDataStream(interp, buf, nBytes) != TCL_OK) { 1713 1708 return TCL_ERROR; -
nanovis/branches/1.1/FlowCmd.cpp
r4613 r4830 231 231 return TCL_ERROR; 232 232 } 233 Rappture::Buffer buf ;233 Rappture::Buffer buf(nBytes); 234 234 TRACE("Flow data loading bytes: %d components: %d", nBytes, nComponents); 235 235 if (GetDataStream(interp, buf, nBytes) != TCL_OK) { 236 236 return TCL_ERROR; 237 237 } 238 char *bytes = (char *)buf.bytes(); 239 size_t length = buf.size(); 240 238 241 Rappture::Unirect3d *dataPtr; 239 242 dataPtr = new Rappture::Unirect3d(nComponents); 240 243 241 244 Flow *flow = (Flow *)clientData; 242 size_t length = buf.size();243 char *bytes = (char *)buf.bytes();244 245 if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) { 245 246 if (!dataPtr->importDx(result, nComponents, length - 4, bytes + 4)) { … … 292 293 { 293 294 char info[1024]; 294 ssize_t nWritten; 295 size_t length; 296 297 length = sprintf(info, "nv>data tag %s min %g max %g\n", 298 flow->name(), dataPtr->magMin(), dataPtr->magMax()); 299 nWritten = write(1, info, length); 300 assert(nWritten == (ssize_t)strlen(info)); 295 int length = 296 sprintf(info, "nv>data tag %s min %g max %g\n", 297 flow->name(), dataPtr->magMin(), dataPtr->magMax()); 298 ssize_t nWritten = write(1, info, (size_t)length); 299 if (nWritten != (ssize_t)length) { 300 ERROR("Short write"); 301 return TCL_ERROR; 302 } 301 303 } 302 304 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); -
nanovis/branches/1.1/NvZincBlendeReconstructor.cpp
r3502 r4830 369 369 370 370 ZincBlendeVolume * 371 NvZincBlendeReconstructor::loadFromMemory( void *dataBlock)371 NvZincBlendeReconstructor::loadFromMemory(const void *dataBlock) 372 372 { 373 373 ZincBlendeVolume *volume = NULL; … … 377 377 int version = 1; 378 378 379 unsigned char *stream = (unsigned char *)dataBlock;379 const unsigned char *stream = (const unsigned char *)dataBlock; 380 380 char str[5][20]; 381 381 do { … … 469 469 } 470 470 471 void NvZincBlendeReconstructor::getLine( unsigned char*& stream)471 void NvZincBlendeReconstructor::getLine(const unsigned char*& stream) 472 472 { 473 473 char ch; -
nanovis/branches/1.1/NvZincBlendeReconstructor.h
r3502 r4830 41 41 ZincBlendeVolume *loadFromStream(std::istream& stream); 42 42 43 ZincBlendeVolume *loadFromMemory( void *dataBlock);43 ZincBlendeVolume *loadFromMemory(const void *dataBlock); 44 44 45 45 /** … … 73 73 */ 74 74 void getLine(std::istream& stream); 75 void getLine( unsigned char*& stream);75 void getLine(const unsigned char*& stream); 76 76 77 77 char buff[255];
Note: See TracChangeset
for help on using the changeset viewer.