本文整理汇总了C++中ON_BoundingBox类的典型用法代码示例。如果您正苦于以下问题:C++ ON_BoundingBox类的具体用法?C++ ON_BoundingBox怎么用?C++ ON_BoundingBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ON_BoundingBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vtol
bool
Subcurve::Intersect(const Subcurve &other,
double tolerance /* = 0.0 */,
ON_BoundingBox *intersection /* = NULL */) const
{
ON_3dVector vtol(tolerance, tolerance, tolerance);
ON_BoundingBox new_bbox(m_node.m_min - vtol, m_node.m_max + vtol);
ON_BoundingBox box;
bool ret = box.Intersection(new_bbox, other.m_node);
if (intersection != NULL) {
*intersection = box;
}
return ret;
}
示例2: BoundingBox
bool ON_Arc::GetBoundingBox(
ON_BoundingBox& bbox,
int bGrowBox
) const
{
if (bGrowBox)
{
ON_BoundingBox arc_bbox = BoundingBox();
bbox.Union(arc_bbox);
}
else
bbox = BoundingBox();
return bbox.IsValid();
}
示例3: ON_Brep_GetTightFaceBoundingBox_Helper
// Add a face to the partial boundingbox result.
static void ON_Brep_GetTightFaceBoundingBox_Helper( const ON_BrepFace& face, ON_BoundingBox& bbox, const ON_Xform* xform, const ON_Xform* xform_inverse )
{
ON_BoundingBox loose_box;
// This should ideally test for planarity inside the OuterLoop() pbox only,
// but no such function exists in the SDK as far as I can tell.
if( face.IsPlanar() )
return;
// Get loose boundingbox of face.
if( face.GetBoundingBox(loose_box, false) )
{
if( xform_inverse )
loose_box.Transform(*xform_inverse);
if( bbox.Includes(loose_box, false) )
return;
}
const TL_Brep* tlbrep = TL_Brep::Promote(face.Brep());
if( tlbrep )
{
ON_Brep_GetTightIsoCurveBoundingBox_Helper( *tlbrep, face, bbox, xform, 0);
ON_Brep_GetTightIsoCurveBoundingBox_Helper( *tlbrep, face, bbox, xform, 1);
}
}
示例4: GetBoundingBox
bool ON_Line::GetBoundingBox(
ON_BoundingBox& bbox,
int bGrowBox
) const
{
bbox.Set( 3, false, 2, 3, &from.x, bGrowBox );
return true;
}
示例5: CreatePseudoInfinitePlane
bool ON_PlaneSurface::CreatePseudoInfinitePlane(
const ON_Plane& plane,
const ON_BoundingBox& bbox,
double padding
)
{
ON_3dPoint bbox_corners[8];
if ( !bbox.GetCorners(bbox_corners) )
return false;
return CreatePseudoInfinitePlane(plane,8,bbox_corners,padding);
}
示例6: ON_Brep_GetTightBoundingBox_Helper
static bool ON_Brep_GetTightBoundingBox_Helper( const ON_Brep& brep, ON_BoundingBox& bbox, ON_Xform* xform )
{
ON_Xform xform_inverse;
ON_Xform* inverse = NULL;
if( xform )
{
xform_inverse = xform->Inverse();
inverse = &xform_inverse;
}
// make sure we have an empty/invalid bbox
bbox.Destroy();
// Compute Vertex bounding box.
int vertex_count = brep.m_V.Count();
if( xform )
{
ON_3dPointArray vtx(vertex_count);
for( int i=0; i<vertex_count; i++ )
vtx.Append(brep.m_V[i].point);
vtx.GetTightBoundingBox(bbox, false, xform);
}
else
{
for( int i=0; i<vertex_count; i++ )
bbox.Set(brep.m_V[i].point,true);
}
// Grow partial result with Edge bounding boxes.
int edge_count = brep.m_E.Count();
for( int i=0; i<edge_count; i++)
ON_Brep_GetTightCurveBoundingBox_Helper(brep.m_E[i], bbox, xform, inverse);
// Grow partial result with Face bounding boxes.
int face_count = brep.m_F.Count();
for( int i=0; i<face_count; i++)
ON_Brep_GetTightFaceBoundingBox_Helper(brep.m_F[i], bbox, xform, inverse);
return bbox.IsValid();
}
示例7: PointInPolyline
bool PointInPolyline(
const ON_3dPoint& P,
const ON_Polyline pline,
double tol
)
{
if (!pline.IsClosed(tol)) { /* no inside to speak of */
return false;
}
/* First we need to find a point that's in the plane and outside the polyline */
ON_BoundingBox bbox;
PolylineBBox(pline, &bbox);
ON_3dPoint adder;
int i;
for (i = 0; i < pline.Count(); i++) {
adder = P - pline[i];
if (!VNEAR_ZERO(adder, tol)) {
break;
}
}
ON_3dPoint DistantPoint = P;
int multiplier = 2;
do {
DistantPoint += adder*multiplier;
multiplier = multiplier*multiplier;
} while (bbox.IsPointIn(DistantPoint, false));
bool inside = false;
int rv;
ON_3dPoint result[2];
for (i = 0; i < pline.Count() - 1; i++) {
rv = SegmentSegmentIntersect(P, DistantPoint, pline[i], pline[i + 1], result, tol);
if (rv == 1) {
inside = !inside;
} else if (rv == 2) {
bu_exit(-1, "This is very unlikely bug in PointInPolyline which needs to be fixed\n");
}
}
return inside;
}
示例8: IsValid
BOOL ON_HatchLoop::IsValid( ON_TextLog* text_log) const
{
BOOL rc = m_p2dCurve != NULL;
if( !rc)
{
if( text_log)
text_log->Print( "2d loop curve is NULL\n");
}
if( rc)
{
rc = m_p2dCurve->IsValid( text_log);
if( !rc)
{
if( text_log)
text_log->Print( "Loop curve is not valid\n");
}
}
if( rc)
{
ON_BoundingBox box;
m_p2dCurve->GetBoundingBox( box);
rc = ( box.Max().z == box.Min().z && box.Max().z == 0.0);
if( !rc)
{
if( text_log)
text_log->Print( "2d loop curve has non-zero z coordinates\n");
}
}
if( rc && m_type != ltOuter && m_type != ltInner)
{
if( text_log)
text_log->Print( "Loop type is invalid.\n");
rc = false;
}
return rc;
}
示例9: GetDistanceToBoundingBox
bool ON_Plane::GetDistanceToBoundingBox(const ON_BoundingBox& Box,
double* min, double* max) const
{
//min and max signed distance. Returns false if plane normal has zero length.
ON_3dVector UnitNormal = Normal();
if (!UnitNormal.Unitize())
return false;
double mind, maxd;
mind = maxd = (Box.Min() - Origin())*UnitNormal;
int i0, i1, i2;
for (i0=0;i0<2;i0++)
{
for(i1=0;i1<2;i1++)
{
for (i2=0;i2<2;i2++)
{
if (i0||i1||i2)
{
ON_3dPoint P;
P[0]=(i0)?Box.Max()[0]:Box.Min()[0];
P[1]=(i1)?Box.Max()[1]:Box.Min()[1];
P[2]=(i2)?Box.Max()[2]:Box.Min()[2];
double d = (P - Origin())*UnitNormal;
//double dd = P.DistanceTo(ClosestPointTo(P));
if (d < mind)
mind=d;
else if (d > maxd)
maxd=d;
}
}
}
}
*min = mind;
*max = maxd;
return true;
}
示例10: GetTightBoundingBox
bool ON_PointGrid::GetTightBoundingBox(
ON_BoundingBox& tight_bbox,
int bGrowBox,
const ON_Xform* xform
) const
{
if ( bGrowBox && !tight_bbox.IsValid() )
{
bGrowBox = false;
}
if ( !bGrowBox )
{
tight_bbox.Destroy();
}
int i;
for ( i = 0; i < m_point_count[0]; i++ )
{
if ( ON_GetPointListBoundingBox( 3, 0, m_point_count[1], 3, &m_point[i].x, tight_bbox, bGrowBox, xform ) )
bGrowBox = true;
}
return bGrowBox?true:false;
}
示例11: corners
bool ON_Geometry::GetTightBoundingBox(
ON_BoundingBox& tight_bbox,
int bGrowBox,
const ON_Xform* xform
) const
{
// This implementation should be overridden by classes devived
// from ON_Geometry
if ( bGrowBox && !tight_bbox.IsValid() )
{
bGrowBox = false;
}
if ( !bGrowBox )
{
tight_bbox.Destroy();
}
if ( xform && !xform->IsIdentity() )
{
ON_3dPointArray corners(8);
ON_BoundingBox world_bbox;
if ( GetBoundingBox(world_bbox,false) )
{
world_bbox.GetCorners(corners);
if ( corners.GetTightBoundingBox(tight_bbox,bGrowBox,xform) )
bGrowBox = true;
}
}
else
{
if ( GetBoundingBox(tight_bbox,bGrowBox) )
bGrowBox = true;
}
return bGrowBox?true:false;
}
示例12: ON_Brep_GetTightCurveBoundingBox_Helper
// Add a curve to the partial boundingbox result.
static void ON_Brep_GetTightCurveBoundingBox_Helper( const ON_Curve& crv, ON_BoundingBox& bbox, const ON_Xform* xform, const ON_Xform* xform_inverse )
{
// Get loose boundingbox of curve.
ON_BoundingBox tempbox;
if( !crv.GetBoundingBox(tempbox, false) )
return;
// Transform the loose box if necessary.
// Note: transforming a box might result in a larger box,
// it's better to transform the curve,
// which might actually result in a smaller box.
if( xform_inverse )
{
tempbox.Transform(*xform_inverse);
}
// If loose boundingbox of curve is inside partial result, return.
if( bbox.Includes(tempbox, false) )
return;
// Get tight boundingbox of curve, grow partial result.
if( crv.GetTightBoundingBox(tempbox, false, xform) )
bbox.Union(tempbox);
}
示例13: IsZero
bool ON_Localizer::IsZero( const ON_BoundingBox& bbox ) const
{
bool rc = false;
ON_BoundingBox loc_bbox;
bool bTestLocBox = false;
double d;
switch ( m_type )
{
case cylinder_type:
{
ON_3dPointArray corners;
bbox.GetCorners(corners);
int i;
double t0, t1;
t0 = t1 = (corners[0]-m_P)*m_V;
for ( i = 1; i < 8; i++ )
{
d = (corners[i]-m_P)*m_V;
if ( d < t0 )
t0 = d;
else if (d > t1 )
t1 = d;
}
ON_Line L(m_P+t0*m_V,m_P+t1*m_V);
if ( m_d[0] > m_d[1] )
{
// function is supported along the line
d = bbox.MinimumDistanceTo(L);
if ( d >= m_d[0] )
rc = true;
}
else
{
// function is supported outside cylinder
d = bbox.MaximumDistanceTo(L);
if ( d <= m_d[0] )
rc = true;
}
}
break;
case plane_type:
{
ON_PlaneEquation e;
e.x = m_V.x; e.y = m_V.y; e.z = m_V.z; e.d = m_P.x;
e.d -= m_d[0];
if ( m_d[0] > m_d[1] )
{
e.x = -e.x; e.y = -e.y; e.z = -e.z; e.d = -e.d;
}
if ( e.MaximumValueAt(bbox) <= 0.0 )
rc = true;
}
break;
case sphere_type:
loc_bbox.m_min = m_P;
loc_bbox.m_max = m_P;
bTestLocBox = true;
break;
case curve_type:
if ( m_nurbs_curve)
{
loc_bbox = m_nurbs_curve->BoundingBox();
bTestLocBox = true;
}
break;
case surface_type:
if ( m_nurbs_surface)
{
loc_bbox = m_nurbs_surface->BoundingBox();
bTestLocBox = true;
}
break;
case distance_type:
rc = false;
break;
default:
rc = true;
}
if ( bTestLocBox )
{
if ( m_d[1] < m_d[0] && m_d[0] > 0.0 )
{
// function is zero outside loc_bbox + m_d[0]
double d = loc_bbox.MinimumDistanceTo(bbox);
if ( d > m_d[0] )
rc = true;
}
else if ( m_d[0] > 0.0 )
{
// function is zero inside loc_bbox-m_d[0]
loc_bbox.m_min.x += m_d[0];
//.........这里部分代码省略.........
示例14: ON_ArePointsOnPlane
int ON_ArePointsOnPlane( // returns 0=no, 1 = yes, 2 = pointset is (to tolerance) a single point on the line
int dim, // 2 or 3
int is_rat,
int count,
int stride, const double* point,
const ON_BoundingBox& bbox, // if needed, use ON_GetBoundingBox(dim,is_rat,count,stride,point)
const ON_Plane& plane, // line to test
double tolerance
)
{
double w;
int i, j, k;
if ( count < 1 )
return 0;
if ( !plane.IsValid() )
{
ON_ERROR("plane parameter is not valid");
return 0;
}
if ( !bbox.IsValid() )
{
ON_ERROR("bbox parameter is not valid");
return 0;
}
if ( !ON_IsValid(tolerance) || tolerance < 0.0 )
{
ON_ERROR("tolerance must be >= 0.0");
return 0;
}
if ( dim < 2 || dim > 3 )
{
ON_ERROR("dim must be 2 or 3");
return 0;
}
if ( stride < (is_rat?(dim+1):dim) )
{
ON_ERROR("stride parameter is too small");
return 0;
}
if ( 0 == point )
{
ON_ERROR("point parameter is null");
return 0;
}
int rc = 0;
if ( tolerance == 0.0 ) {
tolerance = bbox.Tolerance();
}
ON_3dPoint Q;
// test bounding box to quickly detect the common coordinate axis cases
rc = (count == 1 || bbox.Diagonal().Length() <= tolerance) ? 2 : 1;
for ( i = 0; rc && i < 2; i++ ) {
Q.x = bbox[i].x;
for ( j = 0; rc && j < 2; j++) {
Q.y = bbox[j].y;
for ( k = 0; rc && k < 2; k++) {
Q.z = bbox[k].z;
if ( Q.DistanceTo( plane.ClosestPointTo( Q ) ) > tolerance )
rc = 0;
}
}
}
if ( !rc ) {
// test points one by one
Q.Zero();
rc = (count == 1 || bbox.Diagonal().Length() <= tolerance) ? 2 : 1;
if ( is_rat ) {
for ( i = 0; i < count; i++ ) {
w = point[dim];
if ( w == 0.0 ) {
ON_ERROR("rational point has zero weight");
return 0;
}
ON_ArrayScale( dim, 1.0/w, point, &Q.x );
if ( Q.DistanceTo( plane.ClosestPointTo( Q ) ) > tolerance ) {
rc = 0;
break;
}
point += stride;
}
}
else {
for ( i = 0; i < count; i++ ) {
memcpy( &Q.x, point, dim*sizeof(Q.x) );
if ( Q.DistanceTo( plane.ClosestPointTo( Q ) ) > tolerance ) {
rc = 0;
break;
}
point += stride;
}
}
}
return rc;
//.........这里部分代码省略.........
示例15: points
ON_BOOL32 ON_Light::GetBBox( // returns true if successful
double* boxmin, // boxmin[dim]
double* boxmax, // boxmax[dim]
ON_BOOL32 bGrowBox
) const
{
bool rc = true;
ON_3dPointArray points(16);
switch(m_style)
{
case ON::camera_directional_light:
case ON::world_directional_light:
points.Append(m_location);
points.Append(m_location+m_direction);
break;
case ON::camera_point_light:
case ON::world_point_light:
points.Append(m_location);
break;
case ON::camera_spot_light:
case ON::world_spot_light:
if ( m_spot_angle > 0.0 && m_spot_angle < 90.0 )
{
double r = m_direction.Length()*tan(ON_PI*m_spot_angle/180.0);
ON_Circle c(ON_Plane(m_location+m_direction,m_direction),r);
ON_BoundingBox cbox = c.BoundingBox();
cbox.GetCorners( points );
}
else
{
points.Append(m_location+m_direction);
}
points.Append(m_location);
break;
case ON::ambient_light:
points.Append(m_location);
rc = false;
break;
case ON::world_linear_light:
points.Append(m_location);
points.Append(m_location+m_length);
break;
case ON::world_rectangular_light:
points.Append(m_location);
points.Append(m_location+m_length);
points.Append(m_location+m_width);
points.Append(m_location+m_width+m_length);
{
// include target and direction marker to avoid display clipping
ON_3dPoint center(m_location+(m_width+m_length)*0.5);
points.Append(center+m_direction);
ON_3dVector marker(m_direction);
marker.Unitize();
marker *= (m_width+m_length).Length()/12.0; // from GetRectangularLightSegments
points.Append(center+marker);
}
break;
default:
rc = false;
break;
}
if ( rc && points.Count() > 0 )
{
rc = ON_GetPointListBoundingBox( 3, 0, points.Count(), 3,
(double*)points.Array(),
boxmin, boxmax,
bGrowBox?true:false )
? true
: false;
}
return rc;
}