mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-14 02:30:35 +05:00
0023197: [CEA] Extract and rebuild: engine (ecxept algorithm)
This commit is contained in:
parent
0a40f988ad
commit
553dce807d
@ -59,6 +59,7 @@ SET(GEOMAlgo_HEADERS
|
||||
GEOMAlgo_DataMapOfPassKeyInteger.hxx
|
||||
GEOMAlgo_DataMapOfShapeMapOfShape.hxx
|
||||
GEOMAlgo_DataMapOfShapePnt.hxx
|
||||
GEOMAlgo_Extractor.hxx
|
||||
GEOMAlgo_FinderShapeOn.hxx
|
||||
GEOMAlgo_FinderShapeOn1.hxx
|
||||
GEOMAlgo_FinderShapeOn2.hxx
|
||||
@ -123,6 +124,7 @@ SET(GEOMAlgo_SOURCES
|
||||
GEOMAlgo_ClsfSurf.cxx
|
||||
GEOMAlgo_CoupleOfShapes.cxx
|
||||
GEOMAlgo_FinderShapeOn2.cxx
|
||||
GEOMAlgo_Extractor.cxx
|
||||
GEOMAlgo_GetInPlace.cxx
|
||||
GEOMAlgo_GetInPlace_1.cxx
|
||||
GEOMAlgo_GetInPlace_2.cxx
|
||||
|
159
src/GEOMAlgo/GEOMAlgo_Extractor.cxx
Normal file
159
src/GEOMAlgo/GEOMAlgo_Extractor.cxx
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: GEOMAlgo_Extractor.cxx
|
||||
// Created:
|
||||
// Author: Sergey KHROMOV
|
||||
//
|
||||
|
||||
|
||||
#include <GEOMAlgo_Extractor.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GEOMAlgo_Extractor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMAlgo_Extractor::GEOMAlgo_Extractor()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ~GEOMAlgo_Extractor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMAlgo_Extractor::~GEOMAlgo_Extractor()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMAlgo_Extractor::SetShape(const TopoDS_Shape &theShape)
|
||||
{
|
||||
myShape = theShape;
|
||||
clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetShapesToRemove
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMAlgo_Extractor::SetShapesToRemove
|
||||
(const TopTools_ListOfShape &theSubShapes)
|
||||
{
|
||||
mySubShapes.Assign(theSubShapes);
|
||||
clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMAlgo_Extractor::Perform()
|
||||
{
|
||||
clear();
|
||||
myErrorStatus = 0;
|
||||
//
|
||||
checkData();
|
||||
|
||||
if(myErrorStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myWarningStatus == 10) {
|
||||
// The result is the same shape. Nothing is modified.
|
||||
myResult = myShape;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetResult
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const TopoDS_Shape &GEOMAlgo_Extractor::GetResult() const
|
||||
{
|
||||
return myResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMAlgo_Extractor::clear()
|
||||
{
|
||||
myErrorStatus = 1;
|
||||
myWarningStatus = 0;
|
||||
myResult.Nullify();
|
||||
myRemoved.Clear();
|
||||
myModified.Clear();
|
||||
myNew.Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : checkData
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMAlgo_Extractor::checkData()
|
||||
{
|
||||
if (myShape.IsNull()) {
|
||||
myErrorStatus = 10;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mySubShapes.IsEmpty()) {
|
||||
myWarningStatus = 10;
|
||||
return;
|
||||
}
|
||||
|
||||
TopTools_ListIteratorOfListOfShape anIter(mySubShapes);
|
||||
TopTools_IndexedMapOfShape anIndices;
|
||||
|
||||
TopExp::MapShapes(myShape, anIndices);
|
||||
|
||||
for (; anIter.More(); anIter.Next()) {
|
||||
const TopoDS_Shape &aSubShape = anIter.Value();
|
||||
|
||||
if (!anIndices.Contains(aSubShape)) {
|
||||
myErrorStatus = 11;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// myErrorStatus :
|
||||
//
|
||||
// 10 -myShape=NULL
|
||||
// 11 -mySubShapes contains not only sub-shapes of myShape.
|
||||
//
|
||||
// myWarningStatus :
|
||||
//
|
||||
// 10 -mySubShapes is empty
|
||||
//
|
147
src/GEOMAlgo/GEOMAlgo_Extractor.hxx
Normal file
147
src/GEOMAlgo/GEOMAlgo_Extractor.hxx
Normal file
@ -0,0 +1,147 @@
|
||||
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: GEOMAlgo_Extractor.hxx
|
||||
// Author: Sergey KHROMOV
|
||||
|
||||
#ifndef _GEOMAlgo_Extractor_HeaderFile
|
||||
#define _GEOMAlgo_Extractor_HeaderFile
|
||||
|
||||
|
||||
#include <GEOMAlgo_Algo.hxx>
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
|
||||
|
||||
/**
|
||||
* \brief This class encapsulates an algorithm of extraction of sub-shapes
|
||||
* from the main shape.
|
||||
*/
|
||||
class GEOMAlgo_Extractor : public GEOMAlgo_Algo
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Empty constructor.
|
||||
*/
|
||||
Standard_EXPORT GEOMAlgo_Extractor();
|
||||
|
||||
/**
|
||||
* \brief Virtual destructor.
|
||||
*/
|
||||
Standard_EXPORT virtual ~GEOMAlgo_Extractor();
|
||||
|
||||
/**
|
||||
* \brief This method sets the main shape.
|
||||
*
|
||||
* \param theShape the main shape.
|
||||
*/
|
||||
Standard_EXPORT void SetShape(const TopoDS_Shape &theShape);
|
||||
|
||||
/**
|
||||
* \brief This method returns the main shape.
|
||||
*
|
||||
* \return the main shape.
|
||||
*/
|
||||
const TopoDS_Shape &GetShape() const
|
||||
{ return myShape; }
|
||||
|
||||
/**
|
||||
* \brief This method sets the list of sub-shapes to be removed
|
||||
* from the main shape.
|
||||
*
|
||||
* \param theSubShapes the sub-shapes to be removed.
|
||||
*/
|
||||
Standard_EXPORT void SetShapesToRemove
|
||||
(const TopTools_ListOfShape &theSubShapes);
|
||||
|
||||
/**
|
||||
* \brief This method returns the list of sub-shapes to be removed
|
||||
* from the main shape.
|
||||
*
|
||||
* \return the list of sub-shapes to be removed.
|
||||
*/
|
||||
const TopTools_ListOfShape &GetShapesToRemove() const
|
||||
{ return mySubShapes; }
|
||||
|
||||
/**
|
||||
* This method performs computation of the extracted shape.
|
||||
*/
|
||||
Standard_EXPORT virtual void Perform();
|
||||
|
||||
/**
|
||||
* This method returns the result of the algorithm.
|
||||
*
|
||||
* \return the result of the operation.
|
||||
*/
|
||||
Standard_EXPORT const TopoDS_Shape &GetResult() const;
|
||||
|
||||
/**
|
||||
* \brief This method returns the sub-shapes removed from the main shape.
|
||||
*
|
||||
* \return the list of removed sub-shapes.
|
||||
*/
|
||||
const TopTools_ListOfShape &GetRemoved() const
|
||||
{ return myRemoved; }
|
||||
|
||||
/**
|
||||
* \brief This method returns the sub-shapes modified in the main shape.
|
||||
*
|
||||
* \return the list of modified sub-shapes.
|
||||
*/
|
||||
const TopTools_ListOfShape &GetModified() const
|
||||
{ return myModified; }
|
||||
|
||||
/**
|
||||
* \brief This method returns the newly created sub-shapes in the result
|
||||
* shape.
|
||||
*
|
||||
* \return the list of new sub-shapes in result.
|
||||
*/
|
||||
const TopTools_ListOfShape &GetNew() const
|
||||
{ return myNew; }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* This method reinitializes the shape.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* This method checks the input data.
|
||||
*/
|
||||
void checkData();
|
||||
|
||||
protected:
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
TopoDS_Shape myResult;
|
||||
TopTools_ListOfShape mySubShapes;
|
||||
TopTools_ListOfShape myRemoved;
|
||||
TopTools_ListOfShape myModified;
|
||||
TopTools_ListOfShape myNew;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -79,6 +79,7 @@ SET(GEOMImpl_HEADERS
|
||||
GEOMImpl_ICircle.hxx
|
||||
GEOMImpl_ISpline.hxx
|
||||
GEOMImpl_IEllipse.hxx
|
||||
GEOMImpl_IExtract.hxx
|
||||
GEOMImpl_IFillet.hxx
|
||||
GEOMImpl_IFillet1d.hxx
|
||||
GEOMImpl_IFillet2d.hxx
|
||||
|
73
src/GEOMImpl/GEOMImpl_IExtract.hxx
Normal file
73
src/GEOMImpl/GEOMImpl_IExtract.hxx
Normal file
@ -0,0 +1,73 @@
|
||||
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
//NOTE: This is an intreface to a function for the Offset creation.
|
||||
//
|
||||
#include "GEOM_Function.hxx"
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
|
||||
#define EXTRACT_SHAPE 1
|
||||
#define EXTRACT_IDS 2
|
||||
#define EXTRACT_REMOVED_IDS 3
|
||||
#define EXTRACT_MODIFIED_IDS 4
|
||||
#define EXTRACT_ADDED_IDS 5
|
||||
|
||||
class GEOMImpl_IExtract
|
||||
{
|
||||
public:
|
||||
|
||||
GEOMImpl_IExtract(Handle(GEOM_Function) theFunction): _func(theFunction) {}
|
||||
|
||||
void SetShape(Handle(GEOM_Function) theShape)
|
||||
{ _func->SetReference(EXTRACT_SHAPE, theShape); }
|
||||
|
||||
Handle(GEOM_Function) GetShape()
|
||||
{ return _func->GetReference(EXTRACT_SHAPE); }
|
||||
|
||||
void SetSubShapeIDs(const Handle(TColStd_HArray1OfInteger)& theSubShapeIDs)
|
||||
{ _func->SetIntegerArray(EXTRACT_IDS, theSubShapeIDs); }
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) GetSubShapeIDs()
|
||||
{ return _func->GetIntegerArray(EXTRACT_IDS); }
|
||||
|
||||
void SetRemovedIDs(const Handle(TColStd_HArray1OfInteger)& theRemovedIDs)
|
||||
{ _func->SetIntegerArray(EXTRACT_REMOVED_IDS, theRemovedIDs); }
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) GetRemovedIDs()
|
||||
{ return _func->GetIntegerArray(EXTRACT_REMOVED_IDS); }
|
||||
|
||||
void SetModifiedIDs(const Handle(TColStd_HArray1OfInteger)& theModifiedIDs)
|
||||
{ _func->SetIntegerArray(EXTRACT_MODIFIED_IDS, theModifiedIDs); }
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) GetModifiedIDs()
|
||||
{ return _func->GetIntegerArray(EXTRACT_MODIFIED_IDS); }
|
||||
|
||||
void SetAddedIDs(const Handle(TColStd_HArray1OfInteger)& theAddedIDs)
|
||||
{ _func->SetIntegerArray(EXTRACT_ADDED_IDS, theAddedIDs); }
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) GetAddedIDs()
|
||||
{ return _func->GetIntegerArray(EXTRACT_ADDED_IDS); }
|
||||
|
||||
private:
|
||||
|
||||
Handle(GEOM_Function) _func;
|
||||
};
|
@ -36,6 +36,7 @@
|
||||
#include "GEOMImpl_GlueDriver.hxx"
|
||||
#include "GEOMImpl_FillingDriver.hxx"
|
||||
|
||||
#include "GEOMImpl_IExtract.hxx"
|
||||
#include "GEOMImpl_IVector.hxx"
|
||||
#include "GEOMImpl_IShapes.hxx"
|
||||
#include "GEOMImpl_IShapeExtend.hxx"
|
||||
@ -3172,11 +3173,95 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeExtraction
|
||||
const Handle(TColStd_HArray1OfInteger) &theSubShapeIDs,
|
||||
std::list<ExtractionStat> &theStats)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
if (theShape.IsNull()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Add a new Result object
|
||||
Handle(GEOM_Object) aResult =
|
||||
GetEngine()->AddObject(GetDocID(), GEOM_EXTRACTION);
|
||||
|
||||
//Add a new Extraction function
|
||||
Handle(GEOM_Function) aFunction =
|
||||
aResult->AddFunction(GEOMImpl_ShapeDriver::GetID(), EXTRACTION);
|
||||
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Handle(GEOM_Function) aShape = theShape->GetLastFunction();
|
||||
|
||||
if (aShape.IsNull()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GEOMImpl_IExtract aCI (aFunction);
|
||||
|
||||
aCI.SetShape(aShape);
|
||||
aCI.SetSubShapeIDs(theSubShapeIDs);
|
||||
|
||||
//Compute the Edge value
|
||||
try {
|
||||
OCC_CATCH_SIGNALS;
|
||||
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||
SetErrorCode("Shape driver failed");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||
SetErrorCode(aFail->GetMessageString());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Fill in statistics.
|
||||
theStats.clear();
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) aStatIDsArray[3] =
|
||||
{ aCI.GetRemovedIDs(), aCI.GetModifiedIDs(), aCI.GetAddedIDs() };
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < 3; ++j) {
|
||||
if (!aStatIDsArray[j].IsNull()) {
|
||||
const int anUpperID = aStatIDsArray[j]->Upper();
|
||||
ExtractionStat aStat;
|
||||
|
||||
for (i = aStatIDsArray[j]->Lower(); i <= anUpperID; ++i) {
|
||||
aStat.indices.push_back(aStatIDsArray[j]->Value(i));
|
||||
}
|
||||
|
||||
aStat.type = (ExtractionStatType) j;
|
||||
theStats.push_back(aStat);
|
||||
}
|
||||
}
|
||||
|
||||
//Make a Python command
|
||||
GEOM::TPythonDump pd(aFunction);
|
||||
|
||||
pd << aResult << " = geompy.MakeExtraction(" << theShape << ", [";
|
||||
|
||||
if (!theSubShapeIDs.IsNull()) {
|
||||
const int aNbIDs = theSubShapeIDs->Upper();
|
||||
|
||||
for (i = theSubShapeIDs->Lower(); i < aNbIDs; ++i) {
|
||||
pd << theSubShapeIDs->Value(i) << ", ";
|
||||
}
|
||||
|
||||
// Dump the last value without a comma.
|
||||
pd << theSubShapeIDs->Value(i);
|
||||
}
|
||||
|
||||
pd << "])";
|
||||
|
||||
SetErrorCode(OK);
|
||||
|
||||
return theShape;
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <GEOMImpl_ShapeDriver.hxx>
|
||||
|
||||
#include <GEOMImpl_IExtract.hxx>
|
||||
#include <GEOMImpl_IIsoline.hxx>
|
||||
#include <GEOMImpl_IShapes.hxx>
|
||||
#include <GEOMImpl_IShapeExtend.hxx>
|
||||
@ -32,6 +33,7 @@
|
||||
#include <GEOM_Function.hxx>
|
||||
#include <GEOMUtils_Hatcher.hxx>
|
||||
#include <GEOMAlgo_State.hxx>
|
||||
#include <GEOMAlgo_Extractor.hxx>
|
||||
|
||||
// OCCT Includes
|
||||
#include <ShapeFix_Wire.hxx>
|
||||
@ -73,6 +75,7 @@
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
|
||||
@ -107,6 +110,39 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
/**
|
||||
* \brief This static function converts the list of shapes into an array
|
||||
* of their IDs. If the input list is empty, null handle will be returned.
|
||||
* this method doesn't check if a shape presents in theIndices map.
|
||||
*
|
||||
* \param theListOfShapes the list of shapes.
|
||||
* \param theIndices the indexed map of shapes.
|
||||
* \return the array of shape IDs.
|
||||
*/
|
||||
static Handle(TColStd_HArray1OfInteger) GetShapeIDs
|
||||
(const TopTools_ListOfShape &theListOfShapes,
|
||||
const TopTools_IndexedMapOfShape &theIndices)
|
||||
{
|
||||
Handle(TColStd_HArray1OfInteger) aResult;
|
||||
|
||||
if (!theListOfShapes.IsEmpty()) {
|
||||
const Standard_Integer aNbShapes = theListOfShapes.Extent();
|
||||
TopTools_ListIteratorOfListOfShape anIter(theListOfShapes);
|
||||
Standard_Integer i;
|
||||
|
||||
aResult = new TColStd_HArray1OfInteger(1, aNbShapes);
|
||||
|
||||
for (i = 1; anIter.More(); anIter.Next(), ++i) {
|
||||
const TopoDS_Shape &aShape = anIter.Value();
|
||||
const Standard_Integer anIndex = theIndices.FindIndex(aShape);
|
||||
|
||||
aResult->SetValue(i, anIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// check that compound includes only shapes of expected type
|
||||
@ -784,6 +820,86 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (aType == EXTRACTION) {
|
||||
allowCompound = true;
|
||||
|
||||
GEOMImpl_IExtract aCI(aFunction);
|
||||
Handle(GEOM_Function) aRefShape = aCI.GetShape();
|
||||
TopoDS_Shape aShapeBase = aRefShape->GetValue();
|
||||
|
||||
if (aShapeBase.IsNull()) {
|
||||
Standard_NullObject::Raise("Argument Shape is null");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) anIDs = aCI.GetSubShapeIDs();
|
||||
TopTools_ListOfShape aListSubShapes;
|
||||
TopTools_IndexedMapOfShape anIndices;
|
||||
int i;
|
||||
|
||||
TopExp::MapShapes(aShapeBase, anIndices);
|
||||
|
||||
if (!anIDs.IsNull()) {
|
||||
const int anUpperID = anIDs->Upper();
|
||||
|
||||
for (i = anIDs->Lower(); i <= anUpperID; ++i) {
|
||||
const Standard_Integer anIndex = anIDs->Value(i);
|
||||
const TopoDS_Shape &aSubShape = anIndices.FindKey(anIndex);
|
||||
aListSubShapes.Append(aSubShape);
|
||||
}
|
||||
}
|
||||
|
||||
// Compute extraction.
|
||||
GEOMAlgo_Extractor anExtractor;
|
||||
|
||||
anExtractor.SetShape(aShapeBase);
|
||||
anExtractor.SetShapesToRemove(aListSubShapes);
|
||||
|
||||
anExtractor.Perform();
|
||||
|
||||
// Interprete results
|
||||
Standard_Integer iErr = anExtractor.ErrorStatus();
|
||||
|
||||
// The detailed description of error codes is in GEOMAlgo_Extractor.cxx
|
||||
if (iErr) {
|
||||
TCollection_AsciiString aMsg(" iErr : ");
|
||||
|
||||
aMsg += TCollection_AsciiString(iErr);
|
||||
StdFail_NotDone::Raise(aMsg.ToCString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
aShape = anExtractor.GetResult();
|
||||
|
||||
// Get statistics.
|
||||
const TopTools_ListOfShape &aRemoved = anExtractor.GetRemoved();
|
||||
const TopTools_ListOfShape &aModified = anExtractor.GetModified();
|
||||
const TopTools_ListOfShape &aNew = anExtractor.GetNew();
|
||||
Handle(TColStd_HArray1OfInteger) aRemovedIDs =
|
||||
GetShapeIDs(aRemoved, anIndices);
|
||||
Handle(TColStd_HArray1OfInteger) aModifiedIDs =
|
||||
GetShapeIDs(aModified, anIndices);
|
||||
Handle(TColStd_HArray1OfInteger) aNewIDs;
|
||||
|
||||
if (!aShape.IsNull()) {
|
||||
// Get newly created sub-shapes
|
||||
TopTools_IndexedMapOfShape aNewIndices;
|
||||
|
||||
TopExp::MapShapes(aShape, aNewIndices);
|
||||
aNewIDs = GetShapeIDs(aNew, aNewIndices);
|
||||
}
|
||||
|
||||
if (!aRemovedIDs.IsNull()) {
|
||||
aCI.SetRemovedIDs(aRemovedIDs);
|
||||
}
|
||||
|
||||
if (!aModifiedIDs.IsNull()) {
|
||||
aCI.SetModifiedIDs(aModifiedIDs);
|
||||
}
|
||||
|
||||
if (!aNewIDs.IsNull()) {
|
||||
aCI.SetAddedIDs(aNewIDs);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
@ -1746,6 +1862,15 @@ GetCreationInformation(std::string& theOperationName,
|
||||
AddParam(theParams, "Face", aSE.GetShape());
|
||||
break;
|
||||
}
|
||||
case EXTRACTION:
|
||||
{
|
||||
GEOMImpl_IExtract aCI (function);
|
||||
|
||||
theOperationName = "EXTRACTION";
|
||||
AddParam(theParams, "Main Shape", aCI.GetShape());
|
||||
AddParam(theParams, "Sub-shape IDs", aCI.GetSubShapeIDs());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -119,6 +119,8 @@
|
||||
|
||||
#define GEOM_TRANSFER_DATA 57
|
||||
|
||||
#define GEOM_EXTRACTION 58
|
||||
|
||||
//GEOM_Function types
|
||||
|
||||
#define COPY_WITH_REF 1
|
||||
@ -316,6 +318,7 @@
|
||||
#define FACE_UV 17
|
||||
#define SURFACE_FROM_FACE 18
|
||||
#define SOLID_FACES 19
|
||||
#define EXTRACTION 20
|
||||
|
||||
#define ARCHIMEDE_TYPE 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user