mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-26 07:07:55 +05:00
Improvement:
Adding support of export to STL format (ASCII and Binary modes)
This commit is contained in:
parent
fc0f3a279c
commit
d6a9af2f7d
@ -1,5 +1,5 @@
|
||||
Import: BREP|IGES|STEP
|
||||
Export: BREP|IGES|IGES_5_3|STEP
|
||||
Export: BREP|IGES|IGES_5_3|STEP|STL_Bin|STL_ASCII
|
||||
|
||||
BREP.Import: libBREPImport.so
|
||||
BREP.Export: libBREPExport.so
|
||||
@ -16,3 +16,9 @@ IGES_5_3.Pattern: IGES 5.3 Files ( *.iges *.igs )
|
||||
STEP.Import: libSTEPImport.so
|
||||
STEP.Export: libSTEPExport.so
|
||||
STEP.Pattern: STEP Files ( *.step *.stp )
|
||||
|
||||
STL_Bin.Export: libSTLExport.so
|
||||
STL_Bin.Pattern: STL Binary Files ( *.stl )
|
||||
|
||||
STL_ASCII.Export: libSTLExport.so
|
||||
STL_ASCII.Pattern: STL ASCII Files ( *.stl )
|
@ -260,7 +260,7 @@ Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
|
||||
|
||||
if (!InitResMgr()) return Standard_False;
|
||||
|
||||
// Read Import formats list
|
||||
// Read Import formats list from install directory
|
||||
if (myResMgr->Find("Import")) {
|
||||
TCollection_AsciiString aFormats (myResMgr->Value("Import"));
|
||||
TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
|
||||
@ -270,6 +270,25 @@ Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
|
||||
}
|
||||
}
|
||||
|
||||
// Read Import formats from user directory
|
||||
if (myResMgrUser->Find("Import")) {
|
||||
TCollection_AsciiString aFormats (myResMgrUser->Value("Import"));
|
||||
TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
|
||||
int i = 1;
|
||||
for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
|
||||
int aLenFormats = theFormats->Length();
|
||||
bool isFound = false;
|
||||
for(int aInd=1;aInd<=aLenFormats;aInd++){
|
||||
if( theFormats->Value(aInd) == aToken){
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!isFound)
|
||||
theFormats->Append(aToken);
|
||||
}
|
||||
}
|
||||
|
||||
// Read Patterns for each supported format
|
||||
int j = 1, len = theFormats->Length();
|
||||
for (; j <= len; j++) {
|
||||
@ -277,10 +296,14 @@ Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
|
||||
aKey = theFormats->Value(j) + ".ImportPattern";
|
||||
if (myResMgr->Find(aKey.ToCString()))
|
||||
aPattern = myResMgr->Value(aKey.ToCString());
|
||||
else if(myResMgrUser->Find(aKey.ToCString()))
|
||||
aPattern = myResMgrUser->Value(aKey.ToCString());
|
||||
else {
|
||||
aKey = theFormats->Value(j) + ".Pattern";
|
||||
if (myResMgr->Find(aKey.ToCString()))
|
||||
aPattern = myResMgr->Value(aKey.ToCString());
|
||||
else if(myResMgrUser->Find(aKey.ToCString()))
|
||||
aPattern = myResMgrUser->Value(aKey.ToCString());
|
||||
else {
|
||||
aPattern = theFormats->Value(j);
|
||||
aPattern += " Files ( *.* )";
|
||||
@ -313,7 +336,7 @@ Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
|
||||
|
||||
if (!InitResMgr()) return Standard_False;
|
||||
|
||||
// Read Export formats list
|
||||
// Read Export formats list from install directory
|
||||
if (myResMgr->Find("Export")) {
|
||||
TCollection_AsciiString aFormats (myResMgr->Value("Export"));
|
||||
TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
|
||||
@ -323,6 +346,25 @@ Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
|
||||
}
|
||||
}
|
||||
|
||||
// Read Export formats list from user directory
|
||||
if (myResMgrUser->Find("Export")) {
|
||||
TCollection_AsciiString aFormats (myResMgrUser->Value("Export"));
|
||||
TCollection_AsciiString aToken = aFormats.Token("| \t", 1);
|
||||
int i = 1;
|
||||
for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) {
|
||||
int aLenFormats = theFormats->Length();
|
||||
bool isFound = false;
|
||||
for(int aInd=1;aInd<=aLenFormats;aInd++){
|
||||
if( theFormats->Value(aInd) == aToken){
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!isFound)
|
||||
theFormats->Append(aToken);
|
||||
}
|
||||
}
|
||||
|
||||
// Read Patterns for each supported format
|
||||
int j = 1, len = theFormats->Length();
|
||||
for (; j <= len; j++) {
|
||||
@ -330,10 +372,14 @@ Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
|
||||
aKey = theFormats->Value(j) + ".ExportPattern";
|
||||
if (myResMgr->Find(aKey.ToCString()))
|
||||
aPattern = myResMgr->Value(aKey.ToCString());
|
||||
else if (myResMgrUser->Find(aKey.ToCString()))
|
||||
aPattern = myResMgrUser->Value(aKey.ToCString());
|
||||
else {
|
||||
aKey = theFormats->Value(j) + ".Pattern";
|
||||
if (myResMgr->Find(aKey.ToCString()))
|
||||
aPattern = myResMgr->Value(aKey.ToCString());
|
||||
else if (myResMgrUser->Find(aKey.ToCString()))
|
||||
aPattern = myResMgrUser->Value(aKey.ToCString());
|
||||
else {
|
||||
aPattern = theFormats->Value(j);
|
||||
aPattern += " Files ( *.* )";
|
||||
@ -363,7 +409,8 @@ Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
|
||||
if (isImport) aMode = "Import";
|
||||
else aMode = "Export";
|
||||
|
||||
// Read supported formats for the certain mode
|
||||
|
||||
// Read supported formats for the certain mode from install directory
|
||||
if (myResMgr->Find(aMode.ToCString())) {
|
||||
TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString()));
|
||||
if (aFormats.Search(theFormat) > -1) {
|
||||
@ -378,7 +425,23 @@ Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read supported formats for the certain mode from user directory
|
||||
if (myResMgrUser->Find(aMode.ToCString())) {
|
||||
TCollection_AsciiString aFormats (myResMgrUser->Value(aMode.ToCString()));
|
||||
if (aFormats.Search(theFormat) > -1) {
|
||||
// Read library name for the supported format
|
||||
TCollection_AsciiString aKey (theFormat);
|
||||
aKey += ".";
|
||||
aKey += aMode;
|
||||
if (myResMgrUser->Find(aKey.ToCString())) {
|
||||
TCollection_AsciiString aLibName (myResMgrUser->Value(aKey.ToCString()));
|
||||
theLibName = new TCollection_HAsciiString (aLibName);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
@ -391,14 +454,24 @@ Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
|
||||
{
|
||||
if (myResMgr.IsNull()) {
|
||||
// Initialize the Resource Manager
|
||||
TCollection_AsciiString aResDir (getenv("GEOM_ROOT_DIR"));
|
||||
TCollection_AsciiString aResDir (getenv("GEOM_ROOT_DIR")),aNull;
|
||||
#ifdef WNT
|
||||
aResDir += "\\share\\salome\\resources\\geom";
|
||||
#else
|
||||
aResDir += "/share/salome/resources/geom";
|
||||
#endif
|
||||
|
||||
myResMgr = new Resource_Manager ("ImportExport", aResDir, aNull, Standard_False);
|
||||
|
||||
if (!myResMgr->Find("Import") && !myResMgr->Find("Export")) {
|
||||
// instead of complains in Resource_Manager
|
||||
INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString());
|
||||
}
|
||||
}
|
||||
|
||||
if (myResMgrUser.IsNull()) {
|
||||
char * dir = getenv("GEOM_ENGINE_RESOURCES_DIR");
|
||||
TCollection_AsciiString aUserResDir;
|
||||
TCollection_AsciiString aUserResDir,aNull;
|
||||
if ( dir )
|
||||
{
|
||||
aUserResDir = dir;
|
||||
@ -412,14 +485,16 @@ Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
|
||||
aUserResDir += "/.salome/resources";
|
||||
#endif
|
||||
}
|
||||
myResMgr = new Resource_Manager ("ImportExport", aResDir, aUserResDir, Standard_False);
|
||||
|
||||
if (!myResMgr->Find("Import") && !myResMgr->Find("Export")) {
|
||||
myResMgrUser = new Resource_Manager ("ImportExport", aNull, aUserResDir, Standard_False);
|
||||
|
||||
if (!myResMgrUser->Find("Import") && !myResMgrUser->Find("Export")) {
|
||||
// instead of complains in Resource_Manager
|
||||
INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString() <<
|
||||
" and in " << aUserResDir.ToCString() );
|
||||
INFOS("No valid file \"ImportExport\" found in " << aUserResDir.ToCString() );
|
||||
}
|
||||
}
|
||||
|
||||
return ( myResMgr->Find("Import") || myResMgr->Find("Export") );
|
||||
}
|
||||
|
||||
return ( myResMgr->Find("Import") || myResMgr->Find("Export") ||
|
||||
myResMgrUser->Find("Import") || myResMgrUser->Find("Export"));
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
|
||||
|
||||
private:
|
||||
Handle(Resource_Manager) myResMgr;
|
||||
Handle(Resource_Manager) myResMgrUser;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -32,6 +32,6 @@ VPATH=.:@srcdir@
|
||||
|
||||
@COMMENCE@
|
||||
|
||||
SUBDIRS = OBJECT ARCHIMEDE NMTDS NMTTools NMTAlgo GEOMAlgo SKETCHER GEOM BREPExport BREPImport IGESExport IGESImport STEPExport STEPImport ShHealOper GEOMImpl GEOM_I GEOMClient DlgRef GEOMFiltersSelection GEOMGUI GEOMBase GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI GroupGUI BlocksGUI GEOM_I_Superv GEOM_SWIG
|
||||
SUBDIRS = OBJECT ARCHIMEDE NMTDS NMTTools NMTAlgo GEOMAlgo SKETCHER GEOM BREPExport BREPImport IGESExport IGESImport STEPExport STEPImport ShHealOper GEOMImpl GEOM_I GEOMClient DlgRef GEOMFiltersSelection GEOMGUI GEOMBase GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI GroupGUI BlocksGUI GEOM_I_Superv GEOM_SWIG STLExport
|
||||
|
||||
@MODULE@
|
||||
|
45
src/STLExport/Makefile.in
Normal file
45
src/STLExport/Makefile.in
Normal file
@ -0,0 +1,45 @@
|
||||
# Copyright (C) 2003 CEA
|
||||
#
|
||||
# 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 : Makefile.in
|
||||
# Author : Eugeny Nikolaev
|
||||
# Module : GEOM
|
||||
# $Header:
|
||||
|
||||
top_srcdir=@top_srcdir@
|
||||
top_builddir=../..
|
||||
srcdir=@srcdir@
|
||||
VPATH=.:@srcdir@:@top_srcdir@/idl
|
||||
|
||||
@COMMENCE@
|
||||
|
||||
# Libraries targets
|
||||
|
||||
LIB= libSTLExport.la
|
||||
|
||||
LIB_SRC = STLExport.cxx
|
||||
|
||||
# additionnal information to compil and link file
|
||||
CPPFLAGS+= $(OCC_INCLUDES) $(KERNEL_CXXFLAGS)
|
||||
CXXFLAGS+= $(OCC_CXXFLAGS) $(KERNEL_CXXFLAGS)
|
||||
|
||||
LDFLAGS+= $(CAS_LDPATH) -lTKSTL $(KERNEL_LDFLAGS)
|
||||
|
||||
@CONCLUDE@
|
68
src/STLExport/STLExport.cxx
Normal file
68
src/STLExport/STLExport.cxx
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright (C) 2005 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: STLExport.cxx
|
||||
// Created: Wed May 19 14:53:52 2004
|
||||
// Author: Pavel TELKOV
|
||||
// <ptv@mutex.nnov.opencascade.com>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <StlAPI_Writer.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
#include <SALOME_WNT.hxx>
|
||||
#else
|
||||
#define SALOME_WNT_EXPORT
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
extern "C"
|
||||
{
|
||||
SALOME_WNT_EXPORT
|
||||
int Export(const TopoDS_Shape& theShape,
|
||||
const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theFormatName)
|
||||
{
|
||||
MESSAGE("Export STL into file " << theFileName.ToCString());
|
||||
|
||||
try
|
||||
{
|
||||
StlAPI_Writer aWriter;
|
||||
bool aIsASCIIMode;
|
||||
aIsASCIIMode = (theFormatName.IsEqual("STL_ASCII")) ? true : false;
|
||||
aWriter.ASCIIMode() = aIsASCIIMode;
|
||||
aWriter.Write(theShape, theFileName.ToCString()) ;
|
||||
return 1;
|
||||
}
|
||||
catch(Standard_Failure)
|
||||
{
|
||||
//THROW_SALOME_CORBA_EXCEPTION("Exception catched in STLExport", SALOME::BAD_PARAM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user