+ unify DLL export defines to namespace names

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer
2011-10-10 13:44:52 +00:00
commit 120ca87015
4155 changed files with 2965978 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
/***************************************************************************
* (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* FreeCAD 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* *
* Juergen Riegel 2002 *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <stdio.h>
# if defined (_POSIX_C_SOURCE)
# undef _POSIX_C_SOURCE
# endif // (re-)defined in pyconfig.h
# include <Python.h>
#endif
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <App/Application.h>
#include <Mod/Part/App/TopologyPy.h>
#include "FeatureImportStep.h"
#include "FeatureImportIges.h"
/* registration table */
extern struct PyMethodDef Import_methods[];
// python entry
#ifdef FC_OS_WIN32
# define ModuleExport __declspec(dllexport)
#else
# define ModuleExport
#endif
extern "C" {
void ModuleExport initImport() {
(void) Py_InitModule("Import", Import_methods); /* mod name, table ptr */
// load dependend module
Base::Interpreter().loadModule("Part");
App::AbstractFeatureFactory().AddProducer("ImportStep",new App::AbstractFeatureProducer<Import::FeatureImportStep>);
App::AbstractFeatureFactory().AddProducer("ImportIges",new App::AbstractFeatureProducer<Import::FeatureImportIges>);
Base::Console().Log("Import loaded\n");
return;
}
} // extern "C" {

View File

@@ -0,0 +1,118 @@
/***************************************************************************
* (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* FreeCAD 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* *
* Juergen Riegel 2002 *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <stdio.h>
# if defined (_POSIX_C_SOURCE)
# undef _POSIX_C_SOURCE
# endif // (re-)defined in pyconfig.h
# include <Python.h>
# include <BRep_Builder.hxx>
# include <BRepTools.hxx>
#endif
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/Feature.h>
#include <App/Property.h>
#include <Mod/Part/App/TopologyPy.h>
/* module functions */
static PyObject *
open(PyObject *self, PyObject *args)
{
const char* Name;
if (! PyArg_ParseTuple(args, "s",&Name))
return NULL;
Base::Console().Log("Open in Import with %s",Name);
// extract ending
std::string cEnding(Name);
unsigned int pos = cEnding.find_last_of('.');
if(pos == cEnding.size())
Py_Error(PyExc_Exception,"no file ending");
cEnding.erase(0,pos+1);
if(cEnding == "stp" || cEnding == "step")
{
// create new document and add Import feature
App::Document *pcDoc = App::GetApplication().newDocument();
App::AbstractFeature *pcFeature = pcDoc->addFeature("ImportStep","Step Import");
pcFeature->setPropertyString (Name,"FileName");
pcFeature->TouchProperty("FileName");
pcDoc->recompute();
}else if(cEnding == "igs" || cEnding == "iges")
{
// create new document and add Import feature
App::Document *pcDoc = App::GetApplication().newDocument();
App::AbstractFeature *pcFeature = pcDoc->addFeature("ImportIges","Iges Import");
assert(0);
// pcFeature->GetProperty("FileName").Set(Name);
pcFeature->TouchProperty("FileName");
pcDoc->recompute();
}else
Py_Error(PyExc_Exception,"unknown file ending");
Py_Return;
}
/* module functions */
static PyObject *
save(PyObject *self, PyObject *args)
{
char* str;
if (! PyArg_ParseTuple(args, "s",&str))
return NULL;
TopoDS_Shape ResultShape;
BRep_Builder aBuilder;
BRepTools::Read(ResultShape,(const Standard_CString)str,aBuilder);
return new Part::TopoShapePy(ResultShape); /* convert C -> Python */
}
/* registration table */
struct PyMethodDef Import_methods[] = {
{"open", open, 1}, /* method name, C func ptr, always-tuple */
{"save", save, 1},
{NULL, NULL} /* end of table marker */
};

View File

@@ -0,0 +1,45 @@
add_definitions(-DFCAppImport -DFC_DEBUG)
include_directories(
# ${CMAKE_SOURCE_DIR}/src
# ${OPENCV_INCLUDE_DIR}
${OCC_INCLUDE_DIR}
# ${PYTHON_INCLUDE_PATH}
${ZLIB_INCLUDE_DIR}
${XERCES_INCLUDE_DIR})
if(WIN32)
set(Import_LIBS
# ${OPENCV_LIBRARIES}
# -lTKIGES \
# -lTKSTEP \
Part
FreeCADApp)
else(WIN32)
set(Import_LIBS
# -lTKIGES \
# -lTKSTEP \
# -lFreeCADBase \
# -lFreeCADApp \
# -lPart
)
endif(WIN32)
set(Import_SRCS
AppImport.cpp
AppImportPy.cpp
FeatureImportIges.cpp
FeatureImportIges.h
FeatureImportStep.cpp
FeatureImportStep.h
PreCompiled.cpp
PreCompiled.h
)
add_library(Import SHARED ${Import_SRCS})
target_link_libraries(Import ${Import_LIBS})
set_target_properties(Import PROPERTIES SUFFIX ".pyd")
install(TARGETS Import DESTINATION lib)

View File

