Exemplo n.º 1
0
void Meshing2Surfaces :: TransformToPlain (const Point3d & locpoint, 
					   const MultiPointGeomInfo & geominfo,
					   Point2d & planepoint, 
					   double h, int & zone)
{
  Point<2> hp;
  surface.ToPlane (locpoint, hp, h, zone);
  planepoint.X() = hp(0);
  planepoint.Y() = hp(1);
}
Exemplo n.º 2
0
  int Meshing2OCCSurfaces :: TransformFromPlain (Point2d & planepoint,
						 Point3d & locpoint,
						 PointGeomInfo & gi,
						 double h)
  {
    Point<3> hp;
    Point<2> hp2 (planepoint.X(), planepoint.Y());
    surface.FromPlane (hp2, hp, gi, h);
    locpoint = hp;
    return 0;
  }
Exemplo n.º 3
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") {
Exemplo n.º 4
0
int netrule :: IsLineInFreeZone2 (const Point2d & p1, const Point2d & p2) const
{
  int i;
  int left, right, allleft, allright;
  double nx, ny, nl, c;

  if (p1.X() > fzmaxx && p2.X() > fzmaxx ||
      p1.X() < fzminx && p2.X() < fzminx ||
      p1.Y() > fzmaxy && p2.Y() > fzmaxy ||
      p1.Y() < fzminy && p2.Y() < fzminy) return 0;

  for (i = 1; i <= transfreezone.Size(); i++)
    {
      if (freesetinequ.Get(i, 1) * p1.X() + freesetinequ.Get(i, 2) * p1.Y() +
	  freesetinequ.Get(i, 3) > -1e-6 &&
	  freesetinequ.Get(i, 1) * p2.X() + freesetinequ.Get(i, 2) * p2.Y() +
	  freesetinequ.Get(i, 3) > -1e-6
	  ) return 0;
    }

  nx =  (p2.Y() - p1.Y());
  ny = -(p2.X() - p1.X());
  nl = sqrt (nx * nx + ny * ny);
  if (nl > 1e-8)
    {
      nx /= nl;
      ny /= nl;
      c = - (p1.X() * nx + p1.Y() * ny);

      allleft = 1;
      allright = 1;

      for (i = 1; i <= transfreezone.Size(); i++)
	{
	  left  = transfreezone.Get(i).X() * nx + transfreezone.Get(i).Y() + c <  1e-7;
	  right = transfreezone.Get(i).X() * nx + transfreezone.Get(i).Y() + c > -1e-7;

	  if (!left) allleft = 0;
	  if (!right) allright = 0;
	}
      if (allleft || allright) return 0;
    }

  return 1;
}
Exemplo n.º 5
0
int netrule :: IsLineInFreeZone2 (const Point2d & p1, const Point2d & p2) const
{
  if ( (p1.X() > fzmaxx && p2.X() > fzmaxx) ||
       (p1.X() < fzminx && p2.X() < fzminx) ||
       (p1.Y() > fzmaxy && p2.Y() > fzmaxy) ||
       (p1.Y() < fzminy && p2.Y() < fzminy) ) return 0;

  for (int i = 1; i <= transfreezone.Size(); i++)
    {
      if (freesetinequ.Get(i, 1) * p1.X() + freesetinequ.Get(i, 2) * p1.Y() +
	  freesetinequ.Get(i, 3) > -1e-8 &&    // -1e-6
	  freesetinequ.Get(i, 1) * p2.X() + freesetinequ.Get(i, 2) * p2.Y() +
	  freesetinequ.Get(i, 3) > -1e-8       // -1e-6
	  ) return 0;
    }

  double nx =  (p2.Y() - p1.Y());
  double ny = -(p2.X() - p1.X());
  double nl = sqrt (nx * nx + ny * ny);
  if (nl > 1e-8)
    {
      nx /= nl;
      ny /= nl;
      double c = - (p1.X() * nx + p1.Y() * ny);

      bool allleft = true;
      bool allright = true;

      for (int i = 1; i <= transfreezone.Size(); i++)
	{
	  bool left  = transfreezone.Get(i).X() * nx + transfreezone.Get(i).Y() * ny + c <  1e-7;
          bool right = transfreezone.Get(i).X() * nx + transfreezone.Get(i).Y() * ny + c > -1e-7;
	  if (!left) allleft = false;
	  if (!right) allright = false;
	}
      if (allleft || allright) return false;
    }

  return true;
}
Exemplo n.º 6
0
inline Vec2d operator- (const Point2d & p1, const Point2d & p2)
  {
  return Vec2d (p1.X() - p2.X(), p1.Y() - p2.Y());
  }
