for (; anExp.more() && aPointsIt != aPoints.cend(); anExp.next(), ++aPointsIt) {
GeomShapePtr aPoint = *aPointsIt;
GeomShapePtr anEdge = anExp.current();
- aResultBody->generated(aPoint, anEdge, "Edge");
+ aResultBody->generated(aPoint, anEdge);
}
if (!isClosed) {
ListOfMakeShape::const_iterator aGenMSIt = aGenMakeShapes.cbegin();
for(; aGenBaseIt != aGenBaseShapes.cend() && aGenMSIt != aGenMakeShapes.cend();
++aGenBaseIt, ++aGenMSIt) {
- storeGenerationHistory(aResultBody, *aGenBaseIt, *aGenMSIt, aTag);
+ storeGenerationHistory(aResultBody, *aGenBaseIt, *aGenMSIt);
}
- int aModTag = aTag;
- storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt, aModTag);
+ storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt);
ResultBaseAlgo aRBA;
aRBA.resultBody = aResultBody;
aRBA.baseShape = *aBoolObjIt;
aRBA.makeShape = *aBoolMSIt;
- aRBA.delTag = aModTag;
aResultBaseAlgoList.push_back(aRBA);
aResultShapesList.push_back((*aBoolMSIt)->shape());
}
void FeaturesPlugin_CompositeBoolean::storeModificationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theObject,
const ListOfShape& theTools,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag)
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
{
- int aModTag = theTag;
- int anEdgesAndFacesTag = ++aModTag;
- int aDelTag = ++anEdgesAndFacesTag;
- theTag = aDelTag;
-
const std::string aModName = "Modfied";
ListOfShape aTools = theTools;
std::string aName;
for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) {
- if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) {
- aName = aModName + "_Edge";
- }
- else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) {
- aName = aModName + "_Face";
- } else {
- aName = aModName;
- }
theResultBody->loadModifiedShapes(theMakeShape, *anIt,
(*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
GeomAPI_Shape::EDGE :
- GeomAPI_Shape::FACE,
- aName);
+ GeomAPI_Shape::FACE);
}
}
ResultBodyPtr resultBody;
GeomShapePtr baseShape;
std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape;
- int delTag;
};
protected:
/// Stores generation history.
virtual void storeGenerationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag) = 0;
+ const GeomMakeShapePtr theMakeShape) = 0;
/// Stores modification history.
void storeModificationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theObject,
const ListOfShape& theTools,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag);
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
/// Stores deleted shapes.
void storeDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
static void storeSubShape(ResultBodyPtr theResultBody,
const GeomShapePtr theShape,
const GeomAPI_Shape::ShapeType theType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
int& theShapeIndex);
aResultBody->storeGenerated(theBaseShape, theMakeShape->shape());
// Store generated edges/faces.
- int aGenTag = 1;
- storeGenerationHistory(aResultBody, theBaseShape, theMakeShape, aGenTag);
+ storeGenerationHistory(aResultBody, theBaseShape, theMakeShape);
setResult(aResultBody, theIndex);
}
//=================================================================================================
void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag)
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
{
GeomAPI_Shape::ShapeType aBaseShapeType = theBaseShape->shapeType();
GeomAPI_Shape::ShapeType aShapeTypeToExplode = GeomAPI_Shape::SHAPE;
- std::string aGenName = "Generated_";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = theMakeShape->mapOfSubShapes();
switch(aBaseShapeType) {
case GeomAPI_Shape::EDGE: {
aShapeTypeToExplode = GeomAPI_Shape::VERTEX;
break;
}
case GeomAPI_Shape::WIRE: {
- //std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
- //GeomAlgoAPI_ShapeTools::findBounds(theBaseShape, aV1, aV2);
- //ListOfShape aV1History, aV2History;
- //theMakeShape->generated(aV1, aV1History);
- //theMakeShape->generated(aV2, aV2History);
- //if(!aV1History.empty()) {
- // theResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", theTag++);
- //}
- //if(!aV2History.empty()) {
- // theResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", theTag++);
- //}
aShapeTypeToExplode = GeomAPI_Shape::COMPOUND;
break;
}
}
}
+ int aLateralIndex = 1;
+ int aBaseEdgeIndex = 1;
+ int aVertexIndex = 1;
+ int aBaseVertexIndex = 1;
+
if(aShapeTypeToExplode == GeomAPI_Shape::VERTEX ||
aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
- theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape,
- GeomAPI_Shape::VERTEX,
- theTag++, aGenName + "Edge",
- *aMapOfSubShapes.get());
+ theResultBody->loadGeneratedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX);
}
if(aShapeTypeToExplode == GeomAPI_Shape::EDGE ||
aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
- theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(),
- theBaseShape, GeomAPI_Shape::EDGE,
- theTag++, aGenName + "Face",
- *aMapOfSubShapes.get());
+ theResultBody->loadGeneratedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
}
// issue #2197: make naming of edges generated from vertices
if (aShapeTypeToExplode == GeomAPI_Shape::EDGE) {
if (anEdgesFromVertices.isBound(aGenerated)) // already here
continue;
std::ostringstream aStream;
- aStream << "Lateral_" << theTag++;
+ aStream << "Lateral_" << aLateralIndex++;
theResultBody->generated(aGenerated, aStream.str());
anEdgesFromVertices.bind(aGenerated, aVertExp.current());
if (!anEdgesFromVertices.isBound(anEdgesExp.current())) {
// found a base edge
std::ostringstream aStream;
- aStream << "Base_Edge_" << theTag++;
+ aStream << "Base_Edge_" << aBaseEdgeIndex++;
theResultBody->generated(anEdgesExp.current(), aStream.str());
// only one orientation is needed
anEdgesFromVertices.bind(anEdgesExp.current(), anEdgesExp.current());
if (!aVertices.isBound(aVertExp.current())) {
// found a base edge
std::ostringstream aStream;
- aStream << "Vertex_" << theTag++;
+ aStream << "Vertex_" << aVertexIndex++;
theResultBody->generated(aVertExp.current(), aStream.str());
// only one orientation is needed
aVertices.bind(aVertExp.current(), aVertExp.current());
}
if (aNumEdges == 2 && aNumClosed == 1) {
std::ostringstream aStream;
- aStream << "Base_Edge_" << theTag++;
+ aStream << "Base_Edge_" << aBaseEdgeIndex++;
theResultBody->generated(aNotClosedEdge, aStream.str());
if (aDegenerateEdge.get()) { // export vertex of the degenerated edge (apex) #2520
GeomAPI_ShapeExplorer anEdgeExp(aDegenerateEdge, GeomAPI_Shape::VERTEX);
if (anEdgeExp.more()) {
std::ostringstream aStream;
- aStream << "Base_Vertex_" << theTag++;
+ aStream << "Base_Vertex_" << aBaseVertexIndex++;
theResultBody->generated(anEdgeExp.current(), aStream.str());
}
}
std::dynamic_pointer_cast<GeomAlgoAPI_MakeSweep>(theMakeShape);
if(aMakeSweep.get()) {
// Store from shapes.
- storeShapes(theResultBody, aBaseShapeType, aMapOfSubShapes,
- aMakeSweep->fromShapes(), "From_", theTag);
+ storeShapes(theResultBody, aBaseShapeType, aMakeSweep->fromShapes(), "From_");
// Store to shapes.
- storeShapes(theResultBody, aBaseShapeType, aMapOfSubShapes,
- aMakeSweep->toShapes(), "To_", theTag);
+ storeShapes(theResultBody, aBaseShapeType, aMakeSweep->toShapes(), "To_");
}
}
//=================================================================================================
void FeaturesPlugin_CompositeSketch::storeShapes(ResultBodyPtr theResultBody,
const GeomAPI_Shape::ShapeType theBaseShapeType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const ListOfShape& theShapes,
- const std::string theName,
- int& theTag)
+ const std::string theName)
{
GeomAPI_Shape::ShapeType aShapeTypeToExplore = GeomAPI_Shape::FACE;
std::string aShapeTypeStr = "Face";
storeSubShape(theResultBody,
aShape,
aShape->shapeType(),
- theMapOfSubShapes,
aName,
aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex);
} else {
std::string aName = theName + aShapeTypeStr;
- storeSubShape(theResultBody, aShape, aShapeTypeToExplore,
- theMapOfSubShapes, aName, aShapeIndex);
+ storeSubShape(theResultBody,
+ aShape,
+ aShapeTypeToExplore,
+ aName,
+ aShapeIndex);
if (theBaseShapeType == GeomAPI_Shape::WIRE) { // issue 2289: special names also for vertices
aName = theName + "Vertex";
- storeSubShape(theResultBody, aShape, GeomAPI_Shape::VERTEX,
- theMapOfSubShapes, aName, aShapeIndex);
+ storeSubShape(theResultBody,
+ aShape,
+ GeomAPI_Shape::VERTEX,
+ aName,
+ aShapeIndex);
}
}
}
void storeSubShape(ResultBodyPtr theResultBody,
const GeomShapePtr theShape,
const GeomAPI_Shape::ShapeType theType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
int& theShapeIndex)
{
for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
GeomShapePtr aSubShape = anExp.current();
- if(theMapOfSubShapes->isBound(aSubShape)) {
- aSubShape = theMapOfSubShapes->find(aSubShape);
- }
std::ostringstream aStr;
aStr << theName << "_" << theShapeIndex++;
theResultBody->generated(aSubShape, aStr.str());
/// Stores generation history.
void storeGenerationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag);
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
/// Used to store from and to shapes.
void storeShapes(ResultBodyPtr theResultBody,
const GeomAPI_Shape::ShapeType theBaseShapeType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const ListOfShape& theShapes,
- const std::string theName,
- int& theTag);
+ const std::string theName);
};
//=================================================================================================
void FeaturesPlugin_ExtrusionBoolean::storeGenerationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag)
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
{
- FeaturesPlugin_Extrusion::storeGenerationHistory(theResultBody, theBaseShape,
- theMakeShape, theTag);
+ FeaturesPlugin_Extrusion::storeGenerationHistory(theResultBody, theBaseShape, theMakeShape);
}
/// Stores generation history.
void storeGenerationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag);
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
};
#endif
std::shared_ptr<ModelAPI_ResultBody> aResultBody =
document()->createBody(data(), aResultIndex);
- loadNamingDS(aResultBody, aSolid, aFilletEdgesAndVertices, aResult, aFilletBuilder);
+ loadNamingDS(aResultBody, aSolid, aResult, aFilletBuilder);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
void FeaturesPlugin_Fillet::loadNamingDS(
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
const std::shared_ptr<GeomAPI_Shape> theBaseShape,
- const ListOfShape& theFilletShapes,
const std::shared_ptr<GeomAPI_Shape> theResultShape,
const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape)
{
return;
}
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = theMakeShape->mapOfSubShapes();
-
- const int aGeneratedTag = 3;
-
theResultBody->storeModified(theBaseShape, theResultShape);
- const std::string aModFaceName = "Modified_Face";
const std::string aFilletFaceName = "Fillet_Face";
// Store modified faces
- theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aModFaceName);
+ theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
// Store new faces generated from edges and vertices
- theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape,
- GeomAPI_Shape::EDGE, aGeneratedTag, aFilletFaceName, *aMapOfShapes);
- theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape,
- GeomAPI_Shape::VERTEX, aGeneratedTag, aFilletFaceName, *aMapOfShapes);
+ theResultBody->loadGeneratedShapes(theMakeShape,
+ theBaseShape,
+ GeomAPI_Shape::EDGE,
+ aFilletFaceName);
+ theResultBody->loadGeneratedShapes(theMakeShape,
+ theBaseShape,
+ GeomAPI_Shape::VERTEX,
+ aFilletFaceName);
// Deleted shapes
theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
/// 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& theFilletShapes,
const std::shared_ptr<GeomAPI_Shape> theResultShape,
const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape);
};
static void storeSubShape(ResultBodyPtr theResultBody,
const GeomShapePtr theShape,
const GeomAPI_Shape::ShapeType theType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
int& theShapeIndex);
anIter = aBaseShapesList.cbegin(); anIter != aBaseShapesList.cend(); anIter++) {
std::shared_ptr<GeomAPI_Shape> aBaseShape = *anIter;
- GeomAlgoAPI_Pipe aPipeAlgo = aCreationMethod ==
- CREATION_METHOD_SIMPLE() ? GeomAlgoAPI_Pipe(aBaseShape, aPathShape) :
- GeomAlgoAPI_Pipe(aBaseShape, aPathShape, aBiNormal);
+ std::shared_ptr<GeomAlgoAPI_Pipe> aPipeAlgo(
+ aCreationMethod == CREATION_METHOD_SIMPLE() ? new GeomAlgoAPI_Pipe(aBaseShape,
+ aPathShape)
+ : new GeomAlgoAPI_Pipe(aBaseShape,
+ aPathShape,
+ aBiNormal));
- if(!aPipeAlgo.isDone()) {
+ if(!aPipeAlgo->isDone()) {
setError("Error: Pipe algorithm failed.");
aResultIndex = 0;
break;
}
// Check if shape is valid
- if(!aPipeAlgo.shape().get() || aPipeAlgo.shape()->isNull()) {
+ if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) {
setError("Error: Resulting shape is Null.");
aResultIndex = 0;
break;
}
- if(!aPipeAlgo.isValid()) {
+ if(!aPipeAlgo->isValid()) {
setError("Error: Resulting shape is not valid.");
aResultIndex = 0;
break;
storeResult(aBaseShape, aPipeAlgo, aResultIndex++);
}
} else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) {
- GeomAlgoAPI_Pipe aPipeAlgo = GeomAlgoAPI_Pipe(aBaseShapesList, aLocations, aPathShape);
+ std::shared_ptr<GeomAlgoAPI_Pipe> aPipeAlgo(new GeomAlgoAPI_Pipe(aBaseShapesList,
+ aLocations,
+ aPathShape));
- if(!aPipeAlgo.isDone()) {
+ if(!aPipeAlgo->isDone()) {
setError("Error: Pipe algorithm failed.");
removeResults(0);
return;
}
// Check if shape is valid
- if(!aPipeAlgo.shape().get() || aPipeAlgo.shape()->isNull()) {
+ if(!aPipeAlgo->shape().get() || aPipeAlgo->shape()->isNull()) {
setError("Error: Resulting shape is Null.");
removeResults(0);
return;
}
- if(!aPipeAlgo.isValid()) {
+ if(!aPipeAlgo->isValid()) {
setError("Error: Resulting shape is not valid.");
removeResults(0);
return;
//==================================================================================================
void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
- GeomAlgoAPI_Pipe& thePipeAlgo,
+ const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex)
{
// Create result body.
ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
// Store generated shape.
- aResultBody->storeGenerated(theBaseShape, thePipeAlgo.shape());
+ aResultBody->storeGenerated(theBaseShape, thePipeAlgo->shape());
// Store generated edges/faces.
GeomAPI_Shape::ShapeType aBaseShapeType = theBaseShape->shapeType();
GeomAPI_Shape::ShapeType aShapeTypeToExplode;
- int aGenTag = 1;
- std::string aGenName = "Generated_";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = thePipeAlgo.mapOfSubShapes();
switch(aBaseShapeType) {
case GeomAPI_Shape::VERTEX: {
aShapeTypeToExplode = GeomAPI_Shape::VERTEX;
std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
GeomAlgoAPI_ShapeTools::findBounds(theBaseShape, aV1, aV2);
ListOfShape aV1History, aV2History;
- thePipeAlgo.generated(aV1, aV1History);
- thePipeAlgo.generated(aV2, aV2History);
+ thePipeAlgo->generated(aV1, aV1History);
+ thePipeAlgo->generated(aV2, aV2History);
if(!aV1History.empty()) {
- aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1");
+ aResultBody->generated(aV1, aV1History.front());
}
if(!aV2History.empty()) {
- aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2");
+ aResultBody->generated(aV2, aV2History.front());
}
}
case GeomAPI_Shape::FACE:
if(aShapeTypeToExplode == GeomAPI_Shape::VERTEX ||
aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
- aResultBody->loadAndOrientGeneratedShapes(&thePipeAlgo, theBaseShape, GeomAPI_Shape::VERTEX,
- aGenTag++, aGenName + "Edge", *aMapOfSubShapes.get());
+ aResultBody->loadGeneratedShapes(thePipeAlgo, theBaseShape, GeomAPI_Shape::VERTEX);
}
if(aShapeTypeToExplode == GeomAPI_Shape::EDGE ||
aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
- aResultBody->loadAndOrientGeneratedShapes(&thePipeAlgo, theBaseShape, GeomAPI_Shape::EDGE,
- aGenTag++, aGenName + "Face", *aMapOfSubShapes.get());
+ aResultBody->loadGeneratedShapes(thePipeAlgo, theBaseShape, GeomAPI_Shape::EDGE);
}
// Store from shapes.
- int aFromTag = aGenTag;
- storeShapes(aResultBody, aBaseShapeType, aMapOfSubShapes,
- thePipeAlgo.fromShapes(), "From_", aFromTag);
+ storeShapes(aResultBody, aBaseShapeType, thePipeAlgo->fromShapes(), "From_");
// Store to shapes.
- int aToTag = aFromTag;
- storeShapes(aResultBody, aBaseShapeType, aMapOfSubShapes, thePipeAlgo.toShapes(), "To_", aToTag);
+ storeShapes(aResultBody, aBaseShapeType, thePipeAlgo->toShapes(), "To_");
setResult(aResultBody, theResultIndex);
}
//==================================================================================================
void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes,
- GeomAlgoAPI_Pipe& thePipeAlgo,
+ const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex)
{
// Create result body.
ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
// Store generated shape.
- aResultBody->storeGenerated(theBaseShapes.front(), thePipeAlgo.shape());
+ aResultBody->storeGenerated(theBaseShapes.front(), thePipeAlgo->shape());
// Store generated edges/faces.
- int aGenTag = 1;
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = thePipeAlgo.mapOfSubShapes();
-
- for(ListOfShape::const_iterator
- anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) {
+ for(ListOfShape::const_iterator anIter = theBaseShapes.cbegin();
+ anIter != theBaseShapes.cend();
+ ++anIter)
+ {
GeomShapePtr aBaseShape = *anIter;
GeomAPI_Shape::ShapeType aBaseShapeType = aBaseShape->shapeType();
GeomAPI_Shape::ShapeType aShapeTypeToExplode;
- std::string aGenName = "Generated_";
switch(aBaseShapeType) {
case GeomAPI_Shape::VERTEX: {
aShapeTypeToExplode = GeomAPI_Shape::VERTEX;
- aGenName += "Edge";
break;
}
case GeomAPI_Shape::EDGE:
std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
GeomAlgoAPI_ShapeTools::findBounds(aBaseShape, aV1, aV2);
ListOfShape aV1History, aV2History;
- thePipeAlgo.generated(aV1, aV1History);
- thePipeAlgo.generated(aV2, aV2History);
- aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1");
- aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2");
+ thePipeAlgo->generated(aV1, aV1History);
+ thePipeAlgo->generated(aV2, aV2History);
+ aResultBody->generated(aV1, aV1History.front());
+ aResultBody->generated(aV2, aV2History.front());
}
case GeomAPI_Shape::FACE:
case GeomAPI_Shape::SHELL: {
aShapeTypeToExplode = GeomAPI_Shape::EDGE;
- aGenName += "Face";
break;
}
}
- aResultBody->loadAndOrientGeneratedShapes(&thePipeAlgo, aBaseShape, aShapeTypeToExplode,
- aGenTag++, aGenName, *aMapOfSubShapes.get());
+ aResultBody->loadGeneratedShapes(thePipeAlgo, aBaseShape, aShapeTypeToExplode);
}
// Store from shapes.
- int aFromTag = aGenTag;
- storeShapes(aResultBody, theBaseShapes.front()->shapeType(), aMapOfSubShapes,
- thePipeAlgo.fromShapes(), "From", aFromTag);
+ storeShapes(aResultBody, theBaseShapes.front()->shapeType(), thePipeAlgo->fromShapes(), "From_");
// Store to shapes.
- int aToTag = aFromTag;
- storeShapes(aResultBody, theBaseShapes.back()->shapeType(),
- aMapOfSubShapes, thePipeAlgo.toShapes(), "To", aToTag);
+ storeShapes(aResultBody, theBaseShapes.back()->shapeType(), thePipeAlgo->toShapes(), "To_");
setResult(aResultBody, theResultIndex);
//==================================================================================================
void FeaturesPlugin_Pipe::storeShapes(ResultBodyPtr theResultBody,
- const GeomAPI_Shape::ShapeType theBaseShapeType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
- const ListOfShape& theShapes,
- const std::string theName,
- int& theTag)
+ const GeomAPI_Shape::ShapeType theBaseShapeType,
+ const ListOfShape& theShapes,
+ const std::string theName)
{
GeomAPI_Shape::ShapeType aShapeTypeToExplore = GeomAPI_Shape::FACE;
std::string aShapeTypeStr = "Face";
if(aShapeTypeToExplore == GeomAPI_Shape::COMPOUND) {
std::string aName = theName + (aShape->shapeType() == GeomAPI_Shape::EDGE ? "Edge" : "Face");
- storeSubShape(theResultBody,
- aShape,
+ storeSubShape(theResultBody, aShape,
aShape->shapeType(),
- theMapOfSubShapes,
aName,
aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex);
} else {
std::string aName = theName + aShapeTypeStr;
- storeSubShape(theResultBody, aShape, aShapeTypeToExplore,
- theMapOfSubShapes, aName, aShapeIndex);
+ storeSubShape(theResultBody, aShape, aShapeTypeToExplore, aName, aShapeIndex);
}
}
}
void storeSubShape(ResultBodyPtr theResultBody,
const GeomShapePtr theShape,
const GeomAPI_Shape::ShapeType theType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
int& theShapeIndex)
{
for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
GeomShapePtr aSubShape = anExp.current();
- if(theMapOfSubShapes->isBound(aSubShape)) {
- aSubShape = theMapOfSubShapes->find(aSubShape);
- }
std::ostringstream aStr;
aStr << theName << "_" << theShapeIndex++;
theResultBody->generated(aSubShape, aStr.str());
private:
void storeResult(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
- GeomAlgoAPI_Pipe& thePipeAlgo,
+ const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex = 0);
void storeResult(const ListOfShape& theBaseShapes,
- GeomAlgoAPI_Pipe& thePipeAlgo,
+ const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex = 0);
void storeShapes(ResultBodyPtr theResultBody,
const GeomAPI_Shape::ShapeType theBaseShapeType,
- const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const ListOfShape& theShapes,
- const std::string theName,
- int& theTag);
+ const std::string theName);
};
#endif
//=================================================================================================
void FeaturesPlugin_RevolutionBoolean::storeGenerationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag)
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
{
- FeaturesPlugin_Revolution::storeGenerationHistory(theResultBody, theBaseShape,
- theMakeShape, theTag);
+ FeaturesPlugin_Revolution::storeGenerationHistory(theResultBody, theBaseShape, theMakeShape);
}
/// Stores generation history.
void storeGenerationHistory(ResultBodyPtr theResultBody,
const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
- int& theTag);
+ const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
};
#endif
theResultBody->loadModifiedShapes(theMakeShape,
theBaseShape,
GeomAPI_Shape::FACE,
- theName + "_Face");
+ theName);
}
case GeomAPI_Shape::FACE:
case GeomAPI_Shape::WIRE: {
theResultBody->loadModifiedShapes(theMakeShape,
theBaseShape,
GeomAPI_Shape::EDGE,
- theName + "_Edge");
+ theName);
}
case GeomAPI_Shape::EDGE: {
theResultBody->loadModifiedShapes(theMakeShape,
theBaseShape,
GeomAPI_Shape::VERTEX,
- theName + "_Vertex");
+ theName);
}
}
}
{
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
std::string aName = theName;
+ std::string aPrefix = "";
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;
+ case GENERATED_VERTICES_TAG: aPrefix = aName.empty() ? "Generated_Vertex" : "GV:"; break;
+ case GENERATED_EDGES_TAG: aPrefix = aName.empty() ? "Generated_Edge" : "GE:"; break;
+ case GENERATED_FACES_TAG: aPrefix = aName.empty() ? "Generated_Face" : "GF:"; break;
+ case MODIFIED_VERTICES_TAG: aPrefix = aName.empty() ? "Modified_Vertex" : "MV:"; break;
+ case MODIFIED_EDGES_TAG: aPrefix = aName.empty() ? "Modified_Edge" : "ME:"; break;
+ case MODIFIED_FACES_TAG: aPrefix = aName.empty() ? "Modified_Face" : "MF:"; break;
}
+ aName.insert(0, aPrefix);
TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str());
}
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;
+ TopAbs_ShapeEnum aShapeTypeToExplore = 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()) {
+ for (TopExp_Explorer anExp(aNewShape, aShapeTypeToExplore); anExp.More(); anExp.Next()) {
builder(aTag)->Generated(anOldShape, anExp.Current());
- buildName(aTag, theName);
}
+ buildName(aTag, theName);
} else {
aTag = getGenerationTag(aNewShape);
if (aTag == INVALID_TAG) return;
}
// Keep only the shapes with minimal shape type
-static void keepTopLevelShapes(ListOfShape& theShapes, const TopoDS_Shape& theRoot,
- const GeomShapePtr& theResultShape = GeomShapePtr())
+static void keepTopLevelShapes(ListOfShape& theShapes,
+ const TopoDS_Shape& theRoot,
+ const GeomShapePtr& theResultShape = GeomShapePtr())
{
GeomAPI_Shape::ShapeType aKeepShapeType = GeomAPI_Shape::SHAPE;
ListOfShape::iterator anIt = theShapes.begin();
}
}
-void Model_BodyBuilder::loadAndOrientGeneratedShapes (
- GeomAlgoAPI_MakeShape* theMS,
- GeomShapePtr theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes)
+void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName)
{
- TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
- TopTools_MapOfShape aView;
- bool isBuilt = !theName.empty();
- TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- //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;
- GeomShapePtr aRShape(new GeomAPI_Shape());
- aRShape->setImpl((new TopoDS_Shape(aRoot)));
- theMS->generated(aRShape, aList);
- keepTopLevelShapes(aList, aRoot);
- 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)) {
- GeomShapePtr aMapShape(theSubShapes.find(*anIt));
- aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
- }
- if (!aRoot.IsSame (aNewShape)) {
- builder(theTag)->Generated(aRoot,aNewShape);
- if(isBuilt)
- 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(aRoot, anExp.Current());
- TCollection_AsciiString aChildName =
- TCollection_AsciiString((theName + "_").c_str()) + aTag;
- TDataStd_Name::Set(aChildLabel, aChildName.ToCString());
- aTag++;
+ TopTools_MapOfShape anAlreadyProcessedShapes;
+ for (GeomAPI_ShapeExplorer anOldShapeExp(theOldShape, theShapeTypeToExplore);
+ anOldShapeExp.more();
+ anOldShapeExp.next())
+ {
+ GeomShapePtr anOldSubShape = anOldShapeExp.current();
+ const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl<TopoDS_Shape>();
+
+ // There is no sense to write history if shape already processed.
+ if (!anAlreadyProcessedShapes.Add(anOldSubShape_)) continue;
+
+ // Get new shapes.
+ ListOfShape aNewShapes;
+ theAlgo->generated(anOldSubShape, aNewShapes);
+
+ keepTopLevelShapes(aNewShapes, anOldSubShape_);
+
+ for (ListOfShape::const_iterator aNewShapesIt = aNewShapes.cbegin();
+ aNewShapesIt != aNewShapes.cend();
+ ++aNewShapesIt)
+ {
+ GeomShapePtr aNewShape = *aNewShapesIt;
+ const TopoDS_Shape& aNewShape_ = aNewShape->impl<TopoDS_Shape>();
+
+ TopAbs_ShapeEnum aNewShapeType = aNewShape_.ShapeType();
+ if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) {
+ // TODO: This is a workaround. New shape should be only edge or face.
+ TopAbs_ShapeEnum aShapeTypeToExplore = aNewShapeType == TopAbs_WIRE ? TopAbs_EDGE
+ : TopAbs_FACE;
+ int aTag = TopAbs_WIRE ? GENERATED_EDGES_TAG : GENERATED_FACES_TAG;
+ for (TopExp_Explorer anExp(aNewShape_, aShapeTypeToExplore); anExp.More(); anExp.Next()) {
+ builder(aTag)->Generated(anOldSubShape_, anExp.Current());
}
+ buildName(aTag, theName);
+ }
+ else {
+ int aTag = getGenerationTag(aNewShape_);
+ if (aTag == INVALID_TAG) return;
+ builder(aTag)->Generated(anOldSubShape_, aNewShape_);
+ buildName(aTag, theName);
}
}
}
/// 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);
+ virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName = "") override;
/// Loads shapes of the first level (to be used during shape import)
MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
const std::string& theName = "") = 0;
/// load and orient generated shapes
- virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
- GeomShapePtr theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
+ virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName = "") = 0;
/// load shapes of the first level (to be used during shape import)
virtual void loadFirstLevel(GeomShapePtr theShape,
myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
}
-void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
- 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::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName)
+{
+ myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
}
void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
/// load and orient generated shapes
MODELAPI_EXPORT
- virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
- GeomShapePtr theShapeIn,
- const int theKindOfShape,
- const int theTag,
- const std::string& theName,
- GeomAPI_DataMapOfShapeShape& theSubShapes);
+ virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
+ const GeomShapePtr& theOldShape,
+ const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
+ const std::string& theName = "");
/// load shapes of the first level (to be used during shape import)
MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,