1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0025540: Visualization - discretization of the circle differs in shaded and wireframe modes.

1. "HilightDrawer" were added to SelectMgr_SelectableObject.
2. Static drawer in StdSelect_Shape was replaced by class member. It's value is taken from special HilightDrawer of Selectable() object.
3. Computed relative deflection is stored as absolute deflection to be used for sub-shapes.
4. The ColoredShape object was updated to use for sub-shapes relative deflection computed for main shape.
5. Test case was added.

Tuning of test-case bug25532
This commit is contained in:
osa 2015-03-05 14:05:11 +03:00 committed by bugmaster
parent 076b125a90
commit 7f91733552
13 changed files with 238 additions and 41 deletions

View File

@ -36,7 +36,6 @@
#include <StdPrs_ShadedShape.hxx>
#include <StdPrs_ToolShadedShape.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
#include <StdPrs_WFShape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
@ -321,6 +320,15 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
}
StdPrs_ShadedShape::Tessellate (myshape, myDrawer);
}
// After this call if type of deflection is relative
// computed deflection coefficient is stored as absolute.
StdPrs_ShadedShape::Tessellate (myshape, myDrawer);
}
else // WireFrame mode
{
// After this call if type of deflection is relative
// computed deflection coefficient is stored as absolute.
Prs3d::GetDeflection (myshape, myDrawer);
}
TopoDS_Compound anOpened, aClosed;
@ -395,6 +403,12 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
aDrawer = myDrawer;
}
// It is supposed that absolute deflection contains previously computed relative deflection
// (if deflection type is relative).
// In case of CustomDrawer it is taken from Link().
Aspect_TypeOfDeflection aPrevType = aDrawer->TypeOfDeflection();
aDrawer->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
// Draw each kind of subshapes and personal-colored shapes in a separate group
// since it's necessary to set transparency/material for all subshapes
// without affecting their unique colors
@ -408,6 +422,7 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
{
StdPrs_WFDeflectionShape::Add (thePrs, aShapeDraw, aDrawer);
}
aDrawer->SetTypeOfDeflection (aPrevType);
}
}
}

View File

@ -28,7 +28,6 @@
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <AIS_LocalStatus.hxx>
#include <StdPrs_WFShape.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_Group.hxx>
#include <Select3D_SensitiveTriangulation.hxx>

View File

@ -155,6 +155,8 @@ is
-- deviation coefficient from theDrawer and the shape's bounding box;</li>
-- <li><b>Aspect_TOD_ABSOLUTE</b>: the maximal chordial deviation from theDrawer is returned.</li>
-- </ul>
-- In case of the type of deflection in theDrawer computed relative deflection for shape
-- is stored as absolute deflection. It is necessary to use it later on for sub-shapes.
-- This function should always be used to compute the deflection value for building
-- discrete representations of the shape (triangualtion, wireframe) to avoid incosistencies
-- between different representations of the shape and undesirable visual artifacts.

View File

@ -69,6 +69,9 @@ Standard_Real Prs3d::GetDeflection (const TopoDS_Shape& theShape,
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
aDeflection = MAX3 (aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * theDrawer->DeviationCoefficient() * 4.0;
// we store computed relative deflection of shape as absolute deviation coefficient
// in case relative type to use it later on for sub-shapes.
theDrawer->SetMaximalChordialDeviation (aDeflection);
}
}
return aDeflection;

View File

@ -198,10 +198,25 @@ is
UnsetAttributes(me:mutable) is virtual;
---Purpose: Clears settings provided by the drawing tool theDrawer.
SetHilightAttributes(me:mutable; theDrawer: Drawer from Prs3d) is virtual;
---Purpose: Initializes the hilight drawing tool theDrawer.
HilightAttributes(me) returns any Drawer from Prs3d;
---C++: return const&
---C++: inline
---Purpose: Returns the hilight attributes settings.
UnsetHilightAttributes(me:mutable) is virtual;
---Purpose: Clears settings provided by the hilight drawing tool theDrawer.
InitDefaultHilightAttributes(myclass; theDrawer : Drawer from Prs3d);
---Purpose: Initializes theDrawer by default hilight settings.
fields
myselections : SequenceOfSelection is protected;
myDrawer : Drawer from Prs3d is protected;
myHilightDrawer : Drawer from Prs3d is protected;
mycurrent : Integer;
myAutoHilight : Boolean from Standard;

View File

