public Sequence(Block.Generator blockGenerator) { blocks = new Matrix2d<Block>(PuzzleOption.BlockCountX, PuzzleOption.BlockCountY); blocks.ForAll( delegate(int x, int y, ref Block cell, ref bool stop) { cell = blockGenerator.GetNew(x, y); } ); }
public Solver(Sequence sequence) { blocks = new Matrix2d<E_BlockType>(sequence.blocks.width, sequence.blocks.height); for (int i = 0; i < blocks.width; i++) { for (int j = 0; j < blocks.height; j++) { blocks.Set(i, j, sequence.blocks.Get(i, j).blockType); } } deadBlocks = new Matrix2d<bool>(blocks.width, blocks.height); }
public Matrix2d<Block> ExportMatrix() { Matrix2d<Block> ret = new Matrix2d<Block>(blocks.width, blocks.height); blocks.ForAll( delegate(int x, int y, ref Block cell, ref bool stop) { Block block = null; if (cell != null) { block = new Block(cell); } ret.Set(x, y, block); } ); return ret; }
public virtual void transform(Matrix2d mat) { if (SwigDerivedClassHasMethod("transform", swigMethodTypes12)) { touchvgPINVOKE.MgBaseShape_transformSwigExplicitMgBaseShape(swigCPtr, Matrix2d.getCPtr(mat)); } else { touchvgPINVOKE.MgBaseShape_transform(swigCPtr, Matrix2d.getCPtr(mat)); } if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } }
public Matrix2d scaleBy(float s) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_scaleBy__SWIG_1(swigCPtr, s), false); return(ret); }
public Matrix2d setToRotation(float angle, Point2d center) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToRotation__SWIG_0(swigCPtr, angle, Point2d.getCPtr(center)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public Matrix2d setToShearing(float sx, float sy, Point2d pnt) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToShearing__SWIG_0(swigCPtr, sx, sy, Point2d.getCPtr(pnt)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public Matrix2d preMultBy(Matrix2d leftSide) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_preMultBy(swigCPtr, Matrix2d.getCPtr(leftSide)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public Matrix2d setToIdentity() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToIdentity(swigCPtr), false); return ret; }
public Matrix2d setToRotation(float angle) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToRotation__SWIG_1(swigCPtr, angle), false); return(ret); }
public static Matrix2d translation(Vector2d vec) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_translation(Vector2d.getCPtr(vec)), true); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public Matrix2d setToIdentity() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToIdentity(swigCPtr), false); return(ret); }
public Matrix2d set(float _m11, float _m12, float _m21, float _m22, float _dx, float _dy) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_set(swigCPtr, _m11, _m12, _m21, _m22, _dx, _dy), false); return(ret); }
public Matrix2d inverse() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_inverse(swigCPtr), true); return(ret); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Matrix2d obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public Matrix2d setToProduct(Matrix2d m1, Matrix2d m2) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToProduct(swigCPtr, Matrix2d.getCPtr(m1), Matrix2d.getCPtr(m2)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static Matrix2d scaling(float scale, Point2d center) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_scaling__SWIG_0(scale, Point2d.getCPtr(center)), true); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public Matrix2d setToScaling(float scaleX, float scaleY) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToScaling__SWIG_3(swigCPtr, scaleX, scaleY), false); return(ret); }
public static Matrix2d shearing(float sx, float sy) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_shearing__SWIG_1(sx, sy), true); return ret; }
public Matrix2d setToMirroring() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToMirroring__SWIG_1(swigCPtr), false); return(ret); }
public Matrix2d inverse() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_inverse(swigCPtr), true); return ret; }
public Matrix2d setToShearing(float sx, float sy) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToShearing__SWIG_1(swigCPtr, sx, sy), false); return(ret); }
public Matrix2d set(float _m11, float _m12, float _m21, float _m22, float _dx, float _dy) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_set(swigCPtr, _m11, _m12, _m21, _m22, _dx, _dy), false); return ret; }
public static Matrix2d rotation(float angle) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_rotation__SWIG_1(angle), true); return(ret); }
public Matrix2d setToMirroring(Point2d pnt, Vector2d dir) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToMirroring__SWIG_2(swigCPtr, Point2d.getCPtr(pnt), Vector2d.getCPtr(dir)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static Matrix2d scaling(float scaleX, float scaleY) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_scaling__SWIG_3(scaleX, scaleY), true); return(ret); }
public Matrix2d setToScaling(float scaleX, float scaleY, Point2d center) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToScaling__SWIG_2(swigCPtr, scaleX, scaleY, Point2d.getCPtr(center)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public bool Solve(int MaxRounds = 1024) { AxisAlignedBox2d TargetBounds = Target.Bounds; Box2d fitBounds = new Box2d(Fit.GetBounds()); InputTranslate = -fitBounds.Center; int N = Fit.VertexCount; Polygon2d FitCentered = new Polygon2d(Fit); for (int k = 0; k < N; ++k) { FitCentered[k] = Fit[k] + InputTranslate; } fitBounds = new Box2d(FitCentered.GetBounds()); Polygon2d FitXForm = new Polygon2d(FitCentered); Random r = new Random(31337); int ri = 0; bool solved = false; while (ri++ < MaxRounds && solved == false) { Vector2d center = random_point_in_target(r, TargetBounds.SampleT, Target.Contains); Matrix2d rotate = Matrix2d.Identity; if (EnableRotate) { Util.gDevAssert(EnableRandomRotations == false); double rotAngle = ValidRotationsDeg[r.Next() % ValidRotationsDeg.Length]; rotate.SetToRotationDeg(rotAngle); } for (int k = 0; k < N; ++k) { FitXForm[k] = rotate * (ApplyScale * FitCentered[k]) + center; } if (!Target.Outer.Contains(FitXForm)) { continue; } if (Target.Intersects(FitXForm)) { continue; } FitBounds = fitBounds; FitBounds.RotateAxes(rotate); FitBounds.Translate(center); FitRotation = rotate; FitPolygon = FitXForm; solved = true; } return(solved); }
public Matrix2d setToTranslation(Vector2d vec) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToTranslation(swigCPtr, Vector2d.getCPtr(vec)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static Matrix2d mirroring(Point2d pnt, Vector2d dir) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_mirroring__SWIG_2(Point2d.getCPtr(pnt), Vector2d.getCPtr(dir)), true); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static Matrix2d mirroring() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_mirroring__SWIG_1(), true); return(ret); }
public static Matrix2d kIdentity() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_kIdentity(), true); return(ret); }
public static Matrix2d mirroring() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_mirroring__SWIG_1(), true); return ret; }
public static Matrix2d shearing(float sx, float sy) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_shearing__SWIG_1(sx, sy), true); return(ret); }
public static Matrix2d rotation(float angle) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_rotation__SWIG_1(angle), true); return ret; }
public int smoothForPoints(int count, Point2d points, Matrix2d m2d, float tol) { int ret = touchvgPINVOKE.MgSplines_smoothForPoints(swigCPtr, count, Point2d.getCPtr(points), Matrix2d.getCPtr(m2d), tol); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static Matrix2d scaling(float scaleX, float scaleY) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_scaling__SWIG_3(scaleX, scaleY), true); return ret; }
public Triangle2d TransformBy(Matrix2d mat) { return(new Triangle2d(Array.ConvertAll( _pts, p => p.TransformBy(mat)))); }
public static Matrix2d transformWith2P(Point2d from1, Point2d from2, Point2d to1, Point2d to2) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_transformWith2P(Point2d.getCPtr(from1), Point2d.getCPtr(from2), Point2d.getCPtr(to1), Point2d.getCPtr(to2)), true); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public Matrix2d worldToModel() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.GiTransform_worldToModel(swigCPtr), false); return(ret); }
public Matrix2d(Matrix2d src) : this(touchvgPINVOKE.new_Matrix2d__SWIG_1(Matrix2d.getCPtr(src)), true) { if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); }
public Matrix2d displayToWorld() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.GiTransform_displayToWorld(swigCPtr), false); return(ret); }
public bool isEqualTo(Matrix2d mat) { bool ret = touchvgPINVOKE.Matrix2d_isEqualTo__SWIG_1(swigCPtr, Matrix2d.getCPtr(mat)); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public Matrix2d displayToModel() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.GiTransform_displayToModel__SWIG_2(swigCPtr), false); return(ret); }
public Matrix2d scaleBy(float s) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_scaleBy__SWIG_1(swigCPtr, s), false); return ret; }
public Matrix2d modelToDisplay() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.GiTransform_modelToDisplay(swigCPtr), false); return(ret); }
public Matrix2d setCoordSystem(Vector2d e0, Vector2d e1, Point2d origin) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setCoordSystem(swigCPtr, Vector2d.getCPtr(e0), Vector2d.getCPtr(e1), Point2d.getCPtr(origin)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public virtual bool applyTransform(MgMotion sender, Matrix2d xf) { bool ret = touchvgPINVOKE.MgSelection_applyTransform(swigCPtr, MgMotion.getCPtr(sender), Matrix2d.getCPtr(xf)); if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public Matrix2d setToMirroring() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToMirroring__SWIG_1(swigCPtr), false); return ret; }
public static Tuple <Dictionary <string, string>, List <string[]> > GetBuildingPreparationMatrix(Grid grid, List <Building> buildings, Terrain terrain, Point3d[] demVoxel) { string buildingNumberMatrix = ""; List <Matrix3d> listMatrixNormalMaterial = new List <Matrix3d>(); List <Matrix3d> listMatrixGreenMaterial = new List <Matrix3d>(); List <string> hightMatrixBuilding = new List <string>(); List <Material> materials = new List <Material>(); List <string[]> greenInfo = new List <string[]>(); Dictionary <string, string> buildingDict = new Dictionary <string, string>(); buildingDict.Add("greenDBMatrix", "\n"); Mesh union = new Mesh(); buildings.ForEach(b => union.Append(b.GetMesh())); if (!CheckDistanceFromBorder(union, grid)) { return(null); } for (int i = 0; i < buildings.Count; i++) { //union.Append(buildings[i].GetMesh()); Mesh tempMesh = buildings[i].GetMesh(); if (terrain != null) { tempMesh = Building.MoveBuildingsUp(buildings[i].GetMesh(), terrain.GetSrfMesh()); } if (buildings[i].SimplifiedCalculation) { Point3d[] buildingVoxel = Building.VoxelPoints(tempMesh, grid); buildings[i].CreateVoxMatrixBuilding(buildingVoxel, demVoxel, grid, i + 1); } else { try { Point3d[] buildingVoxel = Building.VoxelPoints(tempMesh, grid, tolerance: Building.TOLERANCE); buildings[i].CreateVoxMatrixBuilding(buildingVoxel, demVoxel, grid, i + 1); } catch { Point3d[] buildingVoxel = Building.VoxelPoints(tempMesh, grid); buildings[i].CreateVoxMatrixBuilding(buildingVoxel, demVoxel, grid, i + 1); } } listMatrixNormalMaterial.Add(buildings[i].GetMatrix3d()); hightMatrixBuilding.Add(buildings[i].BuildingFlagAndNr); materials.Add(buildings[i].GetMaterial()); buildingNumberMatrix += buildings[i].BuildingFlagAndNr; string greenWall = buildings[i].GetMaterial().GreenWallMaterial; string greenRoof = buildings[i].GetMaterial().GreenRoofMaterial; if (greenWall == Material.DefaultGreenWallMaterial) { greenWall = " "; } if (greenRoof == Material.DefaultGreenRoofMaterial) { greenRoof = " "; } string[] greenBld = new string[] { (i + 1).ToString(), " ", buildings[i].GetMaterial().WallMaterial, buildings[i].GetMaterial().RoofMaterial, greenWall, greenRoof }; greenInfo.Add(greenBld); if (greenWall != " " || greenRoof != " ") { listMatrixGreenMaterial.Add(buildings[i].GetMatrix3d()); } buildings[i].Dispose(); tempMesh.Dispose(); } buildingDict.Add("buildingNumberMatrix", buildingNumberMatrix); // Building Matrix Matrix3d uniqueMatrix = Matrix3d.Union(listMatrixNormalMaterial); buildingDict.Add("wallDBMatrix", Building.SetMaterials(uniqueMatrix, materials)); if (listMatrixGreenMaterial.Count > 0) { Matrix3d uniqueGreenMatrix = Matrix3d.Union(listMatrixGreenMaterial); buildingDict["greenDBMatrix"] = Building.SetMaterials(uniqueGreenMatrix, materials, green: true); } // 2d part // Top Matrix Matrix2d temp = Building.GetMatrixFromRayShoot(grid, union, top: true); buildingDict.Add("topMatrix", Grid.CreateTextMatrix(temp)); // Bottom Matrix temp = Building.GetMatrixFromRayShoot(grid, union, top: false); buildingDict.Add("bottomMatrix", Grid.CreateTextMatrix(temp)); // Fixed Matrix temp = Building.BuildingFixed2d(uniqueMatrix, grid); buildingDict.Add("fixedMatrix", Grid.CreateTextMatrix(matrix: temp)); // Id Matrix temp = Building.BuildingId2d(uniqueMatrix); buildingDict.Add("idMatrix", Grid.CreateTextMatrix(matrix: temp)); return(new Tuple <Dictionary <string, string>, List <string[]> >(buildingDict, greenInfo)); }
public Matrix2d setToProduct(Matrix2d m1, Matrix2d m2) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToProduct(swigCPtr, Matrix2d.getCPtr(m1), Matrix2d.getCPtr(m2)), false); if (touchvgPINVOKE.SWIGPendingException.Pending) throw touchvgPINVOKE.SWIGPendingException.Retrieve(); return ret; }
internal PlatePolycut(AdvanceSteel.Nodes.SteelDbObject element, double xOffset, double yOffset, int corner, int cutShapeRectCircle, List <Property> plateFeatureProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = plateFeatureProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = plateFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); double length = 0; double width = 0; double radius = 0; if (defaultData.FirstOrDefault <Property>(x => x.Name == "Length") != null) { length = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Length").InternalValue; } if (defaultData.FirstOrDefault <Property>(x => x.Name == "Width") != null) { width = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Width").InternalValue; } if (defaultData.FirstOrDefault <Property>(x => x.Name == "Radius") != null) { radius = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Radius").InternalValue; } string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace(); string elementHandle = element.Handle; FilerObject obj = Utils.GetObject(elementHandle); PlateFeatContour plateFeat = null; if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kPlate)) { if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null) { Matrix2d m2d = new Matrix2d(); m2d.SetCoordSystem(new Point2d(xOffset, yOffset), new Vector2d(1, 0), new Vector2d(0, 1)); switch (cutShapeRectCircle) { case 0: plateFeat = new PlateFeatContour(m2d, length, width); break; case 1: plateFeat = new PlateFeatContour(m2d, radius); break; } Vector2d offset; switch (corner) { case 0: //Top Left offset = new Vector2d(-1, 1); break; case 1: //Top Right offset = new Vector2d(1, 1); break; case 2: //Bottom Right offset = new Vector2d(1, -1); break; case 3: //Bottom left offset = new Vector2d(-1, -1); break; default: //Anything else ignore offset = new Vector2d(0, 0); break; } plateFeat.Offset = offset; AtomicElement atomic = obj as AtomicElement; if (defaultData != null) { Utils.SetParameters(plateFeat, defaultData); } atomic.AddFeature(plateFeat); if (postWriteDBData != null) { Utils.SetParameters(plateFeat, postWriteDBData); } } else { plateFeat = Utils.GetObject(existingFeatureHandle) as PlateFeatContour; if (plateFeat != null && plateFeat.IsKindOf(FilerObject.eObjectType.kPlateFeatContour)) { Plate plate = obj as Plate; plate.DelFeature(plateFeat); plate.WriteToDb(); Matrix2d m2d = new Matrix2d(); m2d.SetCoordSystem(new Point2d(xOffset, yOffset), new Vector2d(1, 0), new Vector2d(0, 1)); switch (cutShapeRectCircle) { case 0: plateFeat = new PlateFeatContour(m2d, length, width); break; case 1: plateFeat = new PlateFeatContour(m2d, radius); break; } Vector2d offset; switch (corner) { case 0: //Top Left offset = new Vector2d(-1, 1); break; case 1: //Top Right offset = new Vector2d(1, 1); break; case 2: //Bottom Right offset = new Vector2d(1, -1); break; case 3: //Bottom left offset = new Vector2d(-1, -1); break; default: //Anything else ignore offset = new Vector2d(0, 0); break; } plateFeat.Offset = offset; AtomicElement atomic = obj as AtomicElement; if (defaultData != null) { Utils.SetParameters(plateFeat, defaultData); } atomic.AddFeature(plateFeat); if (postWriteDBData != null) { Utils.SetParameters(plateFeat, postWriteDBData); } } else { throw new System.Exception("Not a Plate Feature"); } } } else { throw new System.Exception("No Input Element found"); } Handle = plateFeat.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(plateFeat); } } }
public Matrix2d setToRotation(float angle) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToRotation__SWIG_1(swigCPtr, angle), false); return ret; }
public GiSaveModelTransform(GiTransform xform, Matrix2d mat) : this(touchvgPINVOKE.new_GiSaveModelTransform(GiTransform.getCPtr(xform), Matrix2d.getCPtr(mat)), true) { if (touchvgPINVOKE.SWIGPendingException.Pending) { throw touchvgPINVOKE.SWIGPendingException.Retrieve(); } }
public Matrix2d setToScaling(float scaleX, float scaleY) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToScaling__SWIG_3(swigCPtr, scaleX, scaleY), false); return ret; }
public static Point2d MoveDistance(this Point2d theP2d, Vector2d theVec, double dist) { Vector2d newVec = new Vector2d(dist * Math.Cos(theVec.Angle), dist * Math.Sin(theVec.Angle)); return(theP2d.TransformBy(Matrix2d.Displacement(newVec))); }
public Matrix2d setToShearing(float sx, float sy) { Matrix2d ret = new Matrix2d(touchvgPINVOKE.Matrix2d_setToShearing__SWIG_1(swigCPtr, sx, sy), false); return ret; }
public virtual Matrix2d modelTransform() { Matrix2d ret = new Matrix2d(touchvgPINVOKE.MgView_modelTransform(swigCPtr), false); return(ret); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Matrix2d obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
/// <summary> /// Creates a new instance of PolylineSegmentCollection from an Ellipse. /// </summary> /// <param name="ellipse">An Ellipse instance.</param> public PolylineSegmentCollection(Ellipse ellipse) { // PolylineSegmentCollection figuring the closed ellipse double pi = Math.PI; Plane plane = new Plane(Point3d.Origin, ellipse.Normal); Point3d cen3d = ellipse.Center; Point3d pt3d0 = cen3d + ellipse.MajorAxis; Point3d pt3d4 = cen3d + ellipse.MinorAxis; Point3d pt3d2 = ellipse.GetPointAtParameter(pi / 4.0); Point2d cen = cen3d.Convert2d(plane); Point2d pt0 = pt3d0.Convert2d(plane); Point2d pt2 = pt3d2.Convert2d(plane); Point2d pt4 = pt3d4.Convert2d(plane); Line2d line01 = new Line2d(pt0, (pt4 - cen).GetNormal() + (pt2 - pt0).GetNormal()); Line2d line21 = new Line2d(pt2, (pt0 - pt4).GetNormal() + (pt0 - pt2).GetNormal()); Line2d line23 = new Line2d(pt2, (pt4 - pt0).GetNormal() + (pt4 - pt2).GetNormal()); Line2d line43 = new Line2d(pt4, (pt0 - cen).GetNormal() + (pt2 - pt4).GetNormal()); Line2d majAx = new Line2d(cen, pt0); Line2d minAx = new Line2d(cen, pt4); Point2d pt1 = line01.IntersectWith(line21)[0]; Point2d pt3 = line23.IntersectWith(line43)[0]; Point2d pt5 = pt3.TransformBy(Matrix2d.Mirroring(minAx)); Point2d pt6 = pt2.TransformBy(Matrix2d.Mirroring(minAx)); Point2d pt7 = pt1.TransformBy(Matrix2d.Mirroring(minAx)); Point2d pt8 = pt0.TransformBy(Matrix2d.Mirroring(minAx)); Point2d pt9 = pt7.TransformBy(Matrix2d.Mirroring(majAx)); Point2d pt10 = pt6.TransformBy(Matrix2d.Mirroring(majAx)); Point2d pt11 = pt5.TransformBy(Matrix2d.Mirroring(majAx)); Point2d pt12 = pt4.TransformBy(Matrix2d.Mirroring(majAx)); Point2d pt13 = pt3.TransformBy(Matrix2d.Mirroring(majAx)); Point2d pt14 = pt2.TransformBy(Matrix2d.Mirroring(majAx)); Point2d pt15 = pt1.TransformBy(Matrix2d.Mirroring(majAx)); double bulge1 = Math.Tan((pt4 - cen).GetAngleTo(pt1 - pt0) / 2.0); double bulge2 = Math.Tan((pt1 - pt2).GetAngleTo(pt0 - pt4) / 2.0); double bulge3 = Math.Tan((pt4 - pt0).GetAngleTo(pt3 - pt2) / 2.0); double bulge4 = Math.Tan((pt3 - pt4).GetAngleTo(pt0 - cen) / 2.0); _contents.Add(new PolylineSegment(pt0, pt1, bulge1)); _contents.Add(new PolylineSegment(pt1, pt2, bulge2)); _contents.Add(new PolylineSegment(pt2, pt3, bulge3)); _contents.Add(new PolylineSegment(pt3, pt4, bulge4)); _contents.Add(new PolylineSegment(pt4, pt5, bulge4)); _contents.Add(new PolylineSegment(pt5, pt6, bulge3)); _contents.Add(new PolylineSegment(pt6, pt7, bulge2)); _contents.Add(new PolylineSegment(pt7, pt8, bulge1)); _contents.Add(new PolylineSegment(pt8, pt9, bulge1)); _contents.Add(new PolylineSegment(pt9, pt10, bulge2)); _contents.Add(new PolylineSegment(pt10, pt11, bulge3)); _contents.Add(new PolylineSegment(pt11, pt12, bulge4)); _contents.Add(new PolylineSegment(pt12, pt13, bulge4)); _contents.Add(new PolylineSegment(pt13, pt14, bulge3)); _contents.Add(new PolylineSegment(pt14, pt15, bulge2)); _contents.Add(new PolylineSegment(pt15, pt0, bulge1)); // if the ellipse is an elliptical arc: if (!ellipse.Closed) { double startParam, endParam; Point2d startPoint = ellipse.StartPoint.Convert2d(plane); Point2d endPoint = ellipse.EndPoint.Convert2d(plane); // index of the PolylineSegment closest to the ellipse start point int startIndex = GetClosestSegmentIndexTo(startPoint); // start point on the PolylineSegment Point2d pt = _contents[startIndex].ToCurve2d().GetClosestPointTo(startPoint).Point; // if the point is equal to the PolylineSegment end point, jump the next segment in collection if (pt.IsEqualTo(_contents[startIndex].EndPoint)) { if (startIndex == 15) { startIndex = 0; } else { startIndex++; } startParam = 0.0; } // else get the 'parameter' at point on the PolylineSegment else { startParam = _contents[startIndex].GetParameterOf(pt); } // index of the PolylineSegment closest to the ellipse end point int endIndex = GetClosestSegmentIndexTo(endPoint); // end point on the PolylineSegment pt = _contents[endIndex].ToCurve2d().GetClosestPointTo(endPoint).Point; // if the point is equals to the PolylineSegment startPoint, jump to the previous segment if (pt.IsEqualTo(_contents[endIndex].StartPoint)) { if (endIndex == 0) { endIndex = 15; } else { endIndex--; } endParam = 1.0; } // else get the 'parameter' at point on the PolylineSegment else { endParam = _contents[endIndex].GetParameterOf(pt); } // if the parameter at start point is not equal to 0.0, calculate the bulge if (startParam != 0.0) { _contents[startIndex].StartPoint = startPoint; _contents[startIndex].Bulge = _contents[startIndex].Bulge * (1.0 - startParam); } // if the parameter at end point is not equal to 1.0, calculate the bulge if (endParam != 1.0) //(endParam != 0.0) { _contents[endIndex].EndPoint = endPoint; _contents[endIndex].Bulge = _contents[endIndex].Bulge * (endParam); } // if both points are on the same segment if (startIndex == endIndex) { PolylineSegment segment = _contents[startIndex]; _contents.Clear(); _contents.Add(segment); } else if (startIndex < endIndex) { _contents.RemoveRange(endIndex + 1, 15 - endIndex); _contents.RemoveRange(0, startIndex); } else { _contents.AddRange(_contents.GetRange(0, endIndex + 1)); _contents.RemoveRange(0, startIndex); } } }