Esempio n. 1
0
        private bool showLine()
        {
            GeoPoint  startPoint = new GeoPoint(iCurve.StartPoint, iCurve.EndPoint);         // Mittelpunkt
            GeoVector vPerp      = (iCurve.StartDirection ^ base.ActiveDrawingPlane.Normal); // Senkrechte

            if (!vPerp.IsNullVector())
            {
                base.MultiSolutionCount = 2;
                vPerp.Norm();
                GeoPoint endPoint;
                if (nextSol)
                {
                    endPoint = startPoint - lineLength * vPerp;
                }
                else
                {
                    endPoint = startPoint + lineLength * vPerp;
                }
                line.SetTwoPoints(startPoint, endPoint);
                // die Basis für die Längenangabe
                lengthInput.SetDistanceFromLine(iCurve.StartPoint, iCurve.EndPoint);
                base.ShowActiveObject = true;
                return(true);
            }
            base.ShowActiveObject   = false;
            base.MultiSolutionCount = 0;
            return(false);
        }
        private void Point1(GeoPoint p)
        {
            //			elliPoint1 = p;
            GeoVector dir = p - ellipse.Center;

            if (!dir.IsNullVector())
            {
                // dir1 als senkrechte zu dir in der ActiveDrawingPlane erzeugen:
                GeoVector dir1 = ellipse.Plane.Normal ^ dir;
                dir1.Norm();
                dir1 = ellipse.MinorRadius * dir1;
                // nun daraus neue ellipse, in der Orientierung dir ist der Winkel enthalten
                ellipse.SetEllipseArcCenterAxis(ellipse.Center, dir, dir1, ellipse.StartParameter, ellipse.SweepParameter);
                // für die Mauseingabe des 2.Radius wird hier die Referenzlinie ellipse.Center,p angegeben
                elliMinRad.SetDistanceFromLine(ellipse.Center, p);
            }

            /*
             *          if (!dir.IsNullVector())
             *          {
             *              ellipse.MajorRadius = Geometry.dist(ellipse.Center,p);
             *              // dir1 als senkrechte zu dir in der ActiveDrawingPlane erzeugen:
             *              GeoVector dir1 = base.ActiveDrawingPlane.Normal ^ dir;
             *              // nun daraus neue ellipse.plane, in der Orientierung dir ist der Winkel enthalten
             *              ellipse.Plane = new Plane(ellipse.Center,dir,dir1);
             *              // für die Mauseingabe des 2.Radius wird hier die Referenzlinie ellipse.Center,p angegeben
             *              elliMinRad.SetDistanceFromLine(ellipse.Center,p);
             *              elliAngle = new Angle(ActiveDrawingPlane.DirectionX,dir);
             *          }
             */
        }
Esempio n. 3
0
 private Boolean showEllipse()
 {
     if (!Precision.IsEqual(point1, point2) && !vector1.IsNullVector() && !vector2.IsNullVector())
     {
         return(ellipse.SetEllipse2PointsDirections(point1, vector1, point2, vector2));
     }
     return(false);
 }
Esempio n. 4
0
        public override void OnSetAction()
        {
            base.ActiveObject = Face.Construct();

            if (axisVector.IsNullVector())
            {
                axisVector = GeoVector.XAxis;
            }
            if (angleRotation == 0.0)
            {
                angleRotation = Math.PI;
            }

            base.TitleId = "Constr.Face.PathRotate";

            curveInput = new CurveInput("Constr.Face.PathRotate.Path");
            curveInput.MouseOverCurvesEvent       += new CurveInput.MouseOverCurvesDelegate(curveInputPath);
            curveInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(curveInputPathChanged);
            if (selectedMode)
            {
                curveInput.Fixed = true;
            }

            rotateLineInput                             = new CurveInput("Constr.Face.PathRotate.AxisLine");
            rotateLineInput.Decomposed                  = true; // nur Einzelelemente, auch bei Polyline und Pfad
            rotateLineInput.MouseOverCurvesEvent       += new CurveInput.MouseOverCurvesDelegate(RotateLine);
            rotateLineInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(RotateLineChanged);


            axisPointInput = new GeoPointInput("Constr.Face.PathRotate.AxisPoint", axisPoint);
            axisPointInput.SetGeoPointEvent   += new GeoPointInput.SetGeoPointDelegate(SetAxisPoint);
            axisPointInput.GetGeoPointEvent   += new GeoPointInput.GetGeoPointDelegate(GetAxisPoint);
            axisPointInput.ForwardMouseInputTo = curveInput;
            axisPointInput.DefinesBasePoint    = true;

            axisVectorInput = new GeoVectorInput("Constr.Face.PathRotate.AxisVector", axisVector);
            axisVectorInput.SetGeoVectorEvent += new GeoVectorInput.SetGeoVectorDelegate(SetAxisVector);
            axisVectorInput.GetGeoVectorEvent += new GeoVectorInput.GetGeoVectorDelegate(GetAxisVector);
            //            vectorInput.DefaultGeoVector = ConstrDefaults.DefaultExtrudeDirection;
            axisVectorInput.ForwardMouseInputTo = curveInput;
            optionalOrg();

            AngleInput angleInput = new AngleInput("Constr.Face.PathRotate.Angle", angleRotation);

            angleInput.SetAngleEvent += new AngleInput.SetAngleDelegate(SetAngleInput);
            angleInput.GetAngleEvent += new AngleInput.GetAngleDelegate(GetAngleInput);

            AngleInput angleOffsetInput = new AngleInput("Constr.Face.PathRotate.AngleOffset", angleOffsetRotation);

            angleOffsetInput.SetAngleEvent += new AngleInput.SetAngleDelegate(SetAngleOffsetInput);
            angleOffsetInput.GetAngleEvent += new AngleInput.GetAngleDelegate(GetAngleOffsetInput);
            angleOffsetInput.Optional       = true;

            base.SetInput(curveInput, rotateLineInput, axisPointInput, axisVectorInput, angleInput, angleOffsetInput);
            base.ShowAttributes = true;
            base.OnSetAction();
        }
