Brep.CreateContourCurves issue

  • some segments do not reconnect in the right order, and therefore a few pieces remain isolated. This is a problem of tolerances that are way too high when they arrive to the inner computations. RH-65835

Could you please take a look at Brep.CreateContourCurves as well? It creates 4 or 5 segments sometimes (on edges mostly). what about adding a merge/join built-in in command option?

Thank you

Hi @bahman.farshbaf,

In order to assist, we’ll need some geometry and source code that isn’t working for you.

– Dale

Thank you @dale
I’ve sent you geometry by pm and here is the code:

             string child_name1 = "Depart Paths";
            Layer childlayer1 = new Layer
            {
                Name = child_name1,
                Color = System.Drawing.Color.MediumVioletRed
            };
            int active1 = RhinoDoc.ActiveDoc.Layers.Add(childlayer1);

            string child_name = "XAxis";
            Layer childlayer = new Layer
            {
                Name = child_name,
                Color = System.Drawing.Color.Blue
            };
            int active = RhinoDoc.ActiveDoc.Layers.Add(childlayer);
            Curve[] curves;
            Vector3d vec = Vector3d.XAxis;
            int a = 0;
            foreach (ObjRef obj_ref in objrefs)
            {
                GeometryBase geometry = obj_ref.Geometry();
                if (geometry == null)
                {
                    return;
                }
                for (double i = -450; i <= 450; i += 5)
                {
                    double d2 = i + 2.5;
                    Point3d pt = new Point3d(d2, 0, 0);
                    if (geometry is Brep)
                    {
                        curves = Brep.CreateContourCurves(geometry as Brep, new Plane(pt, vec));
                    }
                    else
                    {
                        curves = Mesh.CreateContourCurves(geometry as Mesh, new Plane(pt, vec));
                    }
                    foreach (Curve curve in curves)
                    {
                        if (a % 2 != 0)
                        {
                            RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(active1, true);
                            a += 1;
                        }
                        else
                        {
                            RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(active, true);
                            a += 1;
                        }
                        Guid curve_object_id = doc.Objects.AddCurve(curve);
                        doc.Objects.Select(curve_object_id);
                    }
                }
            }

There are 3 segments in highlighted area!

Hi @bahman.farshbaf,

Does Rhino’s Contour command exhibit the same behavior?

– Dale

yes @dale, exactly at x = -202.5 of shape!

Hi @bahman.farshbaf,

I’ve logged this issue.

https://mcneel.myjetbrains.com/youtrack/issue/RH-65908

– Dale

Does this problem only happen with this geometry or do you many models that exhibit this behavior? I looked into this some, you can see my notes on the YT issue, and I don’t think this is Contour or Section despite the problem manifesting itself there. For example, I was able to make a cut plane in the problem region. I extracted the 3 faces of the brep that seem to have issues and intersected them individually with the same cut plane. In theory, since those surfaces were joined you ought to be able to join the curves from the separate intersections. 2 did, the end points were .009 units apart. The last one didn’t. It’s end was .012 from the other end point.

@dale Thanke Dale
@tim Yes, that problem only happens with this Brep, I don’t have any other models. I tried to do same with mesh, but it produces a lot of segments in another particular areas even in Y direction and Diagonal directions. So, how can we overcome of this issue?

If you have access to version 6 you could try contour there. In V6, Contour (and Section) use a different mesh/plane intersector. If it works better then we should log bugs for the mesh/mesh intersector that is used in V7.

In the case of polysurfaces, Contour does use a low level function that is different than intersection. It calls a function that does one face at a time. Intersection does an entire polysurface, I suspect that ultimately it also calls the one face at a time function though too, I just didn’t look.

I know these problems manifest themselves in Contour but they’re deeper than that. Contour just automates the process of making a bunch of cut planes, doing the intersections and joining the results. The key to fixing the problem is taking Contour out of the equation. I know you can’t see the models in the YT issue (the permissions are such that only developers can view them because you sent your initial model as a pm) but I was able to isolate cut planes that exhibited the weird behavior outside of Contour. Doing more of that and reporting them as surface/surface intersection problems or mesh/mesh intersection problems will help.

How did you create the polysurface in the first place? Did you make it entirely in Rhino?

In your code, why don’t you add the planes to the model and then you’ll example geometry to work with.

I think I have to install Rhino 6 trial version to test it, yeah good idea!
I didn’t know how is behind of contour, Thanks so much for great explanations.
I can see the YT issue, thanks to @dale, he changed visibility to public view.
The Brep/Polysurfaces is made by our customer and I’m sure they didn’t use Rhino. It was a STEP(stp) file and when I imported it in Rhino, Rhino created 19 Surfaces and then I joined them together to make a polysurfaces/brep.
I should try your last question!
Thank you so much for your efforts!

Hello - can you please post here or send to tech@mcneel.com, with a link back to this topic in your comments, the file that shows the problem?

-Pascal

What we’d actually like to see is the step model that you made the Rhino file from. Can you walk us through the process you took to get to the point of the Rhino file you sent in?

@pascal I have sent it to that email.
@tim After opening that STEP file, I have removed that Circle only and those objects that arent inside of the shape. Then joined all 19 surfaces together and saved as 3dm Rhino file.