diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 7bd203de97f9fc445c4329f395b15b5a03437838..45aabe1ebc87f6a16071b3a363ab7d3dfc37b9af 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -221,24 +221,24 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, int nrc = 0, nrcs = 0; int nrso = somap.Extent(), nrsh = shmap.Extent(), nrf = fmap.Extent(); int nrw = wmap.Extent(), nre = emap.Extent(), nrv = vmap.Extent(); - for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nrc++; - for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nrcs++; + for(exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nrc++; + for(exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nrcs++; double surfacecont = 0; - for (exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){ + for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){ TopoDS_Face face = TopoDS::Face(exp0.Current()); GProp_GProps system; BRepGProp::SurfaceProperties(face, system); surfacecont += system.Mass(); } - if (fixdegenerated){ + if(fixdegenerated){ Msg::Info("- fix degenerated edges and faces"); { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ + for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if(BRep_Tool::Degenerated(edge)) rebuild->Remove(edge, false); @@ -252,10 +252,10 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()){ + for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){ TopoDS_Face face = TopoDS::Face(exp0.Current()); - sff = new ShapeFix_Face (face); + sff = new ShapeFix_Face(face); sff->FixAddNaturalBoundMode() = Standard_True; sff->FixSmallAreaWireMode() = Standard_True; sff->Perform(); @@ -288,28 +288,28 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ + for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); - if (BRep_Tool::Degenerated(edge)) + if(BRep_Tool::Degenerated(edge)) rebuild->Remove(edge, false); } shape = rebuild->Apply(shape); } } - if (fixsmalledges){ + if(fixsmalledges){ Msg::Info("- fixing small edges"); Handle(ShapeFix_Wire) sfw; Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()){ + for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){ TopoDS_Face face = TopoDS::Face(exp0.Current()); - for (exp1.Init (face, TopAbs_WIRE); exp1.More(); exp1.Next()){ + for(exp1.Init(face, TopAbs_WIRE); exp1.More(); exp1.Next()){ TopoDS_Wire oldwire = TopoDS::Wire(exp1.Current()); - sfw = new ShapeFix_Wire (oldwire, face ,tolerance); + sfw = new ShapeFix_Wire(oldwire, face ,tolerance); sfw->ModifyTopologyMode() = Standard_True; sfw->ClosedWireMode() = Standard_True; @@ -318,22 +318,22 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, replace = sfw->FixReorder() || replace; replace = sfw->FixConnected() || replace; - if (sfw->FixSmall(Standard_False, tolerance) && - ! (sfw->StatusSmall(ShapeExtend_FAIL1) || - sfw->StatusSmall(ShapeExtend_FAIL2) || - sfw->StatusSmall(ShapeExtend_FAIL3))){ + if(sfw->FixSmall(Standard_False, tolerance) && + ! (sfw->StatusSmall(ShapeExtend_FAIL1) || + sfw->StatusSmall(ShapeExtend_FAIL2) || + sfw->StatusSmall(ShapeExtend_FAIL3))){ Msg::Info(" fixed small edge in wire %d", wmap.FindIndex(oldwire)); replace = true; } - else if (sfw->StatusSmall(ShapeExtend_FAIL1)) + else if(sfw->StatusSmall(ShapeExtend_FAIL1)) Msg::Warning("Failed to fix small edge in wire %d, edge cannot be checked " "(no 3d curve and no pcurve)", wmap.FindIndex(oldwire)); - else if (sfw->StatusSmall(ShapeExtend_FAIL2)) + else if(sfw->StatusSmall(ShapeExtend_FAIL2)) Msg::Warning("Failed to fix small edge in wire %d, " "edge is null-length and has different vertives at begin and " "end, and lockvtx is True or ModifiyTopologyMode is False", wmap.FindIndex(oldwire)); - else if (sfw->StatusSmall(ShapeExtend_FAIL3)) + else if(sfw->StatusSmall(ShapeExtend_FAIL3)) Msg::Warning("Failed to fix small edge in wire, CheckConnected has failed", wmap.FindIndex(oldwire)); @@ -355,13 +355,13 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ + for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); - if (vmap.FindIndex(TopExp::FirstVertex(edge)) == - vmap.FindIndex(TopExp::LastVertex(edge))){ + if(vmap.FindIndex(TopExp::FirstVertex(edge)) == + vmap.FindIndex(TopExp::LastVertex(edge))){ GProp_GProps system; BRepGProp::LinearProperties(edge, system); - if (system.Mass() < tolerance){ + if(system.Mass() < tolerance){ Msg::Info(" removing degenerated edge %d from vertex %d to vertex %d", emap.FindIndex(edge), vmap.FindIndex(TopExp::FirstVertex(edge)), vmap.FindIndex(TopExp::LastVertex(edge))); @@ -375,7 +375,7 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ + for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); if(BRep_Tool::Degenerated(edge) ) rebuild->Remove(edge, false); @@ -385,61 +385,61 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe; sfwf->SetPrecision(tolerance); - sfwf->Load (shape); + sfwf->Load(shape); sfwf->ModeDropSmallEdges() = Standard_True; - if (sfwf->FixWireGaps()){ + if(sfwf->FixWireGaps()){ Msg::Info("- fixing wire gaps"); - if (sfwf->StatusWireGaps(ShapeExtend_OK)) + if(sfwf->StatusWireGaps(ShapeExtend_OK)) Msg::Info(" no gaps found"); - if (sfwf->StatusWireGaps(ShapeExtend_DONE1)) + if(sfwf->StatusWireGaps(ShapeExtend_DONE1)) Msg::Info(" some 2D gaps fixed"); - if (sfwf->StatusWireGaps(ShapeExtend_DONE2)) + if(sfwf->StatusWireGaps(ShapeExtend_DONE2)) Msg::Info(" some 3D gaps fixed"); - if (sfwf->StatusWireGaps(ShapeExtend_FAIL1)) + if(sfwf->StatusWireGaps(ShapeExtend_FAIL1)) Msg::Info(" failed to fix some 2D gaps"); - if (sfwf->StatusWireGaps(ShapeExtend_FAIL2)) + if(sfwf->StatusWireGaps(ShapeExtend_FAIL2)) Msg::Info(" failed to fix some 3D gaps"); } sfwf->SetPrecision(tolerance); - if (sfwf->FixSmallEdges()){ + if(sfwf->FixSmallEdges()){ Msg::Info("- fixing wire frames"); - if (sfwf->StatusSmallEdges(ShapeExtend_OK)) + if(sfwf->StatusSmallEdges(ShapeExtend_OK)) Msg::Info(" no small edges found"); - if (sfwf->StatusSmallEdges(ShapeExtend_DONE1)) + if(sfwf->StatusSmallEdges(ShapeExtend_DONE1)) Msg::Info(" some small edges fixed"); - if (sfwf->StatusSmallEdges(ShapeExtend_FAIL1)) + if(sfwf->StatusSmallEdges(ShapeExtend_FAIL1)) Msg::Info(" failed to fix some small edges"); } shape = sfwf->Shape(); } - if (fixspotstripfaces){ + if(fixspotstripfaces){ Msg::Info("- fixing spot and strip faces"); Handle(ShapeFix_FixSmallFace) sffsm = new ShapeFix_FixSmallFace(); - sffsm -> Init (shape); - sffsm -> SetPrecision (tolerance); - sffsm -> Perform(); + sffsm->Init(shape); + sffsm->SetPrecision(tolerance); + sffsm->Perform(); - shape = sffsm -> FixShape(); + shape = sffsm->FixShape(); } - if (sewfaces){ + if(sewfaces){ Msg::Info("- sewing faces"); BRepOffsetAPI_Sewing sewedObj(tolerance); - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()){ - TopoDS_Face face = TopoDS::Face (exp0.Current()); - sewedObj.Add (face); + for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){ + TopoDS_Face face = TopoDS::Face(exp0.Current()); + sewedObj.Add(face); } sewedObj.Perform(); - if (!sewedObj.SewedShape().IsNull()) + if(!sewedObj.SewedShape().IsNull()) shape = sewedObj.SewedShape(); else Msg::Info(" not possible"); @@ -448,41 +448,41 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, { Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ + for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){ TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); - if ( BRep_Tool::Degenerated(edge) ) + if(BRep_Tool::Degenerated(edge)) rebuild->Remove(edge, false); } shape = rebuild->Apply(shape); } - if (makesolids){ + if(makesolids){ Msg::Info("- making solids"); BRepBuilderAPI_MakeSolid ms; int count = 0; - for (exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next()){ + for(exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next()){ count++; - ms.Add (TopoDS::Shell(exp0.Current())); + ms.Add(TopoDS::Shell(exp0.Current())); } - if (!count){ + if(!count){ Msg::Info(" not possible (no shells)"); } else{ BRepCheck_Analyzer ba(ms); - if (ba.IsValid ()){ + if(ba.IsValid()){ Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape; - sfs->Init (ms); + sfs->Init(ms); sfs->SetPrecision(tolerance); sfs->SetMaxTolerance(tolerance); sfs->Perform(); shape = sfs->Shape(); - for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()){ + for(exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()){ TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); TopoDS_Solid newsolid = solid; - BRepLib::OrientClosedSolid (newsolid); + BRepLib::OrientClosedSolid(newsolid); Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; // rebuild->Apply(shape); rebuild->Replace(solid, newsolid, Standard_False); @@ -496,12 +496,12 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, } } - if (connect){ + if(connect){ #if defined(HAVE_SALOME) Msg::Info("- cutting and connecting faces with Salome's Partition_Spliter"); TopExp_Explorer e2; Partition_Spliter ps; - for (e2.Init(shape, TopAbs_SOLID); e2.More(); e2.Next()) + for(e2.Init(shape, TopAbs_SOLID); e2.More(); e2.Next()) ps.AddShape(e2.Current()); try{ ps.Compute(); @@ -521,7 +521,7 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, } double newsurfacecont = 0; - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next()){ + for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){ TopoDS_Face face = TopoDS::Face(exp0.Current()); GProp_GProps system; BRepGProp::SurfaceProperties(face, system); @@ -532,8 +532,8 @@ void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, int nnrc = 0, nnrcs = 0; int nnrso = somap.Extent(), nnrsh = shmap.Extent(), nnrf = fmap.Extent(); int nnrw = wmap.Extent(), nnre = emap.Extent(), nnrv = vmap.Extent(); - for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nnrc++; - for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nnrcs++; + for(exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nnrc++; + for(exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nnrcs++; Msg::Info("-----------------------------------"); Msg::Info("Compounds : %d (%d)", nnrc, nrc); @@ -567,14 +567,14 @@ void OCC_Internals::loadBREP(const char *fn) void OCC_Internals::writeBREP(const char *fn) { std::ofstream myFile; - myFile.open (fn); + myFile.open(fn); try { BRepTools::Write(shape, myFile); } catch(Standard_Failure &err){ Msg::Error("%s", err.GetMessageString()); } - myFile.close (); + myFile.close(); } void OCC_Internals::loadSTEP(const char *fn) @@ -600,7 +600,7 @@ void OCC_Internals::writeSTEP(const char *fn) { STEPControl_Writer writer; IFSelect_ReturnStatus status = writer.Transfer(shape, STEPControl_ManifoldSolidBrep); - if (status == IFSelect_RetDone) + if(status == IFSelect_RetDone) status = writer.Write((char*)fn); } @@ -661,7 +661,7 @@ GRegion *OCC_Internals::getOCCRegionByNativePtr(GModel *model, TopoDS_Solid toFi GVertex *OCC_Internals::addVertexToModel(GModel *model, TopoDS_Vertex vertex) { GVertex *gv = getOCCVertexByNativePtr(model, vertex); - if (gv) return gv; + if(gv) return gv; addShapeToLists(vertex); buildShapeFromLists(vertex); buildGModel(model); @@ -671,7 +671,7 @@ GVertex *OCC_Internals::addVertexToModel(GModel *model, TopoDS_Vertex vertex) GEdge *OCC_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge) { GEdge *ge = getOCCEdgeByNativePtr(model, edge); - if (ge) return ge; + if(ge) return ge; addShapeToLists(edge); buildShapeFromLists(edge); buildGModel(model); @@ -681,7 +681,7 @@ GEdge *OCC_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge) GFace* OCC_Internals::addFaceToModel(GModel *model, TopoDS_Face face) { GFace *gf = getOCCFaceByNativePtr(model, face); - if (gf) return gf; + if(gf) return gf; addShapeToLists(face); buildShapeFromLists(face); buildGModel(model); @@ -691,7 +691,7 @@ GFace* OCC_Internals::addFaceToModel(GModel *model, TopoDS_Face face) GRegion* OCC_Internals::addRegionToModel(GModel *model, TopoDS_Solid region) { GRegion *gr = getOCCRegionByNativePtr(model, region); - if (gr) return gr; + if(gr) return gr; addShapeToLists(region); buildShapeFromLists(region); buildGModel(model); @@ -704,7 +704,7 @@ void OCC_Internals::buildGModel(GModel *model) int numv = model->getMaxElementaryNumber(0) + 1; for(int i = 1; i <= vmap.Extent(); i++){ TopoDS_Vertex vertex = TopoDS::Vertex(vmap(i)); - if (!getOCCVertexByNativePtr(model, vertex)){ + if(!getOCCVertexByNativePtr(model, vertex)){ model->add(new OCCVertex(model, numv, vertex)); numv++; } @@ -715,7 +715,7 @@ void OCC_Internals::buildGModel(GModel *model) for(int i = 1; i <= emap.Extent(); i++){ int i1 = vmap.FindIndex(TopExp::FirstVertex(TopoDS::Edge(emap(i)))); int i2 = vmap.FindIndex(TopExp::LastVertex(TopoDS::Edge(emap(i)))); - if (!getOCCEdgeByNativePtr(model, TopoDS::Edge(emap(i)))){ + if(!getOCCEdgeByNativePtr(model, TopoDS::Edge(emap(i)))){ GVertex *v1 = getOCCVertexByNativePtr(model, TopoDS::Vertex(vmap(i1))); GVertex *v2 = getOCCVertexByNativePtr(model, TopoDS::Vertex(vmap(i2))); model->add(new OCCEdge(model, TopoDS::Edge(emap(i)), nume, v1, v2)); @@ -726,7 +726,7 @@ void OCC_Internals::buildGModel(GModel *model) // building geom faces int numf = model->getMaxElementaryNumber(2) + 1; for(int i = 1; i <= fmap.Extent(); i++){ - if (!getOCCFaceByNativePtr(model, TopoDS::Face(fmap(i)))){ + if(!getOCCFaceByNativePtr(model, TopoDS::Face(fmap(i)))){ model->add(new OCCFace(model, TopoDS::Face(fmap(i)), numf)); numf++; } @@ -735,7 +735,7 @@ void OCC_Internals::buildGModel(GModel *model) // building geom regions int numr = model->getMaxElementaryNumber(3) + 1; for(int i = 1; i <= somap.Extent(); i++){ - if (!getOCCRegionByNativePtr(model, TopoDS::Solid(somap(i)))){ + if(!getOCCRegionByNativePtr(model, TopoDS::Solid(somap(i)))){ model->add(new OCCRegion(model, TopoDS::Solid(somap(i)), numr)); numr++; } @@ -744,7 +744,7 @@ void OCC_Internals::buildGModel(GModel *model) void addSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList) { - if (theShape.ShapeType() != TopAbs_COMPOUND && + if(theShape.ShapeType() != TopAbs_COMPOUND && theShape.ShapeType() != TopAbs_COMPSOLID) { theList.Append(theShape); return; @@ -753,11 +753,11 @@ void addSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList) TopTools_MapOfShape mapShape; TopoDS_Iterator It(theShape, Standard_True, Standard_True); - for (; It.More(); It.Next()) { + for(; It.More(); It.Next()) { TopoDS_Shape aShape_i = It.Value(); - if (mapShape.Add(aShape_i)) { - if (aShape_i.ShapeType() == TopAbs_COMPOUND || - aShape_i.ShapeType() == TopAbs_COMPSOLID) { + if(mapShape.Add(aShape_i)) { + if(aShape_i.ShapeType() == TopAbs_COMPOUND || + aShape_i.ShapeType() == TopAbs_COMPSOLID) { addSimpleShapes(aShape_i, theList); } else { @@ -769,8 +769,8 @@ void addSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList) void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op) { - if (tool.IsNull()) return; - if (shape.IsNull()) shape = tool; + if(tool.IsNull()) return; + if(shape.IsNull()) shape = tool; else{ switch(op){ case OCC_Internals::Intersection : @@ -785,21 +785,21 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato Standard_Boolean isCompound = (listShape1.Extent() > 1 || listShape2.Extent() > 1); - TopTools_ListIteratorOfListOfShape itSub1 (listShape1); - for (; itSub1.More(); itSub1.Next()) { + TopTools_ListIteratorOfListOfShape itSub1(listShape1); + for(; itSub1.More(); itSub1.Next()) { TopoDS_Shape aValue1 = itSub1.Value(); - TopTools_ListIteratorOfListOfShape itSub2 (listShape2); - for (; itSub2.More(); itSub2.Next()) { + TopTools_ListIteratorOfListOfShape itSub2(listShape2); + for(; itSub2.More(); itSub2.Next()) { TopoDS_Shape aValue2 = itSub2.Value(); - BRepAlgoAPI_Common BO (aValue1, aValue2); - if (!BO.IsDone()) { + BRepAlgoAPI_Common BO(aValue1, aValue2); + if(!BO.IsDone()) { Msg::Error("Boolean Intersection Operator can not be performed"); } - if (isCompound) { + if(isCompound) { TopoDS_Shape aStepResult = BO.Shape(); - if (aStepResult.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator aCompIter (aStepResult); - for (; aCompIter.More(); aCompIter.Next()) { + if(aStepResult.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator aCompIter(aStepResult); + for(; aCompIter.More(); aCompIter.Next()) { B.Add(C, aCompIter.Value()); } } @@ -811,16 +811,16 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato theNewShape = BO.Shape(); } } - if (isCompound) { + if(isCompound) { TopTools_ListOfShape listShapeC; addSimpleShapes(C, listShapeC); TopTools_ListIteratorOfListOfShape itSubC(listShapeC); bool isOnlySolids = true; - for (; itSubC.More(); itSubC.Next()) { + for(; itSubC.More(); itSubC.Next()) { TopoDS_Shape aValueC = itSubC.Value(); - if (aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; + if(aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; } - // if (isOnlySolids) + // if(isOnlySolids) // theNewShape = GlueFaces(C, Precision::Confusion()); // else theNewShape = C; @@ -841,24 +841,24 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato Standard_Boolean isCompound = (listShapes.Extent() > 1); - TopTools_ListIteratorOfListOfShape itSub1 (listShapes); - for (; itSub1.More(); itSub1.Next()) { + TopTools_ListIteratorOfListOfShape itSub1(listShapes); + for(; itSub1.More(); itSub1.Next()) { TopoDS_Shape aCut = itSub1.Value(); // tools - TopTools_ListIteratorOfListOfShape itSub2 (listTools); - for (; itSub2.More(); itSub2.Next()) { + TopTools_ListIteratorOfListOfShape itSub2(listTools); + for(; itSub2.More(); itSub2.Next()) { TopoDS_Shape aTool = itSub2.Value(); - BRepAlgoAPI_Cut BO (aCut, aTool); - if (!BO.IsDone()) { + BRepAlgoAPI_Cut BO(aCut, aTool); + if(!BO.IsDone()) { Msg::Error("Cut operation can not be performed on the given shapes"); return; } aCut = BO.Shape(); } - if (isCompound) { - if (aCut.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator aCompIter (aCut); - for (; aCompIter.More(); aCompIter.Next()) { + if(isCompound) { + if(aCut.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator aCompIter(aCut); + for(; aCompIter.More(); aCompIter.Next()) { B.Add(C, aCompIter.Value()); } } @@ -870,16 +870,16 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato theNewShape = aCut; } - if (isCompound) { + if(isCompound) { TopTools_ListOfShape listShapeC; addSimpleShapes(C, listShapeC); - TopTools_ListIteratorOfListOfShape itSubC (listShapeC); + TopTools_ListIteratorOfListOfShape itSubC(listShapeC); bool isOnlySolids = true; - for (; itSubC.More(); itSubC.Next()) { + for(; itSubC.More(); itSubC.Next()) { TopoDS_Shape aValueC = itSubC.Value(); - if (aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; + if(aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; } - // if (isOnlySolids) + // if(isOnlySolids) // theNewShape = GlueFaces(C, Precision::Confusion()); // else theNewShape = C; @@ -889,8 +889,8 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato break; case OCC_Internals::Fuse : { - BRepAlgoAPI_Fuse BO (tool, shape); - if (!BO.IsDone()) { + BRepAlgoAPI_Fuse BO(tool, shape); + if(!BO.IsDone()) { Msg::Error("Fuse operation can not be performed on the given shapes"); } shape = BO.Shape(); @@ -908,24 +908,24 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato addSimpleShapes(tool, listTools); Standard_Boolean isCompound = (listShapes.Extent() > 1); - TopTools_ListIteratorOfListOfShape itSub1 (listShapes); - for (; itSub1.More(); itSub1.Next()) { + TopTools_ListIteratorOfListOfShape itSub1(listShapes); + for(; itSub1.More(); itSub1.Next()) { TopoDS_Shape aValue1 = itSub1.Value(); - TopTools_ListIteratorOfListOfShape itSub2 (listTools); - for (; itSub2.More(); itSub2.Next()) { + TopTools_ListIteratorOfListOfShape itSub2(listTools); + for(; itSub2.More(); itSub2.Next()) { TopoDS_Shape aValue2 = itSub2.Value(); - BRepAlgoAPI_Section BO (aValue1, aValue2, Standard_False); + BRepAlgoAPI_Section BO(aValue1, aValue2, Standard_False); BO.Approximation(Standard_True); BO.Build(); - if (!BO.IsDone()) { + if(!BO.IsDone()) { Msg::Error("Section operation can not be performed on the given shapes"); return; } - if (isCompound) { + if(isCompound) { TopoDS_Shape aStepResult = BO.Shape(); - if (aStepResult.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator aCompIter (aStepResult); - for (; aCompIter.More(); aCompIter.Next()) { + if(aStepResult.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator aCompIter(aStepResult); + for(; aCompIter.More(); aCompIter.Next()) { B.Add(C, aCompIter.Value()); } } @@ -937,7 +937,7 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato theNewShape = BO.Shape(); } } - if (isCompound) + if(isCompound) theNewShape = C; shape = theNewShape; } @@ -954,24 +954,24 @@ void OCC_Internals::fillet(std::vector<TopoDS_Edge> &edgesToFillet, { // create a tool for fillet BRepFilletAPI_MakeFillet fill(shape); - for (unsigned int i = 0; i < edgesToFillet.size(); ++i){ + for(unsigned int i = 0; i < edgesToFillet.size(); ++i){ fill.Add(edgesToFillet[i]); } - for (int i = 1; i <= fill.NbContours(); i++){ + for(int i = 1; i <= fill.NbContours(); i++){ fill.SetRadius(Radius, i, 1); } fill.Build(); - if (!fill.IsDone()) { + if(!fill.IsDone()) { Msg::Error("Fillet can't be computed on the given shape with the given radius"); return; } shape = fill.Shape(); - if (shape.IsNull()) return; + if(shape.IsNull()) return; // Check shape validity - BRepCheck_Analyzer ana (shape, false); - if (!ana.IsValid()) { + BRepCheck_Analyzer ana(shape, false); + if(!ana.IsValid()) { Msg::Error("Fillet algorithm have produced an invalid shape result"); } } @@ -1009,7 +1009,7 @@ int GModel::readOCCIGES(const std::string &fn) int GModel::writeOCCBREP(const std::string &fn) { - if (!_occ_internals){ + if(!_occ_internals){ Msg::Error("No OpenCASCADE model found"); return 0; } @@ -1020,7 +1020,7 @@ int GModel::writeOCCBREP(const std::string &fn) int GModel::writeOCCSTEP(const std::string &fn) { - if (!_occ_internals){ + if(!_occ_internals){ Msg::Error("No OpenCASCADE model found"); return 0; } diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index 27f6f1636a3e2d858bdce0fc45b65b70a65113be..5e2fcc3db0f6e4fc336f0037cc1bb7c78cfc3447 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -15,8 +15,9 @@ class OCC_Internals { protected : + // the shape TopoDS_Shape shape; - // all TopoDS_Shapes in the OCC model + // all the (sub) TopoDS_Shapes in 'shape' TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap; // cache mapping TopoDS_Shapes to their corresponding GEntity tags TopTools_DataMapOfShapeInteger gvNumCache, geNumCache, gfNumCache, grNumCache;