Esempio n. 5
0
 private bool SetElliDir2(GeoVector dir)
 {
     if (!dir.IsNullVector())
     {
         vector2 = dir;
         feedBackLine.SetTwoPoints(point2, base.CurrentMousePosition);
         return(showEllipse());
     }
     return(false);
 }
Esempio n. 6
0
 private void OnSetDirectionYParallel(GeoVectorProperty sender, GeoVector v)
 {
     if (!v.IsNullVector())
     {
         if (!Precision.SameDirection(v, polyline.ParallelogramMainDirection, false))
         {
             polyline.ParallelogramSecondaryDirection = v; // übernimmt nicht die Länge!
         }
     }
 }
 private bool ElliDir(GeoVector dir)
 {
     if (!dir.IsNullVector())
     {   // dir1 als senkrechte zu dir in der ActiveDrawingPlane erzeugen:
         GeoVector dir1 = ellipse.Plane.Normal ^ dir;
         // nun daraus neue ellipse.plane, in der Orientierung dir ist der Winkel enthalten
         ellipse.Plane = new Plane(ellipse.Center, dir, dir1);
         return(true);
     }
     return(false);
 }
        private void Point2(GeoPoint p)
        {
            //            elliPoint2 = p;
            GeoVector dir1 = p - Geometry.DropPL(p, ellipse.Center, ellipse.Plane.DirectionX);

            if (!dir1.IsNullVector())
            {
                // nun daraus neue ellipse,
                ellipse.SetEllipseArcCenterAxis(ellipse.Center, ellipse.MajorRadius * ellipse.Plane.DirectionX, dir1, ellipse.StartParameter, ellipse.SweepParameter);
            }
        }
 private bool YVector(GeoVector v)
 {
     if (!v.IsNullVector())
     {
         if (!Precision.SameDirection(v, line.ParallelogramMainDirection, false))
         {
             line.SetParallelogram(line.ParallelogramLocation, line.ParallelogramMainDirection, v);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a surface by sweeping the curve <paramref name="toSweep"/> along the curve <paramref name="along"/> and keeping the vector <paramref name="normal"/>
 /// unchanged
 /// </summary>
 /// <param name="toSweep"></param>
 /// <param name="along"></param>
 /// <param name="normal"></param>
 /// <param name="usedArea"></param>
 public GeneralSweptCurve(ICurve toSweep, ICurve along, GeoVector normal) : base()
 {
     if (normal.IsNullVector())
     {
         GeoPoint[] pnts = new GeoPoint[7];
         for (int i = 0; i < pnts.Length; i++)
         {
             pnts[i] = along.PointAt(i / (double)(pnts.Length));
         }
         double maxDist;
         bool   isLinear;
         Plane  pln = Plane.FromPoints(pnts, out maxDist, out isLinear);
         if (isLinear)
         {
             GeoVector n1 = along.StartDirection ^ GeoVector.XAxis;
             GeoVector n2 = along.StartDirection ^ GeoVector.YAxis;
             GeoVector n3 = along.StartDirection ^ GeoVector.ZAxis;
             if (n1.Length > n2.Length)
             {
                 if (n1.Length > n3.Length)
                 {
                     normal = n1;
                 }
                 else
                 {
                     normal = n3;
                 }
             }
             else
             {
                 if (n2.Length > n3.Length)
                 {
                     normal = n2;
                 }
                 else
                 {
                     normal = n3;
                 }
             }
         }
         else
         {
             normal = pln.Normal;
         }
     }
     this.toSweep = toSweep;
     this.along   = along;
     this.vmin    = 0;
     this.vmax    = 1.0;
     this.normal  = normal;
     initSecondaryData();
     initNurbsSurface();
 }
Esempio n. 11
0
 private Boolean showEllipse()
 {
     if (!Precision.IsEqual(point1, point2) && !vector1.IsNullVector() && !vector2.IsNullVector())
     {
         if (ellipse.SetEllipseArc2PointsDirections(point1, vector1, point2, vector2, dir, base.ActiveDrawingPlane))
         {
             base.MultiSolutionCount = 2; // zur schnellen Umschaltung der Richtung in OnDifferentSolution, s.u.
             return(true);
         }
     }
     base.MultiSolutionCount = 0;
     return(false);
 }
Esempio n. 12
0
 /// <summary>
 /// Creates a new plane. The parameter data is under-determined for the plane, so the x-axis and y-axis
 /// will be determined arbitrarily
 /// </summary>
 /// <param name="Location">location of the plane</param>
 /// <param name="Normal">normal vector of the plane</param>
 public Plane(GeoPoint Location, GeoVector Normal)
 {   // ist ja nicht eindeutig bezüglich x und y Richtung.
     // hier wird CndOCas verwendet, damit es in gleicher weise wie dort generiert wird.
     if (Normal.IsNullVector())
     {
         throw new PlaneException(PlaneException.tExceptionType.ConstructorFailed);
     }
     try
     {
         if (Normal.x == 0 && Normal.y == 0 && Normal.z > 0)
         {   // kommt wohl oft vor:
             coordSys = new CoordSys(Location, GeoVector.XAxis, GeoVector.YAxis);
         }
         else
         //oCasBuddy = new CndOCas.Plane();
         //oCasBuddy.InitFromPntDir(Location.gpPnt(),Normal.gpDir());
         //coordSys = new CoordSys(new GeoPoint(oCasBuddy.Location),new GeoVector(oCasBuddy.DirectionX),new GeoVector(oCasBuddy.DirectionY));
         // OpenCascade ist zu unsicher (gibt manchmal exceptions), deshalb jetzt selbstgestrickt
         {
             GeoVector dx;
             if (Math.Abs(Normal.x) > Math.Abs(Normal.y))
             {
                 if (Math.Abs(Normal.y) < Math.Abs(Normal.z))
                 {   // y ist die kleinste Komponente, also X-Achse
                     dx = GeoVector.YAxis;
                 }
                 else
                 {
                     dx = GeoVector.ZAxis;
                 }
             }
             else
             {
                 if (Math.Abs(Normal.x) < Math.Abs(Normal.z))
                 {   // x ist die kleinste Komponente, also X-Achse
                     dx = GeoVector.XAxis;
                 }
                 else
                 {
                     dx = GeoVector.ZAxis;
                 }
             }
             GeoVector v = Normal ^ dx;
             coordSys = new CoordSys(Location, v, v ^ Normal);
         }
     }
     catch (CoordSysException)
     {
         throw new PlaneException(PlaneException.tExceptionType.ConstructorFailed);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.Position (GeoPoint, GeoVector, double)"/>
        /// </summary>
        /// <param name="fromHere"></param>
        /// <param name="direction"></param>
        /// <param name="precision"></param>
        /// <returns></returns>
        public override double Position(GeoPoint fromHere, GeoVector direction, double precision)
        {   // noch nicht getestet
            double    pos1, pos2;
            GeoVector ldir = endPoint - startPoint;

            if (ldir.IsNullVector())
            {
                return(Geometry.LinePar(fromHere, direction, startPoint));
            }
            else
            {
                double d = Geometry.DistLL(startPoint, ldir, fromHere, direction, out pos1, out pos2);
                return(pos2);
            }
        }
        private bool Angle(Angle angle)
        {
            // derWinkel bezieht sich auf die DrawingPlane der aktuellen Ansicht
            // und wird hier umgerechnet
            GeoVector dir = base.WorldDirection(angle);

            if (!dir.IsNullVector())
            {   // dir1 als senkrechte zu dir in der ActiveDrawingPlane erzeugen:
                GeoVector dir1 = base.ActiveDrawingPlane.Normal ^ dir;
                // nun daraus neue ellipse.plane, in der Orientierung dir ist der Winkel enthalten
                ellipse.Plane = new Plane(ellipse.Center, dir, dir1);
                return(true);
            }
            return(false);
        }
Esempio n. 15
0
 private bool ZVector(GeoVector v)
 {
     if (!v.IsNullVector())
     {
         if (!Precision.SameDirection(v, boxDirX, false) && !Precision.SameDirection(v, boxDirY, false))
         {
             boxDirZ    = v;
             boxLengthZ = boxDirZ.Length;
             box        = Make3D.MakeBox(boxStartPoint, boxDirX, boxDirY, boxDirZ);
             box.CopyAttributes(base.ActiveObject);
             base.ActiveObject = box;
             boxOrg(3);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 16
0
 private bool OnSetLength(double length)
 {
     if (length > Precision.eps)
     {
         lineLength = length;
     }
     else
     {
         return(false);
     }
     if (curveInput.Fixed)
     {
         base.MultiSolutionCount = 2;
         objectPoint             = base.CurrentMousePosition;
         GeoVector v = line.EndPoint - line.StartPoint;
         if (!v.IsNullVector())
         {
             v.Norm();
         }
         else
         {
             v = new GeoVector(1.0, 0.0, 0.0);
         }
         GeoPoint endPoint    = line.StartPoint + length * v;
         GeoPoint endPointOpp = line.StartPoint - length * v;
         if (!nextSol)
         {
             if (objectPoint.Distance(endPoint) > objectPoint.Distance(endPointOpp))
             {
                 endPoint = endPointOpp;
             }
         }
         else
         {
             if (objectPoint.Distance(endPoint) < objectPoint.Distance(endPointOpp))
             {
                 endPoint = endPointOpp;
             }
         }
         line.EndPoint = endPoint;
         return(true);
     }
     base.MultiSolutionCount = 0;
     return(false);
 }
        private void Point1(GeoPoint p)
        {
            point1 = p;
            GeoVector dir = p - ellipse.Center;

            if (!dir.IsNullVector())
            {
                // dir1 als senkrechte zu dir in der ActiveDrawingPlane erzeugen:
                GeoVector dir1 = ellipse.Plane.Normal ^ dir;
                dir1.Norm();
                dir1 = ellipse.MinorRadius * dir1;
                // nun daraus neue ellipse, in der Orientierung dir ist der Winkel enthalten
                ellipse.SetEllipseCenterAxis(ellipse.Center, dir, dir1);
                //				ellipse.SetEllipseCenterAxis(ellipse.Center,dir,dir1,base.ActiveDrawingPlane);
                // für die Mauseingabe des 2.Radius wird hier die Referenzlinie ellipse.Center,p angegeben
                elliMinRad.SetDistanceFromLine(ellipse.Center, p);
            }
        }
Esempio n. 18
0
 private bool Vec_OnSetGeoVector(GeoVector vector)
 {
     if (!vector.IsNullVector())
     {
         using (Frame.Project.Undo.ContextFrame(this))
         {
             if (vectorProperty != null)
             {
                 vectorProperty.SetGeoVector(vector);
             }
         }
         actualVector = vector;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 19
0
 private bool Vec_OnSetGeoVector(GeoVector vector)
 {
     if (!vector.IsNullVector())
     {
         actualPoint = currentPoint + vector;
         using (Frame.Project.Undo.ContextFrame(this))
         {
             if (geoPointProperty != null)
             {
                 geoPointProperty.SetGeoPoint(actualPoint);
             }
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
 private bool RectAngle(GeoVector vector)
 {   // derWinkel als x-Achsen Vektor
     if (!vector.IsNullVector())
     {
         vector.Norm();
         //if (ActiveDrawingPlane.Normal != vector) // Spezialfall, ausschliessen, sonst krachts
         //    line.SetRectangle(line.RectangleLocation,line.RectangleWidth*vector,line.RectangleHeight*(ActiveDrawingPlane.Normal^vector));
         GeoVector2D v1 = base.ActiveDrawingPlane.Project(vector);
         GeoVector   v2 = base.ActiveDrawingPlane.ToGlobal(v1);
         if (!v2.IsNullVector())
         {
             v2.Norm();
             if (ActiveDrawingPlane.Normal != v2) // Spezialfall, ausschliessen, sonst krachts
             {
                 line.SetRectangle(line.RectangleLocation, line.RectangleWidth * v2, line.RectangleHeight * (ActiveDrawingPlane.Normal ^ v2));
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 21
0
 private void SetEndPoint(GeoPoint p)
 {
     endPoint = p;
     if (startPointInput.Fixed)
     {
         vec.Fixed = true; // damit die Aktion nach dem Endpunkt aufhört
         GeoVector vect = new GeoVector(startPoint, p);
         if (!vect.IsNullVector())
         {
             feedBackLine.SetTwoPoints(startPoint, p);
             actualPoint = currentPoint + vect;
             using (Frame.Project.Undo.ContextFrame(this))
             {
                 if (geoPointProperty != null)
                 {
                     geoPointProperty.SetGeoPoint(actualPoint);
                 }
             }
         }
     }
 }
Esempio n. 22
0
        public override void OnSetAction()
        {
            base.ActiveObject = Face.Construct();
            handed            = true;

            if (axisVector.IsNullVector())
            {
                axisVector = GeoVector.XAxis;
            }
            if (angleRotation == 0.0)
            {
                angleRotation = Math.PI;
            }

            base.TitleId = "Constr.Face.ScrewPath";

            pathInput = new CurveInput("Constr.Face.ScrewPath.Path");
            //curveInput.MouseOverCurvesEvent += new CurveInput.MouseOverCurvesDelegate(curveInputPath);
            //curveInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(curveInputPathChanged);
            if (path != null || shape != null)
            {
                pathInput.Fixed = true;
            }

            rotateLineInput                       = new CurveInput("Constr.Face.ScrewPath.AxisLine");
            rotateLineInput.Decomposed            = true; // nur Einzelelemente, auch bei Polyline und Pfad
            rotateLineInput.MouseOverCurvesEvent += new CurveInput.MouseOverCurvesDelegate(mouseOverAxis);
            //rotateLineInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(RotateLineChanged);

            orientation = new MultipleChoiceInput("Constr.Face.ScrewPath.Orientation", "Constr.Face.ScrewPath.Orientation.Values", 0);
            orientation.SetChoiceEvent += Orientation_SetChoiceEvent;
            orientation.GetChoiceEvent += Orientation_GetChoiceEvent;
            numTurns = new DoubleInput("Constr.Face.ScrewPath.NumTurns", 2.5);
            turns    = 2.5;
            numTurns.GetDoubleEvent += NumTurns_GetDoubleEvent;
            numTurns.SetDoubleEvent += NumTurns_SetDoubleEvent;
            base.SetInput(pathInput, rotateLineInput, orientation, numTurns); // , axisPointInput, axisVectorInput);
            base.ShowAttributes = true;
            base.OnSetAction();
        }
Esempio n. 23
0
            internal bool IntersectWith(TangentPlane other, bool onEdge)
            {
                GeoVector common = this.normal ^ other.normal;

                if (common.IsNullVector())
                {
                    return(false);
                }
                GeoVector perp  = other.normal ^ common;   // Vektor senkrecht zur Schnittrichtung und in anderer Ebene
                GeoPoint  oloc  = toThis * other.location; // anderer Nullpunkt in diesem System
                GeoVector operp = toThis * perp;           // senkrechter Vektor in diesem System
                double    l     = oloc.z / operp.z;
                GeoPoint  ip    = oloc + l * operp;        // Schnittpunkt in diesem System (z muss 0 sein)

                lineStartPoint.Add(new GeoPoint2D(ip));
                lineDirection.Add(new GeoVector2D(toThis * common));
                this.other.Add(other);
                GeoPoint2D sp;

                other.AddLine(new GeoPoint2D(other.toThis * to3d(new GeoPoint2D(ip))), new GeoVector2D(-(other.toThis * common)), this);
                return(true);
            }
 private void SetDimLocation(GeoPoint p)
 {   // der Lagepunkt der Bemassung
     dim.DimLineRef = p;
     if (dimPoint1Input.Fixed & dimPoint2Input.Fixed & dimPoint3Input.Fixed & dimPoint4Input.Fixed)
     {
         GeoVector v = new GeoVector(dim.GetPoint(0), dimP1);
         if (!v.IsNullVector())
         {
             v.Norm();
         }
         v = Geometry.Dist(dim.GetPoint(0), p) * v;
         GeoPoint pLoc = dim.GetPoint(0) + v;
         if (Geometry.Dist(dimP1, pLoc) < Geometry.Dist(dimP2, pLoc))
         {
             dim.SetPoint(1, dimP1);
         }
         else
         {
             dim.SetPoint(1, dimP2);
         }
         v = new GeoVector(dim.GetPoint(0), dimP3);
         if (!v.IsNullVector())
         {
             v.Norm();
         }
         v    = Geometry.Dist(dim.GetPoint(0), p) * v;
         pLoc = dim.GetPoint(0) + v;
         if (Geometry.Dist(dimP3, pLoc) < Geometry.Dist(dimP4, pLoc))
         {
             dim.SetPoint(2, dimP3);
         }
         else
         {
             dim.SetPoint(2, dimP4);
         }
     }
 }
Esempio n. 25
0
        public override void OnSetAction()
        {
            base.ActiveObject = Face.Construct();
            if (axisVector.IsNullVector())
            {
                axisVector = GeoVector.YAxis;
            }
            if (angleRotation == 0.0)
            {
                angleRotation = Math.PI;
            }

            base.TitleId = "Constr.Solid.FaceRotate";

            geoObjectInput = new GeoObjectInput("Constr.Solid.FaceRotate.Path");
            geoObjectInput.MouseOverGeoObjectsEvent       += new GeoObjectInput.MouseOverGeoObjectsDelegate(geoObjectInputFace);
            geoObjectInput.GeoObjectSelectionChangedEvent += new GeoObjectInput.GeoObjectSelectionChangedDelegate(geoObjectInputFaceChanged);
            if (selectedMode)
            {
                geoObjectInput.Fixed = true;
            }

            innerPointInput = new GeoPointInput("Constr.Solid.FaceRotate.InnerPoint");
            innerPointInput.SetGeoPointEvent += new GeoPointInput.SetGeoPointDelegate(SetInnerPointInput);
            innerPointInput.MouseClickEvent  += new MouseClickDelegate(innerPointInputMouseClickEvent);
            innerPointInput.Optional          = true;


            rotateLineInput                             = new CurveInput("Constr.Face.PathRotate.AxisLine");
            rotateLineInput.Decomposed                  = true; // nur Einzelelemente, auch bei Polyline und Pfad
            rotateLineInput.MouseOverCurvesEvent       += new CurveInput.MouseOverCurvesDelegate(RotateAxis);
            rotateLineInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(RotateAxisChanged);

            axisPointInput = new GeoPointInput("Constr.Face.PathRotate.AxisPoint", axisPoint);
            axisPointInput.SetGeoPointEvent   += new GeoPointInput.SetGeoPointDelegate(SetAxisPoint);
            axisPointInput.GetGeoPointEvent   += new GeoPointInput.GetGeoPointDelegate(GetAxisPoint);
            axisPointInput.ForwardMouseInputTo = geoObjectInput;
            axisPointInput.DefinesBasePoint    = true;

            axisVectorInput = new GeoVectorInput("Constr.Face.PathRotate.AxisVector", axisVector);
            axisVectorInput.SetGeoVectorEvent += new GeoVectorInput.SetGeoVectorDelegate(SetAxisVector);
            axisVectorInput.GetGeoVectorEvent += new GeoVectorInput.GetGeoVectorDelegate(GetAxisVector);
            //            vectorInput.DefaultGeoVector = ConstrDefaults.DefaultExtrudeDirection;
            axisVectorInput.ForwardMouseInputTo = geoObjectInput;
            updateOptional();

            AngleInput angleInput = new AngleInput("Constr.Face.PathRotate.Angle", angleRotation);

            angleInput.SetAngleEvent += new AngleInput.SetAngleDelegate(SetAngleInput);
            angleInput.GetAngleEvent += new AngleInput.GetAngleDelegate(GetAngleInput);

            AngleInput angleOffsetInput = new AngleInput("Constr.Face.PathRotate.AngleOffset", angleOffsetRotation);

            angleOffsetInput.SetAngleEvent += new AngleInput.SetAngleDelegate(SetAngleOffsetInput);
            angleOffsetInput.GetAngleEvent += new AngleInput.GetAngleDelegate(GetAngleOffsetInput);
            angleOffsetInput.Optional       = true;

            MultipleChoiceInput insertMode = new MultipleChoiceInput("Constr.Solid.SolidInsertMode", "Constr.Solid.SolidInsertMode.Values");

            insertMode.GetChoiceEvent += new MultipleChoiceInput.GetChoiceDelegate(GetInsertMode);
            insertMode.SetChoiceEvent += new CADability.Actions.ConstructAction.MultipleChoiceInput.SetChoiceDelegate(SetInsertMode);

            base.SetInput(geoObjectInput, innerPointInput, rotateLineInput, axisPointInput, axisVectorInput, angleInput, angleOffsetInput, insertMode);
            base.ShowAttributes   = true;
            base.ShowActiveObject = false;
            base.OnSetAction();
            if (selectedMode)
            {
                rotateOrg(false); // zum Zeichnen und organisieren
            }
        }
Esempio n. 26
0
        public override int GetExtremePositions(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, out List <Tuple <double, double, double, double> > extremePositions)
        {
            switch (other)
            {
            case SphericalSurface ss:
            {
                GeoPoint2D fp = PositionOf(ss.Location);
                extremePositions = new List <Tuple <double, double, double, double> >();
                extremePositions.Add(new Tuple <double, double, double, double>(fp.x, fp.y, double.NaN, double.NaN));
                return(1);
            }

            case ToroidalSurface ts:
            {
                GeoVector dir = (ts.ZAxis ^ Normal) ^ ts.ZAxis;         // this is the direction of a line from the center of the torus where the u positions of the extereme position of the torus are
                if (dir.IsNullVector())
                {
                    break;
                }
                GeoPoint2D[] ip = ts.GetLineIntersection(ts.Location, dir);         // the result should be 4 points, but we are interested in u parameters only and this must be u and u+pi
                if (ip != null && ip.Length > 0)
                {
                    extremePositions = new List <Tuple <double, double, double, double> >();
                    double u = ip[0].x;
                    SurfaceHelper.AdjustUPeriodic(ts, otherBounds, ref u);
                    if (u >= otherBounds.Left && u <= otherBounds.Right)
                    {
                        extremePositions.Add(new Tuple <double, double, double, double>(double.NaN, double.NaN, u, double.NaN));
                    }
                    u += Math.PI;
                    SurfaceHelper.AdjustUPeriodic(ts, otherBounds, ref u);
                    if (u >= otherBounds.Left && u <= otherBounds.Right)
                    {
                        extremePositions.Add(new Tuple <double, double, double, double>(double.NaN, double.NaN, u, double.NaN));
                    }
                    return(extremePositions.Count);
                }
            }
            break;

            case PlaneSurface ps:
            case CylindricalSurface cys:
            case ConicalSurface cos:
                extremePositions = null;
                return(0);

            case ISurfaceImpl ns:
            {
                GeoPoint2D[] normals = ns.BoxedSurfaceEx.PositionOfNormal(Normal);
                extremePositions = new List <Tuple <double, double, double, double> >();
                for (int i = 0; i < normals.Length; i++)
                {
                    if (otherBounds.Contains(normals[i]))
                    {
                        extremePositions.Add(new Tuple <double, double, double, double>(double.NaN, double.NaN, normals[i].x, normals[i].y));
                    }
                }
            }
            break;
            }
            extremePositions = null;
            return(-1); // means: no implementation for this combination
        }
Esempio n. 27
0
        private bool extrudeOrg()
        {
            if (selectedObjectsList == null)
            {
                return(false);
            }
            IGeoObject iGeoObjectSel;

            blk = Block.Construct(); // zur Darstellung
            if (base.ActiveObject != null)
            {
                blk.CopyAttributes(base.ActiveObject);
            }
            // der block wird das neue aktive Objekt, er muss die Attribute tragen, weil sie später
            // wieder von ihm verlangt werden
            Boolean success         = false;                    // hat er wenigstens eins gefunden
            int     extrudeModeTemp = extrudeMode;              // Merker, da extrudeMode evtl. umgeschaltet wird

            for (int i = 0; i < selectedObjectsList.Count; i++) // läuft über alle selektierten Objekte. Evtl nur eins bei Konstruktion
            {
                extrudeMode                 = extrudeModeTemp;
                iGeoObjectSel               = selectedObjectsList[i]; // zur Vereinfachung
                geoObjectOrgList[i]         = iGeoObjectSel;          // zum Weglöschen des Originals in onDone
                ownerList[i]                = iGeoObjectSel.Owner;    // owner merken für löschen
                pathCreatedFromModelList[i] = null;
                shapeList[i]                = null;
                Path p = null;
                if (iGeoObjectSel is ICurve)
                {
                    p = CADability.GeoObject.Path.CreateFromModel(iGeoObjectSel as ICurve, Frame.ActiveView.Model, Frame.ActiveView.Projection, true);
                    if (p == null)
                    {     // also nur Einzelelement
                        if (iGeoObjectSel is Path)
                        { // schon fertig
                            p = iGeoObjectSel.Clone() as Path;
                        }
                        else
                        {  // Pfad aus Einzelobjekt machen:
                            p = Path.Construct();
                            p.Set(new ICurve[] { iGeoObjectSel.Clone() as ICurve });
                        }
                    }
                    else
                    {                                       // CreateFromModel hat was zusammengesetzt
                        geoObjectOrgList[i]         = null; // zum nicht Weglöschen des Originals in onDone
                        pathCreatedFromModelList[i] = p;    // kopie merken für onDone
                        p = p.Clone() as Path;
                        p.Flatten();
                    }
                }
                if (p != null)
                { // Objekt hat keine Ebene und Objektebene eingestellt: Höheneingabe sperren
                    //                heightInput.ReadOnly = ((p.GetPlanarState() != PlanarState.Planar) && planeMode);
                    if (planeMode)
                    {
                        if (p.GetPlanarState() != PlanarState.Planar)
                        {
                            heightInput.ReadOnly = true;
                            //                        heightOffsetInput.ReadOnly = true;
                            //                        VectorOrHeight = true;
                            extrudeMode = 2;
                            optionalOrg();
                        }
                        else
                        {
                            Plane pl = p.GetPlane();
                            pl.Align(base.ActiveDrawingPlane, false, true);

                            //                        planeVector = pl.Normal;
                            vector       = height * pl.Normal;
                            vectorOffset = heightOffset * pl.Normal;
                        }
                    }
                    if (!vectorOffset.IsNullVector())
                    {
                        ModOp m = ModOp.Translate(vectorOffset);
                        p.Modify(m);
                    }
                    IGeoObject shape;
                    if (pipePath == null)
                    {
                        shape = Make3D.MakePrism(p, vector, Frame.Project, true);
                    }
                    else
                    {
                        shape = Make3D.MakePipe(p, pipePath, Frame.Project);
                    }
                    if (shape != null)
                    {
                        //                        shape.CopyAttributes(iGeoObjectSel as IGeoObject);
                        shape.CopyAttributes(blk);
                        // die Attribute müssen vom Block übernommen werden
                        shapeList[i] = shape;         // fertiger Körper in shapeList
                        blk.Add(shape);               // zum Darstellen
                        base.FeedBack.AddSelected(p); // zum Markieren des Ursprungsobjekts
                        success = true;
                    }
                }
                //            VectorOrHeight = VectorOrHeightTemp;
            }
            extrudeMode = extrudeModeTemp;
            if (success)
            {
                base.ActiveObject     = blk; // darstellen
                base.ShowActiveObject = true;
                return(true);
            }
            else
            {
                optionalOrg();
                heightInput.ReadOnly  = false;
                base.ShowActiveObject = false;
                base.FeedBack.ClearSelected();
                return(false);
            }
        }
Esempio n. 28
0
        public override void OnSetAction()
        {
            base.ActiveObject = Face.Construct();
            DefaultLength l = new DefaultLength(ConstructAction.DefaultLength.StartValue.ViewWidth8);

            if (vector.IsNullVector())
            {
                vector = l * base.ActiveDrawingPlane.Normal;
            }
            if (height == 0.0)
            {
                height = l;
            }
            ;
            //           if (!VectorOrHeight)
            if (extrudeMode < 2)
            {
                vector = height * base.ActiveDrawingPlane.Normal;
            }
            base.TitleId = "Constr.Face.PathExtrude";

            curveInput = new CurveInput("Constr.Face.PathExtrude.Path");
            curveInput.MouseOverCurvesEvent       += new CurveInput.MouseOverCurvesDelegate(curveInputPath);
            curveInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(curveInputPathChanged);
            if (selectedMode)
            {
                curveInput.Fixed = true;
            }

            heightInput = new LengthInput("Constr.Face.PathExtrude.Height");
            heightInput.SetLengthEvent     += new LengthInput.SetLengthDelegate(SetHeight);
            heightInput.GetLengthEvent     += new LengthInput.GetLengthDelegate(GetHeight);
            heightInput.ForwardMouseInputTo = curveInput;
            if (selectedMode)
            {
                extrudeOrg();               //schonmal berechnen und markieren!
            }
            planeInput = new BooleanInput("Constr.Face.PathExtrude.Plane", "Constr.Face.PathExtrude.Plane.Values", planeMode);
            planeInput.SetBooleanEvent += new BooleanInput.SetBooleanDelegate(SetPlaneMode);

            vectorInput = new GeoVectorInput("Constr.Face.PathExtrude.Vector", vector);
            vectorInput.SetGeoVectorEvent += new GeoVectorInput.SetGeoVectorDelegate(SetVector);
            vectorInput.GetGeoVectorEvent += new GeoVectorInput.GetGeoVectorDelegate(GetVector);
            //            vectorInput.DefaultGeoVector = ConstrDefaults.DefaultExtrudeDirection;
            vectorInput.ForwardMouseInputTo = curveInput;

            heightOffsetInput = new LengthInput("Constr.Face.PathExtrude.HeightOffset");
            heightOffsetInput.SetLengthEvent     += new LengthInput.SetLengthDelegate(SetHeightOffset);
            heightOffsetInput.GetLengthEvent     += new LengthInput.GetLengthDelegate(GetHeightOffset);
            heightOffsetInput.ForwardMouseInputTo = curveInput;
            heightOffsetInput.Optional            = true;

            vectorOffsetInput = new GeoVectorInput("Constr.Face.PathExtrude.VectorOffset", vectorOffset);
            vectorOffsetInput.SetGeoVectorEvent  += new GeoVectorInput.SetGeoVectorDelegate(SetVectorOffset);
            vectorOffsetInput.GetGeoVectorEvent  += new GeoVectorInput.GetGeoVectorDelegate(GetVectorOffset);
            vectorOffsetInput.ForwardMouseInputTo = curveInput;
            vectorOffsetInput.Optional            = true;

            pipeInput = new CurveInput("Constr.Face.PathExtrude.Pipe");
            pipeInput.MouseOverCurvesEvent       += new CurveInput.MouseOverCurvesDelegate(pipeInputCurves);
            pipeInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(pipeInputCurveChanged);

            optionalOrg();

            SeparatorInput separatorHeight = new SeparatorInput("Constr.Face.PathExtrude.SeparatorHeight");
            SeparatorInput separatorVector = new SeparatorInput("Constr.Face.PathExtrude.SeparatorVector");
            SeparatorInput separatorPipe   = new SeparatorInput("Constr.Face.PathExtrude.SeparatorPipe");

            //            if (selectedMode)
            //                base.SetInput( heightInput, heightOffsetInput, separatorVector, vectorInput, vectorOffsetInput, separatorPipe, pipeInput, planeInput);
            //             else base.SetInput(curveInput,separatorHeight, heightInput, heightOffsetInput,separatorVector,vectorInput, vectorOffsetInput,separatorPipe,pipeInput, planeInput);
            base.SetInput(curveInput, separatorHeight, heightInput, heightOffsetInput, planeInput, separatorVector, vectorInput, vectorOffsetInput, separatorPipe, pipeInput);
            base.ShowAttributes = true;
            base.OnSetAction();
        }
Esempio n. 29
0
        internal void AdjustCoordinate(GeoPoint p)
        {
#if DEBUG
            if (1070 == this.hashCode || 1063 == this.hashCode)
            {
            }
#endif
            GeoPoint mp = new GeoPoint(position, p); // point in between the two starting positions
            // collect all involved surfaces
            Set <Face> surfaces = new Set <Face>();
            foreach (Edge edg in edges)
            {
                surfaces.Add(edg.PrimaryFace);
                if (edg.SecondaryFace != null)
                {
                    surfaces.Add(edg.SecondaryFace);
                }
            }
            // find surfaces, which are not tangential at this position
            Dictionary <GeoVector, Face> nonTangentialSurfaces = new Dictionary <GeoVector, Face>();
            foreach (Face srf in surfaces)
            {
                GeoVector n = srf.Surface.GetNormal(srf.Surface.PositionOf(mp));
                if (n.IsNullVector())
                {
                    continue;                   // a pole
                }
                bool found = false;
                foreach (KeyValuePair <GeoVector, Face> kv in nonTangentialSurfaces)
                {
                    GeoVector cross = kv.Key.Normalized ^ n.Normalized;
                    double    cl    = cross.Length;
                    if (cl < 1e-3)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    nonTangentialSurfaces[n] = srf;
                }
            }
            if (nonTangentialSurfaces.Count >= 3)
            {
                Face[] fcs = new Face[nonTangentialSurfaces.Count];
                nonTangentialSurfaces.Values.CopyTo(fcs, 0);
                GeoPoint2D uv1, uv2, uv3;
                Surfaces.NewtonIntersect(fcs[0].Surface, fcs[0].Area.GetExtent(), fcs[1].Surface, fcs[1].Area.GetExtent(), fcs[2].Surface, fcs[2].Area.GetExtent(), ref mp, out uv1, out uv2, out uv3);
                if ((!fcs[0].Area.Contains(uv1, true) && fcs[0].Area.Distance(uv1) > fcs[0].Area.GetExtent().Size * 1e-4) ||
                    (!fcs[1].Area.Contains(uv2, true) && fcs[1].Area.Distance(uv2) > fcs[0].Area.GetExtent().Size * 1e-4) ||
                    (!fcs[2].Area.Contains(uv3, true) && fcs[2].Area.Distance(uv3) > fcs[2].Area.GetExtent().Size * 1e-4))
                {
                    mp = position; // invalid recalculation, e.g.: three planes with a common intersection line like in 3567_0005_01_02.stp
                }
            }
            else if (nonTangentialSurfaces.Count == 2)
            {   // use the two non tangential surfaces and a plane perpendicular to both surfaces in that point
                // to calculate a good point
                Face[]      fcs = new Face[nonTangentialSurfaces.Count];
                GeoVector[] nrm = new GeoVector[nonTangentialSurfaces.Count];
                nonTangentialSurfaces.Values.CopyTo(fcs, 0);
                nonTangentialSurfaces.Keys.CopyTo(nrm, 0);
                PlaneSurface pls = new PlaneSurface(new Plane(mp, nrm[0], nrm[1]));
                GeoPoint2D   uv1, uv2, uv3;
                Surfaces.NewtonIntersect(fcs[0].Surface, fcs[0].Area.GetExtent(), fcs[1].Surface, fcs[1].Area.GetExtent(), pls, BoundingRect.HalfInfinitBoundingRect, ref mp, out uv1, out uv2, out uv3);
            }

            position = mp;
            foreach (Edge edg in edges)
            {
                if (edg.Curve3D != null && edg.Vertex1 != edg.Vertex2)
                {
                    try
                    {
                        if (edg.Vertex1 == this && !Precision.IsEqual(edg.Curve3D.EndPoint, mp))
                        {
                            edg.Curve3D.StartPoint = mp;
                        }
                        else if (edg.Vertex2 == this && !Precision.IsEqual(edg.Curve3D.StartPoint, mp))
                        {
                            edg.Curve3D.EndPoint = mp;
                        }
                        else if (edg.Vertex1 != this && edg.Vertex2 != this)
                        {
                            throw new ApplicationException("Edge-Vertex mismatch");
                        }
                    }
                    catch { }
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Overrides <see cref="CADability.Actions.ConstructAction.OnSetAction ()"/>
        /// </summary>
        public override void OnSetAction()
        {
            base.TitleId = "CopyMatrixObjects";

            BoundingRect result = originals.GetExtent(Frame.ActiveView.ProjectedModel.Projection, true, false);

            centerPoint = base.ActiveDrawingPlane.ToGlobal(result.GetCenter());
            distX       = result.Width;
            distY       = result.Height;
            // da oben static private, werden diese Variablen gemerkt. Beim ersten Mal vorbesetzen:
            if ((horRight == 0) & (horLeft == 0) & (verUp == 0) & (verDown == 0))
            {
                horRight = 3;
                verUp    = 2;
            }
            // da oben static private, wird diese Variable gemerkt. Beim ersten Mal vorbesetzen:
            if (dirV.IsNullVector())
            {
                dirV = new GeoVector(1.0, 0.0, 0.0);
            }

            IntInput horCountRight = new IntInput("CopyMatrixObjects.HorCountRight", horRight);

            horCountRight.SetMinMax(0, int.MaxValue, true);
            horCountRight.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetHorCountRight);
            //			horCountRight.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcHorCountRight);

            IntInput verCountUp = new IntInput("CopyMatrixObjects.VerCountUp", verUp);

            verCountUp.SetMinMax(0, int.MaxValue, true);
            verCountUp.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetVerCountUp);
            //			verCountUp.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcVerCountUp);

            horDist = new LengthInput("CopyMatrixObjects.HorDist", distX);
            horDist.SetDistanceFromLine(centerPoint, centerPoint + (dirV ^ base.ActiveDrawingPlane.Normal));
            horDist.SetLengthEvent += new CADability.Actions.ConstructAction.LengthInput.SetLengthDelegate(SetHorDist);

            verDist = new LengthInput("CopyMatrixObjects.VerDist", distY);
            verDist.SetDistanceFromLine(centerPoint, centerPoint + dirV);
            verDist.SetLengthEvent += new CADability.Actions.ConstructAction.LengthInput.SetLengthDelegate(SetVerDist);

            GeoVectorInput dir = new GeoVectorInput("CopyMatrixObjects.Direction", dirV);

            dir.Optional = true;
            dir.SetVectorFromPoint(centerPoint);
            dir.SetGeoVectorEvent += new CADability.Actions.ConstructAction.GeoVectorInput.SetGeoVectorDelegate(SetDir);
            dir.IsAngle            = true;

            IntInput horCountLeft = new IntInput("CopyMatrixObjects.HorCountLeft", horLeft);

            horCountLeft.SetMinMax(0, int.MaxValue, true);
            horCountLeft.Optional     = true;
            horCountLeft.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetHorCountLeft);
            //			horCountLeft.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcHorCountLeft);

            IntInput verCountDown = new IntInput("CopyMatrixObjects.VerCountDown", verDown);

            verCountDown.SetMinMax(0, int.MaxValue, true);
            verCountDown.Optional     = true;
            verCountDown.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetVerCountDown);
            //			verCountDown.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcVerCountDown);


            base.SetInput(horCountRight, verCountUp, horDist, verDist, dir, horCountLeft, verCountDown);

            base.OnSetAction();
            showMatrix();
        }