[ブログに戻る](/ja/blog) # Teigha BIM: 塗りつぶしパターン入門 \[パート2\]

Daniil Zhirnov 7月 18, 2017 [\#rvt](/ja/blog/tag/rvt) [\#rfa](/ja/blog/tag/rfa) [\#Example](/ja/blog/tag/example)

<a class="a2a_button_facebook"></a><a class="a2a_button_twitter"></a><a class="a2a_button_linkedin"></a>

#### レンダリング

OdGiFill特性属性が提供されている場合、対応するシェルをレンダリングする際に塗りつぶしパターンのレンダリングが実行されます。[以前の記事](https://www.opendesign.com/blog/2017/july/teigha-bim-introduction-fillpatterns-part-1)で説明したように、既存のOdBmFace-&gt;OdBmGFilling-&gt;PatternIdが存在する場合、OdGiFillはOdBmFillPatternElem::subSetAttributes(OdGiDrawableTraits\* pDrwTraits)呼び出しによって提供されます。OdGiFillは、塗りつぶしパターンをレンダリングするために必要なハッチングデータを表しますが、それだけでは不十分です。パターンを正しくレンダリングするには、OdGiFaceDataとOdGiMapperItemEntryも必要です。

概略的に、このプロセスは以下のステップに分解できます。

1\) パターンスケールを決定します。

```
double patternScal = 1.0;
if (pHatch->isDraft())
{
  if (m_pDrawCtx)
  {
    patternScal = m_pDrawCtx->annotationScale();
  }
}

```

ドラフトパターンはビューのスケールに依存します。したがって、対応するポータブル拡張機能（Portable Extension）を介して取得し、考慮に入れる必要があります。

2\) マッパーを使用すべきかどうかを決定します。

```
OdGiMapperItemEntryPtr pCurrentMapper;
if (pMapper)
{
  OdGiMapper::Projection proj = pMapper->mapper().projection();
  if (proj == OdGiMapper::kCylinder || proj == OdGiMapper::kSphere)
  {
    pCurrentMapper = pMapper;
  }
}

```

面が非平面テクスチャマッピングを必要とする場合、塗りつぶしパターンはマッパーによってテクスチャと同じ方法で処理されるべきです。

3\) 投影平面を計算し、すべての面の頂点をその平面に投影します。

![image1](/files/inline-images/image003_2.png)投影平面は点P0、2つの直交ベクトルU,Vで表され、与えられた面の3点(P0, P1, Pn-1)から計算されます。ハッチング処理は2D空間で行われるため、平面の投影が必要です。

4\) 必要に応じて、テクスチャマッピング変換を計算します。

```
OdGePoint3d origin;
OdGeVector3d U, V;
plane.get(origin, U, V);

OdGiMapperItemEntry::MapInputTriangle pts;
pts.inPt[0] = origin;
pts.inPt[1] = origin + U;
pts.inPt[2] = origin + V;

OdGiMapperItemEntry::MapOutputCoords res;
pCurrentMapper->mapCoords(pts, res);

OdGeVector2d newU = res.outCoords[1] - res.outCoords[0];
OdGeVector2d newV = res.outCoords[2] - res.outCoords[0];

OdGeMatrix2d trf;
trf[0][0] = new.x;
trf[0][1] = new.y;
trf[1][0] = new.x;
trf[1][1] = new.y;

```

マッパーが提示された場合、パターンを面に正しくマッピングするために2Dマッピング変換を使用する必要があります。

5\) 面固有のオフセットと角度でハッチデータを修正します。

```
OdGePoint2d faceFillOrigin = pFaceData->fillOrigins()[faceIndex];
OdGeVector2d faceFillDirection = pFaceData->fillDirections()[faceIndex];

patLine.m_basePoint += faceFillOrigin.asVector();
patLine.m_dLineAngle += faceFillDirection.angle();

```

面固有のオフセットと角度はOdGiFaceDataを通じて提供され、パターンを正しく描画するために考慮に入れる必要があります。

6\) 準備されたデータをハッチ描画プロシージャに送信します。

このプロシージャは2D空間でハッチ線を出力するため、それらを3D空間に変換し直してから描画する必要があります。

```
bool dash(const OdGePoint2d& _start, const OdGePoint2d& _end)
{
  OdGePoint2d start = m_Trf * _start;
  OdGePoint2d end = m_Trf * _end;

  OdGePoint3d points[2];

  points[0] = m_PlaneOrigin + start.x * m_PlaneU + start.y * m_PlaneV;
  points[1] = m_PlaneOrigin + end.x * m_PlaneU + end.y * m_PlaneV;

  m_pSimplifier->polylineProc(2, points);
  return true;
}

```

## 今すぐ始める

**ODAソフトウェアを60日間無料でお試しください。  
リスクなし、クレジットカード不要。**

[無料で試す](https://www.opendesign.com/ja/free-trial)
