geom/src/GEOM_I/GEOM_IBooleanOperations_i.cc

275 lines
9.8 KiB
C++
Raw Normal View History

2013-04-01 18:25:01 +06:00
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
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
//
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:14:22 +06:00
#include <Standard_Stream.hxx>
2004-12-01 15:39:14 +05:00
#include "GEOM_IBooleanOperations_i.hh"
#include "utilities.h"
#include "OpUtil.hxx"
#include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx"
#include <TColStd_HArray1OfInteger.hxx>
//=============================================================================
/*!
* constructor:
*/
//=============================================================================
GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i (PortableServer::POA_ptr thePOA,
2012-08-09 13:58:02 +06:00
GEOM::GEOM_Gen_ptr theEngine,
::GEOMImpl_IBooleanOperations* theImpl)
2004-12-01 15:39:14 +05:00
:GEOM_IOperations_i(thePOA, theEngine, theImpl)
{
MESSAGE("GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i");
}
//=============================================================================
/*!
* destructor
*/
//=============================================================================
GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i()
{
MESSAGE("GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i");
}
//=============================================================================
/*!
* MakeBoolean
*/
//=============================================================================
2004-12-01 15:39:14 +05:00
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean
(GEOM::GEOM_Object_ptr theShape1,
2012-08-09 13:58:02 +06:00
GEOM::GEOM_Object_ptr theShape2,
CORBA::Long theOp)
2004-12-01 15:39:14 +05:00
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference shapes
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh1 = GetObjectImpl(theShape1);
Handle(GEOM_Object) aSh2 = GetObjectImpl(theShape2);
2004-12-01 15:39:14 +05:00
if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn();
// Make Boolean
Handle(GEOM_Object) anObject = GetOperations()->MakeBoolean(aSh1, aSh2, theOp);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakePartition
*/
//=============================================================================
2004-12-01 15:39:14 +05:00
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
(const GEOM::ListOfGO& theShapes,
2012-08-09 13:58:02 +06:00
const GEOM::ListOfGO& theTools,
const GEOM::ListOfGO& theKeepIns,
const GEOM::ListOfGO& theRemoveIns,
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials,
CORBA::Short theKeepNonlimitShapes)
2004-12-01 15:39:14 +05:00
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
int ind, aLen;
Handle(TColStd_HSequenceOfTransient) aShapes = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aTools = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aKeepIns = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aRemIns = new TColStd_HSequenceOfTransient;
Handle(TColStd_HArray1OfInteger) aMaterials;
//Get the shapes
aLen = theShapes.length();
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
2004-12-01 15:39:14 +05:00
if (aSh.IsNull()) return aGEOMObject._retn();
aShapes->Append(aSh);
}
//Get the tools
aLen = theTools.length();
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theTools[ind]);
2004-12-01 15:39:14 +05:00
if (aSh.IsNull()) return aGEOMObject._retn();
aTools->Append(aSh);
}
//Get the keep inside shapes
aLen = theKeepIns.length();
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theKeepIns[ind]);
2004-12-01 15:39:14 +05:00
if (aSh.IsNull()) return aGEOMObject._retn();
aKeepIns->Append(aSh);
}
//Get the remove inside shapes
aLen = theRemoveIns.length();
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theRemoveIns[ind]);
2004-12-01 15:39:14 +05:00
if (aSh.IsNull()) return aGEOMObject._retn();
aRemIns->Append(aSh);
}
//Get the materials
aLen = theMaterials.length();
if ( aLen ) {
aMaterials = new TColStd_HArray1OfInteger (1, aLen);
for (ind = 0; ind < aLen; ind++) {
aMaterials->SetValue(ind+1, theMaterials[ind]);
}
}
// Make Partition
Handle(GEOM_Object) anObject =
GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
2012-08-09 13:58:02 +06:00
theLimit, theRemoveWebs, aMaterials,
theKeepNonlimitShapes,
/*PerformSelfIntersections*/Standard_True);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakePartitionNonSelfIntersectedShape
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape
(const GEOM::ListOfGO& theShapes,
2012-08-09 13:58:02 +06:00
const GEOM::ListOfGO& theTools,
const GEOM::ListOfGO& theKeepIns,
const GEOM::ListOfGO& theRemoveIns,
CORBA::Short theLimit,
CORBA::Boolean theRemoveWebs,
const GEOM::ListOfLong& theMaterials,
CORBA::Short theKeepNonlimitShapes)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
int ind, aLen;
Handle(TColStd_HSequenceOfTransient) aShapes = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aTools = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aKeepIns = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aRemIns = new TColStd_HSequenceOfTransient;
Handle(TColStd_HArray1OfInteger) aMaterials;
//Get the shapes
aLen = theShapes.length();
2004-12-01 15:39:14 +05:00
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
aShapes->Append(aSh);
}
//Get the tools
aLen = theTools.length();
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theTools[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
aTools->Append(aSh);
}
//Get the keep inside shapes
aLen = theKeepIns.length();
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theKeepIns[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
aKeepIns->Append(aSh);
}
//Get the remove inside shapes
aLen = theRemoveIns.length();
for (ind = 0; ind < aLen; ind++) {
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theRemoveIns[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
aRemIns->Append(aSh);
}
//Get the materials
aLen = theMaterials.length();
if ( aLen ) {
aMaterials = new TColStd_HArray1OfInteger (1, aLen);
for (ind = 0; ind < aLen; ind++) {
aMaterials->SetValue(ind+1, theMaterials[ind]);
}
2004-12-01 15:39:14 +05:00
}
// Make Partition
Handle(GEOM_Object) anObject =
GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
2012-08-09 13:58:02 +06:00
theLimit, theRemoveWebs, aMaterials,
theKeepNonlimitShapes,
/*PerformSelfIntersections*/Standard_False);
2004-12-01 15:39:14 +05:00
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeHalfPartition
*/
//=============================================================================
2004-12-01 15:39:14 +05:00
GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
(GEOM::GEOM_Object_ptr theShape,
2012-08-09 13:58:02 +06:00
GEOM::GEOM_Object_ptr thePlane)
2004-12-01 15:39:14 +05:00
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference shapes
2012-08-09 13:58:02 +06:00
Handle(GEOM_Object) aSh = GetObjectImpl(theShape);
Handle(GEOM_Object) aPl = GetObjectImpl(thePlane);
2004-12-01 15:39:14 +05:00
if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn();
// Make Half Partition
Handle(GEOM_Object) anObject = GetOperations()->MakeHalfPartition(aSh, aPl);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}