b311480e |
1 | // Created on: 2007-08-04 |
2 | // Created by: Alexander GRIGORIEV |
973c2be1 |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #ifndef VrmlData_ShapeConvert_HeaderFile |
17 | #define VrmlData_ShapeConvert_HeaderFile |
18 | |
19 | #include <VrmlData_Geometry.hxx> |
20 | #include <VrmlData_Appearance.hxx> |
21 | #include <NCollection_List.hxx> |
22 | #include <TopoDS_Shape.hxx> |
23 | |
24 | class VrmlData_Scene; |
25 | class TopoDS_Face; |
857ffd5e |
26 | class Handle(Poly_Triangulation); |
27 | class Handle(Poly_Polygon3D); |
28 | class Handle(VrmlData_Coordinate); |
7fd59977 |
29 | /** |
30 | * Algorithm converting one shape or a set of shapes to VrmlData_Scene. |
31 | */ |
32 | |
33 | class VrmlData_ShapeConvert |
34 | { |
35 | public: |
36 | |
37 | typedef struct { |
38 | TCollection_AsciiString Name; |
39 | TopoDS_Shape Shape; |
40 | Handle(VrmlData_Node) Node; |
41 | } ShapeData; |
42 | |
43 | // ---------- PUBLIC METHODS ---------- |
44 | |
45 | |
46 | /** |
47 | * Constructor. |
48 | * @param theScene |
49 | * Scene receiving all Vrml data. |
50 | * @param theScale |
51 | * Scale factor, considering that VRML standard specifies coordinates in |
52 | * meters. So if your data are in mm, you should provide theScale=0.001 |
53 | */ |
54 | inline VrmlData_ShapeConvert (VrmlData_Scene& theScene, |
55 | const Standard_Real theScale = 1.) |
56 | : myScene (theScene), |
57 | myScale (theScale) |
58 | {} |
59 | |
60 | /** |
61 | * Add one shape to the internal list, may be called several times with |
62 | * different shapes. |
63 | */ |
64 | Standard_EXPORT void AddShape (const TopoDS_Shape& theShape, |
65 | const char * theName = 0L); |
66 | |
67 | /** |
68 | * Convert all accumulated shapes and store them in myScene. |
69 | * The internal data structures are cleared in the end of convertion. |
70 | * @param theExtractFaces |
71 | * If True, converter extracst faces from the shapes. |
72 | * @param theExtractEdges |
73 | * If True, converter extracts edges from the shapes. |
74 | * @param theDeflection |
75 | * Deflection for tessellation of geometrical lines/surfaces. Existing mesh |
76 | * is used if its deflection is smaller than the one given by this |
77 | * parameter. |
78 | * @param theDeflAngle |
79 | * Angular deflection for tessellation of geometrical lines. |
80 | */ |
81 | Standard_EXPORT void Convert (const Standard_Boolean theExtractFaces, |
82 | const Standard_Boolean theExtractEdges, |
83 | const Standard_Real theDeflection = 0.01, |
c6541a0c |
84 | const Standard_Real theDeflAngle = 20.*M_PI/180.); |
7fd59977 |
85 | //this value of theDeflAngle is used by default |
86 | //for tesselation while shading (Drawer->HLRAngle()) |
7fd59977 |
87 | protected: |
88 | // ---------- PROTECTED METHODS ---------- |
89 | |
857ffd5e |
90 | Handle(VrmlData_Geometry) triToIndexedFaceSet |
91 | (const Handle(Poly_Triangulation)&, |
7fd59977 |
92 | const TopoDS_Face&, |
857ffd5e |
93 | const Handle(VrmlData_Coordinate)&); |
7fd59977 |
94 | |
857ffd5e |
95 | Handle(VrmlData_Geometry) polToIndexedLineSet |
96 | (const Handle(Poly_Polygon3D)&); |
7fd59977 |
97 | |
857ffd5e |
98 | Handle(VrmlData_Appearance) defaultMaterialFace () const; |
7fd59977 |
99 | |
857ffd5e |
100 | Handle(VrmlData_Appearance) defaultMaterialEdge () const; |
7fd59977 |
101 | |
102 | private: |
103 | // ---------- PRIVATE FIELDS ---------- |
104 | |
105 | VrmlData_Scene& myScene; |
106 | Standard_Real myScale; |
107 | NCollection_List <ShapeData> myShapes; |
d390b166 |
108 | // ---------- PRIVATE METHODS ---------- |
109 | void operator= (const VrmlData_ShapeConvert&); |
7fd59977 |
110 | }; |
111 | |
112 | #endif |