#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_BodyBuilder.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Session.h>
}
GeomAlgoAPI_MakeShapeList aMakeShapeList;
- aMakeShapeList.append(aBoolAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aBoolAlgo.makeShape());
GeomAPI_DataMapOfShapeShape aMapOfShapes;
aMapOfShapes.merge(aBoolAlgo.mapOfShapes());
return;
}
- aMakeShapeList.append(aFillerAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo.shape()) > 1.e-7) {
if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo.shape()) > 1.e-7) {
aSolidsToFuse.push_back(aCutAlgo.shape());
- aMakeShapeList.append(aCutAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aCutAlgo.makeShape());
aMapOfShapes.merge(aCutAlgo.mapOfShapes());
}
}
}
std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo.shape();
- aMakeShapeList.append(aFuseAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aFuseAlgo.makeShape());
aMapOfShapes.merge(aFuseAlgo.mapOfShapes());
// Add result to not used solids from compsolid (if we have any).
}
aShape = aFillerAlgo.shape();
- aMakeShapeList.append(aFillerAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
}
// Created: 11 June 2015
// Author: Dmitry Bobylev
-#include <FeaturesPlugin_CompositeBoolean.h>
+#include "FeaturesPlugin_CompositeBoolean.h"
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeReference.h>
-#include <ModelAPI_BodyBuilder.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
}
GeomAlgoAPI_MakeShapeList aMakeShapeList;
- aMakeShapeList.append(aBoolAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aBoolAlgo.makeShape());
GeomAPI_DataMapOfShapeShape aMapOfShapes;
aMapOfShapes.merge(aBoolAlgo.mapOfShapes());
return;
}
- aMakeShapeList.append(aFillerAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo.shape()) > 1.e-7) {
if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo.shape()) > 1.e-7) {
aSolidsToFuse.push_back(aCutAlgo.shape());
- aMakeShapeList.append(aCutAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aCutAlgo.makeShape());
aMapOfShapes.merge(aCutAlgo.mapOfShapes());
}
}
}
std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo.shape();
- aMakeShapeList.append(aFuseAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aFuseAlgo.makeShape());
aMapOfShapes.merge(aFuseAlgo.mapOfShapes());
// Add result to not used solids from compsolid (if we have any).
}
aShape = aFillerAlgo.shape();
- aMakeShapeList.append(aFillerAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aFillerAlgo.makeShape());
aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
}
//Insert lateral face : Face from Edge
if(std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter)) {
std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_Prism>(*aSolidsAlgosIter);
- aSubShapes = aPrismAlgo->mapOfShapes();
- theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo->makeShape().get(), *aShellsIter, GeomAPI_Shape::EDGE, aGenTag,
+ aSubShapes = aPrismAlgo->mapOfSubShapes();
+ theResultBody->loadAndOrientGeneratedShapes(aPrismAlgo.get(), *aShellsIter, GeomAPI_Shape::EDGE, aGenTag,
aLatName, *aSubShapes.get());
aFromFaces = aPrismAlgo->fromFaces();
// Created: 30 May 2014
// Author: Vitaly SMETANNIKOV
-#include <FeaturesPlugin_Extrusion.h>
+#include "FeaturesPlugin_Extrusion.h"
-#include <ModelAPI_BodyBuilder.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Data.h>
#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeString.h>
-#include <ModelAPI_AttributeReference.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_Prism.h>
//load result
theResultBody->storeGenerated(theBasis, thePrismAlgo.shape());
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = thePrismAlgo.mapOfShapes();
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = thePrismAlgo.mapOfSubShapes();
//Insert lateral face : Face from Edge
const std::string aLatName = "LateralFace";
const int aLatTag = 1;
- theResultBody->loadAndOrientGeneratedShapes(thePrismAlgo.makeShape().get(), theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
+ theResultBody->loadAndOrientGeneratedShapes(&thePrismAlgo, theBasis, GeomAPI_Shape::EDGE, aLatTag, aLatName, *aSubShapes);
//Insert to faces
const std::string aToName = "ToFace";
}
// Extrude face
- GeomAlgoAPI_Prism aPrismAlgo(theFace, aToShape, aToSize, aFromShape, aFromSize);
+ std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo(new GeomAlgoAPI_Prism(theFace, aToShape, aToSize, aFromShape, aFromSize));
// Checking that the algorithm worked properly.
- if(!aPrismAlgo.isDone() || !aPrismAlgo.shape().get() || aPrismAlgo.shape()->isNull() ||
- !aPrismAlgo.isValid()) {
+ if(!aPrismAlgo->isDone() || !aPrismAlgo->shape().get() || aPrismAlgo->shape()->isNull() ||
+ !aPrismAlgo->isValid()) {
return;
}
- theResult = aPrismAlgo.shape();
- theFromFaces = aPrismAlgo.fromFaces();
- theToFaces = aPrismAlgo.toFaces();
- theMakeShape = aPrismAlgo.makeShape();
- theDataMap = aPrismAlgo.mapOfShapes();
+ theResult = aPrismAlgo->shape();
+ theFromFaces = aPrismAlgo->fromFaces();
+ theToFaces = aPrismAlgo->toFaces();
+ theMakeShape = aPrismAlgo;
+ theDataMap = aPrismAlgo->mapOfSubShapes();
}
aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aContext->shape(), aBoundingPoints);
std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(new GeomAlgoAPI_MakeShapeCustom);
aMkShCustom->addModified(aContext->shape(), aTool);
- aMakeShapeList.append(aMkShCustom);
+ aMakeShapeList.appendAlgo(aMkShCustom);
aTools.push_back(aTool);
aToolsForNaming.push_back(aContext->shape());
}
if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- aMakeShapeList.append(aPartitionAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aPartitionAlgo.makeShape());
GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get();
loadNamingDS(aResultBody, anObjects.front(), aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes);
setResult(aResultBody, aResultIndex);
if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- aMakeShapeList.append(aPartitionAlgo.makeShape());
+ aMakeShapeList.appendAlgo(aPartitionAlgo.makeShape());
GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get();
loadNamingDS(aResultBody, anObject, aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes);
setResult(aResultBody, aResultIndex);
// Created: 20 Oct 2014
// Author: Sergey ZARITCHNY
-#include <GeomAlgoAPI_MakeShape.h>
+#include "GeomAlgoAPI_MakeShape.h"
#include <BOPAlgo_Builder.hxx>
#include <BRepBuilderAPI_MakeShape.hxx>
-#include <BRepOffsetAPI_MakePipe.hxx>
+#include <BRepCheck_Analyzer.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
//=================================================================================================
GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
-: myBuilderType(OCCT_BRepBuilderAPI_MakeShape),
+: myBuilderType(UNKNOWN),
myDone(false)
{
}
return myShape;
}
+//=================================================================================================
+bool GeomAlgoAPI_MakeShape::isValid() const
+{
+ BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
+ return (aChecker.IsValid() == Standard_True);
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_MakeShape::hasVolume() const
+{
+ bool hasVolume = false;
+ if(isValid()) {
+ const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
+ GProp_GProps aGProp;
+ BRepGProp::VolumeProperties(aRShape, aGProp);
+ if(aGProp.Mass() > Precision::Confusion())
+ hasVolume = true;
+ }
+ return hasVolume;
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_MakeShape::mapOfSubShapes() const
+{
+ return myMap;
+}
+
//=================================================================================================
void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
ListOfShape& theHistory)
//=================================================================================================
void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theShape)
{
+ if(myShape.get() && myShape->isEqual(theShape)) {
+ return;
+ }
+
myShape = theShape;
+
+ // Filling data map to keep correct orientation of sub-shapes.
+ if(myShape.get()) {
+ if(myMap.get()) {
+ myMap->clear();
+ } else {
+ myMap.reset(new GeomAPI_DataMapOfShapeShape);
+ }
+
+ const TopoDS_Shape& aTopoDSSHape = myShape->impl<TopoDS_Shape>();
+ for(TopExp_Explorer anExp(aTopoDSSHape,TopAbs_FACE); anExp.More(); anExp.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ myMap->bind(aCurrentShape, aCurrentShape);
+ }
+ } else {
+ if(myMap.get()) {
+ myMap->clear();
+ }
+ }
}
//=================================================================================================
#include <list>
#include <memory>
-/** \class GeomAlgoAPI_MakeShape
- * \ingroup DataAlgo
- * \brief Interface to the root class of all topological shapes constructions
- */
+/// \class GeomAlgoAPI_MakeShape
+/// \ingroup DataAlgo
+/// \brief Interface to the root class of all topological shapes constructions
class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
{
public:
/// Builder type enum
enum BuilderType {
OCCT_BRepBuilderAPI_MakeShape,
- OCCT_BOPAlgo_Builder
+ OCCT_BOPAlgo_Builder,
+ UNKNOWN
};
public:
/// \brief Empty constructor.
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
- /** \brief Constructor by builder and builder type.
- * \param[in] theBuilder pointer to the builder.
- * \param[in] theBuilderType builder type.
- */
+ /// \brief Constructor by builder and builder type.
+ /// \param[in] theBuilder pointer to the builder.
+ /// \param[in] theBuilderType builder type.
template<class T> explicit GeomAlgoAPI_MakeShape(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
: GeomAPI_Interface(theBuilder),
myBuilderType(theBuilderType)
initialize();
}
- /** \brief Initializes internals.
- * \param[in] theBuilder pointer to the builder.
- * \param[in] theBuilderType builder type.
- */
+ /// \brief Initializes internals.
+ /// \param[in] theBuilder pointer to the builder.
+ /// \param[in] theBuilderType builder type.
template<class T> void initialize(T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
{
setImpl(theBuilder);
/// \return a shape built by the shape construction algorithm.
GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
- /** \return the list of shapes generated from the shape \a theShape.
- * \param[in] theShape base shape.
- * \param[out] theHistory generated shapes.
- */
+ /// \return true if resulting shape is valid.
+ GEOMALGOAPI_EXPORT bool isValid() const;
+
+ /// \return true if resulting shape has volume.
+ GEOMALGOAPI_EXPORT bool hasVolume() const;
+
+ /// \return map of sub-shapes of the result. To be used for History keeping.
+ GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfSubShapes() const;
+
+ /// \return the list of shapes generated from the shape \a theShape.
+ /// \param[in] theShape base shape.
+ /// \param[out] theHistory generated shapes.
GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
ListOfShape& theHistory);
- /** \return the list of shapes modified from the shape \a theShape.
- * \param[in] theShape base shape.
- * \param[out] theHistory modified shapes.
- */
+ /// \return the list of shapes modified from the shape \a theShape.
+ /// \param[in] theShape base shape.
+ /// \param[out] theHistory modified shapes.
GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
ListOfShape& theHistory);
- /** \return true if theShape was deleted.
- * \param[in] theShape base shape.
- */
+ /// \return true if theShape was deleted.
+ /// \param[in] theShape base shape.
GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
protected:
- /** \brief Sets builder type.
- * \param[in] theBuilderType new builder type.
- */
- GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType);
-
- /** \brief Sets status of builder.
- * \param[in] theFlag new status.
- */
- GEOMALGOAPI_EXPORT void setDone(const bool theFlag);
-
- /** \brief Sets result shape.
- * \param[in] theShape new shape.
- */
- GEOMALGOAPI_EXPORT void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
+ /// \brief Sets builder type.
+ /// \param[in] theBuilderType new builder type.
+ void setBuilderType(const BuilderType theBuilderType);
+
+ /// \brief Sets status of builder.
+ /// \param[in] theFlag new status.
+ void setDone(const bool theFlag);
+
+ /// \brief Sets result shape.
+ /// \param[in] theShape new shape.
+ void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
private:
/// \brief Initializes internals.
// Created: 27 May 2015
// Author: Dmitry Bobylev
-#include <GeomAlgoAPI_MakeShapeList.h>
+#include "GeomAlgoAPI_MakeShapeList.h"
-#include <BRepBuilderAPI_MakeShape.hxx>
#include <NCollection_Map.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Shape.hxx>
//=================================================================================================
GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList()
}
//=================================================================================================
-void GeomAlgoAPI_MakeShapeList::append(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+void GeomAlgoAPI_MakeShapeList::appendAlgo(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
{
myListOfMakeShape.push_back(theMakeShape);
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeList::append(const GeomAlgoAPI_MakeShapeList& theMakeShapeList)
-{
- for(ListOfMakeShape::const_iterator anIt = theMakeShapeList.myListOfMakeShape.cbegin();
- anIt != theMakeShapeList.myListOfMakeShape.cend(); anIt++) {
- myListOfMakeShape.push_back(*anIt);
- }
-}
-
//=================================================================================================
const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShapeList::shape() const
{
- if(myListOfMakeShape.empty()) {
- return std::shared_ptr<GeomAPI_Shape>();
- } else {
+ std::shared_ptr<GeomAPI_Shape> aShape = GeomAlgoAPI_MakeShape::shape();
+ if(aShape.get() && !aShape->impl<TopoDS_Shape>().IsNull()) {
+ return aShape;
+ } else if(!myListOfMakeShape.empty()) {
return myListOfMakeShape.back()->shape();
}
+ return std::shared_ptr<GeomAPI_Shape>();
}
//=================================================================================================
#include <memory>
-/** \class GeomAlgoAPI_MakeShapeList
- * \ingroup DataAlgo
- * \brief List of topological shapes constructions
- */
+/// \class GeomAlgoAPI_MakeShapeList
+/// \ingroup DataAlgo
+/// \brief List of topological shapes constructions
class GeomAlgoAPI_MakeShapeList : public GeomAlgoAPI_MakeShape
{
enum OperationType {
/// Default constructor
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeList();
- /** \brief Constructor
- * \param[in] theMakeShapeList list of algorithms.
- */
+ /// \brief Constructor
+ /// \param[in] theMakeShapeList list of algorithms.
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeList(const ListOfMakeShape& theMakeShapeList);
- /** \brief Initializes a class with new list of algorithms.
- * \param[in] theMakeShapeList list of algorithms.
- */
+ /// \brief Initializes a class with new list of algorithms.
+ /// \param[in] theMakeShapeList list of algorithms.
GEOMALGOAPI_EXPORT void init(const ListOfMakeShape& theMakeShapeList);
- /** \brief Adds algo to the end of list.
- * \param[in] theMakeShape algo to be added.
- */
- GEOMALGOAPI_EXPORT void append(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
-
- /** \brief Adds another one list of algos to the end of list.
- * \param[in] theMakeShapeList algo list to be added.
- */
- GEOMALGOAPI_EXPORT void append(const GeomAlgoAPI_MakeShapeList& theMakeShapeList);
+ /// \brief Adds algo to the end of list.
+ /// \param[in] theMakeShape algo to be added.
+ GEOMALGOAPI_EXPORT void appendAlgo(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
/// \return a shape built by the shape construction algorithms
GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
// Created: 23 November 2015
// Author: Dmitry Bobylev
-#include <GeomAlgoAPI_MakeSweep.h>
+#include "GeomAlgoAPI_MakeSweep.h"
//=================================================================================================
const ListOfShape& GeomAlgoAPI_MakeSweep::fromFaces() const
{
return myToFaces;
}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::addFromFace(const std::shared_ptr<GeomAPI_Shape> theFace)
+{
+ myFromFaces.push_back(theFace);
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::setFromFaces(const ListOfShape& theListOfFaces)
+{
+ myFromFaces = theListOfFaces;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::addToFace(const std::shared_ptr<GeomAPI_Shape> theFace)
+{
+ myToFaces.push_back(theFace);
+}
+
+//=================================================================================================
+void GeomAlgoAPI_MakeSweep::setToFaces(const ListOfShape& theListOfFaces)
+{
+ myToFaces = theListOfFaces;
+}
{
public:
/// \returns the list of from faces.
- GEOMALGOAPI_EXPORT const ListOfShape& fromFaces() const;
+ GEOMALGOAPI_EXPORT virtual const ListOfShape& fromFaces() const;
/// \return the list of to faces.
- GEOMALGOAPI_EXPORT const ListOfShape& toFaces() const;
+ GEOMALGOAPI_EXPORT virtual const ListOfShape& toFaces() const;
protected:
- GeomAlgoAPI_MakeSweep(){};
+ /// Empty constructor.
+ GeomAlgoAPI_MakeSweep() : GeomAlgoAPI_MakeShapeList() {};
+
+ /// \brief Adds a face to list of from faces.
+ /// \param[in] theFace a face to add.
+ void addFromFace(const std::shared_ptr<GeomAPI_Shape> theFace);
+
+ /// \brief Sets from faces
+ /// \param[in] theListOfFaces list of from faces.
+ void setFromFaces(const ListOfShape& theListOfFaces);
+
+ /// \brief Adds a face to list of to faces.
+ /// \param[in] theFace a face to add.
+ void addToFace(const std::shared_ptr<GeomAPI_Shape> theFace);
+
+ /// \brief Sets to faces
+ /// \param[in] theListOfFaces list of to faces.
+ void setToFaces(const ListOfShape& theListOfFaces);
private:
ListOfShape myFromFaces;
// Created: 5 May 2015
// Author: Dmitry Bobylev
-#include <GeomAlgoAPI_Prism.h>
+#include "GeomAlgoAPI_Prism.h"
#include <GeomAPI_Face.h>
#include <GeomAPI_Pln.h>
#include <GeomAPI_XYZ.h>
#include <GeomAlgoAPI_DFLoader.h>
#include <GeomAlgoAPI_FaceBuilder.h>
-#include <GeomAlgoAPI_MakeShapeList.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <Bnd_Box.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_Transform.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <BRepExtrema_ExtCF.hxx>
-#include <BRepGProp.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <gp_Pln.hxx>
-#include <GProp_GProps.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <IntAna_Quadric.hxx>
#include <TopExp_Explorer.hxx>
GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
double theToSize,
double theFromSize)
-: myDone(false)
{
build(theBaseShape, std::shared_ptr<GeomAPI_Shape>(), theToSize, std::shared_ptr<GeomAPI_Shape>(), theFromSize);
}
double theToSize,
std::shared_ptr<GeomAPI_Shape> theFromShape,
double theFromSize)
-: myDone(false)
{
build(theBaseShape, theToShape, theToSize, theFromShape, theFromSize);
}
const gp_Pnt& aBasePnt = aBaseLoc->impl<gp_Pnt>();
TopoDS_Shape aResult;
- ListOfMakeShape aListOfMakeShape;
bool isBoundingShapesSet = theFromShape || theToShape;
if(!isBoundingShapesSet) {
// Moving base shape.
if(!aTransformBuilder) {
return;
}
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
+ this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
if(!aTransformBuilder->IsDone()) {
return;
}
if(!aPrismBuilder) {
return;
}
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
+ this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
if(!aPrismBuilder->IsDone()) {
return;
}
std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
aFromShape->setImpl(new TopoDS_Shape(aPrismBuilder->FirstShape(aFace)));
aToShape->setImpl(new TopoDS_Shape(aPrismBuilder->LastShape(aFace)));
- myFromFaces.push_back(aFromShape);
- myToFaces.push_back(aToShape);
+ this->addFromFace(aFromShape);
+ this->addToFace(aToShape);
}
} else {
std::shared_ptr<GeomAPI_Shape> aBoundingFromShape = theFromShape ? theFromShape : aBasePlane;
if(!aTransformBuilder) {
return;
}
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
+ this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
if(!aTransformBuilder->IsDone()) {
return;
}
if(!aPrismBuilder) {
return;
}
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
+ this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
if(!aPrismBuilder->IsDone()) {
return;
}
if(!aToCutBuilder->IsDone()) {
return;
}
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
+ this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
const TopTools_ListOfShape& aToShapes = aToCutBuilder->Modified(aToShape);
for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) {
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- myToFaces.push_back(aShape);
+ this->addToFace(aShape);
}
aResult = aToCutBuilder->Shape();
if(!aFromCutBuilder->IsDone()) {
return;
}
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
+ this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
const TopTools_ListOfShape& aFromShapes = aFromCutBuilder->Modified(aFromShape);
for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) {
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- myFromFaces.push_back(aShape);
+ this->addFromFace(aShape);
}
aResult = aFromCutBuilder->Shape();
if(aResult.IsNull()) {
return;
}
- myShape.reset(new GeomAPI_Shape);
- myShape->setImpl(new TopoDS_Shape(aResult));
-
- // Filling data map to keep correct orientation of sub-shapes.
- myMap.reset(new GeomAPI_DataMapOfShapeShape);
- for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
- std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape);
- aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
- myMap->bind(aCurrentShape, aCurrentShape);
- }
-
- // Setting list of make shape.
- myMkShape.reset(new GeomAlgoAPI_MakeShapeList(aListOfMakeShape));
-
- myDone = true;
-}
-
-//=================================================================================================
-bool GeomAlgoAPI_Prism::isDone() const
-{
- return myDone;
-}
-
-//=================================================================================================
-bool GeomAlgoAPI_Prism::isValid() const
-{
- BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
- return (aChecker.IsValid() == Standard_True);
-}
-
-//=================================================================================================
-bool GeomAlgoAPI_Prism::hasVolume() const
-{
- bool hasVolume(false);
- if(isValid()) {
- const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
- GProp_GProps aGProp;
- BRepGProp::VolumeProperties(aRShape, aGProp);
- if(aGProp.Mass() > Precision::Confusion())
- hasVolume = true;
- }
- return hasVolume;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Prism::shape() const
-{
- return myShape;
-}
-
-//=================================================================================================
-const ListOfShape& GeomAlgoAPI_Prism::fromFaces() const
-{
- return myFromFaces;
-}
-
-//=================================================================================================
-const ListOfShape& GeomAlgoAPI_Prism::toFaces() const
-{
- return myToFaces;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_Prism::mapOfShapes() const
-{
- return myMap;
-}
-
-//=================================================================================================
-std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_Prism::makeShape() const
-{
- return myMkShape;
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aResult));
+ this->setShape(aShape);
+ this->setDone(true);
}
#include <GeomAlgoAPI.h>
#include <GeomAPI_Shape.h>
-#include <GeomAlgoAPI_MakeShape.h>
-#include <GeomAPI_DataMapOfShapeShape.h>
+#include <GeomAlgoAPI_MakeSweep.h>
+
#include <memory>
-/** \class GeomAlgoAPI_Prism
- * \ingroup DataAlgo
- * \brief Allows to create the prism based on a given face and bounding planes.
- * \n Note that only planar faces are allowed as bounding faces and resulting
- * extrusion will be bounded by the infinite planes taken from the faces.
- */
-class GeomAlgoAPI_Prism : public GeomAPI_Interface
+/// \class GeomAlgoAPI_Prism
+/// \ingroup DataAlgo
+/// \brief Allows to create the prism based on a given face and bounding planes.
+/// \n Note that only planar faces are allowed as bounding faces and resulting
+/// extrusion will be bounded by the infinite planes taken from the faces.
+class GeomAlgoAPI_Prism : public GeomAlgoAPI_MakeSweep
{
public:
- /** \brief Creates extrusion for the given shape along the normal for this shape.
- * \param[in] theBaseShape face or wire to be extruded.
- * \param[in] theToSize offset for "to" plane.
- * \param[in] theFromSize offset for "from" plane.
- */
+ /// \brief Creates extrusion for the given shape along the normal for this shape.
+ /// \param[in] theBaseShape face or wire to be extruded.
+ /// \param[in] theToSize offset for "to" plane.
+ /// \param[in] theFromSize offset for "from" plane.
GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
double theToSize,
double theFromSize);
- /** \brief Creates extrusion for the given shape along the normal for this shape.
- * \param[in] theBaseShape face or wire to be extruded.
- * \param[in] theToShape top bounding shape. Can be empty. In this case offset will be applied to the basis.
- * \param[in] theToSize offset for "to" plane.
- * \param[in] theFromShape bottom bounding shape. Can be empty. In this case offset will be applied to the basis.
- * \param[in] theFromSize offset for "from" plane.
- */
+ /// \brief Creates extrusion for the given shape along the normal for this shape.
+ /// \param[in] theBaseShape face or wire to be extruded.
+ /// \param[in] theToShape top bounding shape. Can be empty. In this case offset will be applied to the basis.
+ /// \param[in] theToSize offset for "to" plane.
+ /// \param[in] theFromShape bottom bounding shape. Can be empty. In this case offset will be applied to the basis.
+ /// \param[in] theFromSize offset for "from" plane.
GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
std::shared_ptr<GeomAPI_Shape> theToShape,
double theToSize,
std::shared_ptr<GeomAPI_Shape> theFromShape,
double theFromSize);
- /// \return true if algorithm succeed.
- GEOMALGOAPI_EXPORT bool isDone() const;
-
- /// \return true if resulting shape is valid.
- GEOMALGOAPI_EXPORT bool isValid() const;
-
- /// \return true if resulting shape has volume.
- GEOMALGOAPI_EXPORT bool hasVolume() const;
-
- /// \return result of the Prism algorithm.
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape() const;
-
- /// \returns the list of from faces.
- GEOMALGOAPI_EXPORT const ListOfShape& fromFaces() const;
-
- /// \return the list of to faces.
- GEOMALGOAPI_EXPORT const ListOfShape& toFaces() const;
-
- /// \return map of sub-shapes of the result. To be used for History keeping.
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfShapes() const;
-
- /// \return interface for History processing.
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
-
private:
/// Builds resulting shape.
void build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
double theToSize,
const std::shared_ptr<GeomAPI_Shape>& theFromShape,
double theFromSize);
-
-private:
- /// Fields.
- bool myDone;
- std::shared_ptr<GeomAPI_Shape> myShape;
- ListOfShape myFromFaces;
- ListOfShape myToFaces;
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
- std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
};
#endif