@ -24,6 +24,12 @@
#include <SelectMgr_EntityOwner.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <TopLoc_Location.hxx>
#include <gp_Pnt.hxx>
@ -47,8 +53,12 @@ static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq,
SelectMgr_SelectableObject::SelectMgr_SelectableObject( const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
PrsMgr_PresentableObject (aTypeOfPresentation3d),
myDrawer (new Prs3d_Drawer()),
myHilightDrawer (new Prs3d_Drawer()),
myAutoHilight (Standard_True)
{}
{
InitDefaultHilightAttributes (myHilightDrawer);
myHilightDrawer->Link (myDrawer);
}
//==================================================
@ -378,3 +388,93 @@ void SelectMgr_SelectableObject::UnsetAttributes()
myDrawer = aDrawer;
}
//=======================================================================
//function : SetHilightAttributes
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::SetHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer)
{
myHilightDrawer = theDrawer;
}
//=======================================================================
//function : UnsetAttributes
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::UnsetHilightAttributes()
{
Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer();
InitDefaultHilightAttributes (aDrawer);
aDrawer->Link (myDrawer);
myHilightDrawer = aDrawer;
}
//=======================================================================
//function : InitDefaultHilightAttributes
//purpose :
//=======================================================================
void SelectMgr_SelectableObject::InitDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer)
{
if (!theDrawer->HasOwnPointAspect())
{
theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
if (theDrawer->HasLink())
{
*theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
}
}
if (!theDrawer->HasOwnLineAspect())
{
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
if (theDrawer->HasLink())
{
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
}
}
if (!theDrawer->HasOwnWireAspect())
{
theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
if (theDrawer->HasLink())
{
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
}
}
if (!theDrawer->HasOwnPlaneAspect())
{
theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect());
if (theDrawer->HasLink())
{
*theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect();
}
}
if (!theDrawer->HasOwnFreeBoundaryAspect())
{
theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
if (theDrawer->HasLink())
{
*theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
}
}
if (!theDrawer->HasOwnUnFreeBoundaryAspect())
{
theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
if (theDrawer->HasLink())
{
*theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
}
}
theDrawer->WireAspect()->SetWidth(2.);
theDrawer->LineAspect()->SetWidth(2.);
theDrawer->PlaneAspect()->EdgesAspect()->SetWidth(2.);
theDrawer->FreeBoundaryAspect()->SetWidth(2.);
theDrawer->UnFreeBoundaryAspect()->SetWidth(2.);
theDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_POINT);
theDrawer->PointAspect()->SetScale(2.);
// By default the hilight drawer has absolute type of deflection.
// It is supposed that absolute deflection is taken from Link().
// It is necessary to use for all sub-shapes identical coefficient
// computed in ::Compute() call for whole shape and stored in base drawer.
theDrawer->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE);
}

View File

@ -29,3 +29,6 @@ inline const Handle(Prs3d_Drawer)& SelectMgr_SelectableObject::
Attributes() const
{return myDrawer;}
inline const Handle(Prs3d_Drawer)& SelectMgr_SelectableObject::
HilightAttributes() const
{return myHilightDrawer;}

View File

@ -74,7 +74,7 @@ namespace
if (!aShapeIter.More())
{
// compound contains no shaded elements at all
StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
StdPrs_WFDeflectionShape::Add (thePrs, theShape, theDrawer);
return;
}
@ -103,7 +103,7 @@ namespace
}
if (hasElement)
{
StdPrs_WFShape::Add (thePrs, aCompoundWF, theDrawer);
StdPrs_WFDeflectionShape::Add (thePrs, aCompoundWF, theDrawer);
}
}

View File

