本文整理汇总了C++中BitArray类的典型用法代码示例。如果您正苦于以下问题:C++ BitArray类的具体用法?C++ BitArray怎么用?C++ BitArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BitArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
Result
RSS14Reader::decodeRow(int rowNumber, const BitArray& row_, std::unique_ptr<DecodingState>& state) const
{
RSS14DecodingState* prevState = nullptr;
if (state == nullptr) {
state.reset(prevState = new RSS14DecodingState);
}
else {
#if !defined(ZX_HAVE_CONFIG)
#error "You need to include ZXConfig.h"
#elif !defined(ZX_NO_RTTI)
prevState = dynamic_cast<RSS14DecodingState*>(state.get());
#else
prevState = static_cast<RSS14DecodingState*>(state.get());
#endif
}
if (prevState == nullptr) {
throw std::runtime_error("Invalid state");
}
BitArray row = row_.copy();
AddOrTally(prevState->possibleLeftPairs, DecodePair(row, false, rowNumber));
row.reverse();
AddOrTally(prevState->possibleRightPairs, DecodePair(row, true, rowNumber));
// row.reverse();
for (const auto& left : prevState->possibleLeftPairs) {
if (left.count() > 1) {
for (const auto& right : prevState->possibleRightPairs) {
if (right.count() > 1) {
if (CheckChecksum(left, right)) {
return ConstructResult(left, right);
}
}
}
}
}
return Result(DecodeStatus::NotFound);
}
示例2: ConvertTriSelection
void VWeldMod::ConvertTriSelection (Mesh & mesh, BitArray & targetVerts) {
targetVerts.SetSize (mesh.numVerts);
targetVerts.ClearAll ();
int i, j;
switch (mesh.selLevel) {
case MESH_OBJECT:
targetVerts.SetAll ();
break;
case MESH_VERTEX:
targetVerts = mesh.vertSel;
break;
case MESH_EDGE:
for (i=0; i<mesh.numFaces; i++) {
for (j=0; j<3; j++) {
if (!mesh.edgeSel[i*3+j]) continue;
targetVerts.Set (mesh.faces[i].v[j]);
targetVerts.Set (mesh.faces[i].v[(j+1)%3]);
}
}
break;
case MESH_FACE:
for (i=0; i<mesh.numFaces; i++) {
if (!mesh.faceSel[i]) continue;
for (j=0; j<3; j++) targetVerts.Set (mesh.faces[i].v[j]);
}
break;
}
}
示例3: GetWorkingArea
void GetWorkingArea(BitArray & working_elements, BitArray & working_points,
const Mesh & mesh, const Array<ElementIndex> & bad_elements,
const int width)
{
working_elements.Clear();
working_points.Clear();
for(int i=0; i<bad_elements.Size(); i++)
{
working_elements.Set(bad_elements[i]);
const Element & el = mesh[bad_elements[i]];
for(int j=1; j<=el.GetNP(); j++)
working_points.Set(el.PNum(j));
}
for(int i=0; i<width; i++)
{
for(ElementIndex j=0; j<mesh.GetNE(); j++)
{
if(!working_elements.Test(j))
{
const Element & el = mesh[j];
bool set_active = false;
for(int k=1; !set_active && k<=el.GetNP(); k++)
set_active = working_points.Test(el.PNum(k));
if(set_active)
working_elements.Set(j);
}
}
for(ElementIndex j=0; j<mesh.GetNE(); j++)
{
if(working_elements.Test(j))
{
const Element & el = mesh[j];
for(int k=1; k<=el.GetNP(); k++)
working_points.Set(el.PNum(k));
}
}
}
}
示例4: DbgAssert
void EditPolyData::GrowSelection (IMeshSelect *imod, int level) {
DbgAssert (mpMesh);
if( !mpMesh ) return;
BitArray newSel;
int mnSelLevel = meshSelLevel[level];
DbgAssert (mpMesh->GetFlag (MN_MESH_FILLED_IN));
if (!mpMesh->GetFlag (MN_MESH_FILLED_IN)) return;
SynchBitArrays();
int i;
switch (mnSelLevel) {
case MNM_SL_VERTEX:
for (i=0; i<mpMesh->numv; i++) mpMesh->v[i].SetFlag (MN_USER, mVertSel[i]!=0);
mpMesh->ClearEFlags (MN_USER);
mpMesh->PropegateComponentFlags (MNM_SL_EDGE, MN_USER, MNM_SL_VERTEX, MN_USER);
newSel.SetSize (mpMesh->numv);
for (i=0; i<mpMesh->nume; i++) {
if (mpMesh->e[i].GetFlag (MN_USER)) {
newSel.Set (mpMesh->e[i].v1);
newSel.Set (mpMesh->e[i].v2);
}
}
SetVertSel (newSel, imod, TimeValue(0));
break;
case MNM_SL_EDGE:
for (i=0; i<mpMesh->nume; i++) mpMesh->e[i].SetFlag (MN_USER, mEdgeSel[i]!=0);
mpMesh->ClearVFlags (MN_USER);
mpMesh->PropegateComponentFlags (MNM_SL_VERTEX, MN_USER, MNM_SL_EDGE, MN_USER);
newSel.SetSize (mpMesh->nume);
for (i=0; i<mpMesh->nume; i++) {
if (mpMesh->v[mpMesh->e[i].v1].GetFlag (MN_USER)
|| mpMesh->v[mpMesh->e[i].v2].GetFlag (MN_USER))
newSel.Set (i);
}
SetEdgeSel (newSel, imod, TimeValue(0));
break;
case MNM_SL_FACE:
for (i=0; i<mpMesh->numf; i++) mpMesh->f[i].SetFlag (MN_USER, mFaceSel[i]!=0);
mpMesh->ClearVFlags (MN_USER);
mpMesh->PropegateComponentFlags (MNM_SL_VERTEX, MN_USER, MNM_SL_FACE, MN_USER);
newSel.SetSize (mpMesh->numf);
for (i=0; i<mpMesh->numf; i++) {
int j;
for (j=0; j<mpMesh->f[i].deg; j++) {
if (mpMesh->v[mpMesh->f[i].vtx[j]].GetFlag (MN_USER)) break;
}
if (j<mpMesh->f[i].deg) newSel.Set (i);
}
SetFaceSel (newSel, imod, TimeValue(0));
break;
}
}
示例5: DecodeAnyAI
std::string
ExpandedBinaryDecoder::Decode(const BitArray& bits)
{
if (bits.get(1)) {
return DecodeAI01AndOtherAIs(bits);
}
if (!bits.get(2)) {
return DecodeAnyAI(bits);
}
int fourBitEncodationMethod = GenericAppIdDecoder::ExtractNumeric(bits, 1, 4);
switch (fourBitEncodationMethod) {
case 4: return DecodeAI013103(bits);
case 5: return DecodeAI01320x(bits);
}
int fiveBitEncodationMethod = GenericAppIdDecoder::ExtractNumeric(bits, 1, 5);
switch (fiveBitEncodationMethod) {
case 12: return DecodeAI01392x(bits);
case 13: return DecodeAI01393x(bits);
}
int sevenBitEncodationMethod = GenericAppIdDecoder::ExtractNumeric(bits, 1, 7);
switch (sevenBitEncodationMethod) {
case 56: return DecodeAI013x0x1x(bits, "310", "11");
case 57: return DecodeAI013x0x1x(bits, "320", "11");
case 58: return DecodeAI013x0x1x(bits, "310", "13");
case 59: return DecodeAI013x0x1x(bits, "320", "13");
case 60: return DecodeAI013x0x1x(bits, "310", "15");
case 61: return DecodeAI013x0x1x(bits, "320", "15");
case 62: return DecodeAI013x0x1x(bits, "310", "17");
case 63: return DecodeAI013x0x1x(bits, "320", "17");
}
return std::string();
//throw new IllegalStateException("unknown decoder: " + information);
}
示例6: Proceed
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//| From IPFTest |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
bool PFTestGoToNextEvent::Proceed(IObject* pCont,
PreciseTimeValue timeStart,
PreciseTimeValue& timeEnd,
Object* pSystem,
INode* pNode,
INode* actionNode,
IPFIntegrator* integrator,
BitArray& testResult,
Tab<float>& testTime)
{
int conditionType = pblock()->GetInt(kGoToNextEvent_conditionType, timeStart);
bool exactStep = IsExactIntegrationStep(timeEnd, pSystem);
// get channel container interface
IChannelContainer* chCont;
chCont = GetChannelContainerInterface(pCont);
if (chCont == NULL) return false;
// acquire absolutely necessary particle channels
IParticleChannelAmountR* chAmount = GetParticleChannelAmountRInterface(pCont);
if (chAmount == NULL) return false; // can't find number of particles in the container
IParticleChannelPTVR* chTime = GetParticleChannelTimeRInterface(pCont);
if (chTime == NULL) return false; // can't read timing info for a particle
int count = chAmount->Count();
if (count <= 0) return true;
testResult.SetSize(count);
testTime.SetCount(count);
if((conditionType == kGoToNextEvent_conditionType_all) && exactStep) {
testResult.SetAll();
for(int i=0; i<count; i++) testTime[i] = 0.0f;
} else {
testResult.ClearAll();
}
return true;
}
示例7: main
int main( int argc, char * argv[] )
{
// proejct abandonded becasue bitset
printf( "%d\n", sizeof( uint8 ) );
BitArray B;
BitArray C( 15 );
// printf( "sizeof(B.m_data) = %d\n", sizeof(B.m_data) );
// printf( "sizeof(*(B.m_data)) = %d\n", sizeof(*(B.m_data)) );
// printf( "sizeof(C.m_data) = %d\n", sizeof(C.m_data) );
// printf( "sizeof(*(C.m_data)) = %d\n", sizeof(*(C.m_data)) );
printf( "%d\n", B.int_size() );
printf( "%d\n", B.bit_size() );
printf( "%d\n", C.int_size() );
printf( "%d\n", C.bit_size() );
bitset<50> Z;
string ostring = Z.to_string<char,char_traits<char>,allocator<char> >();
printf( ostring.c_str() );
printf( "\n" );
Z[10] = 1;
Z[15] = 1;
Z[58] = 1;
ostring = Z.to_string<char,char_traits<char>,allocator<char> >();
printf( ostring.c_str() );
printf( "\n" );
return 0;
}
示例8: scaling_list
bool scaling_list(BitArray &ba, uint8_t sizeOfScalingList) {
uint32_t nextScale = 8;
uint32_t lastScale = 8;
uint64_t delta_scale = 0;
for (uint8_t j = 0; j < sizeOfScalingList; j++) {
if (nextScale != 0) {
if (!ba.ReadExpGolomb(delta_scale))
return false;
nextScale = (lastScale + delta_scale + 256) % 256;
}
lastScale = (nextScale == 0) ? lastScale : nextScale;
}
return true;
}
示例9: SelectSubComponent
void EditFaceDataMod::SelectSubComponent (HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert) {
EditFaceDataModData *d = NULL, *od = NULL;
ModContextList mcList;
INodeTab nodes;
ip->GetModContexts(mcList,nodes);
BitArray nsel;
for (int nd=0; nd<mcList.Count(); nd++) {
d = (EditFaceDataModData*) mcList[nd]->localData;
if (d==NULL) continue;
HitRecord *hr = hitRec;
if (!all && (hr->modContext->localData != d)) continue;
for (; hr!=NULL; hr=hr->Next()) if (hr->modContext->localData == d) break;
if (hr==NULL) continue;
Mesh *mesh = d->GetCacheMesh();
MNMesh *mnmesh = d->GetCacheMNMesh();
if (!mesh && !mnmesh) continue;
if (theHold.Holding() && !d->GetHeld()) theHold.Put (new SelectRestore (this, d));
switch (selLevel) {
case SEL_FACE:
nsel = d->GetFaceSel();
for (; hr != NULL; hr=hr->Next()) {
if (d != hr->modContext->localData) continue;
nsel.Set (hr->hitInfo, invert ? !d->GetFaceSel()[hr->hitInfo] : selected);
if (!all) break;
}
d->GetFaceSel() = nsel;
break;
}
}
nodes.DisposeTemporary ();
SelectionChanged ();
}
示例10: Proceed
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//| From IPFTest |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
bool PFTestSplitSelected::Proceed(IObject* pCont,
PreciseTimeValue timeStart,
PreciseTimeValue& timeEnd,
Object* pSystem,
INode* pNode,
INode* actionNode,
IPFIntegrator* integrator,
BitArray& testResult,
Tab<float>& testTime)
{
bool exactStep = IsExactIntegrationStep(timeEnd, pSystem);
int conditionType = pblock()->GetInt(kSplitSelected_conditionType, timeStart);
// acquire absolutely necessary particle channels
IParticleChannelAmountR* chAmount = GetParticleChannelAmountRInterface(pCont);
if (chAmount == NULL) return false; // can't find number of particles in the container
int count = chAmount->Count();
IParticleChannelPTVR* chTime = GetParticleChannelTimeRInterface(pCont);
if (chTime == NULL) return false; // can't read timing info for a particle
IParticleChannelBoolR* chSelect = GetParticleChannelSelectionRInterface(pCont);
// test all particles
testResult.SetSize(count);
testResult.ClearAll();
testTime.SetCount(count);
for(int i=0; i<count; i++)
{
bool selected = (chSelect != NULL) ? chSelect->GetValue(i) : false;
bool sendOut = ((selected && (conditionType == kSplitSelected_conditionType_selected))
|| (!selected && (conditionType == kSplitSelected_conditionType_notSelected)));
if (sendOut && exactStep) {
testResult.Set(i);
testTime[i] = 0.0f;
}
}
return true;
}
示例11: Build
void MNMeshLoop::Build(MNMeshLoopAdvancer &adv, int startid, BitArray &finalsel)
{
// prepare Loopitems
m_items.SetCount(MESHLOOP_ALLOC_ITEMCOUNT);
int allocated = MESHLOOP_ALLOC_ITEMCOUNT;
// add ourself
int itemcnt = 0;
int wave = 1;
MNMeshLoopItem *item = m_items.Addr(0);
item->wave = 0;
item->distance = 0.0f;
item->id = startid;
item->pos = adv.GetPos(startid);
item->prev = NULL;
finalsel.Set(startid);
item++;
itemcnt++;
Tab<MNMeshLoopFront> fronts;
int outcount = adv.SetupFront(startid,fronts);
// then advance each direction
int added = TRUE;
while(added){
added = FALSE;
for (int o = 0; o < outcount; o++){
MNMeshLoopFront *front = fronts.Addr(o);
// loop ended
if (adv.Advance(front,item,itemcnt,wave,finalsel))
continue;
item++;
itemcnt++;
// expand memory (we could use append but well no clue how it resizes)
if (itemcnt%MESHLOOP_ALLOC_ITEMCOUNT == 0){
m_items.SetCount(itemcnt+MESHLOOP_ALLOC_ITEMCOUNT);
item = m_items.Addr(itemcnt);
}
added = TRUE;
}
wave += 1;
}
m_numitems = itemcnt;
}
示例12: if
void TabletReader::QueryExactByColumn(column_t column, const std::string &value, std::function<void(const Record &)> callable) const {
rocksdb::Status status;
ReadStoreKey key{column, value};
std::string result;
status = db_->Get(env_->getReadStoreReadOptions(), key.ToSlice(), &result);
if (status.IsNotFound()) {
return;
} else if (!status.ok()) {
throw TabletLevelDbException{status};
}
BitArray bitArray;
bitArray.readStream(result.data(), result.size());
result.clear();
Record currentRecord;
bitArray.iterateSetBits(static_cast<offsetType>(-1), [&] (uint64_t pos) {
rocksdb::Slice newKey = ReadStoreKey::MaterializedRowKey(pos).ToSlice();
status = db_->Get(
env_->getReadStoreReadOptions(),
newKey,
&result
);
if (status.IsNotFound()) {
return;
}
if (!status.ok()) {
throw TabletLevelDbException{status};
}
currentRecord.ParseFromString(result);
callable(currentRecord);
});
}
示例13:
void MeshTopoData::UpdateClusterVertices(Tab<ClusterClass*> &clusterList)
{
BitArray processedVerts;
processedVerts.SetSize(TVMaps.v.Count());
for (int i = 0; i < clusterList.Count(); i++)
{
if (clusterList[i]->ld == this)
{
clusterList[i]->verts.SetCount(0);
processedVerts.ClearAll();
for (int j = 0; j < clusterList[i]->faces.Count(); j++)
{
int findex = clusterList[i]->faces[j];
AddVertsToCluster(findex, processedVerts, clusterList[i]);
}
for (int j = 0; j < clusterList[i]->verts.Count(); j++)
{
int id = clusterList[i]->verts[j];
}
}
}
}
示例14: DotProd
void SymmetryMod::SliceTriObject (Mesh & mesh, Point3 & N, float offset) {
// Steve Anderson 9/14/2002
// Using the new "MESH_TEMP_1" flag to override Slice selection behavior,
// which is undesirable here.
mesh.SetFlag (MESH_TEMP_1);
MeshDelta slicemd;
slicemd.Slice (mesh, N, offset, false, true);
slicemd.Apply (mesh);
mesh.ClearFlag (MESH_TEMP_1);
// We need to strip out faces on the mirror plane itself.
// (These aren't always removed by slice.)
// Mark vertices at the plane boundary:
BitArray targetVerts;
targetVerts.SetSize (mesh.numVerts);
targetVerts.ClearAll ();
for (int i=0; i<mesh.numVerts; i++) {
float dist = DotProd (N, mesh.verts[i]) - offset;
if (fabsf(dist) > MNEPS) continue;
targetVerts.Set (i);
}
BitArray delFaces, delVerts;
delFaces.SetSize (mesh.numFaces);
for (int i=0; i<mesh.numFaces; i++) {
int j;
for (j=0; j<3; j++) {
if (!targetVerts[mesh.faces[i].v[j]]) break;
}
if (j<3) continue;
// Face needs to be deleted.
delFaces.Set (i);
}
mesh.DeleteFaceSet (delFaces, &delVerts);
mesh.DeleteVertSet (delVerts);
}
示例15:
void UnwrapMod::BuildUsedListFromSelection(BitArray &usedVerts)
{
usedVerts.SetSize(TVMaps.v.Count());
usedVerts.ClearAll();
for (int j =0; j < TVMaps.f.Count(); j++)
{
int faceIndex = j;
if (TVMaps.f[faceIndex]->flags & FLAG_SELECTED)
{
for (int k = 0; k < TVMaps.f[faceIndex]->count; k++)
{
//ne ed to put patch handles in here also
int index = TVMaps.f[faceIndex]->t[k];
usedVerts.Set(index);
if ((TVMaps.f[faceIndex]->flags & FLAG_CURVEDMAPPING) && (TVMaps.f[faceIndex]->vecs))
{
index = TVMaps.f[faceIndex]->vecs->handles[k*2];
if ((index >= 0) && (index < usedVerts.GetSize()))
usedVerts.Set(index);
index = TVMaps.f[faceIndex]->vecs->handles[k*2+1];
if ((index >= 0) && (index < usedVerts.GetSize()))
usedVerts.Set(index);
if (TVMaps.f[faceIndex]->flags & FLAG_INTERIOR)
{
index = TVMaps.f[faceIndex]->vecs->interiors[k];
if ((index >= 0) && (index < usedVerts.GetSize()))
usedVerts.Set(index);
}
}
}
}
}
}