示例#1
0
void QVX_TensileTest::BeginTensileTest(QVX_Environment* pEnvIn, int NumStepIn, double ConvThreshIn, double MixRadiusIn, MatBlendModel ModelIn, double PolyExpIn)
{
	//set up local copy of the environment and object...

//	if (MixRadius != 0)	RenderMixedObject(pEnvIn->pObj, &LocObj, MixRadius); //if there's any mixing, we need to make it...
	//else 
	LocObj = *(pEnvIn->pObj); //otherwise just simulate the original object.
	LocEnv = *pEnvIn; //set local environment params to those of the input
	LocEnv.pObj = &LocObj; //make sure local environment points to local object

	//set up blending if desired
	BlendingEnabled = false;
	if (MixRadiusIn != 0){ //if some blending...
		//check for 2 or fewer materials!
		if (LocObj.GetNumLeafMatInUse() > 2){
			QMessageBox::warning(NULL, "Warning", "Currently blending only supported with 2 or fewer materials. Aborting.");
			return;
		}
		BlendingEnabled = true;
		MixRadius = MixRadiusIn;
		BlendModel = ModelIn;
		PolyExp = PolyExpIn;
	}
	
	NumStep = NumStepIn;
	ConvThresh = ConvThreshIn;
	CurTick = 0;
	TotalTick = NumStep;
	CancelFlag = false;

	std::string Message = "";

	pEnvIn->EnableFloor(false);
	pEnvIn->EnableGravity(false);
	pEnvIn->EnableTemp(false);

	Import(&LocEnv, NULL, &Message);
	EnableSelfCollision(false);

	EnableEquilibriumMode(true);

	SetStopConditionType(SC_MIN_MAXMOVE);
	SetStopConditionValue(ConvThreshIn);
//	SetBondDampZ(1.0);
//	SetSlowDampZ(0.03);

	EnablePlasticity(false);
	EnableFailure(false);

	if (!DoBCChecks()) return;

	CurViewMode = RVM_VOXELS;
	CurViewCol = RVC_STRAIN_EN;
	CurViewVox = RVV_DEFORMED;

	//QString DispMesg;

	OutFilePath = QFileDialog::getSaveFileName(NULL, "Save Tensile Test Results", "", "TXT Files (*.txt)");

	emit StartExternalGLUpdate(33);

	TestRunning = true;
	if (OutFilePath != "") TensileThread.Execute(false);
//	RunTensileTest(&DispMesg);
	if (ProgressMessage != "") QMessageBox::warning(NULL, "warning", QString::fromStdString(ProgressMessage));

}
示例#2
0
CVX_Sim::CVX_Sim(void)// : out("Logfile.txt", std::ios::ate)
{
	pEnv = NULL;

	CurColSystem = COL_SURFACE_HORIZON;
	CurIntegrator = I_EULER;

	PoissonKickBackEnabled = false;
	EnforceLatticeEnabled = false;

	SelfColEnabled = false;
	ColEnableChanged = true;
	CollisionHorizon = 3.0;

	MaxVelLimitEnabled = MemMaxVelEnabled = false;
	MaxVoxVelLimit = (vfloat)0.1;

	BlendingEnabled = false;
	MixRadius=0.0;
	BlendModel=MB_LINEAR;
	PolyExp = 1.0;

	FluidDampEnabled = false;

	PlasticityEnabled = true;
	FailureEnabled = true;

	InputVoxSInd = -1;
	InputBondInd = -1;

	BondDampingZ = MemBondDampZ = 0.1;
	ColDampingZ = 1;
	SlowDampingZ = MemSlowDampingZ = 0.001;

	EquilibriumModeEnabled = false;
//	EnableEquilibriumMode(false);
//	DisableEnergyHistory();
	KinEHistory.resize(HISTORY_SIZE, -1.0);
	TotEHistory.resize(HISTORY_SIZE, -1.0);
	MaxMoveHistory.resize(HISTORY_SIZE, -1.0);

	SetStopConditionType();
	SetStopConditionValue();



	DtFrac = (vfloat)0.9; //percent of maximum dt to use

	StatToCalc = CALCSTAT_ALL;

#ifdef USE_OPEN_GL
	NeedStatsUpdate=true;
	ViewForce = false;
	ViewAngles = false;
	CurViewMode = RVM_VOXELS;
	CurViewCol = RVC_TYPE;
	CurViewVox = RVV_DEFORMED;
#endif

	ClearAll();
	OptimalDt = 0; //remove when hack in ClearAll is dealt with
}
void QVX_TensileTest::BeginTensileTest(QVX_Sim* pSim, int NumStepIn, double ConvThreshIn, Vec3D<double> MixRadIn, MatBlendModel ModelIn, double PolyExpIn)
//void QVX_TensileTest::BeginTensileTest(QVX_Environment* pEnvIn, int NumStepIn, double ConvThreshIn, double MixRadiusIn, MatBlendModel ModelIn, double PolyExpIn)
{
	//set up local copy of the environment and object...
	//QVX_Environment* pEnvIn = (QVX_Environment*) pSim->pEnv;

		
	LocObj = *(pSim->pEnv->pObj); //otherwise just simulate the original object.
	LocEnv = *pSim->pEnv; //set local environment params to those of the input
	LocEnv.pObj = &LocObj; //make sure local environment points to local object

	//set up blending if desired
	bool EnableBlending = false;
	if (MixRadIn.x != 0 || MixRadIn.y != 0 || MixRadIn.z != 0){ //if some blending...
		//check for 2 or fewer materials!
		if (LocObj.GetNumLeafMatInUse() > 2){
			QMessageBox::warning(NULL, "Warning", "Currently blending only supported with 2 or fewer materials. Aborting.");
			return;
		}
		EnableBlending = true;
		MixRadius = MixRadIn;
		BlendModel = ModelIn;
		PolyExp = PolyExpIn;

		if (MixRadius.x==0)MixRadius.x = LocObj.GetLatticeDim()/10000; //set to tiny fraction to avoid blowup of exponential function
		if (MixRadius.y==0)MixRadius.y = LocObj.GetLatticeDim()/10000; //set to tiny fraction to avoid blowup of exponential function
		if (MixRadius.z==0)MixRadius.z = LocObj.GetLatticeDim()/10000; //set to tiny fraction to avoid blowup of exponential function

		RenderMixedObject(pSim->pEnv->pObj, &LocObj, MixRadius); //if there's any mixing, we need to make it...

	}
	EnableFeature(VXSFEAT_BLENDING, EnableBlending);
	
	NumStep = NumStepIn;
	ConvThresh = ConvThreshIn;
	CurTick = 0;
	TotalTick = NumStep;
	CancelFlag = false;

	std::string Message = "";

	LocEnv.EnableFloor(false);
	LocEnv.EnableGravity(false);
	LocEnv.EnableTemp(false);

	Import(&LocEnv, NULL, &Message);
	EnableFeature(VXSFEAT_COLLISIONS, false);
	EnableFeature(VXSFEAT_EQUILIBRIUM_MODE, true);
	EnableFeature(VXSFEAT_PLASTICITY, false);
	EnableFeature(VXSFEAT_FAILURE, false);
	EnableFeature(VXSFEAT_VOLUME_EFFECTS, pSim->IsFeatureEnabled(VXSFEAT_VOLUME_EFFECTS)); //enables volume effects according to last set physics sandbox value
	SetStopConditionType(SC_MIN_MAXMOVE);
	SetStopConditionValue(ConvThreshIn);

	if (!DoBCChecks()) return;

	OutFilePath = QFileDialog::getSaveFileName(NULL, "Save Tensile Test Results", GetLastDir(), "TXT Files (*.txt)");
	
	pTensileView->VoxMesh.LinkSimVoxels(this, pTensileView);
	pTensileView->VoxMesh.DefMesh.DrawSmooth=false;

	//match view to current selection of the physics sandbox
	pTensileView->SetCurViewCol(pSim->pSimView->GetCurViewCol());
	pTensileView->SetCurViewMode(pSim->pSimView->GetCurViewMode());
	pTensileView->SetCurViewVox(pSim->pSimView->GetCurViewVox());
	pTensileView->SetViewAngles(pSim->pSimView->GetViewAngles());
	pTensileView->SetViewForce(pSim->pSimView->GetViewForce());
	emit StartExternalGLUpdate(33);

	TestRunning = true;
	if (OutFilePath != "") TensileThread.Execute(false);
//	RunTensileTest(&DispMesg);
	if (ProgressMessage != "") QMessageBox::warning(NULL, "warning", QString::fromStdString(ProgressMessage));

}
示例#4
0
bool CVX_Sim::ReadXML(CXML_Rip* pXML, std::string* RetMessage)
{
	int tmpInt;
	vfloat tmpVFloat;

	if (pXML->FindElement("Integration")){
		if (pXML->FindLoadElement("Integrator", &tmpInt)) CurIntegrator = (IntegrationType)tmpInt; else CurIntegrator = I_EULER;
		if (!pXML->FindLoadElement("DtFrac", &DtFrac)) DtFrac = (vfloat)0.9;
		pXML->UpLevel();
	}
		
	if (pXML->FindElement("Damping")){
		if (!pXML->FindLoadElement("BondDampingZ", &BondDampingZ)) BondDampingZ = 0.1;
		if (!pXML->FindLoadElement("ColDampingZ", &ColDampingZ)) ColDampingZ = 1.0;
		if (!pXML->FindLoadElement("SlowDampingZ", &SlowDampingZ)) SlowDampingZ = 1.0;
		pXML->UpLevel();
	}

	if (pXML->FindElement("Collisions")){
		if (!pXML->FindLoadElement("SelfColEnabled", &SelfColEnabled)) SelfColEnabled = false;
		if (pXML->FindLoadElement("ColSystem", &tmpInt)) CurColSystem = (ColSystem)tmpInt; else CurColSystem = COL_SURFACE_HORIZON;
		if (!pXML->FindLoadElement("CollisionHorizon", &CollisionHorizon)) CollisionHorizon = (vfloat)2.0;
		pXML->UpLevel();
	}

	if (pXML->FindElement("Features")){
		if (!pXML->FindLoadElement("MaxVelLimitEnabled", &MaxVelLimitEnabled)) MaxVelLimitEnabled = false;
		if (!pXML->FindLoadElement("MaxVoxVelLimit", &MaxVoxVelLimit)) MaxVoxVelLimit = (vfloat)0.1;
		if (!pXML->FindLoadElement("BlendingEnabled", &BlendingEnabled)) BlendingEnabled = false;
		if (!pXML->FindLoadElement("MixRadius", &MixRadius)) MixRadius = 0.0;
		if (pXML->FindLoadElement("BlendModel", &tmpInt)) BlendModel = (MatBlendModel)tmpInt; else BlendModel = MB_LINEAR;
		if (!pXML->FindLoadElement("PolyExp", &PolyExp)) PolyExp = 1.0;

		if (!pXML->FindLoadElement("FluidDampEnabled", &FluidDampEnabled)) FluidDampEnabled = false;
		if (!pXML->FindLoadElement("PoissonKickBackEnabled", &PoissonKickBackEnabled)) PoissonKickBackEnabled = false;
		if (!pXML->FindLoadElement("EnforceLatticeEnabled", &EnforceLatticeEnabled)) EnforceLatticeEnabled = false;
		pXML->UpLevel();
	}

	if (pXML->FindElement("StopCondition")){
		if (pXML->FindLoadElement("StopConditionType", &tmpInt)) SetStopConditionType((StopCondition)tmpInt); else SetStopConditionType();
		if (pXML->FindLoadElement("StopConditionValue", &tmpVFloat)) SetStopConditionValue(tmpVFloat); else SetStopConditionValue();
		pXML->UpLevel();
	}

	if (pXML->FindElement("EquilibriumMode")){
		if (!pXML->FindLoadElement("EquilibriumModeEnabled", &EquilibriumModeEnabled)) EquilibriumModeEnabled = false;
		if (EquilibriumModeEnabled) EnableEquilibriumMode(true); //so it can set up energy history if necessary
		pXML->UpLevel();
	}
	

	if (pXML->FindElement("SurfMesh")){
		if (pXML->FindElement("CMesh")){
			SurfMesh.DefMesh.ReadXML(pXML);
			pXML->UpLevel();
		}
		pXML->UpLevel();
	}

	return ReadAdditionalSimXML(pXML, RetMessage);
}