The Rockfish sample project demonstrates how one might set up a RhinoCommon plug-in to host a Windows Communication Foundation (WCF) service.
To build the Rockfish solution, you will need the following:
- Visual Studio - Any of the free version of Microsoft Visual Studio, that can build plug-ins for Rhino, will work.
- Rhino - The project current targets Rhino 5. But with some minor effort, the project could easily be refactored to work with Rhino 6.
The Rockfish sample solution contains the following projects:
RockfishServer - This project builds a RhinoCommon plug-in that hosts a WCF Service. The service current uses basic HTTP binding, but it has provisions for named pipes for ease of testing. The service contract has four simple operations that can be called from client systems. The project has three commands:
RockfishStart
- Starts the service.RockfishStart
- Stops the service.RockfishStart
- Configures service options.
Note, to access the service remotely, you will need to open TCP Port 8000
on any firewall software running on the system. And in order for the service to listen on TCP Port 8000
, Rhino will need to be launched "as Administrator."
RockfishClient - This project also builds a RhinoCommon plug-in, and it consumes the service provided by RockfishServer. The plug-in provides five simple commands:
RF_SetServer
- Allows you to specify the Rockfish server to be used by the plug-in.RF_Echo
- Tests connectivity with the server by sending a string and then printing the server's response on the command line.RF_PolylineFromPoints
- Selects points objects and then sends their location to the server. The server creates a polyline curve from the points and sends it back.RF_IntersectBreps
- Selects two Brep objects and then sends them to the server. The server calculates the intersection curves and return them back.RF_CreateMeshFromBrep
- Selects one or more Brep objects and then sends them to the server. The server generates meshes from the Brep and return them back.
RockfishCommon - This project creates a .NET assembly that references RhinoCommon. This assembly provides common classes that are shared between the RockfishServer and RockfishClient projects. The classes and interfaces of interest are:
IRockfishServer
- This is the WCF Service Contract that is implemented by RockfishServer.RockfishChannel
This class is responsible with opening a communication channel with a Rockfish server and calling function in the server'sIRockfishServer
implementation.RockfishGeometry
- This class defines a WCF Data Contract. The class also handles the binary serialization and de-serializationRhino.Geometry.GeometryBase
inherited objects.
RockfishConsole - This project creates a .NET console application. The project references the Rhino3dmIO NuGet package which allows .NET applications to read and write Rhino's .3dm
file format. When built, the application will read Breps from .3dm
files and the send them to a Rockfish server. The server will, in turn, return mesh objects which are written to a new .3dm
file. Here is the command line syntax:
C:\> RockfishConsole <host_name> <file_name>
The sample WCF Service instance is multi-threaded. But Rhino is not. You need to keep this in mind when adding functionality to the service.