Interface PrimitiveManagerInterface

The PrimitiveManagerInterface interface is the central point used to render primitive elements, such as points, boxes, lines and a rectangle.

This interface holds the primitive elements interfaces and the materials that are used by these primitive elements.

3D Points, 3D lines, 3D boxes and a single 2D rectangle can be rendered on top of the DMU, with a rendering hint depending on the relative depth between the 3D primitives and the geometries. This interface accessed through the InfiniteEngineInterface.getPrimitiveManager function. The colors of the 3D primitive are handled by the PrimitiveManagerMaterialInterface, accessed through getPrimitiveMaterialManager. Materials are accessed by their ids, and modified by their ids. 3D primitives are rendered colored with their material id, and not directly from a color.

3D Points

The rendering can be enriched with 3D points rendered on top of the geometries, with a rendering hint telling if the point is over or under a geometry.

point display
Creating a point may be done with the following :
/** 
* Sample to explain how to create 3d points on top of the rendering (PrimitiveManagerPointInterface).
*/
import { InfiniteEngineInterface, PrimitiveManagerMaterialInterface, PrimitiveManagerPointInterface, Vector4, Vector3 } from 'generated_files/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;
// created previously, the point position
let lPointPosition : Vector3;

// the material for the inner point color
let lInnerPointColorMaterial : number = -1;
// the material for the outer point color
let lOuterPointColorMaterial : number = -1;
// the primitive material manager
const lPrimitiveMaterialManager : PrimitiveManagerMaterialInterface = lInfiniteEngine.getPrimitiveManager().getPrimitiveMaterialManager();
// the point manager
const lPointManager : PrimitiveManagerPointInterface = lInfiniteEngine.getPrimitiveManager().getPointManager();

// inner point color is white opaque (1 as last parameter)
const lInnerPointColor : Vector4 = new Vector4(1, 1, 1, 1);
// outer point color is black semi transparent (0.5 as last parameter)
const lOuterPointColor : Vector4 = new Vector4(0, 0, 0, 0.5);

// create materials
lInnerPointColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lInnerPointColor);
lOuterPointColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lOuterPointColor);

// and create the point
const lPointId : number = lPointManager.createPoint(
// position
lPointPosition,
// sizes (quite a large point :) )
40,
35,
// colors
lInnerPointColorMaterial,
lOuterPointColorMaterial
);

console.log('Point id is ' + lPointId);

3D Lines

The rendering can be enriched with 3D lines rendered on top of the geometries.

line display

Creating a line may be done with the following :

/** 
* Sample to explain how to create 3d lines on top of the rendering (PrimitiveManagerLineInterface).
*/
import { InfiniteEngineInterface, PrimitiveManagerMaterialInterface, PrimitiveManagerLineInterface, Vector4, Vector3 } from 'generated_files/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;
// created previously, the segment point position 1
let lLinePosition1 : Vector3;
// created previously, the segment point position 2
let lLinePosition2 : Vector3;

// the material for the line color
let lLineColorMaterial : number = -1;
// the primitive material manager
const lPrimitiveMaterialManager : PrimitiveManagerMaterialInterface = lInfiniteEngine.getPrimitiveManager().getPrimitiveMaterialManager();
// the line manager
const lLineManager : PrimitiveManagerLineInterface = lInfiniteEngine.getPrimitiveManager().getLineManager();
// line color is white opaque (1 as last parameter)
const lLineColor : Vector4 = new Vector4(1, 1, 1, 1);

// create material
lLineColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lLineColor);

// and create the line
const lLineId : number = lLineManager.createLine(
// segment extents
lLinePosition1,
lLinePosition2,
lLineColorMaterial,
// line width
5
);

console.log('Line id is ' + lLineId);

3D Boxes

The rendering can be enriched with 3D boxes rendered on top of the geometries, with a rendering hint telling if the edge/face is over or under a geometry.

box display
Creating a box may be done with the following :
/** 
* Sample to explain how to create 3d boxes on top of the rendering (PrimitiveManagerBoxInterface).
*/
import { InfiniteEngineInterface, PrimitiveManagerMaterialInterface, PrimitiveManagerBoxInterface, Vector4, Vector3 } from 'generated_files/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;
// created previously, the box center
let lBoxCenter : Vector3;
// created previously, the box half extent in x,y,z
let lBoxHalfExtent : Vector3;

// the material edges of the box
let lEdgeColorMaterial : number = -1;
// the material for the faces of the box
let lFaceColorMaterial : number = -1;
// the primitive material manager
const lPrimitiveMaterialManager : PrimitiveManagerMaterialInterface = lInfiniteEngine.getPrimitiveManager().getPrimitiveMaterialManager();
// the box manager
const lBoxManager : PrimitiveManagerBoxInterface = lInfiniteEngine.getPrimitiveManager().getBoxManager();

// face color is white opaque (1 as last parameter)
const lFaceColor : Vector4 = new Vector4(1, 1, 1, 1);
// edge color is red semi transparent (0.5 as last parameter)
const lEdgeColor : Vector4 = new Vector4(1, 0, 0, 0.5);

// create materials
lFaceColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lFaceColor);
lEdgeColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lEdgeColor);

// and create the box
const lBoxId : number = lBoxManager.createBox(
// center, half extent
lBoxCenter,
lBoxHalfExtent,
// colors
lEdgeColorMaterial,
lFaceColorMaterial,
// line width
5
);

console.log('Box id is ' + lBoxId);

2D rectangle (rubber band)

The rendering can be enriched with a single 2D rectangle rendered on top of the geometries. The color cannot be changed.

rubber band display
Rendering a 2D rectangle may be done with the following :
/** 
* Sample to explain how to create a 2D rectangle on top of the rendering (PrimitiveManagerRubberBandInterface).
*/
import { InfiniteEngineInterface, PrimitiveManagerRubberBandInterface, Vector2, Rectangle } from 'generated_files/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;
const lSelectionRectangle : Rectangle = new Rectangle();

// created previously, the rectangle extents
let lRectanglePosition1 : Vector2;
let lRectanglePosition2 : Vector2;

// the rubber band manager
const lRubberBandManager : PrimitiveManagerRubberBandInterface = lInfiniteEngine.getPrimitiveManager().getRubberBandManager();

// compute rectangle geometry from the 2 extent points
lSelectionRectangle.x = Math.min(lRectanglePosition1.x, lRectanglePosition2.x);
lSelectionRectangle.y = Math.min(lRectanglePosition1.y, lRectanglePosition2.y);
lSelectionRectangle.width = Math.abs(lRectanglePosition1.x - lRectanglePosition2.x);
lSelectionRectangle.height = Math.abs(lRectanglePosition1.y - lRectanglePosition2.y);

// make sure rectangle is correct
console.assert(lSelectionRectangle.isValid() && (!lSelectionRectangle.isEmpty()));

// set rectangle and display it
lRubberBandManager.setRubberBandRectangle(lSelectionRectangle);
lRubberBandManager.setRubberBandVisible(true);


3D Primitives

interface PrimitiveManagerInterface {
    fromJSON(pPrimitiveData): boolean;
    getBoxManager(): PrimitiveManagerBoxInterface;
    getLineManager(): PrimitiveManagerLineInterface;
    getPointManager(): PrimitiveManagerPointInterface;
    getPrimitiveMaterialManager(): PrimitiveManagerMaterialInterface;
    getRubberBandManager(): PrimitiveManagerRubberBandInterface;
    removeAllPrimitives(): void;
    toJSON(pKey?): Object;
}

