1
/***************************************************************************
2
* Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
#include <Inventor/nodes/SoBaseColor.h>
26
#include <Inventor/nodes/SoCoordinate3.h>
27
#include <Inventor/nodes/SoDrawStyle.h>
28
#include <Inventor/nodes/SoFaceSet.h>
29
#include <Inventor/nodes/SoLineSet.h>
30
#include <Inventor/nodes/SoMarkerSet.h>
31
#include <Inventor/nodes/SoSeparator.h>
32
#include <Inventor/nodes/SoShapeHints.h>
35
#include <App/Application.h>
36
#include <Base/Parameter.h>
37
#include <Gui/Inventor/MarkerBitmaps.h>
38
#include <Mod/Mesh/App/MeshFeature.h>
39
#include <Mod/Mesh/App/Core/Degeneration.h>
40
#include <Mod/Mesh/App/Core/Iterator.h>
42
#include "ViewProviderDefects.h"
46
using namespace MeshGui;
49
PROPERTY_SOURCE_ABSTRACT(MeshGui::ViewProviderMeshDefects, Gui::ViewProviderDocumentObject)
50
PROPERTY_SOURCE(MeshGui::ViewProviderMeshOrientation, MeshGui::ViewProviderMeshDefects)
51
PROPERTY_SOURCE(MeshGui::ViewProviderMeshNonManifolds, MeshGui::ViewProviderMeshDefects)
52
PROPERTY_SOURCE(MeshGui::ViewProviderMeshNonManifoldPoints, MeshGui::ViewProviderMeshDefects)
53
PROPERTY_SOURCE(MeshGui::ViewProviderMeshDuplicatedFaces, MeshGui::ViewProviderMeshDefects)
54
PROPERTY_SOURCE(MeshGui::ViewProviderMeshDuplicatedPoints, MeshGui::ViewProviderMeshDefects)
55
PROPERTY_SOURCE(MeshGui::ViewProviderMeshDegenerations, MeshGui::ViewProviderMeshDefects)
56
PROPERTY_SOURCE(MeshGui::ViewProviderMeshIndices, MeshGui::ViewProviderMeshDefects)
57
PROPERTY_SOURCE(MeshGui::ViewProviderMeshSelfIntersections, MeshGui::ViewProviderMeshDefects)
58
PROPERTY_SOURCE(MeshGui::ViewProviderMeshFolds, MeshGui::ViewProviderMeshDefects)
60
ViewProviderMeshDefects::ViewProviderMeshDefects()
62
ADD_PROPERTY(LineWidth, (2.0F));
64
pcCoords = new SoCoordinate3();
66
pcDrawStyle = new SoDrawStyle();
68
pcDrawStyle->style = SoDrawStyle::LINES;
69
pcDrawStyle->lineWidth = LineWidth.getValue();
72
ViewProviderMeshDefects::~ViewProviderMeshDefects()
78
void ViewProviderMeshDefects::onChanged(const App::Property* prop)
80
if (prop == &LineWidth) {
81
pcDrawStyle->lineWidth = LineWidth.getValue();
83
// Visibility changes must be handled here because in the base class it changes the attribute of
84
// the feature and thus affects the visibility of the mesh view provider which is undesired
86
else if (prop == &Visibility) {
87
Visibility.getValue() ? show() : hide();
90
ViewProviderDocumentObject::onChanged(prop);
94
// ----------------------------------------------------------------------
96
ViewProviderMeshOrientation::ViewProviderMeshOrientation()
99
pcFaces = new SoFaceSet;
104
ViewProviderMeshOrientation::~ViewProviderMeshOrientation()
109
void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat)
111
ViewProviderDocumentObject::attach(pcFeat);
113
SoGroup* pcFaceRoot = new SoGroup();
115
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
116
pcFlatStyle->style = SoDrawStyle::FILLED;
117
pcFaceRoot->addChild(pcFlatStyle);
119
SoShapeHints* flathints = new SoShapeHints;
120
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
121
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
122
pcFaceRoot->addChild(flathints);
125
SoSeparator* linesep = new SoSeparator;
126
SoBaseColor* basecol = new SoBaseColor;
127
basecol->rgb.setValue(1.0F, 0.5F, 0.0F);
128
linesep->addChild(basecol);
129
linesep->addChild(pcCoords);
130
linesep->addChild(pcFaces);
133
SoBaseColor* markcol = new SoBaseColor;
134
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
135
SoMarkerSet* marker = new SoMarkerSet;
136
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
138
App::GetApplication()
139
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
140
->GetInt("MarkerSize", 7));
141
linesep->addChild(markcol);
142
linesep->addChild(marker);
144
pcFaceRoot->addChild(linesep);
146
addDisplayMaskMode(pcFaceRoot, "Face");
149
void ViewProviderMeshOrientation::showDefects(const std::vector<Mesh::ElementIndex>& inds)
151
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
152
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
154
pcCoords->point.deleteValues(0);
155
pcCoords->point.setNum(3 * inds.size());
156
MeshCore::MeshFacetIterator cF(rMesh);
159
for (Mesh::ElementIndex ind : inds) {
161
for (auto cP : cF->_aclPoints) {
162
// move a bit in opposite normal direction to overlay the original faces
163
cP -= 0.001F * cF->GetNormal();
164
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
166
pcFaces->numVertices.set1Value(j++, 3);
169
setDisplayMaskMode("Face");
172
// ----------------------------------------------------------------------
174
ViewProviderMeshNonManifolds::ViewProviderMeshNonManifolds()
177
pcLines = new SoLineSet;
182
ViewProviderMeshNonManifolds::~ViewProviderMeshNonManifolds()
187
void ViewProviderMeshNonManifolds::attach(App::DocumentObject* pcFeat)
189
ViewProviderDocumentObject::attach(pcFeat);
191
SoGroup* pcLineRoot = new SoGroup();
192
pcDrawStyle->lineWidth = 3;
193
pcLineRoot->addChild(pcDrawStyle);
196
SoSeparator* linesep = new SoSeparator;
197
SoBaseColor* basecol = new SoBaseColor;
198
basecol->rgb.setValue(1.0F, 0.0F, 0.0F);
199
linesep->addChild(basecol);
200
linesep->addChild(pcCoords);
201
linesep->addChild(pcLines);
202
pcLineRoot->addChild(linesep);
205
SoBaseColor* markcol = new SoBaseColor;
206
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
207
SoMarkerSet* marker = new SoMarkerSet;
208
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
210
App::GetApplication()
211
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
212
->GetInt("MarkerSize", 7));
213
linesep->addChild(markcol);
214
linesep->addChild(marker);
216
addDisplayMaskMode(pcLineRoot, "Line");
219
void ViewProviderMeshNonManifolds::showDefects(const std::vector<Mesh::ElementIndex>& inds)
221
if ((inds.size() % 2) != 0) {
224
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
225
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
227
pcCoords->point.deleteValues(0);
228
pcCoords->point.setNum(inds.size());
229
MeshCore::MeshPointIterator cP(rMesh);
232
for (std::vector<Mesh::ElementIndex>::const_iterator it = inds.begin(); it != inds.end();
235
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
236
++it; // go to end point
238
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
239
pcLines->numVertices.set1Value(j++, 2);
242
setDisplayMaskMode("Line");
245
// ----------------------------------------------------------------------
247
ViewProviderMeshNonManifoldPoints::ViewProviderMeshNonManifoldPoints()
250
pcPoints = new SoPointSet;
255
ViewProviderMeshNonManifoldPoints::~ViewProviderMeshNonManifoldPoints()
260
void ViewProviderMeshNonManifoldPoints::attach(App::DocumentObject* pcFeat)
262
ViewProviderDocumentObject::attach(pcFeat);
264
SoGroup* pcPointRoot = new SoGroup();
265
pcDrawStyle->pointSize = 3;
266
pcPointRoot->addChild(pcDrawStyle);
269
SoSeparator* pointsep = new SoSeparator;
270
SoBaseColor* basecol = new SoBaseColor;
271
basecol->rgb.setValue(1.0F, 0.5F, 0.0F);
272
pointsep->addChild(basecol);
273
pointsep->addChild(pcCoords);
274
pointsep->addChild(pcPoints);
275
pcPointRoot->addChild(pointsep);
278
SoBaseColor* markcol = new SoBaseColor;
279
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
280
SoMarkerSet* marker = new SoMarkerSet;
281
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
283
App::GetApplication()
284
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
285
->GetInt("MarkerSize", 7));
286
pointsep->addChild(markcol);
287
pointsep->addChild(marker);
289
addDisplayMaskMode(pcPointRoot, "Point");
292
void ViewProviderMeshNonManifoldPoints::showDefects(const std::vector<Mesh::ElementIndex>& inds)
294
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
295
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
296
pcCoords->point.deleteValues(0);
297
pcCoords->point.setNum(inds.size());
298
MeshCore::MeshPointIterator cP(rMesh);
300
for (Mesh::ElementIndex ind : inds) {
302
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
305
setDisplayMaskMode("Point");
308
// ----------------------------------------------------------------------
310
ViewProviderMeshDuplicatedFaces::ViewProviderMeshDuplicatedFaces()
313
pcFaces = new SoFaceSet;
318
ViewProviderMeshDuplicatedFaces::~ViewProviderMeshDuplicatedFaces()
323
void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat)
325
ViewProviderDocumentObject::attach(pcFeat);
327
SoGroup* pcFaceRoot = new SoGroup();
329
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
330
pcFlatStyle->style = SoDrawStyle::FILLED;
331
pcFaceRoot->addChild(pcFlatStyle);
333
SoShapeHints* flathints = new SoShapeHints;
334
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
335
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
336
pcFaceRoot->addChild(flathints);
339
SoSeparator* linesep = new SoSeparator;
340
SoBaseColor* basecol = new SoBaseColor;
341
basecol->rgb.setValue(1.0F, 0.0F, 0.0F);
342
linesep->addChild(basecol);
343
linesep->addChild(pcCoords);
344
linesep->addChild(pcFaces);
345
pcFaceRoot->addChild(linesep);
348
SoBaseColor* markcol = new SoBaseColor;
349
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
350
SoMarkerSet* marker = new SoMarkerSet;
351
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
353
App::GetApplication()
354
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
355
->GetInt("MarkerSize", 7));
356
linesep->addChild(markcol);
357
linesep->addChild(marker);
359
addDisplayMaskMode(pcFaceRoot, "Face");
362
void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector<Mesh::ElementIndex>& inds)
364
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
365
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
367
pcCoords->point.deleteValues(0);
368
pcCoords->point.setNum(3 * inds.size());
369
MeshCore::MeshFacetIterator cF(rMesh);
372
for (Mesh::ElementIndex ind : inds) {
374
for (auto cP : cF->_aclPoints) {
375
// move a bit in normal direction to overlay the original faces
376
cP += 0.001F * cF->GetNormal();
377
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
379
pcFaces->numVertices.set1Value(j++, 3);
382
setDisplayMaskMode("Face");
385
// ----------------------------------------------------------------------
387
ViewProviderMeshDuplicatedPoints::ViewProviderMeshDuplicatedPoints()
390
pcPoints = new SoPointSet;
395
ViewProviderMeshDuplicatedPoints::~ViewProviderMeshDuplicatedPoints()
400
void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
402
ViewProviderDocumentObject::attach(pcFeat);
404
SoGroup* pcPointRoot = new SoGroup();
405
pcDrawStyle->pointSize = 3;
406
pcPointRoot->addChild(pcDrawStyle);
409
SoSeparator* pointsep = new SoSeparator;
410
SoBaseColor* basecol = new SoBaseColor;
411
basecol->rgb.setValue(1.0F, 0.5F, 0.0F);
412
pointsep->addChild(basecol);
413
pointsep->addChild(pcCoords);
414
pointsep->addChild(pcPoints);
415
pcPointRoot->addChild(pointsep);
418
SoBaseColor* markcol = new SoBaseColor;
419
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
420
SoMarkerSet* marker = new SoMarkerSet;
421
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
423
App::GetApplication()
424
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
425
->GetInt("MarkerSize", 7));
426
pointsep->addChild(markcol);
427
pointsep->addChild(marker);
429
addDisplayMaskMode(pcPointRoot, "Point");
432
void ViewProviderMeshDuplicatedPoints::showDefects(const std::vector<Mesh::ElementIndex>& inds)
434
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
435
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
436
pcCoords->point.deleteValues(0);
437
pcCoords->point.setNum(inds.size());
438
MeshCore::MeshPointIterator cP(rMesh);
440
for (Mesh::ElementIndex ind : inds) {
442
pcCoords->point.set1Value(i++, cP->x, cP->y, cP->z);
445
setDisplayMaskMode("Point");
448
// ----------------------------------------------------------------------
450
ViewProviderMeshDegenerations::ViewProviderMeshDegenerations()
453
pcLines = new SoLineSet;
458
ViewProviderMeshDegenerations::~ViewProviderMeshDegenerations()
463
void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat)
465
ViewProviderDocumentObject::attach(pcFeat);
467
SoGroup* pcLineRoot = new SoGroup();
468
pcDrawStyle->lineWidth = 3;
469
pcLineRoot->addChild(pcDrawStyle);
472
SoSeparator* linesep = new SoSeparator;
473
SoBaseColor* basecol = new SoBaseColor;
474
basecol->rgb.setValue(1.0F, 0.5F, 0.0F);
475
linesep->addChild(basecol);
476
linesep->addChild(pcCoords);
477
linesep->addChild(pcLines);
478
pcLineRoot->addChild(linesep);
481
SoBaseColor* markcol = new SoBaseColor;
482
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
483
SoMarkerSet* marker = new SoMarkerSet;
484
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
486
App::GetApplication()
487
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
488
->GetInt("MarkerSize", 7));
489
linesep->addChild(markcol);
490
linesep->addChild(marker);
492
addDisplayMaskMode(pcLineRoot, "Line");
495
void ViewProviderMeshDegenerations::showDefects(const std::vector<Mesh::ElementIndex>& inds)
497
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
498
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
500
pcCoords->point.deleteValues(0);
501
pcCoords->point.setNum(2 * inds.size());
502
MeshCore::MeshFacetIterator cF(rMesh);
505
for (Mesh::ElementIndex ind : inds) {
507
const MeshCore::MeshPoint& rE0 = cF->_aclPoints[0];
508
const MeshCore::MeshPoint& rE1 = cF->_aclPoints[1];
509
const MeshCore::MeshPoint& rE2 = cF->_aclPoints[2];
511
// check if the points are coincident
512
if (rE0 == rE1 && rE0 == rE2) {
513
// set a small tolerance to get a non-degenerated line
515
Base::Vector3f cP1, cP2;
516
cP1.Set(rE1.x + eps, rE1.y + eps, rE1.z + eps);
517
cP2.Set(rE2.x - eps, rE2.y - eps, rE2.z - eps);
518
pcCoords->point.set1Value(i++, cP1.x, cP1.y, cP1.z);
519
pcCoords->point.set1Value(i++, cP2.x, cP2.y, cP2.z);
521
else if (rE0 == rE1) {
522
pcCoords->point.set1Value(i++, rE1.x, rE1.y, rE1.z);
523
pcCoords->point.set1Value(i++, rE2.x, rE2.y, rE2.z);
525
else if (rE1 == rE2) {
526
pcCoords->point.set1Value(i++, rE2.x, rE2.y, rE2.z);
527
pcCoords->point.set1Value(i++, rE0.x, rE0.y, rE0.z);
529
else if (rE2 == rE0) {
530
pcCoords->point.set1Value(i++, rE0.x, rE0.y, rE0.z);
531
pcCoords->point.set1Value(i++, rE1.x, rE1.y, rE1.z);
534
for (int j = 0; j < 3; j++) {
535
Base::Vector3f cVec1 = cF->_aclPoints[(j + 1) % 3] - cF->_aclPoints[j];
536
Base::Vector3f cVec2 = cF->_aclPoints[(j + 2) % 3] - cF->_aclPoints[j];
538
// adjust the neighbourhoods and point indices
539
if (cVec1 * cVec2 < 0.0F) {
540
pcCoords->point.set1Value(i++,
541
cF->_aclPoints[(j + 1) % 3].x,
542
cF->_aclPoints[(j + 1) % 3].y,
543
cF->_aclPoints[(j + 1) % 3].z);
544
pcCoords->point.set1Value(i++,
545
cF->_aclPoints[(j + 2) % 3].x,
546
cF->_aclPoints[(j + 2) % 3].y,
547
cF->_aclPoints[(j + 2) % 3].z);
553
pcLines->numVertices.set1Value(j++, 2);
556
setDisplayMaskMode("Line");
559
// ----------------------------------------------------------------------
561
ViewProviderMeshIndices::ViewProviderMeshIndices()
564
pcFaces = new SoFaceSet;
569
ViewProviderMeshIndices::~ViewProviderMeshIndices()
574
void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat)
576
ViewProviderDocumentObject::attach(pcFeat);
578
SoGroup* pcFaceRoot = new SoGroup();
580
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
581
pcFlatStyle->style = SoDrawStyle::FILLED;
582
pcFaceRoot->addChild(pcFlatStyle);
584
SoShapeHints* flathints = new SoShapeHints;
585
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
586
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
587
pcFaceRoot->addChild(flathints);
590
SoSeparator* linesep = new SoSeparator;
591
SoBaseColor* basecol = new SoBaseColor;
592
basecol->rgb.setValue(1.0F, 0.5F, 0.0F);
593
linesep->addChild(basecol);
594
linesep->addChild(pcCoords);
595
linesep->addChild(pcFaces);
596
pcFaceRoot->addChild(linesep);
599
SoBaseColor* markcol = new SoBaseColor;
600
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
601
SoMarkerSet* marker = new SoMarkerSet;
602
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
604
App::GetApplication()
605
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
606
->GetInt("MarkerSize", 7));
607
linesep->addChild(markcol);
608
linesep->addChild(marker);
610
addDisplayMaskMode(pcFaceRoot, "Face");
613
void ViewProviderMeshIndices::showDefects(const std::vector<Mesh::ElementIndex>& inds)
615
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
616
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
619
pcCoords->point.deleteValues(0);
620
pcCoords->point.setNum(3 * inds.size());
621
MeshCore::MeshFacetIterator cF(rMesh);
624
for (Mesh::ElementIndex ind : inds) {
626
for (auto cP : cF->_aclPoints) {
627
// move a bit in opposite normal direction to overlay the original faces
628
cP -= 0.001F * cF->GetNormal();
629
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
631
pcFaces->numVertices.set1Value(j++, 3);
634
setDisplayMaskMode("Face");
638
// ----------------------------------------------------------------------
640
ViewProviderMeshSelfIntersections::ViewProviderMeshSelfIntersections()
643
pcLines = new SoLineSet;
648
ViewProviderMeshSelfIntersections::~ViewProviderMeshSelfIntersections()
653
void ViewProviderMeshSelfIntersections::attach(App::DocumentObject* pcFeat)
655
ViewProviderDocumentObject::attach(pcFeat);
657
SoGroup* pcLineRoot = new SoGroup();
658
pcDrawStyle->lineWidth = 3;
659
pcLineRoot->addChild(pcDrawStyle);
662
SoSeparator* linesep = new SoSeparator;
663
SoBaseColor* basecol = new SoBaseColor;
664
basecol->rgb.setValue(1.0F, 0.5F, 0.0F);
665
linesep->addChild(basecol);
666
linesep->addChild(pcCoords);
667
linesep->addChild(pcLines);
668
pcLineRoot->addChild(linesep);
671
SoBaseColor* markcol = new SoBaseColor;
672
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
673
SoMarkerSet* marker = new SoMarkerSet;
674
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
676
App::GetApplication()
677
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
678
->GetInt("MarkerSize", 7));
679
linesep->addChild(markcol);
680
linesep->addChild(marker);
682
addDisplayMaskMode(pcLineRoot, "Line");
685
void ViewProviderMeshSelfIntersections::showDefects(const std::vector<Mesh::ElementIndex>& indices)
687
if (indices.size() % 2 != 0) {
690
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
691
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
692
MeshCore::MeshEvalSelfIntersection eval(rMesh);
694
std::vector<std::pair<Mesh::ElementIndex, Mesh::ElementIndex>> intersection;
695
std::vector<Mesh::ElementIndex>::const_iterator it;
696
for (it = indices.begin(); it != indices.end();) {
697
Mesh::ElementIndex id1 = *it;
699
Mesh::ElementIndex id2 = *it;
701
intersection.emplace_back(id1, id2);
704
std::vector<std::pair<Base::Vector3f, Base::Vector3f>> lines;
705
eval.GetIntersections(intersection, lines);
707
pcCoords->point.deleteValues(0);
708
pcCoords->point.setNum(2 * lines.size());
711
for (const auto& line : lines) {
712
pcCoords->point.set1Value(i++, line.first.x, line.first.y, line.first.z);
713
pcCoords->point.set1Value(i++, line.second.x, line.second.y, line.second.z);
714
pcLines->numVertices.set1Value(j++, 2);
717
setDisplayMaskMode("Line");
720
// ----------------------------------------------------------------------
722
ViewProviderMeshFolds::ViewProviderMeshFolds()
725
pcFaces = new SoFaceSet;
730
ViewProviderMeshFolds::~ViewProviderMeshFolds()
735
void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat)
737
ViewProviderDocumentObject::attach(pcFeat);
739
SoGroup* pcFaceRoot = new SoGroup();
741
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
742
pcFlatStyle->style = SoDrawStyle::FILLED;
743
pcFaceRoot->addChild(pcFlatStyle);
745
SoShapeHints* flathints = new SoShapeHints;
746
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
747
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
748
pcFaceRoot->addChild(flathints);
751
SoSeparator* linesep = new SoSeparator;
752
SoBaseColor* basecol = new SoBaseColor;
753
basecol->rgb.setValue(1.0F, 0.0F, 0.0F);
754
linesep->addChild(basecol);
755
linesep->addChild(pcCoords);
756
linesep->addChild(pcFaces);
757
pcFaceRoot->addChild(linesep);
760
SoBaseColor* markcol = new SoBaseColor;
761
markcol->rgb.setValue(1.0F, 1.0F, 0.0F);
762
SoMarkerSet* marker = new SoMarkerSet;
763
marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
765
App::GetApplication()
766
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")
767
->GetInt("MarkerSize", 7));
768
linesep->addChild(markcol);
769
linesep->addChild(marker);
771
addDisplayMaskMode(pcFaceRoot, "Face");
774
void ViewProviderMeshFolds::showDefects(const std::vector<Mesh::ElementIndex>& inds)
776
Mesh::Feature* f = static_cast<Mesh::Feature*>(pcObject);
777
const MeshCore::MeshKernel& rMesh = f->Mesh.getValue().getKernel();
779
pcCoords->point.deleteValues(0);
780
pcCoords->point.setNum(3 * inds.size());
781
MeshCore::MeshFacetIterator cF(rMesh);
784
for (Mesh::ElementIndex ind : inds) {
786
for (auto cP : cF->_aclPoints) {
787
// move a bit in normal direction to overlay the original faces
788
cP += 0.001F * cF->GetNormal();
789
pcCoords->point.set1Value(i++, cP.x, cP.y, cP.z);
791
pcFaces->numVertices.set1Value(j++, 3);
794
setDisplayMaskMode("Face");