fixes #0003169: Mesh Design WB tools does not work on translated object
This commit is contained in:
@@ -39,12 +39,18 @@ using namespace Gui;
|
||||
|
||||
ViewVolumeProjection::ViewVolumeProjection (const SbViewVolume &vv)
|
||||
: viewVolume(vv)
|
||||
, hasTransform(false)
|
||||
{
|
||||
}
|
||||
|
||||
Base::Vector3f ViewVolumeProjection::operator()(const Base::Vector3f &pt) const
|
||||
{
|
||||
SbVec3f pt3d(pt.x,pt.y,pt.z);
|
||||
if (hasTransform) {
|
||||
Base::Vector3f ptt = transform * pt;
|
||||
pt3d.setValue(ptt.x, ptt.y, ptt.z);
|
||||
}
|
||||
|
||||
viewVolume.projectToScreen(pt3d,pt3d);
|
||||
return Base::Vector3f(pt3d[0],pt3d[1],pt3d[2]);
|
||||
}
|
||||
@@ -79,6 +85,17 @@ Base::Vector3d ViewVolumeProjection::inverse (const Base::Vector3d &pt) const
|
||||
return Base::convertTo<Base::Vector3d>(ptf);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief This method applies an additional transformation to the input points
|
||||
* passed with the () operator.
|
||||
* \param mat
|
||||
*/
|
||||
void ViewVolumeProjection::setTransform(const Base::Matrix4D& mat)
|
||||
{
|
||||
transform = mat;
|
||||
hasTransform = (mat != Base::Matrix4D());
|
||||
}
|
||||
|
||||
Base::Matrix4D ViewVolumeProjection::getProjectionMatrix () const
|
||||
{
|
||||
// Inventor stores the transposed matrix
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#include <Base/ViewProj.h>
|
||||
#include <App/Material.h>
|
||||
#include <vector>
|
||||
#include <Inventor/SbColor.h>
|
||||
#include <Inventor/SbVec2f.h>
|
||||
#include <Inventor/SbColor.h>
|
||||
#include <Inventor/SbVec2f.h>
|
||||
#include <Inventor/SbViewVolume.h>
|
||||
|
||||
class SbViewVolume;
|
||||
@@ -96,17 +96,20 @@ class GuiExport ViewVolumeProjection : public Base::ViewProjMethod
|
||||
{
|
||||
public:
|
||||
ViewVolumeProjection (const SbViewVolume &vv);
|
||||
virtual ~ViewVolumeProjection(){};
|
||||
virtual ~ViewVolumeProjection(){}
|
||||
|
||||
Base::Vector3f operator()(const Base::Vector3f &rclPt) const;
|
||||
Base::Vector3d operator()(const Base::Vector3d &rclPt) const;
|
||||
Base::Vector3f inverse (const Base::Vector3f &rclPt) const;
|
||||
Base::Vector3d inverse (const Base::Vector3d &rclPt) const;
|
||||
|
||||
void setTransform(const Base::Matrix4D&);
|
||||
Base::Matrix4D getProjectionMatrix () const;
|
||||
|
||||
protected:
|
||||
SbViewVolume viewVolume;
|
||||
bool hasTransform;
|
||||
Base::Matrix4D transform;
|
||||
};
|
||||
|
||||
class GuiExport Tessellator
|
||||
|
||||
@@ -840,6 +840,8 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n)
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
proj.setTransform(static_cast<Mesh::Feature*>(self->getObject())->
|
||||
Placement.getValue().toMatrix());
|
||||
self->cutMesh(clPoly, proj, clip_inner);
|
||||
}
|
||||
}
|
||||
@@ -878,6 +880,8 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n)
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
proj.setTransform(static_cast<Mesh::Feature*>(self->getObject())->
|
||||
Placement.getValue().toMatrix());
|
||||
self->trimMesh(clPoly, proj, clip_inner);
|
||||
}
|
||||
}
|
||||
@@ -909,7 +913,7 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb)
|
||||
// get the normal of the front clipping plane
|
||||
SbVec3f b,n;
|
||||
view->getNearPlane(b, n);
|
||||
Base::Vector3f cPoint(b[0],b[1],b[2]), cNormal(n[0],n[1],n[2]);
|
||||
Base::Vector3f cNormal(n[0],n[1],n[2]);
|
||||
SoCamera* pCam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vol = pCam->getViewVolume();
|
||||
|
||||
@@ -932,7 +936,11 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb)
|
||||
ViewProviderMesh* that = static_cast<ViewProviderMesh*>(*it);
|
||||
if (that->getEditingMode() > -1) {
|
||||
that->finishEditing();
|
||||
that->splitMesh(toolMesh, cNormal, clip_inner);
|
||||
Base::Placement plm = static_cast<Mesh::Feature*>(that->getObject())->Placement.getValue();
|
||||
plm.invert();
|
||||
MeshCore::MeshKernel copyToolMesh(toolMesh);
|
||||
copyToolMesh.Transform(plm.toMatrix());
|
||||
that->splitMesh(copyToolMesh, cNormal, clip_inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -966,7 +974,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb)
|
||||
// get the normal of the front clipping plane
|
||||
SbVec3f b,n;
|
||||
view->getNearPlane(b, n);
|
||||
Base::Vector3f cPoint(b[0],b[1],b[2]), cNormal(n[0],n[1],n[2]);
|
||||
Base::Vector3f cNormal(n[0],n[1],n[2]);
|
||||
SoCamera* pCam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vol = pCam->getViewVolume();
|
||||
|
||||
@@ -989,7 +997,11 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb)
|
||||
ViewProviderMesh* that = static_cast<ViewProviderMesh*>(*it);
|
||||
if (that->getEditingMode() > -1) {
|
||||
that->finishEditing();
|
||||
that->segmentMesh(toolMesh, cNormal, clip_inner);
|
||||
Base::Placement plm = static_cast<Mesh::Feature*>(that->getObject())->Placement.getValue();
|
||||
plm.invert();
|
||||
MeshCore::MeshKernel copyToolMesh(toolMesh);
|
||||
copyToolMesh.Transform(plm.toMatrix());
|
||||
that->segmentMesh(copyToolMesh, cNormal, clip_inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1059,7 +1071,6 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
|
||||
SbBool inner,
|
||||
std::vector<unsigned long>& indices) const
|
||||
{
|
||||
#if 1
|
||||
const bool ok = true;
|
||||
Base::Polygon2d polygon;
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
||||
@@ -1069,30 +1080,7 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
|
||||
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
|
||||
MeshCore::MeshAlgorithm cAlg(meshProp.getValue().getKernel());
|
||||
cAlg.CheckFacets(&proj, polygon, true, indices);
|
||||
#else
|
||||
// get the normal of the front clipping plane
|
||||
SbVec3f b,n;
|
||||
Viewer.getNearPlane(b, n);
|
||||
Base::Vector3f cPoint(b[0],b[1],b[2]), cNormal(n[0],n[1],n[2]);
|
||||
SoCamera* pCam = Viewer.getCamera();
|
||||
SbViewVolume vol = pCam->getViewVolume();
|
||||
|
||||
// create a tool shape from these points
|
||||
std::vector<MeshCore::MeshGeomFacet> aFaces;
|
||||
bool ok = ViewProviderMesh::createToolMesh(picked, vol, cNormal, aFaces);
|
||||
|
||||
// Get the attached mesh property
|
||||
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
|
||||
|
||||
// Get the facet indices inside the tool mesh
|
||||
MeshCore::MeshKernel cToolMesh;
|
||||
bool locked = Base::Sequencer().setLocked(true);
|
||||
cToolMesh = aFaces;
|
||||
Base::Sequencer().setLocked(locked);
|
||||
MeshCore::MeshFacetGrid cGrid(meshProp.getValue().getKernel());
|
||||
MeshCore::MeshAlgorithm cAlg(meshProp.getValue().getKernel());
|
||||
cAlg.GetFacetsFromToolMesh(cToolMesh, cNormal, cGrid, indices);
|
||||
#endif
|
||||
if (!inner) {
|
||||
// get the indices that are completely outside
|
||||
std::vector<unsigned long> complete(meshProp.getValue().countFacets());
|
||||
|
||||
@@ -301,6 +301,9 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
|
||||
Gui::Document* pDoc = Gui::Application::Instance->getDocument(rDoc);
|
||||
ViewProviderMesh* view = static_cast<ViewProviderMesh*>(pDoc->getViewProvider(object));
|
||||
this->pcLinkRoot->addChild(view->getHighlightNode());
|
||||
|
||||
Base::Placement p = static_cast<Mesh::Feature*>(view->getObject())->Placement.getValue();
|
||||
ViewProviderMesh::updateTransform(p, pcTransform);
|
||||
}
|
||||
}
|
||||
else if (prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) {
|
||||
|
||||
Reference in New Issue
Block a user