本文整理汇总了C++中ON_3dPoint类的典型用法代码示例。如果您正苦于以下问题:C++ ON_3dPoint类的具体用法?C++ ON_3dPoint怎么用?C++ ON_3dPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ON_3dPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RhRegionSelectPointCloudPoints
/*
Description:
Selects point cloud points using a 2D selection region.
Parameters:
view - [in] The view in which the selection region was defined.
cloud - [in] The point cloud to test.
points3d - [in] The 2D (screen) points that define the selection region.
indices - [out] The indices of the points in the point cloud
that lie inside of the selection region.
Returns:
The number of indices added to the output array.
*/
static int RhRegionSelectPointCloudPoints(
CRhinoView* view,
const ON_PointCloud& cloud,
ON_SimpleArray<CPoint>& points2d,
ON_SimpleArray<int>& indices
)
{
if( 0 == view )
return 0;
const int index_count = indices.Count();
CRgn rgn;
if( rgn.CreatePolygonRgn(points2d.Array(), points2d.Count(), WINDING) )
{
ON_Xform w2s;
view->ActiveViewport().VP().GetXform( ON::world_cs, ON::screen_cs, w2s );
int i;
ON_3dPoint point;
for( i = 0; i < cloud.m_P.Count(); i++ )
{
point = cloud.m_P[i];
point.Transform( w2s );
if( rgn.PtInRegion((int)point.x, (int)point.y) )
indices.Append( i );
}
}
return indices.Count() - index_count;
}
示例2: DumpDistanceABHelper
static void DumpDistanceABHelper( ON_TextLog& text_log, ON_3dPoint A0, ON_3dPoint B0, ON_3dPoint A1, ON_3dPoint B1 )
{
if ( A0.DistanceTo(B0) <= A1.DistanceTo(B0) )
DumpDistanceABHelper( text_log, A0, B0 );
else
DumpDistanceABHelper( text_log, A1, B1 );
}
示例3: ON_ERROR
bool ON_BezierCageMorph::Create(
ON_3dPoint P0,
ON_3dPoint P1,
ON_3dPoint P2,
ON_3dPoint P3,
int point_countX,
int point_countY,
int point_countZ
)
{
if ( point_countX < 2 || point_countY < 2 || point_countZ < 2
|| !P0.IsValid()
|| !P1.IsValid()
|| !P2.IsValid()
|| !P3.IsValid() )
{
ON_ERROR("ON_BezierCageMorph::Create - invalid input");
}
m_bValid = false;
ON_3dVector X = P1-P0;
ON_3dVector Y = P2-P0;
ON_3dVector Z = P3-P0;
ON_Xform xform(1.0);
xform[0][0] = X.x;
xform[1][0] = X.y;
xform[2][0] = X.z;
xform[0][1] = Y.x;
xform[1][1] = Y.y;
xform[2][1] = Y.z;
xform[0][2] = Z.x;
xform[1][2] = Z.y;
xform[2][2] = Z.z;
xform[0][3] = P0.x;
xform[1][3] = P0.y;
xform[2][3] = P0.z;
double min_pivot = 0.0;
m_bValid = xform.Invert(&min_pivot);
if (m_bValid)
{
ON_3dPoint box_corners[8];
box_corners[0] = P0;
box_corners[1] = P1;
box_corners[2] = P0+X+Y;
box_corners[3] = P2;
box_corners[4] = P3;
box_corners[5] = P3+X;
box_corners[6] = P3+X+Y;
box_corners[7] = P3+Y;
m_bValid = m_rst2xyz.Create(box_corners,point_countX,point_countY,point_countZ);
m_xyz2rst = xform;
}
else
{
ON_ERROR("ON_BezierCageMorph::Create - invalid input - P0,P1,P2,P3 are coplanar");
m_rst2xyz.Destroy();
}
return m_bValid;
}
示例4: updateInternal
/**
* \return Point on spline at given position t (0..1).
*/
RVector RSpline::getPointAt(double t) const {
updateInternal();
#ifndef R_NO_OPENNURBS
ON_3dPoint p = curve.PointAt(t);
if (p.IsUnsetPoint()) {
return RVector::invalid;
}
return RVector(p.x, p.y);
#else
return RVector::invalid;
#endif
}
示例5: exception
ON_2dPoint
BBNode::getClosestPointEstimate(const ON_3dPoint &pt, ON_Interval &u, ON_Interval &v)
{
if (isLeaf()) {
double uvs[5][2] = {{m_u.Min(), m_v.Min()}, {m_u.Max(), m_v.Min()},
{m_u.Max(), m_v.Max()}, {m_u.Min(), m_v.Max()},
{m_u.Mid(), m_v.Mid()}
}; /* include the estimate */
ON_3dPoint corners[5];
const ON_Surface *surf = m_face->SurfaceOf();
u = m_u;
v = m_v;
/* ??? pass these in from SurfaceTree::surfaceBBox() to avoid
* this recalculation?
*/
if (!surf->EvPoint(uvs[0][0], uvs[0][1], corners[0]) ||
!surf->EvPoint(uvs[1][0], uvs[1][1], corners[1]) ||
!surf->EvPoint(uvs[2][0], uvs[2][1], corners[2]) ||
!surf->EvPoint(uvs[3][0], uvs[3][1], corners[3]))
{
throw new std::exception(); /* FIXME */
}
corners[4] = BBNode::m_estimate;
/* find the point on the surface closest to pt */
size_t mini = 0;
double mindist = pt.DistanceTo(corners[mini]);
double tmpdist;
for (size_t i = 1; i < 5; i++) {
tmpdist = pt.DistanceTo(corners[i]);
TRACE("\t" << mindist << " < " << tmpdist);
if (tmpdist < mindist) {
mini = i;
mindist = tmpdist;
}
}
TRACE("Closest: " << mindist << "; " << PT2(uvs[mini]));
return ON_2dPoint(uvs[mini][0], uvs[mini][1]);
} else {
if (m_children.size() > 0) {
BBNode *closestNode = m_children[0];
for (size_t i = 1; i < m_children.size(); i++) {
closestNode = closer(pt, closestNode, m_children[i]);
TRACE("\t" << PT(closestNode->m_estimate));
}
return closestNode->getClosestPointEstimate(pt, u, v);
}
throw new std::exception();
}
}
示例6: Value
double ON_Localizer::Value(ON_3dPoint P) const
{
double v,s,t = m_d.m_t[1];
switch ( m_type )
{
case cylinder_type:
// t = distance from P to axis
t = ON_CrossProduct( P-m_P, m_V ).Length();
break;
case plane_type:
// t = distance above plane
t = m_V.x*P.x + m_V.y*P.y + m_V.z*P.z + m_P.x;
break;
case sphere_type:
// t = distance to P
t = (P-m_P).Length();
break;
case curve_type:
if ( !m_nurbs_curve )
return 1.0;
if ( !m_nurbs_curve->GetClosestPoint(P,&v) )
return 1.0;
t = P.DistanceTo(m_nurbs_curve->PointAt(v));
break;
case surface_type:
if ( !m_nurbs_surface )
return 1.0;
if ( !m_nurbs_surface->GetClosestPoint(P,&s,&v) )
return 1.0;
t = P.DistanceTo(m_nurbs_surface->PointAt(s,v));
break;
case distance_type:
// confused user should be calling Value(double)
return 1.0; // default must be one
break;
default:
return 1.0; // default must be one
}
return Value(t);
}
示例7: Domain
ON_BOOL32 ON_ArcCurve::SetEndPoint(ON_3dPoint end_point)
{
if (IsCircle())
return false;
ON_BOOL32 rc = false;
if ( m_dim == 3 || end_point.z == 0.0 )
{
ON_3dPoint P;
ON_3dVector T;
double t = Domain()[0];
Ev1Der( t, P, T );
ON_Arc a;
rc = a.Create( P, T, end_point );
if ( rc )
{
m_arc = a;
}
else {
ON_3dPoint start_point = PointAt(Domain()[0]);
if (end_point.DistanceTo(start_point) < ON_ZERO_TOLERANCE*m_arc.Radius()){
//make arc into circle
m_arc.plane.xaxis = start_point - m_arc.Center();
m_arc.plane.xaxis.Unitize();
m_arc.plane.yaxis = ON_CrossProduct(m_arc.Normal(), m_arc.plane.xaxis);
m_arc.plane.yaxis.Unitize();
m_arc.SetAngleRadians(2.0*ON_PI);
rc = true;
}
}
}
return rc;
}
示例8: PointAt
ON_BOOL32 ON_LineCurve::Trim( const ON_Interval& domain )
{
ON_BOOL32 rc = false;
if ( domain.IsIncreasing() )
{
ON_3dPoint p = PointAt( domain[0] );
ON_3dPoint q = PointAt( domain[1] );
if( p.DistanceTo(q)>0){ // 2 April 2003 Greg Arden A successfull trim
// should return an IsValid ON_LineCurve .
m_line.from = p;
m_line.to = q;
m_t = domain;
rc = true;
}
}
return rc;
}
示例9: ClosestPointTo
bool ON_Polyline::ClosestPointTo( const ON_3dPoint& point, double *t, int segment_index0, int segment_index1 ) const
{
bool rc = false;
int segment_index;
double segment_t, segment_d, best_t, best_d;
best_t = 0.0; // to keep lint quiet
best_d = 0.0; // to keep lint quiet
if ( t ) {
if ( segment_index0 < 0 )
segment_index0 = 0;
if ( segment_index1 > SegmentCount() )
segment_index1 = SegmentCount();
for ( segment_index = segment_index0; segment_index < segment_index1; segment_index++ ) {
double seg_length = m_a[segment_index].DistanceTo(m_a[segment_index + 1]);
if (seg_length < ON_EPSILON)
segment_t = 0.0;
else {
const ON_3dVector D = SegmentTangent(segment_index);
const int i = ( point.DistanceTo(m_a[segment_index]) <= point.DistanceTo(m_a[segment_index+1]) ) ? 0 : 1;
segment_t = (point - m_a[segment_index+i])*D/seg_length;
if ( i ) {
segment_t = 1.0 + segment_t;
}
if ( segment_t < 0.0 )
segment_t = 0.0;
else if (segment_t > 1.0 )
segment_t = 1.0;
}
segment_d = point.DistanceTo((1-segment_t)*m_a[segment_index] + segment_t*m_a[segment_index+1]);
if ( !rc || segment_d < best_d )
{
best_t = segment_t + ((double)segment_index);
best_d = segment_d;
}
rc = true;
}
}
if (rc)
*t = best_t;
return rc;
}
示例10: ClosestPointTo
bool ON_Line::ClosestPointTo( const ON_3dPoint& point, double *t ) const
{
bool rc = false;
if ( t ) {
const ON_3dVector D = Direction();
const double DoD = D.LengthSquared();
if ( DoD > 0.0 ) {
if ( point.DistanceTo(from) <= point.DistanceTo(to) ) {
*t = ((point - from)*D)/DoD;
}
else {
*t = 1.0 + ((point - to)*D)/DoD;
}
rc = true;
}
else {
*t = 0.0;
}
}
return rc;
}
示例11: Domain
bool ON_PlaneSurface::GetClosestPoint( const ON_3dPoint& test_point,
double* s,double* t, // parameters of local closest point returned here
double maximum_distance,
const ON_Interval* sdomain, // first parameter sub_domain
const ON_Interval* tdomain // second parameter sub_domain
) const
{
double u = 0.0, v=0.0;
ON_Interval sdom = Domain(0);
ON_Interval tdom = Domain(1);
if(sdomain==NULL)
sdomain = &sdom;
if(tdomain==NULL)
tdomain = &tdom;
bool rc = m_plane.ClosestPointTo( test_point, &u, &v );
if ( rc )
{
// convert m_plane coordinates to ON_Surface coordinates
if ( m_domain[0] != m_extents[0] )
{
u = m_domain[0].ParameterAt( m_extents[0].NormalizedParameterAt(u) );
}
if ( m_domain[1] != m_extents[1] )
{
v = m_domain[1].ParameterAt( m_extents[1].NormalizedParameterAt(v) );
}
if ( u < sdomain->Min() )
u = sdomain->Min();
else if ( u > sdomain->Max() )
u = sdomain->Max();
if ( v < tdomain->Min() )
v = tdomain->Min();
else if ( v > tdomain->Max() )
v = tdomain->Max();
if ( s )
*s = u;
if ( t )
*t = v;
if (maximum_distance > 0.0)
{
ON_3dPoint pt = PointAt(u,v);
if ( test_point.DistanceTo(pt) > maximum_distance )
rc = false;
}
}
return rc;
}
示例12: ON_BrepExtrudeHelper_MakeConeSrf
static
ON_NurbsSurface* ON_BrepExtrudeHelper_MakeConeSrf( const ON_3dPoint& apex_point,
const ON_BrepEdge& edge, ON_BOOL32 bRev )
{
// The "s" parameter runs along the edge.
// The "t" parameter is the ruling parameter;
// t=0 is at the base_edge and t=max is at the apex.
// surface side location
// south base_edge
// east line from bRev?START:END of edge to apex
// north singular side at apex
// west line from bRev?END:START of edge to apex.
ON_NurbsSurface* cone_srf = new ON_NurbsSurface();
if ( cone_srf->CreateConeSurface( apex_point, edge ) )
{
if ( bRev )
cone_srf->Reverse(0);
// get a decent interval for the ruling parameter
double d = 0.0;
ON_Interval edom = edge.Domain();
ON_3dPoint pt;
int i, hint=0;
for ( i = 0; i <= 16; i++ )
{
if ( !edge.EvPoint( edom.ParameterAt(i/16.0), pt, 0, &hint ) )
continue;
if ( pt.DistanceTo(apex_point) > d )
d = pt.DistanceTo(apex_point);
}
if ( d > ON_SQRT_EPSILON )
cone_srf->SetDomain(1,0.0,d);
}
else
{
delete cone_srf;
cone_srf = 0;
}
return cone_srf;
}
示例13: SetCommandPrompt
int CGetPolylinePoints::GetPoints()
{
m_point_array.Empty();
SetCommandPrompt( L"Start of polyline" );
AcceptNothing();
CRhinoGet::result res = GetPoint();
if( res == CRhinoGet::point )
{
m_point_array.Append( Point() );
SetCommandPrompt( L"Next point of polyline" );
for( ;; )
{
SetBasePoint( Point() );
res = GetPoint();
if( res == CRhinoGet::point )
{
ON_3dPoint pt = Point();
if( pt.DistanceTo(m_point_array[m_point_array.Count()-1]) > ON_ZERO_TOLERANCE )
m_point_array.Append( Point() );
continue;
}
if( res == CRhinoGet::nothing )
break;
return 0;
}
}
return m_point_array.Count();
}
示例14: GetLocalClosestPoint
ON_BOOL32 ON_LineCurve::GetLocalClosestPoint( const ON_3dPoint& test_point,
double seed_parameter,
double* t,
const ON_Interval* sub_domain
) const
{
if ( sub_domain )
{
if ( seed_parameter < sub_domain->Min() )
seed_parameter = sub_domain->Min();
else if ( seed_parameter > sub_domain->Max() )
seed_parameter = sub_domain->Max();
}
ON_BOOL32 rc = GetClosestPoint( test_point, t, 0.0, sub_domain );
if ( rc
&& t
&& seed_parameter != *t
&& test_point.DistanceTo(PointAt(seed_parameter)) <= test_point.DistanceTo(PointAt(*t))
)
{
*t = seed_parameter;
}
return rc;
}
示例15: CreateSphereLocalizer
bool ON_Localizer::CreateSphereLocalizer( ON_3dPoint P, double r0, double r1 )
{
Destroy();
if ( P.IsValid()
&& ON_IsValid(r0)
&& ON_IsValid(r1)
&& r0 > 0.0
&& r1 > 0.0
&& r0 != r1 )
{
m_P = P;
m_V.Zero();
m_d.Set(r0,r1);
m_type = sphere_type;
}
return (sphere_type == m_type);
}