void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
const std::string& theName)
{
+ GeomShapePtr aResultShape = shape();
+
+ bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
+ if (aNewShapeIsNotInResultShape) {
+ return;
+ }
+
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
builder(myFreePrimitiveTag)->Generated(aShape);
if (!theName.empty()) {
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
const std::string& theName)
{
+ GeomShapePtr aResultShape = shape();
TopTools_MapOfShape anAlreadyProcessedShapes;
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
for (GeomAPI_ShapeExplorer anOldShapeExp(theOldShape, theShapeTypeToExplore);
anOldShapeExp.more();
anOldShapeExp.next())
GeomShapePtr anOldSubShape = anOldShapeExp.current();
const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl<TopoDS_Shape>();
- // There is no sense to write history if shape already processed.
- if (!anAlreadyProcessedShapes.Add(anOldSubShape_)) continue;
+ // There is no sense to write history if shape already processed
+ // or old shape does not exist in the document.
+ bool anOldSubShapeAlreadyProcessed = !anAlreadyProcessedShapes.Add(anOldSubShape_);
+ bool anOldSubShapeNotInTree = TNaming_Tool::NamedShape(anOldSubShape_, aData->shapeLab())
+ .IsNull();
+ if (anOldSubShapeAlreadyProcessed
+ || anOldSubShapeNotInTree)
+ {
+ continue;
+ }
// Get new shapes.
ListOfShape aNewShapes;
GeomShapePtr aNewShape = *aNewShapesIt;
const TopoDS_Shape& aNewShape_ = aNewShape->impl<TopoDS_Shape>();
+ bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape);
+ bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false);
+ if (aNewShapeIsSameAsOldShape
+ || aNewShapeIsNotInResultShape)
+ {
+ continue;
+ }
+
TopAbs_ShapeEnum aNewShapeType = aNewShape_.ShapeType();
if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) {
// TODO: This is a workaround. New shape should be only edge or face.
delete myBuilder;
}
-void Model_ResultBody::loadModifiedShapes(
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
- const GeomShapePtr& theOldShape,
- const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName)
+void Model_ResultBody::generated(const GeomShapePtr& theNewShape,
+ const std::string& theName)
+{
+ 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);
+ }
+ } else { // do for this directly
+ myBuilder->generated(theNewShape, theName);
+ }
+}
+
+void Model_ResultBody::loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName)
+{
+ if (mySubs.size()) { // consists of subs
+ for (std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+ aSubIter != mySubs.cend();
+ ++aSubIter)
+ {
+ const ResultBodyPtr& aSub = *aSubIter;
+ aSub->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
+ }
+ } else { // do for this directly
+ myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
+ }
+}
+
+void Model_ResultBody::loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName)
{
if (/*theSplitInSubs &&*/ mySubs.size()) { // consists of subs
// optimization of getting of new shapes for specific sub-result
/// Removes the stored builders
MODEL_EXPORT virtual ~Model_ResultBody();
- /// load and orient modified shapes for sub-objects
+ /// 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);
+
+ /// load generated shapes
+ MODELAPI_EXPORT
+ virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName = "") override;
+
+ /// load modified shapes for sub-objects
MODEL_EXPORT
virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
- const std::string& theName) override;
+ const std::string& theName = "") override;
/// Returns the number of sub-elements