1 |
francois |
283 |
//------------------------------------------------------------ |
2 |
|
|
//------------------------------------------------------------ |
3 |
|
|
// MAGiC |
4 |
|
|
// Jean Christophe Cuilli�re et Vincent FRANCOIS |
5 |
|
|
// D�partement de G�nie M�canique - UQTR |
6 |
|
|
//------------------------------------------------------------ |
7 |
|
|
// Le projet MAGIC est un projet de recherche du d�partement |
8 |
|
|
// de g�nie m�canique de l'Universit� du Qu�bec � |
9 |
|
|
// Trois Rivi�res |
10 |
|
|
// Les librairies ne peuvent �tre utilis�es sans l'accord |
11 |
|
|
// des auteurs (contact : francois@uqtr.ca) |
12 |
|
|
//------------------------------------------------------------ |
13 |
|
|
//------------------------------------------------------------ |
14 |
|
|
// |
15 |
|
|
// OCC_fonction1.cpp |
16 |
|
|
// |
17 |
|
|
//------------------------------------------------------------ |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
// COPYRIGHT 2000 |
20 |
|
|
// Version du 02/03/2006 � 11H22 |
21 |
|
|
//------------------------------------------------------------ |
22 |
|
|
//------------------------------------------------------------ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h" |
26 |
|
|
#ifdef BREP_OCC |
27 |
|
|
#pragma hdrstop |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
#include "occ_fonction1.h" |
31 |
|
|
//--------------------------------------------------------------------------- |
32 |
|
|
#pragma package(smart_init) |
33 |
|
|
//using namespace std; |
34 |
|
|
OCC_FONCTION1::OCC_FONCTION1() |
35 |
|
|
{ |
36 |
|
|
} |
37 |
|
|
OCC_FONCTION1::~OCC_FONCTION1() |
38 |
|
|
{ |
39 |
|
|
} |
40 |
|
|
void OCC_FONCTION1::OuvrirFichier(char* file ) //ouvrir un fichier .brep |
41 |
|
|
{ |
42 |
|
|
|
43 |
|
|
Standard_Boolean result=BRepTools::Read(ashape,file,abuilder); |
44 |
|
|
if (!result) return; |
45 |
|
|
} |
46 |
|
|
void OCC_FONCTION1::OuvrirFichierStep(char* file)//ouvrir un fichier.step |
47 |
|
|
{ |
48 |
|
|
|
49 |
|
|
reader.ReadFile(file); |
50 |
|
|
reader.NbRootsForTransfer(); |
51 |
|
|
reader.TransferRoots(); |
52 |
|
|
ashape = reader.OneShape(); |
53 |
|
|
//Standard_Boolean result=BRepTools::Read(ashape,file,abuilder); |
54 |
|
|
//if(!result) return; |
55 |
|
|
|
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
void OCC_FONCTION1::Sauvegarder(char* file) |
59 |
|
|
{ |
60 |
|
|
|
61 |
|
|
Standard_Boolean result1=BRepTools::Write(ashape, file); |
62 |
|
|
if (!result1) return; |
63 |
|
|
} |
64 |
|
|
//****************************************************************************** |
65 |
|
|
// identificateur CAS.CAD |
66 |
|
|
//****************************************************************************** |
67 |
|
|
void OCC_FONCTION1::ajouterGeometrie(const TopoDS_Shape& shape) |
68 |
|
|
{ |
69 |
|
|
/*if (shape.ShapeType() == TopAbs_VERTEX) |
70 |
|
|
{ |
71 |
|
|
Handle(BRep_TVertex) TV = Handle(BRep_TVertex)::DownCast(shape.TShape()); |
72 |
|
|
BRep_ListIteratorOfListOfPointRepresentation itrp(TV->Points()); |
73 |
|
|
while (itrp.More()) |
74 |
|
|
{ |
75 |
|
|
const Handle(BRep_PointRepresentation)& PR = itrp.Value(); |
76 |
|
|
if (PR->IsPointOnCurve()) |
77 |
|
|
{ |
78 |
|
|
curveset.Add(PR->Curve()); |
79 |
|
|
} |
80 |
|
|
itrp.Next(); |
81 |
|
|
} |
82 |
|
|
} |
83 |
|
|
else if (shape.ShapeType() == TopAbs_EDGE) |
84 |
|
|
{ |
85 |
|
|
// Add the curve geometry |
86 |
|
|
Handle(BRep_TEdge) TE = Handle(BRep_TEdge)::DownCast(shape.TShape()); |
87 |
|
|
BRep_ListIteratorOfListOfCurveRepresentation itrc(TE->Curves()); |
88 |
|
|
while (itrc.More()) |
89 |
|
|
{ |
90 |
|
|
const Handle(BRep_CurveRepresentation)& CR = itrc.Value(); |
91 |
|
|
if (CR->IsCurve3D()) |
92 |
|
|
{ |
93 |
|
|
if (!CR->Curve3D().IsNull()) |
94 |
|
|
{ |
95 |
|
|
curveset.Add(CR->Curve3D()); |
96 |
|
|
} |
97 |
|
|
} |
98 |
|
|
itrc.More(); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
else if (shape.ShapeType() == TopAbs_FACE) |
104 |
|
|
{ |
105 |
|
|
// Add the surface geometry |
106 |
|
|
Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(shape.TShape()); |
107 |
|
|
if (!TF->Surface().IsNull()) mySurfaces.Add(TF->Surface()); |
108 |
|
|
} |
109 |
|
|
*/ |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
|
113 |
|
|
int OCC_FONCTION1::GetID(const TopoDS_Shape &shape) |
114 |
|
|
{ |
115 |
|
|
if (shape.IsNull()) return 0; |
116 |
|
|
myLocations.Add(shape.Location()); |
117 |
|
|
TopoDS_Shape S2 = shape; |
118 |
|
|
S2.Location(TopLoc_Location()); |
119 |
|
|
Standard_Integer index = myShapes.FindIndex(S2); |
120 |
|
|
if (index == 0) |
121 |
|
|
{ |
122 |
|
|
ajouterGeometrie(S2); |
123 |
|
|
for (TopoDS_Iterator its(S2,Standard_False,Standard_False);its.More(); its.Next()) |
124 |
|
|
GetID(its.Value()); |
125 |
|
|
index = myShapes.Add(S2); |
126 |
|
|
} |
127 |
|
|
return index; |
128 |
|
|
|
129 |
|
|
|
130 |
|
|
} |
131 |
|
|
//****************************************************************************** |
132 |
|
|
const TopoDS_Shape& OCC_FONCTION1::GetShape(const int id_shape) |
133 |
|
|
{ |
134 |
|
|
|
135 |
|
|
GetID(ashape); |
136 |
|
|
return myShapes(id_shape); |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
//****************************************************************************** |
140 |
|
|
#endif |