Menu

compute volume between two 3D meshes

Mike
2016-05-13
2019-06-11
  • Mike

    Mike - 2016-05-13

    I need to compute the volume between 2 3D meshes. My algorithm is to find the intersection between the two (where one is always larger on the XY plane than the other) by using Clipper, and then find the difference between the volumes under the solution's mesh and the smaller of the two meshes. I'm setting use_xyz and assuming that Clipper will keep my input z values and then call the ZFillFunction when it's interpolating points. I'm also assuming that the input bot1-top1 and bot2-top2 are two different edges and I can pick either edge to interpolate z. Is my understanding correct?

            Clipper clipper = new Clipper();
            clipper.ZFillFunction = MyZFillCallback;
            Poly inner = DTriangListToTriList(innerTris);
            Poly outer = DTriangListToTriList(outerTris);
            Poly solution = new Poly();
            clipper.AddPaths(outer, PolyType.ptSubject, true);
            clipper.AddPaths(inner, PolyType.ptClip, true);
            clipper.Execute(ClipType.ctIntersection, solution);
    
            // convert polys back to triangles
            ArrayList result = new ArrayList();
            foreach (List<IntPoint> poly in solution)
            {
                result.AddRange(PolyToDTriangles(poly));
            }
    
        private void MyZFillCallback(IntPoint bot1, IntPoint top1, 
                            IntPoint bot2, IntPoint top2, ref IntPoint pt)
        {
            try
            {
                if (bot1.X == top1.X || bot1.Y == top1.Y)
                    pt.Z = bot1.Z;
                else
                {
                    // parametric equations
                    // x=x0+t(x1-x0) 
                    // y=y0+t(y1-y0)
                    // z=z0+t(z1-z0)
                    double t1 = (pt.X - bot1.X) / (top1.X - bot1.X);
                    double t2 = (pt.Y - bot1.Y) / (top1.Y - bot1.Y);
                    pt.Z = (Int64)(bot1.Z + t1 * (top1.Z - bot1.Z));
                }
            }
            catch (Exception e)
            {
                _logger.Error(e.Message, e);
            }
        }
    
     
  • David Orejuela Esteban

    Same problem here...

     
  • David Orejuela Esteban

    As I read somewhere in the forum, Z isn't the 3d's z dimension, is an auxiliar storage member, can be used for example to store related vertex information as material IDs, or some kind of flags need to be propagated.

     
MongoDB Logo MongoDB