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

AIS_Triangulation

Takahiro Tsuzuku's picture
Forums: 

Hello.
I tried AIS_Triangulation at OCC6.4.
it display polygons first enough,but it works only as a wireframe.
means it shows up only when SetDisplayMode(AIS_WireFrame);
so, I can't set the FrontMaterial or BackMaterial.
like below.
->Attributes()->ShadingAspect()->Aspect()->SetFrontMaterial(Graphic3d_NOM_GOLD);
->Attributes()->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);

does anybody knows how to set Front and Back material of AIS_Triangulation.

thank you.

Timo Roth's picture

AIS_Triangulation currently supports only display mode 0 (=AIS_WireFrame).

However, the triangulation can be displayed with shading by setting the shading aspect as you can see in the implementation of the Draw command VDrawSphere in ViewerTest_ObjectCommands.cxx.

Billy's picture

Strange because I am having problems setting it to wireframe mode, shading works great.

Timo Roth's picture

Yes, you are right it is shaded. I meant that AIS_Triangulation supports only one mode, which is '0' in its Compute method (see AIS_Triangulation::Compute).

According to the enumeration AIS_DisplayMode (defined in AIS_DisplayMode.hxx), mode '0' is called AIS_WireFrame, which is not really fitting here. Probably, this enumeration is meant only for AIS_Shape, or what do OCCT developers say about it?

Regarding the display of edges, did you have a look at the function VDrawSphere in ViewerTest_ObjectCommands.cxx? In the end of the function visual aspects are defined.
Using the first argument of the constructor of Graphic3d_AspectFillArea3d you can define if the triangulation should be shaded or not.
You can use the SetEdgeOn() / SetEdgeOff() methods of Graphic3d_AspectFillArea3d to control the display of edges.

Here is a code excerpt from the function VDrawSphere:
...
Handle(Graphic3d_AspectFillArea3d) anAspect
= new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
Quantity_NOC_RED,
Quantity_NOC_YELLOW,
Aspect_TOL_SOLID,
1.0,
aMat,
aMat);
Handle(Prs3d_ShadingAspect) aShAsp = new Prs3d_ShadingAspect();
if (toShowEdges)
{
anAspect->SetEdgeOn();
}
else
{
anAspect->SetEdgeOff();
}
aShAsp->SetAspect (anAspect);
aShape->Attributes()->SetShadingAspect (aShAsp);

Regards

Billy's picture

Thank you very much for your response. After I posted I looked at AIS_Triangulation::Compute and verified that only Mode '0' is implemented and then figured out AIS_Wireframe is mode 0.

I was thinking of deriving my own class from AIS_Triangulation and then overriding the compute method. Or just deriving directly from AIS_Object and implement both rendering modes.

Billy's picture

I set ->SetEdgeOn(); but how do I change the Aspect_IS_SOLID parameter (Aspect_IS_HOLLOW)?

Timo Roth's picture

Yes, or Aspect_IS_EMPTY, depending on what you want it to be. Try it out!
Regards

Billy's picture

Just too say that this solution is working very nicely. Thanks once again.