// 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);
}