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

We should really clean up the mess that "reparamOnXXX" has become. Introducing one more horrible "haveParametrization()" member function to add to the general insanity :-)
parent 331e04a1
No related branches found
No related tags found
No related merge requests found
...@@ -305,7 +305,8 @@ const double GOLDEN2 = 2 - GOLDEN; ...@@ -305,7 +305,8 @@ const double GOLDEN2 = 2 - GOLDEN;
// x1 and x3 are the current bounds; the minimum is between them. // x1 and x3 are the current bounds; the minimum is between them.
// x2 is the center point, which is closer to x1 than to x3 // x2 is the center point, which is closer to x1 than to x3
double goldenSectionSearch(const GEdge *ge, const SPoint3 &q, double x1, double x2, double x3, double tau) double goldenSectionSearch(const GEdge *ge, const SPoint3 &q, double x1,
double x2, double x3, double tau)
{ {
// Create a new possible center in the area between x2 and x3, closer to x2 // Create a new possible center in the area between x2 and x3, closer to x2
double x4 = x2 + GOLDEN2 * (x3 - x2); double x4 = x2 + GOLDEN2 * (x3 - x2);
...@@ -328,7 +329,6 @@ double goldenSectionSearch(const GEdge *ge, const SPoint3 &q, double x1, double ...@@ -328,7 +329,6 @@ double goldenSectionSearch(const GEdge *ge, const SPoint3 &q, double x1, double
GPoint GEdge::closestPoint(const SPoint3 &q, double &t) const GPoint GEdge::closestPoint(const SPoint3 &q, double &t) const
{ {
// printf("looking for closest point in curve %d to point %g %g\n",tag(),q.x(),q.y()); // printf("looking for closest point in curve %d to point %g %g\n",tag(),q.x(),q.y());
const int nbSamples = 100; const int nbSamples = 100;
...@@ -448,4 +448,3 @@ void GEdge::replaceEndingPoints (GVertex *replOfv0, GVertex *replOfv1) ...@@ -448,4 +448,3 @@ void GEdge::replaceEndingPoints (GVertex *replOfv0, GVertex *replOfv1)
v1 = replOfv1; v1 = replOfv1;
} }
} }
...@@ -181,16 +181,6 @@ class GEdge : public GEntity { ...@@ -181,16 +181,6 @@ class GEdge : public GEntity {
// gluing // gluing
void replaceEndingPoints(GVertex *, GVertex *); void replaceEndingPoints(GVertex *, GVertex *);
//get bounds
inline double getLowBound() const {
Range<double> bounds = parBounds(0);
return bounds.low();
}
inline double getHighBound() const {
Range<double> bounds = parBounds(0);
return bounds.high();
}
struct { struct {
char Method; char Method;
double coeffTransfinite; double coeffTransfinite;
......
...@@ -222,6 +222,9 @@ class GEntity { ...@@ -222,6 +222,9 @@ class GEntity {
// true if there are parametric degeneracies in the "dim" direction. // true if there are parametric degeneracies in the "dim" direction.
virtual bool degenerate(int dim) const { return false; } virtual bool degenerate(int dim) const { return false; }
// does the entity have a parametrization?
virtual bool haveParametrization(){ return true; }
// parametric bounds of the entity in the "i" direction. // parametric bounds of the entity in the "i" direction.
virtual Range<double> parBounds(int i) const { return Range<double>(0., 0.); } virtual Range<double> parBounds(int i) const { return Range<double>(0., 0.); }
......
...@@ -518,8 +518,8 @@ int GModel::mesh(int dimension) ...@@ -518,8 +518,8 @@ int GModel::mesh(int dimension)
#endif #endif
} }
int GModel::adaptMesh(int technique, simpleFunction<double> *f,
int GModel::adaptMesh(int technique, simpleFunction<double> *f, std::vector<double> parameters, bool meshAll) std::vector<double> parameters, bool meshAll)
{ {
#if defined(HAVE_MESH) #if defined(HAVE_MESH)
...@@ -1472,7 +1472,6 @@ void GModel::createTopologyFromMesh(int ignoreHoles) ...@@ -1472,7 +1472,6 @@ void GModel::createTopologyFromMesh(int ignoreHoles)
double t1 = Cpu(); double t1 = Cpu();
removeDuplicateMeshVertices(CTX::instance()->geom.tolerance); removeDuplicateMeshVertices(CTX::instance()->geom.tolerance);
makeDiscreteRegionsSimplyConnected(); makeDiscreteRegionsSimplyConnected();
makeDiscreteFacesSimplyConnected(); makeDiscreteFacesSimplyConnected();
...@@ -1490,7 +1489,7 @@ void GModel::createTopologyFromMesh(int ignoreHoles) ...@@ -1490,7 +1489,7 @@ void GModel::createTopologyFromMesh(int ignoreHoles)
discFaces.push_back((discreteFace*) *it); discFaces.push_back((discreteFace*) *it);
createTopologyFromFaces(discFaces, ignoreHoles); createTopologyFromFaces(discFaces, ignoreHoles);
//create old format (necessary for boundary layers) //create old format (necessary e.g. for old-style extruded boundary layers)
exportDiscreteGEOInternals(); exportDiscreteGEOInternals();
double t2 = Cpu(); double t2 = Cpu();
...@@ -1723,7 +1722,7 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int ...@@ -1723,7 +1722,7 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int
for (unsigned int i = 0; i < (*itE)->getNumMeshElements(); i++){ for (unsigned int i = 0; i < (*itE)->getNumMeshElements(); i++){
MEdge me = (*itE)->getMeshElement(i)->getEdge(0); MEdge me = (*itE)->getMeshElement(i)->getEdge(0);
std::set<MEdge, Less_Edge >::iterator itset = myEdges.find(me); std::set<MEdge, Less_Edge >::iterator itset = myEdges.find(me);
myEdges.erase(itset); if (itset != myEdges.end()) myEdges.erase(itset);
} }
for (std::vector<int>::iterator itFace = tagFaces.begin(); for (std::vector<int>::iterator itFace = tagFaces.begin();
itFace != tagFaces.end(); itFace++) { itFace != tagFaces.end(); itFace++) {
...@@ -1835,9 +1834,6 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int ...@@ -1835,9 +1834,6 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int
// edgeLoops.push_back(el); // edgeLoops.push_back(el);
// } // }
Msg::Debug("Done creating topology for edges...");
// we need to recreate all mesh elements because some mesh vertices // we need to recreate all mesh elements because some mesh vertices
// might have been changed during the parametrization process // might have been changed during the parametrization process
// (MVertices became MEdgeVertices) // (MVertices became MEdgeVertices)
...@@ -1911,7 +1907,7 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int ...@@ -1911,7 +1907,7 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int
gr->pyramids = newPyramids; gr->pyramids = newPyramids;
} }
Msg::Debug("Done creating topology from edges"); Msg::Debug("Done creating topology for edges");
} }
GModel *GModel::buildCutGModel(gLevelset *ls, bool cutElem, bool saveTri) GModel *GModel::buildCutGModel(gLevelset *ls, bool cutElem, bool saveTri)
......
...@@ -295,6 +295,7 @@ static void getAllParameters(MVertex *v, GFace *gf, std::vector<SPoint2> &params ...@@ -295,6 +295,7 @@ static void getAllParameters(MVertex *v, GFace *gf, std::vector<SPoint2> &params
} }
else if(v->onWhat()->dim() == 1){ else if(v->onWhat()->dim() == 1){
GEdge *ge = (GEdge*)v->onWhat(); GEdge *ge = (GEdge*)v->onWhat();
if(!ge->haveParametrization()) return;
double UU; double UU;
v->getParameter(0, UU); v->getParameter(0, UU);
if (UU == 0.0) if (UU == 0.0)
......
...@@ -257,7 +257,6 @@ void discreteEdge::setBoundVertices() ...@@ -257,7 +257,6 @@ void discreteEdge::setBoundVertices()
v0->addEdge(this); v0->addEdge(this);
v1->addEdge(this); v1->addEdge(this);
} }
/* /*
...@@ -399,7 +398,7 @@ void discreteEdge::computeNormals () const ...@@ -399,7 +398,7 @@ void discreteEdge::computeNormals () const
bool discreteEdge::getLocalParameter(const double &t, int &iLine, bool discreteEdge::getLocalParameter(const double &t, int &iLine,
double &tLoc) const double &tLoc) const
{ {
if(_pars.empty()) return false;
for (iLine = 0; iLine < (int)lines.size(); iLine++){ for (iLine = 0; iLine < (int)lines.size(); iLine++){
double tmin = _pars[iLine]; double tmin = _pars[iLine];
double tmax = _pars[iLine+1]; double tmax = _pars[iLine+1];
...@@ -477,7 +476,7 @@ SVector3 discreteEdge::firstDer(double par) const ...@@ -477,7 +476,7 @@ SVector3 discreteEdge::firstDer(double par) const
{ {
double tLoc; double tLoc;
int iEdge; int iEdge;
getLocalParameter(par, iEdge, tLoc); if(!getLocalParameter(par, iEdge, tLoc)) return SVector3();
MVertex *vB = lines[iEdge]->getVertex(0); MVertex *vB = lines[iEdge]->getVertex(0);
MVertex *vE = lines[iEdge]->getVertex(1); MVertex *vE = lines[iEdge]->getVertex(1);
...@@ -492,7 +491,8 @@ SVector3 discreteEdge::firstDer(double par) const ...@@ -492,7 +491,8 @@ SVector3 discreteEdge::firstDer(double par) const
return der; return der;
} }
double discreteEdge::curvature(double par) const{ double discreteEdge::curvature(double par) const
{
double tLoc; double tLoc;
int iEdge; int iEdge;
if(!getLocalParameter(par, iEdge, tLoc)) return MAX_LC; if(!getLocalParameter(par, iEdge, tLoc)) return MAX_LC;
...@@ -521,5 +521,6 @@ Range<double> discreteEdge::parBounds(int i) const ...@@ -521,5 +521,6 @@ Range<double> discreteEdge::parBounds(int i) const
void discreteEdge::writeGEO(FILE *fp) void discreteEdge::writeGEO(FILE *fp)
{ {
if (getBeginVertex() && getEndVertex()) if (getBeginVertex() && getEndVertex())
fprintf(fp, "Discrete Line(%d) = {%d,%d};\n",tag(), getBeginVertex()->tag(), getEndVertex()->tag()); fprintf(fp, "Discrete Line(%d) = {%d,%d};\n", tag(),
getBeginVertex()->tag(), getEndVertex()->tag());
} }
...@@ -19,12 +19,14 @@ class discreteEdge : public GEdge { ...@@ -19,12 +19,14 @@ class discreteEdge : public GEdge {
public: public:
discreteEdge(GModel *model, int num, GVertex *_v0, GVertex *_v1); discreteEdge(GModel *model, int num, GVertex *_v0, GVertex *_v1);
virtual ~discreteEdge() {} virtual ~discreteEdge() {}
bool getLocalParameter(const double &t, int &iEdge, double &tLoc) const;
virtual GeomType geomType() const { return DiscreteCurve; } virtual GeomType geomType() const { return DiscreteCurve; }
virtual GPoint point(double p) const; virtual GPoint point(double p) const;
virtual SVector3 firstDer(double par) const; virtual SVector3 firstDer(double par) const;
virtual double curvature(double par) const; virtual double curvature(double par) const;
virtual bool haveParametrization(){ return !_pars.empty(); }
virtual Range<double> parBounds(int) const; virtual Range<double> parBounds(int) const;
bool getLocalParameter(const double &t, int &iEdge, double &tLoc) const;
void parametrize(std::map<GFace*, std::map<MVertex*, MVertex*, void parametrize(std::map<GFace*, std::map<MVertex*, MVertex*,
std::less<MVertex*> > > &face2Verts, std::less<MVertex*> > > &face2Verts,
std::map<GRegion*, std::map<MVertex*, MVertex*, std::map<GRegion*, std::map<MVertex*, MVertex*,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment