-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <Config_PropManager.h>
+#include <GeomAPI_Circ.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Ellipse.h>
+#include <GeomAPI_Dir.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Dir.h>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
+#include <GeomAPI_Vertex.h>
#include <GeomAlgoAPI_NExplode.h>
#include <GeomDataAPI_Dir.h>
/// Dump std::endl
friend
DumpStorageBuffer& operator<<(DumpStorageBuffer& theBuffer,
- std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&))
+ std::basic_ostream<char>& (*)(std::basic_ostream<char>&))
{
theBuffer.write("\n");
return theBuffer;
std::list<FeaturePtr> aFeatures = aDoc1->allFeatures();
if (aDoc1 != aDoc2) {
+ // Find the position of the part, where its features should be inserted.
+ // It will avoid checking of appropriate elements in partSet after the current part.
+ std::list<FeaturePtr>::iterator aFIt = aFeatures.begin();
+ for (; aFIt != aFeatures.end(); ++aFIt) {
+ ResultPartPtr aPartRes =
+ std::dynamic_pointer_cast<ModelAPI_ResultPart>((*aFIt)->lastResult());
+ if (aPartRes && aPartRes->partDoc() == aDoc2)
+ break;
+ }
+
std::list<FeaturePtr> anAdditionalFeatures = aDoc2->allFeatures();
- aFeatures.insert(aFeatures.end(), anAdditionalFeatures.begin(), anAdditionalFeatures.end());
+ aFeatures.insert(aFIt, anAdditionalFeatures.begin(), anAdditionalFeatures.end());
}
CompositeFeaturePtr aLastCompositeFeature;
std::list<ModelGeomAlgo_Shape::SubshapeOfResult> anApproproate;
if (ModelGeomAlgo_Shape::findSubshapeByPoint(*aFIt, thePoint, theShape->shapeType(),
anApproproate)) {
+ bool isContinue = true;
+ std::list<std::pair<GeomShapePtr, int> > aCenters;
std::list<ModelGeomAlgo_Shape::SubshapeOfResult>::iterator anApIt = anApproproate.begin();
- for (; anApIt != anApproproate.end(); ++anApIt) {
+ for (; anApIt != anApproproate.end() && isContinue; ++anApIt) {
++aNbPossibleSelections;
// stop if the target shape and result are found
if (!aCurShape)
aCurShape = anApIt->myResult->shape();
- if (anApIt->myResult->isSame(theResult) && aCurShape->isSame(theShape))
- break;
+ if (anApIt->myResult->isSame(theResult)) {
+ if (anApIt->myCenterType == (int)ModelAPI_AttributeSelection::NOT_CENTER)
+ isContinue = !aCurShape->isSame(theShape);
+ else if (theShape->isVertex() && aCurShape->isEdge()) {
+ GeomEdgePtr aCurEdge = aCurShape->edge();
+ GeomVertexPtr aVertex = theShape->vertex();
+ GeomPointPtr aCenter;
+ switch (anApIt->myCenterType) {
+ case (int)ModelAPI_AttributeSelection::CIRCLE_CENTER: {
+ GeomCirclePtr aCirc = aCurEdge->circle();
+ if (aCirc)
+ aCenter = aCirc->center();
+ break;
+ }
+ case (int)ModelAPI_AttributeSelection::ELLIPSE_FIRST_FOCUS: {
+ GeomEllipsePtr anEllipse = aCurEdge->ellipse();
+ if (anEllipse)
+ aCenter = anEllipse->firstFocus();
+ break;
+ }
+ case (int)ModelAPI_AttributeSelection::ELLIPSE_SECOND_FOCUS: {
+ GeomEllipsePtr anEllipse = aCurEdge->ellipse();
+ if (anEllipse)
+ aCenter = anEllipse->secondFocus();
+ break;
+ }
+ }
+ if (aCenter && aCenter->distance(aVertex->point()) < 1.e-7)
+ aCenters.push_back(std::pair<GeomShapePtr, int>(aCurShape, aNbPossibleSelections));
+ }
+ }
}
+ // passed till the appropriate shape, check the center of circle
+ // or a focus of ellipse is selected
+ if (isContinue && !aCenters.empty())
+ aNbPossibleSelections = aCenters.front().second;
}
}
return aNbPossibleSelections;
int aFullIndex = 0;
NbFeaturesMap::const_iterator aFIt = myFeatureCount.begin();
for (; aFIt != myFeatureCount.end(); ++aFIt) {
- std::map<std::string, std::pair<int, int> >::const_iterator aFound =
+ std::map<std::string, std::pair<int, int> >::const_iterator aFoundKind =
aFIt->second.find(aKind);
- if (aFound != aFIt->second.end())
- aFullIndex += aFound->second.first;
+ if (aFoundKind != aFIt->second.end())
+ aFullIndex += aFoundKind->second.first;
}
aDefaultName << aKind << "_" << aFullIndex;
}
bool isFeatureDefaultName = myNames[theFeature].myIsDefault;
// Save only names of results which is not correspond to default feature name
- const std::list<ResultPtr>& aResults = theFeature->results();
std::list<ResultPtr> allRes;
ModelAPI_Tools::allResults(theFeature, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
// dump subfeatures and store result to file
bool isOk = process(theDoc) && myDumpStorage->exportTo(theFileName, myModules);
- clearCustomStorage();
return isOk;
}
return theDumper;
}
+
+
+void ModelHighAPI_Dumper::exportVariables() const
+{
+ DocumentPtr aRoot = ModelAPI_Session::get()->moduleDocument();
+ EntityNameMap::const_iterator aNameIter = myNames.cbegin();
+ for(; aNameIter != myNames.end(); aNameIter++) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aNameIter->first);
+ if (aFeature.get() && aFeature->document() != aRoot) {
+ FeaturePtr aPartFeat = ModelAPI_Tools::findPartFeature(aRoot, aFeature->document());
+ if (aPartFeat.get()) {
+ int aFeatureId = aFeature->data()->featureId();
+ int aPartId = aPartFeat->data()->featureId();
+ std::ostringstream anEntryStr;
+ anEntryStr<<aPartId<<":"<<aFeatureId;
+ std::string anEntry = anEntryStr.str();
+ exportVariable(anEntry, aNameIter->second.myCurrentName);
+ size_t aSize = aFeature->results().size();
+ if (aSize > 1) { // additional entries for features with more than one result
+ for(size_t a = 1; a < aSize; a++) {
+ std::ostringstream aResEntryStr;
+ aResEntryStr<<anEntry<<":"<<a;
+ std::string aResEntry = aResEntryStr.str();
+ exportVariable(aResEntry, aNameIter->second.myCurrentName);
+ }
+ }
+ }
+ }
+ }
+}