extend interface to get actual property with geometric data, get center of gravity of a geometry
This commit is contained in:
@@ -77,6 +77,9 @@ public:
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "MeshGui::ViewProviderMeshFaceSet";
|
||||
}
|
||||
virtual const App::PropertyComplexGeoData* getPropertyOfGeometry() const {
|
||||
return &Mesh;
|
||||
}
|
||||
|
||||
/// handles the MeshPy object
|
||||
virtual PyObject* getPyObject(void);
|
||||
|
||||
@@ -238,6 +238,11 @@ const char* Feature::getViewProviderName(void) const {
|
||||
return "PartGui::ViewProviderPart";
|
||||
}
|
||||
|
||||
const App::PropertyComplexGeoData* Feature::getPropertyOfGeometry() const
|
||||
{
|
||||
return &Shape;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
PROPERTY_SOURCE(Part::FilletBase, Part::Feature)
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const;
|
||||
virtual const App::PropertyComplexGeoData* getPropertyOfGeometry() const;
|
||||
|
||||
virtual PyObject* getPyObject(void);
|
||||
virtual std::vector<PyObject *> getPySubObjects(const std::vector<std::string>&) const;
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
# include <BRepCheck_Result.hxx>
|
||||
# include <BRepClass_FaceClassifier.hxx>
|
||||
# include <BRepFilletAPI_MakeFillet.hxx>
|
||||
# include <BRepGProp.hxx>
|
||||
# include <BRepMesh_IncrementalMesh.hxx>
|
||||
# include <BRepMesh_Triangle.hxx>
|
||||
# include <BRepMesh_Edge.hxx>
|
||||
@@ -94,6 +95,7 @@
|
||||
# include <GeomFill_SectionLaw.hxx>
|
||||
# include <GeomFill_Sweep.hxx>
|
||||
# include <GeomLib.hxx>
|
||||
# include <GProp_GProps.hxx>
|
||||
# include <Law_BSpFunc.hxx>
|
||||
# include <Law_BSpline.hxx>
|
||||
# include <Law_BSpFunc.hxx>
|
||||
@@ -928,6 +930,36 @@ Base::BoundBox3d TopoShape::getBoundBox(void) const
|
||||
return box;
|
||||
}
|
||||
|
||||
bool TopoShape::getCenterOfGravity(Base::Vector3d& center) const
|
||||
{
|
||||
if (_Shape.IsNull())
|
||||
return false;
|
||||
|
||||
// Computing of CentreOfMass
|
||||
gp_Pnt pnt;
|
||||
|
||||
if (_Shape.ShapeType() == TopAbs_VERTEX) {
|
||||
pnt = BRep_Tool::Pnt(TopoDS::Vertex(_Shape));
|
||||
}
|
||||
else {
|
||||
GProp_GProps prop;
|
||||
if (_Shape.ShapeType() == TopAbs_EDGE || _Shape.ShapeType() == TopAbs_WIRE) {
|
||||
BRepGProp::LinearProperties(_Shape, prop);
|
||||
}
|
||||
else if (_Shape.ShapeType() == TopAbs_FACE || _Shape.ShapeType() == TopAbs_SHELL) {
|
||||
BRepGProp::SurfaceProperties(_Shape, prop);
|
||||
}
|
||||
else {
|
||||
BRepGProp::VolumeProperties(_Shape, prop);
|
||||
}
|
||||
|
||||
pnt = prop.CentreOfMass();
|
||||
}
|
||||
|
||||
center.Set(pnt.X(), pnt.Y(), pnt.Z());
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopoShape::Save (Base::Writer & ) const
|
||||
{
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ public:
|
||||
Base::Matrix4D getTransform(void) const;
|
||||
/// Bound box from the CasCade shape
|
||||
Base::BoundBox3d getBoundBox(void)const;
|
||||
virtual bool getCenterOfGravity(Base::Vector3d& center) const;
|
||||
static void convertTogpTrsf(const Base::Matrix4D& mtrx, gp_Trsf& trsf);
|
||||
static void convertToMatrix(const gp_Trsf& trsf, Base::Matrix4D& mtrx);
|
||||
//@}
|
||||
|
||||
@@ -69,6 +69,10 @@ public:
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "PointsGui::ViewProviderScattered";
|
||||
}
|
||||
|
||||
virtual const App::PropertyComplexGeoData* getPropertyOfGeometry() const {
|
||||
return &Points;
|
||||
}
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
//@}
|
||||
|
||||
Reference in New Issue
Block a user