
Sun, 12/15/2024 - 21:36
Forums:
Hello all,
When set in a 2D view (View->SetProj(V3d_Zpos)), what is the best topology to display a shape? It sounds like a weird question, bear with me...
I have a setup whereby the user can create (2D) shape outlines using AIS_Point() and AIS_Line(). When the shape is closed, I'm creating an AIS_ColoredShape() from the outline, but its not being displayed.
In particular, I'm trying to do this via a Face - but not sure if this the best medium to use, as I can't get it to close?
Not sure whether its the non-closing face which is causing the problem, or simply the AIS_Shape() doesn't want to display in a Z-down view?
Any thoughts, code below?...
Mat
{ unsigned i; gp_Pnt p1, p2; TopoDS_Wire aWire; TopoDS_Face aFace; BRepBuilderAPI_MakeWire mkWire; BRepBuilderAPI_MakePolygon aPoly; //--------------create polygon from stored points------------------- for(i=0; i<m_vVertexes.size(); i++) { p1.SetX(m_vVertexes[i].X()); p1.SetY(m_vVertexes[i].Y()); aPoly.Add(p1); } aPoly.Close(); aWire = aPoly.Wire(); //--------------create face from polygon------------------------- gp_Pln aPln(gp::XOY()); aFace = BRepBuilderAPI_MakeFace(aPln, aWire); #ifdef _DEBUG qDebug() << "Face Closed: " << aFace.Closed(); //SHOWS FALSE #endif //-------------create AIS shape to display---------------------- Handle(AIS_ColoredShape) myAIS_Shape = new AIS_ColoredShape(aFace); myAIS_Shape->SetColor(Quantity_Color(Quantity_NOC_DEEPSKYBLUE1)); m_AIScontext->Display(myAIS_Shape, true); //NOTHING SHOWN }
Mon, 12/16/2024 - 05:46
Well, the code looks working for me for a simple shape:
Make sure to call
V3d_View::FitAll()
to fit the scene.Tue, 12/17/2024 - 23:03
How very odd. Thanks for checking, at least I know where not to look!
As my points and lines are showing up fine, I'm wondering two things...
1. I've got a problem with my view setup (defaulting to displaying lines but not faces)?
2. Unexpected transparency on the face
Weirdly, select detection of the face works when I click it, it just isn't visible.
Difficult to pull all the setup together in one place, but does this look any different to your setup?...
Tue, 12/17/2024 - 23:16
Solved!
Missing a line from the display setup:
myContext->SetDisplayMode(AIS_Shaded, Standard_False);
Thanks!