mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-20 17:37:56 +05:00
Geomerty & Mesh plug-ins in the ParaVis module: small corrections.
This commit is contained in:
parent
e7cf13445b
commit
a3113be806
@ -166,17 +166,15 @@ namespace GEOM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData* GetData(const TopoDS_Shape& theShape, float theDeflection)
|
vtkPolyData* GetData(const TopoDS_Shape& theShape, float theDeflection) {
|
||||||
{
|
|
||||||
BRepBuilderAPI_Copy aCopy(theShape);
|
BRepBuilderAPI_Copy aCopy(theShape);
|
||||||
if(!aCopy.IsDone())
|
if(!aCopy.IsDone()) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TopoDS_Shape aShape = aCopy.Shape();
|
TopoDS_Shape aShape = aCopy.Shape();
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New();
|
GEOM_VertexSource* myVertexSource = GEOM_VertexSource::New();
|
||||||
GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New();
|
GEOM_EdgeSource* myIsolatedEdgeSource = GEOM_EdgeSource::New();
|
||||||
GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New();
|
GEOM_EdgeSource* myOneFaceEdgeSource = GEOM_EdgeSource::New();
|
||||||
@ -189,29 +187,13 @@ namespace GEOM
|
|||||||
myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() );
|
myAppendFilter->AddInputConnection( myIsolatedEdgeSource->GetOutputPort() );
|
||||||
myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() );
|
myAppendFilter->AddInputConnection( myOneFaceEdgeSource->GetOutputPort() );
|
||||||
myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() );
|
myAppendFilter->AddInputConnection( mySharedEdgeSource->GetOutputPort() );
|
||||||
|
|
||||||
myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() );
|
myAppendFilter->AddInputConnection( myShadingFaceSource->GetOutputPort() );
|
||||||
|
|
||||||
bool anIsVector = false;
|
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 );
|
GEOM::MeshShape( aShape, theDeflection );
|
||||||
TopExp_Explorer aVertexExp( aShape, TopAbs_VERTEX );
|
TopExp_Explorer aVertexExp( aShape, TopAbs_VERTEX );
|
||||||
for( ; aVertexExp.More(); aVertexExp.Next() )
|
for( ; aVertexExp.More(); aVertexExp.Next() ) {
|
||||||
{
|
|
||||||
const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() );
|
const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() );
|
||||||
myVertexSource->AddVertex( aVertex );
|
myVertexSource->AddVertex( aVertex );
|
||||||
}
|
}
|
||||||
@ -231,12 +213,20 @@ namespace GEOM
|
|||||||
|
|
||||||
myAppendFilter->Update();
|
myAppendFilter->Update();
|
||||||
|
|
||||||
return myAppendFilter->GetOutput();
|
myVertexSource->Delete();
|
||||||
|
myIsolatedEdgeSource->Delete();
|
||||||
|
myOneFaceEdgeSource->Delete();
|
||||||
|
mySharedEdgeSource->Delete();
|
||||||
|
myWireframeFaceSource->Delete();
|
||||||
|
myShadingFaceSource->Delete();
|
||||||
|
|
||||||
|
vtkPolyData* ret = vtkPolyData::New();
|
||||||
|
ret->ShallowCopy(myAppendFilter->GetOutput());
|
||||||
|
myAppendFilter->Delete();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
catch(Standard_Failure)
|
catch(Standard_Failure) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -91,80 +91,16 @@ Standard_Integer VTKPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const
|
|||||||
MESSAGE( "Export VTK into file " << aFileName );
|
MESSAGE( "Export VTK into file " << aFileName );
|
||||||
try
|
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( myWireframeFaceSource->GetOutputPort() ); // iso-lines are unnecessary
|
|
||||||
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, aDeflection );
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
// Set "C" numeric locale to save numbers correctly
|
// Set "C" numeric locale to save numbers correctly
|
||||||
Kernel_Utils::Localizer loc;
|
Kernel_Utils::Localizer loc;
|
||||||
|
|
||||||
|
vtkPolyData* pd = GEOM::GetData( aShape, aDeflection );
|
||||||
vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();
|
vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();
|
||||||
aWriter->SetInputConnection( myAppendFilter->GetOutputPort() );
|
aWriter->SetInputData( pd );
|
||||||
aWriter->SetFileName( aFileName.ToCString() );
|
aWriter->SetFileName( aFileName.ToCString() );
|
||||||
aWriter->Write();
|
aWriter->Write();
|
||||||
aWriter->Delete();
|
aWriter->Delete();
|
||||||
|
pd->Delete(); //instanciated by the GEOM::GetData(...) method
|
||||||
myVertexSource->Delete();
|
|
||||||
myIsolatedEdgeSource->Delete();
|
|
||||||
myOneFaceEdgeSource->Delete();
|
|
||||||
mySharedEdgeSource->Delete();
|
|
||||||
myWireframeFaceSource->Delete();
|
|
||||||
myShadingFaceSource->Delete();
|
|
||||||
|
|
||||||
myAppendFilter->Delete();
|
|
||||||
|
|
||||||
if(!wasMeshed)
|
|
||||||
BRepTools::Clean(aShape);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user