[fix] adjusted the validation and update functions in 'FinSet' to better meet user's expectations
This commit is contained in:
		
							parent
							
								
									ac96222964
								
							
						
					
					
						commit
						f481bb3707
					
				| @ -71,7 +71,7 @@ public class EllipticalFinSet extends FinSet { | ||||
| 		if (MathUtil.equals(this.length, length)) | ||||
| 			return; | ||||
| 		this.length = length; | ||||
| 		validateFinTab(); | ||||
| 		validateFinTabLength(); | ||||
| 		fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| @ -274,7 +274,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
| 		} | ||||
| 		 | ||||
| 		tabHeight = newTabHeight; | ||||
| 
 | ||||
| 		validateFinTabHeight(); | ||||
| 		fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); | ||||
| 	} | ||||
| 	 | ||||
| @ -293,9 +293,15 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
| 		 | ||||
| 		tabLength = lengthRequest; | ||||
| 		 | ||||
| 		setTabPosition(); | ||||
| 		 | ||||
| 		fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); | ||||
| 	} | ||||
| 	 | ||||
| 	protected void setTabPosition(){ | ||||
| 		this.tabPosition = this.tabOffsetMethod.getAsPosition(tabOffset, tabLength, length); | ||||
| 	} | ||||
| 	 | ||||
| 	/**  | ||||
| 	 * internally, set the internal offset and optionally validate tab | ||||
| 	 *  | ||||
| @ -303,7 +309,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
| 	 */ | ||||
| 	public void setTabOffset( final double offsetRequest) { | ||||
| 		tabOffset = offsetRequest; | ||||
| 		tabPosition = tabOffsetMethod.getAsPosition( tabOffset, tabLength, length); | ||||
| 		setTabPosition(); | ||||
| 		 | ||||
| 		fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); | ||||
| 	} | ||||
| @ -318,7 +324,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
|      */ | ||||
| 	public void setTabOffsetMethod(final AxialMethod newPositionMethod) { | ||||
| 		this.tabOffsetMethod = newPositionMethod; | ||||
| 		this.tabOffset = tabOffsetMethod.getAsOffset( tabPosition, tabLength, length); | ||||
| 		this.tabOffset = this.tabOffsetMethod.getAsOffset(tabPosition, tabLength, length); | ||||
| 		 | ||||
| 		fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); | ||||
| 	} | ||||
| 	 | ||||
| @ -340,9 +347,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
| 		return tabPosition + tabLength; | ||||
| 	} | ||||
| 	 | ||||
| 	public void validateFinTab(){ | ||||
| 		this.tabPosition = this.tabOffsetMethod.getAsPosition(tabOffset, tabLength, length); | ||||
| 
 | ||||
| 	public void validateFinTabPosition() { | ||||
| 		//check front bounds: | ||||
| 		if (tabPosition < 0) { | ||||
| 			this.tabPosition = 0; | ||||
| @ -352,6 +357,11 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
| 		if (this.length < tabPosition) { | ||||
| 			this.tabPosition = length; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void validateFinTabLength() { | ||||
| 		//System.err.println(String.format("    >> Fin Tab Length: %.6f @ %.6f", tabLength, tabOffset)); | ||||
| 		 | ||||
| 		final double xTabBack = getTabTrailingEdge(); | ||||
| 		if (this.length < xTabBack) { | ||||
| 			this.tabLength -= (xTabBack - this.length); | ||||
| @ -359,6 +369,10 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
| 		 | ||||
| 		tabLength = Math.max(0, tabLength); | ||||
| 		 | ||||
| 		//System.err.println(String.format("    << Fin Tab Length: %.6f @ %.6f", tabLength, tabOffset)); | ||||
| 	} | ||||
| 	 | ||||
| 	public void validateFinTabHeight(){ | ||||
| 		// check tab height  | ||||
| 		if( null != getParent() ){ | ||||
| 			// pulls the parent-body radius at the fin-tab reference point. | ||||
| @ -792,7 +806,6 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona | ||||
| 			this.centerOfMass = Coordinate.NaN; | ||||
| 			this.totalVolume = Double.NaN; | ||||
| 			this.cantRotation = null; | ||||
| 			validateFinTab(); | ||||
| 		} | ||||
| 		 | ||||
| 		super.componentChanged(e); | ||||
|  | ||||
| @ -319,7 +319,7 @@ public class FreeformFinSet extends FinSet { | ||||
| 			clampLastPoint(); | ||||
| 
 | ||||
| 			if (oldLength != this.length) | ||||
| 				validateFinTab(); | ||||
| 				validateFinTabLength(); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -77,8 +77,9 @@ public class TrapezoidFinSet extends FinSet { | ||||
| 		if (length == r) | ||||
| 			return; | ||||
| 		length = Math.max(r, 0); | ||||
| 		validateFinTab(); | ||||
| 		fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); | ||||
| 		setTabPosition(); | ||||
| 		 | ||||
| 		fireComponentChangeEvent(ComponentChangeEvent.AEROMASS_CHANGE); | ||||
| 	} | ||||
| 	 | ||||
| 	public double getTipChord() { | ||||
|  | ||||
| @ -93,7 +93,7 @@ public class FinSetTest extends BaseTestCase { | ||||
| 			fins.setTabOffsetMethod( methods[caseIndex]); | ||||
| 
 | ||||
| 			//query | ||||
| 			double actShift = fins.getTabOffset(); | ||||
| 			final double actShift = fins.getTabOffset(); | ||||
| 			assertEquals(String.format("Offset doesn't match for: %s \n", methods[caseIndex].name()), expShift[caseIndex], actShift, EPSILON); | ||||
| 		} | ||||
| 	} | ||||
| @ -148,7 +148,11 @@ public class FinSetTest extends BaseTestCase { | ||||
| 		{   // MIDDLE -> native | ||||
| 			fins.setTabOffsetMethod(AxialMethod.MIDDLE); | ||||
| 			fins.setTabOffset(0.0); | ||||
| 			fins.setTabHeight(0.02); | ||||
| 			 | ||||
| 			assertEquals("Setting by MIDDLE method failed!", 0.015, fins.getTabFrontEdge(), EPSILON); | ||||
| 			assertEquals("Setting by MIDDLE method failed!", 0.0, fins.getTabOffset(), EPSILON); | ||||
| 			assertEquals("Setting by MIDDLE method failed!", 0.02, fins.getTabLength(), EPSILON); | ||||
| 			 | ||||
| 			fins.setTabLength(0.04); | ||||
| 			 | ||||
| 			assertEquals("Setting by MIDDLE method failed!", 0.005, fins.getTabFrontEdge(), EPSILON); | ||||
| @ -172,8 +176,8 @@ public class FinSetTest extends BaseTestCase { | ||||
| 
 | ||||
| 		((TrapezoidFinSet)fins).setRootChord(0.08); | ||||
| 		 | ||||
| 		assertEquals("Front edge doesn't match after adjusting root chord...", 0.03, fins.getTabFrontEdge(), EPSILON); | ||||
| 		assertEquals("Offset doesn't match after adjusting root chord....", 0.0, fins.getTabOffset(), EPSILON); | ||||
| 		assertEquals("Front edge doesn't match after adjusting root chord...", 0.03, fins.getTabFrontEdge(), EPSILON); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user