Skip to content

Commit

Permalink
Added cmdSampleBlendCurve.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
dalefugier committed Sep 18, 2024
1 parent 1a768cf commit 9ecc765
Show file tree
Hide file tree
Showing 5 changed files with 566 additions and 53 deletions.
2 changes: 2 additions & 0 deletions cpp/SampleCommands/SampleCommands.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="cmdSampleBlendCurve.cpp" />
<ClCompile Include="cmdSampleChangeDimStyle.cpp" />
<ClCompile Include="cmdSampleClosedCurveContainment.cpp" />
<ClCompile Include="cmdSampleCloseTabbedPanels.cpp" />
Expand Down Expand Up @@ -306,6 +307,7 @@
<ClInclude Include="SampleCommandsPlugIn.h" />
<ClInclude Include="SampleDocumentUserData.h" />
<ClInclude Include="SampleDrawCallback.h" />
<ClInclude Include="SampleFunctions.h" />
<ClInclude Include="SampleObjectUserData.h" />
<ClInclude Include="SampleRectangleObject.h" />
<ClInclude Include="stdafx.h" />
Expand Down
6 changes: 6 additions & 0 deletions cpp/SampleCommands/SampleCommands.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@
<ClCompile Include="cmdSampleGroupUserData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cmdSampleBlendCurve.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SampleCommandsApp.h">
Expand Down Expand Up @@ -899,6 +902,9 @@
<ClInclude Include="SampleDocumentUserData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SampleFunctions.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="SampleCommands.def">
Expand Down
84 changes: 33 additions & 51 deletions cpp/SampleCommands/SampleFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ double ON_CurveTorsion(const ON_Curve& curve, double t)
return tau;
}

/// <summary>
/// Create a blend curve with G0 continuity between two existing curves.
/// </summary>
/// <param name="crvA">Curve to blend from (blending will occur at curve end point).</param>
/// <param name="crvB">Curve to blend to (blending will occur at curve start point).</param>
/// <returns>An ON_Curve representing the blend between A and B.</returns>
/// <remarks>
/// CRITICAL: Memory for the resulting curve is allocated. It is the calling
/// functions responsibility to clean up the memory.
/// </remarks>
ON_Curve* ON_BlendG0Curve(
const ON_Curve* crvA,
const ON_Curve* crvB
)
{
ON_Curve* rc = nullptr;
if (crvA && !crvA->IsClosed() && crvB && !crvB->IsClosed())
{
double ta = crvA->Domain().Max();
double tb = crvB->Domain().Min();

ON_3dPoint A = crvA->PointAt(ta);
ON_3dPoint B = crvB->PointAt(tb);

rc = new ON_LineCurve(A, B);
}
return rc;
}

/// <summary>
/// Create a blend curve with G1 continuity between two existing curves.
/// </summary>
Expand All @@ -46,7 +75,7 @@ ON_Curve* ON_BlendG1Curve(
)
{
ON_Curve* rc = nullptr;
if (crvA && crvB)
if (crvA && !crvA->IsClosed() && crvB && !crvB->IsClosed())
{
double ta = crvA->Domain().Max();
double tb = crvB->Domain().Min();
Expand Down Expand Up @@ -101,7 +130,7 @@ ON_Curve* ON_BlendG2Curve(
)
{
ON_Curve* rc = nullptr;
if (crvA && crvB)
if (crvA && !crvA->IsClosed() && crvB && !crvB->IsClosed())
{
double ta = crvA->Domain().Max();
double tb = crvB->Domain().Min();
Expand Down Expand Up @@ -259,53 +288,6 @@ HBITMAP ON_ReadBitmapPreviewImage(const wchar_t* pszFilePath)
return hBitmap;
}

/// <summary>
/// CRhinoHatchPatternTable helpers for system hatch patterns
/// </summary>
class CRhinoHatchTableHelper
{
public:
/// <summary>
/// Returns the Solid hatch pattern
/// </summary>
static const CRhinoHatchPattern* Solid(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the Hatch1 hatch pattern
/// </summary>
static const CRhinoHatchPattern* Hatch1(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the Hatch2 hatch pattern
/// </summary>
static const CRhinoHatchPattern* Hatch2(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the Hatch3 hatch pattern
/// </summary>
static const CRhinoHatchPattern* Hatch3(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the HatchDash hatch pattern
/// </summary>
static const CRhinoHatchPattern* HatchDash(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the Grid hatch pattern
/// </summary>
static const CRhinoHatchPattern* Grid(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the Grid60 hatch pattern
/// </summary>
static const CRhinoHatchPattern* Grid60(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the Plus hatch pattern
/// </summary>
static const CRhinoHatchPattern* Plus(CRhinoHatchPatternTable& table);
/// <summary>
/// Returns the Squares hatch pattern
/// </summary>
static const CRhinoHatchPattern* Squares(CRhinoHatchPatternTable& table);

private:
static const CRhinoHatchPattern* FindOrCreateHatchPattern(CRhinoHatchPatternTable& table, const ON_HatchPattern& hatch_pattern);
};

const CRhinoHatchPattern* CRhinoHatchTableHelper::Solid(CRhinoHatchPatternTable& table)
{
return FindOrCreateHatchPattern(table, CRhinoHatchPattern::Solid);
Expand Down Expand Up @@ -367,7 +349,7 @@ const CRhinoHatchPattern* CRhinoHatchTableHelper::FindOrCreateHatchPattern(CRhin
/// Returns true if Rhino was started as a standalone executable.
/// Returns false if Rhino was started by some other application or process.
/// </summary>
static bool IsRhinoRunningAsExe()
bool IsRhinoRunningAsExe()
{
bool rc = false;
DWORD dwProcessId = ::GetCurrentProcessId();
Expand All @@ -390,7 +372,7 @@ static bool IsRhinoRunningAsExe()
/// <summary>
/// Returns true if Rhino has input focus.
/// </summary>
static bool RhinoHasFocus()
bool RhinoHasFocus()
{
// Retrieves a handle to the foreground window
HWND hWnd = ::GetForegroundWindow();
Expand Down
Loading

0 comments on commit 9ecc765

Please sign in to comment.