// Build compound.
GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(anOriginalShapes);
// Copy shape.
- GeomAlgoAPI_Copy aCopyAlgo(aCompound);
- GeomShapePtr aCopyCompound = aCopyAlgo.shape();
+ GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aCompound));
+ GeomShapePtr aCopyCompound = aCopyAlgo->shape();
int anIndexToRemove = 0;
if (aCopyCompound) {
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = aCopyAlgo.mapOfSubShapes();
-
ResultBodyPtr aResultBody = document()->createBody(data(), anIndexToRemove++);
aResultBody->store(aCopyCompound);
- aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX,
- 1, "Modified_Vertex", *aMapOfShapes.get(),
- true, false, true);
- aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::EDGE,
- 100000, "Modified_Edge", *aMapOfShapes.get(),
- true, false, true);
- aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::FACE,
- 200000, "Modified_Face", *aMapOfShapes.get(),
- true, false, true);
+ aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX, "Modified_Vertex");
+ aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::EDGE, "Modified_Edge");
+ aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::FACE, "Modified_Face");
setResult(aResultBody);
}
removeResults(anIndexToRemove);
}
// Copy shape.
- GeomAlgoAPI_Copy aCopyAlgo(aShape);
+ GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aShape));
// Check that algo is done.
- if(!aCopyAlgo.isDone()) {
+ if(!aCopyAlgo->isDone()) {
setError("Error: " + getKind() + " algorithm failed.");
return;
}
// Check if shape is not null.
- if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) {
+ if(!aCopyAlgo->shape().get() || aCopyAlgo->shape()->isNull()) {
setError("Error: Resulting shape is null.");
return;
}
// Check that resulting shape is valid.
- if(!aCopyAlgo.isValid()) {
+ if(!aCopyAlgo->isValid()) {
setError("Error: Resulting shape is not valid.");
return;
}
// Store result.
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->storeModified(aShape, aCopyAlgo.shape());
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = aCopyAlgo.mapOfSubShapes();
- int aModVertexTag = 1;
- std::string aModVertexName = "Modified_Vertex";
- aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aShape, GeomAPI_Shape::VERTEX,
- aModVertexTag, aModVertexName, *aSubShapes.get(),
- true);
+ aResultBody->storeModified(aShape, aCopyAlgo->shape());
+ aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::VERTEX, "Modified_Vertex");
setResult(aResultBody, aResultIndex);
++aResultIndex;
ResultBodyPtr aResultBody = document()->createBody(data());
std::set<GeomShapePtr>::const_iterator aContextIt = aContexts.begin();
for (; aContextIt != aContexts.end(); aContextIt++) {
- aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin() ? 0 : -2);
+ aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin());
}
int aVertexIndex = 1;
for (GeomAPI_ShapeExplorer anExp(anEdge, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) {
ResultBodyPtr aResultBody = document()->createBody(data());
std::set<GeomShapePtr>::const_iterator aContextIt = aContexts.begin();
for (; aContextIt != aContexts.end(); aContextIt++) {
- aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin() ? 0 : -2);
+ aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin());
}
aPointsIt = aPoints.cbegin();
for (; anExp.more() && aPointsIt != aPoints.cend(); anExp.next(), ++aPointsIt) {
GeomShapePtr aPoint = *aPointsIt;
GeomShapePtr anEdge = anExp.current();
- aResultBody->generated(aPoint, anEdge, "Edge", 1);
+ aResultBody->generated(aPoint, anEdge, "Edge");
}
if (!isClosed) {
}
// Sew faces.
- GeomAlgoAPI_Sewing aSewingAlgo(aShapes);
+ GeomMakeShapePtr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes));
// Check that algo is done.
- if(!aSewingAlgo.isDone()) {
+ if(!aSewingAlgo->isDone()) {
setError("Error: " + getKind() + " algorithm failed.");
return;
}
// Check if shape is not null.
- if(!aSewingAlgo.shape().get() || aSewingAlgo.shape()->isNull()) {
+ if(!aSewingAlgo->shape().get() || aSewingAlgo->shape()->isNull()) {
setError("Error: Resulting shape is null.");
return;
}
// Check that resulting shape is valid.
- if(!aSewingAlgo.isValid()) {
+ if(!aSewingAlgo->isValid()) {
setError("Error: Resulting shape is not valid.");
return;
}
// Store result.
- GeomShapePtr aResult = aSewingAlgo.shape();
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = aSewingAlgo.mapOfSubShapes();
+ GeomShapePtr aResult = aSewingAlgo->shape();
int anIndex = 0;
for(GeomAPI_ShapeExplorer anExp(aResult, GeomAPI_Shape::SHELL); anExp.more(); anExp.next()) {
ResultBodyPtr aResultBody = document()->createBody(data(), anIndex);
aResultBody->store(aShell);
for(ListOfShape::const_iterator anIt = aShapes.cbegin(); anIt != aShapes.cend(); ++anIt) {
- for(GeomAPI_ShapeExplorer
- aFaceExp(*anIt, GeomAPI_Shape::FACE); aFaceExp.more(); aFaceExp.next()) {
+ for (GeomAPI_ShapeExplorer aFaceExp(*anIt, GeomAPI_Shape::FACE);
+ aFaceExp.more();
+ aFaceExp.next())
+ {
GeomShapePtr aFace = aFaceExp.current();
ListOfShape aHistory;
- aSewingAlgo.modified(aFace, aHistory);
- for(ListOfShape::const_iterator aHistoryIt = aHistory.cbegin();
- aHistoryIt != aHistory.cend();
- ++aHistoryIt) {
+ aSewingAlgo->modified(aFace, aHistory);
+ for (ListOfShape::const_iterator aHistoryIt = aHistory.cbegin();
+ aHistoryIt != aHistory.cend();
+ ++aHistoryIt)
+ {
GeomShapePtr aHistoryShape = *aHistoryIt;
- if(aMapOfShapes->isBound(aHistoryShape)) {
- aHistoryShape = aMapOfShapes->find(aHistoryShape);
- }
- if(aShell->isSubShape(aHistoryShape)) {
- aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::EDGE,
- 1, "Modified_Edge", *aMapOfShapes.get());
- aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::FACE,
- 2, "Modified_Face", *aMapOfShapes.get());
+ if (aShell->isSubShape(aHistoryShape, false)) {
+ aResultBody->loadModifiedShapes(aSewingAlgo,
+ aFace,
+ GeomAPI_Shape::EDGE,
+ "Modified_Edge");
+ aResultBody->loadModifiedShapes(aSewingAlgo,
+ aFace,
+ GeomAPI_Shape::FACE,
+ "Modified_Face");
break;
}
}
void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes,
const GeomShapePtr& theResultShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
+ const GeomMakeShapePtr& theAlgorithm)
{
ResultBodyPtr aResultBody = document()->createBody(data());
aResultBody->store(theResultShape);
// Store faces
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubs = theAlgorithm->mapOfSubShapes();
- int aModifiedTag = 1;
- for(ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
- anIt != theOriginalShapes.cend(); ++anIt) {
+ for (ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
+ anIt != theOriginalShapes.cend();
+ ++anIt)
+ {
GeomShapePtr aShape = *anIt;
- aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE,
- aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true);
+ aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::FACE, "Modified_Face");
}
setResult(aResultBody);
}
if(!aBaseShape.get()) {
return;
}
- GeomAlgoAPI_ShapeBuilder aBuilder;
- aBuilder.removeInternal(aBaseShape);
- GeomShapePtr aResultShape = aBuilder.shape();
+ std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder());
+ aBuilder->removeInternal(aBaseShape);
+ GeomShapePtr aResultShape = aBuilder->shape();
// Get list of shapes.
ListOfShape aShapesToAdd;
// Copy sub-shapes from list to new shape.
if(!aShapesToAdd.empty()) {
- aBuilder.addInternal(aResultShape, aShapesToAdd);
- aResultShape = aBuilder.shape();
+ aBuilder->addInternal(aResultShape, aShapesToAdd);
+ aResultShape = aBuilder->shape();
}
// Store result.
const int aModEdgeTag = 2;
ResultBodyPtr aResultBody = document()->createBody(data());
aResultBody->storeModified(aBaseShape, aResultShape);
- aResultBody->loadAndOrientModifiedShapes(&aBuilder, aBaseShape, GeomAPI_Shape::EDGE, aModEdgeTag,
- "Modified_Edge", *aBuilder.mapOfSubShapes().get());
- for(ListOfShape::const_iterator
- anIt = aShapesToAdd.cbegin(); anIt != aShapesToAdd.cend(); ++anIt) {
+ aResultBody->loadModifiedShapes(aBuilder, aBaseShape, GeomAPI_Shape::EDGE, "Modified_Edge");
+ for (ListOfShape::const_iterator anIt = aShapesToAdd.cbegin();
+ anIt != aShapesToAdd.cend();
+ ++anIt)
+ {
GeomAPI_Shape::ShapeType aShType = (*anIt)->shapeType();
- aResultBody->loadAndOrientModifiedShapes(&aBuilder, *anIt, aShType,
- aShType == GeomAPI_Shape::VERTEX ? aModVertexTag : aModEdgeTag,
- aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex" : "Modified_Edge",
- *aBuilder.mapOfSubShapes().get());
+ aResultBody->loadModifiedShapes(aBuilder,
+ *anIt,
+ aShType,
+ aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex"
+ : "Modified_Edge");
}
setResult(aResultBody);
}
std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
ListOfShape aListWithObject;
aListWithObject.push_back(anObject);
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
GeomShapePtr aResShape;
std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
new GeomAlgoAPI_MakeShapeCustom);
aMkShCustom->addModified(aPlane, aTool);
- aMakeShapeList.appendAlgo(aMkShCustom);
+ aMakeShapeList->appendAlgo(aMkShCustom);
aToolsWithPlanes.push_back(aTool);
}
return;
}
- aMakeShapeList.appendAlgo(aBoolAlgo);
+ aMakeShapeList->appendAlgo(aBoolAlgo);
if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27
|| (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON))
aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end());
}
- loadNamingDS(aResultBody, anObject, aUsedTools, aResShape,
- aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()),
- myOperationType == BOOL_FILL);
+ loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, aMakeShapeList);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
}
}
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
switch(myOperationType) {
std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
new GeomAlgoAPI_MakeShapeCustom);
aMkShCustom->addModified(aPlane, aTool);
- aMakeShapeList.appendAlgo(aMkShCustom);
+ aMakeShapeList->appendAlgo(aMkShCustom);
aToolsWithPlanes.push_back(aTool);
}
return;
}
- aMakeShapeList.appendAlgo(aBoolAlgo);
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
- aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aBoolAlgo);
GeomShapePtr aResultShape = aBoolAlgo->shape();
// Add result to not used solids from compsolid.
return;
}
- aMakeShapeList.appendAlgo(aFillerAlgo);
- aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aFillerAlgo);
aResultShape = aFillerAlgo->shape();
}
aCompSolid,
aUsedTools,
aResultShape,
- aMakeShapeList,
- aMapOfShapes,
- myOperationType == BOOL_FILL);
+ aMakeShapeList);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end());
// Cut edges and faces(if we have any) with solids.
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::shared_ptr<GeomAPI_Shape> aCuttedEdgesAndFaces;
if(!anEdgesAndFaces.empty()) {
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT));
if(aCutAlgo->isDone()) {
aCuttedEdgesAndFaces = aCutAlgo->shape();
- aMakeShapeList.appendAlgo(aCutAlgo);
- aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aCutAlgo);
}
}
anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(),
if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) {
aSolidsToFuse.push_back(aCutAlgo->shape());
- aMakeShapeList.appendAlgo(aCutAlgo);
- aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aCutAlgo);
}
}
}
}
aShape = aFuseAlgo->shape();
- aMakeShapeList.appendAlgo(aFuseAlgo);
- aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aFuseAlgo);
}
// Combine result with not used solids from compsolid and edges and faces (if we have any).
}
aShape = aFillerAlgo->shape();
- aMakeShapeList.appendAlgo(aFillerAlgo);
- aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aFillerAlgo);
}
std::shared_ptr<GeomAPI_Shape> aBackShape = anOriginalShapes.back();
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
loadNamingDS(aResultBody, aBackShape, anOriginalShapes,
- aShape, aMakeShapeList, aMapOfShapes);
+ aShape, aMakeShapeList);
setResult(aResultBody, aResultIndex);
aResultIndex++;
break;
}
}
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList;
GeomAPI_DataMapOfShapeShape aMapOfShapes;
if(!aShapesToAdd.empty()) {
// Cut objects with not used solids.
if(GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) {
aShapesToSmash.clear();
aShapesToSmash.push_back(anObjectsCutAlgo->shape());
- aMakeShapeList.appendAlgo(anObjectsCutAlgo);
+ aMakeShapeList->appendAlgo(anObjectsCutAlgo);
aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes());
}
if(GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) {
aTools.clear();
aTools.push_back(aToolsCutAlgo->shape());
- aMakeShapeList.appendAlgo(aToolsCutAlgo);
+ aMakeShapeList->appendAlgo(aToolsCutAlgo);
aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes());
}
}
setError(aFeatureError);
return;
}
- aMakeShapeList.appendAlgo(aBoolAlgo);
+ aMakeShapeList->appendAlgo(aBoolAlgo);
aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
// Put all (cut result, tools and not used solids) to PaveFiller.
}
std::shared_ptr<GeomAPI_Shape> aShape = aFillerAlgo->shape();
- aMakeShapeList.appendAlgo(aFillerAlgo);
+ aMakeShapeList->appendAlgo(aFillerAlgo);
aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
std::shared_ptr<GeomAPI_Shape> aFrontShape = anOriginalShapes.front();
anOriginalShapes.pop_front();
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, aFrontShape, anOriginalShapes,
- aShape, aMakeShapeList, aMapOfShapes);
+ loadNamingDS(aResultBody, aFrontShape, anOriginalShapes, aShape, aMakeShapeList);
setResult(aResultBody, aResultIndex);
aResultIndex++;
const std::shared_ptr<GeomAPI_Shape> theBaseShape,
const ListOfShape& theTools,
const std::shared_ptr<GeomAPI_Shape> theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes,
- const bool theIsStoreAsGenerated)
+ const GeomMakeShapePtr& theMakeShape)
{
//load result
if(theBaseShape->isEqual(theResultShape)) {
theResultBody->store(theResultShape, false);
- } else {
- const int aModifyTag = 1;
- const int aModifyEdgeTag = 2;
- const int aModifyFaceTag = 3;
- const int aDeletedTag = 4;
- /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
- const int aSubsolidsTag = 5;
-
- theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
- const std::string aModName = "Modified";
- const std::string aModEName = "Modified_Edge";
- const std::string aModFName = "Modified_Face";
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
- aModifyEdgeTag, aModEName, theMapOfShapes, false, theIsStoreAsGenerated, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
- aModifyFaceTag, aModFName, theMapOfShapes, false, theIsStoreAsGenerated, true);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::FACE, aDeletedTag);
-
- int aTag;
- std::string aName;
- for(ListOfShape::const_iterator
- anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
- if((*anIter)->shapeType() <= GeomAPI_Shape::FACE) {
- aTag = aModifyFaceTag;
- aName = aModFName;
- } else {
- aTag = aModifyEdgeTag;
- aName = aModEName;
- }
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter,
- aName == aModEName ? GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE,
- aTag, aName, theMapOfShapes, false, theIsStoreAsGenerated, true);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
- }
+ return;
+ }
+
+ theResultBody->storeModified(theBaseShape, theResultShape);
+
+ const std::string aModEName = "Modified_Edge";
+ const std::string aModFName = "Modified_Face";
+
+ theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, aModEName);
+ theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aModFName);
+
+ theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
+
+ std::string aName;
+ for (ListOfShape::const_iterator anIter = theTools.begin();
+ anIter != theTools.end();
+ ++anIter)
+ {
+ aName = (*anIter)->shapeType() <= GeomAPI_Shape::FACE ? aModFName
+ : aModEName;
+ theResultBody->loadModifiedShapes(theMakeShape,
+ *anIter,
+ aName == aModEName ? GeomAPI_Shape::EDGE
+ : GeomAPI_Shape::FACE,
+ aName);
+
+ theResultBody->loadDeletedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);
}
}
const std::shared_ptr<GeomAPI_Shape> theBaseShape,
const ListOfShape& theTools,
const std::shared_ptr<GeomAPI_Shape> theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes,
- const bool theIsStoreAsGenerated = false);
+ const GeomMakeShapePtr& theMakeShape);
private:
OperationType myOperationType;
#include "FeaturesPlugin_BooleanCommon.h"
+#include "FeaturesPlugin_Tools.h"
+
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
}
int aResultIndex = 0;
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
+ std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+ ListOfShape aResultShapesList;
if (isSimpleMode)
{
}
aShape = aCommonAlgo->shape();
- aMakeShapeList.appendAlgo(aCommonAlgo);
- aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aCommonAlgo);
}
GeomAPI_ShapeIterator aShapeIt(aShape);
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, anObjects.front(), anObjects, aShape, aMakeShapeList, aMapOfShapes);
+ GeomShapePtr aBaseShape = anObjects.front();
+ anObjects.pop_front();
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBaseShape,
+ anObjects,
+ aMakeShapeList,
+ aShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ aTools = anObjects;
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = aBaseShape;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aShape);
}
} else {
for (ListOfShape::iterator anObjectsIt = anObjects.begin();
std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
ListOfShape aListWithObject;
aListWithObject.push_back(anObject);
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
GeomShapePtr aResShape;
std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
new GeomAlgoAPI_MakeShapeCustom);
aMkShCustom->addModified(aPlane, aTool);
- aMakeShapeList.appendAlgo(aMkShCustom);
+ aMakeShapeList->appendAlgo(aMkShCustom);
aToolsWithPlanes.push_back(aTool);
}
return;
}
- aMakeShapeList.appendAlgo(aBoolAlgo);
+ aMakeShapeList->appendAlgo(aBoolAlgo);
GeomAPI_ShapeIterator aShapeIt(aResShape);
if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, anObject, aTools, aResShape,
- aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()));
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ anObject,
+ aTools,
+ aMakeShapeList,
+ aResShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = anObject;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResShape);
}
}
}
aMakeShapeList->appendAlgo(aCommonAlgo);
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
- aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes());
GeomShapePtr aResultShape = aCommonAlgo->shape();
// Add result to not used solids from compsolid.
}
aMakeShapeList->appendAlgo(aFillerAlgo);
- aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
aResultShape = aFillerAlgo->shape();
}
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody,
- aCompSolid,
- aTools,
- aResultShape,
- *aMakeShapeList,
- aMapOfShapes);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aCompSolid,
+ aTools,
+ aMakeShapeList,
+ aResultShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = aCompSolid;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResultShape);
}
}
}
aMakeShapeList->appendAlgo(aCommonAlgo);
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
- aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes());
GeomShapePtr aResultShape = aCommonAlgo->shape();
// Add result to not used shape from compound.
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody,
- aCompound,
- aTools,
- aResultShape,
- *aMakeShapeList,
- aMapOfShapes);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aCompound,
+ aTools,
+ aMakeShapeList,
+ aResultShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+ aRBA.resultBody = aResultBody;
+ aRBA.baseShape = aCompound;
+ aRBA.makeShape = aMakeShapeList;
+ aResultBaseAlgoList.push_back(aRBA);
+ aResultShapesList.push_back(aResultShape);
}
}
}
+ // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
+ // result shape has been deleted, but in another it was modified or stayed.
+ GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
+ FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
+
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
-
-//==================================================================================================
-void FeaturesPlugin_BooleanCommon::loadNamingDS(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes)
-{
- //load result
- if (theBaseShape->isEqual(theResultShape)) {
- theResultBody->store(theResultShape, false);
- } else {
- const int aModifyVTag = 1;
- const int aModifyETag = 2;
- const int aModifyFTag = 3;
- const int aDeletedTag = 4;
- /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
- const int aSubsolidsTag = 5;
-
- theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
- const std::string aModVName = "Modified_Vertex";
- const std::string aModEName = "Modified_Edge";
- const std::string aModFName = "Modified_Face";
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
- false, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
- false, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::FACE, aDeletedTag);
-
- for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
- {
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
- }
- }
-}
/// Use plugin manager for features creation.
FeaturesPlugin_BooleanCommon();
-
-private:
-
- /// Load Naming data structure of the feature to the document
- void loadNamingDS(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes);
-
};
#endif
#include "FeaturesPlugin_BooleanCut.h"
+#include "FeaturesPlugin_Tools.h"
+
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Tools.h>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
-//==================================================================================================
-const int ModifyVTag = 1;
-const int ModifyETag = 2;
-const int ModifyFTag = 3;
-const int DeletedTag = 4;
-/// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
-const int SubsolidsTag = 5;
-
-
//==================================================================================================
FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut()
: FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_CUT)
return;
}
- std::vector<ResultBaseAlgo> aResultBaseAlgoList;
+ std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
ListOfShape aResultShapesList;
// For solids cut each object with all tools.
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, anObject, aTools, aResShape,
- *aMakeShapeList, *(aCutAlgo->mapOfSubShapes()),
- false);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ anObject,
+ aTools,
+ aMakeShapeList,
+ aResShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
- ResultBaseAlgo aRBA;
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
aRBA.resultBody = aResultBody;
aRBA.baseShape = anObject;
aRBA.makeShape = aMakeShapeList;
}
aMakeShapeList->appendAlgo(aCutAlgo);
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
- aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
GeomShapePtr aResultShape = aCutAlgo->shape();
// Add result to not used solids from compsolid.
}
aMakeShapeList->appendAlgo(aFillerAlgo);
- aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
aResultShape = aFillerAlgo->shape();
}
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody,
- aCompSolid,
- aTools,
- aResultShape,
- *aMakeShapeList,
- aMapOfShapes,
- false);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aCompSolid,
+ aTools,
+ aMakeShapeList,
+ aResultShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
- ResultBaseAlgo aRBA;
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
aRBA.resultBody = aResultBody;
aRBA.baseShape = aCompSolid;
aRBA.makeShape = aMakeShapeList;
}
aMakeShapeList->appendAlgo(aCutAlgo);
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
- aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
GeomShapePtr aResultShape = aCutAlgo->shape();
// Add result to not used shape from compound.
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody,
- aCompound,
- aTools,
- aResultShape,
- *aMakeShapeList,
- aMapOfShapes,
- false);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aCompound,
+ aTools,
+ aMakeShapeList,
+ aResultShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
- ResultBaseAlgo aRBA;
+ FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
aRBA.resultBody = aResultBody;
aRBA.baseShape = aCompound;
aRBA.makeShape = aMakeShapeList;
// Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
// result shape has been deleted, but in another it was modified or stayed.
GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
- storeDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
+ FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound);
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
-
-//==================================================================================================
-void FeaturesPlugin_BooleanCut::loadNamingDS(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes,
- const bool theIsStoreAsGenerated)
-{
- //load result
- if(theBaseShape->isEqual(theResultShape)) {
- theResultBody->store(theResultShape, false);
- } else {
- theResultBody->storeModified(theBaseShape, theResultShape, SubsolidsTag);
-
- const std::string aModVName = "Modified_Vertex";
- const std::string aModEName = "Modified_Edge";
- const std::string aModFName = "Modified_Face";
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
- ModifyVTag, aModVName, theMapOfShapes, false,
- theIsStoreAsGenerated, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
- ModifyETag, aModEName, theMapOfShapes, false,
- theIsStoreAsGenerated, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
- ModifyFTag, aModFName, theMapOfShapes, false,
- theIsStoreAsGenerated, true);
-
- for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
- {
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
- ModifyVTag, aModVName, theMapOfShapes, false,
- theIsStoreAsGenerated, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
- ModifyETag, aModEName, theMapOfShapes, false,
- theIsStoreAsGenerated, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
- ModifyFTag, aModFName, theMapOfShapes, false,
- theIsStoreAsGenerated, true);
- }
- }
-}
-
-//==================================================================================================
-void FeaturesPlugin_BooleanCut::storeDeletedShapes(
- std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShapesCompound)
-{
- for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
- anIt != theResultBaseAlgoList.end();
- ++anIt)
- {
- ResultBaseAlgo& aRCA = *anIt;
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
- aRCA.baseShape,
- GeomAPI_Shape::VERTEX,
- DeletedTag,
- theResultShapesCompound);
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
- aRCA.baseShape,
- GeomAPI_Shape::EDGE,
- DeletedTag,
- theResultShapesCompound);
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
- aRCA.baseShape,
- GeomAPI_Shape::FACE,
- DeletedTag,
- theResultShapesCompound);
-
- for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
- {
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
- *anIter,
- GeomAPI_Shape::VERTEX,
- DeletedTag,
- theResultShapesCompound);
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
- *anIter,
- GeomAPI_Shape::EDGE,
- DeletedTag,
- theResultShapesCompound);
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
- *anIter,
- GeomAPI_Shape::FACE,
- DeletedTag,
- theResultShapesCompound);
- }
- }
-}
/// Use plugin manager for features creation.
FeaturesPlugin_BooleanCut();
-private:
-
- struct ResultBaseAlgo {
- ResultBodyPtr resultBody;
- GeomShapePtr baseShape;
- std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape;
- };
-
-private:
-
- /// Load Naming data structure of the feature to the document
- void loadNamingDS(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes,
- const bool theIsStoreAsGenerated = false);
-
- /// Stores deleted shapes.
- void storeDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShapesCompound);
-
};
#endif
#include "FeaturesPlugin_BooleanFuse.h"
+#include "FeaturesPlugin_Tools.h"
+
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeBoolean.h>
#include <ModelAPI_AttributeSelectionList.h>
void FeaturesPlugin_BooleanFuse::execute()
{
ListOfShape anObjects, aTools, anEdgesAndFaces;
- std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
+ std::map<GeomShapePtr, ListOfShape> aCompSolidsObjects;
bool isSimpleCreation = false;
AttributeStringPtr aCreationMethodAttr = string(CREATION_METHOD());
if (aCreationMethodAttr.get()
- && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE()) {
+ && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE())
+ {
isSimpleCreation = true;
}
selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
- std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
+ GeomShapePtr anObject = anObjectAttr->value();
if (!anObject.get()) {
return;
}
ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if (!isSimpleCreation
&& aResCompSolidPtr.get()
- && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) {
- std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
- std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
+ && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID)
+ {
+ GeomShapePtr aContextShape = aResCompSolidPtr->shape();
+ std::map<GeomShapePtr, ListOfShape>::iterator
anIt = aCompSolidsObjects.begin();
for (; anIt != aCompSolidsObjects.end(); anIt++) {
if (anIt->first->isEqual(aContextShape)) {
// Collecting solids from compsolids which will not be modified
// in boolean operation and will be added to result.
ListOfShape aShapesToAdd;
- 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;
+ for (std::map<GeomShapePtr, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
+ anIt != aCompSolidsObjects.end();
+ ++anIt)
+ {
+ GeomShapePtr 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();
+ GeomShapePtr aSolidInCompSolid = anExp.current();
ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
for (; anIt != aUsedInOperationSolids.end(); anIt++) {
if (aSolidInCompSolid->isEqual(*anIt)) {
anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end());
// Cut edges and faces(if we have any) with solids.
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
- std::shared_ptr<GeomAPI_Shape> aCuttedEdgesAndFaces;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
+ GeomShapePtr aCuttedEdgesAndFaces;
if (!anEdgesAndFaces.empty()) {
std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT));
if (aCutAlgo->isDone()) {
aCuttedEdgesAndFaces = aCutAlgo->shape();
- aMakeShapeList.appendAlgo(aCutAlgo);
- aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aCutAlgo);
}
}
anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(),
if (GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) {
aSolidsToFuse.push_back(aCutAlgo->shape());
- aMakeShapeList.appendAlgo(aCutAlgo);
- aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aCutAlgo);
}
}
}
}
// Fuse all objects and all tools.
- std::shared_ptr<GeomAPI_Shape> aShape;
+ GeomShapePtr aShape;
if (anObjects.size() == 1 && aTools.empty()) {
aShape = anObjects.front();
} else if (anObjects.empty() && aTools.size() == 1) {
}
aShape = aFuseAlgo->shape();
- aMakeShapeList.appendAlgo(aFuseAlgo);
- aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aFuseAlgo);
}
// Combine result with not used solids from compsolid and edges and faces (if we have any).
}
aShape = aFillerAlgo->shape();
- aMakeShapeList.appendAlgo(aFillerAlgo);
- aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aFillerAlgo);
}
bool isRemoveEdges = false;
}
aShape = aUnifyAlgo->shape();
- aMakeShapeList.appendAlgo(aUnifyAlgo);
- aMapOfShapes.merge(aUnifyAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aUnifyAlgo);
}
int aResultIndex = 0;
- std::shared_ptr<GeomAPI_Shape> aBackShape = anOriginalShapes.back();
+ GeomShapePtr aBackShape = anOriginalShapes.back();
anOriginalShapes.pop_back();
- std::shared_ptr<ModelAPI_ResultBody> aResultBody =
- document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, aBackShape, anOriginalShapes,
- aShape, aMakeShapeList, aMapOfShapes);
+ ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBackShape,
+ anOriginalShapes,
+ aMakeShapeList,
+ aShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+ FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
+ aBackShape,
+ anOriginalShapes,
+ aMakeShapeList,
+ aShape);
+
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
-
-//==================================================================================================
-void FeaturesPlugin_BooleanFuse::loadNamingDS(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes)
-{
- //load result
- if (theBaseShape->isEqual(theResultShape)) {
- theResultBody->store(theResultShape, false);
- } else {
- const int aModifyVTag = 1;
- const int aModifyETag = 2;
- const int aModifyFTag = 3;
- const int aDeletedTag = 4;
- /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
- const int aSubsolidsTag = 5;
-
- theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
- const std::string aModVName = "Modified_Vertex";
- const std::string aModEName = "Modified_Edge";
- const std::string aModFName = "Modified_Face";
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
- false, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
- false, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::FACE, aDeletedTag);
-
- for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
- {
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
- false, true);
-
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
- }
- }
-}
/// Use plugin manager for features creation.
FeaturesPlugin_BooleanFuse();
-
-private:
- /// Load Naming data structure of the feature to the document
- void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const std::shared_ptr<GeomAPI_Shape> theBaseShape,
- const ListOfShape& theTools,
- const std::shared_ptr<GeomAPI_Shape> theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes);
};
#endif
#include "FeaturesPlugin_BooleanSmash.h"
+#include "FeaturesPlugin_Tools.h"
+
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Tools.h>
}
}
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
- GeomAPI_DataMapOfShapeShape aMapOfShapes;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
if (!aShapesToAdd.empty()) {
// Cut objects with not used solids.
std::shared_ptr<GeomAlgoAPI_Boolean> anObjectsCutAlgo(
if (GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) {
aShapesToSmash.clear();
aShapesToSmash.push_back(anObjectsCutAlgo->shape());
- aMakeShapeList.appendAlgo(anObjectsCutAlgo);
- aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(anObjectsCutAlgo);
}
// Cut tools with not used solids.
if (GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) {
aTools.clear();
aTools.push_back(aToolsCutAlgo->shape());
- aMakeShapeList.appendAlgo(aToolsCutAlgo);
- aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aToolsCutAlgo);
}
}
setError(aFeatureError);
return;
}
- aMakeShapeList.appendAlgo(aBoolAlgo);
- aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aBoolAlgo);
// Put all (cut result, tools and not used solids) to PaveFiller.
GeomShapePtr aShape = aBoolAlgo->shape();
}
aShape = aFillerAlgo->shape();
- aMakeShapeList.appendAlgo(aFillerAlgo);
- aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
+ aMakeShapeList->appendAlgo(aFillerAlgo);
}
std::shared_ptr<GeomAPI_Shape> aFrontShape = anOriginalShapes.front();
anOriginalShapes.pop_front();
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody,
- aFrontShape,
- anOriginalShapes,
- aShape,
- aMakeShapeList,
- aMapOfShapes);
+
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aFrontShape,
+ anOriginalShapes,
+ aMakeShapeList,
+ aShape);
setResult(aResultBody, aResultIndex);
aResultIndex++;
+ FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
+ aFrontShape,
+ anOriginalShapes,
+ aMakeShapeList,
+ aShape);
+
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
-
-//==================================================================================================
-void FeaturesPlugin_BooleanSmash::loadNamingDS(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes)
-{
- //load result
- if (theBaseShape->isEqual(theResultShape)) {
- theResultBody->store(theResultShape, false);
- } else if (theResultShape->isEqual(theTools.front())) {
- theResultBody->store(theResultShape, false);
- } else {
- const int aModifyVTag = 1;
- const int aModifyETag = 2;
- const int aModifyFTag = 3;
- const int aDeletedTag = 4;
- /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids
- const int aSubsolidsTag = 5;
-
- theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-
- const std::string aModVName = "Modified_Vertex";
- const std::string aModEName = "Modified_Edge";
- const std::string aModFName = "Modified_Face";
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
- true, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
- true, true);
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
- true, true);
-
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
- GeomAPI_Shape::FACE, aDeletedTag);
-
- for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
- {
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX,
- aModifyVTag, aModVName, theMapOfShapes, false,
- true, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE,
- aModifyETag, aModEName, theMapOfShapes, false,
- true, true);
-
- theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
- aModifyFTag, aModFName, theMapOfShapes, false,
- true, true);
-
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
- }
- }
-}
/// Use plugin manager for features creation.
FeaturesPlugin_BooleanSmash();
-
-private:
-
- /// Load Naming data structure of the feature to the document
- void loadNamingDS(ResultBodyPtr theResultBody,
- const GeomShapePtr theBaseShape,
- const ListOfShape& theTools,
- const GeomShapePtr theResultShape,
- GeomAlgoAPI_MakeShape& theMakeShape,
- GeomAPI_DataMapOfShapeShape& theMapOfShapes);
-
};
#endif
}
else
{
- aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape(), aTag);
+ aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape());
aTag += 5000;
ListOfShape aTools = theTools;
aTools.push_back(theObject);
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMap = theMakeShape->mapOfSubShapes();
-
- int aTag;
std::string aName;
for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) {
if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) {
- aTag = anEdgesAndFacesTag;
aName = aModName + "_Edge";
}
else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) {
- aTag = anEdgesAndFacesTag;
aName = aModName + "_Face";
} else {
- aTag = aModTag;
aName = aModName;
}
- theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt,
- (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
- GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get(), false, false, true);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIt,
+ (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
+ GeomAPI_Shape::EDGE :
+ GeomAPI_Shape::FACE,
+ aName);
}
}
++anIt)
{
ResultBaseAlgo& aRCA = *anIt;
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
aRCA.baseShape,
GeomAPI_Shape::FACE,
- aRCA.delTag,
theResultShapesCompound);
for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
{
- aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+ aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
*anIter,
GeomAPI_Shape::FACE,
- aRCA.delTag,
theResultShapesCompound);
}
}
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = theMakeShape->mapOfSubShapes();
- const int aDeletedTag = 1;
- const int aModifyTag = 2;
const int aGeneratedTag = 3;
- /// sub solids will be placed at labels 4, 5, etc. if result is compound of solids
- const int aSubsolidsTag = 4;
- theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
+ theResultBody->storeModified(theBaseShape, theResultShape);
const std::string aModFaceName = "Modified_Face";
const std::string aFilletFaceName = "Fillet_Face";
// Store modified faces
- theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), theBaseShape,
- GeomAPI_Shape::FACE, aModifyTag, aModFaceName, *aMapOfShapes);
+ theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aModFaceName);
// Store new faces generated from edges and vertices
theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape,
GeomAPI_Shape::VERTEX, aGeneratedTag, aFilletFaceName, *aMapOfShapes);
// Deleted shapes
- theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape,
- GeomAPI_Shape::EDGE, aDeletedTag);
- theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape,
- GeomAPI_Shape::FACE, aDeletedTag);
+ theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
+ theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
}
} else {
aResultBody->storeModified(aBaseShape, aResultShape);
- const int aModifyEdgeTag = 1;
- const int aModifyFaceTag = 2;
const std::string aModEName = "Modified_Edge";
const std::string aModFName = "Modified_Face";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = anAlgo->mapOfSubShapes();
- aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::EDGE,
- aModifyEdgeTag, aModEName, *aMapOfShapes.get(), true);
- aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::FACE,
- aModifyFaceTag, aModFName, *aMapOfShapes.get(), true);
+ aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::EDGE, aModEName);
+ aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::FACE, aModFName);
}
setResult(aResultBody);
}
std::string("Modified_")
+ (anIndex == 0 ? "Vertex_" : "Edge_")
+ std::to_string((long long)(anIndex == 0 ? aModifiedVertexIndex++
- : aModifiedEdgeIndex++)),
- aTag++);
+ : aModifiedEdgeIndex++)));
} else {
theResultBody->generated(
aSubShape,
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
std::shared_ptr<GeomAPI_Shape> theBaseShape)
{
- int aTag = 1;
- int anIndex = 1;
- std::string aRotatedName;
-
for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
- std::cout << "LOAD" << std::endl;
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
-
// naming of faces
- aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
- aTag++, aRotatedName, *aSubShapes.get(),
- false, true);
+ theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face");
// naming of edges
- aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
- aTag++, aRotatedName, *aSubShapes.get(),
- false, true);
+ theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge");
// naming of vertex
- aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
- aTag++, aRotatedName, *aSubShapes.get(),
- false, true);
-
- ++anIndex;
+ theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex");
}
}
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
std::shared_ptr<GeomAPI_Shape> theBaseShape)
{
- int aTag = 1;
- int anIndex = 1;
- std::string aRotatedName;
-
for (std::list<std::shared_ptr<GeomAlgoAPI_Rotation> >::const_iterator anIt =
theListOfRotationAlgo.begin(); anIt != theListOfRotationAlgo.cend(); ++anIt) {
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
-
// naming of faces
- aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
- aTag++, aRotatedName, *aSubShapes.get(),
- false, true);
+ theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face");
// naming of edges
- aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
- aTag++, aRotatedName, *aSubShapes.get(),
- false, true);
+ theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge");
// naming of vertex
- aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
- aTag++, aRotatedName, *aSubShapes.get(),
- false, true);
- ++anIndex;
+ theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex");
}
}
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
std::shared_ptr<GeomAPI_Shape> theBaseShape)
{
- int aTag = 1;
- int anIndex = 1;
- std::string aTranslatedName;
-
for (std::list<std::shared_ptr<GeomAlgoAPI_Translation> >::const_iterator anIt =
theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) {
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = (*anIt)->mapOfSubShapes();
-
// naming of faces
- aTranslatedName = "Translated_Face_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE,
- aTag++, aTranslatedName, *aSubShapes.get(),
- false, true);
+ theResultBody->loadModifiedShapes(*anIt,
+ theBaseShape,
+ GeomAPI_Shape::FACE,
+ "Translated_Face");
// naming of edges
- aTranslatedName = "Translated_Edge_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE,
- aTag++, aTranslatedName, *aSubShapes.get(),
- false, true);
+ theResultBody->loadModifiedShapes(*anIt,
+ theBaseShape,
+ GeomAPI_Shape::EDGE,
+ "Translated_Edge");
// naming of vertex
- aTranslatedName = "Translated_Vertex_" + std::to_string((long long) anIndex);
- theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX,
- aTag++, aTranslatedName, *aSubShapes.get(),
- false, true);
-
- ++anIndex;
+ theResultBody->loadModifiedShapes(*anIt,
+ theBaseShape,
+ GeomAPI_Shape::VERTEX,
+ "Translated_Vertex");
}
}
return;
}
- const int aDelTag = 1;
- /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
- const int aSubTag = 2;
- int aModTag = aSubTag + 10000;
- const std::string aModName = "Modified";
-
- aResultBody->storeModified(aBaseShape, theResultShape, aSubTag);
+ aResultBody->storeModified(aBaseShape, theResultShape);
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = theMakeShape->mapOfSubShapes();
theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end());
- int anIndex = 1;
- for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) {
+ for (ListOfShape::const_iterator anIt = theObjects.cbegin();
+ anIt != theObjects.cend();
+ ++anIt)
+ {
GeomShapePtr aShape = *anIt;
- std::string aModEdgeName = aModName + "_Edge_" + std::to_string((long long)anIndex);
- aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::EDGE,
- aModTag, aModEdgeName, *aMapOfSubShapes.get(), false, true, true);
- std::string aModFaceName = aModName + "_Face_" + std::to_string((long long)anIndex++);
- aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE,
- aModTag + 1, aModFaceName, *aMapOfSubShapes.get(), false, true, true);
- aResultBody->loadDeletedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, aDelTag);
+ aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::EDGE, "Modified_Edge");
+ aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE, "Modified_Face");
+ aResultBody->loadDeletedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE);
}
setResult(aResultBody, theIndex);
thePipeAlgo.generated(aV1, aV1History);
thePipeAlgo.generated(aV2, aV2History);
if(!aV1History.empty()) {
- aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++);
+ aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1");
}
if(!aV2History.empty()) {
- aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++);
+ aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2");
}
}
case GeomAPI_Shape::FACE:
ListOfShape aV1History, aV2History;
thePipeAlgo.generated(aV1, aV1History);
thePipeAlgo.generated(aV2, aV2History);
- aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++);
- aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++);
+ aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1");
+ aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2");
}
case GeomAPI_Shape::FACE:
case GeomAPI_Shape::SHELL: {
setResult(aResultPart, aResultIndex);
} else {
std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
- GeomAlgoAPI_Transform aTransformAlgo(aBaseShape, aTrsf);
+ std::shared_ptr<GeomAlgoAPI_Transform> aTransformAlgo(new GeomAlgoAPI_Transform(aBaseShape,
+ aTrsf));
// Checking that the algorithm worked properly.
- if(!aTransformAlgo.isDone()) {
+ if(!aTransformAlgo->isDone()) {
static const std::string aFeatureError = "Error: Transform algorithm failed.";
setError(aFeatureError);
break;
}
- if(aTransformAlgo.shape()->isNull()) {
+ if(aTransformAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aTransformAlgo.isValid()) {
+ if(!aTransformAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
//LoadNamingDS
- std::shared_ptr<ModelAPI_ResultBody> aResultBody =
- document()->createBody(data(), aResultIndex);
- loadNamingDS(aTransformAlgo, aResultBody, aBaseShape);
+ ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+ aResultBody->storeModified(aBaseShape, aTransformAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aTransformAlgo, "Placed");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
// Remove the rest results if there were produced in the previous pass.
removeResults(aResultIndex);
}
-
-//============================================================================
-void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- //load result
- theResultBody->storeModified(theBaseShape, theTransformAlgo.shape());
-
- std::string aPlacedName = "Placed";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTransformAlgo.mapOfSubShapes();
-
- FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody,
- theBaseShape, 1, 2, 3, aPlacedName,
- *aSubShapes.get());
-}
/// Use plugin manager for features creation
FeaturesPlugin_Placement();
-private:
- /// Load Naming data structure of the feature to the document
- void loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif
aResultShape = anAttrSelectionInList->value();
}
// deleted and copied must be jointed to one list which keeps all the history
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
// find all removed shapes
std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aDeletedSubs(new GeomAlgoAPI_MakeShapeCustom);
}
}
}
- aMakeShapeList.appendAlgo(aDeletedSubs);
+ aMakeShapeList->appendAlgo(aDeletedSubs);
std::shared_ptr<GeomAlgoAPI_Copy> aCopy(new GeomAlgoAPI_Copy(aResultShape));
aResultShape = aCopy->shape();
- aMakeShapeList.appendAlgo(aCopy);
+ aMakeShapeList->appendAlgo(aCopy);
if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
aResultShape = GeomAlgoAPI_ShapeTools::groupSharedTopology(aResultShape);
// Store result.
ResultBodyPtr aResultBody = document()->createBody(data());
- aResultBody->storeModified(aBaseShape, aResultShape, 1);
- std::set<GeomAPI_Shape::ShapeType>::iterator aTypeIter = aTypes.begin();
- for(; aTypeIter != aTypes.end(); aTypeIter++)
- aResultBody->loadDeletedShapes(&aMakeShapeList, aBaseShape, *aTypeIter, 1);
- aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::FACE,
- 2, "Modified_Face", *aMakeShapeList.mapOfSubShapes().get(), true, false, true);
- aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::EDGE,
- 3, "Modified_Edge", *aMakeShapeList.mapOfSubShapes().get(), false, false, true);
- aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::VERTEX,
- 4, "Modified_Vertex", *aMakeShapeList.mapOfSubShapes().get());
+ aResultBody->storeModified(aBaseShape, aResultShape);
+ for (std::set<GeomAPI_Shape::ShapeType>::iterator aTypeIter = aTypes.begin();
+ aTypeIter != aTypes.end();
+ ++aTypeIter)
+ {
+ aResultBody->loadDeletedShapes(aMakeShapeList, aBaseShape, *aTypeIter);
+ }
+
+ aResultBody->loadModifiedShapes(aMakeShapeList,
+ aBaseShape,
+ GeomAPI_Shape::FACE,
+ "Modified_Face");
+ aResultBody->loadModifiedShapes(aMakeShapeList,
+ aBaseShape,
+ GeomAPI_Shape::EDGE,
+ "Modified_Edge");
+ aResultBody->loadModifiedShapes(aMakeShapeList,
+ aBaseShape,
+ GeomAPI_Shape::VERTEX,
+ "Modified_Vertex");
setResult(aResultBody);
}
aResultPart->setTrsf(*aContext, aTrsf);
setResult(aResultPart, aResultIndex);
} else {
- GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, anAxis, anAngle);
+ std::shared_ptr<GeomAlgoAPI_Rotation> aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape,
+ anAxis,
+ anAngle));
- if (!aRotationAlgo.check()) {
- setError(aRotationAlgo.getError());
+ if (!aRotationAlgo->check()) {
+ setError(aRotationAlgo->getError());
return;
}
- aRotationAlgo.build();
+ aRotationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aRotationAlgo.isDone()) {
+ if(!aRotationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Rotation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aRotationAlgo.shape()->isNull()) {
+ if(aRotationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aRotationAlgo.isValid()) {
+ if(!aRotationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
aResultPart->setTrsf(*aContext, aTrsf);
setResult(aResultPart, aResultIndex);
} else {
- GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, aCenterPoint, aStartPoint, anEndPoint);
+ std::shared_ptr<GeomAlgoAPI_Rotation> aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape,
+ aCenterPoint,
+ aStartPoint,
+ anEndPoint));
- if (!aRotationAlgo.check()) {
- setError(aRotationAlgo.getError());
+ if (!aRotationAlgo->check()) {
+ setError(aRotationAlgo->getError());
return;
}
- aRotationAlgo.build();
+ aRotationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aRotationAlgo.isDone()) {
+ if(!aRotationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Rotation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aRotationAlgo.shape()->isNull()) {
+ if(aRotationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error : Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aRotationAlgo.isValid()) {
+ if(!aRotationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aRotationAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aRotationAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
}
}
-
-//=================================================================================================
-void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- // Store result.
- theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape());
-
- std::string aRotatedName = "Rotated";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfSubShapes();
-
- FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody,
- theBaseShape, 1, 2, 3, aRotatedName,
- *aSubShapes.get());
-}
///Perform the rotation using a center and two points.
void performTranslationByThreePoints();
-
- void loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
anObjectsIt++, aContext++) {
std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
- GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, aScaleFactor);
+ std::shared_ptr<GeomAlgoAPI_Scale> aScaleAlgo(
+ new GeomAlgoAPI_Scale(aBaseShape, aCenterPoint, aScaleFactor));
- if (!aScaleAlgo.check()) {
- setError(aScaleAlgo.getError());
+ if (!aScaleAlgo->check()) {
+ setError(aScaleAlgo->getError());
return;
}
- aScaleAlgo.build();
+ aScaleAlgo->build();
// Checking that the algorithm worked properly.
- if(!aScaleAlgo.isDone()) {
+ if(!aScaleAlgo->isDone()) {
static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
setError(aFeatureError);
break;
}
- if(aScaleAlgo.shape()->isNull()) {
+ if(aScaleAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aScaleAlgo.isValid()) {
+ if(!aScaleAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aScaleAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled");
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
anObjectsIt++, aContext++) {
std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
- GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint,
- aScaleFactorX, aScaleFactorY, aScaleFactorZ);
-
- if (!aScaleAlgo.check()) {
- setError(aScaleAlgo.getError());
+ std::shared_ptr<GeomAlgoAPI_Scale> aScaleAlgo(new GeomAlgoAPI_Scale(aBaseShape,
+ aCenterPoint,
+ aScaleFactorX,
+ aScaleFactorY,
+ aScaleFactorZ));
+
+ if (!aScaleAlgo->check()) {
+ setError(aScaleAlgo->getError());
return;
}
- aScaleAlgo.build();
+ aScaleAlgo->build();
// Checking that the algorithm worked properly.
- if(!aScaleAlgo.isDone()) {
+ if(!aScaleAlgo->isDone()) {
static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
setError(aFeatureError);
break;
}
- if(aScaleAlgo.shape()->isNull()) {
+ if(aScaleAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aScaleAlgo.isValid()) {
+ if(!aScaleAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aScaleAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled");
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
// Remove the rest results if there were produced in the previous pass.
removeResults(aResultIndex);
}
-
-//=================================================================================================
-void FeaturesPlugin_Scale::loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- // Store and name the result.
- theResultBody->storeModified(theBaseShape, theScaleAlgo.shape());
-
- // Name the faces
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theScaleAlgo.mapOfSubShapes();
- std::string aScaledName = "Scaled";
- FeaturesPlugin_Tools::storeModifiedShapes(theScaleAlgo, theResultBody,
- theBaseShape, 1, 2, 3, aScaledName,
- *aSubShapes.get());
-}
/// Perform symmetry using a central point and three dimensions
void performScaleByDimensions();
-
- /// Perform the naming
- void loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif // FEATURESPLUGIN_SCALE_H_
\ No newline at end of file
std::shared_ptr<GeomAlgoAPI_Symmetry>& theSymmetryAlgo,
std::shared_ptr<GeomAPI_Shape> theBaseShape, int theResultIndex)
{
- GeomAlgoAPI_MakeShapeList anAlgoList;
- anAlgoList.appendAlgo(theSymmetryAlgo);
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> anAlgoList(new GeomAlgoAPI_MakeShapeList());
+ anAlgoList->appendAlgo(theSymmetryAlgo);
// Compose source shape and the result of symmetry.
GeomShapePtr aCompound;
if (boolean(KEEP_ORIGINAL_RESULT())->value()) {
// add a copy of a base shape otherwise selection of this base shape is bad (2592)
std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(theBaseShape));
aShapes.push_back(aCopyAlgo->shape());
- anAlgoList.appendAlgo(aCopyAlgo);
+ anAlgoList->appendAlgo(aCopyAlgo);
aShapes.push_back(theSymmetryAlgo->shape());
aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
// Store and name the result.
ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
aResultBody->storeModified(theBaseShape, aCompound);
- loadNamingDS(anAlgoList, aResultBody, theBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theBaseShape, anAlgoList, "Symmetried");
setResult(aResultBody, theResultIndex);
}
aResultPart->setTrsf(theOriginal, theTrsf);
setResult(aResultPart, theResultIndex);
}
-
-//=================================================================================================
-void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_MakeShapeList& theAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- // Name the faces
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theAlgo.mapOfSubShapes();
- std::string aReflectedName = "Symmetried";
- FeaturesPlugin_Tools::storeModifiedShapes(theAlgo, theResultBody,
- theBaseShape, 1, 2, 3, aReflectedName,
- *aSubShapes.get());
-}
/// Perform symmetry with respect to a plane.
void performSymmetryByPlane();
- /// Perform the naming
- void loadNamingDS(GeomAlgoAPI_MakeShapeList& theSymmetryAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
-
/// Create new result on given shapes and the index of result
void buildResult(std::shared_ptr<GeomAlgoAPI_Symmetry>& theSymmetryAlgo,
std::shared_ptr<GeomAPI_Shape> theBaseShape,
#include <GeomAPI_ShapeIterator.h>
-void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape,
- const int theFaceTag,
- const int theEdgeTag,
- const int theVertexTag,
- const std::string theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes)
+//==================================================================================================
+void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
+ const GeomShapePtr theBaseShape,
+ const ListOfShape& theTools,
+ const GeomMakeShapePtr& theMakeShape,
+ const GeomShapePtr theResultShape)
+{
+ if (theBaseShape->isEqual(theResultShape)) {
+ theResultBody->store(theResultShape, false);
+ return;
+ }
+
+ theResultBody->storeModified(theBaseShape, theResultShape);
+
+ ListOfShape aShapes = theTools;
+ aShapes.push_front(theBaseShape);
+
+ for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter)
+ {
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE);
+ theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);
+ }
+}
+
+//==================================================================================================
+void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
+ const GeomShapePtr theBaseShape,
+ const GeomMakeShapePtr& theMakeShape,
+ const std::string theName)
{
switch(theBaseShape->shapeType()) {
case GeomAPI_Shape::COMPOUND: {
for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next())
{
- storeModifiedShapes(theAlgo,
- theResultBody,
- anIt.current(),
- theFaceTag,
- theEdgeTag,
- theVertexTag,
- theName,
- theSubShapes);
+ loadModifiedShapes(theResultBody,
+ anIt.current(),
+ theMakeShape,
+ theName);
}
break;
}
case GeomAPI_Shape::COMPSOLID:
case GeomAPI_Shape::SOLID:
case GeomAPI_Shape::SHELL: {
- theResultBody->loadAndOrientModifiedShapes(&theAlgo,
- theBaseShape, GeomAPI_Shape::FACE,
- theFaceTag, theName + "_Face", theSubShapes, false, true);
+ theResultBody->loadModifiedShapes(theMakeShape,
+ theBaseShape,
+ GeomAPI_Shape::FACE,
+ theName + "_Face");
}
case GeomAPI_Shape::FACE:
case GeomAPI_Shape::WIRE: {
- theResultBody->loadAndOrientModifiedShapes(&theAlgo,
- theBaseShape, GeomAPI_Shape::EDGE,
- theEdgeTag, theName + "_Edge", theSubShapes, false, true);
+ theResultBody->loadModifiedShapes(theMakeShape,
+ theBaseShape,
+ GeomAPI_Shape::EDGE,
+ theName + "_Edge");
}
case GeomAPI_Shape::EDGE: {
- theResultBody->loadAndOrientModifiedShapes(&theAlgo,
- theBaseShape, GeomAPI_Shape::VERTEX,
- theVertexTag, theName + "_Vertex", theSubShapes, false, true);
+ theResultBody->loadModifiedShapes(theMakeShape,
+ theBaseShape,
+ GeomAPI_Shape::VERTEX,
+ theName + "_Vertex");
}
}
}
+
+//==================================================================================================
+void FeaturesPlugin_Tools::loadDeletedShapes(ResultBodyPtr theResultBody,
+ const GeomShapePtr theBaseShape,
+ const ListOfShape& theTools,
+ const GeomMakeShapePtr& theMakeShape,
+ const GeomShapePtr theResultShapesCompound)
+{
+ ListOfShape aShapes = theTools;
+ aShapes.push_front(theBaseShape);
+
+ for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++)
+ {
+ theResultBody->loadDeletedShapes(theMakeShape,
+ *anIter,
+ GeomAPI_Shape::VERTEX,
+ theResultShapesCompound);
+ theResultBody->loadDeletedShapes(theMakeShape,
+ *anIter,
+ GeomAPI_Shape::EDGE,
+ theResultShapesCompound);
+ theResultBody->loadDeletedShapes(theMakeShape,
+ *anIter,
+ GeomAPI_Shape::FACE,
+ theResultShapesCompound);
+ }
+}
+
+//==================================================================================================
+void FeaturesPlugin_Tools::loadDeletedShapes(
+ std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+ const ListOfShape& theTools,
+ const GeomShapePtr theResultShapesCompound)
+{
+ for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
+ anIt != theResultBaseAlgoList.end();
+ ++anIt)
+ {
+ ResultBaseAlgo& aRCA = *anIt;
+ loadDeletedShapes(aRCA.resultBody,
+ aRCA.baseShape,
+ theTools,
+ aRCA.makeShape,
+ theResultShapesCompound);
+ }
+}
#ifndef FeaturesPlugin_Tools_H_
#define FeaturesPlugin_Tools_H_
-#include <GeomAlgoAPI_Translation.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <ModelAPI_ResultBody.h>
-class ModelAPI_ResultBody;
+#include <vector>
class FeaturesPlugin_Tools {
public:
- static void storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape,
- const int theFaceTag,
- const int theEdgeTag,
- const int theVertexTag,
- const std::string theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes);
+ struct ResultBaseAlgo {
+ ResultBodyPtr resultBody;
+ GeomShapePtr baseShape;
+ GeomMakeShapePtr makeShape;
+ };
+
+public:
+ static void loadModifiedShapes(ResultBodyPtr theResultBody,
+ const GeomShapePtr theBaseShape,
+ const ListOfShape& theTools,
+ const GeomMakeShapePtr& theMakeShape,
+ const GeomShapePtr theResultShape);
+
+ static void loadModifiedShapes(ResultBodyPtr theResultBody,
+ const GeomShapePtr theBaseShape,
+ const GeomMakeShapePtr& theMakeShape,
+ const std::string theName);
+
+ /// Stores deleted shapes.
+ static void loadDeletedShapes(ResultBodyPtr theResultBody,
+ const GeomShapePtr theBaseShape,
+ const ListOfShape& theTools,
+ const GeomMakeShapePtr& theMakeShape,
+ const GeomShapePtr theResultShapesCompound);
+
+ /// Stores deleted shapes.
+ static void loadDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+ const ListOfShape& theTools,
+ const GeomShapePtr theResultShapesCompound);
};
#endif /* FeaturesPlugin_Tools_H_ */
aResultPart->setTrsf(*aContext, aTrsf);
setResult(aResultPart, aResultIndex);
} else {
- GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance);
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, anAxis, aDistance));
- if (!aTranslationAlgo.check()) {
- setError(aTranslationAlgo.getError());
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
return;
}
- aTranslationAlgo.build();
+ aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo.isDone()) {
+ if(!aTranslationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Translation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aTranslationAlgo.shape()->isNull()) {
+ if(aTranslationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aTranslationAlgo.isValid()) {
+ if(!aTranslationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBaseShape,
+ aTranslationAlgo,
+ "Translated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
aResultPart->setTrsf(*aContext, aTrsf);
setResult(aResultPart, aResultIndex);
} else {
- GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aDX, aDY, aDZ);
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, aDX, aDY, aDZ));
- if (!aTranslationAlgo.check()) {
- setError(aTranslationAlgo.getError());
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
return;
}
- aTranslationAlgo.build();
+ aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo.isDone()) {
+ if(!aTranslationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Translation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aTranslationAlgo.shape()->isNull()) {
+ if(aTranslationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aTranslationAlgo.isValid()) {
+ if(!aTranslationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBaseShape,
+ aTranslationAlgo,
+ "Translated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
aResultPart->setTrsf(*aContext, aTrsf);
setResult(aResultPart, aResultIndex);
} else {
- GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aFirstPoint, aSecondPoint);
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, aFirstPoint, aSecondPoint));
- if (!aTranslationAlgo.check()) {
- setError(aTranslationAlgo.getError());
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
return;
}
- aTranslationAlgo.build();
+ aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo.isDone()) {
+ if(!aTranslationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Translation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aTranslationAlgo.shape()->isNull()) {
+ if(aTranslationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aTranslationAlgo.isValid()) {
+ if(!aTranslationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBaseShape,
+ aTranslationAlgo,
+ "Translated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
// Remove the rest results if there were produced in the previous pass.
removeResults(aResultIndex);
}
-
-//=================================================================================================
-void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- // Store result.
- theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape());
-
- std::string aTranslatedName = "Translated";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
-
- FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody,
- theBaseShape, 1, 2, 3, aTranslatedName,
- *aSubShapes.get());
-}
///Perform the translation usind two points
void performTranslationByTwoPoints();
-
- void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif
}
// Checking that the algorithm worked properly.
- GeomAlgoAPI_MakeShapeList aMakeShapeList;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
GeomAPI_DataMapOfShapeShape aMapOfShapes;
if(!anAlgo->isDone()) {
setError("Error: Boolean algorithm failed.");
}
GeomShapePtr aShape = anAlgo->shape();
- aMakeShapeList.appendAlgo(anAlgo);
+ aMakeShapeList->appendAlgo(anAlgo);
aMapOfShapes.merge(anAlgo->mapOfSubShapes());
// Store original shapes for naming.
}
aShape = aFillerAlgo->shape();
- aMakeShapeList.appendAlgo(aFillerAlgo);
+ aMakeShapeList->appendAlgo(aFillerAlgo);
aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
}
// workaround: make copy to name edges correctly
// Store result and naming.
- const int aModifyEdgeTag = 1;
- const int aModifyFaceTag = 2;
- const int aDeletedTag = 3;
- /// sub solids will be placed at labels 4, 5 etc. if result is compound of solids
- const int aSubsolidsTag = 4;
const std::string aModEName = "Modified_Edge";
const std::string aModFName = "Modified_Face";
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
- aResultBody->storeModified(anObjects.front(), aShape, aSubsolidsTag);
+ aResultBody->storeModified(anObjects.front(), aShape);
for(ListOfShape::const_iterator anIter = anObjects.begin(); anIter != anObjects.end(); ++anIter) {
- aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::EDGE,
- aModifyEdgeTag, aModEName, aMapOfShapes,
- false, true, true);
- aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE,
- aModifyFaceTag, aModFName, aMapOfShapes,
- false, true, true);
+ aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::EDGE, aModEName);
+ aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aModFName);
//aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag);
}
#include "GeomAlgoAPI_MakeShape.h"
#include <BOPAlgo_Builder.hxx>
+#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeShape.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepGProp.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_ShapeIterator.h>
+#include <TopoDS.hxx>
#include <TopoDS_Builder.hxx>
+#include <TopoDS_Edge.hxx>
// new shape -> old shapes -> index in the old shape
typedef NCollection_DataMap<TopoDS_Shape,
NCollection_DataMap<int, NCollection_DataMap<TopoDS_Shape, MapNewToOld, TopTools_ShapeMapHasher> >
HistoryMap;
-//=================================================================================================
+//==================================================================================================
GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
: myBuilderType(Unknown),
myDone(false)
myHist = 0;
}
-GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape() {
+//==================================================================================================
+GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape()
+{
if (myHist) {
delete (HistoryMap*)myHist;
}
}
-//=================================================================================================
+//==================================================================================================
bool GeomAlgoAPI_MakeShape::isDone() const
{
return myDone;
}
-//=================================================================================================
-const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
+//==================================================================================================
+const GeomShapePtr GeomAlgoAPI_MakeShape::shape() const
{
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;
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::generated(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes)
{
TopTools_ListOfShape aList;
if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
- aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
+ aList = aMakeShape->Generated(theOldShape->impl<TopoDS_Shape>());
} else if(myBuilderType == OCCT_BOPAlgo_Builder) {
BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
- aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
+ aList = aBOPBuilder->Generated(theOldShape->impl<TopoDS_Shape>());
}
for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
- if(anIt.Value().IsNull()) {
- continue;
- }
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ GeomShapePtr aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- theHistory.push_back(aShape);
+ if (!isValidForHistory(aShape)) continue;
+ fixOrientation(aShape);
+ theNewShapes.push_back(aShape);
}
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::modified(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes)
{
TopTools_ListOfShape aList;
if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
try {
- aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
+ aList = aMakeShape->Modified(theOldShape->impl<TopoDS_Shape>());
} catch(Standard_NoSuchObject) {
}
} else if(myBuilderType == OCCT_BOPAlgo_Builder) {
BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
- aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
+ aList = aBOPBuilder->Modified(theOldShape->impl<TopoDS_Shape>());
}
for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
- if(anIt.Value().IsNull()) {
- continue;
- }
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ GeomShapePtr aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- theHistory.push_back(aShape);
+ if (!isValidForHistory(aShape)) continue;
+ fixOrientation(aShape);
+ theNewShapes.push_back(aShape);
}
}
-//=================================================================================================
-bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::isDeleted(const GeomShapePtr theOldShape)
{
bool isDeleted = false;
if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
- isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+ isDeleted = aMakeShape->IsDeleted(theOldShape->impl<TopoDS_Shape>()) == Standard_True;
} else if(myBuilderType == OCCT_BOPAlgo_Builder) {
BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
- isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+ isDeleted = aBOPBuilder->IsDeleted(theOldShape->impl<TopoDS_Shape>()) == Standard_True;
}
return isDeleted;
}
-//=================================================================================================
+//==================================================================================================
void GeomAlgoAPI_MakeShape::setBuilderType(const BuilderType theBuilderType)
{
myBuilderType = theBuilderType;
}
-//=================================================================================================
+//==================================================================================================
void GeomAlgoAPI_MakeShape::setDone(const bool theFlag)
{
myDone = theFlag;
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::setShape(const GeomShapePtr theShape)
{
if(myShape.get() && myShape->isEqual(theShape)) {
return;
const TopoDS_Shape& aTopoDSShape = myShape->impl<TopoDS_Shape>();
for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_VERTEX); anExp.More(); anExp.Next()) {
- std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ GeomShapePtr aCurrentShape(new GeomAPI_Shape());
aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
myMap->bind(aCurrentShape, aCurrentShape);
}
for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_EDGE); anExp.More(); anExp.Next()) {
- std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ GeomShapePtr aCurrentShape(new GeomAPI_Shape());
aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
myMap->bind(aCurrentShape, aCurrentShape);
}
for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) {
- std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ GeomShapePtr aCurrentShape(new GeomAPI_Shape());
aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
myMap->bind(aCurrentShape, aCurrentShape);
}
}
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShape::initialize() {
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::isValidForHistory(const GeomShapePtr theShape)
+{
+ if (!theShape.get()) return false;
+
+ const TopoDS_Shape& aShape_ = theShape->impl<TopoDS_Shape>();
+ if (aShape_.IsNull()) return false;
+
+ if (aShape_.ShapeType() == TopAbs_EDGE) {
+ TopoDS_Edge anEdge_ = TopoDS::Edge(aShape_);
+ if (BRep_Tool::Degenerated(anEdge_)) return false;
+ }
+
+ return true;
+}
+
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::fixOrientation(GeomShapePtr& theShape) {
+ if (myMap->isBound(theShape)) theShape = myMap->find(theShape);
+}
+
+//==================================================================================================
+void GeomAlgoAPI_MakeShape::initialize()
+{
switch (myBuilderType) {
case OCCT_BRepBuilderAPI_MakeShape: {
myDone = implPtr<BRepBuilderAPI_MakeShape>()->IsDone() == Standard_True;
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());
+ GeomShapePtr aCurrentShape(new GeomAPI_Shape());
aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
myMap->bind(aCurrentShape, aCurrentShape);
}
}
-//=================================================================================================
+//==================================================================================================
void GeomAlgoAPI_MakeShape::prepareNamingFaces()
{
long long index = 1;
GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE);
for(GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE); anExp.more(); anExp.next()) {
- std::shared_ptr<GeomAPI_Shape> aFace = anExp.current();
+ GeomShapePtr aFace = anExp.current();
myCreatedFaces["Face_" + std::to_string(index++)] = aFace;
}
}
-//=================================================================================================
-bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){
-
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage)
+{
// isValid() is called from this method
if (!isValid()) {
myError = theMessage + " :: resulting shape is not valid.";
return true ;
}
-bool GeomAlgoAPI_MakeShape::newShapesCollected(
- std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShape::isNewShapesCollected(GeomShapePtr theWholeOld,
+ const int theShapeType)
{
if (!myHist)
return false;
}
void GeomAlgoAPI_MakeShape::collectNewShapes(
- std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType)
+ GeomShapePtr theWholeOld, const int theShapeType)
{
if (!myHist)
myHist = new HistoryMap;
}
}
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::oldShapesForNew(
- std::shared_ptr<GeomAPI_Shape> theWholeOld,
- std::shared_ptr<GeomAPI_Shape> theNewShape, const int theShapeType)
+//==================================================================================================
+GeomShapePtr GeomAlgoAPI_MakeShape::oldShapesForNew(GeomShapePtr theWholeOld,
+ GeomShapePtr theNewShape,
+ const int theShapeType)
{
GeomShapePtr aResult(new GeomAPI_Shape);
TopoDS_Compound aResComp;
/// \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,
+ template<class T> explicit GeomAlgoAPI_MakeShape(
+ T* theBuilder,
const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
: GeomAPI_Interface(theBuilder),
myBuilderType(theBuilderType)
/// \brief Initializes internals.
/// \param[in] theBuilder pointer to the builder.
/// \param[in] theBuilderType builder type.
- template<class T> void initialize(T* theBuilder,
+ template<class T> void initialize(
+ T* theBuilder,
const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape)
{
setImpl(theBuilder);
GEOMALGOAPI_EXPORT bool isDone() const;
/// \return a shape built by the shape construction algorithm.
- GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
+ GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const;
/// \return true if resulting shape is valid.
GEOMALGOAPI_EXPORT bool isValid() const;
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);
+ /// \param[in] theOldShape base shape.
+ /// \param[out] theNewShapes shapes generated from \a theShape. Does not cleared!
+ GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes);
/// \return the list of shapes modified from the shape \a theShape.
- /// \param[in] theShape base shape.
- /// \param[out] theHistory modified shapes. Does not cleared!
- GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory);
+ /// \param[in] theOldShape base shape.
+ /// \param[out] theNewShapes shapes modified from \a theShape. Does not cleared!
+ GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes);
/// \return true if theShape was deleted.
- /// \param[in] theShape base shape.
- GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+ /// \param[in] theOldShape base shape.
+ GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theOldShape);
/// \return true if the data were correct.
GEOMALGOAPI_EXPORT virtual bool check() { return true; };
+ /// \brief Prepare the naming of faces.
+ GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
+
/// \return the list of created faces.
- GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr<GeomAPI_Shape> > getCreatedFaces()
- {return myCreatedFaces;}
+ GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces() {
+ return myCreatedFaces;
+ }
/// \return the error.
GEOMALGOAPI_EXPORT std::string getError() { return myError; }
- /// \brief Prepare the naming of faces.
- GEOMALGOAPI_EXPORT virtual void prepareNamingFaces();
-
/// \brief Check the validity of the produced shape.
GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage);
/// \param theWholeOld the whole old shape
/// \param theShapeType type of the sub-shapes that is used for optimization
/// \returns true if optimization containers are already filled
- GEOMALGOAPI_EXPORT bool newShapesCollected(
- std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType);
+ GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld,
+ const int theShapeType);
/// Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
/// \param theWholeOld the whole old shape
/// \param theShapeType type of the sub-shapes that is used for optimization
/// \returns true if optimization containers are already filled
- GEOMALGOAPI_EXPORT void collectNewShapes(
- std::shared_ptr<GeomAPI_Shape> theWholeOld, const int theShapeType);
+ GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld,
+ const int theShapeType);
/// Optimization of access the new shapes by old shapes for the limited set of needed new shapes.
/// \param theWholeOld the whole old shape
/// \param theNewShape the whole new shape
/// \param theShapeType type of the old sub-shapes
/// \returns compound of all old shapes that were used for creation of the given new
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> oldShapesForNew(
- std::shared_ptr<GeomAPI_Shape> theWholeOld,
- std::shared_ptr<GeomAPI_Shape> theNewShape, const int theShapeType);
+ GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld,
+ GeomShapePtr theNewShape,
+ const int theShapeType);
protected:
/// \brief Sets builder type.
/// \brief Sets result shape.
/// \param[in] theShape new shape.
- void setShape(const std::shared_ptr<GeomAPI_Shape> theShape);
+ void setShape(const GeomShapePtr theShape);
+
+ /// \return true if passed shape is valid for history.
+ bool isValidForHistory(const GeomShapePtr theShape);
+
+ /// Replaces \a theShape with shape from \a myMap.
+ void fixOrientation(GeomShapePtr& theShape);
protected:
/// Data map to keep correct orientation of sub-shapes.
/// Error occurred during the execution of an algorithm.
std::string myError;
/// Map of created faces with their name for naming.
- std::map< std::string, std::shared_ptr<GeomAPI_Shape> > myCreatedFaces;
+ std::map< std::string, GeomShapePtr > myCreatedFaces;
private:
/// \brief Initializes internals.
private:
GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder.
bool myDone; ///< Builder status.
- std::shared_ptr<GeomAPI_Shape> myShape; ///< Resulting shape.
+ GeomShapePtr myShape; ///< Resulting shape.
/// map that is used to keep the optimization structure for access to the history
/// kind of sub-shapes -> whole old shape -> new shape -> list of old shapes that create this new
void* myHist;
};
-typedef std::list<std::shared_ptr<GeomAlgoAPI_MakeShape> > ListOfMakeShape;
+typedef std::shared_ptr<GeomAlgoAPI_MakeShape> GeomMakeShapePtr;
+typedef std::list<GeomMakeShapePtr> ListOfMakeShape;
#endif
#include <GeomAlgoAPI_MakeShapeCustom.h>
-//=================================================================================================
+//==================================================================================================
GeomAlgoAPI_MakeShapeCustom::GeomAlgoAPI_MakeShapeCustom()
{}
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeCustom::setResult(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::setResult(const GeomShapePtr theShape)
{
setShape(theShape);
}
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::addModified(const std::shared_ptr<GeomAPI_Shape> theBase,
- const std::shared_ptr<GeomAPI_Shape> theResult)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addModified(const GeomShapePtr theOldShape,
+ const GeomShapePtr theNewShape)
{
- return myModified.add(theBase, theResult);
+ if (!isValidForHistory(theNewShape)) return false;
+ GeomShapePtr aNewShape = theNewShape;
+ fixOrientation(aNewShape);
+ return myModified.add(theOldShape, aNewShape);
}
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const std::shared_ptr<GeomAPI_Shape> theBase,
- const std::shared_ptr<GeomAPI_Shape> theResult)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const GeomShapePtr theOldShape,
+ const GeomShapePtr theNewShape)
{
- return myGenerated.add(theBase, theResult);
+ if (!isValidForHistory(theNewShape)) return false;
+ GeomShapePtr aNewShape = theNewShape;
+ fixOrientation(aNewShape);
+ return myGenerated.add(theOldShape, aNewShape);
}
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const GeomShapePtr theOldShape)
{
- return myDeleted.bind(theShape, theShape);
+ return myDeleted.bind(theOldShape, theOldShape);
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeCustom::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::generated(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes)
{
ListOfShape aGenerated;
- if(myGenerated.find(theShape, aGenerated)) {
- theHistory.insert(theHistory.end(), aGenerated.begin(), aGenerated.end());
+ if(myGenerated.find(theOldShape, aGenerated)) {
+ theNewShapes.insert(theNewShapes.end(), aGenerated.begin(), aGenerated.end());
}
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeCustom::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeCustom::modified(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes)
{
ListOfShape aModified;
- if(myModified.find(theShape, aModified)) {
- theHistory.insert(theHistory.end(), aModified.begin(), aModified.end());
+ if(myModified.find(theOldShape, aModified)) {
+ theNewShapes.insert(theNewShapes.end(), aModified.begin(), aModified.end());
}
}
-//=================================================================================================
-bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const GeomShapePtr theOldShape)
{
- return myDeleted.isBound(theShape);
-}
\ No newline at end of file
+ return myDeleted.isBound(theOldShape);
+}
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeCustom();
/// Sets result shape.
- GEOMALGOAPI_EXPORT void setResult(const std::shared_ptr<GeomAPI_Shape> theShape);
+ GEOMALGOAPI_EXPORT void setResult(const GeomShapePtr theShape);
/// Adds modified shape.
- GEOMALGOAPI_EXPORT bool addModified(const std::shared_ptr<GeomAPI_Shape> theBase,
- const std::shared_ptr<GeomAPI_Shape> theResult);
+ GEOMALGOAPI_EXPORT bool addModified(const GeomShapePtr theOldShape,
+ const GeomShapePtr theNewShape);
/// Adds generated shape.
- GEOMALGOAPI_EXPORT bool addGenerated(const std::shared_ptr<GeomAPI_Shape> theBase,
- const std::shared_ptr<GeomAPI_Shape> theResult);
+ GEOMALGOAPI_EXPORT bool addGenerated(const GeomShapePtr theOldShape,
+ const GeomShapePtr theNewShape);
/// Adds deleted shape.
- GEOMALGOAPI_EXPORT bool addDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+ GEOMALGOAPI_EXPORT bool addDeleted(const GeomShapePtr theOldShape);
/// \return the list of shapes generated from the shape theShape
- GEOMALGOAPI_EXPORT void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory);
+ GEOMALGOAPI_EXPORT void generated(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes);
/// \return the list of shapes modified from the shape theShape
- GEOMALGOAPI_EXPORT void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory);
+ GEOMALGOAPI_EXPORT void modified(const GeomShapePtr theShape,
+ ListOfShape& theNewShapes);
/// \return whether the shape is deleted
- GEOMALGOAPI_EXPORT bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+ GEOMALGOAPI_EXPORT bool isDeleted(const GeomShapePtr theOldShape);
private:
GeomAPI_DataMapOfShapeMapOfShapes myGenerated;
#include <NCollection_Map.hxx>
#include <TopoDS_Shape.hxx>
-//=================================================================================================
+//==================================================================================================
GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList()
: GeomAlgoAPI_MakeShape()
{}
-//=================================================================================================
+//==================================================================================================
GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList(const ListOfMakeShape& theMakeShapeList)
: GeomAlgoAPI_MakeShape()
{
init(theMakeShapeList);
}
-//=================================================================================================
+//==================================================================================================
void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList)
{
if(myMap.get()) {
}
}
-//=================================================================================================
+//==================================================================================================
void GeomAlgoAPI_MakeShapeList::appendAlgo(
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
+ const GeomMakeShapePtr theMakeShape)
{
myListOfMakeShape.push_back(theMakeShape);
if(!myMap.get()) {
myMap->merge(theMakeShape->mapOfSubShapes());
}
-//=================================================================================================
-const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShapeList::shape() const
+//==================================================================================================
+const GeomShapePtr GeomAlgoAPI_MakeShapeList::shape() const
{
- std::shared_ptr<GeomAPI_Shape> aShape = GeomAlgoAPI_MakeShape::shape();
+ GeomShapePtr 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>();
+ return GeomShapePtr();
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeList::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeList::generated(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes)
{
- result(theShape, GeomAlgoAPI_MakeShapeList::Generated, theHistory);
+ result(theOldShape, GeomAlgoAPI_MakeShapeList::Generated, theNewShapes);
}
-//=================================================================================================
-void GeomAlgoAPI_MakeShapeList::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory)
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeList::modified(const GeomShapePtr theOldShape,
+ ListOfShape& theNewShapes)
{
- result(theShape, GeomAlgoAPI_MakeShapeList::Modified, theHistory);
+ result(theOldShape, GeomAlgoAPI_MakeShapeList::Modified, theNewShapes);
}
-bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
+//==================================================================================================
+bool GeomAlgoAPI_MakeShapeList::isDeleted(const GeomShapePtr theOldShape)
{
- for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin();
- aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) {
- std::shared_ptr<GeomAlgoAPI_MakeShape> aMakeShape = *aBuilderIt;
- if(aMakeShape->isDeleted(theShape)) {
+ for (ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin();
+ aBuilderIt != myListOfMakeShape.end();
+ ++aBuilderIt)
+ {
+ GeomMakeShapePtr aMakeShape = *aBuilderIt;
+ if(aMakeShape->isDeleted(theOldShape)) {
return true;
}
}
return false;
}
-void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr<GeomAPI_Shape> theShape,
+//==================================================================================================
+void GeomAlgoAPI_MakeShapeList::result(const GeomShapePtr theOldShape,
OperationType theOperationType,
- ListOfShape& theHistory)
+ ListOfShape& theNewShapes)
{
if(myListOfMakeShape.empty()) {
return;
NCollection_Map<TopoDS_Shape> anAlgoShapes;
NCollection_Map<TopoDS_Shape> aResultShapesMap;
NCollection_List<TopoDS_Shape> aResultShapesList;
- anAlgoShapes.Add(theShape->impl<TopoDS_Shape>());
- aResultShapesMap.Add(theShape->impl<TopoDS_Shape>());
- aResultShapesList.Append(theShape->impl<TopoDS_Shape>());
+ anAlgoShapes.Add(theOldShape->impl<TopoDS_Shape>());
+ aResultShapesMap.Add(theOldShape->impl<TopoDS_Shape>());
+ aResultShapesList.Append(theOldShape->impl<TopoDS_Shape>());
for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin();
- aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) {
- std::shared_ptr<GeomAlgoAPI_MakeShape> aMakeShape = *aBuilderIt;
+ aBuilderIt != myListOfMakeShape.end();
+ ++aBuilderIt)
+ {
+ GeomMakeShapePtr aMakeShape = *aBuilderIt;
NCollection_Map<TopoDS_Shape> aTempShapes;
- for(NCollection_Map<TopoDS_Shape>::Iterator
- aShapeIt(anAlgoShapes); aShapeIt.More(); aShapeIt.Next()) {
+ for (NCollection_Map<TopoDS_Shape>::Iterator aShapeIt(anAlgoShapes);
+ aShapeIt.More();
+ aShapeIt.Next())
+ {
bool hasResults = false;
bool anArgumentIsInResult = false;
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+ GeomShapePtr aShape(new GeomAPI_Shape);
aShape->setImpl(new TopoDS_Shape(aShapeIt.Value()));
ListOfShape aGeneratedShapes;
aMakeShape->generated(aShape, aGeneratedShapes);
- for (ListOfShape::const_iterator
- anIt = aGeneratedShapes.cbegin(); anIt != aGeneratedShapes.cend(); anIt++) {
+ for (ListOfShape::const_iterator anIt = aGeneratedShapes.cbegin();
+ anIt != aGeneratedShapes.cend();
+ ++anIt)
+ {
const TopoDS_Shape& anItShape = (*anIt)->impl<TopoDS_Shape>();
if (anItShape.IsSame(aShapeIt.Value())) {
anArgumentIsInResult = true;
}
ListOfShape aModifiedShapes;
aMakeShape->modified(aShape, aModifiedShapes);
- for(ListOfShape::const_iterator
- anIt = aModifiedShapes.cbegin(); anIt != aModifiedShapes.cend(); anIt++) {
+ for (ListOfShape::const_iterator anIt = aModifiedShapes.cbegin();
+ anIt != aModifiedShapes.cend();
+ ++anIt)
+ {
const TopoDS_Shape& anItShape = (*anIt)->impl<TopoDS_Shape>();
if (anItShape.IsSame(aShapeIt.Value())) {
anArgumentIsInResult = true;
anAlgoShapes.Unite(aTempShapes);
}
- for(NCollection_List<TopoDS_Shape>::Iterator
- aShapeIt(aResultShapesList); aShapeIt.More(); aShapeIt.Next()) {
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt(aResultShapesList);
+ aShapeIt.More();
+ aShapeIt.Next())
+ {
+ GeomShapePtr aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aShapeIt.Value()));
- theHistory.push_back(aShape);
+ if (!isValidForHistory(aShape)) continue;
+ fixOrientation(aShape);
+ theNewShapes.push_back(aShape);
}
}
/// \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);
+ GEOMALGOAPI_EXPORT void appendAlgo(const GeomMakeShapePtr theMakeShape);
/// \return a shape built by the shape construction algorithms
- GEOMALGOAPI_EXPORT virtual const std::shared_ptr<GeomAPI_Shape> shape() const;
+ GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const;
/// \return the list of shapes generated from the shape \a theShape
- GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
+ GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theShape,
ListOfShape& theHistory);
/// \return the list of shapes modified from the shape \a theShape
- GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape> theShape,
+ GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theShape,
ListOfShape& theHistory);
/// \return whether the shape is deleted
- GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape);
+ GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theShape);
private:
- void result(const std::shared_ptr<GeomAPI_Shape> theShape,
+ void result(const GeomShapePtr theShape,
OperationType theOperationType,
ListOfShape& theHistory);
#include <BRep_Tool.hxx>
#include <BRepTools_History.hxx>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <GeomAlgoAPI_MakeShape.h>
#include <GeomAlgoAPI_SortListOfShapes.h>
#include <Config_PropManager.h>
//#include <TDF_Tool.hxx>
//#define DEB_IMPORT 1
-static const int VERTICES_TAG = 1;
-static const int EDGES_TAG = 2;
-static const int FACES_TAG = 3;
-static const int DELETED_TAG = 4;
-static const int PRIMITIVES_START_TAG = 11;
+static const int INVALID_TAG = -1;
+static const int GENERATED_VERTICES_TAG = 1;
+static const int GENERATED_EDGES_TAG = 2;
+static const int GENERATED_FACES_TAG = 3;
+static const int MODIFIED_VERTICES_TAG = 4;
+static const int MODIFIED_EDGES_TAG = 5;
+static const int MODIFIED_FACES_TAG = 6;
+static const int DELETED_TAG = 7;
+static const int PRIMITIVES_START_TAG = 11;
+
+static int getGenerationTag(const TopoDS_Shape& theShape) {
+ TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
+ switch (aShapeType) {
+ case TopAbs_VERTEX: return GENERATED_VERTICES_TAG;
+ case TopAbs_EDGE: return GENERATED_EDGES_TAG;
+ case TopAbs_FACE: return GENERATED_FACES_TAG;
+ }
+
+ return INVALID_TAG;
+}
+
+static int getModificationTag(const TopoDS_Shape& theShape) {
+ TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
+ switch (aShapeType) {
+ case TopAbs_VERTEX: return MODIFIED_VERTICES_TAG;
+ case TopAbs_EDGE: return MODIFIED_EDGES_TAG;
+ case TopAbs_FACE: return MODIFIED_FACES_TAG;
+ }
+
+ return INVALID_TAG;
+}
+
+static TopAbs_ShapeEnum convertShapeType(const GeomAPI_Shape::ShapeType theType) {
+ switch (theType) {
+ case GeomAPI_Shape::VERTEX: return TopAbs_VERTEX;
+ case GeomAPI_Shape::EDGE: return TopAbs_EDGE;
+ case GeomAPI_Shape::WIRE: return TopAbs_WIRE;
+ case GeomAPI_Shape::FACE: return TopAbs_FACE;
+ case GeomAPI_Shape::SHELL: return TopAbs_SHELL;
+ case GeomAPI_Shape::SOLID: return TopAbs_SOLID;
+ case GeomAPI_Shape::COMPSOLID: return TopAbs_COMPSOLID;
+ case GeomAPI_Shape::COMPOUND: return TopAbs_COMPOUND;
+ case GeomAPI_Shape::SHAPE: return TopAbs_SHAPE;
+ }
+ return TopAbs_SHAPE;
+}
+
+static bool isAlreadyStored(const TNaming_Builder* theBuilder,
+ const TopoDS_Shape& theOldShape,
+ const TopoDS_Shape& theNewShape)
+{
+ for (TNaming_Iterator aNamingIt(theBuilder->NamedShape());
+ aNamingIt.More();
+ aNamingIt.Next())
+ {
+ if (aNamingIt.NewShape().IsSame(theNewShape)
+ && aNamingIt.OldShape().IsSame(theOldShape))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner)
: ModelAPI_BodyBuilder(theOwner),
evolutionToSelectionRec(aShapeLab, theFlag);
}
-void Model_BodyBuilder::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+void Model_BodyBuilder::store(const GeomShapePtr& theShape,
const bool theIsStoreSameShapes)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
}
}
-void Model_BodyBuilder::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape)
+void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape,
+ const GeomShapePtr& theToShape)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
return aFind->second;
}
-void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const bool theIsCleanStored)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
TDF_Label& aShapeLab = aData->shapeLab();
// clean builders
- if (theDecomposeSolidsTag != -2)
- clean();
+ if (theIsCleanStored) clean();
// store the new shape as primitive
TNaming_Builder* aBuilder = builder(0);
if (!theOldShape || !theNewShape)
}
}
-void Model_BodyBuilder::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
+void Model_BodyBuilder::storeWithoutNaming(const GeomShapePtr& theShape)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
{
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
- //aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), theName);
- TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), theName.c_str());
+ std::string aName = theName;
+ switch (theTag) {
+ case GENERATED_VERTICES_TAG: aName += aName.empty() ? "Generated_Vertex" : "_GV"; break;
+ case GENERATED_EDGES_TAG: aName += aName.empty() ? "Generated_Edge" : "_GE"; break;
+ case GENERATED_FACES_TAG: aName += aName.empty() ? "Generated_Face" : "_GF"; break;
+ case MODIFIED_VERTICES_TAG: aName += aName.empty() ? "Modified_Vertex" : "_MV"; break;
+ case MODIFIED_EDGES_TAG: aName += aName.empty() ? "Modified_Edge" : "_ME"; break;
+ case MODIFIED_FACES_TAG: aName += aName.empty() ? "Modified_Face" : "_MF"; break;
+ }
+
+ TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str());
}
-void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
const std::string& theName)
{
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
++myPrimitiveTag;
}
-void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName)
{
TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
- builder(theTag)->Generated(anOldShape, aNewShape);
- if(!theName.empty())
- buildName(theTag, theName);
- TopAbs_ShapeEnum aGenShapeType = aNewShape.ShapeType();
- if(aGenShapeType == TopAbs_WIRE || aGenShapeType == TopAbs_SHELL) {
- TopAbs_ShapeEnum anExplodeShapeType = aGenShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE;
- const TDF_Label aLabel = builder(theTag)->NamedShape()->Label();
- int aTag = 1;
- std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
- for(TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) {
- TDF_Label aChildLabel = aLabel.FindChild(aTag);
- TNaming_Builder aBuilder(aChildLabel);
- aBuilder.Generated(anOldShape, anExp.Current());
- TCollection_AsciiString aChildName = TCollection_AsciiString((theName + "_").c_str()) + aTag;
- //aDoc->addNamingName(aChildLabel, aChildName.ToCString());
- TDataStd_Name::Set(aChildLabel, aChildName.ToCString());
- aTag++;
+ TopAbs_ShapeEnum aNewShapeType = aNewShape.ShapeType();
+ int aTag;
+ if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) {
+ // TODO: This is a workaround. New shape should be only vertex, edge or face.
+ TopAbs_ShapeEnum anExplodeShapeType = aNewShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE;
+ aTag = TopAbs_WIRE ? GENERATED_EDGES_TAG : GENERATED_FACES_TAG;
+ for (TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) {
+ builder(aTag)->Generated(anOldShape, anExp.Current());
+ buildName(aTag, theName);
}
+ } else {
+ aTag = getGenerationTag(aNewShape);
+ if (aTag == INVALID_TAG) return;
+ builder(aTag)->Generated(anOldShape, aNewShape);
+ buildName(aTag, theName);
}
}
-
-void Model_BodyBuilder::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+void Model_BodyBuilder::modified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName)
{
TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
- builder(theTag)->Modify(anOldShape, aNewShape);
- if(!theName.empty())
- buildName(theTag, theName);
+ int aTag = getModificationTag(aNewShape);
+ if (aTag == INVALID_TAG) return;
+ builder(aTag)->Modify(anOldShape, aNewShape);
+ buildName(aTag, theName);
}
-void Model_BodyBuilder::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const int theTag)
+void Model_BodyBuilder::deleted(const GeomShapePtr& theOldShape)
{
TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
- builder(theTag)->Delete(aShape);
+ builder(DELETED_TAG)->Delete(aShape);
}
-void Model_BodyBuilder::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const GeomShapePtr theShapes)
+void Model_BodyBuilder::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const GeomShapePtr& theShapesToExclude)
{
- TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
- TopTools_MapOfShape aView;
- TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
+ TopTools_MapOfShape anAlreadyProcessedShapes;
GeomShapePtr aResultShape = shape();
- for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
- aRShape->setImpl((new TopoDS_Shape(aRoot)));
- if (!theMS->isDeleted(aRShape)
- || aResultShape->isSubShape(aRShape, false)
- || (theShapes.get() && theShapes->isSubShape(aRShape, false))) {
+ for (GeomAPI_ShapeExplorer anExp(theOldShape, theShapeTypeToExplore);
+ anExp.more();
+ anExp.next())
+ {
+ GeomShapePtr anOldSubShape = anExp.current();
+ const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl<TopoDS_Shape>();
+ if (!anAlreadyProcessedShapes.Add(anOldSubShape_)
+ || !theAlgo->isDeleted(anOldSubShape)
+ || aResultShape->isSubShape(anOldSubShape, false)
+ || (theShapesToExclude.get() && theShapesToExclude->isSubShape(anOldSubShape, false)))
+ {
continue;
}
- ListOfShape aHist;
- if (BRepTools_History::IsSupportedType(aRoot)) // to avoid crash in #2572
- theMS->modified(aRShape, aHist);
- if (aHist.size() == 0 || (aHist.size() == 1 && aHist.front()->isSame(aRShape)))
- builder(theTag)->Delete(aRoot);
+ ListOfShape aNewShapes;
+ if (BRepTools_History::IsSupportedType(anOldSubShape_)) { // to avoid crash in #2572
+ theAlgo->modified(anOldSubShape, aNewShapes);
+ }
+
+ if (aNewShapes.size() == 0
+ || (aNewShapes.size() == 1 && aNewShapes.front()->isSame(anOldSubShape))) {
+ builder(DELETED_TAG)->Delete(anOldSubShape_);
+ }
}
}
return TopAbs_VERTEX; // bad case
}
-void Model_BodyBuilder::loadAndOrientModifiedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate,
- const bool theIsStoreAsGenerated)
+void Model_BodyBuilder::loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName)
{
- static const int THE_ANCHOR_TAG = 100000;
-
- int anIndex = 1;
- int aTag = theTag;
- bool isBuilt = !theName.empty();
- std::string aName = theName;
- std::ostringstream aStream;
GeomShapePtr aResultShape = shape();
- TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
- TopTools_MapOfShape aView;
- std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
-
- TopoDS_Shape aShapeToIterate;
- if (theMS->newShapesCollected(theShapeIn, theKindOfShape)) {
+ GeomShapePtr aShapeToExplore = theOldShape;
+ if (theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore)) {
// use optimized set of old shapes for this
- GeomShapePtr aCompound = theMS->oldShapesForNew(theShapeIn, aResultShape, theKindOfShape);
- if (aCompound.get())
- aShapeToIterate = aCompound->impl<TopoDS_Shape>();
- } else {
- aShapeToIterate = aShapeIn;
+ GeomShapePtr aCompound = theAlgo->oldShapesForNew(theOldShape,
+ aResultShape,
+ theShapeTypeToExplore);
+ if (aCompound.get()) aShapeToExplore = aCompound;
}
- TopExp_Explorer aShapeExplorer (aShapeToIterate, (TopAbs_ShapeEnum)theKindOfShape);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
-
- bool aNotInTree =
- TNaming_Tool::NamedShape(aRoot, aData->shapeLab()).IsNull();
- if (aNotInTree && !theIsStoreSeparate) {
- // there is no sense to write history if old shape does not exist in the document
- continue; // but if it is stored separately, it will be builded as a primitive
- }
- ListOfShape aList;
- std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
- aRShape->setImpl((new TopoDS_Shape(aRoot)));
- theMS->modified(aRShape, aList);
+ TopTools_MapOfShape anAlreadyProcessedShapes;
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+ for (GeomAPI_ShapeExplorer anOldShapeExp(aShapeToExplore, theShapeTypeToExplore);
+ anOldShapeExp.more();
+ anOldShapeExp.next())
+ {
+ GeomShapePtr anOldSubShape = anOldShapeExp.current();
+ const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl<TopoDS_Shape>();
- if (!theIsStoreSeparate) {
- //keepTopLevelShapes(aList, aRoot, aResultShape);
- removeBadShapes(aList);
+ // There is no sense to write history if shape already processed
+ // or old shape does not exist in the document.
+ bool anOldSubShapeAlreadyProcessed = !anAlreadyProcessedShapes.Add(anOldSubShape_);
+ bool anOldSubShapeNotInTree = TNaming_Tool::NamedShape(anOldSubShape_, aData->shapeLab())
+ .IsNull();
+ if (anOldSubShapeAlreadyProcessed
+ || anOldSubShapeNotInTree)
+ {
+ continue;
}
- // sort the list of images before naming
- GeomAlgoAPI_SortListOfShapes::sort(aList);
-
- // to trace situation where several objects are produced by one parent (#2317)
- int aSameParentShapes = (aShapeIn.ShapeType() == TopAbs_WIRE
- || aShapeIn.ShapeType() == TopAbs_SHELL
- || aShapeIn.ShapeType() == TopAbs_COMPOUND) ? 0 : -1;
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator
- anIt = aList.begin(), aLast = aList.end();
- for (; anIt != aLast; anIt++) {
- TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
- if (theSubShapes.isBound(*anIt)) {
- std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
- aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
- }
- isBuilt = !theName.empty();
- if(!aRoot.IsSame(aNewShape)
- && aResultShape->isSubShape((*anIt), false)
- && !aResultShape->isSame(*anIt)) // to avoid put of same shape on main label and sub
- {
- if (!theIsStoreSeparate) {
- aSameParentShapes++;
- } else if (aNotInTree) // check this new shape can not be represented as
- // a sub-shape of higher level sub-shapes
- {
- TopAbs_ShapeEnum aNewType = aNewShape.ShapeType();
- TopAbs_ShapeEnum anAncestorType = typeOfAncestor(aNewType);
- if (anAncestorType != TopAbs_VERTEX) {
- bool aFound = false;
- TopoDS_Shape aResultTShape = aResultShape->impl<TopoDS_Shape>();
- TopExp_Explorer anAncestorExp(aResultTShape, anAncestorType);
- for(; anAncestorExp.More() && !aFound; anAncestorExp.Next()) {
- if (aResultTShape.IsSame(anAncestorExp.Current()))
- continue;
- TopExp_Explorer aSubExp(anAncestorExp.Current(), aNewType);
- for(; aSubExp.More(); aSubExp.Next()) {
- if (aNewShape.IsSame(aSubExp.Current())) {
- aFound = true;
- break;
- }
- }
- }
- if (aFound) {
- continue; // not need to store this shape in the BRep structure
- }
- }
- }
- int aFoundTag = 0;
- bool isFoundSameOld = false;
- bool isFoundDiffOld = false;
+ // Get new shapes.
+ ListOfShape aNewShapes;
+ theAlgo->modified(anOldSubShape, aNewShapes);
- // Check if new shape was already stored.
- for (std::map<int, TNaming_Builder*>::iterator aBuildersIt = myBuilders.begin();
- aBuildersIt != myBuilders.end();
- ++aBuildersIt)
- {
- TNaming_Builder* aBuilder = aBuildersIt->second;
- for (TNaming_Iterator aNamingIt(aBuilder->NamedShape());
- aNamingIt.More();
- aNamingIt.Next())
- {
- if (aNamingIt.NewShape().IsSame(aNewShape))
- {
- aNamingIt.OldShape().IsSame(aRoot) ? isFoundSameOld = true
- : isFoundDiffOld = true;
- aFoundTag = aBuildersIt->first;
- }
- }
+ for (ListOfShape::const_iterator aNewShapesIt = aNewShapes.cbegin();
+ aNewShapesIt != aNewShapes.cend();
+ ++aNewShapesIt)
+ {
+ GeomShapePtr aNewShape = *aNewShapesIt;
+ const TopoDS_Shape& aNewShape_ = aNewShape->impl<TopoDS_Shape>();
+ bool isGenerated = anOldSubShape_.ShapeType() != aNewShape_.ShapeType();
- if (isFoundSameOld || isFoundDiffOld) break;
- }
+ bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape);
+ bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false);
+ if (aNewShapeIsSameAsOldShape
+ || aNewShapeIsNotInResultShape)
+ {
+ continue;
+ }
- if (isFoundSameOld) {
- // Builder already contains same old->new shapes, don't store it twice.
+ TNaming_Builder* aBuilder;
+ if (aResultShape->isSame(aNewShape)) {
+ // keep the modification evolution on the root level (2241 - history propagation issue)
+ aBuilder = builder(0);
+ TDF_Label aShapeLab = aBuilder->NamedShape()->Label();
+ Handle(TDF_Reference) aRef;
+ if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
+ // Store only in case if it does not have reference.
continue;
}
- int aBuilderTag = aSameParentShapes > 0 ? THE_ANCHOR_TAG : aTag;
-
- int aCurShapeType = (int)((*anIt)->shapeType());
- bool needSuffix = false; // suffix for the name based on the shape type
- if (aCurShapeType != theKindOfShape) {
- // modified shape has different type => set another tag
- // to avoid shapes of different types on the same label
- aBuilderTag = THE_ANCHOR_TAG;
- needSuffix = true;
- }
- std::string aSuffix;
- if (needSuffix) {
- switch (aCurShapeType) {
- case GeomAPI_Shape::VERTEX: aSuffix = "_v_" + std::to_string(myVIndex++); break;
- case GeomAPI_Shape::EDGE: aSuffix = "_e_" + std::to_string(myEIndex++); break;
- case GeomAPI_Shape::FACE: aSuffix = "_f_" + std::to_string(myFIndex++); break;
- default: break;
- }
- }
-
- std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>> aKeepShapes, aMoveShapes;
- if (isFoundDiffOld) {
- // Found same new shape with different old shape.
- if (aFoundTag >= THE_ANCHOR_TAG) {
- // Found on separated tag.
- aBuilderTag = aFoundTag; // Store it on the same tag.
- isBuilt = false; // Don't change name;
- } else {
- // Found on previous tag.
- if (aBuilderTag < THE_ANCHOR_TAG) {
- // New shape shouls not be separated.
- aBuilderTag = aFoundTag; // Store it on the same tag.
- isBuilt = false; // Don't change name;
- } else {
- // New shape should be separated from others. Move shapes from found tag to new tag.
- while (myBuilders.find(aBuilderTag) != myBuilders.end()) {
- ++aBuilderTag;
- }
-
- TNaming_Builder* aFoundBuilder = myBuilders.at(aFoundTag);
- Handle(TNaming_NamedShape) aFoundNamedShape = aFoundBuilder->NamedShape();
- TDF_Label aFoundLabel = aFoundNamedShape->Label();
- TNaming_Evolution anEvolution = aFoundNamedShape->Evolution();
- for (TNaming_Iterator aNamingIt(aFoundNamedShape);
- aNamingIt.More();
- aNamingIt.Next())
- {
- std::pair<TopoDS_Shape, TopoDS_Shape> aShapesPair =
- std::make_pair(aNamingIt.OldShape(), aNamingIt.NewShape());
- aNamingIt.NewShape().IsSame(aNewShape) ? aMoveShapes.push_back(aShapesPair)
- : aKeepShapes.push_back(aShapesPair);
- }
-
- aFoundNamedShape->Clear();
- for (std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>>::iterator aKeepIt =
- aKeepShapes.begin();
- aKeepIt != aKeepShapes.end();
- ++aKeepIt)
- {
- if (anEvolution == TNaming_GENERATED) {
- aFoundBuilder->Generated(aKeepIt->first, aKeepIt->second);
- } else {
- aFoundBuilder->Modify(aKeepIt->first, aKeepIt->second);
- }
- }
- }
- }
- } else if (aBuilderTag == THE_ANCHOR_TAG) {
- while (myBuilders.find(aBuilderTag) != myBuilders.end()) {
- ++aBuilderTag;
- }
- }
+ // Check if new shape was already stored.
+ if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue;
- if(theIsStoreAsGenerated) {
- // Here we store shapes as generated, to avoid problem when one parent shape produce
- // several child shapes. In this case naming could not determine which shape to select.
- builder(aBuilderTag)->Generated(aRoot, aNewShape);
- for (std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>>::iterator aMoveIt =
- aMoveShapes.begin();
- aMoveIt != aMoveShapes.end();
- ++aMoveIt)
- {
- builder(aBuilderTag)->Generated(aMoveIt->first, aMoveIt->second);
- }
- } else if (aNotInTree) {
- // not in tree -> store as primitive (stored as separated)
- builder(aBuilderTag)->Generated(aNewShape);
- } else if (aCurShapeType != theKindOfShape) {
- // if different shape type is produced, make it as generated
- builder(aBuilderTag)->Generated(aRoot, aNewShape);
- } else {
- builder(aBuilderTag)->Modify(aRoot, aNewShape);
- for (std::vector<std::pair<TopoDS_Shape, TopoDS_Shape>>::iterator aMoveIt =
- aMoveShapes.begin();
- aMoveIt != aMoveShapes.end();
- ++aMoveIt) {
- builder(aBuilderTag)->Modify(aMoveIt->first, aMoveIt->second);
- }
+ if (!aBuilder->NamedShape().IsNull() &&
+ ((isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_GENERATED)
+ || (!isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_MODIFY)))
+ {
+ myBuilders.erase(0); // clear old builder to avoid different evolutions crash
+ aBuilder = builder(0);
}
- if(isBuilt) {
- aStream.str(std::string());
- aStream.clear();
- aStream << theName;
- if (theIsStoreSeparate && !isFoundDiffOld)
- aStream << "_" << anIndex++;
+ } else {
+ int aTag = isGenerated ? getGenerationTag(aNewShape_)
+ : getModificationTag(aNewShape_);
+ aBuilder = builder(aTag);
- if (aSameParentShapes > 0) {
- aStream.str(std::string());
- aStream.clear();
- aStream << aName << "_" << "divided" << "_" << myDividedIndex++;
- }
+ // Check if new shape was already stored.
+ if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue;
- aStream << aSuffix;
- buildName(aBuilderTag, aStream.str());
- }
- if(theIsStoreSeparate && !isFoundDiffOld) {
- aTag++;
- }
- } else if (aResultShape->isSame(*anIt)) {
- // keep the modification evolution on the root level (2241 - history propagation issue)
- TNaming_Builder* aBuilder = builder(0);
- TDF_Label aShapeLab = aBuilder->NamedShape()->Label();
- Handle(TDF_Reference) aRef;
- // Store only in case if it does not have reference.
- if (!aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
- if (theIsStoreAsGenerated) {
- TNaming_Builder* aBuilder = builder(0);
- if (!aBuilder->NamedShape().IsNull() &&
- aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) {
- myBuilders.erase(0); // clear old builder to avoid different evolutions crash
- }
- builder(0)->Generated(aRoot, aNewShape);
- } else {
- TNaming_Builder* aBuilder = builder(0);
- if (!aBuilder->NamedShape().IsNull() &&
- aBuilder->NamedShape()->Evolution() != TNaming_MODIFY) {
- myBuilders.erase(0); // clear old builder to avoid different evolutions crash
- }
- builder(0)->Modify(aRoot, aNewShape);
- }
- }
+ buildName(aTag, theName);
}
+
+ isGenerated ? aBuilder->Generated(anOldSubShape_, aNewShape_)
+ : aBuilder->Modify(anOldSubShape_, aNewShape_);
}
}
}
void Model_BodyBuilder::loadAndOrientGeneratedShapes (
GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
+ GeomShapePtr theShapeIn,
const int theKindOfShape,
const int theTag,
const std::string& theName,
//if (TNaming_Tool::NamedShape(aRoot, builder(theTag)->NamedShape()->Label()).IsNull())
// continue; // there is no sense to write history if old shape does not exist in the document
ListOfShape aList;
- std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+ GeomShapePtr aRShape(new GeomAPI_Shape());
aRShape->setImpl((new TopoDS_Shape(aRoot)));
theMS->generated(aRShape, aList);
keepTopLevelShapes(aList, aRoot);
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator
+ std::list<GeomShapePtr >::const_iterator
anIt = aList.begin(), aLast = aList.end();
for (; anIt != aLast; anIt++) {
TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
if (theSubShapes.isBound(*anIt)) {
- std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+ GeomShapePtr aMapShape(theSubShapes.find(*anIt));
aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
}
if (!aRoot.IsSame (aNewShape)) {
}
//=======================================================================
-void Model_BodyBuilder::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
+void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
//=======================================================================
void Model_BodyBuilder::loadFirstLevel(
- std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
+ GeomShapePtr theShape, const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
if (itr.Value().ShapeType() == TopAbs_COMPOUND ||
itr.Value().ShapeType() == TopAbs_COMPSOLID)
{
- std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+ GeomShapePtr itrShape(new GeomAPI_Shape());
itrShape->setImpl(new TopoDS_Shape(itr.Value()));
loadFirstLevel(itrShape, theName, theTag);
} else {
- std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+ GeomShapePtr itrShape(new GeomAPI_Shape());
itrShape->setImpl(new TopoDS_Shape(itr.Value()));
loadNextLevels(itrShape, theName, theTag);
}
}
} else {
- std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
+ GeomShapePtr itrShape(new GeomAPI_Shape());
itrShape->setImpl(new TopoDS_Shape(aShape));
loadNextLevels(itrShape, theName, theTag);
}
//=======================================================================
void Model_BodyBuilder::loadDisconnectedEdges(
- std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
+ GeomShapePtr theShape, const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
}
}
-void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
+void Model_BodyBuilder::loadDisconnectedVertexes(GeomShapePtr theShape,
const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
}
}
-std::shared_ptr<GeomAPI_Shape> Model_BodyBuilder::shape()
+GeomShapePtr Model_BodyBuilder::shape()
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData && aData->isValid()) {
if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
TopoDS_Shape aShape = aName->Get();
if (!aShape.IsNull()) {
- std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ GeomShapePtr aRes(new GeomAPI_Shape);
aRes->setImpl(new TopoDS_Shape(aShape));
return aRes;
}
}
}
- return std::shared_ptr<GeomAPI_Shape>();
+ return GeomShapePtr();
}
-bool Model_BodyBuilder::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+bool Model_BodyBuilder::isLatestEqual(const GeomShapePtr& theShape)
{
if (theShape.get()) {
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
std::map<int, TNaming_Builder*> myBuilders;
public:
/// Stores the shape (called by the execution method).
- MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ MODEL_EXPORT virtual void store(const GeomShapePtr& theShape,
const bool theIsStoreSameShapes = true);
/// Stores the generated shape (called by the execution method).
- MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape);
+ MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
+ const GeomShapePtr& theToShape);
/// Stores the modified shape (called by the execution method).
/// \param theOldShape shape that produces result
/// \param theNewShape resulting shape
/// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
/// theNewShape is compound of solids, if zero it is not used
- MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const int theDecomposeSolidsTag = 0);
+ MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const bool theIsCleanStored = true) override;
/// Stores the shape without naming support
/// \param theShape shape to store
- MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape);
+ MODEL_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape);
/// Returns the shape-result produced by this feature
- MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+ MODEL_EXPORT virtual GeomShapePtr shape();
/// Records the subshape newShape which was generated during a topological construction.
/// As an example, consider the case of a face generated in construction of a box.
- MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+ MODEL_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
const std::string& theName) override;
/// Records the shape newShape which was generated from the shape oldShape during a topological
/// construction. As an example, consider the case of a face generated from an edge in
/// construction of a prism.
- MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const std::string& theName, const int theTag = 1);
+ MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName = "") override;
/// Records the shape newShape which is a modification of the shape oldShape.
/// As an example, consider the case of a face split or merged in a Boolean operation.
- MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const std::string& theName, const int theTag = 1);
+ MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName = "") override;
/// Records the shape oldShape which was deleted from the current label.
/// As an example, consider the case of a face removed by a Boolean operation.
- MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const int theTag = 1);
+ MODEL_EXPORT virtual void deleted(const GeomShapePtr& theOldShape) override;
/// load deleted shapes
- MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const GeomShapePtr theShapes = GeomShapePtr());
+ MODEL_EXPORT
+ virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override;
+
/// load and orient modified shapes
- MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate = false,
- const bool theIsStoreAsGenerated = false);
- /// load and orient generated shapes
- MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes);
+ MODEL_EXPORT
+ virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName = "") override;
+
+ /// load and orient generated shapes
+ MODEL_EXPORT
+ virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
+ GeomShapePtr theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ const std::string& theName,
+ GeomAPI_DataMapOfShapeShape& theSubShapes);
/// Loads shapes of the first level (to be used during shape import)
- MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag);
+ MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag);
/// Loads disconnected edges
- MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag);
+ MODEL_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag);
/// Loads disconnected vetexes
- MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag);
+ MODEL_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag);
/// Removes the stored builders
MODEL_EXPORT virtual ~Model_BodyBuilder();
/// Returns true if the latest modification of this body in the naming history
// is equal to the given shape
- MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+ MODEL_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape);
protected:
/// Default constructor accessible only by Model_Objects
private:
/// Loads shapes of the next level (to be used during shape import)
- void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
+ void loadNextLevels(GeomShapePtr theShape,
const std::string& theName, int& theTag);
/// builds name for the shape kept at the specified tag
delete myBuilder;
}
-void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
- const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate,
- const bool theIsStoreAsGenerated,
- const bool theSplitInSubs)
+void Model_ResultBody::loadModifiedShapes(
+ const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName)
{
- if (theSplitInSubs && mySubs.size()) { // consists of subs
+ if (/*theSplitInSubs &&*/ mySubs.size()) { // consists of subs
// optimization of getting of new shapes for specific sub-result
- if (!theMS->newShapesCollected(theShapeIn, theKindOfShape))
- theMS->collectNewShapes(theShapeIn, theKindOfShape);
+ if (!theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore))
+ theAlgo->collectNewShapes(theOldShape, theShapeTypeToExplore);
std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
for(; aSubIter != mySubs.cend(); aSubIter++) {
// check that sub-shape was also created as modification of ShapeIn
}
}
}*/
- (*aSubIter)->loadAndOrientModifiedShapes(
- theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
- theIsStoreAsGenerated, theSplitInSubs);
+ (*aSubIter)->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
}
} else { // do for this directly
- myBuilder->loadAndOrientModifiedShapes(
- theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
- theIsStoreAsGenerated);
+ myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
}
}
MODEL_EXPORT virtual ~Model_ResultBody();
/// load and orient modified shapes for sub-objects
- MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
- const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false,
- const bool theSplitInSubs = false);
+ MODEL_EXPORT
+ virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName) override;
/// Returns the number of sub-elements
MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {};
/// Stores the shape (called by the execution method).
- virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ virtual void store(const GeomShapePtr& theShape,
const bool theIsStoreSameShapes = true) = 0;
/// Stores the generated shape (called by the execution method).
- virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape) = 0;
+ virtual void storeGenerated(const GeomShapePtr& theFromShape,
+ const GeomShapePtr& theToShape) = 0;
/// Stores the modified shape (called by the execution method).
- virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const int theDecomposeSolidsTag = 0) = 0;
+ virtual void storeModified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const bool theIsCleanStored = true) = 0;
/// Stores the shape without naming support
- virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+ virtual void storeWithoutNaming(const GeomShapePtr& theShape) = 0;
/// Returns the shape-result produced by this feature
- virtual std::shared_ptr<GeomAPI_Shape> shape() = 0;
+ virtual GeomShapePtr shape() = 0;
/// Records the subshape newShape which was generated during a topological construction.
/// As an example, consider the case of a face generated in construction of a box.
- virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+ virtual void generated(const GeomShapePtr& theNewShape,
const std::string& theName) = 0;
/// Records the shape newShape which was generated from the shape oldShape during a topological
/// construction. As an example, consider the case of a face generated from an edge in
/// construction of a prism.
- virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag = 1) = 0;
+ virtual void generated(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName = "") = 0;
/// Records the shape newShape which is a modification of the shape oldShape.
/// As an example, consider the case of a face split or merged in a Boolean operation.
- virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag = 1) = 0;
+ virtual void modified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName = "") = 0;
/// Records the shape oldShape which was deleted from the current label.
/// As an example, consider the case of a face removed by a Boolean operation.
- virtual void deleted(
- const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
+ virtual void deleted(const GeomShapePtr& theOldShape) = 0;
/// load deleted shapes
- virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const GeomShapePtr theShapes = GeomShapePtr()) = 0;
+ virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const GeomShapePtr& theShapesToAvoid = GeomShapePtr()) = 0;
+
/// load and orient modified shapes
- virtual void loadAndOrientModifiedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate = false,
- const bool theIsStoreAsGenerated = false) = 0;
+ virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName = "") = 0;
+
/// load and orient generated shapes
- virtual void loadAndOrientGeneratedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
+ virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
+ GeomShapePtr theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ const std::string& theName,
+ GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
/// load shapes of the first level (to be used during shape import)
- virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag) = 0;
+ virtual void loadFirstLevel(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag) = 0;
/// load disconnected edges
- virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag) = 0;
+ virtual void loadDisconnectedEdges(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag) = 0;
/// load disconnected vetexes
- virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName,int& theTag) = 0;
+ virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag) = 0;
/// Converts evolution of sub-shapes stored in naming structure to selection
/// (theFlag = true) and back (theFlag = false)
/// Returns true if the latest modification of this body in the naming history
// is equal to the given shape
- virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+ virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0;
protected:
/// Returns the data manager of this object: attributes
return group();
}
-void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const bool theIsStoreSameShapes)
+void ModelAPI_ResultBody::store(const GeomShapePtr& theShape,
+ const bool theIsStoreSameShapes)
{
myBuilder->store(theShape, theIsStoreSameShapes);
myConnect = ConnectionNotComputed;
updateSubs(theShape);
}
-void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape)
+void ModelAPI_ResultBody::storeGenerated(const GeomShapePtr& theFromShape,
+ const GeomShapePtr& theToShape)
{
myBuilder->storeGenerated(theFromShape, theToShape);
myConnect = ConnectionNotComputed;
updateSubs(theToShape);
}
-void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const int theDecomposeSolidsTag)
+void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const bool theIsCleanStored)
{
- myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+ myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored);
myConnect = ConnectionNotComputed;
static Events_Loop* aLoop = Events_Loop::loop();
updateSubs(theNewShape);
}
-void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
+void ModelAPI_ResultBody::storeWithoutNaming(const GeomShapePtr& theShape)
{
myBuilder->storeWithoutNaming(theShape);
myConnect = ConnectionNotComputed;
aECreator->sendUpdated(data()->owner(), aRedispEvent);
}
-std::shared_ptr<GeomAPI_Shape> ModelAPI_ResultBody::shape()
+GeomShapePtr ModelAPI_ResultBody::shape()
{
return myBuilder->shape();
}
-void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+void ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape,
const std::string& theName)
{
myBuilder->generated(theNewShape, theName);
}
-void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag)
+void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName)
{
- myBuilder->generated(theOldShape, theNewShape, theName, theTag);
+ myBuilder->generated(theOldShape, theNewShape, theName);
}
-void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag)
+void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName)
{
- myBuilder->modified(theOldShape, theNewShape, theName, theTag);
+ myBuilder->modified(theOldShape, theNewShape, theName);
}
-void ModelAPI_ResultBody::deleted(
- const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
+void ModelAPI_ResultBody::deleted(const GeomShapePtr& theOldShape)
{
- myBuilder->deleted(theOldShape, theTag);
+ myBuilder->deleted(theOldShape);
}
-void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const GeomShapePtr theShapes)
+void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const GeomShapePtr& theShapesToExclude)
{
- myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag, theShapes);
+ myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude);
}
-void ModelAPI_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
- const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate,
- const bool theIsStoreAsGenerated,
- const bool /*theSplitInSubs*/)
+void ModelAPI_ResultBody::loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName)
{
- myBuilder->loadAndOrientModifiedShapes(
- theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
- theIsStoreAsGenerated);
+ myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
}
void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
- const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
+ GeomShapePtr theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ const std::string& theName,
+ GeomAPI_DataMapOfShapeShape& theSubShapes)
{
myBuilder->loadAndOrientGeneratedShapes(
theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
}
-void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag)
+void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag)
{
myBuilder->loadFirstLevel(theShape, theName, theTag);
}
-void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag)
+void ModelAPI_ResultBody::loadDisconnectedEdges(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag)
{
myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
}
-void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag)
+void ModelAPI_ResultBody::loadDisconnectedVertexes(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag)
{
myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
}
/// param[in] theShape shape to store.
/// param[in] theIsStoreSameShapes if false stores reference to the same shape
/// if it is already in document.
- MODELAPI_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const bool theIsStoreSameShapes = true);
+ MODELAPI_EXPORT virtual void store(const GeomShapePtr& theShape,
+ const bool theIsStoreSameShapes = true);
/// Stores the generated shape (called by the execution method).
- MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape);
+ MODELAPI_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
+ const GeomShapePtr& theToShape);
/// Stores the modified shape (called by the execution method).
- MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
+ MODELAPI_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const bool theIsCleanStored = true);
/// Stores the shape without naming support
- MODELAPI_EXPORT virtual void storeWithoutNaming(
- const std::shared_ptr<GeomAPI_Shape>& theShape);
+ MODELAPI_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape);
/// Returns the shape-result produced by this feature
- MODELAPI_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+ MODELAPI_EXPORT virtual GeomShapePtr shape();
/// Records the subshape newShape which was generated during a topological construction.
/// As an example, consider the case of a face generated in construction of a box.
- MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+ MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theNewShape,
const std::string& theName);
/// Records the shape newShape which was generated from the shape oldShape during a topological
/// construction. As an example, consider the case of a face generated from an edge in
/// construction of a prism.
- MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag = 1);
+ MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName = "");
/// Records the shape newShape which is a modification of the shape oldShape.
/// As an example, consider the case of a face split or merged in a Boolean operation.
- MODELAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag = 1);
+ MODELAPI_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
+ const GeomShapePtr& theNewShape,
+ const std::string& theName = "");
/// Records the shape oldShape which was deleted from the current label.
/// As an example, consider the case of a face removed by a Boolean operation.
- MODELAPI_EXPORT virtual void deleted(
- const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1);
+ MODELAPI_EXPORT virtual void deleted(const GeomShapePtr& theOldShape);
/// load deleted shapes
- MODELAPI_EXPORT virtual void loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const GeomShapePtr theShapes = GeomShapePtr());
+ MODELAPI_EXPORT
+ virtual void loadDeletedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const GeomShapePtr& theShapesToExclude = GeomShapePtr());
/// load and orient modified shapes
- MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
- const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false,
- const bool theSplitInSubs = false);
+ MODELAPI_EXPORT
+ virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName = "");
/// load and orient generated shapes
- MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
- const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes);
+ MODELAPI_EXPORT
+ virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
+ GeomShapePtr theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ const std::string& theName,
+ GeomAPI_DataMapOfShapeShape& theSubShapes);
/// load shapes of the first level (to be used during shape import)
- MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag);
+ MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag);
/// load disconnected edges
- MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag);
+ MODELAPI_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag);
/// load disconnected vetexes
- MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag);
+ MODELAPI_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
+ const std::string& theName,
+ int& theTag);
/// Returns true if the latest modification of this body in the naming history
// is equal to the given shape
- MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+ MODELAPI_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0;
/// Returns true is the topology is connected.
MODELAPI_EXPORT virtual bool isConnectedTopology() = 0;
MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
/// Updates the sub-bodies if shape of this object is compsolid or compound
- MODELAPI_EXPORT virtual void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
+ MODELAPI_EXPORT virtual void updateSubs(const GeomShapePtr& theThisShape,
const bool theShapeChanged = true) = 0;
protected: