How to use TopTools_DataMapIteratorOfDataMapOfShapeShape

TopTools_DataMapIteratorOfDataMapOfShapeShape


Introduction

TopTools_DataMapIteratorOfDataMapOfShapeShape is used to iterate over TopTools_DataMapOfShapeShape map. TopTools_DataMapOfShapeShape is contains the association between TopoDS_Shape to TopoDS_Shape.

Why do we need TopTools_DataMapOfShapeShape

There are many situations where it is necessary to associate one shape with another. For example, when constructing a CAD model, in geometric operation, to analyze shape properties we need TopTools_DataMapOfShapeShape. It is important to have such data structure in large models which contain many shapes. Using this data structure, it is easy to store and retrieve shape associations. This ensures that only shapes are associated with other shapes, which helps to prevent errors.

Example

Here is an example of how to use the TopTools_DataMapIteratorOfDataMapOfShapeShape class.

#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx> 

// map of shape shape assiciation
TopTools_DataMapOfShapeShape shapeMap;
// initialize the iterator
TopTools_DataMapIteratorOfDataMapOfShapeShape itr(shapeMap);
for (; itr.More(); itr.Next())
{
    // get the current association
    const TopoDS_Shape& keyShape = itr.Key();     // key
    const TopoDS_Shape& valueShape = itr.Value(); // value
}

The following code can be used to create TopTools_DataMapOfShapeShape

// we need to have two shapes TopoDS_Shape myShape1 = ...; TopoDS_Shape myShape2 = ...; // make shape-shape association TopTools_DataMapOfShapeShape shapeMap; shapeMap.Bind(myShape1, myShape2);

Post a Comment

Previous Post Next Post