13 #ifdef HMFC_STATIC_LIB
14 # error "Code cannot be statically linked."
27 #include "HOpSelectPolygon.h"
28 #include "HSelectionSetOOC.h"
40 template <
typename SelectionSet>
54 return "HOpSelectPolygonOOC";
73 GetSelectionSet().DeSelectAll();
88 std::vector<ooc::Point>
const triangles(ComputePolygonTriangles());
90 for (
size_t i = 0; i < triangles.size(); i += 3) {
106 std::vector<ooc::Point> ComputePolygonTriangles ()
108 std::vector<ooc::Point> triangles;
110 HC_Open_Segment(
"/");{
111 HC_KEY segment_key = HC_Open_Segment(
"");{
113 HC_KEY shell_key = HC_Generate_Shell_From_Geometry(polygon_key,
"");
117 HC_Show_Shell_By_Tristrips_Size(shell_key, &point_count, &tristrip_count, 0);
118 std::vector<ooc::Point> points(point_count);
119 std::vector<int> tristrips(tristrip_count);
120 HC_Show_Shell_By_Tristrips(shell_key, 0, points.data(), 0, tristrips.data(), 0, 0);
122 triangles = ComputeTrianglesFromTristrips(points, tristrips);
125 HC_Delete_By_Key(segment_key);
131 static bool IsDegenerate (
int const (&triangle_indices)[3])
133 if (triangle_indices[0] == triangle_indices[1]) {
136 if (triangle_indices[0] == triangle_indices[2]) {
139 if (triangle_indices[1] == triangle_indices[2]) {
145 static std::vector<ooc::Point> ComputeTrianglesFromTristrips (
146 std::vector<ooc::Point>
const & points,
147 std::vector<int>
const & tristrips)
149 std::vector<ooc::Point> triangles;
151 for (
size_t i = 0; i < tristrips.size(); ) {
152 size_t const strip_len = tristrips[i++];
153 ASSERT(i + strip_len <= tristrips.size());
154 for (
size_t j = 2; j < strip_len; ++j) {
155 ASSERT(i + j < tristrips.size());
156 int triangle_indices[] = {
157 tristrips[i + j - 2],
158 tristrips[i + j - 1],
159 tristrips[i + j - 0],
161 if (!IsDegenerate(triangle_indices)) {
162 for (
size_t k = 0; k < 3; ++k) {
163 triangles.push_back(points[triangle_indices[k]]);
Definition: HSelectionSetOOC.h:77
HOpSelectPolygonOOC(HBaseView &view)
Definition: HOpSelectPolygonOOC.h:46
The HOpSelectPolygon class computes a selection list for objects inside a user-defined polygonal area...
Definition: HOpSelectPolygon.h:46
virtual int OnLButtonDblClk(HEventInfo &e)
Definition: HOpSelectPolygonOOC.h:81
virtual int OnLButtonDown(HEventInfo &hevent)
The HSelectionSet class manages a list of selected items.
Definition: HSelectionSet.h:66
virtual HBaseOperator * Clone()
Definition: HOpSelectPolygonOOC.h:61
Definition: HOpSelectPolygonOOC.h:41
int m_PolylineCount
Definition: HOpConstructPolyline.h:104
void AddTriangleWindow(ooc::Point const &p1, ooc::Point const &p2, ooc::Point const &p3)
Definition: HSelectionSetOOC.h:420
HSelectionSet * GetSelection()
Definition: HBaseView.h:696
auto SynchronizeWith(Func const &task) -> decltype(task())
Definition: HSelectionSetOOC.h:436
The HBaseOperator class serves as a base for classes which handle user input and operate on the scene...
Definition: HBaseOperator.h:60
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:332
HBaseView * GetView()
Returns a pointer to the view that this operator is associated with.
Definition: HBaseOperator.h:103
The HEventInfo class stores and manages event information.
Definition: HEventInfo.h:207
virtual int OnLButtonDown(HEventInfo &e)
Definition: HOpSelectPolygonOOC.h:71
virtual char const * GetName()
Definition: HOpSelectPolygonOOC.h:52
HPoint * m_pPolyline
Definition: HOpConstructPolyline.h:103
virtual int OnLButtonDblClk(HEventInfo &hevent)