Remove duplicate entities in Brep?

Hello!

I am writing a function to create a Brep composed by BrepFaces from another Brep, which is currently looking something like this:

  /// <summary>
  /// Return a brep formed by the subfaces. 
  /// </summary>
  /// <param name="source"></param>
  /// <param name="indices"></param>
  /// <returns></returns>
  public Brep ExtractSubBrep(Brep source, List<int> indices)
  {
    Brep sub = new Brep();
    foreach (var i in indices)
    {
      BrepFace face = source.Faces[i];
      Brep cloneFace = face.DuplicateFace(false);
      sub.Append(cloneFace);
    }

    // Remove duplicate entities?
    sub.Standardize();
    sub.Compact();

    return sub;
  }

I am trying to output a lightweight Brep that doesn’t have duplicate entities such as vertices, edges, etc. Standardize and Compact are not cutting it, is there anyway in RhinoCommon to do this?

Related question about Brep.Standardize(): Meaning of Brep.Standardize()?

Thank you!

Hi @garciadelcastillo,

I’ve replied to your question on Brep.Standardize.

Brep.Compact simply iterates through the Brep and removes any unused topology or geometry.

I don’t think we have any tool to determine of a Brep has duplicate features.

– Dale

Thanks @dale for both answers! :slight_smile:

Actually, as it turns out, some tinkering is leading me to believe that Brep.Repair() actually does remove some duplicate entities!