int anEdgeIndex = 1;
for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
GeomShapePtr anEdge = anExp.current();
- aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeIndex), anEdgeIndex);
+ aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeIndex));
++anEdgeIndex;
}
int anEdgeInd = 0;
for(GeomAPI_ShapeExplorer anExp(aCreatedFace, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
GeomShapePtr anEdge = anExp.current();
- aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeInd), ++anEdgeInd);
+ aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeInd));
}
setResult(aResultBody, 0);
}
int aVertexIndex = 1;
for (GeomAPI_ShapeExplorer anExp(anEdge, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) {
std::string aVertexName = "Vertex_" + std::to_string((long long)aVertexIndex);
- aResultBody->generated(anExp.current(), aVertexName, aVertexIndex++);
+ aResultBody->generated(anExp.current(), aVertexName);
}
setResult(aResultBody);
aResPoints.push_back(anExp.current());
}
- aResultBody->generated(aResPoints.front(), "FirstVertex", 2);
- aResultBody->generated(aResPoints.back(), "LastVertex", 3);
+ aResultBody->generated(aResPoints.front(), "FirstVertex");
+ aResultBody->generated(aResPoints.back(), "LastVertex");
}
setResult(aResultBody);
const GeomAPI_Shape::ShapeType theType,
const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
- int& theShapeIndex,
- int& theTag);
+ int& theShapeIndex);
//=================================================================================================
void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int theInitFlags)
if (anEdgesFromVertices.isBound(aGenerated)) // already here
continue;
std::ostringstream aStream;
- aStream<<"Lateral_"<<theTag++;
- theResultBody->generated(aGenerated, aStream.str(), theTag++);
+ aStream << "Lateral_" << theTag++;
+ theResultBody->generated(aGenerated, aStream.str());
anEdgesFromVertices.bind(aGenerated, aVertExp.current());
std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aGenerated));
if (!anEdgesFromVertices.isBound(anEdgesExp.current())) {
// found a base edge
std::ostringstream aStream;
- aStream<<"Base_Edge_"<<theTag++;
- theResultBody->generated(anEdgesExp.current(), aStream.str(), theTag++);
+ aStream << "Base_Edge_" << theTag++;
+ 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++;
- theResultBody->generated(aVertExp.current(), aStream.str(), theTag++);
+ aStream << "Vertex_" << theTag++;
+ 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++;
- theResultBody->generated(aNotClosedEdge, aStream.str(), theTag++);
+ aStream << "Base_Edge_" << theTag++;
+ 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++;
- theResultBody->generated(anEdgeExp.current(), aStream.str(), theTag++);
+ theResultBody->generated(anEdgeExp.current(), aStream.str());
}
}
}
aShape->shapeType(),
theMapOfSubShapes,
aName,
- aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex,
- theTag);
+ aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex);
} else {
std::string aName = theName + aShapeTypeStr;
storeSubShape(theResultBody, aShape, aShapeTypeToExplore,
- theMapOfSubShapes, aName, aShapeIndex, theTag);
+ theMapOfSubShapes, 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, theTag);
+ theMapOfSubShapes, aName, aShapeIndex);
}
}
}
const GeomAPI_Shape::ShapeType theType,
const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
- int& theShapeIndex,
- int& theTag)
+ int& theShapeIndex)
{
for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
GeomShapePtr aSubShape = anExp.current();
}
std::ostringstream aStr;
aStr << theName << "_" << theShapeIndex++;
- theResultBody->generated(aSubShape, aStr.str(), theTag++);
+ theResultBody->generated(aSubShape, aStr.str());
}
}
: aModifiedEdgeIndex++)),
aTag++);
} else {
- theResultBody->generated(aSubShape,
+ theResultBody->generated(
+ aSubShape,
std::string("Generated_")
+ (anIndex == 0 ? "Vertex_" : "Edge_")
+ std::to_string((long long)(anIndex == 0 ? aGeneratedVertexIndex++
- : aGeneratedEdgeIndex++)),
- aTag++);
+ : aGeneratedEdgeIndex++)));
}
aStoredShapes.bind(aSubShape, aSubShape);
}
std::shared_ptr<ModelAPI_ResultBody> theResultBody,
std::shared_ptr<GeomAPI_Shape> theBaseShape, int nb)
{
- int aTag = 6*nb+1;
int anIndex = nb+1;
std::string aRotatedName;
for(; anExp.more(); anExp.next()) {
aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex);
aRotatedName = aRotatedName + "_" + std::to_string((long long) numFace);
- theResultBody->generated(anExp.current(), aRotatedName, aTag++);
+ theResultBody->generated(anExp.current(), aRotatedName);
++numFace;
}
++anIndex;
const GeomAPI_Shape::ShapeType theType,
const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
- int& theShapeIndex,
- int& theTag);
+ int& theShapeIndex);
//==================================================================================================
FeaturesPlugin_Pipe::FeaturesPlugin_Pipe()
aShape->shapeType(),
theMapOfSubShapes,
aName,
- aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex,
- theTag);
+ aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex);
} else {
std::string aName = theName + aShapeTypeStr;
storeSubShape(theResultBody, aShape, aShapeTypeToExplore,
- theMapOfSubShapes, aName, aShapeIndex, theTag);
+ theMapOfSubShapes, aName, aShapeIndex);
}
}
}
const GeomAPI_Shape::ShapeType theType,
const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
const std::string theName,
- int& theShapeIndex,
- int& theTag)
+ int& theShapeIndex)
{
for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
GeomShapePtr aSubShape = anExp.current();
}
std::ostringstream aStr;
aStr << theName << "_" << theShapeIndex++;
- theResultBody->generated(aSubShape, aStr.str(), theTag++);
+ theResultBody->generated(aSubShape, aStr.str());
}
}
theConeSegmentAlgo->prepareNamingFaces();
// Insert to faces
- int num = 1;
std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
theConeSegmentAlgo->getCreatedFaces();
- for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
- it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
- std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
- theResultConeSegment->generated(aFace, (*it).first, num++);
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it != listOfFaces.end();
+ ++it)
+ {
+ theResultConeSegment->generated((*it).second, (*it).first);
}
}
// Insert to faces
// Naming for faces and edges
- int num = 1;
std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
theEllipsoidAlgo->getCreatedFaces();
- for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
- it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
- std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
- theResultEllipsoid->generated(aFace, (*it).first, num++);
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it!=listOfFaces.end();
+ ++it)
+ {
+ theResultEllipsoid->generated((*it).second, (*it).first);
}
// Naming vertices
GeomAPI_DataMapOfShapeShape aVertices;
- GeomAPI_ShapeExplorer aVertExp(theEllipsoidAlgo->shape(), GeomAPI_Shape::VERTEX);
- for(int anIndex = 1; aVertExp.more(); aVertExp.next()) {
+ int anIndex = 1;
+ for (GeomAPI_ShapeExplorer aVertExp(theEllipsoidAlgo->shape(), GeomAPI_Shape::VERTEX);
+ aVertExp.more();
+ aVertExp.next())
+ {
if (!aVertices.isBound(aVertExp.current())) {
std::ostringstream aStream;
aStream<<"Vertex_"<<anIndex++;
- theResultEllipsoid->generated(aVertExp.current(), aStream.str(), num++);
+ theResultEllipsoid->generated(aVertExp.current(), aStream.str());
aVertices.bind(aVertExp.current(), aVertExp.current());
}
}
//#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;
+
Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner)
: ModelAPI_BodyBuilder(theOwner),
+ myPrimitiveTag(PRIMITIVES_START_TAG),
myDividedIndex(1),
myVIndex(1),
myEIndex(1),
myBuilders.clear();
// remove the old reference (if any)
aLab.ForgetAttribute(TDF_Reference::GetID());
+ myPrimitiveTag = PRIMITIVES_START_TAG;
myDividedIndex = 1;
myVIndex = 1;
myEIndex = 1;
//aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), theName);
TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), theName.c_str());
}
-void Model_BodyBuilder::generated(
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
+void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+ const std::string& theName)
{
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
- builder(theTag)->Generated(aShape);
- if(!theName.empty())
- buildName(theTag, theName);
+ builder(myPrimitiveTag)->Generated(aShape);
+ if (!theName.empty()) {
+ buildName(myPrimitiveTag, theName);
+ }
+
+ ++myPrimitiveTag;
}
void Model_BodyBuilder::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
/// 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,
- const std::string& theName, const int theTag = 1);
+ 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
void buildName(const int theTag, const std::string& theName);
private:
+ int myPrimitiveTag;
int myDividedIndex;
int myVIndex;
int myEIndex;
/// 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, const std::string& theName,
- const int theTag = 1) = 0;
+ virtual void generated(const std::shared_ptr<GeomAPI_Shape>& 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
}
void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const std::string& theName, const int theTag)
+ const std::string& theName)
{
- myBuilder->generated(theNewShape, theName, theTag);
+ myBuilder->generated(theNewShape, theName);
}
void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
/// 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,
- const std::string& theName, const int theTag = 1);
+ 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
int num = 1;
std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
theBoxAlgo->getCreatedFaces();
- for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
- it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
- std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
- theResultBox->generated(aFace, (*it).first, num++);
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it != listOfFaces.end();
+ ++it)
+ {
+ theResultBox->generated((*it).second, (*it).first);
}
}
theConeAlgo->prepareNamingFaces();
// Insert to faces
- int num = 1;
std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
theConeAlgo->getCreatedFaces();
int nbFaces = 0;
for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
- std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
- theResultCone->generated(aFace, (*it).first, num++);
+ theResultCone->generated((*it).second, (*it).first);
nbFaces++;
}
if (nbFaces == 2) {
// Naming vertices
GeomAPI_DataMapOfShapeShape aVertices;
- GeomAPI_ShapeExplorer aVertExp(theConeAlgo->shape(), GeomAPI_Shape::VERTEX);
- for(int anIndex = 1; aVertExp.more(); aVertExp.next()) {
+ int anIndex = 1;
+ for (GeomAPI_ShapeExplorer aVertExp(theConeAlgo->shape(), GeomAPI_Shape::VERTEX);
+ aVertExp.more();
+ aVertExp.next())
+ {
if (!aVertices.isBound(aVertExp.current())) {
std::ostringstream aStream;
aStream<<"Vertex_"<<anIndex++;
- theResultCone->generated(aVertExp.current(), aStream.str(), num++);
+ theResultCone->generated(aVertExp.current(), aStream.str());
aVertices.bind(aVertExp.current(), aVertExp.current());
}
}
theCylinderAlgo->prepareNamingFaces();
// Insert to faces
- int num = 1;
std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
theCylinderAlgo->getCreatedFaces();
- for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
- it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
- std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
- theResultCylinder->generated(aFace, (*it).first, num++);
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it != listOfFaces.end();
+ ++it)
+ {
+ theResultCylinder->generated((*it).second, (*it).first);
}
}
// Insert to faces
// Naming for faces and edges
- int num = 1;
std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
theSphereAlgo->getCreatedFaces();
- for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
- it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
- std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
- theResultSphere->generated(aFace, (*it).first, num++);
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it != listOfFaces.end();
+ ++it)
+ {
+ theResultSphere->generated((*it).second, (*it).first);
}
// Naming vertices
GeomAPI_DataMapOfShapeShape aVertices;
- GeomAPI_ShapeExplorer aVertExp(theSphereAlgo->shape(), GeomAPI_Shape::VERTEX);
- for(int anIndex = 1; aVertExp.more(); aVertExp.next()) {
+ int anIndex = 1;
+ for (GeomAPI_ShapeExplorer aVertExp(theSphereAlgo->shape(), GeomAPI_Shape::VERTEX);
+ aVertExp.more();
+ aVertExp.next())
+ {
if (!aVertices.isBound(aVertExp.current())) {
std::ostringstream aStream;
aStream<<"Vertex_"<<anIndex++;
- theResultSphere->generated(aVertExp.current(), aStream.str(), num++);
+ theResultSphere->generated(aVertExp.current(), aStream.str());
aVertices.bind(aVertExp.current(), aVertExp.current());
}
}
int num = 1;
std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
theTorusAlgo->getCreatedFaces();
- for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
- it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
- std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
- theResultTorus->generated(aFace, (*it).first, num++);
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it != listOfFaces.end();
+ ++it)
+ {
+ theResultTorus->generated((*it).second, (*it).first);
}
// Naming of edges
GeomAPI_DataMapOfShapeShape anEdges;
- GeomAPI_ShapeExplorer anEdgeExp(theTorusAlgo->shape(), GeomAPI_Shape::EDGE);
- for(int anIndex = 1; anEdgeExp.more(); anEdgeExp.next()) {
+ int anIndex = 1;
+ for (GeomAPI_ShapeExplorer anEdgeExp(theTorusAlgo->shape(), GeomAPI_Shape::EDGE);
+ anEdgeExp.more();
+ anEdgeExp.next())
+ {
if (!anEdges.isBound(anEdgeExp.current())) {
std::ostringstream aStream;
aStream<<"Edge_"<<anIndex++;
- theResultTorus->generated(anEdgeExp.current(), aStream.str(), num++);
+ theResultTorus->generated(anEdgeExp.current(), aStream.str());
anEdges.bind(anEdgeExp.current(), anEdgeExp.current());
}
}