]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
22869: Groups store to/Retrieve from OCAF
authorskv <skv@opencascade.com>
Tue, 24 Mar 2015 14:09:59 +0000 (17:09 +0300)
committerskv <skv@opencascade.com>
Tue, 24 Mar 2015 14:09:59 +0000 (17:09 +0300)
src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx
src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx
src/GEOMImpl/GEOMImpl_IPipe.hxx
src/GEOMImpl/GEOMImpl_IPipeBiNormal.hxx
src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx
src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx

index 977dca317c0eb2121aaa0a6a1cf335e362ab6da7..db32a71e6ecd3bf103cc956fcbfcc37ae1567bc5 100644 (file)
@@ -61,6 +61,7 @@
 #include <GEOMImpl_IDisk.hxx>
 #include <GEOMImpl_ICylinder.hxx>
 #include <GEOMImpl_ICone.hxx>
+#include <GEOMImpl_IGroupOperations.hxx>
 #include <GEOMImpl_ISphere.hxx>
 #include <GEOMImpl_ITorus.hxx>
 #include <GEOMImpl_IPrism.hxx>
@@ -75,6 +76,8 @@
 #include <GEOMImpl_IPipePath.hxx>
 
 #include <Precision.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
 #include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
@@ -88,6 +91,7 @@ GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine,
 : GEOM_IOperations(theEngine, theDocID)
 {
   MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
+  myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
 }
 
 //=============================================================================
@@ -98,6 +102,7 @@ GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine,
 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
 {
   MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
+  delete myGroupOperations;
 }
 
 
@@ -1475,6 +1480,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
 
   aCI.SetBase(aRefBase);
   aCI.SetPath(aRefPath);
+  aCI.SetGenerateGroups(IsGenerateGroups);
 
   //Compute the Pipe value
   try {
@@ -1490,9 +1496,12 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
     return NULL;
   }
 
+  // Create the sequence of objects.
   Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
 
   aSeq->Append(aPipe);
+  createGroups(aPipe, &aCI, aSeq);
+
   //Make a Python command
   GEOM::TPythonDump pyDump(aFunction);
 
@@ -1885,6 +1894,7 @@ Handle(TColStd_HSequenceOfTransient)
   aCI.SetPath(aRefPath);
   aCI.SetWithContactMode(theWithContact);
   aCI.SetWithCorrectionMode(theWithCorrections);
+  aCI.SetGenerateGroups(IsGenerateGroups);
 
   //Compute the Pipe value
   try {
@@ -1900,9 +1910,12 @@ Handle(TColStd_HSequenceOfTransient)
     return NULL;
   }
 
+  // Create the sequence of objects.
   Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
 
   aSeq->Append(aPipeDS);
+  createGroups(aPipeDS, &aCI, aSeq);
+
   //Make a Python command
   GEOM::TPythonDump pyDump(aFunction);
 
@@ -2059,6 +2072,7 @@ Handle(TColStd_HSequenceOfTransient)
   aCI.SetPath(aRefPath);
   aCI.SetWithContactMode(theWithContact);
   aCI.SetWithCorrectionMode(theWithCorrections);
+  aCI.SetGenerateGroups(IsGenerateGroups);
 
   //Compute the Pipe value
   try {
@@ -2074,9 +2088,12 @@ Handle(TColStd_HSequenceOfTransient)
     return NULL;
   }
 
+  // Create the sequence of objects.
   Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
 
   aSeq->Append(aPipeDS);
+  createGroups(aPipeDS, &aCI, aSeq);
+
   //Make a Python command
   GEOM::TPythonDump pyDump(aFunction);
 
@@ -2221,6 +2238,7 @@ Handle(TColStd_HSequenceOfTransient)
 
   aCI.SetBases(aSeqBases);
   aCI.SetLocations(aSeqLocs);
+  aCI.SetGenerateGroups(IsGenerateGroups);
 
   //Compute the Pipe value
   try {
@@ -2236,9 +2254,12 @@ Handle(TColStd_HSequenceOfTransient)
     return NULL;
   }
 
+  // Create the sequence of objects.
   Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
 
   aSeq->Append(aPipeDS);
+  createGroups(aPipeDS, &aCI, aSeq);
+
   //Make a Python command
   GEOM::TPythonDump pyDump(aFunction);
 
@@ -2331,6 +2352,7 @@ Handle(TColStd_HSequenceOfTransient)
   aCI.SetBase(aRefBase);
   aCI.SetPath(aRefPath);
   aCI.SetVector(aRefVec);
+  aCI.SetGenerateGroups(IsGenerateGroups);
 
   //Compute the Pipe value
   try {
@@ -2346,9 +2368,11 @@ Handle(TColStd_HSequenceOfTransient)
     return NULL;
   }
 
+  // Create the sequence of objects.
   Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
 
   aSeq->Append(aPipe);
+  createGroups(aPipe, &aCI, aSeq);
 
   //Make a Python command
   GEOM::TPythonDump pyDump(aFunction);
@@ -2627,3 +2651,122 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
   SetErrorCode(OK);
   return aPath;
 }
+
+//=============================================================================
+/*!
+ *  createGroup
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::createGroup
+                  (const Handle(GEOM_Object)              &theBaseObject,
+                   const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
+                   const TCollection_AsciiString          &theName,
+                   const TopTools_IndexedMapOfShape       &theIndices)
+{
+  if (theBaseObject.IsNull() || theGroupIDs.IsNull()) {
+    return NULL;
+  }
+
+  // Get the Shape type.
+  const Standard_Integer anID      = theGroupIDs->Value(theGroupIDs->Lower());
+  const Standard_Integer aNbShapes = theIndices.Extent();
+
+  if (anID < 1 || anID > aNbShapes) {
+    return NULL;
+  }
+
+  const TopoDS_Shape aSubShape = theIndices.FindKey(anID);
+
+  if (aSubShape.IsNull()) {
+    return NULL;
+  }
+
+  // Create a group.
+  const TopAbs_ShapeEnum aGroupType = aSubShape.ShapeType();
+  Handle(GEOM_Object)    aGroup     =
+    myGroupOperations->CreateGroup(theBaseObject, aGroupType);
+
+  if (aGroup.IsNull() == Standard_False) {
+    aGroup->GetLastFunction()->SetDescription("");
+    aGroup->SetName(theName.ToCString());
+
+    Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger;
+    Standard_Integer                   i;
+
+    for (i = theGroupIDs->Lower(); i <= theGroupIDs->Upper(); ++i) {
+      // Get and check the index.
+      const Standard_Integer anIndex = theGroupIDs->Value(i);
+
+      if (anIndex < 1 || anIndex > aNbShapes) {
+        return NULL;
+      }
+
+      // Get and check the sub-shape.
+      const TopoDS_Shape aSubShape = theIndices.FindKey(anIndex);
+
+      if (aSubShape.IsNull()) {
+        return NULL;
+      }
+
+      // Check the shape type.
+      if (aSubShape.ShapeType() != aGroupType) {
+        return NULL;
+      }
+
+      aSeqIDs->Append(anIndex);
+    }
+
+    myGroupOperations->UnionIDs(aGroup, aSeqIDs);
+    aGroup->GetLastFunction()->SetDescription("");
+  }
+
+  return aGroup;
+}
+
+//=============================================================================
+/*!
+ *  createGroups
+ */
+//=============================================================================
+void GEOMImpl_I3DPrimOperations::createGroups
+                   (const Handle(GEOM_Object)                  &theBaseObject,
+                          GEOMImpl_IPipe                       *thePipe,
+                          Handle(TColStd_HSequenceOfTransient) &theSequence)
+{
+  if (theBaseObject.IsNull() || thePipe == NULL || theSequence.IsNull()) {
+    return;
+  }
+
+  TopoDS_Shape aShape = theBaseObject->GetValue();
+
+  if (aShape.IsNull()) {
+    return;
+  }
+
+  TopTools_IndexedMapOfShape       anIndices;
+  Handle(TColStd_HArray1OfInteger) aGroupIDs;
+  TopoDS_Shape                     aShapeType;
+  const Standard_Integer           aNbGroups = 5;
+  Handle(GEOM_Object)              aGrps[aNbGroups];
+  Standard_Integer                 i;
+
+  TopExp::MapShapes(aShape, anIndices);
+
+  // Create groups.
+  aGroupIDs = thePipe->GetGroupDown();
+  aGrps[0]  = createGroup(theBaseObject, aGroupIDs, "GROUP_DOWN", anIndices);
+  aGroupIDs = thePipe->GetGroupUp();
+  aGrps[1]  = createGroup(theBaseObject, aGroupIDs, "GROUP_UP", anIndices);
+  aGroupIDs = thePipe->GetGroupSide1();
+  aGrps[2]  = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE1", anIndices);
+  aGroupIDs = thePipe->GetGroupSide2();
+  aGrps[3]  = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE2", anIndices);
+  aGroupIDs = thePipe->GetGroupOther();
+  aGrps[4]  = createGroup(theBaseObject, aGroupIDs, "GROUP_OTHER", anIndices);
+
+  for (i = 0; i < aNbGroups; ++i) {
+    if (aGrps[i].IsNull() == Standard_False) {
+      theSequence->Append(aGrps[i]);
+    }
+  }
+}
index 43ff36251be099b45a12c8b34a8582aad370471f..51c01fe43f18e1de8b377aed54c10dfcf05c9f5c 100644 (file)
 #include <TDocStd_Document.hxx>
 #include <TColStd_HSequenceOfTransient.hxx>
 
