diff --git a/Geo/GenericEdge.cpp b/Geo/GenericEdge.cpp index 53af6e71a781ede4985fd67e755f695b9fad1d8f..4643cab2d390cf791050326f76beceece129e014 100644 --- a/Geo/GenericEdge.cpp +++ b/Geo/GenericEdge.cpp @@ -11,8 +11,6 @@ #include "GenericFace.h" #include "Context.h" -//------------------------------------------------------------------------ - GenericEdge::ptrfunction_int_double_refvector GenericEdge::EdgeEvalXYZFromT = NULL; GenericEdge::ptrfunction_int_refdouble_refdouble GenericEdge::EdgeEvalParBounds = NULL; GenericEdge::ptrfunction_int_refstring GenericEdge::EdgeGeomType = NULL; @@ -23,28 +21,25 @@ GenericEdge::ptrfunction_int_refvector_refdouble_refvector_refbool GenericEdge:: GenericEdge::ptrfunction_int_refbool GenericEdge::EdgeIs3D = NULL; GenericEdge::ptrfunction_int_int_double_int_refvector GenericEdge::EdgeReparamOnFace = NULL; -//------------------------------------------------------------------------ - -GenericEdge::GenericEdge(GModel *m, int num, int _native_id, GVertex *v1, GVertex *v2):GEdge(m, num, v1, v2), id(_native_id){ +GenericEdge::GenericEdge(GModel *m, int num, int _native_id, GVertex *v1, GVertex *v2) + : GEdge(m, num, v1, v2), id(_native_id) +{ if ((!EdgeEvalParBounds)||(!EdgeEvalXYZFromT)) Msg::Error("GenericEdge::ERROR: Callback not set"); bool ok = EdgeEvalParBounds(id,s0,s1); if (!ok) Msg::Error("GenericEdge::ERROR from EdgeEvalParBounds ! " ); } -//------------------------------------------------------------------------ - -GenericEdge::~GenericEdge(){ +GenericEdge::~GenericEdge() +{ } -//------------------------------------------------------------------------ - -Range<double> GenericEdge::parBounds(int i) const{ +Range<double> GenericEdge::parBounds(int i) const +{ return Range<double>(s0, s1); } -//------------------------------------------------------------------------ - -SPoint2 GenericEdge::reparamOnFace(const GFace *face, double par, int dir) const{ +SPoint2 GenericEdge::reparamOnFace(const GFace *face, double par, int dir) const +{ vector<double> res(2,0.); if (!EdgeReparamOnFace) Msg::Error("GenericEdge::ERROR: Callback EdgeReparamOnFace not set"); bool ok = EdgeReparamOnFace(id,face->getNativeInt(),par, dir,res); @@ -52,9 +47,8 @@ SPoint2 GenericEdge::reparamOnFace(const GFace *face, double par, int dir) const return SPoint2(res[0],res[1]);; } -//------------------------------------------------------------------------ - -GPoint GenericEdge::closestPoint(const SPoint3 &qp, double ¶m) const{ +GPoint GenericEdge::closestPoint(const SPoint3 &qp, double ¶m) const +{ vector<double> queryPoint(3,0.); for (int i=0;i<3;i++) queryPoint[i] = qp[i]; vector<double> res(3,0.); @@ -66,17 +60,15 @@ GPoint GenericEdge::closestPoint(const SPoint3 &qp, double ¶m) const{ return GPoint(res[0], res[1], res[2], this, param); } -//------------------------------------------------------------------------ - // True if the edge is a seam for the given face -bool GenericEdge::isSeam(const GFace *face) const{ +bool GenericEdge::isSeam(const GFace *face) const +{ Msg::Error("GenericEdge::isSeam: not implemented yet ! "); return false; } -//------------------------------------------------------------------------ - -GPoint GenericEdge::point(double par) const{ +GPoint GenericEdge::point(double par) const +{ vector<double> res(3,0.); if (!EdgeEvalXYZFromT) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalXYZFromT not set"); bool ok = EdgeEvalXYZFromT(id,par,res); @@ -84,9 +76,8 @@ GPoint GenericEdge::point(double par) const{ return GPoint(res[0], res[1], res[2], this, par); } -//------------------------------------------------------------------------ - -SVector3 GenericEdge::firstDer(double par) const{ +SVector3 GenericEdge::firstDer(double par) const +{ vector<double> res(3,0.); if (!EdgeEvalFirstDer) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalFirstDer not set"); bool ok = EdgeEvalFirstDer(id,par,res); @@ -94,9 +85,8 @@ SVector3 GenericEdge::firstDer(double par) const{ return SVector3(res[0],res[1],res[2]); } -//------------------------------------------------------------------------ - -GEntity::GeomType GenericEdge::geomType() const{ +GEntity::GeomType GenericEdge::geomType() const +{ string s; if (!EdgeGeomType) Msg::Error("GenericEdge::ERROR: Callback EdgeGeomType not set"); bool ok = EdgeGeomType(id,s); @@ -127,9 +117,8 @@ GEntity::GeomType GenericEdge::geomType() const{ return Unknown; } -//------------------------------------------------------------------------ - -double GenericEdge::curvature(double par) const{ +double GenericEdge::curvature(double par) const +{ double res; if (!EdgeEvalCurvature) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalCurvature not set"); bool ok = EdgeEvalCurvature(id,par,res); @@ -137,9 +126,8 @@ double GenericEdge::curvature(double par) const{ return res; } -//------------------------------------------------------------------------ - -bool GenericEdge::is3D() const{ +bool GenericEdge::is3D() const +{ bool res; if (!EdgeIs3D) Msg::Error("GenericEdge::ERROR: Callback EdgeIs3D not set"); bool ok = EdgeIs3D(id,res); @@ -147,16 +135,11 @@ bool GenericEdge::is3D() const{ return res; } -//------------------------------------------------------------------------ - -bool GenericEdge::degenerate(int) const{ +bool GenericEdge::degenerate(int) const +{ bool res; if (!EdgeDegenerated) Msg::Error("GenericEdge::ERROR: Callback EdgeDegenerated not set"); bool ok = EdgeDegenerated(id,res); if (!ok) Msg::Error("GenericEdge::ERROR from EdgeDegenerated ! " ); return res; } - -//------------------------------------------------------------------------ - - diff --git a/Geo/GenericEdge.h b/Geo/GenericEdge.h index cd29aadadb2ce4e99e7d298bc3d496c72aa96a30..ff453df8f9538713ef411693c9a993d51ff4a475 100644 --- a/Geo/GenericEdge.h +++ b/Geo/GenericEdge.h @@ -18,68 +18,67 @@ using namespace std; class GenericFace; /*The set of Generic Entities is a generic interface to any other modeler. - Callbacks (function pointers) are given, sending requests, enquiries, to the native modeler. */ + Callbacks (function pointers) are given, sending requests, enquiries, to the + native modeler. */ class GenericEdge : public GEdge { - protected: - double s0, s1; - int id; - public: - // callbacks typedef - typedef bool (*ptrfunction_int_double_refvector)(int, double, vector<double>&); - typedef bool (*ptrfunction_int_refdouble_refdouble)(int, double&, double&); - typedef bool (*ptrfunction_int_double_refdouble)(int, double, double&); - typedef bool (*ptrfunction_int_refstring)(int, string&); - typedef bool (*ptrfunction_int_refbool)(int, bool&); - typedef bool (*ptrfunction_int_refvector_refdouble_refvector_refbool)(int, const vector<double> &, double &, vector<double>&, bool &); - typedef bool (*ptrfunction_int_int_double_int_refvector)(int, int, double, int, vector<double> &); - - GenericEdge(GModel *model, int num,int _native_id, GVertex *v1, GVertex *v2); - virtual ~GenericEdge(); - - virtual Range<double> parBounds(int i) const; - virtual GeomType geomType() const; - virtual bool degenerate(int) const; - virtual GPoint point(double p) const; - virtual SVector3 firstDer(double par) const; - virtual double curvature (double par) const; - virtual SPoint2 reparamOnFace(const GFace *face, double epar, int dir) const; - virtual GPoint closestPoint(const SPoint3 &queryPoint, double ¶m) const; - - ModelType getNativeType() const { return GenericModel; } - virtual int getNativeInt()const{return id;}; - - bool is3D() const; - bool isSeam(const GFace *) const; - - // sets the callbacks, to be given by the user - static void setEdgeEvalXYZFromT(ptrfunction_int_double_refvector fct){EdgeEvalXYZFromT = fct;}; - static void setEdgeEvalParBounds(ptrfunction_int_refdouble_refdouble fct){EdgeEvalParBounds = fct;}; - static void setEdgeGeomType(ptrfunction_int_refstring fct){EdgeGeomType = fct;}; - static void setEdgeDegenerated(ptrfunction_int_refbool fct){EdgeDegenerated = fct;}; - static void setEdgeEvalFirstDer(ptrfunction_int_double_refvector fct){EdgeEvalFirstDer = fct;}; - static void setEdgeEvalCurvature(ptrfunction_int_double_refdouble fct){EdgeEvalCurvature = fct;}; - static void setEdgeClosestPoint(ptrfunction_int_refvector_refdouble_refvector_refbool fct){EdgeClosestPoint = fct;}; - static void setEdgeIs3D(ptrfunction_int_refbool fct){EdgeIs3D = fct;}; - static void setEdgeReparamOnFace(ptrfunction_int_int_double_int_refvector fct){EdgeReparamOnFace = fct;}; - - private: - // the callbacks: - // -------------- - static ptrfunction_int_double_refvector EdgeEvalXYZFromT; - static ptrfunction_int_refdouble_refdouble EdgeEvalParBounds; - static ptrfunction_int_refstring EdgeGeomType; - static ptrfunction_int_refbool EdgeDegenerated; - static ptrfunction_int_double_refvector EdgeEvalFirstDer; - static ptrfunction_int_double_refdouble EdgeEvalCurvature; - // the first vector is a query point xyz, fills the second vector with closest point - // on edge using orthogonal projection. Fills double param with parametric coordinate of end point projection. - static ptrfunction_int_refvector_refdouble_refvector_refbool EdgeClosestPoint; - static ptrfunction_int_refbool EdgeIs3D; - static ptrfunction_int_int_double_int_refvector EdgeReparamOnFace; - - + protected: + double s0, s1; + int id; + public: + // callbacks typedef + typedef bool (*ptrfunction_int_double_refvector)(int, double, vector<double>&); + typedef bool (*ptrfunction_int_refdouble_refdouble)(int, double&, double&); + typedef bool (*ptrfunction_int_double_refdouble)(int, double, double&); + typedef bool (*ptrfunction_int_refstring)(int, string&); + typedef bool (*ptrfunction_int_refbool)(int, bool&); + typedef bool (*ptrfunction_int_refvector_refdouble_refvector_refbool) + (int, const vector<double> &, double &, vector<double>&, bool &); + typedef bool (*ptrfunction_int_int_double_int_refvector)(int, int, double, int, vector<double> &); + + GenericEdge(GModel *model, int num,int _native_id, GVertex *v1, GVertex *v2); + virtual ~GenericEdge(); + + virtual Range<double> parBounds(int i) const; + virtual GeomType geomType() const; + virtual bool degenerate(int) const; + virtual GPoint point(double p) const; + virtual SVector3 firstDer(double par) const; + virtual double curvature (double par) const; + virtual SPoint2 reparamOnFace(const GFace *face, double epar, int dir) const; + virtual GPoint closestPoint(const SPoint3 &queryPoint, double ¶m) const; + + ModelType getNativeType() const { return GenericModel; } + virtual int getNativeInt()const{return id;}; + + bool is3D() const; + bool isSeam(const GFace *) const; + + // sets the callbacks, to be given by the user + static void setEdgeEvalXYZFromT(ptrfunction_int_double_refvector fct){EdgeEvalXYZFromT = fct;}; + static void setEdgeEvalParBounds(ptrfunction_int_refdouble_refdouble fct){EdgeEvalParBounds = fct;}; + static void setEdgeGeomType(ptrfunction_int_refstring fct){EdgeGeomType = fct;}; + static void setEdgeDegenerated(ptrfunction_int_refbool fct){EdgeDegenerated = fct;}; + static void setEdgeEvalFirstDer(ptrfunction_int_double_refvector fct){EdgeEvalFirstDer = fct;}; + static void setEdgeEvalCurvature(ptrfunction_int_double_refdouble fct){EdgeEvalCurvature = fct;}; + static void setEdgeClosestPoint(ptrfunction_int_refvector_refdouble_refvector_refbool fct){EdgeClosestPoint = fct;}; + static void setEdgeIs3D(ptrfunction_int_refbool fct){EdgeIs3D = fct;}; + static void setEdgeReparamOnFace(ptrfunction_int_int_double_int_refvector fct){EdgeReparamOnFace = fct;}; + + private: + // the callbacks: + static ptrfunction_int_double_refvector EdgeEvalXYZFromT; + static ptrfunction_int_refdouble_refdouble EdgeEvalParBounds; + static ptrfunction_int_refstring EdgeGeomType; + static ptrfunction_int_refbool EdgeDegenerated; + static ptrfunction_int_double_refvector EdgeEvalFirstDer; + static ptrfunction_int_double_refdouble EdgeEvalCurvature; + // the first vector is a query point xyz, fills the second vector with closest + // point on edge using orthogonal projection. Fills double param with + // parametric coordinate of end point projection. + static ptrfunction_int_refvector_refdouble_refvector_refbool EdgeClosestPoint; + static ptrfunction_int_refbool EdgeIs3D; + static ptrfunction_int_int_double_int_refvector EdgeReparamOnFace; }; - #endif diff --git a/Geo/GenericFace.cpp b/Geo/GenericFace.cpp index 3046436973158c188c6fea287e1e076e63347f51..6ab96b4e20024627971da79a17b10058c30fb4b8 100644 --- a/Geo/GenericFace.cpp +++ b/Geo/GenericFace.cpp @@ -14,9 +14,6 @@ #include "Context.h" #include <math.h> - -//------------------------------------------------------------------------ - GenericFace::ptrfunction_int_refstring GenericFace::FaceGeomType = NULL; GenericFace::ptrfunction_int_refvector_refvector GenericFace::FaceUVFromXYZ = NULL; GenericFace::ptrfunction_int_refvector_refvector_refvector GenericFace::FaceClosestPoint = NULL; @@ -29,9 +26,8 @@ GenericFace::ptrfunction_int_refvector_refvector GenericFace::FaceEvalNormal = N GenericFace::ptrfunction_int_refvector_refvector_refvector GenericFace::FaceFirstDer = NULL; GenericFace::ptrfunction_int_refvector_refvector_refvector_refvector GenericFace::FaceSecondDer = NULL; -//------------------------------------------------------------------------ - -GenericFace::GenericFace(GModel *m, int num, int _native_id):GFace(m, num), id(_native_id){ +GenericFace::GenericFace(GModel *m, int num, int _native_id):GFace(m, num), id(_native_id) +{ if (!FaceParBounds) Msg::Fatal("Genericface::ERROR: Callback FaceParBounds not set"); Range<double> rangeu = parBounds(0); Range<double> rangev = parBounds(1); @@ -39,58 +35,53 @@ GenericFace::GenericFace(GModel *m, int num, int _native_id):GFace(m, num), id(_ umax = rangeu.high(); vmin = rangev.low(); vmax = rangev.high(); - + // TODO: set periodic or not !!! //bool _periodic[2];// is periodic in u, v -// throw; + // throw; } -//------------------------------------------------------------------------ - -GenericFace::~GenericFace(){ +GenericFace::~GenericFace() +{ } -//------------------------------------------------------------------------ - -Range<double> GenericFace::parBounds(int i) const{ +Range<double> GenericFace::parBounds(int i) const +{ if(i == 0) return Range<double>(umin, umax); return Range<double>(vmin, vmax); } -//------------------------------------------------------------------------ - -SVector3 GenericFace::normal(const SPoint2 ¶m) const{ +SVector3 GenericFace::normal(const SPoint2 ¶m) const +{ vector<double> res(3,0.); vector<double> par(2,0.); - for (int i=0;i<3;i++) par[i] = param[i]; + for (int i=0;i<2;i++) par[i] = param[i]; if (!FaceEvalNormal) Msg::Fatal("Genericface::ERROR: Callback FaceEvalNormal not set"); bool ok = FaceEvalNormal(id,par,res); if (!ok) Msg::Error("GenericFace::ERROR from FaceEvalNormal ! " ); return SVector3(res[0],res[1],res[2]); } -//------------------------------------------------------------------------ - -Pair<SVector3,SVector3> GenericFace::firstDer(const SPoint2 ¶m) const{ +Pair<SVector3,SVector3> GenericFace::firstDer(const SPoint2 ¶m) const +{ if (!FaceFirstDer) Msg::Fatal("Genericface::ERROR: Callback FaceFirstDer not set"); vector<double> deru(3,0.); vector<double> derv(3,0.); vector<double> par(2,0.); - for (int i=0;i<3;i++) par[i] = param[i]; + for (int i=0;i<2;i++) par[i] = param[i]; bool ok = FaceFirstDer(id,par,deru,derv); if (!ok) Msg::Error("GenericFace::ERROR from FaceFirstDer ! " ); return Pair<SVector3,SVector3>(SVector3(deru[0],deru[1],deru[2]), SVector3(derv[0],derv[1],derv[2])); } -//------------------------------------------------------------------------ - -void GenericFace::secondDer(const SPoint2 ¶m,SVector3 *dudu, SVector3 *dvdv, SVector3 *dudv) const{ +void GenericFace::secondDer(const SPoint2 ¶m,SVector3 *dudu, SVector3 *dvdv, SVector3 *dudv) const +{ vector<double> deruu(3,0.); vector<double> dervv(3,0.); vector<double> deruv(3,0.); vector<double> par(2,0.); - for (int i=0;i<3;i++) par[i] = param[i]; + for (int i=0;i<2;i++) par[i] = param[i]; if (!FaceSecondDer) Msg::Fatal("Genericface::ERROR: Callback FaceSecondDer not set"); bool ok = FaceSecondDer(id,par,deruu,dervv,deruv); if (!ok) Msg::Error("GenericFace::ERROR from FaceSecondDer ! " ); @@ -100,9 +91,8 @@ void GenericFace::secondDer(const SPoint2 ¶m,SVector3 *dudu, SVector3 *dvdv, return; } -//------------------------------------------------------------------------ - -GPoint GenericFace::point(double par1, double par2) const{ +GPoint GenericFace::point(double par1, double par2) const +{ vector<double> uv(2,0.); uv[0] = par1; uv[1] = par2; @@ -114,9 +104,8 @@ GPoint GenericFace::point(double par1, double par2) const{ return GPoint(xyz[0], xyz[1], xyz[2], this, pp); } -//------------------------------------------------------------------------ - -GPoint GenericFace::closestPoint(const SPoint3 &qp, const double initialGuess[2]) const{ +GPoint GenericFace::closestPoint(const SPoint3 &qp, const double initialGuess[2]) const +{ vector<double> uvres(2,0.); vector<double> xyzres(3,0.); vector<double> queryPoint(3,0.); @@ -140,9 +129,8 @@ GPoint GenericFace::closestPoint(const SPoint3 &qp, const double initialGuess[2] return GPoint(xyzres[0], xyzres[1], xyzres[2], this, pp); } -//------------------------------------------------------------------------ - -SPoint2 GenericFace::parFromPoint(const SPoint3 &qp, bool onSurface) const{ +SPoint2 GenericFace::parFromPoint(const SPoint3 &qp, bool onSurface) const +{ vector<double> uvres(2,0.); vector<double> xyzres(3,0.); vector<double> queryPoint(3,0.); @@ -150,7 +138,7 @@ SPoint2 GenericFace::parFromPoint(const SPoint3 &qp, bool onSurface) const{ bool ok=true; if (onSurface){ if (!FaceUVFromXYZ) Msg::Fatal("Genericface::ERROR: Callback FaceUVFromXYZ not set"); - ok = FaceUVFromXYZ(id,queryPoint,uvres);// assuming point is on surface + ok = FaceUVFromXYZ(id,queryPoint,uvres);// assuming point is on surface if (!ok) Msg::Error("GenericFace::ERROR from FaceUVFromXYZ ! " ); } if ((!onSurface)||(!ok)){// if not on surface @@ -166,9 +154,8 @@ SPoint2 GenericFace::parFromPoint(const SPoint3 &qp, bool onSurface) const{ return SPoint2(uvres[0],uvres[1]); } -//------------------------------------------------------------------------ - -GEntity::GeomType GenericFace::geomType() const{ +GEntity::GeomType GenericFace::geomType() const +{ string s; if (!FaceGeomType) Msg::Fatal("Genericface::ERROR: Callback FaceGeomType not set"); bool ok = FaceGeomType(id,s); @@ -197,40 +184,38 @@ GEntity::GeomType GenericFace::geomType() const{ return Unknown; } -//------------------------------------------------------------------------ - -double GenericFace::curvatureMax(const SPoint2 ¶m) const{ +double GenericFace::curvatureMax(const SPoint2 ¶m) const +{ vector<double> dirMax(3,0.); vector<double> dirMin(3,0.); double curvMax,curvMin; vector<double> par(2,0.); - for (int i=0;i<3;i++) par[i] = param[i]; + for (int i=0;i<2;i++) par[i] = param[i]; if (!FaceCurvatures) Msg::Fatal("Genericface::ERROR: Callback FaceCurvatures not set"); bool ok = FaceCurvatures(id,par,dirMax,dirMin,curvMax,curvMin); if (!ok) Msg::Error("GenericFace::ERROR from FaceCurvatures ! " ); return std::max(fabs(curvMax), fabs(curvMin)); } -//------------------------------------------------------------------------ - -double GenericFace::curvatures(const SPoint2 &_param,SVector3 *_dirMax,SVector3 *_dirMin,double *curvMax,double *curvMin) const{ +double GenericFace::curvatures(const SPoint2 &_param,SVector3 *_dirMax,SVector3 *_dirMin, + double *curvMax,double *curvMin) const +{ vector<double> param(2,0.); - for (int i=0;i<3;i++) param[i] = _param[i]; + for (int i=0;i<2;i++) param[i] = _param[i]; vector<double> dirMax(3,0.); vector<double> dirMin(3,0.); if (!FaceCurvatures) Msg::Fatal("Genericface::ERROR: Callback FaceCurvatures not set"); bool ok = FaceCurvatures(id,param,dirMax,dirMin,*curvMax,*curvMin); if (!ok) Msg::Error("GenericFace::ERROR from FaceCurvatures ! " ); - + *_dirMax = SVector3(dirMax[0],dirMax[1],dirMax[2]); *_dirMin = SVector3(dirMin[0],dirMin[1],dirMin[2]); return *curvMax; } -//------------------------------------------------------------------------ - -bool GenericFace::containsPoint(const SPoint3 &pt) const{ +bool GenericFace::containsPoint(const SPoint3 &pt) const +{ bool res; vector<double> queryPoint(3,0.); for (int i=0;i<3;i++) queryPoint[i] = pt[i]; @@ -240,5 +225,3 @@ bool GenericFace::containsPoint(const SPoint3 &pt) const{ return res; } -//------------------------------------------------------------------------ - diff --git a/Geo/GenericFace.h b/Geo/GenericFace.h index 76c5e55de9c997c209c1b3764812ffb0f0f1db04..de7069ca43c07392e37729ca308b23c993966ab9 100644 --- a/Geo/GenericFace.h +++ b/Geo/GenericFace.h @@ -16,77 +16,80 @@ using namespace std; -/*The set of Generic Entities is a generic interface to any other modeler. - Callbacks (function pointers) are given, sending requests, enquiries, to the native modeler. */ +/* The set of Generic Entities is a generic interface to any other modeler. + Callbacks (function pointers) are given, sending requests, enquiries, to the + native modeler. */ class GenericFace : public GFace { - protected: - int id; - double umin, umax, vmin, vmax;// face uv bounds - bool _periodic[2];// is periodic in u, v + protected: + int id; + double umin, umax, vmin, vmax;// face uv bounds + bool _periodic[2];// is periodic in u, v public: - // callbacks typedef - typedef bool (*ptrfunction_int_refstring)(int, string&); - typedef bool (*ptrfunction_int_refvector_refvector)(const int , const vector<double> &, vector<double> &); - typedef bool (*ptrfunction_int_refvector_refvector_refvector)(const int , const vector<double> &, vector<double> &, vector<double> &); - typedef bool (*ptrfunction_int_refvector_refbool)(const int , const vector<double> &, bool &); - typedef bool (*ptrfunction_int_int_refdouble_refdouble)(const int, const int, double &, double &); - typedef bool (*ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble)(const int, const vector<double> &, vector<double> &, vector<double> &, double &, double &); - typedef bool (*ptrfunction_int_refvector_refvector_refvector_refvector)(const int , const vector<double> &, vector<double> &, vector<double> &, vector<double> &); + // callbacks typedef + typedef bool (*ptrfunction_int_refstring)(int, string&); + typedef bool (*ptrfunction_int_refvector_refvector)(const int , const vector<double> &, vector<double> &); + typedef bool (*ptrfunction_int_refvector_refvector_refvector) + (const int , const vector<double> &, vector<double> &, vector<double> &); + typedef bool (*ptrfunction_int_refvector_refbool)(const int , const vector<double> &, bool &); + typedef bool (*ptrfunction_int_int_refdouble_refdouble)(const int, const int, double &, double &); + typedef bool (*ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble) + (const int, const vector<double> &, vector<double> &, vector<double> &, double &, double &); + typedef bool (*ptrfunction_int_refvector_refvector_refvector_refvector) + (const int , const vector<double> &, vector<double> &, vector<double> &, vector<double> &); - GenericFace(GModel *m, int num, int _native_id); - virtual ~GenericFace(); + GenericFace(GModel *m, int num, int _native_id); + virtual ~GenericFace(); - Range<double> parBounds(int i) const; - virtual GPoint point(double par1, double par2) const; - virtual GPoint closestPoint(const SPoint3 & queryPoint, - const double initialGuess[2]) const; - virtual bool containsPoint(const SPoint3 &pt) const; - virtual SVector3 normal(const SPoint2 ¶m) const; - virtual Pair<SVector3,SVector3> firstDer(const SPoint2 ¶m) const; - virtual void secondDer(const SPoint2 &, SVector3 *, SVector3 *, SVector3 *) const; - virtual GEntity::GeomType geomType() const; - virtual SPoint2 parFromPoint(const SPoint3 &, bool onSurface=true) const; - virtual double curvatureMax(const SPoint2 ¶m) const; - virtual double curvatures(const SPoint2 ¶m, SVector3 *dirMax, SVector3 *dirMin, - double *curvMax, double *curvMin) const; + Range<double> parBounds(int i) const; + virtual GPoint point(double par1, double par2) const; + virtual GPoint closestPoint(const SPoint3 & queryPoint, + const double initialGuess[2]) const; + virtual bool containsPoint(const SPoint3 &pt) const; + virtual SVector3 normal(const SPoint2 ¶m) const; + virtual Pair<SVector3,SVector3> firstDer(const SPoint2 ¶m) const; + virtual void secondDer(const SPoint2 &, SVector3 *, SVector3 *, SVector3 *) const; + virtual GEntity::GeomType geomType() const; + virtual SPoint2 parFromPoint(const SPoint3 &, bool onSurface=true) const; + virtual double curvatureMax(const SPoint2 ¶m) const; + virtual double curvatures(const SPoint2 ¶m, SVector3 *dirMax, SVector3 *dirMin, + double *curvMax, double *curvMin) const; - ModelType getNativeType() const { return GenericModel; } - virtual int getNativeInt()const{return id;}; - - void addBndInfo(int loop, GEdge *ptr, int sign){ - bnd.insert(make_pair(loop, make_pair(ptr,sign))); - l_dirs.push_back(sign); - l_edges.push_back(ptr); - ptr->addFace(this); - }; - - // sets callbacks - static void setFaceGeomType(ptrfunction_int_refstring fct){FaceGeomType = fct;}; - static void setFaceUVFromXYZ(ptrfunction_int_refvector_refvector fct){FaceUVFromXYZ = fct;}; - static void setFaceClosestPoint(ptrfunction_int_refvector_refvector_refvector fct){FaceClosestPoint = fct;}; - static void setFaceContainsPointFromXYZ(ptrfunction_int_refvector_refbool fct){FaceContainsPointFromXYZ = fct;}; - static void setFaceContainsPointFromUV(ptrfunction_int_refvector_refbool fct){FaceContainsPointFromUV = fct;}; - static void setFaceXYZFromUV(ptrfunction_int_refvector_refvector fct){FaceXYZFromUV = fct;}; - static void setFaceParBounds(ptrfunction_int_int_refdouble_refdouble fct){FaceParBounds = fct;}; - static void setFaceCurvatures(ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble fct){FaceCurvatures = fct;}; - static void setFaceEvalNormal(ptrfunction_int_refvector_refvector fct){FaceEvalNormal = fct;}; - static void setFaceFirstDer(ptrfunction_int_refvector_refvector_refvector fct){FaceFirstDer = fct;}; - static void setFaceSecondDer(ptrfunction_int_refvector_refvector_refvector_refvector fct){FaceSecondDer = fct;}; - - private: - multimap<int, pair<GEdge*,int> > bnd; + ModelType getNativeType() const { return GenericModel; } + virtual int getNativeInt()const{return id;}; - // the callbacks: - static ptrfunction_int_refstring FaceGeomType; - static ptrfunction_int_refvector_refvector FaceUVFromXYZ,FaceXYZFromUV,FaceEvalNormal; - static ptrfunction_int_refvector_refvector_refvector FaceClosestPoint,FaceFirstDer; - static ptrfunction_int_refvector_refbool FaceContainsPointFromXYZ,FaceContainsPointFromUV; - static ptrfunction_int_int_refdouble_refdouble FaceParBounds; - static ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble FaceCurvatures; - static ptrfunction_int_refvector_refvector_refvector_refvector FaceSecondDer; + void addBndInfo(int loop, GEdge *ptr, int sign){ + bnd.insert(make_pair(loop, make_pair(ptr,sign))); + l_dirs.push_back(sign); + l_edges.push_back(ptr); + ptr->addFace(this); + }; + // sets callbacks + static void setFaceGeomType(ptrfunction_int_refstring fct){FaceGeomType = fct;}; + static void setFaceUVFromXYZ(ptrfunction_int_refvector_refvector fct){FaceUVFromXYZ = fct;}; + static void setFaceClosestPoint(ptrfunction_int_refvector_refvector_refvector fct){FaceClosestPoint = fct;}; + static void setFaceContainsPointFromXYZ(ptrfunction_int_refvector_refbool fct){FaceContainsPointFromXYZ = fct;}; + static void setFaceContainsPointFromUV(ptrfunction_int_refvector_refbool fct){FaceContainsPointFromUV = fct;}; + static void setFaceXYZFromUV(ptrfunction_int_refvector_refvector fct){FaceXYZFromUV = fct;}; + static void setFaceParBounds(ptrfunction_int_int_refdouble_refdouble fct){FaceParBounds = fct;}; + static void setFaceCurvatures(ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble fct){FaceCurvatures = fct;}; + static void setFaceEvalNormal(ptrfunction_int_refvector_refvector fct){FaceEvalNormal = fct;}; + static void setFaceFirstDer(ptrfunction_int_refvector_refvector_refvector fct){FaceFirstDer = fct;}; + static void setFaceSecondDer(ptrfunction_int_refvector_refvector_refvector_refvector fct){FaceSecondDer = fct;}; + +private: + multimap<int, pair<GEdge*,int> > bnd; + + // the callbacks: + static ptrfunction_int_refstring FaceGeomType; + static ptrfunction_int_refvector_refvector FaceUVFromXYZ,FaceXYZFromUV,FaceEvalNormal; + static ptrfunction_int_refvector_refvector_refvector FaceClosestPoint,FaceFirstDer; + static ptrfunction_int_refvector_refbool FaceContainsPointFromXYZ,FaceContainsPointFromUV; + static ptrfunction_int_int_refdouble_refdouble FaceParBounds; + static ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble FaceCurvatures; + static ptrfunction_int_refvector_refvector_refvector_refvector FaceSecondDer; }; #endif diff --git a/Geo/GenericRegion.cpp b/Geo/GenericRegion.cpp index a6b8f1a408777c553d70eddad8ebeb541a48d391..1df74a6007d4374b640e8350dfa2a4d23a0ad101 100644 --- a/Geo/GenericRegion.cpp +++ b/Geo/GenericRegion.cpp @@ -11,24 +11,15 @@ #include "GenericFace.h" #include "GenericRegion.h" -//------------------------------------------------------------------------ - GenericRegion::GenericRegion(GModel *m, int num, int _native_id):GRegion(m, num), id(_native_id) { } -//------------------------------------------------------------------------ - GenericRegion::~GenericRegion() { } -//------------------------------------------------------------------------ - GEntity::GeomType GenericRegion::geomType() const { return Unknown; } - -//------------------------------------------------------------------------ - diff --git a/Geo/GenericRegion.h b/Geo/GenericRegion.h index 74850cc8b2e7cb3535f48a167b283391adc97e48..3bc3141645fb2045ee85e233f066b3f390cc6f20 100644 --- a/Geo/GenericRegion.h +++ b/Geo/GenericRegion.h @@ -10,28 +10,30 @@ #include "GRegion.h" /*The set of Generic Entities is a generic interface to any other modeler. - Callbacks (function pointers) are given, sending requests, enquiries, to the native modeler. */ + Callbacks (function pointers) are given, sending requests, enquiries, to the + native modeler. */ class GenericRegion : public GRegion { - public: - GenericRegion(GModel *m, int num, int _native_id); - virtual ~GenericRegion(); - - virtual GeomType geomType() const; - - ModelType getNativeType() const { return GenericModel; } - virtual int getNativeInt()const{return id;}; - - // TODO: When using GRegion->l_dirs and l_faces, what is the convention for l_dirs ? For now, assuming positive value for normals pointing inside the region. - void addFace(GenericFace *ptr, int sign){ - l_dirs.push_back(sign); - l_faces.push_back(ptr); - ptr->addRegion(this); - }; - - - private: - int id; + public: + GenericRegion(GModel *m, int num, int _native_id); + virtual ~GenericRegion(); + + virtual GeomType geomType() const; + + ModelType getNativeType() const { return GenericModel; } + virtual int getNativeInt()const{return id;}; + + // TODO: When using GRegion->l_dirs and l_faces, what is the convention for + // l_dirs ? For now, assuming positive value for normals pointing inside the + // region. + void addFace(GenericFace *ptr, int sign){ + l_dirs.push_back(sign); + l_faces.push_back(ptr); + ptr->addRegion(this); + }; + + private: + int id; }; #endif diff --git a/Geo/GenericVertex.cpp b/Geo/GenericVertex.cpp index a80e787cf8c51a8eb43d9c8e14ae6b87b1d546de..80440972be32e2b8a9467fa786f730c166165edd 100644 --- a/Geo/GenericVertex.cpp +++ b/Geo/GenericVertex.cpp @@ -12,13 +12,10 @@ #include "GenericFace.h" #include<algorithm> -//------------------------------------------------------------------------ - GenericVertex::ptrfunction_int_vector GenericVertex::VertexXYZ = NULL; -//------------------------------------------------------------------------ - -GenericVertex::GenericVertex(GModel *m, int num, int _native_id):GVertex(m, num), id(_native_id){ +GenericVertex::GenericVertex(GModel *m, int num, int _native_id):GVertex(m, num), id(_native_id) +{ if (!VertexXYZ) Msg::Fatal("GenericVertex::ERROR: Callback not set"); @@ -30,13 +27,10 @@ GenericVertex::GenericVertex(GModel *m, int num, int _native_id):GVertex(m, num) _z=vec[2]; } -//------------------------------------------------------------------------ - -GenericVertex::~GenericVertex(){ +GenericVertex::~GenericVertex() +{ } -//------------------------------------------------------------------------ - SPoint2 GenericVertex::reparamOnFace(const GFace *gf, int dir) const { std::list<GEdge*>::const_iterator it = l_edges.begin(); @@ -75,8 +69,6 @@ SPoint2 GenericVertex::reparamOnFace(const GFace *gf, int dir) const return GVertex::reparamOnFace(gf, dir); } -//------------------------------------------------------------------------ - void GenericVertex::setPosition(GPoint &p) { _x = p.x(); @@ -88,5 +80,3 @@ void GenericVertex::setPosition(GPoint &p) mesh_vertices[0]->z() = p.z(); } } - -//------------------------------------------------------------------------ diff --git a/Geo/GenericVertex.h b/Geo/GenericVertex.h index fb34abceb81105f35f8a38d9512952738044547c..e9010b457bdab07ed37a479eb1fbbf6b813d5549 100644 --- a/Geo/GenericVertex.h +++ b/Geo/GenericVertex.h @@ -13,39 +13,39 @@ using namespace std; -/*The set of Generic Entities is a generic interface to any other modeler. - Callbacks (function pointers) are given, sending requests, enquiries, to the native modeler. */ +/* The set of Generic Entities is a generic interface to any other modeler. + Callbacks (function pointers) are given, sending requests, enquiries, to the + native modeler. */ class GenericVertex : public GVertex { - protected: - int id; - double _x, _y, _z; - public: - // callbacks typedef - typedef bool (*ptrfunction_int_vector)(int, vector<double>&); - - GenericVertex(GModel *m, int num, int _native_id); - virtual ~GenericVertex(); - - virtual GPoint point() const { return GPoint(x(), y(), z()); } - virtual double x() const { return _x; } - virtual double y() const { return _y; } - virtual double z() const { return _z; } - - virtual void setPosition(GPoint &p); - virtual SPoint2 reparamOnFace(const GFace *gf, int) const; - - ModelType getNativeType() const { return GenericModel; } - virtual int getNativeInt()const{return id;}; - - // sets the callbacks - static void setVertexXYZ(ptrfunction_int_vector fct){VertexXYZ = fct;}; - - private: - // the callbacks: - // -------------- - // fills vector xyz for vertex of int id - static ptrfunction_int_vector VertexXYZ; + protected: + int id; + double _x, _y, _z; + public: + // callbacks typedef + typedef bool (*ptrfunction_int_vector)(int, vector<double>&); + + GenericVertex(GModel *m, int num, int _native_id); + virtual ~GenericVertex(); + + virtual GPoint point() const { return GPoint(x(), y(), z()); } + virtual double x() const { return _x; } + virtual double y() const { return _y; } + virtual double z() const { return _z; } + + virtual void setPosition(GPoint &p); + virtual SPoint2 reparamOnFace(const GFace *gf, int) const; + + ModelType getNativeType() const { return GenericModel; } + virtual int getNativeInt()const{return id;}; + + // sets the callbacks + static void setVertexXYZ(ptrfunction_int_vector fct){VertexXYZ = fct;}; + +private: + // the callbacks: + // fills vector xyz for vertex of int id + static ptrfunction_int_vector VertexXYZ; }; #endif