diff --git a/Geo/GEntity.h b/Geo/GEntity.h index 95745e9eab9fa9c68074b378c9e464ee9716cbba..93a19d0865f5e30fa8d50849a0d1147d3bfeca6c 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -68,6 +68,8 @@ class GEntity { Line, Circle, Ellipse, + BSpline, + Bezier, ParametricCurve, DiscreteCurve, Plane, @@ -92,6 +94,8 @@ class GEntity { "Line", "Circle", "Ellipse", + "BSpline", + "Bezier", "Parametric curve", "Discrete curve", "Plane", diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 18270f149e5bceb5a0057e16cb018656c5aedecc..da4d09944a6e8ae65656efdeff2ccde526eb597e 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -1,4 +1,4 @@ - // $Id: GModelIO_OCC.cpp,v 1.9 2006-11-21 23:52:59 remacle Exp $ + // $Id: GModelIO_OCC.cpp,v 1.10 2006-11-22 13:57:25 remacle Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -502,9 +502,9 @@ void OCC_Internals :: loadSTEP (const char *fn) Standard_Integer nb = reader.NbRootsForTransfer(); reader.TransferRoots (); shape = reader.OneShape(); -// BRepTools::Clean (shape); -// buildLists(); -// HealGeometry(); + BRepTools::Clean (shape); + buildLists(); + HealGeometry(); BRepTools::Clean (shape); } @@ -583,7 +583,6 @@ int GModel::readOCCBREP(const std::string &fn) occ_internals = new OCC_Internals; occ_internals->loadBREP (fn.c_str()); occ_internals->buildLists (); - // occ_internals->HealGeometry(); occ_internals->buildGModel (this); return 1; } diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp index 3ed9a5c3d7fa72abd5ae714b5ad03c92cd12bc7b..08e34712bf810a9ffc25914d8d30d12f2134b8da 100644 --- a/Geo/OCCEdge.cpp +++ b/Geo/OCCEdge.cpp @@ -1,4 +1,4 @@ -// $Id: OCCEdge.cpp,v 1.9 2006-11-21 23:52:59 remacle Exp $ +// $Id: OCCEdge.cpp,v 1.10 2006-11-22 13:57:25 remacle Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -25,6 +25,8 @@ #include "OCCFace.h" #if defined(HAVE_OCC) +#include "Geom_BSplineCurve.hxx" +#include "Geom_BezierCurve.hxx" #include "Geom_Ellipse.hxx" #include "Geom_Circle.hxx" #include "Geom_Line.hxx" @@ -164,6 +166,10 @@ GEntity::GeomType OCCEdge::geomType() const return Line; else if (curve2d->DynamicType() == STANDARD_TYPE(Geom_Ellipse)) return Ellipse; + else if (curve2d->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) + return BSpline; + else if (curve2d->DynamicType() == STANDARD_TYPE(Geom_BezierCurve)) + return Bezier; // else if (occface->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface)) // return Cone; return Unknown; @@ -176,6 +182,10 @@ GEntity::GeomType OCCEdge::geomType() const return Line; else if (curve->DynamicType() == STANDARD_TYPE(Geom_Ellipse)) return Ellipse; + else if (curve->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) + return BSpline; + else if (curve->DynamicType() == STANDARD_TYPE(Geom_BezierCurve)) + return Bezier; // else if (occface->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface)) // return Cone; return Unknown; diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp index f2a618ef3dee8c1ac09799b96c0b105935fa75a2..5cb54f105f1a96be1cb3174832fbdb7ffc3ae489 100644 --- a/Geo/OCCFace.cpp +++ b/Geo/OCCFace.cpp @@ -1,4 +1,4 @@ -// $Id: OCCFace.cpp,v 1.10 2006-11-21 23:52:59 remacle Exp $ +// $Id: OCCFace.cpp,v 1.11 2006-11-22 13:57:25 remacle Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -29,6 +29,7 @@ #if defined(HAVE_OCC) #include "Geom_CylindricalSurface.hxx" +#include "Geom_ConicalSurface.hxx" #include "Geom_Plane.hxx" #include "gp_Pln.hxx" @@ -173,6 +174,8 @@ GEntity::GeomType OCCFace::geomType() const return Plane; else if (occface->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) return Cylinder; + else if (occface->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface)) + return Cone; // else if (occface->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface)) // return Cone; return Unknown; diff --git a/Geo/OCCVertex.cpp b/Geo/OCCVertex.cpp index ca054bebd18a8a5f8364d5bf53496297e41312de..8a0f10046700836c08aa412dfe1b7d9923324178 100644 --- a/Geo/OCCVertex.cpp +++ b/Geo/OCCVertex.cpp @@ -1,4 +1,4 @@ -// $Id: OCCVertex.cpp,v 1.5 2006-11-21 23:52:59 remacle Exp $ +// $Id: OCCVertex.cpp,v 1.6 2006-11-22 13:57:25 remacle Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -35,7 +35,7 @@ double max_surf_curvature ( const GVertex *gv, double x, double y, double z , co { SPoint2 par = gv->reparamOnFace((*it),1); double cc = (*it)->curvature ( par ); - curv = std::max(curv, cc ); + if (cc < 1.e2)curv = std::max(curv, cc ); ++it; } return curv; @@ -99,10 +99,10 @@ SPoint2 OCCVertex::reparamOnFace ( GFace *gf , int dir) const double OCCVertex::prescribedMeshSizeAtVertex() const { SBoundingBox3d b = model()->bounds(); double lc = 0.1 * norm( SVector3 ( b.max() , b.min() ) ) * CTX.mesh.lc_factor; - double lc_min = 0.004 * norm(SVector3 ( b.max() , b.min() ) ) * CTX.mesh.lc_factor; - double maxc = max_curvature_of_surfaces(); - if (maxc !=0) - lc = std::max(lc_min,std::min (lc,6.28/(CTX.mesh.min_circ_points*maxc))); + // double lc_min = 0.004 * norm(SVector3 ( b.max() , b.min() ) ) * CTX.mesh.lc_factor; + // double maxc = max_curvature_of_surfaces(); + // if (maxc !=0) + // lc = std::max(lc_min,std::min (lc,6.28/(CTX.mesh.min_circ_points*maxc))); return lc; } diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index 0d1613138f79ef390ea5ed466b35411fbfd68e24..40c6b7d2040cb620db792469cb991b00e720bf82 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -1,4 +1,4 @@ -// $Id: BDS.cpp,v 1.65 2006-11-21 23:52:59 remacle Exp $ +// $Id: BDS.cpp,v 1.66 2006-11-22 13:57:25 remacle Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -153,9 +153,8 @@ BDS_Point *BDS_Mesh::add_point(int num, double x, double y, double z) } BDS_Point *BDS_Mesh::add_point(int num, double u, double v, GFace *gf) -{ - - GPoint gp = gf->point(u,v); +{ + GPoint gp = gf->point(u*scalingU,v*scalingV); BDS_Point *pp = new BDS_Point(num, gp.x(), gp.y(), gp.z()); pp->u = u; pp->v = v; @@ -1044,7 +1043,7 @@ bool BDS_Mesh::smooth_point_parametric(BDS_Point * p, GFace *gf) } - GPoint gp = gf->point(U,V); + GPoint gp = gf->point(U*scalingU,V*scalingV); p->u = U; p->v = V; p->lc() = LC; diff --git a/Mesh/BDS.h b/Mesh/BDS.h index 17a5cd38d0f4550a84957913953a549edaa77e9d..bf5aa84721f43588de2a695eec4f98566f334dd4 100644 --- a/Mesh/BDS.h +++ b/Mesh/BDS.h @@ -375,7 +375,8 @@ class BDS_Mesh public: int MAXPOINTNUMBER,SNAP_SUCCESS,SNAP_FAILURE; double Min[3],Max[3],LC; - BDS_Mesh(int _MAXX = 0) : MAXPOINTNUMBER(_MAXX){} + double scalingU, scalingV; + BDS_Mesh(int _MAXX = 0) : MAXPOINTNUMBER(_MAXX),scalingU(1),scalingV(1){} void load(GVertex *gv); // load in BDS all the meshes of the vertex void load(GEdge *ge); // load in BDS all the meshes of the edge void load(GFace *gf); // load in BDS all the meshes of the surface diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 66618dc2cef935cd561997c2bb6641fbc1f2811c..29d52a21225cccf9b03ca737226244c78caa36b4 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFace.cpp,v 1.21 2006-11-21 23:52:59 remacle Exp $ +// $Id: meshGFace.cpp,v 1.22 2006-11-22 13:57:25 remacle Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -428,7 +428,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT) { double lone = NewGetLc ( *it); - if (lone < 1.e-10 && computeParametricEdgeLength((*it)->p1,(*it)->p2) > 1.e-4) lone = 2; + if (lone < 1.e-8 && computeParametricEdgeLength((*it)->p1,(*it)->p2) > 1.e-5) lone = 2; if ((*it)->numfaces() == 2 && (lone > 1.3)) { @@ -474,7 +474,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT) { if (NN2++ >= NN1)break; double lone = NewGetLc ( *it); - if (lone < 1.e-10 && computeParametricEdgeLength((*it)->p1,(*it)->p2) > 1.e-4) lone = 2; + if (lone < 1.e-8 && computeParametricEdgeLength((*it)->p1,(*it)->p2) > 1.e-5) lone = 2; if (!(*it)->deleted && (*it)->numfaces() == 2 && lone < 0.6 ) { bool res = false; @@ -518,7 +518,7 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT) } } IT++; - Msg(INFO," iter %d minL %g maxL %g %d split %d swap %d collapse %d smooth",IT,minL,maxL,nb_split,nb_swap,nb_collaps,nb_smooth); + Msg(DEBUG1," iter %d minL %g maxL %g %d split %d swap %d collapse %d smooth",IT,minL,maxL,nb_split,nb_swap,nb_collaps,nb_smooth); m.cleanup(); } } @@ -1068,7 +1068,7 @@ inline double dist2 (const SPoint2 &p1,const SPoint2 &p2) return dx*dx+dy*dy; } -void buildConsecutiveListOfVertices ( GFace *gf, +bool buildConsecutiveListOfVertices ( GFace *gf, GEdgeLoop &gel , std::vector<BDS_Point*> &result, SBoundingBox3d &bbox, @@ -1159,24 +1159,25 @@ void buildConsecutiveListOfVertices ( GFace *gf, SPoint2 first_coord = mesh1d[0]; double d = dist2(last_coord,first_coord); // printf("d = %12.5E %d\n",d, coords.size()); - if (d < 1.e-8) + if (d < 1.e-6) { coords.clear(); coords = mesh1d; found = GEdgeSigned(1,ge); unordered.erase(it); - break; + goto Finalize; } SPoint2 first_coord_reversed = mesh1d_reversed[0]; double d_reversed = dist2(last_coord,first_coord_reversed); // printf("d_r = %12.5E\n",d_reversed); - if (d_reversed < 1.e-8) + if (d_reversed < 1.e-6) { + // printf("d_r = %12.5E\n",d_reversed); coords.clear(); coords = mesh1d_reversed; found = (GEdgeSigned(-1,ge)); unordered.erase(it); - break; + goto Finalize; } if (seam) { @@ -1184,29 +1185,33 @@ void buildConsecutiveListOfVertices ( GFace *gf, SPoint2 first_coord_seam_reversed = mesh1d_seam_reversed[0]; double d_seam = dist2(last_coord,first_coord_seam); // printf("d_seam = %12.5E\n",d_seam); - if (d_seam < 1.e-8) + if (d_seam < 1.e-6) { coords.clear(); coords = mesh1d_seam; found = (GEdgeSigned(1,ge)); unordered.erase(it); - break; + goto Finalize; } double d_seam_reversed = dist2(last_coord,first_coord_seam_reversed); // printf("d_seam_reversed = %12.5E\n",d_seam_reversed); - if (d_seam_reversed < 1.e-8) + if (d_seam_reversed < 1.e-6) { coords.clear(); coords = mesh1d_seam_reversed; found = (GEdgeSigned(-1,ge)); unordered.erase(it); break; + goto Finalize; } } } ++it; } + Finalize: + if (coords.size() == 0)return false; + std::vector<MVertex*> edgeLoop; if ( found._sign == 1) { @@ -1230,8 +1235,8 @@ void buildConsecutiveListOfVertices ( GFace *gf, GEntity *ge = here->onWhat(); double U,V; SPoint2 param = coords [i]; - U = param.x(); - V = param.y(); + U = param.x() / m->scalingU ; + V = param.y() / m->scalingV; BDS_Point *pp; pp = m->add_point ( count, U,V,gf ); m->add_geom (ge->tag(), ge->dim()); @@ -1253,10 +1258,11 @@ void buildConsecutiveListOfVertices ( GFace *gf, // 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; } -void gmsh2DMeshGeneratorPeriodic ( GFace *gf ) +bool gmsh2DMeshGeneratorPeriodic ( GFace *gf ) { std::map<BDS_Point*,MVertex*> recover_map; @@ -1266,6 +1272,7 @@ void gmsh2DMeshGeneratorPeriodic ( GFace *gf ) const double du = rangeU.high() -rangeU.low(); const double dv = rangeV.high() -rangeV.low(); + const double LC2D = sqrt ( du*du + dv*dv ); @@ -1273,6 +1280,8 @@ void gmsh2DMeshGeneratorPeriodic ( GFace *gf ) // Buid a BDS_Mesh structure that is convenient for doing the actual meshing procedure BDS_Mesh *m = new BDS_Mesh; + m->scalingU = fabs(du); + m->scalingV = fabs(dv); std::vector< std::vector<BDS_Point* > > edgeLoops_BDS; SBoundingBox3d bbox; int nbPointsTotal = 0; @@ -1280,7 +1289,7 @@ void gmsh2DMeshGeneratorPeriodic ( GFace *gf ) for (std::list<GEdgeLoop>::iterator it = gf->edgeLoops.begin() ; it != gf->edgeLoops.end() ; it++) { std::vector<BDS_Point* > edgeLoop_BDS; - buildConsecutiveListOfVertices ( gf, *it , edgeLoop_BDS, bbox, m, recover_map , nbPointsTotal); + if(buildConsecutiveListOfVertices ( gf, *it , edgeLoop_BDS, bbox, m, recover_map , nbPointsTotal)==false)return false; edgeLoops_BDS.push_back(edgeLoop_BDS); } } @@ -1311,7 +1320,7 @@ void gmsh2DMeshGeneratorPeriodic ( GFace *gf ) /// Increase the size of the bounding box by 20 % /// add 4 points than encloses the domain /// Use negative number to distinguish thos fake vertices - bbox *= 1.5; + bbox *= 3.5; MVertex *bb[4]; bb[0] = new MVertex ( bbox.min().x(), bbox.min().y(), 0,0,-1); @@ -1363,7 +1372,11 @@ void gmsh2DMeshGeneratorPeriodic ( GFace *gf ) for ( int j=0;j<edgeLoop_BDS.size();j++) { BDS_Edge * e = m->recover_edge ( edgeLoop_BDS[j]->iD,edgeLoop_BDS[(j+1)%edgeLoop_BDS.size()]->iD); - if (!e)Msg(GERROR,"impossible to recover the edge %d %d\n",edgeLoop_BDS[j]->iD,edgeLoop_BDS[(j+1)%edgeLoop_BDS.size()]->iD); + if (!e) + { + Msg(GERROR,"impossible to recover the edge %d %d\n",edgeLoop_BDS[j]->iD,edgeLoop_BDS[(j+1)%edgeLoop_BDS.size()]->iD); + return false; + } else e->g = &CLASS_E; } } @@ -1554,9 +1567,9 @@ void meshGFace :: operator() (GFace *gf) Msg(DEBUG1, "Generating the mesh"); // mesh the face - gmsh2DMeshGeneratorPeriodic ( gf ) ; + gmsh2DMeshGeneratorPeriodic ( gf ) ; // else - //gmsh2DMeshGenerator ( gf ) ; + //gmsh2DMeshGenerator ( gf ) ; Msg(DEBUG1, "type %d %d triangles generated, %d internal vertices",