mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0028105: HLR rendering crash in MFC sample
User_Cylinder class was updated according to work as single object in Prs3d_Presentation.
This commit is contained in:
parent
b3eab8efc3
commit
4208cf1872
@ -527,20 +527,10 @@ void CViewer3dDoc::InputEvent(const Standard_Integer /*x*/,
|
|||||||
GetBValue (MSColor)/255.0,
|
GetBValue (MSColor)/255.0,
|
||||||
Quantity_TOC_RGB);
|
Quantity_TOC_RGB);
|
||||||
|
|
||||||
TopoDS_Shape S = myAISContext->SelectedShape();
|
Handle(AIS_InteractiveObject) aSelectedObject = myAISContext->SelectedInteractive();
|
||||||
Handle(Geom_Surface) Surface = BRep_Tool::Surface (TopoDS::Face(S));
|
Handle(User_Cylinder)::DownCast (aSelectedObject)->SetColor (CSFColor.Name());
|
||||||
if (Surface->IsKind (STANDARD_TYPE (Geom_Plane)))
|
|
||||||
{
|
|
||||||
Handle(User_Cylinder)::DownCast (myAISContext->SelectedInteractive())
|
|
||||||
->SetPlanarFaceColor (CSFColor.Name());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Handle(User_Cylinder)::DownCast (myAISContext->SelectedInteractive())
|
|
||||||
->SetCylindricalFaceColor (CSFColor.Name());
|
|
||||||
}
|
|
||||||
|
|
||||||
myAISContext->Redisplay (myAISContext->SelectedInteractive());
|
myAISContext->Redisplay (aSelectedObject);
|
||||||
myState = -1;
|
myState = -1;
|
||||||
myAISContext->CloseLocalContext();
|
myAISContext->CloseLocalContext();
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,7 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant)
|
|||||||
myShape = S.Shape();
|
myShape = S.Shape();
|
||||||
SetHilightMode(0);
|
SetHilightMode(0);
|
||||||
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
||||||
myPlanarFaceColor = Quantity_NOC_FIREBRICK3;
|
myColor = Quantity_NOC_GRAY;
|
||||||
myCylindricalFaceColor = Quantity_NOC_GRAY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
User_Cylinder::User_Cylinder(const gp_Ax2 CylAx2, const Standard_Real R, const Standard_Real H) :
|
User_Cylinder::User_Cylinder(const gp_Ax2 CylAx2, const Standard_Real R, const Standard_Real H) :
|
||||||
@ -47,8 +46,7 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant)
|
|||||||
myShape = aNurbsConvert.Shape();
|
myShape = aNurbsConvert.Shape();
|
||||||
SetHilightMode(0);
|
SetHilightMode(0);
|
||||||
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
||||||
myPlanarFaceColor = Quantity_NOC_FIREBRICK3;
|
myColor = Quantity_NOC_KHAKI4;
|
||||||
myCylindricalFaceColor = Quantity_NOC_KHAKI4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void User_Cylinder::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
|
void User_Cylinder::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
|
||||||
@ -56,33 +54,20 @@ void User_Cylinder::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPrese
|
|||||||
const Standard_Integer aMode )
|
const Standard_Integer aMode )
|
||||||
{
|
{
|
||||||
switch (aMode) {
|
switch (aMode) {
|
||||||
case 0:
|
case AIS_WireFrame:
|
||||||
StdPrs_WFShape::Add(aPresentation,myShape, myDrawer );
|
{
|
||||||
break;
|
StdPrs_WFShape::Add(aPresentation,myShape, myDrawer );
|
||||||
case 1:
|
break;
|
||||||
|
}
|
||||||
|
case AIS_Shaded:
|
||||||
{
|
{
|
||||||
|
|
||||||
Standard_Real aTransparency = Transparency();
|
Standard_Real aTransparency = Transparency();
|
||||||
Graphic3d_NameOfMaterial aMaterial = Material();
|
Graphic3d_NameOfMaterial aMaterial = Material();
|
||||||
TopExp_Explorer Ex;
|
myDrawer->ShadingAspect()->SetMaterial(aMaterial);
|
||||||
Handle(Geom_Surface) Surface;
|
myDrawer->ShadingAspect()->SetColor(myColor);
|
||||||
|
myDrawer->ShadingAspect()->SetTransparency (aTransparency);
|
||||||
for (Ex.Init(myShape,TopAbs_FACE); Ex.More(); Ex.Next())
|
StdPrs_ShadedShape::Add(aPresentation,myShape, myDrawer);
|
||||||
{
|
|
||||||
|
|
||||||
Surface = BRep_Tool::Surface(TopoDS::Face(Ex.Current()));
|
|
||||||
myDrawer->ShadingAspect()->SetMaterial(aMaterial);
|
|
||||||
if (Surface->IsKind(STANDARD_TYPE(Geom_Plane)))
|
|
||||||
myDrawer->ShadingAspect()->SetColor(myPlanarFaceColor);
|
|
||||||
else
|
|
||||||
myDrawer->ShadingAspect()->SetColor(myCylindricalFaceColor);
|
|
||||||
|
|
||||||
|
|
||||||
myDrawer->ShadingAspect()->SetTransparency (aTransparency);
|
|
||||||
StdPrs_ShadedShape::Add(aPresentation,Ex.Current(), myDrawer);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
case 6: //color
|
case 6: //color
|
||||||
{
|
{
|
||||||
@ -309,7 +294,11 @@ case 6: //color
|
|||||||
void User_Cylinder::Compute(const Handle(Prs3d_Projector)& aProjector,
|
void User_Cylinder::Compute(const Handle(Prs3d_Projector)& aProjector,
|
||||||
const Handle(Prs3d_Presentation)& aPresentation)
|
const Handle(Prs3d_Presentation)& aPresentation)
|
||||||
{
|
{
|
||||||
myDrawer->EnableDrawHiddenLine();
|
Handle (Prs3d_Drawer) aDefDrawer = GetContext()->DefaultDrawer();
|
||||||
|
if (aDefDrawer->DrawHiddenLine())
|
||||||
|
myDrawer->EnableDrawHiddenLine();
|
||||||
|
else
|
||||||
|
myDrawer->DisableDrawHiddenLine();
|
||||||
StdPrs_HLRPolyShape::Add(aPresentation,myShape,myDrawer,aProjector);
|
StdPrs_HLRPolyShape::Add(aPresentation,myShape,myDrawer,aProjector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,16 +326,6 @@ Standard_Boolean User_Cylinder::AcceptShapeDecomposition() const
|
|||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
void User_Cylinder::SetPlanarFaceColor(const Quantity_Color acolor)
|
|
||||||
{
|
|
||||||
myPlanarFaceColor = acolor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void User_Cylinder::SetCylindricalFaceColor(const Quantity_Color acolor)
|
|
||||||
{
|
|
||||||
myCylindricalFaceColor = acolor;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean User_Cylinder::TriangleIsValid(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3) const
|
Standard_Boolean User_Cylinder::TriangleIsValid(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3) const
|
||||||
{
|
{
|
||||||
gp_Vec V1(P1,P2);// V1=(P1,P2)
|
gp_Vec V1(P1,P2);// V1=(P1,P2)
|
||||||
@ -496,6 +475,5 @@ Quantity_Color User_Cylinder::Color(gp_Pnt& thePoint,Standard_Real AltMin,Standa
|
|||||||
void User_Cylinder::SetColor(const Quantity_Color &aColor)
|
void User_Cylinder::SetColor(const Quantity_Color &aColor)
|
||||||
{
|
{
|
||||||
AIS_InteractiveObject::SetColor(aColor);
|
AIS_InteractiveObject::SetColor(aColor);
|
||||||
SetPlanarFaceColor(aColor);
|
myColor = aColor;
|
||||||
SetCylindricalFaceColor(aColor);
|
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,6 @@ public:
|
|||||||
~User_Cylinder(){};
|
~User_Cylinder(){};
|
||||||
|
|
||||||
Standard_Boolean AcceptShapeDecomposition() const;
|
Standard_Boolean AcceptShapeDecomposition() const;
|
||||||
void Standard_EXPORT SetCylindricalFaceColor(const Quantity_Color acolor);
|
|
||||||
void Standard_EXPORT SetPlanarFaceColor(const Quantity_Color);
|
|
||||||
Standard_Integer NbPossibleSelection() const;
|
Standard_Integer NbPossibleSelection() const;
|
||||||
void SetColor(const Quantity_Color &aColor);
|
void SetColor(const Quantity_Color &aColor);
|
||||||
|
|
||||||
@ -41,10 +39,7 @@ private:
|
|||||||
//
|
//
|
||||||
DEFINE_STANDARD_RTTIEXT(User_Cylinder,AIS_InteractiveObject)
|
DEFINE_STANDARD_RTTIEXT(User_Cylinder,AIS_InteractiveObject)
|
||||||
private:
|
private:
|
||||||
// Quantity_NameOfColor myCylindricalFaceColor;
|
Quantity_Color myColor;
|
||||||
// Quantity_NameOfColor myPlanarFaceColor;
|
|
||||||
Quantity_Color myCylindricalFaceColor;
|
|
||||||
Quantity_Color myPlanarFaceColor;
|
|
||||||
TopoDS_Shape myShape;
|
TopoDS_Shape myShape;
|
||||||
|
|
||||||
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user