Exemplo n.º 1
0
void Plugin_Entity::getPolylineData(QList<Plug_VertexData> *data){
    if (entity == NULL) return;
    RS2::EntityType et = entity->rtti();
    if (et != RS2::EntityPolyline) return;
    RS_Polyline *l = static_cast<RS_Polyline*>(entity);

    RS_Entity* nextEntity = 0;
    RS_AtomicEntity* ae = NULL;
    RS_Entity* v = l->firstEntity(RS2::ResolveNone);
    double bulge=0.0;
//bad polyline without vertex
    if (v == NULL) return;

//First polyline vertex
    if (v->rtti() == RS2::EntityArc) {
        bulge = ((RS_Arc*)v)->getBulge();
    }
    ae = (RS_AtomicEntity*)v;
    data->append(Plug_VertexData(QPointF(ae->getStartpoint().x,
                                         ae->getStartpoint().y),bulge));

    for (v=l->firstEntity(RS2::ResolveNone); v!=NULL; v=nextEntity) {
        nextEntity = l->nextEntity(RS2::ResolveNone);
        bulge = 0.0;
        if (!v->isAtomic()) {
            continue;
        }
        ae = (RS_AtomicEntity*)v;

        if (nextEntity!=NULL) {
            if (nextEntity->rtti()==RS2::EntityArc) {
                bulge = ((RS_Arc*)nextEntity)->getBulge();
            }
        }

        if (l->isClosed()==false || nextEntity!=NULL) {
            data->append(Plug_VertexData(QPointF(ae->getEndpoint().x,
                                         ae->getEndpoint().y),bulge));
        }
    }

}
Exemplo n.º 2
0
void dibSHP::readPolyline(DBFHandle dh, int i){
    int maxPoints;
    Plug_Entity *ent =NULL;
    QHash<int, QVariant> data;
    QList<Plug_VertexData> vl;

    readAttributes(dh, i);
    data.insert(DPI::LAYER, attdata.layer);
    for( int i = 0; i < sobject->nParts; i++ ) {
        if ( (i+1) < sobject->nParts) maxPoints = sobject->panPartStart[i+1];
        else maxPoints = sobject->nVertices;
        vl.clear();
        for( int j = sobject->panPartStart[i]; j < maxPoints; j++ ) {
            vl.append( Plug_VertexData( QPointF(sobject->padfX[j],sobject->padfY[j]), 0.0) );
        }
        if (vl.size() > 2 ) {
            ent = currDoc->newEntity(DPI::POLYLINE);
            ent->updateData(&data);
            currDoc->addEntity(ent);
            ent->updatePolylineData(&vl);
        }
    }
}