#include <map>
#include <sstream>
-static void storeSubShape(ResultBodyPtr theResultBody,
+static void storeSubShape(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+ ResultBodyPtr theResultBody,
const GeomShapePtr theShape,
const GeomAPI_Shape::ShapeType theType,
const std::string& theName);
std::list<std::shared_ptr<GeomAlgoAPI_MakeSweep> >::iterator aSweep = aSweeps.begin();
for(; aSweep != aSweeps.end(); aSweep++) {
// Store from shapes.
- storeShapes(theResultBody, aBaseShapeType, (*aSweep)->fromShapes(), "From_");
+ storeShapes(theMakeShape, theResultBody, aBaseShapeType, (*aSweep)->fromShapes(), "From_");
// Store to shapes.
- storeShapes(theResultBody, aBaseShapeType, (*aSweep)->toShapes(), "To_");
+ storeShapes(theMakeShape, theResultBody, aBaseShapeType, (*aSweep)->toShapes(), "To_");
}
}
//=================================================================================================
-void FeaturesPlugin_CompositeSketch::storeShapes(ResultBodyPtr theResultBody,
- const GeomAPI_Shape::ShapeType theBaseShapeType,
- const ListOfShape& theShapes,
- const std::string theName)
+void FeaturesPlugin_CompositeSketch::storeShapes(
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+ ResultBodyPtr theResultBody,
+ const GeomAPI_Shape::ShapeType theBaseShapeType,
+ const ListOfShape& theShapes,
+ const std::string theName)
{
GeomAPI_Shape::ShapeType aShapeTypeToExplore = GeomAPI_Shape::FACE;
std::string aShapeTypeStr = "Face";
if(aShapeTypeToExplore == GeomAPI_Shape::COMPOUND) {
std::string aName = theName + (aShape->shapeType() == GeomAPI_Shape::EDGE ? "Edge" : "Face");
- storeSubShape(theResultBody, aShape, aShape->shapeType(), aName);
+ storeSubShape(theMakeShape, theResultBody, aShape, aShape->shapeType(), aName);
} else {
std::string aName = theName + aShapeTypeStr;
- storeSubShape(theResultBody, aShape, aShapeTypeToExplore, aName);
+ storeSubShape(theMakeShape, theResultBody, aShape, aShapeTypeToExplore, aName);
if (theBaseShapeType == GeomAPI_Shape::WIRE) { // issue 2289: special names also for vertices
aName = theName + "Vertex";
- storeSubShape(theResultBody, aShape, GeomAPI_Shape::VERTEX, aName);
+ storeSubShape(theMakeShape, theResultBody, aShape, GeomAPI_Shape::VERTEX, aName);
}
}
}
}
-void storeSubShape(ResultBodyPtr theResultBody,
- const GeomShapePtr theShape,
- const GeomAPI_Shape::ShapeType theType,
- const std::string& theName)
+void storeSubShape(
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+ ResultBodyPtr theResultBody,
+ const GeomShapePtr theShape,
+ const GeomAPI_Shape::ShapeType theType,
+ const std::string& theName)
{
for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
GeomShapePtr aSubShape = anExp.current();
- theResultBody->generated(aSubShape, theName);
+ if (!theResultBody->generated(aSubShape, theName)) {
+ // store from/to shapes as primitives and then store modification of them by the boolean
+ theResultBody->generated(aSubShape, theName, false);
+ theResultBody->loadModifiedShapes(theMakeShape, aSubShape, theType);
+ }
}
}
const GeomShapePtr theBaseShape,
const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
- /// Used to store from and to shapes.
- void storeShapes(ResultBodyPtr theResultBody,
+ /// Used to store from and to shapes: generated, or in common modified tag
+ void storeShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
+ ResultBodyPtr theResultBody,
const GeomAPI_Shape::ShapeType theBaseShapeType,
const ListOfShape& theShapes,
const std::string theName);
TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str());
}
-void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
- const std::string& theName)
+bool Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
+ const std::string& theName,
+ const bool theCheckIsInResult)
{
GeomShapePtr aResultShape = shape();
-
- bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
- if (aNewShapeIsNotInResultShape) {
- return;
+ if (theCheckIsInResult) {
+ bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
+ if (aNewShapeIsNotInResultShape) {
+ return false;
+ }
}
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
buildName(myFreePrimitiveTag, aName);
}
++myFreePrimitiveTag;
+ return true;
}
void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape,
/// Records the subshape newShape which was generated during a topological construction.
/// As an example, consider the case of a face generated in construction of a box.
- MODEL_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
- const std::string& theName) override;
+ /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
+ MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
+ const std::string& theName, const bool theCheckIsInResult = true) override;
/// Records the shape newShape which was generated from the shape oldShape during a topological
/// construction. As an example, consider the case of a face generated from an edge in
delete myBuilder;
}
-void Model_ResultBody::generated(const GeomShapePtr& theNewShape,
- const std::string& theName)
+bool Model_ResultBody::generated(const GeomShapePtr& theNewShape,
+ const std::string& theName, const bool theCheckIsInResult)
{
+ bool aResult = false;
if (mySubs.size()) { // consists of subs
for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
aSubIter != mySubs.cend();
++aSubIter)
{
const ResultBodyPtr& aSub = *aSubIter;
- aSub->generated(theNewShape, theName);
+ if (aSub->generated(theNewShape, theName, theCheckIsInResult))
+ aResult = true;
}
} else { // do for this directly
- myBuilder->generated(theNewShape, theName);
+ if (myBuilder->generated(theNewShape, theName, theCheckIsInResult))
+ aResult = true;
}
+ return aResult;
}
void Model_ResultBody::loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
/// Records the subshape newShape which was generated during a topological construction.
/// As an example, consider the case of a face generated in construction of a box.
- MODEL_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
- const std::string& theName) override;
+ MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
+ const std::string& theName, const bool theCheckIsInResult = true) override;
/// load generated shapes
MODEL_EXPORT
/// Records the subshape newShape which was generated during a topological construction.
/// As an example, consider the case of a face generated in construction of a box.
- virtual void generated(const GeomShapePtr& theNewShape,
- const std::string& theName) = 0;
+ /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
+ virtual bool generated(const GeomShapePtr& theNewShape,
+ const std::string& theName, const bool theCheckIsInResult = true) = 0;
/// Records the shape newShape which was generated from the shape oldShape during a topological
/// construction. As an example, consider the case of a face generated from an edge in
return myBuilder->shape();
}
-void ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape,
- const std::string& theName)
+bool ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape,
+ const std::string& theName, const bool theCheckIsInResult)
{
- myBuilder->generated(theNewShape, theName);
+ return myBuilder->generated(theNewShape, theName, theCheckIsInResult);
}
void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
/// Records the subshape newShape which was generated during a topological construction.
/// As an example, consider the case of a face generated in construction of a box.
- MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
- const std::string& theName);
+ /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
+ MODELAPI_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
+ const std::string& theName, const bool theCheckIsInResult = true);
/// Records the shape newShape which was generated from the shape oldShape during a topological
/// construction. As an example, consider the case of a face generated from an edge in
break; // some empty label left in the end
}
}
- return true;
+ return myNBLevel.size() == list().size();
}
TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName,