本文整理汇总了C++中ON_SimpleArray::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ON_SimpleArray::Empty方法的具体用法?C++ ON_SimpleArray::Empty怎么用?C++ ON_SimpleArray::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ON_SimpleArray
的用法示例。
在下文中一共展示了ON_SimpleArray::Empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCorners
bool ON_Box::GetCorners( ON_SimpleArray<ON_3dPoint>& corners ) const
{
corners.Empty();
corners.Reserve(8);
bool rc = GetCorners(corners.Array());
if (rc)
corners.SetCount(8);
return rc;
}
示例2: FindLoops
void FindLoops(ON_Brep **b) {
ON_3dPoint ptmatch, ptterminate, pstart, pend;
int *curvearray;
curvearray = static_cast<int*>(bu_malloc((*b)->m_C3.Count() * sizeof(int), "sketch edge list"));
for (int i = 0; i < (*b)->m_C3.Count(); i++) {
curvearray[i] = -1;
}
ON_SimpleArray<ON_Curve *> allsegments;
ON_SimpleArray<ON_Curve *> loopsegments;
int loop_complete;
for (int i = 0; i < (*b)->m_C3.Count(); i++) {
allsegments.Append((*b)->m_C3[i]);
}
int allcurvesassigned = 0;
int assignedcount = 0;
int curvecount = 0;
int loopcount = 0;
while (allcurvesassigned != 1) {
int havefirstcurve = 0;
while ((havefirstcurve == 0) && (curvecount < allsegments.Count())) {
if (curvearray[curvecount] == -1) {
havefirstcurve = 1;
} else {
curvecount++;
}
}
// First, sort through things to assign curves to loops.
loop_complete = 0;
while ((loop_complete != 1) && (allcurvesassigned != 1)) {
curvearray[curvecount] = loopcount;
ptmatch = (*b)->m_C3[curvecount]->PointAtEnd();
ptterminate = (*b)->m_C3[curvecount]->PointAtStart();
for (int i = 0; i < allsegments.Count(); i++) {
pstart = (*b)->m_C3[i]->PointAtStart();
pend = (*b)->m_C3[i]->PointAtEnd();
if (NEAR_ZERO(ptmatch.DistanceTo(pstart), ON_ZERO_TOLERANCE) && (curvearray[i] == -1)) {
curvecount = i;
ptmatch = pend;
i = allsegments.Count();
if (NEAR_ZERO(pend.DistanceTo(ptterminate), ON_ZERO_TOLERANCE)) {
loop_complete = 1;
loopcount++;
}
} else {
if (i == allsegments.Count() - 1) {
loop_complete = 1; //If we reach this pass, loop had better be complete
loopcount++;
assignedcount = 0;
for (int j = 0; j < allsegments.Count(); j++) {
if (curvearray[j] != -1) assignedcount++;
}
if (allsegments.Count() == assignedcount) allcurvesassigned = 1;
}
}
}
}
}
double maxdist = 0.0;
int largest_loop_index = 0;
for (int i = 0; i <= loopcount ; i++) {
ON_BoundingBox lbbox;
for (int j = 0; j < (*b)->m_C3.Count(); j++) {
if (curvearray[j] == i) {
ON_Curve *currcurve = (*b)->m_C3[j];
currcurve->GetBoundingBox(lbbox, true);
}
}
point_t minpt, maxpt;
double currdist;
VSET(minpt, lbbox.m_min[0], lbbox.m_min[1], lbbox.m_min[2]);
VSET(maxpt, lbbox.m_max[0], lbbox.m_max[1], lbbox.m_max[2]);
currdist = DIST_PT_PT(minpt, maxpt);
if (currdist > maxdist) {
maxdist = currdist;
largest_loop_index = i;
}
}
for (int i = 0; i < allsegments.Count(); i++) {
if (curvearray[i] == largest_loop_index) loopsegments.Append((*b)->m_C3[i]);
}
(*b)->NewPlanarFaceLoop(0, ON_BrepLoop::outer, loopsegments, true);
loopsegments.Empty();
// If there's anything left, make inner loops out of it
for (int i = 0; i <= loopcount; i++) {
if (i != largest_loop_index) {
for (int j = 0; j < allsegments.Count(); j++) {
if (curvearray[j] == i) loopsegments.Append((*b)->m_C3[j]);
}
(*b)->NewPlanarFaceLoop(0, ON_BrepLoop::inner, loopsegments, true);
}
loopsegments.Empty();
}
//.........这里部分代码省略.........
示例3: FindAdjacentFaces
static void FindAdjacentFaces(const ON_MeshTopology& Top,
ON_SimpleArray<int>& FacesToCheck,
const ON_SimpleArray<int>& SortedFaceArray,
ON_SimpleArray<int>& DupFaceArray,
bool bUseVertexConnections,
bool bTopologicalConnections)
{
int fi, vi, ei, facecount = FacesToCheck.Count(), totalcount = SortedFaceArray.Count();
DupFaceArray.Zero();
ON_SimpleArray<int> OldFacesToCheck = FacesToCheck;
FacesToCheck.Empty();
for (fi=0;fi<facecount;fi++)
{
if (totalcount > OldFacesToCheck[fi])
{
if (0 == SortedFaceArray[OldFacesToCheck[fi]])
{
FacesToCheck.Append(OldFacesToCheck[fi]);
DupFaceArray[OldFacesToCheck[fi]] = 1;
}
if (false == bUseVertexConnections)
{
int j;
const ON_MeshTopologyFace& face = Top.m_topf[OldFacesToCheck[fi]];
for(ei=0;ei<(face.IsQuad()?4:3);ei++)
{
const ON_MeshTopologyEdge& edge = Top.m_tope[face.m_topei[ei]];
if (1 == edge.m_topf_count || (false == bTopologicalConnections && true == IsUnweldedEdge(face.m_topei[ei], Top)))
continue;
for(j=0;j<edge.m_topf_count;j++)
{
if (0 == SortedFaceArray[edge.m_topfi[j]] && 1 != DupFaceArray[edge.m_topfi[j]])
{
FacesToCheck.Append(edge.m_topfi[j]);
DupFaceArray[edge.m_topfi[j]] = 1;
}
}
}
}
else
{
int j, k, m;
ON_3fPoint Pt;
const ON_MeshFace& face = Top.m_mesh->m_F[OldFacesToCheck[fi]];
for(vi=0;vi<(face.IsQuad()?4:3);vi++)
{
const ON_MeshTopologyVertex& vertex = Top.m_topv[Top.m_topv_map[face.vi[vi]]];
for (j=0; vertex.m_tope_count>j; j++)
{
const ON_MeshTopologyEdge& edge = Top.m_tope[vertex.m_topei[j]];
for (k=0; edge.m_topf_count>k; k++)
{
if (true == bTopologicalConnections)
{
if (0 == SortedFaceArray[edge.m_topfi[k]] && 1 != DupFaceArray[edge.m_topfi[k]])
{
FacesToCheck.Append(edge.m_topfi[k]);
DupFaceArray[edge.m_topfi[k]] = 1;
}
}
else
{
Pt = Top.m_mesh->m_V[vertex.m_vi[0]];
const ON_MeshFace& thisface = Top.m_mesh->m_F[edge.m_topfi[k]];
for (m=0; m<(thisface.IsQuad()?4:3);m++)
{
if (Pt != Top.m_mesh->m_V[thisface.vi[m]])
continue;
if (face.vi[vi] == thisface.vi[m] && 0 == SortedFaceArray[edge.m_topfi[k]] && 1 != DupFaceArray[edge.m_topfi[k]])
{
//Faces share vertex
FacesToCheck.Append(edge.m_topfi[k]);
DupFaceArray[edge.m_topfi[k]] = 1;
break;
}
}
}
}
}
}
}
}
}
}
示例4: hyp_bottom_plane
extern "C" void
rt_hyp_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *)
{
struct rt_hyp_internal *eip;
RT_CK_DB_INTERNAL(ip);
eip = (struct rt_hyp_internal *)ip->idb_ptr;
RT_HYP_CK_MAGIC(eip);
point_t p1_origin, p2_origin;
ON_3dPoint plane1_origin, plane2_origin;
ON_3dVector plane_x_dir, plane_y_dir;
// First, find planes corresponding to the top and bottom faces - initially
vect_t x_dir, y_dir;
VMOVE(x_dir, eip->hyp_A);
VCROSS(y_dir, eip->hyp_A, eip->hyp_Hi);
VREVERSE(y_dir, y_dir);
VMOVE(p1_origin, eip->hyp_Vi);
plane1_origin = ON_3dPoint(p1_origin);
plane_x_dir = ON_3dVector(x_dir);
plane_y_dir = ON_3dVector(y_dir);
const ON_Plane hyp_bottom_plane(plane1_origin, plane_x_dir, plane_y_dir);
VADD2(p2_origin, eip->hyp_Vi, eip->hyp_Hi);
plane2_origin = ON_3dPoint(p2_origin);
const ON_Plane hyp_top_plane(plane2_origin, plane_x_dir, plane_y_dir);
// Next, create ellipses in the planes corresponding to the edges of the hyp
ON_Ellipse b_ell(hyp_bottom_plane, MAGNITUDE(eip->hyp_A), eip->hyp_b);
ON_NurbsCurve* bcurve = ON_NurbsCurve::New();
b_ell.GetNurbForm((*bcurve));
bcurve->SetDomain(0.0, 1.0);
ON_Ellipse t_ell(hyp_top_plane, MAGNITUDE(eip->hyp_A), eip->hyp_b);
ON_NurbsCurve* tcurve = ON_NurbsCurve::New();
t_ell.GetNurbForm((*tcurve));
tcurve->SetDomain(0.0, 1.0);
// Generate the bottom cap
ON_SimpleArray<ON_Curve*> boundary;
boundary.Append(ON_Curve::Cast(bcurve));
ON_PlaneSurface* bp = new ON_PlaneSurface();
bp->m_plane = hyp_bottom_plane;
bp->SetDomain(0, -100.0, 100.0);
bp->SetDomain(1, -100.0, 100.0);
bp->SetExtents(0, bp->Domain(0));
bp->SetExtents(1, bp->Domain(1));
(*b)->m_S.Append(bp);
const int bsi = (*b)->m_S.Count() - 1;
ON_BrepFace& bface = (*b)->NewFace(bsi);
(*b)->NewPlanarFaceLoop(bface.m_face_index, ON_BrepLoop::outer, boundary, true);
const ON_BrepLoop* bloop = (*b)->m_L.Last();
bp->SetDomain(0, bloop->m_pbox.m_min.x, bloop->m_pbox.m_max.x);
bp->SetDomain(1, bloop->m_pbox.m_min.y, bloop->m_pbox.m_max.y);
bp->SetExtents(0, bp->Domain(0));
bp->SetExtents(1, bp->Domain(1));
(*b)->FlipFace(bface);
(*b)->SetTrimIsoFlags(bface);
boundary.Empty();
delete bcurve;
// Generate the top cap
boundary.Append(ON_Curve::Cast(tcurve));
ON_PlaneSurface* tp = new ON_PlaneSurface();
tp->m_plane = hyp_top_plane;
tp->SetDomain(0, -100.0, 100.0);
tp->SetDomain(1, -100.0, 100.0);
tp->SetExtents(0, bp->Domain(0));
tp->SetExtents(1, bp->Domain(1));
(*b)->m_S.Append(tp);
int tsi = (*b)->m_S.Count() - 1;
ON_BrepFace& tface = (*b)->NewFace(tsi);
(*b)->NewPlanarFaceLoop(tface.m_face_index, ON_BrepLoop::outer, boundary, true);
ON_BrepLoop* tloop = (*b)->m_L.Last();
tp->SetDomain(0, tloop->m_pbox.m_min.x, tloop->m_pbox.m_max.x);
tp->SetDomain(1, tloop->m_pbox.m_min.y, tloop->m_pbox.m_max.y);
tp->SetExtents(0, bp->Domain(0));
tp->SetExtents(1, bp->Domain(1));
(*b)->SetTrimIsoFlags(tface);
delete tcurve;
// Now, the hard part. Need an elliptical hyperbolic NURBS surface.
// First step is to create a nurbs curve.
double MX = eip->hyp_b * eip->hyp_bnr;
point_t ep1, ep2, ep3;
VSET(ep1, -eip->hyp_b, 0, 0.5*MAGNITUDE(eip->hyp_Hi));
VSET(ep2, -MX*eip->hyp_bnr, 0, 0);
VSET(ep3, -eip->hyp_b, 0, -0.5*MAGNITUDE(eip->hyp_Hi));
ON_3dPoint onp1 = ON_3dPoint(ep1);
ON_3dPoint onp2 = ON_3dPoint(ep2);
ON_3dPoint onp3 = ON_3dPoint(ep3);
ON_3dPointArray cpts(3);
cpts.Append(onp1);
//.........这里部分代码省略.........
示例5: ReplaceLoops
bool ON_Hatch::ReplaceLoops(ON_SimpleArray<const ON_Curve*> loop_curves)
{
if(loop_curves.Count() < 1)
return false;
bool rc = true;
ON_Xform xf;
bool flat = false;
ON_SimpleArray<ON_HatchLoop*> loops;
for(int i = 0; i < loop_curves.Count(); i++)
{
if(loop_curves[i] == 0)
{
rc = false;
break;
}
ON_Curve* p2d = loop_curves[i]->Duplicate();
if(p2d == 0)
{
rc = false;
break;
}
if(p2d->Dimension() == 3)
{
if(!flat)
{
xf.PlanarProjection(m_plane);
flat = true;
}
if(!p2d->Transform(xf) ||
!p2d->ChangeDimension(2))
{
delete p2d;
rc = false;
break;
}
}
ON_HatchLoop* loop = new ON_HatchLoop(p2d,loops.Count()?ON_HatchLoop::ltInner:ON_HatchLoop::ltOuter);
if(loop)
loops.Append(loop);
else
delete p2d;
}
if(!rc)
{
for(int i = 0; i < loops.Count(); i++)
delete loops[i];
loops.Empty();
}
if(loops.Count() < 1)
return false;
for(int i = 0; i < m_loops.Count(); i++)
delete m_loops[i];
m_loops.Empty();
for(int i = 0; i < loops.Count(); i++)
m_loops.Append(loops[i]);
return true;
}
示例6: RunCommand
CRhinoCommand::result CCommandVRCreateViews::RunCommand( const CRhinoCommandContext& context )
{
AFX_MANAGE_STATE( ::RhinoApp().RhinoModuleState() ); // dunno, from example
ON_wString wStr;
wStr.Format( L"READY SET\n", EnglishCommandName() );
RhinoApp().Print( wStr );
ON_SimpleArray<CRhinoView*> viewList; // don't know what is up with* this*
ON_SimpleArray<ON_UUID> viewportIds;
CRhinoView* lView = 0;
CRhinoView* rView = 0;
ON_SimpleArray<CRhinoView*> lrViews; // will contain our vr views
int i = 0; // also use this in loops
int lr = 0; // use to track 1st and 2nd find
// builds a list of (current) viewport IDs
context.m_doc.GetViewList( viewList, true, false );
for ( i = 0; i < viewList.Count(); i ++)
{
CRhinoView* tempView = viewList[i]; // pull view out -> this is redeclared here, in sample, but not in second loop
if (tempView)
viewportIds.Append( tempView->ActiveViewportID() );
}
viewList.Empty(); // empty bc we are going to re-build later when new views
context.m_doc.NewView( ON_3dmView() );
context.m_doc.NewView( ON_3dmView() ); // we will build two
// find viewport UUID just created
context.m_doc.GetViewList( viewList, true, false);
for (i = 0; i < viewList.Count(); i++)
{
CRhinoView* tempView = viewList[i];
if (tempView)
{
int rc = viewportIds.Search( tempView->ActiveViewportID() ); // returns index of 1st element which satisfies search. returns -1 when no such item found
if (rc < 0 ) // if current tempView did not exist prior to this running
{
if (lr > 0) // and if lr already found 1
{
rView = tempView; // right is 2nd view we find
break;
// so this breaks when we find, and lView is left as the viewList[i] where we found the new viewport, whose ID was not in our list.
// and we are left with lView being = viewList[i] at new view
}
if (lr == 0)
{
lView = tempView; // left is 1st view
lr = 1;
}
}
else
tempView = 0; // reset lView to null and re-loop
}
}
lrViews.Append(lView);
lrViews.Append(rView);
// init points
ON_3dPoint locationL = ON_3dPoint(100.0,100.0,100.0);
ON_3dPoint locationR = ON_3dPoint(100.0,165.1,100.0);
ON_3dPoint targetSetup = ON_3dPoint(0,0,0);
if (lView && rView)
{
for (int i = 0; i < 2; i++)
{
// RhinoApp().ActiveView()->
ON_3dmView onView = lrViews[i]->ActiveViewport().View();
if(i == 0)
onView.m_name = L"lView";
//lrViews[i]->MoveWindow(0,0,VR().resolution.w/2,VR().resolution.h, true);
if(i == 1)
onView.m_name = L"rView";
//lrViews[i]->MoveWindow(960,0,VR().resolution.w/2,VR().resolution.h, true);
lrViews[i]->ActiveViewport().SetView(onView);
lrViews[i]->ActiveViewport().m_v.m_vp.ChangeToPerspectiveProjection(50,true,35);
lrViews[i]->ActiveViewport().m_v.m_vp.SetCameraLocation(locationL);
lrViews[i]->FloatRhinoView(true);
lrViews[i]->Redraw();
}
}
VR().lView = lView;
VR().rView = rView;
ON_wString SYNC;
SYNC.Format(L"SYNCVRBEGIN\n" );
RhinoApp().Print( SYNC );
if (vrConduit.IsEnabled()
&& ::IsWindow( vrConduit.m_hWnd1 )
&& ::IsWindow( vrConduit.m_hWnd2 ) ) // if is already enabled ?
{
vrConduit.m_pView1 = 0;
vrConduit.m_pView2 = 0;
//.........这里部分代码省略.........