Close

Relief for ODA Team in Ukraine

Learn more
ODA PRC SDK
Sample Console Application that Illustrates Creation of a .prc File with Different Entities

Summary

ODA Product: ODA PRC SDK
Sample Name: OdPrcCreate
Categories: C++ / Beginner, Advanced / Working with .prc files / Android, iOS, macOS, Linux, Windows
Source Code Location: CommonApplications/Prc/Examples/OdPrcCreate

Description

A console sample application which illustrates creating entities of different types in a .prc file:

  • Boundary representation entities.
  • Wire body entities.
  • Markup entities.
  • Tessellation entities.

It also contains sample code for creating a .prc file, adding new model, schema data, creating and adding new file structures, global data sections and other complex .prc file objects.

Run Sample Application

To run the OdPrcCreate sample application, please do the following:

  1. Open the terminal window and go to the directory where the sample binary file is allocated:
    • For Windows® platforms: <PRC_DIR>\exe\<version>
    • For Non-Windows platforms: <PRC_DIR>/bin/<version>

    <PRC_DIR> is a directory where you unpacked the PRC SDK archive.

    To determine your <version> parameter, please see the appropriate section in the Download ODA PRC SDK topic.

  2. Run the sample with appropriate arguments:
    
                OdPrcCreate <example> <filename>
              
    example The name of one of the available examples. See the full list of examples below.
    filename A full path to the output .prc file to create. Created file can be opened with OdaPrcApp.

Predefined names of examples are listed in tables below.

Boundary Representation Entities
Example name Description
BrepSphere Sphere Brep export example
BrepBox Box Brep export example
BrepModelSphere Brep model filled with a sphere example
BrepModelCylinder Brep model filled with a cylinder example
BrepModelCone Brep model filled with a cone example
BrepModelRuled Brep model filled with a ruled surface example
BrepModelExtrusion Brep model filled with an extruded surface example
BrepModelFromCurves Brep model filled with a curved surface example
BrepModelRevolution Brep model filled with a revolution surface example
BrepModelCylindrical Brep model filled with a cylindrical surface example
BrepModelNURBS Brep model filled with a NURBS surface example
BrepModelTorusT1 Brep model filled with a torus of type1 example
BrepModelTorusT2 Brep model filled with a torus of type2 example
BrepModelOffset Brep model filled with an offset surface example
BrepModelTransform Brep model filled with a transform surface example
BrepModelPlane Brep model filled with a plane example
BrepModelBlend01 Brep model filled with a Blend01 surface example
BrepModelBlend02 Brep model filled with a Blend02 surface example
BrepModelBlend03 Brep model filled with a Blend03 surface example
BrepModelConeWithLoops Brep model filled with srfCone example with loops
AllBrepModelExamples Brep model filled with all surfaces example
Representation Item Entities
Example name Description
RepresentationItemPolyWire Representation item polyWire example
RepresentationItemPointSet Representation item PointSet example
RepresentationItemPolyBrepModel Representation item PolyBrepModel example
RepresentationItemSet Representation item with all RI type example
TessObjectTexture Textured PolyBrepModel textured example
TessObjectTexture Textured PolyBrepModel textured example
BrepObjectMaterial Brep with material model filled with srfPlane example
BoxByVerticesExample Brep box example generated by list of vertices
PyramidByVerticesExample Brep pyramid example generated by list of vertices
TqsSolidByVerticesExample Some Brep solid example generated by list of vertices
ManyTqsSolidByVerticesExample Many Brep solids example generated by list of vertices

See also:

Work with Representation Entities
Wire Topology Entities
Example name Description
SingleWireBodyCrvLine Single wire body filled with CrvLine example
SingleWireBodyCrvCircle Single wire body filled with CrvCircle example
SingleWireBodyCrvNURBS Single wire body filled with CrvNURBS example
SingleWireBodyCrvPolyLine Single wire body filled with CrvPolyLine example
SingleWireBodyCrvHyperbola Single wire body filled with CrvHyperbola example
SingleWireBodyCrvParabola Single wire body filled with CrvParabola example
SingleWireBodyCrvEllipse Single wire body filled with CrvEllipse example
SingleWireBodyCrvOnSurf Single wire body filled with CrvOnSurf example
SingleWireBodyCrvHelixT0 Single wire body filled with CrvHelixT0 example
SingleWireBodyCrvHelixT1 Single wire body filled with CrvHelixT1 example
SingleWireBodyCrvIntersection Single wire body filled with CrvIntersection example
SingleWireBodyCrvBlend02Boundary Single wire body filled with CrvBlend02Boundary example
SingleWireBodyCrvComposite Single wire body filled with CrvComposite example
SingleWireBodyCrvTransform Single wire body filled with CrvTransform example
SingleWireBodyCrvOffset Single wire body filled with CrvOffset example
SingleWireBodyCrvEquation Single wire body filled with CrvEquation example
SingleWireBodyCrvPolyLine2d Single wire body filled with CrvPolyLine2d example
SingleWireBodyCrvEquation2d Single wire body filled with CrvEquation2d example
SingleWireBodyCrvNURBS2d Single wire body filled with CrvNURBS2d example
SingleWireBodyCrvComposite2d Single wire body filled with CrvComposite2d example
SingleWireBodyCrvTransform2d Single wire body filled with CrvTransform2d example
SingleWireBodyCrvLine2d Single wire body filled with CrvLine2d example
SingleWireBodyCrvCircle2d Single wire body filled with CrvCircle2d example
SingleWireBodyCrvHyperbola2d Single wire body filled with CrvHyperbola2d example
SingleWireBodyCrvParabola2d Single wire body filled with CrvParabola2d example
SingleWireBodyCrvEllipse2d Single wire body filled with CrvEllipse2d example
AllSingleWireBodies Single wire body filled with all curves example
WireTessWithFlags 3D polywire with flags
Markup Entities