+class GEOMImpl_IGroupOperations;
+class GEOMImpl_IPipe;
+class TopTools_IndexedMapOfShape;
+
+
 class GEOMImpl_I3DPrimOperations : public GEOM_IOperations {
  public:
   Standard_EXPORT GEOMImpl_I3DPrimOperations(GEOM_Engine* theEngine, int theDocID);
@@ -165,6 +170,23 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) RestorePath (Handle(GEOM_Object) theShape,
                                                    const Handle(TColStd_HSequenceOfTransient)& theBase1,
                                                    const Handle(TColStd_HSequenceOfTransient)& theBase2);
+
+private:
+
+  Handle(GEOM_Object) createGroup
+                  (const Handle(GEOM_Object)              &theBaseObject,
+                   const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
+                   const TCollection_AsciiString          &theName,
+                   const TopTools_IndexedMapOfShape       &theIndices);
+
+  void createGroups(const Handle(GEOM_Object)                  &theBaseObject,
+                          GEOMImpl_IPipe                       *thePipe,
+                          Handle(TColStd_HSequenceOfTransient) &theSequence);
+
+private:
+
+  GEOMImpl_IGroupOperations *myGroupOperations;
+
 };
 
 #endif
index 22ace08b3084ddd7aece1300b17c877c5acca3db..fc346c5f13d8359c1ccd921fec2634d133937f4d 100644 (file)
 
 #include "GEOM_Function.hxx"
 
-#define PIPE_ARG_BASE 1
-#define PIPE_ARG_PATH 2
+#include <TColStd_HArray1OfInteger.hxx>
+
+// ---- GEOMImpl_IPipe
+#define PIPE_ARG_BASE          1
+#define PIPE_ARG_PATH          2
+
+// ---- GEOMImpl_IPipeBiNormal
+#define PIPE_ARG_VEC           3
+
+// ---- GEOMImpl_IPipeDiffSect
+#define PIPEDS_LIST_BASES      1
+//#define PIPEDS_ARG_PATH      2
+#define PIPEDS_LIST_LOCATIONS  3
+#define PIPEDS_ARG_WITHCONTACT 4
+#define PIPEDS_ARG_WITHCORRECT 5
+
+// ---- GEOMImpl_IPipeShellSect
+#define PIPEDS_LIST_SUBBASES   6
+
+// ---- Generate groups block (common)
+#define PIPE_GENERATE_GROUPS   7
+#define PIPE_GROUP_DOWN        8
+#define PIPE_GROUP_UP          9
+#define PIPE_GROUP_SIDE1       10
+#define PIPE_GROUP_SIDE2       11
+#define PIPE_GROUP_OTHER       12
+
 
 class GEOMImpl_IPipe
 {
  public:
 
   GEOMImpl_IPipe(Handle(GEOM_Function) theFunction): _func(theFunction) {}
+  virtual ~GEOMImpl_IPipe() {}
 
   void SetBase (Handle(GEOM_Function) theBase) { _func->SetReference(PIPE_ARG_BASE, theBase); }
   void SetPath (Handle(GEOM_Function) thePath) { _func->SetReference(PIPE_ARG_PATH, thePath); }
+  void SetGenerateGroups (int theGenerateGroups)
+  { _func->SetInteger(PIPE_GENERATE_GROUPS, theGenerateGroups); }
+  void SetGroupDown (const Handle(TColStd_HArray1OfInteger) &theGroup)
+  { _func->SetIntegerArray(PIPE_GROUP_DOWN, theGroup); }
+  void SetGroupUp (const Handle(TColStd_HArray1OfInteger) &theGroup)
+  { _func->SetIntegerArray(PIPE_GROUP_UP, theGroup); }
+  void SetGroupSide1 (const Handle(TColStd_HArray1OfInteger) &theGroup)
+  { _func->SetIntegerArray(PIPE_GROUP_SIDE1, theGroup); }
+  void SetGroupSide2 (const Handle(TColStd_HArray1OfInteger) &theGroup)
+  { _func->SetIntegerArray(PIPE_GROUP_SIDE2, theGroup); }
+  void SetGroupOther (const Handle(TColStd_HArray1OfInteger) &theGroup)
+  { _func->SetIntegerArray(PIPE_GROUP_OTHER, theGroup); }
 
   Handle(GEOM_Function) GetBase() { return _func->GetReference(PIPE_ARG_BASE); }
   Handle(GEOM_Function) GetPath() { return _func->GetReference(PIPE_ARG_PATH); }
+  int GetGenerateGroups () { return _func->GetInteger(PIPE_GENERATE_GROUPS); }
+  Handle(TColStd_HArray1OfInteger) GetGroupDown ()
+  { return _func->GetIntegerArray(PIPE_GROUP_DOWN); }
+  Handle(TColStd_HArray1OfInteger) GetGroupUp ()
+  { return _func->GetIntegerArray(PIPE_GROUP_UP); }
+  Handle(TColStd_HArray1OfInteger) GetGroupSide1 ()
+  { return _func->GetIntegerArray(PIPE_GROUP_SIDE1); }
+  Handle(TColStd_HArray1OfInteger) GetGroupSide2 ()
+  { return _func->GetIntegerArray(PIPE_GROUP_SIDE2); }
+  Handle(TColStd_HArray1OfInteger) GetGroupOther ()
+  { return _func->GetIntegerArray(PIPE_GROUP_OTHER); }
 
  protected:
 
index 8d3780f1a368d2ba1cd2b30d428e44036357f2a9..e6b154c164cf99a4c7c9a4082d4b5f883dfbcf58 100644 (file)
 #ifndef _GEOMImpl_IPIPEBINORMAL_HXX_
 #define _GEOMImpl_IPIPEBINORMAL_HXX_
 
-#include "GEOM_Function.hxx"
 
-#ifndef _GEOMImpl_IPIPE_HXX_
 #include "GEOMImpl_IPipe.hxx"
-#endif
 
-#define PIPE_ARG_BASE 1
-#define PIPE_ARG_PATH 2
-#define PIPE_ARG_VEC  3
+// Position definitions are declared in the base class.
 
 class GEOMImpl_IPipeBiNormal : public GEOMImpl_IPipe
 {
index 563d326333f6b5bdd1aebbe138110105ed823462..902f0cf4d436aeb0ba1eafb50d23e5baac61e017 100644 (file)
 #ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_
 #define _GEOMImpl_IPIPEDIFFSECT_HXX_
 
-#include "GEOM_Function.hxx"
 
-#include <TColStd_HSequenceOfTransient.hxx>
-
-#ifndef _GEOMImpl_IPIPE_HXX_
 #include "GEOMImpl_IPipe.hxx"
-#endif
-
-#define PIPEDS_LIST_BASES 1
-#define PIPEDS_LIST_LOCATIONS 3
-//#define PIPEDS_ARG_PATH 2
-#define PIPEDS_ARG_WITHCONTACT 4
-#define PIPEDS_ARG_WITHCORRECT 5
+#include <TColStd_HSequenceOfTransient.hxx>
 
+// Position definitions are declared in the base class.
 
 class GEOMImpl_IPipeDiffSect : public GEOMImpl_IPipe
 {
index e65a60b1f600c817d7160fd44f9190fc5e1823bc..f162a0b97d4be8d0d253dc2f4952f88186da628b 100644 (file)
 #ifndef _GEOMImpl_IPIPESHELLSECT_HXX_
 #define _GEOMImpl_IPIPESHELLSECT_HXX_
 
-#include "GEOM_Function.hxx"
 
-#ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_
 #include "GEOMImpl_IPipeDiffSect.hxx"
-#endif
-
+#include "GEOM_Function.hxx"
 #include <TColStd_HSequenceOfTransient.hxx>
 
-#define PIPEDS_LIST_SUBBASES 6
-
+// Position definitions are declared in the base class GEOMImpl_IPipe.
 
 class GEOMImpl_IPipeShellSect : public GEOMImpl_IPipeDiffSect
 {