Пример #1
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="mesh"></param>
            /// <param name="target"></param>
            /// <param name="features"></param>
            /// <param name="tolerance"></param>
            public Solver(HeMesh mesh, ISurfaceFeature target, IEnumerable <IFeature> features = null, Settings settings = null)
            {
                if (features == null)
                {
                    features = Enumerable.Empty <IFeature>();
                }

                _mesh = mesh;
                _mesh.Compact();

                _settings  = settings ?? new Settings();
                _stepCount = 0;

                // triangulate all faces starting with the shortest diagonal
                _mesh.TriangulateFaces(FaceTriangulator.CreateStrip(mesh, he =>
                {
                    var p0 = he.Start.Position;
                    var p1 = he.Next.End.Position;
                    return(p0.SquareDistanceTo(p1));
                }));

                // initialize features
                _target = target;
                InitFeatures(features);
            }
Пример #2
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="mesh"></param>
            /// <param name="target"></param>
            /// <param name="features"></param>
            /// <param name="settings"></param>
            public Solver(HeMesh mesh, ISurfaceFeature target, IEnumerable <IFeature> features = null, Settings settings = null)
            {
                if (features == null)
                {
                    features = Enumerable.Empty <IFeature>();
                }

                _mesh = mesh;
                _mesh.Compact();

                _settings  = settings ?? new Settings();
                _stepCount = 0;

                // triangulate all faces starting from the halfedge with the shortest diagonal
                _mesh.TriangulateFaces(FaceTriangulator.CreateStrip(), GetStart);

                // initialize features
                _target = target;
                InitFeatures(features);

                E GetStart(F face)
                {
                    return(face.Halfedges.SelectMin(he =>
                                                    he.Start.Position.SquareDistanceTo(he.Next.End.Position)));
                }
            }
Пример #3
0
            /// <summary>
            ///
            /// </summary>
            /// <typeparam name="TV"></typeparam>
            /// <typeparam name="TE"></typeparam>
            /// <typeparam name="TF"></typeparam>
            /// <param name="mesh"></param>
            /// <param name="target"></param>
            /// <param name="features"></param>
            /// <param name="settings"></param>
            /// <returns></returns>
            public static Solver Create <TV, TE, TF>(HeMesh <TV, TE, TF> mesh, ISurfaceFeature target, IEnumerable <IFeature> features = null, Settings settings = null)
                where TV : HeMesh <TV, TE, TF> .Vertex, IPosition3d
                where TE : HeMesh <TV, TE, TF> .Halfedge
                where TF : HeMesh <TV, TE, TF> .Face
            {
                var copy = HeMesh.Factory.CreateCopy(mesh, (v0, v1) => v0.Position = v1.Position, null, null);

                return(new Solver(copy, target, features, settings));
            }
Пример #4
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="mesh"></param>
            /// <param name="target"></param>
            /// <param name="features"></param>
            /// <param name="settings"></param>
            public Solver(HeMesh mesh, ISurfaceFeature target, IEnumerable <IFeature> features = null, Settings settings = null)
            {
                if (features == null)
                {
                    features = Enumerable.Empty <IFeature>();
                }

                _mesh = mesh;
                _mesh.Compact();

                _verts     = _mesh.Vertices;
                _hedges    = _mesh.Halfedges;
                _settings  = settings ?? new Settings();
                _stepCount = 0;

                _target = target;
                InitFeatures(features);

                // start on features
                ProjectToFeatures();
            }