public Constr3DScrewPath(GeoObjectList selectedObjects) { GeoObjectList clones = selectedObjects.CloneObjects(); if (selectedObjects.Count == 1) { if (selectedObjects[0] is Hatch) { shape = (selectedObjects[0] as Hatch).CompoundShape; plane = (selectedObjects[0] as Hatch).Plane; return; } else if (selectedObjects[0] is Face) { if ((selectedObjects[0] as Face).Surface is PlaneSurface) { // here we could directely set shape and plane } clones.Clear(); foreach (Edge edg in (selectedObjects[0] as Face).AllEdgesIterated()) { if (edg.Curve3D != null) { clones.Add(edg.Curve3D as IGeoObject); } } } } shape = CompoundShape.CreateFromList(clones, Precision.eps, out plane); if (shape == null) { Path toRotate = Path.Construct(); toRotate.Set(clones, false, Precision.eps); if (toRotate.CurveCount > 0) { if (toRotate.GetPlanarState() == PlanarState.Planar) { plane = toRotate.GetPlane(); path = toRotate.GetProjectedCurve(plane) as Path2D; } } } }
public Constr3DFaceExtrude(GeoObjectList selectedObjectsList) : this() { selectedMode = (selectedObjectsList != null); if (selectedMode) { GeoObjectList clonedList = selectedObjectsList.Clone(); GeoObjectList curves = new GeoObjectList(); for (int i = clonedList.Count - 1; i >= 0; --i) { if (clonedList[i] is ICurve) { curves.Add(clonedList[i]); clonedList.Remove(i); } } Plane pln; CompoundShape cs = CompoundShape.CreateFromList(curves, Precision.eps, out pln); if (cs != null && !cs.Empty) { // man konnte ein CompoundShape erzeugen, dann dieses zu Faces machen und verwenden for (int i = 0; i < cs.SimpleShapes.Length; i++) { PlaneSurface ps = new PlaneSurface(pln); Face toAdd = Face.MakeFace(ps, cs.SimpleShapes[i]); toAdd.CopyAttributes(curves[0]); clonedList.Add(toAdd); } this.selectedObjectsList = clonedList; } else { this.selectedObjectsList = selectedObjectsList.Clone(); } ListDefault(this.selectedObjectsList.Count); // setzt alle Listen auf gleiche Länge, Inhalte "null" } ; }
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); } }