void avtTraceHistoryFilter::Execute(void) { // // Write out the connectivity. "-1" is the hint to do that. // OutputTime(GetTypedInput(), -1); // // Pull out just the points. // avtDataset_p ds = InitializeDataset(); // // Put the fields from the current time step on the points and then // output those fields. // PerformIteration(0, ds, false); OutputTime(ds, 0); // // Now iterate through the time slices, displacing and evaluating. // for (int i = 0 ; i < atts.GetNumiter() ; i++) { ds->SetSource(GetInput()->GetSource()); PerformIteration(i, ds, true); OutputTime(ds, i+1); } // The operator just passes the data through. GetDataTree() = GetInputDataTree(); }
int PHS_FULL(void *out, size_t outlen, const void *in, size_t inlen, const void *salt, size_t saltlen, uint32_t t_cost, uint32_t m_cost) { uint32_t i, ret = SUCCESS; if (t_cost < 1) return ERROR_TIME_LESS; if (m_cost < 1) return ERROR_COST_LESS; if (m_cost > 31) return ERROR_COST_MORE; if ((saltlen > 256) || (saltlen < 0)) return ERROR_SALTLEN_INVALID; uint8_t* alpha = (uint8_t *)malloc(H_BYTES_OUT); size_t alphaDataLength = getAlphaDataLength(inlen, saltlen); uint8_t* alphaData = (uint8_t *)malloc(alphaDataLength); PrepareAlphaData((uint8_t*)in, inlen, (uint8_t*)salt, saltlen, t_cost, (outlen * 8), alphaData); HASH_INPUT(alphaData, alphaDataLength, alpha); free(alphaData); uint64_t __M = ((uint64_t)1 << m_cost); uint8_t* ChainingValue = (uint8_t*)malloc(H_BYTES_OUT); memcpy(ChainingValue, alpha, H_BYTES_OUT); // TODO: The large mallocs in the lines below may fail if there isn't enough memory. // Need to put a alloc-check. HashData* KeySet = (HashData*)malloc((size_t)(H_BYTES_KS * __M)); AlphaData* AlphaSet = (AlphaData*)malloc((size_t)(H_BYTES_OUT * __M)); uint64_t Count = 0; uint64_t M = ((uint64_t)1 << m_cost); ret = PerformSetupPhase(ChainingValue, AlphaSet, KeySet, M, &Count); if (ret != SUCCESS) return ret; for (i = 0; i < t_cost; i++) { ret = PerformIteration(AlphaSet, KeySet, ChainingValue, M, m_cost, &Count, i); if (ret != SUCCESS) return ret; } uint8_t CNT[CNT_BYTES]; LongToBytes(++Count, CNT); uint8_t _M[CNT_BYTES]; LongToBytes(M, _M); uint8_t *H3_in = (uint8_t *)malloc(CNT_BYTES * 2 + H_BYTES_OUT + saltlen); memcpy(H3_in, CNT, CNT_BYTES); memcpy(H3_in + CNT_BYTES, ChainingValue, H_BYTES_OUT); memcpy(H3_in + CNT_BYTES + H_BYTES_OUT, salt, saltlen); memcpy(H3_in + CNT_BYTES + H_BYTES_OUT + saltlen, _M, CNT_BYTES); uint8_t H3_Out[H3_BYTES_OUT]; HASH_OUTPUT(H3_in, CNT_BYTES * 2 + H_BYTES_OUT + saltlen, H3_Out); free(H3_in); free(KeySet); free(AlphaSet); free(ChainingValue); free(alpha); if (outlen <= H3_BYTES_OUT) { for (i = 0; i < outlen; i++) { ((uint8_t*)out)[i] = H3_Out[i]; } } else { return ERROR_INVALID_OUT_HLEN; } return SUCCESS; }
// must be critical cell void BSPOctree::PerformIteration(PolygonPtrList& mesh1, PolygonPtrList& mesh2 , Box3& bbox, OctTreeNode **node) { if ((mesh1.size() + mesh2.size()) < 17) { PerformBoolean(mesh1, mesh2, bbox, node); return; } Box3 childBBox[8]; bool bCriticalCells[8]; memset(bCriticalCells, 0 , 8); SplitSpaceByXYZ(bbox, childBBox); DetermineCriticalCell(childBBox, bCriticalCells); PolygonPtrList XYZSplits1[8], XYZSplits2[8]; for (auto index: mesh1) { auto &pos = mMesh1[index].Position; for (int i = 0; i < 8; i++) { //if (!bCriticalCells[i]) continue; if (TestTriangleAABBOverlap(pos[0], pos[1], pos[2], childBBox[i])) { XYZSplits1[i].push_back(index); } } } for (auto index: mesh2) { auto &pos = mMesh2[index].Position; for (int i = 0; i < 8; i++) { //if (!bCriticalCells[i]) continue; if (TestTriangleAABBOverlap(pos[0], pos[1], pos[2], childBBox[i])) { XYZSplits2[i].push_back(index); } } } // for containment test, jxd auto &pNode = *node; pNode = new OctTreeNode; pNode->bbox = bbox; pNode->type = eIntered; // end for (int i = 0; i < 8; i++) { if (!bCriticalCells[i])/* continue;*/ { // for containment test, jxd OctLeafNode *pLeaf = new OctLeafNode; pLeaf->bbox = childBBox[i]; pLeaf->type = eNormal; FillOctreeLeafNode(XYZSplits1[i], XYZSplits2[i], pLeaf); pNode->child[i] = pLeaf; // end } else { if (XYZSplits1[i].size()*XYZSplits2[i].size() == 0) { // for containment test, jxd OctLeafNode *pLeaf = new OctLeafNode; pLeaf->bbox = childBBox[i]; pLeaf->type = eCritical; FillOctreeLeafNode(XYZSplits1[i], XYZSplits2[i], pLeaf); pNode->child[i] = pLeaf; // end } else PerformIteration(XYZSplits1[i], XYZSplits2[i], childBBox[i], &(pNode->child[i])); } } }
void BSPOctree::BSPOperation(BaseMesh *mesh1, BaseMesh *mesh2, BaseMesh** output) { Box3 bbox = mesh1->AABB(); bbox.IncludeBox(mesh2->AABB()); NormalMesh *myMesh1 = new NormalMesh(mesh1), *myMesh2; if (FixedBSPTree::OP_DIFFERENCE == mOperation) myMesh2 = new NormalMesh(mesh2, NormalMesh::PARA_NEGATE); else myMesh2 = new NormalMesh(mesh2); myMesh1->NormalizeCoord(&bbox); myMesh1->FilterVertex(11); myMesh2->NormalizeCoord(&bbox); myMesh2->FilterVertex(11); normalizeBox3(mesh1->AABB(), bbox, mAABB1); normalizeBox3(mesh2->AABB(), bbox, mAABB2); staticFilterP(mAABB1, 11); staticFilterP(mAABB2, 11); auto t0 = clock(); // initialize the para of the first cell PolygonPtrList pool1, pool2; GSOutputTimeLog(L"init: "); auto &ver1 = myMesh1->Vertex(); auto &tri1 = myMesh1->Triangle(); int i = 0; for (auto &titr: tri1) { mMesh1.emplace_back(ver1[titr[0]], ver1[titr[1]], ver1[titr[2]]); mMesh1.back().index = i; mMesh1.back().mpMesh = mesh1; mMesh1.back().mTriId = i; pool1.push_back(i++); } delete myMesh1; auto &ver2 = myMesh2->Vertex(); auto &tri2 = myMesh2->Triangle(); i = 0; for (auto &titr: tri2) { mMesh2.emplace_back(ver2[titr[0]], ver2[titr[1]], ver2[titr[2]]); mMesh2.back().mpMesh = mesh2; mMesh2.back().mTriId = i; pool2.push_back(i++); } delete myMesh2; for (auto &meshe: mMesh1) meshe.pMeshData = &meshe; for (auto &meshe: mMesh2) meshe.pMeshData = &meshe; Box3 initBox(Box3::BOX_MIRROR_SCALE); mesh1->NormalizeCoord(&bbox); mesh2->NormalizeCoord(&bbox); GSOutputTimeLog(L"start Iteration: "); PerformIteration(pool1, pool2, initBox, &mpRoot); if (*output) delete *output; auto &outputPtr = *output; GSOutputTimeLog(L"end Iteration: "); outputPtr = CollectPolygons(mesh1, mesh2); GSOutputTimeLog(L"end collection: "); mesh1->DenormalizeCoord(); mesh2->DenormalizeCoord(); outputPtr->DenormalizeCoord(&bbox); outputPtr->GenAABB(false); auto t1 = clock(); long t = t1-t0; wchar_t ch[32]; wsprintf(ch, L"time: %d\n", t); WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), ch, wcslen(ch), 0, 0); }