예제 #1
0
        public override void UpdateCurvesGeometry()
        {
            base.UpdateCurvesGeometry();

            // get projected versions of top/bottom circles
            var top         = Center.Value + 0.5 * Length.Value * Axis.Value;
            var topCircle3d = ShapeHelper.GenerateCircle(top, Axis, TopRadiusInternal, 20);
            var topCircle   = ShapeHelper.ProjectCurve(topCircle3d);

            var bottom         = Center.Value - 0.5 * Length.Value * Axis.Value;
            var bottomCircle3d = ShapeHelper.GenerateCircle(bottom, Axis, BottomRadiusInternal, 20);
            var bottomCircle   = ShapeHelper.ProjectCurve(bottomCircle3d);

            // find the axis in projected coordinates
            var tb     = ShapeHelper.ProjectCurve(top, bottom);
            var axis2d = tb[0] - tb[1];

            // find the 2 silhouette lines
            var perp = new Vector(axis2d.Y, -axis2d.X);

            perp.Normalize();
            var lt = tb[0] + TopRadiusInternal * perp;
            var lb = tb[1] + BottomRadiusInternal * perp;
            var rt = tb[0] - TopRadiusInternal * perp;
            var rb = tb[1] - BottomRadiusInternal * perp;

            var leftLine  = new Point[] { lt, lb };
            var rightLine = new Point[] { rt, rb };
        }
예제 #2
0
        public override void UpdateCurvesGeometry()
        {
            var circle3d = ShapeHelper.GenerateCircle(Center, new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), Radius, 20);
            var circle   = ShapeHelper.ProjectCurve(circle3d);

            SilhouetteCircle.Points = circle.Append(circle.First()).ToArray();
        }
        private Geometry GetGeometry(CircleFeatureCurve circle)
        {
            var circlePoints = ShapeHelper.GenerateCircle(circle.CenterResult,
                                                          circle.NormalResult,
                                                          circle.RadiusResult,
                                                          20);

            return(GetProjectedGeometry(circlePoints));
        }
예제 #4
0
        public void Update()
        {
            var normal = featureCurve.NormalResult;
            var center = featureCurve.CenterResult;
            var radius = featureCurve.RadiusResult;

            var points = ShapeHelper.GenerateCircle(center, normal, radius, CIRCLE_SAMPLES_COUNT).ToList();

            points.Add(points.First());

            model3d.Geometry = GenerateMeshGeometry(points, normal);
        }
예제 #5
0
        private MeshGeometry3D GenerateMeshGeometry(IList <Point3D> points, Vector3D xAxis)
        {
            // normalize the x axis in order to satisfy the requirements of ShapeHelper.GenerateCircle
            xAxis.Normalize();

            // generate all circles
            var circles = new List <IList <Point3D> >();
            var normals = GenerateNormals(points);

            for (int i = 0; i < points.Count; ++i)
            {
                var pnt    = points[i];
                var nrm    = normals[i];
                var yAxis  = Vector3D.CrossProduct(xAxis, nrm).Normalized();
                var circle = ShapeHelper.GenerateCircle(pnt, xAxis, yAxis, thickness, CROSS_SECTION_SAMPLES_COUNT);
                circles.Add(circle);
            }

            // generate the mesh geometry
            var geometry = new MeshGeometry3D();

            geometry.Positions = new Point3DCollection(circles.SelectMany(c => c)); // put in all points
            for (int i = 0; i < circles.Count; ++i)
            {
                var currBaseIndex = i * CROSS_SECTION_SAMPLES_COUNT;
                var nextBaseIndex = currBaseIndex + CROSS_SECTION_SAMPLES_COUNT;
                for (int j = 0; j < CROSS_SECTION_SAMPLES_COUNT; ++j)
                {
                    var c1 = currBaseIndex + j;
                    var c2 = currBaseIndex + (j + 1) % CROSS_SECTION_SAMPLES_COUNT;
                    var n1 = nextBaseIndex + j;
                    var n2 = nextBaseIndex + (j + 1) % CROSS_SECTION_SAMPLES_COUNT;

                    geometry.TriangleIndices.Add(c1);
                    geometry.TriangleIndices.Add(c2);
                    geometry.TriangleIndices.Add(n1);

                    geometry.TriangleIndices.Add(n1);
                    geometry.TriangleIndices.Add(c2);
                    geometry.TriangleIndices.Add(n2);
                }
            }

            return(geometry);
        }
        public static Visual3D CreateConeView(SnappedCone coneData)
        {
            Contract.Requires(coneData != null);
            Contract.Ensures(Contract.Result <Visual3D>() != null);

            var topCircle = ShapeHelper.GenerateCircle(
                coneData.TopFeatureCurve.CenterResult,
                coneData.TopFeatureCurve.NormalResult,
                coneData.TopFeatureCurve.RadiusResult,
                50);
            var botCircle = ShapeHelper.GenerateCircle(
                coneData.BottomFeatureCurve.CenterResult,
                coneData.BottomFeatureCurve.NormalResult,
                coneData.BottomFeatureCurve.RadiusResult,
                50);

            return(CreateCylinderView(topCircle, botCircle, coneData));
        }