Enhance API of mesh selection

This commit is contained in:
wmayer 2013-09-04 12:18:20 +02:00
parent b51fcb4470
commit 8f9a9b71a2
5 changed files with 53 additions and 11 deletions

View File

@ -1794,6 +1794,16 @@ MeshRefPointToFacets::operator[] (unsigned long pos) const
return _map[pos]; return _map[pos];
} }
void MeshRefPointToFacets::AddNeighbour(unsigned long pos, unsigned long facet)
{
_map[pos].insert(facet);
}
void MeshRefPointToFacets::RemoveNeighbour(unsigned long pos, unsigned long facet)
{
_map[pos].erase(facet);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MeshRefFacetToFacets::Rebuild (void) void MeshRefFacetToFacets::Rebuild (void)
@ -1881,6 +1891,16 @@ MeshRefPointToPoints::operator[] (unsigned long pos) const
return _map[pos]; return _map[pos];
} }
void MeshRefPointToPoints::AddNeighbour(unsigned long pos, unsigned long facet)
{
_map[pos].insert(facet);
}
void MeshRefPointToPoints::RemoveNeighbour(unsigned long pos, unsigned long facet)
{
_map[pos].erase(facet);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void MeshRefEdgeToFacets::Rebuild (void) void MeshRefEdgeToFacets::Rebuild (void)

View File

@ -374,6 +374,8 @@ public:
std::set<unsigned long> NeighbourPoints(const std::vector<unsigned long>& , int level) const; std::set<unsigned long> NeighbourPoints(const std::vector<unsigned long>& , int level) const;
void Neighbours (unsigned long ulFacetInd, float fMaxDist, MeshCollector& collect) const; void Neighbours (unsigned long ulFacetInd, float fMaxDist, MeshCollector& collect) const;
Base::Vector3f GetNormal(unsigned long) const; Base::Vector3f GetNormal(unsigned long) const;
void AddNeighbour(unsigned long, unsigned long);
void RemoveNeighbour(unsigned long, unsigned long);
protected: protected:
void SearchNeighbours(const MeshFacetArray& rFacets, unsigned long index, const Base::Vector3f &rclCenter, void SearchNeighbours(const MeshFacetArray& rFacets, unsigned long index, const Base::Vector3f &rclCenter,
@ -432,6 +434,8 @@ public:
const std::set<unsigned long>& operator[] (unsigned long) const; const std::set<unsigned long>& operator[] (unsigned long) const;
Base::Vector3f GetNormal(unsigned long) const; Base::Vector3f GetNormal(unsigned long) const;
float GetAverageEdgeLength(unsigned long) const; float GetAverageEdgeLength(unsigned long) const;
void AddNeighbour(unsigned long, unsigned long);
void RemoveNeighbour(unsigned long, unsigned long);
protected: protected:
const MeshKernel &_rclMesh; /**< The mesh kernel. */ const MeshKernel &_rclMesh; /**< The mesh kernel. */

View File

@ -162,13 +162,13 @@ void MeshSelection::stopInteractiveCallback(Gui::View3DInventorViewer* viewer)
} }
} }
void MeshSelection::prepareBrushSelection(bool add) void MeshSelection::prepareBrushSelection(bool add,SoEventCallbackCB *cb)
{ {
// a rubberband to select a rectangle area of the meshes // a rubberband to select a rectangle area of the meshes
Gui::View3DInventorViewer* viewer = this->getViewer(); Gui::View3DInventorViewer* viewer = this->getViewer();
if (viewer) { if (viewer) {
stopInteractiveCallback(viewer); stopInteractiveCallback(viewer);
startInteractiveCallback(viewer, selectGLCallback); startInteractiveCallback(viewer, cb);
// set cross cursor // set cross cursor
Gui::BrushSelection* brush = new Gui::BrushSelection(); Gui::BrushSelection* brush = new Gui::BrushSelection();
brush->setColor(1.0f,0.0f,0.0f); brush->setColor(1.0f,0.0f,0.0f);
@ -186,12 +186,19 @@ void MeshSelection::prepareBrushSelection(bool add)
void MeshSelection::startSelection() void MeshSelection::startSelection()
{ {
prepareBrushSelection(true); prepareBrushSelection(true, selectGLCallback);
} }
void MeshSelection::startDeselection() void MeshSelection::startDeselection()
{ {
prepareBrushSelection(false); prepareBrushSelection(false, selectGLCallback);
}
void MeshSelection::stopSelection()
{
Gui::View3DInventorViewer* viewer = getViewer();
if (viewer)
stopInteractiveCallback(viewer);
} }
void MeshSelection::fullSelection() void MeshSelection::fullSelection()
@ -332,11 +339,21 @@ void MeshSelection::setCheckOnlyPointToUserTriangles(bool on)
onlyPointToUserTriangles = on; onlyPointToUserTriangles = on;
} }
bool MeshSelection::isCheckedOnlyPointToUserTriangles() const
{
return onlyPointToUserTriangles;
}
void MeshSelection::setCheckOnlyVisibleTriangles(bool on) void MeshSelection::setCheckOnlyVisibleTriangles(bool on)
{ {
onlyVisibleTriangles = on; onlyVisibleTriangles = on;
} }
bool MeshSelection::isCheckedOnlyVisibleTriangles() const
{
return onlyVisibleTriangles;
}
void MeshSelection::setAddComponentOnClick(bool on) void MeshSelection::setAddComponentOnClick(bool on)
{ {
addComponent = on; addComponent = on;

View File

@ -47,6 +47,7 @@ public:
void startSelection(); void startSelection();
void startDeselection(); void startDeselection();
void stopSelection();
bool deleteSelection(); bool deleteSelection();
void fullSelection(); void fullSelection();
void clearSelection(); void clearSelection();
@ -58,18 +59,22 @@ public:
void deselectTriangle(); void deselectTriangle();
void setCheckOnlyPointToUserTriangles(bool); void setCheckOnlyPointToUserTriangles(bool);
bool isCheckedOnlyPointToUserTriangles() const;
void setCheckOnlyVisibleTriangles(bool); void setCheckOnlyVisibleTriangles(bool);
bool isCheckedOnlyVisibleTriangles() const;
void setAddComponentOnClick(bool); void setAddComponentOnClick(bool);
void setRemoveComponentOnClick(bool); void setRemoveComponentOnClick(bool);
void setObjects(const std::vector<Gui::SelectionObject>&); void setObjects(const std::vector<Gui::SelectionObject>&);
std::vector<App::DocumentObject*> getObjects() const; std::vector<App::DocumentObject*> getObjects() const;
private: protected:
std::list<ViewProviderMesh*> getViewProviders() const; std::list<ViewProviderMesh*> getViewProviders() const;
Gui::View3DInventorViewer* getViewer() const; Gui::View3DInventorViewer* getViewer() const;
void prepareBrushSelection(bool,SoEventCallbackCB *cb);
void startInteractiveCallback(Gui::View3DInventorViewer* viewer,SoEventCallbackCB *cb); void startInteractiveCallback(Gui::View3DInventorViewer* viewer,SoEventCallbackCB *cb);
void stopInteractiveCallback(Gui::View3DInventorViewer* viewer); void stopInteractiveCallback(Gui::View3DInventorViewer* viewer);
void prepareBrushSelection(bool);
private:
static void selectGLCallback(void * ud, SoEventCallback * n); static void selectGLCallback(void * ud, SoEventCallback * n);
static void pickFaceCallback(void * ud, SoEventCallback * n); static void pickFaceCallback(void * ud, SoEventCallback * n);

View File

@ -1596,11 +1596,7 @@ void ViewProviderMesh::deleteSelection()
if (!indices.empty()) { if (!indices.empty()) {
rMesh.clearFacetSelection(); rMesh.clearFacetSelection();
unhighlightSelection(); unhighlightSelection();
removeFacets(indices);
Mesh::MeshObject* pMesh = meshProp.startEditing();
pMesh->deleteFacets(indices);
meshProp.finishEditing();
pcObject->purgeTouched();
} }
} }