1 #ifdef OCCGEOMETRY
2 
3 #ifndef FILE_OCCMESHSURF
4 #define FILE_OCCMESHSURF
5 
6 #include "occgeom.hpp"
7 
8 #define PARAMETERSPACE -1
9 #define PLANESPACE     1
10 
11 class OCCGeometry;
12 
13 class SingularMatrixException
14 {};
15 
16 class UVBoundsException
17 {};
18 
19 class OCCSurface
20 {
21 public:
22   TopoDS_Face topods_face;
23   Handle(Geom_Surface) occface;
24   TopAbs_Orientation orient;
25   int projecttype;
26 
27 protected:
28   Point<3> p1;
29   Point<3> p2;
30 
31   /// in plane, directed p1->p2
32   Vec<3> ex;
33   /// in plane
34   Vec<3> ey;
35   /// outer normal direction
36   Vec<3> ez;
37 
38   /// normal vector in p2
39   Vec<3> n2;
40 
41   /// average normal vector
42   Vec<3> nmid;
43 
44   // for transformation to parameter space
45   Point<2> psp1;
46   Point<2> psp2;
47   Vec<2> psex;
48   Vec<2> psey;
49   Mat<2,2> Amat, Amatinv;
50 
51   // UV Bounds
52   double umin, umax, vmin, vmax;
53 
54 public:
OCCSurface(const TopoDS_Face & aface,int aprojecttype)55   OCCSurface (const TopoDS_Face & aface, int aprojecttype)
56   {
57     topods_face = aface;
58     occface = BRep_Tool::Surface(topods_face);
59     orient = topods_face.Orientation();
60     projecttype = aprojecttype;
61     ShapeAnalysis::GetFaceUVBounds (topods_face, umin, umax, vmin, vmax);
62     umin -= fabs(umax-umin)/100.0;
63     vmin -= fabs(vmax-vmin)/100.0;
64     umax += fabs(umax-umin)/100.0;
65     vmax += fabs(vmax-vmin)/100.0;
66     // projecttype = PLANESPACE;
67     /*
68     TopExp_Explorer exp1;
69     exp1.Init (topods_face, TopAbs_WIRE);
70     orient = TopAbs::Compose (orient, exp1.Current().Orientation());
71     */
72   };
73 
~OCCSurface()74   ~OCCSurface()
75   {};
76 
77   void Project (Point<3> & p, PointGeomInfo & gi);
78 
79   void GetNormalVector (const Point<3> & p,
80 			const PointGeomInfo & geominfo,
81 			Vec<3> & n) const;
82 
83   /**
84     Defines tangential plane in ap1.
85     The local x-coordinate axis point to the direction of ap2 */
86   void DefineTangentialPlane (const Point<3> & ap1,
87 			      const PointGeomInfo & geominfo1,
88 			      const Point<3> & ap2,
89 			      const PointGeomInfo & geominfo2);
90 
91 
92   /// Transforms 3d point p3d to local coordinates pplane
93   void ToPlane (const Point<3> & p3d, const PointGeomInfo & geominfo,
94 		Point<2> & pplane, double h, int & zone) const;
95 
96   /// Transforms point pplane in local coordinates to 3d point
97   void FromPlane (const Point<2> & pplane,
98 		  Point<3> & p3d,
99 		  PointGeomInfo & gi,
100 		  double h);
101 };
102 
103 
104 
105 ///
106 class Meshing2OCCSurfaces : public Meshing2
107 {
108   ///
109   OCCSurface surface;
110 
111 
112 public:
113   ///
114   Meshing2OCCSurfaces (const TopoDS_Shape & asurf, const Box<3> & aboundingbox, int aprojecttype);
115 
116   ///
GetProjectionType()117   int GetProjectionType ()
118   { return surface.projecttype; }
119 
120 protected:
121   ///
122   virtual void DefineTransformation (const Point3d & p1, const Point3d & p2,
123 				     const PointGeomInfo * geominfo1,
124 				     const PointGeomInfo * geominfo2);
125   ///
126   virtual void TransformToPlain (const Point3d & locpoint,
127 				 const MultiPointGeomInfo & geominfo,
128 				 Point2d & plainpoint,
129 				 double h, int & zone);
130   ///
131 
132   virtual int TransformFromPlain (Point2d & plainpoint,
133 				  Point3d & locpoint,
134 				  PointGeomInfo & gi,
135 				  double h);
136   ///
137   virtual double CalcLocalH (const Point3d & p, double gh) const;
138 
139 };
140 
141 
142 
143 ///
144 class MeshOptimize2dOCCSurfaces : public MeshOptimize2d
145   {
146   ///
147   const OCCGeometry & geometry;
148 
149 public:
150     ///
151     MeshOptimize2dOCCSurfaces (const OCCGeometry & ageometry);
152 
153     ///
154     virtual void ProjectPoint (INDEX surfind, Point<3> & p) const;
155     ///
156     virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point<3> & p) const;
157     ///
158     virtual int ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const;
159     ///
160     virtual void GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const;
161     ///
162     virtual void GetNormalVector(INDEX surfind, const Point<3> & p, PointGeomInfo & gi, Vec<3> & n) const;
163 
164     virtual int CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point<3> & p3) const;
165 };
166 
167 
168 
169 class OCCGeometry;
170 
171 
172 class OCCRefinementSurfaces : public Refinement
173 {
174   const OCCGeometry & geometry;
175 
176 public:
177   OCCRefinementSurfaces (const OCCGeometry & ageometry);
178   virtual ~OCCRefinementSurfaces ();
179 
180   virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
181 			     int surfi,
182 			     const PointGeomInfo & gi1,
183 			     const PointGeomInfo & gi2,
184 			     Point<3> & newp, PointGeomInfo & newgi) const;
185 
186   virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
187 			     int surfi1, int surfi2,
188 			     const EdgePointGeomInfo & ap1,
189 			     const EdgePointGeomInfo & ap2,
190 			     Point<3> & newp, EdgePointGeomInfo & newgi) const;
191 
192   virtual void ProjectToSurface (Point<3> & p, int surfi) const;
193 
194   virtual void ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const;
195 };
196 
197 
198 
199 #endif
200 
201 
202 
203 #endif
204