Beispiel #1
0
 private bool Radius1(double length)
 {
     if (length > Precision.eps)
     {
         coneRadius1 = length;
         coneDirX    = coneRadius1 * coneDirX.Normalized;
         cone        = Make3D.MakeCone(coneStartPoint, coneDirX, coneDirZ, coneRadius1, coneRadius2);
         if (cone == null)
         {
             return(false);
         }
         cone.CopyAttributes(base.ActiveObject);
         if (startPointInput.Fixed && !endPointInput.Fixed)
         { // er will also einen Kegel senkrecht auf der drawingplane
             endPointInput.Optional     = true;
             height.Optional            = false;
             height.ForwardMouseInputTo = new object[0]; // den forward abschalten
             coneDirX = coneRadius1 * base.ActiveDrawingPlane.DirectionX;
             coneDirZ = coneHeight * (base.ActiveDrawingPlane.DirectionX ^ base.ActiveDrawingPlane.DirectionY);
         }
         base.ActiveObject = cone;
         return(true);
     }
     return(false);
 }
Beispiel #2
0
 public override void OnDone()
 {
     if (edges.Count > 0)
     {
         IGeoObject[] affected;
         IGeoObject[] modified = Make3D.MakeChamfer(theFace, edges.ToArray(), dist1, dist2, out affected);
         if (affected.Length > 0)
         {
             using (Frame.Project.Undo.UndoFrame)
             {
                 IGeoObjectOwner owner = null;
                 for (int i = 0; i < affected.Length; ++i)
                 {
                     if (owner == null || affected[i].Owner is Model)
                     {
                         owner = affected[i].Owner;
                     }
                     affected[i].Owner.Remove(affected[i]);
                 }
                 for (int i = 0; i < modified.Length; ++i)
                 {
                     owner.Add(modified[i]);
                 }
             }
         }
     }
     base.OnDone();
 }
 private bool ruledSolidOrg()
 {
     if (((p1 as ICurve).GetPlanarState() == PlanarState.Planar) && ((p2 as ICurve).GetPlanarState() == PlanarState.Planar))
     {     // also nur Ebene Pfade mit unterschiedlichen Ebenen:
         if (!Precision.IsEqual((p1 as ICurve).GetPlane(), (p2 as ICurve).GetPlane()))
         { // also was geeignetes dabei
             Solid ss = Make3D.MakeRuledSolid(p1, p2, Frame.Project);
             if (ss != null)
             {
                 if (base.ActiveObject != null)
                 {
                     ss.CopyAttributes(base.ActiveObject);
                 }
                 // der block wird das neue aktive Objekt, er muss die Attribute tragen, weil sie später
                 // wieder von ihm verlangt werden
                 //                        ss.CopyAttributes(attrObject);
                 base.ActiveObject     = ss; // darstellen
                 base.ShowActiveObject = true;
                 return(true);
             }
         }
     }
     base.ShowActiveObject = false;
     return(false);
 }
Beispiel #4
0
 private void Recalculate()
 {
     if (path != null)
     {
         if (path.IsClosed)
         {
             Solid sld = Make3D.MakeHelicalSolid(plane.Project(axis.Location), plane.Project(axis.Direction), plane, path, turns, handed);
             if (sld != null)
             {
                 ActiveObject = sld;
             }
         }
         else
         {
             Solid sld = Make3D.MakeHelicalSolid(plane.Project(axis.Location), plane, path, turns, handed);
             if (sld != null)
             {
                 ActiveObject = sld;
             }
         }
     }
     else if (shape != null)
     {
         Solid sld = Make3D.MakeHelicalSolid(plane.Project(axis.Location), plane.Project(axis.Direction), plane, shape.SimpleShapes[0].Outline.AsPath(), turns, handed);
         if (sld != null)
         {
             ActiveObject = sld;
         }
     }
 }
Beispiel #5
0
 private bool Radius1(double length)
 {
     if (length > Precision.eps)
     {  // Ringradius=torusRadius2 angleichen
         if (!radius2.Fixed)
         {
             torusRadius2 = length / 5.0;
         }
         else
         { // wenn torusRadius2 schon bestimmt: torusRadius1 muss immer kleiner sein!
             if (torusRadius1 <= torusRadius2)
             {
                 return(false);
             }
         }
         torusRadius1 = length;
         torus        = Make3D.MakeTorus(torusCenterPoint, torusNormal, torusRadius1, torusRadius2);
         if (torus == null)
         {
             return(false);
         }
         torus.CopyAttributes(base.ActiveObject);
         base.ActiveObject = torus;
         return(true);
     }
     return(false);
 }
Beispiel #6
0
 private void EndPoint(GeoPoint p)
 {
     if (!Precision.IsEqual(p, coneStartPoint))
     {
         coneDirZ = new GeoVector(coneStartPoint, p);
         if (height.Fixed) // die schon bestimmte Höhe benutzen!
         {
             coneDirZ = coneHeight * coneDirZ.Normalized;
         }
         else
         {
             coneHeight = coneDirZ.Length;
         }
         // coneDirX muss irgendwie senkrecht auf coneDirZ stehen. Hier: Hilfsvektor definieren mit der kleinsten Komponente von coneDirZ
         GeoVector vT = new GeoVector(1, 0, 0); // x am kleinsten
         if (Math.Abs(coneDirZ.y) < Math.Abs(coneDirZ.x))
         {
             vT = new GeoVector(0, 1, 0); // y am kleinsten
         }
         if ((Math.Abs(coneDirZ.x) > Math.Abs(coneDirZ.z)) && (Math.Abs(coneDirZ.y) > Math.Abs(coneDirZ.z)))
         {
             vT = new GeoVector(0, 0, 1); // z am kleinsten
         }
         coneDirX = coneRadius1 * (vT ^ coneDirZ).Normalized;
         cone     = Make3D.MakeCone(coneStartPoint, coneDirX, coneDirZ, coneRadius1, coneRadius2);
         cone.CopyAttributes(base.ActiveObject);
         base.ActiveObject = cone;
     }
 }
Beispiel #7
0
 private void CenterPoint(GeoPoint p)
 {
     torusCenterPoint = p;
     torus            = Make3D.MakeTorus(torusCenterPoint, torusNormal, torusRadius1, torusRadius2);
     torus.CopyAttributes(base.ActiveObject);
     base.ActiveObject = torus;
 }
Beispiel #8
0
 private bool ruledFaceOrg()
 {
     if (!(Precision.IsEqual(p1.StartPoint, p2.StartPoint) && (Precision.IsEqual(p1.EndPoint, p2.EndPoint)))) // 1. Näherung, dass sie nicht gleich sind!
     {
         if ((p1.IsClosed && p2.IsClosed) || (!p1.IsClosed && !p2.IsClosed))                                  // OPenCascade will nur geschlossene oder nur offene
         {
             if ((((p1 as ICurve).GetPlanarState() == PlanarState.Planar) || (p1 as ICurve).GetPlanarState() == PlanarState.UnderDetermined) && (((p2 as ICurve).GetPlanarState() == PlanarState.Planar) || (p2 as ICurve).GetPlanarState() == PlanarState.UnderDetermined))
             { // also nur Ebene Pfade mit unterschiedlichen Ebenen oder unbestimmt, z.B. Linien:
                 if (((p1 as ICurve).GetPlanarState() == PlanarState.Planar) && ((p2 as ICurve).GetPlanarState() == PlanarState.Planar) && Precision.IsEqual((p1 as ICurve).GetPlane(), (p2 as ICurve).GetPlane()))
                 {
                     return(false);
                 }
                 // also was geeignetes dabei
                 IGeoObject ss = Make3D.MakeRuledShell(p1, p2, Frame.Project);
                 if (ss != null)
                 {
                     if (base.ActiveObject != null)
                     {
                         ss.CopyAttributes(base.ActiveObject);
                     }
                     // der block wird das neue aktive Objekt, er muss die Attribute tragen, weil sie später
                     // wieder von ihm verlangt werden
                     //                        ss.CopyAttributes(attrObject);
                     base.ActiveObject     = ss; // darstellen
                     base.ShowActiveObject = true;
                     return(true);
                 }
             }
         }
     }
     base.ShowActiveObject = false;
     return(false);
 }
Beispiel #9
0
 private void StartPoint(GeoPoint p)
 {
     boxStartPoint = p;
     box           = Make3D.MakeBox(boxStartPoint, boxDirX, boxDirY, boxDirZ);
     box.CopyAttributes(base.ActiveObject);
     base.ActiveObject = box;
 }
Beispiel #10
0
 private void CenterPoint(GeoPoint p)
 {
     sphereCenterPoint = p;
     radius.SetDistanceFromPoint(p);
     sphere = Make3D.MakeSphere(sphereCenterPoint, sphereRadius);
     sphere.CopyAttributes(base.ActiveObject);
     base.ActiveObject = sphere;
 }
Beispiel #11
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;
 }
Beispiel #12
0
 private void StartPoint(GeoPoint p)
 {
     coneStartPoint = p;
     // die Höhe berechnet sich als Abstand von diesem Punkt
     height.SetDistanceFromPoint(coneStartPoint);
     cone = Make3D.MakeCone(coneStartPoint, coneDirX, coneDirZ, coneRadius1, coneRadius2);
     cone.CopyAttributes(base.ActiveObject);
     base.ActiveObject = cone;
 }
Beispiel #13
0
 private void EndPoint(GeoPoint p)
 { // definiert die Achse des Torus
     if (!Precision.IsEqual(p, torusCenterPoint))
     {
         torusNormal = new GeoVector(torusCenterPoint, p);
         torus       = Make3D.MakeTorus(torusCenterPoint, torusNormal, torusRadius1, torusRadius2);
         torus.CopyAttributes(base.ActiveObject);
         base.ActiveObject = torus;
     }
 }
Beispiel #14
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);
 }
Beispiel #15
0
 private bool Height(double length)
 {
     if (length > Precision.eps)
     {
         boxLengthZ = length;
         boxDirZ    = boxLengthZ * boxDirZ.Normalized;
         box        = Make3D.MakeBox(boxStartPoint, boxDirX, boxDirY, boxDirZ);
         box.CopyAttributes(base.ActiveObject);
         base.ActiveObject = box;
         return(true);
     }
     return(false);
 }
Beispiel #16
0
 private bool Length(double length)
 {
     //            if (Math.Abs(length) > Precision.eps) geht nicht in MakeBox
     if (length > Precision.eps)
     {
         boxLengthX = length;
         boxDirX    = boxLengthX * boxDirX.Normalized;
         box        = Make3D.MakeBox(boxStartPoint, boxDirX, boxDirY, boxDirZ);
         box.CopyAttributes(base.ActiveObject);
         base.ActiveObject = box;
         return(true);
     }
     return(false);
 }
Beispiel #17
0
        public override void OnSetAction()
        {
            cone           = Solid.Construct();
            base.BasePoint = ConstrDefaults.DefaultStartPoint;
            coneStartPoint = base.BasePoint;
            coneRadius1    = ConstrDefaults.DefaultArcRadius;
            coneRadius2    = ConstrDefaults.DefaultArcRadius / 2;
            coneHeight     = ConstrDefaults.DefaultBoxHeight;
            coneDirX       = coneRadius1 * base.ActiveDrawingPlane.DirectionX;
            coneDirZ       = coneHeight * (base.ActiveDrawingPlane.DirectionX ^ base.ActiveDrawingPlane.DirectionY);
            cone           = Make3D.MakeCone(coneStartPoint, coneDirX, coneDirZ, coneRadius1, coneRadius2);

            base.ActiveObject = cone;
            base.TitleId      = "Constr.Cone";

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

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

            radius1 = new LengthInput("Constr.Cone.Radius1");
            radius1.DefaultLength         = ConstrDefaults.DefaultArcRadius;
            radius1.SetLengthEvent       += new ConstructAction.LengthInput.SetLengthDelegate(Radius1);
            radius1.GetLengthEvent       += new LengthInput.GetLengthDelegate(GetRadius1);
            radius1.CalculateLengthEvent += new CADability.Actions.ConstructAction.LengthInput.CalculateLengthDelegate(Radius1Calculate);


            radius2 = new LengthInput("Constr.Cone.Radius2");
            radius2.SetLengthEvent       += new ConstructAction.LengthInput.SetLengthDelegate(Radius2);
            radius2.GetLengthEvent       += new LengthInput.GetLengthDelegate(GetRadius2);
            radius2.CalculateLengthEvent += new CADability.Actions.ConstructAction.LengthInput.CalculateLengthDelegate(Radius2Calculate);

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

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

            base.OnSetAction();
        }
