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

0031425: Visualization - free Edge has selection sensitivity inconsistent to presentation

BRepTools::Triangulation() has been extended with a new parameter for checking Poly_Polygon3D presense within free Edges.
StdPrs_WFShape::Add() now performs auto-triangulation in the same way as StdPrs_ShadedShape::Add().
StdSelect_BRepSelectionTool::GetEdgeSensitive() now creates Select3D_SensitiveSegment instead of Select3D_SensitiveCurve for tessellated segment.
Select3D_SensitiveSegment default sensitivity factor has been changed to 3 pixels to match Select3D_SensitiveCurve.

Test case bug23625_1, added workaround for out-of-range crash in HLRBRep_PolyAlgo on re-triangulated shape.
This commit is contained in:
kgv 2020-03-11 17:06:49 +03:00 committed by bugmaster
parent 08669adf1b
commit 29263c947e
14 changed files with 122 additions and 46 deletions

View File

@ -121,21 +121,21 @@ eval compound [explode mass w] mass
compound sample occ name material sheets scale mass text compound sample occ name material sheets scale mass text
compound snowflake lines text drawing compound snowflake lines text drawing
bounding snowflake -save x1 y1 z1 x2 y2 z2
# display in 3d view # display in 3d view
vinit Driver1/Viewer1/View1 w=1024 h=768 vinit Driver1/Viewer1/View1 w=1024 h=768
vdisplay snowflake lines text vdisplay snowflake lines text
vrenderparams -msaa 8 vrenderparams -msaa 8
vsetcolor snowflake 0 0 0 vsetcolor snowflake BLACK
vsetcolor lines 0 0 0 vsetcolor lines BLACK
vsetcolor text 0 0 0 vsetcolor text BLACK
vbackground -color WHITE vbackground -color WHITE
vtop vtop
vfit vfit
# add dimension: # add dimension:
# detect vertices extremal in X direction # detect vertices extremal in X direction
bounding snowflake -save x1 y1 z1 x2 y2 z2
plane f1 x1 0 0 1 0 0 plane f1 x1 0 0 1 0 0
plane f2 x2 0 0 1 0 0 plane f2 x2 0 0 1 0 0
mkface f1 f1 mkface f1 f1
@ -159,7 +159,3 @@ for {set i 1} {$i <= 2} {incr i} {
} }
} }
vdimension length -length -shapes $v1 $v2 -plane xoy -value 0.001 -dispunits mm -showunits -flyout 70 -label above -color black -text 5 3d sh vdimension length -length -shapes $v1 $v2 -plane xoy -value 0.001 -dispunits mm -showunits -flyout 70 -label above -color black -text 5 3d sh
if { [regexp HAVE_GL2PS [dversion]] } {
puts "You can use command vexport to generate PDF: vexport your_file_path.pdf"
}

View File

@ -903,25 +903,61 @@ void BRepTools::RemoveUnusedPCurves(const TopoDS_Shape& S)
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean BRepTools::Triangulation(const TopoDS_Shape& S, Standard_Boolean BRepTools::Triangulation(const TopoDS_Shape& theShape,
const Standard_Real deflec) const Standard_Real theLinDefl,
const Standard_Boolean theToCheckFreeEdges)
{
TopExp_Explorer anEdgeIter;
TopLoc_Location aDummyLoc;
for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
const Handle(Poly_Triangulation)& aTri = BRep_Tool::Triangulation (aFace, aDummyLoc);
if (aTri.IsNull()
|| aTri->Deflection() > theLinDefl)
{
return Standard_False;
}
for (anEdgeIter.Init (aFace, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current());
const Handle(Poly_PolygonOnTriangulation)& aPoly = BRep_Tool::PolygonOnTriangulation (anEdge, aTri, aDummyLoc);
if (aPoly.IsNull())
{ {
TopExp_Explorer exf, exe;
TopLoc_Location l;
Handle(Poly_Triangulation) T;
Handle(Poly_PolygonOnTriangulation) Poly;
for (exf.Init(S, TopAbs_FACE); exf.More(); exf.Next()) {
const TopoDS_Face& F = TopoDS::Face(exf.Current());
T = BRep_Tool::Triangulation(F, l);
if (T.IsNull() || (T->Deflection() > deflec))
return Standard_False; return Standard_False;
for (exe.Init(F, TopAbs_EDGE); exe.More(); exe.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exe.Current());
Poly = BRep_Tool::PolygonOnTriangulation(E, T, l);
if (Poly.IsNull()) return Standard_False;
} }
} }
}
if (!theToCheckFreeEdges)
{
return Standard_True;
}
Handle(Poly_Triangulation) anEdgeTri;
for (anEdgeIter.Init (theShape, TopAbs_EDGE, TopAbs_FACE); anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current());
const Handle(Poly_Polygon3D)& aPolygon = BRep_Tool::Polygon3D (anEdge, aDummyLoc);
if (!aPolygon.IsNull())
{
if (aPolygon->Deflection() > theLinDefl)
{
return Standard_False;
}
}
else
{
const Handle(Poly_PolygonOnTriangulation)& aPoly = BRep_Tool::PolygonOnTriangulation (anEdge, anEdgeTri, aDummyLoc);
if (aPoly.IsNull()
|| anEdgeTri.IsNull()
|| anEdgeTri->Deflection() > theLinDefl)
{
return Standard_False;
}
}
}
return Standard_True; return Standard_True;
} }

View File

@ -162,10 +162,18 @@ public:
//! refer to surfaces not belonging to any face of <S> //! refer to surfaces not belonging to any face of <S>
Standard_EXPORT static void RemoveUnusedPCurves (const TopoDS_Shape& S); Standard_EXPORT static void RemoveUnusedPCurves (const TopoDS_Shape& S);
//! verifies that each face from the shape <S> has got //! Verifies that each Face from the shape has got a triangulation with a deflection smaller or equal to specified one
//! a triangulation with a deflection <= deflec and //! and the Edges a discretization on this triangulation.
//! the edges a discretisation on this triangulation. //! @param theShape [in] shape to verify
Standard_EXPORT static Standard_Boolean Triangulation (const TopoDS_Shape& S, const Standard_Real deflec); //! @param theLinDefl [in] maximum allowed linear deflection
//! @param theToCheckFreeEdges [in] if TRUE, then free Edges are required to have 3D polygon
//! @return FALSE if input Shape contains Faces without triangulation,
//! or that triangulation has worse (greater) deflection than specified one,
//! or Edges in Shape lack polygons on triangulation
//! or free Edges in Shape lack 3D polygons
Standard_EXPORT static Standard_Boolean Triangulation (const TopoDS_Shape& theShape,
const Standard_Real theLinDefl,
const Standard_Boolean theToCheckFreeEdges = Standard_False);
//! Returns True if the distance between the two //! Returns True if the distance between the two
//! vertices is lower than their tolerance. //! vertices is lower than their tolerance.

View File

@ -31,6 +31,7 @@ Select3D_SensitiveSegment::Select3D_SensitiveSegment (const Handle(SelectMgr_Ent
const gp_Pnt& theLastPnt) const gp_Pnt& theLastPnt)
: Select3D_SensitiveEntity (theOwnerId) : Select3D_SensitiveEntity (theOwnerId)
{ {
mySFactor = 3;
myStart = theFirstPnt; myStart = theFirstPnt;
myEnd = theLastPnt; myEnd = theLastPnt;
} }

View File

@ -542,9 +542,6 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
return; return;
} }
// add wireframe presentation for isolated edges and vertices
wireframeFromShape (thePrs, theShape, theDrawer);
// Use automatic re-triangulation with deflection-check logic only if this feature is enable // Use automatic re-triangulation with deflection-check logic only if this feature is enable
if (theDrawer->IsAutoTriangulation()) if (theDrawer->IsAutoTriangulation())
{ {
@ -552,6 +549,9 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
StdPrs_ToolTriangulatedShape::Tessellate (theShape, theDrawer); StdPrs_ToolTriangulatedShape::Tessellate (theShape, theDrawer);
} }
// add wireframe presentation for isolated edges and vertices
wireframeFromShape (thePrs, theShape, theDrawer);
// add special wireframe presentation for faces without triangulation // add special wireframe presentation for faces without triangulation
wireframeNoTriangFacesFromShape (thePrs, theShape, theDrawer); wireframeNoTriangFacesFromShape (thePrs, theShape, theDrawer);

View File

@ -240,7 +240,7 @@ void StdPrs_ToolTriangulatedShape::Normal (const TopoDS_Face& theFace,
Standard_Boolean StdPrs_ToolTriangulatedShape::IsTessellated (const TopoDS_Shape& theShape, Standard_Boolean StdPrs_ToolTriangulatedShape::IsTessellated (const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer) const Handle(Prs3d_Drawer)& theDrawer)
{ {
return BRepTools::Triangulation (theShape, Prs3d::GetDeflection (theShape, theDrawer)); return BRepTools::Triangulation (theShape, Prs3d::GetDeflection (theShape, theDrawer), true);
} }
// ======================================================================= // =======================================================================

View File

@ -100,6 +100,11 @@ void StdPrs_WFShape::Add (const Handle(Prs3d_Presentation)& thePresentation,
return; return;
} }
if (theDrawer->IsAutoTriangulation())
{
StdPrs_ToolTriangulatedShape::Tessellate (theShape, theDrawer);
}
// draw triangulation-only edges // draw triangulation-only edges
if (Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True)) if (Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True))
{ {

View File

@ -113,8 +113,8 @@ void StdSelect_BRepSelectionTool::Load (const Handle(SelectMgr_Selection)& theSe
const Standard_Real theMaxParam) const Standard_Real theMaxParam)
{ {
Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority; Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
if (isAutoTriangulation
if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) ) && !BRepTools::Triangulation (theShape, Precision::Infinite(), true))
{ {
BRepMesh_IncrementalMesh aMesher(theShape, theDeflection, Standard_False, theDeviationAngle); BRepMesh_IncrementalMesh aMesher(theShape, theDeflection, Standard_False, theDeviationAngle);
} }
@ -447,8 +447,16 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape
Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge); Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge);
if (!aPoints.IsNull() if (!aPoints.IsNull()
&& !aPoints->IsEmpty()) && !aPoints->IsEmpty())
{
if (aPoints->Length() == 2)
{
// don't waste memory, create a segment
theSensitive = new Select3D_SensitiveSegment (theOwner, aPoints->First(), aPoints->Last());
}
else
{ {
theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints); theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
}
return; return;
} }

