forked from mcneel/opennurbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopennurbs_mesh_topology.cpp
188 lines (163 loc) · 4.84 KB
/
opennurbs_mesh_topology.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
#include "opennurbs.h"
#if !defined(ON_COMPILING_OPENNURBS)
// This check is included in all opennurbs source .c and .cpp files to insure
// ON_COMPILING_OPENNURBS is defined when opennurbs source is compiled.
// When opennurbs source is being compiled, ON_COMPILING_OPENNURBS is defined
// and the opennurbs .h files alter what is declared and how it is declared.
#error ON_COMPILING_OPENNURBS must be defined when compiling opennurbs
#endif
///////////////////////////////////////////////////////////////////
//
// ON_MeshFaceSide
//
#pragma region ON_MeshFaceSide implementation
static ON_MeshFaceSide ON_MeshFaceSide_UnsetInitializer()
{
ON_MeshFaceSide unset;
memset(&unset,0,sizeof(unset));
return unset;
}
const ON_MeshFaceSide ON_MeshFaceSide::Unset = ON_MeshFaceSide_UnsetInitializer();
///////////////////////////////////////////////////////////////////
//
// ON_MeshFaceSide - sort by vertex index
//
#define ON_COMPILING_OPENNURBS_QSORT_FUNCTIONS
#define ON_SORT_TEMPLATE_STATIC_FUNCTION
#define ON_SORT_TEMPLATE_TYPE ON_MeshFaceSide
#define ON_SORT_TEMPLATE_COMPARE ON__MeshFaceSide_compare_m_vi
static int ON_SORT_TEMPLATE_COMPARE(
ON_SORT_TEMPLATE_TYPE const * side1,
ON_SORT_TEMPLATE_TYPE const * side2
)
{
if ( side1->m_vi[0] < side2->m_vi[0] )
return -1;
if ( side1->m_vi[0] > side2->m_vi[0] )
return 1;
if ( side1->m_vi[1] < side2->m_vi[1] )
return -1;
if ( side1->m_vi[1] > side2->m_vi[1] )
return 1;
if ( side1->m_fi < side2->m_fi )
return -1;
if ( side1->m_fi > side2->m_fi )
return 1;
if ( side1->m_side < side2->m_side )
return -1;
if ( side1->m_side > side2->m_side )
return 1;
if ( side1->m_dir < side2->m_dir )
return -1;
if ( side1->m_dir > side2->m_dir )
return 1;
return 0;
}
#define ON_QSORT_FNAME ON__MeshFaceSide_qsort_m_vi
#include "opennurbs_qsort_template.h"
int ON_MeshFaceSide::CompareVertexIndex(
const ON_MeshFaceSide* a,
const ON_MeshFaceSide* b
)
{
if ( 0 == a )
a = &ON_MeshFaceSide::Unset;
if ( 0 == b )
b = &ON_MeshFaceSide::Unset;
return ON_SORT_TEMPLATE_COMPARE(a,b);
}
void ON_MeshFaceSide::SortByVertexIndex(
ON_MeshFaceSide* face_sides,
size_t face_sides_count
)
{
if ( face_sides_count >= 2 && 0 != face_sides )
ON_QSORT_FNAME( face_sides, face_sides_count );
}
#undef ON_QSORT_FNAME
#undef ON_SORT_TEMPLATE_COMPARE
///////////////////////////////////////////////////////////////////
//
// ON_MeshFaceSide - sort by face index
//
#define ON_SORT_TEMPLATE_HAVE_SHORT_SORT
#define ON_SORT_TEMPLATE_COMPARE ON__MeshFaceSide_compare_m_fi
static int ON_SORT_TEMPLATE_COMPARE(
ON_SORT_TEMPLATE_TYPE const * side1,
ON_SORT_TEMPLATE_TYPE const * side2
)
{
if ( side1->m_fi < side2->m_fi )
return -1;
if ( side1->m_fi > side2->m_fi )
return 1;
if ( side1->m_vi[0] < side2->m_vi[0] )
return -1;
if ( side1->m_vi[0] > side2->m_vi[0] )
return 1;
if ( side1->m_vi[1] < side2->m_vi[1] )
return -1;
if ( side1->m_vi[1] > side2->m_vi[1] )
return 1;
if ( side1->m_side < side2->m_side )
return -1;
if ( side1->m_side > side2->m_side )
return 1;
if ( side1->m_dir < side2->m_dir )
return -1;
if ( side1->m_dir > side2->m_dir )
return 1;
return 0;
}
#define ON_QSORT_FNAME ON__MeshFaceSide_qsort_m_fi
#include "opennurbs_qsort_template.h"
int ON_MeshFaceSide::CompareFaceIndex(
const ON_MeshFaceSide* a,
const ON_MeshFaceSide* b
)
{
if ( 0 == a )
a = &ON_MeshFaceSide::Unset;
if ( 0 == b )
b = &ON_MeshFaceSide::Unset;
return ON_SORT_TEMPLATE_COMPARE(a,b);
}
void ON_MeshFaceSide::SortByFaceIndex(
ON_MeshFaceSide* face_sides,
size_t face_sides_count
)
{
if ( face_sides_count >= 2 && 0 != face_sides )
ON_QSORT_FNAME( face_sides, face_sides_count );
}
///////////////////////////////////////////////////////////////////
//
// done using sort template for ON_MeshFaceSide
//
#undef ON_COMPILING_OPENNURBS_QSORT_FUNCTIONS
#undef ON_SORT_TEMPLATE_STATIC_FUNCTION
#undef ON_SORT_TEMPLATE_TYPE
#undef ON_QSORT_FNAME
#undef ON_SORT_TEMPLATE_HAVE_SHORT_SORT
#undef ON_QSORT_SHORT_SORT_FNAME
//
// done using sort template for ON_MeshFaceSide
//
///////////////////////////////////////////////////////////////////
#pragma endregion
//
// ON_MeshFaceSide
//
///////////////////////////////////////////////////////////////////