Point Cloud with color

Hi, I have rendered a Point cloud succesfully by subclassing AIS_InteractiveObject.

thanks to the guidance in this thread : http://www.opencascade.org/org/forum/thread_1125/

I cant find anywhere, how to assing unique colors to each marker in the MarkerSet.

Any Ideas of how to show unique colors on the points?

I have a ptx file , with the x,y,z,intensity of the range finder point cloud.

i would like to map the intensity from 0 to 1 to a color.

thanks,

Alex

Handle(Graphic3d_Structure) theStructure = Handle(Graphic3d_Structure)::DownCast(aPresentation);

Handle(Graphic3d_Group) theGroup= new Graphic3d_Group(theStructure);

Handle(Graphic3d_AspectMarker3d) asp;
asp = myDrawer->PointAspect()->Aspect();

asp->SetType(Aspect_TOM_POINT);
//asp->SetType(Aspect_TOM_O_POINT);

theGroup->SetGroupPrimitivesAspect(asp);

const Graphic3d_Array1OfVertex& theArray = cloud_data; //your points

theGroup->MarkerSet(theArray);

}

Attachments: 
JuryS's picture

void PreviewView2::showMarker(const double &X, const double &Y, const double &Z, const int &mType)
{
if (!aMarkerPrs->IsEmpty()) //is marker exists
{
if (aMarkerData.X == X && aMarkerData.Y == Y &&
aMarkerData.Z == Z && aMarkerData.mType == mType) //on the window, exit
return;
else
aMarkerPrs->Clear(true); //clear prs
}

//create marker
Quantity_Color aColor(0,1,0,Quantity_TOC_RGB);
Handle(Aspect_AspectMarker) aMarker = new Aspect_AspectMarker(aColor,(Aspect_TypeOfMarker)mType,1.);
//Create group
Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aMarkerPrs);
TheGroup->SetPrimitivesAspect(aMarker);
//Save new values
aMarkerData.X = X; aMarkerData.Y = Y; aMarkerData.Z = Z; aMarkerData.mType = mType;
//Add point
Graphic3d_Vertex aGrVertex(X,Y,Z);
TheGroup->Marker(aGrVertex);
//Display prs
aMarkerPrs->Display();
myContext->UpdateCurrentViewer();
}

AP's picture

Hey Jury mega thanks!!!!

thanks for the suggestion of using the Geom_Plate Surface. the plate surface technique is only useful when you know the topology of what you scanned, but you first need to do canonical shape recognition to filter the features in common of the point cloud and then run the plate algorithim on a region of points you know belongs to a smooth surface. In my case these point clouds are scans of a architectural building , which maybe made of many different type of surface meeting at seems or sharp corners.

I just wanted to see how fast i could display point clouds in occ, the code i pasted above, ive been able to display 20 million points and still rotating the model very nicely, the trick was now to incorporate the range scanners distance to the point which for the leica ciclone, is an intensity value.

let me give a shot at adding the code you pasted, and see what it looks like.

thanks again for all the suggestions, im follow all your posts.

Best,

Alex

JuryS's picture

There is some type of markers:

Aspect_TOM_POINT,
Aspect_TOM_PLUS,
Aspect_TOM_STAR,
Aspect_TOM_O,
Aspect_TOM_X,
Aspect_TOM_O_POINT,
Aspect_TOM_O_PLUS,
Aspect_TOM_O_STAR,
Aspect_TOM_O_X,
Aspect_TOM_BALL,
Aspect_TOM_RING1,
Aspect_TOM_RING2,
Aspect_TOM_RING3,

And also I have some markers like rectangle, rect + circle, rect + cross ....

JuryS's picture

I see your screenshot. Why you are don't using GeomPlate_MakeApprox algoritm ????

Make this points with next:

TopoDS_Vertex vertex;
gp_Pnt pt;
Plate_Plate myPlate;

TopoDS_ListIteratorOfListOfShape aShapeIterator;
for(aShapeIterator.Initialize(aList);aShapeIterator.More();aShapeIterator.Next())
{
vertex = TopoDS::Vertex(aShapeIterator.Value());
pt = BRep_Tool::Pnt(vertex);

gp_Pnt ptProj(pt.X(), pt.Y(), 0. );
gp_Vec aVec( ptProj, pt);
gp_XY pntXY(pt.X(),pt.Y());
Plate_PinpointConstraint PCst( pntXY,aVec.XYZ() );
myPlate.Load(PCst);// Load plate
}

myPlate.SolveTI(2, 1.);// resolution
if (!myPlate.IsDone()) return;

// Computation of plate surface
gp_Pnt Or(0,0,0.);
gp_Dir Norm(0., 0., 1.);
Handle(Geom_Plane) myPlane =
new Geom_Plane(Or, Norm);// Plane of normal Oz
Handle(GeomPlate_Surface) myPlateSurf =
new GeomPlate_Surface( myPlane, myPlate);//plate surface

GeomPlate_MakeApprox aMKS(myPlateSurf, Precision::Approximation(), 4, 7, 0.001, 0);//bspline surface

TopoDS_Face ResultShape = BRepBuilderAPI_MakeFace(aMKS.Surface());
if (!BRepAlgo::IsValid(ResultShape))
return;

AP's picture

thanks for the code Jury, i tried answering above, that in a point cloud of 130 million points the plate surface might not be as optimal, i think the occ team sells a product that is specific for this feature of transforming point clouds into recognizable surfaces, theres also geomagics.

in my case i just wanted to visualize the point cloud as points with color, so far ive viualized it, ill use your code and see how it looks like with color.

thanks again.

Alex

JuryS's picture

It's a result of your points with prev algoritm

Attachments: