Exemplo n.º 1
0
void QgsMapSettings::setDestinationCrs( const QgsCoordinateReferenceSystem &crs )
{
  mDestCRS = crs;
  mScaleCalculator.setMapUnits( crs.mapUnits() );
  // Since the map units have changed, force a recalculation of the scale.
  updateDerived();
}
/*! Specified Young's modulus and failure stress must both be positive.
Yield stress is interpreted as identical to failure stress. If failure stress is not specified an arbitrary data point consistent with the specified Young's modulus is added to the model.
*/
bool CVX_Material::setModelLinear(float youngsModulus, float failureStress)
{
	if (youngsModulus<=0){
		error = "Young's modulus must be positive";
		return false;
	}
	if (failureStress != -1.0f && failureStress<=0){
		error = "Failure stress must be positive";
		return false;
	}

	float tmpfailureStress = failureStress; //create a dummy failure stress if none was provided
	if (tmpfailureStress == -1) tmpfailureStress = 1000000;
	float tmpfailStrain = tmpfailureStress/youngsModulus;

	strainData.clear();
	stressData.clear();
	strainData.push_back(0); //add in the zero data point (required always)
	stressData.push_back(0);
	strainData.push_back(tmpfailStrain);
	stressData.push_back(tmpfailureStress);

	linear=true;
	E=youngsModulus;
	sigmaYield = failureStress; //yield and failure are one in the same here.
	sigmaFail = failureStress;
	epsilonYield = (failureStress == -1) ? -1 : tmpfailStrain;
	epsilonFail = (failureStress == -1) ? -1 : tmpfailStrain;
	return updateDerived();
}
Exemplo n.º 3
0
void QgsMapSettings::setMapUnits( QGis::UnitType u )
{
  mScaleCalculator.setMapUnits( u );

  // Since the map units have changed, force a recalculation of the scale.
  updateDerived();
}
Exemplo n.º 4
0
void QgsMapSettings::setRotation( double degrees )
{
  if ( qgsDoubleNear( mRotation, degrees ) ) return;

  mRotation = degrees;

  // TODO: update extent while keeping scale ?
  updateDerived();
}
Exemplo n.º 5
0
void QgsMapSettings::setExtent( const QgsRectangle& extent, bool magnified )
{
  QgsRectangle magnifiedExtent = extent;

  if ( !magnified )
    magnifiedExtent.scale( 1 / mMagnificationFactor );

  mExtent = magnifiedExtent;

  updateDerived();
}
Exemplo n.º 6
0
QgsMapSettings::QgsMapSettings()
  : mDpi( qt_defaultDpiX() ) // DPI that will be used by default for QImage instances
  , mSize( QSize( 0, 0 ) )
  , mBackgroundColor( Qt::white )
  , mSelectionColor( Qt::yellow )
  , mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling | DrawSelection )
  , mSegmentationTolerance( M_PI_2 / 90 )
{
  mScaleCalculator.setMapUnits( QgsUnitTypes::DistanceUnknownUnit );

  updateDerived();
}
Exemplo n.º 7
0
void QgsMapSettings::setMagnificationFactor( double factor )
{
  double ratio = mMagnificationFactor / factor;
  mMagnificationFactor = factor;

  double rot = rotation();
  setRotation( 0.0 );

  QgsRectangle ext = visibleExtent();
  ext.scale( ratio );

  mRotation = rot;
  mExtent = ext;
  mDpi = outputDpi() / ratio;

  updateDerived();
}
/*! Specified Young's modulus, plastic modulus, yield stress, and failure stress must all be positive.
Plastic modulus must be less than Young's modulus and failure stress must be greater than the yield stress.
*/
bool CVX_Material::setModelBilinear(float youngsModulus, float plasticModulus, float yieldStress, float failureStress)
{
	if (youngsModulus<=0){
		error = "Young's modulus must be positive";
		return false;
	}
	if (plasticModulus<=0 || plasticModulus>=youngsModulus){
		error = "Plastic modulus must be positive but less than Young's modulus";
		return false;
	}
	if (yieldStress<=0){
		error = "Yield stress must be positive";
		return false;
	}
	if (failureStress != -1.0f && failureStress <= yieldStress){
		error = "Failure stress must be positive and greater than the yield stress";
		return false;
	}

	float yieldStrain = yieldStress / youngsModulus;
	float tmpfailureStress = failureStress; //create a dummy failure stress if none was provided
	if (tmpfailureStress == -1) tmpfailureStress = 3*yieldStress;

	float tM = plasticModulus;
	float tB = yieldStress-tM*yieldStrain; //y-mx=b
	float tmpfailStrain = (tmpfailureStress-tB)/tM; // (y-b)/m = x

	strainData.clear();
	strainData.push_back(0); //add in the zero data point (required always)
	strainData.push_back(yieldStrain);
	strainData.push_back(tmpfailStrain);

	stressData.clear();
	stressData.push_back(0);
	stressData.push_back(yieldStress);
	stressData.push_back(tmpfailureStress);

	linear = false;
	E=youngsModulus;
	sigmaYield = yieldStress;
	sigmaFail = failureStress;
	epsilonYield = yieldStrain;
	epsilonFail = failureStress==-1 ? -1 : tmpfailStrain;
	return updateDerived();

}
Exemplo n.º 9
0
void QgsMapSettings::setMagnificationFactor( double factor )
{
  double ratio = mMagnificationFactor / factor;

  mMagnificationFactor = factor;

  double rot = rotation();
  setRotation( 0.0 );

  QgsRectangle ext = visibleExtent();
  ext.scale( ratio );

  mRotation = rot;
  mExtent = ext;
  mDpi = mDpi / ratio;

  QgsDebugMsg( QStringLiteral( "Magnification factor: %1  dpi: %2  ratio: %3" ).arg( factor ).arg( mDpi ).arg( ratio ) );

  updateDerived();
}
Exemplo n.º 10
0
QgsMapSettings::QgsMapSettings()
    : mDpi( qt_defaultDpiX() ) // DPI that will be used by default for QImage instances
    , mSize( QSize( 0, 0 ) )
    , mExtent()
    , mRotation( 0.0 )
    , mProjectionsEnabled( false )
    , mDestCRS( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId )  // WGS 84
    , mDatumTransformStore( mDestCRS )
    , mBackgroundColor( Qt::white )
    , mSelectionColor( Qt::yellow )
    , mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling | DrawSelection )
    , mImageFormat( QImage::Format_ARGB32_Premultiplied )
    , mValid( false )
    , mVisibleExtent()
    , mMapUnitsPerPixel( 1 )
    , mScale( 1 )
{
  updateDerived();

  // set default map units - we use WGS 84 thus use degrees
  setMapUnits( QGis::Degrees );
}
Exemplo n.º 11
0
CVX_Material::CVX_Material(void)
{
	r = -1;
	g = -1;
	b = -1;
	a = -1;
	linear = true;
	E = DEFAULT_YOUNGSMODULUS;
	sigmaYield = -1.0;
	sigmaFail = -1.0;
	epsilonYield = -1.0;
	epsilonFail = -1.0;
	nu = DEFAULT_POISSONSRATIO;
	rho = DEFAULT_DENSITY;
	alphaCTE = 0.0;
	muStatic = 0.0;
	muKinetic = 0.0;
	zetaInternal = 0.1f;
	zetaGlobal = 0.1f;
	nomSize=1.0;
	extScale=Vec3D<>(1.0, 1.0, 1.0);
	updateDerived();
}
Exemplo n.º 12
0
void QgsMapSettings::setDevicePixelRatio( float dpr )
{
  mDevicePixelRatio = dpr;
  updateDerived();
}
Exemplo n.º 13
0
void QgsMapSettings::setOutputDpi( int dpi )
{
  mDpi = dpi;

  updateDerived();
}
Exemplo n.º 14
0
void QgsMapSettings::setOutputSize( QSize size )
{
  mSize = size;

  updateDerived();
}
Exemplo n.º 15
0
void QgsMapSettings::setExtent( const QgsRectangle& extent )
{
  mExtent = extent;

  updateDerived();
}
Exemplo n.º 16
0
bool CVX_MaterialLink::updateAll()
{
	nomSize = 0.5*(vox1Mat->nomSize + vox2Mat->nomSize); //these should be the same...

	r=(int)(0.5*(vox1Mat->r + vox2Mat->r));
	g=(int)(0.5*(vox1Mat->g + vox2Mat->g));
	b=(int)(0.5*(vox1Mat->b + vox2Mat->b));
	a=(int)(0.5*(vox1Mat->a + vox2Mat->a));

	rho = 0.5f*(vox1Mat->rho + vox2Mat->rho);
	alphaCTE = 0.5f*(vox1Mat->alphaCTE + vox2Mat->alphaCTE);
	muStatic = 0.5f*(vox1Mat->muStatic + vox2Mat->muStatic);
	muKinetic = 0.5f*(vox1Mat->muKinetic + vox2Mat->muKinetic);
	zetaInternal = 0.5f*(vox1Mat->zetaInternal + vox2Mat->zetaInternal);
	zetaGlobal = 0.5f*(vox1Mat->zetaGlobal + vox2Mat->zetaGlobal);
	zetaCollision= 0.5f*(vox1Mat->zetaCollision + vox2Mat->zetaCollision);

	extScale=Vec3D<>(1.0, 1.0, 1.0);

	//failure stress (f) is the minimum of the two failure stresses, or if both are -1.0f it should also be -1.0f to denote no failure specified
	float stressFail=-1.0f, /*strainFail=-1.0f,*/ f1=vox1Mat->sigmaFail, f2=vox2Mat->sigmaFail;
	if (f1 == -1.0f) stressFail = f2; //-1.0f or vox2Mat fail
	else if (f2 == -1.0f) stressFail = f1; //vox1Mat fail
	else stressFail = f1 < f2 ? f1 : f2; //the lesser stress denotes failure

	if (vox1Mat->linear && vox2Mat->linear) setModelLinear(2.0f*vox1Mat->E*vox2Mat->E/(vox1Mat->E+vox2Mat->E), stressFail);
	else { //at least 1 bilinear or data-based, so build up data points and apply it.
		std::vector<float> newStressValues, newStrainValues;
		newStressValues.push_back(0.0f);
		newStrainValues.push_back(0.0f);

		//step up through ascending strains data points (could alternate randomly between vox1Mat and vox2Mat points
		int dataIt1 = 1, dataIt2 = 1; //iterators through each data point of the model
		while (dataIt1 < (int)vox1Mat->strainData.size() && dataIt2 < (int)vox2Mat->strainData.size()){
			float strain = FLT_MAX; //strain for the next data point is the smaller of the two possible next strain points (but we have to make sure we don't access off the end of one of the arrays)
			if (dataIt1 < (int)vox1Mat->strainData.size()) strain = vox1Mat->strainData[dataIt1];
			if (dataIt2 < (int)vox2Mat->strainData.size() && vox2Mat->strainData[dataIt2]<strain) strain = vox2Mat->strainData[dataIt2];
			else assert(strain != FLT_MAX); //this should never happen

			if (strain == vox1Mat->strainData[dataIt1]) dataIt1++;
			if (strain == vox2Mat->strainData[dataIt2]) dataIt2++;


			float modulus1 = vox1Mat->modulus(strain-FLT_EPSILON);
			float modulus2 = vox2Mat->modulus(strain-FLT_EPSILON);
			float thisModulus = 2.0f*modulus1*modulus2/(modulus1+modulus2);

			//add to the new strain/stress values
			int lastDataIndex = newStrainValues.size()-1;

			newStrainValues.push_back(strain);
			newStressValues.push_back(newStressValues[lastDataIndex] + thisModulus*(strain - newStrainValues[lastDataIndex])); //springs in series equation
		}

		setModel(newStrainValues.size(), &newStrainValues[0], &newStressValues[0]);

		//override failure points in case no failure was specified before (as possible in combos of linear and bilinear materials)
		//yield point is handled correctly in setModel.
		sigmaFail = stressFail;
		epsilonFail = stressFail==-1.0f ? -1.0f : strain(stressFail);
	}

	//poissons ratio: choose such that Ehat ends up according to spring in series of Ehat1 and EHat2
	if (vox1Mat->nu==0 && vox2Mat->nu==0) nu = 0;
	else { //poissons ratio: choose such that Ehat ends up according to spring in series of Ehat1 and EHat2
		float tmpEHat = 2*vox1Mat->_eHat*vox2Mat->_eHat/(vox1Mat->_eHat+vox2Mat->_eHat);
		float tmpE = youngsModulus();
		//completing the square algorithm to solve for nu.
		//eHat = E/((1-2nu)(1+nu)) -> E/EHat = -2nu^2-nu+1 -> nu^2+0.5nu = (EHat+E)/(2EHat)
		float c2 = (tmpEHat-tmpE)/(2*tmpEHat)+0.0625; //nu^2+0.5nu+0.0625 = c2 -> (nu+0.25)^2 = c2
		nu = sqrt(c2)-0.25; //from solving above
	}

	return updateDerived();
}
Exemplo n.º 17
0
/*! The arrays are assumed to be of equal length.
The first data point is assumed to be [0,0] and need not be provided.
At least 1 non-zero data point must be provided.
The inital segment from [0,0] to the first strain and stress value is interpreted as young's modulus.
The slope of the stress/strain curve should never exceed this value in subsequent segments.
The last data point is assumed to represent failure of the material. The 0.2% offset method is used to calculate the yield point.

Restrictions on pStrainValues:
	- The values must be positive and increasing in order.
	- Strains are defined in absolute numbers according to delta l / L.

Restrictions on pStressValues:
	- The values must be positive and increasing in order.

Special cases:
	- 1 data point (linear): Yield and failure are assumed to occur simultaneously at the single data point.
	- 2 data points (bilinear): Yield is taken as the first data point, failure at the second.

*/
bool CVX_Material::setModel(int dataPointCount, float* pStrainValues, float* pStressValues)
{
	//Pre-checks
	if (*pStrainValues==0 && *pStressValues==0) { //if first data point is 0,0, ignore it
		pStrainValues++; //advance the pointers...
		pStressValues++;
		dataPointCount--; //decrement the count
	}
	if (dataPointCount<=0){
		error = "Not enough data points";
		return false;
	}
	if (*pStrainValues<=0 || *pStressValues<=0){
		error = "First stress and strain data points negative or zero";
		return false; 
	}

	//Copy the data into something more usable (and check for monotonically increasing)
	std::vector<float> tmpStrainData;
	std::vector<float> tmpStressData;
	tmpStrainData.push_back(0); //add in the zero data point (required always)
	tmpStressData.push_back(0);
	float sweepStrain = 0.0f, sweepStress = 0.0f;
	for (int i=0; i<dataPointCount; i++){
		float thisStrain = *(pStrainValues+i); //grab the values
		float thisStress = *(pStressValues+i);

		if (thisStrain <= sweepStrain){
			error = "Out of order strain data";
			return false;
		}

		if (thisStress <= sweepStress){
			error = "Stress data is not monotonically increasing";
			return false;
		}

		if (i>0 && (thisStress-sweepStress)/(thisStrain-sweepStrain) > tmpStressData[0]/tmpStrainData[0]){
			error = "Slope of stress/strain curve should never exceed that of the first line segment (youngs modulus)";
			return false;
		}

		sweepStrain = thisStrain;
		sweepStress = thisStress;

		tmpStrainData.push_back(thisStrain); //add to the temporary vector
		tmpStressData.push_back(thisStress);
	}

	assert(tmpStrainData.size() == dataPointCount+1 && tmpStressData.size() == dataPointCount+1); //sizes match up? (+1 to include the zero point)

	//at this point, we know we have valid data and will return true
	strainData = tmpStrainData;
	stressData = tmpStressData;
	E=stressData[1]/strainData[1]; //youngs modulus is the inital slope
	sigmaFail = stressData[stressData.size()-1]; //failure stress is the highest stress data point
	epsilonFail = strainData[strainData.size()-1]; //failure strain is the highest strain data point
	linear = (dataPointCount==1);

	if (dataPointCount == 1 || dataPointCount == 2){ //linear or blinear
		sigmaYield = stressData[1];
		epsilonYield = strainData[1];
	}
	else { //.2% (0.002) strain offset to find a good yield point...
		setYieldFromData();
	}

	return updateDerived();
}
Exemplo n.º 18
0
bool CVX_Material::setNominalSize(float size)
{
	if (size <= 0) size = FLT_MIN;
	nomSize=size;
	return updateDerived(); //update derived quantities
}
Exemplo n.º 19
0
void CVX_Material::setDensity(float density)
{
	if (density <= 0) density = FLT_MIN; //density of exactly 0 will cause problems, but can get as close as desired.
	rho = density;
	updateDerived();
}