File size: 5,801 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | // SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2010 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef MESHGUI_MESHEDITOR_H
#define MESHGUI_MESHEDITOR_H
#include <QObject>
#include <Mod/Mesh/Gui/ViewProvider.h>
class SoCoordinate3;
class SoFaceSet;
class SoEventCallback;
class SoPickedPoint;
class SoGroup;
class SoSeparator;
class SoRayPickAction;
class SbLine;
class SbVec3f;
namespace Gui
{
class View3DInventor;
class View3DInventorViewer;
} // namespace Gui
namespace Mesh
{
class MeshObject;
}
namespace Mesh
{
class Feature;
}
namespace MeshGui
{
class SoFCMeshPickNode;
/** The ViewProviderFace class is used to display a single face.
* @author Werner Mayer
*/
class MeshGuiExport ViewProviderFace: public Gui::ViewProviderDocumentObject
{
PROPERTY_HEADER_WITH_OVERRIDE(MeshGui::ViewProviderFace);
public:
ViewProviderFace();
~ViewProviderFace() override;
// Build up the initial Inventor node
void attach(App::DocumentObject* obj) override;
void setDisplayMode(const char* ModeName) override;
const char* getDefaultDisplayMode() const override;
std::vector<std::string> getDisplayModes() const override;
SoPickedPoint* getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const;
ViewProviderMesh* mesh {nullptr};
std::vector<int> index;
int current_index {-1};
SoCoordinate3* pcCoords;
SoFaceSet* pcFaces;
SoFCMeshPickNode* pcMeshPick;
FC_DISABLE_COPY_MOVE(ViewProviderFace)
};
/**
* Display data of a mesh kernel.
* \author Werner Mayer
*/
class MeshGuiExport MeshFaceAddition: public QObject
{
Q_OBJECT
public:
explicit MeshFaceAddition(Gui::View3DInventor* parent);
~MeshFaceAddition() override;
void startEditing(ViewProviderMesh*);
public Q_SLOTS:
void finishEditing();
private Q_SLOTS:
void addFace();
void clearPoints();
void flipNormal();
private:
bool addMarkerPoint();
void showMarker(SoPickedPoint*);
static void addFacetCallback(void* ud, SoEventCallback* n);
private:
ViewProviderFace* faceView;
Q_DISABLE_COPY_MOVE(MeshFaceAddition)
};
class MeshGuiExport MeshHoleFiller
{
public:
MeshHoleFiller() = default;
virtual ~MeshHoleFiller() = default;
MeshHoleFiller(const MeshHoleFiller&) = delete;
MeshHoleFiller(MeshHoleFiller&&) = delete;
MeshHoleFiller& operator=(const MeshHoleFiller&) = delete;
MeshHoleFiller& operator=(MeshHoleFiller&&) = delete;
virtual bool fillHoles(
Mesh::MeshObject&,
const std::list<std::vector<Mesh::PointIndex>>&,
Mesh::PointIndex,
Mesh::PointIndex
)
{
return false;
}
};
/**
* Display data of a mesh kernel.
* \author Werner Mayer
*/
class MeshGuiExport MeshFillHole: public QObject
{
Q_OBJECT
public:
MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent);
~MeshFillHole() override;
void startEditing(ViewProviderMesh*);
public Q_SLOTS:
void finishEditing();
private Q_SLOTS:
void closeBridge();
private:
using TBoundary = std::vector<Mesh::PointIndex>;
using Connection = fastsignals::connection;
static void fileHoleCallback(void* ud, SoEventCallback* n);
void createPolygons();
SoNode* getPickedPolygon(const SoRayPickAction& action) const;
float findClosestPoint(const SbLine& ray, const TBoundary& polygon, Mesh::PointIndex&, SbVec3f&) const;
void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop);
private:
SoSeparator* myBoundariesRoot;
SoGroup* myBoundariesGroup;
SoSeparator* myBoundaryRoot;
SoSeparator* myBridgeRoot;
SoCoordinate3* myVertex;
std::map<SoNode*, TBoundary> myPolygons;
Mesh::Feature* myMesh {nullptr};
int myNumPoints {0};
Mesh::PointIndex myVertex1 {0};
Mesh::PointIndex myVertex2 {0};
TBoundary myPolygon;
MeshHoleFiller& myHoleFiller;
Connection myConnection;
Q_DISABLE_COPY_MOVE(MeshFillHole)
};
} // namespace MeshGui
#endif // MESHGUI_MESHEDITOR_H
|