Skip to content

Commit ae2101c

Browse files
committed
Move node implementations to Basic3DNodes module.
1 parent af56603 commit ae2101c

File tree

13 files changed

+186
-171
lines changed

13 files changed

+186
-171
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,12 @@ target_include_directories (
182182
Basic3DNodes PUBLIC
183183
${GLMSourcesFolder}
184184
${GeometrySourcesFolder}
185+
${ModelerSourcesFolder}
185186
${Basic3DNodesHeaderFiles}
186187
${Basic3DNodesSourceFiles}
188+
${VSE_DEVKIT_DIR}/include
187189
)
188-
target_include_directories (Basic3DNodes PUBLIC ${GeometrySourcesFolder} ${VSE_DEVKIT_DIR}/include)
189-
target_link_libraries (Basic3DNodes Geometry)
190+
target_link_libraries (Basic3DNodes Geometry Modeler)
190191
SetCompilerOptions (Basic3DNodes)
191192

192193
# VisualScriptCAD
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Sources/VisualScriptCAD/Nodes/ShapeNodes.cpp renamed to Sources/Basic3DNodes/ShapeNodes.cpp

Lines changed: 0 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
#include "NUIE_NodeCommonParameters.hpp"
44
#include "BI_BuiltInFeatures.hpp"
55

6-
#include "PolygonEditor.hpp"
76
#include "ModelEvaluationData.hpp"
87
#include "TransformationNodes.hpp"
9-
#include "Triangulation.hpp"
108
#include "MaterialNode.hpp"
119

