【问题标题】:Bounding Box intersection边界框相交
【发布时间】:2018-03-06 21:04:59
【问题描述】:

为了找到与几何相交的元素,我使用了 Jeremy 在他的博客 http://thebuildingcoder.typepad.com/blog/2010/12/find-intersecting-elements.html 中的示例帖子。但是边界框始终与 X、Y 和 Z 轴平行,这可能会导致问题,例如返回元素并没有真正发生冲突,因为有时边界框并不总是与几何体重合,因为族实例是旋转的。除此之外,还有一个问题是边界框会考虑符号的几何而不是实例,并且也会考虑翻转的几何,这意味着边界框比我正在寻找的要大。有没有办法获得当前视图中的真实几何图形?我该如何解决这个问题?

【问题讨论】:

    标签: revit-api


    【解决方案1】:

    我正在使用另一种策略,即访问实例的几何形状,以验证族实例的面是否与更近的管道发生冲突。

    class FindIntersection
    {
        public Conduit ConduitRun { get; set; }
        public FamilyInstance Jbox { get; set; }
    
        public List<Conduit> GetListOfConduits = new List<Conduit>();
    
        public FindIntersection(FamilyInstance jbox, UIDocument uiDoc)
        {
            XYZ jboxPoint = (jbox.Location as LocationPoint).Point;
    
            FilteredElementCollector filteredCloserConduits = new FilteredElementCollector(uiDoc.Document);
            List<Element> listOfCloserConduit = filteredCloserConduits.OfClass(typeof(Conduit)).ToList().Where(x =>
            ((x as Conduit).Location as LocationCurve).Curve.GetEndPoint(0).DistanceTo(jboxPoint) < 30 ||
            ((x as Conduit).Location as LocationCurve).Curve.GetEndPoint(1).DistanceTo(jboxPoint) < 30).ToList();
            //getting the location of the box and all conduit around. 
    
            Options opt = new Options();
            opt.View = uiDoc.ActiveView;
    
            GeometryElement geoEle = jbox.get_Geometry(opt);
            //getting the geometry of the element to acess the geometry of the instance.
    
            foreach (GeometryObject geomObje1 in geoEle)
            {
    
                GeometryElement geoInstance = (geomObje1 as GeometryInstance).GetInstanceGeometry();
                //the geometry of the family instance can be acess by this method that returns a GeometryElement type.
                //so we must get the GeometryObject again to acess the Face of the family instance. 
    
                if (geoInstance != null)
                {
    
                    foreach (GeometryObject geomObje2 in geoInstance)
                    {
                        Solid geoSolid = geomObje2 as Solid;
    
                        if (geoSolid != null)
                        {
    
                            foreach (Face face in geoSolid.Faces)
                            {
                                foreach (Element cond in listOfCloserConduit)
                                {
                                    Conduit con = cond as Conduit;
                                    Curve conCurve = (con.Location as LocationCurve).Curve;
                                    SetComparisonResult set = face.Intersect(conCurve);
    
                                    if (set.ToString() == "Overlap")
                                    {
                                        //getting the conduit the intersect the box.
                                        GetListOfConduits.Add(con);
    
                                    }
                                }
                            }
    
    
                        }
                    }
                }
            }
        }
    }
    

    【讨论】:

      【解决方案2】:

      有很多方法可以解决这个问题。通常,在执行冲突检测时,您总是会先运行一个超快速的预处理步骤来确定候选元素,然后在后续步骤中逐步缩小搜索范围。在这种情况下,您可以将边界框相交视为第一步,然后执行后处理以将结果缩小到您的确切目标。

      一个重要的问题是:边界框是否真的为您提供了您需要的所有元素,以及更多?你确定没有遗漏吗?

      一旦确定,您需要做的就是添加应用您关心的详细注意事项的后处理步骤。

      一个简单的可能是:目标体积中是否包含所有目标元素几何顶点?

      更复杂的方法可能涉及检索目标元素和目标体积的完整实体,并在它们之间执行布尔交集,以完全准确地确定它们是否相交、分离或相互包含。

      许多其他的都是可以想象的。

      【讨论】:

        【解决方案3】:

        您能否提供complete minimal reproducible case,以便我们了解确切的上下文并分析可以做什么?也许您可以包括一个轴对齐的接线盒和一个不对齐的接线盒,这样我们就可以看到您现有算法的表现如何。谢谢!

        【讨论】:

          【解决方案4】:

          我在filtering for intersecting elements and conduits intersecting a junction box 的博客文章中总结了这次讨论和迄今为止的结果。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2015-07-13
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-09-28
            • 2012-03-23
            • 2017-07-07
            相关资源
            最近更新 更多