2009-01-13 04:40:13 +05:00
|
|
|
#ifndef FILE_NETRULE
|
|
|
|
#define FILE_NETRULE
|
|
|
|
|
|
|
|
///
|
|
|
|
class netrule
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
typedef struct tf
|
|
|
|
{ float f1, f2, f3; } threefloat;
|
|
|
|
|
|
|
|
class threeint
|
|
|
|
{
|
|
|
|
public: int i1, i2, i3;
|
|
|
|
threeint() { }
|
|
|
|
threeint(int ai1, int ai2, int ai3)
|
|
|
|
{ i1 = ai1; i2 = ai2; i3 = ai3; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
int quality;
|
|
|
|
///
|
2021-06-21 11:36:14 +05:00
|
|
|
string name;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2019-09-29 19:22:00 +05:00
|
|
|
NgArray<Point<2>> points;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<INDEX_2> lines;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2019-09-29 19:22:00 +05:00
|
|
|
NgArray<Point<2>> freezone, freezonelimit;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2021-06-21 11:36:14 +05:00
|
|
|
NgArray<NgArray<Point<2>>> freezone_i;
|
2010-07-21 02:04:16 +06:00
|
|
|
///
|
2019-09-29 19:22:00 +05:00
|
|
|
NgArray<Point<2>> transfreezone;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
///
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<int> dellines;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<Element2d> elements;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<threefloat> tolerances, linetolerances;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<threeint> orientations;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
|
|
|
DenseMatrix oldutonewu, oldutofreearea, oldutofreearealimit;
|
|
|
|
///
|
2021-06-21 11:36:14 +05:00
|
|
|
NgArray<DenseMatrix> oldutofreearea_i;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
|
|
|
MatrixFixWidth<3> freesetinequ;
|
|
|
|
|
|
|
|
///
|
2019-09-29 19:22:00 +05:00
|
|
|
NgArray<Vec<2>> linevecs;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
///
|
|
|
|
int noldp, noldl;
|
|
|
|
///
|
|
|
|
float fzminx, fzmaxx, fzminy, fzmaxy;
|
|
|
|
|
|
|
|
/// topological distance of line to base element
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<int> lnearness;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
///
|
|
|
|
netrule ();
|
|
|
|
///
|
|
|
|
~netrule();
|
|
|
|
|
|
|
|
///
|
|
|
|
int GetNP () const { return points.Size(); }
|
|
|
|
///
|
|
|
|
int GetNL () const { return lines.Size(); }
|
|
|
|
///
|
|
|
|
int GetNE () const { return elements.Size(); }
|
|
|
|
///
|
|
|
|
int GetNOldP () const { return noldp; }
|
|
|
|
///
|
|
|
|
int GetNOldL () const { return noldl; }
|
|
|
|
///
|
|
|
|
int GetNDelL () const { return dellines.Size(); }
|
|
|
|
///
|
|
|
|
int GetNOrientations () const { return orientations.Size(); }
|
|
|
|
///
|
|
|
|
int GetQuality () const { return quality; }
|
|
|
|
///
|
|
|
|
int GetLNearness (int li) const { return lnearness.Get(li); }
|
|
|
|
|
|
|
|
///
|
2019-09-29 19:22:00 +05:00
|
|
|
const Point<2>& GetPoint (int i) const { return points.Get(i); }
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
|
|
|
const INDEX_2 & GetLine (int i) const { return lines.Get(i); }
|
|
|
|
///
|
|
|
|
const Element2d & GetElement (int i) const { return elements.Get(i); }
|
|
|
|
///
|
|
|
|
const threeint & GetOrientation (int i) const { return orientations.Get(i); }
|
|
|
|
///
|
|
|
|
int GetDelLine (int i) const { return dellines.Get(i); }
|
|
|
|
///
|
2019-07-09 13:39:16 +05:00
|
|
|
const NgArray<int> & GetDelLines() const { return dellines; }
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2019-09-30 13:19:35 +05:00
|
|
|
void GetFreeZone (NgArray<Point<2>> & afreearea);
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
|
|
|
|
2019-09-30 13:19:35 +05:00
|
|
|
double CalcPointDist (int pi, const Point<2> & p) const
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2019-09-30 13:19:35 +05:00
|
|
|
double dx = p[0] - points.Get(pi)[0];
|
|
|
|
double dy = p[1] - points.Get(pi)[1];
|
2009-01-13 04:40:13 +05:00
|
|
|
const threefloat * tfp = &tolerances.Get(pi);
|
|
|
|
return tfp->f1 * dx * dx + tfp->f2 * dx * dy + tfp->f3 * dy * dy;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
2019-09-29 19:22:00 +05:00
|
|
|
float CalcLineError (int li, const Vec<2>& v) const;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
///
|
|
|
|
void SetFreeZoneTransformation (const Vector & u, int tolclass);
|
|
|
|
|
|
|
|
///
|
2019-09-30 13:19:35 +05:00
|
|
|
bool IsInFreeZone (const Point<2> & p) const
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2019-09-30 13:19:35 +05:00
|
|
|
if (p[0] < fzminx || p[0] > fzmaxx ||
|
|
|
|
p[1] < fzminy || p[1] > fzmaxy) return 0;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
for (int i = 0; i < transfreezone.Size(); i++)
|
|
|
|
{
|
2019-09-30 13:19:35 +05:00
|
|
|
if (freesetinequ(i, 0) * p[0] +
|
|
|
|
freesetinequ(i, 1) * p[1] +
|
2009-01-13 04:40:13 +05:00
|
|
|
freesetinequ(i, 2) > 0) return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
2019-09-30 13:19:35 +05:00
|
|
|
int IsLineInFreeZone (const Point<2> & p1, const Point<2> & p2) const
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2019-09-30 13:19:35 +05:00
|
|
|
if ( (p1[0] > fzmaxx && p2[0] > fzmaxx) ||
|
|
|
|
(p1[0] < fzminx && p2[0] < fzminx) ||
|
|
|
|
(p1[1] > fzmaxy && p2[1] > fzmaxy) ||
|
|
|
|
(p1[1] < fzminy && p2[1] < fzminy) ) return 0;
|
2009-01-13 04:40:13 +05:00
|
|
|
return IsLineInFreeZone2 (p1, p2);
|
|
|
|
}
|
|
|
|
///
|
2019-09-30 13:19:35 +05:00
|
|
|
int IsLineInFreeZone2 (const Point<2> & p1, const Point<2> & p2) const;
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
|
|
|
int ConvexFreeZone () const;
|
|
|
|
///
|
2019-09-29 19:22:00 +05:00
|
|
|
const NgArray<Point<2>> & GetTransFreeZone () { return transfreezone; }
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
///
|
|
|
|
int GetPointNr (int ln, int endp) const { return lines.Get(ln).I(endp); }
|
|
|
|
|
|
|
|
///
|
|
|
|
const DenseMatrix & GetOldUToNewU () const { return oldutonewu; }
|
|
|
|
///
|
|
|
|
const DenseMatrix & GetOldUToFreeArea () const { return oldutofreearea; }
|
|
|
|
///
|
2021-06-21 11:36:14 +05:00
|
|
|
const string & Name () const { return name; }
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
///
|
|
|
|
void LoadRule (istream & ist);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Draws 2D rules.
|
|
|
|
Visual testing of 2D meshing rules */
|
|
|
|
extern void DrawRules ();
|
|
|
|
#endif
|
|
|
|
|