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
#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>
}
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;
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
{
StdPrs_WFDeflectionShape::Add (thePrs, aShapeDraw, aDrawer);
}
+ aDrawer->SetTypeOfDeflection (aPrevType);
}
}
}
#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>
-- 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.
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;
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;
#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>
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);
+}
//==================================================
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);
+}
Attributes() const
{return myDrawer;}
+inline const Handle(Prs3d_Drawer)& SelectMgr_SelectableObject::
+HilightAttributes() const
+{return myHilightDrawer;}
if (!aShapeIter.More())
{
// compound contains no shaded elements at all
- StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
+ StdPrs_WFDeflectionShape::Add (thePrs, theShape, theDrawer);
return;
}
}
if (hasElement)
{
- StdPrs_WFShape::Add (thePrs, aCompoundWF, theDrawer);
+ StdPrs_WFDeflectionShape::Add (thePrs, aCompoundWF, theDrawer);
}
}
// 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:
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())
{
// highlight and set layer
PM->Highlight (myPrsSh, M);
-
}
else
{
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())
{
{
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())
{
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;
---C++: inline
fields
- mysh : Shape from TopoDS;
+ mysh : Shape from TopoDS;
+ myDrawer : Drawer from Prs3d;
end Shape;
// 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 ,
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"
}
--- /dev/null
+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