@@ -0,0 +1,124 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <fcntl.h>
# include <TopTools_HSequenceOfShape.hxx>
# include <IGESControl_Writer.hxx>
# include <IGESControl_Reader.hxx>
# include <TopoDS_Shape.hxx>
# include <TFunction_Logbook.hxx>
#endif
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
#include "FeatureImportIges.h"
using namespace Import;
void FeatureImportIges::InitLabel(const TDF_Label &rcLabel)
{
addProperty("String","FileName");
}
/*
bool FeaturePartImportStep::MustExecute(void)
{
Base::Console().Log("PartBoxFeature::MustExecute()\n");
return false;
}
*/
Standard_Integer FeatureImportIges::Execute(void)
{
Base::Console().Log("FeaturePartImportIges::Execute()\n");
/* cout << GetFloatProperty("x") << endl;
cout << GetFloatProperty("y") << endl;
cout << GetFloatProperty("z") << endl;
cout << GetFloatProperty("l") << endl;
cout << GetFloatProperty("h") << endl;
cout << GetFloatProperty("w") << endl;*/
try{
IGESControl_Reader aReader;
TopoDS_Shape aShape;
std::string FileName = getPropertyString("FileName");
int i=_open(FileName.c_str(),O_RDONLY);
if( i != -1)
{
_close(i);
}else{
Base::Console().Log("FeaturePartImportIges::Execute() not able to open %s!\n",FileName.c_str());
return 1;
}
// just do show the wait cursor when the Gui is up
Base::Sequencer().start("Load IGES", 1);
Base::Sequencer().next();
// read iges-file
if (aReader.ReadFile((const Standard_CString)FileName.c_str()) != IFSelect_RetDone)
throw Base::Exception("IGES read failed (load file)");
// check iges-file (memory)
//if (!aReader.Check(Standard_True))
// Base::Console().Warning( "IGES model contains errors! try loading anyway....\n" );
// make brep
aReader.TransferRoots();
// one shape, who contain's all subshapes
aShape = aReader.OneShape();
setShape(aShape);
Base::Sequencer().stop();
}
catch(...){
Base::Sequencer().halt();
Base::Console().Error("FeaturePartImportIges::Execute() failed!");
return 1;
}
return 0;
}
/*
void FeatureImportIges::Validate(void)
{
Base::Console().Log("FeaturePartImportStep::Validate()\n");
// We validate the object label ( Label() ), all the arguments and the results of the object:
log.SetValid(Label(), Standard_True);
}
*/

View File

@@ -0,0 +1,58 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef __FeatureImportIges_H__
#define __FeatureImportIges_H__
#include <Mod/Part/App/PartFeature.h>
namespace Import
{
class FeatureImportIges :public Part::Feature
{
public:
virtual void InitLabel(const TDF_Label &rcLabel);
// virtual bool MustExecute(void);
virtual Standard_Integer Execute(void);
// virtual void Validate(void);
/// Returns the Name/Type of the feature
virtual const char *Type(void){return "PartImportIges";};
};
}
#endif // __FeaturePartImportIges_H__

View File

@@ -0,0 +1,141 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <fcntl.h>
# include <TopTools_HSequenceOfShape.hxx>
# include <STEPControl_Writer.hxx>
# include <STEPControl_Reader.hxx>
# include <TopoDS_Shape.hxx>
# include <TFunction_Logbook.hxx>
#endif
#include <Base/Console.h>
#include <Base/Sequencer.h>
#include "FeatureImportStep.h"
using namespace Import;
void FeatureImportStep::InitLabel(const TDF_Label &rcLabel)
{
addProperty("String","FileName");
}
/*
bool FeaturePartImportStep::MustExecute(void)
{
Base::Console().Log("PartBoxFeature::MustExecute()\n");
return false;
}
*/
Standard_Integer FeatureImportStep::Execute(void)
{
Base::Console().Log("FeaturePartImportStep::Execute()\n");
/* cout << GetFloatProperty("x") << endl;
cout << GetFloatProperty("y") << endl;
cout << GetFloatProperty("z") << endl;
cout << GetFloatProperty("l") << endl;
cout << GetFloatProperty("h") << endl;
cout << GetFloatProperty("w") << endl;*/
try{
STEPControl_Reader aReader;
TopoDS_Shape aShape;
std::string FileName = getPropertyString("FileName");
if( FileName == "")
return 1;
int i=_open(FileName.c_str(),O_RDONLY);
if( i != -1)
{
_close(i);
}else{
setError("File not readable");
return 1;
}
// just do show the wait cursor when the Gui is up
Base::Sequencer().start("Load IGES", 1);
Base::Sequencer().next();
Handle(TopTools_HSequenceOfShape) aHSequenceOfShape = new TopTools_HSequenceOfShape;
if (aReader.ReadFile((const Standard_CString)FileName.c_str()) != IFSelect_RetDone)
{
setError("File not readable");
return 1;
}
// Root transfers
Standard_Integer nbr = aReader.NbRootsForTransfer();
//aReader.PrintCheckTransfer (failsonly, IFSelect_ItemsByEntity);
for ( Standard_Integer n = 1; n<= nbr; n++)
{
printf("STEP: Transfering Root %d\n",n);
aReader.TransferRoot(n);
// Collecting resulting entities
Standard_Integer nbs = aReader.NbShapes();
if (nbs == 0) {
aHSequenceOfShape.Nullify();
return 1;
} else {
for (Standard_Integer i =1; i<=nbs; i++)
{
printf("STEP: Transfering Shape %d\n",n);
aShape=aReader.Shape(i);
aHSequenceOfShape->Append(aShape);
}
}
}
setShape(aShape);
Base::Sequencer().stop();
}
catch(...){
Base::Sequencer().halt();
Base::Console().Error("FeaturePartImportStep::Execute() failed!");
return 1;
}
return 0;
}
/*
void FeatureImportStep::Validate(void)
{
Base::Console().Log("FeaturePartImportStep::Validate()\n");
// We validate the object label ( Label() ), all the arguments and the results of the object:
log.SetValid(Label(), Standard_True);
}
*/

View File

@@ -0,0 +1,56 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef __FeatureImportStep_H__
#define __FeatureImportStep_H__
#include <Mod/Part/App/PartFeature.h>
namespace Import
{
class FeatureImportStep :public Part::Feature
{
public:
virtual void InitLabel(const TDF_Label &rcLabel);
virtual Standard_Integer Execute(void);
// virtual void Validate(void);
/// Returns the Name/Type of the feature
virtual const char *Type(void){return "PartImportStep";};
};
}
#endif // __FeatureImportStep_H__

View File

