use new loadBitstreamBuffer function to return voxel data to requesting agent

This commit is contained in:
Stephen Birarda 2013-03-18 13:23:21 -07:00
parent 807377ef97
commit 6e9fa80966

View file

@ -188,61 +188,37 @@ int main(int argc, const char * argv[])
// create an octal code buffer and load it with 0 so that the recursive tree fill can give
// octal codes to the tree nodes that it is creating
randomlyFillVoxelTree(MAX_VOXEL_TREE_DEPTH_LEVELS, randomTree.rootNode);
char *voxelPacket = new char[MAX_VOXEL_PACKET_SIZE];
char *voxelPacketEnd;
// returned unsigned char * is end of last write to bitstream
int packetCount = 0;
unsigned char *stopOctal = randomTree.rootNode->octalCode;
while (true) {
voxelPacketEnd = voxelPacket;
stopOctal = randomTree.loadBitstreamBuffer(voxelPacketEnd, stopOctal, randomTree.rootNode);
printf("Packet %d is %ld bytes\n", ++packetCount, voxelPacketEnd - voxelPacket);
if (stopOctal == NULL) {
break;
}
}
unsigned char *stopOctal;
int packetCount;
sockaddr_in agentPublicAddress;
char *packetData = new char[MAX_PACKET_SIZE];
ssize_t receivedBytes;
int sentVoxels = 0;
// loop to send to agents requesting data
// while (true) {
// if (agentList.getAgentSocket().receive((sockaddr *)&agentPublicAddress, packetData, &receivedBytes)) {
// if (packetData[0] == 'I') {
// printf("Sending voxels to agent at address %s\n", inet_ntoa(agentPublicAddress.sin_addr));
//
// // send the bitstream to the client
// for (int i = 1; i < MAX_VOXEL_BITSTREAM_BYTES / MAX_PACKET_SIZE; i++) {
// if (packetSplitsPtrs[i] == NULL) {
// // no more split pointers to read, break out
// break;
// }
//
// // figure out the number of bytes in this packet
// int thisPacketBytes = packetSplitsPtrs[i] - packetSplitsPtrs[i - 1];
//
// agentList.getAgentSocket().send((sockaddr *)&agentPublicAddress,
// packetSplitsPtrs[i - 1],
// thisPacketBytes);
//
//
// // output the bits in each byte of this packet
// for (int j = 0; j < thisPacketBytes; j++) {
// outputBits(*(packetSplitsPtrs[i - 1] + j));
// }
// }
// }
// }
// }
while (true) {
if (agentList.getAgentSocket().receive((sockaddr *)&agentPublicAddress, packetData, &receivedBytes)) {
if (packetData[0] == 'I') {
stopOctal = randomTree.rootNode->octalCode;
packetCount = 0;
while (stopOctal != NULL) {
voxelPacketEnd = voxelPacket;
stopOctal = randomTree.loadBitstreamBuffer(voxelPacketEnd, stopOctal, randomTree.rootNode);
printf("Packet %d sent to agent at address %s is %ld bytes\n",
++packetCount,
inet_ntoa(agentPublicAddress.sin_addr),
voxelPacketEnd - voxelPacket);
}
}
}
}
pthread_join(reportAliveThread, NULL);