Ejemplo n.º 1
0
            /// <summary>
            ///
            /// </summary>
            private void ProjectToFeatures()
            {
                Parallel.ForEach(Partitioner.Create(0, _verts.Count), range =>
                {
                    for (int i = range.Item1; i < range.Item2; i++)
                    {
                        var v = _verts[i];

                        var p  = v.Position;
                        int fi = v.FeatureIndex;

                        /*
                         * // snap to feature or target if one exists
                         * if (fi != -1)
                         *  v.Position = _features[v.FeatureIndex].ClosestPoint(v.Position);
                         * else if(_target != null)
                         *  v.Position = _target.ClosestPoint(v.Position);
                         */

                        // snap to feature
                        if (fi != -1)
                        {
                            v.Position = _features[v.FeatureIndex].ClosestPoint(v.Position);
                        }

                        // snap to target
                        if (_target != null)
                        {
                            v.Position = _target.ClosestPoint(v.Position);
                        }
                    }
                });
            }
Ejemplo n.º 2
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="weight"></param>
            /// <returns></returns>
            private void PullToFeatures(double weight)
            {
                Parallel.ForEach(Partitioner.Create(0, _mesh.Vertices.Count), range =>
                {
                    var verts = _mesh.Vertices;

                    for (int i = range.Item1; i < range.Item2; i++)
                    {
                        var v = verts[i];
                        var p = v.Position;

                        if (v.IsFeature)
                        {
                            v.MoveSum   += (_features[v.FeatureIndex].ClosestPoint(p) - p) * weight;
                            v.WeightSum += weight;
                        }
                        else if (_target != null)
                        {
                            v.MoveSum   += _target.ClosestPoint(p) - p;
                            v.WeightSum += 1.0;
                        }
                    }
                });
            }