SelectMgr_RectangularFrustum::OverlapsCylinder() - added missing 3D point transformation.
StdSelect_BRepSelectionTool::ComputeSensitive() - fixed cylinder height computation on TopoDS_Shape with scale transformation.
SelectMgr_AxisIntersector::OverlapsCylinder(),::OverlapsSphere() - added missing computations of surface normal.
return Standard_False;
}
+ const gp_Pnt aPntOnSphere (myAxis.Location().XYZ() + myAxis.Direction().XYZ() * aDepth);
+ const gp_Vec aNormal (aPntOnSphere.XYZ() - theCenter.XYZ());
thePickResult.SetDepth (aDepth);
+ thePickResult.SetPickedPoint (aPntOnSphere);
+ thePickResult.SetSurfaceNormal (aNormal);
return Standard_True;
}
{
return false;
}
+
+ const gp_Pnt aPntOnCylinder = aLoc.XYZ() + aRayDir.XYZ() * aDepth;
thePickResult.SetDepth (aDepth);
+ thePickResult.SetPickedPoint (aPntOnCylinder.Transformed (theTrsf));
+ if (Abs (aPntOnCylinder.Z()) < Precision::Confusion())
+ {
+ thePickResult.SetSurfaceNormal (-gp::DZ().Transformed (theTrsf));
+ }
+ else if (Abs (aPntOnCylinder.Z() - theHeight) < Precision::Confusion())
+ {
+ thePickResult.SetSurfaceNormal (gp::DZ().Transformed (theTrsf));
+ }
+ else
+ {
+ thePickResult.SetSurfaceNormal (gp_Vec (aPntOnCylinder.X(), aPntOnCylinder.Y(), 0.0).Transformed (theTrsf));
+ }
return true;
}
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point || mySelectionType == SelectMgr_SelectionType_Box,
"Error! SelectMgr_RectangularFrustum::Overlaps() should be called after selection frustum initialization");
- Standard_Real aTimeEnter = 0.0, aTimeLeave = 0.0;
+ Standard_Real aTimes[2] = { 0.0, 0.0 };
const gp_Trsf aTrsfInv = theTrsf.Inverted();
const gp_Pnt aLoc = myNearPickedPnt.Transformed (aTrsfInv);
const gp_Dir aRayDir = myViewRayDir .Transformed (aTrsfInv);
- if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir, aTimeEnter, aTimeLeave))
+ if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir, aTimes[0], aTimes[1]))
{
return Standard_False;
}
- thePickResult.SetDepth (aTimeEnter * myScale);
+
+ Standard_Integer aResTime = 0;
+ thePickResult.SetDepth (aTimes[aResTime] * myScale);
if (theClipRange.IsClipped (thePickResult.Depth()))
{
- thePickResult.SetDepth (aTimeLeave * myScale);
+ aResTime = 1;
+ thePickResult.SetDepth (aTimes[aResTime] * myScale);
}
- const gp_Pnt aPntOnCylinder (aLoc.XYZ() + aRayDir.XYZ() * thePickResult.Depth());
+
+ const gp_Pnt aPntOnCylinder = aLoc.XYZ() + aRayDir.XYZ() * aTimes[aResTime];
if (Abs (aPntOnCylinder.Z()) < Precision::Confusion())
{
thePickResult.SetSurfaceNormal (-gp::DZ().Transformed (theTrsf));
{
thePickResult.SetSurfaceNormal (gp_Vec (aPntOnCylinder.X(), aPntOnCylinder.Y(), 0.0).Transformed (theTrsf));
}
- thePickResult.SetPickedPoint (aPntOnCylinder);
+ thePickResult.SetPickedPoint (aPntOnCylinder.Transformed (theTrsf));
return !theClipRange.IsClipped (thePickResult.Depth());
}
&TopoDS::Face (aSubfacesMap.FindKey (2))
};
- TopLoc_Location aLocSurf;
+ TopLoc_Location aLocSurf[2];
const Handle(Geom_Surface)* aSurfaces[2] =
{
- &BRep_Tool::Surface (*aFaces[0], aLocSurf),
- &BRep_Tool::Surface (*aFaces[1], aLocSurf)
+ &BRep_Tool::Surface (*aFaces[0], aLocSurf[0]),
+ &BRep_Tool::Surface (*aFaces[1], aLocSurf[1])
};
Standard_Integer aConIndex = 0;
const Standard_Real aRad1 = aCone.RefRadius();
const Standard_Real aHeight = (aRad1 != 0.0)
? aRad1 / Abs (Tan (aCone.SemiAngle()))
- : aCone.Location().Distance (aGeomPln->Location());
+ : aCone.Location().Distance (aGeomPln->Location().Transformed (aLocSurf[aConIndex == 0 ? 1 : 0]));
const Standard_Real aRad2 = (aRad1 != 0.0) ? 0.0 : Tan (aCone.SemiAngle()) * aHeight;
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp_Ax3());
&TopoDS::Face (aSubfacesMap.FindKey (3))
};
- TopLoc_Location aLocSurf;
+ TopLoc_Location aLocSurf[3];
const Handle(Geom_Surface)* aSurfaces[3] =
{
- &BRep_Tool::Surface (*aFaces[0], aLocSurf),
- &BRep_Tool::Surface (*aFaces[1], aLocSurf),
- &BRep_Tool::Surface (*aFaces[2], aLocSurf)
+ &BRep_Tool::Surface (*aFaces[0], aLocSurf[0]),
+ &BRep_Tool::Surface (*aFaces[1], aLocSurf[1]),
+ &BRep_Tool::Surface (*aFaces[2], aLocSurf[2])
};
Standard_Integer aConIndex = -1, aNbPlanes = 0;
Handle(Geom_ConicalSurface) aGeomCone;
Handle(Geom_CylindricalSurface) aGeomCyl;
Handle(Geom_Plane) aGeomPlanes[2];
+ const TopLoc_Location* aGeomPlanesLoc[2];
for (Standard_Integer aSurfIter = 0; aSurfIter < 3; ++aSurfIter)
{
const Handle(Geom_Surface)& aSurf = *aSurfaces[aSurfIter];
aGeomPlanes[aNbPlanes] = Handle(Geom_Plane)::DownCast (aSurf);
if (!aGeomPlanes[aNbPlanes].IsNull())
{
+ aGeomPlanesLoc[aNbPlanes] = &aLocSurf[aSurfIter];
++aNbPlanes;
}
}
{
const gp_Cone aCone = BRepAdaptor_Surface (*aFaces[aConIndex]).Cone();
const Standard_Real aRad1 = aCone.RefRadius();
- const Standard_Real aHeight = aGeomPlanes[0]->Location().Distance (aGeomPlanes[1]->Location());
+ const Standard_Real aHeight = aGeomPlanes[0]->Location().Transformed (*aGeomPlanesLoc[0])
+ .Distance (aGeomPlanes[1]->Location().Transformed (*aGeomPlanesLoc[1]));
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp_Ax3());
const Standard_Real aTriangleHeight = (aCone.SemiAngle() > 0.0)
{
const gp_Cylinder aCyl = BRepAdaptor_Surface (*aFaces[aConIndex]).Cylinder();
const Standard_Real aRad = aCyl.Radius();
- const Standard_Real aHeight = aGeomPlanes[0]->Location().Distance (aGeomPlanes[1]->Location());
+ const Standard_Real aHeight = aGeomPlanes[0]->Location().Transformed (*aGeomPlanesLoc[0])
+ .Distance (aGeomPlanes[1]->Location().Transformed (*aGeomPlanesLoc[1]));
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCyl.Position(), gp_Ax3());
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad, aRad, aHeight, aTrsf);
for (Standard_Integer aShIndex = 1; aShIndex <= aSubfacesMap.Extent(); ++aShIndex)
{
- ComputeSensitive (aSubfacesMap (aShIndex), theOwner,
+ ComputeSensitive (aSubfacesMap.FindKey (aShIndex), theOwner,
theSelection,
theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
}
+++ /dev/null
-vinit View1 -height 400 -width 600
-set subgroup "cone_cylinder"
puts "Tests depth value returned by Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcylinder cyl 10 20
vdisplay cyl -dispmode 1
vfit
puts "Tests detecting Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcylinder cyl 10 20
vdisplay cyl -dispmode 1
vfit
puts "Generating images based on detection of Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcylinder cyl 10 20
vdisplay cyl -dispmode 1
vfit
puts "Tests polygon selection of Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcylinder c1 10 20
pcone c2 10 0 20
pcone c3 10 5 10
puts "Tests rectangular selection of Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcylinder c1 10 20
pcone c2 10 0 20
pcone c3 10 5 10
puts "Tests selection of Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcone cone 10 0 20
vdisplay cone -dispmode 1
vfit
puts "Tests selection of Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcylinder cyl 10 20
vdisplay cyl -dispmode 1
vfit
puts "Tests selection of Select3D_SensitiveCylinder"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
pcone tr_cone 10 5 10
vdisplay tr_cone -dispmode 1
vfit
--- /dev/null
+puts "================================="
+puts "0032652: Visualization - Select3D_SensitiveCylinder returns wrong 3D point on transformed shape"
+puts "Check picking of transformed cone"
+puts "================================="
+
+pload MODELING VISUALIZATION
+pcone c 10 5 10
+fscale c 0 0 0 0.1
+trotate c 0 0 0 1 1 0 25
+ttranslate c 2500 3500 1000
+
+vinit View1
+
+# check Select3D_SensitiveTriangulation
+vclear
+vaxo
+compound {*}[explode c Sh] cc
+vdisplay -dispmode 1 cc
+vfit
+vselaxis 2500 3498 1001 0 1 0 -display a -showNormal
+set aPntTris [vmoveto 200 200]
+vpoint pp {*}$aPntTris
+checkpoint aPntTris_p $aPntTris {2500.42 3499.54 1000.81} 0.1
+if { ![string match "*Select3D_SensitiveTriangulation*" [vstate -entities]] } { puts "Error: triangulation should be detected" }
+vfit
+vdump $imagedir/${casename}_prs_tris.png
+vseldump $imagedir/${casename}_selnorm_tris.png -type surfNormal
+
+# check Select3D_SensitiveCylinder
+vclear
+vdisplay -dispmode 1 c
+vfit
+vselaxis 2500 3498 1001 0 1 0 -display a -showNormal
+set aPntCone [vmoveto 200 200]
+vpoint pp {*}$aPntCone
+checkpoint aPntCone_p $aPntCone {2500.42 3499.54 1000.81} 0.1
+if { ![string match "*Select3D_SensitiveCylinder*" [vstate -entities]] } { puts "Error: cylinder should be detected" }
+vfit
+vdump $imagedir/${casename}_prs_cyl.png
+vseldump $imagedir/${casename}_selnorm_cyl.png -type surfNormal
--- /dev/null
+puts "================================="
+puts "0032652: Visualization - Select3D_SensitiveCylinder returns wrong 3D point on transformed shape"
+puts "Check picking of transformed cylinder"
+puts "================================="
+
+pload MODELING VISUALIZATION
+pcylinder c 10 20
+fscale c 0 0 0 0.1
+trotate c 0 0 0 1 1 0 25
+ttranslate c 2500 3500 1000
+
+vinit View1
+
+# check Select3D_SensitiveTriangulation
+vclear
+vaxo
+compound {*}[explode c Sh] cc
+vdisplay -dispmode 1 cc
+vfit
+vselaxis 2500 3498 1001 0 1 0 -display a -showNormal
+set aPntTris [vmoveto 200 200]
+vpoint pp {*}$aPntTris
+checkpoint aPntTris_p $aPntTris {2500.9 3499.0 1001.6} 0.1
+if { ![string match "*Select3D_SensitiveTriangulation*" [vstate -entities]] } { puts "Error: triangulation should be detected" }
+vfit
+vdump $imagedir/${casename}_prs_tris.png
+vseldump $imagedir/${casename}_selnorm_tris.png -type surfNormal
+
+# check Select3D_SensitiveCylinder
+vclear
+vdisplay -dispmode 1 c
+vfit
+vselaxis 2500 3498 1001 0 1 0 -display a -showNormal
+set aPntCyl [vmoveto 200 200]
+vpoint pp {*}$aPntCyl
+checkpoint aPntCyl_p $aPntCyl {2500.9 3499.0 1001.6} 0.1
+if { ![string match "*Select3D_SensitiveCylinder*" [vstate -entities]] } { puts "Error: cylinder should be detected" }
+vfit
+vdump $imagedir/${casename}_prs_cyl.png
+vseldump $imagedir/${casename}_selnorm_cyl.png -type surfNormal
+++ /dev/null
-vinit View1 -height 400 -width 600
-set subgroup "sphere"
puts "Tests depth value returned by Select3D_SenstiveSphere"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
psphere s 1
vdisplay -dispMode 1 s
vfit
puts "Tests detecting Select3D_SenstiveSphere"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
psphere s 1
vdisplay -dispMode 1 s
vfit
puts "Generating images based on detection of Select3D_SenstiveSphere"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
psphere s 1
vdisplay -dispMode 1 s
vfit
puts "Tests polygon selection of Select3D_SenstiveSphere"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
psphere s1 1
psphere s2 1
psphere s3 1
puts "Tests rectangular selection of Select3D_SenstiveSphere"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
psphere s1 1
psphere s2 1
psphere s3 1
puts "Tests selection of Select3D_SenstiveSphere"
puts "================================="
+pload MODELING VISUALIZATION
+vinit View1 -height 400 -width 600
+
psphere s 1
vdisplay -dispMode 1 s
vfit
--- /dev/null
+puts "================================="
+puts "0032652: Visualization - Select3D_SensitiveCylinder returns wrong 3D point on transformed shape"
+puts "Check picking of transformed sphere"
+puts "================================="
+
+pload MODELING VISUALIZATION
+psphere s 10
+fscale s 0 0 0 0.1
+trotate s 0 0 0 1 1 0 25
+ttranslate s 2500 3500 1000
+
+vinit View1
+vlight headlight -head 0
+
+# check Select3D_SensitiveTriangulation
+vclear
+vaxo
+tcopy s ss
+incmesh ss 1.0
+tclean ss -geom
+vdisplay -dispmode 1 ss
+vfit
+vselaxis 2500 3498 1000 0 1 0 -display a -showNormal
+set aPntTris [vmoveto 200 200]
+vpoint pp {*}$aPntTris
+checkpoint aPntTris_p $aPntTris {2500.54 3499.41 1000.6} 0.1
+if { ![string match "*Select3D_SensitiveTriangulation*" [vstate -entities]] } { puts "Error: triangulation should be detected" }
+vfit
+vdump $imagedir/${casename}_prs_tris.png
+vseldump $imagedir/${casename}_selnorm_tris.png -type surfNormal
+
+# check Select3D_SensitiveSphere
+vclear
+vdisplay -dispmode 1 s
+vfit
+vselaxis 2500 3498 1000 0 1 0 -display a -showNormal
+set aPntSph [vmoveto 200 200]
+vpoint pp {*}$aPntSph
+checkpoint aPntSph_p $aPntSph {2500.54 3499.41 1000.6} 0.1
+if { ![string match "*Select3D_SensitiveSphere*" [vstate -entities]] } { puts "Error: sphere should be detected" }
+vfit
+vdump $imagedir/${casename}_prs_sph.png
+vseldump $imagedir/${casename}_selnorm_sph.png -type surfNormal