using namespace HDK_Sample;
void
{
}
{
}
GAS_NetVDBSliceExchange::~GAS_NetVDBSliceExchange()
{
}
GAS_NetVDBSliceExchange::getDopDescription()
{
static PRM_Default theGeometryNameDefault(0,
"Geometry");
static PRM_Name theVDBName(
"vdbname",
"VDB Names");
static PRM_Name theThisSliceName(
"slice",
"Slice Number");
static PRM_Name theSliceRootName(
"sliceroot",
"Slice Data Root");
static PRM_Name theOverlapName(
"overlap",
"Slice Overlap");
static PRM_Name theOverlapVoxelName(
"overlapvoxel",
"Voxel Overlap");
};
"hdk_gasnetvdbsliceexchange",
"Gas Net VDB Slice Exchange",
"$OS",
classname(),
theTemplates);
return &theDopDescription;
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
static void
GASreadDataFromPacket(openvdb::math::Vec3<float> &value,
UT_NetMessage *msg,
exint offset)
{
}
static void
GASreadDataFromPacket(openvdb::math::Vec3<double> &value,
UT_NetMessage *msg,
exint offset)
{
}
static void
GASreadDataFromPacket(openvdb::math::Vec3<int32> &value,
UT_NetMessage *msg,
exint offset)
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
template <typename GridType>
void
{
typename GridType::Accessor acc = grid.getAccessor();
for (
exint reply = 0; reply < numreply; reply++)
{
if (replyoff >= msg->
length())
{
std::cerr <<
"Malformed reply from " << srcpeer <<
", total replies " << numreply <<
" exhausted message packet sized " << msg->
length() << std::endl;
return;
}
if (magictoken != 0x51DEEFC5)
{
std::cerr << "Malformed reply from " << srcpeer << ", total replies " << numreply << " missing magic token on packet " << reply << " at offset " << replyoff << std::endl;
return;
}
char nodemask[64];
for (int nm = 0; nm < 64; nm++)
replyoff += 16 + 64;
int nodemaskpos = 0;
for (
int x = 0;
x < 8;
x++)
{
for (
int y = 0;
y < 8;
y++)
{
int flag = 1;
for (
int z = 0;
z < 8;
z++)
{
if (nodemask[nodemaskpos] & flag)
{
GASreadDataFromPacket(v, msg, replyoff+nodeoff);
openvdb::Coord coord(minvxl.
x() +
x, minvxl.
y() +
y, minvxl.
z() +
z);
acc.setValueOn(coord, v);
}
flag += flag;
}
nodemaskpos++;
}
}
replyoff += nodeoff;
}
}
void
{
solver, obj, msg);
}
template <typename GridType>
void
{
typename GridType::Accessor acc = grid.getAccessor();
for (int i = 0; i < numslice; i++)
{
if (i != thisslice)
{
msgs(i)->setWriteDataLength(8 + 8);
}
}
packetvoxeloffset.
setSize(numslice);
packetvoxelvalue.
setSize(numslice);
for (auto it = grid.tree().beginLeaf(); it; ++it)
{
auto vdb_box = it->getNodeBoundingBox();
tstart.
assign(vdb_box.min().x()-0.5, vdb_box.min().y()-0.5, vdb_box.min().z()-0.5);
tend.
assign(vdb_box.max().x()+0.5, vdb_box.max().y()+0.5, vdb_box.max().z()+0.5);
tbbox_expand = tbbox;
{
continue;
}
{
for (int i = vdb_box.min().x(); i <= vdb_box.max().x(); i++)
for (
int j = vdb_box.min().y();
j <= vdb_box.max().y();
j++)
for (int k = vdb_box.min().z(); k <= vdb_box.max().z(); k++)
acc.setValueOff(openvdb::Coord(i,
j, k), background);
continue;
}
for (int slice = 0; slice < numslice; slice++)
{
packetvoxeloffset(slice).
entries(0);
packetvoxelvalue(slice).
entries(0);
}
int offset = 0;
for (int i = vdb_box.min().x(); i <= vdb_box.max().x(); i++)
for (
int j = vdb_box.min().y();
j <= vdb_box.max().y();
j++)
for (int k = vdb_box.min().z(); k <= vdb_box.max().z(); k++)
{
{
acc.setValueOff(openvdb::Coord(i,
j, k), background);
}
else
{
for (int slice = 0; slice < numslice; slice++)
{
if (slice == thisslice)
continue;
{
packetvoxeloffset(slice).
append( offset );
packetvoxelvalue(slice).
append( acc.getValue(openvdb::Coord(i,
j, k)) );
}
}
}
offset++;
}
for (int slice = 0; slice < numslice; slice++)
{
if (slice == thisslice)
continue;
if (packetvoxeloffset(slice).
entries() == 0)
continue;
auto && msg = msgs(slice);
exint msgoffset = msgoffsets(slice);
msgpackets(slice)++;
msgoffset += 16;
char nodemask[64];
memset(nodemask, 0, 64);
for (auto && offset : packetvoxeloffset(slice))
{
nodemask[offset >> 3] |= 1 << (offset & 7);
}
for (int nm = 0; nm < 64; nm++)
msgoffset += 64;
for (auto && value : packetvoxelvalue(slice))
{
GASwriteDataToPacket(msg, msgoffset, value);
msgoffset +=
sizeof(
value);
}
msgoffsets(slice) = msgoffset;
}
}
for (int slice = 0; slice < numslice; slice++)
{
if (slice == thisslice)
continue;
msgs(slice)->overwriteInt32(8, msgpackets(slice));
}
}
void
{
msgs,
solver, obj,
overlap, thisslice, slicetable);
}
void
const char *tracker, int port, const char *jobname,
{
if (nslice <= 1)
return;
fpreal overlap = solver->getOverlap();
solver, obj,
overlap,
thisslice, slicetable);
for (int slice = 0; slice < nslice; slice++)
{
if (slice == thisslice)
continue;
netxchg.sendData(slice, dispatchmsgs(slice));
}
netxchg.receiveDataLoop(completed, nslice -1);
for (
int i = 0; i < completed.
entries(); i++)
{
delete msg;
}
}
bool
{
int port;
port = getTrackerPort();
getTrackerAddress(address);
getJobName(jobname);
return true;
exint slice = getSlice();
getSliceRoot(sliceroot);
if (numslice <= 1)
{
return true;
}
if (!geometry)
return true;
getVDBName(vdbname);
for (auto && prim : namedprims)
{
{
if (!name_h.isValid())
else
namelist.
append(name_h.get(prim->getMapOffset()));
}
}
return true;
{
exchangename.
sprintf(
"%s_verifyvdblist", (
const char *) jobname);
if (slice != 0)
{
for (
int i = 0; i < vdblist.
entries(); i++)
{
const char *
name = namelist(i);
while (*name)
{
name++;
}
}
netxchg.sendData( 0, msg);
}
netxchg.receiveDataLoop(completed, (!slice ? (numslice-1) : 0) );
if (slice == 0)
{
for (
int i = 0; i < completed.
entries(); i++)
{
{
errormsg.
appendSprintf(
"Mismatch VDB count: Slice 0 has %d; but Slice %d has %d.\n", (
int) vdblist.
entries(), srcslice, numvdb);
delete msg;
continue;
}
int curvdb = 0;
bool ok = true;
while (ok && curvdb < numvdb && msgoff < msg->
length())
{
while (msgoff < msg->
length())
{
if (!c)
break;
}
if (name.
strcmp(namelist(curvdb)))
{
ok = false;
errormsg.
appendSprintf(
"Mismatch VDB name. Vdb #%d has name %s in Slice 0 but %s in Slice %d.\n",
curvdb, (const char *) namelist(curvdb),
}
if (type != typelist(curvdb))
{
ok = false;
errormsg.
appendSprintf(
"Mismatch VDB type. VDB #%d has type %d in Slice 0 but %d in Slice %d.\n",
curvdb, (int) typelist(curvdb),
(int) type, srcslice);
}
curvdb++;
}
if (ok && (curvdb != numvdb))
{
errormsg.
appendSprintf(
"Malformed packet from slice %d; got %d vdbs but expected %d.\n", srcslice, curvdb, numvdb);
}
delete msg;
}
}
else
{
}
}
{
std::cerr <<
"Error: " << errormsg.
buffer() << std::endl;
}
{
exchangename.
sprintf(
"%s_reportvdblist", (
const char *) jobname);
if (slice == 0)
{
for (int dstslice = 1; dstslice < numslice; dstslice++)
{
const char *text = errormsg.
buffer();
while (*text)
{
text++;
}
netxchg.sendData(dstslice, msg);
}
}
netxchg.receiveDataLoop(completed, (slice ? 1 : 0) );
for (
int i = 0; i < completed.
entries(); i++)
{
while (msgoff < msg->
length())
{
if (!c)
break;
}
delete msg;
}
{
return false;
}
}
for (auto && vdb : vdblist)
{
vdb,
address, port, exchangename.
buffer(),
slice, slicetable);
}
return true;
}