#include <Model_Data.h>
#include <Model_Document.h>
-#include <ModelAPI_AttributeIntArray.h>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Iterator.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TDF_ChildIterator.hxx>
+#include <TDF_Reference.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListOfShape.hxx>
}
for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) {
- aShapePairs.push_back(std::pair<TopoDS_Shape, TopoDS_Shape>
+ // iterator goes in reversed order relatively to the Builder, to, make the list reversed
+ aShapePairs.push_front(std::pair<TopoDS_Shape, TopoDS_Shape>
(anIter.OldShape(), anIter.NewShape()));
}
- }
- // create new
- TNaming_Builder aBuilder(theLab);
- TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution);
- std::list<std::pair<TopoDS_Shape, TopoDS_Shape> >::iterator aPairsIter = aShapePairs.begin();
- for(; aPairsIter != aShapePairs.end(); aPairsIter++) {
- if (theFlag) { // disabled => make selection
- aBuilder.Select(aPairsIter->first, aPairsIter->second);
- } else if (anEvol == TNaming_GENERATED) {
- aBuilder.Generated(aPairsIter->first, aPairsIter->second);
- } else if (anEvol == TNaming_MODIFY) {
- aBuilder.Modify(aPairsIter->first, aPairsIter->second);
- } else if (anEvol == TNaming_DELETE) {
- aBuilder.Delete(aPairsIter->first);
- } else if (anEvol == TNaming_PRIMITIVE) {
- aBuilder.Generated(aPairsIter->second);
- } else if (anEvol == TNaming_SELECTED) {
- aBuilder.Select(aPairsIter->first, aPairsIter->second);
+
+ // create new
+ TNaming_Builder aBuilder(theLab);
+ TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution);
+ std::list<std::pair<TopoDS_Shape, TopoDS_Shape> >::iterator aPairsIter = aShapePairs.begin();
+ for(; aPairsIter != aShapePairs.end(); aPairsIter++) {
+ if (theFlag) { // disabled => make selection
+ aBuilder.Select(aPairsIter->second, aPairsIter->first);
+ } else if (anEvol == TNaming_GENERATED) {
+ aBuilder.Generated(aPairsIter->first, aPairsIter->second);
+ } else if (anEvol == TNaming_MODIFY) {
+ aBuilder.Modify(aPairsIter->first, aPairsIter->second);
+ } else if (anEvol == TNaming_DELETE) {
+ aBuilder.Delete(aPairsIter->first);
+ } else if (anEvol == TNaming_PRIMITIVE) {
+ aBuilder.Generated(aPairsIter->second);
+ } else if (anEvol == TNaming_SELECTED) {
+ aBuilder.Select(aPairsIter->second, aPairsIter->first);
+ }
}
}
// recursive call for all sub-labels
evolutionToSelectionRec(aShapeLab, theFlag);
}
-void Model_BodyBuilder::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
+void Model_BodyBuilder::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
+ const bool theIsStoreSameShapes)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
TDF_Label& aShapeLab = aData->shapeLab();
// clean builders
- clean();
+ clean();
// store the new shape as primitive
TNaming_Builder aBuilder(aShapeLab);
if (!theShape)
if (aShape.IsNull())
return; // null shape inside
- aBuilder.Generated(aShape);
+ if(!theIsStoreSameShapes) {
+ Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aShape, aShapeLab);
+ if(!aNS.IsNull() && !aNS->IsEmpty()) {
+ // This shape is already in document, store reference instead of shape;
+ const TDF_Label aFoundLabel = aNS->Label();
+ TDF_Reference::Set(aShapeLab, aFoundLabel);
+ aShapeLab.ForgetAttribute(TNaming_NamedShape::GetID());
+ return;
+ }
+ }
+
+ aBuilder.Generated(aShape);
// register name
+ aShapeLab.ForgetAttribute(TDF_Reference::GetID());
if(!aBuilder.NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
if(!aName.empty()) {
- std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
+ std::shared_ptr<Model_Document> aDoc =
+ std::dynamic_pointer_cast<Model_Document>(document());
aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
}
}
if (aData) {
TDF_Label& aShapeLab = aData->shapeLab();
// clean builders
- clean();
+ clean();
// store the new shape as primitive
TNaming_Builder aBuilder(aShapeLab);
if (!theFromShape || !theToShape)
if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
if(!aName.empty()) {
- std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
+ std::shared_ptr<Model_Document> aDoc =
+ std::dynamic_pointer_cast<Model_Document>(document());
aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
}
}
if (aData) {
TDF_Label& aShapeLab = aData->shapeLab();
// clean builders
- clean();
+ clean();
// store the new shape as primitive
TNaming_Builder aBuilder(aShapeLab);
if (!theOldShape || !theNewShape)
if (aShapeNew.IsNull())
return; // null shape inside
aBuilder.Modify(aShapeOld, aShapeNew);
- if (theDecomposeSolidsTag && aShapeNew.ShapeType() == TopAbs_COMPOUND) { // make sub elements as subs
-
- // register name if it is possible
- TCollection_AsciiString aName;
- if(!aBuilder.NamedShape()->IsEmpty()) {
- Handle(TDataStd_Name) anAttr;
- if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
- aName = TCollection_AsciiString(anAttr->Get()).ToCString();
- }
- }
-
- TopoDS_Iterator aSubIter(aShapeNew);
- for(int aTag = theDecomposeSolidsTag; aSubIter.More(); aSubIter.Next()) {
- TNaming_Builder aSubBuilder(aShapeLab.FindChild(aTag++));
- aSubBuilder.Generated(aSubIter.Value());
- if(!aName.IsEmpty()) {
- std::string aSolidName =
- (aName + "_Solid_" + TCollection_AsciiString(aTag - theDecomposeSolidsTag)).ToCString();
- std::shared_ptr<Model_Document> aDoc =
+ if(!aBuilder.NamedShape()->IsEmpty()) {
+ Handle(TDataStd_Name) anAttr;
+ if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+ std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
+ if(!aName.empty()) {
+ std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
- aDoc->addNamingName(aSubBuilder.NamedShape()->Label(), aSolidName);
- TDataStd_Name::Set(aSubBuilder.NamedShape()->Label(), aSolidName.c_str());
+ aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
}
}
}
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
- clean();
+ clean();
if (!theShape.get())
return; // bad shape
TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
void Model_BodyBuilder::buildName(const int theTag, const std::string& theName)
{
- std::string aName = data()->name() + "/" + theName;
std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(document());
- aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), aName);
- TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(),aName.c_str());
+ //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)
{
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
builder(theTag)->Generated(aShape);
- if(!theName.empty())
+ if(!theName.empty())
buildName(theTag, theName);
}
TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
builder(theTag)->Generated(anOldShape, aNewShape);
- if(!theName.empty())
+ 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++;
+ }
+ }
}
TopoDS_Shape anOldShape = theOldShape->impl<TopoDS_Shape>();
TopoDS_Shape aNewShape = theNewShape->impl<TopoDS_Shape>();
builder(theTag)->Modify(anOldShape, aNewShape);
- if(!theName.empty())
+ if(!theName.empty())
buildName(theTag, theName);
}
const int theTag,
const std::string& theName,
GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate)
+ const bool theIsStoreSeparate,
+ const bool theIsStoreAsGenerated)
{
+ int anIndex = 1;
int aTag = theTag;
+ bool isBuilt = !theName.empty();
std::string aName = theName;
std::ostringstream aStream;
- int anIndex = 1;
+ GeomShapePtr aResultShape = shape();
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> aRShape(new GeomAPI_Shape());
aRShape->setImpl((new TopoDS_Shape(aRoot)));
theMS->modified(aRShape, aList);
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+ 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>();
+ 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());
}
- if (!aRoot.IsSame (aNewShape)) {
- builder(aTag)->Modify(aRoot,aNewShape);
- if(!isBuilt) {
+ GeomShapePtr aGeomNewShape(new GeomAPI_Shape());
+ aGeomNewShape->setImpl(new TopoDS_Shape(aNewShape));
+ if(!aRoot.IsSame(aNewShape) && aResultShape->isSubShape(aGeomNewShape)) {
+ 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(aTag)->Generated(aRoot,aNewShape);
+ } else {
+ builder(aTag)->Modify(aRoot,aNewShape);
+ }
+ if(isBuilt) {
if(theIsStoreSeparate) {
aStream.str(std::string());
aStream.clear();
{
TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
TopTools_MapOfShape aView;
- bool isBuilt = theName.empty();
+ 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> aRShape(new GeomAPI_Shape());
aRShape->setImpl((new TopoDS_Shape(aRoot)));
theMS->generated(aRShape, aList);
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+ 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>();
+ 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());
}
if (!aRoot.IsSame (aNewShape)) {
builder(theTag)->Generated(aRoot,aNewShape);
- if(!isBuilt)
- buildName(theTag, theName);
+ 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++;
+ }
}
}
}
}
//=======================================================================
-int getDangleShapes(const TopoDS_Shape& theShapeIn,
+int getDangleShapes(const TopoDS_Shape& theShapeIn,
const TopAbs_ShapeEnum theGeneratedFrom,
- TopTools_DataMapOfShapeShape& theDangles)
+ TopTools_DataMapOfShapeShape& theDangles)
{
theDangles.Clear();
TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
TopTools_DataMapOfShapeShape dangles;
if (!getDangleShapes(theShapeIn, theGeneratedFrom, dangles)) return;
TopTools_DataMapIteratorOfDataMapOfShapeShape itr(dangles);
- for (; itr.More(); itr.Next())
+ for (; itr.More(); itr.Next())
theBuilder->Generated(itr.Key(), itr.Value());
}
//=======================================================================
-void Model_BodyBuilder::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
+void Model_BodyBuilder::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
std::string aName;
- if (aShape.ShapeType() == TopAbs_SOLID) {
+ if (aShape.ShapeType() == TopAbs_SOLID) {
TopExp_Explorer expl(aShape, TopAbs_FACE);
- for (; expl.More(); expl.Next()) {
- builder(theTag)->Generated(expl.Current());
+ for (; expl.More(); expl.Next()) {
+ builder(theTag)->Generated(expl.Current());
TCollection_AsciiString aStr(theTag);
aName = theName + aStr.ToCString();
buildName(theTag, aName);
if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
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);
}
TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeAndNeighbourFaces);
- for (Standard_Integer i = 1; i <= anEdgeAndNeighbourFaces.Extent(); i++)
+ for (Standard_Integer i = 1; i <= anEdgeAndNeighbourFaces.Extent(); i++)
{
const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
if (aLL.Extent() < 2) {
theTag++;
}
} else {
- TopExp_Explorer expl(aShape, TopAbs_EDGE);
- for (; expl.More(); expl.Next()) {
+ 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);
theTag++;
- }
+ }
// and load generated vertices.
TopTools_DataMapOfShapeShape generated;
- if (getDangleShapes(aShape, TopAbs_EDGE, generated))
+ if (getDangleShapes(aShape, TopAbs_EDGE, generated))
{
TNaming_Builder* pBuilder = builder(theTag++);
- loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);
+ loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);
}
}
} else if (aShape.ShapeType() == TopAbs_EDGE) {
TopExp_Explorer expl(aShape, TopAbs_VERTEX);
- for (; expl.More(); expl.Next()) {
+ for (; expl.More(); expl.Next()) {
builder(theTag)->Generated(expl.Current());
TCollection_AsciiString aStr(theTag);
aName = theName + aStr.ToCString();
}
//=======================================================================
-int findAmbiguities(const TopoDS_Shape& theShapeIn,
- TopTools_ListOfShape& theList)
+int findAmbiguities(const TopoDS_Shape& theShapeIn,
+ TopTools_ListOfShape& theList)
{
int aNumEdges(0);
theList.Clear();
if(ancestors1.Extent() == ancestors2.Extent() && ancestors1.Extent() > 1) {
int aNum (ancestors2.Extent());
TopTools_ListIteratorOfListOfShape it(ancestors2);
- for(;it.More();it.Next())
+ for(;it.More();it.Next())
if(aMap1.Contains(it.Value())) aNum--;
if(aNum == 0) {
- if(aMap2.Add(aKeyEdge1))
+ if(aMap2.Add(aKeyEdge1))
aKeyList.Append(aKeyEdge1);
if(aMap2.Add(aKeyEdge2))
aKeyList.Append(aKeyEdge2);
}
}
- } // at the end ==> List of edges to be named in addition
+ } // at the end ==> List of edges to be named in addition
}
aNumEdges = aKeyList.Extent();
if(aNumEdges)
- theList.Assign(aKeyList);
- return aNumEdges;
+ theList.Assign(aKeyList);
+ return aNumEdges;
}
//=======================================================================
std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
std::string aName;
if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) {
TopoDS_Iterator itr(aShape);
aName = theName + aStr.ToCString();
buildName(theTag, aName);
if(!theName.empty()) buildName(theTag, aName);
- if (itr.Value().ShapeType() == TopAbs_COMPOUND ||
- itr.Value().ShapeType() == TopAbs_COMPSOLID)
+ 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, theName, theTag);
} else {
std::shared_ptr<GeomAPI_Shape> itrShape(new GeomAPI_Shape());
- itrShape->setImpl(new TopoDS_Shape(itr.Value()));
+ 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, theName, theTag);
+ loadNextLevels(itrShape, theName, theTag);
}
TopTools_ListOfShape aList;
if(findAmbiguities(aShape, aList)) {
std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
TopTools_DataMapOfShapeListOfShape edgeNaborFaces;
TopTools_ListOfShape empty;
TopExp_Explorer explF(aShape, TopAbs_FACE);
break;
}
}
- if (faceIsNew)
- edgeNaborFaces.ChangeFind(anEdge).Append(aFace);
+ if (faceIsNew)
+ edgeNaborFaces.ChangeFind(anEdge).Append(aFace);
}
}
- /* TopTools_IndexedDataMapOfShapeListOfShape aDM;
- TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, aDM);
- for(int i=1; i <= aDM.Extent(); i++) {
- if(aDM.FindFromIndex(i).Extent() > 1) continue;
- if (BRep_Tool::Degenerated(TopoDS::Edge(aDM.FindKey(i))))
- continue;
- builder(theTag)->Generated(aDM.FindKey(i));
- TCollection_AsciiString aStr(theTag);
- std::string aName = theName + aStr.ToCString();
- buildName(theTag, aName);
- #ifdef DEB_IMPORT
- aName += + ".brep";
- BRepTools::Write(aDM.FindKey(i), aName.c_str());
- #endif
- theTag++;
- }
- */
TopTools_MapOfShape anEdgesToDelete;
- TopExp_Explorer anEx(aShape,TopAbs_EDGE);
+ TopExp_Explorer anEx(aShape,TopAbs_EDGE);
std::string aName;
for(;anEx.More();anEx.Next()) {
Standard_Boolean aC0 = Standard_False;
theTag++;
}
}
- }
+ }
TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete);
- for(;itDelete.More();itDelete.Next())
- edgeNaborFaces.UnBind(itDelete.Key());
+ for(;itDelete.More();itDelete.Next())
+ edgeNaborFaces.UnBind(itDelete.Key());
edgeNaborFaces.UnBind(anEdge1);
}
if (aC0) {
builder(theTag)->Generated(anEdge1);
TCollection_AsciiString aStr(theTag);
aName = theName + aStr.ToCString();
- buildName(theTag, aName);
+ buildName(theTag, aName);
theTag++;
}
- }
+ }
}
-void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
+void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
+ const std::string& theName, int& theTag)
{
if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
TopTools_DataMapOfShapeListOfShape vertexNaborEdges;
TopTools_ListOfShape empty;
TopExp_Explorer explF(aShape, TopAbs_EDGE);
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborEdges);
for (; itr.More(); itr.Next()) {
const TopTools_ListOfShape& naborEdges = itr.Value();
- if (naborEdges.Extent() < 2) {
+ if (naborEdges.Extent() < 2) {
builder(theTag)->Generated(itr.Key());
TCollection_AsciiString aStr(theTag);
aName = theName + aStr.ToCString();
- buildName(theTag, aName);
+ buildName(theTag, aName);
theTag++;
}
}
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
- TDF_Label& aShapeLab = aData->shapeLab();
+ TDF_Label aShapeLab = aData->shapeLab();
+ Handle(TDF_Reference) aRef;
+ if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
+ aShapeLab = aRef->Get();
+ }
Handle(TNaming_NamedShape) aName;
if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
TopoDS_Shape aShape = aName->Get();
- if (aShape.IsNull())
- std::cout<<"Model_BodyBuilder::shape returns empty shape "<<std::endl;
- else
- std::cout<<"Model_BodyBuilder::shape returns shape "<<&(*(aShape.TShape()))<<" with type "
- <<aShape.ShapeType()<<std::endl;
if (!aShape.IsNull()) {
std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
aRes->setImpl(new TopoDS_Shape(aShape));
bool Model_BodyBuilder::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
{
if (theShape.get()) {
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
TDF_Label& aShapeLab = aData->shapeLab();
Handle(TNaming_NamedShape) aName;
if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
TopoDS_Shape aLatest = TNaming_Tool::CurrentShape(aName);
+ if (aLatest.IsNull())
+ return false;
if (aLatest.IsEqual(aShape))
return true;
+ // check sub-shapes for comp-solids:
+ for (TopExp_Explorer anExp(aShape, aLatest.ShapeType()); anExp.More(); anExp.Next()) {
+ if (aLatest.IsEqual(anExp.Current()))
+ return true;
+ }
}
}
}