22869: Groups store to/Retrieve from OCAF

This commit is contained in:
skv 2015-03-24 17:09:59 +03:00
parent 7598e448c9
commit 97a79670fa
6 changed files with 221 additions and 25 deletions

View File

@ -61,6 +61,7 @@
#include <GEOMImpl_IDisk.hxx> #include <GEOMImpl_IDisk.hxx>
#include <GEOMImpl_ICylinder.hxx> #include <GEOMImpl_ICylinder.hxx>
#include <GEOMImpl_ICone.hxx> #include <GEOMImpl_ICone.hxx>
#include <GEOMImpl_IGroupOperations.hxx>
#include <GEOMImpl_ISphere.hxx> #include <GEOMImpl_ISphere.hxx>
#include <GEOMImpl_ITorus.hxx> #include <GEOMImpl_ITorus.hxx>
#include <GEOMImpl_IPrism.hxx> #include <GEOMImpl_IPrism.hxx>
@ -75,6 +76,8 @@
#include <GEOMImpl_IPipePath.hxx> #include <GEOMImpl_IPipePath.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #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) : GEOM_IOperations(theEngine, theDocID)
{ {
MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations"); 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() GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
{ {
MESSAGE("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.SetBase(aRefBase);
aCI.SetPath(aRefPath); aCI.SetPath(aRefPath);
aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value //Compute the Pipe value
try { try {
@ -1490,9 +1496,12 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
return NULL; return NULL;
} }
// Create the sequence of objects.
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
aSeq->Append(aPipe); aSeq->Append(aPipe);
createGroups(aPipe, &aCI, aSeq);
//Make a Python command //Make a Python command
GEOM::TPythonDump pyDump(aFunction); GEOM::TPythonDump pyDump(aFunction);
@ -1885,6 +1894,7 @@ Handle(TColStd_HSequenceOfTransient)
aCI.SetPath(aRefPath); aCI.SetPath(aRefPath);
aCI.SetWithContactMode(theWithContact); aCI.SetWithContactMode(theWithContact);
aCI.SetWithCorrectionMode(theWithCorrections); aCI.SetWithCorrectionMode(theWithCorrections);
aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value //Compute the Pipe value
try { try {
@ -1900,9 +1910,12 @@ Handle(TColStd_HSequenceOfTransient)
return NULL; return NULL;
} }
// Create the sequence of objects.
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
aSeq->Append(aPipeDS); aSeq->Append(aPipeDS);
createGroups(aPipeDS, &aCI, aSeq);
//Make a Python command //Make a Python command
GEOM::TPythonDump pyDump(aFunction); GEOM::TPythonDump pyDump(aFunction);
@ -2059,6 +2072,7 @@ Handle(TColStd_HSequenceOfTransient)
aCI.SetPath(aRefPath); aCI.SetPath(aRefPath);
aCI.SetWithContactMode(theWithContact); aCI.SetWithContactMode(theWithContact);
aCI.SetWithCorrectionMode(theWithCorrections); aCI.SetWithCorrectionMode(theWithCorrections);
aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value //Compute the Pipe value
try { try {
@ -2074,9 +2088,12 @@ Handle(TColStd_HSequenceOfTransient)
return NULL; return NULL;
} }
// Create the sequence of objects.
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
aSeq->Append(aPipeDS); aSeq->Append(aPipeDS);
createGroups(aPipeDS, &aCI, aSeq);
//Make a Python command //Make a Python command
GEOM::TPythonDump pyDump(aFunction); GEOM::TPythonDump pyDump(aFunction);
@ -2221,6 +2238,7 @@ Handle(TColStd_HSequenceOfTransient)
aCI.SetBases(aSeqBases); aCI.SetBases(aSeqBases);
aCI.SetLocations(aSeqLocs); aCI.SetLocations(aSeqLocs);
aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value //Compute the Pipe value
try { try {
@ -2236,9 +2254,12 @@ Handle(TColStd_HSequenceOfTransient)
return NULL; return NULL;
} }
// Create the sequence of objects.
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
aSeq->Append(aPipeDS); aSeq->Append(aPipeDS);
createGroups(aPipeDS, &aCI, aSeq);
//Make a Python command //Make a Python command
GEOM::TPythonDump pyDump(aFunction); GEOM::TPythonDump pyDump(aFunction);
@ -2331,6 +2352,7 @@ Handle(TColStd_HSequenceOfTransient)
aCI.SetBase(aRefBase); aCI.SetBase(aRefBase);
aCI.SetPath(aRefPath); aCI.SetPath(aRefPath);
aCI.SetVector(aRefVec); aCI.SetVector(aRefVec);
aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value //Compute the Pipe value
try { try {
@ -2346,9 +2368,11 @@ Handle(TColStd_HSequenceOfTransient)
return NULL; return NULL;
} }
// Create the sequence of objects.
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
aSeq->Append(aPipe); aSeq->Append(aPipe);
createGroups(aPipe, &aCI, aSeq);
//Make a Python command //Make a Python command
GEOM::TPythonDump pyDump(aFunction); GEOM::TPythonDump pyDump(aFunction);
@ -2627,3 +2651,122 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
SetErrorCode(OK); SetErrorCode(OK);
return aPath; 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]);
}
}
}

