#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Boolean.h>
#include <GeomAlgoAPI_MakeShapeList.h>
+#include <GeomAlgoAPI_PaveFiller.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAPI_ShapeExplorer.h>
-#define FACE 4
-#define _MODIFY_TAG 1
-#define _DELETED_TAG 2
-#define _SUBSOLIDS_TAG 3 /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
+#include <algorithm>
//=================================================================================================
FeaturesPlugin_Boolean::FeaturesPlugin_Boolean()
GeomAlgoAPI_Boolean::OperationType aType = (GeomAlgoAPI_Boolean::OperationType)aTypeAttr->value();
ListOfShape anObjects, aTools;
+ std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
// Getting objects.
AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
- std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr = anObjectsSelList->value(anObjectsIndex);
+ AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
if(!anObject.get()) {
return;
}
- anObjects.push_back(anObject);
+ ResultPtr aContext = anObjectAttr->context();
+ ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ if(aResCompSolidPtr.get()) {
+ std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
+ std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
+ for(; anIt != aCompSolidsObjects.end(); anIt++) {
+ if(anIt->first->isEqual(aContextShape)) {
+ aCompSolidsObjects[anIt->first].push_back(anObject);
+ break;
+ }
+ }
+ if(anIt == aCompSolidsObjects.end()) {
+ aCompSolidsObjects[aContextShape].push_back(anObject);
+ }
+ } else {
+ anObjects.push_back(anObject);
+ }
}
// Getting tools.
AttributeSelectionListPtr aToolsSelList = selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
for(int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) {
- std::shared_ptr<ModelAPI_AttributeSelection> aToolAttr = aToolsSelList->value(aToolsIndex);
+ AttributeSelectionPtr aToolAttr = aToolsSelList->value(aToolsIndex);
std::shared_ptr<GeomAPI_Shape> aTool = aToolAttr->value();
if(!aTool.get()) {
return;
switch(aType) {
case GeomAlgoAPI_Boolean::BOOL_CUT:
case GeomAlgoAPI_Boolean::BOOL_COMMON:{
- if(anObjects.empty() || aTools.empty()) {
+ if((anObjects.empty() && aCompSolidsObjects.empty()) || aTools.empty()) {
std::string aFeatureError = "Not enough objects for boolean operation";
setError(aFeatureError);
return;
}
- // Cut each object with all tools
+ // For solids cut each object with all tools.
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) {
std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
ListOfShape aListWithObject;
if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-7) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- LoadNamingDS(aResultBody, anObject, aTools, aBoolAlgo);
+ loadNamingDS(aResultBody, anObject, aBoolAlgo.shape(), aTools, *aBoolAlgo.makeShape(), *aBoolAlgo.mapOfShapes());
+ setResult(aResultBody, aResultIndex);
+ aResultIndex++;
+ }
+ }
+
+ // Compsolids handling
+ for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
+ anIt != aCompSolidsObjects.end(); anIt++) {
+ std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
+ ListOfShape& aUsedInOperationSolids = anIt->second;
+
+ // Collecting solids from compsolids which will not be modified in boolean operation.
+ ListOfShape aNotUsedSolids;
+ for(GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
+ std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
+ ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
+ for(; anIt != aUsedInOperationSolids.end(); anIt++) {
+ if(aSolidInCompSolid->isEqual(*anIt)) {
+ break;
+ }
+ }
+ if(anIt == aUsedInOperationSolids.end()) {
+ aNotUsedSolids.push_back(aSolidInCompSolid);
+ }
+ }
+
+ GeomAlgoAPI_Boolean aBoolAlgo(aUsedInOperationSolids, aTools, aType);
+
+ // Checking that the algorithm worked properly.
+ if(!aBoolAlgo.isDone()) {
+ static const std::string aFeatureError = "Boolean algorithm failed";
+ setError(aFeatureError);
+ return;
+ }
+ if(aBoolAlgo.shape()->isNull()) {
+ static const std::string aShapeError = "Resulting shape is Null";
+ setError(aShapeError);
+ return;
+ }
+ if(!aBoolAlgo.isValid()) {
+ std::string aFeatureError = "Warning: resulting shape is not valid";
+ setError(aFeatureError);
+ return;
+ }
+
+ GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ aMakeShapeList.append(aBoolAlgo.makeShape());
+ GeomAPI_DataMapOfShapeShape aMapOfShapes;
+ aMapOfShapes.merge(aBoolAlgo.mapOfShapes());
+
+ // Add result to not used solids from compsolid.
+ ListOfShape aShapesToAdd = aNotUsedSolids;
+ aShapesToAdd.push_back(aBoolAlgo.shape());
+ GeomAlgoAPI_PaveFiller aFillerAlgo(aShapesToAdd, true);
+ if(!aFillerAlgo.isDone()) {
+ std::string aFeatureError = "PaveFiller algorithm failed";
+ setError(aFeatureError);
+ return;
+ }
+
+ aMakeShapeList.append(aFillerAlgo.makeShape());
+ aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
+
+ if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo.shape()) > 1.e-7) {
+ std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
+ loadNamingDS(aResultBody, aCompSolid, aFillerAlgo.shape(), aTools, aMakeShapeList, aMapOfShapes);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
break;
}
case GeomAlgoAPI_Boolean::BOOL_FUSE: {
- if(anObjects.empty() && aTools.size() > 1) {
- anObjects.push_back(aTools.back());
- aTools.pop_back();
- }else if(aTools.empty() && anObjects.size() > 1) {
- aTools.push_back(anObjects.back());
- anObjects.pop_back();
- }
-
- if(anObjects.empty() || aTools.empty()) {
+ if((anObjects.size() + aTools.size() + aCompSolidsObjects.size()) < 2) {
std::string aFeatureError = "Not enough objects for boolean operation";
setError(aFeatureError);
return;
}
+ // Collecting all solids which will be fused.
+ ListOfShape aSolidsToFuse;
+ aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end());
+ aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end());
+
+ // Collecting solids from compsolids which will not be modified in boolean operation.
+ ListOfShape aNotUsedSolids;
+ for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
+ anIt != aCompSolidsObjects.end(); anIt++) {
+ std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
+ ListOfShape& aUsedInOperationSolids = anIt->second;
+ aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedInOperationSolids.begin(), aUsedInOperationSolids.end());
+
+ // Collect solids from compsolid which will not be modified in boolean operation.
+ for(GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
+ std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
+ ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
+ for(; anIt != aUsedInOperationSolids.end(); anIt++) {
+ if(aSolidInCompSolid->isEqual(*anIt)) {
+ break;
+ }
+ }
+ if(anIt == aUsedInOperationSolids.end()) {
+ aNotUsedSolids.push_back(aSolidInCompSolid);
+ }
+ }
+ }
+
+ ListOfShape anOriginalSolids = aSolidsToFuse;
+ anOriginalSolids.insert(anOriginalSolids.end(), aNotUsedSolids.begin(), aNotUsedSolids.end());
+ GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ GeomAPI_DataMapOfShapeShape aMapOfShapes;
+
+ // If we have compsolids then cut with not used solids all others.
+ if(!aNotUsedSolids.empty()) {
+ aSolidsToFuse.clear();
+ for(ListOfShape::iterator anIt = anOriginalSolids.begin(); anIt != anOriginalSolids.end(); anIt++) {
+ ListOfShape aOneObjectList;
+ aOneObjectList.push_back(*anIt);
+ GeomAlgoAPI_Boolean aCutAlgo(aOneObjectList, aNotUsedSolids, GeomAlgoAPI_Boolean::BOOL_CUT);
+
+ if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo.shape()) > 1.e-7) {
+ aSolidsToFuse.push_back(aCutAlgo.shape());
+ aMakeShapeList.append(aCutAlgo.makeShape());
+ aMapOfShapes.merge(aCutAlgo.mapOfShapes());
+ }
+ }
+ }
+
+ anObjects.clear();
+ anObjects.push_back(aSolidsToFuse.back());
+ aSolidsToFuse.pop_back();
+ aTools = aSolidsToFuse;
+
// Fuse all objects and all tools.
- GeomAlgoAPI_Boolean aBoolAlgo(anObjects, aTools, aType);
+ GeomAlgoAPI_Boolean aFuseAlgo(anObjects, aTools, aType);
// Checking that the algorithm worked properly.
- if(!aBoolAlgo.isDone()) {
+ if(!aFuseAlgo.isDone()) {
static const std::string aFeatureError = "Boolean algorithm failed";
setError(aFeatureError);
return;
}
- if(aBoolAlgo.shape()->isNull()) {
+ if(aFuseAlgo.shape()->isNull()) {
static const std::string aShapeError = "Resulting shape is Null";
setError(aShapeError);
return;
}
- if(!aBoolAlgo.isValid()) {
+ if(!aFuseAlgo.isValid()) {
std::string aFeatureError = "Warning: resulting shape is not valid";
setError(aFeatureError);
return;
}
+ std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo.shape();
+ aMakeShapeList.append(aFuseAlgo.makeShape());
+ aMapOfShapes.merge(aFuseAlgo.mapOfShapes());
+
+ // Add result to not used solids from compsolid (if we have any).
+ if(!aNotUsedSolids.empty()) {
+ aNotUsedSolids.push_back(aShape);
+ GeomAlgoAPI_PaveFiller aFillerAlgo(aNotUsedSolids, true);
+ if(!aFillerAlgo.isDone()) {
+ std::string aFeatureError = "PaveFiller algorithm failed";
+ setError(aFeatureError);
+ return;
+ }
+ if(aFillerAlgo.shape()->isNull()) {
+ static const std::string aShapeError = "Resulting shape is Null";
+ setError(aShapeError);
+ return;
+ }
+ if(!aFillerAlgo.isValid()) {
+ std::string aFeatureError = "Warning: resulting shape is not valid";
+ setError(aFeatureError);
+ return;
+ }
+
+ aShape = aFillerAlgo.shape();
+ aMakeShapeList.append(aFillerAlgo.makeShape());
+ aMapOfShapes.merge(aFillerAlgo.mapOfShapes());
+ }
+
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- LoadNamingDS(aResultBody, anObjects.front(), aTools, aBoolAlgo);
+ loadNamingDS(aResultBody, anOriginalSolids.front(), aShape, anOriginalSolids, aMakeShapeList, aMapOfShapes);
setResult(aResultBody, aResultIndex);
aResultIndex++;
break;
}
//=================================================================================================
-void FeaturesPlugin_Boolean::LoadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
+void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const std::shared_ptr<GeomAPI_Shape> theResultShape,
const ListOfShape& theTools,
- const GeomAlgoAPI_Boolean& theAlgo)
+ GeomAlgoAPI_MakeShape& theMakeShape,
+ GeomAPI_DataMapOfShapeShape& theMapOfShapes)
{
//load result
- if(theBaseShape->isEqual(theAlgo.shape())) {
- theResultBody->store(theAlgo.shape());
+ if(theBaseShape->isEqual(theResultShape)) {
+ theResultBody->store(theResultShape);
} else {
- theResultBody->storeModified(theBaseShape, theAlgo.shape(), _SUBSOLIDS_TAG);
+ 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, theResultShape, aSubsolidsTag);
GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
std::string aModName = "Modified";
- theResultBody->loadAndOrientModifiedShapes(theAlgo.makeShape().get(), theBaseShape, FACE,
- _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get());
- theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), theBaseShape, FACE, _DELETED_TAG);
+ 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(theAlgo.makeShape().get(), *anIter, FACE,
- _MODIFY_TAG, aModName, *theAlgo.mapOfShapes().get());
- theResultBody->loadDeletedShapes(theAlgo.makeShape().get(), *anIter, FACE, _DELETED_TAG);
+ theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
+ aModifyTag, aModName, theMapOfShapes);
+ theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
}
}
}
std::shared_ptr<GeomAPI_Shape> getShape(const std::string& theAttrName);
/// Load Naming data structure of the feature to the document
- void LoadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const std::shared_ptr<GeomAPI_Shape>& theBaseObject,
+ void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const std::shared_ptr<GeomAPI_Shape> theResultShape,
const ListOfShape& theTools,
- const GeomAlgoAPI_Boolean& theAlgo);
+ GeomAlgoAPI_MakeShape& theMakeShape,
+ GeomAPI_DataMapOfShapeShape& theMapOfShapes);
};
#endif
ListOfShape aFreeFaces;
std::shared_ptr<GeomAPI_Shape> aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aFacesList);
GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aShells, aFreeFaces);
- for(ListOfShape::const_iterator anIter = aFreeFaces.cbegin(); anIter != aFreeFaces.cend(); anIter++) {
- aShells.push_back(*anIter);
- }
+ aShells.insert(aShells.end(), aFreeFaces.begin(), aFreeFaces.end());
// Pass shells/faces to solids creation function.
ListOfShape aBooleanTools;
ListOfShape aFreeFaces;
std::shared_ptr<GeomAPI_Shape> aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aFacesList);
GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aShells, aFreeFaces);
- for(ListOfShape::const_iterator anIter = aFreeFaces.cbegin(); anIter != aFreeFaces.cend(); anIter++) {
- aShells.push_back(*anIter);
- }
+ aShells.insert(aShells.end(), aFreeFaces.begin(), aFreeFaces.end());
// Generating result for each shell and face.
int aResultIndex = 0;
ListOfShape aFreeFaces;
std::shared_ptr<GeomAPI_Shape> aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aFacesList);
GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aShells, aFreeFaces);
- for(ListOfShape::const_iterator anIter = aFreeFaces.cbegin(); anIter != aFreeFaces.cend(); anIter++) {
- aShells.push_back(*anIter);
- }
+ aShells.insert(aShells.end(), aFreeFaces.begin(), aFreeFaces.end());
// Generating result for each shell and face.
int aResultIndex = 0;
#include <GeomAPI_Shape.h>
#include <GeomAPI_DataMapOfShapeShape.h>
#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <TopoDS_Shape.hxx>
using namespace std;
GeomAPI_DataMapOfShapeShape::GeomAPI_DataMapOfShapeShape()
- :GeomAPI_Interface((void *)new TopTools_DataMapOfShapeShape){}
+: GeomAPI_Interface(new TopTools_DataMapOfShapeShape){}
void GeomAPI_DataMapOfShapeShape::clear()
{
{
bool flag(false);
if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
- flag = true;
+ flag = true;
return flag;
}
+void GeomAPI_DataMapOfShapeShape::merge(const GeomAPI_DataMapOfShapeShape& theDataMap)
+{
+ const TopTools_DataMapOfShapeShape& aDataMap = theDataMap.impl<TopTools_DataMapOfShapeShape>();
+ TopTools_DataMapOfShapeShape* myDataMap = implPtr<TopTools_DataMapOfShapeShape>();
+ for(TopTools_DataMapIteratorOfDataMapOfShapeShape anIt(aDataMap); anIt.More(); anIt.Next()) {
+ myDataMap->Bind(anIt.Key(), anIt.Value());
+ }
+}
+
+void GeomAPI_DataMapOfShapeShape::merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap)
+{
+ merge(*theDataMap.get());
+}
+
bool GeomAPI_DataMapOfShapeShape::isBound (std::shared_ptr<GeomAPI_Shape> theKey)
{
bool flag(false);
aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
return aShape;
}
-
+
bool GeomAPI_DataMapOfShapeShape::unBind(std::shared_ptr<GeomAPI_Shape> theKey)
{
bool flag(false);
if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
- flag = true;
+ flag = true;
return flag;
}
{
if (!empty()) {
implPtr<TopTools_DataMapOfShapeShape>()->Clear();
- //delete myImpl;
}
}
GEOMAPI_EXPORT
bool bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem);
+ /// Merges two maps
+ GEOMAPI_EXPORT void merge(const GeomAPI_DataMapOfShapeShape& theDataMap);
+
+ /// Merges two maps
+ GEOMAPI_EXPORT void merge(const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theDataMap);
+
/// Returns true if theKey is stored in the map.
GEOMAPI_EXPORT
bool isBound (std::shared_ptr<GeomAPI_Shape> theKey);
GeomAlgoAPI_Transform.h
GeomAlgoAPI_ShapeTools.h
GeomAlgoAPI_Partition.h
+ GeomAlgoAPI_PaveFiller.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_Transform.cpp
GeomAlgoAPI_ShapeTools.cpp
GeomAlgoAPI_Partition.cpp
+ GeomAlgoAPI_PaveFiller.cpp
)
SET(PROJECT_LIBRARIES
#include "GeomAlgoAPI_STEPImport.h"
#include "GeomAlgoAPI_Tools.h"
#include "GeomAlgoAPI_Transform.h"
+ #include "GeomAlgoAPI_PaveFiller.h"
#include <memory>
#include <string>
%include "GeomAlgoAPI_STEPImport.h"
%include "GeomAlgoAPI_Tools.h"
%include "GeomAlgoAPI_Transform.h"
+%include "GeomAlgoAPI_PaveFiller.h"
%typemap(out) std::list< std::shared_ptr< GeomAPI_Shape > >::value_type & {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<GeomAPI_Shape>(*$1)), $descriptor(std::shared_ptr<GeomAPI_Shape> *), SWIG_POINTER_OWN | 0 );
GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const ListOfShape& theObjects,
const ListOfShape& theTools,
const OperationType theOperationType)
-: myDone(false),
- myShape(new GeomAPI_Shape()),
- myMap(new GeomAPI_DataMapOfShapeShape()),
- myMkShape(new GeomAlgoAPI_MakeShape())
+: myDone(false)
{
build(theObjects, theTools, theOperationType);
}
return;
}
}
- myMkShape->setImpl(anOperation);
+ myMkShape.reset(new GeomAlgoAPI_MakeShape(anOperation));
anOperation->SetArguments(anObjects);
anOperation->SetTools(aTools);
}
// fill 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);
}
+ myShape.reset(new GeomAPI_Shape());
myShape->setImpl(new TopoDS_Shape(aResult));
}
// Author: Sergey ZARITCHNY
#include <GeomAlgoAPI_MakeShape.h>
+
+#include <BOPAlgo_Builder.hxx>
#include <BRepBuilderAPI_MakeShape.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
-GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
- : GeomAPI_Interface(theMkShape),myShape(new GeomAPI_Shape())
+//=================================================================================================
+GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape, const AlgoType theAlgoType)
+: GeomAPI_Interface(theMkShape),
+ myAlgoType(theAlgoType),
+ myShape(new GeomAPI_Shape())
{
- myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
+ switch (myAlgoType) {
+ case MakeShape:
+ case MakePipe: {
+ myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
+ break;
+ }
+ case BOPAlgoBuilder: {
+ myShape->setImpl(new TopoDS_Shape(implPtr<BOPAlgo_Builder>()->Shape()));
+ break;
+ }
+ }
}
+//=================================================================================================
GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape,
const std::shared_ptr<GeomAPI_Shape> theWire,
const std::shared_ptr<GeomAPI_Shape> theBaseShape)
: GeomAPI_Interface(theMkShape),
+ myAlgoType(MakePipe),
myShape(new GeomAPI_Shape()),
myWire(theWire),
myBaseShape(theBaseShape)
{
- myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
+ myShape->setImpl(new TopoDS_Shape(implPtr<BRepOffsetAPI_MakePipe>()->Shape()));
}
-GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
- : GeomAPI_Interface(),myShape(new GeomAPI_Shape())
-{}
-
+//=================================================================================================
const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
{
return myShape;
}
-void GeomAlgoAPI_MakeShape::generated(
- const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+//=================================================================================================
+void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
+ ListOfShape& theHistory)
{
- if(!myWire.get()) {
- BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
- if(aBuilder) {
- const TopTools_ListOfShape& aList = aBuilder->Generated(theShape->impl<TopoDS_Shape>());
- TopTools_ListIteratorOfListOfShape it(aList);
- for(;it.More();it.Next()) {
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(it.Value()));
- theHistory.push_back(aShape);
- }
- }
- } else { // Pipe builder
- BRepOffsetAPI_MakePipe* aPipeBuilder = implPtr<BRepOffsetAPI_MakePipe>();
- if(aPipeBuilder) {
- TopExp_Explorer aShapeExplorer(myWire->impl<TopoDS_Wire>(), TopAbs_EDGE);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aSpine = aShapeExplorer.Current();
- const TopoDS_Shape& aProfile = theShape->impl<TopoDS_Shape>();
- if(aProfile.ShapeType() != TopAbs_EDGE && aProfile.ShapeType() != TopAbs_VERTEX) {
- return;
- }
- const TopoDS_Shape& aBaseShape = myBaseShape->impl<TopoDS_Shape>();
- TopExp_Explorer anExp(aBaseShape, aProfile.ShapeType());
- Standard_Boolean hasShape = Standard_False;
- for(; anExp.More(); anExp.Next()) {
- if(anExp.Current().IsSame(aProfile)) {
- hasShape = Standard_True;
- break;
- }
- }
- if(!hasShape) {
+ if(myAlgoType == MakePipe) {
+ BRepOffsetAPI_MakePipe* aMakePipe = implPtr<BRepOffsetAPI_MakePipe>();
+ TopExp_Explorer aShapeExplorer(myWire->impl<TopoDS_Wire>(), TopAbs_EDGE);
+ for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
+ const TopoDS_Shape& aSpine = aShapeExplorer.Current();
+ const TopoDS_Shape& aProfile = theShape->impl<TopoDS_Shape>();
+ if(aProfile.ShapeType() != TopAbs_EDGE && aProfile.ShapeType() != TopAbs_VERTEX) {
return;
+ }
+ const TopoDS_Shape& aBaseShape = myBaseShape->impl<TopoDS_Shape>();
+ TopExp_Explorer anExp(aBaseShape, aProfile.ShapeType());
+ Standard_Boolean hasShape = Standard_False;
+ for(; anExp.More(); anExp.Next()) {
+ if(anExp.Current().IsSame(aProfile)) {
+ hasShape = Standard_True;
+ break;
}
- const TopoDS_Shape& aGeneratedShape = aPipeBuilder->Generated(aSpine, aProfile);
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(aGeneratedShape));
- theHistory.push_back(aShape);
}
+ if(!hasShape) {
+ return;
+ }
+ const TopoDS_Shape& aGeneratedShape = aMakePipe->Generated(aSpine, aProfile);
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aGeneratedShape));
+ theHistory.push_back(aShape);
+ }
+ } else {
+ TopTools_ListOfShape aList;
+ if(myAlgoType == MakeShape) {
+ BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
+ aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
+ } else if(myAlgoType == BOPAlgoBuilder) {
+ BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
+ aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
+ }
+ for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(anIt.Value()));
+ theHistory.push_back(aShape);
}
}
}
-void GeomAlgoAPI_MakeShape::modified(
- const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+//=================================================================================================
+void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
+ ListOfShape& theHistory)
{
- BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
- if(aBuilder) {
- const TopTools_ListOfShape& aList = aBuilder->Modified(theShape->impl<TopoDS_Shape>());
- TopTools_ListIteratorOfListOfShape it(aList);
- for(;it.More();it.Next()) {
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(it.Value()));
- theHistory.push_back(aShape);
- }
+ TopTools_ListOfShape aList;
+ if(myAlgoType == MakeShape) {
+ BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
+ aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
+ } else if(myAlgoType == BOPAlgoBuilder) {
+ BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
+ aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
+ }
+ for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(anIt.Value()));
+ theHistory.push_back(aShape);
}
}
+//=================================================================================================
bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
{
- bool isDeleted(false);
- BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
- if(aBuilder) {
- isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+ bool isDeleted = false;
+ if(myAlgoType == MakeShape) {
+ BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
+ isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+ } else if(myAlgoType == BOPAlgoBuilder) {
+ BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
+ isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
}
+
return isDeleted;
}
class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
{
public:
- /// Constructor
- GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
+ /// Algo type enum
+ enum AlgoType {
+ MakeShape,
+ MakePipe,
+ BOPAlgoBuilder
+ };
+
+public:
/// Constructor by the already stored builder in the interface
- GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder);
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder, const AlgoType theAlgoType = MakeShape);
/// Constructor by the builder and wire. Used for pipe builder.
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder,
const std::shared_ptr<GeomAPI_Shape> theBaseShape);
/// Returns a shape built by the shape construction algorithm
- GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape> shape() const;
+ GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape> shape() const;
/// Returns the list of shapes generated from the shape \a theShape
GEOMALGOAPI_EXPORT virtual void generated(
/// Returns whether the shape is an edge
GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
- protected:
- /// The resulting shape
+protected:
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(){};
+
+protected:
+ GeomAlgoAPI_MakeShape::AlgoType myAlgoType;
std::shared_ptr<GeomAPI_Shape> myShape;
std::shared_ptr<GeomAPI_Shape> myWire;
std::shared_ptr<GeomAPI_Shape> myBaseShape;
myListOfMakeShape = theMakeShapeList;
}
+//=================================================================================================
+void GeomAlgoAPI_MakeShapeList::append(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
{
bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
{
for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) {
- BRepBuilderAPI_MakeShape* aBuilder = (*aBuilderIt)->implPtr<BRepBuilderAPI_MakeShape>();
- if(aBuilder && (aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True)) {
+ std::shared_ptr<GeomAlgoAPI_MakeShape> aMakeShape = *aBuilderIt;
+ if(aMakeShape->isDeleted(theShape)) {
return true;
}
}
theHistory.push_back(aShape);
}
}
-
*/
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);
+
/// \return a shape built by the shape construction algorithms
GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape> shape() const;
std::shared_ptr<GeomAPI_Ax1> theAxis,
double theDistance,
bool theSimpleTransform)
-: myDone(false),
- myShape(new GeomAPI_Shape()),
- myMap(new GeomAPI_DataMapOfShapeShape()),
- myMkShape(new GeomAlgoAPI_MakeShape())
+: myDone(false)
{
build(theSourceShape, theAxis, theDistance, theSimpleTransform);
}
if(!aBuilder) {
return;
}
+ myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder));
myDone = aBuilder->IsDone() == Standard_True;
aResult = aBuilder->Shape();
// Fill data map to keep correct orientation of sub-shapes.
+ myMap.reset(new GeomAPI_DataMapOfShapeShape());
for(TopExp_Explorer anExp(aResult, 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);
}
- myMkShape->setImpl(aBuilder);
}
+ myShape.reset(new GeomAPI_Shape());
myShape->setImpl(new TopoDS_Shape(aResult));
}
//=================================================================================================
GeomAlgoAPI_Partition::GeomAlgoAPI_Partition(const ListOfShape& theObjects,
const ListOfShape& theTools)
-: myDone(false),
- myShape(new GeomAPI_Shape()),
- myMap(new GeomAPI_DataMapOfShapeShape()),
- myMkShape(new GeomAlgoAPI_MakeShape())
+: myDone(false)
{
build(theObjects, theTools);
}
}
// Creating partition operation.
- GEOMAlgo_Splitter * anOperation = new GEOMAlgo_Splitter;
- myMkShape->setImpl(anOperation);
+ GEOMAlgo_Splitter* anOperation = new GEOMAlgo_Splitter;
+ myMkShape.reset(new GeomAlgoAPI_MakeShape(anOperation, GeomAlgoAPI_MakeShape::BOPAlgoBuilder));
// Getting objects.
TopTools_ListOfShape anObjects;
}
// fill 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);
}
+ myShape.reset(new GeomAPI_Shape());
myShape->setImpl(new TopoDS_Shape(aResult));
}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_PaveFiller.cpp
+// Created: 27 August 2015
+// Author: Dmitry Bobylev
+
+#include <GeomAlgoAPI_PaveFiller.h>
+
+#include <GeomAlgoAPI_DFLoader.h>
+#include <GeomAlgoAPI_ShapeTools.h>
+
+#include <BOPAlgo_Builder.hxx>
+#include <BOPAlgo_PaveFiller.hxx>
+#include <BRepCheck_Analyzer.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS_Builder.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
+: myDone(false)
+{
+ build(theListOfShape, theIsMakeCompSolids);
+}
+
+
+//=================================================================================================
+void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids)
+{
+ BOPAlgo_PaveFiller aPaveFiller;
+ BOPCol_ListOfShape aListOfShape;
+ for(ListOfShape::const_iterator anIt = theListOfShape.cbegin(); anIt != theListOfShape.cend(); anIt++) {
+ aListOfShape.Append((*anIt)->impl<TopoDS_Shape>());
+ }
+ aPaveFiller.SetArguments(aListOfShape);
+ aPaveFiller.Perform();
+ Standard_Integer iErr = aPaveFiller.ErrorStatus();
+ if(iErr) {
+ return;
+ }
+
+ BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder();
+ myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder, GeomAlgoAPI_MakeShape::BOPAlgoBuilder));
+ aBuilder->SetArguments(aListOfShape);
+ aBuilder->PerformWithFiller(aPaveFiller);
+ iErr = aBuilder->ErrorStatus();
+ if(iErr) {
+ return;
+ }
+
+ TopoDS_Shape aResult = aBuilder->Shape();
+ if(aResult.ShapeType() == TopAbs_COMPOUND) {
+ aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+ }
+ if(theIsMakeCompSolids && aResult.ShapeType() == TopAbs_COMPOUND) {
+ std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
+ aCompound->setImpl(new TopoDS_Shape(aResult));
+ ListOfShape aCompSolids, aFreeSolids;
+ GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
+ if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
+ aResult = aCompSolids.front()->impl<TopoDS_Shape>();
+ } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
+ TopoDS_Compound aResultComp;
+ TopoDS_Builder aBuilder;
+ aBuilder.MakeCompound(aResultComp);
+ for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
+ aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
+ }
+ for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
+ aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
+ }
+ aResult = aResultComp;
+ }
+ }
+
+ // fill 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);
+ }
+
+ myShape.reset(new GeomAPI_Shape());
+ myShape->setImpl(new TopoDS_Shape(aResult));
+
+ myDone = true;
+}
+
+//=================================================================================================
+const bool GeomAlgoAPI_PaveFiller::isDone() const
+{
+ return myDone;
+}
+
+//=================================================================================================
+const bool GeomAlgoAPI_PaveFiller::isValid() const
+{
+ BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
+ return (aChecker.IsValid() == Standard_True);
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PaveFiller::shape() const
+{
+ return myShape;
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_DataMapOfShapeShape> GeomAlgoAPI_PaveFiller::mapOfShapes() const
+{
+ return myMap;
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAlgoAPI_MakeShape> GeomAlgoAPI_PaveFiller::makeShape() const
+{
+ return myMkShape;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_PaveFiller.h
+// Created: 27 August 2015
+// Author: Dmitry Bobylev
+
+#ifndef GeomAlgoAPI_PaveFiller_H_
+#define GeomAlgoAPI_PaveFiller_H_
+
+#include <GeomAlgoAPI.h>
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Interface.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
+
+/** \class GeomAlgoAPI_PaveFiller
+ * \ingroup DataAlgo
+ * \brief Finds the common parts from the list of shapes and breaks it to shapes with shared subshapes.
+ */
+class GeomAlgoAPI_PaveFiller : public GeomAPI_Interface
+{
+public:
+ /** \brief Constructor.
+ * \param[in] theListOfShape list of shape which should be splitted.
+ * \param[in] theIsMakeCompSolids if true gather shapes with shared faces to compsolids.
+ */
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids = false);
+
+ /// \return true if algorithm succeed.
+ GEOMALGOAPI_EXPORT const bool isDone() const;
+
+ /// \return true if resulting shape is valid.
+ GEOMALGOAPI_EXPORT const bool isValid() const;
+
+ /// \return result of the boolean algorithm.
+ GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape() 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 for History processing.
+ GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
+
+private:
+ /// Builds resulting shape.
+ void build(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids);
+
+private:
+ /// Fields.
+ bool myDone;
+ std::shared_ptr<GeomAPI_Shape> myShape;
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
+ std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
+};
+
+#endif
aMaxFromDist = aPoints[i].Distance(aPntOnFromFace);
}
}
- Standard_Real aPipeLength = aMaxToDist + aMaxFromDist;
+ // We added 1 just to be sure that pipe is long enough for boolean operation.
+ Standard_Real aPipeLength = aMaxToDist + aMaxFromDist + 1;
// Making wire for pipe.
std::shared_ptr<GeomAPI_Pnt> aCentreOfMass = GeomAlgoAPI_ShapeTools::centreOfMass(theBasis);
std::shared_ptr<GeomAPI_Ax1> theAxis,
double theAngle,
bool theSimpleTransform)
-: myDone(false),
- myShape(new GeomAPI_Shape()),
- myMap(new GeomAPI_DataMapOfShapeShape()),
- myMkShape(new GeomAlgoAPI_MakeShape())
+: myDone(false)
{
build(theSourceShape, theAxis, theAngle, theSimpleTransform);
}
if(!aBuilder) {
return;
}
+ myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder));
myDone = aBuilder->IsDone() == Standard_True;
aResult = aBuilder->Shape();
// Fill data map to keep correct orientation of sub-shapes.
+ myMap.reset(new GeomAPI_DataMapOfShapeShape());
for(TopExp_Explorer anExp(aResult, 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);
}
- myMkShape->setImpl(aBuilder);
}
+ myShape.reset(new GeomAPI_Shape());
myShape->setImpl(new TopoDS_Shape(aResult));
}
GeomAlgoAPI_Transform::GeomAlgoAPI_Transform(std::shared_ptr<GeomAPI_Shape> theSourceShape,
std::shared_ptr<GeomAPI_Trsf> theTrsf)
: myDone(false),
- myTrsf(theTrsf),
- myShape(new GeomAPI_Shape()),
- myMap(new GeomAPI_DataMapOfShapeShape()),
- myMkShape(new GeomAlgoAPI_MakeShape())
+ myTrsf(theTrsf)
{
build(theSourceShape, theTrsf);
}
if(!aBuilder) {
return;
}
+ myMkShape.reset(new GeomAlgoAPI_MakeShape(aBuilder));
myDone = aBuilder->IsDone() == Standard_True;
if(!myDone) {
TopoDS_Shape aResult = aBuilder->Shape();
// Fill data map to keep correct orientation of sub-shapes.
+ myMap.reset(new GeomAPI_DataMapOfShapeShape());
for(TopExp_Explorer anExp(aResult, 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);
}
- myMkShape->setImpl(aBuilder);
+ myShape.reset(new GeomAPI_Shape());
myShape->setImpl(new TopoDS_Shape(aResult));
}
return true;
}
+ theError = "Not enough arguments";
return false;
}