diff --git a/src/BRepMesh/BRepMesh.cdl b/src/BRepMesh/BRepMesh.cdl index d45d3beedb..c9313d30b0 100755 --- a/src/BRepMesh/BRepMesh.cdl +++ b/src/BRepMesh/BRepMesh.cdl @@ -44,14 +44,7 @@ is enumeration DegreeOfFreedom is Frontier, Deleted; - enumeration Status is - ---Purpose: Discribes the wires discretisation. - NoError, - OpenWire, - SelfIntersectingWire, - Failure, - ReMesh - end Status; + imported Status from BRepMesh; enumeration FactoryError is FE_NOERROR, diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.cdl b/src/BRepMesh/BRepMesh_IncrementalMesh.cdl index cf4c5e1cc7..141413f74f 100755 --- a/src/BRepMesh/BRepMesh_IncrementalMesh.cdl +++ b/src/BRepMesh/BRepMesh_IncrementalMesh.cdl @@ -74,7 +74,8 @@ is -- built. is static private; - EchoStatus(me) + GetStatusFlags(me) + returns Integer from Standard is static; @@ -87,6 +88,7 @@ fields myancestors : IndexedDataMapOfShapeListOfShape from TopTools is protected; mydtotale : Real from Standard is protected; myBox : Box from Bnd is protected; + myStatus : Integer from Standard is protected; end IncrementalMesh; diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx index ba8c665f1f..eb1a977220 100755 --- a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx +++ b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx @@ -52,7 +52,8 @@ //======================================================================= BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh() : myRelative(Standard_False), - myModified(Standard_False) + myModified(Standard_False), + myStatus(0) { mymapedge.Clear(); myancestors.Clear(); @@ -69,7 +70,8 @@ BRepMesh_IncrementalMesh(const TopoDS_Shape& S, const Standard_Boolean Rel, const Standard_Real Ang) : myRelative(Rel), - myModified(Standard_False) + myModified(Standard_False), + myStatus(0) { mymapedge.Clear(); myancestors.Clear(); @@ -155,37 +157,15 @@ void BRepMesh_IncrementalMesh::Perform() Standard_True); // Update(myShape); -#ifdef DEB - EchoStatus(); -#endif } //======================================================================= -//function : EchoStatus +//function : GetStatus //purpose : //======================================================================= -void BRepMesh_IncrementalMesh::EchoStatus() const +Standard_Integer BRepMesh_IncrementalMesh::GetStatusFlags() const { - cout << "BRepMesh_FastDiscret::Meshing status: "; - switch(myMesh->CurrentFaceStatus()) - { - case BRepMesh_NoError: - cout << "NoError" << endl; - break; - case BRepMesh_OpenWire: - cout << "OpenWire" << endl; - break; - case BRepMesh_SelfIntersectingWire: - cout << "SelfIntersectingWire" << endl; - break; - case BRepMesh_Failure: - cout << "Failure" << endl; - break; - case BRepMesh_ReMesh: - cout << "ReMesh" << endl; - break; - default: cout << "UnsupportedStatus" << endl; - } + return myStatus; } //======================================================================= @@ -454,6 +434,7 @@ void BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F) B.UpdateFace(F, TNull); } myMesh->Add(F); + myStatus |= (Standard_Integer)(myMesh->CurrentFaceStatus()); if (myMesh->CurrentFaceStatus() == BRepMesh_ReMesh) { #ifdef DEB_MESH cout << " face remaillee + finement que prevu."<< endl; diff --git a/src/BRepMesh/BRepMesh_Status.hxx b/src/BRepMesh/BRepMesh_Status.hxx new file mode 100755 index 0000000000..338ec7d2b1 --- /dev/null +++ b/src/BRepMesh/BRepMesh_Status.hxx @@ -0,0 +1,18 @@ +// File: BRepMesh_Status.hxx +// Created: May 17 11:59:53 2011 +// Author: Oleg AGASHIN +// Copyright: Open CASCADE SAS 2011 + +#ifndef _BRepMesh_Status_HeaderFile +#define _BRepMesh_Status_HeaderFile + +//! Discribes the wires discretisation.
+enum BRepMesh_Status { +BRepMesh_NoError = 0x0, +BRepMesh_OpenWire = 0x1, +BRepMesh_SelfIntersectingWire = 0x2, +BRepMesh_Failure = 0x4, +BRepMesh_ReMesh = 0x8 +}; + +#endif diff --git a/src/BRepMesh/FILES b/src/BRepMesh/FILES index 9820176ce5..8da01f5161 100755 --- a/src/BRepMesh/FILES +++ b/src/BRepMesh/FILES @@ -7,4 +7,5 @@ BRepMesh_MapOfInteger.hxx BRepMesh_ListOfInteger.hxx BRepMesh_BaseAllocator.hxx BRepMesh_PairOfIndex.hxx +BRepMesh_Status.hxx EXTERNLIB diff --git a/src/MeshTest/MeshTest.cxx b/src/MeshTest/MeshTest.cxx index d9a3d0a13b..e573d160b8 100755 --- a/src/MeshTest/MeshTest.cxx +++ b/src/MeshTest/MeshTest.cxx @@ -1,7 +1,7 @@ -// File: MeshTest.cxx -// Created: Wed Sep 22 18:35:55 1993 -// Author: Didier PIFFAULT -// +// File: MeshTest.cxx +// Created: Wed Sep 22 18:35:55 1993 +// Author: Didier PIFFAULT +// #include @@ -80,6 +80,11 @@ #include #include +//OAN: for triepoints +#include +#include +#include + #ifdef WNT Standard_IMPORT Draw_Viewer dout; #endif @@ -166,7 +171,7 @@ static Standard_Integer planesection(Draw_Interpretor&, Standard_Integer nbarg, //purpose : //======================================================================= -static Standard_Integer incrementalmesh(Draw_Interpretor&, Standard_Integer nbarg, const char** argv) +static Standard_Integer incrementalmesh(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv) { if (nbarg < 3) return 1; @@ -175,6 +180,40 @@ static Standard_Integer incrementalmesh(Draw_Interpretor&, Standard_Integer nbar if (S.IsNull()) return 1; BRepMesh_IncrementalMesh MESH(S,d); + Standard_Integer statusFlags = MESH.GetStatusFlags(); + + di << "Meshing statuses: "; + + if( !statusFlags ) + { + di << "NoError"; + } + else + { + Standard_Integer i; + for( i = 0; i < 4; i++ ) + { + if( (statusFlags >> i) & (Standard_Integer)1 ) + { + switch(i+1) + { + case 1: + di << "OpenWire "; + break; + case 2: + di << "SelfIntersectingWire "; + break; + case 3: + di << "Failure "; + break; + case 4: + di << "ReMesh "; + break; + } + } + } + } + return 0; } @@ -1455,7 +1494,78 @@ Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer nbarg, const cha #endif +//======================================================================= +//function : triedgepoints +//purpose : +//======================================================================= +Standard_Integer triedgepoints(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv) +{ + if( nbarg < 2 ) + return 1; + + for( Standard_Integer i = 1; i < nbarg; i++ ) + { + TopoDS_Shape aShape = DBRep::Get(argv[i]); + if ( aShape.IsNull() ) + continue; + + Handle(Poly_PolygonOnTriangulation) aPoly; + Handle(Poly_Triangulation) aT; + TopLoc_Location aLoc; + TopTools_MapOfShape anEdgeMap; + TopTools_MapIteratorOfMapOfShape it; + + if( aShape.ShapeType() == TopAbs_EDGE ) + { + anEdgeMap.Add( aShape ); + } + else + { + TopExp_Explorer ex(aShape, TopAbs_EDGE); + for(; ex.More(); ex.Next() ) + anEdgeMap.Add( ex.Current() ); + } + + if ( anEdgeMap.Extent() == 0 ) + continue; + + char newname[1024]; + strcpy(newname,argv[i]); + char* p = newname; + while (*p != '\0') p++; + *p = '_'; + p++; + + Standard_Integer nbEdge = 1; + for(it.Initialize(anEdgeMap); it.More(); it.Next()) + { + BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(it.Key()), aPoly, aT, aLoc); + if ( aT.IsNull() || aPoly.IsNull() ) + continue; + + const TColgp_Array1OfPnt& Nodes = aT->Nodes(); + const TColStd_Array1OfInteger& Indices = aPoly->Nodes(); + const Standard_Integer nbnodes = Indices.Length(); + + for( Standard_Integer j = 1; j <= nbnodes; j++ ) + { + gp_Pnt P3d = Nodes(Indices(j)); + if( !aLoc.IsIdentity() ) + P3d.Transform(aLoc.Transformation()); + + if( anEdgeMap.Extent() > 1 ) + sprintf(p,"%d_%d",nbEdge,j); + else + sprintf(p,"%d",j); + DBRep::Set( newname, BRepBuilderAPI_MakeVertex(P3d) ); + di.AppendElement(newname); + } + nbEdge++; + } + } + return 0; +} //======================================================================= void MeshTest::Commands(Draw_Interpretor& theCommands) @@ -1491,6 +1601,7 @@ void MeshTest::Commands(Draw_Interpretor& theCommands) theCommands.Add("veriftriangles","veriftriangles name, verif triangles",__FILE__,veriftriangles,g); theCommands.Add("wavefront","wavefront name",__FILE__, wavefront, g); theCommands.Add("onetriangulation","onetriangulation name",__FILE__, onetriangulation, g); + theCommands.Add("triepoints", "triepoints shape1 [shape2 ...]",__FILE__, triedgepoints, g); #if 0 theCommands.Add("extrema","extrema ",__FILE__, extrema, g);