how to color the surface of a triangle?

in my project I'm tesselelating a TopoDS_Shape.
Then I use a meanshift-algorithm to divide the triangle-mesh in different segments.
Now, I'd like to color the surface of each segment in a different color.
I know, how to color each edge of a triangle, but how can I color the surface?

Here is the code I use to color the edge of a triangle:
colors is an array of Quantity_NameOfColor.
point1 and point2 are ColumnVector which represent the coordinates of the vertices.

BRep_Builder builder;
TopoDS_Compound Comp;

BRepBuilderAPI_MakeEdge ME(gp_Pnt(point1(1),point1(2), point1(3)), gp_Pnt(point2(1),point2(2), point2(3)));
if (ME.IsDone())
Handle_AIS_Shape ctriangulation = new AIS_Shape(Comp);

Seth Jackson's picture

i believe you would first need to build edges, then a face for your triangle, before creating the AIS_Shape. then the color you apply with SetColor() will hold...

Matthias Teich's picture

You want colored Faces, but you only create edges!
The following code-snippet creates wires from the edges and faces from the wires.
Edges is an Array which must be fillded with the edges for the face.

TopoDS_Edge edges[3];

BRepBuilderAPI_MakeEdge ME(gp_Pnt(point1(1),point1(2), point1(3)),gp_Pnt(point2(1),point2(2), point2(3)));
if (ME.IsDone())
TopoDS_Edge edge = ME.Edge();
edges[k-1] = edge;
BRepBuilderAPI_MakeWire MW (edges[0],edges[1],edges[2]);
BRepBuilderAPI_MakeFace MF(MW.Wire());
Handle_AIS_Shape f = new AIS_Shape(MF.Face());

Best Regards, Matthias :)