Пример #1
0
void Additional_Class::Get_PolyLine_Point( AcDbObjectId PolyLineId,AcGePoint3dArray &PointArray )
{
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY IS NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	AcGePoint3d Start_temp_PT,End_temp_PT;
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			AcGeLineSeg3d tempLine;
			pPolyLine->getLineSegAt(index,tempLine);
			Start_temp_PT = tempLine.startPoint();
			End_temp_PT = tempLine.endPoint();
			PointArray.append(Start_temp_PT);
			PointArray.append(End_temp_PT);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			Start_temp_PT.set(tempArc.startPoint().x,tempArc.startPoint().y,0);
			End_temp_PT.set(tempArc.endPoint().x,tempArc.endPoint().y,0);
			PointArray.append(Start_temp_PT);
			PointArray.append(End_temp_PT);
		}
	}
	pEnt_Temp->close();
	AcGeIntArray IndexArray;
	for (int i=1; i<PointArray.length();i++)
	{
		if (PointArray[i] == PointArray[i-1])
		{
			IndexArray.append(i);
			PointArray.remove(PointArray[i]);
		}
	}
}
Пример #2
0
void Additional_Class::Get_PolyLineType( AcDbObjectId PolyLineId,LINEINFO &LineInfo_List )
{
	double PI=3.1415926535897932384626433832795;
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	LineInfo_List.push_back("");
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			CString tempStr_Line;
			tempStr_Line = "直线段";
			LineInfo_List.push_back(tempStr_Line);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			double StartAngle = tempArc.startAng();
			double EndAngle = tempArc.endAng();
			double Angle = abs(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;
			tempStr_Radius = tempStr_Angle+" "+tempStr_Radius;
			LineInfo_List.push_back(tempStr_Radius);
		}
	}
}
Пример #3
0
void Additional_Class::Get_PolyLine_Length( AcDbObjectId PolyLineId, AcGeDoubleArray &LengthArray )
{
	double PI=3.1415926535897932384626433832795;
	AcDbEntity *pEnt_Temp = NULL;
	Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt_Temp, PolyLineId, AcDb::kForRead);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nOPEN POLYLINE ERROR"));
		return;
	}
	if (!pEnt_Temp->isKindOf(AcDbPolyline::desc()))
	{
		acutPrintf(_T("\nENTITY NOT POLYLINE"));
		return;
	}
	AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt_Temp);
	int num = pPolyLine->numVerts();
	for (int index=0; index<num; index++)
	{
		if (pPolyLine->segType(index) == AcDbPolyline::kLine)
		{
			AcGeLineSeg3d tempLine;
			pPolyLine->getLineSegAt(index,tempLine);
			double LineLength = tempLine.length();
			LengthArray.append(LineLength);
		}
		else if (pPolyLine->segType(index) == AcDbPolyline::kArc)
		{
			AcGeCircArc2d tempArc;
			pPolyLine->getArcSegAt(index,tempArc);
			double StartAngle = tempArc.startAng();
			double EndAngle = tempArc.endAng();
			double Angle = EndAngle-StartAngle;
			//Angle = (180/PI)*Angle;
			double Radius = tempArc.radius();
			double ArcLength = Radius*Angle;
			LengthArray.append(ArcLength);
		}
	}
	LengthArray.insertAt(0,0);
}
Пример #4
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;
}
Пример #5
0
	virtual Acad::ErrorStatus   getOsnapInfo(
		AcDbEntity*			pickedObject,
		Adesk::GsMarker		gsSelectionMark,
		const AcGePoint3d&		pickPoint,
		const AcGePoint3d&		lastPoint,
		const AcGeMatrix3d&	viewXform,
		AcArray<AcGePoint3d>&	snapPoints,
		AcArray<int>&			geomIdsForPts,
		AcArray<AcGeCurve3d*>& snapCurves,
		AcArray<int>&			geomIdsForLines)
	{
		// Specialised implementation for AcDbPolylines:
		//  Parametrisation of AcDbPolylines is different: each whole numbered paramater appears
		//  at a vertex, so we cannot simply divide by three to get the correct parameter.

		// Protocol Extension insures that the following assertion is always
		// true, but check in non-prod versions just to be safe.
		assert( pickedObject->isKindOf( AcDbPolyline::desc() ));

		// but in production, a hard cast is fastest
		AcDbPolyline *pPline = (AcDbPolyline*)pickedObject;

		Acad::ErrorStatus es;

		if ( bSnapToSegments )
		{
			// Snap to a third of each of the segments
			unsigned int numSegs = pPline->numVerts() - 1;
			AcGeLineSeg3d segLn;
			AcGeCircArc3d segArc;
			double startParam, endParam, newParam, dist;
			AcGePoint3d pt;

			for ( unsigned int idx = 0; idx < numSegs; idx++ )
			{
				switch( pPline->segType( idx ))
				{
				case AcDbPolyline::kLine:
					es=pPline->getLineSegAt( idx, segLn );
					startParam = segLn.paramOf( segLn.startPoint() );
					endParam = segLn.paramOf( segLn.endPoint() );
					snapPoints.append(segLn.evalPoint( startParam + ((endParam - startParam) / 3 )));
					snapPoints.append(segLn.evalPoint( startParam + ((endParam - startParam) * 2 / 3 )));
					break;
				case AcDbPolyline::kArc:
					es=pPline->getArcSegAt( idx, segArc );
					startParam = segArc.paramOf( segArc.startPoint() );
					endParam = segArc.paramOf( segArc.endPoint() );
					dist = segArc.length( startParam, endParam );
					newParam = segArc.paramAtLength( startParam, dist / 3 );
					snapPoints.append( segArc.evalPoint( newParam ));
					newParam = segArc.paramAtLength( startParam, dist * 2 / 3 );
					snapPoints.append( segArc.evalPoint( newParam ));
					break;
				default:
					break;
				}
			}
		}
		else {
			double endParam;
			AcGePoint3d pt;
			double dist;

			es=pPline->getEndParam( endParam );
			es=pPline->getDistAtParam( endParam, dist );
			es=pPline->getPointAtDist( dist / 3, pt );
			assert(Acad::eOk==es);
			snapPoints.append( pt );
			es=pPline->getPointAtDist( dist * 2 / 3, pt );
			assert(Acad::eOk==es);
			snapPoints.append( pt );
			if ( pPline->isClosed() )
			{
				es=pPline->getStartPoint( pt );
				snapPoints.append( pt );
			}
		}
		return Acad::eOk;
	}