Example #1
0
void EditPolyData::ShrinkSelection (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();

	switch (mnSelLevel) {
	case MNM_SL_VERTEX: 
		// Find the edges between two selected vertices.
		mpMesh->ClearEFlags (MN_USER);
		mpMesh->PropegateComponentFlags (MNM_SL_EDGE, MN_USER, mnSelLevel, MN_SEL, true);
		newSel = mVertSel;
		// De-select all the vertices touching edges to unselected vertices:
		for (int i=0; i<mpMesh->nume; i++) {
			if (!mpMesh->e[i].GetFlag (MN_USER)) {
				newSel.Clear (mpMesh->e[i].v1);
				newSel.Clear (mpMesh->e[i].v2);
			}
		}
		SetVertSel (newSel, imod, TimeValue(0));
		break;
	case MNM_SL_EDGE:
		// Find all vertices used by only selected edges:
		mpMesh->ClearVFlags (MN_USER);
		mpMesh->PropegateComponentFlags (MNM_SL_VERTEX, MN_USER, mnSelLevel, MN_SEL, true);
		newSel = mEdgeSel;
		for (int i=0; i<mpMesh->nume; i++) {
			// Deselect edges with at least one vertex touching a nonselected edge:
			if (!mpMesh->v[mpMesh->e[i].v1].GetFlag (MN_USER) || !mpMesh->v[mpMesh->e[i].v2].GetFlag (MN_USER))
				newSel.Clear (i);
		}
		SetEdgeSel (newSel, imod, TimeValue(0));
		break;
	case MNM_SL_FACE:
		// Find all vertices used by only selected faces:
		mpMesh->ClearVFlags (MN_USER);
		mpMesh->PropegateComponentFlags (MNM_SL_VERTEX, MN_USER, mnSelLevel, MN_SEL, true);
		newSel = mFaceSel;
		for (int i=0; i<mpMesh->numf; i++) {
			for (int j=0; j<mpMesh->f[i].deg; j++) {
				if (!mpMesh->v[mpMesh->f[i].vtx[j]].GetFlag (MN_USER)) 
            {
               // Deselect faces with at least one vertex touching a nonselected face:
               newSel.Clear (i);
               break;
            }
			}
		}
		SetFaceSel (newSel, imod, TimeValue(0));
		break;
	}
}
Example #2
0
void TriObject::GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel ) 
	{	
	if ( tm || useSel ) {
		box.Init();
		BitArray sel;
		BitArray vhide;
		float *vssel = NULL;
		if ( useSel ) {
			sel = mesh.VertexTempSel();
			vssel = mesh.getVSelectionWeights ();
		} else {
			vhide = mesh.vertHide;
			if (vhide.NumberSet ()) {
				for (int i=0; i<mesh.getNumFaces(); i++) {
					if (mesh.faces[i].Hidden ()) continue;
					for (int j=0; j<3; j++) vhide.Clear (mesh.faces[i].v[j]);
				}
			}
			}
		for ( int i = 0; i < mesh.getNumVerts(); i++ ) {
			if (!useSel && vhide[i]) continue;
			if ( !useSel || sel[i] || (vssel&&vssel[i])) {
				if ( tm ) {
					box += *tm * mesh.getVert(i);
				} else {
					box += mesh.getVert(i);
					}
				}
			}
	} else {
		box = mesh.getBoundingBox();
		}
	}
Example #3
0
  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));
	      }
	  }
      }
  }
