-
-using namespace std;
+// 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
+//
+
+#include <Standard_Stream.hxx>
#include <BRepOffsetAPI_MakeFilling.hxx>
-#include "GEOMImpl_BlockDriver.hxx"
-#include "GEOMImpl_IBlocks.hxx"
-#include "GEOMImpl_IBlockTrsf.hxx"
-#include "GEOMImpl_GlueDriver.hxx"
-#include "GEOMImpl_Types.hxx"
-#include "GEOMImpl_ILocalOperations.hxx"
-#include "GEOMImpl_Block6Explorer.hxx"
-#include "GEOM_Function.hxx"
+#include <GEOMImpl_BlockDriver.hxx>
+#include <GEOMImpl_IBlocks.hxx>
+#include <GEOMImpl_IBlockTrsf.hxx>
+#include <GEOMImpl_GlueDriver.hxx>
+#include <GEOMImpl_Types.hxx>
+#include <GEOMImpl_ILocalOperations.hxx>
+#include <GEOMImpl_Block6Explorer.hxx>
+#include <GEOMImpl_IBlocksOperations.hxx>
+
+#include <GEOM_Function.hxx>
+
+#include <ShHealOper_Sewing.hxx>
+#include <ShHealOper_ShapeProcess.hxx>
+//#include <GEOMAlgo_Gluer.hxx>
+#include <BlockFix_BlockFixAPI.hxx>
+#include <BlockFix_UnionFaces.hxx>
-#include "ShHealOper_Sewing.hxx"
-#include "NMTAlgo_Splitter1.hxx"
+#include "utilities.h"
#include <TNaming_CopyShape.hxx>
+#include <BRepAdaptor_Curve.hxx>
#include <BRepLib.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepCheck_Analyzer.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepExtrema_ExtPF.hxx>
#include <GProp_GProps.hxx>
+#include <Geom_Line.hxx>
+#include <GC_MakeLine.hxx>
+
#include <gp.hxx>
#include <gp_Pnt.hxx>
#include <gp_Ax3.hxx>
}
// build wire in right order, corresponding to edges connexity
- BRepBuilderAPI_MakeWire MW;
+ BRepBuilderAPI_MakeWire* MW;
if (isConnected12)
- MW = BRepBuilderAPI_MakeWire(anEdge1, anEdge2, anEdge3, anEdge4);
+ MW = new BRepBuilderAPI_MakeWire(anEdge1, anEdge2, anEdge3, anEdge4);
else
- MW = BRepBuilderAPI_MakeWire(anEdge1, anEdge3, anEdge2, anEdge4);
+ MW = new BRepBuilderAPI_MakeWire(anEdge1, anEdge3, anEdge2, anEdge4);
- if (!MW.IsDone()) {
+ if (!MW->IsDone()) {
Standard_ConstructionError::Raise
("Impossible to build a connected wire from the given edges");
}
- TopoDS_Wire aWire = MW;
+ TopoDS_Wire aWire = *MW;
+ delete MW;
+
+ // check the wire closure
+ TopoDS_Vertex aV1, aV2;
+ TopExp::Vertices(aWire, aV1, aV2);
+ if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+ aWire.Closed( true );
+
if (!aWire.Closed()) {
Standard_ConstructionError::Raise
("Impossible to build a closed wire from the given edges");
// create two edges, linking ends of the given edges
TopoDS_Vertex V11, V12, V21, V22;
- TopExp::Vertices(anEdge1, V11, V12, Standard_True);
- TopExp::Vertices(anEdge2, V21, V22, Standard_True);
+ TopExp::Vertices(anEdge1, V11, V12, Standard_False);
+ TopExp::Vertices(anEdge2, V21, V22, Standard_False);
if (V11.IsNull() || V12.IsNull() ||
V21.IsNull() || V22.IsNull()) {
Standard_NullObject::Raise("Bad edge for face construction: vertex is not defined");
}
- gp_Pnt P11 = BRep_Tool::Pnt(V11);
- gp_Pnt P12 = BRep_Tool::Pnt(V12);
- gp_Pnt P21 = BRep_Tool::Pnt(V21);
- gp_Pnt P22 = BRep_Tool::Pnt(V22);
+
+ BRepAdaptor_Curve C1 (anEdge1);
+ BRepAdaptor_Curve C2 (anEdge2);
+ gp_Pnt P11, P12, P21, P22;
+
+ // Mantis issue 0020599: Creation of a quadrangle face from 2 edges: SIGSEGV
+ P11 = C1.Value(C1.FirstParameter());
+ P12 = C1.Value(C1.LastParameter());
+ P21 = C2.Value(C2.FirstParameter());
+ P22 = C2.Value(C2.LastParameter());
+ //gp_Pnt P11 = BRep_Tool::Pnt(V11);
+ //gp_Pnt P12 = BRep_Tool::Pnt(V12);
+ //gp_Pnt P21 = BRep_Tool::Pnt(V21);
+ //gp_Pnt P22 = BRep_Tool::Pnt(V22);
if (P11.Distance(P21) < prec || P12.Distance(P22) < prec ||
P11.Distance(P22) < prec || P12.Distance(P21) < prec) {
Standard_Real per11 = P11.Distance(P21) + P12.Distance(P22);
Standard_Real per12 = P11.Distance(P22) + P12.Distance(P21);
+ BRep_Builder BB;
+
TopoDS_Edge anEdge3;
TopoDS_Edge anEdge4;
+
+ // Mantis issue 0020599: Creation of a quadrangle face from 2 edges: SIGSEGV
if (per11 < per12) {
- anEdge3 = BRepBuilderAPI_MakeEdge(V11, V21);
- anEdge4 = BRepBuilderAPI_MakeEdge(V12, V22);
- } else {
- anEdge3 = BRepBuilderAPI_MakeEdge(V11, V22);
- anEdge4 = BRepBuilderAPI_MakeEdge(V12, V21);
+ Handle(Geom_Line) Line1 = GC_MakeLine(P11, P21).Value();
+ Handle(Geom_Line) Line2 = GC_MakeLine(P12, P22).Value();
+
+ BB.MakeEdge(anEdge3, Line1, Precision::Confusion());
+ BB.Range(anEdge3, 0., P11.Distance(P21));
+ BB.Add(anEdge3, V11.Oriented(TopAbs_FORWARD));
+ BB.Add(anEdge3, V21.Oriented(TopAbs_REVERSED));
+
+ BB.MakeEdge(anEdge4, Line2, Precision::Confusion());
+ BB.Range(anEdge4, 0., P12.Distance(P22));
+ BB.Add(anEdge4, V12.Oriented(TopAbs_FORWARD));
+ BB.Add(anEdge4, V22.Oriented(TopAbs_REVERSED));
+ }
+ else {
+ Handle(Geom_Line) Line1 = GC_MakeLine(P11, P22).Value();
+ Handle(Geom_Line) Line2 = GC_MakeLine(P12, P21).Value();
+
+ BB.MakeEdge(anEdge3, Line1, Precision::Confusion());
+ BB.Range(anEdge3, 0., P11.Distance(P22));
+ BB.Add(anEdge3, V11.Oriented(TopAbs_FORWARD));
+ BB.Add(anEdge3, V22.Oriented(TopAbs_REVERSED));
+
+ BB.MakeEdge(anEdge4, Line2, Precision::Confusion());
+ BB.Range(anEdge4, 0., P12.Distance(P21));
+ BB.Add(anEdge4, V12.Oriented(TopAbs_FORWARD));
+ BB.Add(anEdge4, V21.Oriented(TopAbs_REVERSED));
}
+ //if (per11 < per12) {
+ // anEdge3 = BRepBuilderAPI_MakeEdge(V11, V21);
+ // anEdge4 = BRepBuilderAPI_MakeEdge(V12, V22);
+ //} else {
+ // anEdge3 = BRepBuilderAPI_MakeEdge(V11, V22);
+ // anEdge4 = BRepBuilderAPI_MakeEdge(V12, V21);
+ //}
// build a wire
- BRepBuilderAPI_MakeWire MW (anEdge1, anEdge3, anEdge2, anEdge4);
- if (!MW.IsDone()) {
+ BRepBuilderAPI_MakeWire* MW;
+ MW = new BRepBuilderAPI_MakeWire(anEdge1, anEdge3, anEdge2, anEdge4);
+ if (!MW->IsDone()) {
Standard_ConstructionError::Raise("Wire construction failed");
}
+ TopoDS_Wire aWire = *MW;
+ delete MW;
+
+ TopoDS_Vertex aV1, aV2;
+ TopExp::Vertices(aWire, aV1, aV2);
+ if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+ aWire.Closed( true );
+
+ if (!aWire.Closed()) {
+ Standard_ConstructionError::Raise
+ ("Impossible to build a closed wire from the given edges");
+ }
+
// try to build face on the wire
- GEOMImpl_Block6Explorer::MakeFace(MW, Standard_False, aShape);
+ GEOMImpl_Block6Explorer::MakeFace(aWire, Standard_False, aShape);
if (aShape.IsNull()) {
Standard_ConstructionError::Raise("Face construction failed");
}
}
// try to build face on the wire
+ aMkPoly.Close();
GEOMImpl_Block6Explorer::MakeFace(aMkPoly, Standard_False, aShape);
if (aShape.IsNull()) {
Standard_ConstructionError::Raise("Face construction failed");
BRepTools_Quilt Glue;
if (aType == BLOCK_SIX_FACES) {
-
// Make block (hexahedral solid) from six faces
for (Standard_Integer ind = 1; ind <= nbshapes; ind++) {
if (anArgs(ind).ShapeType() != TopAbs_FACE) {
Glue.Add(anArgs(ind));
}
- } else {
-
+ }
+ else {
// Make block (hexahedral solid) from two opposite faces
if (anArgs(1).ShapeType() != TopAbs_FACE ||
anArgs(2).ShapeType() != TopAbs_FACE) {
}
aShape = Sol;
BRepLib::SameParameter(aShape, 1.E-5, Standard_True);
-
- } else if (aType == BLOCK_COMPOUND_GLUE) {
-
+ }
+ else if (aType == BLOCK_COMPOUND_GLUE) {
// Make blocks compound from a compound
if (anArgs(1).ShapeType() != TopAbs_COMPOUND &&
anArgs(2).ShapeType() != TopAbs_COMPSOLID) {
TopoDS_Shape aCompound = anArgs(1);
- // Glue coincident faces and edges (with Partition algorithm).
- NMTAlgo_Splitter1 PS;
- PS.AddShape(aCompound);
- PS.Compute();
- PS.SetRemoveWebs(Standard_False);
-// PS.Build(aCompound.ShapeType());
- PS.Build(TopAbs_SOLID);
-
- aShape = PS.Shape();
- } else {
+ // Glue coincident faces and edges
+ aShape = GEOMImpl_GlueDriver::GlueFaces(aCompound, Precision::Confusion(), Standard_True);
+ //GEOMAlgo_Gluer aGluer;
+ //aGluer.SetShape(aCompound);
+ //aGluer.SetCheckGeometry(Standard_True);
+ //aGluer.Perform();
+ //aShape = aGluer.Result();
}
-
- } else { // Multi-transformations
-
- TopoDS_Shape aMulti;
- GEOMImpl_IBlockTrsf aCI (aFunction);
- Handle(GEOM_Function) aRefShape = aCI.GetOriginal();
- TopoDS_Shape aBlockIni = aRefShape->GetValue();
- if (aBlockIni.IsNull()) {
- Standard_NullObject::Raise("Null Block");
+ else {
}
- // Copy block to avoid problems (PAL6706)
- TColStd_IndexedDataMapOfTransientTransient aMap;
- TopoDS_Shape aBlock;
- TNaming_CopyShape::CopyTool(aBlockIni, aMap, aBlock);
+ } else { // Multi-transformations and compound improving
- // Block tolerance in vertices
- Standard_Real aTol = prec;
- TopExp_Explorer expV (aBlock, TopAbs_VERTEX);
- TopTools_MapOfShape mapShape;
- for (; expV.More(); expV.Next()) {
- if (mapShape.Add(expV.Current())) {
- TopoDS_Vertex aV = TopoDS::Vertex(expV.Current());
- aTol = Max(BRep_Tool::Tolerance(aV), aTol);
- }
- }
+ if (aType == BLOCK_REMOVE_EXTRA ||
+ aType == BLOCK_COMPOUND_IMPROVE) {
- if (aType == BLOCK_MULTI_TRANSFORM_1D) {
- // Retrieve a faces by Ids
- Standard_Integer aFace1Id = aCI.GetFace1U();
- Standard_Integer aFace2Id = aCI.GetFace2U();
- TopoDS_Shape aFace1, aFace2;
- if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1Id, aFace1)) {
- Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
+ GEOMImpl_IBlockTrsf aCI (aFunction);
+ Handle(GEOM_Function) aRefShape = aCI.GetOriginal();
+ TopoDS_Shape aBlockOrComp = aRefShape->GetValue();
+ if (aBlockOrComp.IsNull()) {
+ Standard_NullObject::Raise("Null Shape given");
}
- if (aFace1.ShapeType() != TopAbs_FACE) {
- Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
+
+ // Copy shape to avoid problems (Mantis issue 0021683)
+ TopoDS_Shape aShapeCopy;
+ TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
+ TNaming_CopyShape::CopyTool(aBlockOrComp, aMapTShapes, aShapeCopy);
+ aBlockOrComp = aShapeCopy;
+
+ // 1. Improve solids with seam and/or degenerated edges
+ BlockFix_BlockFixAPI aTool;
+ //aTool.Tolerance() = toler;
+ aTool.OptimumNbFaces() = aCI.GetOptimumNbFaces();
+ aTool.SetShape(aBlockOrComp);
+ aTool.Perform();
+
+ TopoDS_Shape aFixedExtra = aTool.Shape();
+
+ // Repair result
+ BRepCheck_Analyzer ana (aFixedExtra, false);
+ if (!ana.IsValid()) {
+ TopoDS_Shape aFixed;
+ ShHealOper_ShapeProcess aHealer;
+ aHealer.Perform(aFixedExtra, aFixed);
+ if (aHealer.isDone())
+ aFixedExtra = aFixed;
}
- if (aFace2Id > 0) {
- if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2Id, aFace2)) {
- Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
- }
- if (aFace2.ShapeType() != TopAbs_FACE) {
- Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
+ if (aType == BLOCK_REMOVE_EXTRA)
+ {
+ aShape = aFixedExtra;
+
+ if (aShape == aBlockOrComp) {
+ MESSAGE("No modifications have been done");
}
}
+ else // aType == BLOCK_COMPOUND_IMPROVE
+ {
+ // 2. Separate non-blocks
+ TopTools_ListOfShape BLO; // All blocks from the given compound
+ TopTools_ListOfShape NOT; // Not blocks
+ TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges
+ TopTools_ListOfShape NOQ; // All non-quadrangular faces
+ GEOMImpl_IBlocksOperations::AddBlocksFrom(aFixedExtra, BLO, NOT, EXT, NOQ);
+
+ if (NOT.Extent() > 0) {
+ MESSAGE("Some non-blocks have been removed");
+ }
- Standard_Integer aNbIter = aCI.GetNbIterU();
+ // 3. Warn about staying extra-edges
+ if (EXT.Extent() > 0) {
+ MESSAGE("Warning: Not all seam or degenerated edges was removed");
+ }
- MultiTransformate1D(aBlock, aFace1, aFace2, aNbIter, aMulti);
+ // ??? Throw away standalone blocks ???
- } else if (aType == BLOCK_MULTI_TRANSFORM_2D) {
- // Retrieve a faces by Ids
- Standard_Integer aFace1UId = aCI.GetFace1U();
- Standard_Integer aFace2UId = aCI.GetFace2U();
- Standard_Integer aFace1VId = aCI.GetFace1V();
- Standard_Integer aFace2VId = aCI.GetFace2V();
+ // 4. Create compound of all blocks
+ TopoDS_Compound aComp;
+ BRep_Builder BB;
+ BB.MakeCompound(aComp);
+ TopTools_ListIteratorOfListOfShape BLOit (BLO);
+ for (; BLOit.More(); BLOit.Next()) {
+ BB.Add(aComp, BLOit.Value());
+ }
- TopoDS_Shape aFace1U, aFace2U, aFace1V, aFace2V;
- if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1UId, aFace1U) ||
- !GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1VId, aFace1V)) {
- Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
+ // 5. Glue Faces
+ aShape = GEOMImpl_GlueDriver::GlueFaces(aComp, Precision::Confusion(), Standard_False);
}
- if (aFace1U.ShapeType() != TopAbs_FACE ||
- aFace1V.ShapeType() != TopAbs_FACE) {
- Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
+ } else if (aType == BLOCK_MULTI_TRANSFORM_1D ||
+ aType == BLOCK_MULTI_TRANSFORM_2D) {
+
+ TopoDS_Shape aMulti;
+ GEOMImpl_IBlockTrsf aCI (aFunction);
+ Handle(GEOM_Function) aRefShape = aCI.GetOriginal();
+ TopoDS_Shape aBlockIni = aRefShape->GetValue();
+ if (aBlockIni.IsNull()) {
+ Standard_NullObject::Raise("Null Block");
}
- if (aFace2UId > 0) {
- if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2UId, aFace2U)) {
- Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
+ // Copy block to avoid problems (PAL6706)
+ TColStd_IndexedDataMapOfTransientTransient aMap;
+ TopoDS_Shape aBlock;
+ TNaming_CopyShape::CopyTool(aBlockIni, aMap, aBlock);
+
+ // Block tolerance in vertices
+ Standard_Real aTol = prec;
+ TopExp_Explorer expV (aBlock, TopAbs_VERTEX);
+ TopTools_MapOfShape mapShape;
+ for (; expV.More(); expV.Next()) {
+ if (mapShape.Add(expV.Current())) {
+ TopoDS_Vertex aV = TopoDS::Vertex(expV.Current());
+ aTol = Max(BRep_Tool::Tolerance(aV), aTol);
}
+ }
- if (aFace2U.ShapeType() != TopAbs_FACE) {
+ if (aType == BLOCK_MULTI_TRANSFORM_1D) {
+ // Retrieve a faces by Ids
+ Standard_Integer aFace1Id = aCI.GetFace1U();
+ Standard_Integer aFace2Id = aCI.GetFace2U();
+ TopoDS_Shape aFace1, aFace2;
+ if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1Id, aFace1)) {
+ Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
+ }
+ if (aFace1.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
}
- }
- if (aFace2VId > 0) {
- if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2VId, aFace2V)) {
+ if (aFace2Id > 0) {
+ if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2Id, aFace2)) {
+ Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
+ }
+ if (aFace2.ShapeType() != TopAbs_FACE) {
+ Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
+ }
+ }
+
+ Standard_Integer aNbIter = aCI.GetNbIterU();
+
+ MultiTransformate1D(aBlock, aFace1, aFace2, aNbIter, aMulti);
+
+ } else { // aType == BLOCK_MULTI_TRANSFORM_2D
+ // Retrieve a faces by Ids
+ Standard_Integer aFace1UId = aCI.GetFace1U();
+ Standard_Integer aFace2UId = aCI.GetFace2U();
+ Standard_Integer aFace1VId = aCI.GetFace1V();
+ Standard_Integer aFace2VId = aCI.GetFace2V();
+
+ TopoDS_Shape aFace1U, aFace2U, aFace1V, aFace2V;
+ if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1UId, aFace1U) ||
+ !GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1VId, aFace1V)) {
Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
}
- if (aFace2V.ShapeType() != TopAbs_FACE) {
+ if (aFace1U.ShapeType() != TopAbs_FACE ||
+ aFace1V.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
}
+
+ if (aFace2UId > 0) {
+ if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2UId, aFace2U)) {
+ Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
+ }
+
+ if (aFace2U.ShapeType() != TopAbs_FACE) {
+ Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
+ }
+ }
+
+ if (aFace2VId > 0) {
+ if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2VId, aFace2V)) {
+ Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id");
+ }
+
+ if (aFace2V.ShapeType() != TopAbs_FACE) {
+ Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face");
+ }
+ }
+
+ Standard_Integer aNbIterU = aCI.GetNbIterU();
+ Standard_Integer aNbIterV = aCI.GetNbIterV();
+
+ MultiTransformate2D(aBlock,
+ aFace1U, aFace2U, aNbIterU,
+ aFace1V, aFace2V, aNbIterV, aMulti);
}
- Standard_Integer aNbIterU = aCI.GetNbIterU();
- Standard_Integer aNbIterV = aCI.GetNbIterV();
+ if (aMulti.IsNull()) {
+ StdFail_NotDone::Raise("Multi-transformation failed");
+ }
- MultiTransformate2D(aBlock,
- aFace1U, aFace2U, aNbIterU,
- aFace1V, aFace2V, aNbIterV, aMulti);
+ // Glue faces of the multi-block
+ aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol, Standard_False);
- } else {
- return 0;
- }
+ } else if (aType == BLOCK_UNION_FACES) {
+ GEOMImpl_IBlockTrsf aCI (aFunction);
+ Handle(GEOM_Function) aRefShape = aCI.GetOriginal();
+ TopoDS_Shape aBlockOrComp = aRefShape->GetValue();
+ if (aBlockOrComp.IsNull()) {
+ Standard_NullObject::Raise("Null Shape given");
+ }
- if (aMulti.IsNull()) {
- StdFail_NotDone::Raise("Multi-transformation failed");
+ BlockFix_UnionFaces aFaceUnifier;
+
+ aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces.
+ aShape = aFaceUnifier.Perform(aBlockOrComp);
+ } else { // unknown function type
return 0;
}
-
- // Glue faces of the multi-block
- aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol);
}
if (aShape.IsNull()) return 0;
theResult = aCompound;
}
-//=======================================================================
-//function : GEOMImpl_BlockDriver_Type_
-//purpose :
-//=======================================================================
-Standard_EXPORT Handle_Standard_Type& GEOMImpl_BlockDriver_Type_()
-{
-
- static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
- if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
- static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
- if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
- static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
- if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
+//================================================================================
+/*!
+ * \brief Returns a name of creation operation and names and values of creation parameters
+ */
+//================================================================================
-
- static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
- static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_BlockDriver",
- sizeof(GEOMImpl_BlockDriver),
- 1,
- (Standard_Address)_Ancestors,
- (Standard_Address)NULL);
-
- return _aType;
-}
-
-//=======================================================================
-//function : DownCast
-//purpose :
-//=======================================================================
-const Handle(GEOMImpl_BlockDriver) Handle(GEOMImpl_BlockDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
+bool GEOMImpl_BlockDriver::
+GetCreationInformation(std::string& theOperationName,
+ std::vector<GEOM_Param>& theParams)
{
- Handle(GEOMImpl_BlockDriver) _anOtherObject;
-
- if (!AnObject.IsNull()) {
- if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_BlockDriver))) {
- _anOtherObject = Handle(GEOMImpl_BlockDriver)((Handle(GEOMImpl_BlockDriver)&)AnObject);
- }
+ if (Label().IsNull()) return 0;
+ Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
+
+ Standard_Integer aType = function->GetType();
+ GEOMImpl_IBlocks aCI1 (function);
+ GEOMImpl_IBlockTrsf aCI2 (function);
+ Handle(TColStd_HSequenceOfTransient) aShapes = aCI1.GetShapes();
+
+ switch ( aType ) {
+ case BLOCK_FACE_FOUR_EDGES:
+ theOperationName = "Q_FACE";
+ AddParam( theParams, "Edge 1", aShapes->Value(1) );
+ AddParam( theParams, "Edge 2", aShapes->Value(2) );
+ AddParam( theParams, "Edge 3", aShapes->Value(3) );
+ AddParam( theParams, "Edge 4", aShapes->Value(4) );
+ break;
+ case BLOCK_FACE_TWO_EDGES:
+ theOperationName = "Q_FACE";
+ AddParam( theParams, "Edge 1", aShapes->Value(1) );
+ AddParam( theParams, "Edge 2", aShapes->Value(2) );
+ break;
+ case BLOCK_FACE_FOUR_PNT:
+ theOperationName = "Q_FACE";
+ AddParam( theParams, "Point 1", aShapes->Value(1) );
+ AddParam( theParams, "Point 2", aShapes->Value(2) );
+ AddParam( theParams, "Point 3", aShapes->Value(3) );
+ AddParam( theParams, "Point 4", aShapes->Value(4) );
+ break;
+ case BLOCK_SIX_FACES:
+ theOperationName = "HEX_SOLID";
+ AddParam( theParams, "Face 1", aShapes->Value(1) );
+ AddParam( theParams, "Face 2", aShapes->Value(2) );
+ AddParam( theParams, "Face 3", aShapes->Value(3) );
+ AddParam( theParams, "Face 4", aShapes->Value(4) );
+ AddParam( theParams, "Face 5", aShapes->Value(5) );
+ AddParam( theParams, "Face 6", aShapes->Value(6) );
+ break;
+ case BLOCK_TWO_FACES:
+ theOperationName = "HEX_SOLID";
+ AddParam( theParams, "Face 1", aShapes->Value(1) );
+ AddParam( theParams, "Face 2", aShapes->Value(2) );
+ break;
+ case BLOCK_COMPOUND_GLUE:
+ theOperationName = "MakeBlockCompound";
+ AddParam( theParams, "Compound", aShapes->Value(1) );
+ break;
+ case BLOCK_REMOVE_EXTRA:
+ theOperationName = "REMOVE_EXTRA_EDGES";
+ AddParam( theParams, "Selected shape", aCI2.GetOriginal() );
+ AddParam( theParams, "Union faces", aCI2.GetOptimumNbFaces() == 0);
+ break;
+ case BLOCK_COMPOUND_IMPROVE:
+ theOperationName = "CHECK_COMPOUND";
+ AddParam( theParams, "Selected shape", aCI2.GetOriginal() );
+ break;
+ case BLOCK_MULTI_TRANSFORM_1D:
+ theOperationName = "MUL_TRANSFORM";
+ AddParam( theParams, "Main Object", aCI2.GetOriginal() );
+ AddParam( theParams, "Face 1", aCI2.GetFace1U() );
+ AddParam( theParams, "Face 2", aCI2.GetFace2U() );
+ AddParam( theParams, "Nb. Times", aCI2.GetNbIterU() );
+ break;
+ case BLOCK_MULTI_TRANSFORM_2D:
+ theOperationName = "MUL_TRANSFORM";
+ AddParam( theParams, "Main Object", aCI2.GetOriginal() );
+ AddParam( theParams, "Face 1 U", aCI2.GetFace1U() );
+ AddParam( theParams, "Face 2 U", aCI2.GetFace2U() );
+ AddParam( theParams, "Nb. Times V", aCI2.GetNbIterV() );
+ AddParam( theParams, "Face 1 V", aCI2.GetFace1V() );
+ AddParam( theParams, "Face 2 V", aCI2.GetFace2V() );
+ AddParam( theParams, "Nb. Times V", aCI2.GetNbIterV() );
+ break;
+ case BLOCK_UNION_FACES:
+ theOperationName = "UNION_FACES";
+ AddParam( theParams, "Selected shape", aCI2.GetOriginal() );
+ break;
+ default:
+ return false;
}
- return _anOtherObject ;
+ return true;
}
+
+IMPLEMENT_STANDARD_HANDLE (GEOMImpl_BlockDriver,GEOM_BaseDriver);
+
+IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_BlockDriver,GEOM_BaseDriver);