/// <summary> /// Constructs a new basic material from a <see cref="Rhino.DocObjects.Material">Material</see>. /// </summary> /// <param name="material">(optional)The material to create the basic material from.</param> /// <returns>A new basic material.</returns> public static RenderMaterial CreateBasicMaterial(DocObjects.Material material) { IntPtr const_ptr_source_material = (material == null ? IntPtr.Zero : material.ConstPointer()); IntPtr ptr_new_material = UnsafeNativeMethods.Rdk_Globals_NewBasicMaterial(const_ptr_source_material); NativeRenderMaterial new_material = FromPointer(ptr_new_material) as NativeRenderMaterial; if (new_material != null) new_material.AutoDelete = true; return new_material; }
public bool UpdateToText(Geometry.TextEntity text, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); IntPtr pConstText = text.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToText2(m_parent.m_pObjectPairArray, m_index, pConstText, pConstAttributes); }
public bool UpdateToText(string text, Geometry.Plane plane, double height, string fontName, bool bold, bool italic, Geometry.TextJustification justification, DocObjects.ObjectAttributes attributes) { if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(fontName)) return false; int fontStyle = 0; if (bold) fontStyle |= 1; if (italic) fontStyle |= 2; IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); RhinoDoc doc = m_parent.Document; int docId = (doc == null) ? 0 : doc.m_docId; return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToText(m_parent.m_pObjectPairArray, docId, m_index, text, ref plane, height, fontName, fontStyle, (int)justification, pConstAttributes); }
/// <summary> /// Generate geometry that would be used to draw the hatch with a given hatch pattern /// </summary> /// <param name="pattern"></param> /// <param name="patternScale"></param> /// <param name="bounds"></param> /// <param name="lines"></param> /// <param name="solidBrep"></param> public void CreateDisplayGeometry(DocObjects.HatchPattern pattern, double patternScale, out Curve[] bounds, out Line[] lines, out Brep solidBrep) { IntPtr const_ptr_this = ConstPointer(); IntPtr const_ptr_pattern = pattern.ConstPointer(); using(var curve_array = new Runtime.InteropWrappers.SimpleArrayCurvePointer()) using(var line_array = new Runtime.InteropWrappers.SimpleArrayLine()) { IntPtr ptr_curves = curve_array.NonConstPointer(); IntPtr ptr_lines = line_array.NonConstPointer(); IntPtr ptr_brep = UnsafeNativeMethods.CRhinoHatchPattern_CreateDisplay(const_ptr_this, const_ptr_pattern, patternScale, ptr_curves, ptr_lines); solidBrep = (ptr_brep==IntPtr.Zero) ? null : new Brep(ptr_brep, null); bounds = curve_array.ToNonConstArray(); lines = line_array.ToArray(); } }
/// <summary> /// Checks geometry to see if it passes the basic GeometryAttributeFilter. /// </summary> /// <param name="rhObject">parent object being considered.</param> /// <param name="geometry">geometry being considered.</param> /// <param name="componentIndex">if >= 0, geometry is a proper sub-part of object->Geometry() with componentIndex.</param> /// <returns> /// true if the geometry passes the filter returned by GeometryAttributeFilter(). /// </returns> public bool PassesGeometryAttributeFilter(DocObjects.RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex) { IntPtr pRhinoObject = IntPtr.Zero; if (rhObject != null) pRhinoObject = rhObject.ConstPointer(); IntPtr pGeometry = IntPtr.Zero; if (geometry != null) pGeometry = geometry.ConstPointer(); IntPtr ptr = NonConstPointer(); return UnsafeNativeMethods.CRhinoGetObject_PassesGeometryAttributeFilter(ptr, pRhinoObject, pGeometry, componentIndex); }
public bool PushViewInfo(DocObjects.ViewInfo viewinfo, bool includeTraceImage) { IntPtr pThis = NonConstPointer(); IntPtr pConstView = viewinfo.ConstPointer(); return UnsafeNativeMethods.CRhinoViewport_PushViewInfo(pThis, pConstView, includeTraceImage); }
public bool UpdateToHatch(Geometry.Hatch hatch, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); IntPtr pConstHatch = hatch.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToHatch(m_parent.m_pObjectPairArray, m_index, pConstHatch, pConstAttributes); }
public bool UpdateToBrep(Geometry.Brep brep, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); IntPtr pConstBrep = brep.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToBrep(m_parent.m_pObjectPairArray, m_index, pConstBrep, pConstAttributes); }
public DisplayMaterial(DocObjects.Material material) { IntPtr pConstMaterial = material.ConstPointer(); m_ptr = UnsafeNativeMethods.CDisplayPipelineMaterial_New4(pConstMaterial); }
/// <summary> /// Gets a transform from origin coordinate system to a target coordinate system. /// </summary> /// <param name="sourceSystem">The origin coordinate system.</param> /// <param name="destinationSystem">The target coordinate system.</param> /// <returns> /// 4x4 transformation matrix (acts on the left) /// Identity matrix is returned if this function fails. /// </returns> /// <example> /// <code source='examples\vbnet\ex_pointatcursor.vb' lang='vbnet'/> /// <code source='examples\cs\ex_pointatcursor.cs' lang='cs'/> /// </example> public Transform GetTransform(DocObjects.CoordinateSystem sourceSystem, DocObjects.CoordinateSystem destinationSystem) { Transform matrix = new Transform(); IntPtr const_ptr_this = ConstPointer(); if (!UnsafeNativeMethods.CRhinoViewport_VP_GetXform(const_ptr_this, (int)sourceSystem, (int)destinationSystem, ref matrix)) return Transform.Identity; return matrix; }
/// <summary> /// Checks geometry to see if it can be selected. /// Override to provide fancy filtering. /// </summary> /// <param name="rhObject">parent object being considered.</param> /// <param name="geometry">geometry being considered.</param> /// <param name="componentIndex"> /// if >= 0, geometry is a proper sub-part of object->Geometry() with componentIndex. /// </param> /// <returns> /// The default returns true unless you've set a custom geometry filter. If a custom /// filter has been set, that delegate is called /// </returns> public virtual bool CustomGeometryFilter( DocObjects.RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex ) { if (m_filter != null) return m_filter(rhObject, geometry, componentIndex); return true; }
/// <summary> /// Initializes a new object reference from a Rhino object. /// </summary> /// <param name="rhinoObject">The Rhino object.</param> public ObjRef(DocObjects.RhinoObject rhinoObject) { IntPtr pObject = rhinoObject.ConstPointer(); m_ptr = UnsafeNativeMethods.CRhinoObjRef_New2(pObject); }
/// <summary> /// Override this function to provide a Rhino.DocObjects.Material definition for this material /// to be used by other rendering engines including the display. /// </summary> /// <param name="simulation">Set the properties of the input basic material to provide the simulation for this material.</param> /// <param name="isForDataOnly">Called when only asking for a hash - don't write any textures to the disk - just provide the filenames they will get.</param> public virtual void SimulateMaterial(ref DocObjects.Material simulation, bool isForDataOnly) { if (IsNativeWrapper()) { UnsafeNativeMethods.Rdk_RenderMaterial_SimulateMaterial(NonConstPointer(), simulation.ConstPointer(), isForDataOnly); } else { UnsafeNativeMethods.Rdk_RenderMaterial_CallSimulateMaterialBase(NonConstPointer(), simulation.ConstPointer(), isForDataOnly); } }
/// <summary> /// Adds an ObjRef to the list. /// </summary> /// <param name="objref">An ObjRef to add.</param> public void Add(DocObjects.ObjRef objref) { if (null != objref) { IntPtr ptr_const_objref = objref.ConstPointer(); IntPtr ptr_this = NonConstPointer(); UnsafeNativeMethods.ON_ClassArrayON_ObjRef_Append(ptr_this, ptr_const_objref); } }
public bool UpdateToSurface(Geometry.Surface surface, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); IntPtr pConstSurface = surface.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToSurface(m_parent.m_pObjectPairArray, m_index, pConstSurface, pConstAttributes); }
public bool UpdateToExtrusion(Geometry.Extrusion extrusion, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); IntPtr pConstExtrusion = extrusion.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToExtrusion(m_parent.m_pObjectPairArray, m_index, pConstExtrusion, pConstAttributes); }
/// <summary> /// Draws a <see cref="DocObjects.RhinoObject">RhinoObject</see> with an applied transformation. /// </summary> /// <param name="rhinoObject">The Rhino object.</param> /// <param name="xform">The transformation.</param> /// <example> /// <code source='examples\vbnet\ex_arraybydistance.vb' lang='vbnet'/> /// <code source='examples\cs\ex_arraybydistance.cs' lang='cs'/> /// <code source='examples\py\ex_arraybydistance.py' lang='py'/> /// </example> public void DrawObject(DocObjects.RhinoObject rhinoObject, Transform xform) { IntPtr pThis = NonConstPointer(); IntPtr pRhinoObject = rhinoObject.ConstPointer(); UnsafeNativeMethods.CRhinoDisplayPipeline_DrawObject2(pThis, pRhinoObject, ref xform); }
public bool UpdateToLeader(Geometry.Leader leader, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); IntPtr pConstLeader = leader.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToLeader(m_parent.m_pObjectPairArray, m_index, pConstLeader, pConstAttributes); }
/// <summary> /// Determines if an object can be visible in this viewport based on it's object type and display attributes. /// This test does not check for visibility based on location of the object. /// NOTE: Use CRhinoDisplayPipeline::IsVisible() to perform "visibility" /// tests based on location (is some part of the object in the view frustum). /// Use CRhinoDisplayPipeline::IsActive() to perform "visibility" /// tests based on object type. /// </summary> /// <param name="rhinoObject">Object to test.</param> /// <returns> /// true if this object can be drawn in the pipeline's viewport based on it's object type and display attributes. /// </returns> public bool IsActive(DocObjects.RhinoObject rhinoObject) { IntPtr pRhinoObject = rhinoObject.ConstPointer(); return UnsafeNativeMethods.CRhinoDisplayPipeline_IsVisibleOrActive(m_ptr, pRhinoObject, false); }
/// <summary> /// Pushes the current construction plane on the viewport's /// construction plane stack and sets the construction plane /// to cplane. /// </summary> /// <param name="cplane">The constuction plane to push.</param> public void PushConstructionPlane(DocObjects.ConstructionPlane cplane) { IntPtr pThis = NonConstPointer(); IntPtr pCPlane = cplane.CopyToNative(); if (pCPlane != IntPtr.Zero) { UnsafeNativeMethods.CRhinoViewport_SetConstructionPlane(pThis, pCPlane, true); UnsafeNativeMethods.ON_3dmConstructionPlane_Delete(pCPlane); } }
public bool UpdateToLine(Geometry.Point3d from, Geometry.Point3d to, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateResult8(m_parent.m_pObjectPairArray, m_index, from, to, pConstAttributes); }
/// <summary> /// Checks geometry to see if it can be selected. /// Override to provide fancy filtering. /// </summary> /// <param name="rhObject">parent object being considered.</param> /// <param name="geometry">geometry being considered.</param> /// <param name="componentIndex"> /// if >= 0, geometry is a proper sub-part of object->Geometry() with componentIndex. /// </param> /// <returns>The default always returns true.</returns> public virtual bool CustomGeometryFilter( DocObjects.RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex ) { return true; }
public bool UpdateToPolyline(IEnumerable<Geometry.Point3d> points, DocObjects.ObjectAttributes attributes) { int count; Geometry.Point3d[] ptArray = Collections.Point3dList.GetConstPointArray(points, out count); if (null == ptArray || count < 1) return false; IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToPolyline(m_parent.m_pObjectPairArray, m_index, count, ptArray, pConstAttributes); }
/// <summary> /// Get ON_Viewport* from a ViewportInfo instance /// </summary> /// <param name="viewport"></param> /// <returns></returns> public static IntPtr NativeNonConstPointer(DocObjects.ViewportInfo viewport) { return viewport.NonConstPointer(); }
public bool UpdateToEllipse(Geometry.Ellipse ellipse, DocObjects.ObjectAttributes attributes) { IntPtr pConstAttributes = (attributes == null) ? IntPtr.Zero : attributes.ConstPointer(); return UnsafeNativeMethods.CRhinoObjectPairArray_UpdateToEllipse(m_parent.m_pObjectPairArray, m_index, ref ellipse, pConstAttributes); }