void SplineData::PasteToSelected(int splineIndex, int crossSectionIndex)
{
	if ((splineIndex < 0) || (splineIndex >= mSplineElementData.Count()))
	{
		DbgAssert(0);
		return;
	}
	int numCross = NumberOfCrossSections(splineIndex);
	if ((crossSectionIndex < 0) || (crossSectionIndex > numCross))
	{
		DbgAssert(0);
		return;
	}

	SplineCrossSection section = mSplineElementData[splineIndex]->GetCrossSection(crossSectionIndex);
	for (int i = 0; i < NumberOfSplines(); i++ )
	{
		if (IsSplineSelected(i))
		{
			for (int j = 0; j < NumberOfCrossSections(i); j++)
			{
				if (CrossSectionIsSelected(i,j))
				{
					SplineCrossSection *crossSection = GetCrossSection(i,j);
					crossSection->mScale = section.mScale;
					crossSection->mQuat = section.mQuat;
				}
			}
		}
	}
	RecomputeCrossSections();
}
void	SplineData::RotateSelectedCrossSections(Quat q)
{
	Tab<int> selSplines;
	Tab<int> selCrossSections;
	GetSelectedCrossSections(selSplines,selCrossSections);

	//move the cross sections
	for (int i = 0; i < selSplines.Count(); i++)
	{
		int splineIndex = selSplines[i];
		int crossSectionIndex = selCrossSections[i];
		SplineCrossSection *section = GetCrossSection(splineIndex,crossSectionIndex);

		Matrix3 sTM = section->mTM;
		sTM.NoScale();
		sTM.NoTrans();

		Quat tq = TransformQuat(sTM,q);
		//no back into our initial space
		tq = TransformQuat(section->mIBaseTM,tq);

		section->mQuat += tq;


	}

	RecomputeCrossSections();	
}
Example #3
0
double WeightCalculator::GetCrossSection(const std::string &process, const int m1,
                                         const int m2) const{
  if(m1>=0 && m2>=0){
    if(process.find("SMS-T1tttt_2J_mGo-845to3000_mLSP-1to1355_TuneZ2star_14TeV-madgraph-tauola_Summer12-START53_V7C_FSIM_PU_S12-v1_AODSIM_UCSB1949reshuf_v71")!=std::string::npos){
      return GetT1tttt14TeVCrossSection(m1, m2);
    }else{
      //Other models go here eventually
      return -1.0;
    }
  }else{
    return GetCrossSection(process);
  }
}
void SplineData::AlignCrossSection(int splineIndex, int crossSectionIndex,Point3 vec)
{
	if ((splineIndex >= 0) && (splineIndex < mSplineElementData.Count()))
	{
		int numCrossSections = NumberOfCrossSections(splineIndex);

		if ((crossSectionIndex >= 0) && (crossSectionIndex < numCrossSections))
		{

			//put the vec in spline space
			SplineCrossSection *crossSection = GetCrossSection(splineIndex,crossSectionIndex);


			Matrix3 crossSectionTM = crossSection->mTM;
			crossSectionTM.NoScale();
			crossSectionTM.NoTrans();
			Matrix3 icrossSectionTM = Inverse(crossSectionTM);


			Point3 crossSectionZVec = crossSection->mTangentNormalized;


			Point3 yvec = Normalize(vec);

			Point3 xvec = Normalize(CrossProd(yvec,crossSectionZVec));
			Point3 zvec = Normalize(CrossProd(xvec,yvec));

			Matrix3 rtm(1);
			rtm.SetRow(0,xvec);
			rtm.SetRow(1,yvec);
			rtm.SetRow(2,zvec);
			rtm.SetRow(3,Point3(0.0f,0.0f,0.0f));

			Matrix3 relativeTM =  crossSection->mIBaseTM * rtm;

			Quat q(relativeTM);


			q = TransformQuat(crossSection->mIBaseTM,q);

			crossSection->mQuat = q;

			return;
		}
	}
	DbgAssert(0);


}
void	SplineData::Copy()
{
	for (int i = 0; i < NumberOfSplines(); i++ )
	{
		if (IsSplineSelected(i))
		{
			for (int j = 0; j < NumberOfCrossSections(i); j++)
			{
				if (CrossSectionIsSelected(i,j))
				{
					mCopyBuffer = *GetCrossSection(i,j);
					mHasCopyBuffer = TRUE;
					return;
				}
			}
		}
	}
}
void	SplineData::ScaleSelectedCrossSections(Point2 v)
{
 	Tab<int> selSplines;
	Tab<int> selCrossSections;
	GetSelectedCrossSections(selSplines,selCrossSections);

	//move the cross sections
	for (int i = 0; i < selSplines.Count(); i++)
	{
		int splineIndex = selSplines[i];
		int crossSectionIndex = selCrossSections[i];
		SplineCrossSection *section = GetCrossSection(splineIndex,crossSectionIndex);
		section->mScale.x *= v.x;
		section->mScale.y *= v.y;
	}

	RecomputeCrossSections();	
}
void	SplineData::Paste()
{
	for (int i = 0; i < NumberOfSplines(); i++ )
	{
		if (IsSplineSelected(i))
		{
			for (int j = 0; j < NumberOfCrossSections(i); j++)
			{
				if (CrossSectionIsSelected(i,j))
				{
					SplineCrossSection *crossSection = GetCrossSection(i,j);
					crossSection->mScale = mCopyBuffer.mScale;
					crossSection->mQuat = mCopyBuffer.mQuat;
				}
			}
		}
	}
	RecomputeCrossSections();
}
Box3 SplineData::GetWorldsBounds()
{
	Box3 bounds;
	bounds.Init();

	mShapeCache.BuildBoundingBox();
	bounds = mShapeCache.bdgBox;
	float extraPadding = 0.0f;
	for (int i = 0; i < mSplineElementData.Count(); i++)
	{
		for (int j = 0; j < NumberOfCrossSections(i); j++)
		{
			SplineCrossSection *section = GetCrossSection(i,j);
			float d = section->GetLargestScale();
			if (d > extraPadding)
				extraPadding = d;
		}
	}
	
	bounds.EnlargeBy(extraPadding);


	return bounds;
}
void	SplineData::MoveSelectedCrossSections(Point3 vec)
{
	

 	Tab<int> selSplines;
	Tab<int> selCrossSections;
	GetSelectedCrossSections(selSplines,selCrossSections);
	if (selSplines.Count() == 0) return;
//get the spline length
	float l = mSplineElementData[selSplines[0]]->GetSplineLength();
//get the sel cross u
	SplineCrossSection *section = GetCrossSection(selSplines[0],selCrossSections[0]);

	//transform into spline space
	Matrix3 sTM = section->mTM;
	sTM.NoScale();
	Point3 tv = VectorTransform(sTM,vec);
	//no back into our initial space
	Point3 v = VectorTransform(section->mIBaseTM,tv);

//compute how much u to move
	
	float incU = v.z/l;
	//move the cross sections
	for (int i = 0; i < mSplineElementData.Count(); i++)
	{
		if (mSplineElementData[i]->IsSelected())
		{
			for (int j = 0; j < (NumberOfCrossSections(i)); j++)
			{
				if (CrossSectionIsSelected(i,j))
				{
					SplineCrossSection *section = GetCrossSection(i,j);

					Matrix3 sTM = section->mTM;
					sTM.NoScale();

					tv = VectorTransform(sTM,vec);
					v = VectorTransform(section->mIBaseTM,tv);
					float tempU = section->mOffset.z + incU;
					
					if (tempU > 1.0f)
						tempU = 1.0f;
					if (tempU < 0.0f)
						tempU = 0.0f;
					float prevU = 0.0f;
					if (j != 0)
						prevU = GetCrossSection(i,j-1)->mOffset.z;
					float nextU = 1.0;
					if ((j+1) < NumberOfCrossSections(i))
						nextU = GetCrossSection(i,j+1)->mOffset.z;

					if ((tempU < nextU) && (tempU > prevU))
					{
						//we cant slide the end/start cross sections
						if ((j != 0) && (j != NumberOfCrossSections(i)-1))
							section->mOffset.z = tempU;
					}

					

					section->mOffset.x += v.x;
					section->mOffset.y += v.y;


				}
			}
		}
	}

	RecomputeCrossSections();	
}