mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-20 17:37:56 +05:00
Implementation of 2.6.3/2.6.4 improvements
This commit is contained in:
parent
e957479789
commit
e7cf13445b
@ -35,6 +35,12 @@
|
|||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
#include <TopTools_ListOfShape.hxx>
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <vtkAppendPolyData.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <BRepBuilderAPI_Copy.hxx>
|
||||||
|
|
||||||
#define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
|
#define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
|
||||||
#define MAX3(X, Y, Z) (MAX2(MAX2(X,Y), Z))
|
#define MAX3(X, Y, Z) (MAX2(MAX2(X,Y), Z))
|
||||||
|
|
||||||
@ -159,4 +165,78 @@ namespace GEOM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vtkPolyData* GetData(const TopoDS_Shape& theShape, float theDeflection)
|
||||||
|
{
|
||||||
|
BRepBuilderAPI_Copy aCopy(theShape);
|
||||||
|
if(!aCopy.IsDone())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
TopoDS_Shape aShape = aCopy.Shape();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New();
|
||||||
|
GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New();
|
||||||
|
GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New();
|
||||||
|
GEOM_EdgeSource* mySharedEdgeSource = GEOM_EdgeSource::New();
|
||||||
|
GEOM_WireframeFace* myWireframeFaceSource = GEOM_WireframeFace::New();
|
||||||
|
GEOM_ShadingFace* myShadingFaceSource = GEOM_ShadingFace::New();
|
||||||
|
|
||||||
|
vtkAppendPolyData* myAppendFilter = vtkAppendPolyData::New();
|
||||||
|
myAppendFilter->AddInputConnection( myVertexSource->GetOutputPort() );
|
||||||
|
myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() );
|
||||||
|
myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() );
|
||||||
|
myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() );
|
||||||
|
|
||||||
|
myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() );
|
||||||
|
|
||||||
|
bool anIsVector = false;
|
||||||
|
|
||||||
|
// Is shape triangulated?
|
||||||
|
bool wasMeshed = true;
|
||||||
|
TopExp_Explorer ex;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
for (ex.Init(aShape, TopAbs_FACE); ex.More(); ex.Next())
|
||||||
|
{
|
||||||
|
const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
|
||||||
|
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
|
||||||
|
if(aPoly.IsNull())
|
||||||
|
{
|
||||||
|
wasMeshed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GEOM::MeshShape( aShape, theDeflection );
|
||||||
|
TopExp_Explorer aVertexExp( aShape, TopAbs_VERTEX );
|
||||||
|
for( ; aVertexExp.More(); aVertexExp.Next() )
|
||||||
|
{
|
||||||
|
const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() );
|
||||||
|
myVertexSource->AddVertex( aVertex );
|
||||||
|
}
|
||||||
|
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
||||||
|
TopExp::MapShapesAndAncestors( aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap );
|
||||||
|
|
||||||
|
GEOM::SetShape( aShape,
|
||||||
|
anEdgeMap,
|
||||||
|
anIsVector,
|
||||||
|
0,
|
||||||
|
myIsolatedEdgeSource,
|
||||||
|
myOneFaceEdgeSource,
|
||||||
|
mySharedEdgeSource,
|
||||||
|
myWireframeFaceSource,
|
||||||
|
myShadingFaceSource );
|
||||||
|
|
||||||
|
myAppendFilter->Update();
|
||||||
|
|
||||||
|
return myAppendFilter->GetOutput();
|
||||||
|
}
|
||||||
|
catch(Standard_Failure)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class GEOM_VertexSource;
|
|||||||
class GEOM_EdgeSource;
|
class GEOM_EdgeSource;
|
||||||
class GEOM_WireframeFace;
|
class GEOM_WireframeFace;
|
||||||
class GEOM_ShadingFace;
|
class GEOM_ShadingFace;
|
||||||
|
class vtkPolyData;
|
||||||
namespace GEOM
|
namespace GEOM
|
||||||
{
|
{
|
||||||
// moved from GEOM_AssemblyBuilder
|
// moved from GEOM_AssemblyBuilder
|
||||||
@ -47,6 +47,8 @@ namespace GEOM
|
|||||||
GEOM_EdgeSource* theSharedEdgeSource,
|
GEOM_EdgeSource* theSharedEdgeSource,
|
||||||
GEOM_WireframeFace* theWireframeFaceSource,
|
GEOM_WireframeFace* theWireframeFaceSource,
|
||||||
GEOM_ShadingFace* theShadingFaceSource);
|
GEOM_ShadingFace* theShadingFaceSource);
|
||||||
|
|
||||||
|
OCC2VTK_EXPORT vtkPolyData* GetData(const TopoDS_Shape& theShape, float theDeflection);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OCC2VTK_TOOLS_H
|
#endif // OCC2VTK_TOOLS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user