Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- //
- // Wired
- //
- // Copyright(C) 1999-2018, tetraface Inc.
- //
- // Sample for Object plug-in for deleting faces with reserving lines
- // in the faces.
- // Created DLL must be installed in "Plugins\Object" directory.
- //
- // オブジェクト中の辺のみを残して面を削除するオブジェクトプラグイン
- // のサンプル。
- // 作成したDLLは"Plugins\Object"フォルダに入れる必要がある。
- //
- //
- //---------------------------------------------------------------------------
- #ifdef WIN32
- #define WIN32_LEAN_AND_MEAN
- #define NOMINMAX
- #include <windows.h>
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <vector>
- #include <algorithm>
- #include "MQPlugin.h"
- #include "MQBasePlugin.h"
- #include "MQWidget.h"
- #include "MQBoneManager.h"
- #include <wchar.h>
- #if __APPLE__
- #include "../osx/StringUtil.h"
- #endif
- #ifdef WIN32
- HINSTANCE hInstance;
- //---------------------------------------------------------------------------
- // DllMain
- //---------------------------------------------------------------------------
- BOOL APIENTRY DllMain( HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- // リソース表示に必要なので、インスタンスを保存しておく
- // Store the instance because it is necessary for displaying resources.
- hInstance = (HINSTANCE)hModule;
- // プラグインとしては特に必要な処理はないので、何もせずにTRUEを返す
- // There is nothing to do for a plugin. So just return TRUE.
- return TRUE;
- }
- #endif
- //---------------------------------------------------------------------------
- // class WiredPlugin
- //---------------------------------------------------------------------------
- class WiredPlugin : public MQObjectPlugin
- {
- public:
- WiredPlugin();
- ~WiredPlugin();
- void GetPlugInID(DWORD *Product, DWORD *ID) override;
- const char *GetPlugInName(void) override;
- const char *EnumString(int index) override;
- BOOL Execute(int index, MQDocument doc) override;
- private:
- BOOL TestBone(MQDocument doc);
- };
- MQBasePlugin *GetPluginClass()
- {
- static WiredPlugin plugin;
- return &plugin;
- }
- WiredPlugin::WiredPlugin()
- {
- }
- WiredPlugin::~WiredPlugin()
- {
- }
- //---------------------------------------------------------------------------
- // MQGetPlugInID
- // プラグインIDを返す。
- // この関数は起動時に呼び出される。
- //---------------------------------------------------------------------------
- void WiredPlugin::GetPlugInID(DWORD *Product, DWORD *ID)
- {
- // プロダクト名(制作者名)とIDを、全部で64bitの値として返す
- // 値は他と重複しないようなランダムなもので良い
- *Product = 0x56A31D35;
- *ID = 0x157E8680;
- }
- //---------------------------------------------------------------------------
- // MQGetPlugInName
- // プラグイン名を返す。
- // この関数は[プラグインについて]表示時に呼び出される。
- //---------------------------------------------------------------------------
- const char *WiredPlugin::GetPlugInName(void)
- {
- // プラグイン名
- return "TestBone ";
- }
- //---------------------------------------------------------------------------
- // MQEnumString
- // ポップアップメニューに表示される文字列を返す。
- // この関数は起動時に呼び出される。
- //---------------------------------------------------------------------------
- const char *WiredPlugin::EnumString(int index)
- {
- static char buffer[256];
- switch(index){
- case 0:
- // Note: following $res$ means the string uses system resource string.
- return "TestBone";
- }
- return NULL;
- }
- //---------------------------------------------------------------------------
- // MQModifyObject
- // メニューから選択されたときに呼び出される。
- //---------------------------------------------------------------------------
- BOOL WiredPlugin::Execute(int index, MQDocument doc)
- {
- switch(index){
- case 0: return TestBone(doc);
- }
- return FALSE;
- }
- //ワイヤー化
- BOOL WiredPlugin::TestBone(MQDocument doc)
- {
- MQBoneManager bone_manager(this, doc);
- int bone_num = bone_manager.GetBoneNum();
- std::vector<UINT> bone_id;
- wchar_t *buf = (wchar_t *)malloc(10000);
- if(bone_num > 0){
- bone_id.resize(bone_num);
- bone_manager.EnumBoneID(bone_id);
- for(int i=0; i<bone_num; i++)
- {
- UINT id = bone_id[i];
- UINT parent_id;
- std::wstring name;
- bone_manager.GetName(id, name);
- bone_manager.GetParent(id, parent_id);
- std::wstring pname;
- bone_manager.GetName(parent_id, pname);
- int child_num=0;
- bone_manager.GetChildNum(id, child_num);
- wsprintfW(buf, L"id: %u (%s), parent: %u (%s)\n child: ", id, name.c_str(), parent_id, pname.c_str());
- if(child_num>0)
- {
- std::vector<UINT> child_bone_id;
- child_bone_id.resize(child_num);
- bone_manager.GetChildren(id, child_bone_id);
- for(int k=0;k<child_num;k++)
- {
- UINT childid = child_bone_id[k];
- std::wstring cname;
- bone_manager.GetName(childid, cname);
- wsprintfW(buf + wcslen(buf), L"%u (%s), ", childid, cname.c_str());
- }
- }
- OutputDebugStringW(buf);
- OutputDebugStringW(L"\n");
- }
- }
- free(buf);
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement