CogGeneralContour ReplaceSegmentWithLineSegment Method Cognex VisionPro 9.8 SR1
Replaces ReplaceSegment with a new line segment. If StartFlags has the 'connected' bit set, then StartX and StartY are ignored. This also applies to EndFlags.

Namespace: Cognex.VisionPro
Assembly: Cognex.VisionPro.Core (in Cognex.VisionPro.Core.dll) Version: 75.0.0.0
Syntax

public CogGeneralContourSegmentIterator ReplaceSegmentWithLineSegment(
	CogGeneralContourSegmentIterator replaceSegment,
	CogGeneralContourVertexConstants startFlags,
	double startX,
	double startY,
	CogGeneralContourVertexConstants endFlags,
	double endX,
	double endY
)

Parameters

replaceSegment
Type: Cognex.VisionPro CogGeneralContourSegmentIterator

The segment to be replaced.

startFlags
Type: Cognex.VisionPro CogGeneralContourVertexConstants

Flags that specify how the start point is treated with respect to the other segments in the contour shape.

startX
Type: System Double

X-coordinate of the start point of the segment. Ignored if startFlags includes Connected.

startY
Type: System Double

Y-coordinate of the start point of the segment. Ignored if startFlags includes Connected.

endFlags
Type: Cognex.VisionPro CogGeneralContourVertexConstants

Flags that specify how the end point is treated with respect to the other segments in the contour shape.

endX
Type: System Double

X-coordinate of the end point of the segment. Ignored if endFlags includes Connected.

endY
Type: System Double

Y-coordinate of the end point of the segment. Ignored if endFlags includes Connected.

Return Value

Type: CogGeneralContourSegmentIterator

A new iterator positioned at the new segment.

Events

Event TypeReason
CogGeneralContour Changed

Fires when the segment is replaced.

The following state flags may be affected:

    Exceptions

    ExceptionCondition
    CogShapeBadContourSegConnException

    replaceSegment is the first segment and startFlags includes Connected or replaceSegment is the end segment and endFlags includes Connected.

    ArgumentException

    startFlags or endFlags include bits that are not defined in CogGeneralContourVertexConstants.

    CogShapeCoordinatesMustDifferException

    Points in the new segment are coincident.

    CogIteratorInvalidIteratorException

    replaceSegment is invalid and not the end iterator.

    CogShapeBadContourChainClosureException

    endFlags include Closed but startFlags do not include Connected ; or startFlags include Closed but endFlags do not include Connected. This error may also occur if the startFlags and endFlags are set properly but closing the chain would create a contour with only two segments.

    Remarks

    Replaces replaceSegment with a new line segment and returns a new iterator positioned at the new segment.

    If replaceSegment is Nothing or if replaceSegment.IsEnd is True, ReplaceSegmentWithLineSegment(CogGeneralContourSegmentIterator, CogGeneralContourVertexConstants, Double, Double, CogGeneralContourVertexConstants, Double, Double) behaves exactly as if AddLineSegment(CogGeneralContourSegmentIterator, CogGeneralContourVertexConstants, Double, Double, CogGeneralContourVertexConstants, Double, Double) were called with NextSegment set to Nothing.

    If startFlags includes Connected, then startX and startY are ignored. Similarly, if endFlags includes Connected, then endX and endY are ignored.

    Note: ReplaceSegmentWithLineSegment(CogGeneralContourSegmentIterator, CogGeneralContourVertexConstants, Double, Double, CogGeneralContourVertexConstants, Double, Double) can break connections and undo closed contour chains. Any CogGeneralContourSegmentIterator positioned at the replaced segment (including replaceSegment) become invalid. Other iterators are unchanged.

    See Also