Acad::ErrorStatus 
rx_makeArc(const AcGePoint3d    pt1, 
           const AcGePoint3d    pt2, 
                 double         bulge,
           const AcGeVector3d   entNorm,
                 AcGeCircArc3d& arc)
{
    Acad::ErrorStatus es = Acad::eOk;

    // The points that are coming in are in ECS. These are actually
    // 2d points, may be with an elevation in the z coord.
    //
    // Therefore, let's create a 2d arc from these values and transform
    // the relevant data of the arc for creating a 3d arc.

    AcGeCircArc2d arc2d;
    AcGePoint2d p1, p2;

    assert(fabs(pt1[Z] - pt2[Z]) < 1.0e-10);

    p1.set(pt1[X], pt1[Y]); p2.set(pt2[X], pt2[Y]);
    arc2d.set(p1, p2, bulge);

    AcGePoint3d center((arc2d.center())[X], (arc2d.center())[Y], pt1[Z]);
    AcGePoint3d startPnt((arc2d.startPoint())[X], 
                         (arc2d.startPoint())[Y], pt1[Z]);
    AcGePoint3d endPnt((arc2d.endPoint())[X], (arc2d.endPoint())[Y], pt1[Z]);

    // If the arc is CW, flip the normal.

    AcGeVector3d norm;

    if (arc2d.startAng() > arc2d.endAng()) {
	norm.set(0, 0, -1);
    } else {
	norm.set(0, 0, 1);
    }

    double incAng = fabs(arc2d.endAng() - arc2d.startAng());

    // Transform all the data to WCS.

    acdbEcs2Wcs(asDblArray(center), asDblArray(center), asDblArray(entNorm), 
							    Adesk::kFalse);
    acdbEcs2Wcs(asDblArray(startPnt), asDblArray(startPnt), asDblArray(entNorm), 
							    Adesk::kFalse);
    acdbEcs2Wcs(asDblArray(endPnt), asDblArray(endPnt), asDblArray(entNorm), 
							    Adesk::kFalse);
    acdbEcs2Wcs(asDblArray(norm), asDblArray(norm), asDblArray(entNorm), 
							    Adesk::kTrue);

    arc.set(center, norm, norm.perpVector(),
	(startPnt - center).length(), 0, incAng);

    return es;
}
Exemplo n.º 2
0
static int extractEntityInfo(struct resbuf *rb,
                             int&          sel_method,
                             ads_name      ename,
                             ads_name      subname,
                             short&	   marker,
                             AcGePoint3d&  pickpnt,
                             AcGeVector3d& pickvec)
{
   if ( rb == NULL || rb->restype != RTLB )
   {
     assert(0);
     return 0;
   }
   
   // Get the selection method.
   //
   rb = rb->rbnext;  // Bump up to the selection method, always after RTLB.
   sel_method = rb->resval.rint;

   // Get the first ename (could be either the actual entity name or
   // subentity name).
   //
   rb = rb->rbnext;  // Bump up to the first name, always after sel method.
   ename[0] = rb->resval.rlname[0];
   ename[1] = rb->resval.rlname[1];
   subname[0] = rb->resval.rlname[0];
   subname[1] = rb->resval.rlname[1];

   // Get marker info.
   //
   rb = rb->rbnext;
   marker = rb->resval.rint;

   // Get the pick location and vector, only for PICK and FENCE.  For FENCE,
   // we take the first intersection with the entity as the pick location.
   //
   if ( sel_method == PICK_METH || 
        sel_method == FENCE_METH)
   {
      rb = rb->rbnext;  // Skip to RTLB for pick location.
      rb = rb->rbnext;  // Skip to point description info.
      rb = rb->rbnext;  // Skip to the pick location.
      pickpnt.set( rb->resval.rpoint[0],
                   rb->resval.rpoint[1],
                   rb->resval.rpoint[2] );

      rb = rb->rbnext;  // Will be normal vector if we're not in XY view.
                        // Otherwise, it'll be an RTLE for pick location.

      if ( rb->restype == RT3DPOINT )
      {
        pickvec.set( rb->resval.rpoint[0],
                     rb->resval.rpoint[1],
                     rb->resval.rpoint[2] );
        rb = rb->rbnext;  // Make it point to the RTLE for the pick location.
      }
   }

   return CONTINUE;
}
Exemplo n.º 3
0
void Additional_Class::RotateEnt( AcDbObjectId EntID, double RotateAng, AcGePoint3d InpPt)
{
	AcDbEntity *pEnt_Temp;
	if (acdbOpenAcDbEntity(pEnt_Temp, EntID, AcDb::kForWrite) != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN ERROR"));
		return;
	}
	 AcGeMatrix3d tt;
	 AcGeVector3d zAxis;
	 zAxis.set(0,0,1);
	tt.setToRotation(RotateAng, zAxis, InpPt);
	pEnt_Temp->transformBy(tt);
	pEnt_Temp->close();
}
Adesk::Boolean
AecUiPrSubentity::retrievePickDataAt(long index)
{
    AecRmCString hardErrMsg(GetAecUiBaseAppName(), AECU_STR_RETRIEVEPICKDATAAT_AECUIPRSUBENTITY_ERROR_COULD_NOT, TRUE);  //~  "\nERROR: could not retreive pick data!"

    resbuf* rb;
    ads_name selSet;

    m_ss.asAdsName(selSet);

    if (ads_ssnamex(&rb, selSet, index) != RTNORM)
        return Adesk::kFalse;

        // find out the objectId of the item picked
    AcDbObjectId mainId;
    ads_name ent;
    ads_ssname(selSet, index, ent);
    if (Aec::enameToObjId(ent, mainId) != Acad::eOk) {
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

    resbuf* tmp = rb;
    if ((tmp == NULL) || (tmp->restype != RTLB)) { // should start with this
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

        // second element is selection method, which should always be pickPt=1
    tmp = tmp->rbnext;
    if ((tmp == NULL) || (tmp->restype != RTSHORT) || (tmp->resval.rint != 1)) {
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

        // third element is entity name of object selected
    tmp = tmp->rbnext;
    if ((tmp == NULL) || (tmp->restype != RTENAME)) {
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

        // fourth element is the gsMarker
    tmp = tmp->rbnext;
    if ((tmp == NULL) || (tmp->restype != RTSHORT)) {
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }
    int gsMarker = tmp->resval.rint;

        // fifth element is start of list for pickPt
    tmp = tmp->rbnext;
    if ((tmp == NULL) || (tmp->restype != RTLB)) {
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

        // sixth element is point descriptor
    tmp = tmp->rbnext;
    if ((tmp == NULL) || (tmp->restype != RTSHORT)) {
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

        // seventh element is pick point
    tmp = tmp->rbnext;
    if ((tmp == NULL) || (tmp->restype != RT3DPOINT)) {
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

    AcGePoint3d pickPt(tmp->resval.rpoint[0], tmp->resval.rpoint[1], tmp->resval.rpoint[2]);

        // eigth element is either end of list or the direction vector
    tmp = tmp->rbnext;
    if (tmp == NULL) {
        AEC_ASSERT(0);
        ads_relrb(rb);
        ads_printf(hardErrMsg);
        return Adesk::kFalse;
    }

    AcGeVector3d pickVector;
    if (tmp->restype == RT3DPOINT)
        pickVector.set(tmp->resval.rpoint[0], tmp->resval.rpoint[1], tmp->resval.rpoint[2]);
    else
        pickVector.set(0.0, 0.0, 1.0);    // WCS Z-axis

    ads_relrb(rb);

        // if this is the first time its picked, set mainId to this objectId.
        // All subsequent picks must match this id
    if (m_mainEnt == AcDbObjectId::kNull) {
        m_mainEnt = mainId;

            // add this to the "set" of objects selected (which in our case is 1 item)
        m_selSet.setLogicalLength(0);   // reset array
        m_selSet.append(mainId);
    }
    else {
            // must be from same entity!
        if (m_mainEnt != mainId) {
            AecRmCString msg;
            msg.LoadString(GetAecUiBaseAppName(), AECU_STR_SUBENT_MUST_BE_FROM_MAINENT);
            ads_printf(msg);
            return Adesk::kFalse;
        }
    }

        // unhighlight any existing edges
    doUnHighlight(m_mainEnt);

        // if the same edge is picked twice, remove it out of the set
    int atIndex;
    if (m_gsMarkers.find(gsMarker, atIndex)) {
        m_gsMarkers.removeAt(atIndex);
        m_pickPts.removeAt(atIndex);
        m_pickVecs.removeAt(atIndex);

        DEBUG_ONLY(ads_printf(_DNT(_T("\nAecUiPrSubentity:: removed gsmarker: %d")), gsMarker));
    }
    else {
        m_isValidssnamexData = Adesk::kTrue;    // this isn't really accurate Nth time thru loop
        m_gsMarkers.append(gsMarker);
        m_pickPts.append(pickPt);
        m_pickVecs.append(pickVector);

        DEBUG_ONLY(ads_printf(_DNT(_T("\nAecUiPrSubentity:: added gsmarker: %d")), gsMarker));
    }

        // re-highlight with new data
    doHighlight(m_mainEnt);

    return Adesk::kTrue;
}