Beispiel #18
0
 private bool Radius2(double length)
 {
     if ((length > Precision.eps) && (length < torusRadius1))
     {   // Neue Torus
         torusRadius2 = length;
         torus        = Make3D.MakeTorus(torusCenterPoint, torusNormal, torusRadius1, torusRadius2);
         if (torus == null)
         {
             return(false);
         }
         torus.CopyAttributes(base.ActiveObject);
         base.ActiveObject = torus;
         return(true);
     }
     return(false);
 }
Beispiel #19
0
 private bool Radius(double length)
 {
     if (length > Precision.eps)
     {
         sphereRadius = length;
         sphere       = Make3D.MakeSphere(sphereCenterPoint, sphereRadius);
         if (sphere == null)
         {
             return(false);
         }
         sphere.CopyAttributes(base.ActiveObject);
         base.ActiveObject = sphere;
         return(true);
     }
     return(false);
 }
Beispiel #20
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);
 }
Beispiel #21
0
 private bool Height(double length)
 {
     if (length > Precision.eps)
     {
         coneHeight = length;
         coneDirZ   = coneHeight * coneDirZ.Normalized;
         cone       = Make3D.MakeCone(coneStartPoint, coneDirX, coneDirZ, coneRadius1, coneRadius2);
         if (cone == null)
         {
             return(false);
         }
         cone.CopyAttributes(base.ActiveObject);
         base.ActiveObject = cone;
         return(true);
     }
     return(false);
 }
Beispiel #22
0
        private double HeightCalculate(GeoPoint MousePosition)
        {  // falls die Höhe über einen Punkt im Raum über der jetzigen Box bestimmt wird:
            // der Lotfußpunkt von MousePosition auf die Ebene X-Y
            Plane  pl = new Plane(boxStartPoint, boxDirX, boxDirY);
            double l  = pl.ToLocal(MousePosition).z;

            //            if (Math.Abs(l) > Precision.eps) geht nicht in MakeBox
            if (l > Precision.eps)
            {   // Neue Box
                boxLengthZ = l;
                box        = Make3D.MakeBox(boxStartPoint, boxDirX, boxDirY, boxLengthZ * boxDirZ.Normalized);
                box.CopyAttributes(base.ActiveObject);
                base.ActiveObject = box;
                // nun die Länge zurückliefern
                return(boxLengthZ);
            }
            return(0);
        }
Beispiel #23
0
 public override void OnDone()
 {
     if (edges.Count > 0)
     {
         IGeoObject[] affected;
         IGeoObject[] modified = Make3D.MakeFillet(edges.ToArray(), radius, out affected);
         if (affected != null && affected.Length > 0)
         {
             using (Frame.Project.Undo.UndoFrame)
             {
                 IGeoObjectOwner owner = null; // should be a solid if the affected shell is part of a solid, or owner should be the model
                 // only the edges of a single shell should be rounded!
                 for (int i = 0; i < affected.Length; ++i)
                 {
                     if (owner == null || affected[i].Owner is Model)
                     {
                         owner = affected[i].Owner;
                     }
                     affected[i].Owner.Remove(affected[i]);
                 }
                 if (owner is Model model)
                 {
                     model.Remove(affected);
                     model.Add(modified);
                 }
                 else if (owner is Solid sld)
                 {
                     Model m = sld.Owner as Model;
                     if (m != null)    // not able to round edges of Solid which is part of a Block?
                     {
                         m.Remove(sld);
                         for (int i = 0; i < modified.Length; ++i)
                         {
                             Solid rsld = Solid.Construct();
                             rsld.SetShell(modified[i] as Shell);
                             m.Add(rsld);
                         }
                     }
                 }
             }
         }
     }
     base.OnDone();
 }
Beispiel #24
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();
        }
Beispiel #25
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);
 }