Working with markup entities is implemented in the markupExample() function in MarkupExample.cpp. This function has four parameters:

  • pPrcStream — A pointer to a .prc stream buffer used for writing data to the file.
  • mode — Example mode, determining which example should be executed.
  • pH — A reference to the ODA Platform application host service, providing platform-dependant implementation of database operations.
  • pPrcHost — A reference to the ODA PRC SDK application host service, providing platform-dependant implementation of operations with .prc files.

The common algorithm is described below:

  1. Create extents for a part definition boundary box.
  2. Create prc model data.
  3. Get the file structure (currently only one file structure is created at the previous step).
  4. Create root product occurrence and add it to the file structure.
  5. Get an array of child occurrences (as an object IDs array). At this moment the array is empty.
  6. Set root product occurrence as a start for the model file data.
  7. Set root product occurrence for the file structure.
  8. Create a new product occurrence with markup common data.
  9. Add newly created product occurrence to the child product occurrences array.
  10. Create markup and leader of specified type.
  11. Fill markup topology.
  12. Write the .prc file contents to a specified stream.

Creating .prc model data for markup is implemented in the CreateModelForMarkup() function:

  1. Create .prc file object.
  2. Set .prc file versions.
  3. Generate unique identifier for a file structure.
  4. Initialize model file data (unit from external CAD application flag and unit value).
  5. Create file structures section.
  6. Create a new file structure, generate its UID and add it to the .prc file.
  7. Create file structure global data section.
  8. Set tessellation parameters: chord height ration and tessellation angle.
  9. Set version for the newly created file section.

The function CreateTopologyCommonForMarkup() creates a new product occurrence with markup common topology data. It takes two parameters:

  • pFile — A pointer to the .prc file object.
  • extents — A reference to the extents object to set the bounding box for the part definition.

Steps:

  1. Create new part definition and add it to the file structure.
  2. Create new product definition and set a reference to the created part definition for it.
  3. Create topology context (exact geometry section) and add it to the file structure.
  4. Create bounding box for the part definition based on a specified extents.
  5. Specify the color of the exact geometry and add it to the file structure global data.
  6. Specify font parameters and add it to the file structure global data.
  7. Add the ID of the created part definition to the file structure tree.

To create a markup entity and fill its topology, the FillTopoMarkups() function is used. The function accepts the following input data:

  • newStructure — A reference to an appropriate file structure.
  • newProductOccurrence — A reference to an appropriate product occurrence.
  • mTess — Markup tessellation data.
  • type — Markup entity type.
  • subtype — Markup entity subtype.
  • arr_leader — Markup Leaders.
  • name — Markup entity name.

The algorithm implemented in the FillTopoMarkups() function includes the following operations:

  1. Add markup leader IDs to the product occurrence markup leader IDs array. Leaders are added to the file structure.
  2. Add markup leader tessellation data to the file structure tessellation.
  3. Create a new instance of OdPrcMarkup class and add it to the file structure.
  4. Set markup attributes (name, type, tessellation data).
  5. Add leaders to the markup.
  6. The ID of the newly created markup is added to the product occurrence markup IDs array (storing all markup data for the product occurrence is implemented in the OdPrcMarkup class).
  7. Create annotation items for the markup and set its attributes.
  8. Link created annotation item with the markup by specifying the markup ID.
  9. Add annotation item to the file structure and product occurrence annotation item IDs.
  10. Add markup tessellation data to the file structure tessellation.
Example name Description
PlainTextMarkup Markup example with plain text type.
DistanceDimensionMarkup Markup example with distance dimension type
DimensionRadius Markup markup example with dimension radius type
DiameterDimension Markup markup example with diameter dimension type
TangentDiameterDimension Markup markup example with tangent diameter dimension type
CylinderDiameterDimension Markup markup example with cylinder diameter dimension type
LengthDimension Markup markup example with length dimension type
AngleDimension Markup markup example with angle dimension type
DatumIdentifier Markup markup example with datum identifier type
DatumTarget Markup markup example with datum target type
GDTMarkup Markup example with geometric dimensioning and tolerance type
RoughnessMarkup Markup example with roughness type
TableMarkup Markup example with table type
MarkupViewExample View example with brep cylinder and markups
MarkupAnnotationExample Annotation example
AllMarkupExamples All markup examples

See also:

Work with Markup Entities
Other Entities
Example name Description
CreateComplexExample Example with complex topology
MeshBox Box as mesh export example
TriangleFan Triangle fan export example
TriangleStripe Triangle stripe export example
TessCombination Combination of triangle stripe and triangle fan example
TessExample2 Many boxes as one prc tessellation per box export example
TessExample1 Many boxes as single prc tessellation export example
Entities with Attributes
Example name Description
AttributeInt Create sphere and write integer attribute in it
AttributeTimeStamp Create sphere and write time stamp attribute in it
AttributeString Create sphere and write string attribute in it
AttributeDouble Create sphere and write double attribute in it

See also:

ODA PRC SDK Sample Applications
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.