Fri, 11/15/2024 - 05:03
Forums:
Dear all:
I know AIS_Shape is more convenient. But some big files are not necessary to load the Topo data. So I try to load STL file just for visualization. For this goal, I hit plateaus.
First, I can't add ComputeSelection to AIS_Triangulation, because there are no topos. How to add ComputeSelection for AIS_Triangulation?
Second, Some colors are not work. For example, Quantity_NOC_BLACK is fine. But Quantity_NOC_GRAY is not work, the displayed color is similary with Brass.
Finally, the displayed model is odd, maybe it caused by there is no WireFrame.
Thanks for replys, I would glad to get some advices.
Here are the codes
Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile(theFileNmae.c_str());
Handle(AIS_Triangulation) tris = new AIS_Triangulation(aSTLMesh);
int numNodes = aSTLMesh->NbNodes();
Quantity_Color color;
int RGB_I;
color.Color2argb(Quantity_NOC_GRAY, RGB_I);
Handle(TColStd_HArray1OfInteger) colors = new TColStd_HArray1OfInteger(1, numNodes);
for (int i = 1; i <= numNodes; ++i)
{
colors->SetValue(i, RGB_I);
}
tris->SetColors(colors);
Handle(Prs3d_Drawer) theDrawer = new Prs3d_Drawer();
Handle(Prs3d_LineAspect) theLineAspect = new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
theDrawer->SetFaceBoundaryAspect(theLineAspect);
tris->SetAttributes(theDrawer);
//tris->SetDisplayMode(Graphic3d_TypeOfShadingModel_PhongFacet);
Attachments:
Fri, 11/15/2024 - 16:27
There is no need to use
AIS_Triangulation
- just createTopoDS_Face
from yourPoly_Triangulation
andAIS_Shape
will do everything you need (and in a more flexible and efficient way). Here is how it can be done (based onreadstl
DRAW command inXSDRAWSTLVRML.cxx
):The only reason to take a look into
AIS_Triangulation
is when you need to assign nodal colors to your mesh (but there are better ways to do that).Tue, 11/19/2024 - 08:12
Thank you so much. I tried those codes and it works. The generating time is accept. And it more convinent Lol