From: mpv Date: Tue, 11 Dec 2018 12:59:16 +0000 (+0300) Subject: Remove of unused methods from the BodyBuilder X-Git-Tag: End2018~77 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc80cc95e126484f9da128cd640ab245c6ac1ee6;p=modules%2Fshaper.git Remove of unused methods from the BodyBuilder --- diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 212d9d1b4..fee31e5c4 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -96,21 +96,6 @@ static int getModificationTag(const TopoDS_Shape& theShape) { return INVALID_TAG; } -static TopAbs_ShapeEnum convertShapeType(const GeomAPI_Shape::ShapeType theType) { - switch (theType) { - case GeomAPI_Shape::VERTEX: return TopAbs_VERTEX; - case GeomAPI_Shape::EDGE: return TopAbs_EDGE; - case GeomAPI_Shape::WIRE: return TopAbs_WIRE; - case GeomAPI_Shape::FACE: return TopAbs_FACE; - case GeomAPI_Shape::SHELL: return TopAbs_SHELL; - case GeomAPI_Shape::SOLID: return TopAbs_SOLID; - case GeomAPI_Shape::COMPSOLID: return TopAbs_COMPSOLID; - case GeomAPI_Shape::COMPOUND: return TopAbs_COMPOUND; - case GeomAPI_Shape::SHAPE: return TopAbs_SHAPE; - } - return TopAbs_SHAPE; -} - static bool isAlreadyStored(const TNaming_Builder* theBuilder, const TopoDS_Shape& theOldShape, const TopoDS_Shape& theNewShape) @@ -259,21 +244,6 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape, } } -void Model_BodyBuilder::storeWithoutNaming(const GeomShapePtr& theShape) -{ - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - if (aData) { - clean(); - if (!theShape.get()) - return; // bad shape - TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) - return; // null shape inside - TNaming_Builder aBuilder(aData->shapeLab()); - aBuilder.Select(aShape, aShape); - } -} - void Model_BodyBuilder::clean() { TDF_Label aLab = std::dynamic_pointer_cast(data())->shapeLab(); @@ -391,12 +361,6 @@ void Model_BodyBuilder::modified(const GeomShapePtr& theOldShape, buildName(aTag, theName); } -void Model_BodyBuilder::deleted(const GeomShapePtr& theOldShape) -{ - TopoDS_Shape aShape = theOldShape->impl(); - builder(DELETED_TAG)->Delete(aShape); -} - void Model_BodyBuilder::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, const GeomShapePtr& theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, @@ -430,22 +394,6 @@ void Model_BodyBuilder::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, } } -static void removeBadShapes(ListOfShape& theShapes) -{ - ListOfShape::iterator anIt = theShapes.begin(); - while (anIt != theShapes.end()) { - TopoDS_Shape aNewShape = (*anIt)->impl(); - bool aSkip = aNewShape.IsNull() - || (aNewShape.ShapeType() == TopAbs_EDGE && BRep_Tool::Degenerated(TopoDS::Edge(aNewShape))); - if (aSkip) { - ListOfShape::iterator aRemoveIt = anIt++; - theShapes.erase(aRemoveIt); - } else { - ++anIt; - } - } -} - // Keep only the shapes with minimal shape type static void keepTopLevelShapes(ListOfShape& theShapes, const TopoDS_Shape& theRoot, @@ -478,15 +426,6 @@ static void keepTopLevelShapes(ListOfShape& theShapes, } } -// returns an ancestor shape-type that used for naming-definition of the sub-type -TopAbs_ShapeEnum typeOfAncestor(const TopAbs_ShapeEnum theSubType) { - if (theSubType == TopAbs_VERTEX) - return TopAbs_EDGE; - if (theSubType == TopAbs_EDGE) - return TopAbs_FACE; - return TopAbs_VERTEX; // bad case -} - /// Checks that shape is presented in the tree with not-selection evolution /// In theOriginalLabel it returns label where NS of old sub-shape is stored static bool isShapeInTree(const TDF_Label& theAccess1, const TDF_Label& theAccess2, @@ -703,6 +642,7 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, } } +// LCOV_EXCL_START //======================================================================= int getDangleShapes(const TopoDS_Shape& theShapeIn, const TopAbs_ShapeEnum theGeneratedFrom, @@ -735,6 +675,7 @@ void loadGeneratedDangleShapes( for (; itr.More(); itr.Next()) theBuilder->Generated(itr.Key(), itr.Value()); } +// LCOV_EXCL_STOP //======================================================================= void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape, @@ -935,121 +876,6 @@ void Model_BodyBuilder::loadFirstLevel(GeomShapePtr theShape, const std::string& } } -//======================================================================= -void Model_BodyBuilder::loadDisconnectedEdges(GeomShapePtr theShape, const std::string& theName) -{ - if(theShape->isNull()) return; - TopoDS_Shape aShape = theShape->impl(); - TopTools_DataMapOfShapeListOfShape edgeNaborFaces; - TopTools_ListOfShape empty; - TopExp_Explorer explF(aShape, TopAbs_FACE); - for (; explF.More(); explF.Next()) { - const TopoDS_Shape& aFace = explF.Current(); - TopExp_Explorer explV(aFace, TopAbs_EDGE); - for (; explV.More(); explV.Next()) { - const TopoDS_Shape& anEdge = explV.Current(); - if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty); - Standard_Boolean faceIsNew = Standard_True; - TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge)); - for (; itrF.More(); itrF.Next()) { - if (itrF.Value().IsSame(aFace)) { - faceIsNew = Standard_False; - break; - } - } - if (faceIsNew) - edgeNaborFaces.ChangeFind(anEdge).Append(aFace); - } - } - - TopTools_MapOfShape anEdgesToDelete; - TopExp_Explorer anEx(aShape,TopAbs_EDGE); - std::string aName; - for(;anEx.More();anEx.Next()) { - Standard_Boolean aC0 = Standard_False; - TopoDS_Shape anEdge1 = anEx.Current(); - if (edgeNaborFaces.IsBound(anEdge1)) { - const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1); - if (aList1.Extent()<2) continue; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces); - for (; itr.More(); itr.Next()) { - TopoDS_Shape anEdge2 = itr.Key(); - if(anEdgesToDelete.Contains(anEdge2)) continue; - if (anEdge1.IsSame(anEdge2)) continue; - const TopTools_ListOfShape& aList2 = itr.Value(); - // compare lists of the neighbor faces of edge1 and edge2 - if (aList1.Extent() == aList2.Extent()) { - Standard_Integer aMatches = 0; - for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next()) - for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next()) - if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++; - if (aMatches == aList1.Extent()) { - aC0=Standard_True; - builder(myFreePrimitiveTag)->Generated(anEdge2); - anEdgesToDelete.Add(anEdge2); - TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); - aName = theName + "_" + aStr.ToCString(); - buildName(myFreePrimitiveTag, aName); - ++myFreePrimitiveTag; - } - } - } - TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete); - for(;itDelete.More();itDelete.Next()) - edgeNaborFaces.UnBind(itDelete.Key()); - edgeNaborFaces.UnBind(anEdge1); - } - if (aC0) { - builder(myFreePrimitiveTag)->Generated(anEdge1); - TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); - aName = theName + "_" + aStr.ToCString(); - buildName(myFreePrimitiveTag, aName); - ++myFreePrimitiveTag; - } - } -} - -void Model_BodyBuilder::loadDisconnectedVertexes(GeomShapePtr theShape, - const std::string& theName) -{ - if(theShape->isNull()) return; - TopoDS_Shape aShape = theShape->impl(); - TopTools_DataMapOfShapeListOfShape vertexNaborEdges; - TopTools_ListOfShape empty; - TopExp_Explorer explF(aShape, TopAbs_EDGE); - for (; explF.More(); explF.Next()) { - const TopoDS_Shape& anEdge = explF.Current(); - TopExp_Explorer explV(anEdge, TopAbs_VERTEX); - for (; explV.More(); explV.Next()) { - const TopoDS_Shape& aVertex = explV.Current(); - if (!vertexNaborEdges.IsBound(aVertex)) vertexNaborEdges.Bind(aVertex, empty); - Standard_Boolean faceIsNew = Standard_True; - TopTools_ListIteratorOfListOfShape itrF(vertexNaborEdges.Find(aVertex)); - for (; itrF.More(); itrF.Next()) { - if (itrF.Value().IsSame(anEdge)) { - faceIsNew = Standard_False; - break; - } - } - if (faceIsNew) { - vertexNaborEdges.ChangeFind(aVertex).Append(anEdge); - } - } - } - std::string aName; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborEdges); - for (; itr.More(); itr.Next()) { - const TopTools_ListOfShape& naborEdges = itr.Value(); - if (naborEdges.Extent() < 2) { - builder(myFreePrimitiveTag)->Generated(itr.Key()); - TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); - aName = theName + "_" + aStr.ToCString(); - buildName(myFreePrimitiveTag, aName); - ++myFreePrimitiveTag; - } - } -} - GeomShapePtr Model_BodyBuilder::shape() { std::shared_ptr aData = std::dynamic_pointer_cast(data()); @@ -1071,28 +897,3 @@ GeomShapePtr Model_BodyBuilder::shape() } return GeomShapePtr(); } - -bool Model_BodyBuilder::isLatestEqual(const GeomShapePtr& theShape) -{ - if (theShape.get()) { - TopoDS_Shape aShape = theShape->impl(); - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label aShapeLab = aData->shapeLab(); - Handle(TNaming_NamedShape) aName; - if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - TopoDS_Shape aLatest = TNaming_Tool::CurrentShape(aName); - if (aLatest.IsNull()) - return false; - if (aLatest.IsEqual(aShape)) - return true; - // check sub-shapes for comp-solids: - for (TopExp_Explorer anExp(aShape, aLatest.ShapeType()); anExp.More(); anExp.Next()) { - if (aLatest.IsEqual(anExp.Current())) - return true; - } - } - } - } - return false; -} diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index 440791b69..0689a0f52 100755 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -57,10 +57,6 @@ public: const GeomShapePtr& theNewShape, const bool theIsCleanStored = true) override; - /// Stores the shape without naming support - /// \param theShape shape to store - MODEL_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape); - /// Returns the shape-result produced by this feature MODEL_EXPORT virtual GeomShapePtr shape(); @@ -84,10 +80,6 @@ public: const GeomShapePtr& theNewShape, const std::string& theName = "") override; - /// Records the shape oldShape which was deleted from the current label. - /// As an example, consider the case of a face removed by a Boolean operation. - MODEL_EXPORT virtual void deleted(const GeomShapePtr& theOldShape) override; - /// load deleted shapes MODEL_EXPORT virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo, @@ -113,21 +105,9 @@ public: MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, const std::string& theName) override; - /// Loads disconnected edges - MODEL_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape, - const std::string& theName) override; - - /// Loads disconnected vetexes - MODEL_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape, - const std::string& theName) override; - /// Removes the stored builders MODEL_EXPORT virtual ~Model_BodyBuilder(); - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - MODEL_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape); - protected: /// Default constructor accessible only by Model_Objects Model_BodyBuilder(ModelAPI_Object* theOwner); diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 8b736b339..c226ac762 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -309,20 +309,6 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS } } -bool Model_ResultBody::isLatestEqual(const std::shared_ptr& theShape) -{ - if (myBuilder->isLatestEqual(theShape)) - return true; - // also check that it is asked for sub-elements - std::vector::const_iterator aSubIter = mySubs.cbegin(); - for(; aSubIter != mySubs.cend(); aSubIter++) { - if (aSubIter->get() && (*aSubIter)->isLatestEqual(theShape)) { - return true; - } - } - return false; -} - bool Model_ResultBody::isConnectedTopology() { TDF_Label aDataLab = std::dynamic_pointer_cast(data())->label(); diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 95cb798c8..721ad71f3 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -33,7 +33,7 @@ * Provides a shape that may be displayed in the viewer. * May provide really huge results, so, working with this kind * of result must be optimized. -* Also provides a conainer of sub-body result in case it is compound or compsolid. +* Also provides a container of sub-body result in case it is compound or compsolid. */ class Model_ResultBody : public ModelAPI_ResultBody { @@ -76,11 +76,11 @@ public: MODEL_EXPORT virtual ResultBodyPtr subResult(const int theIndex, bool forTree = false) const; - /// Returns true if feature or reuslt belong to this composite feature as subs + /// Returns true if feature or result belong to this composite feature as subs /// Returns theIndex - zero based index of sub if found MODEL_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const; - /// Returns the parameters of color definition in the resources config manager + /// Returns the parameters of color definition in the resources configuration manager MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault); @@ -95,10 +95,6 @@ public: /// Sets all subs as concealed in the data tree (referenced by other objects) MODEL_EXPORT virtual void setIsConcealed(const bool theValue); - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape); - /// Returns true is the topology is connected. MODEL_EXPORT virtual bool isConnectedTopology(); @@ -110,7 +106,7 @@ protected: void updateSubs(const std::shared_ptr& theThisShape, const bool theShapeChanged = true); - // Checks the state of children and partents to send events of creation/erase when needed + // Checks the state of children and parents to send events of creation/erase when needed void updateConcealment(); friend class Model_Objects; diff --git a/src/ModelAPI/ModelAPI_BodyBuilder.h b/src/ModelAPI/ModelAPI_BodyBuilder.h index d551a0104..6523241df 100755 --- a/src/ModelAPI/ModelAPI_BodyBuilder.h +++ b/src/ModelAPI/ModelAPI_BodyBuilder.h @@ -54,9 +54,6 @@ public: const GeomShapePtr& theNewShape, const bool theIsCleanStored = true) = 0; - /// Stores the shape without naming support - virtual void storeWithoutNaming(const GeomShapePtr& theShape) = 0; - /// Returns the shape-result produced by this feature virtual GeomShapePtr shape() = 0; @@ -79,10 +76,6 @@ public: const GeomShapePtr& theNewShape, const std::string& theName = "") = 0; - /// Records the shape oldShape which was deleted from the current label. - /// As an example, consider the case of a face removed by a Boolean operation. - virtual void deleted(const GeomShapePtr& theOldShape) = 0; - /// load deleted shapes virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo, const GeomShapePtr& theOldShape, @@ -105,18 +98,6 @@ public: virtual void loadFirstLevel(GeomShapePtr theShape, const std::string& theName) = 0; - /// load disconnected edges - virtual void loadDisconnectedEdges(GeomShapePtr theShape, - const std::string& theName) = 0; - - /// load disconnected vetexes - virtual void loadDisconnectedVertexes(GeomShapePtr theShape, - const std::string& theName) = 0; - - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0; - protected: /// Returns the data manager of this object: attributes MODELAPI_EXPORT virtual std::shared_ptr data() const; @@ -125,7 +106,7 @@ protected: MODELAPI_EXPORT virtual std::shared_ptr document() const; protected: - /// Deafult constructor accessible only from Model_Object + /// Default constructor accessible only from Model_Object MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner); ModelAPI_Object* myOwner; ///< the owner object this builder belongs to diff --git a/src/ModelAPI/ModelAPI_ResultBody.cpp b/src/ModelAPI/ModelAPI_ResultBody.cpp index 96507db57..22284d1ee 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.cpp +++ b/src/ModelAPI/ModelAPI_ResultBody.cpp @@ -82,17 +82,6 @@ void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape, updateSubs(theNewShape); } -void ModelAPI_ResultBody::storeWithoutNaming(const GeomShapePtr& theShape) -{ - myBuilder->storeWithoutNaming(theShape); - myConnect = ConnectionNotComputed; - - static Events_Loop* aLoop = Events_Loop::loop(); - static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); - static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - aECreator->sendUpdated(data()->owner(), aRedispEvent); -} - GeomShapePtr ModelAPI_ResultBody::shape() { return myBuilder->shape(); @@ -119,11 +108,6 @@ void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape, } -void ModelAPI_ResultBody::deleted(const GeomShapePtr& theOldShape) -{ - myBuilder->deleted(theOldShape); -} - void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, const GeomShapePtr& theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, @@ -154,18 +138,6 @@ void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape, myBuilder->loadFirstLevel(theShape, theName); } -void ModelAPI_ResultBody::loadDisconnectedEdges(GeomShapePtr theShape, - const std::string& theName) -{ - myBuilder->loadDisconnectedEdges(theShape, theName); -} - -void ModelAPI_ResultBody::loadDisconnectedVertexes(GeomShapePtr theShape, - const std::string& theName) -{ - myBuilder->loadDisconnectedVertexes(theShape, theName); -} - bool ModelAPI_ResultBody::isConnectedTopology() { if (myConnect == ConnectionNotComputed) { diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 8cb8afdf1..1ad95f5d1 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -36,12 +36,12 @@ class GeomAlgoAPI_MakeShape; * Provides a shape that may be displayed in the viewer. * May provide really huge results, so, working with this kind * of result must be optimized. -* Also provides a conainer of sub-body result in case it is compound or compsolid. +* Also provides a container of sub-body result in case it is compound or compsolid. */ class ModelAPI_ResultBody : public ModelAPI_Result { public: - /// Iternal enumeration for storage the information of connected topology flag + /// Internal enumeration for storage the information of connected topology flag enum ConnectedTopologyFlag { ConnectionNotComputed, ///< not yet computed IsConnected, ///< the topology is connected @@ -87,7 +87,7 @@ public: MODELAPI_EXPORT virtual std::shared_ptr subResult( const int theIndex, bool forTree = false) const = 0; - /// Returns true if feature or reuslt belong to this composite feature as subs + /// Returns true if feature or result belong to this composite feature as subs /// Returns theIndex - zero based index of sub if found MODELAPI_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const = 0; @@ -107,9 +107,6 @@ public: const GeomShapePtr& theNewShape, const bool theIsCleanStored = true); - /// Stores the shape without naming support - MODELAPI_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape); - /// Returns the shape-result produced by this feature MODELAPI_EXPORT virtual GeomShapePtr shape(); @@ -132,10 +129,6 @@ public: const GeomShapePtr& theNewShape, const std::string& theName = ""); - /// Records the shape oldShape which was deleted from the current label. - /// As an example, consider the case of a face removed by a Boolean operation. - MODELAPI_EXPORT virtual void deleted(const GeomShapePtr& theOldShape); - /// load deleted shapes MODELAPI_EXPORT virtual void loadDeletedShapes(const std::shared_ptr& theAlgo, @@ -161,18 +154,6 @@ public: MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, const std::string& theName); - /// load disconnected edges - MODELAPI_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape, - const std::string& theName); - - /// load disconnected vetexes - MODELAPI_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape, - const std::string& theName); - - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - MODELAPI_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0; - /// Returns true is the topology is connected. MODELAPI_EXPORT virtual bool isConnectedTopology() = 0; diff --git a/src/Selector/Selector_NExplode.cpp b/src/Selector/Selector_NExplode.cpp index 33552c40d..5657a171f 100644 --- a/src/Selector/Selector_NExplode.cpp +++ b/src/Selector/Selector_NExplode.cpp @@ -128,7 +128,7 @@ bool CompareShapes::operator() (const TopoDS_Shape& theShape1, } } } -// LCOV_EXCL_START +// LCOV_EXCL_STOP } else // compare addresses if shapes are geometrically equal return theShape1.TShape().get() > theShape2.TShape().get(); }