Toponaming: Transfer in missing Code for BaseFeatures and Sketches
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "BodyPy.h"
|
||||
#include "FeatureBase.h"
|
||||
#include "FeatureSketchBased.h"
|
||||
#include "FeatureSolid.h"
|
||||
#include "FeatureTransformed.h"
|
||||
#include "ShapeBinder.h"
|
||||
|
||||
@@ -118,6 +119,22 @@ App::DocumentObject* Body::getPrevSolidFeature(App::DocumentObject *start)
|
||||
start = Tip.getValue();
|
||||
}
|
||||
|
||||
//
|
||||
// #ifdef FC_USE_TNP_FIX
|
||||
// int index;
|
||||
// if (!start || !start->getNameInDocument()
|
||||
// // || start->isDerivedFrom(PartDesign::Extrusion::getClassTypeId())
|
||||
// || start->isDerivedFrom(PartDesign::Solid::getClassTypeId())
|
||||
// || !this->Group.find(start->getNameInDocument(), &index)) { // No Tip
|
||||
// return nullptr;
|
||||
// }
|
||||
// const auto & objs = this->Group.getValues();
|
||||
// for (--index; index>=0; --index) {
|
||||
// if (isSolidFeature(objs[index]))
|
||||
// return objs[index];
|
||||
// }
|
||||
//
|
||||
// #else
|
||||
if (!start) { // No Tip
|
||||
return nullptr;
|
||||
}
|
||||
@@ -136,7 +153,7 @@ App::DocumentObject* Body::getPrevSolidFeature(App::DocumentObject *start)
|
||||
if (rvIt != features.rend()) { // the solid found in model list
|
||||
return *rvIt;
|
||||
}
|
||||
|
||||
// #endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -146,6 +163,20 @@ App::DocumentObject* Body::getNextSolidFeature(App::DocumentObject *start)
|
||||
start = Tip.getValue();
|
||||
}
|
||||
|
||||
// #ifdef FC_USE_TNP_FIX
|
||||
// int index;
|
||||
// if (!start || !start->getNameInDocument()
|
||||
// || !this->Group.find(start->getNameInDocument(), &index)) { // No Tip
|
||||
// return nullptr;
|
||||
// }
|
||||
//
|
||||
// const auto & objs = this->Group.getValues();
|
||||
// int count = this->Group.getSize();
|
||||
// for (++index; index<count; ++index) {
|
||||
// if (isSolidFeature(objs[index]))
|
||||
// return objs[index];
|
||||
// }
|
||||
// #else
|
||||
if (!start || !hasObject(start)) { // no or faulty tip
|
||||
return nullptr;
|
||||
}
|
||||
@@ -167,7 +198,7 @@ App::DocumentObject* Body::getNextSolidFeature(App::DocumentObject *start)
|
||||
if (rvIt != features.end()) { // the solid found in model list
|
||||
return *rvIt;
|
||||
}
|
||||
|
||||
// #endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -190,6 +221,9 @@ bool Body::isSolidFeature(const App::DocumentObject *obj)
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (obj == BaseFeature.getValue())
|
||||
// return true;
|
||||
|
||||
if (obj->isDerivedFrom<PartDesign::Feature>()) {
|
||||
if (PartDesign::Feature::isDatum(obj)) {
|
||||
// Datum objects are not solid
|
||||
@@ -375,6 +409,7 @@ std::vector<App::DocumentObject*> Body::removeObject(App::DocumentObject* featur
|
||||
|
||||
App::DocumentObjectExecReturn *Body::execute()
|
||||
{
|
||||
Part::BodyBase::execute();
|
||||
/*
|
||||
Base::Console().Error("Body '%s':\n", getNameInDocument());
|
||||
App::DocumentObject* tip = Tip.getValue();
|
||||
@@ -502,6 +537,29 @@ std::vector<std::string> Body::getSubObjects(int reason) const {
|
||||
App::DocumentObject *Body::getSubObject(const char *subname,
|
||||
PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const
|
||||
{
|
||||
// while(subname && *subname=='.') ++subname; // skip leading .
|
||||
//
|
||||
// // PartDesign::Feature now support grouping sibling features, and the user
|
||||
// // is free to expand/collapse at any time. To not disrupt subname path
|
||||
// // because of this, the body will peek the next two sub-objects reference,
|
||||
// // and skip the first sub-object if possible.
|
||||
// if(subname) {
|
||||
// const char * firstDot = strchr(subname,'.');
|
||||
// if (firstDot) {
|
||||
// const char * secondDot = strchr(firstDot+1, '.');
|
||||
// if (secondDot) {
|
||||
// auto firstObj = Group.find(std::string(subname, firstDot).c_str());
|
||||
// if (!firstObj || firstObj->isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
|
||||
// auto secondObj = Group.find(std::string(firstDot+1, secondDot).c_str());
|
||||
// if (secondObj) {
|
||||
// // we support only one level of sibling grouping, so no
|
||||
// // recursive call to our own getSubObject()
|
||||
// return Part::BodyBase::getSubObject(firstDot+1,pyObj,pmat,transform,depth+1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
#if 1
|
||||
return Part::BodyBase::getSubObject(subname,pyObj,pmat,transform,depth);
|
||||
#else
|
||||
|
||||
@@ -52,21 +52,31 @@ short int FeatureBase::mustExecute() const {
|
||||
if(BaseFeature.isTouched())
|
||||
return 1;
|
||||
|
||||
return Part::Feature::mustExecute();
|
||||
return PartDesign::Feature::mustExecute();
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObjectExecReturn* FeatureBase::execute() {
|
||||
App::DocumentObjectExecReturn* FeatureBase::execute()
|
||||
{
|
||||
|
||||
if(!BaseFeature.getValue())
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "BaseFeature link is not set"));
|
||||
if (!BaseFeature.getValue()) {
|
||||
return new App::DocumentObjectExecReturn(
|
||||
QT_TRANSLATE_NOOP("Exception", "BaseFeature link is not set"));
|
||||
}
|
||||
|
||||
if(!BaseFeature.getValue()->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "BaseFeature must be a Part::Feature"));
|
||||
if (!BaseFeature.getValue()->isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
return new App::DocumentObjectExecReturn(
|
||||
QT_TRANSLATE_NOOP("Exception", "BaseFeature must be a Part::Feature"));
|
||||
}
|
||||
|
||||
auto shape = static_cast<Part::Feature*>(BaseFeature.getValue())->Shape.getValue();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "BaseFeature has an empty shape"));
|
||||
auto shape = Part::Feature::getTopoShape(BaseFeature.getValue());
|
||||
if (!shape.countSubShapes(TopAbs_SOLID)) {
|
||||
shape = shape.makeElementSolid();
|
||||
}
|
||||
if (shape.isNull()) {
|
||||
return new App::DocumentObjectExecReturn(
|
||||
QT_TRANSLATE_NOOP("Exception", "BaseFeature has an empty shape"));
|
||||
}
|
||||
|
||||
Shape.setValue(shape);
|
||||
|
||||
@@ -91,7 +101,7 @@ void FeatureBase::onChanged(const App::Property* prop) {
|
||||
trySetBaseFeatureOfBody();
|
||||
}
|
||||
|
||||
Part::Feature::onChanged(prop);
|
||||
PartDesign::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
void FeatureBase::onDocumentRestored()
|
||||
@@ -100,6 +110,7 @@ void FeatureBase::onDocumentRestored()
|
||||
auto body = getFeatureBody();
|
||||
if (!body)
|
||||
Placement.setStatus(App::Property::Hidden, false);
|
||||
PartDesign::Feature::onDocumentRestored();
|
||||
}
|
||||
|
||||
}//namespace PartDesign
|
||||
|
||||
Reference in New Issue
Block a user