Example #4
0
BlurMgr::BlurMgr() :
	pbMaster(NULL), pbBlurData(NULL), pbSelData(NULL), mp_CCtl(NULL),
	m_lastBMModifyID(0xFFFFFFFF), m_imageW(0), m_imageH(0), m_imageSz(0), m_compValid(false)

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
{
	m_blurs[idBlurUnif]		= new BlurUniform(this);
	m_blurs[idBlurDir]		= new BlurDirectional(this);
	m_blurs[idBlurRadial]	= new BlurRadial(this);

	m_sels[idSelImage]		= new SelImage(this);
	m_sels[idSelIBack]		= new SelIgnBack(this);
	m_sels[idSelLum]		= new SelLum(this);
	m_sels[idSelMask]		= new SelMaps(this);
	m_sels[idSelObjIds]		= new SelObjIds(this);
	m_sels[idSelMatIds]		= new SelMatIds(this);

	// this added to allow extension of seltypes -- adding new param active ids breaks the original sequential enumeration
	// i should have enumerated the param ids sparsely to allow for extensibility.
	// if they are added sequentially, it changes the value of old param ids and will break loading of old versions
	m_selActiveIds[idSelImage]	= prmImageActive;
	m_selActiveIds[idSelIBack]	= prmIBackActive;
	m_selActiveIds[idSelLum]	= prmLumActive;
	m_selActiveIds[idSelMask]	= prmMaskActive;
	m_selActiveIds[idSelObjIds]	= prmObjIdsActive;
	m_selActiveIds[idSelMatIds]	= prmMatIdsActive;

	// set default blur radial origin to coincide with current render settings
	pbdBlurData.ParamOption(prmRadialXOrig, p_default, GetCOREInterface()->GetRendWidth()/2);
	pbdBlurData.ParamOption(prmRadialYOrig, p_default, GetCOREInterface()->GetRendHeight()/2);
	blurMgrCD.MakeAutoParamBlocks(this);
	assert(	pbMaster && pbBlurData && pbSelData);

	// create a curve control and reference it
	ICurveCtl *pICurveCtl = (ICurveCtl*)CreateInstance(REF_MAKER_CLASS_ID, CURVE_CONTROL_CLASS_ID);
	assert (pICurveCtl);
	ReplaceReference(idSelCurveCtrl, pICurveCtl);
	pICurveCtl->RegisterResourceMaker(this);
	pICurveCtl->SetCCFlags(CC_DRAWUTOOLBAR | CC_CONSTRAIN_Y | CC_SHOWRESET/*| CC_RCMENU_MOVE_XY | CC_RCMENU_MOVE_X | CC_RCMENU_MOVE_Y | CC_RCMENU_SCALE | CC_RCMENU_INSERT_CORNER | CC_RCMENU_INSERT_BEZIER | CC_RCMENU_DELETE*/);
	pICurveCtl->SetXRange(0.0f,1.0f);
	pICurveCtl->SetYRange(0.0f,1.0f);
	BitArray ba;
	ba.SetSize(32);
	ba.Set(0);
	ba.Clear(1);
	pICurveCtl->SetDisplayMode(ba);
	pICurveCtl->SetNumCurves(2);
	pICurveCtl->SetScrollValues(2, -44);
	pICurveCtl->SetZoomValues(133, 117);
}
Example #5
0
// Selection set, misc fixup utility function
// This depends on PatchMesh::RecordTopologyTags being called prior to the topo changes
void EditPatchMod::ResolveTopoChanges() 
{
	ModContextList mcList;		
	INodeTab nodes;
	TimeValue t = ip->GetTime();
	ip->GetModContexts(mcList, nodes);
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
	
	for (int i = 0; i < mcList.Count(); i++)
	{
		EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
		if (!patchData)
			continue;
		if (patchData->GetFlag(EPD_BEENDONE))
			continue;
		
		// If the mesh isn't yet cache, this will cause it to get cached.
		RPatchMesh *rpatch;
		PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
		if (!patch)
			continue;
		// First, the vertex selections
		int set;
		for (set = 0; set < patchData->vselSet.Count(); ++set)
		{
			BitArray *oldVS = &patchData->vselSet[set];
			BitArray newVS;
			newVS.SetSize(patch->numVerts);
			for (int vert = 0; vert < patch->numVerts; ++vert)
			{
				// Get the knot's previous location, then copy that selection into the new set
				int tag = patch->verts[vert].aux1;
				if (tag >= 0)
					newVS.Set(vert, (*oldVS)[tag]);
				else
					newVS.Clear(vert);
			}
			if (theHold.Holding())
				theHold.Put(new ChangeNamedSetRestore(&patchData->vselSet, set, oldVS));
			patchData->vselSet[set] = newVS;
		}
		// Now the edge selections
		for (set = 0; set < patchData->eselSet.Count(); ++set)
		{
			BitArray *oldES = &patchData->eselSet[set];
			BitArray newES;
			newES.SetSize(patch->numEdges);
			for (int edge = 0; edge < patch->numEdges; ++edge)
			{
				// Get the knot's previous location, then copy that selection into the new set
				int tag = patch->edges[edge].aux1;
				if (tag >= 0)
					newES.Set(edge, (*oldES)[tag]);
				else
					newES.Clear(edge);
			}
			if (theHold.Holding())
				theHold.Put(new ChangeNamedSetRestore(&patchData->eselSet, set, oldES));
			patchData->eselSet[set] = newES;
		}
		// Now the patch selections
		for (set = 0; set < patchData->pselSet.Count(); ++set)
		{
			BitArray *oldPS = &patchData->pselSet[set];
			BitArray newPS;
			newPS.SetSize(patch->numPatches);
			for (int p = 0; p < patch->numPatches; ++p)
			{
				// Get the knot's previous location, then copy that selection into the new set
				int tag = patch->patches[p].aux1;
				if (tag >= 0)
					newPS.Set(p, (*oldPS)[tag]);
				else
					newPS.Clear(p);
			}
			if (theHold.Holding())
				theHold.Put(new ChangeNamedSetRestore(&patchData->pselSet, set, oldPS));
			patchData->pselSet[set] = newPS;
		}
		
		// watje 4-16-99
		patch->HookFixTopology();
		
		patchData->SetFlag(EPD_BEENDONE, TRUE);
	}
	
	nodes.DisposeTemporary();
	ClearPatchDataFlag(mcList, EPD_BEENDONE);
}
Example #6
0
	void ResetFace (int faceID) { if ((faceID>=0)&&(faceID<mFacesAffected.GetSize())) mFacesAffected.Clear(faceID); }
Example #7
0
void EditFaceDataModData::ResetFace (BitArray & faces) {
	for (int i=0; i<faces.GetSize(); i++) {
		if (!faces[i]) continue;
		mFacesAffected.Clear (i);
	}
}
Example #8
0
IGeometryChecker::ReturnVal IsolatedVertexChecker::GeometryCheck(TimeValue t,INode *nodeToCheck, IGeometryChecker::OutputVal &val)
{
	val.mIndex.ZeroCount();
	if(IsSupported(nodeToCheck))
	{
		LARGE_INTEGER	ups,startTime;
		QueryPerformanceFrequency(&ups);
		QueryPerformanceCounter(&startTime); //used to see if we need to pop up a dialog 
		bool compute = true;
		bool checkTime = GetIGeometryCheckerManager()->GetAutoUpdate();//only check time for the dialog if auto update is active!
		ObjectState os  = nodeToCheck->EvalWorldState(t);
		Object *obj = os.obj;
		BitArray arrayOfVerts; //we fill this up with the verts, if not empty then we have isolated vets
		if(os.obj->IsSubClassOf(triObjectClassID))
		{
			TriObject *tri = dynamic_cast<TriObject *>(os.obj);
			if(tri)
			{
				Mesh &mesh = tri->GetMesh();
				arrayOfVerts.SetSize(mesh.numVerts);
				arrayOfVerts.SetAll ();
				for (int i=0; i<mesh.numFaces; i++) {
					
					for (int j=0; j<3; j++) arrayOfVerts.Clear(mesh.faces[i].v[j]);
					if(checkTime==true)
					{
						DialogChecker::Check(checkTime,compute,mesh.numFaces,startTime,ups);
						if(compute==false)
							break;
						
					}
				}
			}
			else return IGeometryChecker::eFail;
		}
		else if(os.obj->IsSubClassOf(polyObjectClassID))
		{
			PolyObject *poly = dynamic_cast<PolyObject *>(os.obj);
			if(poly)
			{
				MNMesh &mnMesh = poly->GetMesh();
				arrayOfVerts.SetSize(mnMesh.numv);
				arrayOfVerts.SetAll();
				for(int i=0;i<mnMesh.numf;++i)
				{
					for(int j=0;j<mnMesh.f[i].deg;++j) 
					{
						if(mnMesh.f[i].GetFlag(MN_DEAD)==0)
							arrayOfVerts.Clear(mnMesh.f[i].vtx[j]);
					}
					if(checkTime==true)
					{
						DialogChecker::Check(checkTime,compute,mnMesh.numf,startTime,ups);
						if(compute==false)
							break;
					}
				}
			}
			else return IGeometryChecker::eFail;
		}
		if(arrayOfVerts.IsEmpty()==false) //we have an isolated vierts
		{
			int localsize= arrayOfVerts.GetSize();
			for(int i=0;i<localsize;++i)
			{
				if(arrayOfVerts[i])
					val.mIndex.Append(1,&i);
			}
		}
		return TypeReturned();
	}
	return IGeometryChecker::eFail;
}
void MeshTopoData::DetachFromGeoFaces(BitArray faceSel, BitArray &vertSel, UnwrapMod *mod)
{


	TimeValue t = GetCOREInterface()->GetTime();

	//loop through the geo vertices and create our geo list of all verts in the 
	Tab<int> geoPoints;

	BitArray usedGeoPoints;
	usedGeoPoints.SetSize(TVMaps.geomPoints.Count());
	usedGeoPoints.ClearAll();

	BitArray isolatedPoints;
	isolatedPoints.SetSize(TVMaps.v.Count());
	isolatedPoints.SetAll();

	for (int i = 0; i < TVMaps.f.Count(); i++)
	{
		if (!(TVMaps.f[i]->flags & FLAG_DEAD))
		{
			if (faceSel[i])
			{	
				int degree = TVMaps.f[i]->count;
				for (int j = 0; j < degree; j++)
				{
					int index = TVMaps.f[i]->v[j];
					if (!usedGeoPoints[index])
					{
						usedGeoPoints.Set(index);
						geoPoints.Append(1,&index,3000);
					}
					if (TVMaps.f[i]->vecs)
					{
						int index = TVMaps.f[i]->vecs->vhandles[j*2];
						if (index != -1)
						{
							if (!usedGeoPoints[index])
							{
								usedGeoPoints.Set(index);
								geoPoints.Append(1,&index,3000);
							}
						}
						index = TVMaps.f[i]->vecs->vhandles[j*2+1];
						if (index != -1)
						{
							if (!usedGeoPoints[index])
							{
								usedGeoPoints.Set(index);
								geoPoints.Append(1,&index,3000);
							}
						}
						index = TVMaps.f[i]->vecs->vinteriors[j];
						if (index != -1)
						{
							if (!usedGeoPoints[index])
							{
								usedGeoPoints.Set(index);
								geoPoints.Append(1,&index,3000);
							}
						}
					}
				}
			}
			else 
			{	
				int degree = TVMaps.f[i]->count;
				for (int j = 0; j < degree; j++)
				{
					int index = TVMaps.f[i]->t[j];
					isolatedPoints.Clear(index);
					if (TVMaps.f[i]->vecs)
					{
						int index = TVMaps.f[i]->vecs->handles[j*2];					
						if (index != -1)
						{
							isolatedPoints.Clear(index);
						}
						index = TVMaps.f[i]->vecs->handles[j*2+1];
						if (index != -1)
						{
							isolatedPoints.Clear(index);
						}
						index = TVMaps.f[i]->vecs->interiors[j];
						if (index != -1)
						{
							isolatedPoints.Clear(index);
						}
					}
				}
			}
		}

	}

	for (int i = 0; i < TVMaps.v.Count(); i++)
	{
		if (isolatedPoints[i])
			SetTVVertDead(i,TRUE);
	}
	
	//get our dead verts
	Tab<int> deadVerts;
	for (int i = 0; i < TVMaps.v.Count(); i++)
	{
		if (TVMaps.v[i].IsDead() && !TVMaps.mSystemLockedFlag[i])
		{
			deadVerts.Append(1,&i,1000);
		}
	}

	//build the look up list
	Tab<int> lookupList;
	lookupList.SetCount(TVMaps.geomPoints.Count());
	for (int i = 0; i < TVMaps.geomPoints.Count(); i++)
		lookupList[i] = -1;
	int deadIndex = 0;
	for (int i = 0; i < geoPoints.Count(); i++)
	{
		int vIndex = geoPoints[i];
		Point3 p = TVMaps.geomPoints[vIndex];
	
		if (deadIndex < deadVerts.Count())
		{
			lookupList[vIndex] = deadVerts[deadIndex];
			SetTVVertControlIndex(deadVerts[deadIndex],-1);
			SetTVVert(t,deadVerts[deadIndex],p,mod);//TVMaps.v[found].p = p;
			SetTVVertInfluence(deadVerts[deadIndex],0.0f);//TVMaps.v[found].influence = 0.0f;
			SetTVVertDead(deadVerts[deadIndex],FALSE);//TVMaps.v[found].flags -= FLAG_DEAD;
			deadIndex++;
		}
		else
		{
			lookupList[vIndex] = TVMaps.v.Count();
			UVW_TVVertClass tv;
			tv.SetP(p);
			tv.SetFlag(0);
			tv.SetInfluence(0.0f);
			tv.SetControlID(-1);
			TVMaps.v.Append(1,&tv,1);
			mVSel.SetSize(TVMaps.v.Count(), 1);
			TVMaps.mSystemLockedFlag.SetSize(TVMaps.v.Count(), 1);
		}

	}

	vertSel.SetSize(TVMaps.v.Count());
	vertSel.ClearAll();

	for (int i = 0; i < TVMaps.f.Count(); i++)
	{
		if ((faceSel[i]) && (!(TVMaps.f[i]->flags & FLAG_DEAD)))
		{
	
			int degree = TVMaps.f[i]->count;
			for (int j = 0; j < degree; j++)
			{
				int index = TVMaps.f[i]->v[j];
				TVMaps.f[i]->t[j] = lookupList[index];
				vertSel.Set(lookupList[index],TRUE);

				if (TVMaps.f[i]->vecs)
				{
					int index = TVMaps.f[i]->vecs->vhandles[j*2];
					if ((index != -1) && (lookupList[index] != -1))
					{
						TVMaps.f[i]->vecs->handles[j*2] = lookupList[index];
						vertSel.Set(lookupList[index],TRUE);
					}

					index = TVMaps.f[i]->vecs->vhandles[j*2+1];
					if ((index != -1) && (lookupList[index] != -1))
					{
						TVMaps.f[i]->vecs->handles[j*2+1] = lookupList[index];
						vertSel.Set(lookupList[index],TRUE);
					}
					index = TVMaps.f[i]->vecs->vinteriors[j];
					if ((index != -1) && (lookupList[index] != -1))
					{
						TVMaps.f[i]->vecs->interiors[j] = lookupList[index];
						vertSel.Set(lookupList[index],TRUE);
					}
				}
			}
		}
	}

}