Skip to content
Snippets Groups Projects
Commit 9f1bd050 authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

*** empty log message ***

parent ba08d9a7
No related branches found
No related tags found
No related merge requests found
// $Id: OCCEdge.cpp,v 1.14 2006-11-29 16:57:01 remacle Exp $ // $Id: OCCEdge.cpp,v 1.15 2006-12-11 20:12:33 remacle Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "Message.h" #include "Message.h"
#include "OCCEdge.h" #include "OCCEdge.h"
#include "OCCFace.h" #include "OCCFace.h"
#include "Context.h"
extern Context_T CTX;
#if defined(HAVE_OCC) #if defined(HAVE_OCC)
#include "Geom2dLProp_CLProps2d.hxx" #include "Geom2dLProp_CLProps2d.hxx"
...@@ -62,26 +64,31 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar,int dir) const ...@@ -62,26 +64,31 @@ SPoint2 OCCEdge::reparamOnFace(GFace *face, double epar,int dir) const
double t0,t1; double t0,t1;
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface(c, *s, t0, t1); Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface(c, *s, t0, t1);
if (c2d.IsNull()) if (c2d.IsNull())
{
Msg(GERROR,"Reparam on face failed : curve %d is not on surface %d\n",tag(),face->tag());
return GEdge::reparamOnFace(face, epar,dir); return GEdge::reparamOnFace(face, epar,dir);
}
double u,v; double u,v;
c2d->Value(epar).Coord(u,v); c2d->Value(epar).Coord(u,v);
if (! isSeam ( face ) ) if (! isSeam ( face ) )
{ {
// sometimes OCC miserably fails ...
GPoint p1 = point(epar);
GPoint p2 = face->point(u,v);
const double dx = p1.x()-p2.x();
const double dy = p1.y()-p2.y();
const double dz = p1.z()-p2.z();
if (sqrt(dx*dx+dy*dy+dz*dz) > 1.e-7 * CTX.lc)
{
GPoint ppp = face->closestPoint(SPoint3(p1.x(),p1.y(),p1.z()));
return SPoint2(ppp.u(),ppp.v());
}
return SPoint2 (u,v); return SPoint2 (u,v);
} }
else else
{ {
BRepAdaptor_Surface surface( *s ); BRepAdaptor_Surface surface( *s );
// printf ("surface %d (%d %d) firstu %g lastu %g firstv %g lastv %g\n",
// surface.IsUPeriodic() ,
// surface.IsVPeriodic() ,
// face->tag(),
// surface.FirstUParameter(),
// surface.LastUParameter(),
// surface.FirstVParameter(),
// surface.LastVParameter());
if ( surface.IsUPeriodic() ) if ( surface.IsUPeriodic() )
{ {
if (dir == -1) if (dir == -1)
......
// $Id: BDS.cpp,v 1.70 2006-12-05 14:22:05 remacle Exp $ // $Id: BDS.cpp,v 1.71 2006-12-11 20:12:33 remacle Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -991,6 +991,9 @@ bool test_move_point_parametric_triangle (BDS_Point * p, double u, double v, BDS ...@@ -991,6 +991,9 @@ bool test_move_point_parametric_triangle (BDS_Point * p, double u, double v, BDS
double b[2] = {pc[0]-pa[0],pc[1]-pa[1]}; double b[2] = {pc[0]-pa[0],pc[1]-pa[1]};
double area_init = fabs(a[1] * b[2] - a[2] * b[1]); double area_init = fabs(a[1] * b[2] - a[2] * b[1]);
if (area_init == 0.0) return true;
double ori_init = gmsh::orient2d(pa, pb, pc); double ori_init = gmsh::orient2d(pa, pb, pc);
if (p == pts[0]) if (p == pts[0])
...@@ -1006,7 +1009,7 @@ bool test_move_point_parametric_triangle (BDS_Point * p, double u, double v, BDS ...@@ -1006,7 +1009,7 @@ bool test_move_point_parametric_triangle (BDS_Point * p, double u, double v, BDS
if (area_final < 0.1 * area_init)return false; if (area_final < 0.1 * area_init)return false;
double ori_final = gmsh::orient2d(pa, pb, pc); double ori_final = gmsh::orient2d(pa, pb, pc);
// allow to move a point when a triangle was flat // allow to move a point when a triangle was flat
return ori_init*ori_final >= 0; return ori_init*ori_final > 0;
} }
bool BDS_Mesh::smooth_point_parametric(BDS_Point * p, GFace *gf) bool BDS_Mesh::smooth_point_parametric(BDS_Point * p, GFace *gf)
...@@ -1025,15 +1028,18 @@ bool BDS_Mesh::smooth_point_parametric(BDS_Point * p, GFace *gf) ...@@ -1025,15 +1028,18 @@ bool BDS_Mesh::smooth_point_parametric(BDS_Point * p, GFace *gf)
while(eit != p->edges.end()) { while(eit != p->edges.end()) {
if ((*eit)->numfaces() == 1) return false; if ((*eit)->numfaces() == 1) return false;
BDS_Point *op = ((*eit)->p1 == p) ? (*eit)->p2 : (*eit)->p1; BDS_Point *op = ((*eit)->p1 == p) ? (*eit)->p2 : (*eit)->p1;
// const double l_e = (*eit)->length();
U += op->u; U += op->u;
V += op->v; V += op->v;
// tot_length += (*eit)->length(); // tot_length += l_e;
LC += op->lc(); LC += op->lc();
++eit; ++eit;
} }
U /= (p->edges.size()); U /= (p->edges.size());
V /= (p->edges.size()); V /= (p->edges.size());
// U /= tot_length;
// V /= tot_length;
LC /= p->edges.size(); LC /= p->edges.size();
std::list < BDS_Face * >ts; std::list < BDS_Face * >ts;
......
// $Id: meshGFace.cpp,v 1.38 2006-12-05 14:22:05 remacle Exp $ // $Id: meshGFace.cpp,v 1.39 2006-12-11 20:12:33 remacle Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -427,7 +427,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT) ...@@ -427,7 +427,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT)
} }
// recompute mesh sizes takin into account curvature , BGMESH & co // recompute mesh sizes takin into account curvature , BGMESH & co
m.cleanup(); m.cleanup();
if (IT % 5 == 0 && (CTX.mesh.lc_from_curvature || BGMExists())) if (IT == 5 && (CTX.mesh.lc_from_curvature || BGMExists()))
{ {
std::set<BDS_Point*,PointLessThan>::iterator itp = m.points.begin(); std::set<BDS_Point*,PointLessThan>::iterator itp = m.points.begin();
while (itp != m.points.end()) while (itp != m.points.end())
...@@ -441,7 +441,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT) ...@@ -441,7 +441,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT)
} }
++itp; ++itp;
} }
for (int ITERA = 0;ITERA< 6; ITERA++); for (int ITERA = 0;ITERA< 0; ITERA++);
{ {
it = m.edges.begin(); it = m.edges.begin();
while (it != m.edges.end()) while (it != m.edges.end())
...@@ -556,7 +556,7 @@ bool recover_medge ( BDS_Mesh *m, GEdge *ge) ...@@ -556,7 +556,7 @@ bool recover_medge ( BDS_Mesh *m, GEdge *ge)
// domain, including embedded points // domain, including embedded points
// and surfaces // and surfaces
void gmsh2DMeshGenerator ( GFace *gf ) bool gmsh2DMeshGenerator ( GFace *gf )
{ {
typedef std::set<MVertex*> v_container ; typedef std::set<MVertex*> v_container ;
...@@ -570,6 +570,8 @@ void gmsh2DMeshGenerator ( GFace *gf ) ...@@ -570,6 +570,8 @@ void gmsh2DMeshGenerator ( GFace *gf )
it = edges.begin(); it = edges.begin();
while(it != edges.end()) while(it != edges.end())
{ {
if ((*it)->isSeam(gf))return false;
all_vertices.insert ( (*it)->mesh_vertices.begin() , (*it)->mesh_vertices.end() ); all_vertices.insert ( (*it)->mesh_vertices.begin() , (*it)->mesh_vertices.end() );
all_vertices.insert ( (*it)->getBeginVertex()->mesh_vertices.begin() , (*it)->getBeginVertex()->mesh_vertices.end() ); all_vertices.insert ( (*it)->getBeginVertex()->mesh_vertices.begin() , (*it)->getBeginVertex()->mesh_vertices.end() );
all_vertices.insert ( (*it)->getEndVertex()->mesh_vertices.begin() , (*it)->getEndVertex()->mesh_vertices.end() ); all_vertices.insert ( (*it)->getEndVertex()->mesh_vertices.begin() , (*it)->getEndVertex()->mesh_vertices.end() );
...@@ -720,7 +722,7 @@ void gmsh2DMeshGenerator ( GFace *gf ) ...@@ -720,7 +722,7 @@ void gmsh2DMeshGenerator ( GFace *gf )
if (!recover_medge ( m, *it)) if (!recover_medge ( m, *it))
{ {
Msg(WARNING,"Face not meshed"); Msg(WARNING,"Face not meshed");
return; return false;
} }
++it; ++it;
} }
...@@ -863,14 +865,13 @@ void gmsh2DMeshGenerator ( GFace *gf ) ...@@ -863,14 +865,13 @@ void gmsh2DMeshGenerator ( GFace *gf )
// delete the mesh // delete the mesh
// char name[245];
// sprintf(name,"s%d.pos",gf->tag());
// outputScalarField(m->triangles, name);
delete m; delete m;
delete [] U_; delete [] U_;
delete [] V_; delete [] V_;
return true;
} }
// this function buils a list of vertices (BDS) that // this function buils a list of vertices (BDS) that
...@@ -1082,10 +1083,11 @@ bool buildConsecutiveListOfVertices ( GFace *gf, ...@@ -1082,10 +1083,11 @@ bool buildConsecutiveListOfVertices ( GFace *gf,
result.insert(result.end(),edgeLoop_BDS.begin(),edgeLoop_BDS.end()); result.insert(result.end(),edgeLoop_BDS.begin(),edgeLoop_BDS.end());
} }
// for (int i=0;i<result.size();i++) if (gf->tag() == 280)
// { for (int i=0;i<result.size();i++)
// printf("point %3d (%8.5f %8.5f) (%2d,%2d)\n",i,result[i]->u,result[i]->v,result[i]->g->classif_tag,result[i]->g->classif_degree); {
// } printf("point %3d (%8.5f %8.5f) (%2d,%2d)\n",i,result[i]->u,result[i]->v,result[i]->g->classif_tag,result[i]->g->classif_degree);
}
return true; return true;
} }
...@@ -1093,6 +1095,8 @@ bool buildConsecutiveListOfVertices ( GFace *gf, ...@@ -1093,6 +1095,8 @@ bool buildConsecutiveListOfVertices ( GFace *gf,
bool gmsh2DMeshGeneratorPeriodic ( GFace *gf ) bool gmsh2DMeshGeneratorPeriodic ( GFace *gf )
{ {
// if(gf->tag() != 6)return true;
std::map<BDS_Point*,MVertex*> recover_map; std::map<BDS_Point*,MVertex*> recover_map;
...@@ -1108,8 +1112,8 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf ) ...@@ -1108,8 +1112,8 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf )
// Buid a BDS_Mesh structure that is convenient for doing the actual meshing procedure // Buid a BDS_Mesh structure that is convenient for doing the actual meshing procedure
BDS_Mesh *m = new BDS_Mesh; BDS_Mesh *m = new BDS_Mesh;
m->scalingU = fabs(du); // m->scalingU = fabs(du);
m->scalingV = fabs(dv); // m->scalingV = fabs(dv);
std::vector< std::vector<BDS_Point* > > edgeLoops_BDS; std::vector< std::vector<BDS_Point* > > edgeLoops_BDS;
SBoundingBox3d bbox; SBoundingBox3d bbox;
int nbPointsTotal = 0; int nbPointsTotal = 0;
...@@ -1187,6 +1191,8 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf ) ...@@ -1187,6 +1191,8 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf )
free (doc.points); free (doc.points);
free (doc.delaunay); free (doc.delaunay);
// Recover the boundary edges // Recover the boundary edges
// and compute characteristic lenghts using mesh edge spacing // and compute characteristic lenghts using mesh edge spacing
...@@ -1281,6 +1287,8 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf ) ...@@ -1281,6 +1287,8 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf )
m->del_point(m->find_point(-3)); m->del_point(m->find_point(-3));
m->del_point(m->find_point(-4)); m->del_point(m->find_point(-4));
// goto hhh; // goto hhh;
// start mesh generation // start mesh generation
...@@ -1337,12 +1345,12 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf ) ...@@ -1337,12 +1345,12 @@ bool gmsh2DMeshGeneratorPeriodic ( GFace *gf )
// delete the mesh // delete the mesh
char name[245];
sprintf(name,"param%d.pos",gf->tag());
outputScalarField(m->triangles, name,1);
sprintf(name,"real%d.pos",gf->tag());
outputScalarField(m->triangles, name,0);
// char name[245];
// sprintf(name,"param%d.pos",gf->tag());
// outputScalarField(m->triangles, name,1);
// sprintf(name,"real%d.pos",gf->tag());
// outputScalarField(m->triangles, name,0);
delete m; delete m;
return true; return true;
} }
...@@ -1385,7 +1393,10 @@ void meshGFace :: operator() (GFace *gf) ...@@ -1385,7 +1393,10 @@ void meshGFace :: operator() (GFace *gf)
if(gf->getNativeType() == GEntity::GmshModel || gf->edgeLoops.empty()) if(gf->getNativeType() == GEntity::GmshModel || gf->edgeLoops.empty())
gmsh2DMeshGenerator ( gf ) ; gmsh2DMeshGenerator ( gf ) ;
else else
gmsh2DMeshGeneratorPeriodic ( gf ) ; {
if (!gmsh2DMeshGeneratorPeriodic ( gf ))
Msg(GERROR, "Impossible to mesh face %d",gf->tag());
}
Msg(DEBUG1, "type %d %d triangles generated, %d internal vertices", Msg(DEBUG1, "type %d %d triangles generated, %d internal vertices",
gf->geomType(),gf->triangles.size(),gf->mesh_vertices.size()); gf->geomType(),gf->triangles.size(),gf->mesh_vertices.size());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment