2013-04-01 18:25:01 +06:00
|
|
|
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2005-12-05 21:23:52 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <Standard_Stream.hxx>
|
2005-01-27 20:22:36 +05:00
|
|
|
|
2005-08-11 10:43:57 +06:00
|
|
|
#include <GEOMImpl_PartitionDriver.hxx>
|
|
|
|
#include <GEOMImpl_IPartition.hxx>
|
|
|
|
#include <GEOMImpl_Types.hxx>
|
|
|
|
|
|
|
|
#include <GEOM_Object.hxx>
|
|
|
|
#include <GEOM_Function.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <GEOMAlgo_Splitter.hxx>
|
2005-01-27 20:22:36 +05:00
|
|
|
|
|
|
|
#include <TDataStd_IntegerArray.hxx>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <TNaming_CopyShape.hxx>
|
2005-01-27 20:22:36 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//#include <BRepBuilderAPI_Copy.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <BRep_Tool.hxx>
|
|
|
|
#include <BRepAlgo.hxx>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <BRepTools.hxx>
|
2005-01-27 20:22:36 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <TopAbs.hxx>
|
|
|
|
#include <TopExp.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TopoDS.hxx>
|
|
|
|
#include <TopoDS_Shape.hxx>
|
|
|
|
#include <TopoDS_Vertex.hxx>
|
|
|
|
#include <TopoDS_Wire.hxx>
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <TopoDS_Iterator.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TopTools_MapOfShape.hxx>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
2005-01-27 20:22:36 +05:00
|
|
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <TopTools_DataMapOfShapeShape.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <ShapeFix_ShapeTolerance.hxx>
|
|
|
|
#include <ShapeFix_Shape.hxx>
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
|
2005-01-27 20:22:36 +05:00
|
|
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
|
|
|
#include <TColStd_ListOfInteger.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <Standard_NullObject.hxx>
|
|
|
|
#include <Precision.hxx>
|
|
|
|
#include <gp_Pnt.hxx>
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : GetID
|
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
const Standard_GUID& GEOMImpl_PartitionDriver::GetID()
|
|
|
|
{
|
|
|
|
static Standard_GUID aPartitionDriver("FF1BBB22-5D14-4df2-980B-3A668264EA16");
|
2008-03-07 12:45:34 +05:00
|
|
|
return aPartitionDriver;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : GEOMImpl_PartitionDriver
|
2008-03-07 12:45:34 +05:00
|
|
|
//purpose :
|
2004-12-01 15:39:14 +05:00
|
|
|
//=======================================================================
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver()
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
|
|
|
//function : SimplifyCompound
|
|
|
|
//purpose :
|
|
|
|
//=======================================================================
|
|
|
|
static void PrepareShapes (const TopoDS_Shape& theShape,
|
|
|
|
Standard_Integer theType,
|
|
|
|
TopTools_ListOfShape& theSimpleList)
|
|
|
|
{
|
|
|
|
if (theType == PARTITION_NO_SELF_INTERSECTIONS ||
|
|
|
|
theShape.ShapeType() != TopAbs_COMPOUND) {
|
|
|
|
theSimpleList.Append(theShape);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// explode compound on simple shapes to allow their intersections
|
|
|
|
TopoDS_Iterator It (theShape, Standard_True, Standard_True);
|
|
|
|
TopTools_MapOfShape mapShape;
|
|
|
|
for (; It.More(); It.Next()) {
|
|
|
|
if (mapShape.Add(It.Value())) {
|
|
|
|
TopoDS_Shape curSh = It.Value();
|
|
|
|
PrepareShapes(curSh, theType, theSimpleList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=======================================================================
|
|
|
|
//function : Execute
|
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
|
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
if (Label().IsNull()) return 0;
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
|
|
|
|
|
|
|
|
GEOMImpl_IPartition aCI (aFunction);
|
|
|
|
Standard_Integer aType = aFunction->GetType();
|
|
|
|
|
|
|
|
TopoDS_Shape aShape;
|
2008-03-07 12:45:34 +05:00
|
|
|
//sklNMTAlgo_Splitter1 PS;
|
|
|
|
GEOMAlgo_Splitter PS;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
TopTools_DataMapOfShapeShape aCopyMap;
|
|
|
|
TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
if (aType == PARTITION_PARTITION || aType == PARTITION_NO_SELF_INTERSECTIONS)
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes();
|
|
|
|
Handle(TColStd_HSequenceOfTransient) aTools = aCI.GetTools();
|
|
|
|
Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns();
|
|
|
|
Handle(TColStd_HSequenceOfTransient) aRemIns = aCI.GetRemoveIns();
|
|
|
|
Handle(TColStd_HArray1OfInteger) aMaterials = aCI.GetMaterials();
|
2008-03-07 12:45:34 +05:00
|
|
|
//skl Standard_Boolean DoRemoveWebs = !aMaterials.IsNull();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
unsigned int ind;
|
|
|
|
//unsigned int ind, nbshapes = 0;
|
|
|
|
//nbshapes += aShapes->Length() + aTools->Length();
|
|
|
|
//nbshapes += aKeepIns->Length() + aRemIns->Length();
|
|
|
|
//TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
|
|
|
|
TopTools_MapOfShape ShapesMap, ToolsMap;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// add object shapes that are in ListShapes;
|
|
|
|
for (ind = 1; ind <= aShapes->Length(); ind++) {
|
|
|
|
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind));
|
|
|
|
TopoDS_Shape aShape_i = aRefShape->GetValue();
|
|
|
|
if (aShape_i.IsNull()) {
|
|
|
|
Standard_NullObject::Raise("In Partition a shape is null");
|
|
|
|
}
|
2012-12-13 14:40:36 +06:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
TopoDS_Shape aShape_i_copy;
|
|
|
|
TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
|
2012-12-13 14:40:36 +06:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
// fill aCopyMap for history
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_inds;
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_copy_inds;
|
|
|
|
TopExp::MapShapes(aShape_i, aShape_i_inds);
|
|
|
|
TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
|
|
|
|
Standard_Integer nbInds = aShape_i_inds.Extent();
|
|
|
|
for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
|
|
|
|
aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
|
|
|
|
}
|
|
|
|
//
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListOfShape aSimpleShapes;
|
2012-08-09 13:58:02 +06:00
|
|
|
//PrepareShapes(aShape_i, aType, aSimpleShapes);
|
|
|
|
PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
|
|
|
|
for (; aSimpleIter.More(); aSimpleIter.Next()) {
|
|
|
|
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
|
|
|
|
if (ShapesMap.Add(aSimpleSh)) {
|
|
|
|
PS.AddShape(aSimpleSh);
|
|
|
|
//skl if (DoRemoveWebs) {
|
|
|
|
//skl if (aMaterials->Length() >= ind)
|
|
|
|
//skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind));
|
|
|
|
//skl }
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add tool shapes that are in ListTools and not in ListShapes;
|
|
|
|
for (ind = 1; ind <= aTools->Length(); ind++) {
|
|
|
|
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aTools->Value(ind));
|
|
|
|
TopoDS_Shape aShape_i = aRefShape->GetValue();
|
|
|
|
if (aShape_i.IsNull()) {
|
|
|
|
Standard_NullObject::Raise("In Partition a tool shape is null");
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
//BRepBuilderAPI_Copy aCopyTool (aShape_i);
|
|
|
|
TopoDS_Shape aShape_i_copy;
|
|
|
|
TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
|
|
|
|
//if (aCopyTool.IsDone())
|
|
|
|
// aShape_i_copy = aCopyTool.Shape();
|
|
|
|
//else
|
|
|
|
// Standard_NullObject::Raise("Bad shape detected");
|
|
|
|
//
|
|
|
|
// fill aCopyMap for history
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_inds;
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_copy_inds;
|
|
|
|
TopExp::MapShapes(aShape_i, aShape_i_inds);
|
|
|
|
TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
|
|
|
|
Standard_Integer nbInds = aShape_i_inds.Extent();
|
|
|
|
for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
|
|
|
|
aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
|
|
|
|
}
|
|
|
|
//
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListOfShape aSimpleShapes;
|
2012-08-09 13:58:02 +06:00
|
|
|
//PrepareShapes(aShape_i, aType, aSimpleShapes);
|
|
|
|
PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
|
|
|
|
for (; aSimpleIter.More(); aSimpleIter.Next()) {
|
|
|
|
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
|
|
|
|
if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) {
|
|
|
|
PS.AddTool(aSimpleSh);
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// add shapes that are in ListKeepInside, as object shapes;
|
|
|
|
for (ind = 1; ind <= aKeepIns->Length(); ind++) {
|
|
|
|
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
|
|
|
|
TopoDS_Shape aShape_i = aRefShape->GetValue();
|
|
|
|
if (aShape_i.IsNull()) {
|
|
|
|
Standard_NullObject::Raise("In Partition a Keep Inside shape is null");
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
//BRepBuilderAPI_Copy aCopyTool (aShape_i);
|
|
|
|
TopoDS_Shape aShape_i_copy;
|
|
|
|
TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
|
|
|
|
//if (aCopyTool.IsDone())
|
|
|
|
// aShape_i_copy = aCopyTool.Shape();
|
|
|
|
//else
|
|
|
|
// Standard_NullObject::Raise("Bad shape detected");
|
|
|
|
//
|
|
|
|
// fill aCopyMap for history
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_inds;
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_copy_inds;
|
|
|
|
TopExp::MapShapes(aShape_i, aShape_i_inds);
|
|
|
|
TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
|
|
|
|
Standard_Integer nbInds = aShape_i_inds.Extent();
|
|
|
|
for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
|
|
|
|
aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
|
|
|
|
}
|
|
|
|
//
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListOfShape aSimpleShapes;
|
2012-08-09 13:58:02 +06:00
|
|
|
//PrepareShapes(aShape_i, aType, aSimpleShapes);
|
|
|
|
PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
|
|
|
|
for (; aSimpleIter.More(); aSimpleIter.Next()) {
|
|
|
|
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
|
|
|
|
if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
|
|
|
|
PS.AddShape(aSimpleSh);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// add shapes that are in ListRemoveInside, as object shapes;
|
|
|
|
for (ind = 1; ind <= aRemIns->Length(); ind++) {
|
|
|
|
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
|
|
|
|
TopoDS_Shape aShape_i = aRefShape->GetValue();
|
|
|
|
if (aShape_i.IsNull()) {
|
|
|
|
Standard_NullObject::Raise("In Partition a Remove Inside shape is null");
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
//BRepBuilderAPI_Copy aCopyTool (aShape_i);
|
|
|
|
TopoDS_Shape aShape_i_copy;
|
|
|
|
TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
|
|
|
|
//if (aCopyTool.IsDone())
|
|
|
|
// aShape_i_copy = aCopyTool.Shape();
|
|
|
|
//else
|
|
|
|
// Standard_NullObject::Raise("Bad shape detected");
|
|
|
|
//
|
|
|
|
// fill aCopyMap for history
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_inds;
|
|
|
|
TopTools_IndexedMapOfShape aShape_i_copy_inds;
|
|
|
|
TopExp::MapShapes(aShape_i, aShape_i_inds);
|
|
|
|
TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
|
|
|
|
Standard_Integer nbInds = aShape_i_inds.Extent();
|
|
|
|
for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
|
|
|
|
aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
|
|
|
|
}
|
|
|
|
//
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListOfShape aSimpleShapes;
|
2012-08-09 13:58:02 +06:00
|
|
|
//PrepareShapes(aShape_i, aType, aSimpleShapes);
|
|
|
|
PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
|
2008-03-07 12:45:34 +05:00
|
|
|
TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
|
|
|
|
for (; aSimpleIter.More(); aSimpleIter.Next()) {
|
|
|
|
const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
|
|
|
|
if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
|
|
|
|
PS.AddShape(aSimpleSh);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
PS.SetLimitMode(aCI.GetKeepNonlimitShapes());
|
2012-08-09 13:58:02 +06:00
|
|
|
PS.SetLimit((TopAbs_ShapeEnum)aCI.GetLimit());
|
2008-03-07 12:45:34 +05:00
|
|
|
PS.Perform();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
//skl PS.Compute();
|
|
|
|
//skl PS.SetRemoveWebs(!DoRemoveWebs);
|
|
|
|
//skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
|
|
|
|
/*skl
|
2004-12-01 15:39:14 +05:00
|
|
|
// suppress result outside of shapes in KInsideMap
|
|
|
|
for (ind = 1; ind <= aKeepIns->Length(); ind++) {
|
|
|
|
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
|
|
|
|
TopoDS_Shape aShape_i = aRefShape->GetValue();
|
|
|
|
PS.KeepShapesInside(aShape_i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// suppress result inside of shapes in RInsideMap
|
|
|
|
for (ind = 1; ind <= aRemIns->Length(); ind++) {
|
|
|
|
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
|
|
|
|
TopoDS_Shape aShape_i = aRefShape->GetValue();
|
|
|
|
PS.RemoveShapesInside(aShape_i);
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
else if (aType == PARTITION_HALF)
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(GEOM_Function) aRefShape = aCI.GetShape();
|
|
|
|
Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
|
|
|
|
TopoDS_Shape aShapeArg = aRefShape->GetValue();
|
|
|
|
TopoDS_Shape aPlaneArg = aRefPlane->GetValue();
|
|
|
|
|
|
|
|
if (aShapeArg.IsNull() || aPlaneArg.IsNull()) {
|
|
|
|
Standard_NullObject::Raise("In Half Partition a shape or a plane is null");
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
TopoDS_Shape aShapeArg_copy;
|
|
|
|
TopoDS_Shape aPlaneArg_copy;
|
|
|
|
{
|
|
|
|
TNaming_CopyShape::CopyTool(aShapeArg, aMapTShapes, aShapeArg_copy);
|
|
|
|
//BRepBuilderAPI_Copy aCopyTool (aShapeArg);
|
|
|
|
//if (aCopyTool.IsDone())
|
|
|
|
// aShapeArg_copy = aCopyTool.Shape();
|
|
|
|
//else
|
|
|
|
// Standard_NullObject::Raise("Bad shape detected");
|
|
|
|
//
|
|
|
|
// fill aCopyMap for history
|
|
|
|
TopTools_IndexedMapOfShape aShapeArg_inds;
|
|
|
|
TopTools_IndexedMapOfShape aShapeArg_copy_inds;
|
|
|
|
TopExp::MapShapes(aShapeArg, aShapeArg_inds);
|
|
|
|
TopExp::MapShapes(aShapeArg_copy, aShapeArg_copy_inds);
|
|
|
|
Standard_Integer nbInds = aShapeArg_inds.Extent();
|
|
|
|
for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
|
|
|
|
aCopyMap.Bind(aShapeArg_inds.FindKey(ie), aShapeArg_copy_inds.FindKey(ie));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
TNaming_CopyShape::CopyTool(aPlaneArg, aMapTShapes, aPlaneArg_copy);
|
|
|
|
//BRepBuilderAPI_Copy aCopyTool (aPlaneArg);
|
|
|
|
//if (aCopyTool.IsDone())
|
|
|
|
// aPlaneArg_copy = aCopyTool.Shape();
|
|
|
|
//else
|
|
|
|
// Standard_NullObject::Raise("Bad shape detected");
|
|
|
|
//
|
|
|
|
// fill aCopyMap for history
|
|
|
|
TopTools_IndexedMapOfShape aPlaneArg_inds;
|
|
|
|
TopTools_IndexedMapOfShape aPlaneArg_copy_inds;
|
|
|
|
TopExp::MapShapes(aPlaneArg, aPlaneArg_inds);
|
|
|
|
TopExp::MapShapes(aPlaneArg_copy, aPlaneArg_copy_inds);
|
|
|
|
Standard_Integer nbInds = aPlaneArg_inds.Extent();
|
|
|
|
for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
|
|
|
|
aCopyMap.Bind(aPlaneArg_inds.FindKey(ie), aPlaneArg_copy_inds.FindKey(ie));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// add object shapes that are in ListShapes;
|
2012-08-09 13:58:02 +06:00
|
|
|
PS.AddShape(aShapeArg_copy);
|
|
|
|
//PS.AddShape(aShapeArg);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// add tool shapes that are in ListTools and not in ListShapes;
|
2012-08-09 13:58:02 +06:00
|
|
|
PS.AddTool(aPlaneArg_copy);
|
|
|
|
//PS.AddTool(aPlaneArg);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
//skl PS.Compute();
|
|
|
|
PS.Perform();
|
|
|
|
//PS.SetRemoveWebs(Standard_False);
|
|
|
|
//PS.Build(aShapeArg.ShapeType());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-01-27 20:22:36 +05:00
|
|
|
} else {
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2005-01-27 20:22:36 +05:00
|
|
|
aShape = PS.Shape();
|
2012-12-13 14:40:36 +06:00
|
|
|
if (aShape.IsNull()) {
|
|
|
|
// Mantis issue 22009
|
|
|
|
if (PS.ErrorStatus() == 10 && PS.Tools().Extent() == 0 && PS.Shapes().Extent() == 1)
|
|
|
|
aShape = PS.Shapes().First();
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//Alternative case to check not valid partition IPAL21418
|
|
|
|
TopoDS_Iterator It (aShape, Standard_True, Standard_True);
|
2012-12-13 14:40:36 +06:00
|
|
|
int nbSubshapes = 0;
|
2012-08-09 13:58:02 +06:00
|
|
|
for (; It.More(); It.Next())
|
|
|
|
nbSubshapes++;
|
|
|
|
if (!nbSubshapes)
|
|
|
|
Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
|
|
|
|
//end of IPAL21418
|
|
|
|
|
2005-01-27 20:22:36 +05:00
|
|
|
if (!BRepAlgo::IsValid(aShape)) {
|
2009-02-13 17:16:39 +05:00
|
|
|
// 08.07.2008 added by skl during fixing bug 19761 from Mantis
|
|
|
|
ShapeFix_ShapeTolerance aSFT;
|
|
|
|
aSFT.LimitTolerance(aShape, Precision::Confusion(),
|
|
|
|
Precision::Confusion(), TopAbs_SHAPE);
|
|
|
|
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
|
|
|
|
aSfs->Perform();
|
|
|
|
aShape = aSfs->Shape();
|
|
|
|
if (!BRepAlgo::IsValid(aShape))
|
|
|
|
Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
|
2005-01-27 20:22:36 +05:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
aFunction->SetValue(aShape);
|
|
|
|
|
2005-01-27 20:22:36 +05:00
|
|
|
// Fill history to be used by GetInPlace functionality
|
|
|
|
TopTools_IndexedMapOfShape aResIndices;
|
|
|
|
TopExp::MapShapes(aShape, aResIndices);
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Map: source_shape/images of source_shape in Result
|
|
|
|
const TopTools_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult();
|
|
|
|
|
2005-01-27 20:22:36 +05:00
|
|
|
// history for all argument shapes
|
2012-08-09 13:58:02 +06:00
|
|
|
// be sure to use aCopyMap
|
2005-01-27 20:22:36 +05:00
|
|
|
TDF_LabelSequence aLabelSeq;
|
|
|
|
aFunction->GetDependency(aLabelSeq);
|
|
|
|
Standard_Integer nbArg = aLabelSeq.Length();
|
|
|
|
|
|
|
|
for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) {
|
|
|
|
|
|
|
|
TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);
|
|
|
|
|
|
|
|
Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
|
|
|
|
TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();
|
|
|
|
|
|
|
|
TopTools_IndexedMapOfShape anArgumentIndices;
|
|
|
|
TopExp::MapShapes(anArgumentShape, anArgumentIndices);
|
|
|
|
Standard_Integer nbArgumentEntities = anArgumentIndices.Extent();
|
|
|
|
|
|
|
|
// Find corresponding label in history
|
|
|
|
TDF_Label anArgumentHistoryLabel =
|
|
|
|
aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True);
|
|
|
|
|
|
|
|
for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
|
|
|
|
TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie);
|
2012-08-09 13:58:02 +06:00
|
|
|
// be sure to use aCopyMap here
|
|
|
|
if (aCopyMap.IsBound(anEntity))
|
|
|
|
anEntity = aCopyMap.Find(anEntity);
|
|
|
|
//
|
2008-03-07 12:45:34 +05:00
|
|
|
if (!aMR.Contains(anEntity)) continue;
|
|
|
|
|
|
|
|
const TopTools_ListOfShape& aModified = aMR.FindFromKey(anEntity);
|
2005-01-27 20:22:36 +05:00
|
|
|
Standard_Integer nbModified = aModified.Extent();
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (nbModified > 0) { // Mantis issue 0021182
|
|
|
|
int ih = 1;
|
|
|
|
TopTools_ListIteratorOfListOfShape itM (aModified);
|
|
|
|
for (; itM.More() && nbModified > 0; itM.Next(), ++ih) {
|
|
|
|
if (!aResIndices.Contains(itM.Value())) {
|
|
|
|
nbModified = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-01-27 20:22:36 +05:00
|
|
|
if (nbModified > 0) {
|
|
|
|
TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
|
|
|
|
Handle(TDataStd_IntegerArray) anAttr =
|
|
|
|
TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
int ih = 1;
|
2005-01-27 20:22:36 +05:00
|
|
|
TopTools_ListIteratorOfListOfShape itM (aModified);
|
2008-03-07 12:45:34 +05:00
|
|
|
for (; itM.More(); itM.Next(), ++ih) {
|
2005-01-27 20:22:36 +05:00
|
|
|
int id = aResIndices.FindIndex(itM.Value());
|
2008-03-07 12:45:34 +05:00
|
|
|
anAttr->SetValue(ih, id);
|
2005-01-27 20:22:36 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
log.SetTouched(Label());
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : GEOMImpl_PartitionDriver_Type_
|
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_()
|
|
|
|
{
|
|
|
|
static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
|
2012-08-09 13:58:02 +06:00
|
|
|
if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
|
2004-12-01 15:39:14 +05:00
|
|
|
static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
|
2012-08-09 13:58:02 +06:00
|
|
|
if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
|
2004-12-01 15:39:14 +05:00
|
|
|
static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
|
2012-08-09 13:58:02 +06:00
|
|
|
if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
static Handle_Standard_Transient _Ancestors[] = {aType1,aType2,aType3,NULL};
|
|
|
|
static Handle_Standard_Type _aType =
|
|
|
|
new Standard_Type ("GEOMImpl_PartitionDriver", sizeof(GEOMImpl_PartitionDriver),
|
|
|
|
1, (Standard_Address)_Ancestors, (Standard_Address)NULL);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
return _aType;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : DownCast
|
|
|
|
//purpose :
|
2008-03-07 12:45:34 +05:00
|
|
|
//=======================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
const Handle(GEOMImpl_PartitionDriver) Handle(GEOMImpl_PartitionDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
|
|
|
|
{
|
|
|
|
Handle(GEOMImpl_PartitionDriver) _anOtherObject;
|
|
|
|
|
|
|
|
if (!AnObject.IsNull()) {
|
|
|
|
if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PartitionDriver))) {
|
|
|
|
_anOtherObject = Handle(GEOMImpl_PartitionDriver)((Handle(GEOMImpl_PartitionDriver)&)AnObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
return _anOtherObject;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|