Skip to content
Snippets Groups Projects
Commit ea74526f authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix out of bound access

parent 030e50f4
No related branches found
No related tags found
No related merge requests found
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "GenericFace.h" #include "GenericFace.h"
#include "Context.h" #include "Context.h"
//------------------------------------------------------------------------
GenericEdge::ptrfunction_int_double_refvector GenericEdge::EdgeEvalXYZFromT = NULL; GenericEdge::ptrfunction_int_double_refvector GenericEdge::EdgeEvalXYZFromT = NULL;
GenericEdge::ptrfunction_int_refdouble_refdouble GenericEdge::EdgeEvalParBounds = NULL; GenericEdge::ptrfunction_int_refdouble_refdouble GenericEdge::EdgeEvalParBounds = NULL;
GenericEdge::ptrfunction_int_refstring GenericEdge::EdgeGeomType = NULL; GenericEdge::ptrfunction_int_refstring GenericEdge::EdgeGeomType = NULL;
...@@ -23,28 +21,25 @@ GenericEdge::ptrfunction_int_refvector_refdouble_refvector_refbool GenericEdge:: ...@@ -23,28 +21,25 @@ GenericEdge::ptrfunction_int_refvector_refdouble_refvector_refbool GenericEdge::
GenericEdge::ptrfunction_int_refbool GenericEdge::EdgeIs3D = NULL; GenericEdge::ptrfunction_int_refbool GenericEdge::EdgeIs3D = NULL;
GenericEdge::ptrfunction_int_int_double_int_refvector GenericEdge::EdgeReparamOnFace = 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"); if ((!EdgeEvalParBounds)||(!EdgeEvalXYZFromT)) Msg::Error("GenericEdge::ERROR: Callback not set");
bool ok = EdgeEvalParBounds(id,s0,s1); bool ok = EdgeEvalParBounds(id,s0,s1);
if (!ok) Msg::Error("GenericEdge::ERROR from EdgeEvalParBounds ! " ); 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); 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.); vector<double> res(2,0.);
if (!EdgeReparamOnFace) Msg::Error("GenericEdge::ERROR: Callback EdgeReparamOnFace not set"); if (!EdgeReparamOnFace) Msg::Error("GenericEdge::ERROR: Callback EdgeReparamOnFace not set");
bool ok = EdgeReparamOnFace(id,face->getNativeInt(),par, dir,res); bool ok = EdgeReparamOnFace(id,face->getNativeInt(),par, dir,res);
...@@ -52,9 +47,8 @@ SPoint2 GenericEdge::reparamOnFace(const GFace *face, double par, int dir) const ...@@ -52,9 +47,8 @@ SPoint2 GenericEdge::reparamOnFace(const GFace *face, double par, int dir) const
return SPoint2(res[0],res[1]);; return SPoint2(res[0],res[1]);;
} }
//------------------------------------------------------------------------ GPoint GenericEdge::closestPoint(const SPoint3 &qp, double &param) const
{
GPoint GenericEdge::closestPoint(const SPoint3 &qp, double &param) const{
vector<double> queryPoint(3,0.); vector<double> queryPoint(3,0.);
for (int i=0;i<3;i++) queryPoint[i] = qp[i]; for (int i=0;i<3;i++) queryPoint[i] = qp[i];
vector<double> res(3,0.); vector<double> res(3,0.);
...@@ -66,17 +60,15 @@ GPoint GenericEdge::closestPoint(const SPoint3 &qp, double &param) const{ ...@@ -66,17 +60,15 @@ GPoint GenericEdge::closestPoint(const SPoint3 &qp, double &param) const{
return GPoint(res[0], res[1], res[2], this, param); return GPoint(res[0], res[1], res[2], this, param);
} }
//------------------------------------------------------------------------
// True if the edge is a seam for the given face // 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 ! "); Msg::Error("GenericEdge::isSeam: not implemented yet ! ");
return false; return false;
} }
//------------------------------------------------------------------------ GPoint GenericEdge::point(double par) const
{
GPoint GenericEdge::point(double par) const{
vector<double> res(3,0.); vector<double> res(3,0.);
if (!EdgeEvalXYZFromT) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalXYZFromT not set"); if (!EdgeEvalXYZFromT) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalXYZFromT not set");
bool ok = EdgeEvalXYZFromT(id,par,res); bool ok = EdgeEvalXYZFromT(id,par,res);
...@@ -84,9 +76,8 @@ GPoint GenericEdge::point(double par) const{ ...@@ -84,9 +76,8 @@ GPoint GenericEdge::point(double par) const{
return GPoint(res[0], res[1], res[2], this, par); 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.); vector<double> res(3,0.);
if (!EdgeEvalFirstDer) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalFirstDer not set"); if (!EdgeEvalFirstDer) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalFirstDer not set");
bool ok = EdgeEvalFirstDer(id,par,res); bool ok = EdgeEvalFirstDer(id,par,res);
...@@ -94,9 +85,8 @@ SVector3 GenericEdge::firstDer(double par) const{ ...@@ -94,9 +85,8 @@ SVector3 GenericEdge::firstDer(double par) const{
return SVector3(res[0],res[1],res[2]); return SVector3(res[0],res[1],res[2]);
} }
//------------------------------------------------------------------------ GEntity::GeomType GenericEdge::geomType() const
{
GEntity::GeomType GenericEdge::geomType() const{
string s; string s;
if (!EdgeGeomType) Msg::Error("GenericEdge::ERROR: Callback EdgeGeomType not set"); if (!EdgeGeomType) Msg::Error("GenericEdge::ERROR: Callback EdgeGeomType not set");
bool ok = EdgeGeomType(id,s); bool ok = EdgeGeomType(id,s);
...@@ -127,9 +117,8 @@ GEntity::GeomType GenericEdge::geomType() const{ ...@@ -127,9 +117,8 @@ GEntity::GeomType GenericEdge::geomType() const{
return Unknown; return Unknown;
} }
//------------------------------------------------------------------------ double GenericEdge::curvature(double par) const
{
double GenericEdge::curvature(double par) const{
double res; double res;
if (!EdgeEvalCurvature) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalCurvature not set"); if (!EdgeEvalCurvature) Msg::Error("GenericEdge::ERROR: Callback EdgeEvalCurvature not set");
bool ok = EdgeEvalCurvature(id,par,res); bool ok = EdgeEvalCurvature(id,par,res);
...@@ -137,9 +126,8 @@ double GenericEdge::curvature(double par) const{ ...@@ -137,9 +126,8 @@ double GenericEdge::curvature(double par) const{
return res; return res;
} }
//------------------------------------------------------------------------ bool GenericEdge::is3D() const
{
bool GenericEdge::is3D() const{
bool res; bool res;
if (!EdgeIs3D) Msg::Error("GenericEdge::ERROR: Callback EdgeIs3D not set"); if (!EdgeIs3D) Msg::Error("GenericEdge::ERROR: Callback EdgeIs3D not set");
bool ok = EdgeIs3D(id,res); bool ok = EdgeIs3D(id,res);
...@@ -147,16 +135,11 @@ bool GenericEdge::is3D() const{ ...@@ -147,16 +135,11 @@ bool GenericEdge::is3D() const{
return res; return res;
} }
//------------------------------------------------------------------------ bool GenericEdge::degenerate(int) const
{
bool GenericEdge::degenerate(int) const{
bool res; bool res;
if (!EdgeDegenerated) Msg::Error("GenericEdge::ERROR: Callback EdgeDegenerated not set"); if (!EdgeDegenerated) Msg::Error("GenericEdge::ERROR: Callback EdgeDegenerated not set");
bool ok = EdgeDegenerated(id,res); bool ok = EdgeDegenerated(id,res);
if (!ok) Msg::Error("GenericEdge::ERROR from EdgeDegenerated ! " ); if (!ok) Msg::Error("GenericEdge::ERROR from EdgeDegenerated ! " );
return res; return res;
} }
//------------------------------------------------------------------------
...@@ -18,7 +18,8 @@ using namespace std; ...@@ -18,7 +18,8 @@ using namespace std;
class GenericFace; class GenericFace;
/*The set of Generic Entities is a generic interface to any other 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. */ Callbacks (function pointers) are given, sending requests, enquiries, to the
native modeler. */
class GenericEdge : public GEdge { class GenericEdge : public GEdge {
protected: protected:
...@@ -31,7 +32,8 @@ class GenericEdge : public GEdge { ...@@ -31,7 +32,8 @@ class GenericEdge : public GEdge {
typedef bool (*ptrfunction_int_double_refdouble)(int, double, double&); typedef bool (*ptrfunction_int_double_refdouble)(int, double, double&);
typedef bool (*ptrfunction_int_refstring)(int, string&); typedef bool (*ptrfunction_int_refstring)(int, string&);
typedef bool (*ptrfunction_int_refbool)(int, bool&); 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_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> &); 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); GenericEdge(GModel *model, int num,int _native_id, GVertex *v1, GVertex *v2);
...@@ -65,21 +67,18 @@ class GenericEdge : public GEdge { ...@@ -65,21 +67,18 @@ class GenericEdge : public GEdge {
private: private:
// the callbacks: // the callbacks:
// --------------
static ptrfunction_int_double_refvector EdgeEvalXYZFromT; static ptrfunction_int_double_refvector EdgeEvalXYZFromT;
static ptrfunction_int_refdouble_refdouble EdgeEvalParBounds; static ptrfunction_int_refdouble_refdouble EdgeEvalParBounds;
static ptrfunction_int_refstring EdgeGeomType; static ptrfunction_int_refstring EdgeGeomType;
static ptrfunction_int_refbool EdgeDegenerated; static ptrfunction_int_refbool EdgeDegenerated;
static ptrfunction_int_double_refvector EdgeEvalFirstDer; static ptrfunction_int_double_refvector EdgeEvalFirstDer;
static ptrfunction_int_double_refdouble EdgeEvalCurvature; static ptrfunction_int_double_refdouble EdgeEvalCurvature;
// the first vector is a query point xyz, fills the second vector with closest point // the first vector is a query point xyz, fills the second vector with closest
// on edge using orthogonal projection. Fills double param with parametric coordinate of end point projection. // 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_refvector_refdouble_refvector_refbool EdgeClosestPoint;
static ptrfunction_int_refbool EdgeIs3D; static ptrfunction_int_refbool EdgeIs3D;
static ptrfunction_int_int_double_int_refvector EdgeReparamOnFace; static ptrfunction_int_int_double_int_refvector EdgeReparamOnFace;
}; };
#endif #endif
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
#include "Context.h" #include "Context.h"
#include <math.h> #include <math.h>
//------------------------------------------------------------------------
GenericFace::ptrfunction_int_refstring GenericFace::FaceGeomType = NULL; GenericFace::ptrfunction_int_refstring GenericFace::FaceGeomType = NULL;
GenericFace::ptrfunction_int_refvector_refvector GenericFace::FaceUVFromXYZ = NULL; GenericFace::ptrfunction_int_refvector_refvector GenericFace::FaceUVFromXYZ = NULL;
GenericFace::ptrfunction_int_refvector_refvector_refvector GenericFace::FaceClosestPoint = NULL; GenericFace::ptrfunction_int_refvector_refvector_refvector GenericFace::FaceClosestPoint = NULL;
...@@ -29,9 +26,8 @@ GenericFace::ptrfunction_int_refvector_refvector GenericFace::FaceEvalNormal = N ...@@ -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 GenericFace::FaceFirstDer = NULL;
GenericFace::ptrfunction_int_refvector_refvector_refvector_refvector GenericFace::FaceSecondDer = 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"); if (!FaceParBounds) Msg::Fatal("Genericface::ERROR: Callback FaceParBounds not set");
Range<double> rangeu = parBounds(0); Range<double> rangeu = parBounds(0);
Range<double> rangev = parBounds(1); Range<double> rangev = parBounds(1);
...@@ -45,52 +41,47 @@ GenericFace::GenericFace(GModel *m, int num, int _native_id):GFace(m, num), id(_ ...@@ -45,52 +41,47 @@ GenericFace::GenericFace(GModel *m, int num, int _native_id):GFace(m, num), id(_
// 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); if(i == 0) return Range<double>(umin, umax);
return Range<double>(vmin, vmax); return Range<double>(vmin, vmax);
} }
//------------------------------------------------------------------------ SVector3 GenericFace::normal(const SPoint2 &param) const
{
SVector3 GenericFace::normal(const SPoint2 &param) const{
vector<double> res(3,0.); vector<double> res(3,0.);
vector<double> par(2,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"); if (!FaceEvalNormal) Msg::Fatal("Genericface::ERROR: Callback FaceEvalNormal not set");
bool ok = FaceEvalNormal(id,par,res); bool ok = FaceEvalNormal(id,par,res);
if (!ok) Msg::Error("GenericFace::ERROR from FaceEvalNormal ! " ); if (!ok) Msg::Error("GenericFace::ERROR from FaceEvalNormal ! " );
return SVector3(res[0],res[1],res[2]); return SVector3(res[0],res[1],res[2]);
} }
//------------------------------------------------------------------------ Pair<SVector3,SVector3> GenericFace::firstDer(const SPoint2 &param) const
{
Pair<SVector3,SVector3> GenericFace::firstDer(const SPoint2 &param) const{
if (!FaceFirstDer) Msg::Fatal("Genericface::ERROR: Callback FaceFirstDer not set"); if (!FaceFirstDer) Msg::Fatal("Genericface::ERROR: Callback FaceFirstDer not set");
vector<double> deru(3,0.); vector<double> deru(3,0.);
vector<double> derv(3,0.); vector<double> derv(3,0.);
vector<double> par(2,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); bool ok = FaceFirstDer(id,par,deru,derv);
if (!ok) Msg::Error("GenericFace::ERROR from FaceFirstDer ! " ); if (!ok) Msg::Error("GenericFace::ERROR from FaceFirstDer ! " );
return Pair<SVector3,SVector3>(SVector3(deru[0],deru[1],deru[2]), return Pair<SVector3,SVector3>(SVector3(deru[0],deru[1],deru[2]),
SVector3(derv[0],derv[1],derv[2])); SVector3(derv[0],derv[1],derv[2]));
} }
//------------------------------------------------------------------------ void GenericFace::secondDer(const SPoint2 &param,SVector3 *dudu, SVector3 *dvdv, SVector3 *dudv) const
{
void GenericFace::secondDer(const SPoint2 &param,SVector3 *dudu, SVector3 *dvdv, SVector3 *dudv) const{
vector<double> deruu(3,0.); vector<double> deruu(3,0.);
vector<double> dervv(3,0.); vector<double> dervv(3,0.);
vector<double> deruv(3,0.); vector<double> deruv(3,0.);
vector<double> par(2,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"); if (!FaceSecondDer) Msg::Fatal("Genericface::ERROR: Callback FaceSecondDer not set");
bool ok = FaceSecondDer(id,par,deruu,dervv,deruv); bool ok = FaceSecondDer(id,par,deruu,dervv,deruv);
if (!ok) Msg::Error("GenericFace::ERROR from FaceSecondDer ! " ); if (!ok) Msg::Error("GenericFace::ERROR from FaceSecondDer ! " );
...@@ -100,9 +91,8 @@ void GenericFace::secondDer(const SPoint2 &param,SVector3 *dudu, SVector3 *dvdv, ...@@ -100,9 +91,8 @@ void GenericFace::secondDer(const SPoint2 &param,SVector3 *dudu, SVector3 *dvdv,
return; return;
} }
//------------------------------------------------------------------------ GPoint GenericFace::point(double par1, double par2) const
{
GPoint GenericFace::point(double par1, double par2) const{
vector<double> uv(2,0.); vector<double> uv(2,0.);
uv[0] = par1; uv[0] = par1;
uv[1] = par2; uv[1] = par2;
...@@ -114,9 +104,8 @@ GPoint GenericFace::point(double par1, double par2) const{ ...@@ -114,9 +104,8 @@ GPoint GenericFace::point(double par1, double par2) const{
return GPoint(xyz[0], xyz[1], xyz[2], this, pp); 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> uvres(2,0.);
vector<double> xyzres(3,0.); vector<double> xyzres(3,0.);
vector<double> queryPoint(3,0.); vector<double> queryPoint(3,0.);
...@@ -140,9 +129,8 @@ GPoint GenericFace::closestPoint(const SPoint3 &qp, const double initialGuess[2] ...@@ -140,9 +129,8 @@ GPoint GenericFace::closestPoint(const SPoint3 &qp, const double initialGuess[2]
return GPoint(xyzres[0], xyzres[1], xyzres[2], this, pp); 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> uvres(2,0.);
vector<double> xyzres(3,0.); vector<double> xyzres(3,0.);
vector<double> queryPoint(3,0.); vector<double> queryPoint(3,0.);
...@@ -166,9 +154,8 @@ SPoint2 GenericFace::parFromPoint(const SPoint3 &qp, bool onSurface) const{ ...@@ -166,9 +154,8 @@ SPoint2 GenericFace::parFromPoint(const SPoint3 &qp, bool onSurface) const{
return SPoint2(uvres[0],uvres[1]); return SPoint2(uvres[0],uvres[1]);
} }
//------------------------------------------------------------------------ GEntity::GeomType GenericFace::geomType() const
{
GEntity::GeomType GenericFace::geomType() const{
string s; string s;
if (!FaceGeomType) Msg::Fatal("Genericface::ERROR: Callback FaceGeomType not set"); if (!FaceGeomType) Msg::Fatal("Genericface::ERROR: Callback FaceGeomType not set");
bool ok = FaceGeomType(id,s); bool ok = FaceGeomType(id,s);
...@@ -197,25 +184,24 @@ GEntity::GeomType GenericFace::geomType() const{ ...@@ -197,25 +184,24 @@ GEntity::GeomType GenericFace::geomType() const{
return Unknown; return Unknown;
} }
//------------------------------------------------------------------------ double GenericFace::curvatureMax(const SPoint2 &param) const
{
double GenericFace::curvatureMax(const SPoint2 &param) const{
vector<double> dirMax(3,0.); vector<double> dirMax(3,0.);
vector<double> dirMin(3,0.); vector<double> dirMin(3,0.);
double curvMax,curvMin; double curvMax,curvMin;
vector<double> par(2,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 (!FaceCurvatures) Msg::Fatal("Genericface::ERROR: Callback FaceCurvatures not set"); if (!FaceCurvatures) Msg::Fatal("Genericface::ERROR: Callback FaceCurvatures not set");
bool ok = FaceCurvatures(id,par,dirMax,dirMin,curvMax,curvMin); bool ok = FaceCurvatures(id,par,dirMax,dirMin,curvMax,curvMin);
if (!ok) Msg::Error("GenericFace::ERROR from FaceCurvatures ! " ); if (!ok) Msg::Error("GenericFace::ERROR from FaceCurvatures ! " );
return std::max(fabs(curvMax), fabs(curvMin)); 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.); 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> dirMax(3,0.);
vector<double> dirMin(3,0.); vector<double> dirMin(3,0.);
...@@ -228,9 +214,8 @@ double GenericFace::curvatures(const SPoint2 &_param,SVector3 *_dirMax,SVector3 ...@@ -228,9 +214,8 @@ double GenericFace::curvatures(const SPoint2 &_param,SVector3 *_dirMax,SVector3
return *curvMax; return *curvMax;
} }
//------------------------------------------------------------------------ bool GenericFace::containsPoint(const SPoint3 &pt) const
{
bool GenericFace::containsPoint(const SPoint3 &pt) const{
bool res; bool res;
vector<double> queryPoint(3,0.); vector<double> queryPoint(3,0.);
for (int i=0;i<3;i++) queryPoint[i] = pt[i]; for (int i=0;i<3;i++) queryPoint[i] = pt[i];
...@@ -240,5 +225,3 @@ bool GenericFace::containsPoint(const SPoint3 &pt) const{ ...@@ -240,5 +225,3 @@ bool GenericFace::containsPoint(const SPoint3 &pt) const{
return res; return res;
} }
//------------------------------------------------------------------------
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
using namespace std; using namespace std;
/* The set of Generic Entities is a generic interface to any other 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. */ Callbacks (function pointers) are given, sending requests, enquiries, to the
native modeler. */
class GenericFace : public GFace { class GenericFace : public GFace {
protected: protected:
...@@ -29,11 +30,14 @@ class GenericFace : public GFace { ...@@ -29,11 +30,14 @@ class GenericFace : public GFace {
// callbacks typedef // callbacks typedef
typedef bool (*ptrfunction_int_refstring)(int, string&); 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)(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_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_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_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_refdouble_refdouble)
typedef bool (*ptrfunction_int_refvector_refvector_refvector_refvector)(const int , const vector<double> &, vector<double> &, vector<double> &, vector<double> &); (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); GenericFace(GModel *m, int num, int _native_id);
virtual ~GenericFace(); virtual ~GenericFace();
...@@ -86,7 +90,6 @@ class GenericFace : public GFace { ...@@ -86,7 +90,6 @@ class GenericFace : public GFace {
static ptrfunction_int_int_refdouble_refdouble FaceParBounds; static ptrfunction_int_int_refdouble_refdouble FaceParBounds;
static ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble FaceCurvatures; static ptrfunction_int_refvector_refvector_refvector_refdouble_refdouble FaceCurvatures;
static ptrfunction_int_refvector_refvector_refvector_refvector FaceSecondDer; static ptrfunction_int_refvector_refvector_refvector_refvector FaceSecondDer;
}; };
#endif #endif
...@@ -11,24 +11,15 @@ ...@@ -11,24 +11,15 @@
#include "GenericFace.h" #include "GenericFace.h"
#include "GenericRegion.h" #include "GenericRegion.h"
//------------------------------------------------------------------------
GenericRegion::GenericRegion(GModel *m, int num, int _native_id):GRegion(m, num), id(_native_id) GenericRegion::GenericRegion(GModel *m, int num, int _native_id):GRegion(m, num), id(_native_id)
{ {
} }
//------------------------------------------------------------------------
GenericRegion::~GenericRegion() GenericRegion::~GenericRegion()
{ {
} }
//------------------------------------------------------------------------
GEntity::GeomType GenericRegion::geomType() const GEntity::GeomType GenericRegion::geomType() const
{ {
return Unknown; return Unknown;
} }
//------------------------------------------------------------------------
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include "GRegion.h" #include "GRegion.h"
/*The set of Generic Entities is a generic interface to any other 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. */ Callbacks (function pointers) are given, sending requests, enquiries, to the
native modeler. */
class GenericRegion : public GRegion { class GenericRegion : public GRegion {
public: public:
...@@ -22,14 +23,15 @@ class GenericRegion : public GRegion { ...@@ -22,14 +23,15 @@ class GenericRegion : public GRegion {
ModelType getNativeType() const { return GenericModel; } ModelType getNativeType() const { return GenericModel; }
virtual int getNativeInt()const{return id;}; 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. // 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){ void addFace(GenericFace *ptr, int sign){
l_dirs.push_back(sign); l_dirs.push_back(sign);
l_faces.push_back(ptr); l_faces.push_back(ptr);
ptr->addRegion(this); ptr->addRegion(this);
}; };
private: private:
int id; int id;
}; };
......
...@@ -12,13 +12,10 @@ ...@@ -12,13 +12,10 @@
#include "GenericFace.h" #include "GenericFace.h"
#include<algorithm> #include<algorithm>
//------------------------------------------------------------------------
GenericVertex::ptrfunction_int_vector GenericVertex::VertexXYZ = NULL; 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) if (!VertexXYZ)
Msg::Fatal("GenericVertex::ERROR: Callback not set"); Msg::Fatal("GenericVertex::ERROR: Callback not set");
...@@ -30,13 +27,10 @@ GenericVertex::GenericVertex(GModel *m, int num, int _native_id):GVertex(m, num) ...@@ -30,13 +27,10 @@ GenericVertex::GenericVertex(GModel *m, int num, int _native_id):GVertex(m, num)
_z=vec[2]; _z=vec[2];
} }
//------------------------------------------------------------------------ GenericVertex::~GenericVertex()
{
GenericVertex::~GenericVertex(){
} }
//------------------------------------------------------------------------
SPoint2 GenericVertex::reparamOnFace(const GFace *gf, int dir) const SPoint2 GenericVertex::reparamOnFace(const GFace *gf, int dir) const
{ {
std::list<GEdge*>::const_iterator it = l_edges.begin(); std::list<GEdge*>::const_iterator it = l_edges.begin();
...@@ -75,8 +69,6 @@ SPoint2 GenericVertex::reparamOnFace(const GFace *gf, int dir) const ...@@ -75,8 +69,6 @@ SPoint2 GenericVertex::reparamOnFace(const GFace *gf, int dir) const
return GVertex::reparamOnFace(gf, dir); return GVertex::reparamOnFace(gf, dir);
} }
//------------------------------------------------------------------------
void GenericVertex::setPosition(GPoint &p) void GenericVertex::setPosition(GPoint &p)
{ {
_x = p.x(); _x = p.x();
...@@ -88,5 +80,3 @@ void GenericVertex::setPosition(GPoint &p) ...@@ -88,5 +80,3 @@ void GenericVertex::setPosition(GPoint &p)
mesh_vertices[0]->z() = p.z(); mesh_vertices[0]->z() = p.z();
} }
} }
//------------------------------------------------------------------------
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
using namespace std; using namespace std;
/* The set of Generic Entities is a generic interface to any other 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. */ Callbacks (function pointers) are given, sending requests, enquiries, to the
native modeler. */
class GenericVertex : public GVertex { class GenericVertex : public GVertex {
protected: protected:
...@@ -43,7 +44,6 @@ class GenericVertex : public GVertex { ...@@ -43,7 +44,6 @@ class GenericVertex : public GVertex {
private: private:
// the callbacks: // the callbacks:
// --------------
// fills vector xyz for vertex of int id // fills vector xyz for vertex of int id
static ptrfunction_int_vector VertexXYZ; static ptrfunction_int_vector VertexXYZ;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment