//! Check if the given point is outside / inside / on section.
Graphic3d_ClipState ProbePoint (const Graphic3d_Vec4d& thePoint) const
{
+ Graphic3d_ClipState aState = Graphic3d_ClipState_Out;
for (const Graphic3d_ClipPlane* aPlaneIter = this; aPlaneIter != NULL; aPlaneIter = aPlaneIter->myNextInChain.get())
{
Graphic3d_ClipState aPlnState = aPlaneIter->ProbePointHalfspace (thePoint);
- if (aPlnState == Graphic3d_ClipState_On)
+ if (aPlnState == Graphic3d_ClipState_In)
{
- return Graphic3d_ClipState_On;
+ return Graphic3d_ClipState_In;
}
- else if (aPlnState == Graphic3d_ClipState_Out
- && aPlaneIter->myNextInChain.IsNull())
+ else if (aPlnState != Graphic3d_ClipState_Out)
{
- return Graphic3d_ClipState_Out;
+ aState = Graphic3d_ClipState_On;
}
}
- return Graphic3d_ClipState_In;
+ return aState;
}
//! Check if the given bounding box is fully outside / fully inside.
Graphic3d_ClipState ProbeBox (const Graphic3d_BndBox3d& theBox) const
{
- Graphic3d_ClipState aPrevState = Graphic3d_ClipState_On;
+ Graphic3d_ClipState aState = Graphic3d_ClipState_Out;
for (const Graphic3d_ClipPlane* aPlaneIter = this; aPlaneIter != NULL; aPlaneIter = aPlaneIter->myNextInChain.get())
{
- if (aPlaneIter->IsBoxFullOutHalfspace (theBox))
+ if (aPlaneIter->IsBoxFullInHalfspace (theBox))
{
- if (aPlaneIter->myNextInChain.IsNull())
- {
- return Graphic3d_ClipState_Out;
- }
- else if (aPrevState == Graphic3d_ClipState_In)
- {
- return Graphic3d_ClipState_On;
- }
- aPrevState = Graphic3d_ClipState_Out;
+ // within union operation, if box is entirely inside at least one half-space, others can be ignored
+ return Graphic3d_ClipState_In;
}
- else if (aPlaneIter->IsBoxFullInHalfspace (theBox))
+ else if (!aPlaneIter->IsBoxFullOutHalfspace (theBox))
{
- if (aPlaneIter->myNextInChain.IsNull())
- {
- return Graphic3d_ClipState_In;
- }
- else if (aPrevState == Graphic3d_ClipState_Out)
- {
- return Graphic3d_ClipState_On;
- }
- aPrevState = Graphic3d_ClipState_In;
- }
- else
- {
- return Graphic3d_ClipState_On;
+ // if at least one full out test fail, clipping state is inconclusive (partially clipped)
+ aState = Graphic3d_ClipState_On;
}
}
- return Graphic3d_ClipState_On;
+ return aState;
}
public:
box b3 0 40 0 20 10 70
box b4 0 10 0 10 30 70
box b5 0 0 0 30 10 70
+box bb 10 -10 0 20 10 10
set aNbParts 6
set aColors { RED YELLOW GREEN GRAY MAGENTA1 ORANGE }
vviewparams -scale 4.66737 -proj 0.465292 -0.577133 0.671134 -up -0.46873 0.482524 0.739907 -at 15.807 37.1157 21.9799
vpoint p0 0 0 0
+vdisplay -dispMode 1 bb
+vaspects -noupdate bb -setColor CYAN1
vzbufftrihedron
puts "Display the geometry as dedicated objects"
vdisplay pp1 pp2
vclipplane pln -set {*}$aCapParams -equation1 0 0 -1 40 -equation2 0 1 0 -15
+if { [vreadpixel 200 360 rgb name] != "DARKTURQUOISE" } { puts "Error: bb should NOT be clipped" }
vdump $::imagedir/${::casename}_2.png
vclipplane pln -set {*}$aCapParams -equation1 0 0 -1 40 -equation2 0 1 0 -15 -equation3 -1 0 0 5