.. role:: blue :class: blue Constructing a Patch ==================== .. _Constructing_a_Patch_: .. kernel version: 118041 The function .. code-block:: cpp MbResultType PatchShell( const MbPatchShellParams & params, c3d::SolidSPtr & result ); constructs a patch from a set of curves. A **params** object of the :blue:`MbPatchShellParams` class is the input parameter of the function and contains the following parameters required for the operation (see *op_shell_parameter.h*): - **initCurves** -- is a set of curves; - **patchValues** -- is an object of the :blue:`PatchValues` structure, which contains construction parameters; - **names** -- is the operation's namer. The :blue:`MbPatchShellParams` class contains three constructors for a set of curves, parameters, and the namer: .. code-block:: cpp MbPatchShellParams( const std::vector> & initCurves, const PatchValues & patchValues, const MbSNameMaker & names ); MbPatchShellParams( const RPArray & initCurves, const PatchValues & patchValues, const MbSNameMaker & names ); MbPatchShellParams( const RPArray & initCurves, const PatchValues & patchValues, const MbSNameMaker & names ); The function output parameter is the **result** parameter, which contains a constructed body. The function returns a result code of the operation from the :blue:`MbResultType` enumeration (see *mb_operation_result.h*). The function is declared in *action_shell.h* file. The function constructs a body formed by a face, the borders of which contain defined curves. The body will be constructed correctly if the curves of **initCurves** set connect end-to-end and form a closed contour. If all **initCurves** in the set lie in a single plane, the patch is a portion of that plane bounded by the contour formed by the curves. If all **initCurves** in the curve set lie on a single curved surface, the patch will be a portion of that surface bounded by the contour formed by the specified curves. If **initCurves** set contains a single curve, that curve is split into two segments, and the resulting patch surface is a ruled surface with two poles. A patch is constructed in a similar way when the **initCurves** set contains two curves: the patch surface will be a ruled surface with two poles. If the number of **initCurves** is three, the patch surface will be an :blue:`MbCornerSurface` constructed from the three curves and having a pole. If the number of **initCurves** is four, the patch surface will be an :blue:`MbCoverSurface` constructed by the four curves. In other cases, the construction may fail. The **patchValues** object contains information about the patch type and the self-intersection check flag. To initialize the object the following constructor of the :blue:`PatchValues` structure is set by default: .. code-block:: cpp PatchValues() : type ( ts_none ) , checkSelfInt ( false ) , mergeEdges ( true ) , tolerantData ( false ) , internalMatingType ( pmt_None ) { } where - **type** -- is the patch type; - **checkSelfInt** -- is the intersection check flag; - **mergeEdges** -- is the flag for merging similar edges (*true* -- merge similar edges); - **tolerantData** -- is the flag for building an inaccurate patch based on inaccurate input data; - **internalMatingType** -- is the conjugation type between patch parts. Used for **type** = *ts_byCurves*. The following patch types are defined for the **patchValues** object (see the :blue:`SurfaceType` enumeration): - *ts_tang* -- tangentially; - *ts_norm* -- according to a norm; - *ts_none* -- not defined; - *ts_plane* -- is a flat patch; - *ts_byCurves* -- the construction is set by conjugates for each curve. The *ts_tang* and *ts_norm* types are set when constructing a patch tangentially or normally, respectively. If the patch type *ts_plane* is set, a patch with flat edges is constructed. The *ts_byCurves* type is set if you want to build a patch with conjugation along some boundaries. In this case, for a desired :blue:`MbPatchCurve` boundary, you need to set the conjugation by the :blue:`SetMating`\() method. Fig. 1 shows eight curves on the boundary of the inner face cut. Fig. 2 shows a patch constructed from the curves shown in Fig. 1: .. figure:: /MODELER/METHODS_OF_SOLID_BUILDING/pictures/M.1.12.1.png :width: 11cm :align: center Fig. 1 .. figure:: /MODELER/METHODS_OF_SOLID_BUILDING/pictures/M.1.12.2.png :width: 11cm :align: center Fig. 2 Fig. 3 shows six curves lying on the borders of various faces produced by cutting faces with a common surface. .. figure:: /MODELER/METHODS_OF_SOLID_BUILDING/pictures/M.1.12.3.png :width: 12cm :align: center Fig. 3 If the boundary edges retain information about the cutting surface after the cut, that surface can be used to construct the patch. Fig. 4 shows an example of constructing a patch as a part of the cutting surface that formed border edges shown in Fig. 3: .. figure:: /MODELER/METHODS_OF_SOLID_BUILDING/pictures/M.1.12.4.png :width: 12cm :align: center Fig. 4 As a rule, the curves for **initCurves** set are taken from border edges. After construction, the patch is often stiched with other bodies adjacent to its borders. :blue:`PatchShell`\() function adds :blue:`MbPatchCreator` constructor into a log of the newly constructed body. :blue:`MbPatchCreator` constructor is declared in *cr_patch_creator.h* file.