-// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 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
// 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 : GEOMImpl_IShapesOperations.cxx
// Created :
#include "GEOMImpl_IGlue.hxx"
#include "GEOMImpl_Block6Explorer.hxx"
+#include "GEOMImpl_IHealingOperations.hxx"
+
+#include <GEOMImpl_Gen.hxx>
#include "GEOM_Function.hxx"
#include "GEOM_ISubShape.hxx"
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TopAbs.hxx>
aCI.SetIsPlanar(isPlanarWanted);
//Compute the Face value
+ Standard_Boolean isWarning = Standard_False;
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
- return NULL;
+ // to provide warning
+ if (!aFunction->GetValue().IsNull()) {
+ isWarning = Standard_True;
+ } else {
+ return NULL;
+ }
}
//Make a Python command
GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFace("
<< theWire << ", " << (int)isPlanarWanted << ")";
- SetErrorCode(OK);
+ // to provide warning
+ if (!isWarning) SetErrorCode(OK);
return aFace;
}
aCI.SetIsPlanar(isPlanarWanted);
//Compute the shape
+ Standard_Boolean isWarning = Standard_False;
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
- return NULL;
+ // to provide warning
+ if (!aFunction->GetValue().IsNull()) {
+ isWarning = Standard_True;
+ } else {
+ return NULL;
+ }
}
//Make a Python command
}
pd << "], " << (int)isPlanarWanted << ")";
- SetErrorCode(OK);
+ // to provide warning
+ if (!isWarning) SetErrorCode(OK);
return aShape;
}
// on the main shape for each being calculated sub-shape separately.
aFunction->SetValue(aValue);
- // Put this subshape in the list of subshapes of theMainShape
+ // Put this subshape in the list of sub-shapes of theMainShape
aMainShape->AddSubShapeReference(aFunction);
}
// on the main shape for each being calculated sub-shape separately.
aFunction->SetValue(aValue);
- // Put this subshape in the list of subshapes of theMainShape
+ // Put this sub-shape in the list of sub-shapes of theMainShape
aMainShape->AddSubShapeReference(aFunction);
aSeq->Append(anObj);
if (theShape.IsNull()) return NULL;
+ /*
//Add a new reversed object
Handle(GEOM_Object) aReversed = GetEngine()->AddObject(GetDocID(), theShape->GetType());
<< " = geompy.ChangeOrientation(" << theShape << ")";
SetErrorCode(OK);
+ */
+
+ Handle(GEOM_Object) aReversed;
+
+ GEOM_Engine* anEngine = GetEngine();
+ //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
+ GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
+
+ if (aGen) {
+ GEOMImpl_IHealingOperations* anIHealingOperations =
+ aGen->GetIHealingOperations(GetDocID());
+ aReversed = anIHealingOperations->ChangeOrientationCopy(theShape);
+ SetErrorCode(anIHealingOperations->GetErrorCode());
+ }
+
return aReversed;
}
// Make a Python command
anAsciiList.Trunc(anAsciiList.Length() - 1);
- GEOM::TPythonDump pd (aMainShape, /*append=*/true);
+ // IPAL22904: TC6.5.0: order of python commands is wrong after dump study
+ Handle(TColStd_HSequenceOfTransient) anObjects = new TColStd_HSequenceOfTransient;
+ for( it = theShapes.begin(); it != theShapes.end(); it++ )
+ {
+ Handle(GEOM_Object) anObj = *it;
+ if( !anObj.IsNull() )
+ anObjects->Append( anObj );
+ }
+
+ // Get the function of the latest published object
+ Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast( anObjects )->GetLastFunction();
+ if( aFunction.IsNull() ) // just in case
+ aFunction = aMainShape;
+
+ GEOM::TPythonDump pd (aFunction, /*append=*/true);
pd << "[" << anAsciiList.ToCString()
<< "] = geompy.GetSharedShapesMulti([";
//=======================================================================
//function : getShapesOnBoxIDs
/*!
- * \brief Find IDs of subshapes complying with given status about surface
- * \param theBox - the box to check state of subshapes against
+ * \brief Find IDs of sub-shapes complying with given status about surface
+ * \param theBox - the box to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfInteger)
//=======================================================================
//function : GetShapesOnBoxIDs
/*!
- * \brief Find subshapes complying with given status about surface
- * \param theBox - the box to check state of subshapes against
+ * \brief Find sub-shapes complying with given status about surface
+ * \param theBox - the box to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfInteger)
const Standard_Integer theShapeType,
GEOMAlgo_State theState)
{
- // Find subshapes ids
+ // Find sub-shapes ids
Handle(TColStd_HSequenceOfInteger) aSeqOfIDs =
getShapesOnBoxIDs (theBox, theShape, theShapeType, theState);
if ( aSeqOfIDs.IsNull() || aSeqOfIDs->Length() == 0 )
//=======================================================================
//function : GetShapesOnBox
/*!
- * \brief Find subshapes complying with given status about surface
- * \param theBox - the box to check state of subshapes against
+ * \brief Find sub-shapes complying with given status about surface
+ * \param theBox - the box to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfTransient) - found subshapes
+ * \retval Handle(TColStd_HSequenceOfTransient) - found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfTransient)
const Standard_Integer theShapeType,
GEOMAlgo_State theState)
{
- // Find subshapes ids
+ // Find sub-shapes ids
Handle(TColStd_HSequenceOfInteger) aSeqOfIDs =
getShapesOnBoxIDs (theBox, theShape, theShapeType, theState);
if ( aSeqOfIDs.IsNull() || aSeqOfIDs->Length() == 0 )
//=======================================================================
//function : getShapesOnShapeIDs
/*!
- * \brief Find IDs of subshapes complying with given status about surface
- * \param theCheckShape - the shape to check state of subshapes against
+ * \brief Find IDs of sub-shapes complying with given status about surface
+ * \param theCheckShape - the shape to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfInteger)
//=======================================================================
//function : GetShapesOnShapeIDs
/*!
- * \brief Find subshapes complying with given status about surface
- * \param theCheckShape - the shape to check state of subshapes against
+ * \brief Find sub-shapes complying with given status about surface
+ * \param theCheckShape - the shape to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfInteger)
//=======================================================================
//function : GetShapesOnShape
/*!
- * \brief Find subshapes complying with given status about surface
- * \param theCheckShape - the shape to check state of subshapes against
+ * \brief Find sub-shapes complying with given status about surface
+ * \param theCheckShape - the shape to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfTransient) - found subshapes
+ * \retval Handle(TColStd_HSequenceOfTransient) - found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfTransient)
//=======================================================================
//function : getShapesOnSurfaceIDs
/*!
- * \brief Find IDs of subshapes complying with given status about surface
- * \param theSurface - the surface to check state of subshapes against
+ * \brief Find IDs of sub-shapes complying with given status about surface
+ * \param theSurface - the surface to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfInteger)
//=======================================================================
//function : getShapesOnSurface
/*!
- * \brief Find subshapes complying with given status about surface
- * \param theSurface - the surface to check state of subshapes against
+ * \brief Find sub-shapes complying with given status about surface
+ * \param theSurface - the surface to check state of sub-shapes against
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theState - required state
* \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfTransient)
GEOMAlgo_State theState,
TCollection_AsciiString & theShapeEntries)
{
- // Find subshapes ids
+ // Find sub-shapes ids
Handle(TColStd_HSequenceOfInteger) aSeqOfIDs =
getShapesOnSurfaceIDs (theSurface, theShape->GetValue(), theShapeType, theState);
if ( aSeqOfIDs.IsNull() || aSeqOfIDs->Length() == 0 )
//=======================================================================
//function : getShapesOnQuadrangleIDs
/*!
- * \brief Find IDs of subshapes complying with given status about quadrangle
+ * \brief Find IDs of sub-shapes complying with given status about quadrangle
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theTopLeftPoint - top left quadrangle corner
* \param theTopRigthPoint - top right quadrangle corner
* \param theBottomLeftPoint - bottom left quadrangle corner
* \param theBottomRigthPoint - bottom right quadrangle corner
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfInteger)
//=======================================================================
//function : GetShapesOnQuadrangle
/*!
- * \brief Find subshapes complying with given status about quadrangle
+ * \brief Find sub-shapes complying with given status about quadrangle
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theTopLeftPoint - top left quadrangle corner
* \param theTopRigthPoint - top right quadrangle corner
* \param theBottomLeftPoint - bottom left quadrangle corner
* \param theBottomRigthPoint - bottom right quadrangle corner
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfTransient)
//=======================================================================
//function : GetShapesOnQuadrangleIDs
/*!
- * \brief Find IDs of subshapes complying with given status about quadrangle
+ * \brief Find IDs of sub-shapes complying with given status about quadrangle
* \param theShape - the shape to explore
- * \param theShapeType - type of subshape of theShape
+ * \param theShapeType - type of sub-shape of theShape
* \param theTopLeftPoint - top left quadrangle corner
* \param theTopRigthPoint - top right quadrangle corner
* \param theBottomLeftPoint - bottom left quadrangle corner
* \param theBottomRigthPoint - bottom right quadrangle corner
* \param theState - required state
- * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
+ * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
*/
//=======================================================================
Handle(TColStd_HSequenceOfInteger)
//================================================================================
/*!
- * \brief Return type of shape for explode. In case of compound it will be a type of sub shape.
+ * \brief Return type of shape for explode. In case of compound it will be a type of sub-shape.
*/
//================================================================================
TopAbs_ShapeEnum GEOMImpl_IShapesOperations::GetTypeOfSimplePart (const TopoDS_Shape& theShape)
aModifiedArray->SetValue(imod, aWhereIndices.FindIndex(anIterModif.Value()));
}
else {
- SetErrorCode("Error: wrong sub shape returned");
+ SetErrorCode("Error: wrong sub-shape returned");
return NULL;
}
}
return NULL;
}
- if (aModifiedArray->Length() > 1) {
+ if (aModifiedArray->Length() > 1 || theShapeWhat->GetType() == GEOM_GROUP) {
//Set a GROUP type
aResult->SetType(GEOM_GROUP);
- //Set a sub shape type
+ //Set a sub-shape type
TopoDS_Shape aFirstFound = aLSA.First();
TopAbs_ShapeEnum aShapeType = aFirstFound.ShapeType();
if ( isFound && iType == TopAbs_FACE )
{
// check normals at pOnWhat and pOnWhere
- const double angleTol = PI/180.;
+ const double angleTol = M_PI/180.;
gp_Vec normToWhat = GetNormal( TopoDS::Face(Exp_aWhat.Current()), aWhatDistance);
gp_Vec normToWhere = GetNormal( TopoDS::Face(Exp_aWhere.Current()), aWhereDistance);
if ( normToWhat * normToWhere < 0 )
return NULL;
}
- if (aModifiedArray->Length() > 1) {
+ if (aModifiedArray->Length() > 1 || theShapeWhat->GetType() == GEOM_GROUP) {
//Set a GROUP type
aResult->SetType(GEOM_GROUP);
- //Set a sub shape type
+ //Set a sub-shape type
TopoDS_Shape aFirstFound = aWhereIndices.FindKey(aModifiedArray->Value(1));
TopAbs_ShapeEnum aShapeType = aFirstFound.ShapeType();
//Set a GROUP type
aResult->SetType(GEOM_GROUP);
- //Set a sub shape type
+ //Set a sub-shape type
TopoDS_Shape aFirstFound = aWhereIndices.FindKey(aModifiedArray->Value(1));
TopAbs_ShapeEnum aShapeType = aFirstFound.ShapeType();
return aResult;
}
+
+
+//=======================================================================
+//function : GetSameIDs
+//purpose :
+//=======================================================================
+Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetSameIDs(const Handle(GEOM_Object)& theShapeWhere,
+ const Handle(GEOM_Object)& theShapeWhat)
+{
+ SetErrorCode(KO);
+ if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return NULL;
+
+ TopoDS_Shape aWhere = theShapeWhere->GetValue();
+ TopoDS_Shape aWhat = theShapeWhat->GetValue();
+
+ if (aWhere.IsNull() || aWhat.IsNull()) return NULL;
+
+ int anIndex = -1;
+ bool isFound = false;
+ TopTools_ListOfShape listShape;
+ TopTools_MapOfShape aMap;
+
+ if (aWhat.ShapeType() == TopAbs_COMPOUND || aWhat.ShapeType() == TopAbs_COMPSOLID) {
+ TopoDS_Iterator It (aWhat, Standard_True, Standard_True);
+ if (It.More()) aWhat = It.Value();
+ It.Next();
+ if (It.More()) {
+ SetErrorCode("Compounds of two or more shapes are not allowed for aWhat argument");
+ return NULL;
+ }
+ }
+
+ switch (aWhat.ShapeType()) {
+ case TopAbs_VERTEX: {
+ gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aWhat));
+ TopExp_Explorer E(aWhere, TopAbs_VERTEX);
+ for(; E.More(); E.Next()) {
+ if(!aMap.Add(E.Current())) continue;
+ gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(E.Current()));
+ if(P.Distance(P2) <= MAX_TOLERANCE) {
+ listShape.Append(E.Current());
+ }
+ }
+ break;
+ }
+ case TopAbs_EDGE: {
+ TopoDS_Edge anEdge = TopoDS::Edge(aWhat);
+ TopExp_Explorer E(aWhere, TopAbs_EDGE);
+ for(; E.More(); E.Next()) {
+ if(!aMap.Add(E.Current())) continue;
+ if(isSameEdge(anEdge, TopoDS::Edge(E.Current()))) {
+ listShape.Append(E.Current());
+ }
+ }
+ break;
+ }
+ case TopAbs_FACE: {
+ TopoDS_Face aFace = TopoDS::Face(aWhat);
+ TopExp_Explorer E(aWhere, TopAbs_FACE);
+ for(; E.More(); E.Next()) {
+ if(!aMap.Add(E.Current())) continue;
+ if(isSameFace(aFace, TopoDS::Face(E.Current()))) {
+ listShape.Append(E.Current());
+ }
+ }
+ break;
+ }
+ case TopAbs_SOLID: {
+ TopoDS_Solid aSolid = TopoDS::Solid(aWhat);
+ TopExp_Explorer E(aWhere, TopAbs_SOLID);
+ for(; E.More(); E.Next()) {
+ if(!aMap.Add(E.Current())) continue;
+ if(isSameSolid(aSolid, TopoDS::Solid(E.Current()))) {
+ listShape.Append(E.Current());
+ }
+ }
+ break;
+ }
+ default:
+ return NULL;
+ }
+
+ if ( !listShape.IsEmpty() ) {
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aWhere, anIndices);
+ TopTools_ListIteratorOfListOfShape itSub (listShape);
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+ for (; itSub.More(); itSub.Next()) {
+ if (anIndices.Contains(itSub.Value()))
+ aSeq->Append(anIndices.FindIndex(itSub.Value()));
+ }
+ SetErrorCode(OK);
+ // The GetSameIDs() doesn't change object so no new function is required.
+ Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast(theShapeWhere,theShapeWhat)->GetLastFunction();
+
+ // Make a Python command
+ GEOM::TPythonDump(aFunction)
+ << "listSameIDs = geompy.GetSameIDs("
+ << theShapeWhere << ", "
+ << theShapeWhat << ")";
+ return aSeq;
+ } else {
+ SetErrorCode(NOT_FOUND_ANY);
+ return NULL;
+ }
+}