private void SampleCollectionsFromTree(Action <List <string> > collectionSampler, XbimOctree <int> tree = null)
        {
            tree = tree ?? _tree;
            List <string> collection = BuildCollectionFromEntityLabels(tree.Content().ToList());

            if (collection.Count == 1 && tree.Parent != null)
            {
                collection = BuildCollectionFromEntityLabels(tree.Parent.Content().ToList());
            }

            if (collection.Count > 1)
            {
                collectionSampler.Invoke(collection);
            }

            foreach (XbimOctree <int> subTree in tree.Subtrees)
            {
                SampleCollectionsFromTree(collectionSampler, subTree);
            }
        }
Esempio n. 2
0
        private IEnumerable <IfcProduct> GetCandidatesFromNode(IfcProduct original, XbimOctree <IfcProduct> node)
        {
            if (original != null && node != null)
            {
                //content which if from other models
                var nodeContent = node.Content().Where(nc => (nc.ModelOf != original.ModelOf) && (nc.GetType() == original.GetType()));
                var prodBBox    = XbimRect3D.Empty;

                foreach (var candidate in nodeContent)
                {
                    //check BBoxes for equality
                    var contBBox = _prodBBsB[candidate];
                    prodBBox = _prodBBsA[original];
                    if (XbimAABBoxAnalyser.AlmostEqual(contBBox, prodBBox, _precision))
                    {
                        if (!_processedFromB.Contains(candidate))
                        {
                            _processedFromB.Add(candidate);
                        }
                        yield return(candidate);
                    }

                    //cope with the situation when product's bbox is on the border and
                    //it's equivalent from the second model might have end up on the higher level
                    var borderDirections = BBoxBorderDirections(node.Bounds, prodBBox);
                    var parents          = GetParentsInDirections(borderDirections, node);
                    foreach (var parent in parents)
                    {
                        foreach (var item in GetCandidatesFromNode(original, parent))//recursion
                        {
                            if (!_processedFromB.Contains(candidate))
                            {
                                _processedFromB.Add(candidate);
                            }
                            yield return(candidate);
                        }
                    }
                }
            }
        }