Exemplo n.º 1
0
        private void updateLocalFrameTransforms()
        {
            _localFrame.Transforms.Clear();

            Transform tScale = Rhino.Geometry.Transform.Scale(Point3d.Origin, DrawUtil.ScaleFactorLocalFrame);

            foreach (BrepFace bf in Value.Faces)
            {
                //int n_seg_u = Math.Max(1, (int)(bf.Domain(0).Length * DrawUtil.DensityFactorLocalFrame));
                //int n_seg_v = Math.Max(1, (int)(bf.Domain(1).Length * DrawUtil.DensityFactorLocalFrame));

                int n_seg_u = Math.Max(1, (int)(bf.IsoCurve(0, 0).GetLength() * DrawUtil.DensityFactorLocalFrame));
                int n_seg_v = Math.Max(1, (int)(bf.IsoCurve(1, 0).GetLength() * DrawUtil.DensityFactorLocalFrame));

                for (int i = 0; i <= n_seg_v; i++)
                {
                    for (int j = 0; j <= n_seg_u; j++)
                    {
                        double para_u = bf.Domain(0).ParameterAt((double)j / (double)n_seg_u);
                        double para_v = bf.Domain(1).ParameterAt((double)i / (double)n_seg_v);

                        if (DrawUtil.DensityFactorLocalFrame < 0.001)
                        {
                            para_u = bf.Domain(0).ParameterAt(0.5);
                            para_v = bf.Domain(1).ParameterAt(0.5);
                        }

                        Point3d ap = bf.PointAt(para_u, para_v);

                        Transform t = TransformUtils.GetGlobalTransformArea(ap, bf, DirectionLocalX);

                        if (FlipZ)
                        {
                            t = t * Rhino.Geometry.Transform.Rotation(Math.PI, Vector3d.XAxis, Point3d.Origin);
                        }

                        Transform tTranslate = Rhino.Geometry.Transform.Translation(new Vector3d(ap));

                        _localFrame.Transforms.Add(tTranslate * t * tScale);
                    }
                }
            }
        }