IXpsOMGeometryFigure::SetSegments 메서드(xpsobjectmodel.h)

그림에서 세그먼트에 대한 세그먼트 정보 및 데이터 요소를 설정합니다.

구문

HRESULT SetSegments(
  [in] UINT32                 segmentCount,
  [in] UINT32                 segmentDataCount,
  [in] const XPS_SEGMENT_TYPE *segmentTypes,
  [in] const FLOAT            *segmentData,
  [in] const BOOL             *segmentStrokes
);

매개 변수

[in] segmentCount

세그먼트 수입니다.

이 값은 segmentTypessegmentStrokes에서 참조하는 배열의 요소 수이기도 합니다.

[in] segmentDataCount

세그먼트 데이터 포인트의 수입니다.

이 값은 segmentData에서 참조하는 배열의 요소 수이기도 합니다.

[in] segmentTypes

XPS_SEGMENT_TYPE 변수의 배열입니다. segmentCount 값은 이 배열의 요소 수를 지정합니다.

[in] segmentData

세그먼트 데이터 값의 배열입니다. segmentDataCount 값은 이 배열의 요소 수를 지정합니다.

[in] segmentStrokes

세그먼트 스트로크 값의 배열입니다. segmentCount 값은 이 배열의 요소 수를 지정합니다.

반환 값

이 메서드는 HRESULT를 반환합니다. 가능한 값에는 다음 표의 값이 포함되지만 이에 국한되지는 않습니다. 이 표에 나열되지 않은 XPS 문서 API 반환 값에 대한 자세한 내용은 XPS 문서 오류를 참조하세요.

반환 코드 Description
S_OK
메서드가 성공했습니다.
E_INVALIDARG
segmentTypes에는 인식할 수 없는 형식의 값이 포함됩니다.

또는 segmentData 배열의 항목 수가 segmentTypes 배열의 항목 수보다 큽니다.

E_POINTER
segmentTypes, segmentData 또는 segmentStrokesNULL입니다.
XPS_E_INVALID_FLOAT
segmentData 에는 무한이거나 숫자(NAN)가 아닌 FLOAT 값이 포함되어 있습니다.
XPS_E_MISSING_SEGMENT_DATA
segmentData에 전달되는 배열에는 segmentTypes에 전달된 배열보다 적은 항목이 있습니다.
XPS_E_NEGATIVE_FLOAT
segmentData에 전달되는 배열의 항목에는 음수 값이 포함되어 있지만 음수가 아닌 값이 포함되어야 합니다.

설명

기하 도형 세그먼트는 시작점, 세그먼트 형식 및 세그먼트 형식에 따라 값이 결정되는 추가 매개 변수로 설명됩니다. 첫 번째 세그먼트의 시작점에 대한 좌표는 기하 도형의 속성이며 SetStartPoint를 호출하여 설정됩니다. 각 후속 세그먼트의 시작점은 이전 세그먼트의 끝점입니다.

선 세그먼트를 정의하는 데이터 값의 수는 세그먼트 유형에 따라 달라집니다. 다음 표에서는 각 세그먼트 유형에 사용해야 하는 특정 필수 데이터 값 집합에 대해 설명합니다. segmentData 매개 변수에 전달되는 세그먼트 데이터 배열의 값은 segmentTypes 매개 변수에 전달되는 배열의 XPS_SEGMENT_TYPE 값과 일치해야 합니다. 예를 들어 첫 번째 선 세그먼트에 세그먼트 형식 값이 XPS_SEGMENT_TYPE_LINE 경우 segmentData 배열의 처음 두 데이터 값은 해당 세그먼트의 끝점의 x 및 y 좌표가 됩니다. 다음 세그먼트에 XPS_SEGMENT_TYPE_BEZIER 세그먼트 형식 값이 있는 경우 segmentData 배열의 다음 6개 값은 해당 세그먼트의 특성을 설명합니다. 기하 도형의 각 선 세그먼트에 대해 등입니다.

