Exemplo n.º 1
0
static int Check_range(Element *E){
  int elmtid;
  static int init = 1;
  if(rnge){
    register int i;
    int cnt = 0;
    if(E->dim() == 3)
      for(i = 0; i < E->Nverts; ++i){
  if(      (E->vert[i].x > rnge->x[0])&&(E->vert[i].x < rnge->x[1])
        && (E->vert[i].y > rnge->y[0])&&(E->vert[i].y < rnge->y[1])
        && (E->vert[i].z > rnge->z[0])&&(E->vert[i].z < rnge->z[1])) ++cnt;
      }
    else
      for(i = 0; i < E->Nverts; ++i){
  if(   (E->vert[i].x > rnge->x[0])&&(E->vert[i].x < rnge->x[1])
     && (E->vert[i].y > rnge->y[0])&&(E->vert[i].y < rnge->y[1])) ++cnt;
      }
    return (cnt == E->Nverts) ? 1:0;
  }
  else if(elmtid = option("ELMTID")){
    static int *eids;

    if(init){
      Edge *e,*e1;
      Element *U;
      int nel = countelements(E),i;
      eids = ivector(0,nel-1);

      izero(nel,eids,1);

      eids[elmtid-1] = 1;
      /* find element */
      for(U = E; U; U = U->next)
  if(U->id == elmtid-1)
    break;

      for(i = 0; i < U->Nedges; ++i)
  for(e = U->edge[i].base; e; e = e->link)
    eids[e->eid] = 1;
      init = 0;
    }

    return eids[E->id];
  } else
    return 1;
}
Exemplo n.º 2
0
// ---------------------------------------------------------------------------
// 
// -----------
bool bBoxPosElement::action(bGenericGraphicContext *ctx){
	if(countelements()>=2){
bGenericGeoElement*		geo=ctx->getCurElement();
bStdXMLValueElement*	elt;

		elt=(bStdXMLValueElement*)(void*)getelement(1);
		elt->getvalue(geo,&_xval);
		elt=(bStdXMLValueElement*)(void*)getelement(2);
		elt->getvalue(geo,&_yval);
	}

int		npts,*offsets,noffsets;
float	*xpts,*ypts;
	ctx->getGeometry(&xpts,&ypts,&npts,&offsets,&noffsets);
	if(npts<=0){
		return(true);
	}
CGPoint	min,max;
CGPoint	res;
	min.x=max.x=xpts[0];
	min.y=max.y=ypts[0];
	for(int i=1;i<npts;i++){
		if(min.x>xpts[i]){
			min.x=xpts[i];
		}
		else if(max.x<xpts[i]){
			max.x=xpts[i];
		}
		if(min.y>ypts[i]){
			min.y=ypts[i];
		}
		else if(max.y<ypts[i]){
			max.y=ypts[i];
		}
	}
	res.x=min.x+(max.x-min.x)*_xval;
	res.y=min.y+(max.y-min.y)*_yval;
	ctx->setGeometry(&res.x,&res.y,1,NULL,0);	
	return(true);
}
// ---------------------------------------------------------------------------
// 
// -----------
bool bOffsetCoordElement::action(bGenericGraphicContext *ctx){
	if(countelements()!=2){
		return(true);
	}
bGenericGeoElement*	geo=ctx->getCurElement();
	if(!geo){
		return(true);
	}
	
int		npts,*offsets,noffsets;
float	*xpts,*ypts;
	
	ctx->getGeometry(&xpts,&ypts,&npts,&offsets,&noffsets);

bStdXMLValueElement*	elt;
d2dvertex				vx;

	elt=(bStdXMLValueElement*)(void*)getelement(1);
	elt->getvalue(geo,&vx.x);
	elt=(bStdXMLValueElement*)(void*)getelement(2);
	elt->getvalue(geo,&vx.y);
	
	if((vx.x==0)&&(vx.y==0)){
		return(true);
	}
	
CGPoint		cgp;
	_gapp->locConverter()->convert(&cgp,&vx);
	
	cgp.x=(cgp.x-xpts[0]);
	cgp.y=(cgp.y-ypts[0]);
	
	for(int i=0;i<npts;i++){
		xpts[i]+=cgp.x;
		ypts[i]+=cgp.y;
	}

	return(true);
}
// ---------------------------------------------------------------------------
//
// ------------
bool bXMapNetClean::process(int msg, void* prm){
_bTrace_("bXMapNetClean::process",true);
netcleancfg_prm*	cp;
netcleanact_prm*	ap;
bool				b;
    
    switch(msg){
        case kExtProcessCallFromIntf:
            _silent=false;
            process_network(true);
            break;
        case kExtProcessCallWithParams:
            ap=(netcleanact_prm*)prm;
            _silent=false;
            process_network(false);
            break;
        case kExtProcessCallWithXMLTree:{
            if(countelements()==6){
                init_data();

char                    val[_values_length_max_];
bGenericXMLBaseElement*	elt;
                elt=getelement(1);
                elt->getvalue(val);
                _act_prm.create_nodes=atoi(val);

                if(_act_prm.create_nodes){
                    elt=getelement(2);
                    elt->getvalue(val);
                    _act_prm.cut_edges=atoi(val);
                }
                else{
                    _act_prm.cut_edges=false;
                }

                elt=getelement(3);
                elt->getvalue(val);
                _act_prm.join_on_nodes=atoi(val);

                elt=getelement(4);
                elt->getvalue(val);
                _act_prm.join_on_edges=atoi(val);
                if(_act_prm.join_on_nodes&&_act_prm.join_on_edges){
                    _act_prm.join_on_edges=false;
                }
                
                elt=getelement(5);
                elt->getvalue(val);
                _act_prm.check_nodes=atoi(val);

                elt=getelement(6);
                elt->getvalue(val);
                _act_prm.check_edges=atoi(val);

                _silent=true;
                process_network(false);
                
                _nodes.reset();
                _edges.reset();
            }
            else{
                return(false);
            }
            }
            break;
        case kExtProcessCallGetData:
_tm_("kExtProcessCallGetData");
            cp=(netcleancfg_prm*)prm;
            if(cp->nodes){
                cp->nodes->reset();
                b=(*cp->nodes)+_nodes;
            }
            if(cp->edges){
                cp->edges->reset();
                b=(*cp->edges)+_edges;
            }
            cp->tnod=_cfg_prm.tnod;
            cp->stnod=_cfg_prm.stnod;
            strcpy(cp->name,_cfg_prm.name);
            cp->tbdg=_cfg_prm.tbdg;
            cp->stbdg=_cfg_prm.stbdg;
            cp->dnod=_cfg_prm.dnod;
            cp->dbdg=_cfg_prm.dbdg;
            cp->autoclean=_cfg_prm.autoclean;
            break;
        case kExtProcessCallSetData:
_tm_("kExtProcessCallSetData");
            cp=(netcleancfg_prm*)prm;
            if(cp->nodes){
                _nodes.reset();
                b=_nodes+(*cp->nodes);
            }
            if(cp->edges){
                _edges.reset();
                b=_edges+(*cp->edges);
            }
            _cfg_prm.tnod=cp->tnod;
            _cfg_prm.stnod=cp->stnod;
            strcpy(_cfg_prm.name,cp->name);
            _cfg_prm.tbdg=cp->tbdg;
            _cfg_prm.stbdg=cp->stbdg;
            _cfg_prm.dnod=cp->dnod;
            _cfg_prm.dbdg=cp->dbdg;
            _cfg_prm.autoclean=cp->autoclean;
            write_p();
            break;
        default:
            return(false);
    }
    return(true);
}
Exemplo n.º 5
0
// ---------------------------------------------------------------------------
// 
// -----------
void bStdUserScript::open(int* flags){
	if(countelements()>0){
		bStdUserExt::open(flags);
		_root=(bStdXMLScriptElement*)(void*)_gapp->classMgr()->NthElement(this,1,"script");
	}
}