1
1
/***************************************************************************
2
* Copyright (c) 2006 Werner Mayer <wmayer@users.sourceforge.net> *
2
* Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
4
* This file is part of the FreeCAD CAx development system. *
28
28
# include <Inventor/SoPickedPoint.h>
29
29
# include <Inventor/details/SoFaceDetail.h>
30
30
# include <Inventor/nodes/SoBaseColor.h>
31
# include <Inventor/nodes/SoCoordinate3.h>
31
32
# include <Inventor/nodes/SoDrawStyle.h>
33
# include <Inventor/nodes/SoIndexedLineSet.h>
32
34
# include <Inventor/nodes/SoMaterial.h>
33
35
# include <Inventor/nodes/SoMaterialBinding.h>
34
36
# include <Inventor/nodes/SoPolygonOffset.h>
69
71
#include <Mod/Mesh/App/Core/Iterator.h>
70
72
#include <Mod/Mesh/App/Core/MeshIO.h>
71
73
#include <Mod/Mesh/App/Core/MeshKernel.h>
72
#include <Mod/Mesh/App/Core/Triangulation.h>
74
#include <Mod/Mesh/App/Core/Triangulation.h>
73
75
#include <Mod/Mesh/App/Core/Visitor.h>
74
76
#include <Mod/Mesh/App/Mesh.h>
75
77
#include <Mod/Mesh/App/MeshFeature.h>
76
78
#include <Mod/Mesh/App/MeshProperties.h>
78
80
#include "ViewProviderMeshFaceSet.h"
79
#include "SoFCMeshObject.h"
80
#include "SoFCIndexedFaceSet.h"
81
#include "SoFCMeshObject.h"
82
#include "SoFCIndexedFaceSet.h"
83
85
using namespace MeshGui;
159
161
showOpenEdges(OpenEdges.getValue());
163
void ViewProviderMeshFaceSet::createMesh(const MeshCore::MeshKernel& rcMesh)
165
// set the point coordinates
166
const MeshCore::MeshPointArray& cP = rcMesh.GetPoints();
167
pcMeshCoord->point.setNum(rcMesh.CountPoints());
168
SbVec3f* verts = pcMeshCoord->point.startEditing();
170
for (MeshCore::MeshPointArray::_TConstIterator it = cP.begin(); it != cP.end(); ++it, i++) {
171
verts[i].setValue(it->x, it->y, it->z);
173
pcMeshCoord->point.finishEditing();
175
// set the face indices
177
const MeshCore::MeshFacetArray& cF = rcMesh.GetFacets();
178
pcMeshFaces->coordIndex.setNum(4*rcMesh.CountFacets());
179
int32_t* indices = pcMeshFaces->coordIndex.startEditing();
180
for (MeshCore::MeshFacetArray::_TConstIterator it = cF.begin(); it != cF.end(); ++it, j++) {
181
for (int i=0; i<3; i++) {
182
indices[4*j+i] = it->_aulPoints[i];
184
indices[4*j+3] = SO_END_FACE_INDEX;
186
pcMeshFaces->coordIndex.finishEditing();
165
void ViewProviderMeshFaceSet::createMesh(const MeshCore::MeshKernel& rcMesh)
167
// set the point coordinates
168
const MeshCore::MeshPointArray& cP = rcMesh.GetPoints();
169
pcMeshCoord->point.setNum(rcMesh.CountPoints());
170
SbVec3f* verts = pcMeshCoord->point.startEditing();
172
for (MeshCore::MeshPointArray::_TConstIterator it = cP.begin(); it != cP.end(); ++it, i++) {
173
verts[i].setValue(it->x, it->y, it->z);
175
pcMeshCoord->point.finishEditing();
177
// set the face indices
179
const MeshCore::MeshFacetArray& cF = rcMesh.GetFacets();
180
pcMeshFaces->coordIndex.setNum(4*rcMesh.CountFacets());
181
int32_t* indices = pcMeshFaces->coordIndex.startEditing();
182
for (MeshCore::MeshFacetArray::_TConstIterator it = cF.begin(); it != cF.end(); ++it, j++) {
183
for (int i=0; i<3; i++) {
184
indices[4*j+i] = it->_aulPoints[i];
186
indices[4*j+3] = SO_END_FACE_INDEX;
188
pcMeshFaces->coordIndex.finishEditing();
189
191
void ViewProviderMeshFaceSet::showOpenEdges(bool show)
199
201
pcOpenEdge->addChild(pcLineStyle);
200
202
pcOpenEdge->addChild(pOpenColor);
202
if (directRendering) {
204
if (directRendering) {
203
205
pcOpenEdge->addChild(pcMeshNode);
204
206
pcOpenEdge->addChild(new SoFCMeshObjectBoundary);
207
209
pcOpenEdge->addChild(pcMeshCoord);
208
SoIndexedLineSet* lines = new SoIndexedLineSet;
210
SoIndexedLineSet* lines = new SoIndexedLineSet;
209
211
pcOpenEdge->addChild(lines);
211
// Build up the lines with indices to the list of vertices 'pcMeshCoord'
213
const MeshCore::MeshKernel& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue().getKernel();
214
const MeshCore::MeshFacetArray& rFaces = rMesh.GetFacets();
215
for (MeshCore::MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) {
216
for (int i=0; i<3; i++) {
217
if (it->_aulNeighbours[i] == ULONG_MAX) {
218
lines->coordIndex.set1Value(index++,it->_aulPoints[i]);
219
lines->coordIndex.set1Value(index++,it->_aulPoints[(i+1)%3]);
220
lines->coordIndex.set1Value(index++,SO_END_LINE_INDEX);
213
// Build up the lines with indices to the list of vertices 'pcMeshCoord'
215
const MeshCore::MeshKernel& rMesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.getValue().getKernel();
216
const MeshCore::MeshFacetArray& rFaces = rMesh.GetFacets();
217
for (MeshCore::MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it) {
218
for (int i=0; i<3; i++) {
219
if (it->_aulNeighbours[i] == ULONG_MAX) {
220
lines->coordIndex.set1Value(index++,it->_aulPoints[i]);
221
lines->coordIndex.set1Value(index++,it->_aulPoints[(i+1)%3]);
222
lines->coordIndex.set1Value(index++,SO_END_LINE_INDEX);
226
228
// add to the highlight node
227
229
pcRoot->addChild(pcOpenEdge);
231
SoShape* ViewProviderMeshFaceSet::getShapeNode() const
234
return this->pcMeshShape;
235
return this->pcMeshFaces;
233
SoShape* ViewProviderMeshFaceSet::getShapeNode() const
236
return this->pcMeshShape;
237
return this->pcMeshFaces;