Class Edge
- Namespace
- CADability
- Assembly
- CADability.dll
Edge is a abstract description of an egde on a Face. An Edge may belong to one or two faces. Edges don't exist without faces (use IGeoObject and ICurvederived classes for simple 3d curves). The Edge is defined in several ways, which are overdetermined and therfore must always be in a consistent state: It is the pur 3-dimensional curve, an ICurve, and on each Face the edge is defined as a 2-dimensional curve on the surface (see Surface), which has a 2-dimensional (u/v) coordinate system (parametric space). The Edge may be an outer or an inner edge on each face or some curve on the inside of a face (typically an outlining curve for a certain Projection). The edge may not be outside of a face.
public class Edge : ISerializable, IGeoObjectOwner, IDeserializationCallback, IComparable<Edge>, IJsonSerialize, IJsonSerializeDone, IExportStep
- Inheritance
-
Edge
- Implements
- Inherited Members
- Extension Methods
Constructors
Edge(IGeoObject, ICurve, Face, ICurve2D, bool)
Creates an edge which is the edge of two connected faces.
public Edge(IGeoObject owner, ICurve curve3d, Face primaryFace, ICurve2D curveOnPrimaryFace, bool forwardOnPrimaryFace)
Parameters
ownerIGeoObjectcurve3dICurvethe 3-dimensional curve
primaryFaceFacefirst face
curveOnPrimaryFaceICurve2D2-d curve on first face
forwardOnPrimaryFacebooltrue, if the 3d curve has the same orientation as the 2d curve on the first face (which runs counterclockwise seen from outside)
Edge(IGeoObject, ICurve, Face, ICurve2D, bool, Face, ICurve2D, bool)
Creates an edge which is the edge of two connected faces.
public Edge(IGeoObject owner, ICurve curve3d, Face primaryFace, ICurve2D curveOnPrimaryFace, bool forwardOnPrimaryFace, Face secondaryFace, ICurve2D curveOnSecondaryFace, bool forwardOnSecondaryFace)
Parameters
ownerIGeoObjectthe owner of the edge; since it belongs to two faces this is usually a Shell
curve3dICurvethe 3-dimensional curve
primaryFaceFacefirst face
curveOnPrimaryFaceICurve2D2-d curve on first face
forwardOnPrimaryFacebooltrue, if the 3d curve has the same orientation as the 2d curve on the first face (which runs counterclockwise seen from outside)
secondaryFaceFaceseconsd face
curveOnSecondaryFaceICurve2D2-d curve on second face
forwardOnSecondaryFacebooltrue, if the 3d curve has the same orientation as the 2d curve on the second face
Edge(SerializationInfo, StreamingContext)
Implements the constructor for deserialization.
protected Edge(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfocontextStreamingContext
Properties
Curve3D
Gets the 3D curve of this edge. Dont modify this curve or the edge will be in an inconsistent state.
public ICurve Curve3D { get; }
Property Value
Faces
Enumerates the faces of this edge: the PrimaryFace and, if there is one, the SecondaryFace. Faces that are null are skipped.
public IEnumerable<Face> Faces { get; }
Property Value
ForwardOnPrimaryFace
The orientation on the primary face: true if Curve3D runs in the direction of the loop of the PrimaryFace, see Forward(Face). For a seam edge (primary and secondary face are the same face) this is the orientation of the first occurrence of this edge in the loop of the face.
public bool ForwardOnPrimaryFace { get; }
Property Value
ForwardOnSecondaryFace
The orientation on the secondary face. For a seam edge (primary and secondary face are the same face) this is the orientation of the second occurrence of this edge in the loop of the face.
public bool ForwardOnSecondaryFace { get; }
Property Value
Owner
The owner of this edge as an IGeoObject, which is its PrimaryFace. Setting it is only needed while reading files.
public IGeoObject Owner { get; set; }
Property Value
PrimaryFace
The first face bounded by this edge. Every edge of a face has a primary face (only an edge that is still being constructed has none); an edge of a shell that is shared by two faces has a SecondaryFace too. For a seam edge both are the same face.
public Face PrimaryFace { get; }
Property Value
SecondaryFace
The second face bounded by this edge, or null for an open edge that belongs to a single face. For a seam edge on a periodic surface (e.g. the closing edge of a full cylinder) it is the same face as PrimaryFace.
public Face SecondaryFace { get; }
Property Value
Vertex1
The vertex at the start point of Curve3D, regardless of the orientation of the edge on its faces (see StartVertex(Face) for that). For an edge whose curve is closed, and for a pole (an edge without 3d curve, which collapses to a point), Vertex1 and Vertex2 are the same vertex. The vertices are created from the curve on first access.
public Vertex Vertex1 { get; }
Property Value
Vertex2
The vertex at the end point of Curve3D, regardless of the orientation of the edge on its faces (see EndVertex(Face) for that). For an edge whose curve is closed, and for a pole, this is the same vertex as Vertex1. The vertices are created from the curve on first access.
public Vertex Vertex2 { get; }
Property Value
Vertices
The two vertices of this edge (the same vertex twice for a closed edge).
public IEnumerable<Vertex> Vertices { get; }
Property Value
Methods
Clone()
Returns a new edge whith a clone of the 3d curve, but null references to PrimaryFace and SecondaryFace.
public Edge Clone()
Returns
- Edge
Copy of this edge
Clone(Dictionary<Vertex, Vertex>)
Clones the 3d curve and the vertices of this edge; the clone has no faces yet. A vertex found in
clonedVertices is reused, otherwise it is cloned and the pair original/clone is added to the
dictionary, so that edges of several faces that are cloned together share their vertices.
public Edge Clone(Dictionary<Vertex, Vertex> clonedVertices)
Parameters
clonedVerticesDictionary<Vertex, Vertex>maps original vertices to their clones, extended by this call
Returns
- Edge
the cloned edge without faces
CloneReplaceFace(Face, Face, bool)
Clones this edge (with a cloned 3d curve, but the same vertices, which get the clone added) and replaces the face
toReplace by replaceWith in the clone, keeping the 2d curve and the
orientation of the replaced face. With removeOtherFace the clone refers only to
replaceWith (as its primary face), otherwise it keeps the other face of this edge as well.
Used when a face is replaced by a modified copy while its neighbours stay.
public Edge CloneReplaceFace(Face toReplace, Face replaceWith, bool removeOtherFace)
Parameters
toReplaceFacethe primary or secondary face of this edge that is to be replaced
replaceWithFacethe face that takes its place
removeOtherFacebooltrue: the clone gets only the new face, false: also the other face of this edge
Returns
- Edge
the cloned edge
CloneWithVertices()
Clones the 3d curve of this edge; the clone uses the same vertices as this edge (which get the clone added to their edges) and has no faces. Without a 3d curve the clone has no vertices either.
public Edge CloneWithVertices()
Returns
- Edge
the cloned edge without faces
CommonFace(Edge, Edge)
The face both edges belong to, or null if there is none.
public static Face CommonFace(Edge edge1, Edge edge2)
Parameters
Returns
ConnectsSameSurfaces()
Returns true if the two faces of this edge lie on geometrically identical surfaces (e.g. the two halves of a cylinder split at its seam, or two coplanar faces), so that the edge is not a real edge of the shape. The result is cached. False for an open edge.
public bool ConnectsSameSurfaces()
Returns
- bool
true if both faces have the same surface
Curve2D(Face)
Returns the 2-dimensional curve of this edge in the u/v system of the surface of the given face. If this is not an edge on the given face, null will be returned.
public ICurve2D Curve2D(Face onThisFace)
Parameters
onThisFaceFaceon this face
Returns
- ICurve2D
the 2-dimensional curve
Curve2D(Face, ICurve2D[])
Returns the 2-dimensional curve of this edge in the u/v system of the surface of the given face.
If this curve has two different representations on the provided Face (which is the case for a seam
on a periodic surface) then a representation is returned, which is not in the provided array doNotReturn.
public ICurve2D Curve2D(Face onThisFace, ICurve2D[] doNotReturn)
Parameters
onThisFaceFaceFace, on which the 2d curve resides
doNotReturnICurve2D[]List of curves which should not be returned
Returns
- ICurve2D
The 2d representation of this edge or null
EndVertex(Face)
Returns the vertex at the end of this edge in the direction of the edge on the provided face, i.e. the vertex at which the edge arrives when the loop of the face is traversed counterclockwise (outline) or clockwise (hole). This is Vertex2 when Forward(Face) is true for the face, Vertex1 otherwise.
public Vertex EndVertex(Face onThisFace)
Parameters
onThisFaceFacethe face that specifies the orientation
Returns
- Vertex
the end vertex, or null when
onThisFaceis not a face of this edge
Forward(Face)
Checks the orientation of this edge. The curve of this edge (Curve3D) has a
orientation (StartPoint and EndPoint). The corresponding 2d curves on the face are also oriented,
so that seen from the outside the 2d curves are oriented counterclockwise. If the 3d curve orientation is the same as the 2d orientation on the
provided face onThisFace, then true is returned, otherwise false is returned.
public bool Forward(Face onThisFace)
Parameters
onThisFaceFaceFace, on which the orientation of the 3d curve is checked.
Returns
- bool
true, if forward oriented, false otherwise
FreeCachedMemory()
Intended to release cached data of this edge. Currently does nothing.
public void FreeCachedMemory()
GetHashCode()
public override int GetHashCode()
Returns
GetObjectData(IJsonWriteData)
Writes this edge for the JSON serialization (IJsonSerialize): its 3d curve, its faces with the 2d curves and orientations on them, and its vertices.
public void GetObjectData(IJsonWriteData data)
Parameters
dataIJsonWriteDatareceives the properties
IsConnected(Edge)
Returns true if this edge and other have a common vertex.
public bool IsConnected(Edge other)
Parameters
otherEdgethe other edge
Returns
- bool
true if the edges share a vertex
IsPartOfHole(Face)
Returns true if this edge belongs to one of the holes of onThisFace (see
HoleEdges(int)), false if it is part of the outline or does not belong to the face at all.
public bool IsPartOfHole(Face onThisFace)
Parameters
onThisFaceFacethe face to check
Returns
- bool
true if the edge bounds a hole of the face
IsTangentialEdge()
Returns true if the two faces of this edge join smoothly along it, i.e. have the same surface normal at the edge (like the edge between a fillet and the face it blends into), false for a sharp edge or an open edge. The normals are compared at the vertices and in the middle of the edge; faces on the same surface are always tangential.
public bool IsTangentialEdge()
Returns
- bool
true for a tangential edge
MakeEdge(Face, ICurve2D)
Creates an edge on onThisFace from the curve curve in the parameter (u/v)
space of its surface. The 3d curve is computed from the surface, the edge is oriented forward on the face (so
curve must run in the direction of the loop of the face) and has no secondary face. The edge is
not inserted into the loops of the face.
public static Edge MakeEdge(Face onThisFace, ICurve2D curve)
Parameters
onThisFaceFacethe face the edge belongs to
curveICurve2Dthe 2d curve of the edge on the surface of the face
Returns
- Edge
the new edge
OtherFace(Face)
Returns the other face, which contains this edge. If there is no such face, null will be returned.
public Face OtherFace(Face thisFace)
Parameters
thisFaceFaceone of the faces of this edge
Returns
- Face
the other face
OtherVertex(Vertex)
public Vertex OtherVertex(Vertex v)
Parameters
vVertexone of the vertices of this edge
Returns
- Vertex
the other vertex
Overlaps(Edge, double, out double, out double, out double, out double)
Tests whether the 3d curves of this edge and other overlap, i.e. have a common part. The common
part is returned as parameter intervals of both curves (see Overlapping(ICurve, ICurve, double, out double, out double, out double, out double)). Returns false, with
all intervals 0, when one of the edges has no 3d curve (a pole).
public bool Overlaps(Edge other, double precision, out double from, out double to, out double otherFrom, out double otherTo)
Parameters
otherEdgethe other edge
precisiondoublemaximum distance between the curves on the common part
fromdoublestart parameter of the common part on this edge
todoubleend parameter of the common part on this edge
otherFromdoublestart parameter of the common part on the other edge
otherTodoubleend parameter of the common part on the other edge
Returns
- bool
true if the edges overlap
RecalcCurve2D(Face)
Recomputes the 2d curve of this edge on onThisface by projecting Curve3D onto the
surface of the face, keeping the orientation of the edge on that face. Needed after the 3d curve or the surface has
changed. Not suitable for a seam edge, whose two 2d curves lie on the same face.
public void RecalcCurve2D(Face onThisface)
Parameters
onThisfaceFacethe primary or secondary face of this edge
Exceptions
- ApplicationException
when
onThisfaceis not a face of this edge
RecalcCurve3D()
Intended to recompute Curve3D from the surfaces of the faces. Currently does nothing.
public void RecalcCurve3D()
SameGeometry(Edge, double)
Returns true if the 3d curves of this edge and other describe the same curve within
precision, regardless of their direction.
public bool SameGeometry(Edge other, double precision)
Parameters
Returns
- bool
true if the curves coincide
SetCurve2D(Face, ICurve2D)
Sets the 2d curve for this face. Reverses the curve if the appropriate forward on this face is false
public void SetCurve2D(Face onThisFace, ICurve2D curve)
Parameters
Exceptions
SetFace(Face, ICurve2D, bool)
Attaches this edge to face: as its primary face when it has none yet, otherwise as its
secondary face. curve2D is the edge in the parameter (u/v) space of the surface of the face, in
the direction of Curve3D; forward tells whether Curve3D runs in the
direction of the loop of the face (if not, the 2d curve is reversed, so that the stored 2d curve always runs in the
direction of the loop). Used when building faces, e.g. before Set(ISurface, Edge[][], bool).
public void SetFace(Face face, ICurve2D curve2D, bool forward)
Parameters
faceFacethe face to attach to
curve2DICurve2Dthe 2d curve of the edge on the face, running in the direction of Curve3D
forwardbooltrue if the 3d curve runs in the direction of the loop of the face
Exceptions
- ApplicationException
when the edge already has two faces
SetObjectData(IJsonReadData)
Reads this edge from the JSON serialization (IJsonSerialize), the counterpart of GetObjectData(IJsonWriteData).
public void SetObjectData(IJsonReadData data)
Parameters
dataIJsonReadDatathe properties to read
StartVertex(Face)
Returns the start vertex in the direction of the edge on the provided face
public Vertex StartVertex(Face onThisFace)
Parameters
onThisFaceFaceThe face that specifies the orientation
Returns
- Vertex
The requested vertex
UseVertices(params Vertex[])
Replaces the vertices of this edge by those vertices in toUse that lie at the start and the end
point of Curve3D (within eps). A vertex that is replaced is merged into the new
one, so that its other edges refer to the new vertex too. A vertex for which there is no match is kept. Used to
connect edges of different faces at common vertices, e.g. when importing.
public void UseVertices(params Vertex[] toUse)
Parameters
toUseVertex[]the vertices to use