Пример #1
0
        public virtual void Update()
        {
            base.begin_update();
            int start_timestamp = this.CurrentInputTimestamp;

            if (MeshSource == null)
            {
                throw new Exception("GenerateClosedMeshOp: must set valid MeshSource to compute!");
            }

            try {
                DMesh3   inputmesh    = MeshSource.GetDMeshUnsafe();
                ISpatial inputSpatial = MeshSource.HasSpatial ? MeshSource.GetSpatial() : null;

                DMeshAABBTree3 spatial = (inputSpatial != null && inputSpatial is DMeshAABBTree3) ?
                                         inputSpatial as DMeshAABBTree3 : get_cached_spatial(inputmesh);
                DMesh3 meshIn = new DMesh3(inputmesh);

                MeshRepairOrientation repair = new MeshRepairOrientation(meshIn, spatial);
                repair.OrientComponents();
                repair.SolveGlobalOrientation();

                if (invert_result)
                {
                    meshIn.ReverseOrientation(true);
                }

                ResultMesh = meshIn;
                base.complete_update();
            } catch (Exception e) {
                PostOnOperatorException(e);
                ResultMesh = base.make_failure_output(MeshSource.GetDMeshUnsafe());
                base.complete_update();
            }
        }
Пример #2
0
        void repair_orientation(bool bGlobal)
        {
            MeshRepairOrientation orient = new MeshRepairOrientation(Mesh);

            orient.OrientComponents();
            if (Cancelled())
            {
                return;
            }
            if (bGlobal)
            {
                orient.SolveGlobalOrientation();
            }
        }
        /// <summary>
        /// Applies the Meshop multiple times, attempting a repair operation between iterations to reduce constraints due to face windings.
        /// </summary>
        /// <param name="maxTimes">maximum number of attempts to perform. The operation stops before this number if no failed attempts were encountered.</param>
        /// <returns>true if all the candidates have been successfully merged, false if some constraints prevented some merges</returns>
        public virtual bool ApplyIteratively(int maxTimes = 2)
        {
            int  tally = 0;
            bool ret   = false;

            while (tally++ < maxTimes)
            {
                ret = Apply();
                if (ret)
                {
                    return(true);
                }
                // fix the orientation before a retry
                var rep = new MeshRepairOrientation(Mesh);
                rep.OrientComponents();
            }
            return(ret);
        }