Tue, 05/07/2024 - 05:23
Forums:
Hello guys,
I have troubles with visualizing AIS_Point. I create about 0.33 million (330000) AIS_Point and use context->Load() to display them on screen, then I see a huge memory consumption (About 4.3 GB memory) and low frame rate. Could you please help me with this problem?
My point class:
class Point_3 : public AIS_Point {
public:
Point_3(double x, double y, double z) :
AIS_Point(new Geom_CartesianPoint(x, y, z))
{
point_index = 0;
}
~Point_3() {
}
unsigned int point_index;
std::set<unsigned int> parent_poly_index;
};
How I add points to context (m_point is std::vector
for (Handle(AIS_Point) point : m_point) {
point->SetColor(Quantity_NOC_BLACK);
point->Attributes()->SetDisplayMode(AIS_WireFrame);
point->SetMarker(Aspect_TOM_BALL);
m_context->Load(point, -1);
}
m_context->DisplayAll();
m_view->FitAll();
Tue, 05/07/2024 - 08:45
AIS_InteractiveObject(and it's subclassAIS_Point) is a complex object that has considerable memory overhead. It is not designed for displaying large amounts of such small objects like points.For that purpose, it is better displaying points grouped into one or several interactive objects - using
AIS_PointCloudorAIS_Shapeclasses.P.S.: use code tags on the forum.
Tue, 05/07/2024 - 10:53
Thanks for your reply! I read the tutorial about AIS presentation, maybe I need to create my own AIS class.
I'm trying to create an app to visualize solid mesh data with some interact functions, like selection with points, edges, solids. For example, points, edges,
and solids have their own index, I want to return their index when user selects them.
Right now, I want to derive
SelectMgr_EntityOwnerand add index to owner class, could you please give me some advice about doing this?And, sorry for the format issue.
Tue, 05/07/2024 - 11:21
I use
Topods_Compoundto createAIS_Shape. For each compound, I create 12 triangles, and these compound cost me about 10 GB memory. After I load them into context, memory used increase to 13 GB.Function
make_faceconstructTopods_Faceand push_back to face(std::vector<Topods_Face>)void polys_to_shapes(std::vector<Handle(OCC::Point_3)>& point_3s, std::vector<std::vector<unsigned int>>& polys, std::vector<Handle(OCC::Edge)>& edges, std::vector< Handle(OCC::Polygon)>& polygons ) { static int edge_count = 0; std::map<std::pair<Handle(OCC::Point_3), Handle(OCC::Point_3)>, unsigned int> map; for (int i = 0; i < polys.size(); i++) { int size = polys[i].size(); std::vector<Handle(OCC::Point_3)> points; if (size == 8) { // solid std::vector<TopoDS_Face> faces; for (int j = 0; j < 4; j++) { points.emplace_back(point_3s[polys[i][j]]); } points.emplace_back(point_3s[polys[i][0]]); make_shape(points, edges, map, faces); points.clear(); for (int j = 4; j < polys[i].size(); j++) { points.emplace_back(point_3s[polys[i][j]]); } points.emplace_back(point_3s[polys[i][4]]); make_shape(points, edges, map, faces); points.clear(); points.emplace_back(point_3s[polys[i][0]]); points.emplace_back(point_3s[polys[i][1]]); points.emplace_back(point_3s[polys[i][5]]); points.emplace_back(point_3s[polys[i][4]]); points.emplace_back(point_3s[polys[i][0]]); make_shape(points, edges, map, faces); points.clear(); points.emplace_back(point_3s[polys[i][1]]); points.emplace_back(point_3s[polys[i][2]]); points.emplace_back(point_3s[polys[i][6]]); points.emplace_back(point_3s[polys[i][5]]); points.emplace_back(point_3s[polys[i][1]]); make_shape(points, edges, map, faces); points.clear(); points.emplace_back(point_3s[polys[i][2]]); points.emplace_back(point_3s[polys[i][3]]); points.emplace_back(point_3s[polys[i][7]]); points.emplace_back(point_3s[polys[i][6]]); points.emplace_back(point_3s[polys[i][2]]); make_shape(points, edges, map, faces); points.clear(); points.emplace_back(point_3s[polys[i][3]]); points.emplace_back(point_3s[polys[i][0]]); points.emplace_back(point_3s[polys[i][4]]); points.emplace_back(point_3s[polys[i][7]]); points.emplace_back(point_3s[polys[i][3]]); make_shape(points, edges, map, faces); points.clear(); TopoDS_Compound compound; BRep_Builder builder; builder.MakeCompound(compound); for (auto& sh : faces) { builder.Add(compound, sh); } Handle(OCC::Polygon) p = new OCC::Polygon(compound); p->poly_index = i; //p->SetAttributes(nullptr); p->SetDynamicHilightAttributes(nullptr); p->SetHilightAttributes(nullptr); p->UnsetAttributes(); polygons.emplace_back(p); } else if(size == 4) { // polygon for (int j = 0; j < size; j++) { points.emplace_back(point_3s[polys[i][j]]); } points.emplace_back(point_3s[polys[i][0]]); std::vector<TopoDS_Face> sh; make_shape(points, edges, map, sh); TopoDS_Compound compound; BRep_Builder builder; builder.MakeCompound(compound); builder.Add(compound, sh[0]); builder.Add(compound, sh[1]); Handle(OCC::Polygon) p = new OCC::Polygon(compound); p->SetDynamicHilightAttributes(nullptr); p->SetHilightAttributes(nullptr); p->poly_index = i; polygons.emplace_back(p); } } }Tue, 05/07/2024 - 13:45
Puttings triangles and small polygons into TopoDS_Shape like this doesn't look like a good idea. It is better creating
Poly_Triangulationor some custom structure for such data.Wed, 05/08/2024 - 04:21
Thank you for advice!