mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0027555: Visualization, AIS_Shape - own deviation coefficient change is not considered by Wireframe presentation mode
This commit is contained in:
parent
52db475165
commit
83b0f13a58
@ -310,14 +310,8 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
if (myDrawer->IsAutoTriangulation())
|
||||
{
|
||||
// compute mesh for entire shape beforehand to ensure consistency and optimizations (parallelization)
|
||||
Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
|
||||
Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
|
||||
Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
|
||||
if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
|
||||
|| (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
|
||||
{
|
||||
BRepTools::Clean (myshape);
|
||||
}
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
|
||||
|
||||
// After this call if type of deflection is relative
|
||||
// computed deflection coefficient is stored as absolute.
|
||||
Standard_Boolean wasRecomputed = StdPrs_ToolTriangulatedShape::Tessellate (myshape, myDrawer);
|
||||
@ -331,6 +325,8 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
}
|
||||
else // WireFrame mode
|
||||
{
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
|
||||
|
||||
// After this call if type of deflection is relative
|
||||
// computed deflection coefficient is stored as absolute.
|
||||
Prs3d::GetDeflection (myshape, myDrawer);
|
||||
|
@ -122,7 +122,7 @@ Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const
|
||||
//=======================================================================
|
||||
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
|
||||
const Handle(Prs3d_Presentation)& aPrs,
|
||||
const Standard_Integer aMode)
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
aPrs->Clear();
|
||||
if(myshape.IsNull()) return;
|
||||
@ -144,13 +144,14 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
|
||||
if (IsInfinite())
|
||||
{
|
||||
aPrs->SetInfiniteState (Standard_True); //not taken in account duting FITALL
|
||||
aPrs->SetInfiniteState (Standard_True); //not taken in account during FITALL
|
||||
}
|
||||
|
||||
switch (aMode)
|
||||
switch (theMode)
|
||||
{
|
||||
case AIS_WireFrame:
|
||||
{
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
@ -169,18 +170,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
}
|
||||
case AIS_Shaded:
|
||||
{
|
||||
if (myDrawer->IsAutoTriangulation())
|
||||
{
|
||||
Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
|
||||
Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
|
||||
Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
|
||||
if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
|
||||
|| (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
|
||||
{
|
||||
BRepTools::Clean (myshape);
|
||||
}
|
||||
}
|
||||
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
|
||||
if ((Standard_Integer) myshape.ShapeType() > 4)
|
||||
{
|
||||
StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
|
||||
|
@ -440,28 +440,14 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager3d)& /*t
|
||||
{
|
||||
case AIS_WireFrame:
|
||||
{
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
|
||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||
break;
|
||||
}
|
||||
case AIS_Shaded:
|
||||
case 3: // texture mapping on triangulation
|
||||
{
|
||||
if (myDrawer->IsAutoTriangulation())
|
||||
{
|
||||
Standard_Real aPrevAngle;
|
||||
Standard_Real aNewAngle;
|
||||
Standard_Real aPrevCoeff;
|
||||
Standard_Real aNewCoeff;
|
||||
|
||||
Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (aNewAngle, aPrevAngle);
|
||||
Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient (aNewCoeff,aPrevCoeff);
|
||||
if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnDeviationAngle) ||
|
||||
((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnDeviationCoefficient))
|
||||
{
|
||||
BRepTools::Clean (myshape);
|
||||
}
|
||||
}
|
||||
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
|
||||
if (myshape.ShapeType() > TopAbs_FACE)
|
||||
{
|
||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||
|
@ -202,6 +202,15 @@ public:
|
||||
: 0.0;
|
||||
}
|
||||
|
||||
//! Updates the previous value used for the chordal deviation coefficient to the current state.
|
||||
void UpdatePreviousDeviationCoefficient()
|
||||
{
|
||||
if (myHasOwnDeviationCoefficient)
|
||||
{
|
||||
myPreviousDeviationCoefficient = DeviationCoefficient();
|
||||
}
|
||||
}
|
||||
|
||||
//! Sets the deviation coefficient aCoefficient for removal
|
||||
//! of hidden lines created by different viewpoints in
|
||||
//! different presentations. The Default value is 0.02.
|
||||
@ -282,6 +291,15 @@ public:
|
||||
: 0.0;
|
||||
}
|
||||
|
||||
//! Updates the previous deviation angle to the current value
|
||||
void UpdatePreviousDeviationAngle()
|
||||
{
|
||||
if (myHasOwnDeviationAngle)
|
||||
{
|
||||
myPreviousDeviationAngle = DeviationAngle();
|
||||
}
|
||||
}
|
||||
|
||||
//! Sets anAngle, the angle of maximum chordal deviation for removal of hidden lines created by
|
||||
//! different viewpoints in different presentations.
|
||||
//! The default value is 20 * M_PI / 180.
|
||||
|
@ -252,3 +252,37 @@ Standard_Boolean StdPrs_ToolTriangulatedShape::Tessellate (const TopoDS_Shape&
|
||||
|
||||
return wasRecomputed;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ClearOnOwnDeflectionChange
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Boolean theToResetCoeff)
|
||||
{
|
||||
if (!theDrawer->IsAutoTriangulation()
|
||||
|| theShape.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Boolean isOwnDeviationAngle = theDrawer->HasOwnDeviationAngle();
|
||||
const Standard_Boolean isOwnDeviationCoefficient = theDrawer->HasOwnDeviationCoefficient();
|
||||
const Standard_Real anAngleNew = theDrawer->DeviationAngle();
|
||||
const Standard_Real anAnglePrev = theDrawer->PreviousDeviationAngle();
|
||||
const Standard_Real aCoeffNew = theDrawer->DeviationCoefficient();
|
||||
const Standard_Real aCoeffPrev = theDrawer->PreviousDeviationCoefficient();
|
||||
if ((!isOwnDeviationAngle || Abs (anAngleNew - anAnglePrev) <= Precision::Angular())
|
||||
&& (!isOwnDeviationCoefficient || Abs (aCoeffNew - aCoeffPrev) <= Precision::Confusion()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BRepTools::Clean (theShape);
|
||||
if (theToResetCoeff)
|
||||
{
|
||||
theDrawer->UpdatePreviousDeviationAngle();
|
||||
theDrawer->UpdatePreviousDeviationCoefficient();
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,18 @@ public:
|
||||
//! @return true if tesselation was recomputed and false otherwise.
|
||||
Standard_EXPORT static Standard_Boolean Tessellate (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
//! If presentation has own deviation coefficient and IsAutoTriangulation() is true,
|
||||
//! function will compare actual coefficients with previous values and will clear triangulation on their change
|
||||
//! (regardless actual tessellation quality).
|
||||
//! Function is placed here for compatibility reasons - new code should avoid using IsAutoTriangulation().
|
||||
//! @param theShape [in] the shape
|
||||
//! @param theDrawer [in] the display settings
|
||||
//! @param theToResetCoeff [in] updates coefficients in theDrawer to actual state to avoid redundant recomputations
|
||||
Standard_EXPORT static void ClearOnOwnDeflectionChange (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Boolean theToResetCoeff);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user