세그먼트 유형 필수 데이터 값
XPS_SEGMENT_TYPE_LINE XPS_SEGMENT_TYPE_LINE 그림 세그먼트의 예를 보여 주는 다이어그램 두 데이터 값:
세그먼트 선 끝점의 x 좌표입니다.
세그먼트 선 끝점의 y 좌표입니다.
XPS_SEGMENT_TYPE_ARC_LARGE_CLOCKWISE XPS_SEGMENT_TYPE_ARC_LARGE_CLOCKWISE 그림 세그먼트의 다이어그램 5가지 데이터 값:
호 끝점의 x 좌표입니다.
호 끝점의 y 좌표입니다.
x축을 따라 타원 반경의 길이입니다.
y축을 따라 타원 반경의 길이입니다.
회전 각도입니다.
XPS_SEGMENT_TYPE_ARC_SMALL_CLOCKWISE XPS_SEGMENT_TYPE_ARC_SMALL_CLOCKWISE 그림 세그먼트의 예를 보여 주는 다이어그램 5가지 데이터 값:
호 끝점의 x 좌표입니다.
호 끝점의 y 좌표입니다.
x축을 따라 타원 반경의 길이입니다.
y축을 따라 타원 반경의 길이입니다.
회전 각도입니다.
XPS_SEGMENT_TYPE_ARC_LARGE_COUNTERCLOCKWISE XPS_SEGMENT_TYPE_ARC_LARGE_COUNTERCLOCKWISE 그림 세그먼트의 다이어그램 5가지 데이터 값:
호 끝점의 x 좌표입니다.
호 끝점의 y 좌표입니다.
x축을 따라 타원 반경의 길이입니다.
y축을 따라 타원 반경의 길이입니다.
회전 각도입니다.
XPS_SEGMENT_TYPE_ARC_SMALL_COUNTERCLOCKWISE XPS_SEGMENT_TYPE_ARC_SMALL_COUNTERCLOCKWISE 그림 세그먼트의 예를 보여 주는 다이어그램 5가지 데이터 값:
호 끝점의 x 좌표입니다.
호 끝점의 y 좌표입니다.
x축을 따라 타원 반경의 길이입니다.
y축을 따라 타원 반경의 길이입니다.
회전 각도입니다.
XPS_SEGMENT_TYPE_BEZIER XPS_SEGMENT_TYPE_BEZIER 그림 세그먼트의 예를 보여 주는 다이어그램 6개의 데이터 값:
베지어 곡선의 첫 번째 제어점 x 좌표입니다.
베지어 곡선의 첫 번째 제어점의 y 좌표입니다.
베지어 곡선의 두 번째 제어점 x 좌표입니다.
베지어 곡선의 두 번째 제어점의 y 좌표입니다.
베지어 곡선 끝점의 x 좌표입니다.
베지어 곡선 끝점의 y 좌표입니다.
XPS_SEGMENT_TYPE_QUADRATIC_BEZIER XPS_SEGMENT_TYPE_QUADRATIC_BEZIER 그림 세그먼트의 예를 보여 주는 다이어그램 4개의 데이터 값:
쿼드 베지어 곡선의 제어점 x 좌표입니다.
쿼드 베지어 곡선의 제어점 y 좌표입니다.
쿼드 베지어 곡선 끝점의 x 좌표입니다.
쿼드 베지어 곡선 끝점의 y 좌표입니다.
 

그림에서 세그먼트 형식을 얻으려면 GetSegmentTypes를 호출합니다.

다음 코드 예제에서는 SetSegments에 필요한 버퍼를 만들고 채우는 한 가지 방법을 보여 줍니다.

첫 번째 코드 예제에서 AddSegmentDataToArrays 메서드는 단일 세그먼트를 설명하는 데이터 요소를 가져와 SetSegments 메서드에 필요한 세 가지 데이터 버퍼에 저장합니다. AddSegmentDataToArrays에 인수로 전달되는 데이터 버퍼는 AddSegmentDataToArrays 다음 코드 예제와 같이 호출 메서드에 의해 관리됩니다.

