WireFrameVisual from GeometryModel3D created with MeshBooleanOperations

Is it possible to create a Wireframe using a GeometryModel3D created with meshes joined or substracted with the MeshBooleanOperations?

I am able to create a Wireframe using a pre defined by the library GeometryModel3D for example: Boxes, Cones etc..
But I fail with this code below which seems at first glance to be correct:

var boxMesh = new Ab3d.Meshes.BoxMesh3D(new Point3D(0, 0, 0), new Size3D(50, 50, 50), 1, 1, 1).Geometry;
var boxMesh2 = new Ab3d.Meshes.BoxMesh3D(new Point3D(0, 15, 0), new Size3D(25, 25, 25), 1, 1, 1).Geometry;

var joinedBoxesMesh = Ab3d.Utilities.MeshBooleanOperations.Union(boxMesh, boxMesh2);
var brush = new SolidColorBrush() { Opacity = 0.4, Color = Colors.SlateBlue };
var material = new DiffuseMaterial(brush);
var geometryModel = new GeometryModel3D(joinedBoxesMesh, material)

 Ab3d.Utilities.MeshUtils.CreatePolygonIndicesByDefault = true;

 WireframeVisual1.ShowPolygonLines = true;
 WireframeVisual1.OriginalModel = geometryModel ;
PolygonIndices are defined by a manually created collection of positions that can define the polygons for a 3D model and that can be used to show edges of the 3D model (this shows less lines then when lines for each triangle are shown).

The standard objects created by Ab3d.PowerToys can generate the PolygonIndices (this is enabled by setting the static Ab3d.Utilities.MeshUtils.CreatePolygonIndicesByDefault filed to true - though in your case it would be better to set that before creating the box meshes).

But some advanced objects like creating an extruded objects and using boolean operations does not recreate the PolygonIndices.

So you have two options:
1) if you just want to show wireframe with showing all the triangles, then just set the WireframeVisual1.ShowPolygonLines to false.

2) if you want to show correct model edges, then you will need to use the EdgeLinesFactory class that can define the model edges - see the "Edge lines creation" sample in the "3D lines section". Then you will need to use MultiLineVisual3D to show the 3D lines (and not WireframeVisual3D).
Andrej Benedik
Thanks for your fast reply.

I only need to have the models edges visible. When I tried to do what you replied earlier, all of the triangle edges were visible. Changing the parameter edgeStartAngleInDegrees doesn't give me the result i would expect.

I wrote something like this (which is pretty much a copy from the edges example):
//caseObject3D is a GeometryModel3D

var edgeLinePositions = new Point3DCollection();
EdgeLinesFactory.AddEdgeLinePositions(caseObject3D, 0, edgeLinePositions);
MultiLineVisual3D _multiLineVisual3D;
_multiLineVisual3D = new MultiLineVisual3D()
  Positions = edgeLinePositions,
  LineColor = Colors.Black,
  LineThickness = 4,


Am I missing something?

Also, when i set the CreatePolygonIndicesByDefault = true before creating the meshes i get a StackOverflowException...
The boolean operations split the triangles in the original mesh into smaller triangles as seen here - using your 2 meshes and a union operation:


This leads to some additional lines when detecting edges:


If you can create two meshes where their volume does not intersect, then you can use Ab3d.Utilities.MeshUtils.CombineMeshes method to combine two meshes into one - for example:

var boxMesh1 = new Ab3d.Meshes.BoxMesh3D(new Point3D(0, 0, 0), new Size3D(50, 50, 50), 1, 1, 1).Geometry;
           var boxMesh2 = new Ab3d.Meshes.BoxMesh3D(new Point3D(0, 28.25, 0), new Size3D(25, 7.5, 25), 1, 1, 1).Geometry;

var joinedBoxesMesh = Ab3d.Utilities.MeshUtils.CombineMeshes(boxMesh1, boxMesh2);

This produces the following:

Andrej Benedik
This works like the Union boolean operation. Is it possible to achieve my goal when I also need to use Substract or Intersect on my meshes?
I am working on updating the EdgeLinesFactory.AddEdgeLinePositions so that it will correctly remove the lines that do not represent an actual edge. It will be part of the new verison of Ab3d.PowerToys that is going to be released very soon (this is the last new feature that will come to the next version).
Andrej Benedik
Great to hear that. Do you know if it's a matter of days, weeks or months?
I hope that I will be able to release it next week.
Andrej Benedik
Okay. Thanks for helping. Waiting for the update!

Forum Jump:

Users browsing this thread:
1 Guest(s)