mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
110
samples/mfc/standard/05_ImportExport/src/ColoredShape.cpp
Executable file
110
samples/mfc/standard/05_ImportExport/src/ColoredShape.cpp
Executable file
@@ -0,0 +1,110 @@
|
||||
// ColoredShape.cpp: implementation of the CColoredShape class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ColoredShape.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CColoredShape::CColoredShape()
|
||||
{
|
||||
m_colorName = Quantity_NOC_RED;
|
||||
}
|
||||
|
||||
|
||||
CColoredShape::CColoredShape(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape)
|
||||
{
|
||||
m_colorName = aColor;
|
||||
m_shapeObject = aShape;
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIAL(CColoredShape, CObject,1);
|
||||
|
||||
// This schema contains all the Persistent Geometry and Topology
|
||||
#include <ShapeSchema.hxx>
|
||||
|
||||
// Tools to store TopoDS_Shape
|
||||
#include <MgtBRep.hxx>
|
||||
#include <PTopoDS_HShape.hxx>
|
||||
#include <PTColStd_TransientPersistentMap.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
// Tools to put Persistent Object in an archive
|
||||
#include <FSD_Archive.hxx>
|
||||
#include <Storage_Data.hxx>
|
||||
#include <Storage_HSeqOfRoot.hxx>
|
||||
#include <Storage_Root.hxx>
|
||||
#include <PTColStd_PersistentTransientMap.hxx>
|
||||
|
||||
void CColoredShape::Serialize(CArchive & ar)
|
||||
{
|
||||
CObject::Serialize(ar);
|
||||
|
||||
// an I/O driver
|
||||
FSD_Archive f( &ar );
|
||||
|
||||
// the applicative Schema containing Persistent Topology and Geometry
|
||||
// Note that it inherits from the class Storage_Schema
|
||||
Handle(ShapeSchema) s = new ShapeSchema;
|
||||
|
||||
if ( ar.IsStoring() )
|
||||
{
|
||||
// Store the color in the archive
|
||||
ar << m_colorName;
|
||||
|
||||
//Create the persistent Shape
|
||||
PTColStd_TransientPersistentMap aMap;
|
||||
|
||||
Handle(PTopoDS_HShape) aPShape =
|
||||
MgtBRep::Translate(m_shapeObject, aMap, MgtBRep_WithoutTriangle);
|
||||
|
||||
// Store the Persistent shape in the archive
|
||||
Handle(Storage_Data) d = new Storage_Data;
|
||||
d->AddRoot("ObjectName", aPShape);
|
||||
s->Write( f, d);
|
||||
|
||||
// Check
|
||||
if (d->ErrorStatus() != Storage_VSOk)
|
||||
{
|
||||
::MessageBox(NULL, " Error while writing... ", " Error ",MB_OK) ;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read the Color from the archive
|
||||
Standard_Integer tmp;
|
||||
|
||||
ar >> tmp;
|
||||
m_colorName = (Quantity_NameOfColor) tmp;
|
||||
|
||||
// Read the Persistent Shape from the archive
|
||||
Handle(Storage_Data) d = s->Read( f );
|
||||
Handle(Storage_HSeqOfRoot) roots = d->Roots();
|
||||
Handle(Standard_Persistent) p;
|
||||
Handle(Storage_Root) r;
|
||||
Handle(PTopoDS_HShape) aPShape;
|
||||
|
||||
r = roots->Value(1);
|
||||
p = r->Object();
|
||||
aPShape = Handle(PTopoDS_HShape)::DownCast(p);
|
||||
|
||||
// Create the shape
|
||||
PTColStd_PersistentTransientMap aMap;
|
||||
|
||||
MgtBRep::Translate(aPShape,aMap,m_shapeObject,MgtBRep_WithoutTriangle);
|
||||
}
|
||||
}
|
||||
|
||||
void CColoredShape::Display(Handle(AIS_InteractiveContext)& anAIScontext)
|
||||
{
|
||||
Handle(AIS_Shape) ais = new AIS_Shape(m_shapeObject);
|
||||
|
||||
anAIScontext->SetColor(ais, m_colorName);
|
||||
anAIScontext->Display(ais, Standard_False);
|
||||
|
||||
}
|
34
samples/mfc/standard/05_ImportExport/src/ColoredShape.h
Executable file
34
samples/mfc/standard/05_ImportExport/src/ColoredShape.h
Executable file
@@ -0,0 +1,34 @@
|
||||
// ColoredShape.h: interface for the CColoredShape class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_COLOREDSHAPE_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)
|
||||
#define AFX_COLOREDSHAPE_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
class CColoredShape : public CObject
|
||||
{
|
||||
public:
|
||||
CColoredShape( const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape);
|
||||
|
||||
void Display( Handle(AIS_InteractiveContext)& anAIScontext);
|
||||
|
||||
// fields
|
||||
Quantity_NameOfColor m_colorName;
|
||||
TopoDS_Shape m_shapeObject;
|
||||
|
||||
protected:
|
||||
CColoredShape();
|
||||
|
||||
// Declare CArchive >> operator
|
||||
DECLARE_SERIAL(CColoredShape);
|
||||
|
||||
// mute CObject::Serialize
|
||||
void Serialize(CArchive& ar);
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_COLOREDSHAPE_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)
|
132
samples/mfc/standard/05_ImportExport/src/ColoredShapes.cpp
Executable file
132
samples/mfc/standard/05_ImportExport/src/ColoredShapes.cpp
Executable file
@@ -0,0 +1,132 @@
|
||||
// ColoredShapes.cpp: implementation of the CColoredShape class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <afxtempl.h>
|
||||
|
||||
#include "ColoredShapes.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CColoredShapes::CColoredShapes()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CColoredShapes::Add(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape)
|
||||
{
|
||||
m_shapeList.Append(aShape);
|
||||
m_colorMap.Bind(aShape, aColor);
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIAL(CColoredShapes, CObject,1);
|
||||
|
||||
// This schema contains all the Persistent Geometry and Topology
|
||||
#include <ShapeSchema.hxx>
|
||||
|
||||
// Tools to store TopoDS_Shape
|
||||
#include <MgtBRep.hxx>
|
||||
#include <PTopoDS_HShape.hxx>
|
||||
#include <PTColStd_TransientPersistentMap.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
// Tools to put Persistent Object in an archive
|
||||
#include <FSD_Archive.hxx>
|
||||
#include <Storage_Data.hxx>
|
||||
#include <Storage_HSeqOfRoot.hxx>
|
||||
#include <Storage_Root.hxx>
|
||||
#include <PTColStd_PersistentTransientMap.hxx>
|
||||
|
||||
void CColoredShapes::Serialize(CArchive & ar)
|
||||
{
|
||||
CObject::Serialize(ar);
|
||||
|
||||
// an I/O driver
|
||||
FSD_Archive f( &ar );
|
||||
|
||||
// the applicative Schema containing Persistent Topology and Geometry
|
||||
// Note that it inherits from the class Storage_Schema
|
||||
Handle(ShapeSchema) s = new ShapeSchema;
|
||||
|
||||
if ( ar.IsStoring() )
|
||||
{
|
||||
// Write number of shapes to be serialized
|
||||
|
||||
ar << (int)m_colorMap.Extent();
|
||||
|
||||
for ( TopoDS_ListIteratorOfListOfShape iter(m_shapeList); iter.More(); iter.Next() )
|
||||
{
|
||||
//Create the persistent Shape
|
||||
PTColStd_TransientPersistentMap aMap;
|
||||
|
||||
Handle(PTopoDS_HShape) aPShape =
|
||||
MgtBRep::Translate(iter.Value(), aMap, MgtBRep_WithoutTriangle);
|
||||
|
||||
// Store the Persistent shape in the archive
|
||||
Handle(Storage_Data) d = new Storage_Data;
|
||||
d->AddRoot("ObjectName", aPShape);
|
||||
s->Write( f, d);
|
||||
|
||||
// Check
|
||||
if (d->ErrorStatus() != Storage_VSOk)
|
||||
{
|
||||
::MessageBox(NULL, " Error while writing... ", " Error ",MB_OK) ;
|
||||
}
|
||||
|
||||
// Store the color in the archive
|
||||
ar << (Standard_Integer)m_colorMap.Find(iter.Value());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get numbe of stored shapes
|
||||
int nbShapes;
|
||||
ar >> nbShapes;
|
||||
|
||||
Standard_Integer tmp;
|
||||
Quantity_NameOfColor theColor;
|
||||
|
||||
// Reading all shapes
|
||||
for ( int i = 0; i < nbShapes; i++ )
|
||||
{
|
||||
// Read the Persistent Shape from the archive
|
||||
Handle(Storage_Data) d = s->Read( f );
|
||||
Handle(Storage_HSeqOfRoot) roots = d->Roots();
|
||||
Handle(Standard_Persistent) p;
|
||||
Handle(Storage_Root) r;
|
||||
Handle(PTopoDS_HShape) aPShape;
|
||||
TopoDS_Shape theShape;
|
||||
|
||||
r = roots->Value(1);
|
||||
p = r->Object();
|
||||
aPShape = Handle(PTopoDS_HShape)::DownCast(p);
|
||||
|
||||
// Create the shape
|
||||
PTColStd_PersistentTransientMap aMap;
|
||||
|
||||
MgtBRep::Translate(aPShape,aMap,theShape,MgtBRep_WithoutTriangle);
|
||||
|
||||
m_shapeList.Append(theShape);
|
||||
|
||||
// Read the Color from the archive
|
||||
ar >> tmp;
|
||||
theColor = (Quantity_NameOfColor) tmp;
|
||||
m_colorMap.Bind(theShape, theColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CColoredShapes::Display(Handle(AIS_InteractiveContext)& anAIScontext)
|
||||
{
|
||||
for ( TopoDS_ListIteratorOfListOfShape iter(m_shapeList); iter.More(); iter.Next() )
|
||||
{
|
||||
Handle(AIS_Shape) ais = new AIS_Shape(iter.Value());
|
||||
anAIScontext->SetColor(ais, (Quantity_NameOfColor)m_colorMap.Find(iter.Value()));
|
||||
anAIScontext->SetMaterial(ais, Graphic3d_NOM_GOLD, Standard_False);
|
||||
anAIScontext->Display(ais, Standard_False);
|
||||
}
|
||||
}
|
35
samples/mfc/standard/05_ImportExport/src/ColoredShapes.h
Executable file
35
samples/mfc/standard/05_ImportExport/src/ColoredShapes.h
Executable file
@@ -0,0 +1,35 @@
|
||||
// ColoredShape.h: interface for the CColoredShape class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_COLOREDSHAPES_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)
|
||||
#define AFX_COLOREDSHAPES_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
class CColoredShapes : public CObject
|
||||
{
|
||||
public:
|
||||
CColoredShapes();
|
||||
void Add(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape);
|
||||
|
||||
void Display( Handle(AIS_InteractiveContext)& anAIScontext);
|
||||
|
||||
TopoDS_ListOfShape getShapes();
|
||||
Quantity_NameOfColor getShapeColor(TopoDS_Shape aShape);
|
||||
|
||||
protected:
|
||||
// Declare CArchive >> operator
|
||||
DECLARE_SERIAL(CColoredShapes);
|
||||
|
||||
// mute CObject::Serialize
|
||||
void Serialize(CArchive& ar);
|
||||
|
||||
private:
|
||||
TopTools_DataMapOfShapeInteger m_colorMap;
|
||||
TopoDS_ListOfShape m_shapeList;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_COLOREDSHAPES_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)
|
1695
samples/mfc/standard/05_ImportExport/src/FSD_Archive.cxx
Executable file
1695
samples/mfc/standard/05_ImportExport/src/FSD_Archive.cxx
Executable file
File diff suppressed because it is too large
Load Diff
276
samples/mfc/standard/05_ImportExport/src/FSD_Archive.hxx
Executable file
276
samples/mfc/standard/05_ImportExport/src/FSD_Archive.hxx
Executable file
@@ -0,0 +1,276 @@
|
||||
// File generated by CPPExt (Value)
|
||||
// Copyright (C) 1991,1995 by
|
||||
//
|
||||
// MATRA DATAVISION, FRANCE
|
||||
//
|
||||
// This software is furnished in accordance with the terms and conditions
|
||||
// of the contract and with the inclusion of the above copyright notice.
|
||||
// This software or any other copy thereof may not be provided or otherwise
|
||||
// be made available to any other person. No title to an ownership of the
|
||||
// software is hereby transferred.
|
||||
//
|
||||
// At the termination of the contract, the software and all copies of this
|
||||
// software must be deleted.
|
||||
|
||||
#ifndef _FSD_Archive_HeaderFile
|
||||
#define _FSD_Archive_HeaderFile
|
||||
|
||||
#ifndef _FSD_CArchive_HeaderFile
|
||||
#include <FSD_CArchive.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Address_HeaderFile
|
||||
#include <Standard_Address.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_BaseDriver_HeaderFile
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_Error_HeaderFile
|
||||
#include <Storage_Error.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_OpenMode_HeaderFile
|
||||
#include <Storage_OpenMode.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Character_HeaderFile
|
||||
#include <Standard_Character.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_ExtCharacter_HeaderFile
|
||||
#include <Standard_ExtCharacter.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_ShortReal_HeaderFile
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_CString_HeaderFile
|
||||
#include <Standard_CString.hxx>
|
||||
#endif
|
||||
class Storage_StreamTypeMismatchError;
|
||||
class Storage_StreamFormatError;
|
||||
class Storage_StreamWriteError;
|
||||
class Storage_StreamExtCharParityError;
|
||||
class TCollection_AsciiString;
|
||||
class TCollection_ExtendedString;
|
||||
class TColStd_SequenceOfAsciiString;
|
||||
class TColStd_SequenceOfExtendedString;
|
||||
class Storage_BaseDriver;
|
||||
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
class FSD_Archive : public Storage_BaseDriver {
|
||||
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
// Methods PUBLIC
|
||||
//
|
||||
Standard_EXPORT virtual long Tell();
|
||||
|
||||
Standard_EXPORT FSD_Archive();
|
||||
Standard_EXPORT FSD_Archive(const FSD_CArchive& anArchive);
|
||||
Standard_EXPORT Storage_Error Open(const TCollection_AsciiString& aName,const Storage_OpenMode aMode) ;
|
||||
Standard_EXPORT Standard_Boolean IsEnd() ;
|
||||
Standard_EXPORT static Storage_Error IsGoodFileType(const TCollection_AsciiString& aName) ;
|
||||
Standard_EXPORT Storage_Error BeginWriteInfoSection() ;
|
||||
Standard_EXPORT void WriteInfo(const Standard_Integer nbObj,const TCollection_AsciiString& dbVersion,const TCollection_AsciiString& date,const TCollection_AsciiString& schemaName,const TCollection_AsciiString& schemaVersion,const TCollection_ExtendedString& appName,const TCollection_AsciiString& appVersion,const TCollection_ExtendedString& objectType,const TColStd_SequenceOfAsciiString& userInfo) ;
|
||||
Standard_EXPORT Storage_Error EndWriteInfoSection() ;
|
||||
Standard_EXPORT Storage_Error BeginReadInfoSection() ;
|
||||
Standard_EXPORT void ReadInfo(Standard_Integer& nbObj,TCollection_AsciiString& dbVersion,TCollection_AsciiString& date,TCollection_AsciiString& schemaName,TCollection_AsciiString& schemaVersion,TCollection_ExtendedString& appName,TCollection_AsciiString& appVersion,TCollection_ExtendedString& objectType,TColStd_SequenceOfAsciiString& userInfo) ;
|
||||
Standard_EXPORT Storage_Error EndReadInfoSection() ;
|
||||
Standard_EXPORT Storage_Error BeginWriteCommentSection() ;
|
||||
Standard_EXPORT void WriteComment(const TColStd_SequenceOfExtendedString& userComments) ;
|
||||
Standard_EXPORT Storage_Error EndWriteCommentSection() ;
|
||||
Standard_EXPORT Storage_Error BeginReadCommentSection() ;
|
||||
Standard_EXPORT void ReadComment(TColStd_SequenceOfExtendedString& userComments) ;
|
||||
Standard_EXPORT Storage_Error EndReadCommentSection() ;
|
||||
Standard_EXPORT Storage_Error BeginWriteTypeSection() ;
|
||||
Standard_EXPORT void SetTypeSectionSize(const Standard_Integer aSize) ;
|
||||
Standard_EXPORT void WriteTypeInformations(const Standard_Integer typeNum,const TCollection_AsciiString& typeName) ;
|
||||
Standard_EXPORT Storage_Error EndWriteTypeSection() ;
|
||||
Standard_EXPORT Storage_Error BeginReadTypeSection() ;
|
||||
Standard_EXPORT Standard_Integer TypeSectionSize() ;
|
||||
Standard_EXPORT void ReadTypeInformations(Standard_Integer& typeNum,TCollection_AsciiString& typeName) ;
|
||||
Standard_EXPORT Storage_Error EndReadTypeSection() ;
|
||||
Standard_EXPORT Storage_Error BeginWriteRootSection() ;
|
||||
Standard_EXPORT void SetRootSectionSize(const Standard_Integer aSize) ;
|
||||
Standard_EXPORT void WriteRoot(const TCollection_AsciiString& rootName,const Standard_Integer aRef,const TCollection_AsciiString& aType) ;
|
||||
Standard_EXPORT Storage_Error EndWriteRootSection() ;
|
||||
Standard_EXPORT Storage_Error BeginReadRootSection() ;
|
||||
Standard_EXPORT Standard_Integer RootSectionSize() ;
|
||||
Standard_EXPORT void ReadRoot(TCollection_AsciiString& rootName,Standard_Integer& aRef,TCollection_AsciiString& aType) ;
|
||||
Standard_EXPORT Storage_Error EndReadRootSection() ;
|
||||
Standard_EXPORT Storage_Error BeginWriteRefSection() ;
|
||||
Standard_EXPORT void SetRefSectionSize(const Standard_Integer aSize) ;
|
||||
Standard_EXPORT void WriteReferenceType(const Standard_Integer reference,const Standard_Integer typeNum) ;
|
||||
Standard_EXPORT Storage_Error EndWriteRefSection() ;
|
||||
Standard_EXPORT Storage_Error BeginReadRefSection() ;
|
||||
Standard_EXPORT Standard_Integer RefSectionSize() ;
|
||||
Standard_EXPORT void ReadReferenceType(Standard_Integer& reference,Standard_Integer& typeNum) ;
|
||||
Standard_EXPORT Storage_Error EndReadRefSection() ;
|
||||
Standard_EXPORT Storage_Error BeginWriteDataSection() ;
|
||||
Standard_EXPORT void WritePersistentObjectHeader(const Standard_Integer aRef,const Standard_Integer aType) ;
|
||||
Standard_EXPORT void BeginWritePersistentObjectData() ;
|
||||
Standard_EXPORT void BeginWriteObjectData() ;
|
||||
Standard_EXPORT void EndWriteObjectData() ;
|
||||
Standard_EXPORT void EndWritePersistentObjectData() ;
|
||||
Standard_EXPORT Storage_Error EndWriteDataSection() ;
|
||||
Standard_EXPORT Storage_Error BeginReadDataSection() ;
|
||||
Standard_EXPORT void ReadPersistentObjectHeader(Standard_Integer& aRef,Standard_Integer& aType) ;
|
||||
Standard_EXPORT void BeginReadPersistentObjectData() ;
|
||||
Standard_EXPORT void BeginReadObjectData() ;
|
||||
Standard_EXPORT void EndReadObjectData() ;
|
||||
Standard_EXPORT void EndReadPersistentObjectData() ;
|
||||
Standard_EXPORT Storage_Error EndReadDataSection() ;
|
||||
Standard_EXPORT void SkipObject() ;
|
||||
Standard_EXPORT Storage_BaseDriver& PutReference(const Standard_Integer aValue) ;
|
||||
Standard_EXPORT Storage_BaseDriver& PutCharacter(const Standard_Character aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Character aValue)
|
||||
{
|
||||
return PutCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& PutExtCharacter(const Standard_ExtCharacter aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_ExtCharacter aValue)
|
||||
{
|
||||
return PutExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& PutInteger(const Standard_Integer aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Integer aValue)
|
||||
{
|
||||
return PutInteger(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& PutBoolean(const Standard_Boolean aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Boolean aValue)
|
||||
{
|
||||
return PutBoolean(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& PutReal(const Standard_Real aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_Real aValue)
|
||||
{
|
||||
return PutReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& PutShortReal(const Standard_ShortReal aValue) ;
|
||||
Storage_BaseDriver& operator <<(const Standard_ShortReal aValue)
|
||||
{
|
||||
return PutShortReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& GetReference(Standard_Integer& aValue) ;
|
||||
Standard_EXPORT Storage_BaseDriver& GetCharacter(Standard_Character& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Character& aValue)
|
||||
{
|
||||
return GetCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& GetExtCharacter(Standard_ExtCharacter& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_ExtCharacter& aValue)
|
||||
{
|
||||
return GetExtCharacter(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& GetInteger(Standard_Integer& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Integer& aValue)
|
||||
{
|
||||
return GetInteger(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& GetBoolean(Standard_Boolean& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Boolean& aValue)
|
||||
{
|
||||
return GetBoolean(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& GetReal(Standard_Real& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_Real& aValue)
|
||||
{
|
||||
return GetReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_BaseDriver& GetShortReal(Standard_ShortReal& aValue) ;
|
||||
Storage_BaseDriver& operator >>(Standard_ShortReal& aValue)
|
||||
{
|
||||
return GetShortReal(aValue);
|
||||
}
|
||||
|
||||
Standard_EXPORT Storage_Error Close() ;
|
||||
Standard_EXPORT void Destroy() ;
|
||||
~FSD_Archive()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Methods PROTECTED
|
||||
//
|
||||
Standard_EXPORT void ReadLine(TCollection_AsciiString& buffer) ;
|
||||
Standard_EXPORT void WriteLine(const TCollection_AsciiString& buffer) ;
|
||||
Standard_EXPORT void ReadExtendedLine(TCollection_ExtendedString& buffer) ;
|
||||
Standard_EXPORT void WriteExtendedLine(const TCollection_ExtendedString& buffer) ;
|
||||
Standard_EXPORT void ReadChar(TCollection_AsciiString& buffer,const Standard_Integer rsize) ;
|
||||
Standard_EXPORT Storage_Error FindTag(const Standard_CString aTag) ;
|
||||
|
||||
|
||||
// Fields PROTECTED
|
||||
//
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Methods PRIVATE
|
||||
//
|
||||
Standard_EXPORT static const Standard_CString MagicNumber() ;
|
||||
|
||||
|
||||
// Fields PRIVATE
|
||||
//
|
||||
FSD_CArchive myStream;
|
||||
Standard_Address myCFile;
|
||||
Standard_Boolean myEof;
|
||||
Standard_Boolean myExternFlag;
|
||||
Standard_Boolean myFormat;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// other Inline functions and methods (like "C++: function call" methods)
|
||||
//
|
||||
|
||||
|
||||
#endif
|
19
samples/mfc/standard/05_ImportExport/src/FSD_Archive.ixx
Executable file
19
samples/mfc/standard/05_ImportExport/src/FSD_Archive.ixx
Executable file
@@ -0,0 +1,19 @@
|
||||
// File generated by CPPExt (Value)
|
||||
// Copyright (C) 1991,1995 by
|
||||
//
|
||||
// MATRA DATAVISION, FRANCE
|
||||
//
|
||||
// This software is furnished in accordance with the terms and conditions
|
||||
// of the contract and with the inclusion of the above copyright notice.
|
||||
// This software or any other copy thereof may not be provided or otherwise
|
||||
// be made available to any other person. No title to an ownership of the
|
||||
// software is hereby transferred.
|
||||
//
|
||||
// At the termination of the contract, the software and all copies of this
|
||||
// software must be deleted.
|
||||
//
|
||||
#include <FSD_Archive.jxx>
|
||||
|
||||
|
||||
|
||||
|
30
samples/mfc/standard/05_ImportExport/src/FSD_Archive.jxx
Executable file
30
samples/mfc/standard/05_ImportExport/src/FSD_Archive.jxx
Executable file
@@ -0,0 +1,30 @@
|
||||
#ifndef _Storage_StreamTypeMismatchError_HeaderFile
|
||||
#include <Storage_StreamTypeMismatchError.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_StreamFormatError_HeaderFile
|
||||
#include <Storage_StreamFormatError.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_StreamWriteError_HeaderFile
|
||||
#include <Storage_StreamWriteError.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_StreamExtCharParityError_HeaderFile
|
||||
#include <Storage_StreamExtCharParityError.hxx>
|
||||
#endif
|
||||
#ifndef _TCollection_AsciiString_HeaderFile
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#endif
|
||||
#ifndef _TCollection_ExtendedString_HeaderFile
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#endif
|
||||
#ifndef _TColStd_SequenceOfAsciiString_HeaderFile
|
||||
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||
#endif
|
||||
#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
|
||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
||||
#endif
|
||||
#ifndef _Storage_BaseDriver_HeaderFile
|
||||
#include <Storage_BaseDriver.hxx>
|
||||
#endif
|
||||
#ifndef _FSD_Archive_HeaderFile
|
||||
#include <FSD_Archive.hxx>
|
||||
#endif
|
15
samples/mfc/standard/05_ImportExport/src/FSD_CArchive.hxx
Executable file
15
samples/mfc/standard/05_ImportExport/src/FSD_CArchive.hxx
Executable file
@@ -0,0 +1,15 @@
|
||||
#ifndef _FSD_CArchive_HeaderFile
|
||||
#define _FSD_CArchive_HeaderFile
|
||||
|
||||
#ifdef WNT
|
||||
|
||||
//#define _MBCS
|
||||
|
||||
#include <afx.h>
|
||||
|
||||
typedef CArchive* FSD_CArchive;
|
||||
#else
|
||||
typedef void* FSD_CArchive;
|
||||
#endif
|
||||
|
||||
#endif
|
15
samples/mfc/standard/05_ImportExport/src/FSD_CFile.hxx
Executable file
15
samples/mfc/standard/05_ImportExport/src/FSD_CFile.hxx
Executable file
@@ -0,0 +1,15 @@
|
||||
#ifndef _FSD_CFile_HeaderFile
|
||||
#define _FSD_CFile_HeaderFile
|
||||
|
||||
#ifdef WNT
|
||||
|
||||
//#define _MBCS
|
||||
|
||||
#include <afx.h>
|
||||
|
||||
typedef CFile FSD_CFile;
|
||||
#else
|
||||
typedef void* FSD_CFile;
|
||||
#endif
|
||||
|
||||
#endif
|
153
samples/mfc/standard/05_ImportExport/src/ImportExportApp.cpp
Executable file
153
samples/mfc/standard/05_ImportExport/src/ImportExportApp.cpp
Executable file
@@ -0,0 +1,153 @@
|
||||
// ImportExportApp.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ImportExportApp.h"
|
||||
|
||||
#include "OCC_MainFrame.h"
|
||||
#include "OCC_3dChildFrame.h"
|
||||
#include "ImportExportDoc.h"
|
||||
#include <OCC_3dView.h>
|
||||
#include <res\resource.h>
|
||||
|
||||
BEGIN_MESSAGE_MAP(CImportExportApp, OCC_3dApp)
|
||||
//{{AFX_MSG_MAP(CSerializeApp)
|
||||
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportApp construction
|
||||
|
||||
CImportExportApp::CImportExportApp()
|
||||
{
|
||||
// Set the local system units
|
||||
try
|
||||
{ UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); }
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
AfxMessageBox("Fatal Error in units initialisation");
|
||||
}
|
||||
SampleName = "ImportExport"; //for about dialog
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CImportExportApp object
|
||||
|
||||
CImportExportApp theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportApp initialization
|
||||
|
||||
BOOL CImportExportApp::InitInstance()
|
||||
{
|
||||
AfxEnableControlContainer();
|
||||
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
// Change the registry key under which our settings are stored.
|
||||
// You should modify this string to be something appropriate
|
||||
// such as the name of your company or organization.
|
||||
// Modified by CasCade :
|
||||
SetRegistryKey(_T("Local CasCade Applications"));
|
||||
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CMultiDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CMultiDocTemplate(
|
||||
IDR_3DTYPE,
|
||||
RUNTIME_CLASS(CImportExportDoc),
|
||||
RUNTIME_CLASS(OCC_3dChildFrame),
|
||||
RUNTIME_CLASS(OCC_3dView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
// create main MDI Frame window
|
||||
OCC_MainFrame* pMainFrame = new OCC_MainFrame(with_AIS_TB);
|
||||
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
|
||||
return FALSE;
|
||||
m_pMainWnd = pMainFrame;
|
||||
|
||||
// Parse command line for standard shell commands, DDE, file open
|
||||
CCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo))
|
||||
return FALSE;
|
||||
|
||||
// The main window has been initialized, so show and update it.
|
||||
pMainFrame->ShowWindow(m_nCmdShow);
|
||||
pMainFrame->UpdateWindow();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CDocument* CImportExportApp::OpenDocumentFile(LPCTSTR lpszFileName)
|
||||
{
|
||||
CFile cf;
|
||||
|
||||
if (!cf.Open(lpszFileName,CFile::modeReadWrite)){
|
||||
AfxMessageBox("File not found!");
|
||||
return NULL;
|
||||
}
|
||||
cf.Close();
|
||||
return CWinApp::OpenDocumentFile(lpszFileName);
|
||||
}
|
||||
|
||||
void CImportExportApp::OnFileOpen()
|
||||
{
|
||||
CFileDialog dlg(TRUE,
|
||||
NULL,
|
||||
NULL,
|
||||
OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
|
||||
NULL,
|
||||
NULL );
|
||||
|
||||
|
||||
CString initdir(((OCC_BaseApp*) AfxGetApp())->GetInitDataDir());
|
||||
initdir += "\\Data";
|
||||
|
||||
dlg.m_ofn.lpstrInitialDir = initdir;
|
||||
|
||||
CString strFilter;
|
||||
CString strDefault;
|
||||
|
||||
POSITION pos = GetFirstDocTemplatePosition();
|
||||
|
||||
CDocTemplate* pTemplate = GetNextDocTemplate(pos);
|
||||
CString strFilterExt, strFilterName;
|
||||
if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) &&
|
||||
!strFilterExt.IsEmpty() &&
|
||||
pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) &&
|
||||
!strFilterName.IsEmpty()) {
|
||||
// add to filter
|
||||
strFilter += strFilterName;
|
||||
ASSERT(!strFilter.IsEmpty()); // must have a file type name
|
||||
strFilter += (TCHAR)'\0'; // next string please
|
||||
strFilter += (TCHAR)'*';
|
||||
strFilter += strFilterExt;
|
||||
strFilter += (TCHAR)'\0'; // next string please
|
||||
dlg.m_ofn.nMaxCustFilter++;
|
||||
}
|
||||
// append the "*.*" all files filter
|
||||
CString allFilter;
|
||||
VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
|
||||
strFilter += allFilter;
|
||||
strFilter += (TCHAR)'\0'; // next string please
|
||||
strFilter += _T("*.*");
|
||||
strFilter += (TCHAR)'\0'; // last string
|
||||
dlg.m_ofn.nMaxCustFilter++;
|
||||
dlg.m_ofn.lpstrFilter = strFilter;
|
||||
|
||||
if (dlg.DoModal() == IDOK)
|
||||
{
|
||||
AfxGetApp()->OpenDocumentFile(dlg.GetPathName());
|
||||
}
|
||||
}
|
34
samples/mfc/standard/05_ImportExport/src/ImportExportApp.h
Executable file
34
samples/mfc/standard/05_ImportExport/src/ImportExportApp.h
Executable file
@@ -0,0 +1,34 @@
|
||||
// ImportExportApp.h : main header file for the IMPORTEXPORT application
|
||||
//
|
||||
|
||||
#if !defined(AFX_IMPORTEXPORT_H__88A21474_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
||||
#define AFX_IMPORTEXPORT_H__88A21474_3B23_11D2_8E1E_0800369C8A03__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include <OCC_3dApp.h>
|
||||
|
||||
class CImportExportApp : public OCC_3dApp
|
||||
{
|
||||
public:
|
||||
CImportExportApp();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CImportExportApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName);
|
||||
//}}AFX_VIRTUAL
|
||||
protected:
|
||||
//{{AFX_MSG(CSerializeApp)
|
||||
afx_msg void OnFileOpen();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // !defined(AFX_IMPORTEXPORT_H__88A21474_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
286
samples/mfc/standard/05_ImportExport/src/ImportExportDoc.cpp
Executable file
286
samples/mfc/standard/05_ImportExport/src/ImportExportDoc.cpp
Executable file
@@ -0,0 +1,286 @@
|
||||
// ImportExportDoc.cpp : implementation of the CImportExportDoc class
|
||||
//
|
||||
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ImportExportApp.h"
|
||||
|
||||
#include "ImportExportDoc.h"
|
||||
|
||||
#include <ImportExport/ImportExport.h>
|
||||
|
||||
#include <AISDialogs.h>
|
||||
#include "res/resource.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#define new DEBUG_NEW // by cascade
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CImportExportDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CImportExportDoc, OCC_3dBaseDoc)
|
||||
//{{AFX_MSG_MAP(CImportExportDoc)
|
||||
ON_COMMAND(ID_FILE_IMPORT_BREP, OnFileImportBrep)
|
||||
ON_COMMAND(ID_FILE_IMPORT_CSFDB, OnFileImportCSFDB)
|
||||
ON_COMMAND(ID_FILE_EXPORT_CSFDB, OnFileExportCSFDB)
|
||||
ON_COMMAND(ID_FILE_IMPORT_IGES, OnFileImportIges)
|
||||
ON_COMMAND(ID_FILE_EXPORT_IGES, OnFileExportIges)
|
||||
ON_COMMAND(ID_FILE_IMPORT_STEP, OnFileImportStep)
|
||||
ON_COMMAND(ID_FILE_EXPORT_STEP, OnFileExportStep)
|
||||
ON_COMMAND(ID_FILE_EXPORT_VRML, OnFileExportVrml)
|
||||
ON_COMMAND(ID_FILE_EXPORT_STL, OnFileExportStl)
|
||||
ON_COMMAND(ID_BOX, OnBox)
|
||||
ON_COMMAND(ID_Cylinder, OnCylinder)
|
||||
//}}AFX_MSG_MAP
|
||||
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc construction/destruction
|
||||
|
||||
CImportExportDoc::CImportExportDoc()
|
||||
{
|
||||
/*
|
||||
Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
|
||||
((CImportExportApp*)AfxGetApp())->GetGraphicDevice();
|
||||
|
||||
TCollection_ExtendedString a3DName("Visu3D");
|
||||
myViewer = new V3d_Viewer(theGraphicDevice,a3DName.ToExtString(),"", 1000.0,
|
||||
V3d_XposYnegZpos, Quantity_NOC_GRAY30,
|
||||
V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
|
||||
Standard_True, Standard_False);
|
||||
|
||||
myViewer->SetDefaultLights();
|
||||
myViewer->SetLightOn();
|
||||
|
||||
myAISContext =new AIS_InteractiveContext(myViewer);
|
||||
|
||||
*/
|
||||
/*
|
||||
// TRIHEDRON
|
||||
Handle(AIS_Trihedron) aTrihedron;
|
||||
Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
|
||||
aTrihedron=new AIS_Trihedron(aTrihedronAxis);
|
||||
myAISContext->Display(aTrihedron);
|
||||
*/
|
||||
|
||||
m_pcoloredshapeList = new CColoredShapes();
|
||||
}
|
||||
|
||||
CImportExportDoc::~CImportExportDoc()
|
||||
{
|
||||
if( m_pcoloredshapeList ) delete m_pcoloredshapeList;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSerializeDoc serialization
|
||||
|
||||
void CImportExportDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// Put the curent CColoredShape in the archive
|
||||
ar << m_pcoloredshapeList;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read from the archive the current CColoredShape
|
||||
ar >> m_pcoloredshapeList;
|
||||
|
||||
// Display the new object
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void CImportExportDoc::OnWindowNew3d()
|
||||
{
|
||||
((CImportExportApp*)AfxGetApp())->CreateView3D(this);
|
||||
}
|
||||
*/
|
||||
|
||||
// nCmdShow could be : ( default is SW_RESTORE )
|
||||
// SW_HIDE SW_SHOWNORMAL SW_NORMAL
|
||||
// SW_SHOWMINIMIZED SW_SHOWMAXIMIZED
|
||||
// SW_MAXIMIZE SW_SHOWNOACTIVATE
|
||||
// SW_SHOW SW_MINIMIZE
|
||||
// SW_SHOWMINNOACTIVE SW_SHOWNA
|
||||
// SW_RESTORE SW_SHOWDEFAULT
|
||||
// SW_MAX
|
||||
|
||||
// use pViewClass = RUNTIME_CLASS( CImportExportView3D ) for 3D Views
|
||||
|
||||
void CImportExportDoc::ActivateFrame(CRuntimeClass* pViewClass,int nCmdShow)
|
||||
{
|
||||
POSITION position = GetFirstViewPosition();
|
||||
while (position != (POSITION)NULL)
|
||||
{
|
||||
CView* pCurrentView = (CView*)GetNextView(position);
|
||||
if(pCurrentView->IsKindOf(pViewClass) )
|
||||
{
|
||||
ASSERT_VALID(pCurrentView);
|
||||
CFrameWnd* pParentFrm = pCurrentView->GetParentFrame();
|
||||
ASSERT(pParentFrm != (CFrameWnd *)NULL);
|
||||
// simply make the frame window visible
|
||||
pParentFrm->ActivateFrame(nCmdShow);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CImportExportDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CImportExportDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc commands
|
||||
|
||||
|
||||
void CImportExportDoc::OnFileImportBrep()
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) aSeqOfShape = CImportExport::ReadBREP();
|
||||
for(int i=1;i<= aSeqOfShape->Length();i++)
|
||||
{
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, aSeqOfShape->Value(i));
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
Fit();
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnFileImportCSFDB()
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) aSeqOfShape = CImportExport::ReadCSFDB();
|
||||
for(int i=1;i<= aSeqOfShape->Length();i++)
|
||||
{
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, aSeqOfShape->Value(i));
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
Fit();
|
||||
}
|
||||
void CImportExportDoc::OnFileExportCSFDB()
|
||||
{ CImportExport::SaveCSFDB(myAISContext);}
|
||||
|
||||
void CImportExportDoc::OnFileImportIges()
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) aSeqOfShape = CImportExport::ReadIGES();
|
||||
for(int i=1;i<= aSeqOfShape->Length();i++)
|
||||
{
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, aSeqOfShape->Value(i));
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
Fit();
|
||||
}
|
||||
void CImportExportDoc::OnFileExportIges()
|
||||
{ CImportExport::SaveIGES(myAISContext);}
|
||||
|
||||
void CImportExportDoc::OnFileImportStep()
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) aSeqOfShape = CImportExport::ReadSTEP();
|
||||
for(int i=1;i<= aSeqOfShape->Length();i++)
|
||||
{
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, aSeqOfShape->Value(i));
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
Fit();
|
||||
}
|
||||
void CImportExportDoc::OnFileExportStep()
|
||||
{ CImportExport::SaveSTEP(myAISContext);}
|
||||
|
||||
|
||||
void CImportExportDoc::OnFileExportVrml()
|
||||
{ CImportExport::SaveVRML(myAISContext);}
|
||||
|
||||
void CImportExportDoc::OnFileExportStl()
|
||||
{ CImportExport::SaveSTL(myAISContext);}
|
||||
|
||||
void CImportExportDoc::Popup(const Standard_Integer x,
|
||||
const Standard_Integer y ,
|
||||
const Handle(V3d_View)& aView )
|
||||
{
|
||||
Standard_Integer PopupMenuNumber=0;
|
||||
myAISContext->InitCurrent();
|
||||
if (myAISContext->MoreCurrent())
|
||||
PopupMenuNumber=1;
|
||||
|
||||
CMenu menu;
|
||||
VERIFY(menu.LoadMenu(IDR_Popup3D));
|
||||
CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber);
|
||||
|
||||
ASSERT(pPopup != NULL);
|
||||
if (PopupMenuNumber == 1) // more than 1 object.
|
||||
{
|
||||
bool OneOrMoreInShading = false;
|
||||
for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
|
||||
if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true;
|
||||
if(!OneOrMoreInShading)
|
||||
pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
|
||||
POINT winCoord = { x , y };
|
||||
Handle(WNT_Window) aWNTWindow=
|
||||
Handle(WNT_Window)::DownCast(aView->Window());
|
||||
ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord);
|
||||
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y ,
|
||||
AfxGetMainWnd());
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnBox()
|
||||
{
|
||||
AIS_ListOfInteractive aList;
|
||||
myAISContext->DisplayedObjects(aList);
|
||||
AIS_ListIteratorOfListOfInteractive aListIterator;
|
||||
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
|
||||
myAISContext->Remove(aListIterator.Value());
|
||||
}
|
||||
|
||||
BRepPrimAPI_MakeBox B(200.,150.,100.);
|
||||
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, B.Shape());
|
||||
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
Fit();
|
||||
|
||||
// document has been modified
|
||||
SetModifiedFlag(TRUE);
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnCylinder()
|
||||
{
|
||||
AIS_ListOfInteractive aList;
|
||||
myAISContext->DisplayedObjects(aList);
|
||||
AIS_ListIteratorOfListOfInteractive aListIterator;
|
||||
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
|
||||
myAISContext->Remove(aListIterator.Value());
|
||||
}
|
||||
|
||||
BRepPrimAPI_MakeCylinder C(50.,200.);
|
||||
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_GREEN, C.Shape());
|
||||
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
Fit();
|
||||
|
||||
// document has been modified
|
||||
SetModifiedFlag(TRUE);
|
||||
}
|
62
samples/mfc/standard/05_ImportExport/src/ImportExportDoc.h
Executable file
62
samples/mfc/standard/05_ImportExport/src/ImportExportDoc.h
Executable file
@@ -0,0 +1,62 @@
|
||||
// ImportExportDoc.h : interface of the CImportExportDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_IMPORTEXPORTDOC_H__88A2147C_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
||||
#define AFX_IMPORTEXPORTDOC_H__88A2147C_3B23_11D2_8E1E_0800369C8A03__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include <ColoredShapes.h>
|
||||
#include <OCC_3dBaseDoc.h>
|
||||
|
||||
class CImportExportDoc : public OCC_3dBaseDoc{
|
||||
DECLARE_DYNCREATE(CImportExportDoc)
|
||||
public:
|
||||
CImportExportDoc();
|
||||
virtual ~CImportExportDoc();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
|
||||
void ActivateFrame(CRuntimeClass* pViewClass, int nCmdShow = SW_RESTORE );
|
||||
virtual void Popup (const Standard_Integer x ,
|
||||
const Standard_Integer y ,
|
||||
const Handle(V3d_View)& aView );
|
||||
|
||||
|
||||
// Implementation
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CImportExportDoc)
|
||||
afx_msg void OnFileImportCSFDB();
|
||||
afx_msg void OnFileExportCSFDB();
|
||||
afx_msg void OnFileImportIges();
|
||||
afx_msg void OnFileExportIges();
|
||||
afx_msg void OnFileImportStep();
|
||||
afx_msg void OnFileExportStep();
|
||||
afx_msg void OnFileImportBrep();
|
||||
// afx_msg void OnWindowNew3d();
|
||||
afx_msg void OnFileExportVrml();
|
||||
afx_msg void OnFileExportStl();
|
||||
afx_msg void OnBox();
|
||||
afx_msg void OnCylinder();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
//Attributes
|
||||
protected:
|
||||
CColoredShapes* m_pcoloredshapeList;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_IMPORTEXPORTDOC_H__88A2147C_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
6
samples/mfc/standard/05_ImportExport/src/StdAfx.cpp
Executable file
6
samples/mfc/standard/05_ImportExport/src/StdAfx.cpp
Executable file
@@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// SampleImportExport.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
197
samples/mfc/standard/05_ImportExport/src/StdAfx.h
Executable file
197
samples/mfc/standard/05_ImportExport/src/StdAfx.h
Executable file
@@ -0,0 +1,197 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__88A21476_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
||||
#define AFX_STDAFX_H__88A21476_3B23_11D2_8E1E_0800369C8A03__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#include <afxdisp.h> // MFC OLE automation classes
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
|
||||
#if !defined(WNT)
|
||||
#error WNT precompiler directive is mandatory for CasCade
|
||||
#endif
|
||||
#if !defined(CSFDB)
|
||||
#error CSFDB precompiler directive is mandatory for CasCade
|
||||
#endif
|
||||
|
||||
#define DEFAULT_DEVIATIONCOEFFICIENT 0.001
|
||||
#define DEFAULT_DCBIG 0.005
|
||||
#define DEFAULT_DCVBIG 0.01
|
||||
#define DEFAULT_DCSMALL 0.0002
|
||||
#define DEFAULT_DCVSMALL 0.00004
|
||||
#define DEFAULT_COLOR Quantity_NOC_CYAN1
|
||||
#define DEFAULT_MATERIAL Graphic3d_NOM_PLASTER
|
||||
#define DEFAULT_BACKGROUNDCOLOR Quantity_NOC_MATRAGRAY
|
||||
#define DEFAULT_HILIGHTCOLOR Quantity_NOC_YELLOW
|
||||
|
||||
#pragma warning( disable : 4244 ) // Issue warning 4244
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#pragma warning( default : 4244 ) // Issue warning 4244
|
||||
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_Trihedron.hxx>
|
||||
|
||||
#include <Aspect_Background.hxx>
|
||||
#include <Aspect_TypeOfline.hxx>
|
||||
#include <Aspect_TypeOfText.hxx>
|
||||
#include <Aspect_WidthOfline.hxx>
|
||||
#include <Aspect_Window.hxx>
|
||||
#include <Bnd_Box2d.hxx>
|
||||
#include <BndLib_Add2dCurve.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <BRepBuilderAPI.hxx>
|
||||
#include <BRepAlgo.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <DsgPrs_LengthPresentation.hxx>
|
||||
#include <GCE2d_MakeSegment.hxx>
|
||||
#include <GCPnts_TangentialDeflection.hxx>
|
||||
#include <Geom_CartesianPoint.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 <Graphic3d_WNTGraphicDevice.hxx>
|
||||
#include <MMgt_TShared.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <PrsMgr_PresentationManager2d.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 <SelectBasics_BasicTool.hxx>
|
||||
#include <SelectBasics_ListOfBox2d.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <SelectMgr_SelectableObject.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <SelectMgr_SelectionManager.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 <StdPrs_Curve.hxx>
|
||||
#include <StdPrs_Point.hxx>
|
||||
#include <StdPrs_PoleCurve.hxx>
|
||||
#include <StdSelect_SensitiveText2d.hxx>
|
||||
#include <StdSelect_TextProjector2d.hxx>
|
||||
#include <StdSelect_ViewerSelector2d.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 <TopTools_DataMapOfShapeInteger.hxx>
|
||||
#include <UnitsAPI.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
#include <WNT_WDriver.hxx>
|
||||
#include <WNT_Window.hxx>
|
||||
|
||||
// specific STEP
|
||||
|
||||
#include <STEPControl_Controller.hxx>
|
||||
#include <STEPControl_Reader.hxx>
|
||||
#include <STEPControl_Writer.hxx>
|
||||
|
||||
|
||||
// specific IGES
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
|
||||
#include <IGESControl_Controller.hxx>
|
||||
#include <IGESControl_Writer.hxx>
|
||||
|
||||
#include <IGESToBRep_Actor.hxx>
|
||||
#include <IGESToBRep_Reader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
|
||||
// specific CSFDB
|
||||
#include <FSD_File.hxx>
|
||||
#include <MgtBRep.hxx>
|
||||
#include <MgtBRep_TriangleMode.hxx>
|
||||
//#include <MgtBRep_PurgeMode.hxx>
|
||||
#include <PTColStd_PersistentTransientMap.hxx>
|
||||
#include <PTColStd_TransientPersistentMap.hxx>
|
||||
#include <PTopoDS_HShape.hxx>
|
||||
#include <Storage_Data.hxx>
|
||||
#include <Storage_Error.hxx>
|
||||
#include <Storage_HSeqOfRoot.hxx>
|
||||
#include <Storage_Root.hxx>
|
||||
|
||||
#include <STEPControl_StepModelType.hxx>
|
||||
|
||||
//#include <TransferBRep_Analyzer.hxx>
|
||||
|
||||
// specific STL VRML
|
||||
#include "StlAPI_Writer.hxx"
|
||||
#include "VrmlAPI_Writer.hxx"
|
||||
|
||||
//End CasCade
|
||||
|
||||
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__88A21476_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
Reference in New Issue
Block a user