clean Mod/Mesh from #if 0
This commit is contained in:
@@ -476,28 +476,6 @@ void MeshObject::swapKernel(MeshCore::MeshKernel& kernel,
|
||||
this->_segments[index].setName(g[index]);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifndef FC_DEBUG
|
||||
try {
|
||||
MeshCore::MeshEvalNeighbourhood nb(_kernel);
|
||||
if (!nb.Evaluate()) {
|
||||
Base::Console().Warning("Errors in neighbourhood of mesh found...");
|
||||
_kernel.RebuildNeighbours();
|
||||
Base::Console().Warning("fixed\n");
|
||||
}
|
||||
|
||||
MeshCore::MeshEvalTopology eval(_kernel);
|
||||
if (!eval.Evaluate()) {
|
||||
Base::Console().Warning("The mesh data structure has some defects\n");
|
||||
}
|
||||
}
|
||||
catch (const Base::MemoryException&) {
|
||||
// ignore memory exceptions and continue
|
||||
Base::Console().Log("Check for defects in mesh data structure failed\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void MeshObject::save(std::ostream& out) const
|
||||
@@ -1999,7 +1977,6 @@ std::vector<Segment> MeshObject::getSegmentsOfType(MeshObject::GeometryType type
|
||||
std::shared_ptr<MeshCore::MeshDistanceSurfaceSegment> surf;
|
||||
switch (type) {
|
||||
case PLANE:
|
||||
//surf.reset(new MeshCore::MeshDistancePlanarSegment(this->_kernel, minFacets, dev));
|
||||
surf.reset(new MeshCore::MeshDistanceGenericSurfaceFitSegment(new MeshCore::PlaneSurfaceFit,
|
||||
this->_kernel, minFacets, dev));
|
||||
break;
|
||||
|
||||
@@ -76,142 +76,7 @@
|
||||
|
||||
using namespace Mesh;
|
||||
|
||||
// deprecated
|
||||
#if 0
|
||||
DEF_STD_CMD_A(CmdMeshTransform)
|
||||
|
||||
CmdMeshTransform::CmdMeshTransform()
|
||||
:Command("Mesh_Transform")
|
||||
{
|
||||
sAppModule = "Mesh";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Transform mesh");
|
||||
sToolTipText = QT_TR_NOOP("Rotate or move a mesh");
|
||||
sWhatsThis = "Mesh_Transform";
|
||||
sStatusTip = QT_TR_NOOP("Rotate or move a mesh");
|
||||
sPixmap = "Std_Tool1";
|
||||
}
|
||||
|
||||
void CmdMeshTransform::activated(int)
|
||||
{
|
||||
unsigned int n = getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
if ( n!=1 )
|
||||
return;
|
||||
|
||||
std::string fName = getUniqueObjectName("Move");
|
||||
std::vector<Gui::SelectionSingleton::SelObj> cSel = getSelection().getSelection();
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Create"));
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"Mesh::Transform\",\"%s\")",fName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",fName.c_str(),cSel[0].FeatName);
|
||||
doCommand(Gui,"Gui.hide(\"%s\")",cSel[0].FeatName);
|
||||
commitCommand();
|
||||
|
||||
updateActive();
|
||||
}
|
||||
|
||||
bool CmdMeshTransform::isActive(void)
|
||||
{
|
||||
//return true;
|
||||
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
DEF_STD_CMD_A(CmdMeshDemolding)
|
||||
|
||||
CmdMeshDemolding::CmdMeshDemolding()
|
||||
:Command("Mesh_Demolding")
|
||||
{
|
||||
sAppModule = "Mesh";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Interactive demolding direction");
|
||||
sToolTipText = sMenuText;
|
||||
sWhatsThis = "Mesh_Demolding";
|
||||
sStatusTip = sMenuText;
|
||||
sPixmap = "Std_Tool1";
|
||||
}
|
||||
|
||||
void CmdMeshDemolding::activated(int)
|
||||
{
|
||||
unsigned int n = getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
if ( n!=1 )
|
||||
return;
|
||||
|
||||
std::string fName = getUniqueObjectName("Demolding");
|
||||
std::vector<Gui::SelectionSingleton::SelObj> cSel = getSelection().getSelection();
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Create"));
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"Mesh::TransformDemolding\",\"%s\")",fName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",fName.c_str(),cSel[0].FeatName);
|
||||
doCommand(Gui,"Gui.hide(\"%s\")",cSel[0].FeatName);
|
||||
commitCommand();
|
||||
|
||||
updateActive();
|
||||
}
|
||||
|
||||
bool CmdMeshDemolding::isActive(void)
|
||||
{
|
||||
//return true;
|
||||
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
DEF_STD_CMD_A(CmdMeshToolMesh)
|
||||
|
||||
CmdMeshToolMesh::CmdMeshToolMesh()
|
||||
:Command("Mesh_ToolMesh")
|
||||
{
|
||||
sAppModule = "Mesh";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Segment by tool mesh");
|
||||
sToolTipText = QT_TR_NOOP("Creates a segment from a given tool mesh");
|
||||
sWhatsThis = "Mesh_ToolMesh";
|
||||
sStatusTip = QT_TR_NOOP("Creates a segment from a given tool mesh");
|
||||
}
|
||||
|
||||
void CmdMeshToolMesh::activated(int)
|
||||
{
|
||||
std::vector<App::DocumentObject*> fea = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
if ( fea.size() == 2 )
|
||||
{
|
||||
std::string fName = getUniqueObjectName("MeshSegment");
|
||||
App::DocumentObject* mesh = fea.front();
|
||||
App::DocumentObject* tool = fea.back();
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Segment by tool mesh"));
|
||||
doCommand(Doc, "import Mesh");
|
||||
doCommand(Gui, "import MeshGui");
|
||||
doCommand(Doc,
|
||||
"App.activeDocument().addObject(\"Mesh::SegmentByMesh\",\"%s\")\n"
|
||||
"App.activeDocument().%s.Source = App.activeDocument().%s\n"
|
||||
"App.activeDocument().%s.Tool = App.activeDocument().%s\n",
|
||||
fName.c_str(), fName.c_str(), mesh->getNameInDocument(), fName.c_str(), tool->getNameInDocument() );
|
||||
|
||||
commitCommand();
|
||||
updateActive();
|
||||
|
||||
App::Document* pDoc = getDocument();
|
||||
App::DocumentObject * pObj = pDoc->getObject( fName.c_str() );
|
||||
|
||||
if ( pObj )
|
||||
{
|
||||
doCommand(Gui,"Gui.hide(\"%s\")", mesh->getNameInDocument());
|
||||
doCommand(Gui,"Gui.hide(\"%s\")", tool->getNameInDocument());
|
||||
getSelection().clearSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdMeshToolMesh::isActive(void)
|
||||
{
|
||||
// Check for the selected mesh feature (all Mesh types)
|
||||
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
DEF_STD_CMD_A(CmdMeshUnion)
|
||||
|
||||
@@ -780,60 +645,6 @@ bool CmdMeshPolySegm::isActive()
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
#if 0
|
||||
DEF_STD_CMD_A(CmdMeshPolySelect)
|
||||
|
||||
CmdMeshPolySelect::CmdMeshPolySelect()
|
||||
: Command("Mesh_PolySelect")
|
||||
{
|
||||
sAppModule = "Mesh";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Select mesh");
|
||||
sToolTipText = QT_TR_NOOP("Select an area of the mesh");
|
||||
sWhatsThis = "Mesh_PolySelect";
|
||||
sStatusTip = QT_TR_NOOP("Select an area of the mesh");
|
||||
}
|
||||
|
||||
void CmdMeshPolySelect::activated(int)
|
||||
{
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
for (std::vector<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end(); ++it) {
|
||||
if (it == docObj.begin()) {
|
||||
Gui::Document* doc = getActiveGuiDocument();
|
||||
Gui::MDIView* view = doc->getActiveView();
|
||||
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
|
||||
viewer->setEditing(true);
|
||||
viewer->startSelection(Gui::View3DInventorViewer::Rectangle);
|
||||
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::selectGLCallback);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Gui::ViewProvider* pVP = getActiveGuiDocument()->getViewProvider(*it);
|
||||
pVP->startEditing();
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdMeshPolySelect::isActive(void)
|
||||
{
|
||||
// Check for the selected mesh feature (all Mesh types)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0)
|
||||
return false;
|
||||
|
||||
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
|
||||
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
|
||||
return !viewer->isEditing();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
DEF_STD_CMD_A(CmdMeshAddFacet)
|
||||
|
||||
@@ -1404,48 +1215,13 @@ CmdMeshSmoothing::CmdMeshSmoothing()
|
||||
|
||||
void CmdMeshSmoothing::activated(int)
|
||||
{
|
||||
#if 0
|
||||
MeshGui::SmoothingDialog dlg(Gui::getMainWindow());
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
Gui::WaitCursor wc;
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Mesh Smoothing"));
|
||||
std::vector<App::DocumentObject*> meshes = getSelection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = meshes.begin(); it != meshes.end(); ++it) {
|
||||
Mesh::Feature* mesh = (Mesh::Feature*)*it;
|
||||
Mesh::MeshObject* mm = mesh->Mesh.startEditing();
|
||||
switch (dlg.method()) {
|
||||
case MeshGui::DlgSmoothing::Taubin:
|
||||
{
|
||||
MeshCore::TaubinSmoothing s(mm->getKernel());
|
||||
s.SetLambda(dlg.lambdaStep());
|
||||
s.SetMicro(dlg.microStep());
|
||||
s.Smooth(dlg.iterations());
|
||||
} break;
|
||||
case MeshGui::DlgSmoothing::Laplace:
|
||||
{
|
||||
MeshCore::LaplaceSmoothing s(mm->getKernel());
|
||||
s.SetLambda(dlg.lambdaStep());
|
||||
s.Smooth(dlg.iterations());
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mesh->Mesh.finishEditing();
|
||||
}
|
||||
commitCommand();
|
||||
}
|
||||
#else
|
||||
Gui::Control().showDialog(new MeshGui::TaskSmoothing());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CmdMeshSmoothing::isActive()
|
||||
{
|
||||
#if 1
|
||||
if (Gui::Control().activeDialog())
|
||||
return false;
|
||||
#endif
|
||||
// Check for the selected mesh feature (all Mesh types)
|
||||
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
|
||||
}
|
||||
|
||||
@@ -1915,9 +1691,6 @@ bool CmdMeshScale::isActive()
|
||||
void CreateMeshCommands()
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
//rcCmdMgr.addCommand(new CmdMeshDemolding());
|
||||
//rcCmdMgr.addCommand(new CmdMeshToolMesh());
|
||||
//rcCmdMgr.addCommand(new CmdMeshTransform());
|
||||
rcCmdMgr.addCommand(new CmdMeshImport());
|
||||
rcCmdMgr.addCommand(new CmdMeshExport());
|
||||
rcCmdMgr.addCommand(new CmdMeshVertexCurvature());
|
||||
@@ -1926,7 +1699,6 @@ void CreateMeshCommands()
|
||||
rcCmdMgr.addCommand(new CmdMeshDifference());
|
||||
rcCmdMgr.addCommand(new CmdMeshIntersection());
|
||||
rcCmdMgr.addCommand(new CmdMeshPolySegm());
|
||||
//rcCmdMgr.addCommand(new CmdMeshPolySelect());
|
||||
rcCmdMgr.addCommand(new CmdMeshAddFacet());
|
||||
rcCmdMgr.addCommand(new CmdMeshPolyCut());
|
||||
rcCmdMgr.addCommand(new CmdMeshPolySplit());
|
||||
|
||||
@@ -439,20 +439,7 @@ void DlgEvaluateMeshImp::on_analyzeOrientationButton_clicked()
|
||||
const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel();
|
||||
MeshEvalOrientation eval(rMesh);
|
||||
std::vector<MeshCore::FacetIndex> inds = eval.GetIndices();
|
||||
#if 0
|
||||
if (inds.empty() && !eval.Evaluate()) {
|
||||
d->ui.checkOrientationButton->setText(tr("Flipped normals found"));
|
||||
MeshEvalFoldOversOnSurface f_eval(rMesh);
|
||||
if (!f_eval.Evaluate()) {
|
||||
qApp->restoreOverrideCursor();
|
||||
QMessageBox::warning(this, tr("Orientation"),
|
||||
tr("Check failed due to folds on the surface.\n"
|
||||
"Please run the command to repair folds first"));
|
||||
qApp->setOverrideCursor(Qt::WaitCursor);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
if (inds.empty()) {
|
||||
d->ui.checkOrientationButton->setText( tr("No flipped normals") );
|
||||
d->ui.checkOrientationButton->setChecked(false);
|
||||
@@ -958,26 +945,12 @@ void DlgEvaluateMeshImp::on_repairSelfIntersectionButton_clicked()
|
||||
{
|
||||
if (d->meshFeature) {
|
||||
const char* docName = App::GetApplication().getDocumentName(d->meshFeature->getDocument());
|
||||
#if 0
|
||||
const char* objName = d->meshFeature->getNameInDocument();
|
||||
#endif
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
|
||||
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Fix self-intersections"));
|
||||
#if 0
|
||||
try {
|
||||
Gui::Application::Instance->runCommand(
|
||||
true, "App.getDocument(\"%s\").getObject(\"%s\").fixSelfIntersections()"
|
||||
, docName, objName);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(this, tr("Self-intersections"), QString::fromLatin1(e.what()));
|
||||
}
|
||||
#else
|
||||
|
||||
Mesh::MeshObject* mesh = d->meshFeature->Mesh.startEditing();
|
||||
mesh->removeSelfIntersections(d->self_intersections);
|
||||
d->meshFeature->Mesh.finishEditing();
|
||||
#endif
|
||||
|
||||
doc->commitCommand();
|
||||
doc->getDocument()->recompute();
|
||||
|
||||
@@ -1283,7 +1256,6 @@ DockEvaluateMeshImp::DockEvaluateMeshImp( QWidget* parent, Qt::WindowFlags fl )
|
||||
// use Qt macro for preparing for translation stuff (but not translating yet)
|
||||
QDockWidget* dw = pDockMgr->addDockWindow("Evaluate & Repair Mesh",
|
||||
scrollArea, Qt::RightDockWidgetArea);
|
||||
//dw->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
|
||||
dw->show();
|
||||
}
|
||||
|
||||
@@ -255,30 +255,6 @@ void MeshRenderer::Private::generateGLArrays(SoGLRenderAction*,
|
||||
|
||||
void MeshRenderer::Private::renderFacesGLArray(SoGLRenderAction *action)
|
||||
{
|
||||
#if 0 // use Inventor's coordIndex saves memory but the rendering is very slow then
|
||||
const cc_glglue * glue = cc_glglue_instance(action->getCacheContext());
|
||||
PFNGLPRIMITIVERESTARTINDEXPROC glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)
|
||||
cc_glglue_getprocaddress(glue, "glPrimitiveRestartIndex");
|
||||
|
||||
int cnt = coordIndex.getNum();
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
// https://www.opengl.org/discussion_boards/archive/index.php/t-180767.html
|
||||
// https://www.khronos.org/opengl/wiki/Vertex_Rendering#Primitive_Restart
|
||||
glPrimitiveRestartIndex(0xffffffff);
|
||||
glEnable(GL_PRIMITIVE_RESTART);
|
||||
//glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
||||
|
||||
glInterleavedArrays(GL_N3F_V3F, 0, &(vertex_array[0]));
|
||||
glDrawElements(GL_TRIANGLES, cnt, GL_UNSIGNED_INT, coordIndex.getValues(0));
|
||||
|
||||
glDisable(GL_PRIMITIVE_RESTART);
|
||||
//glDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
#else // Needs more memory but makes it very fast
|
||||
(void)action;
|
||||
int cnt = index_array.size();
|
||||
|
||||
@@ -293,7 +269,7 @@ void MeshRenderer::Private::renderFacesGLArray(SoGLRenderAction *action)
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void MeshRenderer::Private::renderCoordsGLArray(SoGLRenderAction *)
|
||||
@@ -616,9 +592,6 @@ void SoFCIndexedFaceSet::drawFaces(SoGLRenderAction *action)
|
||||
drawCoords(static_cast<const SoGLCoordinateElement*>(coords), cindices, numindices,
|
||||
normals, nindices, &mb, mindices, binding, &tb, tindices);
|
||||
|
||||
// getVertexData() internally calls readLockNormalCache() that read locks
|
||||
// the normal cache. When the cache is not needed any more we must call
|
||||
// readUnlockNormalCache()
|
||||
if (normalCacheUsed)
|
||||
this->readUnlockNormalCache();
|
||||
|
||||
@@ -976,15 +949,13 @@ void SoFCIndexedFaceSet::startSelection(SoAction * action)
|
||||
glInitNames();
|
||||
glPushName(-1);
|
||||
|
||||
//double mp[16];
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT,viewport);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
//glGetDoublev(GL_PROJECTION_MATRIX ,mp);
|
||||
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
// See https://www.opengl.org/discussion_boards/showthread.php/184308-gluPickMatrix-Implementation?p=1259884&viewfull=1#post1259884
|
||||
//gluPickMatrix(x, y, w, h, viewport);
|
||||
|
||||
if (w > 0 && h > 0) {
|
||||
glTranslatef((viewport[2] - 2 * (x - viewport[0])) / w, (viewport[3] - 2 * (y - viewport[1])) / h, 0);
|
||||
glScalef(viewport[2] / w, viewport[3] / h, 1.0);
|
||||
@@ -1074,11 +1045,6 @@ void SoFCIndexedFaceSet::stopVisibility(SoAction * /*action*/)
|
||||
|
||||
void SoFCIndexedFaceSet::renderVisibleFaces(const SbVec3f * coords3d)
|
||||
{
|
||||
//GLint redBits, greenBits, blueBits;
|
||||
|
||||
//glGetIntegerv (GL_RED_BITS, &redBits);
|
||||
//glGetIntegerv (GL_GREEN_BITS, &greenBits);
|
||||
//glGetIntegerv (GL_BLUE_BITS, &blueBits);
|
||||
glDisable (GL_BLEND);
|
||||
glDisable (GL_DITHER);
|
||||
glDisable (GL_FOG);
|
||||
|
||||
@@ -668,9 +668,6 @@ void SoFCMeshObjectShape::GLRender(SoGLRenderAction *action)
|
||||
drawPoints(mesh, needNormals, ccw);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Disable caching for this node
|
||||
//SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DONT_AUTO_CACHE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -885,32 +882,6 @@ void SoFCMeshObjectShape::generateGLArrays(SoState * state)
|
||||
const MeshCore::MeshPointArray& cP = kernel.GetPoints();
|
||||
const MeshCore::MeshFacetArray& cF = kernel.GetFacets();
|
||||
|
||||
#if 0
|
||||
// Smooth shading
|
||||
face_vertices.resize(cP.size() * 6);
|
||||
face_indices.resize(3 * cF.size());
|
||||
|
||||
int indexed = 0;
|
||||
for (MeshCore::MeshPointArray::const_iterator it = cP.begin(); it != cP.end(); ++it) {
|
||||
face_vertices[indexed * 6 + 3] += it->x;
|
||||
face_vertices[indexed * 6 + 4] += it->y;
|
||||
face_vertices[indexed * 6 + 5] += it->z;
|
||||
indexed++;
|
||||
}
|
||||
|
||||
indexed = 0;
|
||||
for (MeshCore::MeshFacetArray::const_iterator it = cF.begin(); it != cF.end(); ++it) {
|
||||
Base::Vector3f n = kernel.GetFacet(*it).GetNormal();
|
||||
for (int i=0; i<3; i++) {
|
||||
int32_t idx = it->_aulPoints[i];
|
||||
face_vertices[idx * 6 + 0] += n.x;
|
||||
face_vertices[idx * 6 + 1] += n.y;
|
||||
face_vertices[idx * 6 + 2] += n.z;
|
||||
|
||||
face_indices[indexed++] = idx;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Flat shading
|
||||
face_vertices.reserve(3 * cF.size() * 6); // duplicate each vertex
|
||||
face_indices.resize(3 * cF.size());
|
||||
@@ -931,8 +902,6 @@ void SoFCMeshObjectShape::generateGLArrays(SoState * state)
|
||||
indexed++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
this->index_array.swap(face_indices);
|
||||
this->vertex_array.swap(face_vertices);
|
||||
}
|
||||
@@ -1016,15 +985,11 @@ void SoFCMeshObjectShape::startSelection(SoAction * action, const Mesh::MeshObje
|
||||
glInitNames();
|
||||
glPushName(-1);
|
||||
|
||||
//double mp[16];
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT,viewport);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
//glGetDoublev(GL_PROJECTION_MATRIX ,mp);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
// See https://www.opengl.org/discussion_boards/showthread.php/184308-gluPickMatrix-Implementation?p=1259884&viewfull=1#post1259884
|
||||
//gluPickMatrix(x, y, w, h, viewport);
|
||||
if (w > 0 && h > 0) {
|
||||
glTranslatef((viewport[2] - 2 * (x - viewport[0])) / w, (viewport[3] - 2 * (y - viewport[1])) / h, 0);
|
||||
glScalef(viewport[2] / w, viewport[3] / h, 1.0);
|
||||
@@ -1087,13 +1052,6 @@ void SoFCMeshObjectShape::renderSelectionGeometry(const Mesh::MeshObject* mesh)
|
||||
}
|
||||
}
|
||||
|
||||
// test bbox intersection
|
||||
//static SbBool
|
||||
//SoFCMeshObjectShape_ray_intersect(SoRayPickAction * action, const SbBox3f & box)
|
||||
//{
|
||||
// if (box.isEmpty()) return false;
|
||||
// return action->intersect(box, true);
|
||||
//}
|
||||
|
||||
/**
|
||||
* Calculates picked point based on primitives generated by subclasses.
|
||||
@@ -1101,15 +1059,6 @@ void SoFCMeshObjectShape::renderSelectionGeometry(const Mesh::MeshObject* mesh)
|
||||
void
|
||||
SoFCMeshObjectShape::rayPick(SoRayPickAction * action)
|
||||
{
|
||||
//if (this->shouldRayPick(action)) {
|
||||
// this->computeObjectSpaceRay(action);
|
||||
|
||||
// const SoBoundingBoxCache* bboxcache = getBoundingBoxCache();
|
||||
// if (!bboxcache || !bboxcache->isValid(action->getState()) ||
|
||||
// SoFCMeshObjectShape_ray_intersect(action, bboxcache->getProjectedBox())) {
|
||||
// this->generatePrimitives(action);
|
||||
// }
|
||||
//}
|
||||
inherited::rayPick(action);
|
||||
}
|
||||
|
||||
@@ -1308,9 +1257,6 @@ void SoFCMeshSegmentShape::GLRender(SoGLRenderAction *action)
|
||||
else {
|
||||
drawPoints(mesh, needNormals, ccw);
|
||||
}
|
||||
|
||||
// Disable caching for this node
|
||||
//SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DONT_AUTO_CACHE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1695,9 +1641,6 @@ void SoFCMeshObjectBoundary::GLRender(SoGLRenderAction *action)
|
||||
mb.sendFirst(); // make sure we have the correct material
|
||||
|
||||
drawLines(mesh);
|
||||
|
||||
// Disable caching for this node
|
||||
//SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DONT_AUTO_CACHE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -356,7 +356,6 @@ void ViewProviderMesh::onChanged(const App::Property* prop)
|
||||
else if (prop == &Lighting) {
|
||||
if (Lighting.getValue() == 0) {
|
||||
pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING;
|
||||
//pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
}
|
||||
else {
|
||||
pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
@@ -484,8 +483,7 @@ void ViewProviderMesh::attach(App::DocumentObject *pcFeat)
|
||||
void ViewProviderMesh::updateData(const App::Property* prop)
|
||||
{
|
||||
Gui::ViewProviderGeometryObject::updateData(prop);
|
||||
//if (prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) {
|
||||
//}
|
||||
|
||||
if (prop->getTypeId() == App::PropertyColorList::getClassTypeId()) {
|
||||
Coloring.setStatus(App::Property::Hidden, false);
|
||||
}
|
||||
@@ -513,7 +511,6 @@ App::PropertyColorList* ViewProviderMesh::getColorProperty() const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr; // no such property found
|
||||
}
|
||||
|
||||
@@ -1413,40 +1410,6 @@ private:
|
||||
std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacets(const SbViewportRegion& vp,
|
||||
SoCamera* camera) const
|
||||
{
|
||||
#if 0
|
||||
Q_UNUSED(vp)
|
||||
|
||||
SbVec3f pos = camera->position.getValue();
|
||||
|
||||
const Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
|
||||
const Mesh::MeshObject& mesh = meshProp.getValue();
|
||||
|
||||
const MeshCore::MeshKernel& kernel = mesh.getKernel();
|
||||
MeshCore::MeshFacetGrid grid(kernel);
|
||||
|
||||
std::vector<Base::Vector3f> points;
|
||||
points.reserve(kernel.CountFacets());
|
||||
for (unsigned long i = 0; i < kernel.CountFacets(); i++) {
|
||||
points.push_back(kernel.GetFacet(i).GetGravityPoint());
|
||||
}
|
||||
|
||||
Vertex v(kernel, grid, Base::convertTo<Base::Vector3f>(pos));
|
||||
QFuture<bool> future = QtConcurrent::mapped
|
||||
(points, std::bind(&Vertex::visible, &v, bp::_1));
|
||||
QFutureWatcher<bool> watcher;
|
||||
watcher.setFuture(future);
|
||||
watcher.waitForFinished();
|
||||
|
||||
unsigned long index = 0;
|
||||
std::vector<unsigned long> faces;
|
||||
for (QFuture<bool>::const_iterator i = future.begin(); i != future.end(); ++i, index++) {
|
||||
if ((*i)) {
|
||||
faces.push_back(index);
|
||||
}
|
||||
}
|
||||
|
||||
return faces;
|
||||
#else
|
||||
const Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
|
||||
const Mesh::MeshObject& mesh = meshProp.getValue();
|
||||
uint32_t count = (uint32_t)mesh.countFacets();
|
||||
@@ -1468,13 +1431,9 @@ std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacets(const SbViewpor
|
||||
|
||||
mat->diffuseColor.finishEditing();
|
||||
|
||||
// backface culling
|
||||
//SoShapeHints* hints = new SoShapeHints;
|
||||
//hints->shapeType = SoShapeHints::SOLID;
|
||||
//hints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
SoMaterialBinding* bind = new SoMaterialBinding();
|
||||
bind->value = SoMaterialBinding::PER_FACE;
|
||||
//root->addChild(hints);
|
||||
|
||||
root->addChild(mat);
|
||||
root->addChild(bind);
|
||||
root->addChild(this->getCoordNode());
|
||||
@@ -1509,7 +1468,6 @@ std::vector<Mesh::FacetIndex> ViewProviderMesh::getVisibleFacets(const SbViewpor
|
||||
faces.erase(std::unique(faces.begin(), faces.end()), faces.end());
|
||||
|
||||
return faces;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ViewProviderMesh::cutMesh(const std::vector<SbVec2f>& picked,
|
||||
|
||||
Reference in New Issue
Block a user