public GeoObjectList makeFaceDo(GeoObjectList selectedObjectsList, IFrame frame) { this.selectedObjectsList = selectedObjectsList.Clone(); ListDefault(selectedObjectsList.Count); // setzt alle Listen auf gleiche Länge, Inhalte "null" IGeoObject iGeoObjectSel; // IGeoObject iGeoObjectOrg; Boolean success = false; // hat er wenigstens eins gefunden GeoObjectList outList = new GeoObjectList(); // sammelt die gelungenen faces for (int i = 0; i < selectedObjectsList.Count; i++) // läuft über alle selektierten Objekte. Evtl nur eins bei Konstruktion { IGeoObject iGeoObjectTemp = null; // lokaler Merker 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; faceList[i] = null; // Boolean VectorOrHeightTemp = VectorOrHeight; if (!(iGeoObjectSel is Face) && !(iGeoObjectSel is Shell)) { if ((iGeoObjectSel is ICurve)) { Path p = null; if (selectedObjectsList.Count == 1 && !(iGeoObjectSel as ICurve).IsClosed) { 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 if (p.IsClosed) { 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.IsClosed) { // jetzt face machen iGeoObjectTemp = Make3D.MakeFace(p, frame.Project); } } } if (iGeoObjectTemp != null) { // also was geeignetes dabei iGeoObjectTemp.CopyAttributes(iGeoObjectSel as IGeoObject); faceList[i] = iGeoObjectTemp; // fertiger Körper in shapeList success = true; } } // for-Schleife über die Objekte der Liste if (success) { using (frame.Project.Undo.UndoFrame) { for (int i = 0; i < selectedObjectsList.Count; i++) // geht durch die komplette Liste { if (faceList[i] != null) // nur hier was machen! { outList.Add(faceList[i]); // die Guten sammeln frame.Project.GetActiveModel().Add(faceList[i]); // einfügen if (frame.GetBooleanSetting("Construct.3D_Delete2DBase", false)) { if (geoObjectOrgList[i] != null) // evtl. Einzelobjekt (Object oder Path) als Original rauslöschen { ownerList[i].Remove(geoObjectOrgList[i] as IGeoObject); } else { // die Einzelelemente des CreateFromModel identifizieren for (int j = 0; j < pathCreatedFromModelList[i].Count; ++j) { IGeoObject obj = null; if ((pathCreatedFromModelList[i].Curve(j) as IGeoObject).UserData.ContainsData("CADability.Path.Original")) { obj = (pathCreatedFromModelList[i].Curve(j) as IGeoObject).UserData.GetData("CADability.Path.Original") as IGeoObject; } if (obj != null && obj.Owner != null) { obj.Owner.Remove(obj); // löschen } } } } } } } return(outList); } return(null); }
private bool rotateOrg(bool openDraw) { if (selectedObjectsList == null || selectedObjectsList.Count == 0) { return(false); } IGeoObject selectedObject = null; blk = Block.Construct(); // as feedback object 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; GeoPoint axisPointSav = axisPoint; GeoVector axisVectorSav = axisVector; updateOptional(); if (selectedObjectsList.Count > 1) { // maybe there are several curves in the list, then we try to make a path // and use only this path. No mixture of faces and paths possible List <ICurve> crvs = new List <ICurve>(); for (int i = 0; i < selectedObjectsList.Count; i++) { if (selectedObjectsList[i] is ICurve crv) { crvs.Add(crv); } } if (crvs.Count > 1) { Path path = Path.FromSegments(crvs, false); if (path != null) { selectedObjectsList.Clear(); selectedObjectsList.Add(path); } } } for (int i = 0; i < selectedObjectsList.Count; i++) { IGeoObject objectToRotate = null; // lokaler Merker geoObjectOrgList[i] = selectedObject; // zum Weglöschen des Originals in onDone selectedObject = selectedObjectsList[i]; ownerList[i] = selectedObject.Owner; // owner merken für löschen pathCreatedFromModelList[i] = null; shapeList[i] = null; if ((selectedObject is Face) || (selectedObject is Shell)) { // nur kopieren objectToRotate = selectedObject.Clone(); } else { if (selectedObject is ICurve selCurve) { Path p = null; if (!selCurve.IsClosed) { // trying to rotate an open curve: if the axis and the curve have a commonn plane close a path with the perpendicular foot points and axis segment Line axisLine = Line.TwoPoints(axisPoint, axisPoint + axisVector); if (Curves.GetCommonPlane(new ICurve[] { selCurve, axisLine }, out Plane commonPlane)) { Line l1 = Line.TwoPoints(selCurve.EndPoint, Geometry.DropPL(selCurve.EndPoint, axisPoint, axisVector)); Line l2 = Line.TwoPoints(Geometry.DropPL(selCurve.StartPoint, axisPoint, axisVector), selCurve.StartPoint); Line l3 = Line.TwoPoints(l1.EndPoint, l2.StartPoint); List <ICurve> closedPath = new List <ICurve>(); closedPath.Add(selCurve); if (l1.Length > Precision.eps) { closedPath.Add(l1); } if (l3.Length > Precision.eps) { closedPath.Add(l3); } if (l2.Length > Precision.eps) { closedPath.Add(l2); } p = Path.FromSegments(closedPath, true); // should always work p.Flatten(); } } else { p = Path.FromSegments(new ICurve[] { selCurve }, true); } if (p == null) { continue; // no path constructed } if ((p as ICurve).GetSelfIntersections().Length > 0) { continue; // not possible } if (!p.IsClosed) { continue; } // make a face from the closed pathe objectToRotate = Make3D.MakeFace(p, Frame.Project, true); } } if (objectToRotate != null) { // also was geeignetes dabei //if (angleOffsetRotation != 0.0) //{ // ModOp m = ModOp.Rotate(axisPoint, axisVector, new SweepAngle(angleOffsetRotation)); // iGeoObjectTemp.Modify(m); //} double sw = angleRotation; if (sw == 0.0) { sw = Math.PI * 2.0; } // IGeoObject shape = Make3D.MakeRevolution(iGeoObjectTemp, axisPoint, axisVector, sw, Frame.Project); IGeoObject shape = Make3D.Rotate(objectToRotate, new Axis(axisPoint, axisVector), sw, angleOffsetRotation, Frame.Project); if (shape != null) { shape.CopyAttributes(blk); shapeList[i] = shape; // fertiger Körper in shapeList blk.Add(shape); // resulting object base.FeedBack.AddSelected(objectToRotate); // zum Markieren des Ursprungsobjekts success = true; } } } axisPoint = axisPointSav; // im Fall nicht geschlossener Pfad und nichts bestimmt, werden diese Parameter oben verstellt axisVector = axisVectorSav; if (success) { base.ActiveObject = blk; // darstellen base.ShowActiveObject = true; return(true); } else { updateOptional(); base.ShowActiveObject = false; base.FeedBack.ClearSelected(); return(false); } }
private bool makeFaceOrg() { if (selectedObjectsList == null) { return(false); } IGeoObject iGeoObjectSel; // IGeoObject iGeoObjectOrg; 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 for (int i = 0; i < selectedObjectsList.Count; i++) // läuft über alle selektierten Objekte. Evtl nur eins bei Konstruktion { IGeoObject iGeoObjectTemp = null; // lokaler Merker 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; faceList[i] = null; // Boolean VectorOrHeightTemp = VectorOrHeight; if (!(iGeoObjectSel is Face) && !(iGeoObjectSel is Shell)) { if ((iGeoObjectSel is ICurve)) { Path p = null; if (selectedObjectsList.Count == 1) { 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 if (p.IsClosed) { 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.IsClosed) { // jetzt face machen iGeoObjectTemp = Make3D.MakeFace(p, Frame.Project); } } } else if (iGeoObjectSel is Face) // nur kopieren { iGeoObjectTemp = iGeoObjectSel.Clone(); } if (iGeoObjectTemp != null) { // also was geeignetes dabei // iGeoObjectTemp.CopyAttributes(iGeoObjectSel as IGeoObject); iGeoObjectTemp.CopyAttributes(blk); // die Attribute müssen vom Block übernommen werden faceList[i] = iGeoObjectTemp; // fertiger Körper in shapeList blk.Add(iGeoObjectTemp); // zum Darstellen base.FeedBack.AddSelected(iGeoObjectTemp); // zum Markieren des Ursprungsobjekts success = true; } } // for-Schleife über die Objekte der Liste if (success) { base.ActiveObject = blk; // darstellen base.ShowActiveObject = true; return(true); } else { base.ShowActiveObject = false; base.FeedBack.ClearSelected(); return(false); } }
private bool extrudeOrg() { if (selectedObjectsList == null) { return(false); } IGeoObject iGeoObjectSel; // IGeoObject iGeoObjectOrg; 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 blk.IsTmpContainer = true; Boolean success = false; // hat er wenigstens eins gefunden int extrudeModeTemp = extrudeMode; // Merker, da extrudeMode evtl. umgeschaltet wird Plane pln; CompoundShape dbg = CompoundShape.CreateFromList(selectedObjectsList, Precision.eps, out pln); for (int i = 0; i < selectedObjectsList.Count; i++) // läuft über alle selektierten Objekte. Evtl nur eins bei Konstruktion { IGeoObject iGeoObjectTemp = null; // lokaler Merker 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; // Boolean VectorOrHeightTemp = VectorOrHeight; if ((iGeoObjectSel is Face) || (iGeoObjectSel is Shell)) { // nur kopieren iGeoObjectTemp = iGeoObjectSel.Clone(); } else { if (iGeoObjectSel is ICurve) { Path p = null; p = CADability.GeoObject.Path.CreateFromModel(iGeoObjectSel as ICurve, base.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(); if (iGeoObjectSel is Polyline) { p.Set(new ICurve[] { iGeoObjectSel.Clone() as ICurve }); p.Flatten(); } else if (iGeoObjectSel is Ellipse && !(iGeoObjectSel as Ellipse).IsArc) { Ellipse elli = iGeoObjectSel as Ellipse; p.Set(elli.Split(0.5)); // zwei Halbkreise } else { p.Set(new ICurve[] { iGeoObjectSel.Clone() as ICurve }); } } } else { // CreateFromModel hat was zusammengesetzt if (p.IsClosed) { // iGeoObjectOrg = null; // zum nicht Weglöschen des Originals in onDone 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.IsClosed) { // jetzt face machen iGeoObjectTemp = Make3D.MakeFace(p, Frame.Project); } } } if (iGeoObjectTemp != null) { // also was geeignetes dabei if (planeMode) // Objektebene soll Grundlage sein { Face faceTemp = null; if (iGeoObjectTemp is Face) { faceTemp = (iGeoObjectTemp as Face); } if ((iGeoObjectTemp is Shell) && ((iGeoObjectTemp as Shell).Faces.Length == 1)) { faceTemp = (iGeoObjectTemp as Shell).Faces[0]; } if (faceTemp != null) { if (faceTemp.Surface is PlaneSurface) { GeoVector faceNormal = faceTemp.Surface.GetNormal(GeoPoint2D.Origin); // GeoVector temp = base.ActiveDrawingPlane.ToLocal(faceNormal); // die ActiveDrawingPlane ändert sich wenn immer der Cursor durch ein Fenster bewegt wird // das hat manchmal komische Effekte. deshalb hier die etwas statischere // ActiveView.Projection.DrawingPlane verwenden GeoVector temp = base.Frame.ActiveView.Projection.DrawingPlane.ToLocal(faceNormal); if (temp.z < 0.0) { faceNormal.Reverse(); } vector = height * faceNormal; vectorOffset = heightOffset * faceNormal; } else { heightInput.ReadOnly = true; extrudeMode = 2; // VectorOrHeight = true; optionalOrg(); } } } if (!vectorOffset.IsNullVector()) { ModOp m = ModOp.Translate(vectorOffset); iGeoObjectTemp.Modify(m); } // IGeoObject shape = Make3D.MakePrism(iGeoObjectTemp, vector, Frame.Project); IGeoObject shape; if (pipePath == null) { shape = Make3D.MakePrism(iGeoObjectTemp, vector, Frame.Project, false); } else { shape = Make3D.MakePipe(iGeoObjectTemp, 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(iGeoObjectTemp); // zum Markieren des Ursprungsobjekts success = true; } } // VectorOrHeight = VectorOrHeightTemp; } // for-Schleife über die Objekte der Liste 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); } }