Bug in display conduit brep shaded?

Hi,

For some reason when i’m trying to display a shaded brep with display conduit it does not display the whole brep. You can see what i mean by that in the figure below. Any ideas what could be wrong? I did draw the geometry in the postdraw method of the display conduit wit the following code:

e.Display.DrawBrepShaded(corbel, new DisplayMaterial(Color.Black, 0.5));

With best regards
MAtti

Hello - you’ll need to have the conduit recalculate the scene bounding box.
There’s a similar example here -

-Pascal

Hi @pascal ,

Thanks for the answer. I have done that already like this:

    protected override void CalculateBoundingBox(Rhino.Display.CalculateBoundingBoxEventArgs e)
    {
        base.CalculateBoundingBox(e);
        if (corbel != null)
            e.IncludeBoundingBox(corbel.GetBoundingBox(true));

    }

If it helps here is the whole Class:

public class CorbelConduit:Rhino.Display.DisplayConduit
{
    public Brep corbel;
    public List<Brep> reinforcements = new List<Brep>();

    protected override void CalculateBoundingBox(Rhino.Display.CalculateBoundingBoxEventArgs e)
    {
        base.CalculateBoundingBox(e);
        if (corbel != null)
            e.IncludeBoundingBox(corbel.GetBoundingBox(true));

    }


    protected override void PostDrawObjects(Rhino.Display.DrawEventArgs e)
    {
        if (corbel != null)
        {
            e.Display.DrawBrepShaded(corbel, new DisplayMaterial(Color.Black, 0.5));
            e.Display.DrawBrepWires(corbel,Color.Black);
        }
        foreach (Brep brep in reinforcements)
        {
            e.Display.DrawBrepShaded(brep, new DisplayMaterial(Color.Black, 0.1));
        }       
    }



}

Hello - I’m going to shift this to the developer forum, we’re definitely out of my league here…

-Pascal

Hi @Matti_Pirinen,

Is the Brep something you have in your model, or are you build this yourself in memory.

How can I repeat what you are seeing?

– Dale

Hi @dale ,

The brep is in memory

I pushed the project to:

If you just start the project it should automatically display in the screen

Hi @Matti_Pirinen,

I’ve fixed some flaws in your Brep creation. Please review my changes. If you’re happy with them, then merge my changes into your master branch.

FormMain.cs (21.7 KB)

– Dale

Thank you @dale! It worked perfectly. It was the kinky face problem. Just for the record here is dales fix to my problem if some people ran into this problem in future:

        // Extrude the planar curve
        var dir = new Vector3d(0, convertToDouble(textBox_b.Text), 0);
        var srf = Surface.CreateExtrusion(curve, dir);

        // Create a Brep from the surface
        var brep = srf.ToBrep();

        // The profile curve is a degree=1 curve. Thus, the extruded surface will
        // have kinks. Because kinked surface can cause problems down stream, Rhino
        // always splits kinked surfaces when adding Breps to the document. Since
        // we are not adding this Brep to the document, lets split the kinked
        // surfaces ourself.
        brep.Faces.SplitKinkyFaces(RhinoMath.DefaultAngleTolerance, true);

        // Cap any planar holes
        var capped_brep = brep.CapPlanarHoles(RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);

        // The profile curve, created by the input points, is oriented clockwise.
        // Thus when the profile is extruded, the resulting surface will have its
        // normals pointed inwards. So lets check the orientation and, if inwards,
        // flip the face normals.
        if (BrepSolidOrientation.Inward == capped_brep.SolidOrientation)
            capped_brep.Flip();

Now that I think I think I had a similar problem one year ago. Human mind is forgetful.

1 Like