HRESULT
AddSegmentDataToArrays(
    XPS_SEGMENT_TYPE        segmentType,
    BOOL                    segmentStroke,
    FLOAT                   *segmentPoints,
    UINT32                  *segmentsAvailable,
    UINT32                  *segmentPointsAvailable,
    XPS_SEGMENT_TYPE        **segmentTypeBuffer,
    BOOL                    **segmentStrokeBuffer,
    FLOAT                   **segmentPointBuffer
)
/*
Description:

Populates the buffers required by IXpsOMGeometryFigure::SetSegmentData
using data and buffers provided by the calling method.

Parameters:

segmentType
    IN: XPS_SEGMENT_TYPE value that specifies the segment type for
        the current segment.

segmentStroke
    IN: BOOL value that specifies whether the current segment 
        is stroked.

*segmentPoints
    IN: pointer to an array of FLOAT values that specify the 
        segment's data points. The number of values in the array
        depend on the value of the segmentType parameter.

*segmentsAvailable
    IN: the number of values that remain unused in the
        segmentTypeBuffer and the segmentStrokeBuffer.
        This value must be >= 1 when calling the method.
    OUT:  the number of values that remain unused in the
        segmentTypeBuffer and the segmentStrokeBuffer after
        segmentType and segmentStroke have been added. If the 
        method was successful, the returned value is one less 
        than the value passed in to the method.

*segmentPointsAvailable
    IN: the number of values that remain unused in the
        segmentPointBuffer.    This value must be greater-than or equal
        to the number of points required by the segmentType value.
    OUT:  the number of values that remain unused in the
        segmentPointBuffer after the segmentPoints have been added.
        The returned value depends on the segmentType value.

**segmentTypeBuffer
    IN: the first free element in the buffer that receives the segment
        type values.
    OUT: the first free element in the buffer that receives the segment
        type values. If the method is successful, this will be the element
        after the element pointed to by this value before the method 
        was called.

**segmentStrokeBuffer
    IN: the first free element in the buffer that receives the segment
        stroke values.
    OUT: the first free element in the buffer that receives the segment
        stroke values. If the method is successful, this will be the element
        after the element pointed to by this value before the method 
        was called.

**segmentPointBuffer
    IN: the first free element in the buffer that receives the segment
        point values.
    OUT: the first free element in the buffer that receives the segment
        point values. If the method is successful, the element referenced
        by this value will depend on the segment type.

Remarks.
1) the buffers and values passed into this method are managed by
    the calling method.

2) if the value returned in segmentsAvailable is 0, segmentTypeBuffer
    and segmentStrokeBuffer point to invalid memory.

3) if the value returned in segmentPointsAvailable is 0, segmentPointBuffer
    point to invalid memory.

*/
{
    HRESULT hr = S_OK;

    // test to see if there is sufficient space in the 
    // segmentTypeBuffer and the segmentStrokeBuffer before
    // proceeding
    if (*segmentsAvailable == 0)
    {
        hr = HRESULT_FROM_WIN32(ERROR_MORE_DATA);
    }

    if (SUCCEEDED(hr))
    {
        // process the data based on the segment type
        switch (segmentType) 
        {
            case    XPS_SEGMENT_TYPE_ARC_LARGE_CLOCKWISE:
            case    XPS_SEGMENT_TYPE_ARC_LARGE_COUNTERCLOCKWISE:
            case    XPS_SEGMENT_TYPE_ARC_SMALL_CLOCKWISE:
            case    XPS_SEGMENT_TYPE_ARC_SMALL_COUNTERCLOCKWISE:
                if (*segmentPointsAvailable >= 5) 
                {
                    // 5 data points
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<arc end point (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<arc end point (y)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<arc radius (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<arc radius (y)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<arc angle
                    *segmentPointsAvailable -= 5;
                }
                else
                {
                    hr = HRESULT_FROM_WIN32(ERROR_MORE_DATA);
                }
                break;
            case    XPS_SEGMENT_TYPE_BEZIER:
                if (*segmentPointsAvailable >= 6) 
                {
                    // 6 data points
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<control point 1 (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<control point 1 (y)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<control point 2 (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<control point 2 (y)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<end point (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<end point (y)
                    *segmentPointsAvailable -= 6;
                }
                else
                {
                    hr = HRESULT_FROM_WIN32(ERROR_MORE_DATA);
                }
                break;
            case    XPS_SEGMENT_TYPE_LINE:
                if (*segmentPointsAvailable >= 2) 
                {
                    // 2 data points
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<end point (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<end point (y)
                    *segmentPointsAvailable -= 2;
                }
                else
                {
                    hr = HRESULT_FROM_WIN32(ERROR_MORE_DATA);
                }
                break;
            case    XPS_SEGMENT_TYPE_QUADRATIC_BEZIER:
                if (*segmentPointsAvailable >= 4) 
                {
                    // 4 data points
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<control point 2 (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<control point 2 (y)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<end point (x)
                    *(*segmentPointBuffer)++ = *segmentPoints++; //<end point (y)
                    *segmentPointsAvailable -= 4;
                }
                else
                {
                    hr = HRESULT_FROM_WIN32(ERROR_MORE_DATA);
                }
                break;
            default:
                // unrecognized segment type
                hr = E_UNEXPECTED;
                break;
        }

    }

    if (SUCCEEDED(hr))
    {
        // Copy segment type and segment stroke values
        // to array and decrement number of array values
        // that remain unused.
        //
        // The space available for these operations was
        // tested at the beginning of the method.
        *(*segmentTypeBuffer)++ = segmentType;
        *(*segmentStrokeBuffer)++ = segmentStroke;
        *segmentsAvailable--;
    } 

    return hr;
}

이 코드 예제에서 UpdateSegmentDataSetSegments 메서드에 필요한 데이터 버퍼를 만들고 이전 코드 예제에서 AddSegmentDataToArrays 메서드를 호출하여 세그먼트 데이터로 채웁니다. 버퍼가 채워지면 이 데이터를 기하 도형에 추가하기 위해 SetSegments 가 호출됩니다.

참고 실제 세그먼트 데이터는 이러한 코드 예제에 표시되지 않습니다.

 
HRESULT
UpdateSegmentData (
    IXpsOMGeometryFigure    *geometryFigure,
    UINT32                  segmentCount,
    UINT32                  segmentDataCount
)
/*
    Note that this method is not complete and only includes
    the code necessary to show how the SetSegments call is used.

    In this sample, the geometryFigure, segmentCount, and
    segmentDataCount values are assumed to have been initialized
    outside of this example.
*/
{
    HRESULT             hr = S_OK;
    XPS_SEGMENT_TYPE    segmentType = (XPS_SEGMENT_TYPE)0;
    BOOL                segmentStroke = FALSE;
    FLOAT               segmentPoints = 0;
    UINT32              segmentsAvailable = 0;
    UINT32              segmentPointsAvailable = 0;
    // these buffers are sized and allocated based on 
    //    the segment data to store.
    XPS_SEGMENT_TYPE    *segmentTypeBuffer = NULL;
    BOOL                *segmentStrokeBuffer = NULL;
    FLOAT               *segmentPointBuffer = NULL;

    XPS_SEGMENT_TYPE    *nextSegmentTypeValue = NULL;
    BOOL                *nextSegmentStrokeValue = NULL;
    FLOAT               *nextSegmentPointValue = NULL;

    // segment data is created outside of this example

    // allocate buffers as required using information 
    // from segment data. This can be dynamic or static
    // depending on how the segment information is managed.
    // This example assumes that the segment information 
    // does not change during this method.

    // initialize "next" pointers to point to the first
    // element in each array.
    nextSegmentTypeValue = segmentTypeBuffer;
    nextSegmentStrokeValue = segmentStrokeBuffer;
    nextSegmentPointValue = segmentPointBuffer;

    // for each segment in the figure, add the 
    // segment data to the buffers

        hr = AddSegmentDataToArrays(
                segmentType,
                segmentStroke,
                &segmentPoints,
                &segmentsAvailable,
                &segmentPointsAvailable,
                &nextSegmentTypeValue,
                &nextSegmentStrokeValue,
                &nextSegmentPointValue);
        
    if (SUCCEEDED(hr))
    {
        // set segment data
        hr = geometryFigure->SetSegments (
            segmentCount,
            segmentDataCount,
            segmentTypeBuffer,
            segmentPointBuffer,
            segmentStrokeBuffer);
    }
    // clean up buffers

    return hr;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 7, Windows Vista SP2 및 Windows Vista용 플랫폼 업데이트 [데스크톱 앱 | UWP 앱]
지원되는 최소 서버 Windows Server 2008 R2, Windows Server 2008 SP2 및 Windows Server 2008용 플랫폼 업데이트 [데스크톱 앱 | UWP 앱]
대상 플랫폼 Windows
헤더 xpsobjectmodel.h

추가 정보

GetSegmentTypes

IXpsOMGeometryFigure

XML Paper Specification

XPS 문서 오류

XPS_SEGMENT_TYPE