Methods

  • Sets the content of the PrimitiveManagerInterface from a former call to toJSON.

    PrimitiveManagerInterface parameters (boxes, points, lines and materials definitions) are streamed, using the following schema :

    {
    "$defs": {
    "primitivebox": {
    "additionalProperties": false,
    "properties": {
    "boxmaterial": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "center": {
    "$ref": "#/$defs/vec3"
    },
    "halfextent": {
    "$ref": "#/$defs/vec3extent"
    },
    "id": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "linematerial": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "linewidth": {
    "exclusiveMinimum": 0,
    "type": "number"
    },
    "visible": {
    "type": "boolean"
    }
    },
    "required": [
    "id",
    "visible",
    "linematerial",
    "boxmaterial",
    "linewidth",
    "center",
    "halfextent"
    ],
    "title": "Primitive Line definition",
    "type": "object"
    },
    "primitiveline": {
    "additionalProperties": false,
    "properties": {
    "id": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "material": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "pointa": {
    "$ref": "#/$defs/vec3"
    },
    "pointb": {
    "$ref": "#/$defs/vec3"
    },
    "visible": {
    "type": "boolean"
    },
    "width": {
    "exclusiveMinimum": 0,
    "type": "number"
    }
    },
    "required": [
    "id",
    "visible",
    "material",
    "width",
    "pointa",
    "pointb"
    ],
    "title": "Primitive Line definition",
    "type": "object"
    },
    "primitivematerial": {
    "additionalProperties": false,
    "properties": {
    "color": {
    "description": "A RGBA color in the form #XXXXXXXX",
    "example": "#ABABABAB",
    "maxLength": 20,
    "minLength": 9,
    "pattern": "^\\s*#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})\\s*$",
    "type": "string"
    },
    "id": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    }
    },
    "required": [
    "id",
    "color"
    ],
    "title": "Material definition",
    "type": "object"
    },
    "primitivepoint": {
    "additionalProperties": false,
    "properties": {
    "id": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "innermaterial": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "innersize": {
    "minimum": 0,
    "type": "number"
    },
    "outermaterial": {
    "description": "A strictly positive integer",
    "example": 3,
    "minimum": 1,
    "type": "integer"
    },
    "position": {
    "$ref": "#/$defs/vec3"
    },
    "size": {
    "exclusiveMinimum": 0,
    "type": "number"
    },
    "visible": {
    "type": "boolean"
    }
    },
    "required": [
    "id",
    "visible",
    "innermaterial",
    "outermaterial",
    "innersize",
    "size",
    "position"
    ],
    "title": "Primitive Point definition",
    "type": "object"
    },
    "primitives": {
    "additionalProperties": false,
    "properties": {
    "boxes": {
    "items": {
    "$ref": "#/$defs/primitivebox"
    },
    "type": "array"
    },
    "lines": {
    "items": {
    "$ref": "#/$defs/primitiveline"
    },
    "type": "array"
    },
    "materials": {
    "items": {
    "$ref": "#/$defs/primitivematerial"
    },
    "type": "array"
    },
    "points": {
    "items": {
    "$ref": "#/$defs/primitivepoint"
    },
    "type": "array"
    },
    "type": {
    "const": "primitives",
    "type": "string"
    },
    "version": {
    "description": "Define the version of the object",
    "example": 1,
    "type": "integer"
    }
    },
    "required": [
    "type"
    ],
    "title": "Primitives definition",
    "type": "object"
    },
    "vec3": {
    "description": "Define the coordinates [x,y,z] of a point / vector",
    "items": {
    "type": "number"
    },
    "maxItems": 3,
    "minItems": 3,
    "title": "3D Vector definition",
    "type": "array"
    },
    "vec3extent": {
    "description": "Define the coordinates [x,y,z] of an extent vector",
    "items": {
    "minimum": 0,
    "type": "number"
    },
    "maxItems": 3,
    "minItems": 3,
    "title": "3D Vector extent definition",
    "type": "array"
    }
    },
    "$ref": "#/$defs/primitives",
    "$schema": "https://json-schema.org/draft-07/schema#"
    }

    This schema may evolve in the future.

    Parameters

    • pPrimitiveData: string | Object
      in
      Internal InfiniteEngineInterface data to set.

    Returns boolean

    true if the data is set.

  • Removes all primitives.

    Returns void

  • Gets a deep copy of the internal data of the PrimitiveManagerInterface.

    All boxes, points, lines and materials definitions are dumped.

    Please refer to JSON.stringify.

    Parameters

    • Optional pKey: any
      in
      Unused.

    Returns Object

    The internal PrimitiveManagerInterface data.