Exemplo n.º 7
0
 Point2d Center () const
  { return Point2d( (p1->X()+p2->X()+p3->X())/3, (p1->Y()+p2->Y()+p3->Y())/3); }
Exemplo n.º 8
0
 double XMin() const { return min3 (p1->X(), p2->X(), p3->X()); }
Exemplo n.º 9
0
 double XMax() const { return max3 (p1->X(), p2->X(), p3->X()); }
Exemplo n.º 10
0
void netrule :: LoadRule (istream & ist)
{
  char buf[256];
  char ch;
  Point2d p;
  INDEX_2 lin;
  int i, j;
  DenseMatrix tempoldutonewu(20, 20), tempoldutofreearea(20, 20),
    tempoldutofreearealimit(20, 20);

  tempoldutonewu = 0;
  tempoldutofreearea = 0;
  tempoldutofreearealimit = 0;

  noldp = 0;
  noldl = 0;

  ist.get (buf, sizeof(buf), '"');
  ist.get (ch);
  ist.get (buf, sizeof(buf), '"');
  ist.get (ch);

  // if(name != NULL) 
  delete [] name;
  name = new char[strlen (buf) + 1];
  strcpy (name, buf);
  //(*testout) << "name " << name << endl;
  //  (*mycout) << "Rule " << name << " found." << endl;

  do
    {
      ist >> buf;

      //(*testout) << "buf " << buf << endl;

      if (strcmp (buf, "quality") == 0)

	{
	  ist >> quality;
	}

      else if (strcmp (buf, "mappoints") == 0)
	{
	  ist >> ch;

	  while (ch == '(')
	    {
	      ist >> p.X();
	      ist >> ch;    // ','
	      ist >> p.Y();
	      ist >> ch;    // ')'

	      points.Append (p);
	      noldp++;

	      tolerances.SetSize (noldp);
	      tolerances.Elem(noldp).f1 = 1.0;
	      tolerances.Elem(noldp).f2 = 0;
	      tolerances.Elem(noldp).f3 = 1.0;

	      ist >> ch;
	      while (ch != ';')
		{
		  if (ch == '{')
		    {
		      ist >> tolerances.Elem(noldp).f1;
		      ist >> ch;  // ','
		      ist >> tolerances.Elem(noldp).f2;
		      ist >> ch;  // ','
		      ist >> tolerances.Elem(noldp).f3;
		      ist >> ch;  // '}'
		    }
		  else if (ch == 'd')
		    {
		      //            delpoints.Append (noldp);
		      ist >> ch; // 'e'
		      ist >> ch; // 'l'
		    }
Exemplo n.º 11
0
inline void PpSmV (const Point2d & p1, double s,
                   const Vec2d & v, Point2d & p2)
  {
  p2.X() = p1.X() + s * v.X();
  p2.Y() = p1.Y() + s * v.Y();
  }
Exemplo n.º 12
0
 double Length2 () const
       { return sqr (p1->X() - p2->X()) +
                sqr (p1->Y() - p2->Y()); }
Exemplo n.º 13
0
 Vec2d Delta () const { return Vec2d (p2->X()-p1->X(), p2->Y()-p1->Y()); }
Exemplo n.º 14
0
 double Length2 () const
       { return sqr (p1.X() - p2.X()) +
                sqr (p1.Y() - p2.Y()); }
Exemplo n.º 15
0
 Vec2d Delta () const { return Vec2d (p2.X()-p1.X(), p2.Y()-p1.Y()); }
Exemplo n.º 16
0
inline Point2d operator+ (const Point2d & p1, const Vec2d & v)
  {
  return Point2d (p1.X() + v.X(), p1.Y() + v.Y());
  }
Exemplo n.º 17
0
inline Point2d Center (const Point2d & p1, const Point2d & p2)
  {
  return Point2d ((p1.X() + p2.X()) / 2, (p1.Y() + p2.Y()) / 2);
  }
Exemplo n.º 18
0
 double XMax() const { return max3 (p1.X(), p2.X(), p3.X()); }
Exemplo n.º 19
0
inline void PmP (const Point2d & p1, const Point2d & p2, Vec2d & v)
  {
  v.X() = p1.X() - p2.X();
  v.Y() = p1.Y() - p2.Y();
  }
Exemplo n.º 20
0
 double XMin() const { return min3 (p1.X(), p2.X(), p3.X()); }
Exemplo n.º 21
0
 inline Point2d Center () const
  { return Point2d( (p1.X()+p2.X()+p3.X())/3, (p1.Y()+p2.Y()+p3.Y())/3); }
Exemplo n.º 22
0
void Mesh::Refine()
{
    // reduce 2nd order
    size_t nb_vertices = ComputeNVertices();

    points.resize(nb_vertices);
    IndexPair_map<PointIndex> between(nb_vertices + 5);

    size_t oldns = segments.size();
    for (size_t si = 0; si < oldns; si++) {
        const Segment& seg = segments[si];
        const MeshPoint& p1 = points[seg[0]];
        const MeshPoint& p2 = points[seg[1]];

        IndexPair i2(seg[0], seg[1]);
        i2.Sort();
        PointIndex pi_new;

        if (between.count(i2) == 1) {
            pi_new = between[i2];
        } else {
            Point2d pnew;
            pnew.X() = 0.5 * (p1.X() + p2.X());
            pnew.Y() = 0.5 * (p1.Y() + p2.Y());
            pi_new = AddPoint(pnew);
            between[i2] = pi_new;
        }

        Segment ns1 = seg;
        Segment ns2 = seg;
        ns1[1] = pi_new;
        ns2[0] = pi_new;

        segments[si] = ns1;
        AddSegment(ns2);
    }

    // refine surface elements
    size_t oldnf = elements.size();
    for (size_t sei = 0; sei < oldnf; sei++) {
        int j, k;
        const Element2d& el = elements[sei];

        PointIndex pnums[6];

        static int betw[3][3] = {{1, 2, 3},
                                 {0, 2, 4},
                                 {0, 1, 5}};

        for (j = 0; j < 3; j++) {
            pnums[j] = el.PointID(j);
        }

        for (j = 0; j < 3; j++) {
            PointIndex pi1 = pnums[betw[j][0]];
            PointIndex pi2 = pnums[betw[j][1]];

            IndexPair i2(pi1, pi2);
            i2.Sort();

            if (between.count(i2) == 0) {
                const MeshPoint& p1 = points[pi1];
                const MeshPoint& p2 = points[pi2];
                Point2d pnew;
                pnew.X() = 0.5 * (p1.X() + p2.X());
                pnew.Y() = 0.5 * (p1.Y() + p2.Y());
                between[i2] = AddPoint(pnew);
            }
            pnums[3 + j] = between[i2];
        }

        static int reftab[4][3] = {{0, 5, 4},
                                   {1, 3, 5},
                                   {2, 4, 3},
                                   {5, 3, 4}};

        DomainIndex ind = el.FaceID();
        for (j = 0; j < 4; j++) {
            Element2d new_element;
            for (k = 0; k < 3; k++) {
                new_element.PointID(k) = pnums[reftab[j][k]];
            }
            new_element.SetFaceID(ind);

            if (j == 0) {
                elements[sei] = new_element;
            } else {
                AddElement(new_element);
            }
        }
    }

    ComputeNVertices();
    RebuildSurfaceElementLists();
}