static const ResultPtr anEmpty;
theValue = aDoc->findNamingName(aSubShapeName, anUniqueContext ? aCont : anEmpty);
+ // sketch sub-component shape and name is located in separated feature label, try the sub-name
+ if (theValue.IsNull() && aCont->groupName() == ModelAPI_ResultConstruction::group()) {
+ std::string::size_type aSlash = aSubShapeName.rfind('/');
+ if (aSlash != std::string::npos) {
+ std::string aCompName = aSubShapeName.substr(aSlash + 1);
+ CompositeFeaturePtr aComposite =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aDoc->feature(aCont));
+ if (aComposite.get() && aComposite->numberOfSubs()) {
+ const int aSubNum = aComposite->numberOfSubs();
+ for (int a = 0; a < aSubNum; a++) {
+ FeaturePtr aSub = aComposite->subFeature(a);
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aSub->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResults.cbegin();
+ for (; aRes != aResults.cend(); aRes++) {
+ if ((*aRes)->data()->name() == aCompName) {
+ theValue = std::dynamic_pointer_cast<Model_Data>((*aRes)->data())->shapeLab();
+ }
+ }
+ }
+ }
+ }
+ }
+
/* to find the latest lower result that keeps given shape
bool aFindNewContext = true;
while(aFindNewContext && aCont.get()) {
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData && aData->isValid()) {
+ std::string aMyName = data()->name();
TDF_Label& aShapeLab = aData->shapeLab();
if (!theShape.get() || theShape->isNull()) {
aShapeLab.ForgetAllAttributes();
+ TDataStd_Name::Set(aShapeLab, aMyName.c_str()); // restore name forgotten
return;
}
std::shared_ptr<Model_Document> aMyDoc =
aShapeLab.ForgetAllAttributes(); // clear all previously stored
TNaming_Builder aBuilder(aShapeLab);
aBuilder.Generated(aShape);
- std::string aMyName = data()->name();
TDataStd_Name::Set(aShapeLab, aMyName.c_str());
aMyDoc->addNamingName(aShapeLab, aMyName);
} else if (aShape.ShapeType() == TopAbs_EDGE) { // store sub-vertices on sub-labels
TDataStd_Name::Set(aSubLab, aVertexName.c_str());
aMyDoc->addNamingName(aSubLab, aVertexName);
}
- std::string aMyName = data()->name();
TDataStd_Name::Set(aShapeLab, aMyName.c_str());
aMyDoc->addNamingName(aShapeLab, aMyName);
} else { // this is probably sketch, so, work with it as with composite
}
}
aShapeLab.ForgetAllAttributes(); // clear all previously stored
+ TDataStd_Name::Set(aShapeLab, aMyName.c_str()); // restore name forgotten
TNaming_Builder aBuilder(aShapeLab); // store the compound to get it ready on open of document
aBuilder.Generated(aShape);
+ aMyDoc->addNamingName(aShapeLab, aMyName);
// set new faces to the labels
int aCurrentTag = 1;
NCollection_List<TopoDS_Face>::Iterator anUnordered(anUnorderedFaces);
aName.erase(std::remove(aName.begin(), aName.end(), '-'), aName.end());
aName.erase(std::remove(aName.begin(), aName.end(), '/'), aName.end());
aName.erase(std::remove(aName.begin(), aName.end(), '&'), aName.end());
+ if (aName.empty())
+ return "";
// remove the last 's', 'e', 'f' and 'r' symbols:
// they are used as markers of start/end/forward/rewersed indicators
static const std::string aSyms("sefr");
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
if (aSketch.get()) {
- for (int i = 0; i < aSketch->numberOfSubs(); i++) {
+ int aNumberOfSubs = aSketch->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aFeature = aSketch->subFeature(i);
aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations
std::list<ResultPtr> aResults = aFeature->results();
return false;
Bnd_Box aBox;
- for (int aSubFeatureId = 0; aSubFeatureId < theSketch->numberOfSubs(); aSubFeatureId++) {
+ int aNumberOfSubs = theSketch->numberOfSubs();
+ for (int aSubFeatureId = 0; aSubFeatureId < aNumberOfSubs; aSubFeatureId++) {
FeaturePtr aFeature = theSketch->subFeature(aSubFeatureId);
if (!aFeature.get())
continue;
CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>
(aResultFeature);
std::list<ResultPtr> anAuxiliaryResults;
- for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) {
+ int aNumberOfSubs = aSketchFeature->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aFeature = aSketchFeature->subFeature(i);
if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) {
std::list<ResultPtr> aResults = aFeature->results();
// Remove invalid sketch entities
std::set<FeaturePtr> anInvalidFeatures;
ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
- for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+ int aNumberOfSubs = myCurrentSketch->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aFeature = myCurrentSketch->subFeature(i);
if (aFeature.get()) {
if (!aFactory->validate(aFeature))
QStringList anInfo;
Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
- for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+ aNumberOfSubs = myCurrentSketch->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aFeature = myCurrentSketch->subFeature(i);
#ifdef DEBUG_SKETCHER_ENTITIES
anInfo.append(ModuleBase_Tools::objectInfo(aFeature));
}
else {
// Hide all sketcher sub-Objects
- for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+ int aNumberOfSubs = myCurrentSketch->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aFeature = myCurrentSketch->subFeature(i);
std::list<ResultPtr> aResults = aFeature->results();
std::list<ResultPtr>::const_iterator aIt;
FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
if (anObjectFeature.get()) {
int aSize = myCurrentSketch->numberOfSubs();
- for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) {
+ for (int i = 0; i < aSize && !isFoundObject; i++) {
FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i);
isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature;
}
if (aPrevState != theState) {
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
- for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+ int aNumberOfSubs = myCurrentSketch->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
bool aProcessed = false;
bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, theType, aProcessed);
return;
static Events_Loop* aLoop = Events_Loop::loop();
- for (int i = 0; i < theComposite->numberOfSubs(); i++) {
+ int aNumberOfSubs = theComposite->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aSubFeature = theComposite->subFeature(i);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
aECreator->sendUpdated(aSubFeature, theEventId);
std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincidencePoint(myConstraint);
std::shared_ptr<GeomAPI_Pnt2d> aP;
FeaturePtr aSub;
- for (int i = 0; i < mySketch->numberOfSubs(); i++) {
+ int aNumberOfSubs = mySketch->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
aSub = mySketch->subFeature(i);
if (aSub->getKind() == SketchPlugin_ConstraintCoincidence::ID() &&
aSub.get() != myConstraint) {
if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultBody::group()) {
ResultBodyPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
- bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
- for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
+ int aNumberOfSubs = aCompsolidResult->numberOfSubs();
+ bool anAllSubsVisible = aNumberOfSubs > 0;
+ for(int i = 0; i < aNumberOfSubs && anAllSubsVisible; i++) {
anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i));
}
aVisible = anAllSubsVisible;