Example #1
0
 private void EndPoint(GeoPoint p)
 {
     if (!Precision.IsEqual(p, cylinderStartPoint))
     {
         cylinderDirZ = new GeoVector(cylinderStartPoint, p);
         if (height.Fixed) // die schon bestimmt Höhe benutzen!
         {
             cylinderDirZ = cylinderHeight * cylinderDirZ.Normalized;
         }
         else
         {
             cylinderHeight = cylinderDirZ.Length;
         }
         // cylinderDirX muss irgendwie senkrecht auf cylinderDirZ stehen. Hier: Hilfsvektor definieren mit der kleinsten Komponente von cylinderDirZ
         GeoVector vT = new GeoVector(1, 0, 0); // x am kleinsten
         if (Math.Abs(cylinderDirZ.y) < Math.Abs(cylinderDirZ.x))
         {
             vT = new GeoVector(0, 1, 0); // y am kleinsten
         }
         if ((Math.Abs(cylinderDirZ.x) > Math.Abs(cylinderDirZ.z)) && (Math.Abs(cylinderDirZ.y) > Math.Abs(cylinderDirZ.z)))
         {
             vT = new GeoVector(0, 0, 1); // z am kleinsten
         }
         cylinderDirX = cylinderRadius * (vT ^ cylinderDirZ).Normalized;
         cylinder     = Make3D.MakeCylinder(cylinderStartPoint, cylinderDirX, cylinderDirZ);
         cylinder.CopyAttributes(base.ActiveObject);
         base.ActiveObject = cylinder;
     }
 }
Example #2
0
 private void StartPoint(GeoPoint p)
 {
     cylinderStartPoint = p;
     // die Höhe berechnet sich als Abstand von diesem Punkt
     height.SetDistanceFromPoint(cylinderStartPoint);
     cylinder = Make3D.MakeCylinder(cylinderStartPoint, cylinderDirX, cylinderDirZ);
     cylinder.CopyAttributes(base.ActiveObject);
     base.ActiveObject = cylinder;
 }
Example #3
0
 private bool Height(double length)
 {
     if (length > Precision.eps)
     {
         cylinderHeight = length;
         cylinderDirZ   = cylinderHeight * cylinderDirZ.Normalized;
         cylinder       = Make3D.MakeCylinder(cylinderStartPoint, cylinderDirX, cylinderDirZ);
         cylinder.CopyAttributes(base.ActiveObject);
         base.ActiveObject = cylinder;
         return(true);
     }
     return(false);
 }
Example #4
0
        public override void OnSetAction()
        {
            cylinder           = Solid.Construct();
            base.BasePoint     = ConstrDefaults.DefaultStartPoint;
            cylinderStartPoint = base.BasePoint;
            cylinderRadius     = ConstrDefaults.DefaultArcRadius;
            cylinderHeight     = ConstrDefaults.DefaultBoxHeight;
            cylinderDirX       = cylinderRadius * base.ActiveDrawingPlane.DirectionX;
            cylinderDirZ       = cylinderHeight * (base.ActiveDrawingPlane.DirectionX ^ base.ActiveDrawingPlane.DirectionY);
            cylinder           = Make3D.MakeCylinder(ConstrDefaults.DefaultStartPoint, cylinderDirX, cylinderDirZ);

            base.ActiveObject = cylinder;
            base.TitleId      = "Constr.Cylinder";

            startPointInput = new GeoPointInput("Constr.Cylinder.StartPoint");
            startPointInput.DefaultGeoPoint   = ConstrDefaults.DefaultStartPoint;
            startPointInput.DefinesBasePoint  = true;
            startPointInput.SetGeoPointEvent += new ConstructAction.GeoPointInput.SetGeoPointDelegate(StartPoint);

            endPointInput = new GeoPointInput("Constr.Cylinder.EndPoint");
            endPointInput.DefaultGeoPoint   = ConstrDefaults.DefaultStartPoint;
            endPointInput.SetGeoPointEvent += new ConstructAction.GeoPointInput.SetGeoPointDelegate(EndPoint);

            radius = new LengthInput("Constr.Cylinder.Radius");
            radius.DefaultLength         = ConstrDefaults.DefaultArcRadius;
            radius.SetLengthEvent       += new ConstructAction.LengthInput.SetLengthDelegate(Radius);
            radius.GetLengthEvent       += new LengthInput.GetLengthDelegate(GetRadius);
            radius.CalculateLengthEvent += new CADability.Actions.ConstructAction.LengthInput.CalculateLengthDelegate(RadiusCalculate);

            height = new LengthInput("Constr.Cylinder.Height");
            height.DefaultLength       = ConstrDefaults.DefaultBoxHeight;
            height.SetLengthEvent     += new ConstructAction.LengthInput.SetLengthDelegate(Height);
            height.GetLengthEvent     += new LengthInput.GetLengthDelegate(GetHeight);
            height.ForwardMouseInputTo = endPointInput;
            height.Optional            = true;

            base.SetInput(startPointInput, endPointInput, radius, height);
            base.ShowAttributes = true;

            base.OnSetAction();
        }
Example #5
0
 private bool Radius(double length)
 {
     if (length > Precision.eps)
     {
         cylinderRadius = length;
         cylinderDirX   = cylinderRadius * cylinderDirX.Normalized;
         cylinder       = Make3D.MakeCylinder(cylinderStartPoint, cylinderDirX, cylinderDirZ);
         cylinder.CopyAttributes(base.ActiveObject);
         if (startPointInput.Fixed && !endPointInput.Fixed)
         { // er will also einen Zylinder senkrecht auf der drawingplane
             endPointInput.Optional     = true;
             height.Optional            = false;
             height.ForwardMouseInputTo = new object[0]; // den forward abschalten
             cylinderDirX = cylinderRadius * base.ActiveDrawingPlane.DirectionX;
             cylinderDirZ = cylinderHeight * (base.ActiveDrawingPlane.DirectionX ^ base.ActiveDrawingPlane.DirectionY);
         }
         base.ActiveObject = cylinder;
         return(true);
     }
     return(false);
 }