Table of Contents

Class BRepOperation

Namespace
CADability
Assembly
CADability.dll

The boolean operations on BRep shells: union, intersection and difference of two closed shells, splitting a shell by a plane or a face, clipping a face by a shell and connecting a set of intersecting faces to shells. It is an OctTree<T> of BRepItems: the vertices, edges and faces of both shells are inserted so that only nearby edge/face pairs are intersected; the intersection edges split the faces, the parts are classified as inside or outside the other shell and recombined to the resulting shells according to the BRepOperation.Operation passed to the constructor. Create one with the two shells and the operation and call Result() for the resulting shells. Applications usually call it through Unite(Solid, Solid), Intersect(Solid, Solid), Subtract(Solid, Solid) and the static methods SplitByPlane(Shell, Plane), SplitByFace(Shell, Face), RoundEdges(Shell, Edge[], double), ChamferEdges(Face, Edge[], double, double) and ClipFace(Face, Shell).

public class BRepOperation : OctTree<BRepItem>
Inheritance
BRepOperation
Inherited Members

Constructors

BRepOperation(Face, Shell)

public BRepOperation(Face toClip, Shell clipBy)

Parameters

toClip Face
clipBy Shell

BRepOperation(Shell, Face)

Split the shell toSplit by a face. The face splitBy must split the shell into two or more parts It may not enter the shell without cutting through

public BRepOperation(Shell toSplit, Face splitBy)

Parameters

toSplit Shell
splitBy Face

BRepOperation(Shell, Shell, Operation)

public BRepOperation(Shell s1, Shell s2, BRepOperation.Operation operation)

Parameters

s1 Shell
s2 Shell
operation BRepOperation.Operation

BRepOperation(Shell, Shell, Dictionary<Edge, Tuple<Face, Face>>, Operation)

public BRepOperation(Shell s1, Shell s2, Dictionary<Edge, Tuple<Face, Face>> knownIntersections, BRepOperation.Operation operation)

Parameters

s1 Shell
s2 Shell
knownIntersections Dictionary<Edge, Tuple<Face, Face>>
operation BRepOperation.Operation

BRepOperation(Shell, Shell, HashSet<(Edge, Face)>, Operation)

This is a constructor for connecting and intersecting (open) shells, where we have a set of edge-face pairs, which should not be used for intersecting

public BRepOperation(Shell s1, Shell s2, HashSet<(Edge, Face)> dontIntersect, BRepOperation.Operation operation)

Parameters

s1 Shell
s2 Shell
dontIntersect HashSet<(Edge, Face)>
operation BRepOperation.Operation

BRepOperation(Shell, Plane)

Prepare a brep operation for splitting a (closed) shell with a plane. Or for returning the compound shapes on the specified plane. Here we assume that "toSplit" is properly oriented and han no periodic faces (no seams)

public BRepOperation(Shell toSplit, Plane splitBy)

Parameters

toSplit Shell

the shell to split (must be closed)

splitBy Plane

the plane to split by

BRepOperation(IEnumerable<Face>)

Connect all provided faces, remove the overhangs. Used by Shell.GetOffset.

public BRepOperation(IEnumerable<Face> facesToConnect)

Parameters

facesToConnect IEnumerable<Face>

the faces to connect; they are used directly, not cloned

Properties

AllowOpenEdges

public bool AllowOpenEdges { set; }

Property Value

bool

DebugEdgesToSplit

public GeoObjectList DebugEdgesToSplit { get; }

Property Value

GeoObjectList

DontCombineConnectedFaces

public bool DontCombineConnectedFaces { set; }

Property Value

bool

IntersectingFaces

Get all face pairs, which intersect each other

public HashSet<(Face, Face)> IntersectingFaces { get; }

Property Value

HashSet<(Face, Face)>

Unchanged

public bool Unchanged { get; }

Property Value

bool

UnusedFaces

public List<Face> UnusedFaces { get; }

Property Value

List<Face>

Methods

ChamferEdges(Face, Edge[], double, double)

Chamfer or bevel the provided edges. the edges must be connected and only two edges may have a common vertex. The edges must build a path. We have two distances from the edge to make chamfers with different angles. All edges must belong to the primaryFace. The first distance is on the primary face, the second on the other face (in most cases the distances are equal).

public static Shell ChamferEdges(Face primaryFace, Edge[] edges, double primaryDist, double secondaryDist)

Parameters

primaryFace Face
edges Edge[]
primaryDist double
secondaryDist double

Returns

Shell

ClipFace(Face, Shell)

public static Face[] ClipFace(Face toClip, Shell clipBy)

Parameters

toClip Face
clipBy Shell

Returns

Face[]

GetOverlappingFaces(out Face[], out Face[], out ModOp2D[])

Returns the pairs of faces of the two shells that lie on the same surface and overlap (or coincide), as found when the operation was prepared. Such faces are not intersected with each other but handled separately.

public int GetOverlappingFaces(out Face[] onShell1, out Face[] onShell2, out ModOp2D[] firstToSecond)

Parameters

onShell1 Face[]

The overlapping faces belonging to the first shell

onShell2 Face[]

The corresponding faces belonging to the second shell, in the same order as onShell1

firstToSecond ModOp2D[]

For each pair the 2d transformation that maps the parameter space of the face on the first shell to the parameter space of the face on the second shell

Returns

int

The number of overlapping face pairs, i.e. the length of the three arrays

Intersect(out GeoPoint)

Checks whether the two shells intersect each other

public bool Intersect(out GeoPoint anyIntersectionPoint)

Parameters

anyIntersectionPoint GeoPoint

Returns

bool

IsSameFace(HashSet<Edge>, HashSet<Vertex>, Face, double)

public static bool IsSameFace(HashSet<Edge> edges, HashSet<Vertex> vertices, Face fce, double precision)

Parameters

edges HashSet<Edge>
vertices HashSet<Vertex>
fce Face
precision double

Returns

bool

Result()

public Shell[] Result()

Returns

Shell[]

RoundEdges(Shell, Edge[], double)

public static Shell RoundEdges(Shell toRound, Edge[] edges, double radius)

Parameters

toRound Shell
edges Edge[]
radius double

Returns

Shell

SplitByFace(Shell, Face)

public static (Shell[] upperPart, Shell[] lowerPart) SplitByFace(Shell toSplit, Face splitBy)

Parameters

toSplit Shell
splitBy Face

Returns

(Shell[] upperPart, Shell[] lowerPart)

SplitByPlane(Shell, Plane)

public static (Shell[] upperPart, Shell[] lowerPart) SplitByPlane(Shell shell, Plane pln)

Parameters

shell Shell
pln Plane

Returns

(Shell[] upperPart, Shell[] lowerPart)

SplitNode(Node<BRepItem>, BRepItem)

Criterion whether to split a node when it contains too many leaves. The default implemenation yield a dynamically balanced tree which allows more leaves in deeper nodes.

protected override bool SplitNode(OctTree<BRepItem>.Node<BRepItem> node, BRepItem objectToAdd)

Parameters

node OctTree<BRepItem>.Node<BRepItem>

The node beeing checked

objectToAdd BRepItem

The object beeing added

Returns

bool

true, if node should be splitted, false otherwise

SplitResult()

public CompoundShape SplitResult()

Returns

CompoundShape

TryFindIntersectingEdges(IEnumerable<Edge>, out Edge, out Edge, out Edge)

Looks for three edges which share three faces. These edges probably have a common intersection point

public static bool TryFindIntersectingEdges(IEnumerable<Edge> edges, out Edge e1, out Edge e2, out Edge e3)

Parameters

edges IEnumerable<Edge>
e1 Edge
e2 Edge
e3 Edge

Returns

bool