View File

@ -30,6 +30,11 @@
#include <TDocStd_Document.hxx> #include <TDocStd_Document.hxx>
#include <TColStd_HSequenceOfTransient.hxx> #include <TColStd_HSequenceOfTransient.hxx>
class GEOMImpl_IGroupOperations;
class GEOMImpl_IPipe;
class TopTools_IndexedMapOfShape;
class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { class GEOMImpl_I3DPrimOperations : public GEOM_IOperations {
public: public:
Standard_EXPORT GEOMImpl_I3DPrimOperations(GEOM_Engine* theEngine, int theDocID); 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, Standard_EXPORT Handle(GEOM_Object) RestorePath (Handle(GEOM_Object) theShape,
const Handle(TColStd_HSequenceOfTransient)& theBase1, const Handle(TColStd_HSequenceOfTransient)& theBase1,
const Handle(TColStd_HSequenceOfTransient)& theBase2); 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 #endif

View File

@ -27,20 +27,69 @@
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#define PIPE_ARG_BASE 1 #include <TColStd_HArray1OfInteger.hxx>
#define PIPE_ARG_PATH 2
// ---- 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 class GEOMImpl_IPipe
{ {
public: public:
GEOMImpl_IPipe(Handle(GEOM_Function) theFunction): _func(theFunction) {} GEOMImpl_IPipe(Handle(GEOM_Function) theFunction): _func(theFunction) {}
virtual ~GEOMImpl_IPipe() {}
void SetBase (Handle(GEOM_Function) theBase) { _func->SetReference(PIPE_ARG_BASE, theBase); } 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 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) GetBase() { return _func->GetReference(PIPE_ARG_BASE); }
Handle(GEOM_Function) GetPath() { return _func->GetReference(PIPE_ARG_PATH); } 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: protected:

View File

@ -22,15 +22,10 @@
#ifndef _GEOMImpl_IPIPEBINORMAL_HXX_ #ifndef _GEOMImpl_IPIPEBINORMAL_HXX_
#define _GEOMImpl_IPIPEBINORMAL_HXX_ #define _GEOMImpl_IPIPEBINORMAL_HXX_
#include "GEOM_Function.hxx"
#ifndef _GEOMImpl_IPIPE_HXX_
#include "GEOMImpl_IPipe.hxx" #include "GEOMImpl_IPipe.hxx"
#endif
#define PIPE_ARG_BASE 1 // Position definitions are declared in the base class.
#define PIPE_ARG_PATH 2
#define PIPE_ARG_VEC 3
class GEOMImpl_IPipeBiNormal : public GEOMImpl_IPipe class GEOMImpl_IPipeBiNormal : public GEOMImpl_IPipe
{ {

View File

@ -25,20 +25,11 @@
#ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_ #ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_
#define _GEOMImpl_IPIPEDIFFSECT_HXX_ #define _GEOMImpl_IPIPEDIFFSECT_HXX_
#include "GEOM_Function.hxx"
#include "GEOMImpl_IPipe.hxx"
#include <TColStd_HSequenceOfTransient.hxx> #include <TColStd_HSequenceOfTransient.hxx>
#ifndef _GEOMImpl_IPIPE_HXX_ // Position definitions are declared in the base class.
#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
class GEOMImpl_IPipeDiffSect : public GEOMImpl_IPipe class GEOMImpl_IPipeDiffSect : public GEOMImpl_IPipe
{ {

View File

@ -22,16 +22,12 @@
#ifndef _GEOMImpl_IPIPESHELLSECT_HXX_ #ifndef _GEOMImpl_IPIPESHELLSECT_HXX_
#define _GEOMImpl_IPIPESHELLSECT_HXX_ #define _GEOMImpl_IPIPESHELLSECT_HXX_
#include "GEOM_Function.hxx"
#ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_
#include "GEOMImpl_IPipeDiffSect.hxx" #include "GEOMImpl_IPipeDiffSect.hxx"
#endif #include "GEOM_Function.hxx"
#include <TColStd_HSequenceOfTransient.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 class GEOMImpl_IPipeShellSect : public GEOMImpl_IPipeDiffSect
{ {