本文整理汇总了C++中ON_Brep::NewTrim方法的典型用法代码示例。如果您正苦于以下问题:C++ ON_Brep::NewTrim方法的具体用法?C++ ON_Brep::NewTrim怎么用?C++ ON_Brep::NewTrim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ON_Brep
的用法示例。
在下文中一共展示了ON_Brep::NewTrim方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeTrimmingLoop
static int MakeTrimmingLoop( ON_Brep& brep, // returns index of loop
ON_BrepFace& face, // face loop is on
int v0, int v1, int v2, // Indices of corner vertices listed in A,B,C order
int e0, // index of first edge
int e0_dir, // orientation of edge
int e1, // index second edgee
int e1_dir, // orientation of edge
int e2, // index third edge
int e2_dir // orientation of edge
)
{
const ON_Surface& srf = *brep.m_S[face.m_si];
//Create new loop
ON_BrepLoop& loop = brep.NewLoop( ON_BrepLoop::outer, face );
// Create trimming curves running counter clockwise.
// Note that trims of outer loops run counter clockwise while trims of inner loops (holes) run clockwise.
// Also note that when trims locate on surface N,S,E or W ends, then trim_iso becomes N_iso, S_iso, E_iso and W_iso respectfully.
// While if trim is parallel to surface N,S or E,W, then trim is becomes y_iso and x_iso respectfully, the rest are not_iso.
// Start at the south side
ON_Curve* c2;
int c2i, ei=0, bRev3d=0;
ON_Surface::ISO iso = ON_Surface::not_iso;
for ( int side = 0; side < 3; side++ ) {
c2 = CreateTrimmingCurve( srf, side );
//Add trimming curve to brep trmming curves array
c2i = brep.m_C2.Count();
brep.m_C2.Append(c2);
switch ( side ) {
case 0: // south
ei = e0;
bRev3d = (e0_dir == -1);
iso = ON_Surface::S_iso;
break;
case 1: // diagonal
ei = e1;
bRev3d = (e1_dir == -1);
iso = ON_Surface::not_iso;
break;
case 2: // diagonal
ei = e2;
bRev3d = (e2_dir == -1);
iso = ON_Surface::not_iso;
break;
}
//Create new trim topology that references edge, direction reletive to edge, loop and trim curve geometry
ON_BrepTrim& trim = brep.NewTrim( brep.m_E[ei], bRev3d, loop, c2i );
trim.m_iso = iso;
trim.m_type = ON_BrepTrim::boundary; // This one b-rep face, so all trims are boundary ones.
trim.m_tolerance[0] = 0.0; // This simple example is exact - for models with non-exact
trim.m_tolerance[1] = 0.0; // data, set tolerance as explained in definition of ON_BrepTrim.
}
return loop.m_loop_index;
}
示例2:
//.........这里部分代码省略.........
brep->m_C2.Append(trimcurve30); /* 3 */
// EDGES
/* C3 curve */
// left face edges
brep->NewEdge(brep->m_V[0], brep->m_V[1], 0, NULL, SMALL_FASTF); /* 0 */
brep->NewEdge(brep->m_V[1], brep->m_V[2], 1, NULL, SMALL_FASTF); /* 1 */
brep->NewEdge(brep->m_V[2], brep->m_V[3], 2, NULL, SMALL_FASTF); /* 2 */
brep->NewEdge(brep->m_V[3], brep->m_V[0], 3, NULL, SMALL_FASTF); /* 3 */
// right face edges
brep->NewEdge(brep->m_V[5], brep->m_V[4], 4, NULL, SMALL_FASTF); /* 4 */
brep->NewEdge(brep->m_V[6], brep->m_V[5], 5, NULL, SMALL_FASTF); /* 5 */
brep->NewEdge(brep->m_V[7], brep->m_V[6], 6, NULL, SMALL_FASTF); /* 6 */
brep->NewEdge(brep->m_V[4], brep->m_V[7], 7, NULL, SMALL_FASTF); /* 7 */
// horizontal face edges
brep->NewEdge(brep->m_V[0], brep->m_V[4], 8, NULL, SMALL_FASTF); /* 8 */
brep->NewEdge(brep->m_V[5], brep->m_V[1], 9, NULL, SMALL_FASTF); /* 9 */
brep->NewEdge(brep->m_V[2], brep->m_V[6], 10, NULL, SMALL_FASTF); /* 10 */
brep->NewEdge(brep->m_V[7], brep->m_V[3], 11, NULL, SMALL_FASTF); /* 11 */
// XXX
brep->NewEdge(brep->m_V[8], brep->m_V[9], 12, NULL, SMALL_FASTF); /* 12 */
brep->NewEdge(brep->m_V[9], brep->m_V[10], 13, NULL, SMALL_FASTF); /* 13 */
brep->NewEdge(brep->m_V[10], brep->m_V[11], 14, NULL, SMALL_FASTF); /* 14 */
brep->NewEdge(brep->m_V[11], brep->m_V[8], 15, NULL, SMALL_FASTF); /* 15 */
// FACES
ON_BrepFace& face0123 = brep->NewFace(0);
ON_BrepLoop& loop0123 = brep->NewLoop(ON_BrepLoop::outer, face0123); /* 0 */
ON_BrepTrim& trim01 = brep->NewTrim(brep->m_E[0], false, loop0123, 0 /* trim */); /* m_T[0] */
trim01.m_iso = ON_Surface::S_iso;
trim01.m_type = ON_BrepTrim::mated;
trim01.m_tolerance[0] = SMALL_FASTF;
trim01.m_tolerance[1] = SMALL_FASTF;
ON_BrepTrim& trim12 = brep->NewTrim(brep->m_E[1], false, loop0123, 1 /* trim */); /* 1 */
trim12.m_iso = ON_Surface::E_iso;
trim12.m_type = ON_BrepTrim::mated;
trim12.m_tolerance[0] = SMALL_FASTF;
trim12.m_tolerance[1] = SMALL_FASTF;
ON_BrepTrim& trim23 = brep->NewTrim(brep->m_E[2], false, loop0123, 2 /* trim */); /* 2 */
trim23.m_iso = ON_Surface::N_iso;
trim23.m_type = ON_BrepTrim::mated;
trim23.m_tolerance[0] = SMALL_FASTF;
trim23.m_tolerance[1] = SMALL_FASTF;
ON_BrepTrim& trim30 = brep->NewTrim(brep->m_E[3], false, loop0123, 3 /* trim */); /* 3 */
trim30.m_iso = ON_Surface::W_iso;
trim30.m_type = ON_BrepTrim::mated;
trim30.m_tolerance[0] = SMALL_FASTF;
trim30.m_tolerance[1] = SMALL_FASTF;
ON_BrepFace& face4765 = brep->NewFace(1 /* surfaceID */);
ON_BrepLoop& loop4765 = brep->NewLoop(ON_BrepLoop::outer, face4765); /* 1 */
ON_BrepTrim& trim47 = brep->NewTrim(brep->m_E[7], false, loop4765, 0 /* trim */); /* 4 */
trim47.m_iso = ON_Surface::S_iso;
trim47.m_type = ON_BrepTrim::mated;
trim47.m_tolerance[0] = SMALL_FASTF;
trim47.m_tolerance[1] = SMALL_FASTF;
ON_BrepTrim& trim76 = brep->NewTrim(brep->m_E[6], false, loop4765, 1 /* trim */); /* 5 */
trim76.m_iso = ON_Surface::E_iso;
trim76.m_type = ON_BrepTrim::mated;
trim76.m_tolerance[0] = SMALL_FASTF;
trim76.m_tolerance[1] = SMALL_FASTF;
示例3: TwistedCubeTrimmingCurve
int // return value not used?
MakeTwistedCubeTrimmingLoop(ON_Brep& brep,
ON_BrepFace& face,
int v0, int v1, int v2, int v3, // indices of corner vertices
int e0, int eo0, // edge index + orientation w.r.t surface trim
int e1, int eo1,
int e2, int eo2,
int e3, int eo3)
{
// get a reference to the surface
const ON_Surface& srf = *brep.m_S[face.m_si];
ON_BrepLoop& loop = brep.NewLoop(ON_BrepLoop::outer, face);
// create the trimming curves running counter-clockwise around the
// surface's domain, start at the south side
ON_Curve* c2;
int c2i, ei = 0, bRev3d = 0;
ON_2dPoint q;
// flags for isoparametric curves
ON_Surface::ISO iso = ON_Surface::not_iso;
for (int side = 0; side < 4; side++) {
// side: 0=south, 1=east, 2=north, 3=west
c2 = TwistedCubeTrimmingCurve( srf, side );
c2i = brep.m_C2.Count();
brep.m_C2.Append(c2);
switch (side) {
case 0:
ei = e0;
bRev3d = (eo0 == -1);
iso = ON_Surface::S_iso;
break;
case 1:
ei = e1;
bRev3d = (eo1 == -1);
iso = ON_Surface::E_iso;
break;
case 2:
ei = e2;
bRev3d = (eo2 == -1);
iso = ON_Surface::N_iso;
break;
case 3:
ei = e3;
bRev3d = (eo3 == -1);
iso = ON_Surface::W_iso;
break;
}
ON_BrepTrim& trim = brep.NewTrim(brep.m_E[ei], bRev3d, loop, c2i);
trim.m_iso = iso;
// the type gives metadata on the trim type in this case, "mated"
// means the trim is connected to an edge, is part of an
// outer/inner/slit loop, no other trim from the same edge is
// connected to the edge, and at least one trim from a different
// loop is connected to the edge
trim.m_type = ON_BrepTrim::mated; // i.e. this b-rep is closed, so
// all trims have mates
// not convinced these shouldn't be set with a member function
trim.m_tolerance[0] = 0.0; // exact
trim.m_tolerance[1] = 0.0; //
}
return loop.m_loop_index;
}
示例4: MakeTwistedCubeTrimmingLoop
static int MakeTwistedCubeTrimmingLoop( ON_Brep& brep, // returns index of loop
ON_BrepFace& face, // face loop is on
//int vSWi, int vSEi, int vNEi, int vNWi, // Indices of corner vertices listed in SW,SE,NW,NE order
int eSi, // index of edge on south side of surface
int eS_dir, // orientation of edge with respect to surface trim
int eEi, // index of edge on south side of surface
int eE_dir, // orientation of edge with respect to surface trim
int eNi, // index of edge on south side of surface
int eN_dir, // orientation of edge with respect to surface trim
int eWi, // index of edge on south side of surface
int eW_dir // orientation of edge with respect to surface trim
)
{
const ON_Surface& srf = *brep.m_S[face.m_si];
ON_BrepLoop& loop = brep.NewLoop( ON_BrepLoop::outer, face );
// Create trimming curves running counter clockwise around the surface's domain.
// Start at the south side
ON_Curve* c2;
int c2i, ei=0, bRev3d=0;
ON_2dPoint q;
ON_Surface::ISO iso = ON_Surface::not_iso;
for ( int side = 0; side < 4; side++ ) {
// side: 0=south, 1=east, 2=north, 3=west
c2 = TwistedCubeTrimmingCurve( srf, side );
c2i = brep.m_C2.Count();
brep.m_C2.Append(c2);
switch ( side ) {
case 0: // south
ei = eSi;
bRev3d = (eS_dir == -1);
iso = ON_Surface::S_iso;
break;
case 1: // east
ei = eEi;
bRev3d = (eE_dir == -1);
iso = ON_Surface::E_iso;
break;
case 2: // north
ei = eNi;
bRev3d = (eN_dir == -1);
iso = ON_Surface::N_iso;
break;
case 3: // west
ei = eWi;
bRev3d = (eW_dir == -1);
iso = ON_Surface::W_iso;
break;
}
ON_BrepTrim& trim = brep.NewTrim( brep.m_E[ei], bRev3d, loop, c2i );
q = c2->PointAtStart();
//trim.m_P[0] = srf.PointAt( q.x, q.y );
q = c2->PointAtEnd();
//trim.m_P[1] = srf.PointAt( q.x, q.y );
trim.m_iso = iso;
trim.m_type = ON_BrepTrim::mated; // This b-rep is closed, so all trims
// have mates.
trim.m_tolerance[0] = 0.0; // This simple example is exact - for models with
trim.m_tolerance[1] = 0.0; // non-exact data, set tolerance as explained in
// definition of ON_BrepTrim.
}
return loop.m_loop_index;
}
示例5: ON_BrepExtrude
//.........这里部分代码省略.........
ON_Surface* srf = bottomf.DuplicateSurface();
if ( !srf )
{
bOK = false;
break;
}
srf->Transform(tr);
int si = brep.AddSurface(srf);
ON_BrepFace& topf = brep.NewFace(si);
topf.m_bRev = !bottomf.m_bRev;
const int loop_count = bottomf.m_li.Count();
topf.m_li.Reserve(loop_count);
for ( int fli = 0; fli < loop_count; fli++ )
{
const ON_BrepLoop& bottoml = brep.m_L[bottomf.m_li[fli]];
ON_BrepLoop& topl = brep.NewLoop(bottoml.m_type,topf);
const int loop_trim_count = bottoml.m_ti.Count();
topl.m_ti.Reserve(loop_trim_count);
for ( int lti = 0; lti < loop_trim_count; lti++ )
{
const ON_BrepTrim& bottomt = brep.m_T[bottoml.m_ti[lti]];
ON_NurbsCurve* c2 = ON_NurbsCurve::New();
if ( !bottomt.GetNurbForm(*c2) )
{
delete c2;
bOK = false;
break;
}
int c2i = brep.AddTrimCurve(c2);
ON_BrepTrim* topt = 0;
if ( bottomt.m_ei >= 0 )
{
ON_BrepEdge& tope = brep.m_E[topeimap[bottomt.m_ei]];
topt = &brep.NewTrim(tope,bottomt.m_bRev3d,topl,c2i);
}
else
{
// singular trim
ON_BrepVertex& topv = brep.m_V[topvimap[bottomt.m_vi[0]]];
topt = &brep.NewSingularTrim(topv,topl,bottomt.m_iso,c2i);
}
topt->m_tolerance[0] = bottomt.m_tolerance[0];
topt->m_tolerance[1] = bottomt.m_tolerance[1];
topt->m_pbox = bottomt.m_pbox;
topt->m_type = bottomt.m_type;
topt->m_iso = bottomt.m_iso;
}
topl.m_pbox = bottoml.m_pbox;
}
}
}
// build sides
int bRev3d[4] = {0,0,1,1};
int vid[4], eid[4];
if( bOK ) for ( ei = 0; ei < ecount0; ei++ )
{
if ( bSideEdge[ei] && topeimap[ei] )
{
ON_BrepEdge& bottome = brep.m_E[ei];
ON_BrepEdge& tope = brep.m_E[topeimap[ei]];
vid[0] = bottome.m_vi[0];
vid[1] = bottome.m_vi[1];
vid[2] = topvimap[vid[1]];
vid[3] = topvimap[vid[0]];
if ( sideveimap[vid[0]] && sideveimap[vid[1]] )
示例6: ON_BrepExtrudeHelper_MakeTopLoop
//.........这里部分代码省略.........
// duplicate bottom edge curve
const ON_BrepEdge& bottom_edge = brep.m_E[bottom_trim.m_ei];
ON_Curve* top_c3 = bottom_edge.DuplicateCurve();
if ( 0 == top_c3 )
continue;
// move new edge curve to top location
top_c3->Translate(path_vector);
ON_3dPoint P0 = top_c3->PointAtStart();
ON_3dPoint P1 = top_c3->PointAtEnd();
int top_c3i = brep.AddEdgeCurve(top_c3);
top_c3 = 0;
// get vertices at start/end of the new edge
int e_vi0 = top_vertex_index[lti];
int e_vi1 = top_vertex_index[(lti+1)%loop_trim_count];
if ( bottom_trim.m_bRev3d )
{
// put points in trim order
ON_3dPoint tmp_P = P0; P0 = P1; P1 = tmp_P;
}
if ( e_vi0 < 0 )
{
e_vi0 = brep.NewVertex(P0).m_vertex_index;
top_vertex_index[lti] = e_vi0;
}
if ( e_vi1 < 0 )
{
e_vi1 = brep.NewVertex(P1).m_vertex_index;
top_vertex_index[(lti+1)%loop_trim_count] = e_vi1;
}
if ( bottom_trim.m_bRev3d )
{
// put edge vertex indices in edge order
int tmp_i = e_vi0; e_vi0 = e_vi1; e_vi1 = tmp_i;
}
ON_BrepEdge& top_edge = brep.NewEdge(brep.m_V[e_vi0],brep.m_V[e_vi1],top_c3i);
top_edge.m_tolerance = bottom_edge.m_tolerance;
top_edge_index[lti] = top_edge.m_edge_index;
top_trim_bRev3d[lti] = bottom_trim.m_bRev3d?true:false;
// find seam mate and set it's
// top_edge_index[] to top_edge.m_edge_index.
int mate_lti;
for( mate_lti = lti+1; mate_lti < loop_trim_count; mate_lti++ )
{
if ( top_edge_index[mate_lti] != -1 )
continue;
int bottom_mate_ti = bottom_loop.m_ti[mate_lti];
if ( bottom_mate_ti < 0 || bottom_mate_ti >= brep.m_T.Count() )
continue;
const ON_BrepTrim& bottom_mate_trim = brep.m_T[bottom_mate_ti];
if ( bottom_mate_trim.m_type != ON_BrepTrim::seam )
continue;
if ( bottom_mate_trim.m_ei != bottom_trim.m_ei )
continue;
top_edge_index[mate_lti] = top_edge.m_edge_index;
top_trim_bRev3d[mate_lti] = bottom_mate_trim.m_bRev3d?true:false;
break;
}
}
for ( lti = 0; lti < loop_trim_count; lti++ )
{
const ON_BrepTrim& bottom_trim = brep.m_T[ bottom_loop.m_ti[lti] ];
ON_Curve* top_c2 = bottom_trim.DuplicateCurve();
int top_c2i = (0!=top_c2) ? brep.AddTrimCurve(top_c2) : bottom_trim.m_c2i;
top_trim_index = -1;
if ( bottom_trim.m_type == ON_BrepTrim::singular && top_vertex_index[lti] >= 0 )
{
top_trim_index = brep.NewSingularTrim(brep.m_V[top_vertex_index[lti]], top_loop, bottom_trim.m_iso, top_c2i ).m_trim_index;
}
else if ( bottom_trim.m_type != ON_BrepTrim::singular && top_edge_index[lti] >= 0 && top_edge_index[lti] < brep.m_E.Count() )
{
ON_BrepEdge& top_edge = brep.m_E[top_edge_index[lti]];
top_trim_index = brep.NewTrim( top_edge, top_trim_bRev3d[lti], top_loop, top_c2i ).m_trim_index;
}
else
{
ON_ERROR("ON_BrepExtrudeHelper_MakeTopLoop ran into capping trouble.");
rc = false;
break;
}
ON_BrepTrim& top_trim = brep.m_T[top_trim_index];
top_trim.m_pline = bottom_trim.m_pline;
top_trim.m_pbox = bottom_trim.m_pbox;
top_trim.m_iso = bottom_trim.m_iso;
top_trim.m_type = bottom_trim.m_type;
top_trim.m_tolerance[0] = bottom_trim.m_tolerance[0];
top_trim.m_tolerance[1] = bottom_trim.m_tolerance[1];
top_trim.m__legacy_2d_tol = bottom_trim.m__legacy_2d_tol;
top_trim.m__legacy_3d_tol = bottom_trim.m__legacy_2d_tol;
top_trim.m__legacy_flags = bottom_trim.m__legacy_flags;
}
if (rc)
{
top_loop.m_pbox = bottom_loop.m_pbox;
}
return rc;
}