本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddBoundingBox方法的具体用法?C# MeshBuilder.AddBoundingBox怎么用?C# MeshBuilder.AddBoundingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HelixToolkit.Wpf.MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.AddBoundingBox方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateModel
private Model3D CreateModel()
{
var plotModel = new Model3DGroup();
var axesMeshBuilder = new MeshBuilder();
_realRect3D = GetSampleImageBox();
axesMeshBuilder.AddBoundingBox(_realRect3D, 0.01);
plotModel.Children.Add(new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Yellow));
switch (CurrentDirection)
{
case FrameDirection.Top:
CreateTopSelectionSlice(plotModel, SectionBrush);
CreateTopMaxSlice(plotModel);
CreateTopPartSlice(plotModel, SectionPosition);
break;
case FrameDirection.Front:
CreateFrontSelectionSlice(plotModel, SectionBrush);
CreateFrontMaxSlice(plotModel);
CreateFrontPartSlice(plotModel, SectionPosition);
break;
case FrameDirection.Left:
CreateLeftSelectionSlice(plotModel, SectionBrush);
CreateLeftMaxSlice(plotModel);
CreateLeftPartSlice(plotModel, SectionPosition);
break;
default:
throw new InvalidOperationException("Can not process the direction.");
}
return plotModel;
}
示例2: CreateModel
//.........这里部分代码省略.........
// make color value 0 at texture coordinate 0.5
if (Math.Abs(minColorValue) < Math.Abs(maxColorValue))
minColorValue = -maxColorValue;
else
maxColorValue = -minColorValue;
// set the texture coordinates by z-value or ColorValue
var texcoords = new Point[rows,columns];
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
double u = (Points[i, j].Z - minZ)/(maxZ - minZ);
if (ColorValues != null)
u = (ColorValues[i, j] - minColorValue)/(maxColorValue - minColorValue);
texcoords[i, j] = new Point(u, u);
}
var surfaceMeshBuilder = new MeshBuilder();
surfaceMeshBuilder.AddRectangularMesh(Points, texcoords);
var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
surfaceModel.BackMaterial = surfaceModel.Material;
var axesMeshBuilder = new MeshBuilder();
for (double x = minX; x <= maxX; x += IntervalX)
{
double j = (x - minX)/(maxX - minX)*(columns - 1);
var path = new List<Point3D> {new Point3D(x, minY, minZ)};
for (int i = 0; i < rows; i++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(x, maxY, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true, FontSize,
new Point3D(x, minY - FontSize*2.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize,
new Point3D((minX + maxX)*0.5,
minY - FontSize*6, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
for (double y = minY; y <= maxY; y += IntervalY)
{
double i = (y - minY)/(maxY - minY)*(rows - 1);
var path = new List<Point3D> {new Point3D(minX, y, minZ)};
for (int j = 0; j < columns; j++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(maxX, y, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true, FontSize,
new Point3D(minX - FontSize*3, y, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize,
new Point3D(minX - FontSize*10,
(minY + maxY)*0.5, minZ),
new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0));
plotModel.Children.Add(label);
}
double z0 = (int) (minZ/IntervalZ)*IntervalZ;
for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ)
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true, FontSize,
new Point3D(minX - FontSize*3, maxY, z),
new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize,
new Point3D(minX - FontSize*10, maxY,
(minZ + maxZ)*0.5),
new Vector3D(0, 0, 1), new Vector3D(1, 0, 0));
plotModel.Children.Add(label);
}
var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0*(maxZ - minZ));
axesMeshBuilder.AddBoundingBox(bb, LineThickness);
var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black);
plotModel.Children.Add(surfaceModel);
plotModel.Children.Add(axesModel);
return plotModel;
}
示例3: CreateModel
//.........这里部分代码省略.........
var axesMeshBuilder = new MeshBuilder();
for (double x = minX; x <= maxX; x += IntervalX)
{
double j = (x - minX)/(maxX - minX)*(columns - 1);
//var path = new List<Point3D> { new Point3D(x , minY , minZ) };
var path = new List<Point3D> { new Point3D(x, minY , minZ) };
for (int i = 0; i < rows; i++)
{
Point3D p = BilinearInterpolation(Points, i, j);
p.X *= ScaleX;
p.Y *= ScaleY;
p.Z *= ScaleZ;
path.Add(p);
}
path.Add(new Point3D(x, maxY, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(x / ScaleX), Brushes.Black, true, FontSize,
new Point3D(x, minY - FontSize * 2.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.Black, true, FontSize,
new Point3D((minX + maxX)*0.5,
minY - FontSize * 6, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
#endregion
#region eje y
for (double y = minY; y <= maxY; y += IntervalY)
{
double i = (y - minY)/(maxY - minY)*(rows - 1);
var path = new List<Point3D> {new Point3D(minX, y, minZ)};
for (int j = 0; j < columns; j++)
{
Point3D p = BilinearInterpolation(Points, i, j);
p.X *= ScaleX;
p.Y *= ScaleY;
p.Z *= ScaleZ;
path.Add(p);
}
path.Add(new Point3D(maxX, y, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(y / ScaleY), Brushes.Black, true, FontSize,
new Point3D(minX - FontSize * 3, y, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.Black, true, FontSize,
new Point3D(minX - FontSize * 10,
(minY + maxY) * 0.5, minZ),
new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0));
plotModel.Children.Add(label);
}
#endregion
#region eje z
double z0 = (int) (minZ/IntervalZ)*IntervalZ;
for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ)
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(StringUtils.CodeString(z / ScaleZ), Brushes.Black, true, FontSize,
new Point3D(minX - FontSize * 3, maxY, z),
new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.Black, true, FontSize,
new Point3D(minX - FontSize * 10, maxY,
(minZ + maxZ)*0.5),
new Vector3D(0, 0, 1), new Vector3D(1, 0, 0));
plotModel.Children.Add(label);
}
#endregion
var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, 0*(maxZ - minZ));
axesMeshBuilder.AddBoundingBox(bb, LineThickness);
var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black);
plotModel.Children.Add(surfaceModel);
plotModel.Children.Add(axesModel);
return plotModel;
}
示例4: CreateModel
//.........这里部分代码省略.........
out red, out green, out blue);
bm_maker.SetPixel(ix, iy, red, green, blue, 255);
}
catch
{
}
}
}
var texcoords = new Point[rows, columns];
for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++)
{
texcoords[i, j] = new Point(i, j);
}
var surfaceMeshBuilder = new MeshBuilder();
surfaceMeshBuilder.AddRectangularMesh(Points, texcoords);
var surfaceModel = new GeometryModel3D(surfaceMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(new ImageBrush(bm_maker.MakeBitmap(128, 128)), null, null, 1, 0));
surfaceModel.BackMaterial = surfaceModel.Material;
var axesMeshBuilder = new MeshBuilder();
for (double x = minX; x <= maxX; x += IntervalX)
{
double j = (x - minX) / (maxX - minX) * (columns - 1);
var path = new List<Point3D> {new Point3D(x, minY, minZ)};
for (int i = 0; i < rows; i++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(x, maxY, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.Black, true,
FontSize * 3,
new Point3D(x, minY - FontSize * 2.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Axe réel", Brushes.Black, true,
FontSize * 10,
new Point3D((minX + maxX) * 0.25,
minY - FontSize * 6 - 0.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
for (double y = minY; y <= maxY; y += IntervalY)
{
double i = (y - minY) / (maxY - minY) * (rows - 1);
var path = new List<Point3D> {new Point3D(minX, y, minZ)};
for (int j = 0; j < columns; j++)
{
path.Add(BilinearInterpolation(Points, i, j));
}
path.Add(new Point3D(maxX, y, minZ));
axesMeshBuilder.AddTube(path, LineThickness, 9, false);
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.Black, true,
FontSize * 3,
new Point3D(minX - FontSize * 3, y, minZ),
new Vector3D(0, 1, 0), new Vector3D(1, 0, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Axe imaginaire", Brushes.Black, true,
FontSize * 10,
new Point3D(minX - FontSize * 10,
(minY + maxY) * 0.5, minZ),
new Vector3D(0, 1, 0), new Vector3D(1, 0, 0));
plotModel.Children.Add(label);
}
double z0 = (int) (minZ / IntervalZ) * IntervalZ;
for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ)
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.Black, true,
FontSize * 3,
new Point3D(minX - FontSize * 3, maxY, z),
new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Module", Brushes.Black, true, FontSize * 10,
new Point3D(minX - FontSize * 10 - 1.5, maxY,
(minZ + maxZ) * 0.5),
new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
plotModel.Children.Add(label);
}
var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, (maxZ - minZ));
axesMeshBuilder.AddBoundingBox(bb, LineThickness);
var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Black);
plotModel.Children.Add(surfaceModel);
plotModel.Children.Add(axesModel);
return plotModel;
}
示例5: CreateModel
/// <summary>
/// This function creates the model
/// </summary>
/// <returns>A created plot model</returns>
private Model3D CreateModel()
{
var plotModel = new Model3DGroup();
if (Points == null || Points.Count == 0) return plotModel;
double minX = Points.Min(p => p.X);
double maxX = Points.Max(p => p.X);
double minY = Points.Min(p => p.Y);
double maxY = Points.Max(p => p.Y);
double minZ = Points.Min(p => p.Z);
double maxZ = Points.Max(p => p.Z);
double minValue = 0;
double maxValue = 10000;
var valueRange = maxValue - minValue;
var scatterMeshBuilder = new MeshBuilder(true, true);
var oldTCCount = 0;
for (var i = 0; i < Points.Count; ++i)
{
scatterMeshBuilder.AddSphere(Points[i], SphereSize, 4, 4);
var newTCCount = scatterMeshBuilder.TextureCoordinates.Count;
oldTCCount = newTCCount;
}
var scatterModel = new GeometryModel3D(scatterMeshBuilder.ToMesh(),
MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
scatterModel.BackMaterial = scatterModel.Material;
// create bounding box with axes indications
var axesMeshBuilder = new MeshBuilder();
for (double x = minX; x <= maxX; x += IntervalX)
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.White, true, FontSize,
new Point3D(x, minY - FontSize * 2.5, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.White, true, FontSize,
new Point3D((minX + maxX) * 0.5,
minY - FontSize * 6, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
for (double y = minY; y <= maxY; y += IntervalY)
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.White, true, FontSize,
new Point3D(minX - FontSize * 3, y, minZ),
new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.White, true, FontSize,
new Point3D(minX - FontSize * 10,
(minY + maxY) * 0.5, minZ),
new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0));
plotModel.Children.Add(label);
}
double z0 = (int)(minZ / IntervalZ) * IntervalZ;
for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ)
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.White, true, FontSize,
new Point3D(minX - FontSize * 3, maxY, z),
new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
plotModel.Children.Add(label);
}
{
GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.White, true, FontSize,
new Point3D(minX - FontSize * 10, maxY,
(minZ + maxZ) * 0.5),
new Vector3D(0, 0, 1), new Vector3D(1, 0, 0));
plotModel.Children.Add(label);
}
var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, maxZ - minZ);
axesMeshBuilder.AddBoundingBox(bb, LineThickness);
var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.White);
plotModel.Children.Add(scatterModel);
plotModel.Children.Add(axesModel);
return plotModel;
}
示例6: CreateModel
private Model3D CreateModel()
{
bool isCylindarMode = CylindarMode && ExpendedBrush != null && (SlideDirection == CooridinateDirection.ZN || SlideDirection == CooridinateDirection.ZP);
bool isIntersectionmode = IntersectionMode && SectionBrush != null;
bool isIntersectedCylindarMode = isCylindarMode && isIntersectionmode;
var plotModel = new Model3DGroup();
var axesMeshBuilder = new MeshBuilder();
_realRect3D = GetSampleImageBox();
axesMeshBuilder.AddBoundingBox(_realRect3D, 0.01);
plotModel.Children.Add(new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Yellow));
var flipTransform = new ScaleTransform(1, -1, 0.5, 0.5);
var znBrush = ZNBrush?.Clone();
var zpBrush = ZPBrush?.Clone();
if (zpBrush != null)
{
zpBrush.Transform = flipTransform;
}
var ynBrush = YNBrush?.Clone();
var ypBrush = YPBrush?.Clone();
if (ypBrush != null)
{
ypBrush.Transform = flipTransform;
}
var xnBrush = XNBrush?.Clone();
var xpBrush = XPBrush?.Clone();
if (xpBrush != null)
{
xpBrush.Transform = flipTransform;
}
var expBrush = ExpendedBrush?.Clone();
Rect3D rectDraw = _realRect3D;
if (isIntersectionmode)
{
switch (SlideDirection)
{
case CooridinateDirection.XP:
{
rectDraw.SizeX = SectionPosition;
xpBrush = SectionBrush.Clone();
xpBrush.Transform = flipTransform;
double c = SectionPosition / _realRect3D.SizeX;
ynBrush.Viewbox = new Rect(0, 0, 1, c);
ypBrush.Viewbox = new Rect(0, 0, 1, c);
znBrush.Viewbox = new Rect(0, 0, c, 1);
zpBrush.Viewbox = new Rect(0, 0, c, 1);
}
break;
case CooridinateDirection.XN:
{
rectDraw.X = SectionPosition;
rectDraw.SizeX -= rectDraw.X;
xnBrush = SectionBrush.Clone();
double c = SectionPosition / _realRect3D.SizeX;
ynBrush.Viewbox = new Rect(0, c, 1, 1 - c);
ypBrush.Viewbox = new Rect(0, c, 1, 1 - c);
znBrush.Viewbox = new Rect(c, 0, 1 - c, 1);
zpBrush.Viewbox = new Rect(c, 0, 1 - c, 1);
}
break;
case CooridinateDirection.YP:
{
rectDraw.SizeY = SectionPosition;
ypBrush = SectionBrush.Clone();
ypBrush.Transform = flipTransform;
double c = SectionPosition / _realRect3D.SizeY;
xnBrush.Viewbox = new Rect(0, 0, c, 1);
xpBrush.Viewbox = new Rect(0, 0, c, 1);
znBrush.Viewbox = new Rect(0, 0, 1, c);
zpBrush.Viewbox = new Rect(0, 0, 1, c);
}
break;
case CooridinateDirection.YN:
{
rectDraw.Y = SectionPosition;
rectDraw.SizeY -= rectDraw.Y;
ynBrush = SectionBrush.Clone();
double c = SectionPosition / _realRect3D.SizeY;
xnBrush.Viewbox = new Rect(c, 0, 1 - c, 1);
xpBrush.Viewbox = new Rect(c, 0, 1 - c, 1);
znBrush.Viewbox = new Rect(0, c, 1, 1 - c);
zpBrush.Viewbox = new Rect(0, c, 1, 1 - c);
}
break;
case CooridinateDirection.ZP:
{
rectDraw.SizeZ = SectionPosition;
zpBrush = SectionBrush.Clone();
zpBrush.Transform = flipTransform;
//.........这里部分代码省略.........