@@ -0,0 +1,41 @@
lib_LTLIBRARIES=libImport.la
libImport_la_SOURCES=\
AppImport.cpp \
AppImportPy.cpp \
FeatureImportIges.cpp \
FeatureImportIges.h \
FeatureImportStep.cpp \
FeatureImportStep.h \
PreCompiled.cpp \
PreCompiled.h
# the library search path.
libImport_la_LDFLAGS = -L../../../Base -L../../../App -L../../Part/App $(all_libraries) \
-version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
libImport_la_CPPFLAGS = -DAppPartExport=
libImport_la_LIBADD = \
-lTKIGES \
-lTKSTEP \
-lFreeCADBase \
-lFreeCADApp \
-lPart
# set the include path found by configure
AM_CXXFLAGS = $(all_includes) -I../../../
libdir = $(prefix)/Mod/Import
# We need this softlink for Python to load
install-data-local:
cd $(DESTDIR)$(libdir) && \
rm -f Import.so && \
$(LN_S) libImport.so Import.so
EXTRA_DIST = \
AppImport.dsp \
AppImport.vcproj \
Libs.cpp

View File

@@ -0,0 +1,25 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -0,0 +1,247 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef __PRECOMPILED__
#define __PRECOMPILED__
#include <FCConfig.h>
#ifdef _PreComp_
/// here get the warnings of to long specifieres disabled (needet for VC6)
#ifdef _MSC_VER
# pragma warning( disable : 4251 )
# pragma warning( disable : 4503 )
# pragma warning( disable : 4786 ) // specifier longer then 255 chars
#endif
// Importing of App classes
#ifdef FC_OS_WIN32
# define AppPartExport __declspec(dllimport)
#else // for Linux
# define AppPartExport
#endif
// standard
#include <list>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <io.h>
#include <fcntl.h>
#include <vector>
#include <map>
// Xerces
#include <xercesc/util/XercesDefs.hpp>
// OpenCasCade =====================================================================================
// Base
#include <Standard_Failure.hxx>
#include <Standard_GUID.hxx>
#include <Standard_AbortiveTransaction.hxx>
#include <Standard_Address.hxx>
#include <Standard_AncestorIterator.hxx>
#include <Standard_BasicMap.hxx>
#include <Standard_BasicMapIterator.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Byte.hxx>
#include <Standard_Character.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_Container.hxx>
#include <Standard_CString.hxx>
#include <Standard_ctype.hxx>
#include <Standard_DBHandle.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_DimensionError.hxx>
#include <Standard_DimensionMismatch.hxx>
#include <Standard_DivideByZero.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_ExtCharacter.hxx>
#include <Standard_ExtString.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ForMapOfTypes.hxx>
#include <Standard_GUID.hxx>
#include <Standard_ImmutableObject.hxx>
#include <Standard_Integer.hxx>
#include <Standard_InternalType.hxx>
#include <Standard_IStream.hxx>
#include <Standard_KindOfType.hxx>
#include <Standard_LicenseError.hxx>
#include <Standard_LicenseNotFound.hxx>
#include <Standard_Macro.hxx>
#include <Standard_MapOfTypes.hxx>
#include <Standard_math.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_MyMapOfStringsHasher.hxx>
#include <Standard_MyMapOfTypes.hxx>
#include <Standard_NegativeValue.hxx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_NullValue.hxx>
#include <Standard_NumericError.hxx>
#include <Standard_OId.hxx>
#include <Standard_OStream.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_Overflow.hxx>
#include <Standard_Persistent.hxx>
#include <Standard_Persistent_proto.hxx>
#include <Standard_PForMapOfTypes.hxx>
#include <Standard_PrimitiveTypes.hxx>
#include <Standard_ProgramError.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_Real.hxx>
#include <Standard_ShortReal.hxx>
#include <Standard_SStream.hxx>
#include <Standard_Static.hxx>
#include <Standard_Storable.hxx>
#include <Standard_Stream.hxx>
#include <Standard_String.hxx>
#include <Standard_theForMapOfTypes.hxx>
#include <Standard_TooManyUsers.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Transient_proto.hxx>
#include <Standard_Type.hxx>
#include <Standard_TypeDef.hxx>
#include <Standard_TypeMismatch.hxx>
#include <Standard_Underflow.hxx>
#include <Standard_UUID.hxx>
#include <Standard_WayOfLife.hxx>
#include <Quantity_Date.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfExtendedString.hxx>
// OCAF
#include <TDF_Label.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Tool.hxx>
#include <TDF_ListIteratorOfAttributeList.hxx>
#include <TDocStd_Application.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_Comment.hxx>
#include <BRepBuilderAPI.hxx>
#include <BRepTools.hxx>
#include <Standard_DefineHandle.hxx>
#include <DsgPrs_LengthPresentation.hxx>
#include <GCE2d_MakeSegment.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_Line.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <GeomAbs_CurveType.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomTools_Curve2dSet.hxx>
#include <gp_Ax2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <MMgt_TShared.hxx>
#include <OSD_Environment.hxx>
#include <Precision.hxx>
#include <Quantity_Factor.hxx>
#include <Quantity_Length.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Quantity_PhysicalQuantity.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <Quantity_TypeOfColor.hxx>
#include <ShapeSchema.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Integer.hxx>
#include <Standard_IStream.hxx>
#include <Standard_Macro.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Real.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
#include <TColStd_MapOfTransient.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_ListIteratorOfListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <UnitsAPI.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
// OCAF
#include <TDocStd_Document.hxx>
#include <TDF_Label.hxx>
#include <TDF_Reference.hxx>
#include <TDF_ChildIterator.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Builder.hxx>
#include <TDataStd_Real.hxx>
#include <TFunction_Logbook.hxx>
#include <TDataStd_Name.hxx>
#include <TFunction_DriverTable.hxx>
#include <TFunction_Function.hxx>
#include <TDataStd_Integer.hxx>
// IO
#include <IGESControl_Controller.hxx>
#include <IGESControl_Writer.hxx>
#include <IGESControl_Reader.hxx>
#include <STEPControl_Writer.hxx>
#include <STEPControl_Reader.hxx>
#endif //_PreComp_
#endif

