protected void Parse(Stream s, int count) { uint[] slotNames = new uint[count]; uint[] boneNames = new uint[count]; TransformElement[][] transformElements = new TransformElement[count][]; ConeElement[] coneElements = new ConeElement[count]; BinaryReader r = new BinaryReader(s); for (int i = 0; i < slotNames.Length; i++) { slotNames[i] = r.ReadUInt32(); } for (int i = 0; i < boneNames.Length; i++) { boneNames[i] = r.ReadUInt32(); } for (int i = 0; i < transformElements.Length; i++) { transformElements[i] = new TransformElement[3]; transformElements[i][0] = new TransformElement(0, elementHandler, s); //X transformElements[i][1] = new TransformElement(0, elementHandler, s); //Y transformElements[i][2] = new TransformElement(0, elementHandler, s); //Z } for (int i = 0; i < coneElements.Length; i++) { coneElements[i] = new ConeElement(0, elementHandler, s); } for (int i = 0; i < count; i++) { this.Add(new ConePart(0, elementHandler, slotNames[i], boneNames[i], transformElements[i][0], transformElements[i][1], transformElements[i][2], coneElements[i])); } }
public ConePart(int APIversion, EventHandler handler, uint slotName, uint boneName, TransformElement tX, TransformElement tY, TransformElement tZ, ConeElement cone) : base(APIversion, handler) { this.slotName = slotName; this.boneName = boneName; this.tX = new TransformElement(requestedApiVersion, handler, tX); this.tY = new TransformElement(requestedApiVersion, handler, tY); this.tZ = new TransformElement(requestedApiVersion, handler, tZ); this.cone = new ConeElement(requestedApiVersion, handler, cone); }
public ConePart(EventHandler handler, uint slotName, uint boneName, TransformElement tX, TransformElement tY, TransformElement tZ, ConeElement cone) : base(handler) { this.slotName = slotName; this.boneName = boneName; this.tX = new TransformElement(handler, tX); this.tY = new TransformElement(handler, tY); this.tZ = new TransformElement(handler, tZ); this.cone = new ConeElement(handler, cone); }
public static void ConeAndBsplineSurface() { Application app = Utilities.ComApp; Point3d basePt = app.Point3dFromXYZ(2, -23, 0); Point3d topPt = app.Point3dFromXYZ(2, -20, 0); Matrix3d rMatrix = app.Matrix3dFromAxisAndRotationAngle(0, app.Pi() / 6); ConeElement oCone = app.CreateConeElement1(null, 2, ref basePt, 1, ref topPt, ref rMatrix); oCone.Color = 0; app.ActiveModelReference.AddElement(oCone); Point3d[] aFitPnts = new Point3d[4]; InterpolationCurve oFitCurve = new InterpolationCurveClass(); BsplineCurve[] aCurves = new BsplineCurve[3]; aFitPnts[0] = app.Point3dFromXYZ(5.9, -21, -0.5); aFitPnts[1] = app.Point3dFromXYZ(6.9, -20, 1); aFitPnts[2] = app.Point3dFromXYZ(7.9, -20.3, 1.3); aFitPnts[3] = app.Point3dFromXYZ(8.9, -20.8, 0.3); oFitCurve.SetFitPoints(ref aFitPnts); oFitCurve.BesselTangents = true; aCurves[0] = new BsplineCurveClass(); aCurves[0].FromInterpolationCurve(oFitCurve); aFitPnts[0] = app.Point3dFromXYZ(6.4, -22, 0); aFitPnts[1] = app.Point3dFromXYZ(7.1, -21.2, 0.7); aFitPnts[2] = app.Point3dFromXYZ(7.7, -21, 1); aFitPnts[3] = app.Point3dFromXYZ(8.4, -21.7, -0.2); oFitCurve.SetFitPoints(ref aFitPnts); oFitCurve.BesselTangents = true; aCurves[1] = new BsplineCurveClass(); aCurves[1].FromInterpolationCurve(oFitCurve); aFitPnts[0] = app.Point3dFromXYZ(5.9, -23, 0); aFitPnts[1] = app.Point3dFromXYZ(7.2, -23.1, 1.2); aFitPnts[2] = app.Point3dFromXYZ(7.8, -23.3, 0.8); aFitPnts[3] = app.Point3dFromXYZ(8.7, -22.8, 0.2); oFitCurve.SetFitPoints(ref aFitPnts); oFitCurve.BesselTangents = true; aCurves[2] = new BsplineCurveClass(); aCurves[2].FromInterpolationCurve(oFitCurve); BsplineSurface oBsplineSurface = new BsplineSurfaceClass(); oBsplineSurface.FromCrossSections(ref aCurves, MsdBsplineSurfaceDirection.V, 4, true, true); BsplineSurfaceElement oSurfaceElm = app.CreateBsplineSurfaceElement1(null, oBsplineSurface); oSurfaceElm.Color = 1; app.ActiveModelReference.AddElement(oSurfaceElm); }
public static ITFFrameList createFrameCN (PenetrTask task, PenetrInfo penInfo) { task.scanInfo(); // TODO отключено временно, до решения по алгоритму пересечений фланцев: //if (!Keyins.Penetrations.DEBUG_MODE) { // if (task.isCompoundExistsInPlace || task.TFFormsIntersected.Count == 0) // return null; //} var taskUOR = task.UOR; double pipeInsideDiam = penInfo.pipeDiameterInside * taskUOR.active_perSub; double pipeOutsideDiam = penInfo.pipeDiameterOutside * taskUOR.active_perSub; double flangeInsideDiam = penInfo.flangeDiameterInside * taskUOR.active_perSub; double flangeOutsideDiam = penInfo.flangeDiameterOutside * taskUOR.active_perSub; double flangeThick = penInfo.flangeThick * taskUOR.active_perSub; double length = task.Length * taskUOR.active_perSub; double pipeInRadius = pipeInsideDiam / 2; double pipeOutRadius = pipeOutsideDiam / 2; var tfApi = new Bentley.Building.Api.TFApplicationList().AsTFApplication; BCOM.ModelReference activeModel = App.ActiveModelReference; //ITFBrepList brepList; //tfApi.CreateTFBrep(0, out brepList); DPoint3d origin = task.Location.ToDPoint(); origin.ScaleInPlace(taskUOR.active_perMaster); DMatrix3d rot = task.Rotation.ToDMatrix3d(); var dTran = DTransform3d.FromMatrixAndTranslation(rot, origin); var tranInfo = new TransformInfo(dTran); // DMatrix3d.FromColumns( //rot.RowX.ToDVector(), rot.RowX.ToDVector(), rot.RowX.ToDVector()); //ITFFormRecipeList recipeList; var model = Session.Instance.GetActiveDgnModel(); var modelRef = Session.Instance.GetActiveDgnModelRef(); //CellHeaderElement taskEl = Element.GetFromElementRef(task.elemRefP) as CellHeaderElement; //DPoint3d taskOrigin; //taskEl.GetSnapOrigin(out taskOrigin); var ellips = new EllipseElement(model, null, DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, pipeOutRadius, DVector3d.FromXY(0, 1))); ellips.ApplyTransform(tranInfo); var cone = new ConeElement(model, null, pipeOutRadius, pipeOutRadius, DPoint3d.FromXYZ(0, length, 0), DPoint3d.Zero, DMatrix3d.Rotation(DVector3d.UnitX, Angle.FromDegrees(-90)), true); cone.ApplyTransform(tranInfo); var ellips2 = new EllipseElement(model, null, DEllipse3d.FromCenterRadiusNormal( DPoint3d.Zero, pipeInRadius, DVector3d.FromXY(0, 1))); ellips2.ApplyTransform(tranInfo); var cone2 = new ConeElement(model, null, pipeInRadius, pipeInRadius, DPoint3d.Zero, DPoint3d.FromXYZ(0, length, 0), DMatrix3d.Zero, false); cone2.ApplyTransform(tranInfo); //int status = brepList.InitCylinder(pipeInsideRadius*task_subPerMaster, // (length - flangeThick)*task_subPerMaster, ref origin, // ref matrix, ""); //ITFElementList elemList; //tfApi.CreateTFElement(0, out elemList); // Bentley.GeometryNET.Common.CircularCylinder //ITFBrepList coneBrepList, cone2BrepList, resBrepList; //tfApi.CreateTFBrep(0, out coneBrepList); //tfApi.CreateTFBrep(0, out cone2BrepList); //coneBrepList.InitFromElement(cone, modelRef, ""); //cone2BrepList.InitFromElement(cone2, modelRef, ""); //coneBrepList.AsTFBrep.InitCylinder(pipeInsideRadius, length, ref origin, // ref matrix, 0); ITFItemList itemList; tfApi.CreateTFItem(0, out itemList); //var sweepDir = DVector3d.FromXY(1, 0); //coneBrepList.AsTFBrep.Drop(out resBrepList, cone2BrepList, 0); //sweepDir.NegateInPlace(); // coneBrepList.AsTFBrep.Cut(out resBrepList, cone2BrepList, ref sweepDir, length + 150, false, 0); //coneBrepList.AsTFBrep.SweepByVector3(ref sweepDir, length + 300, // pipeOutsideRadius - pipeInsideRadius, 0, 0); //Array arr = new System.Collections.ArrayList().ToArray(); //coneBrepList.AsTFBrep.Cut2(out resBrepList, cone2BrepList.AsTFBrep, ref sweepDir, //Bentley.Building.Api.TFdBrepCutMethod.tfdBrepCutMethod_Outside, //Bentley.Building.Api.TFdBrepCutDirection.tfdBrepCutDirection_Both, //Bentley.Building.Api.TFdBrepCutDepth.tfdBrepCutDepth_UpToSolid, length, //arr, 0, false, Bentley.Building.Api.TFdBrepCutDepth.tfdBrepCutDepth_UpToSolid, length, //arr, 0, false, 0, 0, 0.00005, 0); //lement resElement; //resBrepList.GetElement(out resElement, 0, ""); //coneBrepList.GetElement(out resElement, 0, ""); ITFFrameList frameList; tfApi.CreateTFFrame(0, out frameList); frameList.AsTFFrame.Add3DElement(cone, 0); //frameList.AsTFFrame.Add3DElement(cone2, 0); //frameList.AsTFFrame.Add3DElement(resElement, 0); //ITFFrameList openingFrameList; //tfApi.CreateTFFrame(0, out openingFrameList); //openingFrameList.AsTFFrame.Add3DElement(cone2, 0); //ITFFormRecipeList openRecipeList; ////tfApi.CreateTFFormRecipeArc //ITFFormRecipe openRecipe; //openingFrameList.AsTFFrame.GetFormRecipeList(0, out openRecipeList); //openRecipe = openRecipeList.AsTFFormRecipe; //ITFItemList featureList; //frameList.AsTFFrame.AddOpeningsToForm(out featureList, ref openRecipe, "", 0); ITFPerforatorList perfoList; tfApi.CreateTFPerforator(0, out perfoList); var dir = DVector3d.FromXY(1, 0); var tran = DTransform3d.Identity; perfoList.InitFromElement(ellips, ref dir, length, ref tran, ""); perfoList.AsTFPerforator.SetIsVisible(false, 0); perfoList.SetSweepMode(Bentley.Building.Api.TFdPerforatorSweepMode.tfdPerforatorSweepModeBi, ""); perfoList.SetPolicy(Bentley.Building.Api.TFdPerforatorPolicy.tfdPerforatorPolicyThroughHoleWithinSenseDist, ""); frameList.AsTFFrame.SetPerforatorList(ref perfoList, 0); frameList.AsTFFrame.SetSenseDistance2(length / 100, 0); frameList.AsTFFrame.SetPerforatorsAreActive(true, 0); int stat; // = tfApi.ModelReferenceAddFrameList(modelRef, ref frameList, 0); var frame = frameList.AsTFFrame; stat = tfApi.ModelReferenceUpdateAutoOpeningsByFrame(modelRef, ref frame, true, false, Bentley.Building.Api.TFdFramePerforationPolicy.tfdFramePerforationPolicyNone, 0); //Element cylindr; //brepList.GetElement(out cylindr, 0, ""); //cylindr.AddToModel(); //Element tfElement; //Element perfo = null; //Element dp_2d = null; //int value; //tfApi.ModelReferenceAddElement(ref cylindr, Session.Instance.GetActiveDgnModel(), // 0, 0, out value); //tfApi.ModelReferenceConstructFrameElement(Session.Instance.GetActiveDgnModel(), // 0, ref cylindr, ref perfo, ref origin, ref dp_2d, "name", null, // 1, 0, false, null, false, task.Length, 0.00005, 0, out tfElement); //frameList.InitFromElement(cylindr, ""); // frameList.AsTFFrame.Add3DElement(cylindr, 0); return(frameList); }