#include <Model_Data.h>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
+#include <TDataStd_Name.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
if (aShape.IsNull())
return; // null shape inside
- aBuilder.Generated(aShape);
+ aBuilder.Generated(aShape);
}
}
return myBuilders[theTag];
}
+void Model_ResultBody::buildName(const int theTag, const std::string& theName)
+{
+ std::string aName = data()->name() + "/" + theName;
+ TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(),aName.c_str());
+}
void Model_ResultBody::generated(
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
{
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
builder(theTag)->Generated(aShape);
+ if(!theName.empty())
+ buildName(theTag, theName);
}
void Model_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
{
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);
}
void Model_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag)
{
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);
}
void Model_ResultBody::deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
std::shared_ptr<GeomAPI_Shape> theShapeIn,
const int theKindOfShape,
const int theTag,
+ const std::string& theName,
GeomAPI_DataMapOfShapeShape& theSubShapes)
{
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 ();
std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
}
- if (!aRoot.IsSame (aNewShape))
+ if (!aRoot.IsSame (aNewShape)) {
builder(theTag)->Modify(aRoot,aNewShape);
+ if(!isBuilt)
+ buildName(theTag, theName);
+ }
}
}
}
std::shared_ptr<GeomAPI_Shape> theShapeIn,
const int theKindOfShape,
const int theTag,
+ const std::string& theName,
GeomAPI_DataMapOfShapeShape& theSubShapes)
{
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 ();
std::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
}
- if (!aRoot.IsSame (aNewShape))
+ if (!aRoot.IsSame (aNewShape)) {
builder(theTag)->Generated(aRoot,aNewShape);
+ if(!isBuilt)
+ buildName(theTag, theName);
+ }
}
}
}
//=======================================================================
void Model_ResultBody::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
- int& theTag)
+ const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ std::string aName;
if (aShape.ShapeType() == TopAbs_SOLID) {
TopExp_Explorer expl(aShape, TopAbs_FACE);
for (; expl.More(); expl.Next())
- builder(++theTag)->Generated(expl.Current());
+ builder(++theTag)->Generated(expl.Current());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
}
else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) {
// load faces and all the free edges
TopExp::MapShapes(aShape, TopAbs_FACE, Faces);
if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
TopExp_Explorer expl(aShape, TopAbs_FACE);
- for (; expl.More(); expl.Next())
+ for (; expl.More(); expl.Next()) {
builder(++theTag)->Generated(expl.Current());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
+ }
}
TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeAndNeighbourFaces);
{
const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
if (aLL.Extent() < 2) {
- builder(++theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
+ builder(++theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
} else {
TopTools_ListIteratorOfListOfShape anIter(aLL);
const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
anIter.Next();
if(aFace.IsEqual(anIter.Value())) {
builder(++theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
}
}
}
TopExp_Explorer expl(aShape, TopAbs_VERTEX);
for (; expl.More(); expl.Next()) {
builder(++theTag)->Generated(expl.Current());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
}
} else {
TopExp_Explorer expl(aShape, TopAbs_EDGE);
for (; expl.More(); expl.Next()) {
builder(++theTag)->Generated(expl.Current());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
}
// and load generated vertices.
TopTools_DataMapOfShapeShape generated;
TopExp_Explorer expl(aShape, TopAbs_VERTEX);
for (; expl.More(); expl.Next()) {
builder(++theTag)->Generated(expl.Current());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
}
}
}
//=======================================================================
void Model_ResultBody::loadFirstLevel(
- std::shared_ptr<GeomAPI_Shape> theShape, int& theTag)
+ std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
{
- if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ if(theShape->isNull()) return;
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ std::string aName;
if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
TopoDS_Iterator itr(aShape);
for (; itr.More(); itr.Next()) {
- builder(++theTag)->Generated(itr.Value());
+ builder(++theTag)->Generated(itr.Value());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
+ if(!theName.empty()) buildName(theTag, aName);
if (itr.Value().ShapeType() == TopAbs_COMPOUND ||
itr.Value().ShapeType() == TopAbs_COMPSOLID)
{
std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
itrShape->setImpl(new TopoDS_Shape(itr.Value()));
- loadFirstLevel(itrShape, theTag);
+ loadFirstLevel(itrShape, theName, theTag);
} else {
std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
- itrShape->setImpl(new TopoDS_Shape(itr.Value()));
- loadNextLevels(itrShape, theTag);
+ itrShape->setImpl(new TopoDS_Shape(itr.Value()));
+ loadNextLevels(itrShape, theName, theTag);
}
}
} else {
std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
itrShape->setImpl(new TopoDS_Shape(aShape));
- loadNextLevels(itrShape, theTag);
+ loadNextLevels(itrShape, theName, theTag);
}
}
//=======================================================================
void Model_ResultBody::loadDisconnectedEdges(
- std::shared_ptr<GeomAPI_Shape> theShape, int& theTag)
+ std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
TopTools_MapOfShape anEdgesToDelete;
TopExp_Explorer anEx(aShape,TopAbs_EDGE);
+ std::string aName;
for(;anEx.More();anEx.Next()) {
Standard_Boolean aC0 = Standard_False;
TopoDS_Shape anEdge1 = anEx.Current();
if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
if (aMatches == aList1.Extent()) {
aC0=Standard_True;
- builder(++theTag)->Generated(anEdge2);
+ builder(++theTag)->Generated(anEdge2);
anEdgesToDelete.Add(anEdge2);
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
}
}
}
edgeNaborFaces.UnBind(itDelete.Key());
edgeNaborFaces.UnBind(anEdge1);
}
- if (aC0)
- builder(++theTag)->Generated(anEdge1);
+ if (aC0) {
+ builder(++theTag)->Generated(anEdge1);
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
+ }
}
}
-void Model_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, int& theTag)
+void Model_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
}
}
}
-
+ std::string aName;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborFaces);
for (; itr.More(); itr.Next()) {
const TopTools_ListOfShape& naborFaces = itr.Value();
- if (naborFaces.Extent() < 3)
- builder(++theTag)->Generated(itr.Key());
+ if (naborFaces.Extent() < 3) {
+ builder(++theTag)->Generated(itr.Key());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
+ }
}
}
\ No newline at end of file
/// 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 int theTag = 1);
+ const std::string& theName, const int theTag = 1);
/// 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 int theTag = 1);
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
/// 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 int theTag = 1);
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
/// 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.
std::shared_ptr<GeomAPI_Shape> theShapeIn,
const int theKindOfShape,
const int theTag,
+ const std::string& theName,
GeomAPI_DataMapOfShapeShape& theSubShapes);
/// load and orient generated shapes
MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
std::shared_ptr<GeomAPI_Shape> 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, int& theTag);
+ MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
/// Loads disconnected edges
- MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, int& theTag);
+ MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
/// Loads disconnected vetexes
- MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, int& theTag);
+ MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
/// Removes the stored builders
MODEL_EXPORT virtual ~Model_ResultBody();
private:
/// Loads shapes of the next level (to be used during shape import)
- void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, int& theTag);
+ void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
+
+ /// builds name for the shape kept at the specified tag
+ void buildName(const int theTag, const std::string& theName);
friend class Model_Document;
};
/// 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 int theTag = 1) = 0;
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 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 int theTag = 1) = 0;
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 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 int theTag = 1) = 0;
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 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.
std::shared_ptr<GeomAPI_Shape> theShapeIn,
const int theKindOfShape,
const int theTag,
+ const std::string& theName,
GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
/// load and orient generated shapes
virtual void loadAndOrientGeneratedShapes (
std::shared_ptr<GeomAPI_Shape> 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, int& theTag) = 0;
+ virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag) = 0;
/// load disconnected edges
- virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, int& theTag) = 0;
+ virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag) = 0;
/// load disconnected vetexes
- virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, int& theTag) = 0;
+ virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName,int& theTag) = 0;
protected:
};