7fd59977 |
1 | // GeometryDoc.cpp : implementation of the CGeometryDoc class |
2 | // |
3 | |
4 | #include "stdafx.h" |
5 | |
6 | #include "GeometryDoc.h" |
7 | #include "GeoAlgo_Sol.hxx" |
8 | #include "GeometryApp.h" |
9 | #include "GeometryView2D.h" |
10 | #include "GeometryView.h" |
11 | |
12 | #ifdef _DEBUG |
13 | #undef THIS_FILE |
14 | static char THIS_FILE[] = __FILE__; |
15 | #endif |
16 | #include "GeomSources.h" |
17 | |
18 | #ifdef WNT |
19 | #define EOL "\r\n" |
20 | #else |
21 | #define EOL "\n" |
22 | #endif |
23 | |
24 | #define WAIT_A_LITTLE WaitForInput(500) |
25 | |
26 | #define MAX_PARAM 1000 // if a surface parameter is infinite, it is assingned |
27 | // this value in order to display the "infinit" object in the viewer. |
28 | |
29 | ///////////////////////////////////////////////////////////////////////////// |
30 | // CGeometryDoc |
31 | |
32 | IMPLEMENT_DYNCREATE(CGeometryDoc, CDocument) |
33 | |
34 | BEGIN_MESSAGE_MAP(CGeometryDoc, CDocument) |
5c1f974e |
35 | //{{AFX_MSG_MAP(CGeometryDoc) |
36 | ON_COMMAND(ID_WINDOW_NEW2D, OnWindowNew2d) |
37 | ON_COMMAND(ID_BUTTON_Test_1, OnBUTTONTest1) |
38 | ON_COMMAND(ID_BUTTON_Test_2, OnBUTTONTest2) |
39 | ON_COMMAND(ID_BUTTON_Test_3, OnBUTTONTest3) |
40 | ON_COMMAND(ID_BUTTON_Test_4, OnBUTTONTest4) |
41 | ON_COMMAND(ID_BUTTON_Test_5, OnBUTTONTest5) |
42 | ON_COMMAND(ID_BUTTON_Test_6, OnBUTTONTest6) |
43 | ON_COMMAND(ID_BUTTON_Test_7, OnBUTTONTest7) |
44 | ON_COMMAND(ID_BUTTON_Test_8, OnBUTTONTest8) |
45 | ON_COMMAND(ID_BUTTON_Test_9, OnBUTTONTest9) |
46 | ON_COMMAND(ID_BUTTON_Test_23, OnBUTTONTest23) |
47 | ON_COMMAND(ID_BUTTON_Test_22, OnBUTTONTest22) |
48 | ON_COMMAND(ID_BUTTON_Test_10, OnBUTTONTest10) |
49 | ON_COMMAND(ID_BUTTON_Test_11, OnBUTTONTest11) |
50 | ON_COMMAND(ID_BUTTON_Test_12, OnBUTTONTest12) |
51 | ON_COMMAND(ID_BUTTON_Test_13, OnBUTTONTest13) |
52 | ON_COMMAND(ID_BUTTON_Test_14, OnBUTTONTest14) |
53 | ON_COMMAND(ID_BUTTON_Test_15, OnBUTTONTest15) |
54 | ON_COMMAND(ID_BUTTON_Test_16, OnBUTTONTest16) |
55 | ON_COMMAND(ID_BUTTON_Test_17, OnBUTTONTest17) |
56 | ON_COMMAND(ID_BUTTON_Test_18, OnBUTTONTest18) |
57 | ON_COMMAND(ID_BUTTON_Test_19, OnBUTTONTest19) |
58 | ON_COMMAND(ID_BUTTON_Test_20, OnBUTTONTest20) |
59 | ON_COMMAND(ID_BUTTON_Test_21, OnBUTTONTest21) |
60 | ON_COMMAND(ID_BUTTON_Test_24, OnBUTTONTest24) |
61 | ON_COMMAND(ID_BUTTON_Test_25, OnBUTTONTest25) |
62 | ON_COMMAND(ID_BUTTON_Test_26, OnBUTTONTest26) |
63 | ON_COMMAND(ID_BUTTON_Test_27, OnBUTTONTest27) |
64 | ON_COMMAND(ID_BUTTON_Test_28, OnBUTTONTest28) |
65 | ON_COMMAND(ID_BUTTON_Test_29, OnBUTTONTest29) |
66 | ON_COMMAND(ID_BUTTON_Test_30, OnBUTTONTest30) |
67 | ON_COMMAND(ID_BUTTON_Test_31, OnBUTTONTest31) |
68 | ON_COMMAND(ID_BUTTON_Test_32, OnBUTTONTest32) |
69 | ON_COMMAND(ID_BUTTON_Test_33, OnBUTTONTest33) |
70 | ON_COMMAND(ID_BUTTON_Test_34, OnBUTTONTest34) |
71 | ON_COMMAND(ID_BUTTON_Test_35, OnBUTTONTest35) |
72 | ON_COMMAND(ID_BUTTON_Test_36, OnBUTTONTest36) |
73 | ON_COMMAND(ID_BUTTON_Test_37, OnBUTTONTest37) |
74 | ON_COMMAND(ID_BUTTON_Test_38, OnBUTTONTest38) |
75 | ON_COMMAND(ID_BUTTON_Test_39, OnBUTTONTest39) |
76 | ON_COMMAND(ID_BUTTON_Test_40, OnBUTTONTest40) |
77 | ON_COMMAND(ID_BUTTON_Test_41, OnBUTTONTest41) |
78 | ON_COMMAND(ID_BUTTON_Test_42, OnBUTTONTest42) |
79 | ON_COMMAND(ID_BUTTON_Test_43, OnBUTTONTest43) |
80 | ON_COMMAND(ID_BUTTON_Test_44, OnBUTTONTest44) |
81 | ON_COMMAND(ID_BUTTON_Test_45, OnBUTTONTest45) |
82 | ON_COMMAND(ID_BUTTON_Test_46, OnBUTTONTest46) |
83 | ON_COMMAND(ID_BUTTON_Test_47, OnBUTTONTest47) |
84 | ON_COMMAND(ID_BUTTON_Test_48, OnBUTTONTest48) |
85 | ON_COMMAND(ID_BUTTON_Test_49, OnBUTTONTest49) |
86 | ON_COMMAND(ID_BUTTON_Test_50, OnBUTTONTest50) |
87 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_1 , OnUpdateBUTTONTest1 ) |
88 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_2 , OnUpdateBUTTONTest2 ) |
89 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_3 , OnUpdateBUTTONTest3 ) |
90 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_4 , OnUpdateBUTTONTest4 ) |
91 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_5 , OnUpdateBUTTONTest5 ) |
92 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_6 , OnUpdateBUTTONTest6 ) |
93 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_7 , OnUpdateBUTTONTest7 ) |
94 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_8 , OnUpdateBUTTONTest8 ) |
95 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_9 , OnUpdateBUTTONTest9 ) |
96 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_10 , OnUpdateBUTTONTest10 ) |
97 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_11 , OnUpdateBUTTONTest11 ) |
98 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_12 , OnUpdateBUTTONTest12 ) |
99 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_13 , OnUpdateBUTTONTest13 ) |
100 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_14 , OnUpdateBUTTONTest14 ) |
101 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_15 , OnUpdateBUTTONTest15 ) |
102 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_16 , OnUpdateBUTTONTest16 ) |
103 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_17 , OnUpdateBUTTONTest17 ) |
104 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_18 , OnUpdateBUTTONTest18 ) |
105 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_19 , OnUpdateBUTTONTest19 ) |
106 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_20 , OnUpdateBUTTONTest20 ) |
107 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_21 , OnUpdateBUTTONTest21 ) |
108 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_22 , OnUpdateBUTTONTest22 ) |
109 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_23 , OnUpdateBUTTONTest23 ) |
110 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_24 , OnUpdateBUTTONTest24 ) |
111 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_25 , OnUpdateBUTTONTest25 ) |
112 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_26 , OnUpdateBUTTONTest26 ) |
113 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_27 , OnUpdateBUTTONTest27 ) |
114 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_28 , OnUpdateBUTTONTest28 ) |
115 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_29 , OnUpdateBUTTONTest29 ) |
116 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_30 , OnUpdateBUTTONTest30 ) |
117 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_31 , OnUpdateBUTTONTest31 ) |
118 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_32 , OnUpdateBUTTONTest32 ) |
119 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_33 , OnUpdateBUTTONTest33 ) |
120 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_34 , OnUpdateBUTTONTest34 ) |
121 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_35 , OnUpdateBUTTONTest35 ) |
122 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_36 , OnUpdateBUTTONTest36 ) |
123 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_37 , OnUpdateBUTTONTest37 ) |
124 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_38 , OnUpdateBUTTONTest38 ) |
125 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_39 , OnUpdateBUTTONTest39 ) |
126 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_40 , OnUpdateBUTTONTest40 ) |
127 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_41 , OnUpdateBUTTONTest41 ) |
128 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_42 , OnUpdateBUTTONTest42 ) |
129 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_43 , OnUpdateBUTTONTest43 ) |
130 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_44 , OnUpdateBUTTONTest44 ) |
131 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_45 , OnUpdateBUTTONTest45 ) |
132 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_46 , OnUpdateBUTTONTest46 ) |
133 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_47 , OnUpdateBUTTONTest47 ) |
134 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_48 , OnUpdateBUTTONTest48 ) |
135 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_49 , OnUpdateBUTTONTest49 ) |
136 | ON_UPDATE_COMMAND_UI(ID_BUTTON_Test_50 , OnUpdateBUTTONTest50 ) |
137 | ON_COMMAND(ID_Create_Sol, OnCreateSol) |
138 | ON_COMMAND(ID_BUTTON_Simplify, OnSimplify) |
139 | //}}AFX_MSG_MAP |
7fd59977 |
140 | END_MESSAGE_MAP() |
141 | |
142 | ///////////////////////////////////////////////////////////////////////////// |
143 | // CGeometryDoc construction/destruction |
144 | |
145 | CGeometryDoc::CGeometryDoc() |
146 | { |
5c1f974e |
147 | FitMode = false; |
148 | AfxInitRichEdit(); |
149 | |
150 | // TODO: add one-time construction code here |
151 | Handle(Graphic3d_GraphicDriver) aGraphicDriver = |
152 | ((CGeometryApp*)AfxGetApp())->GetGraphicDriver(); |
153 | |
154 | TCollection_ExtendedString a3DName("Visu3D"); |
155 | myViewer = new V3d_Viewer(aGraphicDriver,a3DName.ToExtString()); |
156 | myViewer->SetDefaultLights(); |
157 | myViewer->SetLightOn(); |
158 | |
159 | myAISContext =new AIS_InteractiveContext(myViewer); |
160 | myAISContext->DefaultDrawer()->UIsoAspect()->SetNumber(11); |
161 | myAISContext->DefaultDrawer()->VIsoAspect()->SetNumber(11); |
162 | |
163 | TCollection_ExtendedString a2DName("Visu2D"); |
164 | myViewer2D = new V3d_Viewer(aGraphicDriver,a2DName.ToExtString()); |
165 | myViewer2D->SetCircularGridValues(0,0,1,8,0); |
166 | myViewer2D->SetRectangularGridValues(0,0,1,1,0); |
167 | //set view projection |
168 | myViewer2D->SetDefaultViewProj(V3d_Zpos); |
169 | myAISContext2D = new AIS_InteractiveContext(myViewer2D); |
170 | myCResultDialog.Create(CResultDialog::IDD,NULL); |
171 | |
172 | RECT dlgrect; |
173 | myCResultDialog.GetWindowRect(&dlgrect); |
174 | LONG width = dlgrect.right-dlgrect.left; |
175 | LONG height = dlgrect.bottom-dlgrect.top; |
176 | RECT MainWndRect; |
177 | AfxGetApp()->m_pMainWnd->GetWindowRect(&MainWndRect); |
178 | LONG left = MainWndRect.left+3; |
179 | LONG top = MainWndRect.top + 138; |
180 | myCResultDialog.MoveWindow(left,top,width,height); |
181 | |
182 | ((CGeometryApp*)AfxGetApp())->CreateView2D(this); |
183 | Minimize2D(); |
184 | Put3DOnTop(); |
7fd59977 |
185 | } |
186 | |
187 | CGeometryDoc::~CGeometryDoc() |
188 | { |
189 | } |
190 | |
191 | BOOL CGeometryDoc::OnNewDocument() |
192 | { |
5c1f974e |
193 | if (!CDocument::OnNewDocument()) |
194 | return FALSE; |
195 | |
196 | // TODO: add reinitialization code here |
197 | // (SDI documents will reuse this document) |
198 | // compute a graphic device --> the same for all Views |
7fd59977 |
199 | |
5c1f974e |
200 | return TRUE; |
7fd59977 |
201 | } |
202 | |
203 | |
204 | |
205 | void CGeometryDoc::OnWindowNew2d() |
206 | { |
5c1f974e |
207 | ((CGeometryApp*)AfxGetApp())->CreateView2D(this); |
7fd59977 |
208 | } |
209 | |
210 | ///////////////////////////////////////////////////////////////////////////// |
211 | // CGeometryDoc serialization |
212 | |
213 | void CGeometryDoc::Serialize(CArchive& ar) |
214 | { |
5c1f974e |
215 | if (ar.IsStoring()) |
216 | { |
217 | // TODO: add storing code here |
218 | } |
219 | else |
220 | { |
221 | // TODO: add loading code here |
222 | } |
7fd59977 |
223 | } |
224 | |
225 | ///////////////////////////////////////////////////////////////////////////// |
226 | // CGeometryDoc diagnostics |
227 | |
228 | #ifdef _DEBUG |
229 | void CGeometryDoc::AssertValid() const |
230 | { |
5c1f974e |
231 | CDocument::AssertValid(); |
7fd59977 |
232 | } |
233 | |
234 | void CGeometryDoc::Dump(CDumpContext& dc) const |
235 | { |
5c1f974e |
236 | CDocument::Dump(dc); |
7fd59977 |
237 | } |
238 | #endif //_DEBUG |
239 | |
240 | ///////////////////////////////////////////////////////////////////////////// |
241 | // CGeometryDoc commands |
242 | |
243 | //----------------------------------------------------------------------------------------- |
244 | // |
245 | //----------------------------------------------------------------------------------------- |
5c573e69 |
246 | void CGeometryDoc::DragEvent2D(const Standard_Integer /*x*/, |
247 | const Standard_Integer /*y*/, |
248 | const Standard_Integer /*TheState*/, |
249 | const Handle(V3d_View)& /*aView*/) |
7fd59977 |
250 | { |
251 | } |
252 | |
253 | |
254 | //----------------------------------------------------------------------------------------- |
255 | // |
256 | //----------------------------------------------------------------------------------------- |
5c573e69 |
257 | void CGeometryDoc::InputEvent2D(const Standard_Integer /*x*/, |
258 | const Standard_Integer /*y*/, |
259 | const Handle(V3d_View)& /*aView*/) |
7fd59977 |
260 | { |
5c1f974e |
261 | myAISContext2D->Select(Standard_True); |
7fd59977 |
262 | } |
263 | |
264 | //----------------------------------------------------------------------------------------- |
265 | // |
266 | //----------------------------------------------------------------------------------------- |
5c573e69 |
267 | void CGeometryDoc::MoveEvent2D(const Standard_Integer x, |
268 | const Standard_Integer y, |
269 | const Handle(V3d_View)& aView) |
7fd59977 |
270 | { |
5c1f974e |
271 | if(aView->Viewer()->Grid()->IsActive()) |
272 | { |
273 | Quantity_Length aGridX=0,aGridY=0,aGridZ=0; |
274 | aView->ConvertToGrid(x,y,aGridX,aGridY,aGridZ); |
275 | //View is not updated automatically in ConvertToGrid |
276 | aView->Update(); |
277 | } |
278 | this->myAISContext2D->MoveTo(x, y, aView); |
7fd59977 |
279 | } |
280 | |
281 | //----------------------------------------------------------------------------------------- |
282 | // |
283 | //----------------------------------------------------------------------------------------- |
5c573e69 |
284 | void CGeometryDoc::ShiftMoveEvent2D(const Standard_Integer /*x*/, |
285 | const Standard_Integer /*y*/, |
286 | const Handle(V3d_View)& /*aView*/) |
7fd59977 |
287 | { |
288 | } |
289 | |
290 | //----------------------------------------------------------------------------------------- |
291 | // |
292 | //----------------------------------------------------------------------------------------- |
5c573e69 |
293 | void CGeometryDoc::ShiftDragEvent2D(const Standard_Integer /*x*/, |
294 | const Standard_Integer /*y*/, |
295 | const Standard_Integer /*TheState*/, |
296 | const Handle(V3d_View)& /*aView*/) |
7fd59977 |
297 | { |
298 | } |
299 | |
300 | |
301 | //----------------------------------------------------------------------------------------- |
302 | // |
303 | //----------------------------------------------------------------------------------------- |
5c573e69 |
304 | void CGeometryDoc::ShiftInputEvent2D(const Standard_Integer /*x*/, |
305 | const Standard_Integer /*y*/, |
306 | const Handle(V3d_View)& /*aView*/) |
7fd59977 |
307 | { |
308 | } |
309 | |
310 | //----------------------------------------------------------------------------------------- |
311 | // |
312 | //----------------------------------------------------------------------------------------- |
5c573e69 |
313 | void CGeometryDoc::Popup2D(const Standard_Integer x, |
314 | const Standard_Integer y, |
315 | const Handle(V3d_View)& aView) |
5c1f974e |
316 | { |
317 | CMenu menu; |
318 | VERIFY(menu.LoadMenu(IDR_Popup3D)); |
319 | CMenu* pPopup; |
320 | |
321 | pPopup = menu.GetSubMenu(0); |
322 | |
323 | ASSERT(pPopup != NULL); |
324 | |
325 | POINT winCoord = { x , y }; |
326 | Handle(WNT_Window) aWNTWindow= |
327 | Handle(WNT_Window)::DownCast(aView->Window()); |
328 | ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord); |
329 | pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y , |
330 | AfxGetMainWnd()); |
7fd59977 |
331 | } |
332 | |
333 | void CGeometryDoc::Put2DOnTop(bool isMax) |
334 | { |
335 | POSITION position = GetFirstViewPosition(); |
336 | while (position != (POSITION)NULL) |
337 | { |
338 | CView* pCurrentView = (CView*)GetNextView(position); |
5c1f974e |
339 | if(pCurrentView->IsKindOf( RUNTIME_CLASS( CGeometryView2D ) ) ) |
7fd59977 |
340 | { |
5c1f974e |
341 | ASSERT_VALID(pCurrentView); |
342 | CFrameWnd* pParentFrm = pCurrentView->GetParentFrame(); |
343 | ASSERT(pParentFrm != (CFrameWnd *)NULL); |
344 | // simply make the frame window visible |
345 | if(isMax) |
346 | { |
347 | pParentFrm->ActivateFrame(SW_SHOWMAXIMIZED); |
348 | } |
349 | else |
350 | { |
351 | pParentFrm->ActivateFrame(SW_SHOW); |
352 | } |
7fd59977 |
353 | } |
354 | } |
355 | } |
356 | |
357 | void CGeometryDoc::Minimize2D() |
358 | { |
359 | POSITION position = GetFirstViewPosition(); |
360 | while (position != (POSITION)NULL) |
361 | { |
362 | CView* pCurrentView = (CView*)GetNextView(position); |
5c1f974e |
363 | if(pCurrentView->IsKindOf( RUNTIME_CLASS( CGeometryView2D ) ) ) |
7fd59977 |
364 | { |
5c1f974e |
365 | ASSERT_VALID(pCurrentView); |
366 | CFrameWnd* pParentFrm = pCurrentView->GetParentFrame(); |
367 | ASSERT(pParentFrm != (CFrameWnd *)NULL); |
368 | // simply make the frame window visible |
369 | pParentFrm->ActivateFrame(SW_HIDE); |
7fd59977 |
370 | } |
371 | } |
7fd59977 |
372 | } |
373 | |
374 | void CGeometryDoc::Fit2DViews() |
375 | { |
376 | POSITION position = GetFirstViewPosition(); |
377 | while (position != (POSITION)NULL) |
378 | { |
379 | CView* pCurrentView = (CView*)GetNextView(position); |
5c1f974e |
380 | if(pCurrentView->IsKindOf( RUNTIME_CLASS( CGeometryView2D ) ) ) |
7fd59977 |
381 | { |
5c1f974e |
382 | ASSERT_VALID(pCurrentView); |
383 | CGeometryView2D* aCGeometryView2D = (CGeometryView2D*)pCurrentView; |
384 | aCGeometryView2D->FitAll(); |
7fd59977 |
385 | } |
386 | } |
7fd59977 |
387 | } |
388 | void CGeometryDoc::Put3DOnTop(bool isMax) |
389 | { |
390 | POSITION position = GetFirstViewPosition(); |
391 | while (position != (POSITION)NULL) |
392 | { |
393 | CView* pCurrentView = (CView*)GetNextView(position); |
5c1f974e |
394 | if(pCurrentView->IsKindOf( RUNTIME_CLASS( CGeometryView ) ) ) |
7fd59977 |
395 | { |
5c1f974e |
396 | ASSERT_VALID(pCurrentView); |
397 | CFrameWnd* pParentFrm = pCurrentView->GetParentFrame(); |
398 | ASSERT(pParentFrm != (CFrameWnd *)NULL); |
399 | // simply make the frame window visible |
400 | if(isMax) |
401 | { |
402 | pParentFrm->ActivateFrame(SW_SHOWMAXIMIZED); |
403 | } |
404 | else |
405 | { |
406 | pParentFrm->ActivateFrame(SW_SHOW); |
407 | } |
7fd59977 |
408 | } |
409 | } |
410 | } |
5c1f974e |
411 | |
7fd59977 |
412 | void CGeometryDoc::Minimize3D() |
413 | { |
414 | POSITION position = GetFirstViewPosition(); |
415 | while (position != (POSITION)NULL) |
416 | { |
417 | CView* pCurrentView = (CView*)GetNextView(position); |
5c1f974e |
418 | if(pCurrentView->IsKindOf( RUNTIME_CLASS( CGeometryView ) ) ) |
7fd59977 |
419 | { |
5c1f974e |
420 | ASSERT_VALID(pCurrentView); |
421 | CFrameWnd* pParentFrm = pCurrentView->GetParentFrame(); |
422 | ASSERT(pParentFrm != (CFrameWnd *)NULL); |
423 | // simply make the frame window visible |
424 | pParentFrm->ActivateFrame(SW_HIDE); |
7fd59977 |
425 | } |
426 | } |
7fd59977 |
427 | } |
428 | |
7fd59977 |
429 | void CGeometryDoc::Fit3DViews(Quantity_Coefficient Coef) |
430 | { |
431 | POSITION position = GetFirstViewPosition(); |
432 | while (position != (POSITION)NULL) |
433 | { |
434 | CView* pCurrentView = (CView*)GetNextView(position); |
5c1f974e |
435 | if(pCurrentView->IsKindOf( RUNTIME_CLASS( CGeometryView ) ) ) |
7fd59977 |
436 | { |
5c1f974e |
437 | ASSERT_VALID(pCurrentView); |
438 | CGeometryView* aCGeometryView = (CGeometryView*)pCurrentView; |
439 | aCGeometryView->FitAll(Coef); |
7fd59977 |
440 | } |
441 | } |
7fd59977 |
442 | } |
5c1f974e |
443 | |
444 | void CGeometryDoc::Set3DViewsZoom(const Quantity_Factor& Coef) |
7fd59977 |
445 | { |
446 | POSITION position = GetFirstViewPosition(); |
447 | while (position != (POSITION)NULL) |
448 | { |
449 | CView* pCurrentView = (CView*)GetNextView(position); |
5c1f974e |
450 | if(pCurrentView->IsKindOf( RUNTIME_CLASS( CGeometryView ) ) ) |
7fd59977 |
451 | { |
5c1f974e |
452 | ASSERT_VALID(pCurrentView); |
453 | CGeometryView* aCGeometryView = (CGeometryView*)pCurrentView; |
454 | aCGeometryView->SetZoom( Coef ); |
7fd59977 |
455 | } |
456 | } |
7fd59977 |
457 | } |
458 | |
459 | void CGeometryDoc::OnBUTTONTest1() |
460 | { Current = 1; |
5c1f974e |
461 | GeomSources::gpTest1(this); } |
7fd59977 |
462 | void CGeometryDoc::OnBUTTONTest2() |
463 | { Current = 2; |
5c1f974e |
464 | GeomSources::gpTest2(this); } |
7fd59977 |
465 | void CGeometryDoc::OnBUTTONTest3() |
466 | { Current = 3; |
5c1f974e |
467 | GeomSources::gpTest3(this); } |
7fd59977 |
468 | void CGeometryDoc::OnBUTTONTest4() |
469 | { Current = 4; |
5c1f974e |
470 | GeomSources::gpTest4(this); } |
7fd59977 |
471 | void CGeometryDoc::OnBUTTONTest5() |
472 | { Current = 5; |
5c1f974e |
473 | GeomSources::gpTest5(this); } |
7fd59977 |
474 | void CGeometryDoc::OnBUTTONTest6() |
475 | { Current = 6; |
5c1f974e |
476 | GeomSources::gpTest6(this); } |
7fd59977 |
477 | void CGeometryDoc::OnBUTTONTest7() |
478 | { Current = 7; |
5c1f974e |
479 | GeomSources::gpTest7(this); } |
7fd59977 |
480 | void CGeometryDoc::OnBUTTONTest8() |
481 | { Current = 8; |
5c1f974e |
482 | GeomSources::gpTest8(this); } |
7fd59977 |
483 | void CGeometryDoc::OnBUTTONTest9() |
484 | { Current = 9; |
5c1f974e |
485 | GeomSources::gpTest9(this); } |
7fd59977 |
486 | void CGeometryDoc::OnBUTTONTest10() |
487 | { Current = 10; |
5c1f974e |
488 | GeomSources::gpTest10(this); } |
7fd59977 |
489 | void CGeometryDoc::OnBUTTONTest11() |
490 | { Current = 11; |
5c1f974e |
491 | GeomSources::gpTest11(this); } |
7fd59977 |
492 | void CGeometryDoc::OnBUTTONTest12() |
493 | { Current = 12; |
5c1f974e |
494 | GeomSources::gpTest12(this); } |
7fd59977 |
495 | void CGeometryDoc::OnBUTTONTest13() |
496 | { Current = 13; |
5c1f974e |
497 | GeomSources::gpTest13(this); } |
7fd59977 |
498 | void CGeometryDoc::OnBUTTONTest14() |
499 | { Current = 14; |
5c1f974e |
500 | GeomSources::gpTest14(this); } |
7fd59977 |
501 | void CGeometryDoc::OnBUTTONTest15() |
502 | { Current = 15; |
5c1f974e |
503 | GeomSources::gpTest15(this); } |
7fd59977 |
504 | void CGeometryDoc::OnBUTTONTest16() |
505 | { Current = 16; |
5c1f974e |
506 | GeomSources::gpTest16(this); } |
7fd59977 |
507 | void CGeometryDoc::OnBUTTONTest17() |
508 | { Current = 17; |
5c1f974e |
509 | GeomSources::gpTest17(this); } |
7fd59977 |
510 | void CGeometryDoc::OnBUTTONTest18() |
511 | { Current = 18; |
5c1f974e |
512 | GeomSources::gpTest18(this); } |
7fd59977 |
513 | void CGeometryDoc::OnBUTTONTest19() |
514 | { Current = 19; |
5c1f974e |
515 | GeomSources::gpTest19(this); } |
7fd59977 |
516 | void CGeometryDoc::OnBUTTONTest20() |
517 | { Current = 20; |
5c1f974e |
518 | GeomSources::gpTest20(this); } |
7fd59977 |
519 | void CGeometryDoc::OnBUTTONTest21() |
520 | { Current = 21; |
5c1f974e |
521 | GeomSources::gpTest21(this); } |
7fd59977 |
522 | void CGeometryDoc::OnBUTTONTest22() |
523 | { Current = 22; |
5c1f974e |
524 | GeomSources::gpTest22(this); } |
7fd59977 |
525 | void CGeometryDoc::OnBUTTONTest23() |
526 | { Current = 23; |
5c1f974e |
527 | GeomSources::gpTest23(this); } |
7fd59977 |
528 | void CGeometryDoc::OnBUTTONTest24() |
529 | { Current = 24; |
5c1f974e |
530 | GeomSources::gpTest24(this); } |
7fd59977 |
531 | void CGeometryDoc::OnBUTTONTest25() |
532 | { Current = 25; |
5c1f974e |
533 | GeomSources::gpTest25(this); } |
7fd59977 |
534 | void CGeometryDoc::OnBUTTONTest26() |
535 | { Current = 26; |
5c1f974e |
536 | GeomSources::gpTest26(this); } |
7fd59977 |
537 | void CGeometryDoc::OnBUTTONTest27() |
538 | { Current = 27; |
5c1f974e |
539 | GeomSources::gpTest27(this); } |
7fd59977 |
540 | void CGeometryDoc::OnBUTTONTest28() |
541 | { Current = 28; |
5c1f974e |
542 | GeomSources::gpTest28(this); } |
7fd59977 |
543 | void CGeometryDoc::OnBUTTONTest29() |
544 | { Current = 29; |
5c1f974e |
545 | GeomSources::gpTest29(this); } |
7fd59977 |
546 | void CGeometryDoc::OnBUTTONTest30() |
547 | { Current = 30; |
5c1f974e |
548 | GeomSources::gpTest30(this); } |
7fd59977 |
549 | void CGeometryDoc::OnBUTTONTest31() |
550 | { Current = 31; |
5c1f974e |
551 | GeomSources::gpTest31(this); } |
7fd59977 |
552 | void CGeometryDoc::OnBUTTONTest32() |
553 | { Current = 32; |
5c1f974e |
554 | GeomSources::gpTest32(this); } |
7fd59977 |
555 | void CGeometryDoc::OnBUTTONTest33() |
556 | { Current = 33; |
5c1f974e |
557 | GeomSources::gpTest33(this); } |
7fd59977 |
558 | void CGeometryDoc::OnBUTTONTest34() |
559 | { Current = 34; |
5c1f974e |
560 | GeomSources::gpTest34(this); } |
7fd59977 |
561 | void CGeometryDoc::OnBUTTONTest35() |
562 | { Current = 35; |
5c1f974e |
563 | GeomSources::gpTest35(this); } |
7fd59977 |
564 | void CGeometryDoc::OnBUTTONTest36() |
565 | { Current = 36; |
5c1f974e |
566 | GeomSources::gpTest36(this); } |
7fd59977 |
567 | |
568 | void CGeometryDoc::OnBUTTONTest37() |
569 | { Current = 37; |
5c1f974e |
570 | GeomSources::gpTest37(this); } |
7fd59977 |
571 | void CGeometryDoc::OnBUTTONTest38() |
572 | { Current = 38; |
5c1f974e |
573 | GeomSources::gpTest38(this); } |
7fd59977 |
574 | void CGeometryDoc::OnBUTTONTest39() |
575 | { Current = 39; |
5c1f974e |
576 | GeomSources::gpTest39(this); } |
7fd59977 |
577 | void CGeometryDoc::OnBUTTONTest40() |
578 | { Current = 40; |
5c1f974e |
579 | GeomSources::gpTest40(this); } |
7fd59977 |
580 | void CGeometryDoc::OnBUTTONTest41() |
581 | { Current = 41; |
5c1f974e |
582 | GeomSources::gpTest41(this); } |
7fd59977 |
583 | void CGeometryDoc::OnBUTTONTest42() |
584 | { Current = 42; |
5c1f974e |
585 | GeomSources::gpTest42(this); } |
7fd59977 |
586 | void CGeometryDoc::OnBUTTONTest43() |
587 | { Current = 43; |
5c1f974e |
588 | GeomSources::gpTest43(this); } |
7fd59977 |
589 | void CGeometryDoc::OnBUTTONTest44() |
590 | { Current = 44; |
5c1f974e |
591 | GeomSources::gpTest44(this); } |
7fd59977 |
592 | void CGeometryDoc::OnBUTTONTest45() |
593 | { Current = 45; |
5c1f974e |
594 | GeomSources::gpTest45(this); } |
7fd59977 |
595 | void CGeometryDoc::OnBUTTONTest46() |
596 | { Current = 46; |
5c1f974e |
597 | GeomSources::gpTest46(this); } |
7fd59977 |
598 | void CGeometryDoc::OnBUTTONTest47() |
599 | { Current = 47; |
5c1f974e |
600 | GeomSources::gpTest47(this); } |
7fd59977 |
601 | void CGeometryDoc::OnBUTTONTest48() |
602 | { Current = 48; |
5c1f974e |
603 | GeomSources::gpTest48(this); } |
7fd59977 |
604 | void CGeometryDoc::OnBUTTONTest49() |
605 | { Current = 49; |
5c1f974e |
606 | GeomSources::gpTest49(this); } |
7fd59977 |
607 | void CGeometryDoc::OnBUTTONTest50() |
608 | { Current = 50; |
5c1f974e |
609 | GeomSources::gpTest50(this); } |
7fd59977 |
610 | |
611 | void CGeometryDoc::OnUpdateBUTTONTest1(CCmdUI* pCmdUI) |
5c1f974e |
612 | { |
613 | if (Current == 1) |
614 | pCmdUI->SetCheck(true); |
615 | else |
616 | pCmdUI->SetCheck(false); |
7fd59977 |
617 | } |
618 | |
619 | void CGeometryDoc::OnUpdateBUTTONTest2(CCmdUI* pCmdUI) |
5c1f974e |
620 | { |
621 | if (Current == 2) |
622 | pCmdUI->SetCheck(true); |
623 | else |
624 | pCmdUI->SetCheck(false); |
7fd59977 |
625 | } |
626 | |
627 | void CGeometryDoc::OnUpdateBUTTONTest3(CCmdUI* pCmdUI) |
5c1f974e |
628 | { |
629 | if (Current == 3) |
630 | pCmdUI->SetCheck(true); |
631 | else |
632 | pCmdUI->SetCheck(false); |
7fd59977 |
633 | } |
634 | |
635 | void CGeometryDoc::OnUpdateBUTTONTest4(CCmdUI* pCmdUI) |
5c1f974e |
636 | { |
637 | if (Current == 4) |
638 | pCmdUI->SetCheck(true); |
639 | else |
640 | pCmdUI->SetCheck(false); |
7fd59977 |
641 | } |
642 | |
643 | void CGeometryDoc::OnUpdateBUTTONTest5(CCmdUI* pCmdUI) |
5c1f974e |
644 | { |
645 | if (Current == 5) |
646 | pCmdUI->SetCheck(true); |
647 | else |
648 | pCmdUI->SetCheck(false); |
7fd59977 |
649 | } |
650 | |
651 | void CGeometryDoc::OnUpdateBUTTONTest6(CCmdUI* pCmdUI) |
5c1f974e |
652 | { |
653 | if (Current == 6) |
654 | pCmdUI->SetCheck(true); |
655 | else |
656 | pCmdUI->SetCheck(false); |
7fd59977 |
657 | } |
658 | |
659 | void CGeometryDoc::OnUpdateBUTTONTest7(CCmdUI* pCmdUI) |
5c1f974e |
660 | { |
661 | if (Current == 7) |
662 | pCmdUI->SetCheck(true); |
663 | else |
664 | pCmdUI->SetCheck(false); |
7fd59977 |
665 | } |
666 | |
667 | void CGeometryDoc::OnUpdateBUTTONTest8(CCmdUI* pCmdUI) |
5c1f974e |
668 | { |
669 | if (Current == 8) |
670 | pCmdUI->SetCheck(true); |
671 | else |
672 | pCmdUI->SetCheck(false); |
7fd59977 |
673 | } |
674 | |
675 | void CGeometryDoc::OnUpdateBUTTONTest9(CCmdUI* pCmdUI) |
5c1f974e |
676 | { |
677 | if (Current == 9) |
678 | pCmdUI->SetCheck(true); |
679 | else |
680 | pCmdUI->SetCheck(false); |
7fd59977 |
681 | } |
682 | |
683 | void CGeometryDoc::OnUpdateBUTTONTest10(CCmdUI* pCmdUI) |
5c1f974e |
684 | { |
685 | if (Current == 10) |
686 | pCmdUI->SetCheck(true); |
687 | else |
688 | pCmdUI->SetCheck(false); |
7fd59977 |
689 | } |
690 | |
691 | void CGeometryDoc::OnUpdateBUTTONTest11(CCmdUI* pCmdUI) |
5c1f974e |
692 | { |
693 | if (Current == 11) |
694 | pCmdUI->SetCheck(true); |
695 | else |
696 | pCmdUI->SetCheck(false); |
7fd59977 |
697 | } |
698 | |
699 | void CGeometryDoc::OnUpdateBUTTONTest12(CCmdUI* pCmdUI) |
5c1f974e |
700 | { |
701 | if (Current == 12) |
702 | pCmdUI->SetCheck(true); |
703 | else pCmdUI->SetCheck(false); |
7fd59977 |
704 | } |
705 | |
706 | void CGeometryDoc::OnUpdateBUTTONTest13(CCmdUI* pCmdUI) |
5c1f974e |
707 | { |
708 | if (Current == 13) |
709 | pCmdUI->SetCheck(true); |
710 | else |
711 | pCmdUI->SetCheck(false); |
7fd59977 |
712 | } |
713 | |
714 | void CGeometryDoc::OnUpdateBUTTONTest14(CCmdUI* pCmdUI) |
5c1f974e |
715 | { |
716 | if (Current == 14) |
717 | pCmdUI->SetCheck(true); |
718 | else |
719 | pCmdUI->SetCheck(false); |
7fd59977 |
720 | } |
721 | |
5c1f974e |
722 | void CGeometryDoc::OnUpdateBUTTONTest15(CCmdUI* pCmdUI) |
723 | { |
724 | if(Current == 15) |
725 | pCmdUI->SetCheck(true); |
726 | else |
727 | pCmdUI->SetCheck(false); |
7fd59977 |
728 | } |
729 | |
5c1f974e |
730 | void CGeometryDoc::OnUpdateBUTTONTest16(CCmdUI* pCmdUI) |
731 | { |
732 | if (Current == 16) |
733 | pCmdUI->SetCheck(true); |
734 | else |
735 | pCmdUI->SetCheck(false); |
7fd59977 |
736 | } |
737 | |
5c1f974e |
738 | void CGeometryDoc::OnUpdateBUTTONTest17(CCmdUI* pCmdUI) |
739 | { |
740 | if (Current == 17) |
741 | pCmdUI->SetCheck(true); |
742 | else |
743 | pCmdUI->SetCheck(false); |
7fd59977 |
744 | } |
745 | |
5c1f974e |
746 | void CGeometryDoc::OnUpdateBUTTONTest18(CCmdUI* pCmdUI) |
747 | { |
748 | if (Current == 18) |
749 | pCmdUI->SetCheck(true); |
750 | else |
751 | pCmdUI->SetCheck(false); |
7fd59977 |
752 | } |
753 | |
5c1f974e |
754 | void CGeometryDoc::OnUpdateBUTTONTest19(CCmdUI* pCmdUI) |
755 | { |
756 | if (Current == 19) |
757 | pCmdUI->SetCheck(true); |
758 | else |
759 | pCmdUI->SetCheck(false); |
7fd59977 |
760 | } |
761 | |
5c1f974e |
762 | void CGeometryDoc::OnUpdateBUTTONTest20(CCmdUI* pCmdUI) |
763 | { |
764 | if (Current == 20) |
765 | pCmdUI->SetCheck(true); |
766 | else |
767 | pCmdUI->SetCheck(false); |
7fd59977 |
768 | } |
769 | |
5c1f974e |
770 | void CGeometryDoc::OnUpdateBUTTONTest21(CCmdUI* pCmdUI) |
771 | { |
772 | if (Current == 21) |
773 | pCmdUI->SetCheck(true); |
774 | else |
775 | pCmdUI->SetCheck(false); |
7fd59977 |
776 | } |
777 | |
5c1f974e |
778 | void CGeometryDoc::OnUpdateBUTTONTest22(CCmdUI* pCmdUI) |
779 | { |
780 | if (Current == 22) |
781 | pCmdUI->SetCheck(true); |
782 | else |
783 | pCmdUI->SetCheck(false); |
7fd59977 |
784 | } |
785 | |
5c1f974e |
786 | void CGeometryDoc::OnUpdateBUTTONTest23(CCmdUI* pCmdUI) |
787 | { |
788 | if (Current == 23) |
789 | pCmdUI->SetCheck(true); |
790 | else |
791 | pCmdUI->SetCheck(false); |
7fd59977 |
792 | } |
793 | |
5c1f974e |
794 | void CGeometryDoc::OnUpdateBUTTONTest24(CCmdUI* pCmdUI) |
795 | { |
796 | if (Current == 24) |
797 | pCmdUI->SetCheck(true); |
798 | else |
799 | pCmdUI->SetCheck(false); |
7fd59977 |
800 | } |
801 | |
5c1f974e |
802 | void CGeometryDoc::OnUpdateBUTTONTest25(CCmdUI* pCmdUI) |
803 | { |
804 | if (Current == 25) |
805 | pCmdUI->SetCheck(true); |
806 | else |
807 | pCmdUI->SetCheck(false); |
7fd59977 |
808 | } |
809 | |
5c1f974e |
810 | void CGeometryDoc::OnUpdateBUTTONTest26(CCmdUI* pCmdUI) |
811 | { |
812 | if (Current == 26) |
813 | pCmdUI->SetCheck(true); |
814 | else |
815 | pCmdUI->SetCheck(false); |
7fd59977 |
816 | } |
817 | |
5c1f974e |
818 | void CGeometryDoc::OnUpdateBUTTONTest27(CCmdUI* pCmdUI) |
819 | { |
820 | if (Current == 27) |
821 | pCmdUI->SetCheck(true); |
822 | else |
823 | pCmdUI->SetCheck(false); |
7fd59977 |
824 | } |
825 | |
5c1f974e |
826 | void CGeometryDoc::OnUpdateBUTTONTest28(CCmdUI* pCmdUI) |
827 | { |
828 | if (Current == 28) |
829 | pCmdUI->SetCheck(true); |
830 | else |
831 | pCmdUI->SetCheck(false); |
7fd59977 |
832 | } |
833 | |
5c1f974e |
834 | void CGeometryDoc::OnUpdateBUTTONTest29(CCmdUI* pCmdUI) |
835 | { |
836 | if (Current == 29) |
837 | pCmdUI->SetCheck(true); |
838 | else |
839 | pCmdUI->SetCheck(false); |
7fd59977 |
840 | } |
841 | |
5c1f974e |
842 | void CGeometryDoc::OnUpdateBUTTONTest30(CCmdUI* pCmdUI) |
843 | { |
844 | if (Current == 30) |
845 | pCmdUI->SetCheck(true); |
846 | else |
847 | pCmdUI->SetCheck(false); |
7fd59977 |
848 | } |
849 | |
5c1f974e |
850 | void CGeometryDoc::OnUpdateBUTTONTest31(CCmdUI* pCmdUI) |
851 | { |
852 | if (Current == 31) |
853 | pCmdUI->SetCheck(true); |
854 | else |
855 | pCmdUI->SetCheck(false); |
7fd59977 |
856 | } |
857 | |
5c1f974e |
858 | void CGeometryDoc::OnUpdateBUTTONTest32(CCmdUI* pCmdUI) |
859 | { |
860 | if (Current == 32) |
861 | pCmdUI->SetCheck(true); |
862 | else |
863 | pCmdUI->SetCheck(false); |
7fd59977 |
864 | } |
865 | |
5c1f974e |
866 | void CGeometryDoc::OnUpdateBUTTONTest33(CCmdUI* pCmdUI) |
867 | { |
868 | if (Current == 33) |
869 | pCmdUI->SetCheck(true); |
870 | else |
871 | pCmdUI->SetCheck(false); |
7fd59977 |
872 | } |
873 | |
5c1f974e |
874 | void CGeometryDoc::OnUpdateBUTTONTest34(CCmdUI* pCmdUI) |
875 | { |
876 | if (Current == 34) |
877 | pCmdUI->SetCheck(true); |
878 | else |
879 | pCmdUI->SetCheck(false); |
7fd59977 |
880 | } |
881 | |
5c1f974e |
882 | void CGeometryDoc::OnUpdateBUTTONTest35(CCmdUI* pCmdUI) |
883 | { |
884 | if (Current == 35) |
885 | pCmdUI->SetCheck(true); |
886 | else |
887 | pCmdUI->SetCheck(false); |
7fd59977 |
888 | } |
889 | |
5c1f974e |
890 | void CGeometryDoc::OnUpdateBUTTONTest36(CCmdUI* pCmdUI) |
891 | { |
892 | if (Current == 36) |
893 | pCmdUI->SetCheck(true); |
894 | else |
895 | pCmdUI->SetCheck(false); |
7fd59977 |
896 | } |
897 | |
5c1f974e |
898 | void CGeometryDoc::OnUpdateBUTTONTest37(CCmdUI* pCmdUI) |
899 | { |
900 | if (Current == 37) |
901 | pCmdUI->SetCheck(true); |
902 | else |
903 | pCmdUI->SetCheck(false); |
7fd59977 |
904 | } |
905 | |
5c1f974e |
906 | void CGeometryDoc::OnUpdateBUTTONTest38(CCmdUI* pCmdUI) |
907 | { |
908 | if (Current == 38) |
909 | pCmdUI->SetCheck(true); |
910 | else |
911 | pCmdUI->SetCheck(false); |
7fd59977 |
912 | } |
913 | |
5c1f974e |
914 | void CGeometryDoc::OnUpdateBUTTONTest39(CCmdUI* pCmdUI) |
915 | { |
916 | if (Current == 39) |
917 | pCmdUI->SetCheck(true); |
918 | else |
919 | pCmdUI->SetCheck(false); |
7fd59977 |
920 | } |
921 | |
5c1f974e |
922 | void CGeometryDoc::OnUpdateBUTTONTest40(CCmdUI* pCmdUI) |
923 | { |
924 | if (Current == 40) |
925 | pCmdUI->SetCheck(true); |
926 | else |
927 | pCmdUI->SetCheck(false); |
7fd59977 |
928 | } |
929 | |
5c1f974e |
930 | void CGeometryDoc::OnUpdateBUTTONTest41(CCmdUI* pCmdUI) |
931 | { |
932 | if (Current == 41) |
933 | pCmdUI->SetCheck(true); |
934 | else |
935 | pCmdUI->SetCheck(false); |
7fd59977 |
936 | } |
937 | |
5c1f974e |
938 | void CGeometryDoc::OnUpdateBUTTONTest42(CCmdUI* pCmdUI) |
939 | { |
940 | if (Current == 42) |
941 | pCmdUI->SetCheck(true); |
942 | else |
943 | pCmdUI->SetCheck(false); |
7fd59977 |
944 | } |
945 | |
5c1f974e |
946 | void CGeometryDoc::OnUpdateBUTTONTest43(CCmdUI* pCmdUI) |
947 | { |
948 | if (Current == 43) |
949 | pCmdUI->SetCheck(true); |
950 | else |
951 | pCmdUI->SetCheck(false); |
7fd59977 |
952 | } |
953 | |
5c1f974e |
954 | void CGeometryDoc::OnUpdateBUTTONTest44(CCmdUI* pCmdUI) |
955 | { |
956 | if (Current == 44) |
957 | pCmdUI->SetCheck(true); |
958 | else |
959 | pCmdUI->SetCheck(false); |
7fd59977 |
960 | } |
961 | |
5c1f974e |
962 | void CGeometryDoc::OnUpdateBUTTONTest45(CCmdUI* pCmdUI) |
963 | { |
964 | if (Current == 45) |
965 | pCmdUI->SetCheck(true); |
966 | else |
967 | pCmdUI->SetCheck(false); |
7fd59977 |
968 | } |
969 | |
5c1f974e |
970 | void CGeometryDoc::OnUpdateBUTTONTest46(CCmdUI* pCmdUI) |
971 | { |
972 | if (Current == 46) |
973 | pCmdUI->SetCheck(true); |
974 | else |
975 | pCmdUI->SetCheck(false); |
7fd59977 |
976 | } |
977 | |
5c1f974e |
978 | void CGeometryDoc::OnUpdateBUTTONTest47(CCmdUI* pCmdUI) |
979 | { |
980 | if (Current == 47) |
981 | pCmdUI->SetCheck(true); |
982 | else |
983 | pCmdUI->SetCheck(false); |
7fd59977 |
984 | } |
985 | |
5c1f974e |
986 | void CGeometryDoc::OnUpdateBUTTONTest48(CCmdUI* pCmdUI) |
987 | { |
988 | if (Current == 48) |
989 | pCmdUI->SetCheck(true); |
990 | else |
991 | pCmdUI->SetCheck(false); |
7fd59977 |
992 | } |
993 | |
5c1f974e |
994 | void CGeometryDoc::OnUpdateBUTTONTest49(CCmdUI* pCmdUI) |
995 | { |
996 | if (Current == 49) |
997 | pCmdUI->SetCheck(true); |
998 | else |
999 | pCmdUI->SetCheck(false); |
7fd59977 |
1000 | } |
1001 | |
5c1f974e |
1002 | void CGeometryDoc::OnUpdateBUTTONTest50(CCmdUI* pCmdUI) |
1003 | { |
1004 | if (Current == 50) |
1005 | pCmdUI->SetCheck(true); |
1006 | else |
1007 | pCmdUI->SetCheck(false); |
7fd59977 |
1008 | } |
1009 | |
7fd59977 |
1010 | void CGeometryDoc::OnCloseDocument() |
1011 | { |
5c1f974e |
1012 | // TODO: Add your specialized code here and/or call the base class |
1013 | CDocument::OnCloseDocument(); |
7fd59977 |
1014 | } |
1015 | |
1016 | void CGeometryDoc::Fit() |
1017 | { |
5c1f974e |
1018 | CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; |
1019 | CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); |
1020 | OCC_3dView *pView = (OCC_3dView *) pChild->GetActiveView(); |
1021 | pView->FitAll(); |
7fd59977 |
1022 | } |
1023 | |
1024 | |
1025 | void CGeometryDoc::OnCreateSol() |
1026 | { |
5c1f974e |
1027 | // TODO: Add your command handler code here |
1028 | // Creation d'un sol |
576f8b11 |
1029 | CFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, |
1030 | L"Points Files (*.dat)|*.dat; |All Files (*.*)|*.*||", NULL); |
5c1f974e |
1031 | |
1032 | CString initdir(((OCC_App*) AfxGetApp())->GetInitDataDir()); |
576f8b11 |
1033 | initdir += L"\\Data\\SurfaceFromPoints"; |
5c1f974e |
1034 | |
1035 | dlg.m_ofn.lpstrInitialDir = initdir; |
1036 | |
1037 | if (dlg.DoModal() == IDOK) |
1038 | { |
1039 | SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); |
1040 | CString filename = dlg.GetPathName(); |
1041 | |
1042 | filebuf fic; |
1043 | istream in(&fic); |
576f8b11 |
1044 | if (!fic.open (filename, ios::in)) |
1045 | MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Unable to open file", L"CasCade Error", MB_ICONERROR); |
1046 | |
5c1f974e |
1047 | TColgp_SequenceOfXYZ seqOfXYZ; |
1048 | gp_XYZ pntXYZ; |
1049 | Standard_Integer nbPnt=0; |
1050 | Standard_Real x,y,z; |
1051 | BRep_Builder B; |
1052 | TopoDS_Compound C; |
1053 | B.MakeCompound(C); |
1054 | while (!in.fail()|| !in.eof()) |
1055 | { |
1056 | if (in >> x && in >> y && in >> z){ |
1057 | pntXYZ.SetX(x); |
1058 | pntXYZ.SetY(y); |
1059 | pntXYZ.SetZ(z); |
1060 | nbPnt++; |
1061 | seqOfXYZ.Append(pntXYZ); |
1062 | BRepBuilderAPI_MakeVertex V(gp_Pnt(x, y, z)); |
1063 | B.Add(C,V.Vertex()); |
1064 | } |
1065 | } |
1066 | fic.close(); |
1067 | Handle(AIS_Shape) anAISCompound = new AIS_Shape(C); |
1068 | myAISContext->Display(anAISCompound, Standard_False); |
1069 | Fit(); |
1070 | Sleep(1000); |
1071 | GeoAlgo_Sol sol; |
1072 | sol.Build(seqOfXYZ); |
1073 | |
1074 | if (sol.IsDone() == Standard_True) |
1075 | { |
1076 | Handle(Geom_BSplineSurface) GeomSol = sol.Surface(); |
1077 | TopoDS_Face aface = BRepBuilderAPI_MakeFace(GeomSol, Precision::Confusion()); |
1078 | if (!BRepAlgo::IsValid(aface)) |
576f8b11 |
1079 | MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : The plate surface is not valid!", L"CasCade Error", MB_ICONERROR); |
5c1f974e |
1080 | Handle_AIS_Shape anAISShape=new AIS_Shape(aface); |
1081 | myAISContext->Display(anAISShape, Standard_False); |
1082 | Fit(); |
1083 | } |
1084 | else |
576f8b11 |
1085 | MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, L"Error : Computation has failed", L"CasCade Error", MB_ICONERROR); |
5c1f974e |
1086 | } |
7fd59977 |
1087 | } |
1088 | |
1089 | /********************************************************************************************* |
1090 | ********************** S I M P L I F Y ***************************************************** |
1091 | *********************************************************************************************/ |
1092 | |
1093 | //================================================================ |
1094 | // Function : fixParam |
1095 | // Purpose : assings a finite value to theParam if it intinite |
1096 | // (equal to +- Precision::Infinite()) |
1097 | //================================================================ |
1098 | static Standard_Boolean fixParam(Standard_Real& theParam) |
1099 | { |
1100 | Standard_Boolean aResult = Standard_False; |
1101 | if (Precision::IsNegativeInfinite(theParam)) |
1102 | { |
1103 | theParam = -MAX_PARAM; |
1104 | aResult = Standard_True; |
1105 | } |
1106 | if (Precision::IsPositiveInfinite(theParam)) |
1107 | { |
1108 | theParam = MAX_PARAM; |
1109 | aResult = Standard_True; |
1110 | } |
1111 | return aResult; |
1112 | } |
1113 | |
1114 | |
1115 | void CGeometryDoc::OnSimplify() |
1116 | { |
5c1f974e |
1117 | CString initfile(((OCC_App*) AfxGetApp())->GetInitDataDir()); |
576f8b11 |
1118 | initfile += L"\\..\\..\\Data\\"; |
1119 | initfile += L"shell1.brep"; |
7fd59977 |
1120 | |
576f8b11 |
1121 | std::filebuf aFileBuf; |
1122 | std::istream aStream (&aFileBuf); |
1123 | if (!aFileBuf.open (initfile, ios::in)) |
1124 | { |
1125 | initfile += L" was not found. The sample can not be shown."; |
1126 | myCResultDialog.SetText (initfile); |
1127 | return; |
1128 | } |
7fd59977 |
1129 | |
1130 | TopoDS_Shape aShape; |
1131 | BRep_Builder aBld; |
576f8b11 |
1132 | BRepTools::Read (aShape, aStream, aBld); |
1133 | if (aShape.IsNull()) |
7fd59977 |
1134 | { |
576f8b11 |
1135 | initfile += L" is invalid file. The sample can not be shown."; |
1136 | myCResultDialog.SetText(initfile); |
7fd59977 |
1137 | return; |
1138 | } |
7fd59977 |
1139 | myAISContext->SetDisplayMode(AIS_Shaded); |
7fd59977 |
1140 | simplify(aShape); |
1141 | } |
1142 | |
1143 | void CGeometryDoc::simplify(const TopoDS_Shape& aShape) |
1144 | { |
5c573e69 |
1145 | myCResultDialog.SetTitle("Simplify Face"); |
1146 | myCResultDialog.SetText(" TopoDS_Shape aShape;\n" |
1147 | "\n" |
1148 | " // initialize aShape\n" |
1149 | " //aShape = ...\n" |
1150 | "\n" |
1151 | " // define parameter triangulation\n" |
1152 | " Standard_Real aDeflection = 0.1;\n" |
1153 | " \n" |
1154 | " // removes all the triangulations of the faces ,\n" |
1155 | " //and all the polygons on the triangulations of the edges\n" |
1156 | " BRepTools::Clean(aShape);\n" |
1157 | " // adds a triangulation of the shape aShape with the deflection aDeflection\n" |
1158 | " BRepMesh::Mesh(aShape,aDeflection);\n" |
1159 | "\n" |
1160 | " Standard_Integer aIndex = 1, nbNodes = 0;\n" |
1161 | " \n" |
1162 | " // define two sequence of points\n" |
1163 | " TColgp_SequenceOfPnt aPoints, aPoints1;\n" |
1164 | " \n" |
1165 | " // triangulation\n" |
1166 | " for(TopExp_Explorer aExpFace(aShape,TopAbs_FACE); aExpFace.More(); aExpFace.Next())\n" |
1167 | " { \n" |
1168 | " TopoDS_Face aFace = TopoDS::Face(aExpFace.Current());\n" |
1169 | " TopLoc_Location aLocation;\n" |
1170 | "\n" |
1171 | " // takes the triangulation of the face aFace\n" |
1172 | " Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation);\n" |
1173 | "\n" |
1174 | " if(!aTr.IsNull())\n" |
1175 | " { \n" |
1176 | " // takes the array of nodes for this triangulation\n" |
1177 | " const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); \n" |
1178 | " nbNodes = aNodes.Length();\n" |
1179 | "\n" |
1180 | " for( Standard_Integer i = 1; i <= nbNodes; i++)\n" |
1181 | " {\n" |
1182 | " // create seguence of node points in absolute coordinate system\n" |
1183 | " gp_Pnt aPnt = aNodes(i).Transformed(aLocation);\n" |
1184 | " aPoints.Append(aPnt);\n" |
1185 | " \n" |
1186 | " }\n" |
1187 | " }\n" |
1188 | " }\n" |
1189 | " \n" |
1190 | " // remove double points\n" |
1191 | " nbNodes = aPoints.Length();\n" |
1192 | " for( Standard_Integer i = 1; i <= nbNodes; i++)\n" |
1193 | " {\n" |
1194 | " gp_Pnt aPi = aPoints(i);\n" |
1195 | " for( Standard_Integer j = i + 1; j < nbNodes; j++)\n" |
1196 | " {\n" |
1197 | " gp_Pnt aPj = aPoints(j);\n" |
1198 | " if(!aPi.IsEqual(aPj,0.9))\n" |
1199 | " aIndex++;\n" |
1200 | " }\n" |
1201 | " if(aIndex == j - 1)\n" |
1202 | " aPoints1.Append(aPi);\n" |
1203 | "\n" |
1204 | " aIndex = i + 1;\n" |
1205 | " }\n" |
1206 | "\n" |
1207 | " // find max point\n" |
1208 | " aIndex = 0;\n" |
1209 | " gp_Pnt aPntMax = aPoints1(1);\n" |
1210 | " nbNodes = aPoints1.Length();\n" |
1211 | " for(i = 2; i <= nbNodes; i++)\n" |
1212 | " {\n" |
1213 | " if(aPoints1(i).X() > aPntMax.X())\n" |
1214 | " {\n" |
1215 | " aIndex = i;\n" |
1216 | " aPntMax = aPoints1(aIndex); \n" |
1217 | " } \n" |
1218 | " }\n" |
1219 | "\n" |
1220 | " // clear seguence\n" |
1221 | " aPoints.Clear();\n" |
1222 | "\n" |
1223 | " Standard_Integer nbLeftNodes = nbNodes;\n" |
1224 | "\n" |
1225 | " // ascending sort - fill aPoints with ascending \n" |
1226 | " // by X coordinate points from aPoints1\n" |
1227 | " for(i = 1; i < nbNodes; i++)\n" |
1228 | " {\n" |
1229 | " Standard_Real aMin = aPntMax.X();\n" |
1230 | " aIndex = 1;\n" |
1231 | " for( Standard_Integer j = 1; j <= nbLeftNodes; j++)\n" |
1232 | " {\n" |
1233 | " if(aPoints1(j).X() < aMin)\n" |
1234 | " {\n" |
1235 | " aMin = aPoints1(j).X();\n" |
1236 | " aIndex = j;\n" |
1237 | " } \n" |
1238 | " }\n" |
1239 | " aPoints.Append(aPoints1(aIndex));\n" |
1240 | " aPoints1.Remove(aIndex);\n" |
1241 | " nbLeftNodes = aPoints1.Length();\n" |
1242 | " }\n" |
1243 | " aPoints.Append(aPntMax);\n" |
1244 | "\n" |
1245 | " // define parameters GeomPlate_BuildPlateSurface\n" |
1246 | " Standard_Integer Degree = 3;\n" |
1247 | " Standard_Integer NbPtsOnCur = 10;\n" |
1248 | " Standard_Integer NbIter = 3;\n" |
1249 | " Standard_Integer Order = 0;\n" |
1250 | " Standard_Integer MaxSeg = 9;\n" |
1251 | " Standard_Integer MaxDegree = 5;\n" |
1252 | " Standard_Real dmax, anApproxTol = 0.001;\n" |
1253 | " Standard_Real aConstrTol = Precision::Confusion();\n" |
1254 | " \n" |
1255 | " // define object BuildPlateSurface\n" |
1256 | " GeomPlate_BuildPlateSurface BPSurf(Degree,NbPtsOnCur,NbIter);\n" |
1257 | " \n" |
1258 | " // add point constraints to GeomPlate_BuildPlateSurface object\n" |
1259 | " nbNodes = aPoints.Length();\n" |
1260 | " for (i = 1; i <= nbNodes; i++)\n" |
1261 | " BPSurf.Add(new GeomPlate_PointConstraint(aPoints(i), Order, aConstrTol));\n" |
1262 | "\n" |
1263 | " BPSurf.Perform();\n" |
1264 | "\n" |
1265 | " // make PlateSurface\n" |
1266 | " Handle(GeomPlate_Surface) PSurf;\n" |
1267 | " Handle(Geom_Surface) aSurf;\n" |
1268 | " \n" |
1269 | " if (BPSurf.IsDone())\n" |
1270 | " {\n" |
1271 | " PSurf = BPSurf.Surface();\n" |
1272 | "\n" |
1273 | " // define parameter approximation\n" |
1274 | " dmax = Max(0.01,10*BPSurf.G0Error());\n" |
1275 | "\n" |
1276 | " // make approximation\n" |
1277 | " GeomPlate_MakeApprox Mapp(PSurf,anApproxTol, MaxSeg,MaxDegree,dmax);\n" |
1278 | " aSurf = Mapp.Surface();\n" |
1279 | " }\n" |
1280 | " else \n" |
1281 | " return;\n" |
1282 | "\n" |
1283 | " ShapeAnalysis_FreeBounds aFreeBounds(aShape, Standard_False, Standard_True);\n" |
1284 | " TopoDS_Compound aClosedWires = aFreeBounds.GetClosedWires();\n" |
1285 | " TopTools_IndexedMapOfShape aWires;\n" |
1286 | " TopExp::MapShapes(aClosedWires, TopAbs_WIRE, aWires);\n" |
1287 | " TopoDS_Wire aWire;\n" |
1288 | " Standard_Integer nbWires = aWires.Extent();\n" |
1289 | " if (nbWires) \n" |
1290 | " aWire = TopoDS::Wire(aWires(1));\n" |
1291 | " else \n" |
1292 | " return;\n" |
1293 | "\n" |
1294 | " BRep_Builder B;\n" |
1295 | " TopoDS_Face aFace;\n" |
1296 | " B.MakeFace(aFace, aSurf, Precision::Confusion());\n" |
1297 | " B.Add(aFace, aWire);\n" |
1298 | " Handle_ShapeFix_Shape sfs = new ShapeFix_Shape(aFace);\n" |
1299 | " sfs->Perform();\n" |
1300 | " TopoDS_Shape aFixedFace = sfs->Shape();\n" |
1301 | " if (aFixedFace.IsNull()) \n" |
1302 | " return;\n"); |
7fd59977 |
1303 | |
5c1f974e |
1304 | // define parameter triangulation |
1305 | Standard_Real aDeflection = 0.1; |
1306 | |
1307 | // removes all the triangulations of the faces , |
1308 | //and all the polygons on the triangulations of the edges |
1309 | BRepTools::Clean(aShape); |
1310 | // adds a triangulation of the shape aShape with the deflection aDeflection |
9a148b08 |
1311 | BRepMesh_IncrementalMesh(aShape,aDeflection); |
5c1f974e |
1312 | |
1313 | Standard_Integer aIndex = 1, nbNodes = 0; |
1314 | |
1315 | // define two sequence of points |
1316 | TColgp_SequenceOfPnt aPoints, aPoints1; |
1317 | |
1318 | // triangulation |
1319 | for(TopExp_Explorer aExpFace(aShape,TopAbs_FACE); aExpFace.More(); aExpFace.Next()) |
1320 | { |
1321 | TopoDS_Face aFace = TopoDS::Face(aExpFace.Current()); |
1322 | TopLoc_Location aLocation; |
1323 | |
1324 | // takes the triangulation of the face aFace |
1325 | Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); |
1326 | |
1327 | if(!aTr.IsNull()) |
1328 | { |
1329 | // takes the array of nodes for this triangulation |
1330 | const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); |
1331 | nbNodes = aNodes.Length(); |
1332 | |
1333 | for( Standard_Integer i = 1; i <= nbNodes; i++) |
1334 | { |
1335 | // create seguence of node points in absolute coordinate system |
1336 | gp_Pnt aPnt = aNodes(i).Transformed(aLocation); |
1337 | aPoints.Append(aPnt); |
1338 | |
1339 | } |
7fd59977 |
1340 | } |
1341 | } |
5c1f974e |
1342 | |
1343 | // remove double points |
1344 | nbNodes = aPoints.Length(); |
1345 | Standard_Integer i; |
1346 | for( i = 1; i <= nbNodes; i++) |
7fd59977 |
1347 | { |
5c1f974e |
1348 | gp_Pnt aPi = aPoints(i); |
1349 | Standard_Integer j; |
1350 | for( j = i + 1; j < nbNodes; j++) |
1351 | { |
1352 | gp_Pnt aPj = aPoints(j); |
1353 | if(!aPi.IsEqual(aPj,0.9)) |
1354 | aIndex++; |
1355 | } |
1356 | if(aIndex == j - 1) |
1357 | aPoints1.Append(aPi); |
7fd59977 |
1358 | |
5c1f974e |
1359 | aIndex = i + 1; |
1360 | } |
7fd59977 |
1361 | |
5c1f974e |
1362 | // find max point |
1363 | aIndex = 0; |
1364 | gp_Pnt aPntMax = aPoints1(1); |
1365 | nbNodes = aPoints1.Length(); |
1366 | for(i = 2; i <= nbNodes; i++) |
7fd59977 |
1367 | { |
5c1f974e |
1368 | if(aPoints1(i).X() > aPntMax.X()) |
1369 | { |
1370 | aIndex = i; |
1371 | aPntMax = aPoints1(aIndex); |
1372 | } |
1373 | } |
7fd59977 |
1374 | |
5c1f974e |
1375 | // clear seguence |
1376 | aPoints.Clear(); |
7fd59977 |
1377 | |
5c1f974e |
1378 | Standard_Integer nbLeftNodes = nbNodes; |
7fd59977 |
1379 | |
5c1f974e |
1380 | // ascending sort - fill aPoints with ascending |
1381 | // by X coordinate points from aPoints1 |
1382 | for(i = 1; i < nbNodes; i++) |
7fd59977 |
1383 | { |
5c1f974e |
1384 | Standard_Real aMin = aPntMax.X(); |
1385 | aIndex = 1; |
1386 | for( Standard_Integer j = 1; j <= nbLeftNodes; j++) |
7fd59977 |
1387 | { |
5c1f974e |
1388 | if(aPoints1(j).X() < aMin) |
1389 | { |
1390 | aMin = aPoints1(j).X(); |
1391 | aIndex = j; |
1392 | } |
1393 | } |
1394 | aPoints.Append(aPoints1(aIndex)); |
1395 | aPoints1.Remove(aIndex); |
1396 | nbLeftNodes = aPoints1.Length(); |
7fd59977 |
1397 | } |
5c1f974e |
1398 | aPoints.Append(aPntMax); |
7fd59977 |
1399 | |
5c1f974e |
1400 | // define parameters GeomPlate_BuildPlateSurface |
1401 | Standard_Integer Degree = 3; |
1402 | Standard_Integer NbPtsOnCur = 10; |
1403 | Standard_Integer NbIter = 3; |
1404 | Standard_Integer Order = 0; |
1405 | Standard_Integer MaxSeg = 9; |
1406 | Standard_Integer MaxDegree = 5; |
1407 | Standard_Real dmax, anApproxTol = 0.001; |
1408 | Standard_Real aConstrTol = Precision::Confusion(); |
7fd59977 |
1409 | |
5c1f974e |
1410 | // define object BuildPlateSurface |
1411 | GeomPlate_BuildPlateSurface BPSurf(Degree,NbPtsOnCur,NbIter); |
7fd59977 |
1412 | |
5c1f974e |
1413 | // add point constraints to GeomPlate_BuildPlateSurface object |
1414 | nbNodes = aPoints.Length(); |
1415 | for (i = 1; i <= nbNodes; i++) |
1416 | BPSurf.Add(new GeomPlate_PointConstraint(aPoints(i), Order, aConstrTol)); |
7fd59977 |
1417 | |
5c1f974e |
1418 | BPSurf.Perform(); |
7fd59977 |
1419 | |
5c1f974e |
1420 | // make PlateSurface |
1421 | Handle(GeomPlate_Surface) PSurf; |
1422 | Handle(Geom_Surface) aSurf; |
7fd59977 |
1423 | |
5c1f974e |
1424 | if (BPSurf.IsDone()) |
1425 | { |
1426 | PSurf = BPSurf.Surface(); |
7fd59977 |
1427 | |
5c1f974e |
1428 | // define parameter approximation |
1429 | dmax = Max(0.01,10*BPSurf.G0Error()); |
7fd59977 |
1430 | |
5c1f974e |
1431 | // make approximation |
1432 | GeomPlate_MakeApprox Mapp(PSurf,anApproxTol, MaxSeg,MaxDegree,dmax); |
1433 | aSurf = Mapp.Surface(); |
1434 | } |
1435 | else |
1436 | return; |
1437 | |
1438 | ShapeAnalysis_FreeBounds aFreeBounds(aShape, Standard_False, Standard_True); |
1439 | TopoDS_Compound aClosedWires = aFreeBounds.GetClosedWires(); |
1440 | TopTools_IndexedMapOfShape aWires; |
1441 | TopExp::MapShapes(aClosedWires, TopAbs_WIRE, aWires); |
1442 | TopoDS_Wire aWire; |
1443 | Standard_Integer nbWires = aWires.Extent(); |
1444 | if (nbWires) |
1445 | aWire = TopoDS::Wire(aWires(1)); |
1446 | else |
1447 | return; |
1448 | |
1449 | BRep_Builder B; |
1450 | TopoDS_Face aFace; |
1451 | B.MakeFace(aFace, aSurf, Precision::Confusion()); |
1452 | B.Add(aFace, aWire); |
1453 | Handle_ShapeFix_Shape sfs = new ShapeFix_Shape(aFace); |
1454 | sfs->Perform(); |
1455 | TopoDS_Shape aFixedFace = sfs->Shape(); |
1456 | if (aFixedFace.IsNull()) |
1457 | return; |
1458 | |
1459 | // output surface, make it half transparent |
1460 | Handle_AIS_InteractiveObject aSurfIO = drawSurface( |
1461 | aSurf, Quantity_NOC_LEMONCHIFFON3, Standard_False); |
1462 | aSurfIO->SetTransparency(0.5); |
1463 | myAISContext->Display(aSurfIO,Standard_False); |
1464 | Fit(); |
1465 | |
1466 | if(WAIT_A_LITTLE) return; |
1467 | |
1468 | // output points |
1469 | for(i = 1; i <= nbNodes; i++) |
1470 | drawPoint(aPoints(i)); |
1471 | |
1472 | if(WAIT_A_LITTLE) return; |
1473 | |
1474 | // output resulting face |
1475 | drawShape(aFixedFace); |
7fd59977 |
1476 | } |
1477 | |
1478 | Handle_AIS_InteractiveObject CGeometryDoc::drawSurface |
1479 | (const Handle_Geom_Surface& theSurface, |
1480 | const Quantity_Color& theColor, |
1481 | const Standard_Boolean toDisplay) |
1482 | { |
1483 | Standard_Real u1, u2, v1, v2; |
1484 | theSurface->Bounds(u1,u2,v1,v2); |
1485 | fixParam(u1); |
1486 | fixParam(u2); |
1487 | fixParam(v1); |
1488 | fixParam(v2); |
1489 | |
1490 | Handle_AIS_Shape aGraphicSurface = |
9181b66d |
1491 | new AIS_Shape(BRepBuilderAPI_MakeFace (theSurface, u1, u2, v1, v2, Precision::Confusion())); |
7fd59977 |
1492 | |
1493 | myAISContext->SetMaterial(aGraphicSurface, Graphic3d_NOM_PLASTIC, toDisplay); |
1494 | myAISContext->SetColor(aGraphicSurface, theColor, toDisplay); |
5c1f974e |
1495 | if (toDisplay) |
1496 | { |
1497 | if (FitMode) |
1498 | { |
1499 | myAISContext->Display (aGraphicSurface, Standard_False); |
1500 | Fit(); |
1501 | } |
1502 | else |
1503 | myAISContext->Display (aGraphicSurface); |
7fd59977 |
1504 | } |
5c1f974e |
1505 | |
7fd59977 |
1506 | return aGraphicSurface; |
1507 | } |
1508 | |
1509 | Standard_Boolean CGeometryDoc::WaitForInput (unsigned long aMilliSeconds) |
1510 | { |
1511 | //::WaitForSingleObject(::CreateEvent (NULL, FALSE, FALSE, NULL), aMilliSeconds); |
1512 | if (::MsgWaitForMultipleObjects(0, NULL, FALSE, aMilliSeconds, |
1513 | QS_KEY | QS_MOUSEBUTTON) != WAIT_TIMEOUT) |
1514 | { |
1515 | MSG msg; |
1516 | if (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) |
1517 | { |
1518 | if (msg.message == WM_KEYUP) |
1519 | { |
1520 | ::PeekMessage (&msg, NULL, 0, 0, PM_REMOVE); |
1521 | return WaitForInput (aMilliSeconds); |
1522 | } |
1523 | else |
1524 | return Standard_True; |
1525 | } |
1526 | } |
1527 | return Standard_False; |
1528 | } |
1529 | |
1530 | Handle_AIS_Point CGeometryDoc::drawPoint |
1531 | (const gp_Pnt& aPnt, |
1532 | const Quantity_Color& theColor, |
1533 | const Standard_Boolean toDisplay) |
1534 | { |
1535 | Handle(AIS_Point) aGraphicPoint = new AIS_Point (new Geom_CartesianPoint(aPnt)); |
1536 | |
1537 | myAISContext->SetColor (aGraphicPoint, theColor, toDisplay); |
5c1f974e |
1538 | if (toDisplay) |
1539 | { |
1540 | myAISContext->Display (aGraphicPoint); |
7fd59977 |
1541 | //COCCDemoDoc::Fit(); |
1542 | } |
1543 | |
1544 | return aGraphicPoint; |
1545 | } |
1546 | |
1547 | Handle_AIS_Shape CGeometryDoc::drawShape |
1548 | (const TopoDS_Shape& theShape, |
1549 | const Graphic3d_NameOfMaterial theMaterial, |
1550 | const Standard_Boolean toDisplay) |
1551 | { |
1552 | Handle_AIS_Shape aGraphicShape = new AIS_Shape(theShape); |
1553 | |
1554 | myAISContext->SetMaterial(aGraphicShape, theMaterial, toDisplay); |
5c1f974e |
1555 | if (toDisplay) |
1556 | { |
1557 | if (FitMode) |
1558 | { |
1559 | myAISContext->Display (aGraphicShape, Standard_False); |
1560 | Fit(); |
1561 | } |
1562 | else |
1563 | myAISContext->Display (aGraphicShape); |
7fd59977 |
1564 | } |
1565 | |
1566 | return aGraphicShape; |
1567 | } |