132 {
133
135
136
137 MFloat vv[3][3] = {{F0, F0, F0}, {F0, F0, F0}, {F0, F0, F0}};
138
140 noVertices = nDim_;
141
142 for(
MInt i = 0; i < noVertices; i++)
143 for(
MInt j = 0; j < nDim_; j++) {
145 }
146
147
148 MFloat ro[3] = {0.0, 0.0, 0.0}, uv[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, quv[2] = {0.0, 0.0};
149 for(
MInt i = 0; i < noVertices; i++) {
151 for(
MInt j = 0; j < nDim_ - 1; j++) {
152 uv[(nDim_ - 1) * i + j] = ro[j];
153 }
154 }
155
156
158 for(
MInt j = 0; j < nDim_ - 1; j++)
159 quv[j] = ro[j];
160
161
162 for(
MInt j = 0; j < nDim_ - 1; j++) {
163 for(
MInt i = 0; i < noVertices; i++)
164 uv[(nDim_ - 1) * i + j] -= quv[j];
165 }
166
167
168 IF_CONSTEXPR(nDim_ == 2) {
169 MInt SH = 0, NSH = 0;
170
171 if(uv[0] > 0)
172 SH = 1;
173 else if(
approx(uv[0], 0.0, MFloatEps))
174 SH = 0;
175 else
176 SH = -1;
177
178 if(uv[1] > 0)
179 NSH = 1;
180 else if(
approx(uv[1], 0.0, MFloatEps))
181 NSH = 0;
182 else
183 NSH = -1;
184
185 if((SH != NSH) || (SH == 0) || (NSH == 0)) return 1;
186 }
187 else {
189
190 for(
MInt i = 0; i < noVertices; i++) {
191 MInt ni = (i + 1) % 3;
192
193 MInt SH = 0, NSH = 0;
194
195 if(uv[i * 2 + 1] > 0)
196 SH = 1;
197 else if(
approx(uv[i * 2 + 1], 0.0, MFloatEps))
198 SH = 0;
199 else
200 SH = -1;
201
202 if(uv[ni * 2 + 1] > 0)
203 NSH = 1;
204 else if(
approx(uv[ni * 2 + 1], 0.0, MFloatEps))
205 NSH = 0;
206 else
207 NSH = -1;
208
209
210 if(SH == 0 && NSH == 0) {
211 NC = 1;
212 break;
213 }
214 else if((SH == 0 &&
approx(uv[i * 2 + 0], 0.0, MFloatEps))
215 || (NSH == 0 &&
approx(uv[ni * 2 + 0], 0.0, MFloatEps))) {
216 NC = 1;
217 break;
218 }
else if(
approx((uv[i * 2 + 0]
219 - uv[i * 2 + 1] * (uv[ni * 2 + 0] - uv[i * 2 + 0]) / (uv[ni * 2 + 1] - uv[i * 2 + 1])),
220 0.0, MFloatEps)) {
221 NC = 1;
222 break;
223 }
224 else if(SH != NSH) {
225 if((uv[i * 2 + 0] > 0) && (uv[ni * 2 + 0] > 0))
226 NC++;
227 else if((uv[i * 2 + 0] > 0) || (uv[ni * 2 + 0] > 0)) {
228
229 if((uv[i * 2 + 0] - uv[i * 2 + 1] * (uv[ni * 2 + 0] - uv[i * 2 + 0]) / (uv[ni * 2 + 1] - uv[i * 2 + 1]))
230 > 0)
231 NC++;
232 }
233 }
234 }
235 if((NC % 2) != 0) {
236 return 1;
237 }
238 }
239 return 0;
240 }
void transformationmatrix(GeometryElement< nDim_ > *el, MFloat tr[3][3])
void rotation(const MFloat q[3], MFloat r[3], MFloat tr[3][3])
MBool approx(const T &, const U &, const T)