1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0027869: Visualization - AIS_ConnectedInteractive does not support exact HLR mode

AIS_ConnectedInteractive now shares HLR computation code with AIS_Shape.

BRepTools_WireExplorer::Orientation() now returns TopAbs_FORWARD
instead of throwing exception in case of infinite Edge without vertices.

StdSelect_BRepSelectionTool::GetSensitiveForFace() now creates Select3D_SensitiveCurve
from 2 points in case of infinite Edge instead of Select3D_SensitiveFace.
This commit is contained in:
kgv
2017-09-10 21:24:56 +03:00
committed by bugmaster
parent a966092904
commit c7ba457824
7 changed files with 299 additions and 359 deletions

View File

@@ -164,54 +164,10 @@ void AIS_ConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Compute (const Handle(Prs3d_Projector)& theProjector,
const Handle(Prs3d_Presentation)& thePresentation,
const Handle(Prs3d_Presentation)& thePrs,
const TopoDS_Shape& theShape)
{
if (myShape.IsNull())
{
return;
}
switch (theShape.ShapeType())
{
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
{
thePresentation->SetDisplayPriority (4);
StdPrs_WFShape::Add (thePresentation, theShape, myDrawer);
break;
}
default:
{
Handle(Prs3d_Drawer) aDefaultDrawer = GetContext()->DefaultDrawer();
if (aDefaultDrawer->DrawHiddenLine())
{
myDrawer->EnableDrawHiddenLine();
}
else
{
myDrawer->DisableDrawHiddenLine();
}
Aspect_TypeOfDeflection aPrevDeflection = aDefaultDrawer->TypeOfDeflection();
aDefaultDrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
// process HLRAngle and HLRDeviationCoefficient()
Standard_Real aPrevAngle = myDrawer->HLRAngle();
Standard_Real aNewAngle = aDefaultDrawer->HLRAngle();
if (myDrawer->IsAutoTriangulation() &&
Abs (aNewAngle - aPrevAngle) > Precision::Angular())
{
BRepTools::Clean (theShape);
}
myDrawer->SetHLRAngle (aNewAngle);
myDrawer->SetHLRDeviationCoefficient (aDefaultDrawer->HLRDeviationCoefficient());
StdPrs_HLRPolyShape::Add (thePresentation, theShape, myDrawer, theProjector);
aDefaultDrawer->SetTypeOfDeflection (aPrevDeflection);
}
}
AIS_Shape::computeHlrPresentation (theProjector, thePrs, theShape, myDrawer);
}
//=======================================================================

View File

@@ -35,6 +35,8 @@
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_SequenceOfGroup.hxx>
#include <Graphic3d_Structure.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <HLRBRep.hxx>
#include <OSD_Timer.hxx>
#include <Precision.hxx>
@@ -157,14 +159,11 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
OCC_CATCH_SIGNALS
StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
}
catch (Standard_Failure)
catch (Standard_Failure const& anException)
{
#ifdef OCCT_DEBUG
cout << "AIS_Shape::Compute() failed" << endl;
cout << "a Shape should be incorrect : No Compute can be maked on it " << endl;
#endif
// presentation of the bounding box is calculated
// Compute(aPresentationManager,aPrs,2);
Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ "Error: AIS_Shape::Compute() wireframe presentation builder has failed ("
+ anException.GetMessageString() + ")", Message_Fail);
}
break;
}
@@ -191,11 +190,11 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
myUVOrigin, myUVRepeat, myUVScale);
}
catch (Standard_Failure)
catch (Standard_Failure const& anException)
{
#ifdef OCCT_DEBUG
cout << "AIS_Shape::Compute() in ShadingMode failed" << endl;
#endif
Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ "Error: AIS_Shape::Compute() shaded presentation builder has failed ("
+ anException.GetMessageString() + ")", Message_Fail);
StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
}
}
@@ -227,150 +226,88 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
}
//=======================================================================
//function : Compute
//purpose : Hidden Line Removal
//function : computeHlrPresentation
//purpose :
//=======================================================================
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
void AIS_Shape::computeHlrPresentation (const Handle(Prs3d_Projector)& theProjector,
const Handle(Prs3d_Presentation)& thePrs,
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer)
{
Compute(aProjector,aPresentation,myshape);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Geom_Transformation)& TheTrsf,
const Handle(Prs3d_Presentation)& aPresentation)
{
const TopLoc_Location& loc = myshape.Location();
TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
Compute(aProjector,aPresentation,shbis);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation,
const TopoDS_Shape& SH)
{
if (SH.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator anExplor (SH);
if (!anExplor.More()) // Shape vide -> Assemblage vide.
return;
if (theShape.IsNull())
{
return;
}
Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
if (defdrawer->DrawHiddenLine())
{myDrawer->EnableDrawHiddenLine();}
else {myDrawer->DisableDrawHiddenLine();}
Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
if (myDrawer->IsAutoTriangulation())
switch (theShape.ShapeType())
{
// coefficients for calculation
Standard_Real aPrevAngle, aNewAngle, aPrevCoeff, aNewCoeff;
Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle (aNewAngle, aPrevAngle);
Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient (aNewCoeff, aPrevCoeff);
if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient))
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
{
BRepTools::Clean(SH);
thePrs->SetDisplayPriority (4);
StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
return;
}
case TopAbs_COMPOUND:
{
TopoDS_Iterator anExplor (theShape);
if (!anExplor.More())
{
return;
}
break;
}
default:
{
break;
}
}
const Handle(Prs3d_Drawer)& aDefDrawer = theDrawer->Link();
if (aDefDrawer->DrawHiddenLine())
{
try {
theDrawer->EnableDrawHiddenLine();
}
else
{
theDrawer->DisableDrawHiddenLine();
}
const Aspect_TypeOfDeflection aPrevDef = aDefDrawer->TypeOfDeflection();
aDefDrawer->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
if (theDrawer->IsAutoTriangulation())
{
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (theShape, theDrawer, Standard_True);
}
{
try
{
OCC_CATCH_SIGNALS
switch (TypeOfHLR()) {
switch (theDrawer->TypeOfHLR())
{
case Prs3d_TOH_Algo:
StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector);
StdPrs_HLRShape::Add (thePrs, theShape, theDrawer, theProjector);
break;
case Prs3d_TOH_PolyAlgo:
default:
StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector);
StdPrs_HLRPolyShape::Add (thePrs, theShape, theDrawer, theProjector);
break;
}
}
catch (Standard_Failure) {
#ifdef OCCT_DEBUG
cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl;
#endif
StdPrs_WFShape::Add(aPresentation,SH,myDrawer);
catch (Standard_Failure const& anException)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ "Error: AIS_Shape::Compute() HLR Algorithm has failed ("
+ anException.GetMessageString() + ")", Message_Fail);
StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
}
}
defdrawer->SetTypeOfDeflection (prevdef);
aDefDrawer->SetTypeOfDeflection (aPrevDef);
}
//=======================================================================
//function : SelectionType
//purpose : gives the type according to the Index of Selection Mode
//=======================================================================
TopAbs_ShapeEnum AIS_Shape::SelectionType(const Standard_Integer aMode)
{
switch(aMode){
case 1:
return TopAbs_VERTEX;
case 2:
return TopAbs_EDGE;
case 3:
return TopAbs_WIRE;
case 4:
return TopAbs_FACE;
case 5:
return TopAbs_SHELL;
case 6:
return TopAbs_SOLID;
case 7:
return TopAbs_COMPSOLID;
case 8:
return TopAbs_COMPOUND;
case 0:
default:
return TopAbs_SHAPE;
}
}
//=======================================================================
//function : SelectionType
//purpose : gives the SelectionMode according to the Type od Decomposition...
//=======================================================================
Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType)
{
switch(aType){
case TopAbs_VERTEX:
return 1;
case TopAbs_EDGE:
return 2;
case TopAbs_WIRE:
return 3;
case TopAbs_FACE:
return 4;
case TopAbs_SHELL:
return 5;
case TopAbs_SOLID:
return 6;
case TopAbs_COMPSOLID:
return 7;
case TopAbs_COMPOUND:
return 8;
case TopAbs_SHAPE:
default:
return 0;
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
@@ -393,7 +330,8 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
// POP protection against crash in low layers
Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
try {
try
{
OCC_CATCH_SIGNALS
StdSelect_BRepSelectionTool::Load(aSelection,
this,
@@ -402,9 +340,14 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
aDeflection,
myDrawer->HLRAngle(),
myDrawer->IsAutoTriangulation());
} catch ( Standard_Failure ) {
// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
if ( aMode == 0 ) {
}
catch (Standard_Failure const& anException)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ "Error: AIS_Shape::ComputeSelection(" + aMode + ") has failed ("
+ anException.GetMessageString() + ")", Message_Fail);
if (aMode == 0)
{
aSelection->Clear();
Bnd_Box B = BoundingBox();
Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);

View File

@@ -211,23 +211,42 @@ public:
//! Returns the transparency attributes of the shape accordingly to
//! the current facing model;
Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE;
//! Activates the same TopAbs shape enumerations as
//! those used by SelectionMode assigning a type to the mode aDecompositionMode.
Standard_EXPORT static TopAbs_ShapeEnum SelectionType (const Standard_Integer aDecompositionMode);
//! Establishes an equivalence between a mode and the
//! type, aShapeType, of selection. The correspondences are as follows:
//! - mode 0 - Shape
//! - mode 1 - Vertex
//! - mode 2 - Edge
//! - mode 3 - Wire
//! - mode 4 - Face
//! - mode 5 - Shell
//! - mode 6 - Solid
//! - mode 7 - Compsolid
//! - mode 8 - Compound
Standard_EXPORT static Standard_Integer SelectionMode (const TopAbs_ShapeEnum aShapeType);
//! Return shape type for specified selection mode.
static TopAbs_ShapeEnum SelectionType (const Standard_Integer theSelMode)
{
switch (theSelMode)
{
case 1: return TopAbs_VERTEX;
case 2: return TopAbs_EDGE;
case 3: return TopAbs_WIRE;
case 4: return TopAbs_FACE;
case 5: return TopAbs_SHELL;
case 6: return TopAbs_SOLID;
case 7: return TopAbs_COMPSOLID;
case 8: return TopAbs_COMPOUND;
case 0: return TopAbs_SHAPE;
}
return TopAbs_SHAPE;
}
//! Return selection mode for specified shape type.
static Standard_Integer SelectionMode (const TopAbs_ShapeEnum theShapeType)
{
switch (theShapeType)
{
case TopAbs_VERTEX: return 1;
case TopAbs_EDGE: return 2;
case TopAbs_WIRE: return 3;
case TopAbs_FACE: return 4;
case TopAbs_SHELL: return 5;
case TopAbs_SOLID: return 6;
case TopAbs_COMPSOLID: return 7;
case TopAbs_COMPOUND: return 8;
case TopAbs_SHAPE: return 0;
}
return 0;
}
public: //! @name methods to alter texture mapping properties
@@ -256,13 +275,31 @@ public: //! @name methods to alter texture mapping properties
protected:
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
//! Compute normal presentation.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute projected presentation.
virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
{
computeHlrPresentation (theProjector, thePrs, myshape, myDrawer);
}
//! Compute projected presentation with transformation.
virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
const Handle(Geom_Transformation)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
{
const TopLoc_Location& aLoc = myshape.Location();
const TopoDS_Shape aShape = myshape.Located (TopLoc_Location (theTrsf->Trsf()) * aLoc);
computeHlrPresentation (theProjector, thePrs, aShape, myDrawer);
}
//! Compute selection.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void LoadRecomputable (const Standard_Integer TheMode);
@@ -274,9 +311,13 @@ protected:
Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const;
private:
public:
Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation, const TopoDS_Shape& ashape);
//! Compute HLR presentation for specified shape.
Standard_EXPORT static void computeHlrPresentation (const Handle(Prs3d_Projector)& theProjector,
const Handle(Prs3d_Presentation)& thePrs,
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer);
protected: