Mesh: Apply clang-format
This commit is contained in:
@@ -22,26 +22,26 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
# include <iomanip>
|
||||
# include <ios>
|
||||
# include <sstream>
|
||||
# include <QCursor>
|
||||
# include <QMenu>
|
||||
#include <QCursor>
|
||||
#include <QMenu>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <ios>
|
||||
#include <sstream>
|
||||
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/details/SoFaceDetail.h>
|
||||
# include <Inventor/actions/SoSearchAction.h>
|
||||
# include <Inventor/events/SoLocation2Event.h>
|
||||
# include <Inventor/events/SoMouseButtonEvent.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
# include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
# include <Inventor/nodes/SoMaterial.h>
|
||||
# include <Inventor/nodes/SoShapeHints.h>
|
||||
# include <Inventor/sensors/SoIdleSensor.h>
|
||||
#include <Inventor/SoPickedPoint.h>
|
||||
#include <Inventor/actions/SoSearchAction.h>
|
||||
#include <Inventor/details/SoFaceDetail.h>
|
||||
#include <Inventor/events/SoLocation2Event.h>
|
||||
#include <Inventor/events/SoMouseButtonEvent.h>
|
||||
#include <Inventor/nodes/SoDrawStyle.h>
|
||||
#include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoShapeHints.h>
|
||||
#include <Inventor/sensors/SoIdleSensor.h>
|
||||
#endif
|
||||
|
||||
# include <boost/range/adaptors.hpp>
|
||||
#include <boost/range/adaptors.hpp>
|
||||
|
||||
#include <App/Annotation.h>
|
||||
#include <App/Document.h>
|
||||
@@ -114,8 +114,8 @@ ViewProviderMeshCurvature::ViewProviderMeshCurvature()
|
||||
mat.transparency = trans[0];
|
||||
}
|
||||
|
||||
ADD_PROPERTY(TextureMaterial,(mat));
|
||||
SelectionStyle.setValue(1); // BBOX
|
||||
ADD_PROPERTY(TextureMaterial, (mat));
|
||||
SelectionStyle.setValue(1); // BBOX
|
||||
}
|
||||
|
||||
ViewProviderMeshCurvature::~ViewProviderMeshCurvature()
|
||||
@@ -131,9 +131,15 @@ void ViewProviderMeshCurvature::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &TextureMaterial) {
|
||||
const App::Material& Mat = TextureMaterial.getValue();
|
||||
pcColorMat->ambientColor.setValue(Mat.ambientColor.r,Mat.ambientColor.g,Mat.ambientColor.b);
|
||||
pcColorMat->specularColor.setValue(Mat.specularColor.r,Mat.specularColor.g,Mat.specularColor.b);
|
||||
pcColorMat->emissiveColor.setValue(Mat.emissiveColor.r,Mat.emissiveColor.g,Mat.emissiveColor.b);
|
||||
pcColorMat->ambientColor.setValue(Mat.ambientColor.r,
|
||||
Mat.ambientColor.g,
|
||||
Mat.ambientColor.b);
|
||||
pcColorMat->specularColor.setValue(Mat.specularColor.r,
|
||||
Mat.specularColor.g,
|
||||
Mat.specularColor.b);
|
||||
pcColorMat->emissiveColor.setValue(Mat.emissiveColor.r,
|
||||
Mat.emissiveColor.g,
|
||||
Mat.emissiveColor.b);
|
||||
pcColorMat->shininess.setValue(Mat.shininess);
|
||||
pcColorMat->transparency.setValue(Mat.transparency);
|
||||
}
|
||||
@@ -160,58 +166,62 @@ void ViewProviderMeshCurvature::init(const Mesh::PropertyCurvatureList* pCurvInf
|
||||
aMinValues.reserve(fCurvInfo.size());
|
||||
aMaxValues.reserve(fCurvInfo.size());
|
||||
|
||||
for (const auto & jt : fCurvInfo) {
|
||||
aMinValues.push_back( jt.fMinCurvature );
|
||||
aMaxValues.push_back( jt.fMaxCurvature );
|
||||
for (const auto& jt : fCurvInfo) {
|
||||
aMinValues.push_back(jt.fMinCurvature);
|
||||
aMaxValues.push_back(jt.fMaxCurvature);
|
||||
}
|
||||
|
||||
if ( aMinValues.empty() || aMaxValues.empty() )
|
||||
return; // no values inside
|
||||
if (aMinValues.empty() || aMaxValues.empty()) {
|
||||
return; // no values inside
|
||||
}
|
||||
|
||||
float fMin = *std::min_element( aMinValues.begin(), aMinValues.end() );
|
||||
float fMax = *std::max_element( aMinValues.begin(), aMinValues.end() );
|
||||
float fMin = *std::min_element(aMinValues.begin(), aMinValues.end());
|
||||
float fMax = *std::max_element(aMinValues.begin(), aMinValues.end());
|
||||
|
||||
// histogram over all values
|
||||
std::map<int, int> aHistogram;
|
||||
for (float aMinValue : aMinValues) {
|
||||
int grp = (int)(10.0f*( aMinValue - fMin )/( fMax - fMin ));
|
||||
int grp = (int)(10.0f * (aMinValue - fMin) / (fMax - fMin));
|
||||
aHistogram[grp]++;
|
||||
}
|
||||
|
||||
float fRMin=-1.0f;
|
||||
for (const auto & mIt : aHistogram) {
|
||||
if ( (float)mIt.second / (float)aMinValues.size() > 0.15f ) {
|
||||
fRMin = mIt.first * ( fMax - fMin )/10.0f + fMin;
|
||||
float fRMin = -1.0f;
|
||||
for (const auto& mIt : aHistogram) {
|
||||
if ((float)mIt.second / (float)aMinValues.size() > 0.15f) {
|
||||
fRMin = mIt.first * (fMax - fMin) / 10.0f + fMin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fMin = *std::min_element( aMaxValues.begin(), aMaxValues.end() );
|
||||
fMax = *std::max_element( aMaxValues.begin(), aMaxValues.end() );
|
||||
fMin = *std::min_element(aMaxValues.begin(), aMaxValues.end());
|
||||
fMax = *std::max_element(aMaxValues.begin(), aMaxValues.end());
|
||||
|
||||
// histogram over all values
|
||||
aHistogram.clear();
|
||||
for (float aMaxValue : aMaxValues) {
|
||||
int grp = (int)(10.0f*( aMaxValue - fMin )/( fMax - fMin ));
|
||||
int grp = (int)(10.0f * (aMaxValue - fMin) / (fMax - fMin));
|
||||
aHistogram[grp]++;
|
||||
}
|
||||
|
||||
float fRMax=1.0f;
|
||||
for ( std::map<int, int>::reverse_iterator rIt2 = aHistogram.rbegin(); rIt2 != aHistogram.rend(); ++rIt2 ) {
|
||||
if ( (float)rIt2->second / (float)aMaxValues.size() > 0.15f ) {
|
||||
fRMax = rIt2->first * ( fMax - fMin )/10.0f + fMin;
|
||||
float fRMax = 1.0f;
|
||||
for (std::map<int, int>::reverse_iterator rIt2 = aHistogram.rbegin(); rIt2 != aHistogram.rend();
|
||||
++rIt2) {
|
||||
if ((float)rIt2->second / (float)aMaxValues.size() > 0.15f) {
|
||||
fRMax = rIt2->first * (fMax - fMin) / 10.0f + fMin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float fAbs = std::max<float>(fabs(fRMin), fabs(fRMax));
|
||||
fRMin = -fAbs;
|
||||
fRMax = fAbs;
|
||||
fMin = fRMin; fMax = fRMax;
|
||||
pcColorBar->setRange( fMin, fMax, 3 );
|
||||
fRMax = fAbs;
|
||||
fMin = fRMin;
|
||||
fMax = fRMax;
|
||||
pcColorBar->setRange(fMin, fMax, 3);
|
||||
}
|
||||
|
||||
void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
|
||||
void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj,
|
||||
const App::Property& Prop)
|
||||
{
|
||||
// we get this for any object for that a property has changed. Thus, we must regard that object
|
||||
// which is linked by our link property
|
||||
@@ -222,26 +232,27 @@ void ViewProviderMeshCurvature::slotChangedObject(const App::DocumentObject& Obj
|
||||
const Mesh::MeshObject& kernel = mesh.getValue();
|
||||
pcColorMat->diffuseColor.setNum((int)kernel.countPoints());
|
||||
pcColorMat->transparency.setNum((int)kernel.countPoints());
|
||||
static_cast<Mesh::Curvature*>(pcObject)->Source.touch(); // make sure to recompute the feature
|
||||
static_cast<Mesh::Curvature*>(pcObject)
|
||||
->Source.touch(); // make sure to recompute the feature
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderMeshCurvature::attach(App::DocumentObject *pcFeat)
|
||||
void ViewProviderMeshCurvature::attach(App::DocumentObject* pcFeat)
|
||||
{
|
||||
// creates the standard viewing modes
|
||||
inherited::attach(pcFeat);
|
||||
attachDocument(pcFeat->getDocument());
|
||||
|
||||
SoShapeHints * flathints = new SoShapeHints;
|
||||
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE ;
|
||||
SoShapeHints* flathints = new SoShapeHints;
|
||||
flathints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
flathints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
|
||||
|
||||
SoGroup* pcColorShadedRoot = new SoGroup();
|
||||
pcColorShadedRoot->addChild(flathints);
|
||||
|
||||
// color shaded
|
||||
SoDrawStyle *pcFlatStyle = new SoDrawStyle();
|
||||
SoDrawStyle* pcFlatStyle = new SoDrawStyle();
|
||||
pcFlatStyle->style = SoDrawStyle::FILLED;
|
||||
pcColorShadedRoot->addChild(pcFlatStyle);
|
||||
|
||||
@@ -254,8 +265,9 @@ void ViewProviderMeshCurvature::attach(App::DocumentObject *pcFeat)
|
||||
addDisplayMaskMode(pcColorShadedRoot, "ColorShaded");
|
||||
|
||||
// Check for an already existing color bar
|
||||
Gui::SoFCColorBar* pcBar = ((Gui::SoFCColorBar*)findFrontRootOfType( Gui::SoFCColorBar::getClassTypeId() ));
|
||||
if ( pcBar ) {
|
||||
Gui::SoFCColorBar* pcBar =
|
||||
((Gui::SoFCColorBar*)findFrontRootOfType(Gui::SoFCColorBar::getClassTypeId()));
|
||||
if (pcBar) {
|
||||
float fMin = pcColorBar->getMinValue();
|
||||
float fMax = pcColorBar->getMaxValue();
|
||||
|
||||
@@ -276,7 +288,8 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
|
||||
{
|
||||
// set to the expected size
|
||||
if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
|
||||
Mesh::Feature* object = static_cast<const App::PropertyLink*>(prop)->getValue<Mesh::Feature*>();
|
||||
Mesh::Feature* object =
|
||||
static_cast<const App::PropertyLink*>(prop)->getValue<Mesh::Feature*>();
|
||||
Gui::coinRemoveAllChildren(this->pcLinkRoot);
|
||||
if (object) {
|
||||
const Mesh::MeshObject& kernel = object->Mesh.getValue();
|
||||
@@ -289,15 +302,18 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
|
||||
ViewProviderMesh* view = static_cast<ViewProviderMesh*>(pDoc->getViewProvider(object));
|
||||
this->pcLinkRoot->addChild(view->getHighlightNode());
|
||||
|
||||
Base::Placement p = static_cast<Mesh::Feature*>(view->getObject())->Placement.getValue();
|
||||
Base::Placement p =
|
||||
static_cast<Mesh::Feature*>(view->getObject())->Placement.getValue();
|
||||
ViewProviderMesh::updateTransform(p, pcTransform);
|
||||
}
|
||||
}
|
||||
else if (prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) {
|
||||
const Mesh::PropertyCurvatureList* curv = static_cast<const Mesh::PropertyCurvatureList*>(prop);
|
||||
if (curv->getSize() < 3) // invalid array
|
||||
const Mesh::PropertyCurvatureList* curv =
|
||||
static_cast<const Mesh::PropertyCurvatureList*>(prop);
|
||||
if (curv->getSize() < 3) { // invalid array
|
||||
return;
|
||||
#if 0 // FIXME: Do not always change the range
|
||||
}
|
||||
#if 0 // FIXME: Do not always change the range
|
||||
init(curv); // init color bar
|
||||
#endif
|
||||
setActiveMode();
|
||||
@@ -311,7 +327,7 @@ SoSeparator* ViewProviderMeshCurvature::getFrontRoot() const
|
||||
|
||||
void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode)
|
||||
{
|
||||
using PropertyMap = std::map<std::string,App::Property*>;
|
||||
using PropertyMap = std::map<std::string, App::Property*>;
|
||||
Mesh::PropertyCurvatureList* pCurvInfo = nullptr;
|
||||
PropertyMap Map;
|
||||
pcObject->getPropertyMap(Map);
|
||||
@@ -321,8 +337,9 @@ void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode)
|
||||
return (type == Mesh::PropertyCurvatureList::getClassTypeId());
|
||||
});
|
||||
|
||||
if (it == Map.end())
|
||||
return; // cannot display this feature type due to missing curvature property
|
||||
if (it == Map.end()) {
|
||||
return; // cannot display this feature type due to missing curvature property
|
||||
}
|
||||
|
||||
pCurvInfo = static_cast<Mesh::PropertyCurvatureList*>(it->second);
|
||||
|
||||
@@ -367,23 +384,23 @@ QIcon ViewProviderMeshCurvature::getIcon() const
|
||||
|
||||
void ViewProviderMeshCurvature::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if ( strcmp("Mean curvature",ModeName)==0 ) {
|
||||
if (strcmp("Mean curvature", ModeName) == 0) {
|
||||
setVertexCurvatureMode(Mesh::PropertyCurvatureList::MeanCurvature);
|
||||
setDisplayMaskMode("ColorShaded");
|
||||
}
|
||||
else if ( strcmp("Gaussian curvature",ModeName)==0 ) {
|
||||
else if (strcmp("Gaussian curvature", ModeName) == 0) {
|
||||
setVertexCurvatureMode(Mesh::PropertyCurvatureList::GaussCurvature);
|
||||
setDisplayMaskMode("ColorShaded");
|
||||
}
|
||||
else if ( strcmp("Maximum curvature",ModeName)==0 ) {
|
||||
else if (strcmp("Maximum curvature", ModeName) == 0) {
|
||||
setVertexCurvatureMode(Mesh::PropertyCurvatureList::MaxCurvature);
|
||||
setDisplayMaskMode("ColorShaded");
|
||||
}
|
||||
else if ( strcmp("Minimum curvature",ModeName)==0 ) {
|
||||
else if (strcmp("Minimum curvature", ModeName) == 0) {
|
||||
setVertexCurvatureMode(Mesh::PropertyCurvatureList::MinCurvature);
|
||||
setDisplayMaskMode("ColorShaded");
|
||||
}
|
||||
else if ( strcmp("Absolute curvature",ModeName)==0 ) {
|
||||
else if (strcmp("Absolute curvature", ModeName) == 0) {
|
||||
setVertexCurvatureMode(Mesh::PropertyCurvatureList::AbsCurvature);
|
||||
setDisplayMaskMode("ColorShaded");
|
||||
}
|
||||
@@ -410,23 +427,28 @@ std::vector<std::string> ViewProviderMeshCurvature::getDisplayModes() const
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderMeshCurvature::OnChange(Base::Subject<int> &/*rCaller*/,int /*rcReason*/)
|
||||
void ViewProviderMeshCurvature::OnChange(Base::Subject<int>& /*rCaller*/, int /*rcReason*/)
|
||||
{
|
||||
setActiveMode();
|
||||
}
|
||||
|
||||
namespace MeshGui {
|
||||
namespace MeshGui
|
||||
{
|
||||
|
||||
class Annotation
|
||||
{
|
||||
public:
|
||||
Annotation(Gui::ViewProviderDocumentObject* vp,
|
||||
const QString& s,const SbVec3f& p, const SbVec3f& n)
|
||||
: vp(vp), s(s), p(p), n(n)
|
||||
{
|
||||
}
|
||||
const QString& s,
|
||||
const SbVec3f& p,
|
||||
const SbVec3f& n)
|
||||
: vp(vp)
|
||||
, s(s)
|
||||
, p(p)
|
||||
, n(n)
|
||||
{}
|
||||
|
||||
static void run(void * data, SoSensor * sensor)
|
||||
static void run(void* data, SoSensor* sensor)
|
||||
{
|
||||
Annotation* self = static_cast<Annotation*>(data);
|
||||
self->show();
|
||||
@@ -438,33 +460,34 @@ public:
|
||||
{
|
||||
App::Document* doc = vp->getObject()->getDocument();
|
||||
|
||||
std::vector<App::DocumentObject*> groups = doc->getObjectsOfType
|
||||
(App::DocumentObjectGroup::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> groups =
|
||||
doc->getObjectsOfType(App::DocumentObjectGroup::getClassTypeId());
|
||||
App::DocumentObjectGroup* group = nullptr;
|
||||
std::string internalname = "CurvatureGroup";
|
||||
for (const auto & it : groups) {
|
||||
for (const auto& it : groups) {
|
||||
if (internalname == it->getNameInDocument()) {
|
||||
group = static_cast<App::DocumentObjectGroup*>(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!group) {
|
||||
group = static_cast<App::DocumentObjectGroup*>(doc->addObject
|
||||
("App::DocumentObjectGroup",internalname.c_str()));
|
||||
group = static_cast<App::DocumentObjectGroup*>(
|
||||
doc->addObject("App::DocumentObjectGroup", internalname.c_str()));
|
||||
}
|
||||
|
||||
App::AnnotationLabel* anno = static_cast<App::AnnotationLabel*>
|
||||
(group->addObject("App::AnnotationLabel", internalname.c_str()));
|
||||
App::AnnotationLabel* anno = static_cast<App::AnnotationLabel*>(
|
||||
group->addObject("App::AnnotationLabel", internalname.c_str()));
|
||||
QStringList lines = s.split(QLatin1String("\n"));
|
||||
std::vector<std::string> text;
|
||||
for (const auto & line : lines)
|
||||
for (const auto& line : lines) {
|
||||
text.emplace_back((const char*)line.toLatin1());
|
||||
}
|
||||
anno->LabelText.setValues(text);
|
||||
std::stringstream str;
|
||||
str << "Curvature info (" << group->Group.getSize() << ")";
|
||||
anno->Label.setValue(str.str());
|
||||
anno->BasePosition.setValue(p[0],p[1],p[2]);
|
||||
anno->TextPosition.setValue(n[0],n[1],n[2]);
|
||||
anno->BasePosition.setValue(p[0], p[1], p[2]);
|
||||
anno->TextPosition.setValue(n[0], n[1], n[2]);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -474,18 +497,20 @@ private:
|
||||
SbVec3f n;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace MeshGui
|
||||
|
||||
void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback * n)
|
||||
void ViewProviderMeshCurvature::curvatureInfoCallback(void* ud, SoEventCallback* n)
|
||||
{
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
|
||||
const SoEvent* ev = n->getEvent();
|
||||
if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
|
||||
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
|
||||
const SoMouseButtonEvent* mbe = static_cast<const SoMouseButtonEvent*>(ev);
|
||||
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
|
||||
// Mark all incoming mouse button events as handled, especially, to deactivate the selection
|
||||
// node
|
||||
n->getAction()->setHandled();
|
||||
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
|
||||
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2
|
||||
&& mbe->getState() == SoButtonEvent::UP) {
|
||||
n->setHandled();
|
||||
// context-menu
|
||||
QMenu menu;
|
||||
@@ -505,8 +530,9 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback
|
||||
view->removeEventCallback(SoEvent::getClassTypeId(), curvatureInfoCallback, ud);
|
||||
}
|
||||
}
|
||||
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) {
|
||||
const SoPickedPoint * point = n->getPickedPoint();
|
||||
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1
|
||||
&& mbe->getState() == SoButtonEvent::UP) {
|
||||
const SoPickedPoint* point = n->getPickedPoint();
|
||||
if (!point) {
|
||||
Base::Console().Message("No facet picked.\n");
|
||||
return;
|
||||
@@ -517,12 +543,14 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback
|
||||
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
|
||||
// really from the mesh we render and not from any other geometry
|
||||
Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath());
|
||||
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId()))
|
||||
if (!vp
|
||||
|| !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId())) {
|
||||
return;
|
||||
}
|
||||
ViewProviderMeshCurvature* self = static_cast<ViewProviderMeshCurvature*>(vp);
|
||||
const SoDetail* detail = point->getDetail(point->getPath()->getTail());
|
||||
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
|
||||
const SoFaceDetail * facedetail = static_cast<const SoFaceDetail *>(detail);
|
||||
const SoFaceDetail* facedetail = static_cast<const SoFaceDetail*>(detail);
|
||||
// get the curvature info of the three points of the picked facet
|
||||
int index1 = facedetail->getPoint(0)->getCoordinateIndex();
|
||||
int index2 = facedetail->getPoint(1)->getCoordinateIndex();
|
||||
@@ -543,31 +571,34 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback
|
||||
}
|
||||
}
|
||||
else if (ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) {
|
||||
const SoPickedPoint * point = n->getPickedPoint();
|
||||
if (!point)
|
||||
const SoPickedPoint* point = n->getPickedPoint();
|
||||
if (!point) {
|
||||
return;
|
||||
}
|
||||
n->setHandled();
|
||||
|
||||
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
|
||||
// really from the mesh we render and not from any other geometry
|
||||
Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath());
|
||||
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId()))
|
||||
if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId())) {
|
||||
return;
|
||||
}
|
||||
ViewProviderMeshCurvature* that = static_cast<ViewProviderMeshCurvature*>(vp);
|
||||
const SoDetail* detail = point->getDetail(point->getPath()->getTail());
|
||||
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
|
||||
const SoFaceDetail * facedetail = static_cast<const SoFaceDetail *>(detail);
|
||||
const SoFaceDetail* facedetail = static_cast<const SoFaceDetail*>(detail);
|
||||
// get the curvature info of the three points of the picked facet
|
||||
int index1 = facedetail->getPoint(0)->getCoordinateIndex();
|
||||
int index2 = facedetail->getPoint(1)->getCoordinateIndex();
|
||||
int index3 = facedetail->getPoint(2)->getCoordinateIndex();
|
||||
std::string info = that->curvatureInfo(false, index1, index2, index3);
|
||||
Gui::getMainWindow()->setPaneText(1,QString::fromLatin1(info.c_str()));
|
||||
Gui::getMainWindow()->setPaneText(1, QString::fromLatin1(info.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, int index2, int index3) const
|
||||
std::string
|
||||
ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, int index2, int index3) const
|
||||
{
|
||||
// get the curvature info of the three points of the picked facet
|
||||
App::Property* prop = pcObject->getPropertyByName("CurvInfo");
|
||||
@@ -577,9 +608,11 @@ std::string ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, in
|
||||
const Mesh::CurvatureInfo& cVal1 = (*curv)[index1];
|
||||
const Mesh::CurvatureInfo& cVal2 = (*curv)[index2];
|
||||
const Mesh::CurvatureInfo& cVal3 = (*curv)[index3];
|
||||
float fVal1 = 0.0f; float fVal2 = 0.0f; float fVal3 = 0.0f;
|
||||
float fVal1 = 0.0f;
|
||||
float fVal2 = 0.0f;
|
||||
float fVal3 = 0.0f;
|
||||
|
||||
bool print=true;
|
||||
bool print = true;
|
||||
std::string mode = getActiveDisplayMode();
|
||||
if (mode == "Minimum curvature") {
|
||||
fVal1 = cVal1.fMinCurvature;
|
||||
@@ -592,19 +625,22 @@ std::string ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, in
|
||||
fVal3 = cVal3.fMaxCurvature;
|
||||
}
|
||||
else if (mode == "Gaussian curvature") {
|
||||
fVal1 = cVal1.fMaxCurvature*cVal1.fMinCurvature;
|
||||
fVal2 = cVal2.fMaxCurvature*cVal2.fMinCurvature;
|
||||
fVal3 = cVal3.fMaxCurvature*cVal3.fMinCurvature;
|
||||
fVal1 = cVal1.fMaxCurvature * cVal1.fMinCurvature;
|
||||
fVal2 = cVal2.fMaxCurvature * cVal2.fMinCurvature;
|
||||
fVal3 = cVal3.fMaxCurvature * cVal3.fMinCurvature;
|
||||
}
|
||||
else if (mode == "Mean curvature") {
|
||||
fVal1 = 0.5f*(cVal1.fMaxCurvature+cVal1.fMinCurvature);
|
||||
fVal2 = 0.5f*(cVal2.fMaxCurvature+cVal2.fMinCurvature);
|
||||
fVal3 = 0.5f*(cVal3.fMaxCurvature+cVal3.fMinCurvature);
|
||||
fVal1 = 0.5f * (cVal1.fMaxCurvature + cVal1.fMinCurvature);
|
||||
fVal2 = 0.5f * (cVal2.fMaxCurvature + cVal2.fMinCurvature);
|
||||
fVal3 = 0.5f * (cVal3.fMaxCurvature + cVal3.fMinCurvature);
|
||||
}
|
||||
else if (mode == "Absolute curvature") {
|
||||
fVal1 = fabs(cVal1.fMaxCurvature) > fabs(cVal1.fMinCurvature) ? cVal1.fMaxCurvature : cVal1.fMinCurvature;
|
||||
fVal2 = fabs(cVal2.fMaxCurvature) > fabs(cVal2.fMinCurvature) ? cVal2.fMaxCurvature : cVal2.fMinCurvature;
|
||||
fVal3 = fabs(cVal3.fMaxCurvature) > fabs(cVal3.fMinCurvature) ? cVal3.fMaxCurvature : cVal3.fMinCurvature;
|
||||
fVal1 = fabs(cVal1.fMaxCurvature) > fabs(cVal1.fMinCurvature) ? cVal1.fMaxCurvature
|
||||
: cVal1.fMinCurvature;
|
||||
fVal2 = fabs(cVal2.fMaxCurvature) > fabs(cVal2.fMinCurvature) ? cVal2.fMaxCurvature
|
||||
: cVal2.fMinCurvature;
|
||||
fVal3 = fabs(cVal3.fMaxCurvature) > fabs(cVal3.fMinCurvature) ? cVal3.fMaxCurvature
|
||||
: cVal3.fMinCurvature;
|
||||
}
|
||||
else {
|
||||
print = false;
|
||||
|
||||
Reference in New Issue
Block a user