Exemplo n.º 1
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.º 2
0
void Additional_Class::Get_ArcMiddle( AcDbObjectId PolyLineId, AcGePoint3dArray &Middle_List,AcGePoint3dArray &CenterListInput, LINEINFO &ArcInfoRList, LINEINFO &ArcInfoAList )
{
	double PI=3.1415926535897932384626433832795;
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN ENTITY ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	AcGePoint3d Start_temp_PT,End_temp_PT;
	AcGePoint3dArray Center_List;
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			AcGePoint2d CenterPoint;
			CenterPoint = tempArc.center();
			AcGePoint3d CenterPoint3d;
			CenterPoint3d.set(CenterPoint.x, CenterPoint.y, 0);
			Center_List.append(CenterPoint3d);
			AcGePoint3d Start_temp_PT, End_temp_PT;
			Start_temp_PT.set(tempArc.startPoint().x,tempArc.startPoint().y,0);
			End_temp_PT.set(tempArc.endPoint().x,tempArc.endPoint().y,0);
			AcGeVector3d tempVec;
			tempVec = End_temp_PT - Start_temp_PT;
			double tempVec_Len = tempVec.length();
			tempVec.normalize();
			tempVec = tempVec*(tempVec_Len/2);
			AcGeVector3d CenterVec;
			CenterVec = Start_temp_PT - CenterPoint3d;
			CenterVec = CenterVec + tempVec;
			AcGeLine2d CenterLine2d;
			AcGePoint3d Middle_Pt_OnLine;
			Middle_Pt_OnLine = CenterPoint3d+CenterVec;
			AcGePoint2d middle2d;
			middle2d.set(Middle_Pt_OnLine.x, Middle_Pt_OnLine.y);
			CenterLine2d.set(CenterPoint, middle2d);

			int s;
			AcGePoint2d MiddlePT, pt2;
			tempArc.intersectWith(CenterLine2d, s,  MiddlePT, pt2);
			AcGePoint3d MiddlePoint;
			MiddlePoint.set(MiddlePT.x,MiddlePT.y,0);
			Middle_List.append(MiddlePoint);

			double StartAngle = tempArc.startAng();
			double EndAngle = tempArc.endAng();
			double Angle = EndAngle-StartAngle;
			Angle = (180/PI)*Angle;
			double Radius = tempArc.radius();
			CString tempStr_Angle,tempStr_Radius,sita,du,banjing;
			sita = "θ=";
			du = "°";
			banjing = "R=";
			tempStr_Angle.Format(_T("%.1f"),Angle);
			tempStr_Angle = sita+tempStr_Angle+du;
			tempStr_Radius.Format(_T("%.1f"),Radius);
			tempStr_Radius = banjing + tempStr_Radius;
			ArcInfoRList.push_back(tempStr_Radius);
			ArcInfoAList.push_back(tempStr_Angle);
		}
	}
	CenterListInput = Center_List;
}