本文整理汇总了C++中BitArray::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BitArray::SetSize方法的具体用法?C++ BitArray::SetSize怎么用?C++ BitArray::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitArray
的用法示例。
在下文中一共展示了BitArray::SetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GrowSelection
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;
}
}
示例2: SynchSize
void EditFaceDataModData::SynchSize (int numFaces) {
if (numFaces<0) {
// We're supposed to get the right size from the cache.
if (mpCacheMesh) numFaces = mpCacheMesh->numFaces;
if (mpCacheMNMesh) numFaces = mpCacheMNMesh->numf;
if (numFaces<0) return; // do nothing if cache missing.
}
mFaceSel.SetSize (numFaces, true);
mFacesAffected.SetSize (numFaces, true);
mtNewFaceValues.SetCount (numFaces);
}
示例3: ModifyTriObject
void EChamferMod::ModifyTriObject (TimeValue t, ModContext &mc, TriObject *tobj) {
Mesh &mesh = tobj->GetMesh();
Interval iv = FOREVER;
float amount;
int i, j;
m_pblock->GetValue (kEchAmount, t, amount, iv);
// Convert existing selection (at whatever level) to edge selection:
BitArray targetEdges;
targetEdges.SetSize (mesh.numFaces*3);
targetEdges.ClearAll ();
switch (mesh.selLevel) {
case MESH_OBJECT:
targetEdges.SetAll ();
break;
case MESH_VERTEX:
for (i=0; i<mesh.numFaces; i++) {
for (j=0; j<3; j++) {
if (!mesh.vertSel[mesh.faces[i].v[j]]) continue;
// Don't select invisible edges:
if (mesh.faces[i].getEdgeVis(j)) targetEdges.Set (i*3+j);
if (mesh.faces[i].getEdgeVis((j+2)%3)) targetEdges.Set (i*3+(j+2)%3);
}
}
break;
case MESH_EDGE:
targetEdges = mesh.edgeSel;
break;
case MESH_FACE:
for (i=0; i<mesh.numFaces; i++) {
if (!mesh.faceSel[i]) continue;
for (j=0; j<3; j++) {
// Don't select invisible edges:
if (mesh.faces[i].getEdgeVis(j)) targetEdges.Set (i*3+j);
}
}
break;
}
// Chamfer the edges -- this just does the topological operation.
MeshDelta tmd;
tmd.InitToMesh (mesh);
MeshTempData temp;
temp.SetMesh (&mesh);
MeshChamferData *mcd = temp.ChamferData();
AdjEdgeList *ae = temp.AdjEList();
tmd.ChamferEdges (mesh, targetEdges, *mcd, ae);
tmd.Apply (mesh);
// Reset the meshdelta, temp data to deal with the post-chamfered topology:
tmd.InitToMesh (mesh);
temp.Invalidate (TOPO_CHANNEL); // Generates a new edge list, but preserves chamfer data
temp.SetMesh (&mesh);
tmd.ChamferMove (mesh, *temp.ChamferData(), amount, temp.AdjEList());
tmd.Apply (mesh);
tobj->UpdateValidity(GEOM_CHAN_NUM,iv);
}
示例4: 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;
}
}
示例5: MNMesh_selectVertexLoops
void MNMesh_selectVertexLoops(MNMesh *mesh, int startid, BitArray &vertexloops)
{
BitArray secondarysel(mesh->ENum());
BitArray connectededges(mesh->ENum());
vertexloops.SetSize(mesh->VNum());
mesh->getEdgeSel(secondarysel);
// convert to Edge
Tab<int> &connected = mesh->vedg[startid];
for (int e=0; e < connected.Count(); e++){
connectededges.Set(connected[e]);
}
// loop edges
mesh->SelectEdgeLoop(connectededges);
// convert back to vertex
MNEdge *edge = mesh->e;
MNEdge *lastedge = edge+mesh->ENum();
int eid = 0;
while (edge < lastedge){
if (connectededges[eid]){
vertexloops.Set(edge->v1);
vertexloops.Set(edge->v2);
}
edge++;
eid++;
}
// select those vertices
mesh->VertexSelect(vertexloops);
// restore old edges
mesh->EdgeSelect(secondarysel);
}
示例6: DeleteFaces
void XTCSample::DeleteFaces(TimeValue t,Object *obj)
{
if(bNF_OnOff)
{
Mesh *mesh = GetMesh(obj);
if(!mesh)
return;
Interval ivalid = FOREVER;
int nf;
bo->GetParamBlockByID(x_params)->GetValue(pb_nf_spin,t,nf, ivalid);
BitArray ba;
ba.SetSize(mesh->getNumFaces());
ba.ClearAll();
for(int i = nf ; i < mesh->getNumFaces() ; i++ )
{
ba.Set(i);
}
if(!ba.IsEmpty())
mesh->DeleteFaceSet(ba);
}
}
示例7:
void UnwrapMod::BuildUsedList(BitArray &usedVerts, ClusterClass *cluster)
{
usedVerts.SetSize(TVMaps.v.Count());
usedVerts.ClearAll();
for (int j =0; j < cluster->faces.Count(); j++)
{
int faceIndex = cluster->faces[j];
for (int k = 0; k < TVMaps.f[faceIndex]->count; k++)
{
//need 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);
}
}
}
}
}
示例8: AssignSetMatchSize
static void AssignSetMatchSize(BitArray &dst, BitArray &src)
{
int size = dst.GetSize();
dst = src;
if (dst.GetSize() != size)
{
dst.SetSize(size, TRUE);
}
}
示例9: WeldVertices
void NifImporter::WeldVertices(Mesh& mesh)
{
MeshDelta tmd(mesh);
BitArray vTempSel;
vTempSel.SetSize(mesh.getNumVerts());
vTempSel.SetAll();
tmd.WeldByThreshold(mesh, vTempSel, weldVertexThresh);
tmd.Apply(mesh);
}
示例10: SetVNum
void RelaxModData::SetVNum (int num) {
if (num==vnum) return;
Clear();
vnum = num;
if (num<1) return;
nbor = new DWordTab[vnum];
vis = new BitArray[vnum];
fnum = new int[vnum];
sel.SetSize (vnum);
}
示例11: CollapseDeadSelections
void EditPolyData::CollapseDeadSelections (EditPolyMod *pMod, MNMesh & mesh)
{
BitArray delSet;
// Fix the vertex selection and hide arrays:
int max = mesh.numv;
if (max>mVertSel.GetSize()) max = mVertSel.GetSize ();
delSet.SetSize (max);
for (int i=0; i<max; i++) delSet.Set (i, mesh.v[i].GetFlag (MN_DEAD));
if (delSet.NumberSet()>0)
{
if (theHold.Holding()) theHold.Put (new EditPolySelectRestore (pMod, this, EPM_SL_VERTEX));
mVertSel.DeleteSet (delSet);
if (theHold.Holding()) theHold.Put (new EditPolyHideRestore (pMod, this, false));
mVertHide.DeleteSet (delSet);
}
// Fix the edge selection array:
max = mesh.nume;
if (max>mEdgeSel.GetSize()) max = mEdgeSel.GetSize ();
delSet.SetSize (max);
for (int i=0; i<max; i++) delSet.Set (i, mesh.e[i].GetFlag (MN_DEAD));
if (delSet.NumberSet()>0)
{
if (theHold.Holding()) theHold.Put (new EditPolySelectRestore (pMod, this, EPM_SL_EDGE));
mEdgeSel.DeleteSet (delSet);
}
// Fix the face selection and hide arrays:
max = mesh.numf;
if (max>mFaceSel.GetSize()) max = mFaceSel.GetSize ();
delSet.SetSize (max);
for (int i=0; i<max; i++) delSet.Set (i, mesh.f[i].GetFlag (MN_DEAD));
if (delSet.NumberSet()>0)
{
if (theHold.Holding()) theHold.Put (new EditPolySelectRestore (pMod, this, EPM_SL_FACE));
mFaceSel.DeleteSet (delSet);
if (theHold.Holding()) theHold.Put (new EditPolyHideRestore (pMod, this, true));
mFaceHide.DeleteSet (delSet);
}
}
示例12: Split
IObject* ParticleChannelMap::Split(BitArray& toSplit)
{
// SysUtil::NeedToImplementLater(); // TODO: optimize the implementation
ParticleChannelMap* newChannel = (ParticleChannelMap*)Clone();
Delete(toSplit);
BitArray reverse = ~toSplit;
if (reverse.GetSize() != newChannel->Count())
reverse.SetSize(newChannel->Count(), TRUE);
newChannel->Delete(reverse);
return newChannel;
}
示例13: LengthSquared
void
UniformGrid::ClosestPoint(Point3 p, float radius, int &pindex, float &d)
{
xHitList.ClearAll();
yHitList.ClearAll();
zHitList.ClearAll();
hitList.SetCount(0);
//find the cell in the XGrid
TagCells(p,radius, 0);
//find the cell in the YGrid
TagCells(p,radius, 1);
//find the cell in the ZGrid
TagCells(p,radius, 2);
BitArray usedList;
usedList.SetSize(pointBase.Count());
usedList.ClearAll();
int closest = -1;
d = 0.0f;
Box3 localBounds;
localBounds.Init();
localBounds += p;
localBounds.EnlargeBy(radius);
for (int i = 0; i < hitList.Count(); i++)
{
int index = hitList[i];
if (!usedList[index]) //check to see if we have processed this one or not
{
if (xHitList[index] && yHitList[index] && zHitList[index])
{
usedList.Set(index);
Point3 source = pointBase[index];
if (localBounds.Contains(source))
{
float dist = LengthSquared(source-p);
if ((dist < d) || (closest == -1))
{
d = dist;
closest = index;
}
}
}
}
}
pindex = closest;
d = sqrt(d);
}
示例14:
////////////////////////////////// MESH WELDER ////////////////////
static void
WeldMesh(Mesh *mesh, float thresh)
{
if (thresh == 0.0f)
thresh = (float)1e-30; // find only the coincident ones BitArray vset, eset;
BitArray vset;
vset.SetSize(mesh->numVerts);
vset.SetAll();
MeshDelta md;
md.WeldByThreshold(*mesh, vset, thresh);
md.Apply(*mesh);
}
示例15: MirrorTriObject
void SymmetryMod::MirrorTriObject (Mesh & mesh, int axis, Matrix3 & tm, Matrix3 & itm, int normalMapChannel) {
// Create scaling matrix for mirroring on selected axis:
Point3 scale(1,1,1);
scale[axis] = -1.0f;
itm.Scale(scale,TRUE);
// Hang on to a copy of the incoming face selection:
BitArray inputFaceSel = mesh.faceSel;
// Make the mirror copy of the entire mesh:
int oldnumv = mesh.numVerts;
int oldnumf = mesh.numFaces;
int oldNumNormals = 0;
if (normalMapChannel != INVALID_NORMALMAPCHANNEL)
{
MeshMap& map = mesh.Map(normalMapChannel);
oldNumNormals = map.vnum;
}
BitArray fset;
fset.SetSize (oldnumf);
fset.SetAll ();
mesh.CloneFaces (fset); // Clears selection on originals, sets it on new faces.
// Transform the cloned vertices to their mirror images:
for (int i=oldnumv; i<mesh.numVerts; i++) {
mesh.verts[i] = (mesh.verts[i]*itm)*tm;
}
// Restore selection of input faces:
for (int i=0; i<oldnumf; i++) mesh.faceSel.Set (i, inputFaceSel[i]);
// Flip over new faces and select to match input:
for (int i=oldnumf; i<mesh.numFaces; i++) {
mesh.FlipNormal (i);
mesh.faceSel.Set (i, inputFaceSel[i-oldnumf]);
}
//flip and specified normals/faces
if (normalMapChannel != INVALID_NORMALMAPCHANNEL)
{
MeshMap& map = mesh.Map(normalMapChannel);
int numNormals = map.vnum;
Matrix3 mirrorTM = itm*tm;
for (int i = oldNumNormals; i < numNormals; i++)
{
Point3 n = map.tv[i];
n = VectorTransform(n,mirrorTM);
map.tv[i] = n;
}
}
}