Beispiel #26
0
        public override void OnSetAction()
        {
            torus            = Solid.Construct();
            base.BasePoint   = ConstrDefaults.DefaultStartPoint;
            torusCenterPoint = base.BasePoint;
            torusRadius1     = ConstrDefaults.DefaultArcRadius;
            torusRadius2     = ConstrDefaults.DefaultArcRadius / 5;
            torusNormal      = base.ActiveDrawingPlane.Normal;
            torus            = Make3D.MakeTorus(torusCenterPoint, torusNormal, torusRadius1, torusRadius2);

            base.ActiveObject = torus;
            base.TitleId      = "Constr.Torus";

            centerPointInput = new GeoPointInput("Constr.Torus.Center");
            centerPointInput.DefaultGeoPoint   = ConstrDefaults.DefaultStartPoint;
            centerPointInput.DefinesBasePoint  = true;
            centerPointInput.SetGeoPointEvent += new ConstructAction.GeoPointInput.SetGeoPointDelegate(CenterPoint);

            endPointInput = new GeoPointInput("Constr.Torus.EndPoint");
            endPointInput.SetGeoPointEvent += new ConstructAction.GeoPointInput.SetGeoPointDelegate(EndPoint);
            endPointInput.Optional          = true;

            radius1 = new LengthInput("Constr.Torus.Radius1");
            radius1.DefaultLength         = ConstrDefaults.DefaultArcRadius;
            radius1.SetLengthEvent       += new ConstructAction.LengthInput.SetLengthDelegate(Radius1);
            radius1.GetLengthEvent       += new LengthInput.GetLengthDelegate(GetRadius1);
            radius1.CalculateLengthEvent += new CADability.Actions.ConstructAction.LengthInput.CalculateLengthDelegate(Radius1Calculate);


            radius2 = new LengthInput("Constr.Torus.Radius2");
            radius2.SetLengthEvent       += new ConstructAction.LengthInput.SetLengthDelegate(Radius2);
            radius2.GetLengthEvent       += new LengthInput.GetLengthDelegate(GetRadius2);
            radius2.CalculateLengthEvent += new CADability.Actions.ConstructAction.LengthInput.CalculateLengthDelegate(Radius2Calculate);

            base.SetInput(centerPointInput, endPointInput, radius1, radius2);
            base.ShowAttributes = true;

            base.OnSetAction();
        }
Beispiel #27
0
        public override void OnSetAction()
        {
            sphere            = Solid.Construct();
            base.BasePoint    = ConstrDefaults.DefaultStartPoint;
            sphereCenterPoint = base.BasePoint;
            sphereRadius      = ConstrDefaults.DefaultArcRadius;
            sphere            = Make3D.MakeSphere(sphereCenterPoint, sphereRadius);

            base.ActiveObject = sphere;
            base.TitleId      = "Constr.Sphere";

            centerPointInput = new GeoPointInput("Constr.Sphere.Center");
            centerPointInput.DefaultGeoPoint   = ConstrDefaults.DefaultStartPoint;
            centerPointInput.SetGeoPointEvent += new ConstructAction.GeoPointInput.SetGeoPointDelegate(CenterPoint);

            radius = new LengthInput("Constr.Sphere.Radius");
            radius.DefaultLength   = ConstrDefaults.DefaultArcRadius;
            radius.SetLengthEvent += new ConstructAction.LengthInput.SetLengthDelegate(Radius);

            base.SetInput(centerPointInput, radius);
            base.ShowAttributes = true;

            base.OnSetAction();
        }
        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);
            }
        }
Beispiel #29
0
        static public void ruledFaceDo(GeoObjectList geoObjectList, IFrame frame)
        { // im Falle zweier selektierter Pfade: alles machen ohne Aktion!
            bool pathCreatedFromModel1 = false;
            bool pathCreatedFromModel2 = false;
            // erstmal versuchen, Pfade draus zu machen
            Path p1;

            if (geoObjectList[0] is Path)
            { // schon fertig
                p1 = geoObjectList[0].Clone() as Path;
            }
            else
            {  // Pfad aus Einzelobjekt machen:
                p1 = findPath(geoObjectList[0], frame.ActiveView.Model, out pathCreatedFromModel1);
            }
            Path p2;

            if (geoObjectList[1] is Path)
            { // schon fertig
                p2 = geoObjectList[1].Clone() as Path;
            }
            else
            {  // Pfad aus Einzelobjekt machen:
                p2 = findPath(geoObjectList[1], frame.ActiveView.Model, out pathCreatedFromModel2);
            }
            IGeoObject ss = null;

            if ((p1 != null) && (p2 != null))
            {
                ss = Make3D.MakeRuledShell(p1, p2, frame.Project);
            }
            if (ss != null)
            {
                using (frame.Project.Undo.UndoFrame)
                {
                    ss.CopyAttributes(geoObjectList[0]);
                    frame.Project.GetActiveModel().Add(ss); // einfügen
                    if (!pathCreatedFromModel2 && frame.GetBooleanSetting("Construct.3D_Delete2DBase", false))
                    {
                        geoObjectList[1].Owner.Remove(geoObjectList[1] as IGeoObject);                                                                                        // Original weg
                    }
                    if (pathCreatedFromModel2)
                    { // die Einzelelemente des CreateFromModel identifizieren
                        for (int i = 0; i < p2.Count; ++i)
                        {
                            IGeoObject obj = null;
                            if ((p2.Curve(i) as IGeoObject).UserData.ContainsData("CADability.Path.Original"))
                            {
                                obj = (p2.Curve(i) as IGeoObject).UserData.GetData("CADability.Path.Original") as IGeoObject;
                            }
                            if (obj != null && obj.Owner != null)
                            {
                                obj.Owner.Remove(obj);                                   // löschen
                            }
                        }
                    }
                    if (!pathCreatedFromModel1 && frame.GetBooleanSetting("Construct.3D_Delete2DBase", false))
                    {
                        geoObjectList[0].Owner.Remove(geoObjectList[0] as IGeoObject);
                    }
                    if (pathCreatedFromModel1)
                    { // die Einzelelemente des CreateFromModel identifizieren
                        for (int i = 0; i < p1.Count; ++i)
                        {
                            IGeoObject obj = null;
                            if ((p1.Curve(i) as IGeoObject).UserData.ContainsData("CADability.Path.Original"))
                            {
                                obj = (p1.Curve(i) as IGeoObject).UserData.GetData("CADability.Path.Original") as IGeoObject;
                            }
                            if (obj != null && obj.Owner != null)
                            {
                                obj.Owner.Remove(obj);                                   // löschen
                            }
                        }
                    }
                }
            }
        }
        public Shell GetInsidePart()
        {
            closedBorder.Flatten();
            if (!closedBorder.IsClosed)
            {
                Line l = Line.Construct();
                l.SetTwoPoints(closedBorder.EndPoint, closedBorder.StartPoint);
                closedBorder.Add(l);
            }
            vertexToFace = new Face[closedBorder.CurveCount];
            for (int i = 0; i < closedBorder.CurveCount; i++)
            {
                Face fc = FindClosestFace(closedBorder.Curve(i).StartPoint);
                if (fc == null)
                {
                    throw new SplitShellWithCurvesException();
                }
                vertexToFace[i] = fc;
            }
            all2DCurves  = new Dictionary <Face, List <ICurve2D> >();
            splitedEdges = new Dictionary <Edge, List <double> >();
            for (int i = 0; i < vertexToFace.Length; i++)
            {
                InsertCurve(i);
            }
            // jetzt die Faces beschneiden und eine neue Shell bauen
            Vertex[] vertices = shell.Vertices;
            outsideVertices = new Set <Vertex>();
            for (int i = 0; i < vertices.Length; i++)
            {   // wenn der Vertex eine Außenkante hat, dann gilt er als außenliegend
                Edge[] vedges = vertices[i].Edges;
                for (int j = 0; j < vedges.Length; j++)
                {
                    if (vedges[j].SecondaryFace == null)
                    {
                        FollowVertex(vertices[j]);
                    }
                }
            }
#if DEBUG
            DebuggerContainer dc = new DebuggerContainer();
            foreach (Vertex vtx in outsideVertices)
            {
                Point pnt = Point.Construct();
                pnt.Location = vtx.Position;
                pnt.Symbol   = PointSymbol.Circle;
                dc.Add(pnt, vtx.GetHashCode());
            }
#endif
            // alle Faces, die aufgesplitted werden müssen:
            Set <Face> splittedFaces = new Set <Face>();
            foreach (Edge edge in splitedEdges.Keys)
            {
                splittedFaces.Add(edge.PrimaryFace);
                if (edge.SecondaryFace != null)
                {
                    splittedFaces.Add(edge.SecondaryFace);
                }
            }
            resultingFaces = new List <Face>();
            for (int i = 0; i < shell.Faces.Length; i++)
            {
                Face face = shell.Faces[i];
                if (splittedFaces.Contains(face))
                {
                    AddSplittedFace(face);
                }
                else
                {
                    if (!outsideVertices.Contains(face.Vertices[0]))
                    {
                        resultingFaces.Add(face.Clone() as Face);
                    }
                }
            }
            GeoObjectList res = Make3D.SewFacesAndShells(new GeoObjectList(resultingFaces.ToArray()));
            if (res.Count == 1)
            {
                return(res[0] as Shell);
            }
            return(null);
        }