mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-24 08:20:35 +05:00
0022315: EDF 2722 GEOM: Import STL in GEOM
This commit is contained in:
parent
7555ded134
commit
a84676a7fa
@ -243,7 +243,7 @@ INCLUDE(CMakePackageConfigHelpers)
|
||||
SET(_${PROJECT_NAME}_exposed_targets
|
||||
GEOMArchimede BREPExport BREPImport BlockFix GEOMbasic GEOMAlgo GEOMClient GEOMImpl
|
||||
GEOMUtils GEOMEngine GEOM_SupervEngine IGESExport IGESImport GEOMSketcher
|
||||
SalomeIDLGEOM STEPExport STEPImport STLExport ShHealOper XAO AdvancedEngine OCC2VTK
|
||||
SalomeIDLGEOM STEPExport STEPImport STLExport STLImport ShHealOper XAO AdvancedEngine OCC2VTK
|
||||
VTKExport
|
||||
)
|
||||
IF(SALOME_BUILD_GUI)
|
||||
|
@ -151,6 +151,7 @@ SET(GEOM_SalomeIDLGEOM SalomeIDLGEOM)
|
||||
SET(GEOM_STEPExport STEPExport)
|
||||
SET(GEOM_STEPImport STEPImport)
|
||||
SET(GEOM_STLExport STLExport)
|
||||
SET(GEOM_STLImport STLImport)
|
||||
SET(GEOM_ShHealOper ShHealOper)
|
||||
SET(GEOM_XAO XAO)
|
||||
SET(GEOM_AdvancedEngine AdvancedEngine)
|
||||
|
@ -38,6 +38,7 @@ FIND_LIBRARY(GEOM_SalomeIDLGEOM SalomeIDLGEOM ${GEOM_ROOT_DIR}/lib/salome)
|
||||
FIND_LIBRARY(GEOM_STEPExport STEPExport ${GEOM_ROOT_DIR}/lib/salome)
|
||||
FIND_LIBRARY(GEOM_STEPImport STEPImport ${GEOM_ROOT_DIR}/lib/salome)
|
||||
FIND_LIBRARY(GEOM_STLExport STLExport ${GEOM_ROOT_DIR}/lib/salome)
|
||||
FIND_LIBRARY(GEOM_STLImport STLImport ${GEOM_ROOT_DIR}/lib/salome)
|
||||
FIND_LIBRARY(GEOM_ShHealOper ShHealOper ${GEOM_ROOT_DIR}/lib/salome)
|
||||
FIND_LIBRARY(GEOM_XAO XAO ${GEOM_ROOT_DIR}/lib/salome)
|
||||
FIND_LIBRARY(GEOM_AdvancedEngine AdvancedEngine ${GEOM_ROOT_DIR}/lib/salome)
|
||||
|
@ -3,17 +3,17 @@
|
||||
\page import_export_geom_obj_page Importing/exporting geometrical objects
|
||||
|
||||
In Geometry module you can import and export geometrical objects
|
||||
from/into BREP, IGES, STEP files. The mechanisms of import and export
|
||||
from/into BREP, IGES, STEP, ACIS and STL files. The mechanisms of import and export
|
||||
are implemented via plug-ins, which gives the opportunity to
|
||||
expand the range of available formats by adding more plug-ins (for
|
||||
example, CATIA 5).
|
||||
|
||||
<em>To import geometrical objects from a BREP, IGES, STEP file:</em>
|
||||
<em>To import geometrical objects from a BREP, IGES, STEP, ACIS or STL file:</em>
|
||||
|
||||
\par
|
||||
From the \b File menu choose \b Import. In the opening dialog box \b Import
|
||||
select the required format of the file for importation and search for
|
||||
a *.brep, *.iges or *.step file.
|
||||
a *.brep, *.iges, *.step, *.sat or *.stl file.
|
||||
|
||||
\image html geomimport.png
|
||||
|
||||
@ -49,7 +49,7 @@ as before this operation.
|
||||
|
||||
\image html geomimport_reopen.png
|
||||
|
||||
\n <em>To export geometrical objects into a BREP, IGES, STEP
|
||||
\n <em>To export geometrical objects into a BREP, IGES, STEP, ACIS or STL
|
||||
file:</em>
|
||||
|
||||
\par
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
\b Geometry module of SALOME is destined for:
|
||||
- \subpage import_export_geom_obj_page "import and export of geometrical models"
|
||||
in IGES, BREP and STEP formats;
|
||||
in IGES, BREP, STEP, ACIS and STL formats;
|
||||
- \subpage create_geom_obj_page "construction of geometrical objects"
|
||||
using a wide range of functions;
|
||||
- \subpage view_geom_obj_page "viewing geometrical objects" in the OCC
|
||||
|
@ -1,4 +1,4 @@
|
||||
Import: BREP|IGES|STEP|ACIS
|
||||
Import: BREP|IGES|STEP|STL|ACIS
|
||||
Export: BREP|IGES|IGES_5_3|STEP|STL_Bin|STL_ASCII|ACIS|VTK
|
||||
|
||||
BREP.Import: BREPImport
|
||||
@ -17,6 +17,9 @@ STEP.Import: STEPImport
|
||||
STEP.Export: STEPExport
|
||||
STEP.Pattern: STEP Files ( *.step *.stp )
|
||||
|
||||
STL.Import: STLImport
|
||||
STL.Pattern: STL Files ( *.stl )
|
||||
|
||||
STL_Bin.Export: STLExport
|
||||
STL_Bin.Pattern: STL Binary Files ( *.stl )
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
##
|
||||
SET(SUBDIRS_COMMON
|
||||
ARCHIMEDE BlockFix GEOMAlgo SKETCHER GEOM BREPExport
|
||||
BREPImport IGESExport IGESImport STEPExport STEPImport STLExport
|
||||
BREPImport IGESExport IGESImport STEPExport STEPImport STLExport STLImport
|
||||
ShHealOper GEOMUtils XAO XAO_Swig GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY
|
||||
AdvancedEngine OCC2VTK VTKExport
|
||||
)
|
||||
|
@ -74,6 +74,21 @@
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||
|
||||
/**
|
||||
* This function returns the input format name from the original format name.
|
||||
*/
|
||||
static TCollection_AsciiString GetImportFormatName
|
||||
(const TCollection_AsciiString& theFormatName)
|
||||
{
|
||||
Standard_Integer aLastInd = 4;
|
||||
|
||||
if (theFormatName.Search("STL") == 1) {
|
||||
aLastInd = 3;
|
||||
}
|
||||
|
||||
return theFormatName.SubString(1, aLastInd);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* constructor
|
||||
@ -236,7 +251,8 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
|
||||
|
||||
Handle(TCollection_HAsciiString) aHLibName;
|
||||
if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) {
|
||||
if (!IsSupported
|
||||
(Standard_True, GetImportFormatName(theFormatName), aHLibName)) {
|
||||
return result;
|
||||
}
|
||||
TCollection_AsciiString aLibName = aHLibName->String();
|
||||
@ -320,7 +336,8 @@ TCollection_AsciiString GEOMImpl_IInsertOperations::ReadValue
|
||||
if (theFileName.IsEmpty() || theFormatName.IsEmpty() || theParameterName.IsEmpty()) return aValue;
|
||||
|
||||
Handle(TCollection_HAsciiString) aHLibName;
|
||||
if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) {
|
||||
if (!IsSupported
|
||||
(Standard_True, GetImportFormatName(theFormatName), aHLibName)) {
|
||||
return aValue;
|
||||
}
|
||||
TCollection_AsciiString aLibName = aHLibName->String();
|
||||
|
52
src/STLImport/CMakeLists.txt
Executable file
52
src/STLImport/CMakeLists.txt
Executable file
@ -0,0 +1,52 @@
|
||||
# Copyright (C) 2012-2013 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
|
||||
#
|
||||
|
||||
# --- options ---
|
||||
|
||||
# additional include directories
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CAS_INCLUDE_DIRS}
|
||||
${PTHREAD_INCLUDE_DIR}
|
||||
${KERNEL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# additional preprocessor / compiler flags
|
||||
ADD_DEFINITIONS(
|
||||
${CAS_DEFINITIONS}
|
||||
)
|
||||
|
||||
# libraries to link to
|
||||
SET(_link_LIBRARIES
|
||||
${CAS_TKSTL}
|
||||
${KERNEL_SALOMELocalTrace}
|
||||
)
|
||||
|
||||
# --- sources ---
|
||||
|
||||
SET(STLImport_SOURCES
|
||||
STLImport.cxx
|
||||
)
|
||||
|
||||
# --- rules ---
|
||||
|
||||
ADD_LIBRARY(STLImport ${STLImport_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(STLImport ${_link_LIBRARIES})
|
||||
INSTALL(TARGETS STLImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
|
||||
|
||||
|
72
src/STLImport/STLImport.cxx
Executable file
72
src/STLImport/STLImport.cxx
Executable file
@ -0,0 +1,72 @@
|
||||
// Copyright (C) 2007-2013 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: STLImport.cxx
|
||||
// Author: Sergey KHROMOV
|
||||
|
||||
|
||||
#include "utilities.h"
|
||||
#include <StlAPI_Reader.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined STLIMPORT_EXPORTS || defined STLImport_EXPORTS
|
||||
#define STLIMPORT_EXPORT __declspec( dllexport )
|
||||
#else
|
||||
#define STLIMPORT_EXPORT __declspec( dllimport )
|
||||
#endif
|
||||
#else
|
||||
#define STLIMPORT_EXPORT
|
||||
#endif
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
extern "C"
|
||||
{
|
||||
STLIMPORT_EXPORT
|
||||
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& /*theFormatName*/,
|
||||
TCollection_AsciiString& theError,
|
||||
const TDF_Label&)
|
||||
{
|
||||
MESSAGE("Import STL from file " << theFileName.ToCString());
|
||||
|
||||
StlAPI_Reader aReader;
|
||||
TopoDS_Shape aShape;
|
||||
|
||||
aReader.Read(aShape, theFileName.ToCString());
|
||||
|
||||
if (aShape.IsNull()) {
|
||||
theError = "STL Import failed";
|
||||
}
|
||||
|
||||
return aShape;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user