diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index 0612806190f68e517b4eda8f9dfe1983e0d3ab2e..387fdc3736da21f9eb8f0784d5a80f01ca9dc762 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -66,35 +66,36 @@ std::string GEntity::getInfoString() return sstream.str(); } -GVertex * GEntity::Cast2Vertex () {return dynamic_cast<GVertex*>(this);} -GEdge * GEntity::Cast2Edge () {return dynamic_cast<GEdge*>(this);} -GFace * GEntity::Cast2Face () {return dynamic_cast<GFace*>(this);} -GRegion * GEntity::Cast2Region () {return dynamic_cast<GRegion*>(this);} - +GVertex *GEntity::cast2Vertex() { return dynamic_cast<GVertex*>(this); } +GEdge *GEntity::cast2Edge() { return dynamic_cast<GEdge*>(this); } +GFace *GEntity::cast2Face() { return dynamic_cast<GFace*>(this); } +GRegion *GEntity::cast2Region() { return dynamic_cast<GRegion*>(this); } void GEntity::registerBindings(binding *b) { classBinding *cb = b->addClass<GEntity>("GEntity"); cb->setDescription("A GEntity is a geometrical entity of the model."); methodBinding *mb; - mb = cb->addMethod("getNumMeshElements",(unsigned int (GEntity::*)())&GEntity::getNumMeshElements); + mb = cb->addMethod("getNumMeshElements", + (unsigned int (GEntity::*)())&GEntity::getNumMeshElements); mb->setDescription("return the number of mesh elements in this entity"); mb = cb->addMethod("getMeshElement",&GEntity::getMeshElement); mb->setDescription("get the mesh element at the given index"); mb->setArgNames("index",NULL); - mb = cb->addMethod("getNumMeshVertices",(unsigned int (GEntity::*)())&GEntity::getNumMeshVertices); + mb = cb->addMethod("getNumMeshVertices", + (unsigned int (GEntity::*)())&GEntity::getNumMeshVertices); mb->setDescription("return the number of mesh vertices in this entity"); mb = cb->addMethod("getMeshVertex",&GEntity::getMeshVertex); mb->setDescription("get the mesh vertex at the given index"); mb->setArgNames("index",NULL); mb = cb->addMethod("model", &GEntity::model); mb->setDescription("returns the geometric model the entity belongs to."); - mb = cb->addMethod("Cast2Vertex", &GEntity::Cast2Vertex); + mb = cb->addMethod("cast2Vertex", &GEntity::cast2Vertex); mb->setDescription("do a dynamic cast of the GEntity to a GVertex (0 if wrong cast)."); - mb = cb->addMethod("Cast2Edge", &GEntity::Cast2Edge); + mb = cb->addMethod("cast2Edge", &GEntity::cast2Edge); mb->setDescription("do a dynamic cast of the GEntity to a GEdge (0 if wrong cast)."); - mb = cb->addMethod("Cast2Face", &GEntity::Cast2Face); + mb = cb->addMethod("cast2Face", &GEntity::cast2Face); mb->setDescription("do a dynamic cast of the GEntity to a GFace (0 if wrong cast)."); - mb = cb->addMethod("Cast2Region", &GEntity::Cast2Region); + mb = cb->addMethod("cast2Region", &GEntity::cast2Region); mb->setDescription("do a dynamic cast of the GEntity to a GRegion (0 if wrong cast)."); } diff --git a/Geo/GEntity.h b/Geo/GEntity.h index 4ad228a5436f66d3f046c8fbbe967c97a270074e..e717303573003b8790ace0e985f860c71f606691 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -33,7 +33,8 @@ class GEntity { // the tag (the number) of this entity int _tag; - // gives the number of the master entity in periodic mesh, gives 0 if non-periodic + // gives the number of the master entity in periodic mesh, gives 0 + // if non-periodic int _meshMaster; // the visibility and the selection flag @@ -219,8 +220,8 @@ class GEntity { void setTag(int tag) { _tag = tag; } // returns the tag of the entity that its master entity (for mesh) - int meshMaster() const {return _meshMaster; } - void setMeshMaster(int m) { _meshMaster=m; } + int meshMaster() const { return _meshMaster; } + void setMeshMaster(int m) { _meshMaster = m; } // get the bounding box virtual SBoundingBox3d bounds() const { return SBoundingBox3d(); } @@ -276,10 +277,10 @@ class GEntity { MVertex *getMeshVertex(unsigned int index) { return mesh_vertices[index]; } // clean downcasts - GVertex * Cast2Vertex (); - GEdge * Cast2Edge (); - GFace * Cast2Face (); - GRegion * Cast2Region (); + GVertex *cast2Vertex(); + GEdge *cast2Edge(); + GFace *cast2Face(); + GRegion *cast2Region(); // bindings static void registerBindings(binding *b); diff --git a/Geo/GFace.h b/Geo/GFace.h index 23447b4b2d2d693db40c922df851888da1bd3922..42f85bfdb97350bd3ee158c9ae50ed8e37d204e2 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -52,8 +52,8 @@ class GFace : public GEntity GFaceCompound *compound; // this model edge belongs to a compound // replace edges (gor gluing) for specific modelers, we have to - // re-create internal data ... - virtual void replaceEdgesInternal (std::list<GEdge*> &){} + // re-create internal data + virtual void replaceEdgesInternal(std::list<GEdge*> &){} public: // this will become protected or private std::list<GEdgeLoop> edgeLoops; @@ -301,7 +301,7 @@ class GFace : public GEntity std::vector<MVertex*> _additional_vertices; // replace edges (gor gluing) - void replaceEdges (std::list<GEdge*> &); + void replaceEdges(std::list<GEdge*> &); static void registerBindings(binding *b); }; diff --git a/Geo/GFaceCompound.h b/Geo/GFaceCompound.h index b92b76d8e8233cd3b7685ebd545094738d5e5b1c..887545ec052ac544370294d9b15d58614fdee828 100644 --- a/Geo/GFaceCompound.h +++ b/Geo/GFaceCompound.h @@ -82,8 +82,8 @@ class GFaceCompound : public GFace { double checkAspectRatio() const; void computeNormals () const; void getBoundingEdges(); - void getUniqueEdges(std::set<GEdge*> & _unique); - void computeALoop(std::set<GEdge*> & _unique, std::list<GEdge*> &); + void getUniqueEdges(std::set<GEdge*> &_unique); + void computeALoop(std::set<GEdge*> &_unique, std::list<GEdge*> &); void getTriangle(double u, double v, GFaceCompoundTriangle **lt, double &_u, double &_v) const; virtual double locCurvature(MTriangle *t, double u, double v) const; @@ -119,10 +119,10 @@ class GFaceCompound : public GFace { bool parametrize() const ; void coherenceNormals(); void partitionFaceCM(); - virtual std::list<GFace*> getCompounds() const {return _compound;}; + virtual std::list<GFace*> getCompounds() const { return _compound; } mutable int nbSplit; - int getNbSplit() const {return nbSplit;} - int allowPartition() const{return _allowPartition;}; + int getNbSplit() const { return nbSplit; } + int allowPartition() const{ return _allowPartition; } private: typeOfIsomorphism _type; mutable typeOfMapping _mapping; diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 560f796260a99687f1de076e265196c33b4a5cc4..7ad1d8082cae3136f794f72682b6b05cf7c6c797 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1406,10 +1406,11 @@ void GModel::save(std::string fileName) GModel::setCurrent(temp); } -static void ComputeDuplicates (GModel * model, - std::multimap<GVertex*,GVertex*> & Unique2Duplicates, - std::map<GVertex*,GVertex*> & Duplicates2Unique, - const double &eps){ +static void ComputeDuplicates(GModel * model, + std::multimap<GVertex*,GVertex*> & Unique2Duplicates, + std::map<GVertex*,GVertex*> & Duplicates2Unique, + const double &eps) +{ // in a first time, we use a greedy algorithm in n^2 // using bounding boxes and the Octree would certainly be better // for huge models... @@ -1422,7 +1423,8 @@ static void ComputeDuplicates (GModel * model, GVertex *pv = *v.begin(); v.erase(v.begin()); bool found = false; - for ( std::multimap<GVertex*,GVertex*>::iterator it = Unique2Duplicates.begin(); it != Unique2Duplicates.end() ; ++it ){ + for ( std::multimap<GVertex*,GVertex*>::iterator it = Unique2Duplicates.begin(); + it != Unique2Duplicates.end(); ++it ){ GVertex *unique = it->first; const double d = sqrt ((unique->x()-pv->x())*(unique->x()-pv->x())+ (unique->y()-pv->y())*(unique->y()-pv->y())+ @@ -1458,10 +1460,11 @@ static void glueVerticesInEdges(GModel * model, } } -static void ComputeDuplicates (GModel * model, - std::multimap<GEdge*,GEdge*> & Unique2Duplicates, - std::map<GEdge*,GEdge*> & Duplicates2Unique, - const double &eps){ +static void ComputeDuplicates(GModel * model, + std::multimap<GEdge*,GEdge*> & Unique2Duplicates, + std::map<GEdge*,GEdge*> & Duplicates2Unique, + const double &eps) +{ // in a first time, we use a greedy algorithm in n^2 // first check edges that have same endpoints @@ -1477,7 +1480,8 @@ static void ComputeDuplicates (GModel * model, GPoint gp = pe->point(0.5*(r.low()+r.high())); e.erase(e.begin()); bool found = false; - for ( std::multimap<GEdge*,GEdge*>::iterator it = Unique2Duplicates.begin(); it != Unique2Duplicates.end() ; ++it ){ + for (std::multimap<GEdge*,GEdge*>::iterator it = Unique2Duplicates.begin(); + it != Unique2Duplicates.end(); ++it ){ GEdge *unique = it->first; // printf ("checking %d %d\n",unique->tag(),pe->tag()); @@ -1526,7 +1530,8 @@ static void ComputeDuplicates (GModel * model, static void glueEdgesInFaces(GModel * model, std::multimap<GEdge*,GEdge*> & Unique2Duplicates, - std::map<GEdge*,GEdge*> & Duplicates2Unique){ + std::map<GEdge*,GEdge*> & Duplicates2Unique) +{ Msg::Debug("Gluing Model Faces"); for (GModel::fiter it = model->firstFace(); it != model->lastFace();++it){ GFace *f = *it; @@ -1548,10 +1553,11 @@ static void glueEdgesInFaces(GModel * model, } } -static void ComputeDuplicates (GModel * model, - std::multimap<GFace*,GFace*> & Unique2Duplicates, - std::map<GFace*,GFace*> & Duplicates2Unique, - const double &eps){ +static void ComputeDuplicates(GModel * model, + std::multimap<GFace*,GFace*> & Unique2Duplicates, + std::map<GFace*,GFace*> & Duplicates2Unique, + const double &eps) +{ std::list<GFace*> f; f.insert(f.begin(),model->firstFace(),model->lastFace()); @@ -1621,7 +1627,8 @@ static void ComputeDuplicates (GModel * model, static void glueFacesInRegions(GModel * model, std::multimap<GFace*,GFace*> & Unique2Duplicates, - std::map<GFace*,GFace*> & Duplicates2Unique){ + std::map<GFace*,GFace*> & Duplicates2Unique) +{ Msg::Debug("Gluing Regions"); for (GModel::riter it = model->firstRegion(); it != model->lastRegion();++it){ GRegion *r = *it; @@ -1642,7 +1649,8 @@ static void glueFacesInRegions(GModel * model, } } -void GModel::glue(const double &eps) { +void GModel::glue(const double &eps) +{ { std::multimap<GVertex*,GVertex*> Unique2Duplicates; std::map<GVertex*,GVertex*> Duplicates2Unique; diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp index f857f7c32812078e8ff9ba368b9d222007ba5387..649d51285f176a748311d5e724e6665c4519eeb4 100644 --- a/Geo/GModelFactory.cpp +++ b/Geo/GModelFactory.cpp @@ -24,8 +24,8 @@ OCCFactory::OCCFactory() : GModelFactory() { } - -GVertex * OCCFactory::createVertex (GModel *_gm, double x, double y, double z, double lc){ +GVertex * OCCFactory::createVertex (GModel *_gm, double x, double y, double z, double lc) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -37,8 +37,8 @@ GVertex * OCCFactory::createVertex (GModel *_gm, double x, double y, double z, d return _gm->_occ_internals->addVertexToModel(_gm,occv); } - -GEdge * OCCFactory::createLine (GModel *_gm, GVertex *start, GVertex *end){ +GEdge * OCCFactory::createLine (GModel *_gm, GVertex *start, GVertex *end) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -57,11 +57,10 @@ GEdge * OCCFactory::createLine (GModel *_gm, GVertex *start, GVertex *end){ return _gm->_occ_internals->addEdgeToModel(_gm,occEdge,start,end); } - GEdge *OCCFactory::createCircleArc (GModel *_gm, const arcCreationMethod &method, - GVertex *start, - GVertex *end, - const SPoint3 &aPoint) { + GVertex *start, GVertex *end, + const SPoint3 &aPoint) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -89,9 +88,9 @@ GEdge *OCCFactory::createCircleArc (GModel *_gm, const arcCreationMethod &method } GEdge *OCCFactory::createSpline (GModel *_gm, const splineType &type, - GVertex *start, - GVertex *end, - fullMatrix<double> *points){ + GVertex *start, GVertex *end, + fullMatrix<double> *points) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -119,7 +118,8 @@ GEdge *OCCFactory::createSpline (GModel *_gm, const splineType &type, GEntity *OCCFactory::revolve (GModel *_gm, GEntity* base, double x1, double y1, double z1, double x2, double y2, double z2, - double angle ){ + double angle) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -128,15 +128,15 @@ GEntity *OCCFactory::revolve (GModel *_gm, GEntity* base, BRepPrimAPI_MakeRevol MR (*(TopoDS_Shape*)base->getNativePtr(), axisOfRevolution, angle, Standard_False); GEntity *ret; - if (base->Cast2Vertex()){ + if (base->cast2Vertex()){ TopoDS_Edge result = TopoDS::Edge(MR.Shape()); ret = _gm->_occ_internals->addEdgeToModel(_gm,result); } - if (base->Cast2Edge()){ + if (base->cast2Edge()){ TopoDS_Face result = TopoDS::Face(MR.Shape()); ret = _gm->_occ_internals->addFaceToModel(_gm,result); } - if (base->Cast2Face()){ + if (base->cast2Face()){ TopoDS_Solid result = TopoDS::Solid(MR.Shape()); ret = _gm->_occ_internals->addRegionToModel(_gm,result); } @@ -144,9 +144,10 @@ GEntity *OCCFactory::revolve (GModel *_gm, GEntity* base, return ret; } -GEntity *OCCFactory::extrude (GModel *_gm, GEntity* base, - double x1, double y1, double z1, - double x2, double y2, double z2){ +GEntity *OCCFactory::extrude(GModel *_gm, GEntity* base, + double x1, double y1, double z1, + double x2, double y2, double z2) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -157,15 +158,15 @@ GEntity *OCCFactory::extrude (GModel *_gm, GEntity* base, GEntity *ret; - if (base->Cast2Vertex()){ + if (base->cast2Vertex()){ TopoDS_Edge result = TopoDS::Edge(MP.Shape()); ret = _gm->_occ_internals->addEdgeToModel(_gm,result); } - if (base->Cast2Edge()){ + if (base->cast2Edge()){ TopoDS_Face result = TopoDS::Face(MP.Shape()); ret = _gm->_occ_internals->addFaceToModel(_gm,result); } - if (base->Cast2Face()){ + if (base->cast2Face()){ TopoDS_Solid result = TopoDS::Solid(MP.Shape()); ret = _gm->_occ_internals->addRegionToModel(_gm,result); } @@ -173,8 +174,8 @@ GEntity *OCCFactory::extrude (GModel *_gm, GEntity* base, return ret; } - -GEntity *OCCFactory::sphere (GModel *_gm, double xc, double yc, double zc, double radius){ +GEntity *OCCFactory::sphere (GModel *_gm, double xc, double yc, double zc, double radius) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -185,7 +186,9 @@ GEntity *OCCFactory::sphere (GModel *_gm, double xc, double yc, double zc, doub _gm->_occ_internals->buildGModel(_gm); } -GEntity *OCCFactory::cylinder (GModel *_gm, std::vector<double> p1, std::vector<double> p2, double radius){ +GEntity *OCCFactory::cylinder(GModel *_gm, std::vector<double> p1, std::vector<double> p2, + double radius) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -213,7 +216,9 @@ GEntity *OCCFactory::cylinder (GModel *_gm, std::vector<double> p1, std::vector return 0; } -GEntity *OCCFactory::torus (GModel *_gm, std::vector<double> p1, std::vector<double> p2, double radius1, double radius2){ +GEntity *OCCFactory::torus(GModel *_gm, std::vector<double> p1, std::vector<double> p2, + double radius1, double radius2) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -240,7 +245,9 @@ GEntity *OCCFactory::torus (GModel *_gm, std::vector<double> p1, std::vector<do return 0; } -GEntity *OCCFactory::cone (GModel *_gm, std::vector<double> p1, std::vector<double> p2, double radius1, double radius2){ +GEntity *OCCFactory::cone (GModel *_gm, std::vector<double> p1, std::vector<double> p2, + double radius1, double radius2) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -268,7 +275,8 @@ GEntity *OCCFactory::cone (GModel *_gm, std::vector<double> p1, std::vector<dou return 0; } -GEntity *OCCFactory::block (GModel *_gm, std::vector<double> p1, std::vector<double> p2){ +GEntity *OCCFactory::block (GModel *_gm, std::vector<double> p1, std::vector<double> p2) +{ if (!_gm->_occ_internals) _gm->_occ_internals = new OCC_Internals; @@ -286,8 +294,8 @@ GEntity *OCCFactory::block (GModel *_gm, std::vector<double> p1, std::vector<do _gm->_occ_internals->buildGModel(_gm); } -GModel *OCCFactory::booleanUnion (GModel* obj, GModel* tool, int createNewModel){ - +GModel *OCCFactory::booleanUnion (GModel* obj, GModel* tool, int createNewModel) +{ OCC_Internals *occ_obj = obj->getOCCInternals(); OCC_Internals *occ_tool = tool->getOCCInternals(); @@ -307,8 +315,8 @@ GModel *OCCFactory::booleanUnion (GModel* obj, GModel* tool, int createNewModel) return obj; } -GModel *OCCFactory::booleanDifference (GModel* obj, GModel* tool, int createNewModel){ - +GModel *OCCFactory::booleanDifference (GModel* obj, GModel* tool, int createNewModel) +{ OCC_Internals *occ_obj = obj->getOCCInternals(); OCC_Internals *occ_tool = tool->getOCCInternals(); @@ -327,8 +335,8 @@ GModel *OCCFactory::booleanDifference (GModel* obj, GModel* tool, int createNewM return obj; } -GModel *OCCFactory::booleanIntersection (GModel* obj, GModel* tool, int createNewModel){ - +GModel *OCCFactory::booleanIntersection (GModel* obj, GModel* tool, int createNewModel) +{ OCC_Internals *occ_obj = obj->getOCCInternals(); OCC_Internals *occ_tool = tool->getOCCInternals(); @@ -341,7 +349,8 @@ GModel *OCCFactory::booleanIntersection (GModel* obj, GModel* tool, int createNe temp->_occ_internals->addShapeToLists(occ_obj->getShape()); obj = temp; } - obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(),OCC_Internals::Intersection); + obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(), + OCC_Internals::Intersection); obj->destroy(); obj->_occ_internals->buildLists(); obj->_occ_internals->buildGModel(obj); @@ -417,4 +426,3 @@ void GModelFactory::registerBindings (binding *b) cb->setParentClass<GModelFactory>(); #endif } - diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 5426ed63d52a4514da2253cc539644b094268163..ce2e04f3c99c7caf6b121278aa2fddda591af9a7 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -29,19 +29,21 @@ void OCC_Internals::buildLists() addShapeToLists(shape); } -void OCC_Internals::buildShapeFromLists(TopoDS_Shape _shape){ +void OCC_Internals::buildShapeFromLists(TopoDS_Shape _shape) +{ BRep_Builder B; TopoDS_Compound C; B.MakeCompound(C); B.Add(C,_shape); - for(int i = 1; i <= vmap.Extent(); i++) B.Add(C,vmap(i)); - for(int i = 1; i <= emap.Extent(); i++) B.Add(C,emap(i)); - for(int i = 1; i <= fmap.Extent(); i++) B.Add(C,fmap(i)); - for(int i = 1; i <= somap.Extent(); i++) B.Add(C,somap(i)); + for(int i = 1; i <= vmap.Extent(); i++) B.Add(C, vmap(i)); + for(int i = 1; i <= emap.Extent(); i++) B.Add(C, emap(i)); + for(int i = 1; i <= fmap.Extent(); i++) B.Add(C, fmap(i)); + for(int i = 1; i <= somap.Extent(); i++) B.Add(C, somap(i)); shape = C; } -const TopoDS_Shape *OCC_Internals::lookupInLists (TopoDS_Shape _shape){ +const TopoDS_Shape *OCC_Internals::lookupInLists(TopoDS_Shape _shape) +{ if (_shape.ShapeType() == TopAbs_VERTEX) { TopoDS_Vertex vertex = TopoDS::Vertex(_shape); int i = vmap.FindIndex(vertex); @@ -56,7 +58,6 @@ const TopoDS_Shape *OCC_Internals::lookupInLists (TopoDS_Shape _shape){ } } - void OCC_Internals::addShapeToLists(TopoDS_Shape _shape) { TopExp_Explorer exp0, exp1, exp2, exp3, exp4, exp5; @@ -450,37 +451,41 @@ void OCC_Internals::loadShape(const TopoDS_Shape *s) buildLists(); } -GVertex* OCC_Internals::addVertexToModel(GModel *model, TopoDS_Vertex vertex){ - GVertex *gv = getOCCVertexByNativePtr (model,vertex); - if (gv)return gv; +GVertex* OCC_Internals::addVertexToModel(GModel *model, TopoDS_Vertex vertex) +{ + GVertex *gv = getOCCVertexByNativePtr(model, vertex); + if (gv) return gv; buildShapeFromLists(vertex); - gv = new OCCVertex(model, model->maxVertexNum()+1, vertex); + gv = new OCCVertex(model, model->maxVertexNum() + 1, vertex); model->add(gv); return gv; } -GEdge * OCC_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge){ - GEdge *ge = getOCCEdgeByNativePtr(model,edge); +GEdge * OCC_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge) +{ + GEdge *ge = getOCCEdgeByNativePtr(model, edge); if (ge) return ge; buildShapeFromLists(edge); TopoDS_Vertex occv1 = TopExp::FirstVertex(edge); TopoDS_Vertex occv2 = TopExp::LastVertex(edge); - GVertex *v1 = addVertexToModel(model,occv1); - GVertex *v2 = addVertexToModel(model,occv2); - OCCEdge *e = new OCCEdge(model, edge, model->maxEdgeNum()+1, v1, v2); + GVertex *v1 = addVertexToModel(model, occv1); + GVertex *v2 = addVertexToModel(model, occv2); + OCCEdge *e = new OCCEdge(model, edge, model->maxEdgeNum() + 1, v1, v2); model->add(e); return e; } -GEdge * OCC_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge, GVertex *g1, GVertex *g2){ - OCCEdge *e = new OCCEdge(model, edge, model->maxEdgeNum()+1, g1, g2); +GEdge * OCC_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge, GVertex *g1, + GVertex *g2) +{ + OCCEdge *e = new OCCEdge(model, edge, model->maxEdgeNum() + 1, g1, g2); e->replaceEndingPoints (g1,g2); model->add(e); return e; } -GFace* OCC_Internals::addFaceToModel(GModel *model, TopoDS_Face face, int i){ - +GFace* OCC_Internals::addFaceToModel(GModel *model, TopoDS_Face face, int i) +{ GFace *gf = getOCCFaceByNativePtr(model,face); if (gf) return gf; @@ -494,7 +499,7 @@ GFace* OCC_Internals::addFaceToModel(GModel *model, TopoDS_Face face, int i){ _edges.push_back(addEdgeToModel(model, edge)); } } - i = model->maxFaceNum()+1; + i = model->maxFaceNum() + 1; OCCFace *f = new OCCFace(model, face, i); model->add(f); model->glue(Precision::Confusion()); @@ -505,7 +510,8 @@ GFace* OCC_Internals::addFaceToModel(GModel *model, TopoDS_Face face, int i){ return f; } -GEntity* OCC_Internals::addShapeToModel(GModel *model, TopoDS_Shape sh){ +GEntity* OCC_Internals::addShapeToModel(GModel *model, TopoDS_Shape sh) +{ TopExp_Explorer exp0, exp1, exp2; std::vector<GEntity*> e; for(exp0.Init(sh, TopAbs_SOLID); exp0.More(); exp0.Next()){ @@ -517,13 +523,14 @@ GEntity* OCC_Internals::addShapeToModel(GModel *model, TopoDS_Shape sh){ addFaceToModel(model, face, -1); } } - OCCRegion *r = new OCCRegion(model, solid, model->maxRegionNum()+1); + OCCRegion *r = new OCCRegion(model, solid, model->maxRegionNum() + 1); e.push_back(r); } return e[0]; } -GRegion* OCC_Internals::addRegionToModel(GModel *model, TopoDS_Solid region, int i){ +GRegion* OCC_Internals::addRegionToModel(GModel *model, TopoDS_Solid region, int i) +{ if (i < 0){ TopExp_Explorer exp0, exp1, exp2; for(exp0.Init(region, TopAbs_SOLID); exp0.More(); exp0.Next()){ @@ -536,7 +543,7 @@ GRegion* OCC_Internals::addRegionToModel(GModel *model, TopoDS_Solid region, int } } } - i = model->maxRegionNum()+1; + i = model->maxRegionNum() + 1; } OCCRegion *r = new OCCRegion(model, region, i); model->add(r); @@ -556,7 +563,8 @@ void OCC_Internals::buildGModel(GModel *model) for(int i = 1; i <= nedges; i++){ int i1 = vmap.FindIndex(TopExp::FirstVertex(TopoDS::Edge(emap(i)))); int i2 = vmap.FindIndex(TopExp::LastVertex(TopoDS::Edge(emap(i)))); - model->add(new OCCEdge(model, TopoDS::Edge(emap(i)), i, model->getVertexByTag(i1), model->getVertexByTag(i2))); + model->add(new OCCEdge(model, TopoDS::Edge(emap(i)), i, + model->getVertexByTag(i1), model->getVertexByTag(i2))); } // building geom faces int nfaces = fmap.Extent(); diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp index d139779d3eeb53cd26243075239b492915b55a23..9bd1539211594fb4cc835dc3fc18ef89e0280614 100644 --- a/Geo/GRegion.cpp +++ b/Geo/GRegion.cpp @@ -262,15 +262,14 @@ bool GRegion::edgeConnected(GRegion *r) const return false; } -// replace faces (gor gluing) -void GRegion::replaceFaces (std::list<GFace*> & new_faces) +void GRegion::replaceFaces (std::list<GFace*> &new_faces) { replaceFacesInternal (new_faces); std::list<GFace*>::iterator it = l_faces.begin(); std::list<GFace*>::iterator it2 = new_faces.begin(); std::list<int>::iterator it3 = l_dirs.begin(); std::list<int> newdirs; - for ( ; it != l_faces.end() ; ++it,++it2,++it3){ + for ( ; it != l_faces.end(); ++it, ++it2, ++it3){ (*it)->delRegion(this); (*it2)->addRegion(this); // if ((*it2)->getBeginVertex() == (*it)->getBeginVertex()) diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp index e02deb4119d017737016dc602d6d26b85a991d6b..861c60c459103dc9ec3b2d817a81c158a27a3a12 100644 --- a/Geo/OCCFace.cpp +++ b/Geo/OCCFace.cpp @@ -31,7 +31,7 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num) : GFace(m, num), s(_s) { - // printf("NEW OCC FACE %d\n",tag()); + // printf("NEW OCC FACE %d\n",tag()); setup(); } @@ -47,7 +47,7 @@ void OCCFace::setup() std::list<GEdge*> l_wire; for(exp3.Init(wire, TopAbs_EDGE); exp3.More(); exp3.Next()){ TopoDS_Edge edge = TopoDS::Edge(exp3.Current()); - GEdge *e = getOCCEdgeByNativePtr(model(),edge); + GEdge *e = getOCCEdgeByNativePtr(model(), edge); if(!e){ Msg::Error("Unknown edge in face %d", tag()); } @@ -374,14 +374,15 @@ GFace *getOCCFaceByNativePtr(GModel *model, TopoDS_Face toFind) for (; it !=model->lastFace(); ++it){ OCCFace *gf = dynamic_cast<OCCFace*>(*it); if (gf){ - if( toFind.IsSame(gf->getTopoDS_Face()) )return *it; - if( toFind.IsSame(gf->getTopoDS_FaceOld()) )return *it; + if(toFind.IsSame(gf->getTopoDS_Face())) return *it; + if(toFind.IsSame(gf->getTopoDS_FaceOld())) return *it; } } return 0; } -void OCCFace::replaceEdgesInternal (std::list<GEdge*> &new_edges){ +void OCCFace::replaceEdgesInternal(std::list<GEdge*> &new_edges) +{ IntTools_Context myContext; // we simply replace old edges by new edges in the structure @@ -392,13 +393,13 @@ void OCCFace::replaceEdgesInternal (std::list<GEdge*> &new_edges){ TopLoc_Location location; Handle(Geom_Surface) copy_of_occface = BRep_Tool::Surface(copy_of_s_forward, location); // check periodicity - bool bIsUPeriodic=_periodic[0]; + bool bIsUPeriodic = _periodic[0]; // get tolerance - double tolerance =BRep_Tool::Tolerance(copy_of_s_forward); + double tolerance = BRep_Tool::Tolerance(copy_of_s_forward); BRep_Builder aBB; TopoDS_Face newFace; - aBB.MakeFace (newFace, copy_of_occface, location, tolerance); + aBB.MakeFace(newFace, copy_of_occface, location, tolerance); // expolore the face TopExp_Explorer aExpW, aExpE; aExpW.Init(copy_of_s_forward, TopAbs_WIRE); @@ -413,7 +414,7 @@ void OCCFace::replaceEdgesInternal (std::list<GEdge*> &new_edges){ std::list<GEdge*>::iterator it2 = new_edges.begin(); TopoDS_Edge aER; Msg::Debug("trying to replace %d by %d",(*it)->tag(),(*it2)->tag()); - for ( ; it != l_edges.end() ; ++it,++it2){ + for ( ; it != l_edges.end(); ++it, ++it2){ OCCEdge *occEd = dynamic_cast<OCCEdge*>(*it); TopoDS_Edge olde = occEd->getTopoDS_Edge(); if (olde.IsSame(aE)){ @@ -434,10 +435,9 @@ void OCCFace::replaceEdgesInternal (std::list<GEdge*> &new_edges){ if (bIsUPeriodic) { Standard_Real aT1, aT2, aTx, aUx; BRep_Builder aBB_; - // - double aTwoPI=2*M_PI+PI; - // - Handle(Geom2d_Curve) aC2D=BRep_Tool::CurveOnSurface(aER, copy_of_s_forward, aT1, aT2); + double aTwoPI = 2 * M_PI + PI; + Handle(Geom2d_Curve) aC2D = + BRep_Tool::CurveOnSurface(aER, copy_of_s_forward, aT1, aT2); if (!aC2D.IsNull()) { if (BRep_Tool::IsClosed(aER, copy_of_s_forward)) { continue; @@ -458,7 +458,8 @@ void OCCFace::replaceEdgesInternal (std::list<GEdge*> &new_edges){ BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aER, copy_of_s_forward); // orient image - Standard_Boolean bIsToReverse = BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext); + Standard_Boolean bIsToReverse = + BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext); if (bIsToReverse) { aER.Reverse(); } @@ -472,7 +473,7 @@ void OCCFace::replaceEdgesInternal (std::list<GEdge*> &new_edges){ aBB.Add(newFace, newWire); } _replaced = s; - s=newFace; + s = newFace; setup(); } diff --git a/Geo/OCCRegion.cpp b/Geo/OCCRegion.cpp index 6f5fb7b0100fe5323277447374cf823215663a87..305452081ec767b099371a387ce2ee12e5513a77 100644 --- a/Geo/OCCRegion.cpp +++ b/Geo/OCCRegion.cpp @@ -54,16 +54,13 @@ bool FaceHaveDifferentOrientations(const TopoDS_Face& aFR, return false; } -void OCCRegion::replaceFacesInternal (std::list<GFace*> &new_faces){ - - +void OCCRegion::replaceFacesInternal(std::list<GFace*> &new_faces) +{ // we simply replace old faces by new faces in the structure - Standard_Integer aNbS; TopTools_IndexedMapOfShape aMS; TopExp_Explorer aExpS, aExpF; BRep_Builder aBB; - // TopoDS_Compound aCmp; aBB.MakeCompound(aCmp); TopoDS_Solid _s_replacement; @@ -106,15 +103,15 @@ void OCCRegion::replaceFacesInternal (std::list<GFace*> &new_faces){ aBB.Add(_shell_replacement, _face); } else { - if (FaceHaveDifferentOrientations(_face,_face_replacement))_face_replacement.Reverse(); + if(FaceHaveDifferentOrientations(_face, _face_replacement)) + _face_replacement.Reverse(); aBB.Add(_shell_replacement, _face_replacement); } } aBB.Add(_s_replacement, _shell_replacement); } - s=_s_replacement; + s = _s_replacement; setup(); } - #endif diff --git a/Geo/OCCVertex.cpp b/Geo/OCCVertex.cpp index d5e9e3e6cb5cb5c296dfe21b032563758329aeab..3174f0c497551730036c65ef90e9921984f245fa 100644 --- a/Geo/OCCVertex.cpp +++ b/Geo/OCCVertex.cpp @@ -108,7 +108,7 @@ SPoint2 OCCVertex::reparamOnFace(const GFace *gf, int dir) const GVertex *getOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind) { GModel::viter it =model->firstVertex(); - for (; it !=model->lastVertex(); it++){ + for (; it != model->lastVertex(); it++){ OCCVertex *occv = dynamic_cast<OCCVertex*>(*it); if (occv){ if (toFind.IsSame(occv->getShape())){ diff --git a/Geo/OCCVertex.h b/Geo/OCCVertex.h index 1111f03eda38b67a6ddbea0bd3c360dad69e8bd5..74bb2a6b7fb449b7a2d5cb3982c911c9e3050264 100644 --- a/Geo/OCCVertex.h +++ b/Geo/OCCVertex.h @@ -30,7 +30,7 @@ class OCCVertex : public GVertex { ModelType getNativeType() const { return OpenCascadeModel; } void * getNativePtr() const { return (void*)&v; } virtual SPoint2 reparamOnFace(const GFace *gf, int) const; - TopoDS_Vertex getShape() {return v;} + TopoDS_Vertex getShape() { return v; } }; GVertex *getOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind); diff --git a/Mesh/Field.cpp b/Mesh/Field.cpp index 61c6dd731a810e5709dac165861b5755c73aca2d..9d0e80e7aa962444f9d5324195d418715042ea54 100644 --- a/Mesh/Field.cpp +++ b/Mesh/Field.cpp @@ -1393,8 +1393,11 @@ FieldManager::FieldManager() map_type_name["MaxEigenHessian"] = new FieldFactoryT<MaxEigenHessianField>(); background_field = -1; } -FieldManager::~FieldManager(){ - for ( std::map<std::string, FieldFactory*>::iterator it = map_type_name.begin(); it!=map_type_name.end(); it++) + +FieldManager::~FieldManager() +{ + for(std::map<std::string, FieldFactory*>::iterator it = map_type_name.begin(); + it != map_type_name.end(); it++) delete it->second; } diff --git a/Mesh/highOrderSmoother.cpp b/Mesh/highOrderSmoother.cpp index 04f620736e7a4596f8ee490a41e8ae8fa311b74b..95957bee56a67395824e8432fd3c64457f43c155 100644 --- a/Mesh/highOrderSmoother.cpp +++ b/Mesh/highOrderSmoother.cpp @@ -1312,9 +1312,8 @@ static int swapHighOrderTriangles(GFace *gf, faceContainer &faceVertices, highOrderSmoother *s) { - printf ("Initial Size of the map %d\n", edgeVertices.size()); - printf ("Initial Size of the face map %d\n", faceVertices.size()); - + printf ("Initial Size of the map %d\n", (int)edgeVertices.size()); + printf ("Initial Size of the face map %d\n", (int)faceVertices.size()); e2t_cont adj; buildEdgeToTriangle(gf->triangles, adj); @@ -1431,9 +1430,9 @@ static int swapHighOrderTriangles(GFace *gf, } gf->triangles.clear(); gf->triangles = triangles2; - printf("%d swaps performed\n",nbSwap); - printf ("Final Size of the map %d\n", edgeVertices.size()); - printf ("Final Size of the face map %d\n", faceVertices.size()); + printf("%d swaps performed\n", nbSwap); + printf("Final Size of the map %d\n", (int)edgeVertices.size()); + printf("Final Size of the face map %d\n", (int)faceVertices.size()); return nbSwap; } diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index d189bd41bab993c1da2edf71cb6d9bebd2a28493..04780ff5feec437676a2d91896bcb1de334b07ee 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1363,7 +1363,7 @@ void meshGFace::operator() (GFace *gf) } Msg::Info("Meshing face %d (%s) as a copy of %d", gf->tag(), gf->getTypeString().c_str(), gf->meshMaster()); - copyMesh(gff,gf); + copyMesh(gff, gf); gf->meshStatistics.status = GFace::DONE; return; } diff --git a/Mesh/meshGFaceLloyd.cpp b/Mesh/meshGFaceLloyd.cpp index 7f4b30d93376a5a664260e99fb4155010900162d..30269164ae813e9528da8a53d5d84f01e1d3ba86 100644 --- a/Mesh/meshGFaceLloyd.cpp +++ b/Mesh/meshGFaceLloyd.cpp @@ -9,8 +9,8 @@ #include "meshGFace.h" #include "BackgroundMesh.h" - -void lloydAlgorithm::operator () ( GFace * gf) { +void lloydAlgorithm::operator () (GFace *gf) +{ std::set<MVertex*> all; // get all the points of the face ... @@ -23,16 +23,16 @@ void lloydAlgorithm::operator () ( GFace * gf) { } backgroundMesh::set(gf); - backgroundMesh::current()->print("bgm.pos",0); + backgroundMesh::current()->print("bgm.pos", 0); // Create a triangulator - DocRecord triangulator (all.size()); + DocRecord triangulator(all.size()); Range<double> du = gf->parBounds(0) ; Range<double> dv = gf->parBounds(1) ; - const double LC2D = sqrt ((du.high()-du.low())*(du.high()-du.low()) + - (dv.high()-dv.low())*(dv.high()-dv.low())); + const double LC2D = sqrt((du.high()-du.low())*(du.high()-du.low()) + + (dv.high()-dv.low())*(dv.high()-dv.low())); //printf("Lloyd on face %d %d elements %d nodes LC %g\n", gf->tag(), // gf->getNumMeshElements(), (int)all.size(), LC2D); @@ -102,7 +102,8 @@ void lloydAlgorithm::operator () ( GFace * gf) { } } - Msg::Debug("GFace %d Lloyd-iter %d Inertia=%g Convergence=%g ",gf->tag(),ITER++,ENERGY, criteria); + Msg::Debug("GFace %d Lloyd-iter %d Inertia=%g Convergence=%g ", gf->tag(), + ITER++, ENERGY, criteria); if (ITER > ITER_MAX)break; // compute the Voronoi diagram @@ -113,7 +114,6 @@ void lloydAlgorithm::operator () ( GFace * gf) { sprintf(name,"LloydIter%d.pos",ITER); triangulator.makePosView(name); } - } // now create the vertices