@ -15,11 +15,10 @@
// commercial license or contractual agreement.
#include <StdSelect_BRepOwner.ixx>
#include <SelectBasics_EntityOwner.hxx>
#include <StdPrs_WFShape.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Prs3d_Drawer.hxx>
#include <SelectBasics_EntityOwner.hxx>
//==================================================
// Function:
@ -88,10 +87,21 @@ void StdSelect_BRepOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
myPrsSh.Nullify();
}
Handle(Prs3d_Drawer) aDrawer;
if (!aSel.IsNull())
{
aDrawer = aSel->HilightAttributes();
}
else
{
aDrawer = new Prs3d_Drawer();
SelectMgr_SelectableObject::InitDefaultHilightAttributes (aDrawer);
}
// generate new presentable shape
if (myPrsSh.IsNull())
{
myPrsSh = new StdSelect_Shape (myShape);
myPrsSh = new StdSelect_Shape (myShape, aDrawer);
}
if (!aSel.IsNull())
{
@ -100,7 +110,6 @@ void StdSelect_BRepOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
// highlight and set layer
PM->Highlight (myPrsSh, M);
}
else
{
@ -131,6 +140,17 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag
myPrsSh.Nullify();
}
Handle(Prs3d_Drawer) aDrawer;
if (!aSel.IsNull())
{
aDrawer = aSel->HilightAttributes();
}
else
{
aDrawer = new Prs3d_Drawer();
SelectMgr_SelectableObject::InitDefaultHilightAttributes (aDrawer);
}
// generate new presentable shape
if(myPrsSh.IsNull())
{
@ -138,10 +158,10 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag
{
TopLoc_Location lbid = Location() * myShape.Location();
TopoDS_Shape ShBis = myShape.Located(lbid);
myPrsSh = new StdSelect_Shape(ShBis);
myPrsSh = new StdSelect_Shape(ShBis, aDrawer);
}
else
myPrsSh = new StdSelect_Shape(myShape);
myPrsSh = new StdSelect_Shape(myShape, aDrawer);
}
if (!aSel.IsNull())
{

View File

@ -23,10 +23,12 @@ uses
Transformation from Geom,
Shape from TopoDS,
PresentationManager3d from PrsMgr,
Drawer from Prs3d,
Presentation from Prs3d
is
Create(Sh:Shape from TopoDS) returns Shape from StdSelect;
Create(theShape : Shape from TopoDS;
theDrawer : Drawer from Prs3d) returns Shape from StdSelect;
Compute(me:mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
@ -61,5 +63,6 @@ is
---C++: inline
fields
mysh : Shape from TopoDS;
mysh : Shape from TopoDS;
myDrawer : Drawer from Prs3d;
end Shape;

View File

@ -15,47 +15,35 @@
// commercial license or contractual agreement.
#include <StdSelect_Shape.ixx>
#include <StdPrs_WFShape.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <StdPrs_ShadedShape.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
#include <TopAbs_ShapeEnum.hxx>
StdSelect_Shape::StdSelect_Shape(const TopoDS_Shape& sh):
mysh(sh)
StdSelect_Shape::StdSelect_Shape (const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer):
mysh (theShape),
myDrawer (theDrawer)
{}
void StdSelect_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*PM*/,
const Handle(Prs3d_Presentation)& P,
const Standard_Integer aMode)
{
if(mysh.IsNull()) return;
static Handle(Prs3d_Drawer) DRWR;
if(DRWR.IsNull()){
DRWR = new Prs3d_Drawer();
DRWR->WireAspect()->SetWidth(2);
DRWR->LineAspect()->SetWidth(2.);
DRWR->PlaneAspect()->EdgesAspect()->SetWidth(2.);
DRWR->FreeBoundaryAspect()->SetWidth(2.);
DRWR->UnFreeBoundaryAspect()->SetWidth(2.);
Standard_Integer I = 5;//pour tests...
DRWR->PointAspect()->SetTypeOfMarker((Aspect_TypeOfMarker)I);
DRWR->PointAspect()->SetScale(2.);
if(mysh.IsNull())
{
return;
}
Standard_Boolean CanShade = (mysh.ShapeType()<5 || mysh.ShapeType()==8);
if(aMode==1){
if(CanShade)
StdPrs_ShadedShape::Add(P,mysh,DRWR);
StdPrs_ShadedShape::Add (P, mysh, myDrawer);
else
StdPrs_WFShape::Add(P,mysh,DRWR);
StdPrs_WFDeflectionShape::Add (P, mysh, myDrawer);
}
else if (aMode==0)
StdPrs_WFShape::Add(P,mysh,DRWR);
StdPrs_WFDeflectionShape::Add (P, mysh, myDrawer);
}
void StdSelect_Shape::Compute(const Handle(Prs3d_Projector)& aProjector ,

View File

@ -47,8 +47,8 @@ puts "Clearing (connected): [expr $aMemClear2 / (1024 * 1024)] MiB"
set aRatio [expr $aMemClear2 / double($aMemClear1)]
# check if the memory difference is greater than 10%
if [expr $aRatio > 1.1] {
# check if the memory difference is greater than 20%
if [expr $aRatio > 1.2] {
puts "Error : TEST FAILED"
}

49
tests/bugs/vis/bug25540 Normal file
View File

@ -0,0 +1,49 @@
puts "============"
puts "CR25540"
puts "Check that the discretization of local selection,"
puts "wireframe and shaded presentation of shape is identical."
puts "============"
puts ""
vinit View1 w=912 h=912
vclear
# Create object in shaded mode
vsetdispmode 1
pcylinder p 1 100
vdisplay p
vfit
# Setup field of view
vrotate 1 1.5 0
vfit
vtranslateview 24 18.5 0
vzoom 32
vtranslateview -0.1 -0.6 0
vzoom 2
vdump $imagedir/${casename}_shaded_pres.png
vmoveto 100 100
vdump $imagedir/${casename}_h_pres.png
# Activate the local selection by edges and hilight small circle edge.
# It's discretization should coincide with discretization of whole shape hiligting.
vsetam 2
vmoveto 130 80
vdump $imagedir/${casename}_local_h_pres.png
vunsetam
# Explode object on faces
explode p F
# Create colored shape: set another color to one face
vaspects p -subshapes p_3 -setcolor RED
vsetam 0
vmoveto 100 100
vdump $imagedir/${casename}_h_sub_pres.png
vsetam 2
vmoveto 130 80
vdump $imagedir/${casename}_local_h_sub_pres.png