private void SetDestPoint1(GeoPoint p) { if (srcP1.Fixed) // macht nur Sinn bei bestimmten 1. Quellpunkt { // zunächst: Block zurücksetzen for (int i = 0; i < originals.Count; ++i) { block.Item(i).CopyGeometry(originals[i]); } dst1 = p; pair1 = true; // dieses Punktepaar ist bestimmt GeoPoint[] src = new GeoPoint[1]; // PunkteArrays für ModOp.Fit erstellen GeoPoint[] dst = new GeoPoint[1]; src[0] = src1; dst[0] = dst1; try { m = ModOp.Fit(src, dst, distSw); } catch (ModOpException) { m = ModOp.Identity; } feedBackLine.SetTwoPoints(src1, p); block.Modify(m); } }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.ReverseOrientation ()"/> /// </summary> /// <returns></returns> public override ModOp2D ReverseOrientation() { // x- und y-Achse vertauschen boxedSurfaceEx = null; fromUnitPlane = fromUnitPlane * new ModOp(0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0); toUnitPlane = fromUnitPlane.GetInverse(); return(new ModOp2D(0, 1, 0, 1, 0, 0)); }
public void Modify(ModOp m) { foreach (IGeoObject go in list) { go.Modify(m); } }
private void RotateWithPlanes() { // get rotation axis from the two planes if (src.Intersect(trg, out GeoPoint loc, out GeoVector dir)) { // set to original position for (int i = 0; i < block.Count; ++i) { block.Child(i).CopyGeometry(originals[i]); } Plane perp = new Plane(loc, dir); // plane perpendicular to rotation axis GeoVector2D from = perp.Project(dir ^ src.Normal); GeoVector2D to = perp.Project(dir ^ trg.Normal); SweepAngle sw = new SweepAngle(from, to); rotationAngle = sw; rotAngleInput.ForceValue(rotationAngle); ModOp m0 = ModOp.Rotate(loc, dir, sw); ModOp m1 = ModOp.Rotate(loc, -dir, sw); GeoVector n0 = m0 * src.Normal; GeoVector n1 = m1 * src.Normal; ModOp m; // not sure, which rotation is better if (Math.Abs(n0 * trg.Normal) > Math.Abs(n1 * trg.Normal)) { m = ModOp.Rotate(loc, dir, sw + GetOffset()); axisVector = dir; } else { m = ModOp.Rotate(loc, -dir, sw + GetOffset()); axisVector = -dir; } block.Modify(m); base.BasePoint = loc; } }
/// <summary> /// Overrides <see cref="IGeoObject.Modify"/>. Must be implemented by each GeoObject. /// No default implementation. /// </summary> /// <param name="m">the modification</param> public override void Modify(ModOp m) { using (new Changing(this)) { location = m * location; } }
static public void SpaceDown(GeoObjectList gl, Projection projection, Project pr) { using (pr.Undo.UndoFrame) { IGeoObject[] geoArray = new IGeoObject[gl.Count]; for (int i = 0; i < gl.Count; ++i) // umkopieren auf ein Array, um den Sort machen zu können { geoArray[i] = gl[i]; } // hier nun Sort, der Compare steht oben als lokal class und braucht die Parameter: Sort nach y = false und pm Array.Sort(geoArray, 0, geoArray.Length, new CompareGeoObject(false, projection)); // die Rechtecke des ersten und letzten Objeks für die Gesamtausdehnung BoundingRect reStart = IGeoObjectImpl.GetExtent(geoArray[0], projection, false); BoundingRect reEnd = IGeoObjectImpl.GetExtent(geoArray[geoArray.Length - 1], projection, false); double reTotal = reEnd.Top - reStart.Bottom; // Gesamtausdehnung double distRe = 0; for (int i = 0; i < geoArray.Length; ++i) // Summe der Ausdehnung der Einzelnen: { BoundingRect re = IGeoObjectImpl.GetExtent(geoArray[i], projection, false); distRe = distRe + re.Height; } double space = (reTotal - distRe) / (geoArray.Length - 1); // Gesamt - Summe Einzelne / Zwischenräume double pos = reStart.Top; for (int i = 1; i < geoArray.Length - 1; ++i) // vom zweiten bis zum vorletzten, die Äußeren bleiben unverändert { BoundingRect re = IGeoObjectImpl.GetExtent(geoArray[i], projection, false); GeoVector2D trans2D = new GeoVector2D(0, pos + space - re.Bottom); pos = pos + space + re.Height; // pos hochzählen auf den oberen Rand des aktuellen GeoVector trans = projection.DrawingPlane.ToGlobal(trans2D); ModOp m = ModOp.Translate(trans); geoArray[i].Modify(m); } } }
private void MakeBlock(int horLeft, int horRight, int verDown, int verUp, double distX, double distY) { // läuft asynchron backgroundBlock = Block.Construct(); for (int i = -horLeft; i <= horRight; ++i) { if (i != 0) // i=0 ist das Original, soll nicht verdoppelt werden! { GeoObjectList li = new GeoObjectList(); // für jede Kopie ein Clone machen li = originals.CloneObjects(); // AbstandX * Kopienwinkel: GeoVector vect = (i * distX) * dirV; ModOp m = ModOp.Translate(vect); li.Modify(m); backgroundBlock.Add(li); } for (int j = -verDown; j <= verUp; ++j) { if (j != 0) // J=0 ist das Original, soll nicht verdoppelt werden! { GeoObjectList liV = new GeoObjectList(); // für jede Kopie ein Clone machen liV = originals.CloneObjects(); // der senkrechte Winkel auf Kopienwinkel dirV GeoVector dirV_Vert = base.ActiveDrawingPlane.Normal ^ dirV; GeoVector vectV = (i * distX) * dirV + (j * distY) * dirV_Vert; ModOp m = ModOp.Translate(vectV); liV.Modify(m); backgroundBlock.Add(liV); } } } }
public PlaneSurface(GeoPoint location, GeoVector uDirection, GeoVector vDirection) { GeoVector zDirection = uDirection ^ vDirection; fromUnitPlane = new ModOp(uDirection, vDirection, zDirection, location); toUnitPlane = fromUnitPlane.GetInverse(); }
private void OnShapeFound(CompoundShape cs, Plane plane, GeoPoint fromThisPoint) { Hatch h = base.ActiveObject as Hatch; if (h == null) { return; // woher kommt das (direkt beim Klicken nach dem Einfügen) } h.CompoundShape = cs; h.Plane = foundOnPlane; // immer auf der ProjectionPlane arbeiten, dort wurde die Schraffur ja gefunden GeoPoint[] src = new GeoPoint[3]; GeoPoint[] dst = new GeoPoint[3]; src[0] = foundOnPlane.ToGlobal(GeoPoint2D.Origin); src[1] = foundOnPlane.ToGlobal(GeoPoint2D.Origin + GeoVector2D.XAxis); src[2] = foundOnPlane.ToGlobal(GeoPoint2D.Origin + GeoVector2D.YAxis); for (int i = 0; i < 3; ++i) { dst[i] = plane.Intersect(src[i], foundOnPlane.Normal); } ModOp toPlane = ModOp.Fit(src, dst, true); h.Modify(toPlane); h.Recalc(); base.ShowActiveObject = true; // System.Diagnostics.Debug.WriteLine("Shape found"); }
public void DeserializeAsset(AssetFile assetFile, StreamReader stream) { operation = (ModOp)stream.ReadInt32(); useSequencesFromSource = stream.ReadBoolean(); stream.AlignTo(); effectInfo = new StandardEffectInfo(assetFile, stream); }
private void SetDestPoint3(GeoPoint p) { if (srcP3.Fixed || pair1 || pair2) // macht nur sinn bei bestimmten 3. Quellpunkt und den beiden Vorgängerpaaren { // zunächst: Block zurücksetzen for (int i = 0; i < originals.Count; ++i) { block.Item(i).CopyGeometry(originals[i]); } dst3 = p; GeoPoint[] src = new GeoPoint[3]; // PunkteArrays für ModOp.Fit erstellen GeoPoint[] dst = new GeoPoint[3]; src[0] = src1; dst[0] = dst1; src[1] = src2; dst[1] = dst2; src[2] = src3; dst[2] = dst3; try { m = ModOp.Fit(src, dst, distSw); } catch (ApplicationException) { m = ModOp.Identity; } feedBackLine.SetTwoPoints(src3, p); block.Modify(m); } }
public override void OnDone() { // ist die Shift Taste gehalten, so werden Kopien gemacht, d.h. der die Elemente // des blocks werden eingefügt. Ansonsten werden die original-Objekte verändert // TODO: Feedback über Cursor bei Shift-Taste fehlt noch // TODO: die neuen oder veränderten Objekte sollten markiert sein. using (Frame.Project.Undo.UndoFrame) { ModOp m = ModOp.Translate(offset); if (((Frame.UIService.ModifierKeys & Keys.Shift) != 0) || copyObject) { GeoObjectList cloned = new GeoObjectList(); foreach (IGeoObject go in originals) { IGeoObject cl = go.Clone(); cl.Modify(m); // go.Owner.Add(cl); cloned.Add(cl); } base.Frame.Project.GetActiveModel().Add(cloned); } else { originals.Modify(m); } } base.ActiveObject = null; // damit es nicht gleich eingefügt wird base.OnDone(); }
private void SetPositionPoint(GeoPoint p) { GeoVector move = p - block.RefPoint; ModOp m = ModOp.Translate(move); block.Modify(m); }
ICurve ICurve.CloneModified(ModOp m) { IGeoObject clone = Clone(); clone.Modify(m); return((ICurve)clone); }
/// <summary> /// Constructor required by deserialization /// </summary> /// <param name="info">SerializationInfo</param> /// <param name="context">StreamingContext</param> protected BlockRef(SerializationInfo info, StreamingContext context) : base(info, context) { idea = InfoReader.Read(info, "Idea", typeof(Block)) as Block; insertion = (ModOp)InfoReader.Read(info, "Insertion", typeof(ModOp)); colorDef = ColorDef.Read(info, context); }
private bool showCirc() { block = Block.Construct(); for (int i = 1; i < copCount; ++i) { GeoObjectList li = new GeoObjectList(); // für jede Kopie ein Clone machen li = originals.CloneObjects(); ModOp m = ModOp.Rotate(rotationPoint, base.ActiveDrawingPlane.Normal, i * copAngle); if (!objRot) // Objekte drehen mit: einfach modifizieren { li.Modify(m); } else { // Objekte drehen nicht mit: Translation des gedrehten centerpoints ModOp mt = ModOp.Translate(new GeoVector(centerPoint, m * centerPoint)); li.Modify(mt); } block.Add(li); } if (block.Count > 0) { base.ActiveObject = block; return(true); } else { base.ActiveObject = null; return(false); } }
/// <summary> /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.Modify (ModOp)"/> /// </summary> /// <param name="m"></param> public override void Modify(ModOp m) { using (new Changing(this, "ModifyInverse", m)) { location = m * location; } }
/// <summary> /// Overrides <see cref="IGeoObjectImpl.Modify"/> and implements <see cref="IGeoObject.Modify"/>. /// </summary> /// <param name="m">the operator for the modification</param> public override void Modify(ModOp m) { using (new Changing(this, "ModifyInverse", m)) { startPoint = m * startPoint; endPoint = m * endPoint; } }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.PositionOf (GeoPoint)"/> /// </summary> /// <param name="p"></param> /// <returns></returns> public override GeoPoint2D PositionOf(GeoPoint p) { if (toUnitPlane.IsNull) { toUnitPlane = fromUnitPlane.GetInverse(); } return((toUnitPlane * p).To2D()); }
internal PlaneSurface(GeoPoint p0, GeoPoint px, GeoPoint py) { // px und py geben ein Rechtssystem für die Ebene, wird bei MakeBox so verwendet GeoVector dirx = px - p0; GeoVector diry = py - p0; fromUnitPlane = new ModOp(dirx, diry, dirx ^ diry, p0); toUnitPlane = fromUnitPlane.GetInverse(); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.GetModified (ModOp)"/> /// </summary> /// <param name="m"></param> /// <returns></returns> public override ISurface GetModified(ModOp m) { ISurface res = Clone(); res.Modify(m); (res as ISurfaceImpl).usedArea = usedArea; return(res); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.GetModified (ModOp)"/> /// </summary> /// <param name="m"></param> /// <returns></returns> public override ISurface GetModified(ModOp m) { RuledSurface res = this.Clone() as RuledSurface; res.Modify(m); res.usedArea = usedArea; return(res); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.PaintTo3D (IPaintTo3D)"/> /// </summary> /// <param name="paintTo3D"></param> public override void PaintTo3D(IPaintTo3D paintTo3D) { ModOp m = ModOp.Translate(location.x, location.y, location.z) * ModOp.Scale(paintTo3D.PixelToWorld); paintTo3D.PushMultModOp(m); geoObject.PaintTo3D(paintTo3D); paintTo3D.PopModOp(); }
/// <summary> /// While the normal <see cref="HitTest(Projection.PickArea, bool)">HitTest</see> only checkes the <see cref="Location"/> of the object /// this method checks the hittest of the object expanded according to the projection in this <paramref name="area"/> /// </summary> /// <param name="area">Pick area to check</param> /// <param name="onlyInside">true, if the whole object must reside inside the pickarea, false if overlapping will suffice</param> /// <returns>true when a hit is recognized</returns> public bool RealHitTest(Projection.PickArea area, bool onlyInside) { ModOp m = ModOp.Translate(location.x, location.y, location.z) * ModOp.Scale(area.Projection.DeviceToWorldFactor); IGeoObject clone = geoObject.Clone(); clone.Modify(m); return(clone.HitTest(area, onlyInside)); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.Modify (ModOp)"/> /// </summary> /// <param name="m"></param> public override void Modify(ModOp m) { using (new Changing(this, "ModifyInverse", m)) { containedObjects.Modify(m); refPoint = m * refPoint; } }
protected PlaneSurface(SerializationInfo info, StreamingContext context) { fromUnitPlane = (ModOp)info.GetValue("FromUnitPlane", typeof(ModOp)); // vorher war: //location = (GeoPoint)info.GetValue("Location", typeof(GeoPoint)); //uDirection = (GeoVector)info.GetValue("UDirection", typeof(GeoVector)); //vDirection = (GeoVector)info.GetValue("VDirection", typeof(GeoVector)); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.FixedV (double, double, double)"/> /// </summary> /// <param name="v"></param> /// <param name="umin"></param> /// <param name="umax"></param> /// <returns></returns> public override ICurve FixedV(double v, double umin, double umax) { double pos1 = (umin - curveStartParameter) / (curveEndParameter - curveStartParameter); double pos2 = (umax - curveStartParameter) / (curveEndParameter - curveStartParameter); ICurve res = basisCurve.CloneModified(ModOp.Translate(v * direction)); res.Trim(pos1, pos2); return(res); }
public override void Modify(ModOp m) { boxedSurfaceEx = null; implicitPolynomial = null; location = m * location; xAxis = m * xAxis; yAxis = m * yAxis; zAxis = m * zAxis; }
/// <summary> /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.Modify (ModOp)"/> /// </summary> /// <param name="m"></param> public override void Modify(ModOp m) { using (new Changing(this, "ModifyInverse", m)) { location = m * location; directionHeight = m * directionHeight; directionWidth = m * directionWidth; } }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.GetOffsetSurface (double)"/> /// </summary> /// <param name="offset"></param> /// <returns></returns> public override ISurface GetOffsetSurface(double offset) { GeoVector n = fromUnitPlane * GeoVector.ZAxis; n.Norm(); ModOp newToUnit = toUnitPlane * ModOp.Translate(-offset * n); return(new PlaneSurface(newToUnit.GetInverse())); }