本文整理汇总了C++中ON_3dVector::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ON_3dVector::IsValid方法的具体用法?C++ ON_3dVector::IsValid怎么用?C++ ON_3dVector::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ON_3dVector
的用法示例。
在下文中一共展示了ON_3dVector::IsValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PerpindicularDirection
ON_3dVector ON_Light::PerpindicularDirection() const
{
// returns a consistent vector perpendicular to the
// light's direction. This vector is useful for
// user interface display.
ON_3dVector dir = m_direction;
if ( !dir.IsValid() || !dir.Unitize() )
return ON_UNSET_VECTOR;
ON_3dVector xdir;
if ( IsLinearLight() || IsRectangularLight() )
{
xdir = m_length;
if ( xdir.IsValid() && xdir.Unitize() && fabs(xdir*dir) <= ON_SQRT_EPSILON )
return xdir;
}
if( dir.IsParallelTo( ON_zaxis, ON_DEGREES_TO_RADIANS * 3.0))
xdir = ON_CrossProduct( dir, ON_xaxis);
else
xdir = ON_CrossProduct( dir, ON_zaxis);
xdir.Unitize();
ON_3dVector ydir = ON_CrossProduct(dir,xdir);
ydir.Unitize();
ON_3dVector right;
switch(dir.MaximumCoordinateIndex())
{
case 0:
right = (fabs(xdir.y) > fabs(ydir.y)) ? xdir : ydir;
if ( right.y < 0.0 )
right.Reverse();
break;
case 1:
case 2:
right = (fabs(xdir.x) > fabs(ydir.x)) ? xdir : ydir;
if ( right.x < 0.0 )
right.Reverse();
break;
default:
right = xdir;
break;
}
if ( right[right.MaximumCoordinateIndex()] < 0.0 )
right.Reverse();
return right;
}
示例2: CreatePlaneLocalizer
bool ON_Localizer::CreatePlaneLocalizer( ON_3dPoint P, ON_3dVector N, double h0, double h1 )
{
Destroy();
if ( P.IsValid()
&& N.IsValid()
&& N.Length() > 0.0
&& ON_IsValid(h0)
&& ON_IsValid(h1)
&& h0 != h1 )
{
m_V = N;
m_V.Unitize();
m_P.Set( -(m_V.x*P.x + m_V.y*P.y + m_V.z*P.z), 0.0, 0.0 );
m_d.Set(h0,h1);
m_type = plane_type;
}
return (plane_type == m_type);
}
示例3: CreateCylinderLocalizer
bool ON_Localizer::CreateCylinderLocalizer( ON_3dPoint P, ON_3dVector V, double r0, double r1 )
{
Destroy();
if ( P.IsValid()
&& V.IsValid()
&& V.Length() > 0.0
&& ON_IsValid(r0)
&& ON_IsValid(r1)
&& r0 > 0.0
&& r1 > 0.0
&& r0 != r1 )
{
m_P = P;
m_V = V;
m_V.Unitize();
m_d.Set(r0,r1);
m_type = cylinder_type;
}
return (cylinder_type == m_type);
}
示例4: RunCommand
CRhinoCommand::result CCommandSampleGetPointOnMesh::RunCommand( const CRhinoCommandContext& context )
{
// Pick a mesh
CRhinoGetObject go;
go.SetCommandPrompt( L"Select mesh" );
go.SetGeometryFilter( CRhinoGetObject::mesh_object );
go.GetObjects( 1, 1 );
if( go.CommandResult() != CRhinoCommand::success )
return go.CommandResult();
// Validate the pick
const CRhinoMeshObject* mesh_object = CRhinoMeshObject::Cast( go.Object(0).Object() );
if( 0 == mesh_object )
return CRhinoCommand::failure;
// Pick a point on the mesh
ON_MESH_POINT point;
int rc = RhinoGetPointOnMesh( mesh_object, L"Point on mesh", FALSE, point );
if( rc != 0 )
return CRhinoCommand::cancel;
// Add the picked point and print results
context.m_doc.AddPointObject( point.m_P );
RhinoApp().Print( L"Added point on face %d, with %g, %g, %g, %g as barycentric coordinates.\n",
point.m_face_index,
point.m_t[0],
point.m_t[1],
point.m_t[2],
point.m_t[3]
);
// Was the pick on a face?
if( point.m_ci.m_type == ON_COMPONENT_INDEX::mesh_face )
{
// Validate mesh
if( point.m_mesh )
{
ON_3dVector normal = ON_UNSET_POINT;
// Does the mesh have face normals?
if( point.m_mesh->HasFaceNormals() )
{
// Get the face normal
ON_3fVector normal = point.m_mesh->m_FN[point.m_ci.m_index];
}
else
{
// Compute the face normal
if( point.m_mesh->HasDoublePrecisionVertices() )
point.m_mesh->m_F[point.m_ci.m_index].ComputeFaceNormal( point.m_mesh->DoublePrecisionVertices().Array(), normal );
else
point.m_mesh->m_F[point.m_ci.m_index].ComputeFaceNormal( point.m_mesh->m_V.Array(), normal );
}
// Validate normal
if( normal.IsValid() )
{
// Add normal line, with arrow, and print results
ON_Line line( point.m_P, point.m_P + normal );
ON_3dmObjectAttributes attributes;
context.m_doc.GetDefaultObjectAttributes( attributes );
attributes.m_object_decoration = ON::end_arrowhead;
context.m_doc.AddCurveObject( line, &attributes );
context.m_doc.Redraw();
ON_wString normal_str;
RhinoFormatPoint( normal, normal_str );
RhinoApp().Print( L"Added line normal to face %d, with % as normal direction.\n", point.m_ci.m_index, normal_str );
}
}
}
return CRhinoCommand::success;
}
示例5: ON_BrepExtrude
bool ON_BrepExtrude(
ON_Brep& brep,
const ON_Curve& path_curve,
bool bCap
)
{
ON_Workspace ws;
const int vcount0 = brep.m_V.Count();
const int tcount0 = brep.m_T.Count();
const int lcount0 = brep.m_L.Count();
const int ecount0 = brep.m_E.Count();
const int fcount0 = brep.m_F.Count();
const ON_3dPoint PathStart = path_curve.PointAtStart();
ON_3dPoint P = path_curve.PointAtEnd();
if ( !PathStart.IsValid() || !P.IsValid() )
return false;
const ON_3dVector height = P - PathStart;
if ( !height.IsValid() || height.Length() <= ON_ZERO_TOLERANCE )
return false;
ON_Xform tr;
tr.Translation(height);
// count number of new sides
int side_count = 0;
int i, vi, ei, fi;
bool* bSideEdge = (bool*)ws.GetIntMemory(ecount0*sizeof(bSideEdge[0]));
for ( ei = 0; ei < ecount0; ei++ )
{
const ON_BrepEdge& e = brep.m_E[ei];
if ( 1 == e.m_ti.Count() )
{
side_count++;
bSideEdge[ei] = true;
}
else
{
bSideEdge[ei] = false;
}
}
brep.m_V.Reserve( 2*vcount0 );
i = 4*side_count + (bCap?tcount0:0);
brep.m_T.Reserve( tcount0 + i );
brep.m_C2.Reserve( brep.m_C2.Count() + i );
brep.m_L.Reserve( lcount0 + side_count + (bCap?lcount0:0) );
i = side_count + (bCap?ecount0:side_count);
brep.m_E.Reserve( ecount0 + i );
brep.m_C3.Reserve( brep.m_C3.Count() + i );
i = side_count + (bCap?fcount0:0);
brep.m_F.Reserve( fcount0 + i );
brep.m_S.Reserve( brep.m_S.Count() + i );
bool bOK = true;
// build top vertices
int* topvimap = ws.GetIntMemory(vcount0);
memset(topvimap,0,vcount0*sizeof(topvimap[0]));
if ( bCap )
{
for ( vi = 0; vi < vcount0; vi++ )
{
const ON_BrepVertex& bottomv = brep.m_V[vi];
ON_BrepVertex& topv = brep.NewVertex(bottomv.point+height,bottomv.m_tolerance);
topvimap[vi] = topv.m_vertex_index;
}
}
else
{
for ( ei = 0; ei < ecount0; ei++ )
{
if ( bSideEdge[ei] )
{
const ON_BrepEdge& bottome = brep.m_E[ei];
int bottomvi0 = bottome.m_vi[0];
if ( bottomvi0 < 0 || bottomvi0 >= vcount0 )
{
bOK = false;
break;
}
int bottomvi1 = bottome.m_vi[1];
if ( bottomvi1 < 0 || bottomvi1 >= vcount0 )
{
bOK = false;
break;
}
if ( !topvimap[bottomvi0] )
{
const ON_BrepVertex& bottomv = brep.m_V[bottomvi0];
ON_BrepVertex& topv = brep.NewVertex(bottomv.point+height,bottomv.m_tolerance);
topvimap[bottomvi0] = topv.m_vertex_index;
}
if ( !topvimap[bottomvi1] )
{
const ON_BrepVertex& bottomv = brep.m_V[bottomvi1];
ON_BrepVertex& topv = brep.NewVertex(bottomv.point+height,bottomv.m_tolerance);
topvimap[bottomvi1] = topv.m_vertex_index;
}
}
//.........这里部分代码省略.........