/// <summary> /// TwistedCubeSideSurface /// </summary> static OnSurface TwistedCubeSideSurface( IOn3dPoint SW, IOn3dPoint SE, IOn3dPoint NE, IOn3dPoint NW ) { OnNurbsSurface ns = new OnNurbsSurface( 3, // dimension false, // not rational 2, // "u" order 2, // "v" order 2, // number of control vertices in "u" dir 2 // number of control vertices in "v" dir ); // Corner CVs in counter clockwise order starting in the south west ns.SetCV(0, 0, SW); ns.SetCV(1, 0, SE); ns.SetCV(1, 1, NE); ns.SetCV(0, 1, NW); // "u" knots ns.SetKnot(0, 0, 0.0); ns.SetKnot(0, 1, 1.0); // "v" knots ns.SetKnot(1, 0, 0.0); ns.SetKnot(1, 1, 1.0); return(ns); }
/// <summary> /// TwistedCubeEdgeCurve /// </summary> static OnCurve TwistedCubeEdgeCurve( IOn3dPoint from, IOn3dPoint to ) { // Creates a 3d line segment to be used as a 3d curve in a OnBrep OnLineCurve c3d = new OnLineCurve(from, to); c3d.SetDomain(0.0, 1.0); return(c3d); }
///////////////////////////////////////////////////////////////////////// // Overridden MRhinoGetPoint::DynamicDraw public override void DynamicDraw(IntPtr hdc, MRhinoViewport vp, IOn3dPoint pt) { MRhinoDisplayPipeline dp = vp.DisplayPipeline(); if (dp != null) { dp.PushObjectColor(0); dp.DrawObjects(m_list.m_objects, m_xform); dp.DrawObjects(m_list.m_grip_owners); dp.PopObjectColor(); base.DynamicDraw(hdc, vp, pt); } }
public override bool CalculateTransform(MRhinoViewport vp, IOn3dPoint point, ref OnXform xform) { bool bResult = false; On3dVector v = new On3dVector(); On3dPoint pt = new On3dPoint(point); v = pt - m_base; if (!v.IsZero()) { xform.Translation(v); bResult = xform.IsValid(); } return(bResult); }
///////////////////////////////////////////////////////////////////////// // Overridden MRhinoGetPoint::OnMouseMove public override void OnMouseMove(MRhinoViewport vp, uint flags, IOn3dPoint pt, System.Drawing.Point view_wnd_point) { m_bHaveXform = CalculateTransform(vp, pt, ref m_xform); if (!m_bHaveXform) { m_xform.Identity(); } for (int i = 0; i < m_list.m_grips.Length; i++) { m_list.m_grips[i].MoveGrip(m_xform); } base.OnMouseMove(vp, flags, pt, view_wnd_point); }
///////////////////////////////////////////////////////////////////////// // STEP 4: Override this abstract function to provide your own custom // transformation method. Call this function to retrieve // the final transformation. public abstract bool CalculateTransform(MRhinoViewport vp, IOn3dPoint point, ref OnXform xform);
public override bool CalculateTransform(MRhinoViewport vp, IOn3dPoint point, ref OnXform xform) { bool bResult = false; On3dVector v = new On3dVector(); On3dPoint pt = new On3dPoint(point); v = pt - m_base; if (!v.IsZero()) { xform.Translation(v); bResult = xform.IsValid(); } return bResult; }
///////////////////////////////////////////////////////////////////////// // Overridden MRhinoGetPoint::SetBasePoint public new void SetBasePoint(IOn3dPoint base_point) { m_base = (On3dPoint)base_point; base.SetBasePoint(base_point); }
/// <summary> /// Quickly finds which voxel the intersection point lies in. /// </summary> /// <param name="Point"></param> /// <param name="XVoxel"></param> /// <param name="YVoxel"></param> /// <param name="ZVoxel"></param> public void PointIsInVoxel(IOn3dPoint Point, ref int XVoxel, ref int YVoxel, ref int ZVoxel) { XVoxel = (int)Math.Floor((Point.x - OverallBounds().Min().x) / X_Incr); YVoxel = (int)Math.Floor((Point.y - OverallBounds().Min().y) / Y_Incr); ZVoxel = (int)Math.Floor((Point.z - OverallBounds().Min().z) / Z_Incr); }
int CreateInstanceDefinition(MRhinoDoc doc, IOnInstanceDefinition idef, IOn3dPoint point, List <IRhinoObject> objects, bool bQuietly) { int found_index = doc.m_instance_definition_table.FindInstanceDefinition(idef.Name(), true); List <IRhinoObject> idef_objects = new List <IRhinoObject>(); OnXform xform = new OnXform(); xform.Translation(new On3dPoint(OnUtil.On_origin) - point); for (int i = 0; i < objects.Count; i++) { IRhinoObject obj = objects[i]; if (obj == null) { continue; } if (obj.ObjectType() == IOn.object_type.light_object || obj.ObjectType() == IOn.object_type.grip_object || obj.ObjectType() == IOn.object_type.phantom_object ) { continue; } // Transform geometry and attributes, but do not add to the document MRhinoObject dupe = doc.TransformObject(obj, xform, false, false, false); if (dupe != null) { if (doc.AddObject(dupe, false, true)) { idef_objects.Add(dupe); } } } if (idef_objects.Count < 1) { return(-1); } int idef_index = -1; if (found_index < 0) { idef_index = doc.m_instance_definition_table.AddInstanceDefinition(idef, idef_objects.ToArray(), false, bQuietly); } else if (doc.m_instance_definition_table.ModifyInstanceDefinitionGeometry(found_index, idef_objects.ToArray(), bQuietly)) { idef_index = found_index; doc.m_instance_definition_table.ModifyInstanceDefinition(idef, idef_index, (uint)IDEF_SETTINGS.all_idef_settings, bQuietly); if (!bQuietly) { IRhinoInstanceObject[] iref_object_list = null; int iref_count = doc.m_instance_definition_table[found_index].GetReferences(out iref_object_list); if (iref_count > 0) { RhUtil.RhinoApp().Print(string.Format("{0} Instances of block \"{1}\" have been updated.\n", iref_count, idef.Name())); } } } if (idef_index < 0 && !bQuietly) { string message = (found_index < 0) ? "Error creating block.\n" : "Error modifying block.\n"; RhUtil.RhinoApp().Print(message); } return(idef_index); }
/// <summary> /// TwistedCubeEdgeCurve /// </summary> static OnCurve TwistedCubeEdgeCurve( IOn3dPoint from, IOn3dPoint to ) { // Creates a 3d line segment to be used as a 3d curve in a OnBrep OnLineCurve c3d = new OnLineCurve(from, to); c3d.SetDomain(0.0, 1.0); return c3d; }
///////////////////////////////////////////////////////////////////////// // Overridden MRhinoGetPoint::OnMouseMove public override void OnMouseMove(MRhinoViewport vp, uint flags, IOn3dPoint pt, System.Drawing.Point view_wnd_point) { m_bHaveXform = CalculateTransform(vp, pt, ref m_xform); if (!m_bHaveXform) m_xform.Identity(); for (int i = 0; i < m_list.m_grips.Length; i++) m_list.m_grips[i].MoveGrip(m_xform); base.OnMouseMove(vp, flags, pt, view_wnd_point); }
/// <summary> /// TwistedCubeSideSurface /// </summary> static OnSurface TwistedCubeSideSurface( IOn3dPoint SW, IOn3dPoint SE, IOn3dPoint NE, IOn3dPoint NW ) { OnNurbsSurface ns = new OnNurbsSurface( 3, // dimension false, // not rational 2, // "u" order 2, // "v" order 2, // number of control vertices in "u" dir 2 // number of control vertices in "v" dir ); // Corner CVs in counter clockwise order starting in the south west ns.SetCV(0, 0, SW); ns.SetCV(1, 0, SE); ns.SetCV(1, 1, NE); ns.SetCV(0, 1, NW); // "u" knots ns.SetKnot(0, 0, 0.0); ns.SetKnot(0, 1, 1.0); // "v" knots ns.SetKnot(1, 0, 0.0); ns.SetKnot(1, 1, 1.0); return ns; }
int CreateInstanceDefinition(MRhinoDoc doc, IOnInstanceDefinition idef, IOn3dPoint point, List<IRhinoObject> objects, bool bQuietly) { int found_index = doc.m_instance_definition_table.FindInstanceDefinition(idef.Name(), true); List<IRhinoObject> idef_objects = new List<IRhinoObject>(); OnXform xform = new OnXform(); xform.Translation(new On3dPoint(OnUtil.On_origin) - point); for (int i = 0; i < objects.Count; i++) { IRhinoObject obj = objects[i]; if (obj == null) continue; if (obj.ObjectType() == IOn.object_type.light_object || obj.ObjectType() == IOn.object_type.grip_object || obj.ObjectType() == IOn.object_type.phantom_object ) continue; // Transform geometry and attributes, but do not add to the document MRhinoObject dupe = doc.TransformObject(obj, xform, false, false, false); if (dupe != null) { if (doc.AddObject(dupe, false, true)) idef_objects.Add(dupe); } } if (idef_objects.Count < 1) return -1; int idef_index = -1; if (found_index < 0) idef_index = doc.m_instance_definition_table.AddInstanceDefinition(idef, idef_objects.ToArray(), false, bQuietly); else if (doc.m_instance_definition_table.ModifyInstanceDefinitionGeometry(found_index, idef_objects.ToArray(), bQuietly)) { idef_index = found_index; doc.m_instance_definition_table.ModifyInstanceDefinition(idef, idef_index, (uint)IDEF_SETTINGS.all_idef_settings, bQuietly); if (!bQuietly) { IRhinoInstanceObject[] iref_object_list = null; int iref_count = doc.m_instance_definition_table[found_index].GetReferences(out iref_object_list); if (iref_count > 0) RhUtil.RhinoApp().Print(string.Format("{0} Instances of block \"{1}\" have been updated.\n", iref_count, idef.Name())); } } if (idef_index < 0 && !bQuietly) { string message = (found_index < 0) ? "Error creating block.\n" : "Error modifying block.\n"; RhUtil.RhinoApp().Print(message); } return idef_index; }