From: dbv Date: Fri, 4 Sep 2015 13:20:29 +0000 (+0300) Subject: Partition naming for infinite planes X-Git-Tag: V_1.4.0_beta4~118 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=952efeb621c89406b5b4b2a7173ad42de4034fa8;p=modules%2Fshaper.git Partition naming for infinite planes --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index b761d0665..9ab80ccfe 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -152,7 +152,7 @@ void FeaturesPlugin_Boolean::execute() if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-7) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, anObject, aBoolAlgo.shape(), aTools, *aBoolAlgo.makeShape(), *aBoolAlgo.mapOfShapes()); + loadNamingDS(aResultBody, anObject, aTools, aBoolAlgo.shape(), *aBoolAlgo.makeShape(), *aBoolAlgo.mapOfShapes()); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -218,7 +218,7 @@ void FeaturesPlugin_Boolean::execute() if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo.shape()) > 1.e-7) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aCompSolid, aFillerAlgo.shape(), aTools, aMakeShapeList, aMapOfShapes); + loadNamingDS(aResultBody, aCompSolid, aTools, aFillerAlgo.shape(), aMakeShapeList, aMapOfShapes); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -336,7 +336,7 @@ void FeaturesPlugin_Boolean::execute() } std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, anOriginalSolids.front(), aShape, anOriginalSolids, aMakeShapeList, aMapOfShapes); + loadNamingDS(aResultBody, anOriginalSolids.front(), anOriginalSolids, aShape, aMakeShapeList, aMapOfShapes); setResult(aResultBody, aResultIndex); aResultIndex++; break; @@ -354,8 +354,8 @@ void FeaturesPlugin_Boolean::execute() //================================================================================================= void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, - const std::shared_ptr theResultShape, const ListOfShape& theTools, + const std::shared_ptr theResultShape, GeomAlgoAPI_MakeShape& theMakeShape, GeomAPI_DataMapOfShapeShape& theMapOfShapes) { diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h index 7ac31e35b..0a072e822 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h @@ -89,8 +89,8 @@ private: /// Load Naming data structure of the feature to the document void loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, - const std::shared_ptr theResultShape, const ListOfShape& theTools, + const std::shared_ptr theResultShape, GeomAlgoAPI_MakeShape& theMakeShape, GeomAPI_DataMapOfShapeShape& theMapOfShapes); }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index 6000c9d84..e165b5a76 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -59,7 +60,7 @@ std::shared_ptr FeaturesPlugin_Partition::getShape(const std::str //================================================================================================= void FeaturesPlugin_Partition::execute() { - ListOfShape anObjects, aTools; + ListOfShape anObjects, aTools, aToolsForNaming; // Getting objects. AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_Partition::OBJECT_LIST_ID()); @@ -72,22 +73,28 @@ void FeaturesPlugin_Partition::execute() anObjects.push_back(anObject); } + GeomAlgoAPI_MakeShapeList aMakeShapeList; + // Getting tools. AttributeSelectionListPtr aToolsSelList = selectionList(FeaturesPlugin_Partition::TOOL_LIST_ID()); for (int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) { std::shared_ptr aToolAttr = aToolsSelList->value(aToolsIndex); std::shared_ptr aTool = aToolAttr->value(); - if (!aTool.get()) { + if(!aTool.get()) { // it could be a construction plane ResultPtr aContext = aToolAttr->context(); - if (aContext.get()) { + if(aContext.get()) { aTool = GeomAlgoAPI_ShapeTools::faceToInfinitePlane(aContext->shape()); + std::shared_ptr aMkShCustom(new GeomAlgoAPI_MakeShapeCustom); + aMkShCustom->addModified(aContext->shape(), aTool); + aMakeShapeList.append(aMkShCustom); + aTools.push_back(aTool); + aToolsForNaming.push_back(aContext->shape()); } + } else { + aTools.push_back(aTool); + aToolsForNaming.push_back(aTool); } - if (!aTool.get()) { - return; - } - aTools.push_back(aTool); } int aResultIndex = 0; @@ -123,8 +130,9 @@ void FeaturesPlugin_Partition::execute() if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->store(aPartitionAlgo.shape()); - loadNamingDS(aResultBody, anObject, aTools, aPartitionAlgo); + aMakeShapeList.append(aPartitionAlgo.makeShape()); + GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get(); + loadNamingDS(aResultBody, anObject, aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -138,30 +146,29 @@ void FeaturesPlugin_Partition::execute() void FeaturesPlugin_Partition::loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, const ListOfShape& theTools, - const GeomAlgoAPI_Partition& thePartitionAlgo) + const std::shared_ptr theResultShape, + GeomAlgoAPI_MakeShape& theMakeShape, + GeomAPI_DataMapOfShapeShape& theMapOfShapes) { //load result - if(theBaseShape->isEqual(thePartitionAlgo.shape())) { - theResultBody->store(thePartitionAlgo.shape()); + if(theBaseShape->isEqual(theResultShape)) { + theResultBody->store(theResultShape); } else { const int aModifyTag = 1; const int aDeletedTag = 2; const int aSubsolidsTag = 3; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids - theResultBody->storeModified(theBaseShape, thePartitionAlgo.shape(), aSubsolidsTag); - - std::shared_ptr aMkShape = thePartitionAlgo.makeShape(); - std::shared_ptr aMapOfShapes = thePartitionAlgo.mapOfShapes(); + theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); std::string aModName = "Modified"; - theResultBody->loadAndOrientModifiedShapes(aMkShape.get(), theBaseShape, GeomAPI_Shape::FACE, - aModifyTag, aModName, *aMapOfShapes.get()); - theResultBody->loadDeletedShapes(aMkShape.get(), theBaseShape, GeomAPI_Shape::FACE, aDeletedTag); + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, + aModifyTag, aModName, theMapOfShapes); + theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aDeletedTag); for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) { - theResultBody->loadAndOrientModifiedShapes(aMkShape.get(), *anIter, GeomAPI_Shape::FACE, - aModifyTag, aModName, *aMapOfShapes.get()); - theResultBody->loadDeletedShapes(aMkShape.get(), *anIter, GeomAPI_Shape::FACE, aDeletedTag); + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, + aModifyTag, aModName, theMapOfShapes); + theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.h b/src/FeaturesPlugin/FeaturesPlugin_Partition.h index a058fd843..9ec475f44 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.h @@ -63,7 +63,9 @@ private: void loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, const ListOfShape& theTools, - const GeomAlgoAPI_Partition& thePartitionAlgo); + const std::shared_ptr theResultShape, + GeomAlgoAPI_MakeShape& theMakeShape, + GeomAPI_DataMapOfShapeShape& theMapOfShapes); }; diff --git a/src/GeomAPI/CMakeLists.txt b/src/GeomAPI/CMakeLists.txt index 12450b5ef..888da4512 100644 --- a/src/GeomAPI/CMakeLists.txt +++ b/src/GeomAPI/CMakeLists.txt @@ -26,7 +26,8 @@ SET(PROJECT_HEADERS GeomAPI_PlanarEdges.h GeomAPI_AISObject.h GeomAPI_IPresentable.h - GeomAPI_Curve.h + GeomAPI_Curve.h + GeomAPI_DataMapOfShapeMapOfShapes.h GeomAPI_DataMapOfShapeShape.h GeomAPI_ICustomPrs.h GeomAPI_Vertex.h @@ -55,6 +56,7 @@ SET(PROJECT_SOURCES GeomAPI_PlanarEdges.cpp GeomAPI_AISObject.cpp GeomAPI_Curve.cpp + GeomAPI_DataMapOfShapeMapOfShapes.cpp GeomAPI_DataMapOfShapeShape.cpp GeomAPI_Vertex.cpp GeomAPI_ICustomPrs.cpp diff --git a/src/GeomAPI/GeomAPI.i b/src/GeomAPI/GeomAPI.i index ff20e6714..2bd0b7857 100644 --- a/src/GeomAPI/GeomAPI.i +++ b/src/GeomAPI/GeomAPI.i @@ -8,6 +8,7 @@ #include "GeomAPI_Circ.h" #include "GeomAPI_Circ2d.h" #include "GeomAPI_Curve.h" + #include "GeomAPI_DataMapOfShapeMapOfShapes.h" #include "GeomAPI_DataMapOfShapeShape.h" #include "GeomAPI_Dir.h" #include "GeomAPI_Dir2d.h" @@ -48,6 +49,7 @@ %shared_ptr(GeomAPI_Circ) %shared_ptr(GeomAPI_Circ2d) %shared_ptr(GeomAPI_Curve) +%shared_ptr(GeomAPI_DataMapOfShapeMapOfShapes) %shared_ptr(GeomAPI_DataMapOfShapeShape) %shared_ptr(GeomAPI_Dir) %shared_ptr(GeomAPI_Dir2d) @@ -79,6 +81,7 @@ %include "GeomAPI_Circ.h" %include "GeomAPI_Circ2d.h" %include "GeomAPI_Curve.h" +%include "GeomAPI_DataMapOfShapeMapOfShapes.h" %include "GeomAPI_DataMapOfShapeShape.h" %include "GeomAPI_Dir.h" %include "GeomAPI_Dir2d.h" diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.cpp b/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.cpp new file mode 100644 index 000000000..53e5411e6 --- /dev/null +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.cpp @@ -0,0 +1,90 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAPI_DataMapOfShapeMapOfShapes.cpp +// Created: 4 September 2015 +// Author: Dmitry Bobylev + +#include + +#include +#include +#include + +#define MY_MAP implPtr > >() + +//================================================================================================= +GeomAPI_DataMapOfShapeMapOfShapes::GeomAPI_DataMapOfShapeMapOfShapes() +: GeomAPI_Interface(new NCollection_DataMap >) +{} + +//================================================================================================= +bool GeomAPI_DataMapOfShapeMapOfShapes::bind(const std::shared_ptr theKey, + const ListOfShape& theItems) +{ + const TopoDS_Shape& aKey = theKey->impl(); + for(ListOfShape::const_iterator anIt = theItems.cbegin(); anIt != theItems.cend(); anIt++) { + const TopoDS_Shape& anItem = (*anIt)->impl(); + if(MY_MAP->IsBound(aKey)) { + MY_MAP->ChangeFind(aKey).Add(anItem); + } else { + NCollection_Map anItems; + anItems.Add(anItem); + MY_MAP->Bind(aKey, anItems); + } + } + + return true; +} + +//================================================================================================= +bool GeomAPI_DataMapOfShapeMapOfShapes::add(const std::shared_ptr theKey, + const std::shared_ptr theItem) +{ + const TopoDS_Shape& aKey = theKey->impl(); + const TopoDS_Shape& anItem = theItem->impl(); + if(MY_MAP->IsBound(aKey)) { + return MY_MAP->ChangeFind(aKey).Add(anItem) == Standard_True; + } else { + NCollection_Map anItems; + anItems.Add(anItem); + return MY_MAP->Bind(aKey, anItems) == Standard_True; + } +} + +//================================================================================================= +bool GeomAPI_DataMapOfShapeMapOfShapes::isBound(const std::shared_ptr theKey) const +{ + const TopoDS_Shape& aKey = theKey->impl(); + return MY_MAP->IsBound(aKey) == Standard_True; +} + +//================================================================================================= +bool GeomAPI_DataMapOfShapeMapOfShapes::find(const std::shared_ptr theKey, + ListOfShape& theItems) const +{ + const TopoDS_Shape& aKey = theKey->impl(); + + if(MY_MAP->IsBound(aKey) == Standard_False) { + return false; + } + + const NCollection_Map& aMap = MY_MAP->Find(aKey); + for(NCollection_Map::Iterator anIt(aMap); anIt.More(); anIt.Next()) { + std::shared_ptr aShape(new GeomAPI_Shape); + aShape->setImpl(new TopoDS_Shape(anIt.Value())); + theItems.push_back(aShape); + } +} + +//================================================================================================= +bool GeomAPI_DataMapOfShapeMapOfShapes::unBind(const std::shared_ptr theKey) +{ + const TopoDS_Shape& aKey = theKey->impl(); + return MY_MAP->UnBind(aKey) == Standard_True; +} + +//================================================================================================= +int GeomAPI_DataMapOfShapeMapOfShapes::size() const +{ + return MY_MAP->Size(); +} diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.h b/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.h new file mode 100644 index 000000000..5dd4dbd4d --- /dev/null +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeMapOfShapes.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAPI_DataMapOfShapeMapOfShapes.h +// Created: 4 September 2015 +// Author: Dmitry Bobylev + +#ifndef GeomAPI_DataMapOfShapeMapOfShapes_H_ +#define GeomAPI_DataMapOfShapeMapOfShapes_H_ + +#include + +#include + +/**\class GeomAPI_DataMapOfShapeMapOfShapes + * \ingroup DataModel + * \brief DataMap of Shape - Map of Shapes defined by TopoDS_Shapes + */ +class GeomAPI_DataMapOfShapeMapOfShapes : public GeomAPI_Interface +{ +public: + /// Constructor.Creates empty map. + GEOMAPI_EXPORT GeomAPI_DataMapOfShapeMapOfShapes(); + + /** \brief Binds list of shapes to the key shape. + \param[in] theKey key shape. + \param[in] theItems list of shapes. If shapes have duplications in list only one will be stored. + \returns true if items bound successfully. + */ + GEOMAPI_EXPORT bool bind(const std::shared_ptr theKey, + const ListOfShape& theItems); + + /** \brief Adds item to the map bounded to the key. + \param[in] theKey key shape. + \param[in] theItem item shape. + \returns true if item bounded successfully. False if it is already bound. + */ + GEOMAPI_EXPORT bool add(const std::shared_ptr theKey, + const std::shared_ptr theItem); + + /// \return true if theKey is stored in the map. + GEOMAPI_EXPORT bool isBound(const std::shared_ptr theKey) const; + + /// \return list of shapes bounded to theKey. + GEOMAPI_EXPORT bool find(const std::shared_ptr theKey, + ListOfShape& theItems) const; + + /// Undinds shapes from theKey. + GEOMAPI_EXPORT bool unBind(const std::shared_ptr theKey); + + /// \return size of map. + GEOMAPI_EXPORT int size() const; +}; + +#endif diff --git a/src/GeomAPI/GeomAPI_ShapeExplorer.h b/src/GeomAPI/GeomAPI_ShapeExplorer.h index fac506fd1..29136a0cb 100644 --- a/src/GeomAPI/GeomAPI_ShapeExplorer.h +++ b/src/GeomAPI/GeomAPI_ShapeExplorer.h @@ -14,12 +14,11 @@ * \ingroup DataModel * \brief This class is used to explore subshapes on shape. */ - class GeomAPI_ShapeExplorer : public GeomAPI_Interface { public: /// Default constructor. Creates an empty explorer, becomes usefull after Init. - GEOMAPI_EXPORT + GEOMAPI_EXPORT GeomAPI_ShapeExplorer(); /** \brief Constructs an explorer to search on theShape, for shapes of type toFind, @@ -28,7 +27,7 @@ public: \param[in] toFind shape type to find. \param[in] toAvoid shape type to avoid. */ - GEOMAPI_EXPORT + GEOMAPI_EXPORT GeomAPI_ShapeExplorer(const std::shared_ptr& theShape, const GeomAPI_Shape::ShapeType toFind, const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE); @@ -39,33 +38,33 @@ public: \param[in] toFind shape type to find. \param[in] toAvoid shape type to avoid. */ - GEOMAPI_EXPORT + GEOMAPI_EXPORT void init(const std::shared_ptr& theShape, const GeomAPI_Shape::ShapeType toFind, const GeomAPI_Shape::ShapeType toAvoid = GeomAPI_Shape::SHAPE); /// \return true if there are more shapes in the exploration. - GEOMAPI_EXPORT + GEOMAPI_EXPORT bool more() const; /// Moves to the next Shape in the exploration or do nothing if there are no more shapes to explore. - GEOMAPI_EXPORT + GEOMAPI_EXPORT void next(); - /// Returns the current shape in the exploration or empty pointer if this explorer has no more shapes to explore. - GEOMAPI_EXPORT + /// \return the current shape in the exploration or empty pointer if this explorer has no more shapes to explore. + GEOMAPI_EXPORT std::shared_ptr current(); /// Reinitialize the exploration with the original arguments. - GEOMAPI_EXPORT + GEOMAPI_EXPORT void reinit(); - /// Returns the current depth of the exploration. 0 is the shape to explore itself. - GEOMAPI_EXPORT + /// \return the current depth of the exploration. 0 is the shape to explore itself. + GEOMAPI_EXPORT int depth() const; /// Clears the content of the explorer. It will return False on more(). - GEOMAPI_EXPORT + GEOMAPI_EXPORT void clear(); }; diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 4354f0f72..9c85cf7bd 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -20,6 +20,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Rotation.h GeomAlgoAPI_Movement.h GeomAlgoAPI_MakeShape.h + GeomAlgoAPI_MakeShapeCustom.h GeomAlgoAPI_MakeShapeList.h GeomAlgoAPI_DFLoader.h GeomAlgoAPI_Placement.h @@ -49,6 +50,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Rotation.cpp GeomAlgoAPI_Movement.cpp GeomAlgoAPI_MakeShape.cpp + GeomAlgoAPI_MakeShapeCustom.cpp GeomAlgoAPI_MakeShapeList.cpp GeomAlgoAPI_DFLoader.cpp GeomAlgoAPI_Placement.cpp diff --git a/src/GeomAlgoAPI/GeomAlgoAPI.i b/src/GeomAlgoAPI/GeomAlgoAPI.i index cd5474eec..1c1c25283 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI.i +++ b/src/GeomAlgoAPI/GeomAlgoAPI.i @@ -9,6 +9,7 @@ #include "GeomAlgoAPI_Extrusion.h" #include "GeomAlgoAPI_FaceBuilder.h" #include "GeomAlgoAPI_MakeShape.h" + #include "GeomAlgoAPI_MakeShapeCustom.h" #include "GeomAlgoAPI_MakeShapeList.h" #include "GeomAlgoAPI_Movement.h" #include "GeomAlgoAPI_Placement.h" @@ -50,6 +51,7 @@ %include "GeomAlgoAPI_Extrusion.h" %include "GeomAlgoAPI_FaceBuilder.h" %include "GeomAlgoAPI_MakeShape.h" +%include "GeomAlgoAPI_MakeShapeCustom.h" %include "GeomAlgoAPI_MakeShapeList.h" %include "GeomAlgoAPI_Movement.h" %include "GeomAlgoAPI_Placement.h" diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h index 594283819..a4c19e8c2 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h @@ -36,7 +36,7 @@ public: const std::shared_ptr theBaseShape); /// Returns a shape built by the shape construction algorithm - GEOMALGOAPI_EXPORT const std::shared_ptr shape() const; + GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; /// Returns the list of shapes generated from the shape \a theShape GEOMALGOAPI_EXPORT virtual void generated( @@ -46,7 +46,7 @@ public: GEOMALGOAPI_EXPORT virtual void modified( const std::shared_ptr theShape, ListOfShape& theHistory); - /// Returns whether the shape is an edge + /// Returns whether the shape is deleted GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); protected: diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp new file mode 100644 index 000000000..318f9b6e5 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp @@ -0,0 +1,68 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_MakeShapeCustom.cpp +// Created: 4 September 2015 +// Author: Dmitry Bobylev + +#include + +//================================================================================================= +GeomAlgoAPI_MakeShapeCustom::GeomAlgoAPI_MakeShapeCustom() +: GeomAlgoAPI_MakeShape() +{} + +//================================================================================================= +void GeomAlgoAPI_MakeShapeCustom::setResult(const std::shared_ptr theShape) +{ + myShape = theShape; +} + +//================================================================================================= +bool GeomAlgoAPI_MakeShapeCustom::addModified(const std::shared_ptr theBase, + const std::shared_ptr theResult) +{ + return myModified.add(theBase, theResult); +} + +//================================================================================================= +bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const std::shared_ptr theBase, + const std::shared_ptr theResult) +{ + return myGenerated.add(theBase, theResult); +} + +//================================================================================================= +bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const std::shared_ptr theShape) +{ + return myDeleted.bind(theShape, theShape); +} + +//================================================================================================= +const std::shared_ptr GeomAlgoAPI_MakeShapeCustom::shape() const +{ + return myShape; +} + +//================================================================================================= +void GeomAlgoAPI_MakeShapeCustom::generated(const std::shared_ptr theShape, + ListOfShape& theHistory) +{ + ListOfShape aGenerated; + myGenerated.find(theShape, aGenerated); + theHistory.insert(theHistory.end(), aGenerated.begin(), aGenerated.end()); +} + +//================================================================================================= +void GeomAlgoAPI_MakeShapeCustom::modified(const std::shared_ptr theShape, + ListOfShape& theHistory) +{ + ListOfShape aModified; + myModified.find(theShape, aModified); + theHistory.insert(theHistory.end(), aModified.begin(), aModified.end()); +} + +//================================================================================================= +bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const std::shared_ptr theShape) +{ + return myDeleted.isBound(theShape); +} \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h new file mode 100644 index 000000000..062e3aaaf --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h @@ -0,0 +1,60 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_MakeShapeCustom.h +// Created: 4 September 2015 +// Author: Dmitry Bobylev + +#ifndef GeomAlgoAPI_MakeShapeCustom_H_ +#define GeomAlgoAPI_MakeShapeCustom_H_ + +#include + +#include +#include + +/** \class GeomAlgoAPI_MakeShapeCustom + * \ingroup DataAlgo + * \brief Interface to the root class of all topological shapes constructions + */ +class GeomAlgoAPI_MakeShapeCustom : public GeomAlgoAPI_MakeShape +{ +public: + /// Default constructor + GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeCustom(); + + /// Sets result shape. + GEOMALGOAPI_EXPORT void setResult(const std::shared_ptr theShape); + + /// Adds modified shape. + GEOMALGOAPI_EXPORT bool addModified(const std::shared_ptr theBase, + const std::shared_ptr theResult); + + /// Adds generated shape. + GEOMALGOAPI_EXPORT bool addGenerated(const std::shared_ptr theBase, + const std::shared_ptr theResult); + + /// Adds deleted shape. + GEOMALGOAPI_EXPORT bool addDeleted(const std::shared_ptr theShape); + + /// \return a shape built by the shape construction algorithms + GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; + + /// \return the list of shapes generated from the shape theShape + GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr theShape, + ListOfShape& theHistory); + + /// \return the list of shapes modified from the shape theShape + GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, + ListOfShape& theHistory); + + /// \return whether the shape is deleted + GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); + +private: + std::shared_ptr myShape; + GeomAPI_DataMapOfShapeMapOfShapes myGenerated; + GeomAPI_DataMapOfShapeMapOfShapes myModified; + GeomAPI_DataMapOfShapeShape myDeleted; +}; + +#endif \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h index 92f1c04df..6b6682c1c 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h @@ -14,7 +14,7 @@ /** \class GeomAlgoAPI_MakeShapeList * \ingroup DataAlgo - * \brief Interface to the root class of all topological shapes constructions + * \brief List of topological shapes constructions */ class GeomAlgoAPI_MakeShapeList : public GeomAlgoAPI_MakeShape { @@ -48,7 +48,7 @@ public: GEOMALGOAPI_EXPORT void append(const GeomAlgoAPI_MakeShapeList& theMakeShapeList); /// \return a shape built by the shape construction algorithms - GEOMALGOAPI_EXPORT const std::shared_ptr shape() const; + GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; /// \return the list of shapes generated from the shape \a theShape GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr theShape, @@ -58,7 +58,7 @@ public: GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, ListOfShape& theHistory); - /// Returns whether the shape is deleted + /// \return whether the shape is deleted GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); private: