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);
}
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);
//=======================================================================
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;
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
}
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);
{
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);
: 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.
: 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.
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();
+ }
+}
//! @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