STYLE: viewFactorsGen with std::vector (reserve) instead of std::list

This commit is contained in:
Mark Olesen
2022-10-25 14:53:24 +02:00
parent 24ffc5236d
commit b145e59049
2 changed files with 25 additions and 17 deletions

View File

@ -25,7 +25,7 @@ dict.add("mergeDistance", SMALL);
labelList triSurfaceToAgglom(5*nFineFaces);
triSurface localSurface = triangulate
const triSurface localSurface = triangulate
(
patches,
includePatches,
@ -57,28 +57,35 @@ triSurfaceToAgglom.resize(surfacesMesh.size());
surfacesMesh.setField(triSurfaceToAgglom);
const pointField& pts = surfacesMesh.localPoints();
std::vector<Triangle> triangles;
std::list<Triangle> triangles;
for (const auto& triLocal : surfacesMesh.localFaces())
{
point p1l = pts[triLocal[0]];
point p2l = pts[triLocal[1]];
point p3l = pts[triLocal[2]];
const auto& surf = static_cast<const triSurface&>(surfacesMesh);
Point p1(p1l[0], p1l[1], p1l[2]);
Point p2(p2l[0], p2l[1], p2l[2]);
Point p3(p3l[0], p3l[1], p3l[2]);
triangles.reserve(surf.size());
Triangle tri(p1, p2, p3);
const pointField& pts = surf.points();
if (tri.is_degenerate())
for (const auto& f : surf)
{
std::cout << tri << std::endl;
const point& a = pts[f.a()];
const point& b = pts[f.b()];
const point& c = pts[f.c()];
triangles.emplace_back
(
Point(a.x(), a.y(), a.z()),
Point(b.x(), b.y(), b.z()),
Point(c.x(), c.y(), c.z())
);
if (triangles.back().is_degenerate())
{
std::cout << triangles.back() << std::endl;
}
}
triangles.push_back(tri);
}
// constructs AABB tree
Tree tree(triangles.begin(), triangles.end());

View File

@ -100,6 +100,7 @@ Description
#endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
#include <vector>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
@ -112,7 +113,7 @@ typedef K::Direction_3 Vector3C;
typedef K::Triangle_3 Triangle;
typedef K::Segment_3 Segment;
typedef std::list<Triangle>::iterator Iterator;
typedef std::vector<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
@ -872,7 +873,7 @@ int main(int argc, char *argv[])
GaussPoints[4][4] = -GaussPoints[4][3];
List<scalarList> GaussWeights(5);
FixedList<scalarList, 5> GaussWeights;
GaussWeights[0].setSize(1);
GaussWeights[0] = 2;