Example #1
0
// ##### nextPointColor() ############################################
Color OctGen::nextPointColor(NodeIndex p) {
  assert (p.getHight() == BASE_NODE_HIGHT);
  assert (cadModel != NULL);
  assert (octree != NULL);
  assert (genHelp != NULL);

  Color color;

  cadModel->first();
  while (!cadModel->getObject()->isPlane() && cadModel->hasObject()) {
    cadModel->next();
  }

  Coordinate sqrDist= MAX_AX_INDEX*MAX_AX_INDEX*MAX_AX_INDEX;
  GeomPoint footpoint= NULL_GEOM_VEC;
  Polygon polygon= Polygon(footpoint, footpoint, footpoint);
  color= NO_OBJECT;
  Polygon* t2= NULL;
  while (cadModel->hasObject()) {
    CadObject* object= cadModel->getObject();
    switch (object->getDataType()) {
    case CadObject::TRIANGLE:
      polygon= genHelp->getPolygon((Triangle *)object);
      break;
    case CadObject::QUADRILATERAL:
      polygon= genHelp->getPolygon((Quadrilateral *)object, t2);
      break;
    default:;
    }

    bool haveMorePolygons= true;
    while (haveMorePolygons) {
      footpoint= polygon.getFootpoint(p);
      if (!polygon.isIn(footpoint)) {
	return false;
      }
      GeomVec rayVec= GeomVec(GeomPoint(p), footpoint);
      Coordinate angle= polygon.getNormVec()*rayVec;
      if (EQUIVAL(rayVec.getSqrLength(), sqrDist)) {
      } else if (rayVec.getSqrLength() < sqrDist) {
	sqrDist= rayVec.getSqrLength();
	color= (angle <= 0.0) ? NO_OBJECT : cadModel->getObjColor();
      }
      
      if (t2 != NULL) {
	polygon= *t2;
	t2= NULL;
      } else {
	haveMorePolygons= false;
      }
    }
    
    cadModel->next();
  }
  return color;
}
Example #2
0
void SplineGeometry::LoadData(std::istream& infile)
{
    MESHIT_LOG_INFO("Load 2D Geometry");

    Point2d x;
    char buf[50], ch;

    std::string keyword;
    std::string flag;

    int nb_domains = 0;

    TestComment(infile);
    // refinement factor
    infile >> elto0;

    while (infile.good()) {
        TestComment(infile);
        infile >> keyword;
        ch = TestComment(infile);

        if (keyword == "points") {
            std::vector<GeomPoint> points;
            std::vector<PointIndex> point_ids;
            size_t point_id;
            size_t nb_points = 0;
            while (!isalpha(static_cast<int>(ch))) {
                infile >> point_id;  // point ids are 1-based
                if (point_id > nb_points) nb_points = point_id;
                point_ids.push_back(point_id);

                infile >> x.X() >> x.Y() >> ch;

                Flags flags;
                while (ch == '-') {
                    infile >> flag;
                    flags.SetCommandLineFlag(flag);
                    ch = TestComment(infile);
                }
                infile.unget();
                ch = TestComment(infile);

                points.push_back(GeomPoint(x, flags.GetNumFlag("ref", 1.0), flags.GetNumFlag("maxh", 1e99)));
            }
            geompoints.resize(nb_points);
            for (size_t i = 0; i < nb_points; i++) {
                geompoints[point_ids[i] - 1] = points[i];
            }
        } else if (keyword == "segments") {
Example #3
0
Color OctGen::testRayColor(NodeIndex p, bool &isAtBorder) {
  isAtBorder= false;
#else
Color OctGen::testRayColor(NodeIndex p) {
#endif
  assert (cadModel != NULL);
  assert (octree != NULL);
  assert (genHelp != NULL);

  Axis rayAxis= RAY_AXIS;
  AxDirection rayDir= RAY_DIR;

  assert (rayAxis < DIMENSIONS);
  assert (rayDir == BACKWARD || rayDir == FORWARD);

  Color color= NO_OBJECT;
  bool intersect= false;
  bool inside= false;

  cadModel->first();
  GeomPoint idxPoint= GeomPoint(p);
  Coordinate dist= (rayDir == FORWARD ? MAX_AX_INDEX : -MAX_AX_INDEX);
  GeomPoint footpoint= NULL_GEOM_VEC;
  Surface *s= NULL;
  color= NO_OBJECT;
  Polygon *t2= NULL;
  while (cadModel->hasObject()) {
    CadObject* object= cadModel->getObject();
    switch (object->getDataType()) {
    case CadObject::TRIANGLE:
      s= new Polygon(genHelp->getPolygon((Triangle *)object));
      break;
    case CadObject::QUADRILATERAL:
      s= new Polygon(genHelp->getPolygon((Quadrilateral *)object, t2));
      break;
    case CadObject::B_SPLINE:
      s= new Spline(*(BSpline *)object, this);
      break;
    default:;
    }

#ifdef CLASSIC_MODE
    s->setHight(idxPoint.getHight());
#else
    idxPoint.setHight(BASE_NODE_HIGHT);
#endif
    assert (s->getHight() == idxPoint.getHight());

    Coordinate pCoord= idxPoint[rayAxis];
    bool haveMorePolygons= true;
    while (haveMorePolygons) {
      assert (s->getHight() == idxPoint.getHight());

#ifdef CLASSIC_MODE
      if (s->isIn(idxPoint)) {
        delete s;
	isAtBorder= true;
	inside= true;
	return cadModel->getObjColor();
      }
#endif
      if (s->testLine(idxPoint, footpoint, intersect, inside)) {
        Coordinate coord= footpoint[rayAxis];
	if (intersect) {
	  if ( (rayDir == FORWARD) ? coord < dist && coord > pCoord
	                           : coord > dist && coord < pCoord ) {
	    dist= coord;
	    color= (inside ? cadModel->getObjColor() : NO_OBJECT);
	  }
	}
      }
      delete s;
      if (t2 != NULL) {
	s= t2;
#ifdef CLASSIC_MODE
        s->setHight(idxPoint.getHight());
#endif
	t2= NULL;
      } else {
	haveMorePolygons= false;
      }
    }

    cadModel->next();
  }
  return color;
}