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