Close

Relief for ODA Team in Ukraine

Learn more
ODA PRC SDK
Create a Markup Tessellation
To create a markup tessellation, create an instance of the OdPrcMarkupTess class:

      OdPrcMarkupTessPtr mTess = OdPrcMarkupTess::createObject();
    

The next steps are to create and fill the markup tessellation buffer:

  1. Create buffer by creating a color tessellation entity (this entity will be the head of the list). Then set the color:
    
              OdPrcMarkupTessBufPtr pFirstMkpTess = OdPrcMarkupTessBufColor::createObject();
              OdPrcRgbColor greenCol;
              greenCol.set(0, 1, 0);
              ((OdPrcMarkupTessBufColorPtr &) pFirstMkpTess)->setColor(greenCol);
            
  2. Add other tessellation entities to the buffer (font, matrix, text, polyline, etc.):
    
              OdPrcMarkupTessBufPtr pCurMkpTess = pFirstMkpTess->setNext(OdPrcMarkupTessBufFont::createObject());
              OdPrcFontKeysSameFont font;
              font.setFontName("Arial");
              font.setCharSet(0);
              font.fontKeys().resize(1);
              font.fontKeys()[0].font_size = 5;
              font.fontKeys()[0].attributes = 1;
              ODA_VERIFY(((OdPrcMarkupTessBufFontPtr &) pCurMkpTess)->setFont(font) == eOk);
    
              pCurMkpTess = pCurMkpTess->setNext(OdPrcMarkupTessBufMatrix::createObject());
              OdGePoint3d origP(3, 3, 0);
              ((OdPrcMarkupTessBufMatrixPtr &) pCurMkpTess)->setMatrix(OdGeMatrix3d::translation(origP.asVector()));
              OdPrcMarkupTessBufTextPtr pBufText = OdPrcMarkupTessBufText::createObject();
              ODA_VERIFY(pBufText->setText("Markup with Text type", 20, 4) == eOk);
              ((OdPrcMarkupTessBufMatrixPtr &) pCurMkpTess)->setNextInBlock(pBufText);
    
              pCurMkpTess = pCurMkpTess->setNext(OdPrcMarkupTessBufPolyline::createObject());
              OdGePoint3dArray polyLine;
              polyLine.resize(6);
              polyLine[0].set(0, 0, 0);
              polyLine[1].set(1, 1, 0);
              polyLine[2].set(25, 1, 0);
              polyLine[3].set(25, 7, 0);
              polyLine[4].set(1, 7, 0);
              polyLine[5].set(1, 1, 0);
              ODA_VERIFY(((OdPrcMarkupTessBufPolylinePtr &) pCurMkpTess)->setPoints(polyLine) == eOk);
            
  3. Apply the created buffer to the markup tessellation object:

        ODA_VERIFY(mTess->setFromOdPrcMarkupTessBuf(pFirstMkpTess, pCurFS) == eOk);
      

Assume that pCurFS is a file structure object, which contains the markup.

According to the source code fragment above, the created markup contains:

  • Color entity
  • Font entity
  • Matrix mode block:
    • Transformation matrix
    • Text entity
  • Polyline consisting of 6 points

The markup tessellation buffer will have the following structure:

Markup Tessellation Buffer

Specify other tessellation attributes if needed (for example, label text):


        mTess->setLabel("test");        
      

As a result of executing the source code above, a plain text markup will be created.

Plain Text Markup Example

Create Markup Leader Tessellations

As in the case of creating a markup tessellation, use the same approach to create a markup leader tessellation:
  1. Create an OdPrcMarkupLeader object:
    
              OdPrcMarkupLeaderPtr leader = OdPrcMarkupLeader::createObject();
            
  2. Create and add graphical data for the leader if needed:
    
              OdPrcGraphics graph;
              leader->graphics() = graph;
            
  3. Create and fill the markup tessellation buffer (contains color, polyline tessellation entity, etc.):
    
              OdPrcMarkupTessBufPtr pFirstMkpTess = OdPrcMarkupTessBufColor::createObject();
              OdPrcRgbColor blackCol;
              blackCol.set(0, 0, 0);
              ((OdPrcMarkupTessBufColorPtr &) pFirstMkpTess)->setColor(blackCol);
    
              OdPrcMarkupTessBufPtr pCurMkpTess = pFirstMkpTess->setNext(OdPrcMarkupTessBufPolyline::createObject());
              OdGePoint3dArray arrPnts;
              arrPnts.resize(2);
              arrPnts[0].set(-1.9, -1, 0);
              arrPnts[1].set(-3.7, -3.8, 0);
              ODA_VERIFY(((OdPrcMarkupTessBufPolylinePtr &) pCurMkpTess)->setPoints(arrPnts) == eOk);
            
  4. Create the markup tessellation object and apply the buffer to it:
    
              OdPrcMarkupTessPtr mTess = OdPrcMarkupTess::createObject();
              ODA_VERIFY(mTess->setFromOdPrcMarkupTessBuf(pFirstMkpTess, pCurFS) == eOk);
            
    The pCurFS variable contains a file structure object where the tessellation should be added.
  5. Set attributes of the created OdPrcMarkupTess object (for example, label text):
    
              mTess->setLabel("test");
            
  6. Add the tessellation object to the leader and then add the created leader to the markup's leader array:
    
              leader->tessellation() = mTess;
              leaders.push_back(leader);
            

Creation of another markup leader can be done the same way:


      leader = OdPrcMarkupLeader::createObject();
      leader->graphics() = graph;

      pFirstMkpTess = OdPrcMarkupTessBufColor::createObject();
      ((OdPrcMarkupTessBufColorPtr &) pFirstMkpTess)->setColor(blackCol);

      pCurMkpTess = pFirstMkpTess->setNext(OdPrcMarkupTessBufPolyline::createObject());
      arrPnts[0].set(1.9, -1, 0);
      arrPnts[1].set(3.7, -3.8, 0);
      ODA_VERIFY(((OdPrcMarkupTessBufPolylinePtr &) pCurMkpTess)->setPoints(arrPnts) == eOk);

      mTess = OdPrcMarkupTess::createObject();
      ODA_VERIFY(mTess->setFromOdPrcMarkupTessBuf(pFirstMkpTess, pCurFS) == eOk);
      mTess->setLabel("test");

      leader->tessellation() = mTess;
      leaders.push_back(leader);
    

The previous code fragments create two leaders for an angle dimension markup (as an illustration, the left part of the picture below represents the markup tessellation structure at a low-level, as code and coordinate arrays):

Angle Dimension Markup Leader Tessellation Structure
Angle Dimension Markup Visualization

See Also

Work with Representation Entities
Overview of Markup Tessellation
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.