TA的每日心情 | 开心 2021-3-7 10:01 |
---|
签到天数: 1440 天 连续签到: 19 天 [LV.10]以坛为家III
|

楼主 |
发表于 2021-2-8 01:58
|
显示全部楼层
mjsduct::intersectWith(const AcDbEntity* pEnt,
> AcDb::Intersect intType,
> AcGePoint3dArray& points,
> int thisGsMarker = 0,
> int otherGsMarker = 0) const
> {
> Acad::ErrorStatus es;
> AcDbVoidPtrArray ents;
> try
> {
> es = explode(ents); // just in case explode() failed but
> if( es != Acad::eOk ) // left entities in the array.
> throw es;
> for(int i = 0; i < ents.length(); i++)
> {
> AcDbEntity* pE = static_cast (ents);
> ASSERT(pE);
> es = pE->intersectWith(pEnt, intType, points,
> thisGsMarker, otherGsMarker);
> if( es != Acad::eOk && es != Acad::eNotImplemented )
> throw es; // anything else is regarded as an error
> }
> throw Acad::eOk;
> }
> catch(const Acad::ErrorStatus e)
> {
> for(int i = 0; i < ents.length(); i++)
> delete static_cast (ents);
> return e;
> }
> return Acad::eOk;
> }
>
>
>
> "Martin Schmid" wrote in message
> news:E3CD0B97ADBC18B2ECA34A0F78B1E22F@in.WebX.maYIadrTaRb...
> > Here is my explode function... I convert the Entity into a
> > AcDb3dPolyline(AcDb::k3dSimplePoly) (see below)
> >
> > Can you provide a simple example on how I would create the
insersectWith?
> I
> > am only concerned about my class (mjsduct) being able to insersect with
> > itself for now.
> >
> > In the documentation, it says:
> > "If the intersectWith() function of your custom entity is called with
> > another entity that is not a native entity, you need to explode your
> custom
> > entity (for example, by using the explode() function) to a set of
> > recognizable native entities, then turn around and call intersectWith()
on
> > the entity that came in as an argument to your intersectWith() function.
> > Because everyone is expected to be able to intersect with native
entities,
> > the entity in the argument would be able to intersect with your exploded
> > version."
> >
> > In my intersectWith(), how do I call explode() to get back
> > AcDb3dPolyline(AcDb::k3dSimplePoly), and how do I then "turn around and
> call
> > intersectWith()....."?
> >
> > Thanks,
> > MS
> >
> >
> > Acad::ErrorStatus mjsduct::explode(AcDbVoidPtrArray& entitySet) const
> > {
> > assertReadEnabled();
> >
> > AcGePoint3dArray PtArray;
> > AcGePoint3d sp;
> > AcGePoint3d ep;
> > AcGePoint3d p1, p2, p3, p4;
> > AcGeVector3d vec, axis;
> > double wd;
> > AcGePoint3d PlinePts[5];
> >
> > sp=getDuctStartPoint();
> > ep=getDuctEndPoint();
> > wd=getDuctWidth();
> >
> > vec.set(ep[0]-sp[0],ep[1]-sp[1],ep[2]-sp[2]);
> > axis=vec.perpVector();
> > axis.set(0.0,0.0,1.0);
> >
> > vec=vec.rotateBy(-pi/2.0,axis);
> > vec=vec.normalize();
> > p1=sp+vec*wd/2;
> > p2=ep+vec*wd/2;
> >
> > vec.rotateBy(pi,axis);
> > p3=ep+vec*wd/2;
> > p4=sp+vec*wd/2;
> >
> > PtArray.append(p1);
> > PtArray.append(p2);
> > PtArray.append(p3);
> > PtArray.append(p4);
> >
> > AcDb3dPolyline *pPoly=new
> > AcDb3dPolyline(AcDb::k3dSimplePoly,PtArray,Adesk::kTrue);
> > entitySet.append(pPoly);
> > return Acad::eOk;
> > } |
|