Sketcher: Port and fix internal faces from RealThunder's branch

Co-authored-by: Zheng Lei <realthunder.dev@gmail.com>
Co-authored-by: Kacper Donat <kacper@kadet.net>
Co-authored-by: Pierre-Louis Boyer <pierrelouis.boyer@gmail.com>
This commit is contained in:
paddle
2025-06-13 16:57:43 +02:00
committed by Kacper Donat
parent 5b2a2b822a
commit 76f2b120ff
13 changed files with 391 additions and 119 deletions

View File

@@ -163,6 +163,7 @@ PyMOD_INIT_FUNC(PartGui)
PartGui::SoBrepEdgeSet ::initClass();
PartGui::SoBrepPointSet ::initClass();
PartGui::SoFCControlPoints ::initClass();
PartGui::SoFCShape ::initClass();
PartGui::SoPreviewShape ::initClass();
PartGui::ViewProviderAttachExtension ::init();
PartGui::ViewProviderAttachExtensionPython ::init();

View File

@@ -47,6 +47,23 @@
using namespace PartGui;
SO_NODE_SOURCE(SoFCShape);
SoFCShape::SoFCShape()
: coords(new SoCoordinate3)
, norm(new SoNormal)
, faceset(new SoBrepFaceSet)
, lineset(new SoBrepEdgeSet)
, nodeset(new SoBrepPointSet)
{
SO_NODE_CONSTRUCTOR(SoFCShape);
}
void SoFCShape::initClass()
{
SO_NODE_INIT_CLASS(SoFCShape, SoSeparator, "Separator");
}
SO_NODE_SOURCE(SoFCControlPoints)
void SoFCControlPoints::initClass()

View File

@@ -23,14 +23,34 @@
#ifndef PARTGUI_SOFCSHAPEOBJECT_H
#define PARTGUI_SOFCSHAPEOBJECT_H
#include "SoBrepEdgeSet.h"
#include "SoBrepFaceSet.h"
#include "SoBrepPointSet.h"
#include <Inventor/fields/SoSFColor.h>
#include <Inventor/fields/SoSFUInt32.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoShape.h>
#include <Mod/Part/PartGlobal.h>
namespace PartGui {
class PartGuiExport SoFCShape : public SoSeparator {
using inherited = SoSeparator;
SO_NODE_HEADER(SoFCShape);
public:
SoFCShape();
static void initClass();
SoCoordinate3* coords;
SoNormal* norm;
SoBrepFaceSet* faceset;
SoBrepEdgeSet* lineset;
SoBrepPointSet* nodeset;
};
class PartGuiExport SoFCControlPoints : public SoShape {
using inherited = SoShape;

View File

@@ -1311,6 +1311,23 @@ void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
# endif
}
void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
SoFCShape* node,
double deviation,
double angularDeflection,
bool normalsFromUV)
{
setupCoinGeometry(shape,
node->coords,
node->faceset,
node->norm,
node->lineset,
node->nodeset,
deviation,
angularDeflection,
normalsFromUV);
}
void ViewProviderPartExt::updateVisual()
{
Gui::SoUpdateVBOAction action;

View File

@@ -23,6 +23,9 @@
#ifndef PARTGUI_VIEWPROVIDERPARTEXT_H
#define PARTGUI_VIEWPROVIDERPARTEXT_H
#include "SoFCShapeObject.h"
#include <map>
#include <App/PropertyUnits.h>
@@ -169,7 +172,13 @@ public:
SoBrepPointSet* nodeset,
double deviation,
double angularDeflection,
bool normalsFromUV);
bool normalsFromUV = false);
static void setupCoinGeometry(TopoDS_Shape shape,
SoFCShape* node,
double deviation,
double angularDeflection,
bool normalsFromUV = false);
protected:
bool setEdit(int ModNum) override;

View File

@@ -45,11 +45,6 @@ SO_NODE_SOURCE(SoPreviewShape);
const SbColor SoPreviewShape::defaultColor = SbColor(1.F, 0.F, 1.F);
SoPreviewShape::SoPreviewShape()
: coords(new SoCoordinate3)
, norm(new SoNormal)
, faceset(new PartGui::SoBrepFaceSet)
, lineset(new PartGui::SoBrepEdgeSet)
, nodeset(new PartGui::SoBrepPointSet)
{
SO_NODE_CONSTRUCTOR(SoPreviewShape);
@@ -216,14 +211,9 @@ void ViewProviderPreviewExtension::updatePreviewShape(Part::TopoShape shape,
const auto updatePreviewShape = [vp](SoPreviewShape* preview, Part::TopoShape shape) {
ViewProviderPartExt::setupCoinGeometry(shape.getShape(),
preview->coords,
preview->faceset,
preview->norm,
preview->lineset,
preview->nodeset,
preview,
vp->Deviation.getValue(),
vp->AngularDeflection.getValue(),
false);
vp->AngularDeflection.getValue());
};
try {

View File

@@ -27,6 +27,7 @@
#include "SoBrepEdgeSet.h"
#include "SoBrepFaceSet.h"
#include "SoBrepPointSet.h"
#include "SoFCShapeObject.h"
#include <QtCore>
@@ -47,8 +48,8 @@
namespace PartGui {
class PartGuiExport SoPreviewShape : public SoSeparator {
using inherited = SoSeparator;
class PartGuiExport SoPreviewShape : public SoFCShape {
using inherited = SoFCShape;
SO_NODE_HEADER(SoPreviewShape);
public:
@@ -62,13 +63,6 @@ public:
SoSFColor color;
SoSFFloat transparency;
SoSFFloat lineWidth;
SoCoordinate3* coords;
SoNormal* norm;
SoBrepFaceSet* faceset;
SoBrepEdgeSet* lineset;
SoBrepPointSet* nodeset;
};
class PartGuiExport ViewProviderPreviewExtension : public Gui::ViewProviderExtension {