From bca0d6dc03d998fb8fe24a0003f7b392b403ea11 Mon Sep 17 00:00:00 2001 From: szy Date: Wed, 29 Oct 2014 15:41:54 +0300 Subject: [PATCH] 29.10.2014.Extrusion feature update. --- src/ExchangePlugin/CMakeLists.txt | 1 + .../FeaturesPlugin_Extrusion.cpp | 55 +++-------- src/FeaturesPlugin/FeaturesPlugin_Extrusion.h | 1 + src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp | 21 ++-- src/GeomAPI/GeomAPI_DataMapOfShapeShape.h | 11 ++- src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp | 76 --------------- src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h | 23 ----- src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp | 96 ++++++------------- src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h | 18 +++- src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp | 17 +++- src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h | 9 +- src/Model/Model_ResultBody.cpp | 91 +++++++++++++++++- src/Model/Model_ResultBody.h | 22 +++++ src/ModelAPI/CMakeLists.txt | 1 + src/ModelAPI/ModelAPI_ResultBody.h | 25 ++++- src/XGUI/CMakeLists.txt | 1 + 16 files changed, 237 insertions(+), 231 deletions(-) diff --git a/src/ExchangePlugin/CMakeLists.txt b/src/ExchangePlugin/CMakeLists.txt index ad3f24fdf..8200a6d93 100644 --- a/src/ExchangePlugin/CMakeLists.txt +++ b/src/ExchangePlugin/CMakeLists.txt @@ -4,6 +4,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/Config ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/GeomAPI + ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI ${CAS_INCLUDE_DIRS} ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index b32f2e97a..eeafb1db6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -18,6 +18,7 @@ using namespace std; #define _LATERAL_TAG 1 #define _FIRST_TAG 2 #define _LAST_TAG 3 +#define EDGE 6 #ifdef _DEBUG #include #include @@ -65,7 +66,6 @@ void FeaturesPlugin_Extrusion::execute() aSize = -aSize; boost::shared_ptr aResultBody = document()->createBody(data()); - //TCollection_AsciiString anError; GeomAlgoAPI_Extrusion aFeature(aFace, aSize); if(!aFeature.isDone()) { std::string aFeatureError = "Extrusion algorithm failed"; @@ -105,44 +105,19 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature, if(theBasis->isEqual(theContext)) theResultBody->store(theFeature.shape()); else - theResultBody->storeGenerated(theContext, theFeature.shape()); - /* - TopTools_DataMapOfShapeShape aSubShapes; - for (TopExp_Explorer Exp(theFeature.shape()->impl(),TopAbs_FACE); Exp.More(); Exp.Next()) { - aSubShapes.Bind(Exp.Current(),Exp.Current()); - } + theResultBody->storeGenerated(theContext, theFeature.shape()); + + GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape(); + theFeature.mapOfShapes(*aSubShapes); + + //Insert lateral face : Face from Edge + theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape(), theFeature.shape(), EDGE,_LATERAL_TAG, *aSubShapes); - //Insert lateral face : Face from Edge - //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes); - - - TopTools_MapOfShape aView; - TopExp_Explorer aShapeExplorer (theFeature.shape()->impl(), TopAbs_EDGE); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - boost::shared_ptr aRootG(new GeomAPI_Shape()); - aRootG->setImpl((void *)&aRoot); - const ListOfShape& aShapes = theFeature.generated(aRootG); - std::list >::const_iterator anIt = aShapes.begin(), aLast = aShapes.end(); - for (; anIt != aLast; anIt++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); - if (aSubShapes.IsBound(aNewShape)) { - aNewShape.Orientation((aSubShapes(aNewShape)).Orientation()); - } - - if (!aRoot.IsSame (aNewShape)) { - boost::shared_ptr aNew(new GeomAPI_Shape()); - aNew->setImpl((void *)&aNewShape); - theResultBody->generated(aRootG, aNew,_LATERAL_TAG); - } - } - } //Insert bottom face - const boost::shared_ptr& aBottomFace = theFeature.firstShape(); + boost::shared_ptr aBottomFace = theFeature.firstShape(); if (!aBottomFace->isNull()) { - if (aSubShapes.IsBound(aBottomFace->impl())) { - aBottomFace->setImpl((void *)&aSubShapes(aBottomFace->impl())); + if (aSubShapes->isBound(aBottomFace)) { + aBottomFace = aSubShapes->find(aBottomFace); } theResultBody->generated(aBottomFace, _FIRST_TAG); } @@ -152,11 +127,11 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature, //Insert top face boost::shared_ptr aTopFace = theFeature.lastShape(); if (!aTopFace->isNull()) { - if (aSubShapes.IsBound(aTopFace->impl())) { - aTopFace->setImpl((void *)&aSubShapes(aTopFace->impl())); + if (aSubShapes->isBound(aTopFace)) { + aTopFace = aSubShapes->find(aTopFace); } - theResultBody->generated(aTopFace, _FIRST_TAG); + theResultBody->generated(aTopFace, _LAST_TAG); } - */ + } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h index d136c8491..c6c500fe2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@ -9,6 +9,7 @@ #include #include #include +#include class FeaturesPlugin_Extrusion : public ModelAPI_Feature { public: diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp index b573c5a0a..56002d3a5 100644 --- a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp @@ -5,6 +5,7 @@ #include #include #include +#include using namespace std; @@ -18,7 +19,7 @@ void GeomAPI_DataMapOfShapeShape::clear() } /// Adds the Key to the Map with the Item. Returns True if the Key was not already in the map -bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr& theKey, const boost::shared_ptr& theItem) +bool GeomAPI_DataMapOfShapeShape::bind (boost::shared_ptr theKey, boost::shared_ptr theItem) { bool flag(false); if(implPtr()->Bind(theKey->impl(), theItem->impl())) @@ -27,7 +28,7 @@ bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr& } /// Returns true if theKey is stored in the map. -bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr& theKey) +bool GeomAPI_DataMapOfShapeShape::isBound (boost::shared_ptr theKey) { bool flag(false); if(impl().IsBound(theKey->impl())) @@ -36,18 +37,26 @@ bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr GeomAPI_DataMapOfShapeShape::find(const boost::shared_ptr& theKey) +const boost::shared_ptr GeomAPI_DataMapOfShapeShape::find(boost::shared_ptr theKey) { boost::shared_ptr aShape(new GeomAPI_Shape()); - aShape->setImpl((void *)&(impl().Find(theKey->impl()))); + aShape->setImpl(new TopoDS_Shape(impl().Find(theKey->impl()))); return aShape; } /// Removes the Key from the map. Returns true if the Key was in the Map -bool GeomAPI_DataMapOfShapeShape::unBind(const boost::shared_ptr& theKey) +bool GeomAPI_DataMapOfShapeShape::unBind(boost::shared_ptr theKey) { bool flag(false); if(implPtr()->UnBind(theKey->impl())) flag = true; return flag; -} \ No newline at end of file +} + + GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape() + { + if (myImpl) { + implPtr()->Clear(); + //delete myImpl; + } + } \ No newline at end of file diff --git a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h index 119cfda0e..20b63903a 100644 --- a/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h +++ b/src/GeomAPI/GeomAPI_DataMapOfShapeShape.h @@ -26,16 +26,19 @@ class GEOMAPI_EXPORT GeomAPI_DataMapOfShapeShape : public GeomAPI_Interface void clear(); /// Adds the Key to the Map with the Item. Returns True if the Key was not already in the map - bool bind (const boost::shared_ptr& theKey, const boost::shared_ptr& theItem); + bool bind (boost::shared_ptr theKey, boost::shared_ptr theItem); /// Returns true if theKey is stored in the map. - bool isBound (const boost::shared_ptr& theKey); + bool isBound (boost::shared_ptr theKey); /// Returns the Item stored with the Key in the Map. - const boost::shared_ptr find(const boost::shared_ptr& theKey); + const boost::shared_ptr find(boost::shared_ptr theKey); /// Removes the Key from the map. Returns true if the Key was in the Map - bool unBind(const boost::shared_ptr& theKey); + bool unBind(boost::shared_ptr theKey); + + /// Destructor + ~GeomAPI_DataMapOfShapeShape(); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp index d309de4a2..89fb0237b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp @@ -25,79 +25,3 @@ const TopoDS_Shape GeomAlgoAPI_DFLoader::refineResult(const TopoDS_Shape& theRe } return aResult; } -/* -//======================================================================= -//function : loadDeletedShapes -//purpose : load deleted shapes in DF -//======================================================================= -void GeomAlgoAPI_DFLoader::loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS, - const TopoDS_Shape& theShapeIn, - const TopAbs_ShapeEnum theKindOfShape, - TNaming_Builder& theBuilder) -{ - TopTools_MapOfShape aView; - TopExp_Explorer ShapeExplorer (theShapeIn, theKindOfShape); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = ShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - if (theMS.IsDeleted (aRoot)) { - theBuilder.Delete (aRoot); - } - } -} - -//======================================================================= -//function : loadAndOrientModifiedShapes -//purpose : load modified shapes in DF with preliminary orientation adjustment -//======================================================================= -void GeomAlgoAPI_DFLoader::loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape& theMS, - const TopoDS_Shape& theShapeIn, - const TopAbs_ShapeEnum theKindOfShape, - TNaming_Builder& theBuilder, - const TopTools_DataMapOfShapeShape& theSubShapes) -{ - TopTools_MapOfShape aView; - TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - const TopTools_ListOfShape& aShapes = theMS.Modified (aRoot); - TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes); - for (;aShapesIterator.More (); aShapesIterator.Next ()) { - TopoDS_Shape aNewShape = aShapesIterator.Value (); - if (theSubShapes.IsBound(aNewShape)) { - aNewShape.Orientation((theSubShapes(aNewShape)).Orientation()); - } - if (!aRoot.IsSame (aNewShape)) theBuilder.Modify (aRoot, aNewShape ); - } - } -} - -//======================================================================= -//function : loadAndOrientGeneratedShapes -//purpose : load generated shapes in DF with preliminary orientation adjustment -//======================================================================= - -void GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape& theMS, - const TopoDS_Shape& theShapeIn, - const TopAbs_ShapeEnum theKindOfShape, - TNaming_Builder& theBuilder, - const TopTools_DataMapOfShapeShape& theSubShapes) -{ - TopTools_MapOfShape aView; - TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - const TopTools_ListOfShape& aShapes = theMS.Generated (aRoot); - TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes); - for (;aShapesIterator.More (); aShapesIterator.Next ()) { - TopoDS_Shape aNewShape = aShapesIterator.Value (); - if (theSubShapes.IsBound(aNewShape)) { - aNewShape.Orientation((theSubShapes(aNewShape)).Orientation()); - } - if (!aRoot.IsSame (aNewShape)) theBuilder.Generated (aRoot,aNewShape ); - } - } -} -*/ \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h b/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h index 815b8cbee..766e0c734 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h @@ -5,12 +5,7 @@ #ifndef GeomAlgoAPI_DFLoader_H_ #define GeomAlgoAPI_DFLoader_H_ #include -//#include -#include #include -#include -#include -#include /**\class GeomAlgoAPI_DFLoader * \ingroup DataAlgo @@ -19,24 +14,6 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_DFLoader { public: - /* - /// Loads to DF deleted shapes - static void loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS, const TopoDS_Shape& theShapeIn, - const TopAbs_ShapeEnum KindOfShape, TNaming_Builder& theBuilder); - - /// Loads to DF generated shapes - static void loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape& theMS, - const TopoDS_Shape& theShapeIn, - const TopAbs_ShapeEnum theKindOfShape, - TNaming_Builder& theBuilder, - const TopTools_DataMapOfShapeShape& theSubShapes); - /// Loads to DF modified shapes - static void loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape& theMS, - const TopoDS_Shape& theShapeIn, - const TopAbs_ShapeEnum theKindOfShape, - TNaming_Builder& theBuilder, - const TopTools_DataMapOfShapeShape& theSubShapes); - */ /// Refine result static const TopoDS_Shape refineResult(const TopoDS_Shape& theShape); }; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp index b81b0f5fe..6955ee89a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,8 +27,8 @@ const double tolerance = Precision::Angular(); // Constructor GeomAlgoAPI_Extrusion::GeomAlgoAPI_Extrusion( boost::shared_ptr theBasis, double theSize) -: mySize(theSize), myDone(false), - myShape(new GeomAPI_Shape()), myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape()) +: mySize(theSize), myDone(false), myShape(new GeomAPI_Shape()), + myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape()) { build(theBasis); } @@ -39,7 +39,6 @@ void GeomAlgoAPI_Extrusion::build(const boost::shared_ptr& theBas bool isFirstNorm = true; gp_Dir aShapeNormal; - //const TopoDS_Shape& aShape = theShape->impl(); TopoDS_Face aBasis = TopoDS::Face(theBasis->impl()); Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface(aBasis)); @@ -64,9 +63,17 @@ void GeomAlgoAPI_Extrusion::build(const boost::shared_ptr& theBas aResult = GeomAlgoAPI_DFLoader::refineResult(aBuilder->Shape()); else aResult = aBuilder->Shape(); + + for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) { + boost::shared_ptr aCurrentShape(new GeomAPI_Shape()); + aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current())); + myMap.bind(aCurrentShape, aCurrentShape); + } + myShape->setImpl(new TopoDS_Shape(aResult)); myFirst->setImpl(new TopoDS_Shape(aBuilder->FirstShape())); myLast->setImpl(new TopoDS_Shape(aBuilder-> LastShape())); + myMkShape = new GeomAlgoAPI_MakeShape (aBuilder); } } } @@ -100,7 +107,7 @@ const boost::shared_ptr& GeomAlgoAPI_Extrusion::shape () const {return myShape;} //============================================================================ -void GeomAlgoAPI_Extrusion::generated( +/*void GeomAlgoAPI_Extrusion::generated( const boost::shared_ptr theShape, ListOfShape& theHistory) { theHistory.clear(); @@ -115,7 +122,7 @@ void GeomAlgoAPI_Extrusion::generated( } } } - +*/ //============================================================================ const boost::shared_ptr& GeomAlgoAPI_Extrusion::firstShape() { @@ -129,71 +136,22 @@ const boost::shared_ptr& GeomAlgoAPI_Extrusion::lastShape() } //============================================================================ -/* -void GeomAlgoAPI_Extrusion::LoadNamingDS(boost::shared_ptr theResultBody, -boost::shared_ptr theContext) +void GeomAlgoAPI_Extrusion::mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const { -if(isValid()) { -const TopoDS_Shape& aShape = myBuilder->Shape(); -TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aShape); -boost::shared_ptr aData = boost::dynamic_pointer_cast(theResultBody->data()); -if (aData) { -const TDF_Label& aShapeLab = aData->shapeLab(); -const Handle(TDF_TagSource)& Tagger = TDF_TagSource::Set(aShapeLab); -if (Tagger.IsNull()) return; -Tagger->Set(0); - -TNaming_Builder aBuilder (aShapeLab); -if(myBasis.IsEqual(theContext->impl())) -aBuilder.Generated(aResult); -else -aBuilder.Generated(theContext->impl(), aResult); - -TopTools_DataMapOfShapeShape aSubShapes; -for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) { -aSubShapes.Bind(Exp.Current(),Exp.Current()); -} - -//Insert lateral face : Face from Edge -TNaming_Builder aLateralFaceBuilder(aShapeLab.NewChild()); -GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes); - -//Insert bottom face -TopoDS_Shape aBottomFace = myBuilder->FirstShape(); -if (!aBottomFace.IsNull()) { -if (aBottomFace.ShapeType() != TopAbs_COMPOUND) { -TNaming_Builder aBottomBuilder(aShapeLab.NewChild()); //2 -if (aSubShapes.IsBound(aBottomFace)) { -aBottomFace = aSubShapes(aBottomFace); -} -aBottomBuilder.Generated(aBottomFace); -} else { -TopoDS_Iterator itr(aBottomFace); -for (; itr.More(); itr.Next()) { -TNaming_Builder aBottomBuilder(aShapeLab.NewChild()); -aBottomBuilder.Generated(itr.Value()); -} + theMap = myMap; } +//============================================================================ +GeomAlgoAPI_MakeShape * GeomAlgoAPI_Extrusion::makeShape() const +{ + return myMkShape; } -//Insert top face -TopoDS_Shape aTopFace = myBuilder->LastShape(); -if (!aTopFace.IsNull()) { -if (aTopFace.ShapeType() != TopAbs_COMPOUND) { -TNaming_Builder aTopBuilder(aShapeLab.NewChild()); //3 -if (aSubShapes.IsBound(aTopFace)) { -aTopFace = aSubShapes(aTopFace); -} -aTopBuilder.Generated(aTopFace); -} else { -TopoDS_Iterator itr(aTopFace); -for (; itr.More(); itr.Next()) { -TNaming_Builder aTopBuilder(aShapeLab.NewChild()); -aTopBuilder.Generated(itr.Value()); -} -} -} -} -} -*/ \ No newline at end of file +//============================================================================ +GeomAlgoAPI_Extrusion::~GeomAlgoAPI_Extrusion() +{ + if (myImpl) { + myMap.clear(); + //delete myImpl; + } +} \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h index bebeb35f5..7a033a6ae 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h @@ -9,13 +9,15 @@ #include #include #include +#include +#include #include /**\class GeomAlgoAPI_Extrusion * \ingroup DataAlgo * \brief Allows to create the prism based on a given face and a direction */ -class GeomAlgoAPI_Extrusion : public GeomAPI_Interface +class GeomAlgoAPI_Extrusion : public GeomAPI_Interface//GeomAlgoAPI_MakeShape { public: @@ -44,15 +46,21 @@ class GeomAlgoAPI_Extrusion : public GeomAPI_Interface GEOMALGOAPI_EXPORT const boost::shared_ptr& shape () const; /// Returns list of shapes generated from theShape - GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr theShape, - ListOfShape& theHistory); + // GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr theShape, + // ListOfShape& theHistory); /// Returns the first shape GEOMALGOAPI_EXPORT const boost::shared_ptr& firstShape(); /// returns last shape - GEOMALGOAPI_EXPORT const boost::shared_ptr& lastShape(); + GEOMALGOAPI_EXPORT const boost::shared_ptr& lastShape(); + + /// Returns map of sub-shapes of the result + GEOMALGOAPI_EXPORT void mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const; + GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape () const; + + GEOMALGOAPI_EXPORT ~GeomAlgoAPI_Extrusion(); private: /// builds resulting shape void build(const boost::shared_ptr& theBasis); @@ -62,6 +70,8 @@ private: boost::shared_ptr myShape; boost::shared_ptr myFirst; boost::shared_ptr myLast; + GeomAPI_DataMapOfShapeShape myMap; + GeomAlgoAPI_MakeShape * myMkShape; }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp index 679526bef..70cfad9f8 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp @@ -3,11 +3,22 @@ // Author: Sergey ZARITCHNY #include +#include #include #include GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape) - : GeomAPI_Interface(theMkShape) + : GeomAPI_Interface(theMkShape),myShape(new GeomAPI_Shape()) +{ + myShape->setImpl((void *)&implPtr()->Shape()); +} + +GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape() + : GeomAPI_Interface(),myShape(new GeomAPI_Shape()) {} +void GeomAlgoAPI_MakeShape::init(void* theMkShape) +{ + setImpl((void *)implPtr()); +} const boost::shared_ptr GeomAlgoAPI_MakeShape::shape() const { @@ -24,7 +35,7 @@ void GeomAlgoAPI_MakeShape::generated( TopTools_ListIteratorOfListOfShape it(aList); for(;it.More();it.Next()) { boost::shared_ptr aShape(new GeomAPI_Shape()); - aShape->setImpl(&(it.Value())); + aShape->setImpl(new TopoDS_Shape(it.Value())); theHistory.push_back(aShape); } } @@ -40,7 +51,7 @@ void GeomAlgoAPI_MakeShape::modified( TopTools_ListIteratorOfListOfShape it(aList); for(;it.More();it.Next()) { boost::shared_ptr aShape(new GeomAPI_Shape()); - aShape->setImpl(&(it.Value())); + aShape->setImpl(new TopoDS_Shape(it.Value())); theHistory.push_back(aShape); } } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h index 89dae08a5..4fa0ef0a1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h @@ -7,16 +7,19 @@ #include #include #include -#include +//#include /**\class GeomAlgoAPI_MakeShape * \ingroup DataModel * \Interface to the root class of all topological shapes constructions */ -class GeomAlgoAPI_MakeShape : GeomAPI_Interface +class GeomAlgoAPI_MakeShape : public GeomAPI_Interface { public: /// Constructor + GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(); + GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder); + /// Returns a shape built by the shape construction algorithm GEOMALGOAPI_EXPORT const boost::shared_ptr shape() const; @@ -31,6 +34,8 @@ class GeomAlgoAPI_MakeShape : GeomAPI_Interface /// Returns whether the shape is an edge GEOMALGOAPI_EXPORT virtual bool isDeleted(const boost::shared_ptr theShape); + GEOMALGOAPI_EXPORT void init(void* theMkShape); + protected: boost::shared_ptr myShape; }; diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 9b18bc046..ce342c2e9 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -8,8 +8,13 @@ #include #include #include +#include +#include #include - +#include +// DEB +//#include +//#include Model_ResultBody::Model_ResultBody() { setIsConcealed(false); @@ -115,12 +120,15 @@ Model_ResultBody::~Model_ResultBody() TNaming_Builder* Model_ResultBody::builder(const int theTag) { - if (myBuilders.size() < (unsigned int)theTag) { + if (myBuilders.size() <= (unsigned int)theTag) { myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL); } if (!myBuilders[theTag]) { boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag)); + //TCollection_AsciiString entry;// + //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry); + //cout << "Label = " <& theOldSha TopoDS_Shape aShape = theOldShape->impl(); builder(theTag)->Delete(aShape); } + +void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag) +{ + TopoDS_Shape aShapeIn = theShapeIn->impl(); + TopTools_MapOfShape aView; + TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); + for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { + const TopoDS_Shape& aRoot = ShapeExplorer.Current (); + if (!aView.Add(aRoot)) continue; + boost::shared_ptr aRShape(new GeomAPI_Shape()); + aRShape->setImpl((new TopoDS_Shape(aRoot))); + if (theMS->isDeleted (aRShape)) { + builder(theTag)->Delete(aRoot); + } + } +} + +void Model_ResultBody::loadAndOrientModifiedShapes ( + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes) +{ + TopoDS_Shape aShapeIn = theShapeIn->impl(); + TopTools_MapOfShape aView; + TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); + for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { + const TopoDS_Shape& aRoot = aShapeExplorer.Current (); + if (!aView.Add(aRoot)) continue; + ListOfShape aList; + boost::shared_ptr aRShape(new GeomAPI_Shape()); + aRShape->setImpl((new TopoDS_Shape(aRoot))); + theMS->generated(aRShape, aList); + std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); + for (; anIt != aLast; anIt++) { + TopoDS_Shape aNewShape = (*anIt)->impl(); + if (theSubShapes.isBound(*anIt)) { + boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); + aNewShape.Orientation(aMapShape->impl().Orientation()); + } + if (!aRoot.IsSame (aNewShape)) + builder(theTag)->Modify(aRoot,aNewShape); + } + } +} + +void Model_ResultBody::loadAndOrientGeneratedShapes ( + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes) +{ + TopoDS_Shape aShapeIn = theShapeIn->impl(); + TopTools_MapOfShape aView; + TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); + for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { + const TopoDS_Shape& aRoot = aShapeExplorer.Current (); + if (!aView.Add(aRoot)) continue; + ListOfShape aList; + boost::shared_ptr aRShape(new GeomAPI_Shape()); + aRShape->setImpl((new TopoDS_Shape(aRoot))); + theMS->generated(aRShape, aList); + std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); + for (; anIt != aLast; anIt++) { + TopoDS_Shape aNewShape = (*anIt)->impl(); + if (theSubShapes.isBound(*anIt)) { + boost::shared_ptr aMapShape(theSubShapes.find(*anIt)); + aNewShape.Orientation(aMapShape->impl().Orientation()); + } + if (!aRoot.IsSame (aNewShape)) + builder(theTag)->Generated(aRoot,aNewShape); + } + } +} \ No newline at end of file diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index f6174cdee..340b35bb5 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -7,6 +7,8 @@ #include "Model.h" #include +#include +#include #include class TNaming_Builder; @@ -64,6 +66,26 @@ public: MODEL_EXPORT virtual void deleted(const boost::shared_ptr& theOldShape, const int theTag = 1); + /// load deleted shapes + MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag); + /// load and orient modified shapes + MODEL_EXPORT virtual void loadAndOrientModifiedShapes ( + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes); + /// load and orient generated shapes + MODEL_EXPORT virtual void loadAndOrientGeneratedShapes ( + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes); + /// Removes the stored builders MODEL_EXPORT virtual ~Model_ResultBody(); diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 9bebf30fb..0bfa08a58 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -56,6 +56,7 @@ INCLUDE_DIRECTORIES( ../Config ../Events ../GeomAPI + ../GeomAlgoAPI ) SET(CMAKE_SWIG_FLAGS "") diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 8942a62f2..4991cf279 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -7,7 +7,9 @@ #include "ModelAPI_Result.h" #include - +#include +#include +#include #include /**\class ModelAPI_ResultBody @@ -68,7 +70,26 @@ public: /// As an example, consider the case of a face removed by a Boolean operation. virtual void deleted( const boost::shared_ptr& theOldShape, const int theTag = 1) = 0; - + + /// load deleted shapes + virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag) = 0; + /// load and orient modified shapes + virtual void loadAndOrientModifiedShapes ( + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes) = 0; + /// load and orient generated shapes + virtual void loadAndOrientGeneratedShapes ( + GeomAlgoAPI_MakeShape* theMS, + boost::shared_ptr theShapeIn, + const int theKindOfShape, + const int theTag, + GeomAPI_DataMapOfShapeShape& theSubShapes) = 0; protected: }; diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 0a07539a4..5ceda7960 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -124,6 +124,7 @@ INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/ModuleBase ${PROJECT_SOURCE_DIR}/src/PartSetPlugin + ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI ${CAS_INCLUDE_DIRS} ${SUIT_INCLUDE}) -- 2.39.2