Esempio n. 1
0
const ValVec<htmRange> &
htmInterface::doHull() {

  if(polyCorners_.length() < 3)
    throw SpatialInterfaceError("htmInterface:convexHull: empty hull: points on one line");

  SpatialVector v;
  SpatialConvex x;
  SpatialDomain d;

  // The constraint we have for each side is a 0-constraint (great circle)
  // passing through the 2 corners. Since we are in counterclockwise order,
  // the vector product of the two successive corners just gives the correct
  // constraint.
  size_t i, len = polyCorners_.length();
  for(i = 0; i < len; i++) {
    v = polyCorners_[i].c_ ^ polyCorners_[ i == len-1 ? 0 : i + 1].c_;
#ifdef DIAG
    cerr << v << " " << i << "," << i+1 << "\n";
#endif
    v.normalize();
    SpatialConstraint c(v,0);
    x.add(c);
  }
  d.add(x);
  d.intersect(index_, idList_);

  range_.cut(range_.length());
  makeRange();

  return range_;
}
Esempio n. 2
0
const ValVec<htmRange> & 
htmInterface::domainCmd( char *str ) {

  cmd_ = str;
  if(t_)delete t_;
  t_ = new VarStrToken(cmd_);

  cmdCode code = getCode();
  if(code != HTMDOMAIN)
    throw SpatialInterfaceError("htmInterface:domainCmd: missing keyword HTMDOMAIN");
  getDepth();

  int32 nx,nc;
  nx = getInteger();

  SpatialDomain dom;
  for(int32 i = 0 ; i < nx; i++ ) {
    SpatialConvex convex;
    nc = getInteger();
    for(int32 j = 0; j < nc; j++ ) {
      float64 x = getFloat();
      float64 y = getFloat();
      float64 z = getFloat();
      float64 d = getFloat();
      SpatialConstraint c(SpatialVector(x,y,z),d);
      convex.add(c);
    }
    dom.add(convex);
  }

  return domain(dom);
}
Esempio n. 3
0
const ValueVector &
htmInterface::doHull() {

	if(polyCorners_.size() < 3)
		throw SpatialInterfaceError("htmInterface:convexHull: empty hull: points on one line");

	SpatialVector v;

	RangeConvex cvx;

	SpatialDomain dom;

	// The constraint we have for each side is a 0-constraint (great circle)
	// passing through the 2 corners. Since we are in counterclockwise order,
	// the vector product of the two successive corners just gives the correct
	// constraint.
	size_t i, len = polyCorners_.size();
	for(i = 0; i < len; i++) {
		v = polyCorners_[i].c_ ^ polyCorners_[ i == len-1 ? 0 : i + 1].c_;
#ifdef DIAG
		cerr << "doHull:: " << v << " " << i << "," << i+1 << endl;
#endif
		v.normalize();
		SpatialConstraint c(v,0);
		cvx.add(c); // [ed:RangeConvex::add]
	}
	dom.add(cvx);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%
//	dom.convexes_[0].boundingCircle_.write(cout);
//	dom.write(cout);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%
	return domain(dom);
}
Esempio n. 4
0
int
test4 (int flag) {

  int nfailed = 0;
  HtmRange hr;
  SpatialIndex  si (3,3);
  SpatialVector sx (0.,0.);
  SpatialVector sz (0.,90.);
  SpatialConstraint sd (sx, .98);
  SpatialConstraint sc (sz, .98);
  RangeConvex cc;
  RangeConvex cd;
  SpatialDomain sdm;

  // create two convexes, along x and z
  cc.add(sc);
  cd.add(sd);
	
  // add them to the domain
  sdm.add(cc);
  sdm.add(cd);

  sdm.intersect(&si, &hr);

  if (flag>=DBG_MORE) sdm.write(cout);
	
  nfailed = 0;
  // showlists("domain 1",flag,full,partial);

  return showtest("Test4 (domain)\t",nfailed,flag);
}
Esempio n. 5
0
int
test4 (int flag) {

  int nfailed = 0;
  ValueVectorUint64 full, partial;
  SpatialIndex  si (3,3);
  SpatialVector sx (0.,0.);
  SpatialVector sz (0.,90.);
  SpatialConstraint sd (sx, .98);
  SpatialConstraint sc (sz, .98);
  SpatialConvex cc;
  SpatialConvex cd;
  SpatialDomain sdm;

  // create two convexes, along x and z
  cc.add(sc);
  cd.add(sd);
	
  // add them to the domain
  sdm.add(cc);
  sdm.add(cd);

  sdm.intersect(&si, partial, full);

  if (flag>=DBG_MORE) sdm.write(std::cout);
	
  nfailed += !(partial.size()==24);
  nfailed += !(full.size()==8);
  showlists("domain 1",flag,full,partial);

  return showtest("Test4 (domain)\t",nfailed,flag);
}
Esempio n. 6
0
const ValueVector & 
htmInterface::circleRegion( float64 ra,
			    float64 dec,
			    float64 rad ) {

	SpatialDomain dom;

	RangeConvex cvx;

	float64 d = cos(gPi * rad/10800.0);
	SpatialConstraint c(SpatialVector(ra,dec),d);
	cvx.add(c); // [ed:RangeConvex::add]
	dom.add(cvx);
	return domain(dom);
}
Esempio n. 7
0
const ValVec<htmRange> & 
htmInterface::circleRegion( float64 ra,
			    float64 dec,
			    float64 rad ) {

  SpatialDomain domain;
  SpatialConvex convex;
  float64 d = cos(gPi * rad/10800.0);
  SpatialConstraint c(SpatialVector(ra,dec),d);

  convex.add(c);
  domain.add(convex);
  domain.intersect(index_, idList_);

  range_.cut(range_.length());
  makeRange();

  return range_;
}