ENH: cv2DMesh: Do not add empty patches

This commit is contained in:
laurence
2013-01-04 12:47:56 +00:00
parent a517fbfcbe
commit 660ddd6d70
3 changed files with 27 additions and 10 deletions

View File

@ -36,14 +36,20 @@ Description
#include "CGAL/Delaunay_triangulation_2.h" #include "CGAL/Delaunay_triangulation_2.h"
#ifdef CGAL_INEXACT #ifdef CGAL_INEXACT
// Fast kernel using a double as the storage type but the triangulation // Fast kernel using a double as the storage type but the triangulation
// may fail // may fail
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h" #include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
#else #else
// Very robust but expensive kernel // Very robust but expensive kernel
#include "CGAL/Exact_predicates_exact_constructions_kernel.h" #include "CGAL/Exact_predicates_exact_constructions_kernel.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef CGAL::Exact_predicates_exact_constructions_kernel K;
#endif #endif

View File

@ -50,17 +50,22 @@ typedef CGAL::indexedVertex<K> Vb;
typedef CGAL::indexedFace<K> Fb; typedef CGAL::indexedFace<K> Fb;
#ifdef CGAL_HIERARCHY #ifdef CGAL_HIERARCHY
// Data structures for hierarchical Delaunay triangulation which is more // Data structures for hierarchical Delaunay triangulation which is more
// efficient but also uses more storage // efficient but also uses more storage
#include "CGAL/Triangulation_hierarchy_2.h" #include "CGAL/Triangulation_hierarchy_2.h"
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vb> Vbh; typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vb> Vbh;
typedef CGAL::Triangulation_data_structure_2<Vbh, Fb> Tds; typedef CGAL::Triangulation_data_structure_2<Vbh, Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> DT; typedef CGAL::Delaunay_triangulation_2<K, Tds> DT;
typedef CGAL::Triangulation_hierarchy_2<DT> Delaunay; typedef CGAL::Triangulation_hierarchy_2<DT> Delaunay;
#else #else
// Data structures for standard Delaunay triangulation // Data structures for standard Delaunay triangulation
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds; typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay; typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay;
#endif #endif

View File

@ -163,20 +163,26 @@ int main(int argc, char *argv[])
Info<< "Constructing patches." << endl; Info<< "Constructing patches." << endl;
List<polyPatch*> patches(poly2DMesh.patchNames().size()); List<polyPatch*> patches(poly2DMesh.patchNames().size());
label countPatches = 0;
forAll(patches, patchI) forAll(patches, patchI)
{ {
patches[patchI] = new polyPatch if (poly2DMesh.patchSizes()[patchI] != 0)
( {
poly2DMesh.patchNames()[patchI], patches[countPatches] = new polyPatch
poly2DMesh.patchSizes()[patchI], (
poly2DMesh.patchStarts()[patchI], poly2DMesh.patchNames()[patchI],
patchI, poly2DMesh.patchSizes()[patchI],
pMesh.boundaryMesh(), poly2DMesh.patchStarts()[patchI],
word::null countPatches,
); pMesh.boundaryMesh(),
} word::null
);
countPatches++;
}
}
patches.setSize(countPatches);
pMesh.addPatches(patches); pMesh.addPatches(patches);
if (extrude) if (extrude)