//定义子类myAisPointCloud .h
//myAisPointCloud .h
class myAisPointCloud :public AIS_PointCloud
{
public:
bmAisPointCloud(const std::vector<gp_Pnt>& vecPoint);
Standard_Boolean AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
private:
void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer aMode);
void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode);
//
};
//myAisPointCloud .cpp
myAisPointCloud ::myAisPointCloud (const std::vector<gp_Pnt>& vecPoint)
:AIS_PointCloud()
{
//do something
// MY_MODE 非0整数
myHilightDrawer->SetDisplayMode(MY_MODE);
}
Standard_Boolean myAisPointCloud ::AcceptDisplayMode(const Standard_Integer aMode) const
{
return aMode == 0|| aMode == MY_MODE;
}
void bmAisPointCloud::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager ,const Handle(Prs3d_Presentation)& thePrs,const Standard_Integer aMode)
{
switch (aMode)
{
case AIS_PointCloud::DM_Points:
case MY_MODE:
{
const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
if (aPoints.IsNull())
{
return;
}
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
//点云是通过mark来呈现
Handle(Graphic3d_AspectMarker3d) aMarker = new Graphic3d_AspectMarker3d(Aspect_TOM_POINT, Quantity_NOC_GREEN, 1.0);
//点的放大比例设为2.5
aMarker->SetScale(2.5);
Handle(Graphic3d_AspectMarker3d) asp;
//设置鼠标hover时单个点的显示样式
asp = myDynHilightDrawer->PointAspect()->Aspect();
//加号“ + ”样式
asp->SetType(Aspect_TOM_PLUS);
//绿色
asp->SetColor(Quantity_NOC_GREEN);
//设置被选中时(整体或者局部选中)显示样式
asp = myHilightDrawer->PointAspect()->Aspect();
//加号“ + ”样式
asp->SetType(Aspect_TOM_PLUS);
//黑色
asp->SetColor(Quantity_NOC_BLACK);
//设置当前GroupPrimitives的Marker aspect
aGroup->SetGroupPrimitivesAspect(aMarker);
//将点云add到PrimitiveArray
aGroup->AddPrimitiveArray(aPoints);
break;
}
//点云作为整体选中的样式,显示包围盒
case AIS_PointCloud::DM_BndBox:
{
Bnd_Box aBndBox = GetBoundingBox();
if (aBndBox.IsVoid())
{
return;
}
StdPrs_BndBox::Add(thePrs, aBndBox, AIS_PointCloud::myDrawer);
break;
}
}
}
Opencascade子类化AIS_PointCloud实现自定义显示和选择样式
原文:https://www.cnblogs.com/Craftsman-lee/p/13657561.html