[英]Computing offset curve with Teigha 4.1.1
I am struggling with computing a parallel line to the existing line in certain distance. 我正在努力计算在一定距离内与现有线的平行线。
I have tried: 我努力了:
OdGeLine2d::getTrimmedOffset()
OdGeLineSeg2d::getTrimmedOffset()
OdGeLine3d::getTrimmedOffset()
OdGeLineSeg3d::getTrimmedOffset()
but all of them trow a "Not implemented" exception. 但它们都引发了“未实现”异常。
Than I tried to use a OdGeOffsetCurve2d
class. 比我尝试使用
OdGeOffsetCurve2d
类。 Constructing of this class doesn't throw exception, but any attempt to get a point of this curve does. 此类的构造不会引发异常,但是任何尝试获得此曲线点的尝试都会引发异常。 Same exception: "Not implemented".
同样的例外:“未实现”。
So, how can a get a point that lies on the OdGeOffsetCurve2d
? 那么, 如何得到
OdGeOffsetCurve2d
上的一个点呢? Or is there any other way to compute an offset curve? 还是有其他方法可以计算偏移曲线?
And what are all those getTrimmedOffset()
methods for? 那些
getTrimmedOffset()
方法有什么用? Just to throw exceptions? 只是抛出异常?
PS: I do not have enough reputation to create a new Teigha tag. PS:我没有足够的声誉来创建新的Teigha标签。 Please, do so and edit my question.
请这样做并编辑我的问题。 Teigha is a core library for developing CAD applications https://www.opendesign.com/ .
Teigha是用于开发CAD应用程序的核心库https://www.opendesign.com/ 。
If i understand correctly you are trying to create a parallel line to an already existing line. 如果我正确理解,您正在尝试创建与现有线平行的线。
If you not specifically looking for OdGeLine2d , i have a solution for similar problem with OdDbLine. 如果您不是专门寻找OdGeLine2d,那么我对于OdDbLine的类似问题也有解决方案。 As you already know , to construct a new line if we have its end points rest is play.
如您所知,如果我们有终点,那么构造一条新线就是比赛。
So I will help you find end Points of Parallel Line with OdDbLine Class. 因此,我将帮助您找到具有OdDbLine类的平行线的终点。 You can try to derive from it.
您可以尝试从中得出。 My code is the .Net version code and not the c++ one.
我的代码是.Net版本代码,而不是c ++版本代码。
If you have and object of OdDbLine
Class lets say OdDbLine line
如果您有
OdDbLine
类的对象,可以说OdDbLine line
a) Get its End Points a)获取终点
OdGePoint3d startPoint = new OdGePoint3d(); line.getStartPoint(startPoint);
OdGePoint3d endPoint = new OdGePoint3d(); line.getEndPoint(endPoint);
OdGeVector3d lineVector = GetLineVector(line); OdGeVector3d perpendicularVec = lineVector.perpVector(); perpendicularVec.normalize(); perpendicularVec = perpendicularVec.Mul(-1);
perpendicularVec.setToProduct(perpendicularVec, offSetValue);
perpendicularVec.setToProduct(perpendicularVec, offSetValue);
OdGePoint3d newOffsetStartPt = startPoint.Add(perpendicularVec); OdGePoint3d newOffsetEndPt = endPoint.Add(perpendicularVec);
Hope it helps !! 希望能帮助到你 !!
There is a shorter way to make an offset curve for a linear entity. 有一种较短的方法可以为线性实体绘制偏移曲线。 You can make a copy of your line and move it (transform it) to a nessesary distance.
您可以复制一行并将其移动(转换)到必要的距离。 Like this:
像这样:
OdGeLine2d ln(OdGePoint2d::kOrigin, OdGeVector2d::kXAxis);
const double dOffsetDistance = 100.0;
OdGeVector2d vOffset = ln.direction().perpVector(); //ccw rotation
vOffset.normalize();
vOffset *= dOffsetDistance;
ln.transformBy( OdGeMatrix2d::translation(vOffset) );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.