From: mzn Date: Fri, 17 Aug 2018 08:10:33 +0000 (+0300) Subject: Issue #2577: add constructor for the single shape. X-Git-Tag: SHAPER_V9_1_0RC1~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d7ab5e3177af721775f0ad52330244942d1e881c;p=modules%2Fshaper.git Issue #2577: add constructor for the single shape. --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp index a2a27ba5d..ee9c6feca 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.cpp @@ -33,6 +33,13 @@ GeomAlgoAPI_UnifySameDomain::GeomAlgoAPI_UnifySameDomain(const ListOfShape& theS build(theShapes); } +//================================================================================================== +GeomAlgoAPI_UnifySameDomain::GeomAlgoAPI_UnifySameDomain(const GeomShapePtr& theShape) +{ + build(theShape, false); +} + +//================================================================================================== void GeomAlgoAPI_UnifySameDomain::build(const ListOfShape& theShapes) { if(theShapes.empty()) { @@ -54,10 +61,20 @@ void GeomAlgoAPI_UnifySameDomain::build(const ListOfShape& theShapes) const TopoDS_Shape& aShell = aCombined.front()->impl(); + std::shared_ptr aShape(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aShell)); + build(aShape, true); +} + +//================================================================================================== +void GeomAlgoAPI_UnifySameDomain::build(const GeomShapePtr& theShape, + const bool theIsToSimplifyShell) +{ ShapeUpgrade_UnifySameDomain* aUnifyAlgo = new ShapeUpgrade_UnifySameDomain(); this->setImpl(aUnifyAlgo); - aUnifyAlgo->Initialize(aShell); + const TopoDS_Shape& aShape = theShape->impl(); + aUnifyAlgo->Initialize(aShape); aUnifyAlgo->Build(); TopoDS_Shape aResult = aUnifyAlgo->Shape(); @@ -65,7 +82,7 @@ void GeomAlgoAPI_UnifySameDomain::build(const ListOfShape& theShapes) return; } - if (aResult.ShapeType() == TopAbs_SHELL) { + if (theIsToSimplifyShell && aResult.ShapeType() == TopAbs_SHELL) { int aNb = 0; TopoDS_Iterator anIt(aResult); for (; anIt.More(); anIt.Next()) { @@ -78,9 +95,9 @@ void GeomAlgoAPI_UnifySameDomain::build(const ListOfShape& theShapes) } } - std::shared_ptr aShape(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aResult)); - this->setShape(aShape); + std::shared_ptr aResShape(new GeomAPI_Shape()); + aResShape->setImpl(new TopoDS_Shape(aResult)); + this->setShape(aResShape); this->setDone(true); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.h b/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.h index a18366672..1b70f43a2 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_UnifySameDomain.h @@ -35,6 +35,9 @@ public: /// Constructor. GEOMALGOAPI_EXPORT GeomAlgoAPI_UnifySameDomain(const ListOfShape& theShapes); + /// Constructor. + GEOMALGOAPI_EXPORT GeomAlgoAPI_UnifySameDomain(const GeomShapePtr& theShape); + /// \return the list of shapes modified from the shape \a theShape. /// \param[in] theShape base shape. /// \param[out] theHistory modified shapes. @@ -42,8 +45,11 @@ public: ListOfShape& theHistory); private: - /// Builds resulting shape. + /// Builds resulting shape from list of shapes. void build(const ListOfShape& theShapes); + + /// Builds resulting shape from the shape. + void build(const GeomShapePtr& theShape, const bool theIsToSimplifyShell); }; #endif