Add inclined section visualization
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
@@ -17,6 +19,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
public double CenterCover { get; set; } = 0.05;
|
||||
public double ReinforcementArea { get; set; } = 0;
|
||||
public IReinforcementLibMaterial ReinforcementMaterial { get; set; }
|
||||
public IPrimitiveVisualProperty VisualProperty { get; set; }
|
||||
|
||||
public BeamShearSection(Guid id)
|
||||
{
|
||||
@@ -24,6 +27,10 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
ConcreteMaterial = ConcreteLibMaterialFactory.GetConcreteLibMaterial(ConcreteLibTypes.Concrete25);
|
||||
ReinforcementMaterial = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement500).HelperMaterial as IReinforcementLibMaterial;
|
||||
ConcreteMaterial.TensionForULS = true;
|
||||
VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("DarkGray")
|
||||
};
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
@@ -7,7 +8,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
/// <summary>
|
||||
/// Properties of RC cross-section for shear strength of beam
|
||||
/// </summary>
|
||||
public interface IBeamShearSection : ISaveable, ICloneable
|
||||
public interface IBeamShearSection : ISaveable, ICloneable, IHasVisualProperty
|
||||
{
|
||||
string? Name { get; set; }
|
||||
/// <summary>
|
||||
|
||||
@@ -36,6 +36,16 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
Check();
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Calculation has been started", TraceLogStatuses.Debug);
|
||||
if (stirrupByDensity.EndCoordinate < inclinedSection.StartCoord)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Stirrup end coordinate Xend = {stirrupByDensity.EndCoordinate}(m) is less than incline section start coordinate Xstart = {inclinedSection.StartCoord}(m), stirrup {stirrupByDensity.Name} has been ignored");
|
||||
return 0;
|
||||
}
|
||||
if (stirrupByDensity.StartCoordinate > inclinedSection.EndCoord)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Stirrup start coordinate Xstart = {stirrupByDensity.StartCoordinate}(m) is bigger than incline section end coordinate Xend = {inclinedSection.EndCoord}(m), stirrup {stirrupByDensity.Name} has been ignored");
|
||||
return 0;
|
||||
}
|
||||
double crackLength = inclinedSection.EndCoord - inclinedSection.StartCoord;
|
||||
TraceLogger?.AddMessage($"Length of crack = {inclinedSection.EndCoord} - {inclinedSection.StartCoord} = {crackLength}(m)");
|
||||
double crackEndCoord = Math.Min(stirrupByDensity.EndCoordinate, inclinedSection.EndCoord);
|
||||
|
||||
@@ -52,6 +52,16 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
public double GetShearStrength()
|
||||
{
|
||||
InitializeStrategies();
|
||||
if (stirrupByRebar.EndCoordinate < inclinedSection.StartCoord)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Stirrup end coordinate Xend = {stirrupByRebar.EndCoordinate}(m) is less than incline section start coordinate Xstart = {inclinedSection.StartCoord}(m), stirrup {stirrupByRebar.Name} has been ignored");
|
||||
return 0;
|
||||
}
|
||||
if (stirrupByRebar.StartCoordinate > inclinedSection.EndCoord)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Stirrup start coordinate Xstart = {stirrupByRebar.StartCoordinate}(m) is bigger than incline section end coordinate Xend = {inclinedSection.EndCoord}(m), stirrup {stirrupByRebar.Name} has been ignored");
|
||||
return 0;
|
||||
}
|
||||
TraceLogger?.AddMessage($"Stirrup diameter d = {stirrupByRebar.Diameter}(m)");
|
||||
TraceLogger?.AddMessage($"Stirrup leg number n = {stirrupByRebar.LegCount}");
|
||||
TraceLogger?.AddMessage($"Stirrup spacing S = {stirrupByRebar.Spacing}(m)");
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
Id = id;
|
||||
VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("Black")
|
||||
Color = (Color)ColorConverter.ConvertFromString("Gray")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
Id = id;
|
||||
VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("Black")
|
||||
Color = (Color)ColorConverter.ConvertFromString("Blue")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
Material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement400).HelperMaterial as IReinforcementLibMaterial;
|
||||
VisualProperty = new PrimitiveVisualProperty(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("Black")
|
||||
Color = (Color)ColorConverter.ConvertFromString("Brown")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,35 +6,40 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses
|
||||
{
|
||||
public class ExportFrameWorkElementLogic : IExportResultLogic
|
||||
{
|
||||
private FrameworkElement visual;
|
||||
private FrameworkElement element;
|
||||
private double scaleFactor;
|
||||
public string FileName { get; set; }
|
||||
|
||||
public void Export()
|
||||
{
|
||||
var encoder = new PngBitmapEncoder();
|
||||
EncodeVisual(visual, FileName, encoder);
|
||||
EncodeVisual(element, FileName, encoder);
|
||||
}
|
||||
|
||||
public ExportFrameWorkElementLogic(FrameworkElement visual)
|
||||
public ExportFrameWorkElementLogic(FrameworkElement visual, double scaleFactor = 1)
|
||||
{
|
||||
this.visual = visual;
|
||||
this.element = visual;
|
||||
this.scaleFactor = scaleFactor;
|
||||
}
|
||||
|
||||
private static void EncodeVisual(FrameworkElement visual, string fileName, BitmapEncoder encoder)
|
||||
private void EncodeVisual(FrameworkElement visual, string fileName, BitmapEncoder encoder)
|
||||
{
|
||||
// Measure and arrange the element to ensure it's fully rendered
|
||||
visual.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
Rect previousBounds = VisualTreeHelper.GetDescendantBounds(visual);
|
||||
visual.Arrange(new Rect(0, 0, visual.ActualWidth, visual.ActualHeight));
|
||||
//visual.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
//Rect previousBounds = VisualTreeHelper.GetDescendantBounds(visual);
|
||||
//visual.Arrange(new Rect(0, 0, visual.ActualWidth, visual.ActualHeight));
|
||||
element.Measure(new Size(element.ActualWidth, element.ActualHeight));
|
||||
element.Arrange(new Rect(new Size(element.ActualWidth, element.ActualHeight)));
|
||||
|
||||
var bitmap = new RenderTargetBitmap(
|
||||
(int)visual.ActualWidth,
|
||||
(int)visual.ActualHeight,
|
||||
(int)(visual.ActualWidth * scaleFactor),
|
||||
(int)(visual.ActualHeight * scaleFactor),
|
||||
96,
|
||||
96,
|
||||
PixelFormats.Pbgra32);
|
||||
@@ -43,7 +48,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses
|
||||
var frame = BitmapFrame.Create(bitmap);
|
||||
encoder.Frames.Add(frame);
|
||||
using (var stream = File.Create(fileName)) encoder.Save(stream);
|
||||
visual.Arrange(previousBounds);
|
||||
//visual.Arrange(previousBounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user