├── CMakeLists.txt ├── Heat_method_3.C ├── Heat_method_3.h ├── README.md └── dso ├── Heat_method_3.dll ├── libgmp-10.dll └── libmpfr-4.dll /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.6 ) 2 | 3 | project( Heat_method ) 4 | 5 | # CMAKE_PREFIX_PATH must contain the path to the toolkit/cmake subdirectory of 6 | # the Houdini installation. See the "Compiling with CMake" section of the HDK 7 | # documentation for more details, which describes several options for 8 | # specifying this path. 9 | list( APPEND CMAKE_PREFIX_PATH "C:/Program Files/Side Effects Software/Houdini 18.0.287/toolkit/cmake" ) 10 | 11 | # Locate Houdini's libraries and header files. 12 | # Registers an imported library target named 'Houdini'. 13 | find_package( Houdini REQUIRED ) 14 | 15 | set( library_name Heat_method_3 ) 16 | 17 | # Code generation for the embedded DS file in Heat_method_3.C. 18 | houdini_generate_proto_headers( FILES Heat_method_3.C ) 19 | 20 | # Add a library and its source files. 21 | add_library( ${library_name} SHARED 22 | Heat_method_3.C 23 | Heat_method_3.h 24 | ) 25 | #add ThirdPartyInclude 26 | #EIGENDIR 27 | list( APPEND ThirdPartIncludePath "$ENV{BOOST_INCLUDEDIR}") 28 | list( APPEND ThirdPartIncludePath "$ENV{CGAL_DIR}/include") 29 | list( APPEND ThirdPartIncludePath "$ENV{CGAL_DIR}/auxiliary/gmp/include") 30 | list( APPEND ThirdPartIncludePath "C:/dev/Eigen3.37") 31 | target_include_directories( ${library_name} PRIVATE 32 | ${ThirdPartIncludePath} 33 | ) 34 | #add ThirdPartylib 35 | list( APPEND ThirdPartLibPath "$ENV{CGAL_DIR}/auxiliary/gmp/lib/libmpfr-4.lib") 36 | list( APPEND ThirdPartLibPath "$ENV{CGAL_DIR}/auxiliary/gmp/lib/libgmp-10.lib") 37 | target_link_libraries( ${library_name} ${ThirdPartLibPath}) 38 | # Link against the Houdini libraries, and add required include directories and 39 | # compile definitions. 40 | target_link_libraries( ${library_name} Houdini ) 41 | 42 | # Include ${CMAKE_CURRENT_BINARY_DIR} for the generated header. 43 | target_include_directories( ${library_name} PRIVATE 44 | ${CMAKE_CURRENT_BINARY_DIR} 45 | ) 46 | 47 | # Sets several common target properties, such as the library's output directory. 48 | houdini_configure_target( ${library_name} ) 49 | -------------------------------------------------------------------------------- /Heat_method_3.C: -------------------------------------------------------------------------------- 1 | 2 | #include "Heat_method_3.h" 3 | 4 | // This is an automatically generated header file based on theDsFile, below, 5 | // to provide Heat_method_3Parms, an easy way to access parameter values from 6 | // Heat_method_3Verb::cook with the correct type. 7 | #include "Heat_method_3.proto.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | typedef CGAL::Simple_cartesian Kernel; 32 | typedef Kernel::Point_3 Point_3; 33 | typedef CGAL::Surface_mesh Triangle_mesh; 34 | typedef boost::graph_traits::vertex_descriptor vertex_descriptor; 35 | typedef Triangle_mesh::Property_map Vertex_distance_map; 36 | typedef Triangle_mesh::Face_index face_descriptor; 37 | 38 | using namespace HDK_Heat_method_3; 39 | // 40 | // Help is stored in a "wiki" style text file. This text file should be copied 41 | // to $HOUDINI_PATH/help/nodes/sop/star.txt 42 | // 43 | // See the sample_install.sh file for an example. 44 | // 45 | 46 | /// This is the internal name of the SOP type. 47 | /// It isn't allowed to be the same as any other SOP's type name. 48 | const UT_StringHolder Heat_method_3::theSOPTypeName("CGAL_Heat_method"_sh); 49 | 50 | /// newSopOperator is the hook that Houdini grabs from this dll 51 | /// and invokes to register the SOP. In this case, we add ourselves 52 | /// to the specified operator table. 53 | void 54 | newSopOperator(OP_OperatorTable *table) 55 | { 56 | table->addOperator(new OP_Operator( 57 | Heat_method_3::theSOPTypeName, // Internal name 58 | "CGAL_Heat_method", // UI name 59 | Heat_method_3::myConstructor, // How to build the SOP 60 | Heat_method_3::buildTemplates(), // My parameters 61 | 0, // Min # of sources 62 | 1, // Max # of sources 63 | nullptr, // Custom local variables (none) 64 | OP_FLAG_GENERATOR)); // Flag it as generator 65 | } 66 | 67 | /// This is a multi-line raw string specifying the parameter interface 68 | /// for this SOP. 69 | static const char *theDsFile = R"THEDSFILE( 70 | { 71 | name parameters 72 | parm { 73 | name "shourcept" // Internal parameter name 74 | label "Shourcept" // Descriptive parameter name for user interface 75 | type integer 76 | default { "0" } // Default for this parameter on new nodes 77 | range { 0! 100000 } // The value is prevented from going below 2 at all. 78 | // The UI slider goes up to 50, but the value can go higher. 79 | export all // This makes the parameter show up in the toolbox 80 | // above the viewport when it's in the node's state. 81 | } 82 | } 83 | )THEDSFILE"; 84 | 85 | PRM_Template* 86 | Heat_method_3::buildTemplates() 87 | { 88 | static PRM_TemplateBuilder templ("Heat_method_3.C"_sh, theDsFile); 89 | return templ.templates(); 90 | } 91 | 92 | class Heat_method_3Verb : public SOP_NodeVerb 93 | { 94 | public: 95 | Heat_method_3Verb() {} 96 | virtual ~Heat_method_3Verb() {} 97 | 98 | virtual SOP_NodeParms *allocParms() const { return new Heat_method_3Parms(); } 99 | virtual UT_StringHolder name() const { return Heat_method_3::theSOPTypeName; } 100 | 101 | virtual CookMode cookMode(const SOP_NodeParms *parms) const { return COOK_GENERIC; } 102 | 103 | virtual void cook(const CookParms &cookparms) const; 104 | 105 | /// This static data member automatically registers 106 | /// this verb class at library load time. 107 | static const SOP_NodeVerb::Register theVerb; 108 | }; 109 | 110 | // The static member variable definition has to be outside the class definition. 111 | // The declaration is inside the class. 112 | const SOP_NodeVerb::Register Heat_method_3Verb::theVerb; 113 | 114 | const SOP_NodeVerb * 115 | Heat_method_3::cookVerb() const 116 | { 117 | return Heat_method_3Verb::theVerb.get(); 118 | } 119 | 120 | OP_ERROR HDK_Heat_method_3::Heat_method_3::cookMySop(OP_Context &context) 121 | { 122 | OP_AutoLockInputs inputs(this); 123 | if (inputs.lock(context) >= UT_ERROR_ABORT) 124 | return error(); 125 | 126 | // Duplicate input geometry 127 | duplicateSource(0, context); 128 | 129 | // Flag the SOP as being time dependent (i.e. cook on time changes) 130 | flags().setTimeDep(true); 131 | return cookMyselfAsVerb(context); 132 | } 133 | 134 | 135 | /// This is the function that does the actual work. 136 | void 137 | Heat_method_3Verb::cook(const SOP_NodeVerb::CookParms &cookparms) const 138 | { 139 | auto &&sopparms = cookparms.parms(); 140 | GU_Detail *detail = cookparms.gdh().gdpNC(); 141 | 142 | // We need two points per division 143 | 144 | int32 sourcePtnum = sopparms.getShourcept(); 145 | 146 | Triangle_mesh tm; 147 | GA_Offset ptoff; 148 | std::vector points; 149 | 150 | GA_RWHandleV3 Phandle(detail->findAttribute(GA_ATTRIB_POINT, "P")); 151 | 152 | detail->addFloatTuple(GA_ATTRIB_POINT, "distance", 1); 153 | GA_RWHandleF DistanceHandl(detail, GA_ATTRIB_POINT, "distance"); 154 | 155 | 156 | std::vector indexmap; 157 | GEO_Primitive *prim; 158 | 159 | GA_FOR_ALL_PTOFF(detail, ptoff) 160 | { 161 | UT_Vector3 Pvalue = Phandle.get(ptoff); 162 | Point_3 ptTemp = Point_3(Pvalue.x(), Pvalue.y(), Pvalue.z()); 163 | vertex_descriptor u = tm.add_vertex(ptTemp); 164 | indexmap.push_back(u); 165 | } 166 | std::vector ptoffsetmap; 167 | 168 | GA_FOR_ALL_PRIMITIVES(detail, prim) 169 | { 170 | GA_Range ptRange = prim->getPointRange(true); 171 | if (ptRange.getEntries() !=3 ) 172 | { 173 | cookparms.sopAddWarning(SOP_MESSAGE, "Input mesh must be Triangle_mesh!"); 174 | return; 175 | } 176 | int32 size = 0; 177 | for (GA_Iterator it(ptRange); !it.atEnd(); ++it) 178 | { 179 | GA_Offset ptoffset = (*it); 180 | ptoffsetmap.push_back((int32)ptoffset); 181 | } 182 | } 183 | for (size_t i =0;i< ptoffsetmap.size()/3;i++) 184 | { 185 | tm.add_face(indexmap[ptoffsetmap[i*3]], indexmap[ptoffsetmap[i*3+1]], indexmap[ptoffsetmap[i*3+2]]); 186 | } 187 | 188 | Vertex_distance_map vertex_distance = tm.add_property_map("v:distance", 0).first; 189 | vertex_descriptor source = (vertices(tm).first)[sourcePtnum]; 190 | CGAL::Heat_method_3::estimate_geodesic_distances(tm, vertex_distance, source); 191 | 192 | int32 indexpt = -1; 193 | for (vertex_descriptor vd : vertices(tm)) 194 | { 195 | indexpt += 1; 196 | ; 197 | fpreal32 distance = get(vertex_distance, vd); 198 | if (indexpt < indexmap.size()) 199 | { 200 | GA_Offset ptOff =detail->pointOffset(indexpt); 201 | DistanceHandl.set(ptOff, distance); 202 | } 203 | else 204 | { 205 | std::cout << vd << " (" << tm.point(vd) << ")" 206 | << " is at distance " << get(vertex_distance, vd) << std::endl; 207 | } 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /Heat_method_3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 3 | * Side Effects Software Inc. All rights reserved. 4 | * 5 | * Redistribution and use of Houdini Development Kit samples in source and 6 | * binary forms, with or without modification, are permitted provided that the 7 | * following conditions are met: 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. The name of Side Effects Software may not be used to endorse or 11 | * promote products derived from this software without specific prior 12 | * written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS 15 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 17 | * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 20 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 23 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | *---------------------------------------------------------------------------- 26 | * This SOP builds a star. 27 | */ 28 | 29 | #ifndef __Heat_method_3_h__ 30 | #define __Heat_method_3_h__ 31 | 32 | #include 33 | #include 34 | 35 | namespace HDK_Heat_method_3 { 36 | /// This is the SOP class definition. It doesn't need to be in a separate 37 | /// file like this. This is just an example of a header file, in case 38 | /// another file needs to reference something in here. 39 | /// You shouldn't have to change anything in here except the name of the class. 40 | class Heat_method_3 : public SOP_Node 41 | { 42 | public: 43 | static PRM_Template *buildTemplates(); 44 | static OP_Node *myConstructor(OP_Network *net, const char *name, OP_Operator *op) 45 | { 46 | return new Heat_method_3(net, name, op); 47 | } 48 | 49 | static const UT_StringHolder theSOPTypeName; 50 | 51 | virtual const SOP_NodeVerb *cookVerb() const override; 52 | 53 | protected: 54 | Heat_method_3(OP_Network *net, const char *name, OP_Operator *op) 55 | : SOP_Node(net, name, op) 56 | { 57 | // All verb SOPs must manage data IDs, to track what's changed 58 | // from cook to cook. 59 | mySopFlags.setManagesDataIDs(true); 60 | } 61 | 62 | virtual ~Heat_method_3() {} 63 | 64 | /// Since this SOP implements a verb, cookMySop just delegates to the verb. 65 | /* virtual OP_ERROR cookMySop(OP_Context &context) override 66 | { 67 | return cookMyselfAsVerb(context); 68 | }*/ 69 | virtual OP_ERROR cookMySop(OP_Context &context) override; 70 | }; 71 | } // End HDK_Sample namespace 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CGAL_Heat_method 2 | ## Use plugin in Houdini 3 | * copy dso to C:\Users\Smile\Documents\houdini18.0 4 | * SOP/CGAL_Heat_method is this node type name 5 | 6 | ## Geting Start With Source 7 | * Using CGAL on Windows (with Visual C++):https://doc.cgal.org/latest/Manual/windows.html 8 | * Add some necessary defines options in houdiniconfig.cmake. 9 | set( _houdini_defines VERSION="18.0.287";CGAL_EIGEN3_ENABLED;BOOST_ALL_DYN_LINK=1;AMD64;SIZEOF_VOID_P=8;FBX_ENABLED=1;OPENCL_ENABLED=1;OPENVDB_ENABLED=1;SESI_LITTLE_ENDIAN;$<$:UT_ASSERT_LEVEL=0>;$<$:UT_ASSERT_LEVEL=1>;$<$:UT_ASSERT_LEVEL=2>;I386;WIN32;SWAP_BITFIELDS;_WIN32_WINNT=0x0600;NOMINMAX;STRICT;WIN32_LEAN_AND_MEAN;_USE_MATH_DEFINES;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;HBOOST_ALL_NO_LIB;EIGEN_MALLOC_ALREADY_ALIGNED=0;$<$:_HAS_ITERATOR_DEBUGGING=0> ) 10 | * Add necessary environment variables: BOOST_INCLUDEDIR and CGAL_DIR 11 | 12 | ## Third Party Dependencies 13 | * boost_1_72 14 | * CGAL-5.0 15 | * Eigen3.37 16 | 17 | -------------------------------------------------------------------------------- /dso/Heat_method_3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmileHoudini/Heat_method_3/05f8eaec10adb7ae6e1d9b51e613a308bcc32c00/dso/Heat_method_3.dll -------------------------------------------------------------------------------- /dso/libgmp-10.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmileHoudini/Heat_method_3/05f8eaec10adb7ae6e1d9b51e613a308bcc32c00/dso/libgmp-10.dll -------------------------------------------------------------------------------- /dso/libmpfr-4.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmileHoudini/Heat_method_3/05f8eaec10adb7ae6e1d9b51e613a308bcc32c00/dso/libmpfr-4.dll --------------------------------------------------------------------------------