%%%flush_merged_shells
%%%iterate_results
OptimizeMappingResultsIterator it = omResults.GetIterator();
while (it.IsValid())
{
if (it.GetMergedShellInfo(out out_shell_key, out out_vertex_offset, out out_face_offset, out out_edge_offset))
{
}
it.Next();
}
%%%merge_shells
segmentOOK.
SetScope(SegmentOptimizationOptions.Scope.SegmentOnly);
OptimizeMappingResults omResults = mySegmentKey.OptimizeWithMapping(segmentOOK);
%%%override_internal_color
mySegmentKey.GetDrawingAttributeControl().SetOverrideInternalColor(visibilityKit);
%%%pbrmaterialkit
PBRMaterialKit pbrKit = new PBRMaterialKit();
pbrKit.SetBaseColorFactor(new RGBAColor(1, 0.65f, 0, 1));
pbrKit.SetRoughnessFactor(0.5f);
pbrKit.SetMetalnessFactor(0.75f);
mySegmentKey.SetPBRMaterial(pbrKit);
%%%handles_operator_constrain
%%%realdwg_import
notifier.Wait();
HPS.IOResult result = notifier.Status();
if (result ==
HPS.IOResult.Success)
{
modelFile = notifier.GetCADModel();
modelFile.ActivateDefaultCapture();
myCanvas.AttachViewAsLayout(myView);
myView.AttachModel(model);
}
notifier.Cancel();
%%%realdwg_layers
Component[] tables = modelFile.GetSubcomponents();
for (int i = 0; i < tables.Length; i++)
{
{
Component[] layers = tables[i].GetSubcomponents();
for (int j = 0; j < layers.Length; j++)
{
if (layer_name.GetValue() == "0")
{
if (layer.IsOn())
layer.TurnOff();
else
layer.TurnOn();
break;
}
}
}
}
%%%realdwg_activate_layout
myView = cadModel.ActivateDefaultLayout();
%%%realdwg_get_all_layouts
for (int i = 0; i < layouts.Length; i++)
{
if (name.GetValue().Equals("PDF"))
{
HPS.
View new_view = layouts[i].Activate();
myCanvas.AttachViewAsLayout(myView);
}
}
%%%grids_1
mySegmentKey.InsertGrid(gridKit);
%%%grids_2
%%%grids_3
myPortfolio.DefineLinePattern("myPattern", myLPK);
mySegmentKey.GetLineAttributeControl().SetPattern("myPattern");
mySegmentKey.GetEdgeAttributeControl().SetPattern("myPattern").SetWeight(2.0f, Edge.SizeUnits.Pixels);
mySegmentKey.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(0.8f, 0.8f, 0.8f));
mySegmentKey.GetMaterialMappingControl().SetLineColor(
new HPS.
RGBAColor(0.0f, 0.0f, 0.0f));
mySegmentKey.GetVisibilityControl().SetEdges(true);
mySegmentKey.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0.4f, 0.7f, 0.2f));
%%%navcube_material
};
portfolio.DefineMaterialPalette("my_material", materialKitArray);
myView.GetNavigationCubeControl().SetMaterialPalette("my_material");
%%%navcube_text
TextAttributeKit myTextAttributeKit = TextAttributeKit.GetDefault();
myView.GetNavigationCubeControl().SetText("Bear", "Trout", "Lion", "Fish", "Birch", "Rana", myTextAttributeKit);
%%%image_glyphs
imageGlyphElement.SetFixedScaling(false);
glyphKit.SetElements(glyphElements);
myPortfolio.DefineGlyph("patternGlyph", glyphKit);
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
mySegmentKey.GetMarkerAttributeControl().SetSymbol("patternGlyph");
mySegmentKey.InsertMarker(new Point(0, 0, 0));
%%%database
%%%show_subsegments
for (int i = 0; i < children.Length; i++)
{
}
%%%manipulate_segment
anotherSegmentKey.
MoveTo(mySegmentKey);
anotherSegmentKey.Flush();
anotherSegmentKey.Delete();
%%%create_subsegment
%%%create_root_segment
%%%include_segment
HPS.
IncludeKey includeKey = windowKey.IncludeSegment(myTurbineModel);
%%%include_filter
%%%delete_include
%%%conditional_include
mySegmentKey.IncludeSegment(someSpecialSegment, condition1);
mySegmentKey.SetCondition("c1");
%%%reference_segment
mySegmentKey.ReferenceGeometry(anotherSegment);
%%%keys
HPS.
TextKey myText = mySegmentKey.InsertText(
new HPS.
Point(0.0f, 0.0f, 0.0f),
"My segment");
%%%geometry_keys
myCircleKey.SetRadius(2.0f);
myCircleKey.SetCenter(
new HPS.
Point(1.0f, 2.5f, 3.2f));
%%%edge_attribute_control_example
mySegmentKey.GetLineAttributeControl().SetPattern("my_line_pattern");
mySegmentKey.GetEdgeAttributeControl().SetWeight(3.0f);
%%%camera_attribute_control_example
mySegmentKey.GetCameraControl().ShowProjection(out proj);
mySegmentKey.GetCameraControl().Orbit(20, 30);
mySegmentKey.GetCameraControl().Zoom(10);
%%%insert_circle
HPS.
CircleKey circleKey = mySegmentKey.InsertCircle(circleKit);
mySegmentKey.InsertCircle(circleKit);
circleKey.
Show(out anotherCircleKit);
%%%modify_circle
circleKey.SetCenter(
new HPS.
Point(0, 0, 0));
circleKey.SetNormal(
new HPS.
Vector(0, 0, 1));
circleKey.SetRadius(0.5f);
circleKey.SetCenter(
new HPS.
Point(0, 0, 0)).SetNormal(
new HPS.
Vector(0, 0, 1)).SetRadius(0.5f);
%%%attribute_locks
childSegment.InsertSphere(
new HPS.
Point(0, 0, 0), 0.5f);
%%%create_application_window
%%%standalone
%%%attribute_locks
childSegment.InsertSphere(
new HPS.
Point(0, 0, 0), 0.5f);
%%%sawok
%%%traversal_1
%%%traversal_2
if (mySegmentKey.Type() ==
HPS.Type.None)
{
}
%%%traversal_3
ulong numChildren = mySegmentKey.ShowSubsegments();
%%%search
out searchResults);
while (it.IsValid())
{
{
}
it.Next();
}
%%%examining_type
HPS.
Key myKey = some_function();
HPS.Type myKeyType = myKey.Type();
switch (myKeyType)
{
break;
break;
break;
default:
break;
}
%%%assuming_type
bool valid = false;
try
{
ShellKey selected_shell = new ShellKey(selected_key);
selected_shell.GetFaceCount();
valid = true;
}
catch (InvalidObjectException ioe)
{
}
%%%set_projection
%%%insert_example
mySegmentKey.InsertShell(shellKit);
mySegmentKey.InsertText(textKit);
mySegmentKey.InsertSphere(sphereKit);
%%%update
windowKey.Update();
myCanvas.Update();
%%%keypath
keyArray[0] = shellKey;
keyArray[1] = includeKey;
%%%shownet
keyPath.ShowNetCamera(out cameraKit);
%%%%010302_a
mySegmentKey.ShowCamera(out myCameraKit);
myCameraKit.ShowPosition(out pos);
mySegmentKey.GetCameraControl().ShowTarget(out target);
mySegmentKey.GetCameraControl().ShowPosition(out pos);
%%%%010302_b
HPS.
TextKey myText = mySegmentKey.InsertText(
new HPS.
Point(0.0f, 0.0f, 0.0f),
"My string is here.");
%%%%010302_c
%%%%010302_d
%%%%010302_e
myTextKey.
Set(highlightText);
%%%%010303_a
HPS.
TextKey myTextKey = mySegmentKey.InsertText(
new HPS.
Point(0.0f, 0.0f, 0.0f),
"My important text string.");
%%%%010303_b
textKit.
SetText(
"My important text string.");
mySegmentKey.InsertText(textKit);
%%%%010303_c
myTextKey.
Show(out textKit);
textKit.SetFont("times new roman");
myTextKey.Set(textKit);
%%%%010304_a
float w, h;
myCameraControl.ShowField(out w, out h);
myCameraControl.ShowPosition(out pos);
%%%show_logic
bool state;
if (mySegmentKey.GetVisibilityControl().ShowLines(out state))
{
}
else
{
}
%%%%010305_a
highlightText.SetBold(true);
%%%%010305_b
highlightText.SetBold(true).SetColor(new RGBAColor(1, 0, 1));
%%%%010305_c
myTextKey.
Set(highlightText);
%%%%010305_d
myTextKey.SetBold(true);
myTextKey.SetColor(new RGBAColor(1, 0, 1));
%%%%010305_e
highlightText.
SetColor(
new RGBAColor(1, 1, 0));
myTextKey.
Set(highlightText);
%%%%010305_f
myTextKey.
Set(highlightText);
%%%%010308_a
%%%user_data
byte [] myData = new byte[] { (byte) 'H', (byte) 'O', (byte) 'O', (byte) 'P', (byte) 'S' } ;
mySegmentKey.SetUserData(new IntPtr(33), 5, myData);
byte[] myByteArray = new byte[100];
mySegmentKey.ShowUserData(new IntPtr(33), out myByteArray);
ulong data_count = mySegmentKey.ShowUserDataCount();
mySegmentKey.UnsetUserData(new IntPtr(33));
%%%create_shell
HPS.
Point[] points = {
new HPS.
Point(0, 0, 0),
new HPS.
Point(2, 0, 0),
new HPS.
Point(2, 2, 0),
new HPS.
Point(0, 2, 0),
new HPS.
Point(0, 0, 2),
new HPS.
Point(2, 0, 2),
new HPS.
Point(2, 2, 2),
new HPS.
Point(0, 2, 2) };
int[] faceList = { 4, 0, 1, 2, 3,
4, 1, 5, 6, 2,
4, 5, 4, 7, 6,
4, 4, 0, 3, 7,
4, 3, 2, 6, 7,
4, 0, 4, 5, 1 };
mySegmentKey.InsertShell(points, faceList);
%%%set_normals
%%%hole
HPS.
Point[] points = {
new HPS.
Point(0, 0, 0),
new HPS.
Point(3, 0, 0),
new HPS.
Point(3, 3, 0),
new HPS.
Point(0, 3, 0),
new HPS.
Point(1, 1, 0),
new HPS.
Point(2, 1, 0),
new HPS.
Point(2, 2, 0),
new HPS.
Point(1, 2, 0) };
int[] faces = { 4, 0, 1, 2, 3,
-4, 4, 5, 6, 7 };
mySegmentKey.InsertShell(points, faces);
%%%%020103_a
HPS.
Point[] points = {
new HPS.
Point(-1, 0, 0),
new HPS.
Point(0, 0, 0),
new HPS.
Point(0, 1, 0),
new HPS.
Point(-1, 1, 0),
new HPS.
Point( 0, 0, 0),
new HPS.
Point(1, 0, 0),
new HPS.
Point(1, 1, 0),
new HPS.
Point( 0, 1, 0),
new HPS.
Point( 1, 0, 0),
new HPS.
Point(2, 0, 0),
new HPS.
Point(2, 1, 0),
new HPS.
Point( 1, 1, 0) };
int[] faces = { 4, 0, 1, 2, 3,
4, 4, 5, 6, 7,
4, 8, 9, 10, 11 };
mySegmentKey.InsertShell(points, faces);
%%%%020103_b
HPS.
Point[] points = {
new HPS.
Point(-1, 0, 0),
new HPS.
Point(0, 0, 0),
new HPS.
Point(0, 1, 0),
new HPS.
Point(-1, 1, 0),
new HPS.
Point( 1, 0, 0),
new HPS.
Point(1, 1, 0),
new HPS.
Point(2, 0, 0),
new HPS.
Point( 2, 1, 0) };
int[] faceList = { 4, 0, 1, 2, 3,
4, 1, 4, 5, 2,
4, 4, 6, 7, 5 };
%%%%020103_c
myShellKey.EditFacelistByDeletion(1, 1);
%%%%020103_d
insertedPoints[0] =
new HPS.
Point(0.5f, 0.5f, 0);
int[] insertedFacelist = { 3, 1, 8, 2 };
myShellKey.EditPointsByInsertion(8, insertedPoints);
myShellKey.EditFacelistByInsertion(1, insertedFacelist);
%%%%020104_a
myShellKey.SetVertexRGBAColorsByRange(0, vertexColors);
%%%%020104_b
mySegmentKey.GetVisibilityControl().SetFaces(false);
mySegmentKey.GetVisibilityControl().SetFaces(true);
%%%%020104_c
mySegmentKey.GetVisibilityControl().SetVertices(true).SetEdges(false).SetFaces(false);
%%%set_marker_size
%%%sphere_marker
mySegmentKey.GetPortfolioControl().Push(portfolioKey);
mySegmentKey.GetVisibilityControl().SetVertices(true);
mySegmentKey.GetVisibilityControl().SetMarkerLights(true).SetLights(true);
mySegmentKey.GetMaterialMappingControl().SetVertexColor(new RGBAColor(1, 1, 0));
mySegmentKey.GetMarkerAttributeControl().SetSymbol("my sphere").SetSize(0.75f);
%%%%020104_e
mySegmentKey.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(1, 0, 0));
%%%shell_from_geometry
HPS.
ShellKey newSphereShell = mySegmentKey.InsertShellFromGeometry(sphereKey);
HPS.
ShellKey newCylinderShell = mySegmentKey.InsertShellFromGeometry(cylinderKey);
HPS.
ShellKey newTextShell = mySegmentKey.InsertShellFromGeometry(textKey);
%%%%0202_a
PointArray[0] =
new HPS.
Point(-0.8f, 0.4f, -0.8f);
PointArray[1] =
new HPS.
Point(-0.8f, 0, -0.6f);
PointArray[2] =
new HPS.
Point(-0.8f, -0.4f, -0.4f);
PointArray[3] =
new HPS.
Point(-0.4f, 0.4f, -0.4f);
PointArray[4] =
new HPS.
Point(-0.4f, 0, -0.2f);
PointArray[5] =
new HPS.
Point(-0.4f, -0.4f, -0.3f);
PointArray[6] =
new HPS.
Point(0, 0.4f, 0.15f);
PointArray[7] =
new HPS.
Point(0, 0, 0.05f);
PointArray[8] =
new HPS.
Point(0, -0.4f, 0.05f);
PointArray[9] =
new HPS.
Point(0.4f, 0.4f, 0.2f);
PointArray[10] =
new HPS.
Point(0.4f, 0, 0.2f);
PointArray[11] =
new HPS.
Point(0.4f, -0.4f, 0.4f);
PointArray[12] =
new HPS.
Point(0.8f, 0.4f, 0.5f);
PointArray[13] =
new HPS.
Point(0.8f, 0, 0.3f);
PointArray[14] =
new HPS.
Point(0.8f, -0.4f, 0.3f);
PointArray[15] =
new HPS.
Point(1.2f, 0.4f, 0.3f);
PointArray[16] =
new HPS.
Point(1.2f, 0, 0.3f);
PointArray[17] =
new HPS.
Point(1.2f, -0.4f, 0.3f);
MeshKey meshKey = mySegmentKey.InsertMesh(6, 3, PointArray);
%%%mesh_normals
%%%%020202_a
mySegmentKey.GetVisibilityControl().SetEdges(false);
mySegmentKey.GetVisibilityControl().SetMeshQuadEdges(true);
%%%%020202_b
ulong[] faceList = new ulong[3];
faceList[0] = 5;
faceList[1] = 10;
faceList[2] = 13;
meshKey.SetFaceRGBColorsByList(faceList, rgbColor);
meshKey.SetFaceVisibilitiesByList(faceList, false);
%%%%0203_a
mySegmentKey.InsertText(textKit);
%%%text_region
TextKey myTextKey = mySegmentKey.InsertText(
new HPS.
Point(0, 0, 0),
"This is my text!");
bool adjust_direction = true;
bool relative_coordinates = true;
bool window_space = false;
myTextKey.SetRegion(pointArray,
adjust_direction,
relative_coordinates,
window_space);
%%%font_search
windowKey.FindFonts(out fsr);
while (iter.IsValid())
{
iter.Next();
}
%%%%020301_a
uint width, height;
myWindowKey.GetWindowInfoControl().ShowPhysicalPixels(out width, out height);
%%%%020302_a
HPS.
TextKey tk = mySegmentKey.InsertText(
new HPS.
Point(0, 0, 0),
"Good morning\nThis is another line");
%%%%020303_a
HPS.
TextKey textKey = mySegmentKey.InsertText(
new HPS.
Point(0, 0, 0),
"TECH SOFT 3D\nBUILD WITH THE BEST");
%%%%020304_a
mySegmentKey.GetTextAttributeControl().SetTransform(
HPS.
Text.
Transform.Transformable);
%%%%020304_b
mySegmentKey.GetTextAttributeControl().SetTransform(
HPS.
Text.
Transform.CharacterPositionOnly);
%%%%020305_a
mySegmentKey.GetTextAttributeControl().SetAlignment(
HPS.
Text.
Alignment.BottomLeft);
mySegmentKey.InsertText(
new HPS.
Point(0, 0, 0),
"Tech Soft 3D");
%%%%020305_b
mySegmentKey.InsertText(
new HPS.
Point(0, 0, 0),
"Choose\nTech Soft 3D\nfor high\nperformance\ngraphics");
%%%rotated_text
HPS.
TextKey textKey = mySegmentKey.InsertText(
new HPS.
Point(0, 0, 0),
"Choose\nTech Soft 3D\nfor high\nperformance\ngraphics");
mySegmentKey.GetTextAttributeControl().
SetFont(
"stroked");
mySegmentKey.GetModellingMatrixControl().Rotate(0, 0, 30);
%%%%020305_d
mySegmentKey.GetTextAttributeControl().SetRotation(40);
%%%%020305_e
mySegmentKey.GetTextAttributeControl().SetPath(
new HPS.
Vector(1, 0.5f, 0));
mySegmentKey.GetTextAttributeControl().SetRotation(
HPS.
Text.
Rotation.FollowPath);
%%%%020306_a
mySegmentKey.GetTextAttributeControl().SetTransform(
HPS.
Text.
Transform.Transformable);
mySegmentKey.GetTextAttributeControl().SetGreeking(true, 6,
%%%%020307_a
String text = "TECH SOFT 3D\u2197\u2300\u21A7";
mySegmentKey.GetTextAttributeControl().
SetFont(
"ts3d");
%%%%0204_a
mySegmentKey.GetMaterialMappingControl().SetLightColor(
new HPS.
RGBAColor(1, 0, 1));
%%%%020401_a
HPS.
SpotlightKey spotlightKey = mySegmentKey.InsertSpotlight(spotlightKit);
%%%%020402_a
mySegmentKey.InsertDistantLight(
new HPS.
Vector(x, y, z));
%%%camera_relative_lights
spotlightKey.SetCameraRelative(true);
distantLightKey.SetCameraRelative(true);
%%%%0205_a
mySegmentKey.InsertLine(pointArray);
%%%%0205_b
mySegmentKey.GetLineAttributeControl().SetWeight(2.0f);
%%%ray
mySegmentKey.InsertInfiniteLine(rayKit);
%%%editing_lines
editedPoints[0] =
new HPS.
Point(0, 0.5f, 0);
myLineKey.EditPointsByReplacement(0, editedPoints);
myLineKey.EditPointsByInsertion(3, editedPoints);
%%%insert_nurbs_surface
int index = 0;
for (int j = 0; j < 10; j++)
{
for (float i = 0; i < 10; i += 0.1f)
{
pointArray[index++] =
new HPS.
Point(i, (
float)Math.Sin(i), (float)j);
}
}
mySegmentKey.InsertNURBSSurface(nsk);
%%%nst_step1
linePoints[0] =
new HPS.
Point(0.35f, 0.3f, 0);
linePoints[1] =
new HPS.
Point(0.70f, 0.3f, 0);
linePoints[2] =
new HPS.
Point(0.5f, 0.7f, 0);
%%%nst_step2
%%%nst_step3
trimElementArray[0] = trimElement;
%%%nst_step4
%%%nst_step5
trimKitArray[0] = trimKit;
%%%nst_step6
nurbsSurfaceKit.SetTrims(trimKitArray);
mySegmentKey.InsertNURBSSurface(nurbsSurfaceKit);
%%%end_caps_joins
mySegmentKey.GetLineAttributeControl().SetPattern("solid", lpok);
%%%infinite_line
mySegmentKey.InsertInfiniteLine(ilk);
%%%%020601_a
HPS.
CircleKey circleKey = mySegmentKey.InsertCircle(circleKit);
%%%%020602_a
mySegmentKey.InsertCircularArc(
new HPS.
Point(-0.5f, -0.5f, 0),
%%%%020603_a
mySegmentKey.InsertCircularWedge(
new HPS.
Point(-0.5f, -0.5f, 0),
%%%%020604_a
mySegmentKey.InsertEllipse(ellipseKit);
%%%%020605_a
ellipticalArcKit.
SetEnd(0.75f);
mySegmentKey.InsertEllipticalArc(ellipticalArcKit);
%%%%0207_a
mySegmentKey.GetMarkerAttributeControl().SetSymbol("myMarkerName");
mySegmentKey.InsertMarker(new Point(0, 0, 0));
%%%%020701_a
segKey2.GetMarkerAttributeControl().SetSize(10,
HPS.
Marker.
SizeUnits.Pixels).SetDrawingPreference(Marker.DrawingPreference.Fastest);
segKey3.GetMarkerAttributeControl().SetSize(0.1f,
HPS.
Marker.
SizeUnits.WorldSpace).SetDrawingPreference(Marker.DrawingPreference.Fastest);
MarkerKey markerKey3 = segKey3.InsertMarker(
new HPS.
Point(0, -0.35f, 0));
%%%%020702_a
markerKey2.SetPoint(
new HPS.
Point(-0.25f, 0, 0));
someOtherMarkerKey.Delete();
%%%%020703_a
mySegmentKey.GetVisibilityControl().SetMarkers(false);
mySegmentKey.GetVisibilityControl().SetMarkers(true);
mySegmentKey.GetMaterialMappingControl().SetMarkerColor(
new HPS.
RGBAColor(1, 0, 0));
%%%%0209_a
pointArray[0] =
new HPS.
Point(0.15f, 0.25f, 0);
pointArray[1] =
new HPS.
Point(-0.35f, 0.35f, 0);
pointArray[2] =
new HPS.
Point(-0.65f, 0, 0);
pointArray[3] =
new HPS.
Point(-0.35f, -0.4f, 0);
pointArray[4] =
new HPS.
Point(0.15f, -0.15f, 0);
HPS.
PolygonKey polygonKey = mySegmentKey.InsertPolygon(pointArray);
%%%%0209_b
mySegmentKey.GetVisibilityControl().SetFaces(true);
mySegmentKey.GetEdgeAttributeControl().SetWeight(2);
mySegmentKey.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(0, 0, 0));
mySegmentKey.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0.32f, 0.78f, 0.95f));
%%%%0209_c
editedPoints[0] =
new HPS.
Point(-0.35f, 0.65f, 0);
polygonKey.EditPointsByReplacement(1, editedPoints);
polygonKey.EditPointsByDeletion(3, 1);
editedPoints[0] =
new HPS.
Point(0.25f, 0, 0);
polygonKey.EditPointsByInsertion(4, editedPoints);
polygonKey.ShowPoints(out editedPoints);
%%%%0210_a
mySegmentKey.InsertSphere(sphereKit);
%%%%0210_b
mySegmentKey.GetSphereAttributeControl().SetTessellation(50);
%%%%0211_a
%%%%021101_a
float[] radii = { 0.5f, 0 };
mySegmentKey.InsertCylinder(cylinderKit);
%%%%021102_a
float[] radius = { 0.25f };
for (int i = 0; i < 64; i++) {
float angle = 2.0f * 3.1415926536f * i / 64.0f;
float x = 0;
float y = (float) Math.Cos(angle);
float z = (float) Math.Sin(angle) - 1.5f;
points[i] = new Point(x, y, z);
}
points[64] = points[0];
%%%%021102_b
float[] radii = { 0.25f, 0.3f };
%%%%021102_c
mySegmentKey.GetCylinderAttributeControl().SetTessellation(40);
%%%%021102_d
%%%%021201_a
Point[] pointArray = {
new HPS.
Point(-1.75f, -1.75f, 0),
new HPS.
Point(-0.75f, -0.75f, 0),
new HPS.
Point(-0.5f, 0.5f, 0),
float[] knotArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
float[] weightArray = { 1, 0.7f, 1, 0.5f, 1, 0.8f, 1 };
mySegmentKey.GetCurveAttributeControl().SetViewDependent(true);
%%%%021201_b
float[] newKnots = { 3.5f, 4.5f };
nurbsKey.EditKnotsByReplacement(3, newKnots);
nurbsKey.EditPointsByReplacement(0, newPoints);
float[] newWeights = { 0.3f };
nurbsKey.EditWeightsByReplacement(5, newWeights);
%%%%021202_a
Point[] points = {
new HPS.
Point(3, 1, 0),
new HPS.
Point(1, 1, 0),
new HPS.
Point(0, 2, 0),
new HPS.
Point(-2, 2, 0),
new HPS.
Point(-2, 3, 0),
new HPS.
Point(3, 1, 1),
new HPS.
Point(1, 1, 1),
new HPS.
Point(0, 2, 1),
new HPS.
Point(-2, 2, 1),
new HPS.
Point(-2, 3, 1),
new HPS.
Point(3, -1, 2),
new HPS.
Point(1, -1, 2),
new HPS.
Point(0, 0, 2),
new HPS.
Point(-2, 0, 2),
new HPS.
Point(-2, 1, 2),
new HPS.
Point(3, -1, 3),
new HPS.
Point(1, -1, 3),
new HPS.
Point(0, 0, 3),
new HPS.
Point(-2, 0, 3),
new HPS.
Point(-2, 1, 3),
new HPS.
Point(3, 0, 4),
new HPS.
Point(1, 0, 4),
new HPS.
Point(0,-1, 4),
new HPS.
Point(-2, -1, 4),
new HPS.
Point(-2, 2, 4) };
float[] weights = { 1, 1, 1, 1, 1, 1, 0.5f, 0.5f, 0.5f, 1, 1, 0.5f, 0.5f,
0.5f, 1, 1, 0.5f, 0.5f, 0.5f, 1, 1, 1, 1, 1, 1 };
float[] uKnots = { 0, 0, 0, 1, 2, 3, 4, 4, 4 };
float[] vKnots = { 0, 0, 0, 1, 2, 3, 4, 4, 4 };
mySegmentKey.InsertNURBSSurface(nsk);
%%%insert_cutting_section
mySegmentKey.GetVisibilityControl().SetCutEdges(true);
mySegmentKey.GetMaterialMappingControl().SetCutEdgeColor(
new HPS.
RGBAColor(1, 0, 0));
mySegmentKey.InsertCuttingSection(new Plane(0, 1, 0, -0.42f));
%%%capping_plane
mySegmentKey.InsertCuttingSection(csk);
%%%capping_geometry
mySegmentKey.GetVisibilityControl().SetCutFaces(true);
mySegmentKey.GetMaterialMappingControl().SetCutFaceColor(
new HPS.
RGBAColor(0.5f, 0, 0));
%%%multiple_sections
planeArray[0] = new Plane(0, 1, 0, -0.1f);
planeArray[1] = new Plane(-1, 0, 0, 0);
csk.SetPlanes(planeArray);
mySegmentKey.InsertCuttingSection(csk);
%%%cutting_sections_gather
myWindowKey.GetVisibilityControl().SetCutGeometry(true);
myWindowKey.GetCuttingSectionAttributeControl()
myWindowKey.Subsegment("model").Delete();
%%%reference_geometry
HPS.
ShellKey shellKey = isolatedSegment.InsertShell(shellKit);
refKey.Delete();
%%%text_extents
float out_xfrac, out_yfrac;
myKeyPath.ComputeTextExtent("My text string...", out out_xfrac, out out_yfrac);
%%%set_face_rgb_by_range
myShellKey.SetFaceRGBColorsByRange(0, 3,
new HPS.
RGBColor(1, 0.5f, 0));
%%%set_face_vis_by_range
myShellKey.SetFaceVisibilitiesByRange(0, 3, false);
%%%level
%%%csak
mySegmentKey.SetCuttingSectionAttribute(csak);
%%%optimize_shell
myShellKey.Optimize(sook);
%%%simple
myShellKey.ComputeRelation(pointArray, srok, out srrk);
srrk.ShowRelations(out shellRelationArray);
for (int i = 0; i < shellRelationArray.size(); i++)
{
{
}
{
}
}
%%%enclosure
srok.SetTreeContext(treeContext);
myShellKey.ComputeRelation(pointArray, srok, out srrk);
float[] floatArray = new float[3];
srrk.ShowRelations(out shellRelationArray);
for (int i = 0; i < shellRelationArray.size(); i++)
{
{
}
{
}
{
}
}
%%%distance
myShellKey.ComputeRelation(pointArray, srok, out srrk);
srrk.ShowDistances(out floatArray);
for (int i = 0; i < floatArray.size(); i++)
{
float distance = floatArray[i];
}
%%%%0301_a
%%%%030101_a
%%%%030102_a
mySegmentKey.SetModellingMatrix(matrixKit);
mySegmentKey.GetModellingMatrixControl().Concatenate(matrixKit);
mySegmentKey.ShowModellingMatrix(out matrixKit);
mySegmentKey.GetModellingMatrixControl().Rotate(10, 50, 90);
mySegmentKey.GetModellingMatrixControl().SetElement(1, 3, -5);
mySegmentKey.UnsetModellingMatrix();
%%%%0302_a
mySegment.GetCameraControl().SetUpVector(
new HPS.
Vector(0, 1, 0)).SetPosition(
new HPS.
Point(0, -10, 0))
.SetTarget(
new HPS.
Point(0, 0, 0)).SetField(4, 4)
mySegmentKey.SetCamera(cameraKit);
%%%camera_components_a
mySegmentKey.ShowCamera(out cameraKit);
cameraKit.ShowPosition(out position);
mySegmentKey.GetCameraControl().ShowPosition(out position);
%%%set_field
mySegmentKey.GetCameraControl().SetField(5, 5);
%%%set_near_limit
mySegmentKey.GetCameraControl().SetNearLimit(0.1f);
%%%aspect_ratio
%%%zoom_dolly
mySegmentKey.GetCameraControl().Zoom(2.0f);
mySegmentKey.GetCameraControl().Dolly(0.5f, 0.25f, 0);
%%%orbit
mySegmentKey.GetCameraControl().Orbit(90.0f, 0);
%%%pan
mySegmentKey.GetCameraControl().Pan(0, 90.0f);
%%%roll
mySegmentKey.GetCameraControl().Roll(180.0f);
%%%transformMasks
axisSegment.GetTransformMaskControl().SetCameraScale(true).SetCameraTranslation(true);
%%%set_orthgraphic
%%%oblique_perspective
mySegmentKey.GetCameraControl().SetProjection(
HPS.
Camera.
Projection.Perspective, 21.8f, -21.8f);
%%%stretched_projection
mySegmentKey.SetCamera(cameraKit);
%%%border
pointArray[0] =
new HPS.
Point(-1, -1, 0);
pointArray[1] =
new HPS.
Point(1, -1, 0);
pointArray[3] =
new HPS.
Point(-1, 1, 0);
pointArray[4] =
new HPS.
Point(-1, -1, 0);
borderKey.InsertLine(pointArray);
borderKey.GetLineAttributeControl().SetWeight(6.0f);
%%%%030206_a
mySegmentKey.GetCameraControl().SetProjection(
HPS.
Camera.
Projection.Perspective, 21.8f, -21.8f);
%%%%030206_b
mySegmentKey.SetCamera(cameraKit);
%%%%030206_c
pointArray[0] =
new HPS.
Point(-1, -1, 0);
pointArray[1] =
new HPS.
Point(1, -1, 0);
pointArray[3] =
new HPS.
Point(-1, 1, 0);
pointArray[4] =
new HPS.
Point(-1, -1, 0);
borderKey.InsertLine(pointArray);
borderKey.GetLineAttributeControl().SetWeight(6.0f);
%%%%0303_a
%%%%0303_b
%%%%0303_c
%%%%0303_d
%%%%0303_e
mySegmentKey.SetPriority(5);
%%%create_core_step1
%%%create_core_step2
canvas.AttachLayout(layout);
layout.AttachViewFront(view1,
new HPS.
Rectangle(-1, 0, -1, 1));
layout.AttachViewFront(view2,
new HPS.
Rectangle( 0, 1, -1, 1));
view1.AttachModel(model);
view2.AttachModel(model);
%%%create_core_step3
HPS.
ShellKey shellKey = modelSegmentKey.InsertShell(myShellKit);
%%%create_core_step4
viewSegmentKey.SetCamera(cameraKit);
modelSegmentKey.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0.81f, 0.72f, 0.08f));
modelSegmentKey.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(0, 0, 0));
modelSegmentKey.GetVisibilityControl().
SetEdges(
true);
%%%using_canvas
canvas.AttachViewAsLayout(view);
%%%fixed_framerate
canvas.SetFrameRate(20.0f);
windowKey.GetCullingControl().SetDeferralExtent(100);
windowKey.GetCullingControl().SetExtent(10);
%%%using_layout
myLayout.AttachViewFront(view,
new HPS.
Rectangle(0, 1, -1, 0));
%%%using_view
%%%fit_world
%%%axis_navcube
%%%nav_aid_set_location
myView.GetNavigationCubeControl()
%%%complex_clip_regions
%%%clip_regions
mySegmentKey.InsertSphere(
new HPS.
Point(0, 0, 0), 2.0f);
mySegmentKey.GetVisibilityControl().SetEdges(true);
pointArray[0] =
new HPS.
Point(10, 10, 0);
pointArray[1] =
new HPS.
Point(-10, 10, 0);
pointArray[2] =
new HPS.
Point(-10, -10, 0);
mySegmentKey.GetDrawingAttributeControl().SetClipRegion(
%%%portfolios_introduction
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
%%%example_definitions
myPortfolio.DefineLinePattern("dashedLine", myLinePatternKit);
myPortfolio.DefineShader("superShader", myShaderKit);
myPortfolio.UndefineTexture("roughTexture");
%%%import_all
myPortfolio.ImportPortfolio(otherPortfolio);
myPortfolio.ImportAllTextures(otherPortfolio);
myPortfolio.ImportGlyph(someGlyph);
%%%import_all_replace
myPortfolio.ImportAllTextures(otherPortfolio, true);
myPortfolio.ImportAllTextures(otherPortfolio, false);
%%%style_segment
styleSegment.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(0, 1, 0));
anotherSegment.GetStyleControl().PushSegment(styleSegment);
%%%unset_style
mySegmentKey.GetStyleControl().Pop();
mySegmentKey.GetStyleControl().SetNamed("newStyle");
mySegmentKey.GetStyleControl().UnsetEverything();
%%%create_named_style
wire_style.GetSource().GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(0.0f, 1.0f, 0.0f));
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
mySegmentKey.GetStyleControl().PushNamed("green wireframe");
%%%simple_condition
mySegmentKey.GetStyleControl().SetNamed("glossy red", condition1);
mySegmentKey.SetCondition("c1");
%%%multiple_conditions
String[] conditionArray = new String[2];
conditionArray[0] = "c1";
conditionArray[1] = "c3";
mySegmentKey.SetConditions(conditionArray);
%%%complex_condition
mySegmentKey.GetStyleControl().SetNamed("myStyle", complexAND);
%%%push_style
mySegmentKey.GetStyleControl().PushNamed("myStyle");
%%%edit_stack
String[] styleNames = new String[3];
mySegmentKey.GetStyleControl().ShowAllNamed(out styleNames, out conditions);
String[] newStyleNames = new String[2];
newStyleNames[0] = styleNames[0];
newStyleNames[1] = styleNames[2];
mySegmentKey.GetStyleControl().Set(styleTypesArray, segmentKeyArray, newStyleNames, conditions);
%%%define_image
try
{
ImageDefinition imageDefinition = myPortfolio.DefineImage("my_image", imageKit);
}
{
String problem = ioe.what();
}
%%%manual_define_image
%%%basic_glyph_usage
myPortfolio.DefineGlyph("circle in a circle", myGlyphKit);
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
mySegmentKey.GetMarkerAttributeControl().SetSymbol("circle in a circle");
mySegmentKey.InsertMarker(
new HPS.
Point(0, 0, 0));
%%%defining_glyphs_step1
%%%defining_glyphs_step2
%%%defining_glyphs_step3
lineGlyphElement.SetExplicitColor(
new HPS.
RGBAColor(1, 0, 0));
%%%defining_glyphs_step4
glyphKit.SetElements(gea);
%%%defining_glyphs_step5
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
%%%defining_glyphs_step6
mySegmentKey.GetMarkerAttributeControl().SetSymbol("myCustomGlyph");
mySegmentKey.InsertMarker(
new HPS.
Point(0, 0, 0));
%%%basic_example
myPortfolio.DefineLinePattern("my_new_pattern", myLinePatternKit);
mySegmentKey.GetLineAttributeControl().SetPattern("my_new_pattern");
%%%line_patterns_step1
%%%line_patterns_step2
lpea_dashed[0] = slpe_orange;
lpea_dashed[1] = blpe;
lpea_solid[0] = slpe_blue;
%%%line_patterns_step3
%%%line_patterns_step4
%%%line_patterns_step5
myPortfolio.DefineLinePattern("myLinePattern", lpk);
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
%%%line_patterns_step6
mySegmentKey.GetLineAttributeControl().SetPattern("myLinePattern");
%%%glyph_line_pattern
lpea[0] = anotherElement;
lpea[1] = glpe;
lpea[2] = anotherElement;
%%%%040203_a
float[] materialIndices = new float[] { 0, 0.25f, 0.5f, 0.75f, 1 };
shellKit.SetFaceIndexColorsByList(faceIndices, materialIndices);
%%%%040204_a
materialKitArray[0].SetDiffuse(
new HPS.
RGBAColor(1, 0, 0, 1));
materialKitArray[1].SetDiffuseTexture("my_texture");
materialKitArray[2].SetDiffuse(
new HPS.
RGBAColor(1, 0, 0, 0));
%%%%040301_a
mySegmentKey.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0.75f, 0.4f, 0.24f, 0.5f));
mySegmentKey.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(0, 0, 1));
%%%%040303_a
ulong[] vertexIndices = new ulong[4];
vertexIndices[0] = 0;
vertexIndices[1] = 1;
vertexIndices[2] = 2;
vertexIndices[3] = 3;
shellKey.SetVertexRGBColorsByList(vertexIndices, colorArray);
%%%%040304_a
mySegmentKey.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(1, 1, 1));
%%%%0404_a
mySegmentKey.GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(1, 1, 1));
%%%show_snapshot
myWindowKey.ShowSnapshot(out myImageKit);
Byte[] imageData;
myImageKit.ShowData(out imageData);
%%%create_material_kit
%%%material_kit_array
%%%material_palette_definition
myPortfolio.DefineMaterialPalette("myPalette", materialKitArray);
mySegmentKey.SetMaterialPalette("myPalette");
%%%using_material_mapping_control
mySegmentKey.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(1.0f, 0, 0, 0.5f));
mySegmentKey.GetMaterialMappingControl().SetFaceGloss(12.4f);
%%%using_material_palettes
mySegmentKey.GetPortfolioControl().
Set(myPortfolio);
mySegmentKey.GetMaterialMappingControl().SetFaceMaterialByIndex(0);
%%%diffuse_color
mySegmentKey.GetMaterialMappingControl().SetFaceColor
%%%specular
myMaterialKit.SetSpecular(
new HPS.
RGBAColor(1, 0.8f, 0.9f, 0.5f));
%%%gloss
myMaterialKit.SetGloss(15.0f);
%%%emission
mySegmentKey.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(1, 0, 0.5f),
mySegmentKey.InsertDistantLight(
new HPS.
Vector(x, y, z));
%%%environment
textureOptionsKit.
mySegmentKey.GetMaterialMappingControl()
%%%basic_transparency
segmentKey1.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0.24f, 0.48f, 0.56f));
segmentKey2.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(1.0f, 0.0f, 0.0f, 0.5f));
%%%set_alpha
myMaterialMappingKit.SetFaceAlpha(0.5f);
myMaterialMappingKit.SetEdgeAlpha(0.75f);
myMaterialMappingKit.SetVertexAlpha(0.25f);
%%%depth_peeling
mySegmentKey.GetTransparencyControl().SetDepthPeelingLayers(3);
%%%transparency_method
%%%texture_step1
try
{
imageKit =
HPS.
Image.File.Import(filename, iok);
}
{
String problem = ioe.what();
return Test.Result.Failure;
}
%%%texture_step1b
%%%texture_step2
%%%texture_step3
portfolioKey.DefineTexture("my_texture", imageDefinition, textureOptionsKit);
%%%texture_step4
mySegmentKey.GetPortfolioControl().Push(portfolioKey);
%%%texture_step5
ulong[] vertices_map = new ulong[4];
vertices_map[0] = 0;
vertices_map[1] = 1;
vertices_map[2] = 2;
vertices_map[3] = 3;
float[] vparams = new float[8];
vparams[0] = 0; vparams[1] = 0;
vparams[2] = 1; vparams[3] = 0;
vparams[4] = 1; vparams[5] = 1;
vparams[6] = 0; vparams[7] = 1;
%%%texture_step6
mySegmentKey.InsertShell(shellKit);
mySegmentKey.GetMaterialMappingControl().SetFaceTexture("my_texture");
%%%direct_bump
mySegmentKey.InsertDistantLight(
new HPS.
Vector(0, 1, 0));
%%%mka_bump
materialKit[0].SetDiffuseColor(
new HPS.
RGBAColor(1, 0, 0, 1));
materialKit[1].SetDiffuseTexture("my_texture");
materialKit[1].SetBump("my_bump_map");
materialKit[2].SetDiffuseColor(
new HPS.
RGBAColor(1, 0, 0, 0));
%%%decal
textureOptionsKit.SetDecal(true);
%%%shaders_step1
String shader_source =
"void custom_shader(const HGlobals globals, inout HColor color) { \n" +
"color.diffuse.rgb = globals.tex.coords.rgb;}\n" +
"#define H3D_COLOR_SHADER custom_shader\n";
%%%shaders_step2
HPS.ShaderKit shaderKit =
new HPS.ShaderKit();
shaderKit.SetSource(shader_source);
portfolioKey.DefineShader("myShader", shaderKit);
mySegmentKey.GetPortfolioControl().Push(portfolioKey);
%%%shaders_step3
mySegmentKey.GetMaterialMappingControl().SetFaceShader("myShader");
%%%mka_segment
for (int i = 0; i < myMaterialKitArray.Length; i++)
myMaterialKitArray[i] = new MaterialKit();
("my_palette", myMaterialKitArray);
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
mySegmentKey.GetMaterialMappingControl().SetFaceMaterialByIndex(1);
%%%direct_segment
mySegmentKey.GetMaterialMappingControl().SetFaceColor
mySegmentKey.GetMaterialMappingControl().SetEdgeColor
%%%material_mapping
myShellKit.SetMaterialMapping(myMaterialMappingKit);
%%%subentity_materials
ulong[] faceIndices = new ulong[3];
faceIndices[0] = 0;
faceIndices[1] = 1;
faceIndices[2] = 2;
float[] materialIndices = new float[3];
materialIndices[0] = 0;
materialIndices[1] = 1;
materialIndices[2] = 2;
myShellKit.SetFaceIndexColorsByList(faceIndices, materialIndices);
%%%%040302_a
shellKey.SetFaceRGBColorsByRange(3, 1,
new HPS.
RGBColor(1, 0.5f, 0));
%%%%040302_b
ulong[] faceIndices = new ulong[2];
faceIndices[0] = 3;
faceIndices[1] = 0;
shellKey.SetFaceRGBColorsByList(faceIndices, colorArray);
%%%%040302_c
shellKey.SetFaceRGBColorsByRange(0, 3,
new HPS.
RGBColor(1, 0.5f, 0));
%%%%040303_a
ulong[] vertexIndices = new ulong[4];
vertexIndices[0] = 0;
vertexIndices[1] = 1;
vertexIndices[2] = 2;
vertexIndices[3] = 3;
shellKey.SetVertexRGBColorsByList(vertexIndices, colorArray);
%%%%040204_a
materialKitArray[0].SetDiffuse(
new HPS.
RGBAColor(1, 0, 0, 1));
materialKitArray[1].SetDiffuseTexture("my_texture");
materialKitArray[2].SetDiffuse(
new HPS.
RGBAColor(1, 0, 0, 0));
%%%%040203_a
float[] materialIndices = new float[] { 0, 0.25f, 0.5f, 0.75f, 1 };
shellKit.SetFaceIndexColorsByList(faceIndices, materialIndices);
%%%selection_algorithm
%%%proximity
%%%granularity
%%%selection_by_point_example
myWindowKey.GetSelectionOptionsControl().SetProximity(0.01f);
ulong numSelectedItems = myWindowKey.GetSelectionControl().SelectByPoint(
selectionPoint,
out selectionResults);
%%%selection_by_ray_example
myWindowKey.GetSelectionOptionsControl().SetProximity(0.01f);
ulong numSelectedItems = myWindowKey.GetSelectionControl().SelectByRay(
rayStart,
rayDir,
out selectionResults);
%%%selection_results
while (srIterator.IsValid())
{
selectionItem.ShowSelectedItem(out key);
{
}
srIterator.Next();
}
%%%selection_by_shell_example
while (srIterator.IsValid())
{
selectionItem.ShowSelectedItem(out key);
{
}
srIterator.Next();
}
%%%selection_by_volume_example
ulong numSelectedItems = myWindowKey.GetSelectionControl()
.SelectByVolume(boundingCuboid, out selectionResults);
%%%selection_by_area_example
ulong numSelectedItems = myWindowKey.GetSelectionControl().SelectByArea(
new HPS.
Rectangle(-1, 1, -1, 1), selectionOptions, out selectionResults);
while (srIterator.IsValid())
{
selectionItem.ShowSelectedItem(out key);
{
}
srIterator.Next();
}
%%%limiting_enhancing
myWindowKey.GetSelectionOptionsControl().SetInternalLimit(10);
myWindowKey.GetSelectionOptionsControl().SetRelatedLimit(2);
%%%highlighting
mySegmentKey.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0.89f, 0.62f, 0.11f));
myWindowKey.GetPortfolioControl().Push(myPortfolio);
myWindowKey.GetHighlightControl().Highlight(keyPath, hok);
%%%overlays
mySegmentKey.GetDrawingAttributeControl().SetOverlay(
HPS.
Drawing.
Overlay.WithZValues);
%%%activate_operator_1
myView.GetOperatorControl().Push(orbitOperator);
%%%activate_operator_2
%%%activate_operator_with_priority
myView.GetOperatorControl().Push(walkOperator, Operator.Priority.Default);
%%%change_priority
myView.GetOperatorControl().Set(walkOperator, Operator.Priority.High);
%%%detach_view
orbitOperator.DetachView();
%%%combining_operators
%%%handles_operator
%%%MyCustomOperator_step1
class MyCustomOperator :
HPS.Operator
{
{
return true;
}
}
%%%MyCustomOperator_step2
{
ulong numTouches = in_state.GetTouchCount();
HPS.
Touch[] touchArray = in_state.GetTouches();
return true;
}
%%%%0202_b
if (in_state.GetButtons().Left())
{
if (in_state.GetModifierKeys().Control())
{
}
}
%%%select_operator
myView.GetOperatorControl().Push(selectOperator);
selectOperator.SetSelectionOptions(sok);
%%%highlight_operator
myView.GetOperatorControl().Push(highlightOperator);
highlightOperator.SetHighlightOptions(hok);
%%%selection_culling
%%%subentity_selection
while (srIterator.IsValid())
{
selectionItem.ShowSelectedItem(out key);
ulong [] out_faces, out_vertices, edges1, edges2;
selectionItem.ShowFaces(out out_faces);
selectionItem.ShowVertices(out out_vertices);
selectionItem.ShowEdges(out edges1, out edges2);
srIterator.Next();
}
%%%window_update
%%%window_update_progress
myWindowKey.Update();
{
}
{
}
%%%window_update_type
%%%fixed_framerate
%%%offscreen_window
%%%notifier_offscreen
%%%get_image_data
Byte[] imageData;
imageKit.ShowData(out imageData);
%%%offscreen_window_opacity
oswok.SetOpacity(0.0f);
oswok.SetOpacity(0.5f);
oswok.SetOpacity(1.0f);
%%%modify_offscreen_image_data
Byte[] imageData;
imageKit.ShowData(out imageData);
imageKit.SetData(imageData);
%%%set_display_lists
%%%set_static_model
%%%culling_optimizations01_a
mySegmentKey.GetCullingControl().SetBackFace(true);
%%%distance_culling_search
SelectionOptionsKit selection_options = SelectionOptionsKit.GetDefault();
selection_options.SetDistanceCullingRespected(false);
%%%distance_culling_set_distance
myWindow.GetCullingControl().SetDistance(((float)8.2));
%%%volume_culling
volume.min = new Point(-1000, -1000, -1000);
volume.max = new Point(1000, 1000, 1000);
cullControl.SetVolume(volume);
%%%volume_culling_full_source
HPS.
Canvas canvas = Factory.CreateCanvas(myWindowKey);
canvas.AttachViewAsLayout(myView);
HPS.
Stream.ImportOptionsKit in_options =
new Stream.ImportOptionsKit();
in_options.SetSegment(mySegKey);
mySegKey.Flush();
try
{
notifier =
HPS.
Stream.File.Import(path_to_model_file, in_options);
notifier.Wait();
}
{
}
myView.FitWorld();
myView.Update();
volume.min = new Point(-1000, -1000, -1000);
volume.max = new Point(1000, 1000, 1000);
cullControl.SetVolume(volume);
myView.FitWorld();
%%%culling_optimizations01_b
mySegmentKey.GetCameraControl().SetPosition(new Point(0, 0, 5));
pointArray[0] =
new HPS.
Point(-1.0f, -1.0f, 0);
pointArray[1] =
new HPS.
Point(-1.0f, 1.0f, 0);
pointArray[2] =
new HPS.
Point(1.0f, 1.0f, 0);
pointArray[3] =
new HPS.
Point(1.0f, -1.0f, 0);
int[] faceList = new int[5];
faceList[0] = 4;
faceList[1] = 0;
faceList[2] = 1;
faceList[3] = 2;
faceList[4] = 3;
faceList[0] = 4;
faceList[1] = 0;
faceList[2] = 3;
faceList[3] = 2;
faceList[4] = 1;
mySegmentKey.InsertShell(pointArray, faceList);
%%%frustum_culling
mySegmentKey.GetCullingControl().SetFrustum(true);
mySegmentKey.GetCullingControl().SetFrustum(false);
%%%hardcopy
try
{
float width, height;
myWindowKey.GetWindowInfoControl().ShowPhysicalSize(out width, out height);
exportOptionsKit.SetWYSIWYG(true);
HPS.IOResult postScriptResult =
}
{
}
%%%window_update_notifier
%%%update_options_kit
myWindowKey.SetUpdateOptions(uok);
%%%culling_extents
mySegmentKey.GetCullingControl().SetExtent(10);
mySegmentKey.GetCullingControl().SetDeferralExtent(100);
%%%set_soft_memory_limit
ulong memoryLimit = 132581244 / 2;
%%%MyEmergencyHandler
class MyEmergencyHandler :
HPS.EmergencyHandler
{
public MyEmergencyHandler(){ notif = null;}
{
{
lock (lockObj)
{
if (notif != null)
notif.Cancel();
}
}
delete_reserve_buffer();
abort();
}
public void SetNotifier(
HPS.
Stream.ImportNotifier in_notif)
{
lock (lockObj)
{
notif = in_notif;
}
}
private void abort() { }
private void delete_reserve_buffer() { }
private System.Object lockObj = new System.Object();
};
%%%set_emergency_handler
MyEmergencyHandler handler = new MyEmergencyHandler();
%%%img_def_target
%%%toggle_anti_alias
mySegmentKey.GetVisualEffectsControl().SetTextAntiAliasing(true);
mySegmentKey.GetVisualEffectsControl().SetTextAntiAliasing(false);
%%%specific_segments
segment_one.GetVisualEffectsControl().SetTextAntiAliasing(true);
segment_two.GetVisualEffectsControl().SetTextAntiAliasing(false);
%%%no_true_type
segment_one.GetTextAttributeControl().SetFont("Times New Roman")
.SetRenderer(Text.Renderer.Truetype)
.SetPreference(Text.Preference.Vector);
%%%enable_simple_shadows
mySegmentKey.GetVisualEffectsControl().SetSimpleShadow(true);
mySegmentKey.GetVisualEffectsControl().SetSimpleShadowPlane(
new HPS.
Plane(0, 1, 0, 0.425f));
mySegmentKey.GetVisualEffectsControl().SetSimpleShadowColor(
new HPS.
RGBAColor(0.2f, 0.2f, 0.2f));
mySegmentKey.GetVisualEffectsControl().SetSimpleShadowLightDirection(
new HPS.
Vector(0, 1, 0));
%%%set_shadow_options
mySegmentKey.GetVisualEffectsControl().SetSimpleShadow(true,
256,
16,
false);
%%%enable_shadow_maps
mySegmentKey.GetVisualEffectsControl().SetShadowMaps(true,
16,
2048,
true,
true);
mySegmentKey.GetVisibilityControl().SetShadows(true);
%%%cast_emit_receive
mySegmentKey.GetVisibilityControl().SetShadowCasting(true);
mySegmentKey.GetVisibilityControl().SetShadowEmitting(true);
mySegmentKey.GetVisibilityControl().SetShadowReceiving(false);
%%%shadow_direction
mySegmentKey.GetVisualEffectsControl().SetSimpleShadowLightDirection(new Vector(1, 1, 1));
%%%set_simple_reflection
mySegmentKey.GetVisualEffectsControl().SetSimpleReflection(true, 0.5f, 1U, false, 0, 0.2f);
mySegmentKey.GetVisualEffectsControl().SetSimpleReflectionPlane(
new HPS.
Plane(0, 1, 0, 1));
%%%enable_bloom
windowKey.SetPostProcessEffects(ppek);
windowKey.SetPostProcessEffects(ppek);
%%%star_bloom
%%%algorithms
%%%hemispheric_ambient
mySegmentKey.GetMaterialMappingControl().SetAmbientLightUpColor(
new HPS.
RGBAColor(1, 0, 0));
mySegmentKey.GetMaterialMappingControl().SetAmbientLightDownColor(
new HPS.
RGBAColor(0, 0, 1));
%%%set_hsra
%%%unset_hsra
myWindowKey.GetSubwindowControl().UnsetRenderingAlgorithm();
%%%priority
%%%hidden_line
mySegmentKey.GetVisibilityControl().SetFaces(true).SetEdges(true).SetLines(true);
mySegmentKey.GetHiddenLineAttributeControl().SetVisibility(false);
%%%dim_factor
mySegmentKey.GetHiddenLineAttributeControl().SetDimFactor(0.75f);
mySegmentKey.GetHiddenLineAttributeControl().SetVisibility(true);
%%%special_segments
mySegmentKey.GetHiddenLineAttributeControl().SetRenderFaces(true);
mySegmentKey.GetHiddenLineAttributeControl().SetRenderText(true);
%%%depth_range
mySegmentKey.GetDrawingAttributeControl().SetDepthRange(0, 0);
%%%set_depth_of_field
myWindowKey.SetPostProcessEffects(ppek);
%%%enable_perimeter_edges
mySegmentKey.GetVisibilityControl().SetEdges(false);
mySegmentKey.GetVisibilityControl().SetPerimeterEdges(true);
mySegmentKey.GetVisibilityControl().SetPerimeterEdges(false);
%%%interior_silhouette_edges
mySegmentKey.GetVisibilityControl().SetInteriorSilhouetteEdges(true);
%%%perimeter_edge_options
myWindowKey.GetPostProcessEffectsControl().SetSilhouetteEdges(true, 10, true);
%%%hard_edges
mySegmentKey.GetVisibilityControl().SetHardEdges(true);
mySegmentKey.GetEdgeAttributeControl().SetHardAngle(135);
%%%smooth
mySegmentKey.GetColorInterpolationControl().SetFaceColor(true);
ulong[] vertexIndices = { 0, 1, 2, 3 };
RGBColor[] colorArray = {
new HPS.
RGBColor(0.24f, 0.48f, 0.56f),
};
myShellKey.SetVertexRGBColorsByList(vertexIndices, colorArray);
%%%hard
for (int i = 0; i < materialKitArray.Length; i++)
float[] materialIndices = new float[5];
materialIndices[0] = 0;
materialIndices[1] = 0.25f;
materialIndices[2] = 0.5f;
materialIndices[3] = 0.75f;
materialIndices[4] = 1;
myShellKit.SetFaceIndexColorsByList(faceIndices, materialIndices);
%%%contour_lines
mySegmentKey.GetContourLineControl().SetVisibility(true)
.SetPositions(1.0f, 0.5f).SetWeights(2.0f).SetColors(new RGBColor(1, 0, 0));
%%%enabling_ci
mySegmentKey.GetColorInterpolationControl().SetFaceColor(true);
mySegmentKey.GetColorInterpolationControl().SetFaceIndex(true);
mySegmentKey.GetColorInterpolationControl().SetEdgeColor(true);
mySegmentKey.GetColorInterpolationControl().SetEdgeIndex(true);
mySegmentKey.GetColorInterpolationControl().SetVertexColor(true);
mySegmentKey.GetColorInterpolationControl().SetVertexIndex(true);
%%%ambient_occlusion
myWindowKey.GetPostProcessEffectsControl().SetAmbientOcclusion(true, 2.0f,
%%%eye_dome
windowKey.GetPostProcessEffectsControl().SetEyeDomeLighting(true, 60.0f, 1.2f);
%%%eye_dome_disable
mySegmentKey.GetVisualEffectsControl().SetPostProcessEffectsEnabled(false);
%%%read_hsf
try
{
importOptionsKit.SetSegment(mySegmentKey);
notifier =
HPS.
Stream.File.Import(filename, importOptionsKit);
float percent_complete;
notifier.Status(out percent_complete);
notifier.Wait();
}
{
}
%%%notifier
HPS.IOResult ioResult = notifier.Status();
if (ioResult ==
HPS.IOResult.Success)
{
}
else
{
}
%%%results
HPS.
Stream.ImportResultsKit importResultsKit = notifier.GetResults();
importResultsKit.ShowDefaultCamera(out cameraKit);
importResultsKit.ShowSegment(out someSegment);
%%%notifier_cancel
notifier =
HPS.
Stream.File.Import(filename, importOptionsKit);
notifier.Cancel();
notifier.Wait();
if (notifier.Status() !=
HPS.IOResult.Canceled);
%%%stream_buffer_import
try
{
importOptionsKit.SetSegment(mySegmentKey);
notifier =
HPS.
Stream.File.Import(buffers, importOptionsKit);
notifier.Wait();
}
{
throw;
}
%%%stream_buffer_export
byte[][] buffers;
try
{
HPS.
Stream.ExportNotifier exportNotifier =
HPS.
Stream.File.Export(mySegmentKey, exportOptionsKit, out buffers);
exportNotifier.Wait();
}
{
throw;
}
%%%exporting
try
{
exportOptionsKit.SetColorCompression(true, 16);
HPS.
Stream.File.Export(filename, mySegmentKey, exportOptionsKit).Wait();
}
{
}
%%%loading_images
try
{
imageKit =
HPS.
Image.File.Import(filename, iok);
}
{
String problem = ioe.Message;
}
%%%save_image
HPS.
Image.File.Export(filename, myImageKit);
%%%screenshot
export_options.SetSize(800, 450);
HPS.
Image.File.Export(filename, myWindowKey, export_options);
%%%other_formats
HPS.
STL.ImportOptionsKit stlOptionsKit =
new HPS.
STL.ImportOptionsKit();
stlOptionsKit.SetSegment(mySegmentKey);
HPS.
STL.ImportNotifier stlNotifier =
HPS.
STL.File.Import(stlFilename, stlOptionsKit);
stlNotifier.Wait();
HPS.
OBJ.ImportOptionsKit objOptionsKit =
new HPS.
OBJ.ImportOptionsKit();
objOptionsKit.SetSegment(mySegmentKey);
HPS.
OBJ.ImportNotifier objNotifier =
HPS.
OBJ.File.Import(objFilename, objOptionsKit);
objNotifier.Wait();
%%%%030102_a
try
{
notifier.Wait();
HPS.
View myView = modelFile.ActivateDefaultCapture();
myCanvas.AttachViewAsLayout(myView);
model = modelFile.GetModel();
}
{
}
%%%set_transform_component_path
SelectionOptionsKit selection_options = new SelectionOptionsKit();
if (myWindowKey.GetSelectionControl().SelectByPoint(new Point(0, 0, 0), selection_options, out results) > 0)
{
item.ShowPath(out path_to_selection);
HPS.
ComponentPath component_path = myCADModel.GetComponentPath(path_to_selection);
transform.Translate(5, 0, 0);
transform_target.SetTransform(transform);
myCanvas.Update();
}
%%%set_transform_full_source
Canvas myCanvas = Factory.CreateCanvas(myWindowKey);
try
{
HPS.
Exchange.ImportOptionsKit importOptionsKit =
new Exchange.ImportOptionsKit();
importOptionsKit.SetBRepMode(Exchange.BRepMode.BRepAndTessellation);
importNotifier =
HPS.
Exchange.File.Import(modelPath, importOptionsKit);
float percent_complete;
importNotifier.Status(out percent_complete);
importNotifier.Wait();
}
{
throw;
}
Exchange.
CADModel myCADModel = importNotifier.GetCADModel();
myCanvas.AttachViewAsLayout(myCADModel.ActivateDefaultCapture());
myCanvas.Update();
SelectionOptionsKit selection_options = new SelectionOptionsKit();
if (myWindowKey.GetSelectionControl().SelectByPoint(new Point(0, 0, 0), selection_options, out results) > 0)
{
item.ShowPath(out path_to_selection);
HPS.
ComponentPath component_path = myCADModel.GetComponentPath(path_to_selection);
transform.Translate(5, 0, 0);
transform_target.SetTransform(transform);
myCanvas.Update();
}
%%%file_load_result
HPS.IOResult result = notifier.Status();
if (result ==
HPS.IOResult.Success)
{
}
notifier.Cancel();
%%%pmi
importOptions.SetPMI(false);
%%%configurations
for (int i = 0; i < configArray.Length; i++)
{
String configName = configArray[i].GetName();
importOptionsKit.SetConfiguration(configName);
}
%%%handling_views
HPS.
Capture[] captureArray = modelFile.GetAllCaptures();
for (int i = 0; i < captureArray.Length; i++)
{
Capture capture = captureArray[i];
if (viewName == "<some interesting view>")
{
capture.Activate();
break;
}
}
%%%handling_metadata
HPS.
Metadata[] metadataArray = modelFile.GetAllMetadata();
for (int i = 0; i < metadataArray.Length; i++)
{
{
String metadataName = sm.
GetName();
String someString = sm.GetValue();
}
{
String metadataName = dm.
GetName();
double someDouble = dm.GetValue();
}
{
String metadataName = im.
GetName();
int someInteger = im.GetValue();
}
{
String metadataName = uim.
GetName();
uint someUnsignedInt = uim.GetValue();
}
{
String metadataName = tm.
GetName();
uint someUnsignedInt = tm.GetValue();
String timeString = tm.GetValueAsString();
}
}
%%%activating_filters
CADModel cadModel = notifier.GetCADModel();
HPS.
View myFirstView = cadModel.GetAllCaptures()[0].Activate();
HPS.
Filter[] filters = cadModel.GetAllFilters();
%%%deactivating_filters
HPS.
Filter[] filterArray = modelFile.GetActiveFilters(myFirstView);
for (int i = 0; i < filterArray.Length; i++)
{
}
%%%exchange_component_reload
importNotifier.Wait();
Exchange.
CADModel myCADModel = importNotifier.GetCADModel();
Exchange.ReloadNotifier reloadNotifier = exchangeComponent.
Reload();
reloadNotifier.Wait();
myCADModel.ActivateDefaultCapture();
%%%exchange_simple_export
%%%exchange_data_mapping
HPS.
Component component = modelFile.GetComponentFromKey(hpsKey);
{
}
HPS.
Key[] keys = component.GetKeys();
%%%simple_export
keyPathArray[0] = sprocketPath.GetKeyPath();
%%%declarations
%%%setup_view
viewKit.SetCamera(cameraKit);
viewKit.SetExternalName("My custom view #1");
artworkKit.AddView(viewKit);
viewKit.SetCamera(cameraKit);
viewKit.SetExternalName("My custom view #2");
artworkKit.AddView(viewKit);
%%%annotation_kit
keyPathArray[0] = sprocketPath.GetKeyPath();
annotationKit.SetArtwork(artworkKit);
annotationKit.SetSource(keyPathArray);
annotationKit.SetPRCTessellationCompression(true);
pageKit.SetAnnotation(annotationKit,
new HPS.
IntRectangle(50, 562, 50, 742));
documentKit.AddPage(pageKit);
%%%template_kit
templateKit.SetAnnotationByField("My3DWindow_1", annotationKit);
templateKit.SetTextValueByField("DocumentTitle_1", "BILL OF MATERIALS");
templateKit.SetTextValueByField("Part NameRow1_1", "Turbine engine");
templateKit.SetTextValueByField("SupplierRow1_1", "Tech Soft 3D");
documentKit.AddPage(templateKit);
%%%linkkit
"var a3d = this.getAnnots3D( 1 )[0];\n" +
"a3d.activated=true;\n" +
"c3d = a3d.context3D;\n" +
"c3d.runtime.setView(\"ALL\", true);\n");
myLinkKit.SetBorderWidth(1);
%%%component_mask
%%%create_document
%%%modify_document
ulong pageCount = myDocumentKey.GetPageCount();
myDocumentKey.AddAttachment(attachmentFilename, attachmentDescription);
myDocumentKey.SetPasswords(newUserPassword, newOwnerPassword);
%%%page_control
myPageControl.AddTable(myTableKit,
new HPS.
IntRectangle(200, 100, 200, 500));
myPageControl.AddAnnotation(myAnnotationKit,
new HPS.
IntRectangle(200, 300, 200, 500));
%%%export_document
%%%skp_import
iok.SetTarget(myModel);
iok.SetView(myView);
notifier.Wait();
%%%parasolid_add_body
Exchange.ImportOptionsKit import_kit = Exchange.ImportOptionsKit.GetDefault();
import_kit.SetPMI(false);
Exchange.ImportNotifier notifier = Exchange.File.Import(my_cad_file, import_kit);
notifier.Wait();
Exchange.
CADModel exchange_cad_model =
new Exchange.CADModel(cad_model);
View view1 = cad_model.ActivateDefaultCapture();
PK.BODY_t solid_body = PK.ENTITY_t.@null;
PK.BODY.create_solid_block(0.05f, 0.05f, 0.05f, null, &solid_body);
PK.ATTDEF_t system_color;
PK.ERROR.code_t error = PK.ATTDEF.find("SDL/TYSA_COLOUR_2", &system_color);
PK.ATTRIB_t color_attribute;
error = PK.ATTRIB.create_empty(solid_body, system_color, &color_attribute);
double [] color = { 1, 0, 0 };
error = PK.ATTRIB.set_doubles(color_attribute, 0, 3, color);
MatrixKit translation = new MatrixKit();
translation.Translate(100.0f, 0.0f, 50.0f);
HPS.
Parasolid.
Component added_component = ExchangeParasolid.File.AddEntity(exchange_cad_model, solid_body, translation);
PK.CLASS_t entity_type;
PK.ENTITY.ask_class(entity, &entity_type);
%%%parasolid_import
%%%parasolid_import_options
ftk.SetFacetSize(1.0, 3.0, 10);
ltk.SetIgnoreCriteria(false);
iok.SetCompoundBodyBehavior(
HPS.
Parasolid.CompoundBodyBehavior.Split);
iok.SetFacetTessellation(ftk);
iok.SetLineTessellation(ltk);
%%%import_default_options
try
{
filename,
Exchange.ImportOptionsKit.GetDefault().SetHiddenObjects(false),
Exchange.TranslationOptionsKit.GetDefault(),
Parasolid.FacetTessellationKit.GetDefault(),
Parasolid.LineTessellationKit.GetDefault());
notifier.Wait();
HPS.
View myView = modelFile.ActivateDefaultCapture();
myCanvas.AttachViewAsLayout(myView);
myView.AttachModel(model);
}
{
}
%%%query_cad_model
if (!subcomponents.empty())
{
Component.
ComponentType component_type = subcomponents[0].GetComponentType();
if (component_type == Component.ComponentType.ExchangeProductOccurrence)
{
Exchange.Component exchange_component = new Exchange.Component(subcomponents[0]);
IntPtr entity = exchange_component.GetExchangeEntity();
}
}
if (!subcomponents.empty())
{
if (subcomponents[0].HasComponentType(Component.ComponentType.ParasolidComponentMask))
{
Parasolid.
Component parasolid_component =
new Parasolid.Component(subcomponents[0]);
PK.ENTITY_t entity = parasolid_component.GetParasolidEntity();
PK.SURF_t surface;
PK.FACE.ask_surf(entity, &surface);
}
}
%%%fillet_retessellate
Exchange.ImportOptionsKit exchange_import = Exchange.ImportOptionsKit.GetDefault();
exchange_import.SetBRepMode(Exchange.BRepMode.BRepAndTessellation);
Exchange.TranslationOptionsKit translation_options = Exchange.TranslationOptionsKit.GetDefault();
ExchangeParasolid.ImportNotifier notifier = ExchangeParasolid.File.Import(
filename, exchange_import, translation_options,
Parasolid.FacetTessellationKit.GetDefault(), Parasolid.LineTessellationKit.GetDefault());
notifier.Wait();
if (notifier.Status() != IOResult.Success)
{
}
View myView = notifier.GetCADModel().ActivateDefaultCapture();
myCanvas.AttachViewAsLayout(myView);
myView.AttachModel(model);
CADModel cad_model = notifier.GetCADModel();
if (edge_components.empty())
{
}
Parasolid.
Component para_edge_component =
new Parasolid.Component(edge_components[0]);
PK.EDGE_t[] edge_entity = new PK.EDGE_t[1];
edge_entity[0] = para_edge_component.GetParasolidEntity();
int number_of_edges = 0;
PK.EDGE_t* edges = null;
PK.EDGE.set_blend_constant_o_t blend_options = new PK.EDGE.set_blend_constant_o_t(true);
PK.ERROR.code_t error = PK.EDGE.set_blend_constant(1, edge_entity, 0.005, &blend_options, &number_of_edges, &edges);
if (error != PK.ERROR.code_t.no_errors)
{
}
int number_of_blend_faces = 0;
PK.FACE_t* created_blend_faces = null;
PK.FACE.array_t* underlying_topology = null;
int* replaced_topologies = null;
PK.blend_fault_t status = PK.blend_fault_t.no_fault_c;
PK.EDGE_t faulty_edge = PK.EDGE_t.@null;
PK.ENTITY_t topology_associated_with_fault = PK.EDGE_t.@null;
PK.BODY.fix_blends_o_v fix_blend_options = new PK.BODY.fix_blends_o_v(true);
error = PK.BODY.fix_blends(para_component.GetParasolidEntity(), &fix_blend_options, &number_of_blend_faces, &created_blend_faces, &underlying_topology, &replaced_topologies, &status, &faulty_edge, &topology_associated_with_fault);
if (error != PK.ERROR.code_t.no_errors || (status != PK.blend_fault_t.no_fault_c && status != PK.blend_fault_t.repaired_c))
{
}
myCanvas.Update();
%%%%00760_exchange_parasolid_boolean_operator_class
class TestBooleanOperator :
HPS.Operator
{
private PK.BODY_t target;
private PK.BODY_t tool;
public TestBooleanOperator(ref Canvas in_canvas, ref CADModel in_cad_model)
{
canvas = in_canvas;
cad_model = in_cad_model;
target = PK.ENTITY_t.@null;
tool = PK.ENTITY_t.@null;
target_style_source = new SegmentKey();
target_highlight = new HighlightOptionsKit();
tool_style_source = new SegmentKey();
tool_highlight = new HighlightOptionsKit();
}
public override string GetName()
{
return "TestBooleanOperator";
}
{
if (IsMouseTriggered(in_state))
{
click_location = in_state.GetLocation();
}
return false;
}
public override bool OnMouseUp(MouseState in_state)
{
if (!IsMouseTriggered(in_state) && in_state.GetLocation() == click_location)
{
ulong count = canvas.GetWindowKey().GetSelectionControl().SelectByPoint(click_location, selection_options, out results);
if (count == 0)
return false;
while (s_it.IsValid())
{
s_it.GetItem().ShowPath(out selected_path);
HPS.
Component[] components = component_path.GetComponents();
{
{
PK.ENTITY_t selected_parasolid_entity = para_component.GetParasolidEntity();
if (target == selected_parasolid_entity)
{
highlight_control.
Unhighlight(selected_path, target_highlight);
canvas.Update();
target = PK.ENTITY_t.@null;
target_component.
Reset();
target_path.Reset();
return true;
}
else if (tool == selected_parasolid_entity)
{
highlight_control.Unhighlight(selected_path, tool_highlight);
canvas.Update();
tool = PK.ENTITY_t.@null;
tool_component.Reset();
tool_path.Reset();
return true;
}
else if (target == PK.ENTITY_t.@null)
{
target = selected_parasolid_entity;
target_component = it;
target_path = selected_path;
highlight_control.Highlight(selected_path, target_highlight);
canvas.Update();
return true;
}
else
{
tool = selected_parasolid_entity;
tool_component = it;
tool_path = selected_path;
highlight_control.Highlight(selected_path, tool_highlight);
canvas.Update();
return true;
}
}
}
s_it.Next();
}
return true;
}
return false;
}
public override void OnViewAttached(
HPS.
View in_attached_view)
{
attached_view = GetAttachedView();
.SetScope(sprocket_path.GetKeyPath());
highlight_material.SetDiffuse(color_1);
highlight_material.SetSpecular(color_2);
target_style_source.GetMaterialMappingControl()
.SetFaceMaterial(highlight_material)
.SetEdgeColor(color_3)
.SetTextColor(color_3)
.SetLineColor(color_3);
target_highlight.SetOverlay(
HPS.
Drawing.
Overlay.None).SetStyleName(
"BooleanOperator_TargetStyle");
highlight_material.SetDiffuse(color_4);
tool_style_source.GetMaterialMappingControl()
.SetFaceMaterial(highlight_material)
.SetEdgeColor(color_4)
.SetTextColor(color_4)
.SetLineColor(color_4);
portfolio.DefineNamedStyle("BooleanOperator_ToolStyle", tool_style_source);
tool_highlight.SetOverlay(
HPS.
Drawing.
Overlay.None).SetStyleName(
"BooleanOperator_ToolStyle");
}
public override void OnViewDetached(
HPS.
View in_detached_view)
{
if (canvas.Type() !=
HPS.Type.None)
{
tool_style_source.Delete();
canvas.Update();
}
}
unsafe public bool ApplyBoolean()
{
canvas.GetWindowKey().GetHighlightControl().UnhighlightEverything();
MatrixKit target_matrix;
target_path.ShowNetModellingMatrix(out target_matrix);
MatrixKit tool_matrix;
tool_path.ShowNetModellingMatrix(out tool_matrix);
MatrixKit transform_matrix = target_matrix.Invert();
transform_matrix.MultiplyAndAssign(tool_matrix);
MatrixKit matrix = new MatrixKit();
if (transform_matrix != matrix)
{
double scale = 0.001;
float[] elements;
transform_matrix.ShowElements(out elements);
PK.TRANSF_sf_t transform_data;
transform_data.matrixI0J0 = elements[0]; transform_data.matrixI1J0 = elements[1]; transform_data.matrixI2J0 = elements[2]; transform_data.matrixI3J0 = elements[3];
transform_data.matrixI0J1 = elements[4]; transform_data.matrixI1J1 = elements[5]; transform_data.matrixI2J1 = elements[6]; transform_data.matrixI3J1 = elements[7];
transform_data.matrixI0J2 = elements[8]; transform_data.matrixI1J2 = elements[9]; transform_data.matrixI2J2 = elements[10]; transform_data.matrixI3J2 = elements[11];
transform_data.matrixI0J3 = elements[12] * scale; transform_data.matrixI1J3 = elements[13] * scale; transform_data.matrixI2J3 = elements[14] * scale; transform_data.matrixI3J3 = elements[15];
PK.TRANSF_t transform;
PK.TRANSF.create(&transform_data, &transform);
PK.BODY.transform_o_t transform_options = new PK.BODY.transform_o_t(true);
PK.TOPOL.track_r_t tracking_1;
PK.TOPOL.local_r_t results;
PK.ERROR.code_t error_1 = PK.BODY.transform_2(tool, transform, 0.001, &transform_options, &tracking_1, &results);
if (error_1 != PK.ERROR.code_t.no_errors)
return false;
else if (results.status != PK.local_status_t.ok_c && results.status != PK.local_status_t.nocheck_c)
return false;
}
bool target_faceted = IsEntityFaceted(target);
bool tool_faceted = IsEntityFaceted(tool);
PK.BODY_t facet_body = PK.ENTITY_t.@null;
PK.TOPOL.track_r_t tracking;
PK.ERROR.code_t error = PK.ERROR.code_t.no_errors;
if (tool_faceted != target_faceted)
{
PK.BODY_t classical_body = PK.ENTITY_t.@null;
if (!tool_faceted)
classical_body = tool;
else if (!target_faceted)
classical_body = target;
PK.BODY.make_facet_body_o_t make_facet_options = new PK.BODY.make_facet_body_o_t(true);
PK.TOPOL.track_r_t redundant_topol;
error = PK.BODY.make_facet_body(classical_body, PK.ENTITY_t.@null, &make_facet_options, &facet_body, &tracking, &redundant_topol);
if (error != PK.ERROR.code_t.no_errors)
return false;
}
PK.BODY.boolean_o_t boolean_options = new PK.BODY.boolean_o_t(true);
boolean_options.function = PK.boolean_function_t.subtract;
PK.boolean_r_t boolean_results;
PK.BODY_t tool_to_use = tool;
PK.BODY_t target_to_use = target;
if (facet_body != PK.ENTITY_t.@null && !tool_faceted)
tool_to_use = facet_body;
else if (facet_body != PK.ENTITY_t.@null && !target_faceted)
target_to_use = facet_body;
error = PK.BODY.boolean_2(target_to_use, 1, &tool_to_use, &boolean_options, &tracking, &boolean_results);
if (error == PK.ERROR.code_t.no_errors
&& boolean_results.result == PK.boolean_result_t.success_c
&& boolean_results.n_bodies > 0)
{
for (int i = 0; i < boolean_results.n_bodies; ++i)
{
if (boolean_results.bodies[i] != target)
return false;
}
tool_component.Delete();
return true;
}
else
return false;
}
unsafe private bool IsEntityFaceted(PK.BODY_t body)
{
int number_of_faces = 0;
PK.FACE_t* faces = null;
PK.ERROR.code_t error = PK.BODY.ask_faces(body, &number_of_faces, &faces);
if (error != PK.ERROR.code_t.no_errors || number_of_faces == 0)
{
return false;
}
PK.SURF_t surface;
error = PK.FACE.ask_surf(faces[0], &surface);
if (error != PK.ERROR.code_t.no_errors)
{
return false;
}
PK.GEOM.ask_geom_category_o_t geom_options = new PK.GEOM.ask_geom_category_o_t(true);
PK.GEOM.category_t category;
error = PK.GEOM.ask_geom_category(surface, &geom_options, &category);
if (error != PK.ERROR.code_t.no_errors)
{
return false;
}
if (category == ((PK.GEOM.category_t)25871))
return true;
else if (category == ((PK.GEOM.category_t)25870))
return false;
return false;
}
}
%%%%00760_exchange_parasolid_boolean_setup
bool setUpScene(ref
HPS.
Canvas myCanvas,
string importFileTarget,
string importFileTool)
{
Exchange.ImportOptionsKit kit = Exchange.ImportOptionsKit.GetDefault();
kit.SetBRepMode(Exchange.BRepMode.BRepAndTessellation);
ExchangeParasolid.ImportNotifier notifier = ExchangeParasolid.File.Import(importFileTarget, kit,
Exchange.TranslationOptionsKit.GetDefault(),
Parasolid.FacetTessellationKit.GetDefault(),
Parasolid.LineTessellationKit.GetDefault());
notifier.Wait();
if (notifier.Status() != IOResult.Success)
return false;
CADModel cadmodel = notifier.GetCADModel();
Component[] location = { cadmodel };
ComponentPath path = new ComponentPath(location);
kit.SetLocation(path);
notifier = ExchangeParasolid.File.Import(importFileTool, kit,
Exchange.TranslationOptionsKit.GetDefault(),
Parasolid.FacetTessellationKit.GetDefault(),
Parasolid.LineTessellationKit.GetDefault());
notifier.Wait();
if (notifier.Status() != IOResult.Success)
return false;
View view = cadmodel.ActivateDefaultCapture();
myCanvas.AttachViewAsLayout(view);
Point position = new Point(-116.158989f, -2172.083008f, 921.859985f);
Point target = new Point(-0.000153f, -89.000000f, 117.000000f);
Vector up_vector = new Vector(-0.004887f, -0.360171f, -0.932874f);
camera_kit.SetPosition(position)
.SetTarget(target)
.SetUpVector(up_vector)
.SetField(894.474365f, 894.474365f)
.SetNearLimit(0.000000f)
view.GetSegmentKey().SetCamera(camera_kit);
Vector distant_light = new Vector(1, 0, 0);
view.GetSegmentKey().InsertDistantLight(distant_light);
myCanvas.Update();
TestBooleanOperator boolean_operator = new TestBooleanOperator(ref myCanvas, ref cadmodel);
view.GetOperatorControl().Push(boolean_operator,
HPS.
Operator.Priority.Default);
return true;
}
%%%%00760_exchange_parasolid_boolean_instantiate
TestBooleanOperator boolean_operator = new TestBooleanOperator(ref myCanvas, ref cadmodel);
view.GetOperatorControl().Push(boolean_operator,
HPS.
Operator.Priority.Default);
%%%%00760_exchange_parasolid_boolean_execute
void executeBooleanOperation(ref
HPS.
Canvas myCanvas)
{
myCanvas.GetFrontView().GetOperatorControl().ShowTop(out myOperator);
if (myOperator.GetName() == "TestBooleanOperator")
{
TestBooleanOperator op = (TestBooleanOperator)myOperator;
op.ApplyBoolean();
myCanvas.UpdateWithNotifier().Wait();
}
}
%%%%00760_exchange_parasolid_boolean_retrieve
myCanvas.GetFrontView().GetOperatorControl().ShowTop(out myOperator);
if (myOperator.GetName() == "TestBooleanOperator")
{
TestBooleanOperator op = (TestBooleanOperator)myOperator;
op.ApplyBoolean();
myCanvas.UpdateWithNotifier().Wait();
}
%%%%00760_exchange_parasolid_boolean_selection_logic
public override bool OnMouseUp(MouseState in_state)
{
if (!IsMouseTriggered(in_state) && in_state.GetLocation() == click_location)
{
ulong count = canvas.GetWindowKey().GetSelectionControl().SelectByPoint(click_location, selection_options, out results);
if (count == 0)
return false;
while (s_it.IsValid())
{
s_it.GetItem().ShowPath(out selected_path);
HPS.
Component[] components = component_path.GetComponents();
{
{
PK.ENTITY_t selected_parasolid_entity = para_component.GetParasolidEntity();
if (target == selected_parasolid_entity)
{
highlight_control.
Unhighlight(selected_path, target_highlight);
canvas.Update();
target = PK.ENTITY_t.@null;
target_component.
Reset();
target_path.Reset();
return true;
}
else if (tool == selected_parasolid_entity)
{
highlight_control.Unhighlight(selected_path, tool_highlight);
canvas.Update();
tool = PK.ENTITY_t.@null;
tool_component.Reset();
tool_path.Reset();
return true;
}
else if (target == PK.ENTITY_t.@null)
{
target = selected_parasolid_entity;
target_component = it;
target_path = selected_path;
highlight_control.Highlight(selected_path, target_highlight);
canvas.Update();
return true;
}
else
{
tool = selected_parasolid_entity;
tool_component = it;
tool_path = selected_path;
highlight_control.Highlight(selected_path, tool_highlight);
canvas.Update();
return true;
}
}
}
s_it.Next();
}
return true;
}
return false;
}
%%%relative_tessellation
ftk.SetTessellationLevel(
HPS.
Parasolid.TessellationLevel.Medium);
%%%parasolid_subcomponent
%%%parasolid_default_view
HPS.
View view = notifier.GetCADModel().ActivateDefaultCapture();
myCanvas.AttachViewAsLayout(view);
%%%parasolid_metadata
HPS.
Metadata metadata = cadModel.GetMetadata(
"Filename");
String filename_value = stringMetadata.
GetValue();
%%%parasolid_create_cad_model
%%%parasolid_entity_creation
PK.BODY_t solid_body = PK.ENTITY_t.@null;
PK.BODY.create_solid_block(0.05, 0.05, 0.05, null, &solid_body);
{
}
Key[] componentKeys = myNewComponent.
GetKeys();
%%%parasolid_retessellate
ltk.SetChordTolerance(0, 0, 1.3);
component.Tessellate(ftk, ltk);
myCanvas.Update();
%%%parasolid_export
export_options.SetFormat(
HPS.
Parasolid.Format.Text).SetUserFields(
true);
%%%publish_button_kit
buttonKit.
SetLabel(
"This is a page button")
.SetVisibility(true)
.SetFontSize(8)
.SetName("execute_button");
%%%publish_button_javascript
myPageKit.SetJavaScriptActionByField("execute_button", myJavascriptSource,
%%%publish_table_source
tableKit.SetHTML(myHTML_source);
tableKit.SetHTMLStyle(myCSS_source);
%%%publish_table_text
textKit.SetColor(new RGBColor(1, 0, 0))
.SetFont(Publish.Text.Font.Name.Courier)
.SetSize(12)
.SetText("My table text");
tableKit.SetText(1, 1, textKit);
%%%publish_table_button
buttonKit.SetLabel("button 1").
SetVisibility(true).
SetName("b1");
tableKit.SetButton(2, 1, buttonKit);
%%%publish_export_subtree
%%%MyEventHandler
class MyEventHandler :
HPS.EventHandler
{
public override HandleResult Handle(
HPS.
Event in_event)
{
return HandleResult.Handled;
}
};
%%%dispatcher
MyEventHandler myHandler = new MyEventHandler();
%%%MyEvent
class MyEvent :
HPS.Event
{
public MyEvent() : base() { }
public MyEvent(IntPtr type) : base(type) { }
public override Event Clone() { return new MyEvent(GetChannel()); }
};
%%%dispatch_MyEvent
MyEvent myEvent =
new MyEvent(
HPS.
Object.ClassID<MyEvent>());
dispatcher.InjectEvent(myEvent);
%%%event_status
%%%wait
%%%custom_event
MyEventHandler myEventHandler = new MyEventHandler();
MyCustomEvent myEvent =
new MyCustomEvent(
HPS.
Object.ClassID<MyCustomEvent>());
dispatcher.UnSubscribe(myEventHandler,
HPS.
Object.ClassID<MyCustomEvent>());
%%%custom_event_full_source
class MyCustomEvent :
HPS.Event
{
private int myRandomNumber;
public MyCustomEvent() : base()
{
}
public MyCustomEvent(IntPtr type) : base(type)
{
}
public MyCustomEvent(IntPtr type, int randomNumber) : base(type)
{
myRandomNumber = randomNumber;
}
public override Event Clone()
{
MyCustomEvent new_event = new MyCustomEvent(GetChannel(), myRandomNumber);
return new_event;
}
public override bool Drop(Event in_that_event)
{
bool drop_status = false;
if ((myRandomNumber % 3) == 0)
drop_status = true;
return drop_status;
}
public int getMyRandomNumber()
{
return this.myRandomNumber;
}
};
public class MyEventHandler :
HPS.EventHandler
{
~MyEventHandler() { Shutdown(); }
public override HandleResult Handle(
HPS.
Event in_event)
{
MyCustomEvent myEvent = (MyCustomEvent)in_event;
return HandleResult.Handled;
}
};
void injectSingleEvent(ref
HPS.
Canvas canvas)
{
MyEventHandler myEventHandler = new MyEventHandler();
MyCustomEvent myEvent =
new MyCustomEvent(
HPS.
Object.ClassID<MyCustomEvent>());
dispatcher.InjectEvent(myEvent);
dispatcher.UnSubscribe(myEventHandler,
HPS.
Object.ClassID<MyCustomEvent>());
}
{
MyEventHandler myEventHandler = new MyEventHandler();
Random rand = new Random();
for (int i = 0; i < 100; i++)
{
int randomNumber = rand.Next();
MyCustomEvent myEvent =
new MyCustomEvent(
HPS.
Object.ClassID<MyCustomEvent>(), randomNumber);
dispatcher.InjectEvent(myEvent);
}
dispatcher.UnSubscribe(myEventHandler,
HPS.
Object.ClassID<MyCustomEvent>());
}
%%%drop_event
MyEventHandler myEventHandler = new MyEventHandler();
Random rand = new Random();
for (int i = 0; i < 100; i++)
{
int randomNumber = rand.Next();
MyCustomEvent myEvent =
new MyCustomEvent(
HPS.
Object.ClassID<MyCustomEvent>(), randomNumber);
dispatcher.InjectEvent(myEvent);
}
dispatcher.UnSubscribe(myEventHandler,
HPS.
Object.ClassID<MyCustomEvent>());
%%%merging_events_example
class MyCustomEvent :
HPS.Event
{
private int myRandomNumber;
public MyCustomEvent() : base()
{
}
public MyCustomEvent(IntPtr type) : base(type)
{
}
public MyCustomEvent(IntPtr type, int randomNumber) : base(type)
{
myRandomNumber = randomNumber;
}
public override Event Clone()
{
MyCustomEvent new_event = new MyCustomEvent(GetChannel(), myRandomNumber);
return new_event;
}
public override bool Drop(Event in_that_event)
{
bool drop_status = false;
if ((myRandomNumber % 3) == 0)
drop_status = true;
return drop_status;
}
public int getMyRandomNumber()
{
return this.myRandomNumber;
}
};
public class MyEventHandler :
HPS.EventHandler
{
~MyEventHandler() { Shutdown(); }
public override HandleResult Handle(
HPS.
Event in_event)
{
MyCustomEvent myEvent = (MyCustomEvent)in_event;
return HandleResult.Handled;
}
};
%%%handling_input
class MyEventHandler :
HPS.EventHandler
{
{
float x = location.x;
float y = location.y;
float z = location.z;
}
}
%%%subscribe
MyEventHandler myEventHandler = new MyEventHandler();
%%%model_compare
subwindowKit.SetModelCompareMode(true, segment1, segment2);
%%%operator
class SphereOperator : Operator
{
private bool operatorStarted;
public SphereOperator(Canvas c)
{
canvas = c;
}
public override void OnViewAttached(
HPS.
View in_attached_view)
{
operatorStarted = false;
HPS.
Model model = canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel();
if (model.Type() ==
HPS.Type.None)
{
canvas.GetAttachedLayout().GetAttachedView().AttachModel(model);
}
temporaryGeometry.GetMaterialMappingControl().
temporaryGeometry.GetMarkerAttributeControl()
.SetSymbol("plus").SetSize(0.3f);
temporaryGeometry.GetCameraControl()
.SetUpVector(
new HPS.
Vector(0, 1, 0)).SetField(2, 2);
temporaryGeometry.GetDrawingAttributeControl()
return;
}
{
if (in_state.GetActiveEvent().CurrentButton.Left())
{
operatorStarted = true;
centerPoint = in_state.GetLocation();
}
return true;
}
{
if (IsMouseTriggered(in_state) && operatorStarted)
return ConstructSphereOutline(in_state.GetLocation());
return false;
}
public override bool OnMouseUp(MouseState in_state)
{
if (in_state.GetActiveEvent().CurrentButton.Left() && operatorStarted)
{
operatorStarted = false;
if (radiusLine != null)
radiusLine.Delete();
if (centerMarker != null)
centerMarker.Delete();
if (circle != null)
circle.Delete();
canvas.GetAttachedLayout().GetAttachedView(),
canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel());
sphere.InsertSphere(drawPosition0, ComputeDistance(drawPosition0, drawPosition1));
GetAttachedView().Update();
}
return true;
}
private bool ConstructSphereOutline(Point currentPosition)
{
if (radiusLine != null)
radiusLine.Delete();
if (centerMarker != null)
centerMarker.Delete();
if (circle != null)
circle.Delete();
canvas.GetAttachedLayout().GetAttachedView(),
canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel());
centerMarker = temporaryGeometry.InsertMarker(new Point(drawPosition0));
radiusLine = temporaryGeometry.InsertLine(drawPosition0, drawPosition1);
circle = temporaryGeometry.InsertCircle(drawPosition0, ComputeDistance(drawPosition0, drawPosition1),
new HPS.
Vector(0, 0, 1));
GetAttachedView().Update();
return true;
}
private float ComputeDistance(Point p0, Point p1)
{
return (float) Math.Sqrt((p1.x - p0.x) * (p1.x - p0.x) +
(p1.y - p0.y) * (p1.y - p0.y) +
(p1.z - p0.z) * (p1.z - p0.z));
}
}
%%%touch_operator_ex
class SphereOperator : Operator
{
private bool operatorStarted;
public SphereOperator(Canvas c)
{
canvas = c;
}
public override void OnViewAttached(
HPS.
View in_attached_view)
{
operatorStarted = false;
HPS.
Model model = canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel();
if (model.Type() ==
HPS.Type.None)
{
canvas.GetAttachedLayout().GetAttachedView().AttachModel(model);
}
temporaryGeometry.GetMaterialMappingControl().
temporaryGeometry.GetMarkerAttributeControl()
.SetSymbol("plus").SetSize(0.3f);
temporaryGeometry.GetCameraControl()
.SetField(2, 2);
temporaryGeometry.GetDrawingAttributeControl()
return;
}
{
Touch[] touches = in_state.GetActiveEvent().Touches;
if (touches.size() == 1)
{
centerPoint = touches[0].Location;
operatorStarted = true;
}
return true;
}
public override bool OnTouchMove(TouchState in_state)
{
Touch[] touches = in_state.GetActiveEvent().Touches;
if (touches.size() == 1 && operatorStarted)
return ConstructSphereOutline(touches[0].Location);
return false;
}
public override bool OnTouchUp(TouchState in_state)
{
Touch[] upTouches = in_state.GetActiveEvent().Touches;
if(upTouches.Length == 1 && operatorStarted)
{
operatorStarted = false;
radiusLine.Delete();
centerMarker.Delete();
circle.Delete();
SegmentKey sphere = GetAttachedView().GetAttachedModel().GetSegmentKey().Subsegment();
sphere.GetMaterialMappingControl().SetFaceColor(new RGBAColor(0, 1, 0, 1));
SprocketPath sprkPath = new SprocketPath(canvas, canvas.GetAttachedLayout(), canvas.GetAttachedLayout().GetAttachedView(),
canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel());
KeyPath path = sprkPath.GetKeyPath();
path.Append(sphere);
Point drawPosition0, drawPosition1;
sphere.InsertSphere(drawPosition0, ComputeDistance(drawPosition0, drawPosition1));
GetAttachedView().Update();
}
return true;
}
private bool ConstructSphereOutline(Point currentPosition)
{
if (radiusLine != null)
radiusLine.Delete();
if (centerMarker != null)
centerMarker.Delete();
if (circle != null)
circle.Delete();
canvas.GetAttachedLayout().GetAttachedView(),
canvas.GetAttachedLayout().GetAttachedView().GetAttachedModel());
centerMarker = temporaryGeometry.InsertMarker(new Point(drawPosition0));
radiusLine = temporaryGeometry.InsertLine(drawPosition0, drawPosition1);
circle = temporaryGeometry.InsertCircle(drawPosition0, ComputeDistance(drawPosition0, drawPosition1),
new HPS.
Vector(0, 0, 1));
GetAttachedView().Update();
return true;
}
private float ComputeDistance(Point p0, Point p1)
{
return (float)Math.Sqrt((p1.x - p0.x) * (p1.x - p0.x) +
(p1.y - p0.y) * (p1.y - p0.y) +
(p1.z - p0.z) * (p1.z - p0.z));
}
}
%%%define_stream_import_handler
class NoBoldEvent :
HPS.Stream.ImportEventHandler
{
public override bool Handle(
HPS.
Stream.ImportEvent e)
{
{
text_event.text_kit.UnsetBold();
}
{
text_attribute_event.text_attribute_kit.UnsetBold();
}
return true;
}
};
%%%set_stream_import_handler
NoBoldEvent no_bold_event = new NoBoldEvent();
%%%define_stream_export_handler
class SpecialExportEvent :
HPS.Stream.ExportEventHandler
{
public override void Handle(
HPS.
Stream.ExportEvent e)
{
string name = seg_event.segment_key.Name();
if (name == "My_Special_Segment")
{
string str = "HOOPS Visualize!";
seg_event.non_db_user_data = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, seg_event.non_db_user_data, 0, seg_event.non_db_user_data.Length);
}
}
};
%%%set_stream_export_handler
SpecialExportEvent special_export_event = new SpecialExportEvent();
export_options.SetEventHandler(special_export_event,
HPS.
Object.ClassID<
HPS.
Stream.SegmentExportEvent>());
%%%load_file_example
importKit.SetSegment(importSeg);
handler.SetNotifier(notif);
notif.Wait();
handler.SetNotifier(null);
%%%export1
%%%export2
annotationKit.SetSource(cadModel, keyPathArray);
%%%export3
HPS.
Exchange.File.ExportPRC(cadModel, filename, exportPRCOptionsKit);
%%%exchange_parasolid_import
HPS.
Exchange.ImportOptionsKit iok = Exchange.ImportOptionsKit.GetDefault();
notifier.Wait();
%%%text_background
textKit.SetPosition(new Point(0, 0.25f, 0));
textKit.SetText("TECH SOFT 3D");
textKit.SetBackground(true, "oval");
mySegmentKey.GetMaterialMappingControl().SetFaceColor(new RGBAColor(0.5f, 0, 0.5f));
mySegmentKey.InsertText(textKit);
%%%text_background_named_style
SegmentKey styleSegment = Database.CreateRootSegment();
styleSegment.GetMaterialMappingControl().SetFaceColor(new RGBAColor(1, 1, 0)).SetEdgeColor(new RGBAColor(0, 0, 1));
styleSegment.GetEdgeAttributeControl().SetWeight(5).SetPattern("dashed_pattern");
myPortfolio.DefineNamedStyle("myShapeStyle", styleSegment);
SegmentKey containingSegment = mySegmentKey.Subsegment();
containingSegment.GetTextAttributeControl().SetBackgroundStyle("myShapeStyle");
%%%custom_text_background
ShapeCoordinate x = new ShapeCoordinate(1, 0);
ShapeCoordinate y = new ShapeCoordinate(0, 1);
ShapeCoordinate neg_x = new ShapeCoordinate(-1, 0);
ShapeCoordinate neg_y = new ShapeCoordinate(0, -1);
ShapeKit clippedShapeKit = new ShapeKit();
ShapePoint [] clipped_points = new ShapePoint[]
{
new ShapePoint(x.SetMargins(1), y),
new ShapePoint(x.SetMargins(0), y.SetMargins(1)),
new ShapePoint(neg_x, y),
new ShapePoint(neg_x.SetMargins(-1), y.SetMargins(0)),
new ShapePoint(neg_x, neg_y),
new ShapePoint(neg_x.SetMargins(0), neg_y.SetMargins(-1)),
new ShapePoint(x, neg_y),
new ShapePoint(x.SetMargins(1), neg_y.SetMargins(0))
};
PolygonShapeElement clipped_element = new PolygonShapeElement(clipped_points);
clippedShapeKit.SetElement(clipped_element);
myPortfolio.DefineShape("clipped background shape", clippedShapeKit);
TextKit textKit = new TextKit();
textKit.SetPosition(new Point(0, 0.25f, 0));
textKit.SetText("TECH SOFT 3D");
textKit.SetBackground(true, "clipped background shape");
mySegmentKey.InsertText(textKit);
%%%incremental1
importOptions.SetMode(
HPS.
Exchange.ImportMode.Incremental);
notifier.Wait();
%%%incremental2
HPS.
Component [] pathComponents = { componentToLoad, rootProductOccurrence, cadModel };
importOptions.SetIncrementalComponentPath(pathToLoad);
notifier =
HPS.
Exchange.File.Import(filename, importOptions);
notifier.Wait();
%%%incremental3
productOccurrence.Unload(
HPS.
Exchange.UnloadMode.ExchangeAndVisualization);
productOccurrence.Unload();
productOccurrence.Unload(
HPS.
Exchange.UnloadMode.ExchangeOnly);
%%%camera_projection
%%%shape_coordinate1
ShapeCoordinate sc1 = new ShapeCoordinate(1.15f, 0);
ShapeCoordinate sc2 = new ShapeCoordinate(0.85f, 1.5f);
ShapePoint sp = new ShapePoint(sc1, sc2);
%%%shape_coordinate2
ShapeCoordinate sc1 = new ShapeCoordinate(1, 0);
ShapeCoordinate sc2 = new ShapeCoordinate(0, 1);
ShapePoint sp = new ShapePoint(sc1, sc2);
%%%shape_coordinate3
ShapeCoordinate sc1 = new ShapeCoordinate(1, 0);
ShapeCoordinate sc2 = new ShapeCoordinate(0, 0);
ShapePoint sp = new ShapePoint(sc1, sc2);
%%%margins
mySegmentKey.GetTextAttributeControl().SetBackgroundMargins(40);
sc1.SetMargins(1, 0, 0, 0);
sc2.SetMargins(0, 3, 2, 0);
sc3.SetMargins(0, 0, -1, 0);
sc4.SetMargins(0, 0, 0, -2.5f);
%%%non_latin_fonts
SegmentKey modelSegment = _canvas.GetFrontView().GetAttachedModel().GetSegmentKey();
modelSegment.GetVisibilityControl().SetText(true);
String font;
modelSegment.GetTextAttributeControl().SetFont("Microsoft YaHei");
modelSegment.GetTextAttributeControl().ShowFont(out font);
modelSegment.InsertText(new Point(0, 0, 0), (String)"Chinese Char 中国智造");
%%%publish_html_export_exchange
Exchange.ImportNotifier notifier;
Exchange.ImportOptionsKit importOptions = Exchange.ImportOptionsKit.GetDefault();
importOptions.SetBRepMode(Exchange.BRepMode.BRepAndTessellation);
notifier = Exchange.File.Import(myCADFilePath, importOptions);
notifier.Wait();
if (notifier.Status() != IOResult.Success)
{
}
try
{
Publish.File.ExportHTML(_cadModel, exportedHTMLFilePath, htmlTemplateFilePath, true);
}
catch (IOException)
{
}
%%%publish_html_export_sprocketkey
SprocketPath path = new SprocketPath(model, view, layout, canvas);
try
{
Publish.File.ExportHTML(path.GetKeyPath(), exportedHTMLFilePath, htmlTemplateFilePath);
}
catch (IOException)
{
}
%%%sprocket_html_export
SprocketPath sPath = new SprocketPath(canvas, layout, view, model);
try
{
HTML.File.Export(sPath.GetKeyPath(), exportedHTMLFilePath, htmlTemplateFilePath);
}
catch (IOException)
{
}
%%%ooc_import
HPS.
OOC.ImportNotifier notifier;
HPS.IOResult status =
HPS.IOResult.Failure;
string message;
try
{
HPS.
OOC.ImportOptionsKit ioOpts =
new HPS.
OOC.ImportOptionsKit();
ioOpts.SetTarget(_model);
notifier =
HPS.
OOC.File.Import(myPointCloudFilePath, ioOpts);
notifier.Wait();
status = notifier.Status();
_view.FitWorld();
}
{
status = ex.result;
message = ex.what();
}
%%%ooc_filter_class
public class CountAll : OOC.QueryFilter
{
public CountAll()
{
point_count = 0;
}
public CountAll(ulong in_point_count = 0)
{
point_count = in_point_count;
}
public override bool RejectPointsInMemory()
{
return false;
}
public override bool RejectPointsOnDisk()
{
return false;
}
public override bool RejectNode(OOC.NodeHandle node_handle)
{
return false;
}
public override bool RejectBounding(Point min_bound, Point max_bound)
{
return false;
}
public override bool AcceptPoint(Point point, ulong point_index)
{
++point_count;
return true;
}
ulong point_count;
}
\htmlonly
%%%ooc_filter_half
public class AcceptHalf : OOC.QueryFilter {
public AcceptHalf()
{
point_count = 0;
}
public AcceptHalf(ulong in_point_count = 0)
{
point_count = in_point_count;
}
public override bool AcceptPoint(Point point, ulong point_index)
{
if (point_index % 2 == 0)
{
++point_count;
return true;
}
else return false;
}
ulong point_count;
}
\htmlonly
%%%ooc_query_all
ulong num_points = 0;
OOC.PointCloud point_cloud = new OOC.PointCloud(_model);
if (point_cloud.Empty())
{
}
CountAll filter = new CountAll();
OOC.QueryIterator it = point_cloud.QueryPoints(filter);
while (true)
{
{
break;
}
++num_points;
it.Next();
}
%%%ooc_query_half
ulong num_points_half = 0;
AcceptHalf filter_half = new AcceptHalf();
OOC.QueryIterator it_half = point_cloud.QueryPoints(filter_half);
while (true)
{
{
break;
}
++num_points_half;
it_half.Next();
}
%%%ooc_vertex_functions
SegmentKey mySegment = _canvas.GetFrontView().GetSegmentKey();
mySegment.GetDrawingAttributeControl().SetVertexDecimation(0.05f);
mySegment.GetDrawingAttributeControl().SetVertexRandomization(true);
%%%find_highlights
ulong numHighlights = myWindowKey.FindHighlights(hsok, out hsr);
while (it.IsValid())
{
Drawing.Overlay overlay = it.GetOverlay();
it.Next();
}
%%%highlight_state
myHighlightControl.ShowHighlightState(myKeyPath, hsok, out myHighlightState);
bool containsHighlightedSubentities = myHighlightState.GetSubentityHighlighted();
bool isDirectlyHighlighted = myHighlightState.GetDirectlyHighlighted();
bool isOnHighlightPath = myHighlightState.GetOnHighlightPath();
%%%obj_export
SprocketPath path = new SprocketPath(canvas, canvas.GetAttachedLayout(), view, model);
string output_file = my_export_directory + "/obj_export_1.obj";
OBJ.ExportNotifier export_notifier = OBJ.File.Export(output_file, path.GetKeyPath());
%%%create_views
importOptions.SetHiddenObjects(true);
importOptions.SetConstructionAndReferences(true);
notifier.Wait();
layout.AttachViewFront(bottomLeft,
new HPS.
Rectangle(-1, 0, -1, 0));
View bottomRight = cadModel.ActivateDefaultCapture();
layout.AttachViewFront(bottomRight,
new HPS.
Rectangle(0, 1, -1, 0));
View topLeft = cadModel.ActivateDefaultCapture();
layout.AttachViewFront(topLeft,
new HPS.
Rectangle(-1, 0, 0, 1));
View topRight = cadModel.ActivateDefaultCapture();
layout.AttachViewFront(topRight,
new HPS.
Rectangle(0, 1, 0, 1));
canvas.AttachLayout(layout);
%%%change_visibility
pathTofirstChildPocc.Append(firstChildPocc);
pathTofirstChildPocc.Append(rootPocc);
pathTofirstChildPocc.Append(cadModel);
pathTofirstChildPocc.Hide(canvas, 3);
pathTofirstChildPocc.Isolate(canvas, 2);
for (int i = 0; i < 3; ++i)
{
pathToHiddenConstruction.
Append(partSubcomponents[i]);
pathToHiddenConstruction.
Append(firstChildPart);
pathToHiddenConstruction.
Append(pathTofirstChildPocc);
pathToHiddenConstruction.
Show(canvas, 1);
}
pathTofirstChildPocc.Isolate(canvas, 1);
pathTofirstChildPocc.Isolate(canvas, 0);
SegmentKey highlightSource = topLeft.GetSegmentKey().Subsegment();
highlightSource.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0, 1, 0)).SetLineColor(
new HPS.
RGBAColor(1, 0, 0));
canvas.GetPortfolioKey().DefineNamedStyle("my_style", highlightSource);
HighlightOptionsKit highlightOptions = new HighlightOptionsKit();
highlightOptions.SetStyleName("my_style").SetOverlay(Drawing.Overlay.InPlace);
pathTofirstChildPocc.Highlight(canvas, 0, highlightOptions);