View File

@ -1,10 +1,7 @@
puts "============" puts "============"
puts "OCC25098" puts "0025098: Visualization - Calculation of depth on selection of a wire is not accurate"
puts "============" puts "============"
puts "" puts ""
####################################################################################
# Visualization - Calculation of depth on selection of a wire is not accurate
####################################################################################
proc ParseEntityInfo {theInfoString} { proc ParseEntityInfo {theInfoString} {
set aStringArr [split $theInfoString " "] set aStringArr [split $theInfoString " "]
@ -34,7 +31,7 @@ proc ParseEntityInfo {theInfoString} {
} }
pload VISUALIZATION MODELING pload VISUALIZATION MODELING
vinit vinit View1
box b 10 10 10 box b 10 10 10
vdisplay b vdisplay b
@ -130,9 +127,9 @@ if {[string equal $aWireType "Detected Shape: TopoDS_TWire"] == 0} {
} }
set aWireChildSensitiveType [string trim [lindex $aOut [expr $aWireTypeStringNb + 1]]] set aWireChildSensitiveType [string trim [lindex $aOut [expr $aWireTypeStringNb + 1]]]
if {[string equal $aWireChildSensitiveType "Detected Child: Select3D_SensitiveCurve"] == 0} { if {[string equal $aWireChildSensitiveType "Detected Child: Select3D_SensitiveSegment"] == 0} {
puts "Wrong type of wire's inner sensitive! Value is: " puts "Wrong type of wire's inner sensitive! Value is: "
puts $aWireChildSensitiveType puts $aWireChildSensitiveType
puts "Must be: Detected Child: Select3D_SensitiveCurve" puts "Must be: Detected Child: Select3D_SensitiveSegment"
puts "ERROR" puts "ERROR"
} }

17
tests/bugs/vis/bug31425 Normal file
View File

@ -0,0 +1,17 @@
puts "============="
puts "0031425: Visualization - free Edge has selection sensitivity inconsistent to presentation"
puts "============="
pload MODELING VISUALIZATION
circle circ 150 0 200 1 0 0 100
mkedge e circ
wire w e
vclear
vinit View1
vdisplay e
vaspects e -setLineWidth 2
vfit
vviewparams -scale 25.38 -proj 0.5 -0.5 0.5 -up -0.4 0.4 0.8 -at 125.128 46.4744 271.346
checkpoint pick [vmoveto 275 175] {150 31 294} 1.0
vdump $::imagedir/${::casename}.png

View File

@ -11,7 +11,7 @@ set depsilon 1.e-7
proc COMPUTE_HLR {viewname algotype} { proc COMPUTE_HLR {viewname algotype} {
uplevel #0 top uplevel #0 top
uplevel #0 clear uplevel #0 clear
uplevel #0 vinit uplevel #0 vinit View1
uplevel #0 vdisplay a uplevel #0 vdisplay a
uplevel #0 $viewname uplevel #0 $viewname
uplevel #0 vcomputehlr a result -algoType $algotype uplevel #0 vcomputehlr a result -algoType $algotype

View File

@ -3,8 +3,16 @@ puts "OCC23625"
puts "============" puts "============"
puts "" puts ""
puts "REQUIRED All: Meshing statuses: SelfIntersectingWire Failure"
set viewname "vfront" set viewname "vfront"
set length 28096.2 set length 28388
restore [locate_data_file bug23625_a1.brep] a restore [locate_data_file bug23625_a1.brep] a
# workaround bug 0031426 until fix
vinit View1
vdefaults -autoTriang 0
incmesh a 7.6 12
COMPUTE_HLR $viewname $algotype COMPUTE_HLR $viewname $algotype

View File

@ -4,7 +4,7 @@ puts "============"
puts "" puts ""
set viewname "vfront" set viewname "vfront"
set length 28990.3 set length 28991.6
restore [locate_data_file bug23625_a2.brep] a restore [locate_data_file bug23625_a2.brep] a
COMPUTE_HLR $viewname $algotype COMPUTE_HLR $viewname $algotype

View File

@ -1,4 +1,4 @@
puts "TODO OCC30286 Linux: Error : The length of result shape is 302.441, expected 301.998" puts "TODO OCC30286 Linux: Error : The length of result shape is 302.443, expected 301.999"
puts "===========================================" puts "==========================================="
puts "OCC25813: regression in Hidden Line Removal" puts "OCC25813: regression in Hidden Line Removal"
@ -6,7 +6,7 @@ puts "==========================================="
puts "" puts ""
set viewname "" set viewname ""
set length 301.998 set length 301.999
ptorus a 30 10 ptorus a 30 10