try again

parent b3603c0a
Pipeline #1349 failed with stage
in 19 minutes and 20 seconds
......@@ -15,13 +15,14 @@
#include "GaussLegendre1D.h"
#include "Context.h"
#include "closestPoint.h"
#include "discreteEdge.h"
#if defined(HAVE_MESH)
#include "meshGEdge.h"
#endif
GEdge::GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1)
: GEntity(model, tag), _length(0.), _tooSmall(false), _cp(0),
v0(_v0), v1(_v1), masterOrientation(0)
v0(_v0), v1(_v1), masterOrientation(0), compound_edge(NULL)
{
if(v0) v0->addEdge(this);
if(v1 && v1 != v0) v1->addEdge(this);
......@@ -663,10 +664,52 @@ void GEdge::discretize(double tol, std::vector<SPoint3> &dpts, std::vector<doubl
}
}
#if defined(HAVE_MESH)
static void meshCompound(GEdge* ge)
{
std::vector<MLine*> lines;
for (unsigned int i = 0; i < ge->_compound.size(); i++){
GEdge *c = (GEdge*)ge->_compound[i];
for (unsigned int j = 0; j<c->lines.size(); j++){
lines.push_back(new MLine(c->lines[j]->getVertex(0),c->lines[j]->getVertex(1)));
}
}
// printf("%d lines %d curves in compound\n",lines.size(),ge->_compound.size());
discreteEdge *de = new discreteEdge(ge->model(), ge->tag() + 100000, NULL, NULL);
ge->model()->add(de);
de->lines = lines;
de->createGeometry();
// printf("geometry done\n");
de->mesh(false);
ge->compound_edge = de;
}
#endif
void GEdge::mesh(bool verbose)
{
#if defined(HAVE_MESH)
meshGEdge mesher;
mesher(this);
if(_compound.size()){ // Some faces are meshed together
if(_compound[0] == this){ // I'm the one that makes the compound job
bool ok = true;
for(unsigned int i = 0; i < _compound.size(); i++){
GEdge *ge = (GEdge*)_compound[i];
ok &= (ge->meshStatistics.status == GEdge::DONE);
}
if(!ok){
meshStatistics.status = GEdge::PENDING;
}
else{
// printf("meshing compound\n");
meshCompound(this);
meshStatistics.status = GEdge::DONE;
return;
}
}
}
#endif
}
......@@ -215,6 +215,11 @@ class GEdge : public GEntity {
} meshStatistics;
std::vector<MLine*> lines;
/************************************************************************/
// when a compound of edges is created, both meshes should be kept alive
// this is due to Gmsh's flow and it only applies to model edges
GEdge *compound_edge;
/************************************************************************/
void addLine(MLine *line){ lines.push_back(line); }
void addElement(int type, MElement *e);
......
......@@ -1353,19 +1353,13 @@ bool GFace::fillPointCloud(double maxDist,
#if defined(HAVE_MESH)
static void meshCompound(GFace* gf, bool verbose)
{
discreteFace *df = new discreteFace(gf->model(), gf->tag() + 100000);
std::set<int> ec;
for (unsigned int i = 0; i < gf->_compound.size(); i++){
GFace *c = (GFace*)gf->_compound[i];
std::list<GEdge*> edges = c->edges();
for (std::list<GEdge*>::iterator it = edges.begin() ; it != edges.end(); ++it){
std::set<int>::iterator found = ec.find((*it)->tag());
if (found == ec.end())ec.insert((*it)->tag());
else ec.erase(found);
}
df->triangles.insert(df->triangles.end(), c->triangles.begin(),
c->triangles.end());
df->mesh_vertices.insert(df->mesh_vertices.end(), c->mesh_vertices.begin(),
......@@ -1374,16 +1368,14 @@ static void meshCompound(GFace* gf, bool verbose)
c->mesh_vertices.clear();
}
std::vector<int> cedges;
cedges.insert(cedges.begin(), ec.begin(), ec.end());
df->setBoundEdges(cedges);
df->createGeometry();
df->mesh(verbose);
gf->mesh_vertices = df->mesh_vertices;
for (int i=0;i<gf->mesh_vertices.size();i++)gf->mesh_vertices[i]->setEntity(gf);
gf->triangles = df->triangles;
df->triangles.clear();
df->mesh_vertices.clear();
// delete df;
delete df;
}
#endif
......@@ -1404,6 +1396,7 @@ void GFace::mesh(bool verbose)
}
else{
meshCompound(this, verbose);
meshStatistics.status = GFace::DONE;
return;
}
}
......
......@@ -86,6 +86,14 @@ void discreteEdge::orderMLines()
// printf("%d ",v11->getNum());
mesh_vertices.push_back(v11);
}
GVertex *g0 = static_cast<GVertex*>(lines[0]->getVertex(0)->onWhat());
if (!g0)Msg::Error ("Compound Edge with non consecutive lines");
GVertex *g1 = static_cast<GVertex*>(lines[lines.size()-1]->getVertex(1)->onWhat());
if (!g1)Msg::Error ("Compound Edge with non consecutive lines");
// printf("%d --> %d\n",g0->tag(),g1->tag());
setBeginVertex (g0);
setEndVertex (g1);
// printf("\n");
}
......@@ -235,7 +243,7 @@ void discreteEdge::interpolateInGeometry(MVertex *v, MVertex **v1,
void discreteEdge::mesh(bool verbose)
{
#if defined(HAVE_MESH)
if (!CTX::instance()->meshDiscrete) return;
if (discrete_lines.empty()) return;
meshGEdge mesher;
mesher(this);
#endif
......
......@@ -118,7 +118,9 @@ GPoint discreteFace::point(double par1, double par2) const
return gp;
}
e->xyz2uvw(xy,uv);
const MTriangle &t3d = _parametrizations[_current_parametrization].t3d[e->getPartition()];
int position = (int)((MTriangle*)e - &_parametrizations[_current_parametrization].t2d[0]);
const MTriangle &t3d = _parametrizations[_current_parametrization].t3d[position];
double X=0,Y=0,Z=0;
double eval[3] = {1.-uv[0]-uv[1],uv[0],uv[1]};
......@@ -332,7 +334,10 @@ Pair<SVector3, SVector3> discreteFace::firstDer(const SPoint2 &param) const
Msg::Warning("discreteFace::firstDer << triangle not found %g %g",param[0],param[1]);
return Pair<SVector3, SVector3>(SVector3(1,0,0), SVector3(0,1,0));
}
const MTriangle &t3d = _parametrizations[_current_parametrization].t3d[e->getPartition()];
int position = (int)((MTriangle*)e - &_parametrizations[_current_parametrization].t2d[0]);
const MTriangle &t3d = _parametrizations[_current_parametrization].t3d[position];
const MVertex *v1 = t3d.getVertex(0);
const MVertex *v2 = t3d.getVertex(1);
const MVertex *v3 = t3d.getVertex(2);
......@@ -480,7 +485,7 @@ void discreteFace::checkAndFixOrientation()
void discreteFace::mesh(bool verbose)
{
#ifdef HAVE_HXT
if(!CTX::instance()->meshDiscrete) return;
if(_parametrizations.empty()) return;
std::vector<MTriangle*> _t;
std::vector<MVertex*> _v;
......@@ -672,8 +677,11 @@ GPoint discreteFace::intersectionWithCircle(const SVector3 &n1, const SVector3 &
MTriangle *t2d = (MTriangle*)_parametrizations[_current_parametrization].oct->find(uv[0],uv[1],0.0);
MTriangle *t3d = NULL;
if (t2d) t3d = &_parametrizations[_current_parametrization].t3d[t2d->getPartition()];
if (t2d) {
int position = (int)(t2d - &_parametrizations[_current_parametrization].t2d[0]);
t3d = &_parametrizations[_current_parametrization].t3d[position];
}
SVector3 n = crossprod(n1,n2);
n.normalize();
......@@ -777,6 +785,16 @@ GPoint discreteFace::intersectionWithCircle(const SVector3 &n1, const SVector3 &
return pp;
}
static void existingEdges (GFace *gf, std::map<MEdge, GEdge*, Less_Edge> &edges){
std::list<GEdge*> e = gf->edges();
for (std::list<GEdge*>::iterator it = e.begin(); it != e.end(); ++it){
for (unsigned int i = 0;i<(*it)->lines.size(); i++){
MLine *ml = (*it)->lines[i];
edges.insert (std::make_pair(MEdge(ml->getVertex(0),ml->getVertex(1)),*it));
}
}
}
bool discreteFace::compute_topology_of_partition (int nbColors,
int *colors,
int *nNodes,
......@@ -852,16 +870,6 @@ bool discreteFace::compute_topology_of_partition (int nbColors,
fprintf(f2,"};\n");
fclose(f2);
// reverse information is set into partition field of the triangulation...
for (size_t i=0;i<_parametrizations.size();i++){
for (size_t j=0;j< _parametrizations[i].t3d.size();j++){
_parametrizations[i].t3d[j].setPartition(j);
_parametrizations[i].t2d[j].setPartition(j);
// printf("%d %d vs %d %d\n",j,j,_parametrizations[i].t3d[j].getPartition(),
// _parametrizations[i].t2d[j].getPartition());
}
}
// compute 1D topology ---------------------------------------------------------
// edges between two colors
std::map<MEdge, std::pair<int,int>, Less_Edge> l;
......@@ -949,7 +957,7 @@ bool discreteFace::compute_topology_of_partition (int nbColors,
std::vector<MVertex*> &v = vs[k];
MVertex *vs[2] = {v[0],v[v.size()-1]};
for (int i=0;i<2;i++){
if(vs[i]->onWhat()->dim() == 1) {
if(vs[i]->onWhat()->dim() == 1 && it->first.second != -1 && it->first.first != -1) {
// vs[i]->onWhat()->mesh_vertices.erase(std::remove(vs[i]->onWhat()->mesh_vertices.begin(),
// vs[i]->onWhat()->mesh_vertices.end(), vs[i]),
// vs[i]->onWhat()->mesh_vertices.end());
......@@ -960,6 +968,7 @@ bool discreteFace::compute_topology_of_partition (int nbColors,
vs[i]->setEntity(gstart);
gstart->mesh_vertices.push_back(vs[i]);
splitDiscreteEdge(de,vs[i],gstart,TAG);
printf("%d %d\n",it->first.first,it->first.second);
Msg::Info("Splitting Existing discrete Edge %d",de->tag());
}
}
......@@ -1074,6 +1083,8 @@ bool discreteFace::compute_topology_of_partition (int nbColors,
return true;
}
HXTStatus discreteFace::reparametrize_through_hxt (){
int n =1;
HXT_CHECK(hxtInitializeLinearSystems(&n, NULL));
......@@ -1100,6 +1111,9 @@ HXTStatus discreteFace::reparametrize_through_hxt (){
// Msg::Info("Face %d has %d internal edges",tag(),internals[0].size());
std::map<MEdge, GEdge*, Less_Edge> cad_edges;
existingEdges (this, cad_edges);
for (size_t i=0;i<_parametrizations.size();i++){
// printf("FACE %d : ",i);
Less_Edge le;
......@@ -1112,8 +1126,13 @@ HXTStatus discreteFace::reparametrize_through_hxt (){
discreteEdge *de = static_cast<discreteEdge*>(*it);
if (!de)Msg::Error("Reparametrization only works for discrete geometries");
if (des.find(de) == des.end()){
des.insert(de);
// printf(" (%d %d) ",de->getBeginVertex()->tag(),de->getEndVertex()->tag());
if (de->_compound.size()){
if (de->compound_edge)des.insert((discreteEdge*)de->compound_edge);
}
else {
des.insert(de);
// printf(" (%d %d) ",de->getBeginVertex()->tag(),de->getEndVertex()->tag());
}
}
}
}
......
......@@ -1197,6 +1197,7 @@ bool BDS_Mesh::smooth_point_centroid(BDS_Point *p, GFace *gf, bool test_quality)
double radius;
SPoint3 center;
bool isSphere = gf->isSphere(radius, center);
// bool isBSplineSurface = gf->geomType() == GEntity::BSplineSurface;
double XX=0,YY=0,ZZ=0;
double U = 0;
......@@ -1233,7 +1234,7 @@ bool BDS_Mesh::smooth_point_centroid(BDS_Point *p, GFace *gf, bool test_quality)
GPoint gp;double uv[2];
SVector3 normal;
if (isSphere){
if (isSphere /*|| isBSplineSurface*/){
gp = gf->closestPoint(SPoint3(XX, YY, ZZ), uv);
U = gp.u();
V = gp.v();
......
......@@ -932,6 +932,7 @@ bool meshGenerator(GFace *gf, int RECUR_ITER,
while(ite != edges.end()){
if((*ite)->isSeam(gf)) return false;
if(!(*ite)->isMeshDegenerated()){
// printf("edge %d\n",(*ite)->tag());
for(unsigned int i = 0; i< (*ite)->lines.size(); i++)
medgesToRecover.push_back(MEdge((*ite)->lines[i]->getVertex(0),
(*ite)->lines[i]->getVertex(1)));
......@@ -2392,7 +2393,7 @@ void deMeshGFace::operator()(GFace *gf)
}
// for debugging, change value from -1 to -100;
int debugSurface = -100; //-100;
int debugSurface = -1; //-100;
void meshGFace::operator()(GFace *gf, bool print)
{
......
......@@ -28,9 +28,9 @@ Curve Loop(13) = {9, -3, -10, -7}; Surface(5) = {13};
Curve Loop(15) = {10, -2, -1, -8}; Surface(10) = {15};
// Treat curves 2, 3 and 4 as a single curve
Compound Curve{2, 3, 4}; // FIXME: not (re)implemeted yet
Compound Curve{2, 3, 4};
// Idem with curves 6, 7 and 8
Compound Curve{6, 7, 8}; // FIXME: not (re)implemeted yet
Compound Curve{6, 7, 8};
// Treat surfaces 12, 14 and 16 as a single surface
Compound Surface{1, 5, 10};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment