00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 # include <Inventor/nodes/SoBaseColor.h>
00028 # include <Inventor/nodes/SoCoordinate3.h>
00029 # include <Inventor/nodes/SoDrawStyle.h>
00030 # include <Inventor/nodes/SoFaceSet.h>
00031 # include <Inventor/nodes/SoLineSet.h>
00032 # include <Inventor/nodes/SoMarkerSet.h>
00033 # include <Inventor/nodes/SoSeparator.h>
00034 # include <Inventor/nodes/SoShapeHints.h>
00035 #endif
00036
00038 #include <Base/Console.h>
00039 #include <Base/Parameter.h>
00040 #include <Base/Exception.h>
00041 #include <Base/Sequencer.h>
00042 #include <App/Application.h>
00043 #include <Gui/Selection.h>
00044 #include <Gui/SoFCSelection.h>
00045
00046 #include <Mod/Mesh/App/Core/Degeneration.h>
00047 #include <Mod/Mesh/App/Core/Evaluation.h>
00048 #include <Mod/Mesh/App/Core/Iterator.h>
00049 #include <Mod/Mesh/App/Mesh.h>
00050 #include <Mod/Mesh/App/MeshFeature.h>
00051
00052 #include "ViewProvider.h"
00053 #include "ViewProviderDefects.h"
00054
00055 using namespace Mesh;
00056 using namespace MeshGui;
00057
00058
00059 PROPERTY_SOURCE_ABSTRACT(MeshGui::ViewProviderMeshDefects, Gui::ViewProviderDocumentObject)
00060 PROPERTY_SOURCE(MeshGui::ViewProviderMeshOrientation, MeshGui::ViewProviderMeshDefects)
00061 PROPERTY_SOURCE(MeshGui::ViewProviderMeshNonManifolds, MeshGui::ViewProviderMeshDefects)
00062 PROPERTY_SOURCE(MeshGui::ViewProviderMeshDuplicatedFaces, MeshGui::ViewProviderMeshDefects)
00063 PROPERTY_SOURCE(MeshGui::ViewProviderMeshDuplicatedPoints, MeshGui::ViewProviderMeshDefects)
00064 PROPERTY_SOURCE(MeshGui::ViewProviderMeshDegenerations, MeshGui::ViewProviderMeshDefects)
00065 PROPERTY_SOURCE(MeshGui::ViewProviderMeshIndices, MeshGui::ViewProviderMeshDefects)
00066 PROPERTY_SOURCE(MeshGui::ViewProviderMeshSelfIntersections, MeshGui::ViewProviderMeshDefects)
00067 PROPERTY_SOURCE(MeshGui::ViewProviderMeshFolds, MeshGui::ViewProviderMeshDefects)
00068
00069 ViewProviderMeshDefects::ViewProviderMeshDefects()
00070 {
00071 ADD_PROPERTY(LineWidth,(2.0f));
00072
00073 pcCoords = new SoCoordinate3();
00074 pcCoords->ref();
00075 pcDrawStyle = new SoDrawStyle();
00076 pcDrawStyle->ref();
00077 pcDrawStyle->style = SoDrawStyle::LINES;
00078 pcDrawStyle->lineWidth = LineWidth.getValue();
00079 }
00080
00081 ViewProviderMeshDefects::~ViewProviderMeshDefects()
00082 {
00083 pcCoords->unref();
00084 pcDrawStyle->unref();
00085 }
00086
00087 void ViewProviderMeshDefects::onChanged(const App::Property* prop)
00088 {
00089 if (prop == &LineWidth) {
00090 pcDrawStyle->lineWidth = LineWidth.getValue();
00091 }
00092 else {
00093 ViewProviderDocumentObject::onChanged(prop);
00094 }
00095 }
00096
00097
00098
00099 ViewProviderMeshOrientation::ViewProviderMeshOrientation()
00100 {
00101 pcFaces = new SoFaceSet;
00102 pcFaces->ref();
00103 }
00104
00105 ViewProviderMeshOrientation::~ViewProviderMeshOrientation()
00106 {
00107 pcFaces->unref();
00108 }
00109
00110 void ViewProviderMeshOrientation::attach(App::DocumentObject* pcFeat)
00111 {
00112 ViewProviderDocumentObject::attach( pcFeat );
00113
00114 SoGroup* pcFaceRoot = new SoGroup();
00115
00116 SoDrawStyle* pcFlatStyle = new SoDrawStyle();
00117 pcFlatStyle->style = SoDrawStyle::FILLED;
00118 pcFaceRoot->addChild(pcFlatStyle);
00119
00120 SoShapeHints * flathints = new SoShapeHints;
00121 flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
00122 flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
00123 pcFaceRoot->addChild(flathints);
00124
00125
00126 SoSeparator* linesep = new SoSeparator;
00127 SoBaseColor * basecol = new SoBaseColor;
00128 basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
00129 linesep->addChild(basecol);
00130 linesep->addChild(pcCoords);
00131 linesep->addChild(pcFaces);
00132
00133
00134 SoBaseColor * markcol = new SoBaseColor;
00135 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00136 SoMarkerSet* marker = new SoMarkerSet;
00137 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00138 linesep->addChild(markcol);
00139 linesep->addChild(marker);
00140
00141 pcFaceRoot->addChild(linesep);
00142
00143 addDisplayMaskMode(pcFaceRoot, "Face");
00144 }
00145
00146 void ViewProviderMeshOrientation::showDefects(const std::vector<unsigned long>& inds)
00147 {
00148 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00149 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00150
00151 pcCoords->point.deleteValues(0);
00152 pcCoords->point.setNum(3*inds.size());
00153 MeshCore::MeshFacetIterator cF(rMesh);
00154 unsigned long i=0;
00155 unsigned long j=0;
00156 for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
00157 cF.Set(*it);
00158 for (int k=0; k<3; k++) {
00159 Base::Vector3f cP = cF->_aclPoints[k];
00160
00161 cP -= 0.001f * cF->GetNormal();
00162 pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
00163 }
00164 pcFaces->numVertices.set1Value(j++, 3);
00165 }
00166
00167 setDisplayMaskMode("Face");
00168 }
00169
00170
00171
00172 ViewProviderMeshNonManifolds::ViewProviderMeshNonManifolds()
00173 {
00174 pcLines = new SoLineSet;
00175 pcLines->ref();
00176 }
00177
00178 ViewProviderMeshNonManifolds::~ViewProviderMeshNonManifolds()
00179 {
00180 pcLines->unref();
00181 }
00182
00183 void ViewProviderMeshNonManifolds::attach(App::DocumentObject* pcFeat)
00184 {
00185 ViewProviderDocumentObject::attach( pcFeat );
00186
00187 SoGroup* pcLineRoot = new SoGroup();
00188 pcDrawStyle->lineWidth = 3;
00189 pcLineRoot->addChild(pcDrawStyle);
00190
00191
00192 SoSeparator* linesep = new SoSeparator;
00193 SoBaseColor * basecol = new SoBaseColor;
00194 basecol->rgb.setValue( 1.0f, 0.0f, 0.0f );
00195 linesep->addChild(basecol);
00196 linesep->addChild(pcCoords);
00197 linesep->addChild(pcLines);
00198 pcLineRoot->addChild(linesep);
00199
00200
00201 SoBaseColor * markcol = new SoBaseColor;
00202 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00203 SoMarkerSet* marker = new SoMarkerSet;
00204 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00205 linesep->addChild(markcol);
00206 linesep->addChild(marker);
00207
00208 addDisplayMaskMode(pcLineRoot, "Line");
00209 }
00210
00211 void ViewProviderMeshNonManifolds::showDefects(const std::vector<unsigned long>& inds)
00212 {
00213 if ((inds.size() % 2) != 0)
00214 return;
00215 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00216 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00217
00218 pcCoords->point.deleteValues(0);
00219 pcCoords->point.setNum(inds.size());
00220 MeshCore::MeshPointIterator cP(rMesh);
00221 unsigned long i=0;
00222 unsigned long j=0;
00223 for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
00224 cP.Set(*it);
00225 pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
00226 ++it;
00227 cP.Set(*it);
00228 pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
00229 pcLines->numVertices.set1Value(j++, 2);
00230 }
00231
00232 setDisplayMaskMode("Line");
00233 }
00234
00235
00236
00237 ViewProviderMeshDuplicatedFaces::ViewProviderMeshDuplicatedFaces()
00238 {
00239 pcFaces = new SoFaceSet;
00240 pcFaces->ref();
00241 }
00242
00243 ViewProviderMeshDuplicatedFaces::~ViewProviderMeshDuplicatedFaces()
00244 {
00245 pcFaces->unref();
00246 }
00247
00248 void ViewProviderMeshDuplicatedFaces::attach(App::DocumentObject* pcFeat)
00249 {
00250 ViewProviderDocumentObject::attach( pcFeat );
00251
00252 SoGroup* pcFaceRoot = new SoGroup();
00253
00254 SoDrawStyle* pcFlatStyle = new SoDrawStyle();
00255 pcFlatStyle->style = SoDrawStyle::FILLED;
00256 pcFaceRoot->addChild(pcFlatStyle);
00257
00258 SoShapeHints * flathints = new SoShapeHints;
00259 flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
00260 flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
00261 pcFaceRoot->addChild(flathints);
00262
00263
00264 SoSeparator* linesep = new SoSeparator;
00265 SoBaseColor * basecol = new SoBaseColor;
00266 basecol->rgb.setValue( 1.0f, 0.0f, 0.0f );
00267 linesep->addChild(basecol);
00268 linesep->addChild(pcCoords);
00269 linesep->addChild(pcFaces);
00270 pcFaceRoot->addChild(linesep);
00271
00272
00273 SoBaseColor * markcol = new SoBaseColor;
00274 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00275 SoMarkerSet* marker = new SoMarkerSet;
00276 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00277 linesep->addChild(markcol);
00278 linesep->addChild(marker);
00279
00280 addDisplayMaskMode(pcFaceRoot, "Face");
00281 }
00282
00283 void ViewProviderMeshDuplicatedFaces::showDefects(const std::vector<unsigned long>& inds)
00284 {
00285 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00286 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00287
00288 pcCoords->point.deleteValues(0);
00289 pcCoords->point.setNum(3*inds.size());
00290 MeshCore::MeshFacetIterator cF(rMesh);
00291 unsigned long i=0;
00292 unsigned long j=0;
00293 for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
00294 cF.Set(*it);
00295 for (int k=0; k<3; k++) {
00296 Base::Vector3f cP = cF->_aclPoints[k];
00297
00298 cP += 0.001f * cF->GetNormal();
00299 pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
00300 }
00301 pcFaces->numVertices.set1Value(j++, 3);
00302 }
00303
00304 setDisplayMaskMode("Face");
00305 }
00306
00307
00308
00309 ViewProviderMeshDuplicatedPoints::ViewProviderMeshDuplicatedPoints()
00310 {
00311 pcPoints = new SoPointSet;
00312 pcPoints->ref();
00313 }
00314
00315 ViewProviderMeshDuplicatedPoints::~ViewProviderMeshDuplicatedPoints()
00316 {
00317 pcPoints->unref();
00318 }
00319
00320 void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
00321 {
00322 ViewProviderDocumentObject::attach( pcFeat );
00323
00324 SoGroup* pcPointRoot = new SoGroup();
00325 pcDrawStyle->pointSize = 3;
00326 pcPointRoot->addChild(pcDrawStyle);
00327
00328
00329 SoSeparator* pointsep = new SoSeparator;
00330 SoBaseColor * basecol = new SoBaseColor;
00331 basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
00332 pointsep->addChild(basecol);
00333 pointsep->addChild(pcCoords);
00334 pointsep->addChild(pcPoints);
00335 pcPointRoot->addChild(pointsep);
00336
00337
00338 SoBaseColor * markcol = new SoBaseColor;
00339 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00340 SoMarkerSet* marker = new SoMarkerSet;
00341 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00342 pointsep->addChild(markcol);
00343 pointsep->addChild(marker);
00344
00345 addDisplayMaskMode(pcPointRoot, "Point");
00346 }
00347
00348 void ViewProviderMeshDuplicatedPoints::showDefects(const std::vector<unsigned long>& inds)
00349 {
00350 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00351 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00352 pcCoords->point.deleteValues(0);
00353 pcCoords->point.setNum(inds.size());
00354 MeshCore::MeshPointIterator cP(rMesh);
00355 unsigned long i = 0;
00356 for ( std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it ) {
00357 cP.Set(*it);
00358 pcCoords->point.set1Value(i++,cP->x,cP->y,cP->z);
00359 }
00360
00361 setDisplayMaskMode("Point");
00362 }
00363
00364
00365
00366 ViewProviderMeshDegenerations::ViewProviderMeshDegenerations()
00367 {
00368 pcLines = new SoLineSet;
00369 pcLines->ref();
00370 }
00371
00372 ViewProviderMeshDegenerations::~ViewProviderMeshDegenerations()
00373 {
00374 pcLines->unref();
00375 }
00376
00377 void ViewProviderMeshDegenerations::attach(App::DocumentObject* pcFeat)
00378 {
00379 ViewProviderDocumentObject::attach( pcFeat );
00380
00381 SoGroup* pcLineRoot = new SoGroup();
00382 pcDrawStyle->lineWidth = 3;
00383 pcLineRoot->addChild(pcDrawStyle);
00384
00385
00386 SoSeparator* linesep = new SoSeparator;
00387 SoBaseColor * basecol = new SoBaseColor;
00388 basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
00389 linesep->addChild(basecol);
00390 linesep->addChild(pcCoords);
00391 linesep->addChild(pcLines);
00392 pcLineRoot->addChild(linesep);
00393
00394
00395 SoBaseColor * markcol = new SoBaseColor;
00396 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00397 SoMarkerSet* marker = new SoMarkerSet;
00398 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00399 linesep->addChild(markcol);
00400 linesep->addChild(marker);
00401
00402 addDisplayMaskMode(pcLineRoot, "Line");
00403 }
00404
00405 void ViewProviderMeshDegenerations::showDefects(const std::vector<unsigned long>& inds)
00406 {
00407 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00408 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00409
00410 pcCoords->point.deleteValues(0);
00411 pcCoords->point.setNum(2*inds.size());
00412 MeshCore::MeshFacetIterator cF(rMesh);
00413 unsigned long i=0;
00414 unsigned long j=0;
00415 for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
00416 cF.Set(*it);
00417 const MeshCore::MeshPoint& rE0 = cF->_aclPoints[0];
00418 const MeshCore::MeshPoint& rE1 = cF->_aclPoints[1];
00419 const MeshCore::MeshPoint& rE2 = cF->_aclPoints[2];
00420
00421
00422 if (rE0 == rE1 && rE0 == rE2) {
00423
00424 float eps = 0.005f;
00425 Base::Vector3f cP1, cP2;
00426 cP1.Set(rE1.x+eps,rE1.y+eps,rE1.z+eps);
00427 cP2.Set(rE2.x-eps,rE2.y-eps,rE2.z-eps);
00428 pcCoords->point.set1Value(i++,cP1.x,cP1.y,cP1.z);
00429 pcCoords->point.set1Value(i++,cP2.x,cP2.y,cP2.z);
00430 }
00431 else if (rE0 == rE1) {
00432 pcCoords->point.set1Value(i++,rE1.x,rE1.y,rE1.z);
00433 pcCoords->point.set1Value(i++,rE2.x,rE2.y,rE2.z);
00434 }
00435 else if (rE1 == rE2) {
00436 pcCoords->point.set1Value(i++,rE2.x,rE2.y,rE2.z);
00437 pcCoords->point.set1Value(i++,rE0.x,rE0.y,rE0.z);
00438 }
00439 else if (rE2 == rE0) {
00440 pcCoords->point.set1Value(i++,rE0.x,rE0.y,rE0.z);
00441 pcCoords->point.set1Value(i++,rE1.x,rE1.y,rE1.z);
00442 }
00443 else {
00444 for (int j=0; j<3; j++) {
00445 Base::Vector3f cVec1 = cF->_aclPoints[(j+1)%3] - cF->_aclPoints[j];
00446 Base::Vector3f cVec2 = cF->_aclPoints[(j+2)%3] - cF->_aclPoints[j];
00447
00448
00449 if (cVec1 * cVec2 < 0.0f) {
00450 pcCoords->point.set1Value(i++,cF->_aclPoints[(j+1)%3].x,cF->_aclPoints[(j+1)%3].y,cF->_aclPoints[(j+1)%3].z);
00451 pcCoords->point.set1Value(i++,cF->_aclPoints[(j+2)%3].x,cF->_aclPoints[(j+2)%3].y,cF->_aclPoints[(j+2)%3].z);
00452 break;
00453 }
00454 }
00455 }
00456
00457 pcLines->numVertices.set1Value(j++, 2);
00458 }
00459
00460 setDisplayMaskMode("Line");
00461 }
00462
00463
00464
00465 ViewProviderMeshIndices::ViewProviderMeshIndices()
00466 {
00467 pcFaces = new SoFaceSet;
00468 pcFaces->ref();
00469 }
00470
00471 ViewProviderMeshIndices::~ViewProviderMeshIndices()
00472 {
00473 pcFaces->unref();
00474 }
00475
00476 void ViewProviderMeshIndices::attach(App::DocumentObject* pcFeat)
00477 {
00478 ViewProviderDocumentObject::attach( pcFeat );
00479
00480 SoGroup* pcFaceRoot = new SoGroup();
00481
00482 SoDrawStyle* pcFlatStyle = new SoDrawStyle();
00483 pcFlatStyle->style = SoDrawStyle::FILLED;
00484 pcFaceRoot->addChild(pcFlatStyle);
00485
00486 SoShapeHints * flathints = new SoShapeHints;
00487 flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
00488 flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
00489 pcFaceRoot->addChild(flathints);
00490
00491
00492 SoSeparator* linesep = new SoSeparator;
00493 SoBaseColor * basecol = new SoBaseColor;
00494 basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
00495 linesep->addChild(basecol);
00496 linesep->addChild(pcCoords);
00497 linesep->addChild(pcFaces);
00498 pcFaceRoot->addChild(linesep);
00499
00500
00501 SoBaseColor * markcol = new SoBaseColor;
00502 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00503 SoMarkerSet* marker = new SoMarkerSet;
00504 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00505 linesep->addChild(markcol);
00506 linesep->addChild(marker);
00507
00508 addDisplayMaskMode(pcFaceRoot, "Face");
00509 }
00510
00511 void ViewProviderMeshIndices::showDefects(const std::vector<unsigned long>& inds)
00512 {
00513 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00514 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00515
00516 if (!inds.empty()) {
00517 pcCoords->point.deleteValues(0);
00518 pcCoords->point.setNum(3*inds.size());
00519 MeshCore::MeshFacetIterator cF(rMesh);
00520 unsigned long i=0;
00521 unsigned long j=0;
00522 for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
00523 cF.Set(*it);
00524 for (int k=0; k<3; k++) {
00525 Base::Vector3f cP = cF->_aclPoints[k];
00526
00527 cP -= 0.001f * cF->GetNormal();
00528 pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
00529 }
00530 pcFaces->numVertices.set1Value(j++, 3);
00531 }
00532
00533 setDisplayMaskMode("Face");
00534 }
00535 }
00536
00537
00538
00539 ViewProviderMeshSelfIntersections::ViewProviderMeshSelfIntersections()
00540 {
00541 pcLines = new SoLineSet;
00542 pcLines->ref();
00543 }
00544
00545 ViewProviderMeshSelfIntersections::~ViewProviderMeshSelfIntersections()
00546 {
00547 pcLines->unref();
00548 }
00549
00550 void ViewProviderMeshSelfIntersections::attach(App::DocumentObject* pcFeat)
00551 {
00552 ViewProviderDocumentObject::attach( pcFeat );
00553
00554 SoGroup* pcLineRoot = new SoGroup();
00555 pcDrawStyle->lineWidth = 3;
00556 pcLineRoot->addChild(pcDrawStyle);
00557
00558
00559 SoSeparator* linesep = new SoSeparator;
00560 SoBaseColor * basecol = new SoBaseColor;
00561 basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
00562 linesep->addChild(basecol);
00563 linesep->addChild(pcCoords);
00564 linesep->addChild(pcLines);
00565 pcLineRoot->addChild(linesep);
00566
00567
00568 SoBaseColor * markcol = new SoBaseColor;
00569 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00570 SoMarkerSet* marker = new SoMarkerSet;
00571 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00572 linesep->addChild(markcol);
00573 linesep->addChild(marker);
00574
00575 addDisplayMaskMode(pcLineRoot, "Line");
00576 }
00577
00578 void ViewProviderMeshSelfIntersections::showDefects(const std::vector<unsigned long>& indices)
00579 {
00580 if (indices.size() % 2 != 0)
00581 return;
00582 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00583 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00584 MeshCore::MeshEvalSelfIntersection eval(rMesh);
00585
00586 std::vector<std::pair<unsigned long, unsigned long> > intersection;
00587 std::vector<unsigned long>::const_iterator it;
00588 for (it = indices.begin(); it != indices.end(); ) {
00589 unsigned long id1 = *it; ++it;
00590 unsigned long id2 = *it; ++it;
00591 intersection.push_back(std::make_pair
00592 <unsigned long, unsigned long>(id1,id2));
00593 }
00594
00595 std::vector<std::pair<Base::Vector3f, Base::Vector3f> > lines;
00596 eval.GetIntersections(intersection, lines);
00597
00598 pcCoords->point.deleteValues(0);
00599 pcCoords->point.setNum(2*lines.size());
00600 unsigned long i=0;
00601 unsigned long j=0;
00602 for (std::vector<std::pair<Base::Vector3f, Base::Vector3f> >::const_iterator it = lines.begin(); it != lines.end(); ++it) {
00603 pcCoords->point.set1Value(i++,it->first.x,it->first.y,it->first.z);
00604 pcCoords->point.set1Value(i++,it->second.x,it->second.y,it->second.z);
00605 pcLines->numVertices.set1Value(j++, 2);
00606 }
00607
00608 setDisplayMaskMode("Line");
00609 }
00610
00611
00612
00613 ViewProviderMeshFolds::ViewProviderMeshFolds()
00614 {
00615 pcFaces = new SoFaceSet;
00616 pcFaces->ref();
00617 }
00618
00619 ViewProviderMeshFolds::~ViewProviderMeshFolds()
00620 {
00621 pcFaces->unref();
00622 }
00623
00624 void ViewProviderMeshFolds::attach(App::DocumentObject* pcFeat)
00625 {
00626 ViewProviderDocumentObject::attach( pcFeat );
00627
00628 SoGroup* pcFaceRoot = new SoGroup();
00629
00630 SoDrawStyle* pcFlatStyle = new SoDrawStyle();
00631 pcFlatStyle->style = SoDrawStyle::FILLED;
00632 pcFaceRoot->addChild(pcFlatStyle);
00633
00634 SoShapeHints * flathints = new SoShapeHints;
00635 flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
00636 flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
00637 pcFaceRoot->addChild(flathints);
00638
00639
00640 SoSeparator* linesep = new SoSeparator;
00641 SoBaseColor * basecol = new SoBaseColor;
00642 basecol->rgb.setValue( 1.0f, 0.0f, 0.0f );
00643 linesep->addChild(basecol);
00644 linesep->addChild(pcCoords);
00645 linesep->addChild(pcFaces);
00646 pcFaceRoot->addChild(linesep);
00647
00648
00649 SoBaseColor * markcol = new SoBaseColor;
00650 markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
00651 SoMarkerSet* marker = new SoMarkerSet;
00652 marker->markerIndex=SoMarkerSet::PLUS_7_7;
00653 linesep->addChild(markcol);
00654 linesep->addChild(marker);
00655
00656 addDisplayMaskMode(pcFaceRoot, "Face");
00657 }
00658
00659 void ViewProviderMeshFolds::showDefects(const std::vector<unsigned long>& inds)
00660 {
00661 Mesh::Feature* f = dynamic_cast<Mesh::Feature*>(pcObject);
00662 const MeshCore::MeshKernel & rMesh = f->Mesh.getValue().getKernel();
00663
00664 pcCoords->point.deleteValues(0);
00665 pcCoords->point.setNum(3*inds.size());
00666 MeshCore::MeshFacetIterator cF(rMesh);
00667 unsigned long i=0;
00668 unsigned long j=0;
00669 for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
00670 cF.Set(*it);
00671 for (int k=0; k<3; k++) {
00672 Base::Vector3f cP = cF->_aclPoints[k];
00673
00674 cP += 0.001f * cF->GetNormal();
00675 pcCoords->point.set1Value(i++,cP.x,cP.y,cP.z);
00676 }
00677 pcFaces->numVertices.set1Value(j++, 3);
00678 }
00679
00680 setDisplayMaskMode("Face");
00681 }