View File

@@ -0,0 +1,13 @@
#add_subdirectory(App)
if(FREECAD_BUILD_GUI)
add_subdirectory(Gui)
endif(FREECAD_BUILD_GUI)
install(
FILES
Init.py
InitGui.py
DESTINATION
Mod/Import
)

View File

@@ -0,0 +1,67 @@
/***************************************************************************
* (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* FreeCAD 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* *
* Juergen Riegel 2002 *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Gui/Application.h>
#include "Workbench.h"
// use a different name to CreateCommand()
void CreateImportCommands(void);
/* registration table */
extern struct PyMethodDef ImportGui_Import_methods[];
extern "C" {
void ImportGuiExport initImportGui()
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
return;
}
(void) Py_InitModule("ImportGui", ImportGui_Import_methods); /* mod name, table ptr */
Base::Console().Log("Loading GUI of Import module... done\n");
try {
Base::Interpreter().loadModule("PartGui");
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
}
CreateImportCommands();
ImportGui::Workbench::init();
}
} // extern "C" {

View File

@@ -0,0 +1,466 @@
/***************************************************************************
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#if defined(__MINGW32__)
# define WNT // avoid conflict with GUID
#endif
#ifndef _PreComp_
# include <climits>
# include <Python.h>
# include <Standard_Version.hxx>
# include <BRep_Builder.hxx>
# include <Handle_TDocStd_Document.hxx>
# include <Handle_XCAFApp_Application.hxx>
# include <TDocStd_Document.hxx>
# include <XCAFApp_Application.hxx>
# include <XCAFDoc_DocumentTool.hxx>
# include <XCAFDoc_ShapeTool.hxx>
# include <XCAFDoc_ColorTool.hxx>
# include <TDF_Label.hxx>
# include <TDF_LabelSequence.hxx>
# include <TDF_ChildIterator.hxx>
# include <TDataStd_Name.hxx>
# include <Quantity_Color.hxx>
# include <STEPCAFControl_Reader.hxx>
# include <STEPCAFControl_Writer.hxx>
# include <IGESCAFControl_Reader.hxx>
# include <IGESCAFControl_Writer.hxx>
# include <IGESControl_Controller.hxx>
# include <Interface_Static.hxx>
# include <Transfer_TransientProcess.hxx>
# include <XSControl_WorkSession.hxx>
# include <TopTools_IndexedMapOfShape.hxx>
# include <TopTools_MapOfShape.hxx>
# include <TopExp_Explorer.hxx>
# include <TopoDS_Iterator.hxx>
#if OCC_VERSION_HEX >= 0x060500
# include <TDataXtd_Shape.hxx>
# else
# include <TDataStd_Shape.hxx>
# endif
#endif
#include <Base/PyObjectBase.h>
#include <Base/Console.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObjectPy.h>
#include <Gui/Application.h>
#include <Mod/Part/Gui/ViewProvider.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/ProgressIndicator.h>
class ImportXCAF
{
public:
ImportXCAF(Handle_TDocStd_Document h, App::Document* d, const std::string& name)
: hdoc(h), doc(d), default_name(name)
{
aShapeTool = XCAFDoc_DocumentTool::ShapeTool (hdoc->Main());
hColors = XCAFDoc_DocumentTool::ColorTool(hdoc->Main());
}
void loadShapes()
{
// collect sequence of labels to display
TDF_LabelSequence shapeLabels, colorLabels;
aShapeTool->GetFreeShapes (shapeLabels);
hColors->GetColors(colorLabels);
// set presentations and show
for (Standard_Integer i=1; i <= shapeLabels.Length(); i++ ) {
// get the shapes and attributes
const TDF_Label& label = shapeLabels.Value(i);
loadShapes(label);
}
std::map<Standard_Integer, TopoDS_Shape>::iterator it;
// go through solids
for (it = mySolids.begin(); it != mySolids.end(); ++it) {
createShape(it->second, true, true);
}
// go through shells
for (it = myShells.begin(); it != myShells.end(); ++it) {
createShape(it->second, true, true);
}
// go through compounds
for (it = myCompds.begin(); it != myCompds.end(); ++it) {
createShape(it->second, true, true);
}
// do the rest
if (!myShapes.empty()) {
BRep_Builder builder;
TopoDS_Compound comp;
builder.MakeCompound(comp);
for (it = myShapes.begin(); it != myShapes.end(); ++it) {
builder.Add(comp, it->second);
}
createShape(comp, true, false);
}
}
private:
void createShape(const TopoDS_Shape& shape, bool perface=false, bool setname=false) const
{
Part::Feature* part;
part = static_cast<Part::Feature*>(doc->addObject("Part::Feature", default_name.c_str()));
part->Shape.setValue(shape);
std::map<Standard_Integer, Quantity_Color>::const_iterator jt;
jt = myColorMap.find(shape.HashCode(INT_MAX));
if (jt != myColorMap.end()) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part);
if (vp && vp->isDerivedFrom(PartGui::ViewProviderPart::getClassTypeId())) {
App::Color color;
color.r = jt->second.Red();
color.g = jt->second.Green();
color.b = jt->second.Blue();
static_cast<PartGui::ViewProviderPart*>(vp)->ShapeColor.setValue(color);
}
}
// set label name if defined
if (setname && !myNameMap.empty()) {
std::map<Standard_Integer, std::string>::const_iterator jt;
jt = myNameMap.find(shape.HashCode(INT_MAX));
if (jt != myNameMap.end()) {
part->Label.setValue(jt->second);
}
}
// check for colors per face
if (perface && !myColorMap.empty()) {
TopTools_IndexedMapOfShape faces;
TopExp_Explorer xp(shape,TopAbs_FACE);
while (xp.More()) {
faces.Add(xp.Current());
xp.Next();
}
bool found_face_color = false;
std::vector<App::Color> faceColors;
faceColors.resize(faces.Extent(), App::Color(0.8f,0.8f,0.8f));
xp.Init(shape,TopAbs_FACE);
while (xp.More()) {
jt = myColorMap.find(xp.Current().HashCode(INT_MAX));
if (jt != myColorMap.end()) {
int index = faces.FindIndex(xp.Current());
App::Color color;
color.r = jt->second.Red();
color.g = jt->second.Green();
color.b = jt->second.Blue();
faceColors[index-1] = color;
found_face_color = true;
}
xp.Next();
}
if (found_face_color) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part);
if (vp && vp->isDerivedFrom(PartGui::ViewProviderPartExt::getClassTypeId())) {
static_cast<PartGui::ViewProviderPartExt*>(vp)->DiffuseColor.setValues(faceColors);
}
}
}
}
void loadShapes(const TDF_Label& label)
{
TopoDS_Shape aShape;
if (aShapeTool->GetShape(label,aShape)) {
if (aShapeTool->IsTopLevel(label)) {
int ctSolids = 0, ctShells = 0, ctComps = 0;
// add the shapes
TopExp_Explorer xp;
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++)
this->mySolids[xp.Current().HashCode(INT_MAX)] = (xp.Current());
for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++)
this->myShells[xp.Current().HashCode(INT_MAX)] = (xp.Current());
// if no solids and no shells were found then go for compounds
if (ctSolids == 0 && ctShells == 0) {
for (xp.Init(aShape, TopAbs_COMPOUND); xp.More(); xp.Next(), ctComps++)
this->myCompds[xp.Current().HashCode(INT_MAX)] = (xp.Current());
}
if (ctComps == 0) {
for (xp.Init(aShape, TopAbs_FACE, TopAbs_SHELL); xp.More(); xp.Next())
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
for (xp.Init(aShape, TopAbs_WIRE, TopAbs_FACE); xp.More(); xp.Next())
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
for (xp.Init(aShape, TopAbs_EDGE, TopAbs_WIRE); xp.More(); xp.Next())
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
for (xp.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); xp.More(); xp.Next())
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
}
}
// getting color
Quantity_Color col;
if (hColors->GetColor(label, XCAFDoc_ColorGen, col) ||
hColors->GetColor(label, XCAFDoc_ColorSurf, col) ||
hColors->GetColor(label, XCAFDoc_ColorCurv, col)) {
// add defined color
myColorMap[aShape.HashCode(INT_MAX)] = col;
}
else {
// http://www.opencascade.org/org/forum/thread_17107/
TopoDS_Iterator it;
for (it.Initialize(aShape);it.More(); it.Next()) {
if (hColors->GetColor(it.Value(), XCAFDoc_ColorGen, col) ||
hColors->GetColor(it.Value(), XCAFDoc_ColorSurf, col) ||
hColors->GetColor(it.Value(), XCAFDoc_ColorCurv, col)) {
// add defined color
myColorMap[it.Value().HashCode(INT_MAX)] = col;
}
}
}
// getting names
Handle(TDataStd_Name) name;
if (label.FindAttribute(TDataStd_Name::GetID(),name)) {
TCollection_ExtendedString extstr = name->Get();
char* str = new char[extstr.LengthOfCString()+1];
extstr.ToUTF8CString(str);
std::string label(str);
if (!label.empty())
myNameMap[aShape.HashCode(INT_MAX)] = label;
delete [] str;
}
if (label.HasChild()) {
TDF_ChildIterator it;
for (it.Initialize(label); it.More(); it.Next()) {
loadShapes(it.Value());
}
}
}
}
private:
Handle_TDocStd_Document hdoc;
App::Document* doc;
Handle_XCAFDoc_ShapeTool aShapeTool;
Handle_XCAFDoc_ColorTool hColors;
std::string default_name;
std::map<Standard_Integer, TopoDS_Shape> mySolids;
std::map<Standard_Integer, TopoDS_Shape> myShells;
std::map<Standard_Integer, TopoDS_Shape> myCompds;
std::map<Standard_Integer, TopoDS_Shape> myShapes;
std::map<Standard_Integer, Quantity_Color> myColorMap;
std::map<Standard_Integer, std::string> myNameMap;
};
/* module functions */
static PyObject * importer(PyObject *self, PyObject *args)
{
const char* Name;
const char* DocName;
if (!PyArg_ParseTuple(args, "ss",&Name,&DocName))
return 0;
PY_TRY {
//Base::Console().Log("Insert in Part with %s",Name);
Base::FileInfo file(Name);
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
}
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) hDoc;
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
if (file.hasExtension("stp") || file.hasExtension("step")) {
STEPCAFControl_Reader aReader;
aReader.SetColorMode(true);
aReader.SetNameMode(true);
aReader.SetLayerMode(true);
if (aReader.ReadFile((Standard_CString)Name) != IFSelect_RetDone) {
PyErr_SetString(PyExc_Exception, "cannot read STEP file");
return 0;
}
Handle_Message_ProgressIndicator pi = new Part::ProgressIndicator(100);
aReader.Reader().WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading STEP file...");
pi->Show();
aReader.Transfer(hDoc);
pi->EndScope();
}
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
IGESControl_Controller::Init();
Interface_Static::SetIVal("read.surfacecurve.mode",3);
IGESCAFControl_Reader aReader;
if (aReader.ReadFile((Standard_CString)Name) != IFSelect_RetDone) {
PyErr_SetString(PyExc_Exception, "cannot read IGES file");
return 0;
}
Handle_Message_ProgressIndicator pi = new Part::ProgressIndicator(100);
aReader.WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading IGES file...");
pi->Show();
aReader.Transfer(hDoc);
pi->EndScope();
}
else {
PyErr_SetString(PyExc_Exception, "no supported file format");
return 0;
}
ImportXCAF xcaf(hDoc, pcDoc, file.fileNamePure());
xcaf.loadShapes();
pcDoc->recompute();
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
PY_CATCH
Py_Return;
}
static PyObject * exporter(PyObject *self, PyObject *args)
{
PyObject* object;
const char* filename;
if (!PyArg_ParseTuple(args, "Os",&object,&filename))
return NULL;
PY_TRY {
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) hDoc;
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
Handle_XCAFDoc_ShapeTool hShapeTool = XCAFDoc_DocumentTool::ShapeTool(hDoc->Main());
Handle_XCAFDoc_ColorTool hColors = XCAFDoc_DocumentTool::ColorTool(hDoc->Main());
TDF_Label rootLabel= TDF_TagSource::NewChild(hDoc->Main());
Py::List list(object);
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
Part::Feature* part = static_cast<Part::Feature*>(obj);
const TopoDS_Shape& shape = part->Shape.getValue();
// Add shape and name
//TDF_Label shapeLabel = hShapeTool->AddShape(shape, Standard_False);
TDF_Label shapeLabel= TDF_TagSource::NewChild(rootLabel);
#if OCC_VERSION_HEX >= 0x060500
TDataXtd_Shape::Set(shapeLabel, shape);
#else
TDataStd_Shape::Set(shapeLabel, shape);
#endif
TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), 1));
// Add color information
Quantity_Color col;
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part);
bool per_face = false;
if (vp && vp->isDerivedFrom(PartGui::ViewProviderPartExt::getClassTypeId())) {
const std::vector<App::Color>& c = static_cast<PartGui::ViewProviderPartExt*>
(vp)->DiffuseColor.getValues();
// define color per face
if (c.size() > 1) {
per_face = true;
std::set<int> face_index;
TopTools_IndexedMapOfShape faces;
TopExp_Explorer xp(shape,TopAbs_FACE);
while (xp.More()) {
face_index.insert(faces.Add(xp.Current()));
xp.Next();
}
xp.Init(shape,TopAbs_FACE);
while (xp.More()) {
int index = faces.FindIndex(xp.Current());
if (face_index.find(index) != face_index.end()) {
face_index.erase(index);
TDF_Label faceLabel= TDF_TagSource::NewChild(shapeLabel);
#if OCC_VERSION_HEX >= 0x060500
TDataXtd_Shape::Set(faceLabel, xp.Current());
#else
TDataStd_Shape::Set(faceLabel, xp.Current());
#endif
const App::Color& color = c[index-1];
Quantity_Parameter mat[3];
mat[0] = color.r;
mat[1] = color.g;
mat[2] = color.b;
col.SetValues(mat[0],mat[1],mat[2],Quantity_TOC_RGB);
hColors->SetColor(faceLabel, col, XCAFDoc_ColorSurf);
}
xp.Next();
}
}
}
if (!per_face && vp && vp->isDerivedFrom(PartGui::ViewProviderPart::getClassTypeId())) {
App::Color color = static_cast<PartGui::ViewProviderPart*>(vp)->ShapeColor.getValue();
Quantity_Parameter mat[3];
mat[0] = color.r;
mat[1] = color.g;
mat[2] = color.b;
col.SetValues(mat[0],mat[1],mat[2],Quantity_TOC_RGB);
hColors->SetColor(shapeLabel, col, XCAFDoc_ColorGen);
}
}
else {
Base::Console().Message("'%s' is not a shape, export will be ignored.\n", obj->Label.getValue());
}
}
}
Base::FileInfo file(filename);
if (file.hasExtension("stp") || file.hasExtension("step")) {
STEPCAFControl_Writer writer;
writer.Transfer(hDoc, STEPControl_AsIs);
writer.Write(filename);
}
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
IGESControl_Controller::Init();
IGESCAFControl_Writer writer;
writer.Transfer(hDoc);
writer.Write(filename);
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
PY_CATCH
Py_Return;
}
/* registration table */
struct PyMethodDef ImportGui_Import_methods[] = {
{"insert" ,importer ,METH_VARARGS,
"insert(string,string) -- Insert the file into the given document."},
{"export" ,exporter ,METH_VARARGS,
"export(list,string) -- Export a list of objects into a single file."},
{NULL, NULL} /* end of table marker */
};

