For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Creating dynamic TopoDS_Compound & AIS_Shape in a incrementing way

Cédric Saillard's picture

Hello everybody,

I am using the mesh components of OCC, and I try to display the mesh while adding color to each face that is created.

In that way, I use the code given in the samples with the "TopExp_Explorer" to explore the mesh. Then I create faces in loops and I would like to associate a color (different for each face). So I think I must use the AIS_Shape, the only object we can associate color with. The problem is that I do not achieve to create AIS_Shape dynamically with an incremental index for example.
Here is the code I use :

//************************TEST MAILLAGE*******************************************


double a, b, c;
int ais=0;
Quantity_Color CouleurFace = Quantity_Color (a, b, c, Quantity_TOC_RGB);

for (TopExp_Explorer ex(myFaceB,TopAbs_FACE) ; ex.More(); ex.Next())
TopoDS_Face F =TopoDS::Face(ex.Current());
TopLoc_Location L;
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);
TColgp_Array1OfPnt tab(1,(facing->NbNodes()));
tab = facing->Nodes();
Poly_Array1OfTriangle tri(1,facing->NbTriangles());
tri = facing->Triangles();

for (Standard_Integer i=1;iNbTriangles());i++)
Poly_Triangle trian = tri.Value(i);
Standard_Integer index1,index2,index3,M,N;

//*******création d'une face à partir des points du triangle

BRepBuilderAPI_MakeWire myWire2;

for (Standard_Integer j=1;j {
switch (j)
case 1 :
M = index1;
N = index2;
case 2 :
N = index3;
case 3 :
M = index2;

BRepBuilderAPI_MakeEdge ME(tab.Value(M),tab.Value(N));
if (ME.IsDone())
// Builder.Add(Bearing1, ME.Edge());
TopoDS_Shape myFace = BRepBuilderAPI_MakeFace(myWire2);

Builder.Add(Bearing1, myFace);


if (b b=b+0.1;
if (b==1)
AfxMessageBox(" b = 1 ");
if (c c=c+0.1;
if (c==1)
AfxMessageBox(" c = 1 ");

Handle(AIS_Shape) myAIS_ais = new AIS_Shape(Bearing1);

CouleurFace.SetValues (a,b,c,Quantity_TOC_RGB);

//*********************fin couleur*****************************

It works but only display a color, the last created I think.
I'm asking if I may create a TopoDS_Compound in he loop to add to the BRep_Builder.

The main problem is to create some AIS_Shape in the loop and to be able to put an index on it...That's what I tried with "myAIS_ais", but doesn't works.

Thanks for help!

Cédric Saillard
French Student (UTT)

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.