Files
OCCT/tests/vselect/bugs/bug_polyline_inclusion
T
Pasukhin Dmitry c076c4ed03 Visualization - Fix polyline selection inclusion test and point-in-polyline check (#1222)
Replaces two buggy pieces of SelectMgr_TriangularFrustumSet used during
polyline (polygon rubber-band) selection:

- OverlapsBox(min, max, bool* theInside): the corner-edge isIntersectBoundary
  heuristic produced false "fully inside" answers whenever an AABB was large
  enough that its 12 edges did not cross the polyline but its interior did
  not lie inside either. Rewrite: first probe every frustum for any overlap;
  if none, return false. Otherwise, project the 8 AABB corners onto the
  frustum near plane and apply a ray-cast inside test against the original
  polyline loop. If any corner projects outside, clear theInside; else leave
  it untouched. The near-plane coplanarity assumption is guaranteed by
  Build(), which derives every near vertex from
  myBuilder->ProjectPntOnViewPlane(x, y, 0.0).

- OverlapsPoint(const gp_Pnt&): previously a stub returning false, which made
  strict-inclusion polyline selection of Select3D_SensitiveTriangle,
  SensitivePoly, SensitiveTriangulation, SensitivePrimitiveArray,
  MeshVS_CommonSensitiveEntity and MeshVS_SensitiveQuad silently impossible
  (those sensitive types call theMgr.OverlapsPoint(...) on each vertex in
  strict-inclusion mode; a blanket false meant nothing was ever picked). Now
  delegates to the same near-plane projection + ray-cast test, so strict
  inclusion works for all these sensitive types in polyline mode.

Covered by a new Draw test tests/vselect/bugs/bug_polyline_inclusion that
exercises both strict-inclusion and overlap modes for spheres inside/outside
a polygonal rubber band. No GTest is added because constructing a working
TriangularFrustumSet requires a configured Graphic3d_Camera + viewport; the
Tcl test is the regression gate.
2026-04-22 11:29:49 +01:00

48 lines
1.8 KiB
Plaintext

puts "========================================"
puts "Visualization - polyline (polygonal) selection in strict-inclusion mode"
puts "Regression guard for SelectMgr_TriangularFrustumSet::OverlapsPoint /"
puts "OverlapsBox: the single-arg OverlapsPoint(gp_Pnt) used to return false"
puts "unconditionally, which made strict-inclusion polyline selection of"
puts "SensitiveTriangle / SensitivePoly / SensitiveTriangulation /"
puts "SensitivePrimitiveArray / MeshVS_* impossible."
puts "Pixel coordinates are reused from tests/vselect/sphere/rectangle_selection."
puts "========================================"
puts ""
pload MODELING VISUALIZATION
vinit View1 -height 400 -width 600
psphere s1 1
psphere s2 1
ttranslate s1 2 0 0
ttranslate s2 -2 0 0
vdisplay -dispMode 1 s1 s2
vfit
# A 4-point polygon that matches the extent of the selection rectangle
# (15,15)-(585,385) used in tests/vselect/sphere/rectangle_selection,
# where strict inclusion is known to select both spheres.
vselect 15 15 585 15 585 385 15 385 -allowoverlap 0
if {![string match "*Selected*" [vstate s1]] ||
![string match "*Selected*" [vstate s2]]} {
puts "Error: polyline enclosing both spheres must select s1 and s2 in strict inclusion mode"
}
# A tiny polygon fully inside the upper-left corner of the viewport that
# does not cover either sphere. Neither sphere must be selected, in either mode.
vselect 0 0
vselect 5 5 40 5 40 40 5 40 -allowoverlap 0
if { [string match "*Selected*" [vstate s1]] ||
[string match "*Selected*" [vstate s2]]} {
puts "Error: polyline not covering any sphere must not select anything (strict)"
}
vselect 0 0
vselect 5 5 40 5 40 40 5 40 -allowoverlap 1
if { [string match "*Selected*" [vstate s1]] ||
[string match "*Selected*" [vstate s2]]} {
puts "Error: polyline not covering any sphere must not select anything (overlap)"
}
vdump ${imagedir}/${casename}.png