/// <summary> /// Builds a dimension on an edge of type Line /// </summary> private static AISInteractiveObject BuildLineDimension(TopoDSEdge edge, gpPnt textLocation, GeomPlane dimensionPlane, DsgPrsArrowSide arrowType, bool isOffset, gpPnt offset) { var curve = new BRepAdaptorCurve(edge); if (curve.GetType != GeomAbsCurveType.GeomAbs_Line) { return(null); } // For a line use a length dimension var line = curve.Line; if (line.Distance(textLocation) < Precision.Confusion) { textLocation.X = (textLocation.X + 0.01); } var firstPoint = curve.Value(curve.FirstParameter); var lastPoint = curve.Value(curve.LastParameter); var plane = dimensionPlane; if (plane == null) { var mkPlane = new GCMakePlane(firstPoint, lastPoint, textLocation); plane = mkPlane.Value; } var length = firstPoint.Distance(lastPoint); return(length < 1e-12 ? null : GeomUtils.BuildLengthDimension(firstPoint, lastPoint, plane, textLocation, arrowType, ArrowSize, 0.2, isOffset, offset)); }
public void AllocDeallocSimpleTest() { //NaroMessage.Show("start test"); //Console.WriteLine("---- wrapper start test ----"); var watch = new Stopwatch(); watch.Start(); for (var i = 0; i < 300000; i++) { var pnt = new gpPnt(i, i, i); var pnt2 = new gpPnt(i + 10, i + 10, i + 10); var aEdge = new BRepBuilderAPIMakeEdge(pnt, pnt2).Edge; var wire = new BRepBuilderAPIMakeWire(aEdge).Wire; TopoDSShape shape = wire; new AISShape(shape); var pln = new gpPln(i + 10, i + 10, i + 10, i + 10); var geomPln = new GeomPlane(pln); var trsf = new gpTrsf(); geomPln.Transform(trsf); } watch.Stop(); //Console.WriteLine("---- wrapper end test - took {0} ms ----", watch.ElapsedMilliseconds); //NaroMessage.Show(String.Format("---- wrapper end test - took {0} ms ----", watch.ElapsedMilliseconds)); }
public override List <SolverPreviewObject> InterestingShapeAroundPoint(gpPln planeOfTheView, Point3D point) { var qosLock = QosFactory.Instance.Get(QosNames.PlaneMatchLock); qosLock.Begin(); foreach (var geometricObject in Geometry) { foreach (var pln in geometricObject.Planes) { var distance = pln.Plane.Distance(point.GpPnt); var precision = _precision * CoreGlobalPreferencesSingleton.Instance.ZoomLevel; if (distance >= precision) { continue; } var plane = new GeomPlane(pln.Plane); var projectionPoint = new GeomAPIProjectPointOnSurf(point.GpPnt, plane, Precision.Confusion, ExtremaExtAlgo.Extrema_ExtAlgo_Grad); if (projectionPoint.NbPoints <= 0) { continue; } return(new List <SolverPreviewObject>() { new SolverPointResult(new Point3D(projectionPoint.NearestPoint), pln.ParentIndex) }); } } qosLock.End(); return(new List <SolverPreviewObject>()); }
public static gpPln ExtractPlaneFromFaceShape(TopoDSShape targetFace) { var face = TopoDS.Face(targetFace); var surf = BRepTool.Surface(face); var pl = new GeomPlane(new gpAx3()); pl = surf.Convert <GeomPlane>(); //surf.DownCast(ref pl); var faceElementAdaptor = new BRepAdaptorSurface(face, true); //TO DO: Investigate why this is not working Ensure.AreEqual(faceElementAdaptor.GetType, GeomAbsSurfaceType.GeomAbs_Plane); return(pl.Pln); }
/// <summary> /// Builds a dimension between a start and end point. /// </summary> private static AISInteractiveObject CreateDimension(gpPnt startPoint, gpPnt endPoint, gpPnt textLocation, DsgPrsArrowSide arrowSide, double arrowSize) { var mkPlane = new GCMakePlane(startPoint, endPoint, textLocation); var plane = new GeomPlane(new gpPln()); try { plane = mkPlane.Value; } catch (Exception) { //return null; } var length = startPoint.Distance(endPoint); return(length < 1e-12 ? null : GeomUtils.BuildLengthDimension(startPoint, endPoint, plane, textLocation, arrowSide, arrowSize, 0.2, false, null)); }
private static void BuildFaceList(TopoDSShape solidShape, SolverGeometricObject solverObject) { var listOfFaces = GeomUtils.ExtractFaces(solidShape); if (listOfFaces.Count <= 0) { return; } foreach (var face in listOfFaces) { var surf = BRepTool.Surface(face); solverObject.Surfaces.Add(new SolverSurface(surf, GeometryType.Face)); // Check if surface is planar var aFaceElementAdaptor = new BRepAdaptorSurface(face, true); var surfaceType = aFaceElementAdaptor.GetType; if (surfaceType != GeomAbsSurfaceType.GeomAbs_Plane) { continue; } GeomPlane pl = surf.Convert <GeomPlane>(); solverObject.Planes.Add(new SolverPlane(pl.Pln, GeometryType.Plane, solverObject.Parent)); } }
private void ConeHeight(bool updateShape) { double height; if (Dependency.Steps[3].Data is Mouse3DPosition) { // If point received from mouse, recalculate the axis direction var plane = new GeomPlane(Dependency.Steps[0].Get <gpAx1>().Location, Dependency.Steps[0].Get <gpAx1>().Direction); height = GeomUtils.PointPosition(plane.Pln, Dependency.Steps[3].Get <Mouse3DPosition>().Point.GpPnt); Dependency.Steps[3].Data = height; } else { // If height received from command line height = Dependency.Steps[3].Get <double>(); } if (Math.Abs(height) < 0.01) { height = 1; } var axis = Dependency.Steps[0].Get <gpAx1>(); if (height > 0) { axis = axis.Reversed; Dependency.Steps[0].Data = axis; } // Prevent the mouse from generating point on the base var basePoint = axis.Location; var excludedPlane = new GeomPlane(basePoint, axis.Direction); Dependency.Inputs.Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.ExcludedPlane, excludedPlane.Pln); // After the base is drawn disable the face picker Dependency.Inputs.Inputs[InputNames.FacePickerPlane].Send(NotificationNames.Suspend); Dependency.AnimationNodeBuilder = new NodeBuilder(Dependency.AnimationDocument, FunctionNames.Cone); var builder = Dependency.AnimationNodeBuilder; DrawCone(ref builder, Dependency.Steps[1].Get <double>(), height, axis, true, false); // Build a distance dimension just for animation purposes var animationBuilder = new NodeBuilder(Dependency.AnimationDocument, FunctionNames.PointsDimension); var firstTransformedPoint = axis.Location; var firstPoint = new Point3D(firstTransformedPoint); animationBuilder[0].TransformedPoint3D = firstPoint; var translationVector = new gpVec(axis.Direction); translationVector.Normalize(); translationVector.Multiply(height); var secondPoint = firstPoint.GpPnt.Translated(translationVector.Reversed); animationBuilder[1].TransformedPoint3D = new Point3D(secondPoint); var textLocation = new Point3D(secondPoint); textLocation.X++; textLocation.Y++; textLocation.Z++; animationBuilder[2].TransformedPoint3D = textLocation; animationBuilder[3].Integer = (int)DsgPrsArrowSide.DsgPrs_AS_FIRSTPT_LASTAR; animationBuilder.EnableSelection = false; animationBuilder.ExecuteFunction(); Dependency.AnimationNodeBuilder = animationBuilder; }
public void SetPlaneAttributes(GeomPlane aComponent, gpPnt aCenter, gpPnt aPmin, gpPnt aPmax) { AIS_Plane_SetPlaneAttributesC014B0(Instance, aComponent.Instance, aCenter.Instance, aPmin.Instance, aPmax.Instance); }
public bool PlaneAttributes(GeomPlane aComponent, gpPnt aCenter, gpPnt aPmin, gpPnt aPmax) { return(AIS_Plane_PlaneAttributesC014B0(Instance, aComponent.Instance, aCenter.Instance, aPmin.Instance, aPmax.Instance)); }
public AISPlane(GeomPlane aComponent, gpPnt aCenter, gpPnt aPmin, gpPnt aPmax, bool aCurrentMode) : base(AIS_Plane_Ctor57A70980(aComponent.Instance, aCenter.Instance, aPmin.Instance, aPmax.Instance, aCurrentMode)) { }
public AISPlane(GeomPlane aComponent, gpPnt aCenter, bool aCurrentMode) : base(AIS_Plane_Ctor13B4A2BC(aComponent.Instance, aCenter.Instance, aCurrentMode)) { }
public AISPlane(GeomPlane aComponent, bool aCurrentMode) : base(AIS_Plane_Ctor774085EF(aComponent.Instance, aCurrentMode)) { }
public AISLengthDimension(TopoDSShape aFShape, TopoDSShape aSShape, GeomPlane aPlane, double aVal, TCollectionExtendedString aText, gpPnt aPosition, DsgPrsArrowSide aSymbolPrs, AISTypeOfDist aTypeDist, double anArrowSize) : base(AIS_LengthDimension_CtorEA089509(aFShape.Instance, aSShape.Instance, aPlane.Instance, aVal, aText.Instance, aPosition.Instance, (int)aSymbolPrs, (int)aTypeDist, anArrowSize)) { }
public AISLengthDimension(TopoDSShape aFShape, TopoDSShape aSShape, GeomPlane aPlane, double aVal, TCollectionExtendedString aText) : base(AIS_LengthDimension_CtorFBAAB8FA(aFShape.Instance, aSShape.Instance, aPlane.Instance, aVal, aText.Instance)) { }