Acad::ErrorStatus AsdkSmiley::osnapQuad( const AcGePoint3d& pickPoint, AcGePoint3dArray& snapPoints) const { AcGeVector3d xoff(0,0,0); AcGeVector3d yoff(0,0,0); // Osnap quad to the face's quad points // xoff.x = yoff.y = radius(); AcGePoint3d center( center() ); snapPoints.append( center + xoff ); snapPoints.append( center + yoff ); snapPoints.append( center - xoff ); snapPoints.append( center - yoff ); // Osnap quad to the eyes' quad points // AcGePoint3dArray eyearray; AcGePoint3d eyecen; eyes( eyearray ); for( int i = 0; i < eyearray.length(); i++ ){ eyecen = eyearray.at( i ); xoff.x = meyesize; yoff.y = meyesize; snapPoints.append( eyecen + xoff ); snapPoints.append( eyecen + yoff ); snapPoints.append( eyecen - xoff ); snapPoints.append( eyecen - yoff ); } return Acad::eOk; }
void RayGenerator::Generate(int level,int pw,int ph,int x,int y, Vec3q *out) const { { DASSERT(level == 3); GridSampler sampler; Vec3q right(tright), up(tup), tadd = txyz; floatq xoff(x + 0, x + 0, x + 2, x + 2); floatq yoff(y + 0, y + 0, y - 1, y - 1); for(int ty = 0; ty < 16; ty++) { floatq tposx[4] = { floatq(0.0f) + xoff, floatq(4.0f) + xoff, floatq(8.0f) + xoff, floatq(12.0f) + xoff }; floatq tposy = floatq(ty) + yoff; Vec3q tpoint = up * tposy + tadd; Vec3q points[4] = { right * tposx[0] + tpoint, right * tposx[1] + tpoint, right * tposx[2] + tpoint, right * tposx[3] + tpoint }; out[ty * 4 + 0] = points[0] * RSqrt(points[0] | points[0]); out[ty * 4 + 1] = points[1] * RSqrt(points[1] | points[1]); out[ty * 4 + 2] = points[2] * RSqrt(points[2] | points[2]); out[ty * 4 + 3] = points[3] * RSqrt(points[3] | points[3]); } return; } if(level > 2) { int npw = pw >> 1, nph = ph >> 1, nl = level - 1; Generate(nl, npw, nph, x , y , out + 0); Generate(nl, npw, nph, x + npw, y , out + (1 << nl*2)); Generate(nl, npw, nph, x , y + nph, out + (2 << nl*2)); Generate(nl, npw, nph, x + npw, y + nph, out + (3 << nl*2)); return; }
Acad::ErrorStatus AsdkSmiley::getGripPoints( AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds) const { assertReadEnabled(); // Grip points to face // AcGePoint3d center( center() ); gripPoints.append( center ); AcGeVector3d xoff( radius(), 0, 0 ), yoff( 0, radius(), 0 ); gripPoints.append( center + xoff ); gripPoints.append( center + yoff ); gripPoints.append( center - xoff ); gripPoints.append( center - yoff ); // Grip points to mouth // AcGeLineSeg3d chord( mouthLeft(), mouthRight() ); gripPoints.append( mouthLeft() ); gripPoints.append( mouthRight() ); gripPoints.append( chord.midPoint() ); gripPoints.append( mouthBottom() ); // Grip points to eyes // AcGePoint3dArray eyearray; AcGePoint3d eyecen; eyes( eyearray ); for( int i = 0; i < eyearray.length(); i++ ){ eyecen = eyearray.at( i ); gripPoints.append( eyecen ); AcGeVector3d xoff( meyesize, 0, 0 ), yoff( 0, meyesize, 0 ); gripPoints.append( eyecen + xoff ); gripPoints.append( eyecen + yoff ); gripPoints.append( eyecen - xoff ); gripPoints.append( eyecen - yoff ); } return Acad::eOk; }
/************************************* * Create a reference to another dt. */ void DtBuilder::dtoff(dt_t *dt, unsigned offset) { type *t = type_alloc(TYint); t->Tcount++; Symbol *s = symbol_calloc("internal"); s->Sclass = SCstatic; s->Sfl = FLextern; s->Sflags |= SFLnodebug; s->Stype = t; s->Sdt = dt; outdata(s); xoff(s, offset); }
Acad::ErrorStatus AsdkSmiley::osnapNear( const AcGePoint3d& pickPoint, AcGePoint3dArray& snapPoints) const { // For osnap near, define the same points as the grip points. // This definitely not the proper implementation, but it is // adequate for this simple sample. // AcGeVector3d xoff( radius(), 0, 0 ); AcGeVector3d yoff( 0, radius(), 0 ); AcGePoint3d center( center() ); snapPoints.append( center + xoff ); snapPoints.append( center + yoff ); snapPoints.append( center - xoff ); snapPoints.append( center - yoff ); return Acad::eOk; }
/****************************** * Create reference to s+offset */ void DtBuilder::xoff(Symbol *s, unsigned offset) { xoff(s, offset, TYnptr); }