1210
#include "IncludeGLM.hpp"
@@ -16,7 +14,6 @@ NE::DynamicSerializationInfo CylinderNode::serializationInfo (NE::ObjectId ("{6C
1614
NE::DynamicSerializationInfo ConeNode::serializationInfo (NE::ObjectId ("{586F0D6E-CBEB-4C19-8B9E-7358E3E75FD2}"), NE::ObjectVersion (1), ConeNode::CreateSerializableInstance);
1715
NE::DynamicSerializationInfo SphereNode::serializationInfo (NE::ObjectId ("{686712CE-BF1B-438E-8C0A-B687A158A0BB}"), NE::ObjectVersion (1), SphereNode::CreateSerializableInstance);
1816
NE::DynamicSerializationInfo TorusNode::serializationInfo (NE::ObjectId ("{E17CF103-A4B6-4498-BB7E-7A566C1F7D26}"), NE::ObjectVersion (1), TorusNode::CreateSerializableInstance);
19-
NE::DynamicSerializationInfo PrismNode::serializationInfo (NE::ObjectId ("{9D1E49DE-FD64-4079-A75B-DE1900FD2C2F}"), NE::ObjectVersion (1), PrismNode::CreateSerializableInstance);
2017
NE::DynamicSerializationInfo PlatonicNode::serializationInfo (NE::ObjectId ("{F7321055-D370-4468-A895-32FA3AD1BF40}"), NE::ObjectVersion (1), PlatonicNode::CreateSerializableInstance);
2118

2219
static bool IsSmooth (int segmentation)
@@ -433,155 +430,6 @@ NE::Stream::Status TorusNode::Write (NE::OutputStream& outputStream) const
433430
return outputStream.GetStatus ();
434431
}
435432

436-
PrismNode::PrismNode () :
437-
PrismNode (L"", NUIE::Point ())
438-
{
439-
440-
}
441-
442-
PrismNode::PrismNode (const std::wstring& name, const NUIE::Point& position) :
443-
ShapeNode (name, position)
444-
{
445-
446-
}
447-
448-
void PrismNode::Initialize ()
449-
{
450-
ShapeNode::Initialize ();
451-
452-
NE::ListValuePtr basePointsDefaultValue (new NE::ListValue ());
453-
basePointsDefaultValue->Push (NE::ValuePtr (new Point2DValue (glm::vec2 (0.0, 0.0))));
454-
basePointsDefaultValue->Push (NE::ValuePtr (new Point2DValue (glm::vec2 (2.0, 0.0))));
455-
basePointsDefaultValue->Push (NE::ValuePtr (new Point2DValue (glm::vec2 (2.0, 2.0))));
456-
basePointsDefaultValue->Push (NE::ValuePtr (new Point2DValue (glm::vec2 (1.0, 2.0))));
457-
basePointsDefaultValue->Push (NE::ValuePtr (new Point2DValue (glm::vec2 (1.0, 1.0))));
458-
basePointsDefaultValue->Push (NE::ValuePtr (new Point2DValue (glm::vec2 (0.0, 1.0))));
459-
460-
RegisterUIInputSlot (NUIE::UIInputSlotPtr (new NUIE::UIInputSlot (NE::SlotId ("material"), L"Material", NE::ValuePtr (new MaterialValue (Modeler::DefaultMaterial)), NE::OutputSlotConnectionMode::Single)));
461-
RegisterUIInputSlot (NUIE::UIInputSlotPtr (new NUIE::UIInputSlot (NE::SlotId ("transformation"), L"Transformation", NE::ValuePtr (new TransformationValue (glm::dmat4 (1.0))), NE::OutputSlotConnectionMode::Single)));
462-
RegisterUIInputSlot (NUIE::UIInputSlotPtr (new NUIE::UIInputSlot (NE::SlotId ("basepoints"), L"Base Points", basePointsDefaultValue, NE::OutputSlotConnectionMode::Multiple)));
463-
RegisterUIInputSlot (NUIE::UIInputSlotPtr (new NUIE::UIInputSlot (NE::SlotId ("height"), L"Height", NE::ValuePtr (new NE::FloatValue (1.0f)), NE::OutputSlotConnectionMode::Single)));
464-
RegisterUIOutputSlot (NUIE::UIOutputSlotPtr (new NUIE::UIOutputSlot (NE::SlotId ("shape"), L"Shape")));
465-
}
466-
467-
NE::ValueConstPtr PrismNode::Calculate (NE::EvaluationEnv& env) const
468-
{
469-
class CGALTriangulator : public Modeler::Triangulator
470-
{
471-
public:
472-
virtual bool TriangulatePolygon (const std::vector<glm::dvec2>& points, std::vector<std::array<size_t, 3>>& result) override
473-
{
474-
return CGALOperations::TriangulatePolygon (points, result);
475-
}
476-
};
477-
478-
NE::ValueConstPtr material = EvaluateInputSlot (NE::SlotId ("material"), env);
479-
NE::ValueConstPtr transformation = EvaluateInputSlot (NE::SlotId ("transformation"), env);
480-
NE::ValueConstPtr basePointsValue = NE::FlattenValue (EvaluateInputSlot (NE::SlotId ("basepoints"), env));
481-
NE::ValueConstPtr heightValue = EvaluateInputSlot (NE::SlotId ("height"), env);
482-
483-
if (!NE::IsComplexType<MaterialValue> (material) || !NE::IsComplexType<TransformationValue> (transformation) || !NE::IsComplexType<Point2DValue> (basePointsValue) || !NE::IsComplexType<NE::NumberValue> (heightValue)) {
484-
return nullptr;
485-
}
486-
487-
Modeler::TriangulatorPtr triangulator (new CGALTriangulator ());
488-
std::vector<glm::dvec2> basePoints;
489-
NE::FlatEnumerate (basePointsValue, [&] (const NE::ValueConstPtr& value) {
490-
basePoints.push_back (Point2DValue::Get (value));
491-
});
492-
493-
NE::ListValuePtr result (new NE::ListValue ());
494-
bool isValid = BI::CombineValues (this, {material, transformation, heightValue}, [&] (const NE::ValueCombination& combination) {
495-
Modeler::ShapePtr shape (new Modeler::PrismShape (
496-
MaterialValue::Get (combination.GetValue (0)),
497-
TransformationValue::Get (combination.GetValue (1)),
498-
basePoints,
499-
NE::NumberValue::ToDouble (combination.GetValue (2)),
500-
triangulator
501-
));
502-
if (!shape->Check ()) {
503-
return false;
504-
}
505-
result->Push (NE::ValuePtr (new ShapeValue (shape)));
506-
return true;
507-
});
508-
509-
if (!isValid) {
510-
return nullptr;
511-
}
512-
return result;
513-
}
514-
515-
void PrismNode::RegisterCommands (NUIE::NodeCommandRegistrator& commandRegistrator) const
516-
{
517-
class SetBasePolygonCommand : public NUIE::NodeCommand
518-
{
519-
public:
520-
SetBasePolygonCommand () :
521-
NUIE::NodeCommand (L"Set Base Polygon", false)
522-
{
523-
524-
}
525-
526-
virtual bool IsApplicableTo (const NUIE::UINodeConstPtr& uiNode) override
527-
{
528-
return NE::Node::IsTypeConst<PrismNode> (uiNode);
529-
}
530-
531-
virtual void Do (NUIE::NodeUIManager& uiManager, NUIE::NodeUIEnvironment& /*uiEnvironment*/, NUIE::UINodePtr& uiNode) override
532-
{
533-
std::shared_ptr<PrismNode> prismNode = std::dynamic_pointer_cast<PrismNode> (uiNode);
534-
NE::InputSlotPtr inputSlot = prismNode->GetInputSlot (NE::SlotId ("basepoints"));
535-
536-
std::vector<glm::dvec2> initPolygon;
537-
NE::ValueConstPtr defaultPolygon = NE::FlattenValue (inputSlot->GetDefaultValue ());
538-
if (NE::IsComplexType<Point2DValue> (defaultPolygon)) {
539-
NE::FlatEnumerate (defaultPolygon, [&] (const NE::ValueConstPtr& value) {
540-
initPolygon.push_back (Point2DValue::Get (value));
541-
});
542-
}
543-
544-
PolygonEditorDialog polygonEditor (nullptr, initPolygon);
545-
if (polygonEditor.ShowModal () == wxID_OK && polygonEditor.HasPolygon ()) {
546-
NE::ListValuePtr basePointsDefaultValue (new NE::ListValue ());
547-
for (const glm::dvec2& point : polygonEditor.GetPolygon ()) {
548-
basePointsDefaultValue->Push (NE::ValuePtr (new Point2DValue (point)));
549-
}
550-
inputSlot->SetDefaultValue (basePointsDefaultValue);
551-
552-
uiManager.InvalidateNodeValue (prismNode);
553-
uiManager.InvalidateNodeDrawing (prismNode);
554-
}
555-
}
556-
557-
private:
558-
bool enable;
559-
};
560-
561-
ShapeNode::RegisterCommands (commandRegistrator);
562-
commandRegistrator.RegisterNodeCommand (NUIE::NodeCommandPtr (new SetBasePolygonCommand ()));
563-
}
564-
565-
void PrismNode::RegisterParameters (NUIE::NodeParameterList& parameterList) const
566-
{
567-
ShapeNode::RegisterParameters (parameterList);
568-
NUIE::RegisterSlotDefaultValueNodeParameter<PrismNode, NE::FloatValue> (parameterList, L"Height", NUIE::ParameterType::Float, NE::SlotId ("height"));
569-
}
570-
571-
NE::Stream::Status PrismNode::Read (NE::InputStream& inputStream)
572-
{
573-
NE::ObjectHeader header (inputStream);
574-
ShapeNode::Read (inputStream);
575-
return inputStream.GetStatus ();
576-
}
577-
578-
NE::Stream::Status PrismNode::Write (NE::OutputStream& outputStream) const
579-
{
580-
NE::ObjectHeader header (outputStream, serializationInfo);
581-
ShapeNode::Write (outputStream);
582-
return outputStream.GetStatus ();
583-
}
584-
585433
static void SetPlatonicNodeType (Modeler::PlatonicSolidType type, NUIE::NodeUIManager& uiManager, std::shared_ptr<PlatonicNode>& platonicNode)
586434
{
587435
platonicNode->SetType (type);

Sources/VisualScriptCAD/Nodes/ShapeNodes.hpp renamed to Sources/Basic3DNodes/ShapeNodes.hpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,6 @@ class TorusNode : public ShapeNode
8686
virtual NE::Stream::Status Write (NE::OutputStream& outputStream) const override;
8787
};
8888

89-
class PrismNode : public ShapeNode
90-
{
91-
DYNAMIC_SERIALIZABLE (PrismNode);
92-
93-
public:
94-
PrismNode ();
95-
PrismNode (const std::wstring& name, const NUIE::Point& position);
96-
97-
virtual void Initialize () override;
98-
virtual NE::ValueConstPtr Calculate (NE::EvaluationEnv& env) const override;
99-
virtual void RegisterCommands (NUIE::NodeCommandRegistrator& commandRegistrator) const;
100-
virtual void RegisterParameters (NUIE::NodeParameterList& parameterList) const;
101-
102-
virtual NE::Stream::Status Read (NE::InputStream& inputStream) override;
103-
virtual NE::Stream::Status Write (NE::OutputStream& outputStream) const override;
104-
};
105-
10689
class PlatonicNode : public ShapeNode
10790
{
10891
DYNAMIC_SERIALIZABLE (PlatonicNode);
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)