diff --git a/Geo/SOrientedBoundingBox.cpp b/Geo/SOrientedBoundingBox.cpp index 755fa8b3786a80486251e2b951dd6eb646df6ff8..76d000db2e9d7fdad0f9b13326dfcae7f2e82c90 100644 --- a/Geo/SOrientedBoundingBox.cpp +++ b/Geo/SOrientedBoundingBox.cpp @@ -314,13 +314,13 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic center[0] = (vmaxs(0)+vmins(0))/2.0; center[1] = (vmaxs(1)+vmins(1))/2.0; center[2] = (vmaxs(2)+vmins(2))/2.0; - + return(new SOrientedBoundingBox(center, sizes[0], sizes[1], sizes[2], Axis1, Axis2, Axis3)); } - - // We take the smallest component, then project the data on the plane defined by the other twos + // We take the smallest component, then project the data on the plane defined + // by the other twos int smallest_comp = 0; if (sizes[0] <= sizes[1] && sizes[0] <= sizes[2]) @@ -334,9 +334,11 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic // We just ignore the coordinate corresponding to smallest_comp. std::vector<SPoint2*> points; for (int i = 0; i < num_vertices; i++) { - SPoint2* p = new SPoint2(projected(smallest_comp==0?1:0,i), projected(smallest_comp==2?1:2,i)); + SPoint2* p = new SPoint2(projected(smallest_comp==0?1:0,i), + projected(smallest_comp==2?1:2,i)); bool keep = true; - for (std::vector<SPoint2*>::iterator point = points.begin();point != points.end();point++) { + for (std::vector<SPoint2*>::iterator point = points.begin(); + point != points.end();point++) { if ( fabs((*p)[0] -(**point)[0]) < 10e-10 && fabs((*p)[1] -(**point)[1]) < 10e-10 ) { keep = false; break; @@ -354,12 +356,19 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic record.numPoints = points.size(); srand((unsigned)time(0)); for (unsigned int i = 0; i < points.size(); i++) { - record.points[i].where.h = points[i]->x()+(10e-6)*sizes[smallest_comp==0?1:0]*(-0.5+((double)rand())/RAND_MAX); - record.points[i].where.v = points[i]->y()+(10e-6)*sizes[smallest_comp==2?1:0]*(-0.5+((double)rand())/RAND_MAX); + record.points[i].where.h = points[i]->x()+ + (10e-6)*sizes[smallest_comp==0?1:0]*(-0.5+((double)rand())/RAND_MAX); + record.points[i].where.v = points[i]->y()+ + (10e-6)*sizes[smallest_comp==2?1:0]*(-0.5+((double)rand())/RAND_MAX); record.points[i].adjacent = NULL; } - record.MakeMeshWithPoints(); + try{ + record.MakeMeshWithPoints(); + } + catch(const char *err){ + Msg::Error("%s", err); + } std::vector<Segment> convex_hull; for (int i = 0; i < record.numTriangles; i++) { @@ -373,8 +382,10 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic for (int j = 0; j < 3; j++) { bool okay = true; - for (std::vector<Segment>::iterator seg = convex_hull.begin(); seg != convex_hull.end(); seg++) { - if ( ((*seg).from == segs[j].from && (*seg).from == segs[j].to) || ((*seg).from == segs[j].to && (*seg).from == segs[j].from)) { + for (std::vector<Segment>::iterator seg = convex_hull.begin(); + seg != convex_hull.end(); seg++) { + if ( ((*seg).from == segs[j].from && (*seg).from == segs[j].to) || + ((*seg).from == segs[j].to && (*seg).from == segs[j].from)) { convex_hull.erase(seg); okay = false; break; @@ -401,7 +412,8 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic least_rectangle.size->at(0) = -1; least_rectangle.size->at(1) = 1; - for (std::vector<Segment>::iterator seg = convex_hull.begin(); seg != convex_hull.end(); seg++) { + for (std::vector<Segment>::iterator seg = convex_hull.begin(); + seg != convex_hull.end(); seg++) { fullVector<double> segment(2); //segment(0) = record.points[(*seg).from].where.h - record.points[(*seg).to].where.h; @@ -457,7 +469,8 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic rotation_inv.mult(axis2,axis_rot2); //*/ - if ((least_rectangle.area() == -1) || (max_x-min_x)*(max_y-min_y) < least_rectangle.area()) { + if ((least_rectangle.area() == -1) || + (max_x-min_x)*(max_y-min_y) < least_rectangle.area()) { least_rectangle.size->at(0) = max_x-min_x; least_rectangle.size->at(1) = max_y-min_y; @@ -499,8 +512,8 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic raw_data[2][2+i] = least_rectangle.axisY->at(0)*left_eigv(i,smallest_comp==0?1:0) + least_rectangle.axisY->at(1)*left_eigv(i,smallest_comp==2?1:2); } - // Msg::Info("Test 1 : %f %f",least_rectangle.center->at(0),least_rectangle.center->at(1)); -// Msg::Info("Test 2 : %f %f",least_rectangle.axisY->at(0),least_rectangle.axisY->at(1)); + // Msg::Info("Test 1 : %f %f",least_rectangle.center->at(0),least_rectangle.center->at(1)); + // Msg::Info("Test 2 : %f %f",least_rectangle.axisY->at(0),least_rectangle.axisY->at(1)); int tri[3]; @@ -558,7 +571,8 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic aux2(i) = left_eigv(i,smallest_comp==0?1:0); aux3(i) = left_eigv(i,smallest_comp==2?1:2); } - center = aux1*center_pca + aux2*least_rectangle.center->at(0) + aux3*least_rectangle.center->at(1); + center = aux1*center_pca + aux2*least_rectangle.center->at(0) + + aux3*least_rectangle.center->at(1); //center[1] = -center[1]; /* @@ -578,7 +592,8 @@ SOrientedBoundingBox* SOrientedBoundingBox::buildOBB(std::vector<SPoint3> vertic #endif } -double SOrientedBoundingBox::compare(SOrientedBoundingBox& obb1, SOrientedBoundingBox& obb2) +double SOrientedBoundingBox::compare(SOrientedBoundingBox& obb1, + SOrientedBoundingBox& obb2) { // "center term" double center_term = norm(obb1.getCenter() - obb2.getCenter()); @@ -587,7 +602,8 @@ double SOrientedBoundingBox::compare(SOrientedBoundingBox& obb1, SOrientedBoundi double size_term = 0.0; for (int i = 0; i < 3; i++) { if ((obb1.getSize())(i) + (obb2.getSize())(i) != 0) { - size_term += fabs((obb1.getSize())(i) - (obb2.getSize())(i)) / ((obb1.getSize())(i) + (obb2.getSize())(i)); + size_term += fabs((obb1.getSize())(i) - (obb2.getSize())(i)) / + ((obb1.getSize())(i) + (obb2.getSize())(i)); } } @@ -598,5 +614,4 @@ double SOrientedBoundingBox::compare(SOrientedBoundingBox& obb1, SOrientedBoundi } return (center_term + size_term + orientation_term); - } diff --git a/Mesh/DivideAndConquer.cpp b/Mesh/DivideAndConquer.cpp index d23a3c773f48821db71c464a3fb7acc5baad46d6..9794a33fc40a362b28fb897e1278d724b23a2766 100644 --- a/Mesh/DivideAndConquer.cpp +++ b/Mesh/DivideAndConquer.cpp @@ -162,8 +162,8 @@ Segment DocRecord::UpperCommonTangent(DT vl, DT vr) int DocRecord::Qtest(PointNumero h, PointNumero i, PointNumero j, PointNumero k) { if((h == i) && (h == j) && (h == k)) { - Msg::Error("Identical points in triangulation: increase element size " - "or Mesh.RandomFactor"); + throw "Identical points in triangulation: increase element size " + "or Mesh.RandomFactor"; return 0; } @@ -959,7 +959,13 @@ void DocRecord::concave(double x,double y,GFace* gf) points[i].vicinity.clear(); } - MakeMeshWithPoints(); + try{ + MakeMeshWithPoints(); + } + catch(const char *err){ + Msg::Error("%s", err); + } + set = tagInterior(x,y); for(it2 = set.begin(); it2 != set.end(); it2++){ index1 = triangles[*it2].a; diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 4983a94e88a5dd68fb7dae6876b871d65da83a9f..251b169b58b78696c1e08e04c4c4cf49e7eb30bc 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1090,7 +1090,12 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, // -) It contains triangles outside the domain (the first edge // loop is the outer one) Msg::Debug("Meshing of the convex hull (%d points)", points.size()); - doc.MakeMeshWithPoints(); + try{ + doc.MakeMeshWithPoints(); + } + catch(const char *err){ + Msg::Error("%s", err); + } Msg::Debug("Meshing of the convex hull (%d points) done", points.size()); for(int i = 0; i < doc.numTriangles; i++) { @@ -1900,7 +1905,13 @@ static bool meshGeneratorPeriodic(GFace *gf, bool debug = true) // -) It contains triangles outside the domain (the first edge // loop is the outer one) Msg::Debug("Meshing of the convex hull (%d points)", nbPointsTotal); - doc.MakeMeshWithPoints(); + + try{ + doc.MakeMeshWithPoints(); + } + catch(const char *err){ + Msg::Error("%s", err); + } for(int i = 0; i < doc.numTriangles; i++){ int a = doc.triangles[i].a; diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp index 144421414fd8845db8263e183e4613016d1d1eb1..4b9880b41b8b760f1b9660baeca7f1dcae39abe3 100644 --- a/Plugin/Triangulate.cpp +++ b/Plugin/Triangulate.cpp @@ -138,7 +138,12 @@ PView *GMSH_TriangulatePlugin::execute(PView *v) } // triangulate - doc.MakeMeshWithPoints(); + try{ + doc.MakeMeshWithPoints(); + } + catch(const char *err){ + Msg::Error("%s", err); + } // create output (using unperturbed data) PView *v2 = new PView(); diff --git a/benchmarks/extrude/aorta_extrude.geo b/benchmarks/extrude/aorta_extrude.geo index 58b7881b7da531d3aaba23d510224e7fbe253c75..7bf9a30adecbc9fd2b6d95fde97fdb5c9971a576 100644 --- a/benchmarks/extrude/aorta_extrude.geo +++ b/benchmarks/extrude/aorta_extrude.geo @@ -1,7 +1,7 @@ Merge "aorta2.stl"; CreateTopology; -//Merge "aortaRADIUS2.bgm"; +Merge "aortaRADIUS2.bgm"; // create a boundary layer, whose tickness is given in View[0] out1[] = Extrude{Surface{-1}; Layers{4, 0.5}; Using Index[0]; Using View[0]; };