Show different colors of face's front and back sides

Hi gentlemen, I have some VERY OLD codes to show faces's front and back sides in different colors. The codes like :
aPrs = new Prs3d_Presentation(myAISContext->CurrentViewer()->Viewer());
Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPrs);
Handle(Graphic3d_AspectFillArea3d) myFillAspect = new Graphic3d_AspectFillArea3d();
myFillAspect->SetInteriorStyle (Aspect_IS_SOLID);
myFillAspect->SetDistinguishOn ();

myFillAspect->SetEdgeOn();
myFillAspect->SetEdgeLineType(Aspect_TOL_SOLID);
myFillAspect->SetEdgeColor(Quantity_NOC_BLACK);
myFillAspect->SetEdgeWidth(1);

Graphic3d_MaterialAspect myFrontMaterial(Graphic3d_NOM_DEFAULT);
myFrontMaterial.SetColor (Quantity_NOC_RED);
myFillAspect->SetFrontMaterial(myFrontMaterial);

Graphic3d_MaterialAspect myBackMaterial(Graphic3d_NOM_DEFAULT);
myBackMaterial.SetColor (Quantity_NOC_GOLD);
myFillAspect->SetBackMaterial(myBackMaterial);

myFillAspect->SetInteriorColor (Quantity_NOC_RED);
myFillAspect->SetBackInteriorColor (Quantity_NOC_GOLD);

aGroup->SetPrimitivesAspect(myFillAspect);
aGroup->AddPrimitiveArray(aTrianglesArray); // aTrianglesArray is an array with many triangles

aPrs->Display();

But the problem is:
If this code based on OCC 6.3.0 , it works OK. The one side of the faces is RED, the other side is GOLD.
If this code based on OCC 7.1.0, it cannot show the faces' back color.
When I followed some OCC 7.1.0 samples and simplify the code like followed still not work, the both sides of every faces are RED color.
......
Handle(Graphic3d_AspectFillArea3d) myFillAspect =
new Graphic3d_AspectFillArea3d ( Aspect_IS_SOLID, Quantity_NOC_RED, Quantity_NOC_BLACK,
Aspect_TOL_SOLID, 1, Graphic3d_NOM_DEFAULT, Graphic3d_NOM_DEFAULT );
myFillAspect->SetEdgeOn();
myFillAspect->SetDistinguishOn ();
myFillAspect->SetInteriorColor ( Quantity_NOC_RED );
myFillAspect->SetBackInteriorColor ( Quantity_NOC_GOLD );

aGroup->SetPrimitivesAspect(myFillAspect);
aGroup->AddPrimitiveArray(aTrianglesArray);
.......
Why? Did I miss something?

Thank for help!

gkv311 n's picture

Your code snippet works as expected on my sample with OCCT 7.7.0.
Please share more code to figure out what might be wrong and please use tags to insert code samples on the Forum.

void MyAisObject::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
                           const Handle(Prs3d_Presentation)& thePrs,
                           const Standard_Integer theMode)
{
  const double aRadius = 100.0, aHeight = 100.0;
  TopoDS_Shape aShape = BRepPrimAPI_MakeCone (aRadius, 0.0, aHeight);

  Prs3d_ToolCylinder aCyl (aRadius, aRadius / 2, aHeight, 25, 25);
  Prs3d_ToolDisk aDisk (0.0, aRadius, 25, 1);
  Handle(Graphic3d_ArrayOfTriangles) aTris =
    new Graphic3d_ArrayOfTriangles (aCyl.VerticesNb() + aDisk.VerticesNb(),
    (aCyl.TrianglesNb() + aDisk.TrianglesNb()) * 3,
                                    Graphic3d_ArrayFlags_VertexNormal);
  aCyl .FillArray (aTris, gp_Trsf());
  aDisk.FillArray (aTris, gp_Trsf());
  Handle(Graphic3d_Group) aGroupTris = thePrs->NewGroup();

  Handle(Graphic3d_AspectFillArea3d) myFillAspect =
    new Graphic3d_AspectFillArea3d ( Aspect_IS_SOLID, Quantity_NOC_RED, Quantity_NOC_BLACK,
                                    Aspect_TOL_SOLID, 1, Graphic3d_NOM_DEFAULT, Graphic3d_NOM_DEFAULT );
  myFillAspect->SetEdgeOn();
  myFillAspect->SetDistinguishOn ();
  myFillAspect->SetInteriorColor ( Quantity_NOC_RED );
  myFillAspect->SetBackInteriorColor ( Quantity_NOC_GOLD );

  aGroupTris->SetPrimitivesAspect(myFillAspect);

  aGroupTris->AddPrimitiveArray (aTris);
  //aGroupTris->SetClosed (true); //
}
X F's picture

Thanks for answer! I upload my codes and some pictures!

Your code and picture confirmed me that perhaps my code is right. So I wonder maybe something wrong with the OCCT 7.1.0's dlls (Those dlls are combined from source code by myself), then I downloaded the opencascade-7.1.0-vc10-64.exe from opencascade.org , installed it, BUT it is still not work. I'm confused. Will it be a bug of the OCCT 7.1.0?

Because my project is complex, I cannot use OCCT 7.6.0 to test it now.

I need to explain something in detail:
The source code is read triangle's data from a file, insert them into a vector, then show them.
The picture show red and gold color is based on OCCT 6.3.0, the picture only show red is based on OCCT 7.1.0

X F's picture

X F's picture

Thanks a lot!