if (mDragDataFlags & kCloneMeForDraggingCalled) {

mDragDataFlags &= kUseDragCache;

// We need to make sure that all the poly’s drag data members

// are in sync with the true data members.

//

//mDragCenter = mCenter;

//mDragStartPoint = mStartPoint;

} else

// Only if we’re not dragging do we want to make an undo

// recording and check if the object’s open for write.

//

assertWriteEnabled();

//if there’s more than one hot vertex or there's one and it is

//the center then simply transform.

if (indices. length()>1 || indices[0] == mNumSides)

return transformBy(AcGeMatrix3d::translation(offset));

AcGeVector3d off(offset);

// Calculate the offset vector of the startpoint

// from the offset vector on a vertex.

double rotateBy = 2.0 * 3.14159265358979323846 /

mNumSides * indices[0];

AcGePoint3d cent;

getCenter(cent);

off. transformBy(AcGeMatrix3d::rotation(rotateBy,

normal(),cent));

acdbWcs2Ecs(asDblArray(off),asDblArray(off),

asDblArray(normal()),Adesk::kTrue);

if (mDragDataFlags & kUseDragCache){

mDragStartPoint = mStartPoint + AcGeVector2d(off. x,off. y);

mDragElevation = mElevation + off. z;

} else{

mStartPoint = mStartPoint + AcGeVector2d(off. x,off. y);

mElevation = mElevation + off. z;

}

return Acad::eOk;

}

Реализация Функции точки растяжения

Набор точек растяжения для объекта - часто подмножество его пунктов{*точек*} власти{*захвата*}. Когда пользователь вызывает команду STRETCH, getStretchPoints () функция используется, чтобы возвратить пункты{*точки*} протяжения, определенные для выбранного объекта. Для многих объектов, режим власти{*захвата*} и режим протяжения идентичен. Выполнение для AcDbEntity:: getStretchPoints () функция и AcDbEntity:: moveStretchPointsAt () функция должно вызвать ваш getGripPoints () и moveGripPointsAt () функции.

НЕ нашли? Не то? Что вы ищете?

Сигнатуры для функций протяжения

virtual Acad::ErrorStatus

AcDbEntity::getStretchPoints( AcGePoint3dArray& stretchPoints) const;

virtual Acad::ErrorStatus

AcDbEntity::moveStretchPointsAt(

const AcDbIntArray& indices,

const AcGeVector3d& offset);

Вы не требуетесь, чтобы перегрузить getStretchPoints () и moveStretchPointsAt () функции AcDbEntity, потому что они значение по умолчанию к getGripPoints () и transformBy () функции.

Заказной AsdkPoly класс перегружает эти функции как показано в примере в этом разделе. GetStretchPoints () функция возвращает вершину многоугольника, но не центр. MoveStretchPointsAt () функциональные проверки, были ли все пункты{*точки*} протяжения выбраны. Если они имеют, это вызывает transformBy () функция. Иначе, это вызывает moveGripPointsAt () функция.

Acad::ErrorStatus

AsdkPoly::getStretchPoints(

AcGePoint3dArray& stretchPoints) const

{

assertReadEnabled();

Acad::ErrorStatus es;

if ((es = getVertices3d(stretchPoints)) != Acad::eOk)

{

return es;

}

// Remove the duplicate point at the start and end.

//

stretchPoints. removeAt(stretchPoints. length() - 1);

return es;

}

Acad::ErrorStatus

AsdkPoly::moveStretchPointsAt(

const AcDbIntArray& indices,

const AcGeVector3d& offset)

{

return moveGripPointsAt(indices, offset);

}

Функции Преобразования

AcDbEntity класс предлагает две функции преобразования. TransformBy() функция применяет матрицу к объекту. GetTransformedCopy () функция дает возможность объекту возвратить копию себя С преобразованием, прикладным к этому.

Если объект однородно масштабируется и ортогональный, заданное по умолчанию выполнение AcDbEntity:: getTransformedCopy () функция имитирует объект и затем вызывает transformBy () функция на имитируемом объекте. (Используйте AcGeMatrix3d:: isUniScaledOrtho () функция, чтобы определить, масштабируется ли входная матрица однородно и ортогональный.)

Заказной AsdkPoly класс перегружает, и transformBy () функция и getTransformedCopy () функция. Когда AsdkPoly неравномерно масштабируется, это становится ломаной линией.

Acad::ErrorStatus

AsdkPoly::transformBy(const AcGeMatrix3d& xform)

{

// If we’re dragging, we aren’t really going to change our

// data, so we don’t want to make an undo recording nor do

// we really care if the object’s open for write.

//

if (mDragDataFlags & kCloneMeForDraggingCalled) {

mDragDataFlags &= kUseDragCache;

mDragPlaneNormal = mPlaneNormal;

mDragElevation = mElevation;

AcGeMatrix2d xform2d(xform. convertToLocal(mDragPlaneNormal,

mDragElevation));

mDragCenter = xform2d * center();

mDragStartPoint = xform2d * startPoint();

mDragPlaneNormal. normalize();

} else {

assertWriteEnabled();

AcGeMatrix2d xform2d(xform. convertToLocal(mPlaneNormal,

mElevation));

mCenter. transformBy(xform2d);

mStartPoint. transformBy(xform2d);

mPlaneNormal. normalize();

}

return Acad::eOk;

}

Acad::ErrorStatus AsdkPoly::getTransformedCopy(

const AcGeMatrix3d& mat,

AcDbEntity*& ent) const

{

assertReadEnabled();

Acad::ErrorStatus es = Acad::eOk;

AcGePoint3dArray vertexArray;

if ((es = getVertices3d(vertexArray)) != Acad::eOk)

{

return es;

}

for (int i = 0; i < vertexArray. length(); i++) {

vertexArray[i].transformBy(mat);

}

AcDbSpline *pSpline = NULL;

if ((es = rx_makeSpline(vertexArray, pSpline)) != Acad::eOk)

{

return es;

}

assert(pSpline != NULL);

pSpline->setPropertiesFrom(this);

ent = pSpline;

return es;

}

Пересечение с Другими примитивами

IntersectWith () функция имеет две формы:

virtual Acad::ErrorStatus

intersectWith(

const AcDbEntity* ent,

AcDb::Intersect intType,

AcGePoint3dArray& points,

int thisGsMarker = 0,

int otherGsMarker = 0) const;

virtual Acad::ErrorStatus

intersectWith(

const AcDbEntity* ent,

AcDb::Intersect intType,

const AcGePlane& projPlane,

AcGePoint3dArray& points,

int thisGsMarker = 0,

int otherGsMarker = 0) const;

Первая форма intersectWith () функциональные испытания на простое пересечение двух объектов. Вторая форма вычисляет пересечение на проекционную плоскость. Однако, обе функции возвращают перекрестные пункты{*точки*} на объекте непосредственно.

Использовать проекционную плоскую форму intersectWith () функция

1 Проектируют ваш объект и объект параметра на плоскость.

2 Проверяют объекты на пересечение на проекционной плоскости.

3 Проектируют перекрестные пункты{*точки*} назад на объект и возвращают их.

Заказной AsdkPoly класс перегружает обеих формы intersectWith () функция.

Acad::ErrorStatus

AsdkPoly::intersectWith(

const AcDbEntity* ent,

AcDb::Intersect intType,

AcGePoint3dArray& points,

int /*thisGsMarker*/,

int /*otherGsMarker*/) const

{

assertReadEnabled();

Acad::ErrorStatus es = Acad::eOk;

if (ent == NULL)

return Acad::eNullEntityPointer;

// The idea is to intersect each side of the polygon

// with the given entity and return all the points.

//

// For non-R12-entities with intersection methods defined,

// we call that method for each of the sides of the polygon.

// For R12-entities, we use the locally defined intersectors,

// since their protocols are not implemented.

//

if (ent->isKindOf(AcDbLine::desc())) {

if ((es = intLine(this, AcDbLine::cast(ent),

intType, NULL, points)) != Acad::eOk)

{

return es;

}

} else if (ent->isKindOf(AcDbArc::desc())) {

if ((es = intArc(this, AcDbArc::cast(ent), intType,

NULL, points)) != Acad::eOk)

{

return es;

}

} else if (ent->isKindOf(AcDbCircle::desc())) {

if ((es = intCircle(this, AcDbCircle::cast(ent),

intType, NULL, points)) != Acad::eOk)

{

return es;

}

} else if (ent->isKindOf(AcDb2dPolyline::desc())) {

if ((es = intPline(this, AcDb2dPolyline::cast(ent),

intType, NULL, points)) != Acad::eOk)

{

return es;

}

} else if (ent->isKindOf(AcDb3dPolyline::desc())) {

if ((es = intPline(this, AcDb3dPolyline::cast(ent),

intType, NULL, points)) != Acad::eOk)

{

return es;

}

} else {

AcGePoint3dArray vertexArray;

if ((es = getVertices3d(vertexArray))

!= Acad::eOk)

{

return es;

}

if (intType == AcDb::kExtendArg

|| intType == AcDb::kExtendBoth)

{

intType = AcDb::kExtendThis;

}

AcDbLine *pAcadLine;

for (int i = 0; i < vertexArray. length() - 1; i++) {

pAcadLine = new AcDbLine();

pAcadLine->setStartPoint(vertexArray[i]);

pAcadLine->setEndPoint(vertexArray[i + 1]);

pAcadLine->setNormal(normal());

if ((es = ent->intersectWith(pAcadLine, intType,

points)) != Acad::eOk)

{

delete pAcadLine;

return es;

}

delete pAcadLine;

}

}

return es;

}

Acad::ErrorStatus

AsdkPoly::intersectWith(

const AcDbEntity* ent,

AcDb::Intersect intType,

const AcGePlane& projPlane,

AcGePoint3dArray& points,

int /*thisGsMarker*/,

int /*otherGsMarker*/) const

{

assertReadEnabled();

Acad::ErrorStatus es = Acad::eOk;

if (ent == NULL)

return Acad::eNullEntityPointer;

// The idea is to intersect each side of the polygon

// with the given entity and return all the points.

//

// For non-R12-entities, with intersection methods defined,

// we call that method for each of the sides of the polygon.

// For R12-entities, we use the locally defined intersectors,

// since their protocols are not implemented.

//

if (ent->isKindOf(AcDbLine::desc())) {

if ((es = intLine(this, AcDbLine::cast(ent),

intType, &projPlane, points)) != Acad::eOk)

{

return es;

}

} else if (ent->isKindOf(AcDbArc::desc())) {

if ((es = intArc(this, AcDbArc::cast(ent), intType,

&projPlane, points)) != Acad::eOk)

{

return es;

}

} else if (ent->isKindOf(AcDbCircle::desc())) {

if ((es = intCircle(this, AcDbCircle::cast(ent),

intType, &projPlane, points)) != Acad::eOk)

{

return es;

}

} else if (ent->isKindOf(AcDb2dPolyline::desc())) {

if ((es = intPline(this, AcDb2dPolyline::cast(ent),

intType, &projPlane, points)) != Acad::eOk)

Из за большого объема этот материал размещен на нескольких страницах:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132