【问题标题】:Eyeshot Devdept Solid to surfaceEyeshot Devdept 实体到表面
【发布时间】:2021-03-03 03:13:16
【问题描述】:

我使用的是 eyeshot 2020 版本。

有一个叫做 CutBy 的函数,它通过一个表面切割一个网格,它工作正常。

问题是浮出水面。例如,从实体或网格,如何创建曲面。

例如,我有一个与另一个实体相交的实体。我需要差异,但 Solid.Difference 方法只给出了切割实体的一部分。不幸的是,我需要另一部分。

我可以通过 Solid.Intersection 方法获得交叉点。我可以通过交叉点的表面切割实体,但我找不到如何获得实体的表面。

简单来说,问题是如何从一个实体中获取一个表面或一个区域对象来调用Solid.Cutby(surface.Plane)方法。

这就是我所做的:

        var template = sceneLeft.Entities[0] as Mesh;
        var piece = sceneLeft.Entities[1] as Mesh;

        var solidT = template.ConvertToSolid();
        var solidP = piece.ConvertToSolid();

        var diff1 = Solid.Difference(solidT, solidP);
        var diff2 = Solid.Difference(solidP, solidT);

        var intersection = Solid.Intersection(solidT, solidP);

        diff1[0].Color = System.Drawing.Color.LightGray;
        diff2[0].Color = System.Drawing.Color.LightGray;

        diff1[0].ColorMethod = colorMethodType.byEntity;
        diff2[0].ColorMethod = colorMethodType.byEntity;

        diff1[0].EntityData = "base";
        diff2[0].EntityData = "piece";

        sceneLeft.Entities.Clear();

      

        //sceneLeft.Entities.Add(diff1[0]);
        //sceneLeft.Entities.Add(piece);

        sceneLeft.Entities.Add(diff2[0]); //diff2 is returns only one solid and not the part that I need.
        //sceneLeft.Entities.Add(intersection[0]);

        //diff2[0].Scale(1.02, 1.02, 1.02);

        //var diff3 = Solid.Difference(intersection[0], solidT);

        //sceneLeft.Entities.Add(diff3[0]);

        sceneLeft.Entities.Regen();
        sceneLeft.Invalidate();

提前致谢。

【问题讨论】:

  • 我相信差异是一系列差异,因为差异可能会产生不止一个实体。我也相信数组是按大小排序的,最大的一块是 diff[0],第二大的是 diff[1]。等等
  • 我也对你的问题感到困惑。因为你没有给你的两个网格提供维度,所以我把它们想象成两个球体。一个球体的表面/区域是球体的一部分,又名:半球。一个平面可以与表面上的任何点相切,或者通过球体的质心,会给你很多不同的东西。您的切割网格是否有您希望切割的非常平坦的平面?

标签: c# eyeshot


【解决方案1】:

Solid.Difference 根据两个差值返回一个实体数组

        public static bool materialSubtraction(ref Mesh targetMesh, Mesh tool)
        {
            bool success = false;
            Solid targetSolid = targetMesh.ConvertToSolid();
            Solid toolSolid = tool.ConvertToSolid();
            Solid[] differenceSolid = Solid.Difference(targetSolid, toolSolid);
            if(differenceSolid != null)
            {
                targetMesh = differenceSolid[0].ConvertToMesh();
                success = true;
            }           
            return success;
        }

它将从 targetSolid 中删除 toolSolid。这可能会导致第一个实体的多个部分,因此返回是一个 Solid[]。这个数组是按大小排序的,最大的实体是第一个。如果您需要不同的作品:

differenceSolid[x]

其中 x 是您需要的部分。

为 CutBy 创建一个平面: 最简单的方法是从实体对象中获取三个顶点并定义一个平面。 从固体中抓住它是:

Point3D X1 = toolSolid.Portions[0].Vertices[1];

网格没有部分,这里有顶点:

Point3D X1 = targetMesh.Vertices[1];
        public static bool materialCutBy(ref Mesh targetMesh, Mesh tool)
        {           
            Solid toolSolid = tool.ConvertToSolid();

            Point3D X1 = targetMesh.Vertices[1];
            Point3D X2 = targetMesh.Vertices[2];
            Point3D X3 = targetMesh.Vertices[3];

            Plane P1 = new Plane(X1, X2, X3);

            var success = toolSolid.CutBy(P1);

            if(success == booleanFailureType.Success)
            {
                targetMesh = toolSolid.ConvertToMesh();
                return true;
            }
            else { return false; }          
        }

【讨论】:

  • 感谢这个非常有用的答案!这不是我所需要的,但非常有用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-29
  • 2017-02-16
  • 2018-10-26
  • 2019-11-20
  • 2017-08-21
  • 2021-04-24
  • 1970-01-01
相关资源
最近更新 更多