display point

Hello,
I want display a point instead a sphere but I have not found how to draw this point has three coordinates. (Is there a method for points as BRepPrimAPI_MakeSphere for display of a sphere)
Thanks.

EricThompson's picture

What you're looking for is:

BRepBuilderAPI_MakeVertex( gp_Pnt pnt );

Also note that the point will display as a yellow +. If you want to change how it looks, you need to work with the PointAspect of the AIS_Shape you create. So your code might look something like this:

// Create the vertex
gp_Pnt pnt( 0,0,0 ) // Use your coordinates here!
TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex( pnt );

// Create the AIS_Shape
Handle(AIS_Shape) aShape = new AIS_Shape(V1);

// Set the vertex shape, color, and size
Quantity_Color color(Quantity_NOC_RED);
Handle_Prs3d_PointAspect myPointAspect=new Prs3d_PointAspect(Aspect_TOM_O,color,2);
aShape->Attributes()->SetPointAspect(myPointAspect);

ATTIA's picture

Thank you very much Eric

ATTIA's picture

viewing points is market but it is very long slow
there exists a method that can accelerate the displaying of points.
thak you.

ATTIA's picture

viewing points is market but it is very slow
there exists a method that can accelerate the displaying of points.
thak you.

EricThompson's picture

There is a noticable performance hit for creating many AIS_Shapes. If you have a lot of points, and they do not need to be individually selectable, you can stuff them all into a TopoDS_Compound and create a single AIS_Shape.

The code might look like this:

// Create a compound shape to hold the points
TopoDS_Compound compoundShape;
BRep_Builder compoundBuilder;
compoundBuilder.MakeCompound( compoundShape );

// Create the points and add to the compound shape
for ( int i=0; i

EricThompson's picture

Sorry about the typo in the for loop, apparently I can't include a less-than sign in a post.

it should read: for( int i=0; i less-than count; i++ )

ATTIA's picture

thank you very much.
exactly what I want.

JuryS's picture

If you are want more that 1000 points I recommend you to use after Compound use Mesh for compounded shape. Or triangulate.
If you are using the OCC Application Interface you must use:
also you can make color. And If you don't want use AIS_PointPresentation you make set for AIS point prs->GetAIS()->Attributes()->SetPointAspect and disable here all that you don't want to see...

#include "point.h"

#include
#include

#include
#include

#include
#include
#include
#include "TNaming_Builder.hxx"
#include "BRepBuilderAPI_MakeVertex.hxx"

QString createpoint::mpoint(TDF_Label MainLab,const double myX , const double myY , const double myZ, const QString Name)
{
//! Ñîçäàþ èíòåðàêòèâíûé îáúåêò ñ àòðèáóòàìè:
// Point Label - ñîçäàííàÿ ìåòêà
// Ïðèñâàèâàþ àòðèáóòû â ñëåäóþùåì ïîðÿäêå:
// 0 -- òèï îáúåêòà (óíèêàëüíûé êîä äëÿ ëþáîãî îáúåêòà)
// 0:0 -- ÎÏÈÑÀÍÈÅ (èìÿ)
// 1 -- ÃÅÎÌÅÒÐÈß
// 1:0 -- ÎÏÈÑÀÍÈÅ
// 1:1 -- X1
// 1:2 -- Y1
// 1:3 -- Z1

// Íîâàÿ ìåòêà â ñòðóêòóðå
TDF_Label L = TDF_TagSource::NewChild(MainLab);

// Òèï îáúåêòà - ïðèìèòèâ
TDataStd_AsciiString::Set(L,"Point");

//Èìÿ
TDF_Label level0 = L.FindChild(0,Standard_True);
TDataStd_AsciiString::Set(level0.FindChild(0), Name.toAscii().data()); //èìÿ

// Ãåîìåòðèÿ:
TDF_Label level1 = L.FindChild(1,Standard_True);
TDataStd_Real::Set(level1.FindChild(1), myX);
TDataStd_Real::Set(level1.FindChild(2), myY);
TDataStd_Real::Set(level1.FindChild(3), myZ);

//Ñòðîþ òî÷êó
gp_Pnt aPnt(myX,myY,myZ);
BRepBuilderAPI_MakeVertex mkVertex (aPnt);
TopoDS_Shape ResultShape = mkVertex.Shape();

TNaming_Builder B(L);
B.Generated(ResultShape);

//Äîáàâëÿþ åå â äîêóìåíò
Handle(TPrsStd_AISPresentation) prs = TPrsStd_AISPresentation::Set(L,TNaming_NamedShape::GetID());

//Îòîáðàæàþ íà ýêðàíå
prs->Display(1);

//Âñå ïîñòðîåíî ïåðåäàþ ðåçóëüòàò ïî ðàáîòå
QString complete;
QTextStream message(&complete);
message << trUtf8("Ïîñòðîèëè òî÷êó ïî êîîðäèíàòàì:") << " X " << QString::number(myX) << " Y " << QString::number(myY) << " Z " << QString::number(myZ)
<< trUtf8(" Èìÿ: ") << QString::fromUtf8(Name.toAscii().data());
return complete;
}

createpoint::createpoint() { }
createpoint::~createpoint() { }

ATTIA's picture

I have 100000 points but I don't understand what recommend to use after Compound use Mesh for compounded shape.
I want display the points without edge.
thank you for your help

JuryS's picture

Hi! I think you may use the triangulate because after compounding you have Shape that are Is not optimized. I make my test and may see that after 10000 point I'm have compound my saved file was 1 Mb, but after Triangulation It's 68 Kb.

You describe a surface points, and in a case with a triangulation in co-ordinates of tops of triangles. The volume of the information is much less, besides much bigger compatibility with others CAD systems. By the way, as I have understood algorithm HLR uses MESH for creation of the flat image.

There no bad sample in 02_7_TopologyTrianguation. It's very simple.

JiangMing's picture

thank you very much.
I am improved after reading your words.
Thank you once more!

JiangMing's picture

thank you very much.

I am improved after reading your words.
Thank you once more!