mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-28 18:30:36 +05:00
Issue 0020904: [CEA 411] export VTK in GEOM
This commit is contained in:
parent
0b3222f523
commit
32e56a241f
@ -423,6 +423,7 @@ AC_OUTPUT([ \
|
|||||||
src/NMTDS/Makefile \
|
src/NMTDS/Makefile \
|
||||||
src/NMTTools/Makefile \
|
src/NMTTools/Makefile \
|
||||||
src/OBJECT/Makefile \
|
src/OBJECT/Makefile \
|
||||||
|
src/OCC2VTK/Makefile \
|
||||||
src/OperationGUI/Makefile \
|
src/OperationGUI/Makefile \
|
||||||
src/PrimitiveGUI/Makefile \
|
src/PrimitiveGUI/Makefile \
|
||||||
src/RepairGUI/Makefile \
|
src/RepairGUI/Makefile \
|
||||||
@ -432,6 +433,7 @@ AC_OUTPUT([ \
|
|||||||
src/STLExport/Makefile \
|
src/STLExport/Makefile \
|
||||||
src/ShHealOper/Makefile \
|
src/ShHealOper/Makefile \
|
||||||
src/TransformationGUI/Makefile \
|
src/TransformationGUI/Makefile \
|
||||||
|
src/VTKExport/Makefile \
|
||||||
resources/Makefile \
|
resources/Makefile \
|
||||||
resources/GEOMCatalog.xml \
|
resources/GEOMCatalog.xml \
|
||||||
idl/Makefile \
|
idl/Makefile \
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
# Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com)
|
# Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com)
|
||||||
# Package : src (source files directory)
|
# Package : src (source files directory)
|
||||||
#
|
#
|
||||||
SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER GEOM BREPExport \
|
SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER OCC2VTK GEOM \
|
||||||
BREPImport IGESExport IGESImport STEPExport STEPImport \
|
BREPExport BREPImport IGESExport IGESImport STEPExport \
|
||||||
STLExport ShHealOper GEOMImpl GEOM_I GEOMClient GEOM_I_Superv \
|
STEPImport STLExport VTKExport ShHealOper GEOMImpl GEOM_I \
|
||||||
GEOM_SWIG
|
GEOMClient GEOM_I_Superv GEOM_SWIG
|
||||||
|
|
||||||
if GEOM_ENABLE_GUI
|
if GEOM_ENABLE_GUI
|
||||||
SUBDIRS += OBJECT DlgRef GEOMFiltersSelection GEOMGUI GEOMBase GEOMToolsGUI \
|
SUBDIRS += OBJECT DlgRef GEOMFiltersSelection GEOMGUI GEOMBase GEOMToolsGUI \
|
||||||
@ -35,8 +35,9 @@ endif
|
|||||||
|
|
||||||
DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER GEOM BREPExport \
|
DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER GEOM BREPExport \
|
||||||
BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \
|
BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \
|
||||||
ShHealOper GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG \
|
VTKExport ShHealOper GEOMImpl GEOM_I GEOMClient GEOM_I_Superv \
|
||||||
OBJECT DlgRef GEOMFiltersSelection GEOMGUI GEOMBase GEOMToolsGUI \
|
GEOM_SWIG OBJECT DlgRef GEOMFiltersSelection GEOMGUI GEOMBase \
|
||||||
DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI \
|
GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \
|
||||||
BuildGUI BooleanGUI TransformationGUI OperationGUI RepairGUI \
|
EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \
|
||||||
MeasureGUI GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM
|
RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \
|
||||||
|
GEOM_SWIG_WITHIHM
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
#include "GEOM_ShadingFace.h"
|
#include "GEOM_ShadingFace.h"
|
||||||
#include "SVTK_Actor.h"
|
#include "SVTK_Actor.h"
|
||||||
|
|
||||||
|
#include <OCC2VTK_Tools.h>
|
||||||
|
|
||||||
#include <vtkObjectFactory.h>
|
#include <vtkObjectFactory.h>
|
||||||
#include <vtkRenderer.h>
|
#include <vtkRenderer.h>
|
||||||
#include <vtkProperty.h>
|
#include <vtkProperty.h>
|
||||||
@ -47,14 +49,8 @@
|
|||||||
|
|
||||||
#include <TopAbs_ShapeEnum.hxx>
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <Poly_Triangulation.hxx>
|
|
||||||
#include <BRepMesh_IncrementalMesh.hxx>
|
|
||||||
#include <Bnd_Box.hxx>
|
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
#include <BRepBndLib.hxx>
|
|
||||||
#include <TopTools_ListOfShape.hxx>
|
|
||||||
#include <TopoDS_Iterator.hxx>
|
|
||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
|
|
||||||
#include <vtkPolyDataWriter.h>
|
#include <vtkPolyDataWriter.h>
|
||||||
@ -354,35 +350,6 @@ GEOM_Actor
|
|||||||
return myVectorMode;
|
return myVectorMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
MeshShape(const TopoDS_Shape& theShape,
|
|
||||||
float& theDeflection,
|
|
||||||
bool theIsRelative)
|
|
||||||
{
|
|
||||||
static Standard_Real RELATIVE_DEFLECTION = 0.0001;
|
|
||||||
Standard_Real aDeflection = theDeflection;
|
|
||||||
|
|
||||||
if(theDeflection <= 0) { // Compute default theDeflection
|
|
||||||
Bnd_Box B;
|
|
||||||
BRepBndLib::Add(theShape, B);
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
||||||
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
Standard_Real aDiagonal = (aXmax-aXmin)*(aXmax-aXmin) +
|
|
||||||
(aYmax-aYmin)*(aYmax-aYmin) +
|
|
||||||
(aZmax-aZmin)*(aZmax-aZmin);
|
|
||||||
aDiagonal = sqrt(aDiagonal);
|
|
||||||
aDeflection = aDiagonal*RELATIVE_DEFLECTION;
|
|
||||||
|
|
||||||
if(theIsRelative)
|
|
||||||
theDeflection = RELATIVE_DEFLECTION;
|
|
||||||
else
|
|
||||||
theDeflection = aDeflection;
|
|
||||||
}
|
|
||||||
|
|
||||||
BRepMesh_IncrementalMesh aMesh(theShape,aDeflection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GEOM_Actor::
|
GEOM_Actor::
|
||||||
SetDeflection(float theDeflection, bool theIsRelative)
|
SetDeflection(float theDeflection, bool theIsRelative)
|
||||||
@ -390,7 +357,7 @@ SetDeflection(float theDeflection, bool theIsRelative)
|
|||||||
myDeflection = theDeflection;
|
myDeflection = theDeflection;
|
||||||
myIsRelative = theIsRelative;
|
myIsRelative = theIsRelative;
|
||||||
|
|
||||||
MeshShape(myShape,myDeflection,myIsRelative);
|
GEOM::MeshShape2(myShape,myDeflection,myIsRelative);
|
||||||
|
|
||||||
SetModified();
|
SetModified();
|
||||||
}
|
}
|
||||||
@ -421,7 +388,12 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
|
|||||||
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
||||||
TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
|
TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
|
||||||
|
|
||||||
SetShape(theShape,anEdgeMap,theIsVector);
|
GEOM::SetShape(theShape,anEdgeMap,theIsVector,
|
||||||
|
myIsolatedEdgeSource.Get(),
|
||||||
|
myOneFaceEdgeSource.Get(),
|
||||||
|
mySharedEdgeSource.Get(),
|
||||||
|
myWireframeFaceSource.Get(),
|
||||||
|
myShadingFaceSource.Get());
|
||||||
isOnlyVertex =
|
isOnlyVertex =
|
||||||
myIsolatedEdgeSource->IsEmpty() &&
|
myIsolatedEdgeSource->IsEmpty() &&
|
||||||
myOneFaceEdgeSource->IsEmpty() &&
|
myOneFaceEdgeSource->IsEmpty() &&
|
||||||
@ -436,65 +408,6 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
|
|
||||||
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
|
|
||||||
bool theIsVector)
|
|
||||||
{
|
|
||||||
if (theShape.ShapeType() == TopAbs_COMPOUND) {
|
|
||||||
TopoDS_Iterator anItr(theShape);
|
|
||||||
for (; anItr.More(); anItr.Next()) {
|
|
||||||
SetShape(anItr.Value(),theEdgeMap,theIsVector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (theShape.ShapeType()) {
|
|
||||||
case TopAbs_WIRE: {
|
|
||||||
TopExp_Explorer anEdgeExp(theShape,TopAbs_EDGE);
|
|
||||||
for (; anEdgeExp.More(); anEdgeExp.Next()){
|
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
|
|
||||||
if (!BRep_Tool::Degenerated(anEdge))
|
|
||||||
myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_EDGE: {
|
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(theShape);
|
|
||||||
if (!BRep_Tool::Degenerated(anEdge))
|
|
||||||
myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_VERTEX: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
TopExp_Explorer aFaceExp (theShape,TopAbs_FACE);
|
|
||||||
for(; aFaceExp.More(); aFaceExp.Next()) {
|
|
||||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current());
|
|
||||||
myWireframeFaceSource->AddFace(aFace);
|
|
||||||
myShadingFaceSource->AddFace(aFace);
|
|
||||||
TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE);
|
|
||||||
for(; anEdgeExp.More(); anEdgeExp.Next()) {
|
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
|
|
||||||
if(!BRep_Tool::Degenerated(anEdge)){
|
|
||||||
// compute the number of faces
|
|
||||||
int aNbOfFaces = theEdgeMap.FindFromKey(anEdge).Extent();
|
|
||||||
switch(aNbOfFaces){
|
|
||||||
case 0: // isolated edge
|
|
||||||
myIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
|
|
||||||
break;
|
|
||||||
case 1: // edge in only one face
|
|
||||||
myOneFaceEdgeSource->AddEdge(anEdge,theIsVector);
|
|
||||||
break;
|
|
||||||
default: // edge shared by at least two faces
|
|
||||||
mySharedEdgeSource->AddEdge(anEdge,theIsVector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OLD METHODS
|
// OLD METHODS
|
||||||
void GEOM_Actor::setDeflection(double adef) {
|
void GEOM_Actor::setDeflection(double adef) {
|
||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
|
@ -51,7 +51,6 @@ typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
|
|||||||
class GEOM_ShadingFace;
|
class GEOM_ShadingFace;
|
||||||
typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
|
typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
|
||||||
|
|
||||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
|
||||||
class vtkRenderer;
|
class vtkRenderer;
|
||||||
|
|
||||||
class vtkAppendPolyData;
|
class vtkAppendPolyData;
|
||||||
@ -174,10 +173,6 @@ public:
|
|||||||
GetVectorMode();
|
GetVectorMode();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetShape(const TopoDS_Shape& theShape,
|
|
||||||
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
|
|
||||||
bool theIsVector = false);
|
|
||||||
|
|
||||||
void SetModified();
|
void SetModified();
|
||||||
|
|
||||||
void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
|
void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#include "GEOM_AssemblyBuilder.h"
|
#include "GEOM_AssemblyBuilder.h"
|
||||||
#include "GEOM_Actor.h"
|
#include "GEOM_Actor.h"
|
||||||
|
|
||||||
|
#include <OCC2VTK_Tools.h>
|
||||||
|
|
||||||
#include <SUIT_Session.h>
|
#include <SUIT_Session.h>
|
||||||
#include <SUIT_ResourceMgr.h>
|
#include <SUIT_ResourceMgr.h>
|
||||||
|
|
||||||
@ -43,14 +45,9 @@
|
|||||||
|
|
||||||
// Open CASCADE Includes
|
// Open CASCADE Includes
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <Bnd_Box.hxx>
|
|
||||||
#include <BRepMesh_IncrementalMesh.hxx>
|
|
||||||
#include <Poly_Triangulation.hxx>
|
|
||||||
#include <BRepBndLib.hxx>
|
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TopTools_ListOfShape.hxx>
|
|
||||||
#include <TopoDS_Iterator.hxx>
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
@ -58,15 +55,6 @@
|
|||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
// SALOME
|
|
||||||
|
|
||||||
#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
|
|
||||||
#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
|
void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
|
||||||
vtkProperty* FaceProp,
|
vtkProperty* FaceProp,
|
||||||
vtkProperty* EdgeFProp,
|
vtkProperty* EdgeFProp,
|
||||||
@ -159,37 +147,6 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GEOM_AssemblyBuilder::MeshShape(const TopoDS_Shape myShape,
|
|
||||||
Standard_Real deflection,
|
|
||||||
Standard_Boolean forced)
|
|
||||||
{
|
|
||||||
// Mesh the shape if necessary
|
|
||||||
Standard_Boolean alreadymesh = Standard_True;
|
|
||||||
TopExp_Explorer ex;
|
|
||||||
TopLoc_Location aLoc;
|
|
||||||
|
|
||||||
for (ex.Init(myShape, 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()) { alreadymesh = Standard_False; break; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!alreadymesh || forced) {
|
|
||||||
if(deflection<=0) {
|
|
||||||
// Compute default deflection
|
|
||||||
Bnd_Box B;
|
|
||||||
BRepBndLib::Add(myShape, B);
|
|
||||||
if ( B.IsVoid() ) return; // NPAL15983 (Bug when displaying empty groups)
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
||||||
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
deflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin) * 0.001 *4;
|
|
||||||
}
|
|
||||||
BRepMesh_IncrementalMesh MESH(myShape,deflection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShape,
|
vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShape,
|
||||||
Standard_Real deflection,
|
Standard_Real deflection,
|
||||||
Standard_Integer mode,
|
Standard_Integer mode,
|
||||||
@ -210,7 +167,7 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
vtkActorCollection* AISActors = vtkActorCollection::New();
|
vtkActorCollection* AISActors = vtkActorCollection::New();
|
||||||
MeshShape(myShape,deflection,forced);
|
GEOM::MeshShape(myShape,deflection,forced);
|
||||||
GEOM_Actor* aGeomActor = GEOM_Actor::New();
|
GEOM_Actor* aGeomActor = GEOM_Actor::New();
|
||||||
aGeomActor->SetShape(myShape,(float)deflection,false,isVector);
|
aGeomActor->SetShape(myShape,(float)deflection,false,isVector);
|
||||||
AISActors->AddItem(aGeomActor);
|
AISActors->AddItem(aGeomActor);
|
||||||
|
@ -50,11 +50,6 @@ class GEOM_OBJECT_EXPORT GEOM_AssemblyBuilder {
|
|||||||
vtkProperty* EdgePVProp,
|
vtkProperty* EdgePVProp,
|
||||||
vtkProperty* VertePVProp);
|
vtkProperty* VertePVProp);
|
||||||
|
|
||||||
static void MeshShape(const TopoDS_Shape myShape,
|
|
||||||
Standard_Real deflection,
|
|
||||||
Standard_Boolean forced);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,12 +43,7 @@ salomeinclude_HEADERS = \
|
|||||||
GEOM_OBJECT_defs.hxx \
|
GEOM_OBJECT_defs.hxx \
|
||||||
GEOM_OCCReader.h \
|
GEOM_OCCReader.h \
|
||||||
GEOM_SmartPtr.h \
|
GEOM_SmartPtr.h \
|
||||||
GEOM_DeviceActor.h \
|
GEOM_DeviceActor.h
|
||||||
GEOM_EdgeSource.h \
|
|
||||||
GEOM_FaceSource.h \
|
|
||||||
GEOM_ShadingFace.h \
|
|
||||||
GEOM_VertexSource.h \
|
|
||||||
GEOM_WireframeFace.h
|
|
||||||
|
|
||||||
# Libraries targets
|
# Libraries targets
|
||||||
lib_LTLIBRARIES = libGEOMObject.la
|
lib_LTLIBRARIES = libGEOMObject.la
|
||||||
@ -62,12 +57,7 @@ dist_libGEOMObject_la_SOURCES = \
|
|||||||
GEOM_AISTrihedron.cxx \
|
GEOM_AISTrihedron.cxx \
|
||||||
GEOM_VTKTrihedron.cxx \
|
GEOM_VTKTrihedron.cxx \
|
||||||
GEOM_AISVector.cxx \
|
GEOM_AISVector.cxx \
|
||||||
GEOM_DeviceActor.cxx \
|
GEOM_DeviceActor.cxx
|
||||||
GEOM_EdgeSource.cxx \
|
|
||||||
GEOM_FaceSource.cxx \
|
|
||||||
GEOM_ShadingFace.cxx \
|
|
||||||
GEOM_VertexSource.cxx \
|
|
||||||
GEOM_WireframeFace.cxx
|
|
||||||
|
|
||||||
|
|
||||||
libGEOMObject_la_CPPFLAGS = \
|
libGEOMObject_la_CPPFLAGS = \
|
||||||
@ -78,9 +68,11 @@ libGEOMObject_la_CPPFLAGS = \
|
|||||||
$(CAS_CPPFLAGS) \
|
$(CAS_CPPFLAGS) \
|
||||||
$(VTK_INCLUDES) \
|
$(VTK_INCLUDES) \
|
||||||
$(KERNEL_CXXFLAGS) \
|
$(KERNEL_CXXFLAGS) \
|
||||||
$(GUI_CXXFLAGS)
|
$(GUI_CXXFLAGS) \
|
||||||
|
-I$(srcdir)/../OCC2VTK
|
||||||
|
|
||||||
libGEOMObject_la_LDFLAGS = \
|
libGEOMObject_la_LDFLAGS = \
|
||||||
|
../OCC2VTK/libOCC2VTK.la \
|
||||||
$(QT_MT_LIBS) \
|
$(QT_MT_LIBS) \
|
||||||
$(CAS_KERNEL) -lTKBRep -lTKG2d -lTKG3d -lTKV3d -lTKMesh -lTKGeomBase -lTKGeomAlgo -lTKTopAlgo -lTKService \
|
$(CAS_KERNEL) -lTKBRep -lTKG2d -lTKG3d -lTKV3d -lTKMesh -lTKGeomBase -lTKGeomAlgo -lTKTopAlgo -lTKService \
|
||||||
$(VTK_LIBS) \
|
$(VTK_LIBS) \
|
||||||
|
@ -20,17 +20,17 @@
|
|||||||
#ifndef GEOM_EDGESOURCE_H
|
#ifndef GEOM_EDGESOURCE_H
|
||||||
#define GEOM_EDGESOURCE_H
|
#define GEOM_EDGESOURCE_H
|
||||||
|
|
||||||
#include "GEOM_DeviceActor.h"
|
#include "OCC2VTK.h"
|
||||||
|
|
||||||
#include <TopoDS_Edge.hxx>
|
#include <TopoDS_Edge.hxx>
|
||||||
#include <NCollection_Set.hxx>
|
#include <NCollection_Set.hxx>
|
||||||
|
|
||||||
typedef NCollection_Set<TopoDS_Edge> TEdgeSet;
|
typedef NCollection_Set<TopoDS_Edge> TEdgeSet;
|
||||||
|
|
||||||
|
#include <vtkPoints.h>
|
||||||
#include <vtkPolyDataSource.h>
|
#include <vtkPolyDataSource.h>
|
||||||
|
|
||||||
|
class OCC2VTK_EXPORT GEOM_EdgeSource: public vtkPolyDataSource
|
||||||
class VTK_EXPORT GEOM_EdgeSource: public vtkPolyDataSource
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkTypeMacro(GEOM_EdgeSource,vtkPolyDataSource);
|
vtkTypeMacro(GEOM_EdgeSource,vtkPolyDataSource);
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef GEOM_FACESOURCE_H
|
#ifndef GEOM_FACESOURCE_H
|
||||||
#define GEOM_FACESOURCE_H
|
#define GEOM_FACESOURCE_H
|
||||||
|
|
||||||
#include "GEOM_DeviceActor.h"
|
#include "OCC2VTK.h"
|
||||||
|
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <TopoDS_Face.hxx>
|
#include <TopoDS_Face.hxx>
|
||||||
@ -28,13 +28,10 @@
|
|||||||
|
|
||||||
typedef NCollection_Set<TopoDS_Face> TFaceSet;
|
typedef NCollection_Set<TopoDS_Face> TFaceSet;
|
||||||
|
|
||||||
|
#include <vtkPoints.h>
|
||||||
#include <vtkPolyDataSource.h>
|
#include <vtkPolyDataSource.h>
|
||||||
|
|
||||||
class GEOM_FaceSource;
|
class OCC2VTK_EXPORT GEOM_FaceSource: public vtkPolyDataSource
|
||||||
typedef GEOM_SmartPtr<GEOM_FaceSource> PFaceSource;
|
|
||||||
|
|
||||||
|
|
||||||
class VTK_EXPORT GEOM_FaceSource: public vtkPolyDataSource
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkTypeMacro(GEOM_FaceSource,vtkPolyDataSource);
|
vtkTypeMacro(GEOM_FaceSource,vtkPolyDataSource);
|
@ -20,10 +20,10 @@
|
|||||||
#ifndef GEOM_SHADINGFACE_H
|
#ifndef GEOM_SHADINGFACE_H
|
||||||
#define GEOM_SHADINGFACE_H
|
#define GEOM_SHADINGFACE_H
|
||||||
|
|
||||||
|
#include "OCC2VTK.h"
|
||||||
#include "GEOM_FaceSource.h"
|
#include "GEOM_FaceSource.h"
|
||||||
|
|
||||||
|
class OCC2VTK_EXPORT GEOM_ShadingFace: public GEOM_FaceSource
|
||||||
class VTK_EXPORT GEOM_ShadingFace: public GEOM_FaceSource
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkTypeMacro(GEOM_ShadingFace,GEOM_FaceSource);
|
vtkTypeMacro(GEOM_ShadingFace,GEOM_FaceSource);
|
@ -20,17 +20,17 @@
|
|||||||
#ifndef GEOM_VERTEXSOURCE_H
|
#ifndef GEOM_VERTEXSOURCE_H
|
||||||
#define GEOM_VERTEXSOURCE_H
|
#define GEOM_VERTEXSOURCE_H
|
||||||
|
|
||||||
#include "GEOM_DeviceActor.h"
|
#include "OCC2VTK.h"
|
||||||
|
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
#include <NCollection_Set.hxx>
|
#include <NCollection_Set.hxx>
|
||||||
|
|
||||||
typedef NCollection_Set<TopoDS_Vertex> TVertexSet;
|
typedef NCollection_Set<TopoDS_Vertex> TVertexSet;
|
||||||
|
|
||||||
|
#include <vtkPoints.h>
|
||||||
#include <vtkPolyDataSource.h>
|
#include <vtkPolyDataSource.h>
|
||||||
|
|
||||||
|
class OCC2VTK_EXPORT GEOM_VertexSource: public vtkPolyDataSource
|
||||||
class VTK_EXPORT GEOM_VertexSource: public vtkPolyDataSource
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkTypeMacro(GEOM_VertexSource,vtkPolyDataSource);
|
vtkTypeMacro(GEOM_VertexSource,vtkPolyDataSource);
|
@ -20,6 +20,7 @@
|
|||||||
#ifndef GEOM_WIREFRAME_FACE_H
|
#ifndef GEOM_WIREFRAME_FACE_H
|
||||||
#define GEOM_WIREFRAME_FACE_H
|
#define GEOM_WIREFRAME_FACE_H
|
||||||
|
|
||||||
|
#include "OCC2VTK.h"
|
||||||
#include "GEOM_FaceSource.h"
|
#include "GEOM_FaceSource.h"
|
||||||
|
|
||||||
#include <GeomAbs_IsoType.hxx>
|
#include <GeomAbs_IsoType.hxx>
|
||||||
@ -27,8 +28,7 @@
|
|||||||
|
|
||||||
#include <vtkPolyDataSource.h>
|
#include <vtkPolyDataSource.h>
|
||||||
|
|
||||||
|
class OCC2VTK_EXPORT GEOM_WireframeFace: public GEOM_FaceSource
|
||||||
class VTK_EXPORT GEOM_WireframeFace: public GEOM_FaceSource
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
vtkTypeMacro(GEOM_WireframeFace,GEOM_FaceSource);
|
vtkTypeMacro(GEOM_WireframeFace,GEOM_FaceSource);
|
53
src/OCC2VTK/Makefile.am
Normal file
53
src/OCC2VTK/Makefile.am
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(top_srcdir)/adm_local/unix/make_common_starter.am
|
||||||
|
|
||||||
|
# header files
|
||||||
|
salomeinclude_HEADERS = \
|
||||||
|
OCC2VTK.h \
|
||||||
|
OCC2VTK_Tools.h \
|
||||||
|
GEOM_EdgeSource.h \
|
||||||
|
GEOM_FaceSource.h \
|
||||||
|
GEOM_ShadingFace.h \
|
||||||
|
GEOM_VertexSource.h \
|
||||||
|
GEOM_WireframeFace.h
|
||||||
|
|
||||||
|
# Libraries targets
|
||||||
|
lib_LTLIBRARIES = libOCC2VTK.la
|
||||||
|
|
||||||
|
dist_libOCC2VTK_la_SOURCES = \
|
||||||
|
OCC2VTK_Tools.cxx \
|
||||||
|
GEOM_EdgeSource.cxx \
|
||||||
|
GEOM_FaceSource.cxx \
|
||||||
|
GEOM_ShadingFace.cxx \
|
||||||
|
GEOM_VertexSource.cxx \
|
||||||
|
GEOM_WireframeFace.cxx
|
||||||
|
|
||||||
|
libOCC2VTK_la_CPPFLAGS = \
|
||||||
|
$(QT_INCLUDES) \
|
||||||
|
$(CAS_CPPFLAGS) \
|
||||||
|
$(VTK_INCLUDES) \
|
||||||
|
$(KERNEL_CXXFLAGS)
|
||||||
|
|
||||||
|
libOCC2VTK_la_LDFLAGS = \
|
||||||
|
$(QT_MT_LIBS) \
|
||||||
|
$(CAS_KERNEL) -lTKBRep -lTKG2d -lTKG3d -lTKV3d -lTKMesh -lTKGeomBase -lTKGeomAlgo -lTKTopAlgo -lTKService \
|
||||||
|
$(VTK_LIBS) \
|
||||||
|
$(KERNEL_LDFLAGS) -lSALOMELocalTrace
|
36
src/OCC2VTK/OCC2VTK.h
Executable file
36
src/OCC2VTK/OCC2VTK.h
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef OCC2VTK_H
|
||||||
|
#define OCC2VTK_H
|
||||||
|
|
||||||
|
#if defined WIN32
|
||||||
|
# if defined OCC2VTK_EXPORTS
|
||||||
|
# define OCC2VTK_EXPORT __declspec( dllexport )
|
||||||
|
# else
|
||||||
|
# define OCC2VTK_EXPORT __declspec( dllimport )
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define OCC2VTK_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // OCC2VTK_H
|
165
src/OCC2VTK/OCC2VTK_Tools.cxx
Executable file
165
src/OCC2VTK/OCC2VTK_Tools.cxx
Executable file
@ -0,0 +1,165 @@
|
|||||||
|
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "OCC2VTK_Tools.h"
|
||||||
|
|
||||||
|
#include "GEOM_VertexSource.h"
|
||||||
|
#include "GEOM_EdgeSource.h"
|
||||||
|
#include "GEOM_WireframeFace.h"
|
||||||
|
#include "GEOM_ShadingFace.h"
|
||||||
|
|
||||||
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <BRepMesh_IncrementalMesh.hxx>
|
||||||
|
#include <Poly_Triangulation.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
|
||||||
|
#define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
|
||||||
|
#define MAX3(X, Y, Z) (MAX2(MAX2(X,Y), Z))
|
||||||
|
|
||||||
|
namespace GEOM
|
||||||
|
{
|
||||||
|
void MeshShape(const TopoDS_Shape theShape,
|
||||||
|
Standard_Real theDeflection,
|
||||||
|
Standard_Boolean theForced)
|
||||||
|
{
|
||||||
|
// Mesh the shape if necessary
|
||||||
|
Standard_Boolean alreadymesh = Standard_True;
|
||||||
|
TopExp_Explorer ex;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
|
||||||
|
for (ex.Init(theShape, 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()) { alreadymesh = Standard_False; break; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!alreadymesh || theForced) {
|
||||||
|
if(theDeflection<=0) {
|
||||||
|
// Compute default deflection
|
||||||
|
Bnd_Box B;
|
||||||
|
BRepBndLib::Add(theShape, B);
|
||||||
|
if ( B.IsVoid() ) return; // NPAL15983 (Bug when displaying empty groups)
|
||||||
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
|
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
theDeflection = MAX3(aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * 0.001 * 4;
|
||||||
|
}
|
||||||
|
BRepMesh_IncrementalMesh MESH(theShape,theDeflection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeshShape2(const TopoDS_Shape& theShape,
|
||||||
|
float& theDeflection,
|
||||||
|
bool theIsRelative)
|
||||||
|
{
|
||||||
|
static Standard_Real RELATIVE_DEFLECTION = 0.0001;
|
||||||
|
Standard_Real aDeflection = theDeflection;
|
||||||
|
|
||||||
|
if(theDeflection <= 0) { // Compute default theDeflection
|
||||||
|
Bnd_Box B;
|
||||||
|
BRepBndLib::Add(theShape, B);
|
||||||
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
|
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
Standard_Real aDiagonal = (aXmax-aXmin)*(aXmax-aXmin) +
|
||||||
|
(aYmax-aYmin)*(aYmax-aYmin) +
|
||||||
|
(aZmax-aZmin)*(aZmax-aZmin);
|
||||||
|
aDiagonal = sqrt(aDiagonal);
|
||||||
|
aDeflection = aDiagonal*RELATIVE_DEFLECTION;
|
||||||
|
|
||||||
|
if(theIsRelative)
|
||||||
|
theDeflection = RELATIVE_DEFLECTION;
|
||||||
|
else
|
||||||
|
theDeflection = aDeflection;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRepMesh_IncrementalMesh aMesh(theShape,aDeflection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetShape(const TopoDS_Shape& theShape,
|
||||||
|
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
|
||||||
|
bool theIsVector,
|
||||||
|
GEOM_EdgeSource* theIsolatedEdgeSource,
|
||||||
|
GEOM_EdgeSource* theOneFaceEdgeSource,
|
||||||
|
GEOM_EdgeSource* theSharedEdgeSource,
|
||||||
|
GEOM_WireframeFace* theWireframeFaceSource,
|
||||||
|
GEOM_ShadingFace* theShadingFaceSource)
|
||||||
|
{
|
||||||
|
if (theShape.ShapeType() == TopAbs_COMPOUND) {
|
||||||
|
TopoDS_Iterator anItr(theShape);
|
||||||
|
for (; anItr.More(); anItr.Next()) {
|
||||||
|
SetShape(anItr.Value(),theEdgeMap,theIsVector,
|
||||||
|
theIsolatedEdgeSource,
|
||||||
|
theOneFaceEdgeSource,
|
||||||
|
theSharedEdgeSource,
|
||||||
|
theWireframeFaceSource,
|
||||||
|
theShadingFaceSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (theShape.ShapeType()) {
|
||||||
|
case TopAbs_WIRE: {
|
||||||
|
TopExp_Explorer anEdgeExp(theShape,TopAbs_EDGE);
|
||||||
|
for (; anEdgeExp.More(); anEdgeExp.Next()){
|
||||||
|
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
|
||||||
|
if (!BRep_Tool::Degenerated(anEdge))
|
||||||
|
theIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TopAbs_EDGE: {
|
||||||
|
const TopoDS_Edge& anEdge = TopoDS::Edge(theShape);
|
||||||
|
if (!BRep_Tool::Degenerated(anEdge))
|
||||||
|
theIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TopAbs_VERTEX: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
TopExp_Explorer aFaceExp (theShape,TopAbs_FACE);
|
||||||
|
for(; aFaceExp.More(); aFaceExp.Next()) {
|
||||||
|
const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current());
|
||||||
|
theWireframeFaceSource->AddFace(aFace);
|
||||||
|
theShadingFaceSource->AddFace(aFace);
|
||||||
|
TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE);
|
||||||
|
for(; anEdgeExp.More(); anEdgeExp.Next()) {
|
||||||
|
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
|
||||||
|
if(!BRep_Tool::Degenerated(anEdge)){
|
||||||
|
// compute the number of faces
|
||||||
|
int aNbOfFaces = theEdgeMap.FindFromKey(anEdge).Extent();
|
||||||
|
switch(aNbOfFaces){
|
||||||
|
case 0: // isolated edge
|
||||||
|
theIsolatedEdgeSource->AddEdge(anEdge,theIsVector);
|
||||||
|
break;
|
||||||
|
case 1: // edge in only one face
|
||||||
|
theOneFaceEdgeSource->AddEdge(anEdge,theIsVector);
|
||||||
|
break;
|
||||||
|
default: // edge shared by at least two faces
|
||||||
|
theSharedEdgeSource->AddEdge(anEdge,theIsVector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
55
src/OCC2VTK/OCC2VTK_Tools.h
Executable file
55
src/OCC2VTK/OCC2VTK_Tools.h
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef OCC2VTK_TOOLS_H
|
||||||
|
#define OCC2VTK_TOOLS_H
|
||||||
|
|
||||||
|
#include "OCC2VTK.h"
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
|
||||||
|
class GEOM_EdgeSource;
|
||||||
|
class GEOM_WireframeFace;
|
||||||
|
class GEOM_ShadingFace;
|
||||||
|
|
||||||
|
namespace GEOM
|
||||||
|
{
|
||||||
|
// moved from GEOM_AssemblyBuilder
|
||||||
|
OCC2VTK_EXPORT void MeshShape(const TopoDS_Shape theShape,
|
||||||
|
Standard_Real theDeflection,
|
||||||
|
Standard_Boolean theForced);
|
||||||
|
|
||||||
|
// moved from GEOM_Actor
|
||||||
|
OCC2VTK_EXPORT void MeshShape2(const TopoDS_Shape& theShape,
|
||||||
|
float& theDeflection,
|
||||||
|
bool theIsRelative);
|
||||||
|
|
||||||
|
// moved from GEOM_Actor
|
||||||
|
OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape,
|
||||||
|
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
|
||||||
|
bool theIsVector,
|
||||||
|
GEOM_EdgeSource* theIsolatedEdgeSource,
|
||||||
|
GEOM_EdgeSource* theOneFaceEdgeSource,
|
||||||
|
GEOM_EdgeSource* theSharedEdgeSource,
|
||||||
|
GEOM_WireframeFace* theWireframeFaceSource,
|
||||||
|
GEOM_ShadingFace* theShadingFaceSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // OCC2VTK_TOOLS_H
|
45
src/VTKExport/Makefile.am
Normal file
45
src/VTKExport/Makefile.am
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
#
|
||||||
|
|
||||||
|
# $Header$
|
||||||
|
#
|
||||||
|
include $(top_srcdir)/adm_local/unix/make_common_starter.am
|
||||||
|
|
||||||
|
# header files
|
||||||
|
salomeinclude_HEADERS =
|
||||||
|
|
||||||
|
# Libraries targets
|
||||||
|
lib_LTLIBRARIES = libVTKExport.la
|
||||||
|
|
||||||
|
dist_libVTKExport_la_SOURCES = \
|
||||||
|
VTKExport.cxx
|
||||||
|
|
||||||
|
# additional information to compile and link file
|
||||||
|
|
||||||
|
libVTKExport_la_CPPFLAGS = \
|
||||||
|
$(CAS_CPPFLAGS) \
|
||||||
|
$(VTK_INCLUDES) \
|
||||||
|
$(KERNEL_CXXFLAGS) \
|
||||||
|
-I$(srcdir)/../OCC2VTK
|
||||||
|
|
||||||
|
libVTKExport_la_LDFLAGS = \
|
||||||
|
../OCC2VTK/libOCC2VTK.la \
|
||||||
|
$(KERNEL_LDFLAGS) -lSALOMELocalTrace \
|
||||||
|
$(STDLIB) \
|
||||||
|
$(CAS_LDPATH)
|
144
src/VTKExport/VTKExport.cxx
Normal file
144
src/VTKExport/VTKExport.cxx
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
//
|
||||||
|
|
||||||
|
// File: VTKExport.cxx
|
||||||
|
// Author: Oleg UVAROV
|
||||||
|
//
|
||||||
|
#include "utilities.h"
|
||||||
|
|
||||||
|
#include <Basics_Utils.hxx>
|
||||||
|
|
||||||
|
#include <OCC2VTK_Tools.h>
|
||||||
|
|
||||||
|
#include <GEOM_VertexSource.h>
|
||||||
|
#include <GEOM_EdgeSource.h>
|
||||||
|
#include <GEOM_WireframeFace.h>
|
||||||
|
#include <GEOM_ShadingFace.h>
|
||||||
|
|
||||||
|
#include <vtkAppendPolyData.h>
|
||||||
|
#include <vtkPolyDataWriter.h>
|
||||||
|
|
||||||
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# if defined VTKEXPORT_EXPORTS || defined VTKExport_EXPORTS
|
||||||
|
# define VTKEXPORT_EXPORT __declspec( dllexport )
|
||||||
|
# else
|
||||||
|
# define VTKEXPORT_EXPORT __declspec( dllimport )
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define VTKEXPORT_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
VTKEXPORT_EXPORT
|
||||||
|
int Export(const TopoDS_Shape& theShape,
|
||||||
|
const TCollection_AsciiString& theFileName,
|
||||||
|
const TCollection_AsciiString& theFormatName)
|
||||||
|
{
|
||||||
|
MESSAGE("Export VTK into file " << theFileName.ToCString());
|
||||||
|
|
||||||
|
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->AddInput( myVertexSource->GetOutput() );
|
||||||
|
myAppendFilter->AddInput( myIsolatedEdgeSource->GetOutput() );
|
||||||
|
myAppendFilter->AddInput( myOneFaceEdgeSource->GetOutput() );
|
||||||
|
myAppendFilter->AddInput( mySharedEdgeSource->GetOutput() );
|
||||||
|
//myAppendFilter->AddInput( myWireframeFaceSource->GetOutput() ); // iso-lines are unnecessary
|
||||||
|
myAppendFilter->AddInput( myShadingFaceSource->GetOutput() );
|
||||||
|
|
||||||
|
float aDeflection = 1.0;
|
||||||
|
bool anIsForced = true;
|
||||||
|
bool anIsRelative = false;
|
||||||
|
bool anIsVector = false;
|
||||||
|
|
||||||
|
GEOM::MeshShape( theShape, aDeflection, anIsForced );
|
||||||
|
|
||||||
|
TopExp_Explorer aVertexExp( theShape, TopAbs_VERTEX );
|
||||||
|
for( ; aVertexExp.More(); aVertexExp.Next() )
|
||||||
|
{
|
||||||
|
const TopoDS_Vertex& aVertex = TopoDS::Vertex( aVertexExp.Current() );
|
||||||
|
myVertexSource->AddVertex( aVertex );
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOM::MeshShape2( theShape, aDeflection, anIsRelative );
|
||||||
|
|
||||||
|
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
||||||
|
TopExp::MapShapesAndAncestors( theShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap );
|
||||||
|
|
||||||
|
GEOM::SetShape( theShape,
|
||||||
|
anEdgeMap,
|
||||||
|
anIsVector,
|
||||||
|
myIsolatedEdgeSource,
|
||||||
|
myOneFaceEdgeSource,
|
||||||
|
mySharedEdgeSource,
|
||||||
|
myWireframeFaceSource,
|
||||||
|
myShadingFaceSource );
|
||||||
|
|
||||||
|
myAppendFilter->Update();
|
||||||
|
|
||||||
|
// Set "C" numeric locale to save numbers correctly
|
||||||
|
Kernel_Utils::Localizer loc;
|
||||||
|
|
||||||
|
vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();
|
||||||
|
aWriter->SetInput( myAppendFilter->GetOutput() );
|
||||||
|
aWriter->SetFileName( theFileName.ToCString() );
|
||||||
|
aWriter->Write();
|
||||||
|
aWriter->Delete();
|
||||||
|
|
||||||
|
myVertexSource->Delete();
|
||||||
|
myIsolatedEdgeSource->Delete();
|
||||||
|
myOneFaceEdgeSource->Delete();
|
||||||
|
mySharedEdgeSource->Delete();
|
||||||
|
myWireframeFaceSource->Delete();
|
||||||
|
myShadingFaceSource->Delete();
|
||||||
|
|
||||||
|
myAppendFilter->Delete();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
catch(Standard_Failure)
|
||||||
|
{
|
||||||
|
//THROW_SALOME_CORBA_EXCEPTION("Exception catched in VTKExport", SALOME::BAD_PARAM);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
47
src/VTKExport/VTKExport.pro
Normal file
47
src/VTKExport/VTKExport.pro
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
#
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
TARGET = VTKExport
|
||||||
|
DESTDIR = ../../lib
|
||||||
|
MOC_DIR = ../../moc
|
||||||
|
OBJECTS_DIR = ../../obj/$$TARGET
|
||||||
|
|
||||||
|
CASROOT = $$(CASROOT)
|
||||||
|
CAS_CPPFLAGS = $${CASROOT}/inc
|
||||||
|
|
||||||
|
KERNEL_CXXFLAGS = $$(KERNEL_ROOT_DIR)/include/salome
|
||||||
|
|
||||||
|
KERNEL_LDFLAGS = -L$$(KERNEL_ROOT_DIR)/lib/salome
|
||||||
|
|
||||||
|
STDLIB = -lstdc++
|
||||||
|
|
||||||
|
CAS_LDPATH = -L$$(CASROOT)/Linux/lib
|
||||||
|
|
||||||
|
INCLUDEPATH += $${CAS_CPPFLAGS} $${KERNEL_CXXFLAGS}
|
||||||
|
|
||||||
|
LIBS += $${STDLIB} $${CAS_LDPATH} $${KERNEL_LDFLAGS} -lSALOMELocalTrace
|
||||||
|
|
||||||
|
CONFIG -= debug release debug_and_release
|
||||||
|
CONFIG += qt thread debug dll shared
|
||||||
|
|
||||||
|
win32:DEFINES += WIN32
|
||||||
|
DEFINES += OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
|
||||||
|
|
||||||
|
SOURCES = VTKExport.cxx
|
Loading…
Reference in New Issue
Block a user