View File

@@ -0,0 +1,61 @@
if(MSVC)
add_definitions(-DFCAppPart -DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
else(MSVC)
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
endif(MSVC)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${COIN3D_INCLUDE_DIR}
${QT_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${SOQT_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${XERCESC_INCLUDE_DIR}
)
link_directories(${OCC_LIBRARY_DIR})
set(ImportGui_LIBS
FreeCADGui
PartGui
TKXCAF
TKLCAF
TKXDESTEP
TKXDEIGES
)
SET(ImportGui_SRCS
AppImportGui.cpp
AppImportGuiPy.cpp
Command.cpp
PreCompiled.cpp
PreCompiled.h
Workbench.cpp
Workbench.h
)
add_library(ImportGui SHARED ${ImportGui_SRCS})
target_link_libraries(ImportGui ${ImportGui_LIBS})
fc_copy_script("Mod/Import" "ImportGui" Init.py)
fc_copy_script("Mod/Import" "ImportGui" InitGui.py)
if(MSVC)
set_target_properties(ImportGui PROPERTIES SUFFIX ".pyd")
set_target_properties(ImportGui PROPERTIES DEBUG_OUTPUT_NAME "ImportGui_d")
set_target_properties(ImportGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Import)
set_target_properties(ImportGui PROPERTIES PREFIX "../")
elseif(MINGW)
set_target_properties(ImportGui PROPERTIES SUFFIX ".pyd")
set_target_properties(ImportGui PROPERTIES DEBUG_OUTPUT_NAME "ImportGui_d")
set_target_properties(ImportGui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Import)
set_target_properties(ImportGui PROPERTIES PREFIX "")
else(MSVC)
set_target_properties(ImportGui PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Mod/Import)
set_target_properties(ImportGui PROPERTIES PREFIX "")
endif(MSVC)
install(TARGETS ImportGui DESTINATION lib)

View File

@@ -0,0 +1,158 @@
/***************************************************************************
* Copyright (c) 2002 Jürgen Riegel (juergen.riegel@web.de) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Exception.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/MainWindow.h>
#include <Gui/Command.h>
#include <Gui/FileDialog.h>
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
using Gui::FileDialog;
//===========================================================================
// Import_Box
//===========================================================================
DEF_STD_CMD_A(FCCmdImportReadBREP);
FCCmdImportReadBREP::FCCmdImportReadBREP()
: Command("Import_ReadBREP")
{
sAppModule = "Import";
sGroup = "Import";
sMenuText = "Read BREP";
sToolTipText = "Read a BREP file";
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Std_Tool1";
}
void FCCmdImportReadBREP::activated(int iMsg)
{
openCommand("Read BREP");
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("BREP (*.brep *.rle)"));
if (fn.isEmpty()) {
abortCommand();
return;
}
doCommand(Doc,"TopoShape = Import.ReadBREP(\"%s\")",(const char*)fn.toUtf8());
commitCommand();
}
bool FCCmdImportReadBREP::isActive(void)
{
return getGuiApplication()->activeDocument() != 0;
}
//===========================================================================
// PartImportStep
//===========================================================================
DEF_STD_CMD_A(ImportStep);
ImportStep::ImportStep()
: Command("Part_ImportStep")
{
sAppModule = "Part";
sGroup = "Part";
sMenuText = "Import STEP";
sToolTipText = "Create or change a Import STEP feature";
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Save";
}
void ImportStep::activated(int iMsg)
{
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("STEP (*.stp *.step)"));
if (!fn.isEmpty()) {
openCommand("Part ImportSTEP Create");
doCommand(Doc,"f = App.document().addObject(\"ImportStep\",\"ImportStep\")");
doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toUtf8());
commitCommand();
updateActive();
}
}
bool ImportStep::isActive(void)
{
if (getActiveGuiDocument())
return true;
else
return false;
}
//===========================================================================
// ImportIges
//===========================================================================
DEF_STD_CMD_A(ImportIges);
ImportIges::ImportIges()
: Command("Import_Iges")
{
sAppModule = "Import";
sGroup = "Part";
sMenuText = "Import IGES";
sToolTipText = "Create or change a Import IGES feature";
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
sPixmap = "Save";
}
void ImportIges::activated(int iMsg)
{
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("IGES (*.igs *.iges)"));
if (!fn.isEmpty()) {
openCommand("ImportIGES Create");
doCommand(Doc,"f = App.document().addObject(\"ImportIges\",\"ImportIges\")");
doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toUtf8());
commitCommand();
updateActive();
}
}
bool ImportIges::isActive(void)
{
if (getActiveGuiDocument())
return true;
else
return false;
}
void CreateImportCommands(void)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new FCCmdImportReadBREP());
}

View File

@@ -0,0 +1,90 @@
lib_LTLIBRARIES=libImportGui.la ImportGui.la
# BUILT_SOURCES=\
#
libImportGui_la_SOURCES=\
AppImportGuiPy.cpp \
Command.cpp \
PreCompiled.cpp \
PreCompiled.h \
Workbench.cpp \
Workbench.h
# the library search path.
libImportGui_la_LDFLAGS = \
-L../../../Base \
-L../../../App \
-L../../../Gui \
-L../../Part/App \
-L../../Part/Gui \
-L$(OCC_LIB) $(QT4_CORE_LIBS) $(all_libraries) \
-version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
libImportGui_la_CPPFLAGS = -DAppPartExport= -DAppPartGuiExport=
libImportGui_la_LIBADD = \
@BOOST_SYSTEM_LIB@ \
-l@PYTHON_LIB@ \
-lTKernel \
-lTKMath \
-lTKBRep \
-lTKXSBase \
-lTKXCAF \
-lTKLCAF \
-lTKCAF \
-lTKSTEP \
-lTKIGES \
-lTKXDESTEP \
-lTKXDEIGES \
-lFreeCADBase \
-lFreeCADApp \
-lFreeCADGui \
-lPart \
-lPartGui
#--------------------------------------------------------------------------------------
# Loader of libImportGui
ImportGui_la_SOURCES=\
AppImportGui.cpp
# the library search path.
ImportGui_la_LDFLAGS = $(libImportGui_la_LDFLAGS) -module -avoid-version
ImportGui_la_CPPFLAGS = $(libImportGui_la_CPPFLAGS)
ImportGui_la_LIBADD = \
$(libImportGui_la_LIBADD) \
-lImportGui
ImportGui_la_DEPENDENCIES = libImportGui.la
#--------------------------------------------------------------------------------------
# rule for Qt MetaObject Compiler:
moc_%.cpp: %.h
$(QT_MOC) $< -o $(@F)
# rule for Qt MetaObject Compiler:
%.moc: %.h
$(QT_MOC) $< -o $(@F)
# rules for Qt User Interface Compiler:
ui_%.h: %.ui
$(QT_UIC) $< -o $(@F)
# rules for Qt Resource Compiler:
qrc_%.cpp: Resources/%.qrc
$(QT_RCC) -name $(*F) $< -o $(@F)
# set the include path found by configure
AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(all_includes) $(QT_CXXFLAGS) -I$(OCC_INC) \
-I$(sim_ac_coin_includedir) -I$(sim_ac_soqt_includedir)
includedir = @includedir@/Mod/Part/Gui
libdir = $(prefix)/Mod/Import
#CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
CMakeLists.txt

View File

@@ -0,0 +1,24 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -0,0 +1,119 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef __PRECOMPILED_GUI__
#define __PRECOMPILED_GUI__
#include <FCConfig.h>
// Importing of App classes
#ifdef FC_OS_WIN32
# define ImportGuiExport __declspec(dllexport)
# define PartExport __declspec(dllimport)
# define PartGuiExport __declspec(dllimport)
#else // for Linux
# define ImportGuiExport
# define PartExport
# define PartGuiExport
#endif
// here get the warnings of too long specifiers disabled (needed for VC6)
#ifdef _MSC_VER
# pragma warning( disable : 4251 )
# pragma warning( disable : 4503 )
# pragma warning( disable : 4786 ) // specifier longer then 255 chars
#endif
#ifdef _PreComp_
// Python
#include <Python.h>
// standard
#include <list>
#include <iostream>
#include <assert.h>
// STL
#include <vector>
#include <map>
#include <string>
#include <set>
#include <Python.h>
#ifndef FC_OS_WIN32
# include <windows.h>
#endif
// Xerces
#include <xercesc/util/XercesDefs.hpp>
// OpenCasCade Base
#include "OpenCascadeAll.h"
// OpenCascade View
#include <Geom_Axis2Placement.hxx>
#include <TDF_Label.hxx>
#include <TDF_TagSource.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_Name.hxx>
#include <TDF_Label.hxx>
#include <TDF_TagSource.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDataStd_ChildNodeIterator.hxx>
#include <gp_Pnt.hxx>
#include <gp_Sphere.hxx>
#include <gp_Trsf.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TNaming_Tool.hxx>
#include <BRep_Tool.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <Geom_SphericalSurface.hxx>
#include <TNaming_NamedShape.hxx>
#include <BRepTools.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <TopoDS_Shape.hxx>
#include <TNaming_Builder.hxx>
#ifndef FC_OS_WIN32
#include <Graphic3d_GraphicDevice.hxx>
#else
#include <Graphic3d_WNTGraphicDevice.hxx>
#endif
// Qt Toolkit
#ifndef __Qt4All__
# include <Gui/Qt4All.h>
#endif
#endif //_PreComp_
#endif // __PRECOMPILED_GUI__

View File

@@ -0,0 +1,57 @@
/***************************************************************************
* Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <qobject.h>
#endif
#include "Workbench.h"
#include <Gui/ToolBarManager.h>
using namespace ImportGui;
/// @namespace ImportGui @class Workbench
TYPESYSTEM_SOURCE(ImportGui::Workbench, Gui::StdWorkbench)
Workbench::Workbench()
{
}
Workbench::~Workbench()
{
}
Gui::ToolBarItem* Workbench::setupToolBars() const
{
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
return root;
}
Gui::ToolBarItem* Workbench::setupCommandBars() const
{
Gui::ToolBarItem* root = new Gui::ToolBarItem;
return root;
}

View File

@@ -0,0 +1,50 @@
/***************************************************************************
* Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef IMPORT_WORKBENCH_H
#define IMPORT_WORKBENCH_H
#include <Gui/Workbench.h>
namespace ImportGui {
/**
* @author Werner Mayer
*/
class Workbench : public Gui::StdWorkbench
{
TYPESYSTEM_HEADER();
public:
Workbench();
virtual ~Workbench();
protected:
Gui::ToolBarItem* setupToolBars() const;
Gui::ToolBarItem* setupCommandBars() const;
};
} // namespace ImportGui
#endif // IMPORT_WORKBENCH_H

33
src/Mod/Import/Init.py Normal file
View File

@@ -0,0 +1,33 @@
# FreeCAD init script of the Import module
# (c) 2001 Juergen Riegel
#***************************************************************************
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD 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 Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Juergen Riegel 2002 *
#***************************************************************************/
# Append the open handler
#FreeCAD.addImportType("STEP 214 (*.step *.stp)","ImportGui")
FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui")
#FreeCAD.addExportType("IGES files (*.iges *.igs)","ImportGui")

70
src/Mod/Import/InitGui.py Normal file
View File

@@ -0,0 +1,70 @@
# Import gui init module
# (c) 2003 Juergen Riegel
#
# Gathering all the information to start FreeCAD
# This is the second one of three init scripts, the third one
# runs when the gui is up
#***************************************************************************
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU General Public License (GPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD 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 Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Juergen Riegel 2002 *
#***************************************************************************/
"""
class ImportWorkbench ( Workbench ):
"Import workbench object"
def Activate(self):
# load the module
try:
Log ('Loading ImportGui module')
import Import
import ImportGui
except:
Err('Cannot load ImportGui')
raise
def GetIcon(self):
# returns an icon for the workbench
return ["/* XPM */\n"
"static const char *fileopen[] = {\n"
"\"16 13 5 1\",\n"
"\". c #040404\",\n"
"\"# c #808304\",\n"
"\"a c None\",\n"
"\"b c #f3f704\",\n"
"\"c c #f3f7f3\",\n"
"\"aaaaaaaaa...aaaa\",\n"
"\"aaaaaaaa.aaa.a.a\",\n"
"\"aaaaaaaaaaaaa..a\",\n"
"\"a...aaaaaaaa...a\",\n"
"\".bcb.......aaaaa\",\n"
"\".cbcbcbcbc.aaaaa\",\n"
"\".bcbcbcbcb.aaaaa\",\n"
"\".cbcb...........\",\n"
"\".bcb.#########.a\",\n"
"\".cb.#########.aa\",\n"
"\".b.#########.aaa\",\n"
"\"..#########.aaaa\",\n"
"\"...........aaaaa\"};\n"]
Gui.addWorkbench("Import",ImportWorkbench())
"""

View File

@@ -0,0 +1,11 @@
#SUBDIRS=App Gui
SUBDIRS=Gui
# Change data dir from default ($(prefix)/share) to $(prefix)
datadir = $(prefix)/Mod/Import
data_DATA = Init.py InitGui.py
EXTRA_DIST = \
$(data_DATA) \
CMakeLists.txt \
import.dox

View File

@@ -0,0 +1,3 @@
/** \defgroup IMPORT Import
* \ingroup WORKBENCHES */