]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
authorszy <szy@opencascade.com>
Fri, 23 Jan 2015 14:40:04 +0000 (17:40 +0300)
committerszy <szy@opencascade.com>
Fri, 23 Jan 2015 14:40:04 +0000 (17:40 +0300)
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_ResultBody.cpp

index 9ffa3bd3d5319f5596cb7e50bbd50bc87c2f2549..85a025f6832ec3b9861f70cd949803cc3ba0ec2a 100644 (file)
@@ -122,8 +122,8 @@ void ExchangePlugin_ImportFeature::loadNamingDS(
   int aTag(1);
   std::string aNameMS = "Shape";
   theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag);
-  std::string aNameDE = "DiscEdges";
-  theResultBody->loadDisconnectedEdges(theGeomShape, aNameDE, aTag);
-  std::string aNameDV = "DiscVertexes";
-  theResultBody->loadDisconnectedVertexes(theGeomShape, aNameDV, aTag); 
+  //std::string aNameDE = "DiscEdges";
+  //theResultBody->loadDisconnectedEdges(theGeomShape, aNameDE, aTag);
+  //std::string aNameDV = "DiscVertexes";
+  //theResultBody->loadDisconnectedVertexes(theGeomShape, aNameDV, aTag); 
 }
index cab45489b05f4e184edba3bb7adee9b546f02a23..33d1b25f5302f26d72bf60d2da27c8e19fbb2710 100644 (file)
 #include <TopAbs_ShapeEnum.hxx>
 #include <TopoDS_Iterator.hxx>
 using namespace std;
+//#define DEB_NAMING 1
+#ifdef DEB_NAMING
+#include <BRepTools.hxx>
+#endif
 /// adeed to the index in the packed map to signalize that the vertex of edge is seleted
 /// (multiplied by the index of the edge)
 static const int kSTART_VERTEX_DELTA = 1000000;
@@ -601,6 +605,9 @@ std::string Model_AttributeSelection::namingName()
   if(!aSubSh.get() || aSubSh->isNull() || !aCont.get() || aCont->shape()->isNull()) 
     return aName;
   TopoDS_Shape aSubShape = aSubSh->impl<TopoDS_Shape>();
+#ifdef DEB_NAMING
+  BRepTools::Write(aSubShape, "Selection.brep");
+#endif
   TopoDS_Shape aContext  = aCont->shape()->impl<TopoDS_Shape>();
   std::shared_ptr<Model_Document> aDoc = 
     std::dynamic_pointer_cast<Model_Document>(aCont->document());
@@ -611,7 +618,7 @@ std::string Model_AttributeSelection::namingName()
     TopAbs_ShapeEnum aType = aSubShape.ShapeType();
        switch (aType) {
          case TopAbs_FACE:
-      // the Face should be in DF. If it is not a case, it is an error ==> to be dbugged               
+      // the Face should be in DF. If it is not the case, it is an error ==> to be debugged            
                break;
          case TopAbs_EDGE:
                  {
@@ -670,6 +677,7 @@ std::string Model_AttributeSelection::namingName()
          case TopAbs_VERTEX:
                  // name structure (Monifold Topology): 
                  // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case.
+                 // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation
                  // 2) F1 | F2      - intersection of 2 faces definses a vertex - applicable for case
                  //                   when 1 faces is cylindrical, conical, spherical or revolution and etc.
                  // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell
@@ -684,7 +692,7 @@ std::string Model_AttributeSelection::namingName()
                        TopTools_ListOfShape aList;
                        TopTools_MapOfShape aFMap;
 #ifdef FIX_BUG1
-                       //int n = aList2.Extent(); //bug!
+                       //int n = aList2.Extent(); //bug! duplication
                        // fix is below
                        TopTools_ListIteratorOfListOfShape itl2(aList2);
                    for (int i = 1;itl2.More();itl2.Next(),i++) {
@@ -693,14 +701,33 @@ std::string Model_AttributeSelection::namingName()
                        }
                        //n = aList.Extent();
 #endif
-                       TopTools_ListIteratorOfListOfShape itl(aList);
-                   for (int i = 1;itl.More();itl.Next(),i++) {
-                         const TopoDS_Shape& aFace = itl.Value();
-                         std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel());
-                         if(i == 1)
-                           aName = aFaceName;
-                         else 
-                           aName += "|" + aFaceName;
+                       int n = aList.Extent();
+                       if(n < 3) { // open topology case => via edges
+                         TopTools_IndexedDataMapOfShapeListOfShape aMap;
+                     TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
+                         const TopTools_ListOfShape& aList2  = aMap.FindFromKey(aSubShape);
+                         if(aList2.Extent() >= 2)  { // regular solution
+                               TopTools_ListIteratorOfListOfShape itl(aList2);
+                       for (int i = 1;itl.More();itl.Next(),i++) {
+                             const TopoDS_Shape& anEdge = itl.Value();
+                             std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel());
+                             if(i == 1)
+                               aName = anEdgeName;
+                             else 
+                               aName += "|" + anEdgeName;
+                               }
+                         }
+                       } 
+                       else {
+                         TopTools_ListIteratorOfListOfShape itl(aList);
+                     for (int i = 1;itl.More();itl.Next(),i++) {
+                           const TopoDS_Shape& aFace = itl.Value();
+                           std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel());
+                           if(i == 1)
+                             aName = aFaceName;
+                           else 
+                             aName += "|" + aFaceName;
+                         }
                        }
                  }
                  break;
index 4a04dda1ade5b955eb825167228ae3a117cbd552..134a3f32d94de46ad088415ca96e530d22b9434c 100644 (file)
 #include <TopTools_DataMapOfShapeShape.hxx>
 #include <TopExp.hxx>
 #include <BRepTools.hxx>
+#include <BRep_Tool.hxx>
 #include <GeomAPI_Shape.h>
 #include <GeomAlgoAPI_MakeShape.h>
 // DEB
 //#include <TCollection_AsciiString.hxx>
 //#include <TDF_Tool.hxx>
+#define DEB_IMPORT 1
+
 Model_ResultBody::Model_ResultBody()
 {
   setIsConcealed(false);
@@ -371,6 +374,8 @@ void Model_ResultBody::loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
        {
       const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
       if (aLL.Extent() < 2) {
+                 if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeAndNeighbourFaces.FindKey(i))))
+          continue;
            builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
                TCollection_AsciiString aStr(theTag);
            aName = theName + aStr.ToCString();
@@ -491,7 +496,24 @@ void Model_ResultBody::loadDisconnectedEdges(
            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); 
   std::string aName;
@@ -536,7 +558,7 @@ void Model_ResultBody::loadDisconnectedEdges(
          buildName(theTag, aName);      
          theTag++;
        }
-  }
+  }  
 }
 
 void Model_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag)