public NewBGCViewModel(
     UiState uiState = null,
     ICurveAssigner curveAssigner     = null,
     IEventAggregator eventAggregator = null,
     IConstrainedOptimizer optimizer  = null)
     : base(uiState, curveAssigner, eventAggregator, optimizer)
 {
     model      = new NewBendedGenCylinder();
     components = EMPTY_COMPONENTS;
 }
        protected override NewPrimitive ConvertCore(SnappedBendedGenCylinder snapped)
        {
            var result = new NewBendedGenCylinder();

            /*result.Axis.Value = snapped.AxisResult;
             * result.Length.Value = snapped.LengthResult;
             * result.Center.Value = MathUtils3D.Lerp(snapped.TopCenterResult, snapped.BottomCenterResult, 0.5);*/
            result.Components = snapped.ComponentResults.CloneArray();

            /*result.EditConstraints.Add(new AxisOnLineConstraint(
             *  snapped.BottomCenterResult,
             *  snapped.AxisResult,
             *  result.Center,
             *  result.Axis));*/
            return(result);
        }
        public NewPrimitive AddNewPrimitive(PrimitiveKinds primitiveKind, LineRange lineRange)
        {
            var pos3d = uiState.SketchPlane.PointFromRay(lineRange);

            if (pos3d != null)
            {
                undoHistory.Push();
                switch (primitiveKind)
                {
                case PrimitiveKinds.Cylinder:
                    var newCylinder = new NewCylinder();
                    newCylinder.Center.Value   = pos3d.Value;
                    newCylinder.Axis.Value     = sketchPlane.YAxis;
                    newCylinder.Diameter.Value = 0.2;
                    newCylinder.Length.Value   = 0.3;
                    sessionData.NewPrimitives.Add(newCylinder);
                    break;

                case PrimitiveKinds.Cone:
                    var newCone = new NewCone();
                    newCone.Center.Value       = pos3d.Value;
                    newCone.Axis.Value         = sketchPlane.YAxis;
                    newCone.TopRadius.Value    = 0.1;
                    newCone.BottomRadius.Value = 0.2;
                    newCone.Length.Value       = 0.3;
                    sessionData.NewPrimitives.Add(newCone);
                    break;

                case PrimitiveKinds.Sphere:
                    var newSphere = new NewSphere();
                    newSphere.Center.Value = pos3d.Value;
                    newSphere.Radius.Value = 0.2;
                    sessionData.NewPrimitives.Add(newSphere);
                    break;

                case PrimitiveKinds.SGC:
                    var newSGC = new NewStraightGenCylinder();
                    newSGC.Center.Value = pos3d.Value;
                    newSGC.Axis.Value   = sketchPlane.YAxis;
                    newSGC.Length.Value = 0.3;
                    newSGC.Components   = SgcComponents.CreateNonLinear(20, 0.075, 0.05, 0.1);
                    sessionData.NewPrimitives.Add(newSGC);
                    break;

                case PrimitiveKinds.BGC:
                    var newBGC = new NewBendedGenCylinder();
                    newBGC.Center.Value = pos3d.Value;
                    newBGC.Axis.Value   = sketchPlane.YAxis;
                    newBGC.Length.Value = 0.3;
                    newBGC.Components   = BgcComponents.Create(20, 0.075, 0.15, newBGC.Center.Value, newBGC.Axis.Value, newBGC.Length.Value);
                    sessionData.NewPrimitives.Add(newBGC);
                    break;

                case PrimitiveKinds.Cuboid:
                    var      newCuboid = new NewCuboid();
                    Vector3D H         = new Vector3D(0, 1, 0);
                    Vector3D W         = new Vector3D(1, 0, 0);
                    Vector3D D         = new Vector3D(0, 0, -1);
                    newCuboid.Center.Value = pos3d.Value;
                    newCuboid.H.Value      = H;
                    newCuboid.W.Value      = W;
                    newCuboid.D.Value      = D;
                    newCuboid.Width.Value  = 0.3;
                    newCuboid.Height.Value = 0.3;
                    newCuboid.Depth.Value  = 0.3;
                    sessionData.NewPrimitives.Add(newCuboid);
                    break;

                default:
                    Trace.Fail("Invalid primitive kind");
                    break;
                }
                sessionData.NewPrimitives.Last().UpdateCurvesGeometry();
                return(sessionData.NewPrimitives.Last());
            }
            else
            {
                return(null);
            }
        }
 public void Init(NewBendedGenCylinder newBgc)
 {
     Model = model = newBgc;
     UpdateFromModel();
 }