FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Selection.hpp
1#ifndef SELECTION_HPP
2#define SELECTION_HPP
3
4#include "fish/fiber/grid/types/LineSet.hpp"
5#include <fish/fiber/baseop/ExpandBBox.hpp>
6#include "gridopDllApi.h"
7
8// #define SELECTIONBYSHAPE_TEST
9
10namespace Fiber
11{
14
15
16#if 1
17
18RefPtr<Chunk<bool> > gridop_API computeIndicesSelectionByShape(const std::vector<Eagle::PhysicalSpace::point>&polygon_coords,
19 const std::vector<LineSet::LineIndices_t>&polygon_indices,
21 const RefPtr<Eagle::BoundingBox>&frag_bbox);
22
23RefPtr<Chunk<uint32_t> > gridop_API computeIndicesSelectionByShape(const std::vector<Eagle::PhysicalSpace::point>&polygon_coords,
24 const std::vector<LineSet::LineIndices_t>&polygon_indices,
26 const RefPtr<Eagle::BoundingBox>&frag_bbox,
27 bool Inverse);
28
29
30
31#else
32
33template<typename T>
35 const MultiArray<1,std::vector<uint32_t>>& polygon_indices,
36 const MultiArray<1,Eagle::PhysicalSpace::point>& pointcloud,
37 const RefPtr<Eagle::BoundingBox>& frag_bbox)
38{
39std::vector<std::vector<Eagle::PhysicalSpace::point>> clipping(polygon_indices.nElements());
40
41 for (unsigned i = 0; i < polygon_indices.nElements(); i++)
42 clipping[i] = polygonClipping(polygon_coords, polygon_indices[i], frag_bbox);
43
44const unsigned size = pointcloud.nElements();
45
46std::vector<bool> inside(size, false);
47std::vector<bool> part_of_polygon(size, false);
48
49#ifdef USE_OPENMP
50#pragma omp parallel for schedule(dynamic, 50000)
51#endif
52 for (unsigned i = 0; i < size; i++)
53 {
54 const Eagle::PhysicalSpace::point& p = pointcloud[i];
55
57 {
58 if (v.size() < 3) continue;
59
60 int value = pointInPolygon(p,v);
61
62 if (value == 0)
63 {
64 part_of_polygon[i] = true;
65 break;
66 }
67
68 if (value > 0)
69 {
70 inside[i] = true;
71 break;
72 }
73 }
74 }
75
76// handle case where the points are part of the polygon
77
78 if (std::count(part_of_polygon.begin(), part_of_polygon.end(), true) > 0)
79 {
80// std::cout << "----- investigation of part_of_polygon points: " << std::count(part_of_polygon.begin(), part_of_polygon.end(), true) << " points" << std::endl;
81
82#ifdef USE_OPENMP
83#pragma omp parallel for schedule(dynamic, 50000)
84#endif
85 for (unsigned i = 0; i < size; i++)
86 {
87 if (!part_of_polygon[i]) continue; // only look at points which lie on the polygon
88
89 const Eagle::PhysicalSpace::point& p = pointcloud[i];
90
91 for (std::vector<uint32_t> line : polygon_indices)
92 {
93 if (line.size() < 3) continue;
94
95 if (pointInPolygon(p,polygon_coords,line) >= 0)
96 {
97 inside[i] = true;
98 break;
99 }
100 }
101 }
102 }
103// else
104// std::cout << "----- no investigation of part_of_polygon points" << std::endl;
105
106 return inside;
107}
108
109#endif
110
111}
112
113#endif // SELECTION_HPP
valarray< size_t > size() const
constexpr iterator_traits< _InputIterator >::difference_type count(_InputIterator __first, _InputIterator __last, const _Tp &__value)
Field Inversion.
Definition Inverse.cpp:96
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
RefPtr< Chunk< bool > > computeIndicesSelectionByShape(const std::vector< Eagle::PhysicalSpace::point > &polygon_coords, const std::vector< LineSet::LineIndices_t > &polygon_indices, const std::vector< Eagle::PhysicalSpace::point > &pointcloud, const RefPtr< Eagle::BoundingBox > &frag_bbox)
Definition Selection.cpp:120